Passing runtime parameters to odeint integrator

后端 未结 2 613
闹比i
闹比i 2021-01-20 08:39

I would like to use the odeint boost integrator to look at geodesic curves in the Kerr spacetime. This necessitates running an integrator for a variety of parameter values (

相关标签:
2条回答
  • 2021-01-20 08:55

    You can pass runtime parameters to the system function defining your ODE:

    struct ode
    {
        double param;
        ode( double param ) : m_param( param ) {}
    
        void operator()( state_type const& x , state_type& dxdt , time_type t ) const 
        {
            // your ode
        }
    };
    
    integrate_const( stepper {} , ode { 0.1 } , x , t_start , t_end , dt , observer );
    
    0 讨论(0)
  • 2021-01-20 09:05

    I ran into a similar problem. What I did was defined global vars so that my function could access the variable I passed via argvs. Let me know if you need example.

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