Re: Writing number of atoms in a specific group to a file

From: Vermaas, Joshua (Joshua.Vermaas_at_nrel.gov)
Date: Fri Dec 16 2016 - 13:12:22 CST

Hi Hamed,

In the dark ages (like 5 years ago), I faced a similar problem, where I wanted to save computer time by terminating a run once a value reaches a certain point. In my case, I wanted to check if I had inserted a lipid into a bilayer. This is what my logic looked like:

proc runblock {maxsteps} {
        set steps 0
        while {$steps < $maxsteps} {
                #With 2fs timesteps, 500000 steps = 1ns
                set runsteps [min 250000 [expr {$maxsteps - $steps}]]
                #set runsteps [min 1000 [expr {$maxsteps - $steps}]] #This option would cause NAMD to pause and check much more often.
                set steps [expr {$steps + $runsteps}]
                run $runsteps

                #Now we need to check if the simulation is done
                #This is really hacky. The timecheck should return status 1 if we are done, and 0 if we are not.
                set status [catch {exec ../timecheck.sh}]
                #print "This is the status"
                #print $status
                if {$status != 0} {
                        set steps $maxsteps
                        set fo [open "done" "w"] # I create a file called "done" so that I know that this directory contains a simulation that is complete.
                        close $fo
                }
        }
}

So instead of just calling "run 25000000" at the end of a simulation as I was used to doing, I would run the simulation in bite-sized pieces by calling runblock until the second script (timecheck.sh) said I was done. Timecheck itself called VMD to check if the insertion happened or not. This approach would still work today, but what I didn't have in the dark ages was colvars that I could measure instead of needing to check the status of a separate executable. Nowadays you would define a collective variable, and check its value occasionally (I think with "cv colvar cvname value", although others can correct me if I'm wrong). This would replace the if logic at the end with if { [cv colvar cvname value] > somecutoff }.

-Josh

On 12/16/2016 11:55 AM, Hamed Fadaei wrote:
Actually I tried to see if there's any way to do it with TCL scripting in NAMD but unfortunately I couldn't find anything related in NAMD user's guide and tutorials for TCL scripting. Can you introduce any good source for further readings?

On Fri, Dec 16, 2016 at 12:11 PM, Brian Radak <bradak_at_anl.gov<mailto:bradak_at_anl.gov>> wrote:
The "measure" command might be useful for this, but I've never used it from the NAMD interface myself.

Brian

On 12/16/2016 11:35 AM, Hamed Fadaei wrote:
Dear NAMD users,

I'm wondering if there's a way to calculate the number of atoms in a group and write it in a text file during a NAMD simulation. For example number of water molecules around a residue (So the selection also changes during time). I know I can do this as a processing with VMD but I need to stop the simulation at the moment this number reaches a certain value. Can you think of any possible way to do that?

Best regards,
Hamed

--
Brian Radak
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory
9700 South Cass Avenue, Bldg. 240
Argonne, IL 60439-4854
(630) 252-8643<tel:%28630%29%20252-8643>
brian.radak_at_anl.gov<mailto:brian.radak_at_anl.gov>

This archive was generated by hypermail 2.1.6 : Sun Dec 31 2017 - 23:20:54 CST