Neighlist Access

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]))

You would have to know when the neighbor list has been rebuilt. By default that is determined dynamically based on how far atoms move. You would have to change settings with neigh_modify to set delay to 0 and check to no so that the value of every will reliably determine when the neighbor list is been recreated. E.g. you could set it to 20 for your case and then break down your run into 50 chunks of 20 steps each (with run 20 pre no post no to reduce redundant work) and then retrieve the neighbor list after a chunk is done before running the next chunk.

Thank you.