[lammps-users] new 'fix restrain'

Hello lammps users,

FYI and FWIW to anyone who might want to restrain dihedral angles when
attempting to fit forcefield parameters or map a potential energy

Attached are three 'fix_restrain.*' files: cpp, h, and txt. If the cpp
and h files are dropped into the src directory and lammps is
recompiled, it should add a new 'fix restrain' command. The txt file
contains lammps documentation. Below is the command summary from the

fix ID group-ID restrain K_start K_stop keyword value(s)

ID, group-ID are documented in "fix"_fix.html command
restrain = style name of this fix command
K_start, K_stop = restraint coefficient at start/end of run
one keyword with one or more sets of parameter values may be appended to args
keyword = {dihedral}
  {dihedral} value = atom1 atom2 atom3 atom4 target
    atom{n} = ID of atom {n} in restrained bond
    target = target value for specified bond (degrees)


fix holdem all restrain 2000.0 2000.0 dihedral 1 2 3 4 120.0
fix holdem all restrain 0.0 2000.0 dihedral 1 2 3 4 120.0 1 2 3 5
-120.0 1 2 3 6 0.0

Currently, it only does dihedral restraints, but if anyone really
wanted e.g. angle restraints, they could easily add that option.

If you're curious about my motivation...

I've been doing atomistic molecular forcefield development lately, and
this generally requires generating dihedral parameters by fitting to
ab initio potential maps of the dihedral(s) of interest. I was able to
cobble together some scripts that cajoled LAMMPS into restraining the
required dihedral(s) using 'dihedral charmm', but this was always ugly
for a variety of reasons:

1) I needed to construct a specialized data file.

2) 'dihedral charmm' wants the offset to be an integer value, but the
angle I want to match isn't always an integer.

3) If my forcefield doesn't already use 'dihedral charmm', I need to
invoke 'dihedral hybrid', which adds another layer of complexity,
difficulty, and opportunity for error. (I had once considered using
'dihedral hybrid' for everything, and I looked at the code and saw
that it would be possible to make it store parameter info in restart
files, which I consider a must-have for the generalization I'm so fond
of, but I also saw how space-inefficient that can be, and I didn't
want to be tied to a modified version of LAMMPS.)


fix_restrain.txt (4.98 KB)

fix_restrain.cpp (8.74 KB)

fix_restrain.h (661 Bytes)