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.

Get Your Ansys Products & Support from the Engineers who Contribute to this Blog.

Technical Expertise to Enable your Additive Manufacturing Success.

Share this post:

Upcoming Events

Apr 29
, 2025
New NVH Tools & Workflows in Ansys 2025 R1 - Webinar
Apr 29
, 2025
Design, Debug, and Test your Ansys Scade One Model - Webinar
May 01
, 2025
Applying Digital Engineering across Space Mission Analysis and Design - Webinar
May 07
, 2025
Meshing Updates in Ansys 2025 R1 - Webinar
May 07
, 2025
Transforming Robot Arm Design with Topology Optimization - Webinar
May 13
, 2025
Ansys Virtual Workshop - PCB Reliability with Sherlock
May 13
, 2025
Dynamic RF Interference: HFSS and STK for Antenna Array Control - Webinar
May 15
, 2025
Applying Digital Engineering across Space Mission Analysis and Design: Satellite - Webinar
May 21
, 2025
Optics Updates in Ansys 2025 R1 - Webinar
May 29
, 2025
Applying Digital Engineering across Space Mission Analysis and Design: Payload - Webinar
Jun 04
, 2025
Composites & Structural Optimization Updates in Ansys 2025 R1 - Webinar
Jun 09
- Jun 11
, 2025
TechConnect World 2025
Jun 18
, 2025
Fluent CPU - UI & UX Updates in Ansys 2025 R1 - Webinar
Jun 16
- Jun 20
, 2025
Turbo Expo
Jun 25
, 2025
E-Mobility and Clean Energy Summit
Jul 02
, 2025
Electric Machine & Consumer Electronics Updates in Ansys 2025 R1 - Webinar
Jul 11
, 2025
2025 Aerospace, Aviation, Defense and Manufacturing Conference
Jul 16
, 2025
HFSS Updates in Ansys 2025 R1 - Webinar
Aug 10
- Aug 13
, 2025
SmallSat 2025

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: