Transient Thermal Analysis

In this example, using the support files, you will create a Transient Thermal analysis and execute a sequence of python journal commands that will define and solve the analysis in Mechanical.

This example begins in the Mechanical application. It requires you to download the following Ansys DesignModeler and python files.

  • Mechanical_Transient_Thermal_Example_001.agdb

  • Mechanical_Transient_Thermal_Example_001.xml

  • Mechanical_Transient_Thermal_Example_001.py

These files are available here.

Procedure

  1. Open Workbench and insert a Transient Thermal system into the Project Schematic.

  2. Double-click the Engineering Data cell to open the workspace.

  3. Select File > Import Engineering Data, navigate to the proper folder location and select Mechanical_Transient_Thermal_Example_001.xml.

  4. Return to the Project tab.

  5. Right-click the Geometry cell and select Import Geometry > Browse and then navigate to the proper folder location and select Mechanical_Transient_Thermal_Example_001.agdb.

  6. Right-click the Geometry cell and select the Properties option.

  7. Set the Analysis Type property to 2D. This property is contained in the Advanced Geometry Options group.

  8. Open Mechanical: right-click the Model cell and select Edit.

  9. Select the Automation tab and select the Scripting option to open the Mechanical Scripting pane.

  10. Select the Open Script option ( ) from the Editor toolbar. Navigate to the proper folder location and select Mechanical_Transient_Thermal_Example_001.py.

  11. Select the Run Script option ( ) from the Editor toolbar.

Scripts Illustrated

In this example, the python file automatically performs the following actions:

# Scenario1 - Set up Unit System: Set up the Unit Systems to Metric (m, kg, N, s, V, A), 

ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardMKS

# Scenario 2 - Set up the Tree Object Items: Define the parts, connections, mesh, Transient Thermal system, the analysis settings, and the solution navigating through the tree items.
GEOMETRY = Model.Geometry
PART1 = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'Surface Body 1'][0]
PART2 = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'Surface Body 2'][0]
MESH = Model.Mesh
TRANSIENT_THERMAL = DataModel.AnalysisByName("Transient Thermal")
ANSLYSIS_SETTINGS = TRANSIENT_THERMAL.AnalysisSettings
SOLUTION = TRANSIENT_THERMAL.Solution

# Scenario 3 - Define Named Selections: Define the Named selections that will be used to define the Mesh Controls, the loads and the results.

NS_BODY1 = DataModel.GetObjectsByName("Body1")[0]
NS_BODY2 = DataModel.GetObjectsByName("Body2")[0]
NS_EDGES2 = DataModel.GetObjectsByName("Edges2")[0]	
NS_EDGE1 = DataModel.GetObjectsByName("Edge1")[0]
NS_EDGE2 = DataModel.GetObjectsByName("Edge2")[0]

# Scenario 4 Assign materials and define 2D behaviour: Assign materials to bodies. Define 2D behaviour as plane stress and assign thickness.

GEOMETRY.Model2DBehavior = Model2DBehavior.PlaneStress
PART1.Material = 'Mechanical_Transient_Thermal_Example_001'
PART2.Material = 'Mechanical_Transient_Thermal_Example_001'
PART1.Thickness = Quantity('0.1 [m]')
PART2.Thickness = Quantity('0.1 [m]')

# Scenario 5 - Define Mesh Settings: Assign global mesh element size of 0.1 m. Assign mesh methods Quadrilateral Dominant and triangles

MESH.ElementSize = Quantity('0.1 [m]')
MESH_METHOD01 = MESH.AddAutomaticMethod()
MESH_METHOD01.Location = NS_BODY1
MESH_METHOD01.Method = MethodType.Automatic
MESH_METHOD02 = MESH.AddAutomaticMethod()
MESH_METHOD02.Location = NS_BODY2
MESH_METHOD02.Method = MethodType.AllTriAllTet

