This example demonstrates how to link Abaqus python scripting to third party libraries such as pandas
and sklearn
. Abaqus software uses a specially compiled version of python from the standard python distribution. As such we cannot directly link third party packages to Abaqus.
We can, however, indirectly link Abaqus to these 3rd party libraries. To do so we essentially have 2 processes/python scripts running: Abaqus python (which does the pre-post processing of our FEA model) and 'external' python which runs our third party libraries such as sklearn
.
Submit icons created by Freepik - Flaticon
We can run Abaqus python inside our external python script (or vice versa) using the built-in subprocess
module which essentially allows users to run terminal/CMD prompt based commands:
import subprocess
subprocess.run(['abaqus', 'cae', 'noGui=YourScriptHere.py'],shell = True)
We also need a way to communicate between different python processes. The most straightforward is to create intermediate files that both processes can understand such as:
- CSV files
- .npy files
- .mat files
NOTE The example code is intended to run with Abaqus 2024 which uses python 3.10. This will note work if run using older Abaqus versions which use python 2.7. However the above linking will work for older Abaqus versions. The external python used was python 3.9 and can be independent version to Abaqus python.
We create a simple surrogate model of the buckling column found here:
The surrogate model is created using a gaussian process from sklearn. the x samples are the Ramberg-Osgood parameters (
Here
Our goal is to map the material parameters
We use 9 different combinations of
The abaqus model for the buckling column. The model is already completed and we only change the material properties
This is the abaqus script that modifies the material properties (i.e metal plasticity) by reading in params.csv
. The script then creates the abaqus jobs and runs it. Afterwards, the force-time curve is extracted from the results
The external python process writtern as a script. As it is separate from Abaqus python, it can freely use third party tools and packages (in this case sklearn
). It runs the script pillar,py
via subprocess
The external python process written in the form of a jypyter notebook. Allows for easier iterations when designing plots
Some helper functions. Demonstrates that certain custom python code can be freely used between the two python versions. If you are mixing code like this, one should limit third party library code to numpy
and scipy
only.
Test data to compare final model against
intermediate file containing material parameters to use for the current iteration
Within Results/<iteration>/
there also exists a params.csv
file which contains the materials parameters used for that iteration
Stresses to calculate plastic strain at based on material parameters
Found in Results/<iteration>/
. Contains the force-time data from the results of that iteraction
Other files are those generated by Abaqus. If you want to visualize the results of an iteration in Abaqus, please refer to the odb file found in Results/<iteration>/
NOTE The example code is intended to run with Abaqus 2024 which uses python 3.10. This will note work if run using older Abaqus versions which use python 2.7. The external python used was python 3.9.
You will first need to have a valid Abaqus 2024 version and access to a license.
Clone this repository or download it as a zip and extract the contents
git clone https://github.com/JohnCSu/Abq_2_ThirdPartyLibrary.git
Install requirements (mainly just numpy and sklearn)
cd Abq_2_ThirdPartyLibrary
pip install -r requirements.txt
Then open up the external.ipynb
or external.py
and run!
MIT