Eigen Vector3d as state vector with odeint's symplectic_rkn_sb3a_mclachlan

≡放荡痞女 提交于 2021-02-11 08:42:26

问题


I'm implementing an n-body simulation by defining individual "particles" with variable (particle to particle, time independent) properties that affect the dynamics, and then defining a "System" of these particles as a vector which defines various operations on them including time evolution of the System by iterating over the vector:

symplectic_rkn_sb3a_mclachlan <Vector3d> rkn;

class Particle
{
    public: 
        // state.first - position, state.second - velocity
        std::pair <Vector3d, Vector3d> state;
        // other stuff
};

class System
{
        vector <Particle> Particles;
        void x_(const Vector3d &v, Vector3d &dxdt) const 
        { 
                dxdt = v; 
        }

        void v_(const Vector3d &x, Vector3d &dvdt) const 
        { 
                dvdt =  -GradientofPotential(x); }
        }
    public:
        double Integrate(double dt)
        {
                for (Particle it : System::Particles)
                rkn.do_step(std::make_pair(boost::bind(&System::x_, *this, _1, _2),
                                           boost::bind(&System::v_, *this, _1, _2)),
                            it.state, 0, dt);
                // more stuff               
        }
        // other stuff
};

The header file compiles fine but when I try to integrate the system, I run into this.

I read this and changed:

symplectic_rkn_sb3a_mclachlan <Vector3d> rkn;

to:

symplectic_rkn_sb3a_mclachlan <Vector3d, double, Vector3d, double, vector_space_algebra> rkn;

I had this error. What am I doing wrong?

Secondly, I need to get the other parameters that affect the dynamics like particle mass, charge, etc into the function v_. How can I do that?

来源:https://stackoverflow.com/questions/31008302/eigen-vector3d-as-state-vector-with-odeints-symplectic-rkn-sb3a-mclachlan

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!