Skip to content

Commit

Permalink
testsuite: Test for initial forces thermostat application
Browse files Browse the repository at this point in the history
  • Loading branch information
fweik committed Nov 28, 2019
1 parent 2e4f50d commit 9c4b4e9
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions testsuite/python/langevin_thermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,16 @@ def test_03__friction_rot(self):
np.copy(system.part[0].omega_body),
o0 * np.exp(-gamma_r_i / rinertia * system.time), atol=5E-4)

def test_04__global_langevin(self):
"""Test for global Langevin parameters."""
def check_global_langevin(self, recalc_forces, loops):
"""Test velocity distribution for global Langevin parameters.
Parameters
----------
recalc_forces : :obj:`bool`
True if the forces should be recalculated after every step.
loops : :obj:`int`
Number of sampling loops
"""
N = 200
system = self.system
system.part.clear()
Expand All @@ -208,11 +216,10 @@ def test_04__global_langevin(self):
system.integrator.run(20)

# Sampling
loops = 150
v_stored = np.zeros((N * loops, 3))
omega_stored = np.zeros((N * loops, 3))
for i in range(loops):
system.integrator.run(1)
system.integrator.run(1, recalc_forces=recalc_forces)
v_stored[i * N:(i + 1) * N, :] = system.part[:].v
if espressomd.has_features("ROTATION"):
omega_stored[i * N:(i + 1) * N, :] = system.part[:].omega_body
Expand All @@ -226,6 +233,16 @@ def test_04__global_langevin(self):
self.check_velocity_distribution(
omega_stored, v_minmax, bins, error_tol, kT)

def test_global_langevin(self):
"""Test velocity distribution for global Langevin parameters."""
self.check_global_langevin(False, loops=150)

def test_global_langevin_initial_forces(self):
"""Test velocity distribution for global Langevin parameters,
when using the initial force calculation.
"""
self.check_global_langevin(True, loops=170)

@utx.skipIfMissingFeatures("LANGEVIN_PER_PARTICLE")
def test_05__langevin_per_particle(self):
"""Test for Langevin particle. Covers all combinations of
Expand Down

0 comments on commit 9c4b4e9

Please sign in to comment.