Steady State Electric Conduction Analysis

In this example, using the support files, you will insert an Steady State 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_Electric_Conduction.agdb

  • Steady_State_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_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_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: Set up the Tree Object Items. 
#Section 2:  Mesh. 
#Section 3: Set up analysis settings. 
#Section 4: Create named selections. 
#Section 5: Set up voltage load. 
#Section 6: Set up current load. 
#Section 7: Set up thermal condition load. 
#Section 8: Insert Results. 
#Section 9: Solve the analysis.

################################################# 
# Section 1 - Set up the Tree Object Items.
Geometry = Model.Geometry
Part1 = Geometry.Children[0]
Part2 = Geometry.Children[1]
Part3 = Geometry.Children[2]
Part4 = Geometry.Children[3]
ELEC = Model.Analyses[0]
ANA_SETTING = ELEC.Children[0]
SOLN = ELEC.Solution

#Section 2 - Mesh
MSH = Model.Mesh
MSH.ElementSize = Quantity("0.75[m]")

#Section 3 - Set up analysis settings
ELEC.EnvironmentTemperature = Quantity("0[C]")
ANA_SETTING.LineSearch = LineSearchType.On
ANA_SETTING.SolverType = SolverType.Direct
ANA_SETTING.NumberOfSteps = 2
ANA_SETTING.SetAutomaticTimeStepping(1, AutomaticTimeStepping.Off)
ANA_SETTING.SetDefineBy(1, TimeStepDefineByType.Substeps)
ANA_SETTING.SetNumberOfSubSteps(1, 10)

ANA_SETTING.SetAutomaticTimeStepping(2, AutomaticTimeStepping.Off)
ANA_SETTING.SetDefineBy(2, TimeStepDefineByType.Substeps)
ANA_SETTING.SetNumberOfSubSteps(2, 10)
ANA_SETTING.SetStoreResultsAt(2, TimePointsOptions.EquallySpacedPoints)
ANA_SETTING.SetStoreResulsAtValue(2, 5)

#Section 4 - Create named selection
Face1 = DataModel.Project.Model.AddNamedSelection()
Face1.ScopingMethod=GeometryDefineByType.Worksheet
Face1.Name = "Face1"
GEN_CRT1 = Face1.GenerationCriteria
CRT1 = Ansys.ACT.Automation.Mechanical.NamedSelectionCriterion()
CRT1.Active=True
CRT1.Action=SelectionActionType.Add
CRT1.EntityType=SelectionType.GeoFace
CRT1.Criterion=SelectionCriterionType.LocationZ
CRT1.Operator=SelectionOperatorType.Equal
CRT1.Value=Quantity('20 [m]')
GEN_CRT1.Add(CRT1)
Face1.Activate()
Face1.Generate()

Face2 = DataModel.Project.Model.AddNamedSelection()
Face2.ScopingMethod=GeometryDefineByType.Worksheet
Face2.Name = "Face2"
GEN_CRT2 = Face2.GenerationCriteria
CRT1 = Ansys.ACT.Automation.Mechanical.NamedSelectionCriterion()
CRT1.Active=True
CRT1.Action=SelectionActionType.Add
CRT1.EntityType=SelectionType.GeoFace
CRT1.Criterion=SelectionCriterionType.LocationZ
CRT1.Operator=SelectionOperatorType.Equal
CRT1.Value=Quantity('0 [m]')
GEN_CRT2.Add(CRT1)
Face2.Activate()
Face2.Generate()

Body1 = DataModel.Project.Model.AddNamedSelection()
Body1.ScopingMethod=GeometryDefineByType.Worksheet
Body1.Name = "Body1"
GEN_CRT3 = Body1.GenerationCriteria
CRT1 = Ansys.ACT.Automation.Mechanical.NamedSelectionCriterion()
CRT1.Active=True
CRT1.Action=SelectionActionType.Add
CRT1.EntityType=SelectionType.GeoBody
CRT1.Criterion=SelectionCriterionType.LocationZ
CRT1.Operator=SelectionOperatorType.LessThan
CRT1.Value=Quantity('22 [m]')
GEN_CRT3.Add(CRT1)
Body1.Activate()
Body1.Generate()

# Section 5 - Set up voltage load
VOLT_LD = ELEC.AddVoltage()
VOLT_LD.Location = Face1
VOLT_LD.Magnitude.Output.Formula = "100*time"
VOLT_LD.PhaseAngle = Quantity("45[deg]")
VOLT_LD.NumberOfSegments = 50

#Section 6 - Set up current load
CURR_LD = ELEC.AddCurrent()
CURR_LD.Location = Face2
CURR_LD.Magnitude.Inputs[0].DiscreteValues = [Quantity("0 [sec]"), Quantity("1 [sec]"), Quantity("2 [sec]")]
CURR_LD.Magnitude.Output.DiscreteValues = [Quantity("0[A]"), Quantity("100[A]"), Quantity("200[A]")]

#Section 7 - Set up thermal condition load
Thermal_Condition = ELEC.AddThermalCondition()
Thermal_Condition.Location = Body1
Thermal_Condition.Magnitude.Inputs[0].DiscreteValues = [Quantity("0 [sec]"), Quantity("1 [sec]"), Quantity("2 [sec]")]
Thermal_Condition.Magnitude.Output.DiscreteValues = [Quantity("0[C]"), Quantity("100[C]"), Quantity("200[C]")]

#Section 8 - Insert Results
ELEC_VOLT = SOLN.AddElectricVoltage()
ELEC_VOLT.DisplayTime = Quantity("1[s]")

ELEC_VOLT2 = SOLN.AddElectricVoltage()
ELEC_VOLT2.DisplayTime = Quantity("2[s]")

JOULE_HEAT = SOLN.AddJouleHeat()
JOULE_HEAT.DisplayTime = Quantity("1[s]")

JOULE_HEAT2 = SOLN.AddJouleHeat()
JOULE_HEAT2.DisplayTime = Quantity("2[s]")

DIR_ELEC_FLD_INT = SOLN.AddDirectionalElectricFieldIntensity()
DIR_ELEC_FLD_INT.NormalOrientation = NormalOrientationType.ZAxis
DIR_ELEC_FLD_INT.DisplayTime = Quantity("1[s]")

DIR_ELEC_FLD_INT2 = SOLN.AddDirectionalElectricFieldIntensity()
DIR_ELEC_FLD_INT2.NormalOrientation = NormalOrientationType.ZAxis
DIR_ELEC_FLD_INT2.DisplayTime = Quantity("2[s]")

DIR_CURR_DEN = SOLN.AddDirectionalCurrentDensity()
DIR_CURR_DEN.NormalOrientation = NormalOrientationType.ZAxis
DIR_CURR_DEN.DisplayTime = Quantity("1[s]")

DIR_CURR_DEN2 = SOLN.AddDirectionalCurrentDensity()
DIR_CURR_DEN2.NormalOrientation = NormalOrientationType.ZAxis
DIR_CURR_DEN2.DisplayTime = Quantity("2[s]")

REAC_PROBE = SOLN.AddEmagReactionProbe()
REAC_PROBE.BoundaryConditionSelection = VOLT_LD
REAC_PROBE.DisplayTime = Quantity("1[s]")

REAC_PROBE2 = SOLN.AddEmagReactionProbe()
REAC_PROBE2.BoundaryConditionSelection = VOLT_LD
REAC_PROBE2.DisplayTime = Quantity("2[s]")

#Section 9- Solve and extract results
SOLN.Solve(True)
ELEC_VOLT_VAL = ELEC_VOLT.Maximum.Value
ELEC_VOLT2_VAL = ELEC_VOLT2.Minimum.Value
JOULE_HEAT_VAL = JOULE_HEAT.Maximum.Value
JOULE_HEAT2_VAL = JOULE_HEAT2.Minimum.Value
DIR_ELEC_FLD_INT_VAL = DIR_ELEC_FLD_INT.Maximum.Value
DIR_ELEC_FLD_INT2_VAL = DIR_ELEC_FLD_INT2.Minimum.Value
DIR_CURR_DEN_VAL = DIR_CURR_DEN.Maximum.Value
DIR_CURR_DEN2_VAL = DIR_CURR_DEN2.Minimum.Value
REAC_PROBE_VAL = REAC_PROBE.Current.Value
REAC_PROBE2_VAL = REAC_PROBE2.Current.Value

Summary

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