extract_atom in LAMMPS as a Python library

Hi all,

I’m using lammps-7Aug2019, built as a library, imported into Python. I want to use the extract_atom function to read in atom ids, types, positions, and velocities (for a non-sequentially tagged system, so I can’t use gather_atoms). I am getting [4.e-310, 4.e-310, 4.e-310] for all coordinates and velocities, and I can’t tell why. I set up a simpler simulation and script (attached), and I still get all 0’s. IDs and types output fine.

Python 3.6.5

Run Command:

mpirun -n 4 --mca btl vader,self python test_lammps.py > out.txt

out.txt (2.98 KB)

in.test_melt (563 Bytes)

test_lammps.py (683 Bytes)

Hi all,

I’m using lammps-7Aug2019, built as a library, imported into Python. I want to use the extract_atom function to read in atom ids, types, positions, and velocities (for a non-sequentially tagged system, so I can’t use gather_atoms). I am getting [4.e-310, 4.e-310, 4.e-310] for all coordinates and velocities, and I can’t tell why. I set up a simpler simulation and script (attached), and I still get all 0’s. IDs and types output fine.

coordinates and velocities are returned as pointers to arrays of pointers to arrays.

thus you have to use:

xp = lmp.extract_atom(“x”, 3)

vp = lmp.extract_atom(“v”, 3)

and

print(me, xp[n][0], xp[n][1], xp[n][2])

print(me, vp[n][0], vp[n][1], vp[n][2])

and it should work fine.

axel.