# [lammps-users] Coulomb friction on individual atom

Dear Users,

I need to apply classic Coulomb dry friction conditions on a group of atoms. As the simplest example consider 3 particles along x axis connected by 2 springs (bond_style harmonic). The left one is fixed by setforce 0, The right one is moved by move linear. the middle one is going to stand dry friction so that it rests until the total acting force on it reaches Fsc (maximum static friction), and afterward a constant kinetic friction Fdy is applied against its motion. Here is my input:

dimension 3
units metal
boundary p p p
atom_style molecular

{3 atoms
2 bonds
1 atom types
1 bond types
-5 100 xlo xhi
-5 5 ylo yhi
-5 5 zlo zhi

Masses

1 1

Atoms

1 1 1 0 0 0
2 1 1 1 0 0
3 1 1 2 0 0

Bonds

1 1 1 2
2 1 2 3} # end of data file

group left id 1
group midd id 2
group right id 3
bond_style harmonic/shift/cut
bond_coeff 1 5 1 10
velocity all create 0 4928459 mom yes rot yes dist uniform
timestep 0.001
thermo 100

variable Fsc equal 0.003
variable Fdy equal 0.002

#fix 1 all nve
fix 1 all nvt temp 0.01 0.01 0.001
fix 2 left setforce 0 0 0
fix 3 right move linear 0.1 0 0 units box
dump 1 all custom 1 dump.xyz id x fx

label loop
variable a loop 50000
variable FX2 equal abs(fx[2])
if “v_FX2 < 0.003” then “fix 4 midd setforce 0 NULL NULL” else “unfix 4” “fix 4 midd addforce -0.002 0 0”
run 1 pre no post no
next a
unfix 4
jump SELF loop

I expected when the spring (bond) 2 is stretched enough, the force fx[2] be bigger than Fsc and it starts to move but it doesn’t. Wrongly, with this code fx[2] always sets to 0. To overcome, I tried another way: define a friction force, FR, which is opposite of fx in static mode and equals to kinetic friction after sliding with this code:

label loop
variable a loop 10000
variable FX equal fx[2]
variable FXA equal abs(FX)
if “v_FXA < 0.003” then “variable FR equal -v_FX” else “variable FR equal -0.002”
fix 4 midd addforce v_FR 0 0
run 1 pre no post no
next a
unfix 4
jump SELF loop

but it doesn’t work either.

Thank you, Kamal

there are multiple problems here:
a) your understanding of the “if” keyword and how LAMMPS processes input is incorrect
b) your model is not representing what you are describing
c) your input has multiple formal issues

first, the approach of using a loop and defining/removing/updating fixes is flawed. it looks as if you are communicating with a human and not a computer program.
so if you want an equal style variable to provide a different result depending on a given condition, you have to put the condition inside the formula. So if you want to add two different force values to be added to a particle you can have an expressions like this: