You are here: Home Help/User Support Parallel Computing in the CAE Lab Cluster Job Example: ANSYS

Cluster Job Example: ANSYS

ANSYS does not offer an educational-market product for large-scale parallel computations. You can use all CPUs on a single multi-CPU system if needed, but our ANSYS license does not allow us to divide the solution work across several separate systems. Therefore, use either "#PBS -l nodes=1:ppn=1" for a single-CPU job, "#PBS -l nodes=1:ppn=2" for a dual-CPU job, or "#PBS -l nodes=1:ppn=4" for a 4-CPU job. For multi-CPU jobs, also add "-np 2" or "-np 4" to the ANSYS command line as appropriate.

The sample qsub command file given is designed to handle larger jobs that constantly write to temporary files during the ANSYS solution process. It's inefficient to keep writing these temporary files to the file server, so it does the following:

  1. makes a temporary folder on the compute node's local hard disk,
  2. copies relevant input files there,
  3. runs ANSYS from this temporary folder,
  4. copies relevant output back to the file server,
  5. removes the temporary folder

Sample input file (ansys_demo.inp)

/COM,ANSYS MEDIA REL. 8.0 (9-17-2003) REF. VERIF. MANUAL: REL. 8.0
/VERIFY,VM1
/PREP7
/TITLE, VM1, STATICALLY INDETERMINATE REACTION FORCE ANALYSIS
C***      STR. OF MATL., TIMOSHENKO, PART 1, 3RD ED., PAGE 26, PROB.10
ANTYPE,STATIC                  ! STATIC ANALYSIS
ET,1,LINK1
R,1,1                          ! CROSS SECTIONAL AREA (ARBITRARY) = 1
MP,EX,1,30E6
N,1
N,2,,4
N,3,,7
N,4,,10
E,1,2                          ! DEFINE ELEMENTS
EGEN,3,1,1
D,1,ALL,,,4,3                  ! BOUNDARY CONDITIONS AND LOADING
F,2,FY,-500
F,3,FY,-1000
FINISH
/SOLU    
OUTPR,BASIC,1
OUTPR,NLOAD,1
SOLVE
FINISH
/POST1
NSEL,S,LOC,Y,10
FSUM
*GET,REAC_1,FSUM,,ITEM,FY
NSEL,S,LOC,Y,0
FSUM
*GET,REAC_2,FSUM,,ITEM,FY

*DIM,LABEL,CHAR,2
*DIM,VALUE,,2,3
LABEL(1) = 'R1, lb','R2, lb '
*VFILL,VALUE(1,1),DATA,900.0,600.0
*VFILL,VALUE(1,2),DATA,ABS(REAC_1),ABS(REAC_2)
*VFILL,VALUE(1,3),DATA,ABS(REAC_1 / 900) ,ABS( REAC_2 / 600)
/OUT,vm1,vrt
/COM
/COM,------------------- VM1 RESULTS COMPARISON ---------------------
/COM,
/COM,         |   TARGET   |   ANSYS   |   RATIO
/COM,
*VWRITE,LABEL(1),VALUE(1,1),VALUE(1,2),VALUE(1,3)
(1X,A8,'   ',F10.1,'  ',F10.1,'   ',1F5.3)
/COM,----------------------------------------------------------------
/OUT
FINISH
*LIST,vm1,vrt

Sample qsub command file (ansys_demo.sh)

#!/bin/bash
# Example ANSYS job

# Request 1 node with 1 free CPU core. If you have a parallelizable job,
# you can adjust your ANSYS command line to include a "-np X" parameter,
# where X is a number between 1 and 8. Set the ppn value below to the
# same X value.
#PBS -l nodes=1:ppn=1

# Reserve 24 hours on selected cores
#PBS -l walltime=24:00:00

# Give the job a descriptive name for emails (name must start with a
# letter)
#PBS -N Finding_reactions

# Send mail to address given below when the job begins, ends normally,
# or aborts
#PBS -m bea
#PBS -M myusername@tntech.edu

cd ${PBS_O_WORKDIR}

# Make temporary folder, copy necessary input files to it, cd there,
# then run Ansys:
TDIR=`mktemp -d`
cp ansys_demo.inp ${TDIR}
cd ${TDIR}

# For single-CPU jobs, uncomment the first command below, and comment
# the second one. For multi-CPU jobs, comment the first command below,
# and uncomment the second one.
ansys110 -b nolist -p AA_T_A -j ansys_demo \
        -i ansys_demo.inp -o ansys_demo.out
# ansys110 -b nolist -p AA_T_A -j ansys_demo -np 2 \
#       -i ansys_demo.inp -o ansys_demo.out

# Copy necessary output files back to original working directory, cd
# there, then remove temporary folder. Adjust according to the output
# files you need. For ANSYS 11, see sections 18.1 (File Management
# Overview) and 18.4.2 (Files that ANSYS Writes) in the Basic Analysis
# Guide for details on which files may need to be kept, and which can be
# safely removed automatically.
cp ansys_demo.out ${PBS_O_WORKDIR}
cd ${PBS_O_WORKDIR}
rm -r ${TDIR}