getting thermo with PyLammps from a rerun command

Dear all,

I would like to see how the energy of my trajectory configurations change when changing some force field parameters. I thought using PyLammps was a convenient way as I am familiar with Python.

My idea was to use L.pair_coeff to redefine the force field terms and then rerun the trajectory.

I’ve seen that the potential energy of a run is very easily extracted with, for instance:

L = PyLammps()
for line in cmdstring.splitlines():
L.command(line)
L.run(1000)

L.runs[0].thermo.PotEng

where cmdstring contains my lmp file with all its commands except the run

(as a comment the lines:

L.runs[0].step #list of time steps in first run

L.runs[0].ke # list of kinetic energy values in first run

in the tutorial raise an error in my version)

Now, instead of run, I need to call rerun for the same trajectory.

I’ve tried:

L.command(‘rerun A-syn_HPS.300.atom last 10000 dump x y z’)

Which, works, but I don’t know how to capture its output. Is there a way?

If this is not possible with PyLammps, is there a way to do that with the python library interface. i.e.:

from lammps import lammps
#run lmp file here

lmp.command(‘rerun A-syn_HPS.300.atom last 10000 dump x y z’)

Again, I don’t know how to capture the output or get the thermo data.

Thanks.

Ramon

ramon,

i think you are making your life needlessly complicated. i would recommend to run LAMMPS in the conventional way with input files and then take advantage of your python experience by using the Pizza.py toolkit to post-process the thermodynamic data of the log files created by your runs.

please also note, that your experiment may not be telling you the complete story. as you will always use the forces from the first set of parameters, but changing the parameters will also change the forces and thus the trajectory and likely change thermodynamic data further, from what you get by using rerun.

what you likely would need to do is to use the clear command and repeat your calculations from the same initial conditions with a new run. this can be put into a loop with LAMMPS input script commands if needed, but it can also be easily done through writing a template file and then filling in individual settings via preprocessing (e.g. with a python script or using LAMMPS variables)

axel.