Pair_style for Harmonic potential?

Hello sir,
i want interaction between active brownian particles and substrate particles in 2 dimension… but I did not found this potential in unbond style
harmonic potential =1/2 k(r-r0)^2
but I found it in bond style…
plz help me to consider this potential…
thank you

As you have found, there is no pair style implemented for that.
You would either write a custom pair style (e.g. based on lj/cut) to realize this ( 3. Modifying & extending LAMMPS — LAMMPS documentation )
implement this via pair style python with a python class ( pair_style python command — LAMMPS documentation )
or use a tabulated potential ( pair_style table command — LAMMPS documentation ).
The tabulation can also created from the Python variant using the pair_write command — LAMMPS documentation

Please carefully review the linked documentation.

Or you could create a feature request issue describing the specifics at: Issues · lammps/lammps · GitHub
and hope that somebody volunteers to implement the potential you are looking for.

Thank you so much for your kind suggestions…

Can’t this interaction be obtained by setting appropriate values for the parameters of the harmonic types from one of the granular pair styles? Is this new style primarily for ease of use, because this simple interaction is used fairly often? Or is there more to it that can’t be achieved via the granular styles?

Granular pair style require a per-atom diameter and have a per-atom mass and many other quirks. Most don’t support atom types.

As of the 17 February version of LAMMPS (released today, obviously), there is a new pair style that implements exactly what was asked for: pair_style harmonic/cut command — LAMMPS documentation

It is likely much more efficient than (ab-)using a granular pair style.
As mentioned in a previous post in this thread the simplest way to implement the requested interaction with an older LAMMPS version is to use the pair_style table command — LAMMPS documentation

1 Like

Hello Sir,
I want to know about the pair style that was added in the latest version (17-02-2022).
Is still giving this error… Illegal pair_style command

plz, consider this problem…

LAMMPS (17 Feb 2022)
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
using 1 OpenMP thread(s) per MPI task
clear
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
using 1 OpenMP thread(s) per MPI task

units lj
dimension 2
boundary p p p
atom_style sphere

lattice sq 1.0
Lattice spacing in x,y,z = 1 1 1
region mybox block 0 36 0 36 0 0.5
create_box 2 mybox
Created orthogonal box = (0 0 0) to (36 36 0.5)
1 by 1 by 1 MPI processor grid
region box block 0 36 0 36 0 0.5 units box
create_atoms 1 region box
Created 1296 atoms
using lattice units in orthogonal box = (0 0 0) to (36 36 0.5)
create_atoms CPU = 0.005 seconds
group mobile type 1
1296 atoms in group mobile
region plane block 0 36 0 36 0 0.5 units box
lattice sq 0.2
Lattice spacing in x,y,z = 2.236068 2.236068 2.236068
create_atoms 2 region plane
Created 289 atoms
using lattice units in orthogonal box = (0 0 0) to (36 36 0.5)
create_atoms CPU = 0.001 seconds
group substrate type 2
289 atoms in group substrate

pair_style harmonic/cut 2.5
ERROR: Illegal pair_style command (src/EXTRA-PAIR/pair_harmonic_cut.cpp:149)
Last command: pair_style harmonic/cut 2.5

The error message is correct. The harmonic/cut pair style takes no arguments and thus your input is incorrect. The documentation says so, too, but unfortunately it’s example is incorrect as well.

Thank you… you are saying right… The example is wrong…