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

[BUG] Unexpected element order from gro to lammps data file #740

Open
shadowater opened this issue Oct 21, 2024 · 2 comments
Open

[BUG] Unexpected element order from gro to lammps data file #740

shadowater opened this issue Oct 21, 2024 · 2 comments

Comments

@shadowater
Copy link

shadowater commented Oct 21, 2024

Bug summary

I am trying to convert a gro file to a lammps data file using the following command:

import dpdata
data = dpdata.System("test.gro")
data.to_lammps_lmp("test.data")
print(data.get_atom_names())

and I expect to get "['Li', 'Cl', 'P', 'S']" (the order of the elements in the gro file), but I get "['P', 'Cl', 'Li', 'S']" instead. The order of the elements is changed. Even though I could get the correct order by supplying type_map, I still think element order should not be changed by the conversion.

dpdata Version

0.2.21

Input Files, Running Commands, Error Log, etc.

test.gro

Generated with MDTraj, t= 0.0
 4
    1MOL     LI    1   0.254   0.254   0.024
    2MOL     CL    2   0.507   0.000   0.000
    3MOL      P    3   0.507   0.507   0.507
    4MOL     S1    4   0.896   0.389   0.118
   1.01400   1.01400   1.01400   0.00000   0.00000   0.00000   0.00000   0.00000   0.00000

Steps to Reproduce

import dpdata
data = dpdata.System("test.gro")
data.to_lammps_lmp("test.data")
print(data.get_atom_names())

Further Information, Files, and Links

test.data


4 atoms
4 atom types
   0.0000000000   10.1400000000 xlo xhi
   0.0000000000   10.1400000000 ylo yhi
   0.0000000000   10.1400000000 zlo zhi
   0.0000000000    0.0000000000    0.0000000000 xy xz yz

Atoms # atomic

     1      3    2.5400000000    2.5400000000    0.2400000000
     2      2    5.0700000000    0.0000000000    0.0000000000
     3      1    5.0700000000    5.0700000000    5.0700000000
     4      4    8.9600000000    3.8900000000    1.1800000000
@shadowater shadowater added the bug Something isn't working label Oct 21, 2024
@wanghan-iapcm
Copy link
Contributor

does type_map solve the issue?
when type_map is not provided, the order/index of the elements is not guaranteed.

@shadowater
Copy link
Author

Yes, "Even though I could get the correct order by supplying type_map, I still think element order should not be changed by the conversion."

@wanghan-iapcm wanghan-iapcm removed the bug Something isn't working label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants