A few months ago, PADT’s Alex Grishin posted an article about using the ever-improving Ansys scripting capabilities for Ansys Mechanical with Python using a tutorial to solve in Ansys MAPDL and then post-process in Python. The post covered how to:
- Build models in Ansys Mechanical
- Programmatically control solving the model in Ansys MAPDL
- Extract the stiffness matrix and load vectors
- Post-process the displacement and stress solution in Python
Now, in part 2 of his series, he goes through the following steps:
- Build models in Ansys Mechanical
- Programmatically control solving the model in Python
- Look at the Degree of Freedom ordering in the Ansys solver
- Post-process the displacement and stress solution in Python
The big difference is using Ansys scripting for solving in Python rather than Ansys Mechanical APDL. But there is a lot more in the tutorial. Things important to Ansys scripting, like DOF ordering, dealing with higher order elements, and who to figure out how Ansys stores the matrix information.
Now we are getting into the nitty gritty of FEA solving, and even if you never have a need to solve your models outside of the Ansys solver, knowing how to do it in Python will help you understand how everything works under the hood. And if you do need to get fancy and do your own solving in Python or prep your matrices for a different solver with Python, this article should help. It also helps the reader understand the mechanics of post-processing for higher-order elements.
In the middle of running this standard NAFEMS challenge problem, Alex uncovered some issues involving an inherent numerical issue worth understanding. He also introduces a new Python library for results plotting, Matplotlib.
As Alex mentions in his final notes, after reading and understanding this content, you should:
- Know how to read the Ansys .full file with for use in Python
- Understand how element contour plots are rendered.
Tutorial on Using Ansys Scripting to Solve and Post Process and Ansys Mechanical Model in Python
Please find the PDF of the tutorial here:
And here is a zip file with the Ansys Mechanical Database
We hope that you find these two tutorials useful and can use them to explore your own applications using Ansys scripting or to understand the math behind FEA better. And don’t forget, if you are interested in having PADT help you with Ansys scripting, contact us and let’s talk.