Skip to content

Commit

Permalink
LE: Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RudolfWeeber committed Jul 29, 2024
1 parent 8f3c019 commit 63c73e3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
39 changes: 26 additions & 13 deletions testsuite/python/lees_edwards.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,13 +738,15 @@ def test_le_breaking_bonds(self):
'initial_pos_offset': -np.sqrt(0.1)}

@utx.skipIfMissingFeatures("LENNARD_JONES")
def run_lj_pair_visibility(self):
def run_lj_pair_visibility(self, shear_direction, shear_plane_normal):
"""
Simulate an LJ liquid under linear shear and verify forces.
This is to make sure that no pairs get lost or are outdated
in the short range loop. To have deterministic forces, velocity
capping is used rather than a thermostat.
"""
shear_axis, normal_axis = axis(
shear_direction), axis(shear_plane_normal)
system = self.system
system.part.clear()
system.time = 0
Expand All @@ -753,13 +755,13 @@ def run_lj_pair_visibility(self):
protocol = espressomd.lees_edwards.LinearShear(
shear_velocity=3, initial_pos_offset=5)
system.lees_edwards.set_boundary_conditions(
shear_direction="z", shear_plane_normal="x", protocol=protocol)
shear_direction=shear_direction, shear_plane_normal=shear_plane_normal, protocol=protocol)
system.cell_system.skin = 0.2
system.non_bonded_inter[0, 0].lennard_jones.set_params(
epsilon=1E-6, sigma=1, cutoff=1.2, shift="auto")
system.part.add(
pos=((0.1, 0, 0.0), (-0.8, 0, 0)),
v=((0, 0, 1), (0, 0, -.3)))
pos=(0.1 * normal_axis, -0.8 * normal_axis),
v=(1.0 * shear_axis, -0.3 * shear_axis))
assert np.all(system.part.all().f == 0.)
tests_common.check_non_bonded_loop_trace(self, system)

Expand All @@ -780,19 +782,30 @@ def test_zz_lj_pair_visibility(self):
# check that regular decomposition without fully connected doesn't catch the particle
system = self.system
with self.assertRaises(AssertionError):
system.cell_system.set_regular_decomposition()
self.run_lj_pair_visibility()
system.cell_system.set_regular_decomposition(
fully_connected_boundary=None)
n_nodes = system.cell_system.get_state()["n_nodes"]
system.cell_system.node_grid = [1, n_nodes, 1]
self.run_lj_pair_visibility("x", "y")

for verlet in False, True:
system.cell_system.set_n_square(use_verlet_lists=verlet)
self.run_lj_pair_visibility()
for shear_direction, shear_plane_normal in self.direction_permutations:
system.cell_system.set_n_square(use_verlet_lists=verlet)
self.run_lj_pair_visibility(
shear_direction, shear_plane_normal)

for verlet in False, True:
n_nodes = system.cell_system.get_state()["n_nodes"]
system.cell_system.node_grid = [n_nodes, 1, 1]
system.cell_system.set_regular_decomposition(
fully_connected_boundary={"boundary": "x", "direction": "z"}, use_verlet_lists=verlet)
self.run_lj_pair_visibility()
for shear_direction, shear_plane_normal in self.direction_permutations:
system.cell_system.set_regular_decomposition(
fully_connected_boundary=None)
n_nodes = system.cell_system.get_state()["n_nodes"]
normal_axis = axis(shear_plane_normal)
system.cell_system.node_grid = [
n_nodes if normal_axis[i] == 1 else 1 for i in range(3)]
system.cell_system.set_regular_decomposition(
fully_connected_boundary={"boundary": shear_plane_normal, "direction": shear_direction}, use_verlet_lists=verlet)
self.run_lj_pair_visibility(
shear_direction, shear_plane_normal)


if __name__ == "__main__":
Expand Down
5 changes: 4 additions & 1 deletion testsuite/python/regular_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import unittest as ut
import unittest_decorators as utx
import espressomd
import numpy as np
import itertools
Expand Down Expand Up @@ -106,7 +107,8 @@ def test_position_rounding(self):
self.system.part.add(pos=[25, 25, 0])
self.assertEqual(1, len(self.system.part))

def test_00_fully_connected_boundary(self):
@utx.skipIfMissingFeatures("LENNARD_JONES")
def test_fully_connected_boundary(self):
system = self.system
system.part.clear()
if system.cell_system.node_grid[1] != 1:
Expand All @@ -126,6 +128,7 @@ def test_00_fully_connected_boundary(self):
system.cell_system.min_global_cut = system.box_l / 4.1
self.assertEqual(system.cell_system.get_params()[
"fully_connected_boundary"], dict(direction="y", boundary="z"))

# Check that particle visibility
# Place particles on a cubic lattice and use the
# non_bonded_loop_trace() to check that all pairs are seen
Expand Down

0 comments on commit 63c73e3

Please sign in to comment.