2.0.0b10
catchment modelling framework
Loading...
Searching...
No Matches
BDF2 Class Reference

An order 2 BDF-Method with fixed-point iteration and variable step size. More...

+ Inheritance diagram for BDF2:
+ Collaboration diagram for BDF2:

Detailed Description

An order 2 BDF-Method with fixed-point iteration and variable step size.

Derived from

  • Roussel C. and Roussel M. (2003) "Generic Object-Oriented Differential Equation Integrators", C/C++ User Journal, Nov. 2003, http://www.ddj.com/cpp/184401724?pgno=8 and
  • Eckert S., Baaser H., Gross D. and Scherf O. (2004) "A BDF2 integration method with step size control for elasto-plasticity", Computational Mechanics 34, 377 - 386, DOI: 10.1007/s00466-004-0581-1

Most important function: Integrate

Public Member Functions

Integrate
void integrate_until (cmf::math::Time t_max, cmf::math::Time dt=Time(), bool reset=false)
 Integrates the vector of state variables until t_max.
 

Protected Attributes

Accuracy parameters
const real Epsilon =1e-9
 Tolerable error.
 

Gear functions: The following functions evaluate the Gear formulas of specified order, loading the results into compareStates.

int max_order
 Maximum order, can be 1 (implicit euler) or 2 (BDF2)
 
ptrdiff_t get_error_position () const
 Returns the position of the biggest error.
 
void reset () override
 Resets any saved history (for multistep methods)
 
 BDF2 (real epsilon=1e-9, cmf::math::Time tStepMin=cmf::math::timespan(10))
 Constructs a new BDF2 integrator.
 
 BDF2 (const cmf::math::state_list &states, real epsilon=1e-9, cmf::math::Time tStepMin=cmf::math::timespan(10))
 Constructs a new Gears_var_Step.
 
 BDF2 (const Integrator &templ)
 Constructs a new BDF2 integrator.
 
Integratorcopy () const override
 Polymorphic copy constructor.
 
std::string to_string () const override
 Desrcibes the iterator.
 
int integrate (cmf::math::Time MaxTime, cmf::math::Time TimeStep) override
 Integrates the vector of state variables.
 

model time

cmf::math::Time get_t () const
 Returns the current model time.
 
void set_t (cmf::math::Time val)
 Sets the current model time.
 
cmf::math::Time get_dt () const
 Returns the last time step.
 
cmf::math::Time m_t
 Actual time of the solver.
 
cmf::math::Time m_dt
 last time step of the solver
 

Constructor & Destructor Documentation

◆ BDF2() [1/3]

BDF2 ( real epsilon = 1e-9,
cmf::math::Time tStepMin = cmf::math::timespan(10) )
explicit

Constructs a new BDF2 integrator.

Parameters
epsilonrelative error tolerance per time step (default=1e-9)
tStepMinminimum time step (default=10s)

◆ BDF2() [2/3]

BDF2 ( const cmf::math::state_list & states,
real epsilon = 1e-9,
cmf::math::Time tStepMin = cmf::math::timespan(10) )
explicit

Constructs a new Gears_var_Step.

Parameters
statesStates to be added to the solver
epsilonrelative error tolerance per time step (default=1e-9)
tStepMinminimum time step (default=10s)

◆ BDF2() [3/3]

BDF2 ( const Integrator & templ)
explicit

Constructs a new BDF2 integrator.

Parameters
templTemplate to be used to construct a BDF2 method

Member Function Documentation

◆ integrate()

int integrate ( cmf::math::Time MaxTime,
cmf::math::Time TimeStep )
overridevirtual

Integrates the vector of state variables.

  • if \( t_{max}-t_{now}\leq 2h_n \) then \( h_{n+1}= t_{max}-t_{now} \) else \( h_{n+1}= 2h_n \)
  • Uses pastStatesArray to store \( y_n,y_{n-1} \)
  • if more than one step is taken start iterating:
    • \( y_{n+1}^i=\frac{1}{1+2\rho }\left( (\rho +1)^{2}y_{n}-\rho ^{2}y_{n-1}+(\rho +1)h\frac{dy}{dt}(y_{n+1}^{i-1},t_{n+1} \right), y_{n+1}^0=y_n \) with \( \rho = \frac{h_{n+1}}{h_n} \)
  • until \( y_{n+1}^{i} - y_{n+1}^{i-1} \leq \ \|\epsilon + \epsilon y_{n+1}\|_{\infty} \)
  • If too many iterations are needed, or the error is rising, repeat iteration with \( h_{n+1} = \frac{h_{n+1}}{2} \)
    Parameters
    MaxTimeTo stop the model (if running in a model framework) at time steps of value exchange e.g. full hours, the next value exchange time can be given
    TimeStepTakes the proposed timestep, ignored by this solver

Implements Integrator.

◆ integrate_until()

void integrate_until ( cmf::math::Time t_max,
cmf::math::Time dt = Time(),
bool reset = false )
inherited

Integrates the vector of state variables until t_max.

Parameters
t_maxTime, the solver should run to
dtTime step (may be omitted)
resetIf true, solver is reseted before integration starts