How can I create a temperature contour plot from an existing .rth file?
Marco Wissinger
Member Posts: 1 **
in Structures
I do have results of a transient thermal analysis performed in Ansys Mechanical. In a next step I would like to use PyDPF to create a contour plot of the temperature of my body and save the contour plot as a picture.
0
Answers
-
Hello, you should be able to use a python result to plot the temperature and export the image with something similar to this example below:
def post_started(sender, analysis):# Do not edit this line define_dpf_workflow(analysis) # Uncomment this function to enable retrieving results from the table/chart # def table_retrieve_result(value):# Do not edit this line # import mech_dpf # import Ans.DataProcessing as dpf # wf = dpf.Workflow(this.WorkflowId) # wf.Connect('contour_selector', value) # this.Evaluate() def define_dpf_workflow(analysis): import mech_dpf import Ans.DataProcessing as dpf import os mech_dpf.setExtAPI(ExtAPI) analysis = ExtAPI.DataModel.Project.Model.Analyses[0] #Results files paths resultFile1 = analysis.ResultFileName #Data Sources dataSource1 = dpf.DataSources(resultFile1) #Time Sets in Results File timeScopOp1 = dpf.operators.metadata.time_freq_provider() timeScopOp1.inputs.data_sources.Connect(dataSource1) timeFreq1 = timeScopOp1.outputs.time_freq_support.GetData() timeResultsSets1 = timeFreq1.NumberSets #Time Scoping timeScopingOp1 = dpf.Scoping() timeScopingOp1.Ids = [10] timeScopingOp1.Location = "Time" #Temperature Results tempOp1 = dpf.operators.result.temperature() tempOp1.inputs.data_sources.Connect(dataSource1) tempOp1.inputs.time_scoping.Connect(timeScopingOp1) temp1 = tempOp1.outputs.fields_container.GetData() dpf_workflow = dpf.Workflow() dpf_workflow.Add(tempOp1) dpf_workflow.SetOutputContour(tempOp1) dpf_workflow.Record('wf_id', False) this.WorkflowId = dpf_workflow.GetRecordedId() imagePath = analysis.WorkingDir imageName = "imag1.png" totalDir = os.path.join(imagePath,imageName) ExtAPI.Graphics.ExportImage(totalDir)
You should get something like this:
0