# [gmx-developers] User defined constraint

Bogdan Costescu bcostescu at gmail.com
Tue Apr 24 02:45:43 CEST 2012

```On Fri, Apr 20, 2012 at 23:06, Ignacia Echeverria <iechever at umd.edu> wrote:
> constrain a group of atoms to move along a curved line.  I already did this in lammps but now I need to extend it to Gromacs.

Could you please explain what would be the advantage of doing this in GROMACS ?

> 1) For a given group of atoms compute the center of mass.

That's easy, code already doing this exists.

> 2) Define the force acting over each of the atoms of the group which basically are of the form Fx = Fx(x,y,z), Fy = Fy(x,y,z) and Fz = Fz(x,y,z)

This is the hardest part: you need to use the difference between the
current atom position and the desired one (=on the curved path) to
calculate how much force should be applied on the atom to bring it or
keep it on the curved path.

> 2) Add these extra forces to the forces that gromacs computes at every integration step.

I guess that should be 3 :) This is the easiest part: there's an array
which keeps the (vector) force for each atom and to which you simply