Skip to content

5 steps to N-body simulation

This is a tutorial inspired by the course "CFD Python: 12 steps to Navier-Stokes". The goal is to teach beginners how to write fast and clean N-body gravity simulations code in Python.

Basic knowledge in Python, calculus and linear algebra is assumed. After completing this tutorial, you will be able to write your own N-body simulation code in Python.

How to use this tutorial?

The source code for the python scripts and the markdown files are available on

but I strongly recommend reading this tutorial on our website:

Code snippets will be shown as we progress, but you don't have to copy them one by one as the full script will be available at the end of each step. However, I recommend you to translate it into your own code in order to have a better understanding.

Contents

References

  1. Lorena Barba and Gilbert Forsyth. CFD Python: the 12 steps to Navier-Stokes equations. Journal of Open Source Education, 2(16):21, 2019. doi:10.21105/jose.00021.
  2. Javier Roa, Adrian S. Hamers, Maxwell X. Cai, and Nathan W. C. Leigh. Moving Planets Around: An Introduction to N-Body Simulations Applied to Exoplanetary Systems. MIT Press, 2020.
  3. Richard L. Burden and J. Douglas Faires. Numerical Analysis. Cengage Learning, nineth edition, 2011.

Comments