Dear Lammps Users,
I have been trying to use lammps from python. I am interested in getting the neighlist but at every build instance. I saw that for ‘run 1000’ I have about 33 neighlist builds. How do I access all of these 33 builds? I tried providing different indexes to the I have been using the following script:
from lammps import lammps
import numpy as np
lmp = lammps()
lmp.commands_string(“”"
dimension 3
boundary p p p
units lj
atom_style full
read_data finalsystem_mod.config
neighbor 0.3 bin
neigh_modify delay 0 every 1 check yes
newton on
pair_style lj/cut 1.1225
pair_modify shift yes
pair_coeff 1 1 1.0 1.0 1.1225
bond_style fene
bond_coeff 1 30.0 1.5 1.0 1.0
special_bonds fene dihedral no
compute mythermo all temp
thermo_modify temp mythermo
thermo 1000
minimize 0 1.0e-8 1000 10000
reset_timestep 0
velocity all create 1.0 918256121 loop local dist gaussian
dump 1 all dcd 100 trajafter2K_1.dcd
dump_modify 1 unwrap yes
#run 4000
fix traj all nvt temp 1.0 1.0 0.1
timestep 0.001
run 1000
#reset_timestep 0
#================================================================
statistics start
#================================================================
compute cc all chunk/atom molecule
compute comchunk all com/chunk cc
fix 2 all ave/time 5 1 5 c_comchunk[*] file com_005_1.txt mode vector format " %f"
compute property all property/local patom1 patom2
compute pairforce all pair/local dist fx fy fz
dump 2 all local 10 force.dump index c_property[1] c_property[2] c_pairforce[*]
timestep 0.001
run 1000
undump 2
“”")
file = ‘neighlistdata.txt’
nlidx = lmp.find_pair_neighlist(‘lj/cut’)
print(nlidx)
with open(file,‘w’) as f:
nl = lmp.numpy.get_neighlist(nlidx)
print(len(nl))
tags = lmp.extract_atom('id')
print("half neighbor list with {} entries".format(nl.size))
# print neighbor list contents
for i in range(0,nl.size):
idx, nlist = nl.get(i)
print("\natom {} with ID {} has {} neighbors:".format(idx,tags[idx],nlist.size))
f.write("\natom {} with ID {} has {} neighbors:".format(idx,tags[idx],nlist.size))
if nlist.size > 0:
for n in np.nditer(nlist):
f.write("\natom {} with ID {}".format(n,tags[n]))
#print(" atom {} with ID {}".format(n,tags[n]))