Yes, you can use odeint for this kind of problems. The explicit steppers expect that the system function (the ODE) you pass to odeint has the signature
ode( x , dxdt , t );
where x
is the input parameter for the current state, dxdt
is the output parameter for the r.h.s. of the ODE an t
is the time. For example a driven oscillator might be implemented like
typedef std::array< double , 2 > state_type;
struct oscillator
{
double driving_strength;
double dribving_frequency;
void operator()( state_type const &x , state_type &dxdt , double t ) const
{
dxdt[0] = x[1];
dxdt[1] = -x[0] + driving_strength * sin( driving_frequency * t );
}
};
state_type x;
oscillator osc;
// initialize x and osc
runge_kutta4< state_type > stepper;
integrate_const( stepper , osc , x , t_start , t_end , dt );