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.
- 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
- 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?