DPF question on layered shell data post processing

Hello,
Code like below which seems to work to read maximum principal stresses in a named selection. However, my selection is shell181 with 5 layers, and I want to get the stresses only in layer 4. I was trying a few things based on (https://dpf.docs.pyansys.com/version/stable/api/ansys/dpf/core/operators/utility/change_shell_layers/change_shell_layers.html#ansys.dpf.core.operators.utility.change_shell_layers.change_shell_layers), but I could not make it work.
Can you please advise on how we can scope to get layer 4 stresses. Please see code below without scoping layers.
Right now, I am post processing ANSYS mechanical results, but ultimately, I want to apply to LS Dyna, is Python snippet same for both or I need changes for LS Dyna?
import mech_dpf
import Ans.DataProcessing as dpf
mech_dpf.setExtAPI(ExtAPI)
Get path to result file
import os
folder = r"......"
filename = "file.rst"
filepath = os.path.join(folder, filename)
fileOutname = "results_py.txt"
fileOutpath = os.path.join(folder, fileOutname)
Data sources
dataSources = dpf.DataSources()
dataSources.SetResultFilePath(filepath)
Model
model = dpf.Model(dataSources)
print(model.TimeFreqSupport)
Using time scopings
time_scoping = dpf.Scoping()
number_sets = model.TimeFreqSupport.NumberSets
time_scoping.Ids = range(1, number_sets + 1)
Scoping on named selection
scoping_on_ns = dpf.operators.scoping.on_named_selection()
scoping_on_ns.inputs.requested_location.Connect('Nodal')
scoping_on_ns.inputs.named_selection_name.Connect('my_named_selection')
scoping_on_ns.inputs.data_sources.Connect(dataSources)
my_mesh_scoping = scoping_on_ns.outputs.mesh_scoping.GetData()
1st Principal Stress
stress1Op = dpf.operators.result.stress_principal_1()
stress1Op.inputs.data_sources.Connect(dataSources)
stress1Op.inputs.mesh_scoping.Connect(my_mesh_scoping)
stress1Op.inputs.time_scoping.Connect(time_scoping)
s1 = stress1Op.outputs.fields_container.GetData()
2nd Principal Stress
stress2Op = dpf.operators.result.stress_principal_2()
stress2Op.inputs.data_sources.Connect(dataSources)
stress2Op.inputs.mesh_scoping.Connect(my_mesh_scoping)
stress2Op.inputs.time_scoping.Connect(time_scoping)
s2 = stress2Op.outputs.fields_container.GetData()
3rd Principal Stress
stress3Op = dpf.operators.result.stress_principal_3() # Corrected to stress_principal_3()
stress3Op.inputs.data_sources.Connect(dataSources)
stress3Op.inputs.mesh_scoping.Connect(my_mesh_scoping)
stress3Op.inputs.time_scoping.Connect(time_scoping)
s3 = stress3Op.outputs.fields_container.GetData()
Initialize a list to store max principal stresses for each time step
max_principal_stresses = []
for i in range(number_sets):
Max 1st Principal Stress
max_min_op = dpf.operators.min_max.min_max(field=s1[i])
max_value1 = max_min_op.outputs.field_max.GetData().Data[0]
Max 2nd Principal Stress
max_min_op = dpf.operators.min_max.min_max(field=s2[i])
max_value2 = max_min_op.outputs.field_max.GetData().Data[0]
Max 3rd Principal Stress
max_min_op = dpf.operators.min_max.min_max(field=s3[i])
max_value3 = max_min_op.outputs.field_max.GetData().Data[0]
Store the values in the list as a tuple
max_principal_stresses.append([max_value1, max_value2, max_value3])
Write the matrix/table of max principal stresses to results.txt
with open(fileOutpath, 'w') as f:
for row in max_principal_stresses:
f.write("{}\t{}\t{}\n".format(row[0], row[1], row[2]))
print("Max principal stresses have been written to results.txt.")
Comments
-
@Hrishikesh.Panchanwagh
The layers operator in DPF can be a bit confusing, it is actually meant to walk you through Shell positions top, bottom and mid -0:Top, 1: Bottom, 2: BottomTop, 3:Mid, 4:BottomTopMid
Multilayered Shells are not supported as of now.
For extracting LS-Dyna results refer to the example below:
0 -
Thank you, Ayush. I appreciate your help. I will look at the examples.
For my problem, it is important to determine stresses in a particular layer. Also, I already have APDL snippet for mechanical and I need to process LS Dyna results (I have save output at all integration points.). For LS Dyna layered sections / multilayer shells, do I need to use PyDPF composites? Does it support only mechanical solver? Or should I use PyDyna or another package?
If none of this support extracting result from LS dyna results, is there a straightforward way to export Principal stresses and nodal areas from WB? I am able to plot selected layer results from WB Solution Plots.
0 -
@Hrishikesh.Panchanwagh PyDPF composites doesn't support LS-Dyna results yet. @Javier Vique, can you please confirm?
Regarding:
is there a straightforward way to export Principal stresses and nodal areas from WB?
Can you please create a technical support request for this question? It will be handled and answered by one of Ansys' Technical Support Engineers.
0 -
@Hrishikesh.Panchanwagh to add to my last comments. SHELL181 multilayered results can be extracted using PyDPF composites, as it supports only MAPDL results.
Check limitations on the documentation page:
0 -
Thank you, Ayush. I will create a technical support request. Best!
1