Re: NAMD-2.9:Help needed on how to write to different DCD files in a single running NAMD simulation??

From: Shailesh Pandey (shaileshp51_at_gmail.com)
Date: Thu Jun 26 2014 - 04:41:49 CDT

Thank you very much friends,

I tried solution suggested by Norman Giest, and it worked for me after
little tweaking, I think scripts which worked for me might be useful to
some other users, willing to do some thing similar.

I have used PBS queuing system, and PBS job submission script as well as
script for namd-run are here.

##############################
NAMD-SCRIPT-STARTS-HERE###########################################
 #!/bin/bash
base_file_name="rCplx01_C" ;# Prefix for namd outputfiles
molecule_name="prot_pep_cplx" ;# Prefix of pdb/psf files if it
is abc.psf/abc.pdb then here "abc"

simulation_time=52 ;# Simulation length in (
ps / ns ) unit as per "steps_unit_time"
sim_restart_time=10
equilibration_time=2

steps_unit_ns=1000000
steps_unit_ps=1000

restart_freq=$((500*$steps_unit_ps))
steps_unit_time=$(($steps_unit_ns))

restart_counts=$(( ($simulation_time + $sim_restart_time -
$equilibration_time + 1 ) / $sim_restart_time ))
echo $restart_counts

time_done=0
for i in $(seq 1 $restart_counts);
do
    i_pre=$(($i-1))
    time_left=$(($simulation_time - $time_done))
    sim_block_time=$sim_restart_time
    if [ "$sim_block_time" -gt "$time_left" ]; then
sim_block_time=$((time_left)); fi

    echo $i_pre
    cat > ${base_file_name}_${i}.namd <<ENDIN

    #############################################################
    ## JOB DESCRIPTION ##
    #############################################################

    # restart of a run
    # peptide in a Water Box
    #
    # to run: namd filename.conf > filename.log &

    #############################################################
    ## ADJUSTABLE PARAMETERS ##
    #############################################################

    structure ${molecule_name}.psf
    coordinates ${molecule_name}.pdb
    set temperature 310

    if {${i} == 1} {
        #coordinates ${molecule_name}.pdb
        set block_run_time $(($equilibration_time))
        set rs 0
        set rsMin 1
        set firsttimestep 0
    } else {
    set block_run_time $(($sim_block_time))
    set rs 1
    set rsMin 0
    set inputname ${base_file_name}_${i_pre}
    set firsttimestep [ expr { $time_done * $steps_unit_time } ]
}

set outputname ${base_file_name}_${i}

set runsteps [ expr { \$block_run_time * $steps_unit_time} ] ;# x *
1ns_steps + .4ns equili

# Continuing a job from the restart files
# if {0} is true
# set rs 0 ;# use restart file? 1 = yes
# set rsMin 1 ;# do mininmize? 0=No, 1=yes or 2 if velocities .vel
not provided
if {\$rs==1} {
    binCoordinates \$inputname.coor
    binVelocities \$inputname.vel ;# remove the "temperature" entry
if you use this!
    extendedSystem \$inputname.xsc
}
# Continuing a job but not from restart files
if {\$rs==2} {
    binCoordinates \$inputname.coor
    # binVelocities \$inputname.vel ;# remove the "temperature" entry
if you use this!
    extendedSystem \$inputname.xsc
}

#############################################################
## SIMULATION PARAMETERS ##
#############################################################
# Input
paraTypeCharmm on
parameters ../../par_all27_prot_lipid.inp

# NOTE: Do not set the initial velocity temperature if you
# have also specified a .vel restart file!
# temperature $temperature
# keep temp if want to assign new velocitites

# Periodic Boundary conditions
# NOTE: Do not set the periodic cell basis if you have also
# specified an .xsc restart file!
if {\$rs==0} {
    # you get the info to make the following from:
    # set sel [atomselect top all]
    # cell basis vectors:
    # measure minmax $sel # then take the difference
    # cellOrigin:
    # measure center $sel
    #

    cellBasisVector1 64.89 0. 0.0
    cellBasisVector2 0.0 82.20 0.0
    cellBasisVector3 0.0 0.0 65.90
    cellOrigin 2.88 -26.92 -42.18
}
wrapWater on
wrapAll on

# Force-Field Parameters
exclude scaled1-4
1-4scaling 1.0
cutoff 12.
switching on
switchdist 10.
pairlistdist 13.5

# Integrator Parameters
timestep 1.0 ;# 2fs/step
rigidBonds water ;# needed for 2fs steps
nonbondedFreq 1
fullElectFrequency 2
stepspercycle 50

#PME (for full-system periodic electrostatics)
if {1} {
    PME yes
    PMEGridSpacing 1.0

    PMEGridSizeX 72
    PMEGridSizeY 84
    PMEGridSizeZ 72
}

# Constant Temperature Control
if {\$rs==0} {
    temperature \$temperature ;# if velocity file is used on restart
disable this
}

langevin on ;# do langevin dynamics
langevinDamping 1 ;# damping coefficient (gamma) of 1/ps
langevinTemp \$temperature
langevinHydrogen no ;# don't couple langevin bath to hydrogens

# Constant Pressure Control (variable volume)
if {1} {
    useGroupPressure yes ;# needed for 2fs steps
    useFlexibleCell no ;# no for water box, yes for membrane
    useConstantArea no ;# no for water box, yes for membrane

    langevinPiston on
    langevinPistonTarget 1.01325 ;# in bar -> 1 atm
    langevinPistonPeriod 100.
    langevinPistonDecay 50.
    langevinPistonTemp \$temperature
}

