Skip to main content

SUMMARY

In this blog's second part, we delve into the process of extracting results in Ansys Mechanical for complex scenarios, providing a comprehensive guide. We will focus on the integration of advanced extraction methods as ADPL snippets with automation tools as Python, aiming to enhance efficiency. We will use a simple, step-by-step example that illustrates the entire procedure. This example serves as a foundational approach that can be adapted and expanded to meet more specific requirements, thereby equipping you with the skills needed to tackle a wide range of computational simulation challenges effectively.

Problem statement

Consider a scenario involving a complex model where it is necessary to generate user-defined results for multiple 'hidden' elements, such as joints. One approach involves manually creating these user result objects individually by utilizing the solution Worksheet and employing the 'Result File Item' method for scoping. Alternatively, Python automation can be employed to facilitate the creation of result objects by iterating through the joints; however, it remains essential to accurately scope each object in relation to its corresponding joint.

The example presented in this blog entry shows how to solve this problem: Create individual user result objects for each joint keeping clear relation between these connectors and their results.

 

Process steps

1. Iterate through the joint connectors: Modifying their names and assigning unique 'Element APDL Name' property to each object. Python programming is used for this task and the script can be run anytime before solving.

 

2. Solve the model and export parameters: An APDL snippet allows to export an external file that contains the  the MPC184 joint element number assigned to the APDL name. This is the key to relate each joint to the result object. Inserting this object in the solution branch will export the file after the solving stage.

 

3. Create a result object for each joint: By looping through the joints and the exported file is possible to create individual results scoping to each joint element. A new Python routine makes this task efficiently assigning  names that allows clear identification with the corresponding joint. This last can be run after the model is solved. 

Example
The model contains three fixed joints created to connect the holes in two separate shell bodies. We want to create a nodal force reaction user result for each of them through the expression 'ENFOX'.

Now, let's dive into the first Python script. This one must be executed before solving the model. The first two lines create API objects to store the joint connector list called 'Con_Joints'. After that, this list is looped choosing the active joints only and a counter is increased. Finally the properties 'Name' and 'JointElementAPDLName' are updated using the counter number. This will allow the user to identify and relate each result with the joint connectors.

Once all the joints have an adequate name and the APDL Name is populated, we can solve the model. In this point the APDL is inserted in the Solution branch to export the scalar parameters set in an external text file stored in the solver files directory using the PARSAV command. This is how the magic happens, at this point we are connecting the User interface objects with the solver information.

 

Finally, a new Phyton routine creates the results. The beginning lines are intended to store the user expression string 'ENFOX' and create the API objects extracting the joints list in the 'Con_Joints' list. Other necessary object named 'this_an_sol' points to the solution section of the analysis. The second block opens the text file previously created and creates a list named 'content' where each element is a line.

In the same routine the next step is actually iterate through the connectors list comparing each of them with the text file lines searching the joint ADPL name. Once the match is found, the result object is created scoping the mesh element already registered in the parameter list previously exported.

Finally, for user readability these objects are grouped. This allows to create more groups if necessary without charging too much the visibility.

Downloadable Resources

2024R2 Post-processing Project file

Other useful Python Resources

https://blog.ozeninc.com/resources/using-python-to-export-tabular-data-from-within-ansys-mechanical

https://blog.ozeninc.com/resources/using-python-in-ansys-mechanical-to-search-the-tree-generate-scripts

https://blog.ozeninc.com/resources/introduction-to-scripting-in-ansys-mechanical

https://blog.ozeninc.com/resources/creating-bolt-tools-for-postprocessing-in-ansys-mechanical-using-python-scripting

 

CONCLUSION

In conclusion, this blog entry has walked you through a systematic approach to handling complex scenarios in Ansys Mechanical using advanced extraction methods combined with Python automation. By following the step-by-step example provided, you now have a foundational strategy to efficiently create and manage user-defined result objects for intricate models, such as those involving multiple hidden elements like joints. This method not only enhances precision but also streamlines the process, making it easier to adapt and expand for various computational challenges. With the tools and techniques discussed, you are now better equipped to tackle a wide array of simulation tasks, pushing the boundaries of what you can achieve in your projects.

 

 

Post by Edwin Rodriguez
October 8, 2024