Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LAMMPS DumpReader returns incorrect coordinate transform #4788

Open
wjq1228 opened this issue Nov 13, 2024 · 5 comments
Open

LAMMPS DumpReader returns incorrect coordinate transform #4788

wjq1228 opened this issue Nov 13, 2024 · 5 comments
Labels
Component-Readers format-LAMMPS more information needed Please reply to requests for information or the issue will be closed.

Comments

@wjq1228
Copy link

wjq1228 commented Nov 13, 2024

Expected behavior

The coordinate transform of "scaled" LAMMPS trajectory should be imported correctly.

Actual behavior

The MDAnalysis calculated incorrectly coordinates from scaled to unscaled. Calculation method of “scaled” is xs = (x-xlo)/(xhi-xlo). So, when coordinate transform, the coordinate can be calculated by x = (xhi-xlo)*xs + xlo. However, the LAMMPS DumpReader returns incorrect coordinate transform. For example, the scaled coordinate in my dump is

ITEM: TIMESTEP
0
ITEM: NUMBER OF ATOMS
6024
ITEM: BOX BOUNDS pp pp pp
3.3501000000000003e-02 6.2616999999999997e+01
-5.2700000000000002e-01 2.8887000000000000e+01
-1.5000000000000000e+01 4.0000000000000000e+01
ITEM: ATOMS id type xs ys zs
2608 2 0.0407033 0.457803 0.384662

The real coordinate of atom 2608 is [2.58086, 12.9388, 6.15641]. However, the coordinate calculated by DumpReader is [2.513854, 13.992818, 36.15641]. Calculation method of DumpReader seem to be x = (xhi-xlo)*xs - xlo. Other atoms are tested and the same error happened.

Code to reproduce the behavior

import numpy as np
import MDAnalysis as mda
from MDAnalysis.analysis.hydrogenbonds import HydrogenBondAnalysis
from MDAnalysis.analysis import hydrogenbonds

# load system
u = mda.Universe("carbonice3nm.data", "ice.lammpstrj", format="LAMMPSDUMP", lammps_coordinate_convention="scaled", dt=10)

O = u.select_atoms('id 2608')
print(O.positions)

## Current version of MDAnalysis ##

- Which version are you using? (2.8.0)
- Which version of Python? (3.10.0)
- Which operating system? (Windows)
- LAMMPS version 2 Aug 2023
@samkenzo
Copy link

If the coordinate transformation is indeed incorrect, you can manually calculate the coordinates using the correct formula as a workaround until an update is available.
mdsimulation.txt

i have attached the file here see if it works

@wjq1228
Copy link
Author

wjq1228 commented Nov 14, 2024

Very thanks! Looking forward to updates soon!

@samkenzo
Copy link

appreciate it
!

@orbeckst
Copy link
Member

@wjq1228 do you have a reference (eg from the LAMMPS docs) that defines the scaled coordinate transformation?

@orbeckst orbeckst added the more information needed Please reply to requests for information or the issue will be closed. label Nov 20, 2024
@hmacdope
Copy link
Member

We will look into this, concerning if correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component-Readers format-LAMMPS more information needed Please reply to requests for information or the issue will be closed.
Projects
None yet
Development

No branches or pull requests

4 participants