Python Result example of Custom Stress calculation
Pernelle Marone-Hitz
Member, Moderator, Employee Posts: 871
✭✭✭✭
in Structures
Can DPF and a Python Result be used to create and plot a custom stress value?
Tagged:
0
Answers
-
Here is an example. Please note that this is just a coding example and has no physical meaning.
This example will extract the principal stresses S1 and S3, evaluate S1-S3 and scale this by a sqrt(2)/2 factor.Code is:
def post_started(sender, analysis):# Do not edit this line define_dpf_workflow(analysis) # Uncomment this function to enable retrieving results from the table/chart def table_retrieve_result(value):# Do not edit this line import mech_dpf import Ans.DataProcessing as dpf wf = dpf.Workflow(this.WorkflowId) wf.Connect('contour_selector', value) this.Evaluate() def define_dpf_workflow(analysis): import mech_dpf import Ans.DataProcessing as dpf mech_dpf.setExtAPI(ExtAPI) data_source = dpf.DataSources(analysis.ResultFileName) timePointsOp =dpf.operators.metadata.time_freq_provider() timePointsOp.inputs.data_sources.Connect(data_source) timepoints = dpf.operators.metadata.time_freq_support_get_attribute(time_freq_support=timePointsOp,property_name="time_freqs",) prin1 = dpf.operators.result.stress_principal_1() prin1.inputs.data_sources.Connect(data_source) prin1.inputs.time_scoping.Connect(timepoints) prin3 = dpf.operators.result.stress_principal_3() prin3.inputs.data_sources.Connect(data_source) prin3.inputs.time_scoping.Connect(timepoints) minus_fc = dpf.operators.math.minus_fc() minus_fc.inputs.field_or_fields_container_A.Connect(prin1.outputs.fields_container) minus_fc.inputs.field_or_fields_container_B.Connect(prin3.outputs.fields_container) scale = dpf.operators.math.scale_fc() scale.inputs.fields_container.Connect(minus_fc) scale.inputs.ponderation.Connect(sqrt(2)/2) dpf_workflow = dpf.Workflow() dpf_workflow.Add(scale) dpf_workflow.SetOutputContour(scale) dpf_workflow.Record('wf_id', False) this.WorkflowId = dpf_workflow.GetRecordedId()
0 -
Can someone explain what this line does:
timepoints = dpf.operators.metadata.time_freq_support_get_attribute(time_freq_support=timePointsOp,property_name="time_freqs",)
0