Hi,
I am trying to calculate energies of small molecules using a python script driving lammps.
I have more than 60000 molecules, each molecule is in a separate data file.
My python script is something like this:
def runlammps(datafile,ffield):
typeorder = ’ C H O N ’
lmp = lammps() #cmdargs=["-screen",“none”])
lmp.command(“units real”)
lmp.command(“boundary p p p”)
lmp.command(“atom_style charge”)
lmp.command("read_data s " datafile)
lmp.command(“pair_style reax/c NULL safezone 1.8 mincap 400”)
lmp.command("pair_coeff * * %s s" (ffield, typeorder))
lmp.command(“neighbor 2 bin”)
lmp.command(“neigh_modify every 10 delay 0 check no”)
lmp.command(“fix fqeq all qeq/reax 1 0.0 10.0 1e-6 reax/c”)
lmp.command(“timestep 0.25”)
lmp.command(‘run 1’)
en = lmp.get_thermo(‘etotal’)
lmp.command(‘clear’)
return lmp,en
and calling runlammps function from main():
for i in range(2000):
print(i)
filename = filenames[i]
lmp,en = runlammps(filename,ffield)
lmp.close()
del lmp
After calculating energies I close lammps instance and even deleting it however after reading 1000 molecules it throws this error:
LAMMPS (14 Dec 2021)
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
using 1 OpenMP thread(s) per MPI task
ERROR: Cannot open file reax_14098196.lmp: Too many open files (src/read_data.cpp:333)
Last command: read_data reax_14098196.lmp
The operating system does not allow more than 1024 files open at the same time. However lmp.close() should also close any open files right?
I checked the read_data.cpp:333 , it checks platform:isfile_open but that function returns false. Apparently lammps.close() is not closing open files or am I missing something?
dundar
Dundar Yilmaz, Ph.D.
Associate Research Professor
Department of Mechanical Engineering
138 Research East Building
The Pennsylvania State University
University Park, PA 16802