4 #include "KVRungeKutta.h"
17 Double_t KVRungeKutta::b31 = 3.0 / 40.0;
18 Double_t KVRungeKutta::b32 = 9.0 / 40.0;
22 Double_t KVRungeKutta::b51 = -11.0 / 54.0;
24 Double_t KVRungeKutta::b53 = -70.0 / 27.0;
25 Double_t KVRungeKutta::b54 = 35.0 / 27.0;
26 Double_t KVRungeKutta::b61 = 1631.0 / 55296.0;
27 Double_t KVRungeKutta::b62 = 175.0 / 512.0;
28 Double_t KVRungeKutta::b63 = 575.0 / 13824.0;
29 Double_t KVRungeKutta::b64 = 44275.0 / 110592.0;
30 Double_t KVRungeKutta::b65 = 253.0 / 4096.0;
31 Double_t KVRungeKutta::c1 = 37.0 / 378.0;
32 Double_t KVRungeKutta::c3 = 250.0 / 621.0;
33 Double_t KVRungeKutta::c4 = 125.0 / 594.0;
34 Double_t KVRungeKutta::c6 = 512.0 / 1771.0;
35 Double_t KVRungeKutta::dc5 = -277.00 / 14336.0;
44 :
KVBase(
"RK4NR",
"Runge-Kutta ODE integrator with adaptive step-size control"),
45 nvar(
N), eps(PREC),
hmin(MINSTEP)
63 dc1 = c1 - 2825.0 / 27648.0;
64 dc3 = c3 - 18575.0 / 48384.0;
65 dc4 = c4 - 13525.0 / 55296.0;
116 for (
int i = 0; i < nvar; i++) y[i] = ystart[i];
118 for (
int nstp = 1; nstp <= MAXSTP; nstp++) {
121 fInitialDeriv =
kTRUE;
125 for (
Int_t i = 0; i < nvar; i++)
128 if ((x +
h -
x2) * (x +
h -
x1) > 0.0)
h =
x2 - x;
136 if (hdid ==
h) ++nok;
138 if ((
x -
x2) * (
x2 -
x1) >= 0.0) {
139 for (
int i = 0; i < nvar; i++) ystart[i] = y[i];
144 KVError::Error(
this,
"Integrate",
"Step size %g too small", hnext);
151 KVError::Error(
this,
"Integrate",
"integration stopped at x=%g", x);
165 void KVRungeKutta::rkqs(
Double_t htry)
183 if (errmax <= 1.0)
break;
193 if (errmax > ERRCON) hnext = SAFETY *
h *
TMath::Power(errmax, PGROW);
194 else hnext = 5.0 *
h;
196 for (
int i = 0; i < nvar; i++) y[i] = yout[i];
216 for (
int i = 0; i < nvar; i++)
217 ytemp[i] = y[i] + b21 * h * dydx[i];
219 for (
int i = 0; i < nvar; i++)
220 ytemp[i] = y[i] + h * (b31 * dydx[i] + b32 * ak2[i]);
222 for (
int i = 0; i < nvar; i++)
223 ytemp[i] = y[i] + h * (b41 * dydx[i] + b42 * ak2[i] + b43 * ak3[i]);
225 for (
int i = 0; i < nvar; i++)
226 ytemp[i] = y[i] + h * (b51 * dydx[i] + b52 * ak2[i] + b53 * ak3[i] + b54 * ak4[i]);
228 for (
int i = 0; i < nvar; i++)
229 ytemp[i] = y[i] + h * (b61 * dydx[i] + b62 * ak2[i] + b63 * ak3[i] + b64 * ak4[i] + b65 * ak5[i]);
231 for (
int i = 0; i < nvar; i++)
232 yout[i] = y[i] + h * (c1 * dydx[i] + c3 * ak3[i] + c4 * ak4[i] + c6 * ak6[i]);
233 for (
int i = 0; i < nvar; i++)
234 yerr[i] = h * (dc1 * dydx[i] + dc3 * ak3[i] + dc4 * ak4[i] + dc5 * ak5[i] + dc6 * ak6[i]);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t hmin
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Base class for KaliVeda framework.
Adaptive step-size 4th order Runge-Kutta ODE integrator from Numerical Recipes.
virtual void CalcDerivs(Double_t X, Double_t *Y, Double_t *DYDX)=0
virtual ~KVRungeKutta()
Destructor.
virtual void Integrate(Double_t *ystart, Double_t x1, Double_t x2, Double_t h1)
void Error(UserClass p, const char *location, const char *va_(fmt),...)
Double_t Min(Double_t a, Double_t b)
Double_t Sign(Double_t a, Double_t b)
Double_t Power(Double_t x, Double_t y)
Double_t Max(Double_t a, Double_t b)