I want to calculate signed von mises in Python Result. I see there is a long winded way.
If you want to display this in Mechanical, creating a Python Result is the way to go. In that case you'll be using Mechanical DPF (and not PyDPF). There are many examples in this forum that could help.
Thanks Pernelle. What is the operator to extract the sign of largest principal stress in absolute value. I used min_max max by component to get the largest abs (principal stress), but not the sign. Please help.
Perhaps @Ayush Kumar can help?
@DSSim I don't believe we have an operator in DPF to get the sign of the absolute max / min. You can combine DPF and Numpy to get the desired results.
import numpy as np from ansys.dpf import core as dpf dpf.start_local_server(ansys_path=r"C:\Program Files\ANSYS Inc\v252") rst = r"D:\…\file.rst" model = dpf.Model(rst) stress = model.results.stress() s1 = dpf.operators.invariant.principal_invariants_fc(fields_container=stress).eval() arr = s1[0].data # 1. Find the index of the maximum absolute value idx = np.argmax(np.abs(arr)) # 2. Get the sign of the value at that index result_sign = np.sign(arr.flat[idx]) print(f"Sign of highest absolute value: {result_sign}")