#!/usr/bin/env python #this script set up and runs several molecular dynamics trajectories #this script must be called in the directory containing the n traj folders named as 000n #a properly formatted Job file is required in the same foulder of the script ################################################# from os import path, getcwd # from os import chdir, system # from shutil import copy # ################################################# # Define traj labels ############################ # first = 1 # last = 1000 # # # Define calculation parameters ################# # this value will be used in the Job file ####### # JobName ='160LO' # Just a general lable: "JobName_NumTraj" TimeLimit ='50' # in hours: "TimeLimit:00:00" NCores ='16' # SubmissionSteps ='200' # # ################################################# JobName = JobName here=getcwd() #workdir for i in range(first,(last+1)): traj= '%.4d' % i # define working directory newdir=path.join(here, traj) # updating mypath if not path.exists(newdir): print "folder", newdir, "not found. exiting..." quit() chdir(newdir) # change workdir if not path.exists('Job-erc'): # otherwise the calculation has already been started sometimes copy('%s/INPUTS/checker' % here , 'checker') # copy the check codes and Jobfile copy('%s/INPUTS/check-CHD3.py' % here , 'check-CHD3.py') # copy('%s/INPUTS/Job-erc' % here , 'Job-erc') # system('cp %s/INPUTS/INCAR* .' % here ) # system('cp %s/INPUTS/POTCAR .' % here ) system('cp %s/INPUTS/KPOINTS .' % here ) system('cp %s/INPUTS/vdw_kernel.bindat .' % here ) lable = traj + '_' + JobName modify = 'sed -e \"s|_JOBNAME_|%s|g\" Job-erc > Job' % lable # modify the Jobfile system(modify) # modify = 'sed -i \"s|_TIMELIMIT_|%s|g\" Job' % TimeLimit # system(modify) # modify = 'sed -i \"s|_NCORES_|%s|g\" Job' % NCores # system(modify) # modify = 'sed -i \"s|_SUBSTEPS_|%s|g\" Job' % SubmissionSteps # system(modify) # system('qsub Job > ID.job') # RUN JOB ####################################### system('cat ID.job') else: print ">>> traj %.4d <<<< already submitted" % i chdir('..') # back to the starting folder