<p>I'm running Python based computational astrophysics simulations on a Jupyter notebook, with the help of a library called REBOUND (also using REBOUNDx), to create a simulation containing the solar system. The code I write runs properly and gives me the expected results. The problem I'm having right now is that if I set the simulation for a few gigayears, it takes at least 8 hours to get the results. Is there any way to optimise my code so that it runs faster?</p>
<p>The code is written in three files as follows:</p>
<ol>
<li>The setup.py file contains the initial conditions and all the objects of the simulation.</li>
<li>The restart.py file is where the simulation runs and takes an extraordinary amount of time for just 3 objects so this is what I'd like to optimise.</li>
<li>The follow.py file is where the data from the simulation archive binary file is plotted for analysis.</li>
</ol>
<p>I've tried Numba's JIT but it doesn't work because it doesn't work with other libraries or data outside of the function you've applied JIT to. I've also considered paying for more hardware computational power on IDEs such as Google's Colab, but I wanted to check if there's a software trick I can exploit. Please let me know.</p>

CC BY-SA 4.0
2024-03-24T00:44:21.397Z
My how the world has changed since I first studied Astronomy; complaining that a few gigayears takes a whole 8 hours to simulate... :-)
uhoh
CC BY-SA 4.0
2024-03-28T14:25:46.910Z
Gyr is actually a lot for 8 hours of working in local. Just a comment from someone who has used (not much though) REBOUNDx... Have you tried getting in touch with the Contributors? (Hanno Rein, Dan Tamayo, David Spiegel, Akihiko Fujii). "[REBOUND](https://pypi.org/project/rebound/0.1.9/) is open source. You are invited to contribute to this project if you are using it. Please contact any of the authors above if you have any questions."
nuwe
CC BY-SA 4.0
2024-03-22T05:57:05.317Z
what books do you use?  I would like to know.
ayr
<astrophysics><python><n-body-simulations>
How to speed up REBOUND python simulations on a Jupyter notebook?
poseidon24
# How to speed up REBOUND python simulations on a Jupyter notebook?

(Asked by: username_0 on 2024-03-21)

I'm running Python based computational astrophysics simulations on a Jupyter notebook, with the help of a library called REBOUND (also using REBOUNDx), to create a simulation containing the solar system. The code I write runs properly and gives me the expected results. The problem I'm having right now is that if I set the simulation for a few gigayears, it takes at least 8 hours to get the results. Is there any way to optimise my code so that it runs faster?

The code is written in three files as follows:

1. The setup.py file contains the initial conditions and all the objects of the simulation.
2. The restart.py file is where the simulation runs and takes an extraordinary amount of time for just 3 objects so this is what I'd like to optimise.
3. The follow.py file is where the data from the simulation archive binary file is plotted for analysis.

I've tried Numba's JIT but it doesn't work because it doesn't work with other libraries or data outside of the function you've applied JIT to. I've also considered paying for more hardware computational power on IDEs such as Google's Colab, but I wanted to check if there's a software trick I can exploit. Please let me know.

**Tags:** astrophysics, python, n-body-simulations

> **Comments:**
> **username_3**: what books do you use?  I would like to know.  
> **username_1**: My how the world has changed since I first studied Astronomy; complaining that a few gigayears takes a whole 8 hours to simulate... :-)  
> **username_2**: Gyr is actually a lot for 8 hours of working in local. Just a comment from someone who has used (not much though) REBOUNDx... Have you tried getting in touch with the Contributors? (Hanno Rein, Dan Tamayo, David Spiegel, Akihiko Fujii). "[REBOUND](https://pypi.org/project/rebound/0.1.9/) is open source. You are invited to contribute to this project if you are using it. Please contact any of the authors above if you have any questions."  

---

## 0 answers

