DPF: time scoping in non-linear plastic structural analysis

tdarling
tdarling Member Posts: 4
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()
    dataSource.SetResultFilePath(r'E:\file.rst','rst')

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

    s1=dpf.operators.result.stress_principal_1()
    s1.inputs.time_scoping.Connect(timeScoping)
    s1.inputs.data_sources.Connect(dataSource)
    s1stress=s1.outputs.fields_container.GetData()

    dpf_workflow = dpf.Workflow()
    dpf_workflow.Add(s1)
    dpf_workflow.SetOutputContour(s1stress)
    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?

Answers

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 345
    25 Answers 100 Comments 25 Likes First Anniversary
    ✭✭✭✭

    @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
    op.inputs.data_sources.Connect(my_data_sources)
    my_time_freq_support = op.outputs.time_freq_support.GetData()

  • Taneli
    Taneli Member Posts: 9
    First Anniversary 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
    try:
        time_frequency_op = dpf.operators.metadata.time_freq_provider()
        time_frequency_op.inputs.streams_container.Connect(dpf_model.StreamsProvider)
        time_frequency_support = time_frequency_op .outputs.time_freq_support.GetData()
        cumulative_step = time_frequency_support.GetTimeFreqCummulativeIndex(time_step)[0] + 1
        print(cumulative_step)
    finally:
        dpf_model.ReleaseStreams()
    

    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?