MDAnalysis / mdanalysis

MDAnalysis is a Python library to analyze molecular dynamics simulations.
https://mdanalysis.org
Other
1.29k stars 647 forks source link

LAMMPSParser cannot read DATA file with "pair ij" #3336

Open amirhs1 opened 3 years ago

amirhs1 commented 3 years ago

Expected behavior

MDAnalysis recognizes both Pair Coeffs (the default pair ii setting in Lammps's write_data command) and PairIJ Coeffs (the pair ij setting Lammps's write_data command ) sections in a Lammps data file.

Actual behavior

Currently, MDAnalysis cannot recognize the PairIJ Coeffs. The MDAnalysis.topology.LAMMPSParser source code does not have a PairIJ Coeffs token in the list of the tokens defined by the variable SECTIONS.

Code to reproduce the behavior

import MDAnalysis as mda
from glob import glob

data_pair_ii_default = glob("./coeffs_ii_default.data")
u_ok = mda.Universe(data_pair_ii_default[0])

data_pair_ij = glob("./coeffs_ij.data")
u_error = mda.Universe(data_pair_ij[0])

Current version of MDAnalysis

coeffs_ii_default.data.txt coeffs_ij.data.txt

orbeckst commented 3 years ago

Can you please clarify what you need MDAnalysis to do?

Does write pair ij write force field coefficients to the data file and are you looking to obtain these coefficients through MDAnalysis?

mnmelo commented 3 years ago

I have no experience with LAMMPS, but took a look at the code and docs. It seems that the LAMMPS parser has an incomplete set (SECTIONS) of possible sections names. From what I could glean, and according to the docs pointed to by @amirhs1, there should be a section name "PairsIJ Coeffs".

Additionally, the header "Pairs LJCoeffs" that is in the list of parseable sections does not seem (from some quick googling) to actually be a LAMMPS name. Maybe it was mistakenly included instead of "PairsIJ Coeffs"? In any case, even if this really is a wrong name in SECTIONS it shouldn't be a problem, because they seem to just be markers for what counts as a section.

@richardjgowers might want to chip in further, as he was the last to touch that part of the code.

In any case, updating the set of SECTIONS to include "PairsIJ Coeffs" should allow for proper parsing of these cases. (I don't think MDA does anything with the interpretation of their actual values, but I might be wrong). Would you like to try and fix this, @amirhs1?

Incidentally, we don't seem to have any LAMMPS test files that use PairsIJ Coeffs. A new one should be added to the test set.

amirhs1 commented 3 years ago

Can you please clarify what you need MDAnalysis to do?

Does write pair ij write force field coefficients to the data file and are you looking to obtain these coefficients through MDAnalysis?

Yes, these are the force field coefficient written to the data file. I do not want to use them directly in my analysis; however, I want use the topology defined in the data file.