Writing a fix to apply a 2D spring force
This is the list of changes that are made to the source code:
- The new files that are created are
fix_addforceXY.cpp
andfix_addforceXY.h
. - The existing files that have been modified are
fix_addforce.cpp
andfix_addforce.h
. - The methods that are modified are constructor,
init()
, andpost_force()
. - The input parameters are
x0
,y0
,kx
, andky
. - Other quantities that are introduced are
kxstr[]
,kystr[]
,kxstyle
,kystyle
,kxvar
,kyvar
, andework[]
. - The LAMMPS syntax is
fix FIX_NAME GROUP addforceXY x0 y0 zvalue kx ky
(we will look at this syntax shortly in this section).
In this section, we will write a fix that applies a 2D, non-radially symmetric spring force on an atom directed toward a specified point.
Theory (2D spring force)
In this setup, we have an atom in a 2D system at location (x, y) that experiences a force pointing toward a point that depends on the spring constants and in the x and y directions...