-
-
September 14, 2023 at 11:41 am
Aleksandr Zhadkovskii
SubscriberGreetings!
Due to several reasons, I have to use "ERESX,NO" APDL command during my solution. With this command, all results are shown as integration point results copied to nodes, which gives lower overall stresses. I wrote a simple Python Result script that extrapolates results to nodes and shows stresses as the right node result (values are identical to ones without the ERESX command). Hovewer, results are shown only for one step, and they don't change when I choose a different time ("retrieve this result" button). Are there any commands to change the displayed values for any chosen time? Or is the only solution to create new results for each time-step needed and display them separately?
The best possible variant is for Python Result to be exactly the same in terms of functionality as ANSYS basic results (i.e., results work at any time, animation across time is possible, e.t.c.).
Code used is shown below.
def post_started(sender, analysis):# Do not edit this line
define_dpf_workflow(analysis)def define_dpf_workflow(analysis):
import mech_dpf
import Ans.DataProcessing as dpf
# get integration points (Gaussian points)
mech_dpf.setExtAPI(ExtAPI)
data_source = dpf.DataSources(analysis.ResultFileName)
# get mesh
model = dpf.Model(data_source)
mesh = model.Mesh
# Von Mises op
von_mises_op = dpf.operators.invariant.von_mises_eqv_fc()# create stress operator and get stress results(6) in the integration points
stress_op = dpf.operators.result.stress()
stress_op.inputs.data_sources.Connect(data_source)
# set time scoping
time_scoping = dpf.Scoping()
number_sets = stress_op.outputs.fields_container.GetData().GetTimeFreqSupport().NumberSets
time_scoping.Ids = range(1, number_sets + 1)
stress_op.inputs.time_scoping.Connect(time_scoping)# extrapolate results from gauss points to nodes
gauss_to_node_op = dpf.operators.averaging.gauss_to_node_fc()
gauss_to_node_op.inputs.mesh.Connect(mesh)
gauss_to_node_op.inputs.fields_container.Connect(stress_op)# get von mises stress
avg_mises_op = dpf.operators.averaging.elemental_nodal_to_nodal_fc()
avg_mises_op.inputs.fields_container.Connect(gauss_to_node_op)
von_mises_op.inputs.fields_container.Connect(avg_mises_op)
dpf_workflow = dpf.Workflow()
dpf_workflow.Add(von_mises_op)
dpf_workflow.SetOutputContour(von_mises_op)
dpf_workflow.Record('wf_id', True)
this.WorkflowId = dpf_workflow.GetRecordedId() -
September 15, 2023 at 2:48 pm
Mike Rife
Ansys EmployeeHi Aleksandr
Instead of:
number_sets = stress_op.outputs.fields_container.GetData().GetTimeFreqSupport().NumberSets
time_scoping.Ids = range(1, number_sets + 1)
Try this instead (don't use your number_sets at all):
timeScop.Ids = [i for i in range(1,model.TimeFreqSupport.NumberSets+1)]
Then add that timeScop to the result operators
-
September 18, 2023 at 10:37 am
Aleksandr Zhadkovskii
SubscriberHi, Mike!
Changed the mentioned lines to the following:
time_scoping.Ids = [i for i in range(1, model.TimeFreqSupport.NumberSets + 1)]
stress_op.inputs.time_scoping.Connect(time_scoping)Regarding the addition of it to the result operator, you mean adding it to the elemental_nodal_to_nodal_fc/gauss_to_node_fc similar to the last string above, right? If this is the case, I believe this cannot be done to these operators (according to the PyDPF online help; see screenshots below; these operators do not have time scoping inputs).
After changing the code, my result is shown below. Only the first step is visible; pressing on different time steps has no effect. Am I missing something? I'm new to this and may be doing something wrong.
-
-
September 15, 2023 at 3:14 pm
mjmiddle
Ansys EmployeeDo you have a property provider which creates fields in the Details, and then sets the value of those fields for the display time or result set chosen? Your code produces this:
The purpose of the "Retrieve this result" when a time history step is chosen in a native result is to populate the Details. Here is a native von Mises result:
The purpose of "Retrieve this Result" is to populate the fields sich as Maximum, Minimum, etc... in the Details for the time set (0.5 s) above. If you have not written fields in the Property Provider for this and supplied the code to fill in these fields, then the "Retrieve this Result" is meaningless. Note that you can retrieve the individual data from the field to get data for each time.
Also, I'm not sure why you added the elemental_nodal_to_nodal_fc() operator section when you have already have the operator gauss_to_node_fc().
-
September 18, 2023 at 11:14 am
Aleksandr Zhadkovskii
SubscriberIt looks like I do not have it (property provider), as all I added is this python result, and that’s all. I didn’t know about this and will look more into this thing.
My interest in the “Retrieve this Result” button is only to display another time step. For a normal result, displaying could be done by clicking on the graph; however, you can enforce it changing using the retrieve option. I wrote about this option, thinking it should be similar in the python result. As of now, only the first time step is shown unless I change the time step used in the code.
My result looks like this, no play/stop button. May it be because analysis is Transient? I wish to see python result produced by the gauss to node operator at any time step, but it doesn’t work for me at the moment.
I added “the elemental_nodal_to_nodal_fc()” operator as done in PyDPF help example “04 extrapolation stress 3d”. There it is used in order for the mesh.plot function to work, I believe, but may be here it is unneccessary, I didn’t check if that’s the case.
UPD:
Tried using my python result in Static Analysis; only first result is shown again, and there are no play/stob/e.t.c. buttons. I’m not adding/using/turning in something needed for this, perhaps?
-
-
September 18, 2023 at 7:42 pm
mjmiddle
Ansys EmployeeEven if you use the property provider to make your own fields, such as a time field, and include the code to fill in more fields with the data at the time entered in the field, it will not be triggered to popolate this field or run the callback when you click in the graph or table and choose "Retrieve This Result." If you really want it to behave this way, you need to create an ACT extension that defines this result. This has an accompanying XML file that determines the Outline objects that can be added from your extension.
Have you made an ACT extension before? There an an ACT training for Mechanical in the Ansys Learning Hub:
https://www.ansys.com/services/ansys-learning-hub
There is also information in the online help for creating ACT extensions. See this page for creating ACT extensions with result objects:
https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v232/en/act_cust_mech/act_Mech_FeatureCreation_Postprocessing.html
-
September 19, 2023 at 1:25 pm
Aleksandr Zhadkovskii
SubscriberUh-oh, got it. This will be my first time using ACT and I will look more into it then.
Alternatively, I think something similar can be done using only rst file and Python with the help of PyDPF and pyplot, however I am not sure which is easier.
Anyway, many thanks for the help!
-
-
- The topic ‘Python Result at any time step of Transient Structural in Ansys Mechanical’ is closed to new replies.

Boost Ansys Fluent Simulations with AWS
Computational Fluid Dynamics (CFD) helps engineers design products in which the flow of fluid components is a significant challenge. These different use cases often require large complex models to solve on a traditional workstation. Click here to join this event to learn how to leverage Ansys Fluids on the cloud, thanks to Ansys Gateway powered by AWS.

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- Solver Pivot Warning in Beam Element Model
- Saving & sharing of Working project files in .wbpz format
- Understanding Force Convergence Solution Output
- User manual
- An Unknown error occurred during solution. Check the Solver Output…..
- What is the difference between bonded contact region and fixed joint
- The solver engine was unable to converge on a solution for the nonlinear problem as constrained.
- whether have the difference between using contact and target bodies
- Defining rigid body and contact
- Colors and Mesh Display
-
7610
-
4440
-
2953
-
1427
-
1322
© 2023 Copyright ANSYS, Inc. All rights reserved.