MDAnalysis / mdanalysis

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

Cannot read default LAMMPS H5MD file out of the box due to lack of `units` tag #4722

Open hmacdope opened 3 weeks ago

hmacdope commented 3 weeks ago

Expected behavior

We are not necessarily doing anything wrong, but just notifying people that we cannot read H5MD files produced by LAMMPS out of the box. LAMMPS does not use the units tag in the H5MD spec, meaning you must specify convert_units=False

Code to reproduce the behaviour

Have the following in LAMMPS input file

write_data system.data
dump h5md1 all h5md 100 dump.h5md position velocity force
import MDAnalysis as mda
u = mda.Universe("system.data", "dump.h5md", atom_style='id type x y z', convert_units=True)

whereas the below will work,

import MDAnalysis as mda
u = mda.Universe("system.data", "dump.h5md", atom_style='id type x y z', convert_units=False)

The resulting system will have units of whatever LAMMPS unit style you chose.

Current version of MDAnalysis

2.8.0dev0

orbeckst commented 1 day ago

Good to know, perhaps we should just mention it in the docs for any LAMMPS users. We could also make the error message be clearer.

Reading through the H5MD Units spec

The datasets of any H5MD element that have a physical dimension may carry an attribute unit to indicate the physical unit of the respective data.

it is a may so LAMMPS is adhering to the standard.