Skip to content

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

@shadowater

Description

@shadowater

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions