Re: Running multiple walker metadynamics replicas as a bundle

From: zeynab hosseini (hosseinizeynab93_at_gmail.com)
Date: Wed Oct 28 2020 - 04:01:19 CDT

Hi Giacomo,

On Mon, Oct 26, 2020 at 2:49 PM Giacomo Fiorin <giacomo.fiorin_at_gmail.com>
wrote:

> Hi Zeynab (and other readers), what you linked as "NAMD user guide" is
> actually part of the Colvars manual, specifically the version that
> documents the NAMD backend:
>
> https://colvars.github.io/colvars-refman-namd/colvars-refman-namd.html#sec:colvarbias_meta_mr
> It is good to clarify that Colvars is a contributed package developed for
> the most part outside the institution that develops VMD and NAMD. To
> maximize usability all these codes are distributed together, and no
> patching is needed on your part. However, I kindly ask that in future
> applications where you use Colvars features you cite both the NAMD paper
> <https://doi.org/10.1063/5.0014475> and the Colvars paper
> <https://dx.doi.org/10.1080/00268976.2013.813594>, because each paper
> acknowledges distinct sources of funding.
>
> Also, if the documentation of the Colvars feature that you are using
> describes a specific reference paper, it is understood that you should cite
> that paper as well (e.g. multiple-walker metadynamics is described directly
> in the "main" Colvars paper, but multiple-walker ABF was added later and
> has an additional reference <https://doi.org/10.1021/ct500874p>).
>

Thank you for the clarification and providing the appropriate citations. As
you said, I‌ would cite properly..

> Back to your question, Josh correctly pointed out that your commands
> didn't have the correct syntax for launching a multiple-replicas NAMD job
> (metadynamics or otherwise). Check the NAMD manual section that he linked
> and the README in NAMD's lib/replica folder. Your command should be
> something along the lines of:
> charmrun +p8 namd2 +replicas 2 job0.namd +stdout job0.rep%d.log
> where "input.namd" is a shared script that contains lines like this one:
> outputName job.rep[myReplica]
>
> In the Colvars version distributed with NAMD 2.14 (which the Colvars doc
> currently describes), the replica's numeric ID is auto-detected internally
> so you won't need to use "myReplica" for that. In earlier versions, you
> would instead inline the metadynamics bias in the NAMD script, and use
> "myReplica":
> cv config "
> metadynamics {
> ...
> replicaID [myReplica]
> ...
> }
> "
>

> Lastly, try to be careful if you combine multiple-walkers with
> well-tempered metadynamics. If the variable you chose is not a good one,
> the replicas will stay more or less where they start from and the PMF would
> "converge" to whatever was their initial distribution. That PMF may make
> even some sense to you and the problem be difficult to detect (unlike
> single-replica metadynamics, where the presence of a single huge minimum
> will always be suspect). This is an issue already with standard
> metadynamics, but only gets worse when you artificially turn down the bias
> to make the PMF converge asymptotically. Whatever you do, with
> multiple-walkers, keep a close look at the trajectories of the walkers, and
> see that they all visit multiple states.
>
If you choose to initialize all walkers at the same structure, what you are
> doing is (at least until the walkers diffuse away) pretty much equivalent
> to single-replica metadynamics.
>

I have to say that I'm very much grateful for your guidance which is of
great help to me and others I think.

> As you suggested I followed the README in the NAMD's lib/replica folder.
There is a replica.namd under the mentioned directory which is the master
script for the replica exchanges. I think replica.namd is
originally written for the temperature bias exchange but I see that it is a
common script also used for the replica-exchange umbrella sampling (reUS).
I'm not that much good at tcl-scripting but I see that inside the
replica.namd the variables $min_temp and $max_temp are needed for a process
called the replica_temp which is used to set the value of variable
$replica(temperature) without any special condition. I think this is the
reason that when I launch the multiple-walker/well-tempered
metadynamics (MWWT-mtd) it crashes with the error asking for $min_temp and
$max_temp. I just don't understand why the same error does not happen when
performing the reUS for which we do not set $min_temp and $max_temp, too.

I guess I'm doing something very wrong when preparing the scripts and sorry
to ask you to have a look at them if possible. I perform the following
command to submit the MWWT-mtd on 2 walkers (as a test example) in my main
directory which contains all needed scripts, the output directory (with 0/
and 1/ subdirectories) and the input directory:

charmrun /usr/local/bin/namd2 ++local +p8 +replicas 2 job0.conf +stdout
output/%d/job0.rep%d.log

*-job0.conf:*
#############
source walker-mtd.conf

# prevent VMD from reading replica.namd by trying command only NAMD has
if { ! [catch numPes] } { source replica.namd }

 *-walker-mtd.conf:*
####################
set num_replicas 2
set temperature 310
set steps_per_run 1000
set num_runs 1000
set runs_per_frame 10
set frames_per_restart 5
set namd_config_file "common.conf"
set output_root "output/%s/CNT_ser" ; # directories must exist
set input_root "input/win.%d"

*-common.conf:*
####################
structure solvate.psf
coordinates solvate.pdb

# Input
paraTypeCharmm on
parameters toppar_c36_jul20/par_all36_prot.prm
mergeCrossterms yes
parameters toppar_c36_jul20/par_all36_lipid.prm
parameters toppar_c36_jul20/par_all36_carb.prm
parameters toppar_c36_jul20/par_all36_na.prm
parameters toppar_c36_jul20/par_all36_cgenff.prm
parameters toppar_c36_jul20/toppar_water_ions-cmt.str

wrapWater on

# Force-Field Parameters
exclude scaled1-4
1-4scaling 1.0
cutoff 12.
switching on
switchdist 10.
pairlistdist 13.5

# Integrator Parameters
timestep 2.0 ;# 2fs/step
rigidBonds all ;# needed for 2fs steps
nonbondedFreq 1
fullElectFrequency 2
stepspercycle 20
COMmotion no
zeromomentum no

cellBasisVector1 67.0 0. 0.0
cellBasisVector2 0.0 67.0 0.0
cellBasisVector3 0.0 0 21.31
cellOrigin 0.0 0.0 0.0

#PME (for full-system periodic electrostatics)
if {1} {
PME yes
PMEGridSpacing 1.0
}

# Constant Temperature Control
langevin on ;# do langevin dynamics
langevinDamping 1 ;# damping coefficient (gamma) of 5/ps
langevinTemp $temperature

# Collective variables
colvars on
cv config "
colvarsTrajFrequency 200
colvar {
   name Translocation
   upperboundary 30.5
   lowerboundary 4.0
   #upperWallConstant 100.0
   #lowerWallConstant 100.0
   width 0.02

   distanceXY {
      main {
         atomnumbers { 165 }
      }
      ref {
         atomnumbers {
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
160
         }
      }
      axis ( 0.0, 0.0, 1.0 )
   }
}

metadynamics {
   name meta-distance
   colvars Translocation
   hillWeight 0.1
   newHillFrequency 250
   #dumpFreeEnergyFile yes
   writeHillsTrajectory on
   hillwidth 0.2

   wellTempered on
 # bias factor=2
   biasTemperature 310

   multipleReplicas yes
   replicaID $replica_id
   replicasRegistry output/registry/replicas.registry.txt
   replicaUpdateFrequency 200
}
"
if { [info exists inName] > 0 } {
    cv load $inName.colvars.state
}

-Here is the error message:
Charmrun> scalable start enabled.
Charmrun> started all node programs in 0.017 seconds.
Charm++> Running in non-SMP mode: 8 processes (PEs)
Charm++> Using recursive bisection (scheme 3) for topology aware partitions
Charm++> TORUS A SIZE 8 USING 0 1 2 3 4 5 6 7
Charm++> TORUS B SIZE 1 USING 0
Charm++> TORUS C SIZE 1 USING 0
Charm++> TORUS MINIMAL MESH SIZE IS 8 BY 1 BY 1
Redirecting stdout to files output/0/job0.rep0.log through 1
Redirecting stdout to files output/0/job0.rep0.log through 1
Redirecting stdout to files output/0/job0.rep0.log through 1
Redirecting stdout to files output/0/job0.rep0.log through 1
REPLICA 0 FATAL ERROR: can't read "min_temp": no such variable
    while executing
"expr ($min_temp * exp(
log(1.0*$max_temp/$min_temp)*(1.0*$i/($num_replicas-1)) ) )"
    (procedure "replica_temp" line 3)
    invoked from within
"replica_temp $replica(index)"
    invoked from within
"set replica(temperature) [replica_temp $replica(index)]"
    (file "replica.namd" line 59)
    invoked from within
"source replica.namd "
    invoked from within
"if { ! [catch numPes] } { source replica.namd }"
    (file "job0.conf" line 5)
REPLICA 1 FATAL ERROR: can't read "min_temp": no such variable
    while executing
"expr ($min_temp * exp(
log(1.0*$max_temp/$min_temp)*(1.0*$i/($num_replicas-1)) ) )"
    (procedure "replica_temp" line 3)
    invoked from within
"replica_temp $replica(index)"
    invoked from within
"set replica(temperature) [replica_temp $replica(index)]"
    (file "replica.namd" line 59)
    invoked from within
"source replica.namd "
    invoked from within
"if { ! [catch numPes] } { source replica.namd }"
    (file "job0.conf" line 5)

All the best,
Zeynab

This archive was generated by hypermail 2.1.6 : Thu Dec 31 2020 - 23:17:14 CST