Changing pair coefficients amid simulation based on atom positions

Hi!

Following up on this question (Pair Coefficients), which is the possibility of changing the pair_style/pair_coeff arguments based on atom positions. Is there a leeway around this without the need to create my own pair_style?

Essentially, I am using a Yuakawa potential in which I want to define a different screening length for different regions of the simulations box (defined by a single coordinate—say z [edge to 0] and [0 to edge]). This is intended to simulate regions with different dielectric constants where I am not simulating the solvent atoms explicitly.

I came across the the use of fix adapt, however, it seems that it does not apply for the Yukawa potential. It says in the manual that I may add a pair_style to this fix “easily”. So, it is one option to pursue.

Another idea is to define a dynamic atom type (akin to a dynamic group) by changing the internal LAMMPS variables through accessing the LAMMPS class through a Python code or so, and by that, I can define multiple pair_coeff lines with the desired screening length for each type. That is, I would have two atom types where each type encompasses the atoms within a specific region that I define, and those atom types are updated through a Python wrapper. I am skeptic on what potential issues the change of atom types amid the simulation could cause, and whether this is advisable at all.

What are some thoughts about this, and whether there are any suggestions? The question referenced above is from 2018, and perhaps there is a LAMMPS command that I am not aware of that I can exploit.

Thanks!

If you are using LAMMPS version 4 Feb 2025 or later, you could try pair style hybrid/scaled and atom style variables, that define how to mix different sub-styles for different atoms. Of course this can also be used when defining multiple sub-styles with different settings for the same pair style and then have the variables evaluate to either 1 or 0 depending on the location of an atom.

Please note that the kind of behavior that you are asking to realized is producing discontinuous interactions and those can lead to all kinds of inconsistent and unphysical behavior.

This is neat. I think this would serve the purpose. I will check its documentation and try to apply it. Thanks, Axel!

I see. This makes sense. And it’s a more cumbersome ‘wrong’ approach anyway.

@Gibbs You might be interested in this implement extract() in pair_style yukawa by evoyiatzis · Pull Request #4498 · lammps/lammps