How to dump potential energy of per atom after minimization

Dear all,

I try to use the following code to minimize and dump the final snap:

compute          atompe all pe/atom

minimize         1.0e-12 1.0e-12 10000 10000

write_data       inherent.data
write_dump       all custom inherent.dump id type x y z c_atompe

But it reports an error:

System init for write_data ...
ERROR: Compute used in dump between runs is not current (src/dump_custom.cpp:584)
Last command: write_dump       all custom inherent.dump id type x y z c_atompe

Could you please give me some suggestions how to solve it?

Thanks,
Jiang

It is important to first understand why this error happens. The compute pe/atom command actually does not compute anything (same for compute pe, compute stress/atom, compute pressure etc.), but makes data available that was collected during the force evaluation at the same timestep. In order to do that, LAMMPS needs to know before a force evaluation whether the data is collected, otherwise it will skip computing and collecting energies (or the virial) and save quite a bit of time. The write_dump command, however, happens after the minimize command, thus LAMMPS would have to go back and repeat the last force evaluation with different internal settings to collect the energy. This is why computes produce this error when they are accessed in between run or minimize commands.

The simplest way to work around this limitation is to explicitly repeat the last force evaluation with the dump defined as a regular dump. For example you can change the quoted input file segment to:

minimize         1.0e-12 1.0e-12 10000 10000

reset_timestep 0
compute          atompe all pe/atom
dump    atompe   all custom 1 inherent.dump id type x y z c_atompe
run 0 post no
undump atompe

write_data       inherent.data

This should produce the desired data in the dump file without triggering an error.

Thanks for your timely response. Your description is really detailed. It makes me a lot about the usage of LAMMPS.