Skip to content

Ansys/Mechanical

Note

The main ansys binary will not run without -mpi openmpi appended as a flag to the binary, i.e. you need to run it as:

ansys2021r2 -mpi openmpi [other options]

Mechanical

1. Prepare your model in Ansys/Workbench on a visualization node.

2. Open it in Ansys/Mechanical and export an input .dat file:

Double-click on your project in Workbench to open Mechanical:

VNC client window

Export a new .dat input file with Solution -> Write Input File:

VNC client window

3. Prepare a submission script and submit a job to the queue:

#!/bin/sh
#
#SBATCH --job-name="ansys"
#SBATCH --partition=compute
#SBATCH --time=00:10:00
#SBATCH --nodes=1
#SBATCH --ntasks=4
#SBATCH --cpus-per-task=1
#SBATCH --mem-per-cpu=2GB
#SBATCH --account=research-<faculty>-<department>

module load 2022r2
module load openmpi
module load ansys

# Run ansys headlessly with OpenMPI:
ansys2021r2 -mpi openmpi -dis -b nolist -np $SLURM_NPROCS -dir workfolder -i test-input-file.dat -o solve.log

Save this as e.g. "run-ansys.sh" and submit the job with:

sbatch run-ansys.sh

After the job is finished, the results will be saved in a newly created folder called "workfolder" (feel free to rename). The output log file "solve.log" will be inside of this folder. It should contain something along the lines of:

          *****  ANSYS COMMAND LINE ARGUMENTS  *****
  BATCH MODE REQUESTED (-b)    = NOLIST
  INPUT FILE COPY MODE (-c)    = COPY
  DISTRIBUTED MEMORY PARALLEL REQUESTED
       4 PARALLEL PROCESSES REQUESTED WITH SINGLE THREAD PER PROCESS
    TOTAL OF     4 CORES REQUESTED
  MPI OPTION                   = OPENMPI
  INPUT FILE NAME              = /scratch/NetID/ansys/test-input-file.dat
  OUTPUT FILE NAME             = /scratch/NetID/ansys/workfolder/solve.log
  INITIAL DIRECTORY = /scratch/NetID/ansys/workfolder

to indicate that we are successfully running things in parallel.

4. Open your result in Workbench

The job in section 3. creates multiple fileX.rst files, one per CPU core requested in the submitted job above. There is also a single combined .rst file in the end, called file.rst. You can load this into your Workbench. To do so, open your original Workbench project file (without a solution), click on "Solution" in the tree of "Static Structural", go to the "Context" tab in the menu bar, select "read result files", and choose the file.rst file.