About one month ago (January 2021), Abaqus Student Edition 2020 was released.
This new version not only includes novelties in the fields of interactions, enhanced compatibility of different finite elements, improvements in some constitutive models… But it also includes what will become a true revolution for Abaqus/Scripting users.
Updates in the Python environment
And here we go, Abaqus 2020 brings a series of updates for the Python interpreter on which Abaqus/Scripting runs. Although it is still Python 2.7, this new version includes three new libraries (or modules) that multiply the variety of actions that can be performed by means of scripting in Abaqus:
Matplotlib
With this library you can make all kind of graphics and plots in 2D and 3D (histograms, contoured plots, rastered images…). It is widely used for data visualization in scientific publications and all sort of reports.
SciPy
This scientific library is supported by numpy to carry out advanced mathematical operations, such as solving nonlinear equations.
SymPy
This library enables the use of symbolic mathematics by employing analytical closed-form expressions, similar to other softwares like Mathematica
What has actually changed?
The table below sums up the main changes from Abaqus 2019 and Abaqus 2020 regarding Python libraries:
Abaqus 2019 | Abaqus 2020 | |
---|---|---|
python | 2.7.3 | 2.7.15 |
numpy | 1.6.2 | 1.15.4 |
matplotlib | - | 2.2.4 |
scipy | - | 1.2.0 |
sympy | - | 1.3 |
What else can we do now in Abaqus/Scripting?
In this post we will not dive into the details of each of these three new libraries that Abaqus 2020 has to offer, but we can point out de brand new possibility of making high quality plots directly from scripts within Abaqus thanks to Matplotlib.
From now on, we will not only be able to export numerical results as plain text files, csv or Excel, but we can produce curves and plots to visualize the results of hundreds of different simulations or obtaining figures that we can include later in our technical reports and projects.
A quick example in Matplotlib
If we want to test how MAtplotlib works in Abaqus 2020, we can just copy and paste the following few lines of code on the console inside Abaqus/CAE (command line interface). We can also copy these lines in a script (with extension .py) and run it from Abaqus/CAE (File > Run Script…).
Python
import matplotlib.pyplot as plt import numpy as np # Create a figure with one axes fig, ax = plt.subplots() # Generate 100 points evenly spaced between -5 and 5 x0 = np.linspace(-5., 5., 100) # y = f(x), function to plot in the next line y0 = np.exp(-x0**2) # Plot x vs. y with black dots, label will be used in the legend ax.plot(x0, y0, 'k.', label=r'$e^{-x^2}$') # Label of the x axis ax.set_xlabel(r'$x$') # Label of the y axis ax.set_ylabel(r'$y$') # Display the legend, i.e. the label of the plotted line ax.legend() # Export the figure into a pdf file (vector quality) fig.savefig('mylines.pdf') # Display the figure on the screen, otherwise we will not see it plt.show()
The previous example generates a plot with a single curve: \(y(x) = e^{-x^2}\) at \(-5 \leq x \leq 5\) with black dots. In addition, the figure is exported to a pdf file that we can visualize and use later.

The customization options are almost infinite in Matplotlib. If you want to see more examples of what you can do with Matplotlib, I recommend you to take a look at the gallery in the official website.
I hope that you find these tips useful!
0 Comments