Re: Is there a way to stop a MD run before the END_OF_RUN timestep?

From: Josh Vermaas (
Date: Mon May 25 2020 - 17:35:40 CDT

Hi Alfredo,

Based on my reading of the scripting guide (,
you could do something like this, having an outer loop that runs at a less
frequent restart rate until you get close. Then you'd use the "output"
feature to force the writing of the .coor, .vel, and .xsc files:

set isfar 1
while { $isfar } {
run 1000
#Insert some code to check the cv value and whatever threshold you are
interested in.
#I assume you have this already, and that you are waiting for the value to
be greater than the threshold.
if { $cvvalueyoucomputed > $somethreshold } {
set isfar 0
while { $isfar == 0 } {
#Now that you are close, run 1 step at a time, and force outputs if needed.
run 1
#Insert some code to check the cv value and whatever threshold you are
interested in.
if { $cvvalueyoucomputed <= $somethreshold } {
#This lets you go back to efficient running if the simulation slides back.
set isfar 1
if { $cvvalueyoucomputed > $targetthreshold } {
#If you reach your target, write a set of output files immediately, and
kill the simulation.
output targetreached

The trick is going to be that as soon as you make it into the inner loop,
your performance is going to be garbage, and the other things that are
required so that you can run 1 step at a time (I think your pairlistfreq
needs to be 1) also make your performance not great. When I wanted to kill
simulations after they had made sufficient progress, I'd just only check
every 1000 steps or so, since the amount of extra compute time that I saved
having pairlistfreq be something reasonable more than made up for
overrunning my target.


On Sun, May 24, 2020 at 11:37 PM Cardenas, Alfredo E <> wrote:

> Hi,
> I use certain TCL script in a NAMD conf file to evaluate certain colvars
> during the run. When certain values of the colvars are reached the
> simulation is kill. We need to save the coor, vel and xsc files at the
> timestep when the colvar condition is satisfied. To do that we use a very
> small restartfreq value and that evidently slows the simulation. I wonder
> if there is a way to trick NAMD, to change on the flight the END_OF_RUN or
> FILE_OUTPUT values so it could write those files when the colvars
> conditions are satisfied without the need to write restart files too often.
> If not, any other suggestion to do this will be appreciated. For example,
> there are ways to print out complete coor, vel and xsc in TCL scripts?
> Thanks,
> Alfredo

This archive was generated by hypermail 2.1.6 : Fri Dec 31 2021 - 23:17:09 CST