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

Mercurius with "line" collision search? #634

Closed Anit5577 closed 1 year ago

Anit5577 commented 1 year ago

I am running Mercurius for a simulation of a tight planetary system after a fly-by. I have decided on the "line" collision search as I would like to make sure that I catch collisions during a timestep.

However, I got the following RuntimeWarning

RuntimeWarning: Mercurius only works with a direct collision search. warnings.warn(msg[1:], RuntimeWarning

Will Mercurius default to "direct" or will it not check for collisions at all now?

hannorein commented 1 year ago

Hi Christina,

You need to make sure your global timestep is small enough to not miss particles which may have a close encounter (overlapping hill spheres). Once a potential close encounter is detected, Mercurius automatically reduces the sub-timestep during close encounters. As the warning says, the only collision detection method supported is the direct method. The reason for this is that the integrator would need both velocities and positions to use something like the line algorithm, but only the positions for the direct method. Because it is a leap-frog style, the positions and velocities are not always synchronized.

Hanno

Anit5577 commented 1 year ago

I have the timestep set based on the period of the innermost planet. Is this the global timestep you referred to: sim.dt = sim.particles[1].P * 0.002

Will Mercurius automatically revert to "direct" even though it is set to "line" in a script I have run?

hannorein commented 1 year ago

No, I don't think it sets it back to "direct". I'm not sure what happens when you set it to line. I guess "undefined behaviour'...

For the timestep, check how far two planets travel in one timestep. Compare that to the critical switchover radius that you have set.