Coupled Field Transient Analysis

In this example, using the support files, you will insert a Coupled Field Transient 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.

  • Coupled_Field_Transient_Example.agdb

  • Coupled_Field_Transient_Example.py

  • Coupled_Field_Transient_Example_Mat.xml

These files are available here.

Procedure

  1. Open Workbench and insert a Coupled Field Transient 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 Coupled_Field_Transient_Example_Mat.xml.

  4. Right-click the Geometry cell and select Properties.

  5. Set the Analysis Type property to 2D under the Advanced Geometry Options category.

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

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

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

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

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

Scripts Illustrated

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

# Scenario 1 Set up the Tree Object Items
GEOMETRY = Model.Geometry
COORDINATE_SYSTEM = Model.CoordinateSystems
CONNECTIONS = Model.Connections
MESH = Model.Mesh
COUPLED_FIELD_TRANSIENT = ExtAPI.DataModel.AnalysisByName("Coupled Field Transient")
ANALYSIS_SETTINGS = COUPLED_FIELD_TRANSIENT.AnalysisSettings
SOLUTION = COUPLED_FIELD_TRANSIENT.Solution

# Scenario 2 Set up the Unit Systems
ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardMKS
ExtAPI.Application.ActiveMetricTemperatureUnit = MetricTemperatureUnitType.Kelvin

# Scenario 3 Define Geometry Details
GEOMETRY.Model2DBehavior=Model2DBehavior.AxiSymmetric

# Scenario 4 Define Named Selections
BODY_NS = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'body'][0]
VERT_EDGE1_NS = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'vert_edge1'][0]
VERT_EDGE2_NS = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'vert_edge2'][0]
HORZ_EDGE1_NS = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'horz_edge1'][0]
HORZ_EDGE2_NS = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'horz_edge1'][0]
SURFACE_NS = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'surface'][0]

# Scenario 5 Assign Material Properties
SURFACE1 = GEOMETRY.Children[0].Children[0]
SURFACE1.Assignment ='MAT1'

# Scenario 6 Define Mesh Settings
MESH.ElementOrder=ElementOrder.Linear
MESH_SIZE1 = MESH.AddSizing()
MESH_SIZE1.Location=HORZ_EDGE1_NS
MESH_SIZE1.Type=SizingType.NumberOfDivisions
MESH_SIZE1.NumberOfDivisions=10
MESH_SIZE1.Behavior=SizingBehavior.Hard
MESH_SIZE2 = MESH_SIZE1.Duplicate()
MESH_SIZE2.Location=HORZ_EDGE2_NS
MESH_SIZE3 = MESH.AddSizing()
MESH_SIZE3.Location=VERT_EDGE1_NS
MESH_SIZE3.Type=SizingType.NumberOfDivisions
MESH_SIZE3.NumberOfDivisions=1
MESH_SIZE3.Behavior=SizingBehavior.Hard
MESH_SIZE4 = MESH_SIZE3.Duplicate()
MESH_SIZE4.Location=VERT_EDGE2_NS
FACE_MESH = MESH.AddFaceMeshing()
FACE_MESH.Location=SURFACE_NS 
MESH.GenerateMesh()

# Scenario 7 Define Initial Physics Option
INITIAL_PHYSICS_OPTION = COUPLED_FIELD_TRANSIENT.Children[1]
INITIAL_PHYSICS_OPTION.InitialTemperatureValue=Quantity('293[K]')
INITIAL_PHYSICS_OPTION.ReferenceTemperature=Quantity('293[K]')

# Scenario 8 Define Analysis Settings
ANALYSIS_SETTINGS.DefineBy=TimeStepDefineByType.Substeps
ANALYSIS_SETTINGS.InitialSubsteps=20
ANALYSIS_SETTINGS.MinimumSubsteps=5
ANALYSIS_SETTINGS.MaximumSubsteps=100
ANALYSIS_SETTINGS.StepEndTime=Quantity('130[s]')
ANALYSIS_SETTINGS.HeatConvergence=ConvergenceToleranceType.On
ANALYSIS_SETTINGS.HeatConvergenceValue=Quantity('0.01[W]')
ANALYSIS_SETTINGS.HeatConvergenceTolerance=1
ANALYSIS_SETTINGS.StructuralOnly=False

# Scenario 9 Insert Load and Boundary Conditions
DISPLACEMENT1 = COUPLED_FIELD_TRANSIENT.AddDisplacement()
DISPLACEMENT1.Location = HORZ_EDGE1_NS.Location
DISPLACEMENT1.YComponent.Output.DiscreteValues = [Quantity('0 [m]')]

DISPLACEMENT2 = COUPLED_FIELD_TRANSIENT.AddDisplacement()
DISPLACEMENT2.Location = HORZ_EDGE2_NS
DISPLACEMENT2.YComponent.Output.DiscreteValues = [Quantity('0 [m]')]

DISPLACEMENT3 = COUPLED_FIELD_TRANSIENT.AddDisplacement()
DISPLACEMENT3.Location = VERT_EDGE1_NS.Location
DISPLACEMENT3.XComponent.Output.DiscreteValues = [Quantity('0.13 [m]')]
DISPLACEMENT3.YComponent.Output.DiscreteValues = [Quantity('0 [m]')]

PLASTIC_HEATING = COUPLED_FIELD_TRANSIENT.AddPlasticHeating()
PLASTIC_HEATING.Location = BODY_NS
PLASTIC_HEATING.PlasticWorkFraction = 0.9

COMMAND_SNIPPET = COUPLED_FIELD_TRANSIENT.AddCommandSnippet()
Cmds_1= "AUTOTS,OFF\nKBC,0\nTINTP,,,,1.0\nOUTRES,ALL,ALL"
COMMAND_SNIPPET.AppendText(Cmds_1)

# Scenario 10 Insert Results
TEMPERATURE = SOLUTION.AddTemperature()
EQUIVALENT_PLASTIC_STRAIN = SOLUTION.AddEquivalentPlasticStrain()

# Scenario 11 Solve and review the Result
SOLUTION.Solve(True)

MAXIMUM_TEMPERATURE = TEMPERATURE.Maximum.Value
MINIMUM_TEMPERATURE = TEMPERATURE.Minimum.Value

MAXIMUM_EQUIVALENT_PLASTIC_STRAIN = EQUIVALENT_PLASTIC_STRAIN.Maximum.Value

Summary

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