Skip to content

Commit

Permalink
Remove code duplication in non-bonded interactions test (#4199)
Browse files Browse the repository at this point in the history
Fixes #4168

Description of changes:
- remove code duplication in test of non-bonded interactions (except Gay-Berne potential) by using a common test function run_test
  • Loading branch information
kodiakhq[bot] authored Apr 8, 2021
2 parents 157a048 + d3745f0 commit d9b112e
Show file tree
Hide file tree
Showing 3 changed files with 233 additions and 529 deletions.
56 changes: 28 additions & 28 deletions testsuite/python/constraint_shape_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ def test_cylinder(self):
espressomd,
cutoff=2.0,
offset=0.,
eps=1.0,
sig=1.0,
epsilon=1.0,
sigma=1.0,
r=1.02),
places=10) # minus for Newton's third law

Expand All @@ -427,8 +427,8 @@ def test_cylinder(self):
espressomd,
cutoff=2.0,
offset=0.,
eps=1.0,
sig=1.0,
epsilon=1.0,
sigma=1.0,
r=dist_part2))

# Test the geometry of a cylinder with top and bottom
Expand Down Expand Up @@ -531,8 +531,8 @@ def test_spherocylinder(self):
espressomd,
cutoff=2.0,
offset=0.,
eps=1.0,
sig=1.0,
epsilon=1.0,
sigma=1.0,
r=1.02),
places=10) # minus for Newton's third law

Expand All @@ -547,7 +547,7 @@ def test_spherocylinder(self):
self.assertAlmostEqual(outer_cylinder_constraint.total_normal_force(),
2 * tests_common.lj_force(
espressomd, cutoff=2.0, offset=0.,
eps=1.0, sig=1.0, r=dist_part2))
epsilon=1.0, sigma=1.0, r=dist_part2))

# Reset
system.part.clear()
Expand Down Expand Up @@ -653,8 +653,8 @@ def test_wall_forces(self):
espressomd,
cutoff=2.0,
offset=0.,
eps=1.0,
sig=1.0,
epsilon=1.0,
sigma=1.0,
r=1.21),
places=10)
self.assertAlmostEqual(
Expand All @@ -663,8 +663,8 @@ def test_wall_forces(self):
espressomd,
cutoff=2.0,
offset=0.,
eps=1.5,
sig=1.0,
epsilon=1.5,
sigma=1.0,
r=0.83),
places=10)

Expand All @@ -675,8 +675,8 @@ def test_wall_forces(self):
espressomd,
cutoff=2.0,
offset=0.,
eps=1.0,
sig=1.0,
epsilon=1.0,
sigma=1.0,
r=1.21),
places=10) # minus for Newton's third law
self.assertAlmostEqual(
Expand All @@ -685,8 +685,8 @@ def test_wall_forces(self):
espressomd,
cutoff=2.0,
offset=0.,
eps=1.5,
sig=1.0,
epsilon=1.5,
sigma=1.0,
r=0.83),
places=10)

Expand All @@ -697,8 +697,8 @@ def test_wall_forces(self):
espressomd,
cutoff=2.0,
offset=0.,
eps=1.5,
sig=1.0,
epsilon=1.5,
sigma=1.0,
r=0.83),
places=10)

Expand Down Expand Up @@ -814,8 +814,8 @@ def test_rhomboid(self):
espressomd,
cutoff=2.,
offset=0.,
eps=1.,
sig=1.,
epsilon=1.,
sigma=1.,
r=1.),
places=10)
self.assertAlmostEqual(
Expand All @@ -824,8 +824,8 @@ def test_rhomboid(self):
espressomd,
cutoff=2.,
offset=0.,
eps=1.,
sig=1.,
epsilon=1.,
sigma=1.,
r=1.),
places=10)

Expand Down Expand Up @@ -914,8 +914,8 @@ def test_rhomboid(self):
espressomd,
cutoff=2.,
offset=0.,
eps=1.,
sig=1.,
epsilon=1.,
sigma=1.,
r=1.),
places=10)

Expand All @@ -929,8 +929,8 @@ def test_rhomboid(self):
espressomd,
cutoff=2.,
offset=0.,
eps=1.,
sig=1.,
epsilon=1.,
sigma=1.,
r=1.2247448714),
places=10)

Expand Down Expand Up @@ -980,8 +980,8 @@ def test_torus(self):
espressomd,
cutoff=2.0,
offset=0.,
eps=1.0,
sig=1.0,
epsilon=1.0,
sigma=1.0,
r=torus_constraint.min_dist()),
places=10)

Expand All @@ -993,7 +993,7 @@ def test_torus(self):

self.assertAlmostEqual(torus_wall.total_force()[1], 0.0)
self.assertAlmostEqual(torus_wall.total_normal_force(), 2 * tests_common.lj_force(
espressomd, cutoff=2.0, offset=0., eps=1.0, sig=1.0,
espressomd, cutoff=2.0, offset=0., epsilon=1.0, sigma=1.0,
r=radius - tube_radius - part_offset))

# Test the geometry of the shape directly
Expand Down
Loading

0 comments on commit d9b112e

Please sign in to comment.