How would one perform an $N$-body simulation in General Relativity (GR) for something like galaxy formation or galactic dynamics?

Suppose one wants to simulate the rotation curve $v(r)$ for galaxies with an $N$-body simulation, and wants to do it in the framework of GR / the Einstein equations.

  • 4
    $\begingroup$ You should be a bit more specific than that. If the conditions are mild than all you need is Newtonian gravity plus some corrections. If the situation is complex (like dynamics of black hole collision, or star collapse) then one needs to discretize full GR equations and this is not simple at all... $\endgroup$
    – Marek
    Jul 24, 2011 at 7:35
  • 2
    $\begingroup$ This isn't a standard reply. As for any physical problem there 10 different approaches with increasing complexity possible. When solving hydrogen atom in QM, you can just solve classical electron picture, you can add relativistic effects, you can add spin-interactions, nucleus composition, QFT effects, etc., etc. Most of these are completely irrelevant for standard purposes. That's why I am asking again: what level of complexity are you after? There's no one single correct approach to numerical GR, there are dozens. If you don't know answer to this then you have no question... $\endgroup$
    – Marek
    Jul 24, 2011 at 7:56
  • 2
    $\begingroup$ okay, now that is some context. It would be nice if you added this (and more) information to the question. $\endgroup$
    – Marek
    Jul 24, 2011 at 9:01
  • 1
    $\begingroup$ The question is still awfully broad. Are you looking for some references on how to enter the field of numerical GR? Looking for references for particular recipes? Looking for known results? $\endgroup$ Jul 24, 2011 at 14:08
  • 1
    $\begingroup$ For galaxy rotation curves, I'm guessing that low order post-Newtonian terms (en.wikipedia.org/wiki/Parameterized_post-Newtonian_formalism) are sufficient as corrections (as pointed out by @Marek). For formation, I would guess that having accurate equations of state would be far more important than any gravitational corrections. $\endgroup$
    – genneth
    Jul 26, 2011 at 9:04

2 Answers 2


So general relativistic n-body problem is not very studied in the community, but it has a bit of a renewal interest. Then I am not aware of public software, but there is a few group which have solution which kind of works:

Then you would see that the first NR nbody date from the 80s with the work of S. L. Shapiro and S. Teukolsky (85,86).


Light++ It is not open source but you can try to contact the author, Werner Benger.

A few years ago we have access to the source code of 'light++'. Not anymore :(

Light++ Raytracer! (general relativistic raytracing)

Simulation of a Black Hole by Raytracing

The Black Earth

About the simulation of galactic close encounters, or a n-body general simulation, under the constraints of GR I found nothing.

"I found nothing" can be read like this "there is not a single software package" because, AFAIK,
no one knows how to apply GR in the computation of planetary and galaxy dynamics (small scale with matter).
The Zeldovich approximation is used in the linearization of GR (with caveats):

and has been successfully applied to describe the large scale clustering in the distribution of galaxy clusters. ..However, within the Zeldovich prescription, after a pancake forms in correspondence of crossing of particle orbits, such particles continue travelling along straight lines, ..

I think that your aim is hopeless because GR is around since 1917 and no one succeeded.
Interesting questions, imo:
How close to the reality are the simulations that are performed with Newtonian codes.
What kind of problems we may expect if we are gonna try to do a simulation code.


  • $\begingroup$ NOTE: Dead link. http://www.photon.at/~werner/light/ returns Forbidden - You don't have permission to access /~werner/light/ on this server. $\endgroup$ Jan 10, 2016 at 7:28
  • $\begingroup$ @ja72 there is a related library here $\endgroup$
    – user46925
    Jan 10, 2016 at 13:39
  • 1
    $\begingroup$ @ja72: Archive.org'd the dead links. $\endgroup$
    – genpfault
    Sep 9, 2016 at 21:10
  • $\begingroup$ Interesting, but raytracing is most definitely not n-body simulation! However, if that is what you want, then try this tutorial with c source code: madore.org/~david/math/kerr.html $\endgroup$
    – m4r35n357
    Nov 9, 2021 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.