-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LB+particles: guard against missed coupling due to round-off error #4827
Conversation
in algorithsm/periodic_fold.hpp, first the lower, then the upper limit is checked, so here Let's consider the other case: box_l-epsilon is < box_l so the folding code does nothing, the coordinate is already folded. So as I understand it, Algorithm::periodic_fold() is correct in all cases. Can someone please double check this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the code changes and all arguments made.
Still, a cpp unit test for algorithm/periodic_fold that explicitly tests the cases mentioned in @RudolfWeeber's comment would support the argument better than my agreement.
Also the python test could look not only at the fact that the particle is coupled, but also could check that the particle is coupled correctly, i.e. momentum conserving.
@RudolfWeeber's argument on the periodic folding w.r.t. roundoff errors is supported by the C++ unit tests: espresso/src/core/unit_tests/periodic_fold_test.cpp Lines 101 to 110 in 2d65667
Here res.first (position) is 0.0 and res.second (image box count) is 0, so the folding was applied twice. This test also checks for the case box+epsilon, and for a non-zero image box counter.
|
…spressomd#4827) Fixes espressomd#4825 Description of changes: * Bugfix: particles outside the simulation box are now properly coupled using PBC. The coordinates are folded before considering shifted positions in the LB particle coupling code. Also, a test that fails without the fix is added. To my understanding, if the particle position is folded, and then all combination of `folded_pos[i]` +/- `box_l[i]` for all Cartesian directions are considered, both the particle in the primary box and all potential halo regions are caught.
Fixes #4825
Description of changes:
folded_pos[i]
+/-box_l[i]
for all Cartesian directions are considered, both the particle in the primary box and all potential halo regions are caught.