List of all members | Public Member Functions | Private Attributes
utl::RK5ODEIntegrator< DerivativeFunctor > Class Template Reference

#include "utl/RK5ODEIntegrator.h"

Public Member Functions

template<class VectorType >
AdaptiveRK5Iterator
< DerivativeFunctor,
VectorType > 
AdaptiveBegin (const double x, const double dx, const VectorType &y, const double accuracy=1e-5)
 
template<class VectorType , class ErrorScalingPolicy >
AdaptiveRK5Iterator
< DerivativeFunctor,
VectorType, ErrorScalingPolicy > 
AdaptiveBegin (const double x, const double dx, const VectorType &y, const double accuracy, ErrorScalingPolicy &es)
 
template<class VectorType >
RK5Iterator< DerivativeFunctor,
VectorType > 
Begin (const double x, const VectorType &y)
 
DerivativeFunctor & GetDerivativeFunctor ()
 
 RK5ODEIntegrator (DerivativeFunctor &d)
 

Private Attributes

DerivativeFunctor & fDerivativeFunctor
 

Detailed Description

template<class DerivativeFunctor>
class utl::RK5ODEIntegrator< DerivativeFunctor >

This class prepares the integration of the Ordinary Differential Equations (ODE) of the form

\[ \frac{{\rm d}y_i}{{\rm d}x} = f_i(x, y_0, \ldots, y_{n-1}) \]

for $i\in{0, \ldots, n-1}$.

ODE is defined through an function class with operator() defined (usualy such classes are called functor in C++). This functor has to define the operator() and unsigned int cast operator:

class MyODE {
public:
void
operator()(const double x, const double y[10], double dydx[10])
{
dydx[0] = ...
dydx[1] = ...
}
operator unsigned int() { return 10; }
};

Operator() calculates derivatives ${\rm d}y_i/{\rm d}x$ of variables $y_i$ with respect to the independent variable x.

The cast operator unsigned int() returns number of OD equations (in this example 10).

The class RK5ODEIntegrator returns an iterator that can be advanced with operator += dx for some step dx in independent variable.

RK4ODEIntegrator<MyODE, double [10]> ode(MyODE());
RK4Iterator<MyODE, double [10]> it = ode.Begin(x0, y0);
it += dx;

Next to the iterator (similar to the RK4Iterator) there is also AdaptiveRK5Iterator available which maintains the accuracy of the result by taking steps of optimal size;

Note that the suitable candidates for template parameter VectorType are vector classes with fixed size (std::vector<> is not appropriate since the default constructor leaves the object with zero size) that support the operator[] for element access. You can use the C-style arrays double[n] or Offline class utl::SVectorType<n>.

See also utl::RK4ODEIntegrator and testODEIntegrator.cc for a real examples.

Author
Darko Veberic
Date
20 Jun 2008

Definition at line 407 of file RK5ODEIntegrator.h.

Constructor & Destructor Documentation

template<class DerivativeFunctor>
utl::RK5ODEIntegrator< DerivativeFunctor >::RK5ODEIntegrator ( DerivativeFunctor &  d)
inline

Definition at line 409 of file RK5ODEIntegrator.h.

Member Function Documentation

template<class DerivativeFunctor>
template<class VectorType >
AdaptiveRK5Iterator<DerivativeFunctor, VectorType> utl::RK5ODEIntegrator< DerivativeFunctor >::AdaptiveBegin ( const double  x,
const double  dx,
const VectorType &  y,
const double  accuracy = 1e-5 
)
inline
template<class DerivativeFunctor>
template<class VectorType , class ErrorScalingPolicy >
AdaptiveRK5Iterator<DerivativeFunctor, VectorType, ErrorScalingPolicy> utl::RK5ODEIntegrator< DerivativeFunctor >::AdaptiveBegin ( const double  x,
const double  dx,
const VectorType &  y,
const double  accuracy,
ErrorScalingPolicy &  es 
)
inline
template<class DerivativeFunctor>
template<class VectorType >
RK5Iterator<DerivativeFunctor, VectorType> utl::RK5ODEIntegrator< DerivativeFunctor >::Begin ( const double  x,
const VectorType &  y 
)
inline
template<class DerivativeFunctor>
DerivativeFunctor& utl::RK5ODEIntegrator< DerivativeFunctor >::GetDerivativeFunctor ( )
inline

Member Data Documentation

template<class DerivativeFunctor>
DerivativeFunctor& utl::RK5ODEIntegrator< DerivativeFunctor >::fDerivativeFunctor
private

The documentation for this class was generated from the following file:

, generated on Tue Sep 26 2023.