Skip to content

Convert units of trajectory data when constructing a universe #5115

@jkalayan

Description

@jkalayan

Is your feature request related to a problem?

Reading in trajectory files that combine atomic forces along with positions, the units for forces are automatically converted from kcal/(mol.Ang) to kJ/(mol.Ang) when reading from Amber (.nc) and GROMACS (.trr) combined trajectory files. But this behaviour is not replicated for the LAMMPSDUMP file (with additional_columns=['fx', 'fy', 'fz']), outputted as real units. The forces remain as kcal/(mol.Ang). This causes issues with further analysis of forces, where the units are expected to be in kJ/(mol.Ang).

To replicate the behaviour with mdanalysis>=2.7.0 and python >=3.11:

Topology and trajectory files used:

amber_top_lammpsdump_traj.zip

Universe is constructed from topology and trajectory with:

u = Universe(top_file, traj_file, format="LAMMPSDUMP", additional_columns=['fx', 'fy', 'fz', 'c_5', 'c_7'], units="real")

Where c_5 and c_7 are per-atom potential and kinetic energies respectively, in units kcal/mol.

Describe the solution you'd like

Is it possible to allow manual conversion of units of atomic forces (and even atomic positions, energies, velocities, charges, etc.) at the point of construction of a universe? It is not always practical to convert units frame-by-frame afterwards if a software expects units to not depend on the MD engine used to produce the trajectory.

Allowing the conversion of trajectory terms will give flexibility in populating other atomic terms (such as per-atom energies outputted from LAMMPS) into a universe without having to worry about units when the universe is analysed with other functions/software afterwards.

Alternatively, but not as general, can the LAMMPSDUMP reader be updated to convert forces to kJ/(mol.Ang)?

Describe alternatives you've considered

I can't find another alternative to convert trajectory data units at the point of creating the universe.

Another solution is to add pre-converted auxiliary data (as shown here: https://userguide.mdanalysis.org/stable/formats/auxiliary.html#loading-data-into-a-universe), but this would mean forces have to be accessed via a different method (ts.forces vs ts.aux.forces), therefore not general over all trajectory types.

Additional context

MDAnalysis is used extensively in CodeEntropy to calculate components of entropy at multiple length scales of molecules from the statistics captured from positions and forces outputted from a MD simulation. The forces are expected to be in units of kJ/(mol.Ang) when populated into a mda universe, currently amber and gromacs trajectories are supported, but the inclusion of LAMMPSDUMP files would be helpful as atomic energies are only outputted with LAMMPS and could be very useful to compare with entropies.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions