Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package/MDAnalysis/coordinates/DLPoly.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def _read_first_frame(self):
if has_vels:
velocities = np.array(velocities, dtype=np.float32)
if has_forces:
forces = np.array(forces, dtype=np.float32)
forces = np.array(forces, dtype=np.float32) / 100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment above this line stating that forces in DL_POLY are 10 J/(mol.Å) and mention issue #2393 — this is weird enough to warrant a hint for future coders

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we should not just divide by 100 here. Instead we should use the normal conversion machinery where you store the native force units in _DLPOLY_UNITS and store the conversion factor in units, then use convert_from_native.

See also https://userguide.mdanalysis.org/stable/units.html .

self.n_atoms = len(coords)

if ids:
Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/coordinates/TRZ.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,4 +605,4 @@ def close(self):
if self.trzfile is None:
return
self.trzfile.close()
self.trzfile = None
self.trzfile = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just undo

6 changes: 4 additions & 2 deletions testsuite/MDAnalysisTests/coordinates/test_dlpoly.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ def test_velocities(self, ts):
ref = np.array([1.056610291, -1.218664448, 3.345828610])
assert_allclose(ts._velocities[0], ref)

# modified to original numbers / 100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment – we can always look in the git blame to find out when something was changed

def test_forces(self, ts):
ref = np.array([-1979.558687, 739.7961625, 1027.996603])
ref = np.array([-19.79558687, 7.397961625, 10.27996603])
assert_allclose(ts._forces[0], ref)


Expand Down Expand Up @@ -118,8 +119,9 @@ def test_vel(self, u):
ref = np.array([2.637614561, 0.5778767520e-01, -1.704765568])
assert_allclose(u.atoms[2].velocity, ref)

# modified to original numbers / 100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

Copy link
Member

@cbouy cbouy Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def test_for(self, u):
ref = np.array([150.3309776, -812.6932914, 1429.413120])
ref = np.array([1.503309776, -8.126932914, 14.29413120])
assert_allclose(u.atoms[2].force, ref)

def test_number(self, u):
Expand Down
Loading