Python Result example of Custom Stress calculation

Member, Moderator, Employee Posts: 888
100 Answers 500 Comments 250 Likes Second Anniversary
✭✭✭✭

Can DPF and a Python Result be used to create and plot a custom stress value?

Tagged:

Answers

  • Member, Moderator, Employee Posts: 888
    100 Answers 500 Comments 250 Likes Second Anniversary
    ✭✭✭✭

    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:

    1. def post_started(sender, analysis):# Do not edit this line
    2. define_dpf_workflow(analysis)
    3.  
    4. # Uncomment this function to enable retrieving results from the table/chart
    5. def table_retrieve_result(value):# Do not edit this line
    6. import mech_dpf
    7. import Ans.DataProcessing as dpf
    8. wf = dpf.Workflow(this.WorkflowId)
    9. wf.Connect('contour_selector', value)
    10. this.Evaluate()
    11.  
    12. def define_dpf_workflow(analysis):
    13. import mech_dpf
    14. import Ans.DataProcessing as dpf
    15. mech_dpf.setExtAPI(ExtAPI)
    16. data_source = dpf.DataSources(analysis.ResultFileName)
    17.  
    18. timePointsOp =dpf.operators.metadata.time_freq_provider()
    19. timePointsOp.inputs.data_sources.Connect(data_source)
    20. timepoints = dpf.operators.metadata.time_freq_support_get_attribute(time_freq_support=timePointsOp,property_name="time_freqs",)
    21.  
    22. prin1 = dpf.operators.result.stress_principal_1()
    23. prin1.inputs.data_sources.Connect(data_source)
    24. prin1.inputs.time_scoping.Connect(timepoints)
    25.  
    26. prin3 = dpf.operators.result.stress_principal_3()
    27. prin3.inputs.data_sources.Connect(data_source)
    28. prin3.inputs.time_scoping.Connect(timepoints)
    29.  
    30. minus_fc = dpf.operators.math.minus_fc()
    31. minus_fc.inputs.field_or_fields_container_A.Connect(prin1.outputs.fields_container)
    32. minus_fc.inputs.field_or_fields_container_B.Connect(prin3.outputs.fields_container)
    33.  
    34. scale = dpf.operators.math.scale_fc()
    35. scale.inputs.fields_container.Connect(minus_fc)
    36. scale.inputs.ponderation.Connect(sqrt(2)/2)
    37.  
    38. dpf_workflow = dpf.Workflow()
    39. dpf_workflow.Add(scale)
    40. dpf_workflow.SetOutputContour(scale)
    41. dpf_workflow.Record('wf_id', False)
    42. this.WorkflowId = dpf_workflow.GetRecordedId()
  • Member, Employee Posts: 31
    Second Anniversary 10 Comments 5 Likes Name Dropper
    ✭✭✭✭

    Can someone explain what this line does:

    timepoints = dpf.operators.metadata.time_freq_support_get_attribute(time_freq_support=timePointsOp,property_name="time_freqs",)

Welcome!

It looks like you're new here. Sign in or register to get started.