Hi all,
I'm working in Ansys Mechanical 2025 R2, using a Python Result object to extract and visualize the principal stress envelope (S1 − S3) over time.
Hi all,
I'm working in Ansys Mechanical 2025 R2, trying to use a Python Result object to extract and visualize the principal stress envelope (S1 − S3) over time.
Here’s exactly what I’m trying to do:
Use a Python Result object in Ansys Mechanical (not standalone DPF).
For a multi-step structural analysis, extract:
S1: Maximum principal stress (1st principal)
S3: Minimum principal stress (3rd principal)
Compute the difference (S1 − S3) at each node or element.
Display this difference as a contour result in Mechanical, with time scoping (i.e. I want to scroll through time steps).
Ideally, I’d like to make the time step detection automatic — but hardcoding [1,2,3] is fine for now.
I’ve tried using both math.minus() and math.minus_fc(), but consistently run into attribute errors such as:
'InputSpec' object has no attribute 'field'
'InputSpec' object has no attribute 'fields_containerA'
'TimeFreqSupport' object has no attribute 'TimeScoping'
'TimeFreqSupport' object has no attribute 'TimeFreqIds'
So far, my only reliably working script is one that displays just S1 using SetOutputContour(s1). When I try to build on this to subtract S3, I run into the issues above.
🔍 What I’d really appreciate help with:
The correct way (in 2025 R2) to:
Loop over all time steps
Compute S1 − S3
Build a FieldsContainer or DPF workflow that can be plotted
Clarification on which operator input names are valid in Python Result (fieldA, fields_containerA, Connect(0,...), etc.)
How to reliably get the list of time step IDs from the result file in Mechanical
🛠️ Example of what I tried:
s1 = dpf.operators.result.stress_principal_1()
s3 = dpf.operators.result.stress_principal_3()
subtract = dpf.operators.math.minus()
subtract.inputs.fieldA.Connect(s1.outputs.field)
subtract.inputs.fieldB.Connect(s3.outputs.field)
This results in:
AttributeError: 'OutputSpec' object has no attribute 'field'
Any guidance or working examples would be massively appreciated 🙏
Thanks in advance!