Skip to content
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

Rhomboid test case is unstable #4853

Open
jngrad opened this issue Jan 23, 2024 · 0 comments
Open

Rhomboid test case is unstable #4853

jngrad opened this issue Jan 23, 2024 · 0 comments
Labels

Comments

@jngrad
Copy link
Member

jngrad commented Jan 23, 2024

The test case ShapeBasedConstraintTest.test_rhomboid in testsuite/python/constraint_shape_based.py is failing on architectures that don't have extended precision, namely ARM64 and POWER9. The test works by creating a cuboid and probing the distance between the cuboid and a particle at different positions on a 3D grid and making sure the distance vector calculated in ESPResSo matches the distance vector calculated in Python. Then a much simpler test is carried out on a rhombohedron.

To start the investigation, one should look for low-hanging fruits, such as numerical instabilities when a particle lands exactly on a corner, edge, or face of the cuboid. This happens when the lattice on which the distance vector is checked coincide with one or more of the 8 corners of the cuboid. In this case, the Python test case will take a different branch depending on whether the particle is inside or outside the cuboid, but Python and C++ don't always propagate rounding errors in the same way, and thus may disagree on whether the particle is inside or outside, which changes how the distance vector is calculated. To avoid that, one typically adds a small offset to the particle position, so that there never is a zero-component in the distance vector.

This is where the test fails on ARM64:

 31/201 Test  #31: constraint_shape_based ........................................***Failed    1.24 sec
...F......
======================================================================
FAIL: test_rhomboid (__main__.ShapeBasedConstraintTest.test_rhomboid)
Checks that rhomboid constraints with LJ interactions exert forces
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/espresso/mpich/testsuite/python/constraint_shape_based.py", line 914, in test_rhomboid
    self.assertAlmostEqual(shape_dist_vec[1], dist_vec[1])
AssertionError: -9.0 != -3.0 within 7 places (6.0 difference)
----------------------------------------------------------------------
Ran 10 tests in 0.784s
FAILED (failures=1)
@jngrad jngrad added the Python label Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant