Skip to content

Commit

Permalink
Convert "Quantity" to raw value for kinetic_energy and potential_ener…
Browse files Browse the repository at this point in the history
…gy in OpenMM reader (#4548)

* Convert "Quantity" to raw value for kinetic_energy and potential_energy in OpenMMSimulationReader.
  • Loading branch information
orionarcher committed Mar 31, 2024
1 parent a2a27aa commit 93630da
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package/CHANGELOG
Expand Up @@ -16,11 +16,12 @@ The rules for this file:
-------------------------------------------------------------------------------
??/??/?? IAlibay, HeetVekariya, marinegor, lilyminium, RMeli,
ljwoods2, aditya292002, pstaerk, PicoCentauri, BFedder,
tyler.je.reddy, SampurnaM, leonwehrhan, kainszs
tyler.je.reddy, SampurnaM, leonwehrhan, kainszs, orionarcher

* 2.8.0

Fixes
* Convert openmm Quantity to raw value for KE and PE in OpenMMSimulationReader.
* Atomname methods can handle empty groups (Issue #2879, PR #4529)
* Add support for TPR files produced by Gromacs 2024.1 (PR #4523)
* Remove mutable data from ``progressbar_kwargs`` argument in ``AnalysisBase.run()``
Expand Down
4 changes: 2 additions & 2 deletions package/MDAnalysis/converters/OpenMM.py
Expand Up @@ -125,10 +125,10 @@ def _mda_timestep_from_omm_context(self):
ts.frame = 0
ts.data["time"] = state.getTime()._value
ts.data["potential_energy"] = (
state.getPotentialEnergy().in_units_of(u.kilojoule/u.mole)
state.getPotentialEnergy().in_units_of(u.kilojoule/u.mole)._value
)
ts.data["kinetic_energy"] = (
state.getKineticEnergy().in_units_of(u.kilojoule/u.mole)
state.getKineticEnergy().in_units_of(u.kilojoule/u.mole)._value
)
ts.triclinic_dimensions = state.getPeriodicBoxVectors(
asNumpy=True)._value
Expand Down
5 changes: 5 additions & 0 deletions testsuite/MDAnalysisTests/converters/test_openmm.py
Expand Up @@ -87,6 +87,11 @@ def test_basic_topology(self, omm_sim_uni):
assert omm_sim_uni.segments.segids[0] == '0'
assert len(omm_sim_uni.bonds.indices) == 0

def test_data(self, omm_sim_uni):
data = omm_sim_uni.trajectory.ts.data
assert isinstance(data["kinetic_energy"], float)
assert isinstance(data["potential_energy"], float)


class TestOpenMMPDBFileReader(_SingleFrameReader):
__test__ = True
Expand Down

0 comments on commit 93630da

Please sign in to comment.