Skip to content

Inconsistency between LAMMPS cell origin and coordinates #3741

@PicoCentauri

Description

@PicoCentauri

Is your feature request related to a problem?

Simulation cells in MDAnalysis (MDA) are defined via the dimensions attribute
defining the cell via 3 lengths and 3 angles. This implies that the cell origin is always at
(0,0,0).

LAMMPS defines its simulation cells via a lower and an upper coordinate, allowing the cell origin not to be at (0,0,0). The LAMMPS approach allows for negative coordinates still in the primary unit cell.

MDA parse LAMMPS cells and converts the box vector according to

def _parse_box(self, header):
x1, x2 = np.float32(header['xlo xhi'].split())
x = x2 - x1
y1, y2 = np.float32(header['ylo yhi'].split())
y = y2 - y1
z1, z2 = np.float32(header['zlo zhi'].split())
z = z2 - z1

shifting the cell origin to (0,0,0). However, in MDA the cell origin is moved to (0,0,0) but the coordinates are not. This is an inconsistency for example that negative coordinates are not in the primary unit cell anymore.

EDIT: I would like to give a practical example: If I have an unwrapped data file (molecules are whole) and I would like to histogram the center of masses along an axis. For the histogram I have to know the range of the box which goes from 0 to L. Whole molecules outside the box, with a negative, center of mass will not be considered even though they are in the primary unit cell in LAMMPS.

Describe the solution you'd like

Sift coordinates like the cell origin by the lower cell coordinate. See this commit for an idea.

Describe alternatives you've considered

Shift coordinates by 'hand' every time loading a LAMMPS data file with negative coordinates.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions