Dear All,
I have been attempting to use ‘gather_atoms’ via LAMMPS’ python interface to extract the image flags for each atom. Unfortunately, when I invoke the command lmp.gather_atoms(“image”,0,3), I immediately get a segmentation fault. Calls such as lmp.gather_atoms(“x”,1,3) and lmp.gather_atoms(“v”,1,3), however, work fine.
I was wondering if anyone has any suggestions regarding what I might be doing wrong. I am using the 17 NOV 16 build of LAMMPS, and my test inputs are below.
Thanks in advance.
Best,
JC
test.py:
from ctypes import *
from lammps import lammps
lmp = lammps()
Load script/data
lmp.file(“in.nve”)
Get initial system properties
natoms = lmp.extract_global(“natoms”,0)
x = ((3*natoms)c_double)()
v = ((3natoms)c_double)()
image = ((3natoms)*c_int)()
mass = lmp.extract_atom(“mass”,2)
atomid = lmp.gather_atoms(“id”,0,1)
atype = lmp.gather_atoms(“type”,0,1)
x = lmp.gather_atoms(“x”,1,3)
v = lmp.gather_atoms(“v”,1,3)
image = lmp.gather_atoms(“image”,0,3)
for i in range(3*natoms):
print i,x[i],v[i],image[i]
in.nve:
Units and atom style
units real
atom_style atomic
Needs to be here to get atom order correct with gather and scatter
atom_modify map array sort 0 0.0
Read
read_data in.dat
Pair info
pair_style sw
pair_coeff * * mW.sw W
Neighbor list
neighbor 2.5 bin
neigh_modify every 5 delay 0 check yes
Integrator and time step
fix 2 all nve
timestep 18.0
run 0
in.dat:
LAMMPS data file via write_data, version 17 Nov 2016, timestep = 159200
1 atoms
1 atom types
0.0000000000000000e+00 2.485700000e+01 xlo xhi
0.0000000000000000e+00 2.48570000e+01 ylo yhi
0.0000000000000000e+00 2.48570000e+01 zlo zhi
Masses
1 18.0153
Atoms # atomic
1 1 0.000 0.000 0.000 0 0 0