Submit MD++ Jobs to a Cluster

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

Submit MD++ to a cluster

Lihua Jin

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

Since we run the job non-interactively, we need to comment out the interactive commands in the MD++ script, for example, openwindow(). Otherwise, the job will stop will errors.

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/

https://hpcc-intranet.stanford.edu/how-do-i/completely-new-to-cluster-computing/

https://hpcc-intranet.stanford.edu/resources/using-the-hpc-clusters-101/

Stretch a polymer melt with MD++

1. Define the simulation cell, and then use the command makelipids to initiate chains with certain number of beads.

2. Redefine the location of beads according to random walk, and replace the original ones. The structure is then allowed to relax by minimizing the potential energy.

3. Stretch the polymer melt by the command changeH_keepS.

input = [1 1 0.1] changeH_keepS
input = [2 2 -0.05] changeH_keepS
input = [3 3 -0.05] changeH_keepS

Line 1 changes the (1,1) component H11 to Failed to parse (Conversion error. Server ("https://wikimedia.org/api/rest_") reported: "Cannot get mml. TeX parse error: Double subscripts: use braces to clarify"): {\displaystyle 1.1H_{1}_{1}} , and line 2 and 3 change Failed to parse (Conversion error. Server ("https://wikimedia.org/api/rest_") reported: "Cannot get mml. TeX parse error: Double subscripts: use braces to clarify"): {\displaystyle H_{2}_{2}} and Failed to parse (Conversion error. Server ("https://wikimedia.org/api/rest_") reported: "Cannot get mml. TeX parse error: Double subscripts: use braces to clarify"): {\displaystyle H_{3}_{3}} to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 0.95H_2_2} and Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 0.95H_3_3} .

Miscellanies

1. A.log files contain codes about font colors. If you open them as plane txt files, they cannot be well showed. Can open them using the command

$more A.log

2. Stress outputs, TSTRESS_xx and TSTRESSinMPa_xx et al, define the compressive ones as positive.

3. To run MD++ scripts written by Python or TCL languages, we need to compile different executable files for the same potential.

$ make ljbond build=R SYS=mc2

The default is for TCL language. For Python

$ make ljbond build=R SYS=mc2 PY=yes

After compile files for Python, you need to make clean before you compile files for TCL, and vice versa.

Suggestions

1. Add searching function in the manual website.

2. Add a comment to clear the variable input.