How do you transform direction stresses to a different coordinate system in DPF
In a Python Result in Mechanical I want to get stresses in a cylindrical (or any other coordinate system). Is there a built in method to transform stresses?
Best Answer
-
For cartesian coordinates use the following script:
import mech_dpf import Ans.DataProcessing as dpf mech_dpf.setExtAPI(ExtAPI) analysis = Model.Analyses[0] model = dpf.Model(analysis.ResultFileName) # Stress Tensor in GCS s = dpf.operators.result.stress() s.inputs.data_sources.Connect(dataSource) s.inputs.requested_location.Connect("Nodal") s_gcs_f = sx.outputs.fields_container.GetData()[0] # Get the Local coordinate system using APDL ID cs = model.CreateOperator(r"mapdl::rst::CS") cs.inputs.cs_id.Connect(14) cs_rot_mat = list(cs.outputs.field.GetData().Data)[0:9] rot_mat_f = dpf.FieldsFactory.CreateScalarField(1) rot_mat_f.Data = cs_rot_mat # Rotation Matrix pos_vec = dpf.FieldsFactory.Create3DVectorField(1) pos_vec.Data = list(cs.outputs.field.GetData().Data)[-3:] pos_vec_rot = dpf.operators.geo.rotate(field=pos_vec, field_rotation_matrix=rot_mat_f) # Rotate stress tensor s_lcs_rot = dpf.operators.geo.rotate(field=sx_gcs_f, field_rotation_matrix=rot_mat_f) s_lcs_rot_f = sx_lcs_rot.outputs.field.GetData() # SX in GCS sx_gcs_f = dpf.operators.logic.component_selector(field=s_gcs_f, component_number=0) sx_gcs_nid_1 = sx_gcs_f.outputs.field.GetData().GetEntityDataById(1) # SX in LCS sx_lcs_f = dpf.operators.logic.component_selector(field=s_lcs_rot_f, component_number=0) sx_lcs_nid_1 = sx_lcs_f.outputs.field.GetData().GetEntityDataById(1)
For Cylindrical CS use: https://dpf.docs.pyansys.com/version/stable/api/ansys.dpf.core.operators.geo.rotate_in_cylindrical_cs.html
1
Answers
-
Hi there, thanks for the information this is very helpful.
I am struggling to get the operator working (r"mapdl::rst::CS"). I think this is due to the CSYS IDs not being present in the .rst file.
I have changed the local CSYS in workbench to have manual ID input, and changed this to a desired number above 12. When I try to call on the ID in the code comes with error stating that there is no CSYS with that ID. Example below where i have manually given the CSYS ID 20
"mapdl::rst::CS:46<-Coordinate System ID '20' not found in rst file"
I have tried rerunning the analysis after renaming the CSYS, but i cannot seem to call it to use the operator.
Any assistance / ideas would be very much appreciated.
Paul
0 -
@Paul Eames Seems like an issue where you need to close down Mechanical, manually clear the RST file and then resolve. To me it looks like, the older DPF process has blocked the RST and resolving doesn't help because it still access the old RST.
You can check the list of CSYS in the RST using the
CSLIST
APDL command:1 -
@Ayush Kumar this seems to have done the trick thanks.
appreciate the help and the fast response.
1 -
FYI this “holding” of the results file was a defect in older versions. It has generally been addressed, but if it is ever seen in current versions contact your local ANSYS technical support.
2