From 7f1e6b6f2792c9a72a0b93167052b0d2e00a734c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20Grad?= Date: Mon, 10 Aug 2020 16:54:15 +0200 Subject: [PATCH] testsuite: Test Correlator checkpointing --- testsuite/python/save_checkpoint.py | 18 ++++++++++++------ testsuite/python/test_checkpoint.py | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/testsuite/python/save_checkpoint.py b/testsuite/python/save_checkpoint.py index 1260a9d0715..e9f295e51d3 100644 --- a/testsuite/python/save_checkpoint.py +++ b/testsuite/python/save_checkpoint.py @@ -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), @@ -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) diff --git a/testsuite/python/test_checkpoint.py b/testsuite/python/test_checkpoint.py index 1ebba9fae27..cd65926c95c 100644 --- a/testsuite/python/test_checkpoint.py +++ b/testsuite/python/test_checkpoint.py @@ -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.]])) @@ -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.")