DPF: time scoping in non-linear plastic structural analysis

tdarling Member Posts: 3
First Comment

I am new to the pyANSYS framework. Using ANSYS 2023 R2.

I am running DPF in ANSYS Mechanical and post processing a structural non-linear plastic analysis with 200 substeps. I'm trying to scope my results in the time domain to the specific time that my max plasticity occurs.

I do this with the following function and it kind of works:

def define_dpf_workflow(analysis):
    import mech_dpf
    import Ans.DataProcessing as dpf
    dataSource = dpf.DataSources()

    timeScoping = dpf.Scoping()
    timeScoping.Location = 'Time'
    timeScoping.Ids = [75]


    dpf_workflow = dpf.Workflow()
    dpf_workflow.Record('wf_id', True)
    this.WorkflowId = dpf_workflow.GetRecordedId()

But I am noticing some strange things.

  1. I have to use the Iron Python Engine. If I use the CPython engine I get the following error:

Error when invoking function 'post_started'.Traceback (most recent call last):
StandardError: Exception has been thrown by the target of an invocation.Traceback (most recent call last):
Exception: name 'this' is not defined

  1. The actual analysis time that the max pasticity occurs is 4 seconds but I have to put in 75 in order to specify the 4s time point even when I specify that op.Location = 'Time'

Does anyone know why I'm getting the "this" exception if I use CPython and how do I get the scoping to take actual time requests rather than substep numbers?


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

    @tdarling Please file a service request for the error message in CPython. I think this is a bug.

    For the time scoping in terms of time, I would suggest this operator to get the "Time-Frequency Support" object. This will have information about the set, step, substep, and time/freq. per the results file. You can use this to determine which sets correspond to the time points you want.

    op = dpf.operators.metadata.time_freq_provider() # operator instantiation
    op.inputs.streams_container.Connect(my_streams_container)# optional
    my_time_freq_support = op.outputs.time_freq_support.GetData()

  • Taneli
    Taneli Member Posts: 8
    Name Dropper First Comment
    edited October 2023

    This is what I ended up using in 23R2 based the previous post.

    dpf_model = dpf.Model("file.rst")
    time_step = 3  # in seconds
        time_frequency_op = dpf.operators.metadata.time_freq_provider()
        time_frequency_support = time_frequency_op .outputs.time_freq_support.GetData()
        cumulative_step = time_frequency_support.GetTimeFreqCummulativeIndex(time_step)[0] + 1

    GetTimeFreqCummulativeIndex returns a tuple ( in my case (9,9,9) when I had 10 result steps). The documentation on the return was a bit sparse, so I ended up using the first index. @Mike.Thompson any idea on if this is alright or what sort of data is returned in the tuple?