triggering compute when calling lammps as a library

Hello,

I have a driver code that calls lammps as a library to extract forces and the potential energy of an atomic configuration. I have to call lammps
many times within a loop. Currently, to compute the energy I achieve my goal by issuing the commands:

lmp->input->one(“run 0 post no”);
energy = ((double) lammps_extract_compute(lmp,“thermo_pe”,0,0));

The problem is that I would like to speed up the process as the

“run 0” command may be performing more operations that those I need just

to get the potential energy of my system.

What would be a minimal setup (if possible) to trigger the PE computation

while avoiding some of the unnecessary work that is done by
update->integrate->setup(); within the run command? (I believe that is where the delay happens)

Carlos

If you can do a "run pre no post no", then you have your savings, if you cannot, then that is it.
Axel

More specifically, the “pre no” setting skips
the setup() call you are asking about,
which can be costly if you are doing run 0 or
run 1.

Steve