# Scenario 6 - Define Analysis Settings: Set the auto time stepping to off with time step of 7 s. Set step end time of 700 s.

ANSLYSIS_SETTINGS.StepEndTime = Quantity('700 [s]')
ANSLYSIS_SETTINGS.AutomaticTimeStepping = AutomaticTimeStepping.Off 
ANSLYSIS_SETTINGS.TimeStep = Quantity('7 [s]')

# Scenario 7 - Insert Thermal loads: Define Initial Temperature. Insert and define Temperature, Convection and Internal Heat Generation loads

INITIAL_TEMPERATURE = TRANSIENT_THERMAL.Children[0]
INITIAL_TEMPERATURE.InitialTemperatureValue = Quantity('50 [C]')

TEMPERATURE = TRANSIENT_THERMAL.AddTemperature()
TEMPERATURE.Location = NS_EDGES2
INITIAL_TEMPERATURE.InitialTemperatureValue = Quantity('50 [C]')

CONVECTION = TRANSIENT_THERMAL.AddConvection()
CONVECTION.Location = NS_EDGE1
CONVECTION.FilmCoefficient.Output.DiscreteValues=[Quantity('10 [W m^-1 m^-1 C^-1]'), Quantity('10 [W m^-1 m^-1 C^-1]')]
CONVECTION.AmbientTemperature.Output.DiscreteValues=[Quantity('20 [C]'), Quantity('20 [C]')]

INTERNAL_HEAT_GENERATION = TRANSIENT_THERMAL.AddInternalHeatGeneration()
INTERNAL_HEAT_GENERATION.Location = NS_BODY2
INTERNAL_HEAT_GENERATION.Magnitude.Inputs[0].DiscreteValues = [Quantity("0 [s]"), Quantity("10 [s]"), Quantity("30 [s]"), Quantity("50 [s]"), Quantity("100 [s]"), Quantity("700 [s]")]
INTERNAL_HEAT_GENERATION.Magnitude.Output.DiscreteValues = [Quantity(10000, "W m^-1 m^-1 m^-1"), Quantity(12000, "W m^-1 m^-1 m^-1"), Quantity(13000, "W m^-1 m^-1 m^-1"), Quantity(14000, "W m^-1 m^-1 m^-1"), Quantity(14000, "W m^-1 m^-1 m^-1"), Quantity(14000, "W m^-1 m^-1 m^-1")]

HEAT_FLUX = TRANSIENT_THERMAL.AddHeatFlux()
HEAT_FLUX.Location = NS_EDGE2
HEAT_FLUX.Magnitude.Inputs[0].DiscreteValues = [Quantity("0 [s]"), Quantity("10 [s]"), Quantity("30 [s]"), Quantity("50 [s]"), Quantity("100 [s]"), Quantity("700 [s]")]
HEAT_FLUX.Magnitude.Output.DiscreteValues = [Quantity(5000, "W m^-1 m^-1"), Quantity(6250, "W m^-1 m^-1"), Quantity(8750, "W m^-1 m^-1"), Quantity(10000, "W m^-1 m^-1"), Quantity(10000, "W m^-1 m^-1"), Quantity(10000, "W m^-1 m^-1")]

# Scenario 8 - Insert Results: Insert a Temperature results.

TEMPERATURE01 = SOLUTION.AddTemperature()
TEMPERATURE01.Location = NS_EDGE2
TEMPERATURE01.DisplayTime = Quantity('200[s]')
TEMPERATURE02 = SOLUTION.AddTemperature()
TEMPERATURE02.Location = NS_EDGE2

# Scenario 9 - Solve and Define the Results: Solve the system and set the results variables. Note the Scripting window returns the value of any of the variables stored. 

SOLUTION.Solve(True)

TEMPERATURE01_MAX = TEMPERATURE01.Maximum.Value
TEMPERATURE02_MAX = TEMPERATURE02.Maximum.Value

Summary

This example demonstrates how scripting in Mechanical can be used to automate your actions.