Re: Accessing Colvars Within NAMD TCL

From: Jérôme Hénin (jhenin_at_ifr88.cnrs-mrs.fr)
Date: Thu Jun 30 2011 - 12:05:01 CDT

Hi David,

None of the features you mention is currently available, but they all
sound like good ideas, and I have been considering some amount of
Tcl-colvars interface lately. It's technically doable, just a matter
of investing the effort into a clean and maintainable design.

You can try to put some code together, but I would not call that
simple. The issue is, the MD interface is entirely abstracted in a
"proxy" class, so adding these functions means:
a) define an interface for them in the proxy class
b) implement the colvar side, talking to proxy functions
c) implement the NAMD side, interfacing the proxy functions and the
Tcl interpreter

Actual scripting, i.e. changing parameters on the fly, is a lot of
work because is involves lots of sanity checks on the new parameters.
Also, the idea is, if you want to do something complicated, you should
extend the colvars by writing your own biasing method.

But passing information back to the script via Tcl variables sounds
useful enough (it could also work with TclForces scripts). I'll have
to look into it.

Cheers,
Jerome

On 30 June 2011 17:28, David Rogers <wantye_at_gmail.com> wrote:
> NAMD Gurus,
>
>  Is is possible to access the content of the variables calculated by
> colvars inside namd's input file?  Specifically, I'd like to do
> something like the following:
>
> ------- vars.conf -------
>
> colvarsTrajFrequency 100
> colvarsTrajAppend off
> analysis off
>
> colvar {
>  name BVpsi
>  outputSystemForce yes
>  dihedral {
>    group1 { atomNameResidueRange CA 76
>                pdfSegID B }
>    group2 { atomNameResidueRange C  76
>                pdfSegID B }
>    group3 { atomNameResidueRange N  77
>                pdfSegID B }
>    group4 { atomNameResidueRange CA 77
>                pdfSegID B }
>  }
> }
>
> ------- run.namd -------
>
> ..
>
> colvars on
> colvarsConfig vars.conf
>
> run            100
>
> if { [ expr $colvars(BVpsi) > 50.0 && $colvars(BVpsi) < 100.0 ] } {
>  #  set a temperature, change a parameter, etc.
>  }
> run            100
>
> -------
>
>  It would also be great to have an API for changing colvar parameters
> (such as harmonic force constants, atom id-s of atoms in groups, etc.)
> during run-time, but this is likely to be much harder to implement
> than copying a number into a tcl variable.  If the latter hasn't been
> done, is there a simple solution to modify the source to create and
> update a tcl variable in this way--e.g. the same way callback is
> implemented:
>
> # NAMD_2.7 callback labels (4/12/11)
> #TS BOND ANGLE DIHED CROSS IMPRP ELECT VDW BOUNDARY MISC POTENTIAL
> KINETIC TOTAL TEMP PRESSURE GPRESSURE VOLUME CELL_A CELL_B CELL_C
> CELL_O PERIODIC
>  proc save_callback {labels values} {
>    global saved_labels saved_values
>    set saved_labels $labels
>    set saved_values $values
>  }
>  callback save_callback
>
> Thanks in advance,
> ~ David Rogers
>  Postdoc, Sandia National Labs
>
>

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:57:22 CST