Using odeint function definition

后端 未结 2 1943
青春惊慌失措
青春惊慌失措 2021-01-14 05:41

Pretty noob question so please bear with me.

I am following the example given here--> http://www.codeproject.com/Articles/268589/odeint-v2-Solving-ordinary-different

相关标签:
2条回答
  • 2021-01-14 06:29

    You can use the "class" version, but modify it so that it is initialized with the R value of interest to you.

    class lorenz_class {
        double R_;
    public:
        lorenz_class (double r) : R_(r) {}
        void operator()( state_type &x , state_type &dxdt , double t ) {
            dxdt[0] = sigma * ( x[1] - x[0] );
            dxdt[1] = R_ * x[0] - x[1] - x[0] * x[2];
            dxdt[2] = x[0]*x[1] - b * x[2];
        }
    };
    

    Then, iterate over your vector R and pass in the value to the lorenz_class instance that you pass to the integrate_const template function.

    for (unsigned i = 0; i < myR.size(); ++i) {
        lorenz_class lorenz(myR[i]);
        integrate_const( runge_kutta4< state_type >() , lorenz , x , 0.0 , 10.0 , dt );
    }
    
    0 讨论(0)
  • 2021-01-14 06:40

    Just a little side note: The tutorial shows a very similar example of a parameter study of the Lorenz system: http://headmyshoulder.github.com/odeint-v2/doc/boost_numeric_odeint/tutorial.html. It is in the Thrust and the VexCL section and it shows how you can parallelize this problem to work on multiple CPUs or the GPU.

    0 讨论(0)
提交回复
热议问题