I want to do a quick study and some tests on the planet-star dynamics ( including the movement of the star). I'm looking for a code that simulates some planets orbiting a star. I've tried searching online and the ones that I found are either incomplete or do not seem to give realistic results. With that in mind I'm wondering if there is any code/package that does this already (in Python).

  • 1
    $\begingroup$ What codes have you tried, and how did they fall short? REBOUND looks interesting but it's hard to guess whether it would meet your needs. $\endgroup$
    – Mike G
    Commented Feb 12, 2020 at 18:26
  • $\begingroup$ Would a planetarium simulation help? I assume the planet orbits are input but cant swear to that. $\endgroup$
    – Natsfan
    Commented Feb 13, 2020 at 0:49
  • $\begingroup$ I just edited my answer and mentioned a few more options $\endgroup$
    – uhoh
    Commented Feb 14, 2020 at 1:12
  • $\begingroup$ astronomy.stackexchange.com/questions/13488/… may or may not be helpful $\endgroup$
    – user21
    Commented Feb 17, 2020 at 16:02
  • $\begingroup$ Thank you for the answers, REBOUND seems perfect for what I wanted and have been working with it for the past few days and getting results, thank you! $\endgroup$
    – T. Silva
    Commented Feb 27, 2020 at 16:14

1 Answer 1


There are of course serious Python packages to simulate solar systems out there, one of which might be found in The random walk of cars and their collision probabilities with planets but I think that other answers that will be posted will give a more complete answer.

I looked into a "roll your own" script as described in answers to How to calculate the planets and moons beyond Newtons's gravitational force? If you don't need to propagate for millions of years, it should be pretty easy and extremely instructive to just do the numerical simulation yourself.

update: The Python package Poliastro may also do exactly what you need (poliastro in Space SE), and while Skyfield does not do this, there are rumblings in Github issues about adding an orbit propagator to it in the future. PyEphem has been depreciated (same developer as Skyfield) but I believe it also does orbit propagation of user-specified objects, though I'm not sure if it's n-body or just Keplerian orbits.

I think that Universe Sandbox will work for you. See also Is a General Relativity approximation available in Universe Sandbox (1 or 2)?

Though it is a complete program and not in Python, Scott Manley talks about Universe Sandbox in several videos.

  • 1
    $\begingroup$ Thank you for the complete answer! Poliastro seems to be the one that best fits my interests from those mentioned, I will let you know if everything works! $\endgroup$
    – T. Silva
    Commented Feb 27, 2020 at 16:13
  • $\begingroup$ @T.Silva that's great news; it will be great to hear how it goes, thanks! $\endgroup$
    – uhoh
    Commented Feb 27, 2020 at 17:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .