


{"id":306817,"date":"2023-09-14T11:41:04","date_gmt":"2023-09-14T11:41:04","guid":{"rendered":"\/forum\/forums\/topic\/python-result-at-any-time-step-of-transient-structural-in-ansys-mechanical\/"},"modified":"2023-09-22T14:25:16","modified_gmt":"2023-09-22T14:25:16","slug":"python-result-at-any-time-step-of-transient-structural-in-ansys-mechanical","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/python-result-at-any-time-step-of-transient-structural-in-ansys-mechanical\/","title":{"rendered":"Python Result at any time step of Transient Structural in Ansys Mechanical"},"content":{"rendered":"<p>Greetings!<\/p>\n<p>Due to several reasons, <strong>I have to use &#8220;ERESX,NO&#8221; APDL command during my solution<\/strong>. With this command, all results are shown as integration point results copied to nodes, which gives lower overall stresses. <strong>I wrote a simple Python Result script that extrapolates results to nodes and shows stresses as the right node result<\/strong> (values are identical to ones without the ERESX command). Hovewer, <strong>results are shown only for one step, and they don&#8217;t change when I choose a different time<\/strong> (&#8220;retrieve this result&#8221; button). <strong>Are there any commands to change the displayed values for any chosen time?<\/strong> Or is the only solution to create new results for each time-step needed and display them separately?<\/p>\n<p>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.).<\/p>\n<p>Code used is shown below.<\/p>\n<p style=\"padding-left: 40px\"><span style=\"font-size: 12pt\">def post_started(sender, analysis):# Do not edit this line<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; define_dpf_workflow(analysis)<\/span><\/p>\n<p style=\"padding-left: 40px\"><span style=\"font-size: 12pt\">def define_dpf_workflow(analysis):<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; import mech_dpf<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; import Ans.DataProcessing as dpf<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp;&nbsp;<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; # get integration points (Gaussian points)<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; mech_dpf.setExtAPI(ExtAPI)<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; data_source = dpf.DataSources(analysis.ResultFileName)<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp;&nbsp;<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; # get mesh<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; model = dpf.Model(data_source)<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; mesh = model.Mesh<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp;&nbsp;<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; # Von Mises op<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; von_mises_op = dpf.operators.invariant.von_mises_eqv_fc()<\/span><\/p>\n<p style=\"padding-left: 40px\"><span style=\"font-size: 12pt\">&nbsp; &nbsp; # create stress operator and get stress results(6) in the integration points<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; stress_op = dpf.operators.result.stress()<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; stress_op.inputs.data_sources.Connect(data_source)<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp;&nbsp;<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; # set time scoping<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; time_scoping = dpf.Scoping()<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; number_sets = stress_op.outputs.fields_container.GetData().GetTimeFreqSupport().NumberSets<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; time_scoping.Ids = range(1, number_sets + 1)<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; stress_op.inputs.time_scoping.Connect(time_scoping)<\/span><\/p>\n<p style=\"padding-left: 40px\"><span style=\"font-size: 12pt\">&nbsp; &nbsp; # extrapolate results from gauss points to nodes<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; gauss_to_node_op = dpf.operators.averaging.gauss_to_node_fc()<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; gauss_to_node_op.inputs.mesh.Connect(mesh)<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; gauss_to_node_op.inputs.fields_container.Connect(stress_op)<\/span><\/p>\n<p style=\"padding-left: 40px\"><span style=\"font-size: 12pt\">&nbsp; &nbsp; # get von mises stress<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; avg_mises_op = dpf.operators.averaging.elemental_nodal_to_nodal_fc()<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; avg_mises_op.inputs.fields_container.Connect(gauss_to_node_op)<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; von_mises_op.inputs.fields_container.Connect(avg_mises_op)<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp;&nbsp;<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; dpf_workflow = dpf.Workflow()<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; dpf_workflow.Add(von_mises_op)<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; dpf_workflow.SetOutputContour(von_mises_op)<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; dpf_workflow.Record(&#8216;wf_id&#8217;, True)<\/span><br \/><span style=\"font-size: 12pt\">&nbsp; &nbsp; this.WorkflowId = dpf_workflow.GetRecordedId()<\/span><\/p>\n","protected":false},"template":"","class_list":["post-306817","topic","type-topic","status-closed","hentry","topic-tag-ansys-mechanical","topic-tag-ironpython","topic-tag-post-processing-data-1","topic-tag-python","topic-tag-result-postprocessing","topic-tag-transient-structural"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_author_ip":["96.7.218.223"]," _bbp_last_reply_id":["0"]," _bbp_likes_count":["0"],"_btv_view_count":["3170"],"_edit_lock":["1694693782:195030"],"_bbp_subscription":["18229","170445"],"_bbp_status":["publish"],"_bbp_topic_status":["unanswered"],"_bbp_topic_id":["306817"],"_bbp_forum_id":["27791"],"_bbp_engagement":["18229","170445","262268"],"_bbp_voice_count":["3"],"_bbp_reply_count":["6"],"_bbp_last_reply_id":["307448"],"_bbp_last_active_id":["307448"],"_bbp_last_active_time":["2023-09-19 13:25:39"]},"test":"user-deleted"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/306817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/306817\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=306817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}