Re: applying harmonic constraints in cphmd

From: Diship Srivastava (
Date: Mon Nov 22 2021 - 03:58:09 CST

Thanks for the suggestion. Based on your reply I have written an ad hoc tcl
script for the same purpose (it harmonically constrains the com of bilayer
and first few non titratable residues of protein ) but during run time the
script crashes with unknown tcl error. Any help regarding this error will
be highly appreciated.

script snippet :
 tclForces on
tclForcesScript {
set k 0.05
set r0 9.847

# com of bilayer
set group1 [addgroup {13 143 266 389 519 649 779 909....}]
# com of amp
set group2 [addgroup {15367 15369 15381 15382..}]
print "starting proc"
print "-------------"
proc calcforces {} {
        print "inside proc"
        print "changing scope of variables"
        # set change variable
        global group1 group2 k r0
        # load coordinates
        loadcoords c
        # get z coords of both groups
        set r1 [$c(1)]
        set r2 [$c(2)]
        foreach {x1 y1 z1} $r1 {}
        foreach {x2 y2 z2} $r2 {}
        set r_z [expr {$z2-$z1}]

        set disp [expr {$r_z-$r0}]
        # optional add energy - will be displayed in MISC
# addenergy [expr {$k*$disp*$disp/2.0}]

        # calculate force
        set force [expr {-$k*$disp}]

        addforce $group1 $force
        addforce $group2 [expr {-1.0*$force}]

# close proc calcforces
# deleting all atomslections

In logfile the error encountered was :
Info: Startup phase 10 took 6.5302e-05 s, 324.613 MB of memory in use
Info: Startup phase 11 took 0.000188028 s, 324.613 MB of memory in use
LDB: Central LB being created...
Info: Startup phase 12 took 0.000182779 s, 324.613 MB of memory in use
TCL: starting proc
TCL: -------------
TCL: parameter unknown for NAMD config parameter
FATAL ERROR: Unknown Tcl error

On Sat, 20 Nov 2021 at 21:55, Brian Radak <> wrote:

> This is unfortunately an unsolved problem. As you point out - the atom
> indices change during a CpHMD simulation and so the selections would need
> to be updated at each cycle (probably with a bit of bookkeeping). One thing
> that can be exploited is that the number of residues does not change, so if
> it is possible to use residue and name based selections, that should work.
> In previous work where we used restraints we took advantage of the fact
> that it was only a single residue that was titrating and so all indices
> above the atom sidechain are fixed during the simulation (a bit of a hack).
> To be honest, it might be easier for someone to implement restraints based
> on a selection syntax rather than solve the indexing problem that is
> specific to CpHMD.
> HTH,
> On 11/20/21 12:29 AM, Diship Srivastava wrote:
> Hi,
> I am currently working on insertion of an antimicrobial peptide (AMP) on
> bilayer membrane using constant pH MD. I am trying to constrain the center
> of mass of AMP and membrane, while cphmd is active. Since cphmd doesn't
> have colvar support and number of atoms during cphmd changes during the
> run, both colvars and constraints result in fatal error during the job. How
> can I constrain the com under cphmd conditions?
> Thanks in advance.
> --
> Diship Srivastava
> Department of Chemistry
> IIT(ISM) - Dhanbad
> India

This archive was generated by hypermail 2.1.6 : Fri Dec 31 2021 - 23:17:12 CST