Skip to main content

PathAnalysis package for pressure vessel licensing procedures in Ansys Mechanical

Tiago Pomella Lobo | 09.01.2023

This article was submitted by Tiago Pomella Lobo of Karlsruhe Institute of Technology and presents his PathAnalysis package for use with ACT in Ansys Mechanical.


Our challenge - At the Ansys CodeFest in KIT 2023

During the last ANSYS CodeFest 2023 held in the Karlsruhe Institute of Technology (KIT, Germany), my group decided to participate with a work challenge that we brought ourselves: the creation of a custom toolbar for our ANSYS Mechanical installations, to enable us to compute and export stress and temperature analyses along linear paths between a point and surface.

For those of you familiar with regulations & codes for licensing pressure vessels, this will sound familiar; standards such as the ASME's BPVC Section VIII and the afcen's RCC-MRx Code require linearization procedures to evaluate average and varying components along selected paths, as a means of qualifying a design. For all others, check here, here or here for example, for more information on linearization along FEM/FEA paths; this article also provides a good discussion on the topic.

Due to the limited time of the event, our group decided to develop a simple (i.e. quick and dirty) set of Python scripts and embed them into a set of buttons in ANSYS Mechanical, in its own toolbar menu. The resulting package can be now found in its own GitHub repository. For this work, we've used Mechanical 2023 R1.

Our solution - The PathAnalysis Package

The toolbar menu that we developed can be seen below. It includes a Path button, a Calculate button and a Delete sub-menu for both stress and temperature solutions.

Toolbar menu of the PathAnalysis extension.

The workflow idealized for the extension included the following steps:

  1. first create named selections for both a node and a surface in your results;
  2. then click the Path button (route icon) in the toolbar to determine and create the shortest path between them;
  3. then click the Calculate button (calculator icon) to compute the stress and temperature analysis summaries and export them as a CVS file on your Desktop.

Implementation was performed by associating each button with a function written in Python, which can be found in the .py files of the package. The toolbar menu itself was created with the PathAnalysis.XML file, by using the toolbar tag to define a new toolbar menu, and one entry tag for each toolbar button. The icon tag was used to associate an image to each button, and the callback and onclick tags were then used to link Python functions to them:

<toolbar name="Analysis along path" caption="Path Analysis">
    <entry name="Create shortest path" caption="Path" icon="route">
        <onclick>create_shortest_path</onclick>         <!-- Call Python function when clicked -->

When implementing these steps, we realized it would best if the Calculate button could perform its action for multiple paths at the same time, so we modified the original Python functions we had idealized in a way that steps 1 and 2 could be repeated as many times as necessary (i.e. to create many paths). To make the workflow repeatable and debugging easier, we also implemented the Delete sub-buttons (under the paper shreder icon), that could be used to delete analysis solutions for all paths at the same time.

Our example

An example file has been included in the repo to test the extension after it has been installed and enabled (see the README for more information). It contains a named Node and a named Surface that can define a path, in a simple geometry loaded with a simple temperature distribution. Altering the given node/surface and clicking Path a few times can provide us with linear paths to perform an example analysis, as seen below.

Multiple paths created by changing the Node and Surface named selections.

Hitting Calculate gives us the linearized analyses for both stresses and temperatures, and it also exports a CSV file onto the Desktop that can be opened with Excel, for example, as shown below.

One of the path analysis solutions: the Linearized Equivalent Stress along the first path.

Solution summaries exported and opened as a spreadsheet.

I like where you are with this (and I'd like to try it out)

An installation guide can be found in the GitHub repository, but it is as simple as copying the contents of the repo's extensions folder into the directory of same name of your installation! After that, the extension must be loaded in the Workbench toolbar (Extensions > Extensions Manager) by enabling the check-box for PathAnalysis. The extension menu will then appear in the toolbar of your window for visualization of results and you can use it to your heart's content!

I like where you're going with this (and I'd like to follow your work)

As mentioned before, this extension was developed quickly due to our limited time during the CodeFest. But we intend to keep working on it to improve its features and use-cases. Next in line are:

  • add the correct logging functions to each function, to facilitate debugging processes;
  • use the direction between the named point and named surface to limit the number of iterations in the loop that searches the shortest path between them;
  • modify the automatic path naming function and fixed named selection basis (of both node and surface) to more generic functionalities.

And, in case anyone is wondering, any contributions to the repo are more than welcome! In such a case, as we were taught by our kind instructor Rohith Patchigolla during the event, it is always a good idea to enable the debugging mode in the ANSYS Mechanical GUI (in Tools > Options > Extensions, enable the check-box for Debug Mode). For additional information on XML tags and custom extensions, one can always check the Online API and XML Reference Guides in ANSYS ACT Developers Guides.


As I can now attest, the ANSYS CodeFest events can not only be fun, but also very fruitful! We brought our own implementation challenge to automatize workflows for qualifying pressure vessel designs, and we are happy to say we were extremely successful. Our group now has an ANSYS Mechanical extension that can be installed by anyone, which adds a custom toolbar menu that can automatically find and create the shortest path between a pair of named Node and Surface, compute linearized (stress and temperature) solutions along those paths, and also export and delete those results. Fruitful indeed!

Tiago Pomella Lobo