Grid Forces: example code, documentation edit, and requested feature

From: David Minh (
Date: Tue Oct 23 2012 - 09:49:26 CDT

Hello namd-l,

I am attaching example python code that takes an AMBER prmtop file and generates dx grids and a grid force file that closely approximates the electrostatic and Lennard-Jones potential by a rigid species. The approximation for the Lennard-Jones potential was described by Meng, Shoichet, and Kuntz (
This posting address the question raised here:

Also, it appears that the documentation regarding grid forces ( is incorrect.

It states:

# x[1-3]del, y[1-3]del, and z[1-3]del are the basis vectors which transform
# grid indices to coordinates in angstroms:
# x(i,j,k) = xorg + i * x1del + j * y1del + k * z1del
# y(i,j,k) = yorg + i * x2del + j * y2del + k * z2del
# z(i,j,k) = zorg + i * x3del + j * y3del + k * z3del

I believe that this should be:

# x(i,j,k) = xorg + i * x1del + j * x2del + k * x3del
# y(i,j,k) = yorg + i * y1del + j * y2del + k * y3del
# z(i,j,k) = zorg + i * z1del + j * z2del + k * z3del

Finally, I have a request. I am using grid forces to accelerate a NAMD implementation of implicit ligand theory (, which rigorously provides binding free energies from molecular docking. It seems to be working now, and it is very fast. With a single processor on my desktop, I can run

20 steps in 2.02 s
1000 steps in 2.16 s
10000 steps in 3.34 s
100000 steps in 15.4 s

That means for a short simulation, most of the time is actually spend in startup and loading the grid. This is actually a problem, because I want to use many short simulations with different values of mgridforcescale between 0 and 1, as I am implementing an alchemical free energy calculation using Hamiltonian replica exchange (by the way, example code for Hamiltonian replica exchange with NAMD is available here: I could incorporate many more calculations within a NAMD instance if I could dynamically modify mgridforcescale during the tcl scripting portion. Unfortunately, it does not appear that I can modify mgridforcescale after a "run" or "coorfile" command; this raises a NAMD error. Would it be difficult to modify the program so that it is possible to change mgridforcescale at a later point?

David Minh

This archive was generated by hypermail 2.1.6 : Mon Dec 31 2012 - 23:22:11 CST