Topic Options
#21235 - 06/12/09 10:03 PM CHARMM and csh scripts for extended MD simulations
rmv Online   content

Forum Member

Registered: 09/17/03
Posts: 8373
Loc: 39 03 48 N, 77 06 54 W
The posts which follow represent a system for running MD in discrete chunks, producing a series of sequentially numbered files. The csh script, dyn.csh, has been extensively used on Unix systems and Linux clusters for years, and some concepts date back to VAX DCL scripts for running CHARMM. This particular example is for a Linux cluster with a PBS queueing system, and a cover script for running CHARMM which handles the runtime setup, esp. for MPI based executables. The output files all have generic names initially, and they are numbered only if dyn.csh determines that the run was successful, based on a few simple tests.

The numbering is controlled by a file named next.seqno, which is first created by and then updated by dyn.csh for successful runs. In the absence of this file, dyn.csh assumes a new simulation is being started, and runs an MD startup script, assumes sequence number 1 for numbering, and puts the number 2 into the next.seqno file. The optional last.seqno file can be used to set a controlled stopping point. When next.seqno is present, an MD continuation script is run each time, extending the dynamics.

Another key step for a successful run is that dyn.res is copied to dyn.rea, the restart file to be read by the next run.

For a failed run, dyn.out is renamed to dyn.err.D.H, where D and H are the date and time in numeric form.

The dyn.csh script is set up to run 5 repetitions, and then attempts to resubmit itself by using ssh to connect to the cluster head node, by running a small csh script which invokes 'qsub'. That script, lobos.com in this case, contains--

#!/bin/csh
qsub -N $cwd:t -l nodes=1:ctown:ppn=8 dyn.csh

and is used to start the chain. In the event that ssh (or rsh) to the head node doesn't work at your site, you can increase the number of repetitions in dyn.csh and resubmit manually. The '$cwd:t' construct uses the current dir name as the PBS job name.

The scripting system assumes a separate subdir for each simulation.

The posts represent three files--
  • dynstrt.inp; MD startup, run if next.seqno does not exist
  • dyn.inp; continue MD; this file is run repeatedly
  • dyn.csh; the csh script which runs CHARMM and evaluates success
_________________________
Rick Venable
computational chemist


Top
#21236 - 06/12/09 10:08 PM Re: CHARMM and csh scripts for extended MD simulations [Re: rmv]
rmv Online   content

Forum Member

Registered: 09/17/03
Posts: 8373
Loc: 39 03 48 N, 77 06 54 W
dynstrt.inp
Code:
* PME/LRC dynamics startup with 64 heptane; C27r
*

read rtf  card name ../toppar/charmm/c27-hydro.rtf
read para card name ../toppar/charmm/par_c27r_lipid_prot_cmap.prm
read psf  card name ../c27rheptan.psf
read coor card name ../heptan1ns.crd

! CRYSTAL SIZE FROM CA. 1 NS FRAME OF EQUIL 
crystal define cubic 25.824 25.824 25.824  90. 90. 90.
crystal build cutoff 12. noper 0
image byres

shake bonh param

open unit 31 write file name dyn.trj
open unit 41 write card name dyn.res
! REDUCE OUTPUT
prnlev 3 node 0
! NPT ENSEMBLE; START
dyna cpt leap start echeck 500. nstep 500000 nprint 500 iprfrq 5000 -
  pcons pmass 500.0 pgamma 20.0 pref 1.0 - 
  hoover reft 312 first 312 finalt 312 tmass 5000. -
  atom lrc cdie cutnb 17.0  ctofnb 12.0 ctonnb 8. -
  wmin 1.0  eps 1.0 inbfrq -1 cutim 17.0 imgfrq -1 -
  ewald pme order 6 spline kappa 0.32 fftx 30 ffty 30 fftz 30 -
  ihtfrq 0 ieqfrq 0 ntrfrq 500 ichecw 0 iasors 1 -
  nsavc 1000 iuncrd 31 iunwri 41

stop

Top
#21237 - 06/12/09 10:10 PM Re: CHARMM and csh scripts for extended MD simulations [Re: rmv]
rmv Online   content

Forum Member

Registered: 09/17/03
Posts: 8373
Loc: 39 03 48 N, 77 06 54 W
dyn.inp
Code:
* PME/LRC dynamics with 64 heptane; C27r
*

read rtf  card name ../toppar/charmm/c27-hydro.rtf
read para card name ../toppar/charmm/par_c27r_lipid_prot_cmap.prm
read psf  card name ../c27rheptan.psf
read coor card name ../heptan1ns.crd

! CRYSTAL SIZE FROM CA. 1 NS FRAME 
crystal define cubic 25.824 25.824 25.824  90. 90. 90.
crystal build cutoff 12. noper 0
image byres

shake bonh param

open unit 31 write file name dyn.trj
open unit 40 read card name dyn.rea
open unit 41 write card name dyn.res
! NPT ENSEMBLE
dyna cpt leap restart echeck 250. nstep 500000 nprint 500 iprfrq 5000 -
  pcons pmass 500.0 pgamma 0.0 pref 1.0 -
  hoover reft 312 first 312 finalt 312 -
  atom lrc cdie cutnb 17.0  ctofnb 12.0 ctonnb 8. -
  wmin 1.5  eps 1.0 inbfrq -1 cutim 17.0 imgfrq -1 -
  ewald pme order 6 spline kappa 0.32 fftx 30 ffty 30 fftz 30 -
  ihtfrq 0 ieqfrq 0 ntrfrq 500 ichecw 0 iasors 1 -
  nsavc 500 iuncrd 31 iunrea 40 iunwri 41

