Using 2 potentials in LAMMPS for MD and per-atom energy calculations respectively

Hello everyone,

I am trying to use two different potentials in LAMMPS. The first is for performing the MD simulation, and the second is for calculating the per-atom energy using compute pe/atom.

Is there a way to calculate per-atom energy using a different potential (without affecting the MD simulation) while keeping the primary potential for the dynamics?

Any help or suggestions would be greatly appreciated!

Thank you!

https://docs.lammps.org/rerun.html

Thank you for your suggestion! I appreciate the guidance regarding the use of the rerun command in LAMMPS. However, I cannot use rerun for my case because:

  1. I am using machine learning potentials for MD simulations.
  2. I rely on two models: the first for predicting forces and energy, and the second for predicting spin (which is treated as atomic energy and computed using compute pe/atom).
  3. Both models require the spin as an additional input alongside atomic coordinates, and the spin is predicted dynamically by the second model during the simulation.
  4. Since I need both models to run on the fly in real-time, rerun isn’t a suitable option for my workflow, as it operates on previously generated data rather than performing simultaneous predictions.

Thanks again for your suggestion, and I would be happy to hear any other ideas!

Then you are out of luck and have to resort to modifying LAMMPS according to your needs.
I have never dealt with the kind of model you describe, so I have no advice to give.

If the spin is a function purely of the coordinates (and possibly velocities), albeit calculated through some complicated model;

and the force and energy are functions of the coordinates (and possibly velocities) and spin;

then the force and energy are implicitly purely functions of the coordinates (and possibly velocities), even though it is impractical explicitly to write them out as such.

In which case, if your force, energy, and spin models are properly integrated with LAMMPS, it should be possible to rerun from a dump of the coordinates (and possibly velocities) and replicate the force and energy (up to floating point errors), since every step of a rerun includes a full force and energy calculation from the coordinates (and velocities) read in from the dump file on the relevant timestep.

This was the procedure I followed in my 2022 constant potential paper (link at end) to show that “charging” only a graphene layer closest to the electrolyte generated almost the same electrostatics as charging layers further in. The constant potential package updates charges on each electrode atom as a function of the electrode and electrolyte particle positions. Because this update is correctly coded (into the constant potential fix’s setup function), rerun could correctly update the electrode atoms’ charges and I could then use write_dump to analyse those charges, directly comparing different constant potential models on the same electrolyte positions.

Paper link: https://pubs.aip.org/aip/jcp/article-abstract/156/18/184101/2841096/Fully-periodic-computationally-efficient-constant

Can you do it with a hybrid/scale, set the scale on the second pair style to 0, and use a compute to extract the energy which is weighted to zero for the purpose of dynamics?