Minimum result over frequency and Sweeping Phase in a Harmonic Analysis

Stelios
Stelios Member, Employee Posts: 10
First Comment Ansys Employee

How can you extract the minimum principal stress over all frequencies and sweeping phase with amplitude set to false?

Comments

  • Stelios
    Stelios Member, Employee Posts: 10
    First Comment Ansys Employee
    edited December 2023
      import System.Collections.Generic as Collections
    
       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()
    
       #Creating Funcion to multiply data with (-1)
       def mult_by_neg_1(field):
       field_data = list(field.Data)
       return Collections.List[float]([field_data[i]*(-1) for i in range(len(field_data))])
    
       def define_dpf_workflow(analysis):
       import mech_dpf
       import Ans.DataProcessing as dpf
       mech_dpf.setExtAPI(ExtAPI)
       ds = dpf.DataSources(analysis.ResultFileName)
    
       #Retrieving Frequencies
       op = dpf.operators.metadata.time_freq_provider()
       op.inputs.data_sources.Connect(ds)
       my_time_freq_support = op.outputs.time_freq_support.GetData()
       freq_list = list(my_time_freq_support.TimeFreqs.Data)
    
       #Retrieving the minimum principal stress
       op = dpf.operators.result.stress_principal_3()
       op.inputs.time_scoping.Connect(freq_list)
       op.inputs.data_sources.Connect(ds)
       my_fields_container = op.outputs.fields_container.GetData()
       my_fc = dpf.FieldsContainer()
       my_fc.Labels = ["time"]
    
       #Running through the results to find min values
       for j in range(0, 2*len(freq_list), 2):
           my_fields_container[j].Data = mult_by_neg_1(my_fields_container[j])
           my_fields_container[j+1].Data = mult_by_neg_1(my_fields_container[j+1])
           op = dpf.operators.min_max.max_over_phase()
           op.inputs.real_field.Connect(my_fields_container[j])
           op.inputs.imaginary_field.Connect(my_fields_container[j+1])
           op.inputs.abs_value.Connect(False)
           # op.inputs.phase_increment.Connect(my_phase_increment)
           my_field = op.outputs.field.GetData()
           my_field.Data = mult_by_neg_1(my_field)
    
           my_fc.Add(my_field, {"time": j//2+1})
    
       op = dpf.operators.min_max.min_max_by_entity() # operator instantiation
       op.inputs.fields_container.Connect(my_fc)
       my_field_min = op.outputs.field_min.GetData()
       my_field_max = op.outputs.field_max.GetData()
       op = dpf.operators.utility.forward() # operator instantiation
       op.inputs.any.Connect(my_field_min)
       # my_any = op.outputs.any.GetData()
       dpf_workflow = dpf.Workflow()
       dpf_workflow.Add(op)
       # dpf_workflow.Add(nrm)
       # dpf_workflow.SetInputName(u, 0, 'time')
       # dpf_workflow.Connect('time', timeScop)
       dpf_workflow.SetOutputContour(op)
       dpf_workflow.Record('wf_id', False)
       this.WorkflowId = dpf_workflow.GetRecordedId()