stop

Top
#21238 - 06/12/09 10:15 PM Re: CHARMM and csh scripts for extended MD simulations [Re: rmv]
rmv Online   content

Forum Member

Registered: 09/17/03
Posts: 8373
Loc: 39 03 48 N, 77 06 54 W
dyn.csh
Code:
#! /bin/csh -f
#PBS -j oe
#PBS -m e

# ASSUMPTION (1): input files are named dynstrt.inp and dyn.inp
# ASSUMPTION (2): output files are named    dyn.res  dyn.trj  dyn.out
# ASSUMPTION (3): previous restart file read as  dyn.rea
#

# change to subdir where 'qsub' was used
cd $PBS_O_WORKDIR

# assign 'chm' variable to point to CHARMM executable
# 'c35b1' is a cover script for running a variety of c35b1 executables
# this usage is for 8 procs on a single node via shared memory MPICH
set chm = "/v/apps/bin/c35b1 shm 8"

# repeat 'run' times 
@ nrun = 5
@ krun = 1
 while ( $krun <= $nrun )

### alternate form is for MPI versions which don't support "stdin"
if ( -e next.seqno ) then
 $chm < dyn.inp > dyn.out
### $chm dyn.inp > dyn.out
else
 $chm < dynstrt.inp > dyn.out
### $chm dynstrt.inp > dyn.out
endif

set okay = true
# TEST FOR EXISTENCE, THEN NONZERO LENGTH OF OUTPUT FILES
if ( -e dyn.res && -e dyn.trj ) then
 @ res = `wc dyn.res | awk '{print $1}'`
 @ tsz = `ls -s dyn.trj | awk '{print $1}'`
# CHECK FOR EXIT MESSAGE
 @ nrm = `grep ' NORMAL TERMINATION ' dyn.out | wc -l`
 if ( $res > 100 && $tsz > 0 && $nrm == 1 ) then
# SUCCESSFUL RUN; COPY RESTART FILE
  cp dyn.res dyn.rea
# DETERMINE RUN NUMBER
  if ( -e next.seqno ) then
   @ i = `cat next.seqno` 
  else
   @ i = 1
  endif
# NUMBER THE OUTPUT FILES; CHANGE EXTENSIONS TO SUIT APPLICATION
  foreach fil ( out res trj )
   mv dyn.$fil dyn$i.$fil
  end
# COMPRESS TEXT BASED FILES
  gzip dyn$i.out dyn$i.res
# CONDITIONAL END CHECK
  if ( -e last.seqno ) then
    @ l = `cat last.seqno`
    if ( $i == $l ) then
      @ i += 1
      echo $i > next.seqno 
      exit
    endif
  endif
  @ i += 1
  echo $i > next.seqno
 else
# ZERO LENGTH FILE(S)
  set okay = false
 endif
else
# FILE DOESN'T EXIST
 set okay = false
endif

# TEST FOR CHARMM RUN FAILED; CREATE .ERR FILE WITH TIMESTAMP
if ( $okay == true ) then
# SUBMIT THE NEXT JOB; LOGIN TO HEAD NODE OF CLUSTER; REQUIRES SSH KEYS
 if ( $krun == $nrun ) ssh m1 "cd $cwd; ./lobos.com"
 @ krun += 1
else
 set ts = `date +%m%d.%H%M`
 mv dyn.out dyn.err.$ts
 exit(201)
endif

end

Top
#31481 - 03/02/13 11:34 AM Re: CHARMM and csh scripts for extended MD simulations [Re: rmv]
sj1 Offline
Forum Member

Registered: 02/19/13
Posts: 27
Dr. venable..I performed a short simulation [DYNAMICS start nstep 50000 timestp 0.002 nprint 100 -
langevin iasvel 1 firstt 300.0 finalt 300.0 -
rbuf 0.0 inbfrq 50 ihbfrq 0 ilbfrq 50 -
iunread -1 iprfrq 100 twindh 5.0 twindl -5.0 -
iunwrite 12 ichecw 1 ieqfrq 0 tbath 300.0 -
iuncrd 20 nsavcrd 250 echeck 1000000000 -
iunvelo -1 nsavvelo 0]
and it terminated normally.
but now I would like to do a 10 ns simulation. in order to do that, do I increase the nstep to 100000 and timestp to 0.100?
thank you in advance.


Edited by sj1 (03/02/13 11:35 AM)

Top
#31482 - 03/02/13 01:02 PM Re: CHARMM and csh scripts for extended MD simulations [Re: rmv]
rmv Online   content

Forum Member

Registered: 09/17/03
Posts: 8373
Loc: 39 03 48 N, 77 06 54 W
The ECHECK 1000000000 value is insane; anything over 500 is usually a bad idea. Large energy changes typically indicate a problem with the model building that needs to be fixed, not suppressed.

DO NOT use TIMESTEP greater than 0.002 for atomistic simulations; our group uses and recommends 0.001 for most work. You should only increase NSTEP to get a longer simulation time for a given run, or use multiple runs with DYNA RESTART. See dynamc.doc

The above scripts indicate a method for which can be used to run much longer simulations using the RESTART capability of CHARMM, and some shell scripts to partially automate file numbering, failure checks, and continuation.
_________________________
Rick Venable
computational chemist


Top

Moderator:  chmgr, John Legato, petrella