Ansys-MAPDL

Below is a basic job script that can run textfiles of Ansys Mechanical APDL commands.

Copy this script to to your work directory and rename it, in this example I have named the script ansys_job1.sh. Then you will need to edit the file to suit your needs. in general in this sample script the <> flags indicate some sort of file name or text you have to input. you can also edit the number of processors, nodes, and run time requested with this script.

This script can be copied from the shared folder on the condo cluster to the directory you are in using this cp command:

cp /shared/hpc/sample-job-scripts/ansys/sample_mapdl_job1.sh ansys_job1.sh

You will also need to make a plain text file of the apdl commands you want to run using some text editor and substitute the name of that file in the appropriate spots in the script below.

Once you have saved your changes, you can use the sbatch program to submit your job:

sbatch ansys_job1.sh

The sample script is below:


#!/bin/bash
# This is an example of an Ansys Mechanical APDL job sbatch script.
# this file must be edited to suit your unique job. The <> flags indicate a field that must be edited in addition to the number of nodes,processors and time.
#when you have finished editing this file change the name and submit by using the sbatch program
#lines beginning with #SBATCH are actually run by the sbatch program when the job is submitted.

# The --job-name is the name of the job as it appears in the queue.
#SBATCH --job-name=<title-of-your-job>

# --output is the file where the program spits results and --error is where it spits errors during runtime
#SBATCH --output=OUTPUT
#SBATCH --error=ERRORS

 

#nodes are the number of individual machines. On Condo each node has 16 processors for example.
#SBATCH --nodes=1
#ntasks is the number of processors.
#SBATCH --ntasks=16
#note: if more processors are requested than the requested nodes have, the job will stall forever.

# time is the time requested for the nodes. If the job does not finish in this time it will be killed.
# longer duration requests may take longer to be granted.
#SBATCH --time=1:00:00
#SBATCH --mail-user=<netid>@iastate.edu

# Specify the types of job status messages you would like to receive.
#  BEGIN - send a message when the job starts.
#  FAIL - send a messages if the job fails.
#  END - send a message when the job runs to completion.
#SBATCH --mail-type=BEGIN,FAIL,END

#change to the directory where the job data is located. should be under a work directory for your group.
cd /work/<your work group>/<rest of path>

#module purge ensures no other modules are loaded.
module purge

#load the Ansys module. version number can be changed.
module load ansys/19.2

#this line actually runs the program. note the number after -np should match the ntasks field above.
#the input file is just a textfile of the apdl commands, this file should be created in the location you are running from.
mapdl -p aa_r -np 16 -mpi INTELMPI -dir "/work/<same path as above>" -j "<job-name>" -i <input-command-file> -o <your-output-name>.out


#after the run is completed there may be many different output and error files (potentially one per processor used).
# there should also be a complete log output in a file with a .log extension.
# the most useful files output from this run are usually the .db and .dbb files.

#these can be copied and run in the desktop client to view data and graphs etc.