Skip to content

Commit 08cf96f

Browse files
authored
Add 'PairIJ Coeffs' section to the list of sections in LAMMPS parser (#3959)
* Add 'PairIJ Coeffs' section to the list of sections in LAMMPS parser. This ensures correct processing of LAMMPS data files * Updating AUTHORS and CHANGELOG * Adding a simple test * Revert "Adding a simple test" This reverts commit 383423f. The test needs to be integrated into the test_lammpsdata.py instead of a separate script, and the sample datafile needs to be placed in the appropriate directory. * Adding test for LAMMPS PairIJ Coeffs file to test_lammpsdata * Revert "Adding test for LAMMPS PairIJ Coeffs file to test_lammpsdata" This reverts commit 8269b20. * Adding the zipped test datafile and class * Implementing requested changes * Bugfix to pass the tests; adding whitespace to pass darker lint * Bugfix * Merging * Remove a duplicate record due to a merging mess * Fixing the format * Fixing the PEP8 violation
1 parent 8d43073 commit 08cf96f

6 files changed

Lines changed: 28 additions & 1 deletion

File tree

package/AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ Chronological list of authors
201201
- Jake Fennick
202202
- Utsav Khatu
203203
- Patricio Barletta
204+
- Mikhail Glagolev
204205

205206

206207
External code

package/CHANGELOG

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ The rules for this file:
1313
* release numbers follow "Semantic Versioning" http://semver.org
1414

1515
------------------------------------------------------------------------------
16-
??/??/?? IAlibay, pgbarletta
16+
??/??/?? IAlibay, pgbarletta, mglagolev
1717

1818
* 2.5.0
1919

2020
Fixes
21+
* Add 'PairIJ Coeffs' to the list of sections in LAMMPSParser.py
22+
(Issue #3336)
2123

2224
Enhancements
2325

package/MDAnalysis/topology/LAMMPSParser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
'Impropers',
120120
'Pair',
121121
'Pair LJCoeffs',
122+
'PairIJ Coeffs',
122123
'Bond Coeffs',
123124
'Angle Coeffs',
124125
'Dihedral Coeffs',
51.4 KB
Binary file not shown.

testsuite/MDAnalysisTests/datafiles.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
"LAMMPShyd", "LAMMPShyd2",
143143
"LAMMPSdata_deletedatoms", # with deleted atoms
144144
"LAMMPSdata_triclinic", # lammpsdata file to test triclinic dimension parsing, albite with most atoms deleted
145+
"LAMMPSdata_PairIJ", # lammps datafile with a PairIJ Coeffs section
145146
"LAMMPSDUMP",
146147
"LAMMPSDUMP_long", # lammpsdump file with a few zeros sprinkled in the first column first frame
147148
"LAMMPSDUMP_allcoords", # lammpsdump file with all coordinate conventions (x,xs,xu,xsu) present, from LAMMPS rdf example
@@ -513,6 +514,7 @@
513514
LAMMPShyd2 = resource_filename(__name__, "data/lammps/hydrogen-class1.data2")
514515
LAMMPSdata_deletedatoms = resource_filename(__name__, 'data/lammps/deletedatoms.data')
515516
LAMMPSdata_triclinic = resource_filename(__name__, "data/lammps/albite_triclinic.data")
517+
LAMMPSdata_PairIJ = resource_filename(__name__, "data/lammps/pairij_coeffs.data.bz2")
516518
LAMMPSDUMP = resource_filename(__name__, "data/lammps/wat.lammpstrj.bz2")
517519
LAMMPSDUMP_long = resource_filename(__name__, "data/lammps/wat.lammpstrj_long.bz2")
518520
LAMMPSDUMP_allcoords = resource_filename(__name__, "data/lammps/spce_all_coords.lammpstrj.bz2")

testsuite/MDAnalysisTests/topology/test_lammpsdata.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
LAMMPSdata_deletedatoms,
3737
LAMMPSDUMP,
3838
LAMMPSDUMP_long,
39+
LAMMPSdata_PairIJ,
3940
)
4041

4142

@@ -179,6 +180,26 @@ def test_traj(self, filename):
179180
dtype=np.float32))
180181

181182

183+
class TestLammpsDataPairIJ(LammpsBase):
184+
"""Tests the reading of lammps .data topology file with a
185+
PairIJ Coeffs section
186+
"""
187+
188+
expected_attrs = ['types', 'resids', 'masses',
189+
'bonds', 'angles', 'dihedrals', 'impropers']
190+
ref_filename = LAMMPSdata_PairIJ
191+
expected_n_atoms = 800
192+
expected_n_atom_types = 2
193+
expected_n_residues = 1
194+
ref_n_bonds = 799
195+
ref_bond = (397, 398)
196+
ref_n_angles = 390
197+
ref_angle = (722, 723, 724)
198+
ref_n_dihedrals = 385
199+
ref_dihedral = (722, 723, 724, 725)
200+
ref_n_impropers = 0
201+
202+
182203
LAMMPS_NORESID = """\
183204
LAMMPS data file via write_data, version 11 Aug 2017, timestep = 0
184205

0 commit comments

Comments
 (0)