From b1c955337ffb4e3fa76db90db2d1bda29ba60c17 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 3 Nov 2013 16:03:03 +0000 Subject: [PATCH] ODESolvers/RKF45: Error evaluation is now consistent with the other RK solvers --- src/ODE/ODESolvers/RKF45/RKF45.C | 28 ++++++++++++---------------- src/ODE/ODESolvers/RKF45/RKF45.H | 20 ++++++++++---------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/ODE/ODESolvers/RKF45/RKF45.C b/src/ODE/ODESolvers/RKF45/RKF45.C index b5324e049b..661c618255 100644 --- a/src/ODE/ODESolvers/RKF45/RKF45.C +++ b/src/ODE/ODESolvers/RKF45/RKF45.C @@ -56,19 +56,17 @@ const scalar RKF45::a64 = 1859.0/4104.0, RKF45::a65 = -11.0/40.0, - RKF45::b41 = 25.0/216.0, - RKF45::b42 = 0.0, - RKF45::b43 = 1408.0/2565.0, - RKF45::b44 = 2197.0/4104.0, - RKF45::b45 = -1.0/5.0, - RKF45::b46 = 0.0, + RKF45::b1 = 16.0/135.0, + RKF45::b3 = 6656.0/12825.0, + RKF45::b4 = 28561.0/56430.0, + RKF45::b5 = -9.0/50.0, + RKF45::b6 = 2.0/55.0, - RKF45::b51 = 16.0/135.0, - RKF45::b52 = 0.0, - RKF45::b53 = 6656.0/12825.0, - RKF45::b54 = 28561.0/56430.0, - RKF45::b55 = -9.0/50.0, - RKF45::b56 = 2.0/55.0; + RKF45::e1 = 25.0/216.0 - RKF45::b1, + RKF45::e3 = 1408.0/2565.0 - RKF45::b3, + RKF45::e4 = 2197.0/4104.0 - RKF45::b4, + RKF45::e5 = -1.0/5.0 - RKF45::b5, + RKF45::e6 = -RKF45::b6; } @@ -143,7 +141,7 @@ Foam::scalar Foam::RKF45::solve { y[i] = y0[i] + dx - *(b51*dydx0[i] + b53*k3_[i] + b54*k4_[i] + b55*k5_[i] + b56*k6_[i]); + *(b1*dydx0[i] + b3*k3_[i] + b4*k4_[i] + b5*k5_[i] + b6*k6_[i]); } // Calculate the error estimate from the difference between the @@ -152,9 +150,7 @@ Foam::scalar Foam::RKF45::solve { err_[i] = dx - *(b41*dydx0[i] + b43*k3_[i] + b44*k4_[i] + b45*k5_[i]) - - (y[i] - y0[i]) - ; + *(e1*dydx0[i] + e3*k3_[i] + e4*k4_[i] + e5*k5_[i] + e6*k6_[i]); } return normalizeError(y0, y, err_); diff --git a/src/ODE/ODESolvers/RKF45/RKF45.H b/src/ODE/ODESolvers/RKF45/RKF45.H index 34a53d0fb0..442d9d3f4e 100644 --- a/src/ODE/ODESolvers/RKF45/RKF45.H +++ b/src/ODE/ODESolvers/RKF45/RKF45.H @@ -31,15 +31,15 @@ Description \verbatim "Low-order classical Runge-Kutta formulas with step size control and their application to some heat transfer problems." - Fehlberg, E., - NASA Technical Report 315 1969 + Fehlberg, E., + NASA Technical Report 315, 1969. - "Solving Ordinary Differential Equations I: Nonstiff Problems, - second edition", - Hairer, E., - Nørsett, S., - Wanner, G., - Springer-Verlag, Berlin. 1993, ISBN 3-540-56670-8. + "Solving Ordinary Differential Equations I: Nonstiff Problems, + second edition", + Hairer, E., + Nørsett, S., + Wanner, G., + Springer-Verlag, Berlin. 1993, ISBN 3-540-56670-8. \endverbatim This method embedds the 4-th order integration step into the 5-th order step @@ -112,8 +112,8 @@ class RKF45 c2, c3, c4, c5, c6, a21, a31, a32, a41, a42, a43, a51, a52, a53, a54, a61, a62, a63, a64, a65, - b41, b42, b43, b44, b45, b46, - b51, b52, b53, b54, b55, b56; + b1, b3, b4, b5, b6, + e1, e3, e4, e5, e6; // Temporary fields