# Output Parameters
outputname \$outputname
firsttimestep \$firsttimestep

restartfreq $restart_freq ;# 500000steps = every 500ps
dcdfreq 200
xstFreq 200
outputEnergies 200
outputPressure 200

# Fixed Atoms Constraint (set PDB beta-column to 1)
if {0} {
    fixedAtoms on
    fixedAtomsFile myfixedatoms.pdb
    fixedAtomsCol B
}

# IMD Settings (can view sim in VMD)
if {0} {
    IMDon on
    IMDport 3000 ;# port number (enter it in VMD)
    IMDfreq 1 ;# send every 1 frame
    IMDwait no ;# wait for VMD to connect before running?
}

#############################################################
## EXTRA PARAMETERS ##
#############################################################

# Put here any custom parameters that are specific to
# this job (e.g., SMD, TclForces, etc...)

#############################################################
## EXECUTION SCRIPT ##
#############################################################

# Minimization
if {\$rsMin==1} {
    minimize 2000
    reinitvels \$temperature ;# the temperature statement above
verforms vel reassignment
}

run \$runsteps

ENDIN

echo "$1,$2: is namd2 run with arguments"
cmd="$1 ${base_file_name}_${i}.namd "
echo $cmd
$cmd

if [ "$i" -eq "1" ]; then time_done=$(($time_done + $equilibration_time));
else time_done=$(($time_done + $sim_block_time)); fi
done

############################## NAMD-SCRIPT-ENDS-HERE###################

save it in a file with name "namd_runCplx01.sh" in directory
"absolute/path/to/current/namd-job"

############################## PBS-JOB-SUBMISSION-SCRIPT-STARTS-HERE
##############

#! /bin/bash
#PBS -l nodes=2:ppn=8
#PBS -l walltime=100:00:00
#PBS -N myjobname
#PBS -q myquename
#PBS -r n
#PBS -V
#PBS -o o.$PBS_JOBID
#PBS -e e.$PBS_JOBID

export I_MPI_JOB_CONTEXT=$PBS_JOBID
export I_MPI_FABRICS=shm:ofa
export I_MPI_OFA_ADAPTER_NAME=mlx4_0

echo PBS JOB id is $PBS_JOBID
echo PBS_NODEFILE is $PBS_NODEFILE
echo PBS_QUEUE is $PBS_QUEUE
NPROCS=`wc -l < $PBS_NODEFILE`
NRINGS=`wc -l < $PBS_NODEFILE`
NRINGS=`cat $PBS_NODEFILE|sort|uniq|wc -l`

echo NPROCS is $NPROCS

outdir="absolute/path/to/current/namd-job"
cd $outdir

cat $PBS_NODEFILE > pbsnodes
export rsh=/usr/bin/ssh

progdir="$HOME/NAMD_2.9_Linux-x86_64-ibverbs"

nodefile=namd6.nodelist
echo group main ++shell /usr/bin/ssh > $nodefile
awk '{ for (i=0;i<1;++i) {print "host",$1} }' pbsnodes>>$nodefile

mpdboot --totalnum=$NRINGS --file=$PBS_NODEFILE --rsh=/usr/bin/ssh
--verbose --ordered
$outdir/namd_runCplx01.sh "$progdir/charmrun ++mpiexec +p$NPROCS
$progdir/namd2 " > ${outdir}/l.$PBS_JOBID.log
mpdallexit
exit 0

############################## PBS-JOB-SUBMISSION-SCRIPT-ENDS-HERE
##############

give execute permission to file
"absolute/path/to/current/namd-job/namd_runCplx01.sh"

and use PBS script for job submission

On Tue, Jun 10, 2014 at 1:15 PM, Ajasja Ljubetič <ajasja.ljubetic_at_gmail.com>
wrote:

> Hi!
>
> I usually write a bash shell script that calls namd with the right
> parameters so that I get 1 ns long DCD files. Environment variables can be
> accessed using
> $env(NAME_OF_VARIABLE) inside of the NAMD configuration file (I'm
> attaching an example).
>
> The other option is if you can use the colvars module
> <http://www.ks.uiuc.edu/Research/namd/2.9/ug/node53.html> to do your
> analysis on the fly, while the simulation is running.
>
> Good luck,
> Ajasja
>
>
>
>
>
> On 9 June 2014 19:54, Shailesh Pandey <shaileshp51_at_gmail.com> wrote:
>
>> Dear NAMD users,
>>
>> I am running NAMD simulations, but my problem is that users are allowed
>> to store only limited data (say 100GB) in their account at our computing
>> center, but when i run a simulations of 100ns allocated user space gets
>> filled and simulation is killed by scheduler before completing. I want to
>> simulations of 100ns length because jobs usually wait for weeks in queue
>> only after such long wait get chance to run, So I want when I get chance to
>> run i should run 100ns in one chance.
>>
>>
>> I want to write different DCD for every (say 20ns) so that once
>> simulation crosses 20 ns, it should start writing to different DCD file and
>> after backing up earlier one I can safely delete older DCD without
>> affecting running simulation.
>>
>> Eg. setting restartsave yes we can save restart files for every restart
>> timestep, A similar thing i want for DCD file.
>>
>> I can not increase DCDfreq, because frames are need for analysis.
>>
>> Any help is appreciated thank you.
>>
>
>

This archive was generated by hypermail 2.1.6 : Thu Dec 31 2015 - 23:20:56 CST