Skip to content

Commit

Permalink
Added test for no drift correction
Browse files Browse the repository at this point in the history
Former-commit-id: fac7926
  • Loading branch information
jd15489 committed Nov 21, 2023
1 parent f595da5 commit 1f5f711
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kinisi/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
23 changes: 23 additions & 0 deletions kinisi/tests/inputs/example_LAMMPS_drift.data
Original file line number Diff line number Diff line change
@@ -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
72 changes: 72 additions & 0 deletions kinisi/tests/inputs/example_LAMMPS_drift.traj
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions kinisi/tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 1f5f711

Please sign in to comment.