hannorein / rebound

💫 An open-source multi-purpose N-body code.
https://rebound.readthedocs.io/
GNU General Public License v3.0
849 stars 219 forks source link

Runtime Warning that never executes the code #621

Closed ruaSulaiman closed 1 year ago

ruaSulaiman commented 1 year ago

Hello,

I am trying to continue a simulation starting from a binary file. The only change that I made is the accuracy of the integrator (I increased it). The simulation is taking so much time and it is still not running. When I change the accuracy back to the original one, the simulation works fine. I was thinking if there is a way to fix that, or is it not possible to change the accuracy of the integrator in the second simulation?

Thank you.

hannorein commented 1 year ago

What integrator do you use and what parameter do you change when you say you change the accuracy?

ruaSulaiman commented 1 year ago

I am using BS integrator. The parameters that I am changing are: 'ri_bs.eps_rel' and 'ri_bs.eps_abs'. I am trying to make them smaller in the second simulation.

hannorein commented 1 year ago

It might just be the case that you're trying to achieve an accuracy which is too high. If the accuracy gets close to machine precision, then the integrator might never converge, thus trying to reduce the timestep further and further. I would try out different epsilon parameters and see where it stops working.

ruaSulaiman commented 1 year ago

Indeed I tried different smaller accuracy and the code ran. However, I already have another simulation that is running that has the same high accuracy (from the beginning of the simulation) that I was trying to switch to in the first simulation that never ran. Do you think it is still a problem due to the machine's precision?

hannorein commented 1 year ago

I'm not sure, but yes, that could be the issue for your other simulation as well.

ruaSulaiman commented 1 year ago

I apologize for that but I think my sentence was not clear. What I meant is that I have a simulation that is running with a very small epsilon (epsilon = 1e-18) that I started the simulation with from the beginning. On the other hand, I have another simulation whose initial epsilon = 1e-10. When I try to continue this simulation with epsilon = 1e-18 the simulation does not run, however, it runs fine when I change epsilon to e-14. What I am trying to say is that simulations with epsilon = 1e-18 are working only if I set their epsilons to be that small from the beginning, but not when I try to switch to epsilon = 1e-18 later (meaning after I start the simulation already with a different epsilon). Is this still related to my machine's precision?

hannorein commented 1 year ago

The default is eps=1e-8. 1e-10 might work, but it doesn't make sense to use a value much smaller than that!

ruaSulaiman commented 1 year ago

I see, but the thing is that in my simulation, along with using BS integrator, I am using the merging collision module. The energy is not conserved, but no merging events are happening (the number of particles is always the same). I thought that this was because of the accuracy of the integrator. Then I thought "is it possible then that it is because of the time step?" So instead of continuing the simulation with higher accuracy, I run it with the epsilon = e-10 but with smaller time steps. The result is still the same, the energy is violated with no merging events. I am not sure why this is happening.

hannorein commented 1 year ago

BS is an adaptive integrator. It sets the timestep automatically depending on what you choose for the accuracy parameter eps.

ruaSulaiman commented 1 year ago

Right, but I thought that if I indicate the time step for the integrator explicitly the results might change. But I still do not understand why there is a violation in energy even though there are no merging events.

hannorein commented 1 year ago

I don't think I can provide any advice here. You'd need to post a minimal example that reproduces the issues.