Skip to content

Commit 05ca87c

Browse files
committed
Add method to return current energy trajectory records.
1 parent d6f62cc commit 05ca87c

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

doc/source/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ organisation on `GitHub <https://github.com/openbiosim/sire>`__.
2121
incorrectly for systems containing more than one molecule with CMAP terms (e.g.
2222
multi-chain glycoproteins).
2323

24+
* Add convenience function to ``sire.mol.dynamics`` to get current energy trajectory records.
25+
2426
`2025.4.0 <https://github.com/openbiosim/sire/compare/2025.3.0...2025.4.0>`__ - February 2026
2527
---------------------------------------------------------------------------------------------
2628

src/sire/mol/_dynamics.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,9 @@ def _exit_dynamics_block(
525525
self._current_time, nrgs, {"lambda": str(sim_lambda_value)}
526526
)
527527

528+
# Store the current energies.
529+
self._nrgs = nrgs
530+
528531
# update the interpolation lambda value
529532
if self._is_interpolate:
530533
if delta_lambda:
@@ -861,6 +864,12 @@ def current_kinetic_energy(self):
861864
def energy_trajectory(self):
862865
return self._energy_trajectory.clone()
863866

867+
def current_energies(self):
868+
try:
869+
return self._nrgs
870+
except Exception:
871+
return {}
872+
864873
def step(self, num_steps: int = 1):
865874
"""
866875
Just perform 'num_steps' steps of dynamics, without saving
@@ -2195,6 +2204,12 @@ def energy_trajectory(self, to_pandas: bool = False, to_alchemlyb: bool = False)
21952204
else:
21962205
return t
21972206

2207+
def current_energies(self):
2208+
"""
2209+
Return a dictionary of the most recent energy trajectory entry.
2210+
"""
2211+
return self._d.current_energies()
2212+
21982213
def to_xml(self, f=None):
21992214
"""
22002215
Save the current state of the dynamics to XML.

0 commit comments

Comments
 (0)