I'm currently writing a 3D $n$-body simulator (similar to what you see here to simulate the evolution of a system of n particles under the force of gravity.

It works fine for "smaller" scale simulations (small galaxies and other random scenarios), but as I scale up to bigger things ($100$ kly diameter galaxies, cosmic clusters, etc) there is a problem. I'm not accounting for any other force other than the force of gravity, so when trying to simulate large-scale scenarios with many particles, the entire system just "collapses" on itself because I'm not accounting for any repulsive force.

I can sort of fake it by using a trig formula when I calculate gravitational attraction, thereby making gravity more localized and having a finite range, but the problem here is that if the distance between two particles is greater than the specified range, there is no attraction. This results in particles just being shot out of the system never to return.

I am wondering, just as there is a formula to determine the force of attraction under gravity of two bodies of mass, is there a formula to determine the repulsive force (due to dark energy maybe?) between two bodies of mass at some distance r?

If not, how can I "fake it" better so that my simulations don't just collapse, and so that particles aren't lost due to my artificially induced "finite range" of the gravitational field?

  • 2
    $\begingroup$ Are you actually trying to simulate the entire universe? If not, you almost certainly don't need dark energy. Most things maintain their separation by rotating; without rotation, you should expect that your simulation will collapse in on itself. $\endgroup$ – David Z Jan 19 '14 at 2:08
  • $\begingroup$ What force formula are you using currently? $\endgroup$ – Kyle Kanos Jan 19 '14 at 2:14
  • 1
    $\begingroup$ There is a very high likelihood that the problem lies with your code, and Physics.SE does not deal with code answers; use Computational Science for that. The first thing to do is to check that you are using a symplectic integrator as that is a very common first mistake. $\endgroup$ – dmckee Jan 19 '14 at 2:15
  • $\begingroup$ @DavidZ Not the whole universe, but slices of it. For example, in this video you can see the filaments forming youtube.com/watch?v=eDGtFRj4xXc but in my own simulation, the whole system just collapses pretty quickly and only showing a glimpse of the filaments. $\endgroup$ – Jesse Jan 19 '14 at 2:19
  • 1
    $\begingroup$ I would actually agree with @ChrisWhite (and originally David Z) here. I think it's an initial conditions problem (most likely). You say that your system collapses in on itself, but I'm wondering what kinds of initial velocities (individual and bulk) you're giving to the particles. These objects are 'rotationally supported', preventing them from just spherically collapsing in on themselves. $\endgroup$ – astromax Jan 19 '14 at 5:50

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.