Updating force on specific atoms

Hi.

Force calculations on verlet.cpp (e.g. Verlet::run()) use force->pair/bond/angle/…->compute(eflag,vflag) . These calculations update the force on all atoms in the system. What would be a feasible modification (and in which parts of the code) to allow updating the forces not for all atoms but for a specific set of them ? This set can be different in each time step and will be determined along the simulation internally in Lammps (i.e. not by the group command).

Thanks,
Vitor

There is not really a well laid out way to do something like that. Basically, what you want to do is to write a new MD code that is based on very different assumptions than what LAMMPS assumes. There is no way to do something at the level of an integrator.

Without significant rewrites to LAMMPS, I only see an option to implement what you are asking by creating a new custom fix command. That command can be executed in every timestep (e.g. in the pre_force or post_force step) and than that fix could determine which atoms to compute interactions for and then use the corresponding “single()” functions. However, those are limited to a subset of pair styles and bonds.

One more alternative would be to just write a custom code that only evaluates the forces and then couple it to LAMMPS using the MDI package infrastructure similar to how it is possible this way to compute forces and energies with a QM code and then let LAMMPS do the MD on those.

Many thanks!
Actually, I have already created this new custom fix by copying and modifying verlet.cpp. In this fix, I determine the atoms to compute interactions for. Now, I will follow your suggestion and look at the “single()” functions.

I don’t think that modifying an integrator class is such a good idea. Integrators are supposed to be ignorant about what kind of forces are computed and for which atoms.

I was talking about adding a custom fix style: 4.8.6. Writing a new fix style — LAMMPS documentation

The idea is to develop a new integrator. This is why I am modifying the integrator class.