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?