How can I plot a custom result which is based on a condition?
Javier Vique
Member, Employee Posts: 86
✭✭✭✭
in Structures
My custom result must be based on a condition applied to scaled Von Mises stresses. If these scaled Von Mises stresses are higher than a threshold (e.g. 2.5), the custom result will follow a specific formulae (e.g. 10^(x/2.5)). If they are lower, the custom result will be got applying another formulae (e.g. 10^(7.5log10(x100)-x*5)).
Please be aware that this formulae are dummy.
Tagged:
0
Answers
-
This can be done using Python Result object. Below an example of script based on the formulae given above. Depending on the complexity of the formulae, we can make use of dpf operators or not. In this example, it is not used because log10 is not available in math operators.
def define_dpf_workflow(analysis): import mech_dpf import Ans.DataProcessing as dpf mech_dpf.setExtAPI(ExtAPI) dataSource = dpf.DataSources(analysis.ResultFileName) import math ScaleRatio = 28300./210000. MyThreshold = 2.5 op_seqv = dpf.operators.result.stress_eqv_as_mechanical() op_seqv.inputs.data_sources.Connect(dataSource) seqv = op_seqv.outputs.fields_container.GetData() op_scale = dpf.operators.math.scale_fc() op_scale.inputs.fields_container.Connect(seqv) op_scale.inputs.ponderation.Connect(ScaleRatio) seqv_scaled = op_scale.outputs.fields_container.GetData() op_hp = dpf.operators.filter.field_high_pass_fc() op_hp.inputs.fields_container.Connect(seqv_scaled) op_hp.inputs.threshold.Connect(MyThreshold) seqv_scaled_h = op_hp.outputs.fields_container.GetData() op_lp = dpf.operators.filter.field_low_pass_fc() op_lp.inputs.fields_container.Connect(seqv_scaled) op_lp.inputs.threshold.Connect(MyThreshold) seqv_scaled_l = op_lp.outputs.fields_container.GetData() num_h = seqv_scaled_h[0].ScopingIds.Count num_l = seqv_scaled_l[0].ScopingIds.Count N_h = [] N_l = [] for i in range(num_h): x = seqv_scaled_h[0].Data[i] data = 10**(x/2.5) N_h.append(data) for i in range(num_l): x = seqv_scaled_l[0].Data[i] data = 10**(7.5*math.log10(x*100)-x*5) N_l.append(data) N_h_field = dpf.FieldsFactory.CreateScalarField(numEntities=num_h) N_h_field.MeshedRegionSupport = seqv_scaled_h[0].MeshedRegionSupport N_h_field.ScopingIds = seqv_scaled_h[0].ScopingIds N_h_field.Data = N_h N_l_field = dpf.FieldsFactory.CreateScalarField(numEntities=num_l) N_l_field.MeshedRegionSupport = seqv_scaled_l[0].MeshedRegionSupport N_l_field.ScopingIds = seqv_scaled_l[0].ScopingIds N_l_field.Data = N_l op_merge = dpf.operators.utility.merge_fields() op_merge.inputs.fields1.Connect(N_h_field) op_merge.inputs.fields2.Connect(N_l_field) dpf_workflow = dpf.Workflow() dpf_workflow.Add(op_merge) # dpf_workflow.SetInputName(u, 0, 'time') # dpf_workflow.Connect('time', timeScop) dpf_workflow.SetOutputContour(op_merge) dpf_workflow.Record('wf_id', False) this.WorkflowId = dpf_workflow.GetRecordedId()
0