How to merge workflow ?

Adrien Vet
Adrien Vet Member Posts: 10
Name Dropper Photogenic First Comment
edited July 2023 in Structures

Hello, I wrote a python result code to plot with dpf the total stiffness energy of named selection with name "R_" + number ("R_1", "R_2", "R_3", etc...).

The user has to select his named selection in the property provider, and the plot appears as a result. My code is :

def post_started(sender, analysis):# Do not edit this line


def define_dpf_workflow(analysis):

  import mech_dpf

  import Ans.DataProcessing as dpf


  # On charge nos résultats

  dataSource = dpf.DataSources(analysis.ResultFileName)

  # On charge notre modème

  model = dpf.Model(dataSource)

  R = this.GetCustomPropertyByPath("Énergie de déformation modale/Sélection").ValueString


  E = dpf.operators.result.stiffness_matrix_energy()   



  e = dpf.operators.math.accumulate(E)

  scale = dpf.operators.math.scale()



  a = e.outputs.getfield().Data[0]

  E_totale = dpf.operators.math.add_constant()



  dpf_workflow = dpf.Workflow()

  dpf_workflow.Add([E, E_totale, e, scale])


  dpf_workflow.Record('wf_energy', False)

  this.WorkflowId = dpf_workflow.GetRecordedId()

Then, I want to display all the plots "all the workflow" in on plot.

I have different possible plots and I want the python result to display all the parts in one plot. (with different colors because the stiffness energy is different for each part)

Any help could help,

Thank you




  • Chris Harrold
    Chris Harrold Member, Administrator, Employee Posts: 117
    First Answer First Comment First Anniversary Ansys Employee

    @Ramdane - can you assist here?

  • Ramdane
    Ramdane Member, Employee Posts: 11
    First Comment First Anniversary Ansys Employee Name Dropper

    assigned it to Varun from the mechanical post team.

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 280
    First Anniversary First Comment 5 Likes Ansys Employee

    @Adrien Vet ,

    I think the general idea you need is to manually create a DPF Field object with Elemental scoping. You can then manually set the values of the Field.Data property from a list (DataList) like this:
    DataCollection = System.Collections.Generic.List[System.Double](map(System.Double, DataList))

    You can also use an existing field where you extract the energy of each element, but then simply change the Field.Data values to be whatever you want. This is just to have an operator setup an elemental field rather than do it from scratch.