2

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?

SgrA
  • 289
  • 3
  • 9
  • 1
    Seems, that the operator/ is missing for Vector3d. I will try to write a solution tomorrow. You could also try to adapt define your own operator/ I think somewhere in boost/numeric/odeint/external/eigen/*.hpp is a snippet for this. – headmyshoulder Jun 23 '15 at 19:33
  • 2
    The change you made is not correct. The symplectic stepper has a different template parameter structure, it should read: ```symplectic_rkn_sb3a_mclachlan rkn;``` I'm not sure if this helps with yout original problem though. – mariomulansky Jun 24 '15 at 12:25
  • @mariomulansky Thanks! It compiles now. – SgrA Jun 25 '15 at 16:06

0 Answers0