Skip to content

Commit

Permalink
testsuite: Test Correlator checkpointing
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Aug 10, 2020
1 parent 59ec974 commit 7f1e6b6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
18 changes: 12 additions & 6 deletions testsuite/python/save_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,22 @@
system.actors.add(p3m)

obs = espressomd.observables.ParticlePositions(ids=[0, 1])
acc = espressomd.accumulators.MeanVarianceCalculator(obs=obs)
acc_mean_variance = espressomd.accumulators.MeanVarianceCalculator(obs=obs)
acc_time_series = espressomd.accumulators.TimeSeries(obs=obs)
acc.update()
acc_correlator = espressomd.accumulators.Correlator(
obs1=obs, tau_lin=10, tau_max=2, delta_N=1,
corr_operation="componentwise_product")
acc_mean_variance.update()
acc_time_series.update()
acc_correlator.update()
system.part[0].pos = [1.0, 2.0, 3.0]
acc.update()
acc_mean_variance.update()
acc_time_series.update()
acc_correlator.update()


system.auto_update_accumulators.add(acc)
system.auto_update_accumulators.add(acc_mean_variance)
system.auto_update_accumulators.add(acc_time_series)
system.auto_update_accumulators.add(acc_correlator)

# constraints
system.constraints.add(shape=Sphere(center=system.box_l / 2, radius=0.1),
Expand Down Expand Up @@ -203,8 +208,9 @@
system.bonded_inter.add(thermalized_bond)
system.part[1].add_bond((thermalized_bond, 0))
checkpoint.register("system")
checkpoint.register("acc")
checkpoint.register("acc_mean_variance")
checkpoint.register("acc_time_series")
checkpoint.register("acc_correlator")
# calculate forces
system.integrator.run(0)
particle_force0 = np.copy(system.part[0].f)
Expand Down
14 changes: 12 additions & 2 deletions testsuite/python/test_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,11 @@ def test_virtual_sites(self):

def test_mean_variance_calculator(self):
np.testing.assert_array_equal(
acc.get_mean(), np.array([[1.0, 1.5, 2.0], [1.0, 1.0, 2.0]]))
acc_mean_variance.get_mean(),
np.array([[1.0, 1.5, 2.0], [1.0, 1.0, 2.0]]))
np.testing.assert_array_equal(
acc.get_variance(), np.array([[0., 0.5, 2.], [0., 0., 0.]]))
acc_mean_variance.get_variance(),
np.array([[0., 0.5, 2.], [0., 0., 0.]]))
np.testing.assert_array_equal(
system.auto_update_accumulators[0].get_variance(),
np.array([[0., 0.5, 2.], [0., 0., 0.]]))
Expand All @@ -325,6 +327,14 @@ def test_time_series(self):
system.auto_update_accumulators[1].time_series(),
expected)

def test_correlator(self):
expected = np.zeros((36, 2, 3))
expected[0:2] = [[[1, 2.5, 5], [1, 1, 4]], [[1, 2, 3], [1, 1, 4]]]
np.testing.assert_array_equal(acc_correlator.result(), expected)
np.testing.assert_array_equal(
system.auto_update_accumulators[2].result(),
expected)

@utx.skipIfMissingFeatures('P3M')
@ut.skipIf('P3M.CPU' not in modes,
"Skipping test due to missing combination.")
Expand Down

0 comments on commit 7f1e6b6

Please sign in to comment.