headmyshoulder / odeint-v2

odeint - solving ordinary differential equations in c++ v2
http://headmyshoulder.github.com/odeint-v2/
Other
340 stars 101 forks source link

Test certain steppers with the problem x'(t) = t^p #146

Closed GregorDeCillia closed 9 years ago

GregorDeCillia commented 9 years ago

As discussed in https://github.com/headmyshoulder/odeint-v2/issues/145

mariomulansky commented 9 years ago

good job, thanks!

to make it more consistent with our other tests i would like to propose a few small adjustments:

while( error < tolerance )
{
}

if possible

GregorDeCillia commented 9 years ago

seems easy to do do, but will take a while because holidays. I will let you know when the adjustments are finished.

GregorDeCillia commented 9 years ago

I just encounterd some problems when changing the state_typefrom vector<double> to double. It seems the initialize function does behave different for those two state types. The following script returns t=0, x=0 for double and t=0.3, x=0.3 for vector<double>. Am I missing something here?

#include <boost/numeric/odeint.hpp>
#include <iostream>

using namespace boost::numeric::odeint;

typedef double state_type;
//typedef std::vector<double> state_type;

void rhs( const state_type &x , state_type &dxdt , const double t ){
    dxdt = 1;
    //dxdt[0] = 1;
}

int main(){
    double t = 0;
    const double dt = 0.1;

    state_type x = 0;
    //state_type x(1); x[0] = 0;

    adams_bashforth< 4, state_type > stepper;    
    stepper.initialize( runge_kutta_fehlberg78< state_type >(),
            rhs, x, t, dt ); 

    std::cout << "Initializing finished: t = " << t << ", x = " 
          << x << std::endl;
    //      << x[0] << std::endl;    
}
mariomulansky commented 9 years ago

Strange. Let me look into that.

mariomulansky commented 9 years ago

Indeed, for this case the wrong overloads of do_step were used. This should be fixed with 4cadbe5 now.

GregorDeCillia commented 9 years ago

147 resolved the issues i had. Now a new version of the test is available. As recommended i

mariomulansky commented 9 years ago

very nice, thanks a lot one final request: put your name in the copyright notice in top of the test instead of ours ;)

GregorDeCillia commented 9 years ago

Done! I hope the location test/numeric is alright for the test.

mariomulansky commented 9 years ago

yes, it's exactly the right place. I will do another quick review tonight and then merge it.

mariomulansky commented 9 years ago

Thanks again, I've merged the code and made some further improvements, see f5079fb258d32ae4bc99b55b698e3b571bc608f5 For example, I added a template parameter for the the initializing stepper in the abm stepper, that allowed me to get rid of the initializing test case. Also, I changed the loop back to the for loop you had initially, sorry for the back and forth... and some minor cosmetic changes (e.g. camel case)