Re: replica_bias and colvars

From: Giacomo Fiorin (giacomo.fiorin_at_gmail.com)
Date: Sat Aug 12 2017 - 13:29:48 CDT

Thank you, I was about to send an email about this, too. Note that this
correction only applies to the older scripts that JC is using and are still
circulating in many groups. Colvars will continue supporting legacy Tcl
commands like colvarbias, provide that they use standard Colvars syntax (at
most one keyword per line).

A simpler version of that instruction would be:
return [list Z "centers $c
forceConstant $k"]
The line break can be put inside the string, and the braces are optional if
a keyword's value fits in one line.

Note, however, that if you use the newer cv command you have more
flexibility, for example:
cv bias harm delete
cv config "
harmonic {
    name harm # Keeping Josh happy
    colvars Z
    centers $c
    forceConstant $k
}"
will delete the previous harmonic restraint and replace it with a new one.
The instruction is a bit more verbose, because the new bias may have not
only a different center and/or force constant, but entirely different
options altogether, including being applied to a different variable.

This can be called at any time during a run.

Giacomo

On Sat, Aug 12, 2017 at 7:49 AM, JC Gumbart <gumbart_at_physics.gatech.edu>
wrote:

> After further digging with Giacomo’s help, the solution turned out to be
> so simple:
>
> return [list Z "centers \{$c\} forceConstant \{$k\}”]
>
>
> is replaced with
>
> return [list Z "centers \{$c\}\nforceConstant \{$k\}”]
>
>
> (note the newline)
>
> Apparently the latter one is the way it was always supposed to be, but for
> some reason the former way worked in earlier versions. Thanks for helping
> us track it down!
>
> Best,
> JC
>
> On Aug 10, 2017, at 10:10 PM, Giacomo Fiorin <giacomo.fiorin_at_gmail.com>
> wrote:
>
> The syntax of the colvarbias command that Josh quoted:
> eval colvarbias [concat changeconfig $replica(colvarbias)]
> has *not* changed.
>
> Perhaps what changed is how the replica dictionary is filled in, i.e. the
> problem is in the script.
>
> Giacomo
>
> On Thu, Aug 10, 2017 at 5:17 PM, JC Gumbart <gumbart_at_physics.gatech.edu>
> wrote:
>
>> Z is the name of the harmonic restraint.
>>
>> For reference, the colvar is in a different file:
>>
>> harmonic {
>> name Z
>> colvars COMDistance
>> forceConstant { 0.0125 } centers { 0.0 }
>> }
>>
>> But the replica(colvarbias.$i) is how the script tells namd to update
>> that replica's properties. I wondered if something has changed in how namd
>> interprets that data.
>>
>> Thanks!
>> JC
>>
>> On Thu, Aug 10, 2017, 1:58 PM Vermaas, Joshua <Joshua.Vermaas_at_nrel.gov>
>> wrote:
>>
>>> The old way would have been through something like "eval colvarbias [cat
>>> changeconfig somestuff here]". I ran into problems once when I neglected to
>>> change the name of the harmonic bias I wanted to change (I call all of mine
>>> harm), accidentally using the collective variable the harmonic was trying
>>> to bias as the name instead. Is "Z" the name of your collective variable or
>>> the harmonic that biases the collective variable?
>>>
>>> -Josh
>>>
>>> On 08/10/2017 11:54 AM, Giacomo Fiorin wrote:
>>> Hi JC, how is this code calling Colvars? I don't see any Tcl command
>>> that does call it in there.
>>>
>>> The primary method for changing parameters for a bias should be through
>>> the "cv" command. Deleting the bias and re-creating it with the new
>>> configuration would be the way to go.
>>>
>>> Giacomo
>>>
>>> On Thu, Aug 10, 2017 at 1:07 PM, JC Gumbart <gumbart_at_physics.gatech.edu
>>> <mailto:gumbart_at_physics.gatech.edu>> wrote:
>>> Has something changed in newer versions of NAMD with regards to how
>>> inputs are fed to different replicas in colvars?
>>>
>>> Specifically, the input below worked fine in earlier versions (2.10 I
>>> think?), but in 2.12, the center and forceConstant both get set to the same
>>> value, namely that for the center.
>>>
>>> > proc replica_bias { i } {
>>> > set c [expr 5.5 + $i*0.5]
>>> > set klist { 10 10 10 10 10 10 5 5 5 5 5 5 5 5 5 5 5 5 5 5 }
>>> > set k [expr [lindex $klist $i]*0.05*0.05]
>>> > return [list Z "centers \{$c\} forceConstant \{$k\}"]
>>> > }
>>>
>>> And then this is how that proc is used:
>>> > set replica(colvarbias) [replica_bias $replica(index)]
>>> > for { set i 0 } { $i < $replica(num_neighbors) } { incr i } {
>>> > set replica(colvarbias.$i) [replica_bias $replica(index.$i)]
>>> > set replica(colvarbias.$i) [replica_bias $replica(index.$i)]
>>> > }
>>>
>>>
>>> Thanks!
>>> JC
>>>
>>>
>>>
>>>
>>> --
>>> Giacomo Fiorin
>>> Associate Professor of Research, Temple University, Philadelphia, PA
>>> Contractor, National Institutes of Health, Bethesda, MD
>>> http://goo.gl/Q3TBQU
>>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__goo.gl_Q3TBQU&d=DwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=6cQ04kjNHUuxT8SDe1wb0TtPDsnWRp4T4iwoYRLFpsY&m=le65FX1fWXGgd_kx40_8XmBrxibpHje2LVmb5ZXwlKY&s=ejCJmH0xLQz-6niH-chFQO7oupkeVnQmzanCeRwDg6s&e=>
>>> <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgoo.g
>>> l%2FQ3TBQU&data=02%7C01%7CJoshua.Vermaas%40nrel.gov%7C831422
>>> 1259fd42dbbd7a08d4e018e602%7Ca0f29d7e28cd4f5484427885aee7c08
>>> 0%7C0%7C0%7C636379844930020633&sdata=8L89QqKCxfU6eQHAfuug45u
>>> DZNPVjMTfWISdnTlqBko%3D&reserved=0
>>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__na01.safelinks.protection.outlook.com_-3Furl-3Dhttp-253A-252F-252Fgoo.gl-252FQ3TBQU-26data-3D02-257C01-257CJoshua.Vermaas-2540nrel.gov-257C8314221259fd42dbbd7a08d4e018e602-257Ca0f29d7e28cd4f5484427885aee7c080-257C0-257C0-257C636379844930020633-26sdata-3D8L89QqKCxfU6eQHAfuug45uDZNPVjMTfWISdnTlqBko-253D-26reserved-3D0&d=DwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=6cQ04kjNHUuxT8SDe1wb0TtPDsnWRp4T4iwoYRLFpsY&m=le65FX1fWXGgd_kx40_8XmBrxibpHje2LVmb5ZXwlKY&s=lNY-a33ikqwInk-sa3mzEA_5Vb3C_YKAobjZNpWW_dA&e=>
>>> >
>>> https://github.com/giacomofiorin
>>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_giacomofiorin&d=DwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=6cQ04kjNHUuxT8SDe1wb0TtPDsnWRp4T4iwoYRLFpsY&m=le65FX1fWXGgd_kx40_8XmBrxibpHje2LVmb5ZXwlKY&s=Zh5zXfsgRslsJeJtrroupym0Vn0vrRf7lQdwK16swWs&e=>
>>> <https://na01.safelinks.protection.outlook.com/?url=https%
>>> 3A%2F%2Fgithub.com%2Fgiacomofiorin&data=02%7C01%7CJoshua.Ver
>>> maas%40nrel.gov%7C8314221259fd42dbbd7a08d4e018e602%7Ca0f29d7
>>> e28cd4f5484427885aee7c080%7C0%7C0%7C636379844930020633&
>>> sdata=4p%2FVXyHfOnhkmFwh9djZRJRJgmVZTLNc1UAxI6v9tU8%3D&reserved=0
>>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__na01.safelinks.protection.outlook.com_-3Furl-3Dhttps-253A-252F-252Fgithub.com-252Fgiacomofiorin-26data-3D02-257C01-257CJoshua.Vermaas-2540nrel.gov-257C8314221259fd42dbbd7a08d4e018e602-257Ca0f29d7e28cd4f5484427885aee7c080-257C0-257C0-257C636379844930020633-26sdata-3D4p-252FVXyHfOnhkmFwh9djZRJRJgmVZTLNc1UAxI6v9tU8-253D-26reserved-3D0&d=DwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=6cQ04kjNHUuxT8SDe1wb0TtPDsnWRp4T4iwoYRLFpsY&m=le65FX1fWXGgd_kx40_8XmBrxibpHje2LVmb5ZXwlKY&s=_fV9RaFM5zoDjEN54QzaoFLV-funRJZM1GMXMKU5MOM&e=>
>>> >
>>>
>>>
>
>
> --
> Giacomo Fiorin
> Associate Professor of Research, Temple University, Philadelphia, PA
> Contractor, National Institutes of Health, Bethesda, MD
> http://goo.gl/Q3TBQU
> https://github.com/giacomofiorin
>
>
>

-- 
Giacomo Fiorin
Associate Professor of Research, Temple University, Philadelphia, PA
Contractor, National Institutes of Health, Bethesda, MD
http://goo.gl/Q3TBQU
https://github.com/giacomofiorin

This archive was generated by hypermail 2.1.6 : Mon Dec 31 2018 - 23:20:31 CST