mdanalysis icon indicating copy to clipboard operation
mdanalysis copied to clipboard

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

Open hmacdope opened this issue 1 year ago • 2 comments

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

hmacdope avatar Oct 01 '24 11:10 hmacdope

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.

orbeckst avatar Oct 21 '24 20:10 orbeckst

I am labeling this failure as a defect because LAMMPS adheres to the H5MD standard and we should be able to read standard-compliant H5MD files.

orbeckst avatar Dec 19 '24 00:12 orbeckst