[Python] How can I access the original xlo/xhi box bounds from a LAMMPS dump file using...

Discussão em 'Python' iniciado por Stack, Abril 14, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working with a LAMMPS trajectory in MDAnalysis using the default LAMMPSDUMP format, like this:

    import MDAnalysis as mda
    u = mda.Universe("datfile.data", "dump.LAMMPSDUMP")


    In my LAMMPS dump file, the box bounds are written explicitly and do not start at '0', for example:

    ITEM: TIMESTEP
    0
    ITEM: NUMBER OF ATOMS
    2197
    ITEM: BOX BOUNDS pp pp pp
    1.7831079224879716e+00 3.3421689207745555e+02
    1.7831079224879716e+00 3.3421689207745555e+02
    1.7831079224879716e+00 3.3421689207745555e+02
    ITEM: ATOMS id type x y z vx vy vz


    However, when I access u.trajectory.ts.dimensions, I only get the box lengths,

    332.43378, 332.43378, 332.43378, 90. , 90. , 90.

    MDAnalysis assumes that the box starts at zero and is giving me the length along X,Y and Z. This causes issues when I'm trying to re-center atoms. Is there a way to access the actual xlo, xhi, etc. values from within MDAnalysis (e.g., something like u.trajectory.ts.xlo)? Or do I have to manually parse the dump file to retrieve these values?

    Thanks !

    Continue reading...

Compartilhe esta Página