# Custom Pair Potential

Dear all,

I am looking to define a specific kind of pairwise potential, which depends not on the distance between 2 atoms, but rather on the distance of each atom to a corresponding reference position.

Say I have two atoms at positions x and y, and their corresponding reference positions x0 and y0. Then, I would like the pairwise potential between positions x and y to be

U(x, y) = K * (x - x0) * (y - y0).

Is this possible to do in LAMMPS? Note that if positions x and y were the same, this would reduce to

U(x) = K * (x - x0)^2,

which is the harmonic bond style. But I am looking for the case where positions x and y are different. Any suggestions for how to accomplish this would be much appreciated!

Best regards,
Andrew Xu

Please have a look at fix spring/self.
Axel.

Dear Axel,

The fix spring/self (and fix spring) commands would solve the problem for the case of

U(x) = K * (x - x0)^2,

since the force would simply be

F(x) = -K * (x - x0).

However, I am looking for the case where for two atoms at separate positions, x and y, the forces are

F(x) = -K * (y - y0),
F(y) = -K * (x - x0).

In other words, the force on atom x depends on the position of atom y at every time step, and vice versa. Is there a way for LAMMPS to do this? Or would I have to write my own potential?

Best regards,
Andrew

i don’t think there is anything like this. the closest that i can think of is this:
https://lammps.sandia.gov/doc/pair_nb3b_harmonic.html

but that is not quite what you describe. perhaps it would be a starting point for writing your own, though.

axel.

It might just be me, but potential does not appear to be bounded from below.Are you sure this is what you want?

I see; it is unfortunate that such a potential does not already exist. Could you please suggest some references or guides for writing our own potentials?

Regarding Stefan’s question that my potential

U(x, y) = K * (x - x0) * (y - y0)

is not bounded from below, it should be, because the positions of the atoms are constrained by the dimensions of the simulation box.

Best regards,
Andrew

i don’t think there is anything like this. the closest that i can think of is this:
https://lammps.sandia.gov/doc/pair_nb3b_harmonic.html

but that is not quite what you describe. perhaps it would be a starting point for writing your own, though.

axel.

There is a whole section in the LAMMPS manual about modifying and extending LAMMPS. Axel.

I see, thanks for the pointer.

Best,
Andrew