I just want use lammps to calculate the energy of 280 small molecular and I use the newest stable version of lammps.I try to accomplish my goalthrough python.Here is the code of one of critical function in my code.
from lammps import PyLammps
from lammps import lammps
lmp = lammps()
L = PyLammps(ptr=lmp)
def cal_energy(ff_name, data_list):
erg_list = [0 for x in range(0,len(data_list))]
for i in range(0,len(data_list)) :
L.command("log none") L.boundary("f f f")
L.command("fix 1 all qeq/reax 1 0.0 10.0 1e-6 reax/c")
erg_list[i] = L.eval("etotal")
This simple function aims to get energy under reaxff of each molecular in data_list,and it gives back the energy in a list .
It works well at the beginning part,but as time goes by,the time of each cycle become longer and longer.The first cycle just spend 2-3 senconds.In 500th cycle it will spend nearly 15 seconds.
Is there any thing wrong in my code?How can I solve this problem?
Thanks and Regards
This seems like it could either be a problem with LAMMPS (e.g. memory leak) or with
the Python wrapper on LAMMPS or with the rest of your Python code (e,g, consuming memory).
To check the first issue, I suggest you just write a LAMMPS input script that
performs these same commands in a loop. You could read from a list of 500 data files
with a variable. Or if they are all similar, you could just read the same file 500 times.
If that works fine, it’s one of the other 2 issues.