Re: Calculating electrostatic force from NAMD trajectory

From: Ben Lowe (
Date: Fri Jul 07 2017 - 02:14:30 CDT

Ah thank you; the script generated by NAMD energy showed me how to do
what I wanted. I didn't realise NAMD itself can read .dcd files for

For anyone interested, I've included the simple script below. Add the
following to the end of a NAMD .conf file and it will read in a .dcd
file, output a .force file (containing forces on all atoms) for every

binaryoutput off
coorfile open dcd namd-temp.dcd

set outfile [open "dcdforces.log" w]

while { ![coorfile read] } {
   firstTimestep $ts
   run 0
   output onlyforces tmp
   ##Insert tcl script here to extract the force on the atom of
interest from "tmp.force"
   incr ts 1
coorfile close
close $outfile

Kind Regards,

On 4 July 2017 at 11:42, sunyeping <> wrote:
> Hi,
> I use the vmd plugin "NAMD energy" to calculate the electrostatic force of
> the selected atoms. Do you think this is apt for your purpose?
> All the best.
> Yeping Sun
> ------------------------------------------------------------------
> From:Ben Lowe <>
> Time:2017 Jul 4 (Tue) 10:37
> To:namd-l <>
> Subject:namd-l: Calculating electrostatic force from NAMD trajectory
> I'm interested in calculating the electrostatic-only force on an atom
> within my system at every frame of a completed trajectory. The
> application is calculating the electric field on a test charge.
> The simulation was ran using PME for electrostatics with the EW3DC
> correction applied via the 'extforces' module, so ideally the
> resulting force would include both these, but a simple nearest
> neighbor coulombic sum may also be acceptable as an approximation to
> this.
> Does anyone know what would be an efficient way to calculate the
> electrostatic-only force on an atom for many (i.e. several thousand)
> frames?
> I can imagine the brute force way would be to write out every frame
> into a pdb/psf, and then run a separate NAMD 'minimisation' for every
> frame with the following settings:
> cutoff 0.1 # essentially disable VDW interactions
> binaryoutput off ;
> run 0
> output onlyforces $outputname
> But I'm sure there is a more efficient way; for example can tclforces
> be used for this kind of post-processing
> analysis?(
> Or colvars maybe
> (
> but this seems to be aimed at ABF calculations rather than this more
> simple problem.
> Thank for any suggestions,
> Ben

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