ph4 stopping conditions and reproducibility #1043
rieder
started this conversation in
Show and tell
Replies: 1 comment
-
The fix is not complete yet, unfortunately. Maybe more is needed on the ph4 side. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I recently encountered a weird issue with the
gravity_collision.py
example: it turned out that the result of this script is not reproducible - even though initial conditions and random seed are identical.After a lot of searching, it looks like this originates from very small roundoff errors in ph4.
To fix it, I replaced the following (summarised) code:
with the following:
The problem with the former is that ph4 stops at a "weird" time - when it detects a collision would happen - and then is instructed by AMUSE to take that time as a starting point for the next step. The fixed code instead ignores this moment (though it handles the collision), and continues to the original end time.
I haven't checked, but I expect the time of collision is determined via the position and velocities of the particles, which may introduce roundoff errors which would then propagate.
So, be warned if you use stopping conditions: preferably use these in a
while
loop rather than with anif
statement!Beta Was this translation helpful? Give feedback.
All reactions