libode
Easy to compile, fast ODE integrators as C++ classes
Loading...
Searching...
No Matches
ode_rkf_32.cc
Go to the documentation of this file.
1
2
3#include "ode_rkf_32.h"
4
5namespace ode {
6
7OdeRKF32::OdeRKF32 (unsigned long neq) :
8 OdeEmbedded (neq, false, 2),
9 OdeRK (neq, 3),
10 OdeERK (neq) {
11
12 method_ = "RKF32";
13 //tableau of coefficients
14 c2 = 1.0; a21 = 1.0;
15 c3 = 1.0/2; a31 = 1.0/4; a32 = 1.0/4;
16 b1 = 1.0/2; b2 = 1.0/2;
17 d1 = 1.0/6; d2 = 1.0/6; d3 = 4.0/6;
18}
19
20void OdeRKF32::step_ (double dt) {
21
22 unsigned long i;
23
24 //------------------------------------------------------------------
25 ode_fun_(sol_, k_[0]);
26
27 //------------------------------------------------------------------
28 for (i=0; i<neq_; i++) soltemp_[i] = sol_[i] + dt*a21*k_[0][i];
29 ode_fun_(soltemp_, k_[1]);
30
31 //------------------------------------------------------------------
32 for (i=0; i<neq_; i++) soltemp_[i] = sol_[i] + dt*(a31*k_[0][i] + a32*k_[1][i]);
33 ode_fun_(soltemp_, k_[2]);
34
35 //------------------------------------------------------------------
36 for (i=0; i<neq_; i++) {
37 solemb_[i] = sol_[i] + dt*(b1*k_[0][i] + b2*k_[1][i]);
38 sol_[i] = sol_[i] + dt*(d1*k_[0][i] + d2*k_[1][i] + d3*k_[2][i]);
39 }
40}
41
42} // namespace ode
unsigned long neq_
number of equations in the system of ODEs
Definition ode_base.h:327
std::string method_
the "name" of the solver/method, as in "Euler" or "RK4"
Definition ode_base.h:319
double * sol_
array for the solution, changing over time
Definition ode_base.h:333
void ode_fun_(double *solin, double *fout)
wrapper, calls ode_fun() and increases the neval counter by one
Definition ode_base.cc:87
Base class providing space for temporary solutions moving through RK stages.
Definition ode_erk.h:9
double * soltemp_
temporary solution vector
Definition ode_erk.h:22
Base clase implementing methods for embedded Runge-Kutta error estimation.
double * solemb_
embedded solution array
OdeRKF32(unsigned long neq)
constructs
Definition ode_rkf_32.cc:7
Provides space for stage slope values, an array of arrays for k values.
Definition ode_rk.h:9
double ** k_
stage evaluations
Definition ode_rk.h:23