Selecting atoms in NAMD .conf file and time-varying electric field

From: Ben Lowe (
Date: Wed Mar 01 2017 - 15:42:55 CST

I would like to implement an electric field which changes at each
timestep as a function of the current z-component of the dipole moment
of the simulation cell (as per equation 3/4).

In VMD I can achieve this by selecting all atoms, then using the
measure command:

>>set sel [atomselect top all]
>>measure dipole $sel -origincenter -elementary
>>set z [lindex $dp 2] ;#eAng
>>set vacuumperm 0.00023964010683888100 ;# in units of ang, e and kcal
>>set efieldzmagnitude [expr {$z/$vacuumperm}]

But in NAMD I am unsure how to implement this because I do not
understand how to select atoms from the current trajectory step. How
would I implement something like the above for each MD step via a NAMD
.conf file?

I suspect something like:

>>eFieldOn yes
>>eFieldNormalized yes
>>set timestep 0
>>set numberofsteps 20
>>while { $timestep < $numberofsteps} {
>> [VMD code as above]
>> eField {0 0 $efieldzmagnitude }
>> run 1
>> incr timestep

>> set sel [atomselect top all]
Provides the error:
'Charm++ fatal error:
FATAL ERROR: wrong # args for NAMD config parameter
    while executing

Maybe using the 'callback' function is what is needed, but it appears
there is no documentation for this.

Many thanks for any help,

Ben Lowe

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