ABAQUS is widely used in the finite element analysis of large deformation of solids, which provides Fortran and C++ api for user-defined material constitutive behaviour by developing user subroutines. Due to historical reasons, most user subroutines are written in Fortran instead of C++. This is a repositry of severial ABAQUS subroutines of user-defined material model written in C++, which offers a more modern coding style and library management.
It is recommended to use cpp subroutines on linux platforms instead of Windows, since the management of the compilation environment is much simpler. One can use g++ as the compiler of cpp subroutines and set environment variables to invoke external libraries. One shall notice that Debian-based linux distributions are not officially supported by ABAQUS, it is recommended to use Red Hat-based linux distributions such as CentOS, Rocky and SUSE.
Assuming that we are using a linux where ABAQUS is installed properly. One can invoke cpp UMAT or VUMAT in ABAQUS by following steps:
- Prepare basic build tools if not installed, e.g.,
as well as external libraries if used in cpp UMAT or VUMAT, e.g.,
sudo dnf install gcc-c++ make gfortran
sudo dnf install eigen3-devel
- For ABAQUS versions 2024 and later, set the environment variable to specify gfortran as the Fortran compiler for linking, e.g.,
export ABQ_USUB_GFORTRAN=1 - Prepare files including:
- ABAQUS input file, e.g., test.inp
- cpp UMAT or VUMAT file, e.g., umat.cpp or vumat.cpp
- Set environment variables to include external libraries if used in c++ subroutine, e.g.,
export CPLUS_INCLUDE_PATH=/path/to/eigen:$CPLUS_INCLUDE_PATH
- Run ABAQUS with the cpp UMAT or VUMAT, e.g.,
abaqus Job=job_name input=input_file.inp user=vumat.cpp cpus=8 interactive
It is recommended to modify the environment-management python script of ABAQUS to invoke optimization flags of g++, e.g., -O3 -march=native, for better performance of cpp UMAT or VUMAT.
- Locate the environment-management script of ABAQUS by executing:
abq_env_path=$(abaqus information=environment | grep "linux_a64/SMA" | head -n 1 | awk '{print $NF}' | sed 's#\(.*linux_a64/SMA\).*#\1#' | awk '{print $0 "/site/lnx86_64.env"}') echo $abq_env_path
- Append the following lines at the end of the script by excecuting:
This will add optimization flags for g++ compilation.
cp $abq_env_path ${abq_env_path}.bak echo "compile_cpp += ['-O3', '-march=native']" >> $abq_env_path