Static Structural Analysis

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

  • Mechanical_Static_Structural_Example_001_Geometry.agdb

  • Mechanical_Static_Structural_Example_001_Script.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 Mechanical_Static_Structural_Example_001_Geometry.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 Mechanical_Static_Structural_Example_001_Script.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.

CS_GRP = Model.CoordinateSystems 
STAT_STRUC = Model.Analyses[0] 
ANALYSIS_SETTINGS = STAT_STRUC.Children[0] 
SOLN= STAT_STRUC.Solution 

# Section 2 - Set up the Unit System.

ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardMKS 
ExtAPI.Application.ActiveAngleUnit = AngleUnitType.Radian 

# Section 3 Named Selection and Coordinate System.

NS1 = Model.NamedSelections.Children[0] 
NS2 = Model.NamedSelections.Children[1] 
NS3 = Model.NamedSelections.Children[2] 
NS4 = Model.NamedSelections.Children[3] 
GCS = CS_GRP.Children[0] 
LCS1 = CS_GRP.Children[1] 

# Section 4 Define remote point. 

RMPT_GRP = Model.RemotePoints 
RMPT_1 = RMPT_GRP.AddRemotePoint() 
RMPT_1.Location = NS1 
RMPT_1.XCoordinate=Quantity("7 [m]") 
RMPT_1.YCoordinate=Quantity("0 [m]") 
RMPT_1.ZCoordinate=Quantity("0 [m]") 

#  Section 5 - Define Mesh Settings.

MSH = Model.Mesh 
MSH.ElementSize =Quantity("0.5 [m]") 
MSH.GenerateMesh() 

#  Section 6 Define boundary conditions.

# Insert FIXED Support 
FIX_SUP = STAT_STRUC.AddFixedSupport() 
FIX_SUP.Location = NS2 

# Insert Frictionless Support 
FRIC_SUP = STAT_STRUC.AddFrictionlessSupport() 
FRIC_SUP.Location = NS3 

#  Section 7 - Define remote force.

REM_FRC1 = STAT_STRUC.AddRemoteForce()
REM_FRC1.Location = RMPT_1
REM_FRC1.DefineBy =LoadDefineBy.Components
REM_FRC1.XComponent.Output.DiscreteValues = [Quantity("1e10 [N]")]

#  Section 8 - Define thermal condition.

THERM_COND = STAT_STRUC.AddThermalCondition()
THERM_COND.Location = NS4
THERM_COND.Magnitude.Output.DefinitionType=VariableDefinitionType.Formula
THERM_COND.Magnitude.Output.Formula="50*(20+z)"
THERM_COND.XYZFunctionCoordinateSystem=LCS1
THERM_COND.RangeMinimum=Quantity("-20 [m]")
THERM_COND.RangeMaximum=Quantity("1 [m]")

#  Section 9 - Insert directional deformation.

DIR_DEF = STAT_STRUC.Solution.AddDirectionalDeformation()
DIR_DEF.Location = NS1
DIR_DEF.NormalOrientation =NormalOrientationType.XAxis

# Section 10 - Add Total Deformation and force reaction probe

TOT_DEF = STAT_STRUC.Solution.AddTotalDeformation()

# Add Force Reaction
FRC_REAC_PROBE = STAT_STRUC.Solution.AddForceReaction()
FRC_REAC_PROBE.BoundaryConditionSelection = FIX_SUP
FRC_REAC_PROBE.ResultSelection =ProbeDisplayFilter.XAxis

# Section 11 - Solve and get the results.

# Solve Static Analysis
STAT_STRUC.Solution.Solve(True)

DIR_DEF_MAX = DIR_DEF.Maximum.Value
DIR_DEF_MIN = DIR_DEF.Minimum.Value
TOT_DEF_MAX = TOT_DEF.Maximum.Value
TOT_DEF_MIN = TOT_DEF.Minimum.Value
FRC_REAC_PROBE_VAL = FRC_REAC_PROBE.XAxis.Value

Summary

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