Dear Lammps developers,
Within the current Lammps framework, I wonder what would be the most efficient way to implement the following idea. Rather than letting the code calculate the energy and forces acting on each atom after each relaxation step by summing a large number of pairwise potentials, I would like to interface the code with my own script which feeds it the energy directly. In my specific case, the energy can be calculated from the atomic coordinates without having to go through a sum of pairwise potentials.
- Are there already similar ideas/tools implemented in Lammps that I could leverage?
- What would be the typical overhead for Lammps to read in these energies at each relaxation step? How would it compare with a potential which requires dihedral corrections in the calculation of the pairwise potentials?
- Rather than using an external script to calculate these energies from the atomic coordinates, I could also consider doing it as a Lammps routine directly. Any recommendation on where to include it?
I’m not expecting anyone to spoon-feed me the work. But as I am mostly just a regular user, I am not too familiar with the Lammps code structure, so anything that could be useful for me to start and avoid re-inventing the wheel with respect to what already exists in Lammps would be useful.
Sure, there are quite a few options. Most are listed here: 8.1.6. Coupling LAMMPS to other codes — LAMMPS documentation
In addition there also is the fix external command — LAMMPS documentation which has the benefit to be compatible with both the C library interface and the Python module to define a callback that would set energies and forces (and virial, if needed).
The MDI based interface is the newest and an option that would not require any changes to LAMMPS since you connect two programs via a standardized communication protocol. So theoretically you would “only” need to write a program that implements the MDI protocol to send the desired data to LAMMPS.
That would depend on the individual method, programming language and whether you are running in parallel and thus need to distribute data.
I have no idea what you mean by that and thus I fail to see how that corresponds to your other questions.
It would have to be as a “style”, i.e. there is no simple point where you could insert a subroutine. The most natural choice - based on your desciption - would be a fix with fix latte as a possible template to start from. Please have a look at: 3. Modifying & extending LAMMPS — LAMMPS documentation
That kind of information is collected here: 4. Information for Developers — LAMMPS documentation
This is a (permanent) work-in-progress, but should be fairly useful already in its current form.
Thank you Axel. I’ll look into the different options and come back if I have further questions. The MDI based interface looks quite appealing.
Regarding the dihedral correction reference, it’s not important. I was thinking in terms of how a sum of pairwise interactions that includes dihedral corrections is computationally more expensive than one that just includes distances between atoms in its computation. But it is irrelevant at this point until I clarify the bigger picture.