Using Ansys Scripting with pyMAPDL, pyDPF-Post, and More – PART 2: Solving and post-processing ANSYS models in Python

Categories:

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:

  1. Build models in Ansys Mechanical
  2. Programmatically control solving the model in Ansys MAPDL
  3. Extract the stiffness matrix and load vectors
  4. Post-process the displacement and stress solution in Python

Now, in part 2 of his series, he goes through the following steps:

  1. Build models in Ansys Mechanical
  2. Programmatically control solving the model in Python
  3. Look at the Degree of Freedom ordering in the Ansys solver
  4. 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:

  1. Know how to read the Ansys .full file with for use in Python
  2. 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.

Share this post:

Upcoming Events

Jan 07
- Jan 10
, 2025
CES 2025
Jan 22
- Jan 25
, 2025
Arizona Photonics Days 2025
Feb 04
- Feb 06
, 2025
MD&M West 2025
Feb 04
- Feb 06
, 2025
2025 Transformative Vertical Flight
Apr 07
- Apr 10
, 2025
40th Space Symposium

Search the PADT Site

Contact Us

Most of our customers receive their support over the phone or via email. Customers who are close by can also set up a face-to-face appointment with one of our engineers.

For most locations, simply contact us: