Steady-State Thermal-Electric Conduction Analysis

In this example, using the support files, you will insert a Steady-State Thermal-Electric Conduction analysis object into an undefined Mechanical session and execute a sequence of python journal commands that will define and solve the analysis.

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

  • Steady_State_Thermal_Electric_Conduction.agdb

  • Steady_State_Thermal_Electric_Conduction.py

These files are available here.

Procedure

  1. Open Mechanical directly without importing a geometry or specifying an analysis type. This can be done through Start Menu.

  2. From the Analysis drop-down menu of the Insert group on the Home tab, insert a Static Structural system into the tree.

  3. Select the Geometry object and select the Attach Geometry option from the Geometry group on the Geometry Context tab. Navigate to the proper folder location and select Steady_State_Thermal_Electric_Conduction.agdb.

     

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

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

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

Scripts Illustrated

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

#Section 1: Store the tree variables
#Section 2: Store the named selections
#section 3: Insert voltage load
#Section 4: Insert temperature and radiation loads
#Section 5: Insert results
#Section 6: Solve and review results
#Section 7: Define tabular Voltage & functional Voltage
#Section 8: Define tabular Temperature loads
#Section 9: Tabular Emissivity
#Section 10: Solve and review results
#=================================================================

#Section 1: Store the tree variables
ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardMKS
THERM_ELEC = Model.Analyses[0]
SOLN = THERM_ELEC.Solution

#Section 2: Store the named selections
NS_GRP = DataModel.Project.Model.NamedSelections
Face1 = NS_GRP.Children[0]
Face2 = NS_GRP.Children[1]
Face3 = NS_GRP.Children[2]
Face4 = NS_GRP.Children[3]
Face7 = NS_GRP.Children[6]

#section 3: Insert voltage load
VOLT_LD1 = THERM_ELEC.AddVoltage()
VOLT_LD1.Location = Face1
VOLT_LD2 = THERM_ELEC.AddVoltage()
VOLT_LD2.Location = Face3
VOLT_LD2.Magnitude.Output.DiscreteValues = [Quantity('0[V]'), Quantity('0.1[V]')]
VOLT_LD3 = THERM_ELEC.AddVoltage()
VOLT_LD3.Location = Face7

#Section 4: Insert temperature and radiation loads
TEMP = THERM_ELEC.AddTemperature()
TEMP.Location = Face2

RAD1 = THERM_ELEC.AddRadiation()
RAD1.Location = Face4
RAD1.Correlation = RadiationType.SurfaceToSurface

RAD2 = THERM_ELEC.AddRadiation()
RAD2.Location = Face7
RAD2.Correlation = RadiationType.SurfaceToSurface

#Section 5: Insert results
TEMP_RST1 = SOLN.AddTemperature()
TEMP_RST2 = SOLN.AddTemperature()
TEMP_RST2.Location = Face4
TEMP_RST3 = SOLN.AddTemperature()
TEMP_RST3.Location = Face7

RAD_PROBE1 = SOLN.AddRadiationProbe()
RAD_PROBE1.BoundaryConditionSelection = RAD1
RAD_PROBE2 = SOLN.AddRadiationProbe()
RAD_PROBE2.BoundaryConditionSelection = RAD2

#Section 6: Solve and review results
SOLN.Solve(True)
TEMP_RST1_VAL = TEMP_RST1.Maximum.Value
TEMP_RST2_VAL = TEMP_RST2.Maximum.Value
TEMP_RST3_VAL = TEMP_RST3.Maximum.Value
RAD_PROBE1_VAL = RAD_PROBE1.EmittedRadiation.Value
RAD_PROBE2_VAL = RAD_PROBE2.EmittedRadiation.Value

#Section 7: Define tabular Voltage & functional Voltage
VOLT_LD2.Magnitude.Output.DiscreteValues=[Quantity('0.05[V]'), Quantity('0.11[V]')]
VOLT_LD3.Magnitude.Output.Formula = '0.1*time'
VOLT_LD3.PhaseAngle = Quantity("45[deg]")
VOLT_LD3.NumberOfSegments = 50

#Section 8: Define tabular Temperature loads
TEMP.Magnitude.Output.DiscreteValues=[Quantity('22[C]'), Quantity('60[C]')]

#Section 9: Tabular Emissivity
RAD1.Emissivity.Output.DiscreteValues=[Quantity('0.4'), Quantity('0.7')]

#Section 10: Solve and review results
SOLN.Solve(True)
TEMP_RST1_VAL = TEMP_RST1.Maximum.Value
TEMP_RST2_VAL = TEMP_RST2.Maximum.Value
TEMP_RST3_VAL = TEMP_RST3.Maximum.Value
RAD_PROBE1_VAL = RAD_PROBE1.EmittedRadiation.Value
RAD_PROBE2_VAL = RAD_PROBE2.EmittedRadiation.Value

Summary

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