libode
Easy to compile, fast ODE integrators as C++ classes
Loading...
Searching...
No Matches
ode_trapz.cc
Go to the documentation of this file.
1
2
3#include "ode_trapz.h"
4
5namespace ode {
6
7OdeTrapz::OdeTrapz (unsigned long neq) :
8 OdeAdaptive (neq, false),
9 OdeRK (neq, 2),
10 OdeERK (neq) {
11
12 method_ = "Trapz";
13 //tableau of coefficients
14 c2 = 1.0; a21 = 1.0;
15 b1 = 1.0/2; b2 = 1.0/2;
16}
17
18void OdeTrapz::step_ (double dt) {
19
20 unsigned long i;
21
22 //------------------------------------------------------------------
23 ode_fun_(sol_, k_[0]);
24
25 //------------------------------------------------------------------
26 for (i=0; i<neq_; i++) soltemp_[i] = sol_[i] + dt*a21*k_[0][i];
27 ode_fun_(soltemp_, k_[1]);
28
29 //------------------------------------------------------------------
30 for (i=0; i<neq_; i++) sol_[i] = sol_[i] + dt*(b1*k_[0][i] + b2*k_[1][i]);
31}
32
33} // namespace ode
Base class implementing solver functions with adaptive time steps.
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
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
OdeTrapz(unsigned long neq)
constructs
Definition ode_trapz.cc:7