Question

I have the following odeint program:

#include <boost/array.hpp>
#include <boost/numeric/odeint.hpp>
using namespace std;

typedef boost::array< double , 1 > state_type;

void eqsystem(const state_type &x, state_type &dxdt, double t) {
    dxdt[0] = 3;
}

void write_system( const state_type &x , const double t ) {
    cout << t << '\t' << x[0] << endl;
}

int main(){
    double t0=0, t1=100;
    double tstep0=0.01;
    state_type x = {{ 0 }};
    cout<<"t\tValue"<<endl;
    boost::numeric::odeint::integrate( eqsystem , x , t0 , t1 , tstep0 , write_system );
}

Every time t is a multiple of 10, I would like to set x[0]=0.1.

That is, I'd like to have a recurring delta function.

Alternatively, if I could have the delta function occur at a finite number of time points, I would be able to approximate the recurrence.

Unfortunately, I was unable to find a documentation of delta functions in odeint. Does anyone know how to achieve this?

Was it helpful?

Solution

This is not possible in odeint, at least not generically. You have two alternatives:

First approximate the delta peaks by very sharp Gaussians.

Second, integrate to the time-point of the peak. Apply the delta peak, i.e. add a step to your existing solution and starting integrate from this point to the next peak an so on.

There are als "exotic" methods for ODEs with discontinuities, but they usually treat the case when you ODE itself has discontinuities and not your external driving.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top