An N-body simulation typically works directly in terms of the gravitational forces and accelerations. If you can solve the equations exactly, this is fine, but there are many instances where this is impossible for a reasonable definition of impossible. Therefore, we approximate the solution.

Namely, we find the acceleration of each point mass, then increment the position and velocity using Euler's method.

One thing about this is that energy and momentum will not necessarily be preserved. This can lead to bad phenomenon such as mass coming to close and causing each other to shoot away. Generally, if you are viewing a simulation casually, most of the inaccuracies come in when energy or momentum are badly changed.

Can you do an N-body simulation directly in terms of concepts such as energy, momentum, work, impulse, etc...? Namely, what are some methods such that the energy and momentum are guaranteed to be conserved by the simulation?

We could give each point mass a velocity and position. This allows you to determine both the energy and momentum of each particle. You can then, as gravitational potential energy changes, calculate the corresponding change in kinetic energy, from there the change in velocity. I think work may be involved somewhere here as well (and therefore force). The problem is, this does not really tell you anything about direction.

Anyone know how a N-body simulation that conserves energy and momentum could work?

  • 1
    $\begingroup$ What you are looking for are basically numerical implementations of the Lagrange and Hamilton formalisms. Yes, that is exactly how one would do precise numerical simulations. Did you hear about symplectic integrators en.wikipedia.org/wiki/Symplectic_integrator? Having said that, the mentioned problem of bodies coming very close to each other can not be avoided. It is a real physical effect leading to long term unpredictable chaotic systems. $\endgroup$ – CuriousOne Jan 3 '16 at 3:29
  • $\begingroup$ @CuriousOne Well, even if it is unpredictable, it would be nice if the energy stayed constant (if you are, say, playing a game, it being off 45 degrees does not matter; it flying into space forever when it shouldn't does.) $\endgroup$ – PyRulez Jan 3 '16 at 3:39
  • 1
    $\begingroup$ As a side note... never, ever use the Euler method. That the energy is constant can be assured numerically quite easily. $\endgroup$ – CuriousOne Jan 3 '16 at 3:39
  • $\begingroup$ @CuriousOne What are you supposed to use instead? $\endgroup$ – PyRulez Jan 3 '16 at 3:39
  • $\begingroup$ Use, at least en.wikipedia.org/wiki/Semi-implicit_Euler_method. $\endgroup$ – CuriousOne Jan 3 '16 at 3:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.