hannorein / rebound

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

max_dt option for IAS15? #399

Closed Fatys closed 5 years ago

Fatys commented 5 years ago

Hello Hanno,

I was wondering whether there is a way to set maximum allowed time-step for ias15 integrator? If not, would it be difficult to implement?

I have several groups of massless particles in the Solar System and I am looking for encounters between particles of one group with particles of other groups. Sometimes the dt chosen by ias15 is too large, so I miss the encounters. Also the particles may experience close encounters with the mass particles, so I would really like to use ias15.

Controlling the maximum time-step in the same way as 'min_dt' controls the shortest one would solve my problem.

I tried to use the mercurius integrator, but the performance with OpenMP was rather poor for some reason.

Anyway, I am a BIG fan of rebound, awesome job!

hannorein commented 5 years ago

No, there is currently no built-in way to set the maximum timestep for IAS15. It should not be difficult to implement. Have a look at this line of code here: https://github.com/hannorein/rebound/blob/master/src/integrator_ias15.c#L566 Basically, just copy and paste it.

There are of course other way you could solve the issue: e.g. using MERCURIUS.

Whether or not OpenMP helps is really tricky to say in general. If you can post a short example code of your setup, I can provide more insight. In short: 1) There might just not be enough particles in your simulation and the overhead from OpenMP dominates. 2) If you use ias15, then the particle having a close encounter will dictate the timestep for all particles, and it's going to be small. There is currently no way to use individual timesteps in REBOUND.

Fatys commented 5 years ago

Thank you for your quick reply! I will implement the max_dt restriction near the lines you pointed out and I'll see how it works for me, but it looks simple enough. Thanks again