From 1f5f711d368b001179a70c73c583c5518737bf00 Mon Sep 17 00:00:00 2001 From: jd15489 Date: Tue, 21 Nov 2023 17:20:07 +0000 Subject: [PATCH] Added test for no drift correction Former-commit-id: fac79261737fc1442d4bdef22c3f7d1650191e28 --- kinisi/parser.py | 3 +- kinisi/tests/inputs/example_LAMMPS_drift.data | 23 ++++++ kinisi/tests/inputs/example_LAMMPS_drift.traj | 72 +++++++++++++++++++ kinisi/tests/test_parser.py | 17 +++++ 4 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 kinisi/tests/inputs/example_LAMMPS_drift.data create mode 100644 kinisi/tests/inputs/example_LAMMPS_drift.traj diff --git a/kinisi/parser.py b/kinisi/parser.py index 8c68c93e..5e53341f 100644 --- a/kinisi/parser.py +++ b/kinisi/parser.py @@ -66,6 +66,7 @@ def __init__(self, self.time_step = time_step self.step_skip = step_skip self.indices = indices + self.drift_indices = drift_indices self.memory_limit = memory_limit self.min_dt = min_dt self.max_dt = max_dt @@ -669,7 +670,7 @@ class MDAnalysisParser(Parser): must be set to None for this to function. Molecules can be specificed as a list of lists of indices. This inner lists must all be on the same length. :param masses: Optional, list of masses associated with the indices in specie_indices. Must be same shape as specie_indices. - :param framework_indices: Optional, list of framework indices to be used to correct framework drift. + :param framework_indices: Optional, list of framework indices to be used to correct framework drift. If an empty list is passed no drift correction will be performed. """ def __init__(self, diff --git a/kinisi/tests/inputs/example_LAMMPS_drift.data b/kinisi/tests/inputs/example_LAMMPS_drift.data new file mode 100644 index 00000000..9f73791e --- /dev/null +++ b/kinisi/tests/inputs/example_LAMMPS_drift.data @@ -0,0 +1,23 @@ +9 atoms +2 atom types + +0 10 xlo xhi +0 10 ylo yhi +0 10 zlo zhi + +Masses + +1 1 +2 16 + +Atoms # full + +1 0 1 0.0 5.0 5.0 5.0 0 0 0 +2 0 2 0.0 2.5 2.5 2.5 0 0 0 +3 0 2 0.0 7.5 2.5 2.5 0 0 0 +4 0 2 0.0 2.5 7.5 2.5 0 0 0 +5 0 2 0.0 2.5 2.5 7.5 0 0 0 +6 0 2 0.0 7.5 7.5 2.5 0 0 0 +7 0 2 0.0 7.5 2.5 7.5 0 0 0 +8 0 2 0.0 2.5 7.5 7.5 0 0 0 +9 0 2 0.0 7.5 7.5 7.5 0 0 0 \ No newline at end of file diff --git a/kinisi/tests/inputs/example_LAMMPS_drift.traj b/kinisi/tests/inputs/example_LAMMPS_drift.traj new file mode 100644 index 00000000..3233c142 --- /dev/null +++ b/kinisi/tests/inputs/example_LAMMPS_drift.traj @@ -0,0 +1,72 @@ +ITEM: TIMESTEP +0 +ITEM: NUMBER OF ATOMS +9 +ITEM: BOX BOUNDS pp pp pp +0 10 +0 10 +0 10 +ITEM: ATOMS id type xs ys zs +1 1 0.5 0.5 0.5 +2 2 0.25 0.25 0.25 +3 2 0.75 0.25 0.25 +4 2 0.25 0.75 0.25 +5 2 0.25 0.25 0.75 +6 2 0.75 0.75 0.25 +7 2 0.75 0.25 0.75 +8 2 0.25 0.75 0.75 +9 2 0.75 0.75 0.75 +ITEM: TIMESTEP +1 +ITEM: NUMBER OF ATOMS +9 +ITEM: BOX BOUNDS pp pp pp +0 10 +0 10 +0 10 +ITEM: ATOMS id type xs ys zs +1 1 0.5 0.5 0.5 +2 2 0.23 0.23 0.23 +3 2 0.73 0.23 0.23 +4 2 0.23 0.73 0.23 +5 2 0.23 0.23 0.73 +6 2 0.73 0.73 0.23 +7 2 0.73 0.23 0.73 +8 2 0.23 0.73 0.73 +9 2 0.73 0.73 0.73 +ITEM: TIMESTEP +2 +ITEM: NUMBER OF ATOMS +9 +ITEM: BOX BOUNDS pp pp pp +0 10 +0 10 +0 10 +ITEM: ATOMS id type xs ys zs +1 1 0.5 0.5 0.5 +2 2 0.21 0.21 0.21 +3 2 0.71 0.21 0.21 +4 2 0.21 0.71 0.21 +5 2 0.21 0.21 0.71 +6 2 0.71 0.71 0.21 +7 2 0.71 0.21 0.71 +8 2 0.21 0.71 0.71 +9 2 0.71 0.71 0.71 +ITEM: TIMESTEP +3 +ITEM: NUMBER OF ATOMS +9 +ITEM: BOX BOUNDS pp pp pp +0 10 +0 10 +0 10 +ITEM: ATOMS id type xs ys zs +1 1 0.5 0.5 0.5 +2 2 0.15 0.15 0.15 +3 2 0.65 0.15 0.15 +4 2 0.15 0.65 0.15 +5 2 0.15 0.15 0.65 +6 2 0.65 0.65 0.15 +7 2 0.65 0.15 0.65 +8 2 0.15 0.65 0.65 +9 2 0.65 0.65 0.65 diff --git a/kinisi/tests/test_parser.py b/kinisi/tests/test_parser.py index 818d4e56..bf506a4f 100644 --- a/kinisi/tests/test_parser.py +++ b/kinisi/tests/test_parser.py @@ -209,6 +209,23 @@ def test_mda_init_with_COM(self): assert_almost_equal(data.step_skip, 1) assert_equal(data.indices, [0]) assert_almost_equal(data.coords_check, [[[0.382421597, 0.2087361, 0.2]]]) + + def test_mda_inti_with_empty_framwork_indices(self): + xd = mda.Universe(os.path.join(os.path.dirname(kinisi.__file__), 'tests/inputs/example_LAMMPS_drift.data'), + os.path.join(os.path.dirname(kinisi.__file__), 'tests/inputs/example_LAMMPS_drift.traj'), + topology_format='DATA', + format='LAMMPSDUMP') + da_params = { + 'specie': '1', + 'time_step': 1, + 'step_skip': 1, + 'framework_indices':[] + } + data = parser.MDAnalysisParser(xd, **da_params) + assert_almost_equal(data.time_step, 1) + assert_almost_equal(data.step_skip, 1) + assert_equal(data.indices, [0]) + assert_equal(data.drift_indices, []) def test_get_matrix(self): matrix = parser._get_matrix([10, 10, 10, 90, 90, 90])