Submit MD++ Jobs to a Cluster

From Micro and Nano Mechanics Group
Jump to navigation Jump to search

Submit MD++ to a cluster

Besides running MD++ on your own computers, we can also submit MD++ jobs to clusters. Here take cluster mc2 as an example. Make a sub-directory Codes in the home directory, and extract the downloaded MD++ files there.

$ mkdir Codes 
$ cd Codes 
$ tar -zxvf md++-2015-01-14.tar.gz

Then we compile the potential energy we need, for example, 'ljbond', for Python files

$ cd MD++
$ make ljbond build=R SYS=mc2 PY=yes

Now we want to submit a job 'scripts/ex_polymer/polymer_expansion.py' with the potential energy 'ljbond_mc2' to the mc2 cluster. We need to prepare the following pbs script.

#!/bin/bash
#PBS -N polymer_equil
#PBS -j oe
#PBS -l nodes=1:ppn=24, walltime=96:00:00
#PBS -V
### ---------------------------------------
### BEGINNING OF EXECUTION
### ---------------------------------------
echo The master node of this job is `hostname`
echo The working directory is `echo $PBS_O_WORKDIR`
echo This job runs on the following nodes:
echo `cat $PBS_NODEFILE`
ncpu=`cat $PBS_NODEFILE | wc -w`
echo "Number of processors = $ncpu "
### end of information preamble
cd $PBS_O_WORKDIR
echo $PWD
sleep 2
bin/ljbond_mc2 scripts/ex_polymer/polymer_expansion.py

PBS is a job resource manager, and it gives queuing and execution services in a batch cluster environment. In a pbs script, #PBS -N polymer_equil specifies the name of the job. #PBS -j oe tells PBS to put both normal output and error output into the same output file. #PBS -l nodes=1:ppn=24, walltime=96:00:00 requests 1 node, 24 processes for 96 hours running time.

cd $PBS_O_WORKDIR asks to open the work directory. bin/ljbond_mc2 scripts/ex_polymer/polymer_expansion.py is the command to run the job.

When we use one process of a node, the whole node is occupied. Therefore, if we have more than one job, we can put them in the same pbs script. Moreover, We can add arguments to the MD++ scripts by adding the following lines at the beginning of the main code of the MD++ script

import sys

if len(sys.argv) == 1 :
    status = 0
elif len(sys.argv) > 1 :
    status = int(sys.argv[1])
print(status)

if len(sys.argv) <= 2 :
    arg2 = 50
elif len(sys.argv) > 2 :
    arg2 = int(sys.argv[2])
print(arg2)

if len(sys.argv) <= 3 :
    arg3 = 80
elif len(sys.argv) > 3 :
    arg3 = int(sys.argv[3])
print(arg3)

Then in one pbs script, we can ask to run several jobs

sleep 2
bin/ljbond_mc2 scripts/ex_polymer/polymer_expansion.py 0 40 50  &
sleep 2
bin/ljbond_mc2 scripts/ex_polymer/polymer_expansion.py 0 50 50  &
sleep 2
bin/ljbond_mc2 scripts/ex_polymer/polymer_expansion.py 0 60 50  &
wait

At the end of each command, '&' asks to continue to run the other commands. Wait asks to keep occupying the nodes and processes.

Saving the pbs file as 'scripts/ex_polymer/md++.pbs', we can submit the job by

qsub scripts/ex_polymer/md++.pbs

We can check the status of the job by

qstat

If the state is Q, the job is queued and waiting to start. If the state is R, the job is running. We can delete the job by

qdel Job_ID

where Job_ID is the job's unique identifier and will be given when you submit the job.

More information about PBS can be found https://rcc.its.psu.edu/user_guides/system_utilities/pbs/.

Stretch a polymer melt with MD++

Suggestions

1. Add searching function in the manual website. 2. Add a comment to clear the variable input.