This example creates a Fracture Analysis that uses a Semi-Elliptical Crack. A semi-elliptical crack is inserted at the tubular joint of the structure, the crack mesh is generated for defined Semi-Elliptical Crack, and then fracture parameters are computed and post-processed.
This example begins in the Mechanical application. It requires you to download the following Ansys DesignModeler and python files.
Semi-Elliptical_Crack_Example_003.agdb
Semi-Elliptical_Crack_Example_003.py
These files are available here.
Procedure
Open Mechanical directly without importing a geometry or specifying an analysis type. This can be done through Start Menu.
From the Analysis drop-down menu of the Insert group on the Home tab, insert a system into the tree.
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 Semi-Elliptical_Crack_Example_003.agdb.
Select the Automation tab and select the Scripting option to open the Mechanical Scripting pane.
Select the Open Script option (
) from the Editor toolbar. Navigate to the proper folder location and select Semi-Elliptical_Crack_Example_003.py.
Select the Run Script option (
) from the Editor toolbar.
Scripts Illustrated
In this example, the python file automatically performs the following actions:
# Scenario 1 Store main Tree Object items MODEL = Model GEOMETRY = Model.Geometry SOLID2 = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == 'Solid2'][0] COORDINATE_SYSTEMS = Model.CoordinateSystems GLOBAL_COORDINATE_SYSTEM = [i for i in COORDINATE_SYSTEMS.GetChildren[Ansys.ACT.Automation.Mechanical.CoordinateSystem](True) if i.Name == 'Global Coordinate System'][0] MESH = Model.Mesh NAMED_SELECTIONS = ExtAPI.DataModel.Project.Model.NamedSelections NS_PIPE_BODY = [i for i in NAMED_SELECTIONS.GetChildren[Ansys.ACT.Automation.Mechanical.NamedSelection](True) if i.Name == 'Pipe_Body'][0] NS_FILET_FACE = [i for i in NAMED_SELECTIONS.GetChildren[Ansys.ACT.Automation.Mechanical.NamedSelection](True) if i.Name == 'Filet_Face'][0] NS_VERTEX_FILET = [i for i in NAMED_SELECTIONS.GetChildren[Ansys.ACT.Automation.Mechanical.NamedSelection](True) if i.Name == 'Vertex_Filet'][0] NS_PRESSURE_FACE = [i for i in NAMED_SELECTIONS.GetChildren[Ansys.ACT.Automation.Mechanical.NamedSelection](True) if i.Name == 'Pressure_Face'][0] STATIC_STRUCTURAL = ExtAPI.DataModel.AnalysisByName("Static Structural") ANALYSIS_SETTINGS = STATIC_STRUCTURAL.AnalysisSettings SOLUTION= STATIC_STRUCTURAL.Solution # Scenario 2 Set Display Unit ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardNMM # Scenario 3 Add local Coordinate System for defining Semi-Elliptical Crack COORDINATE_SYSTEMS.Activate() COORDINATE_SYSTEM = COORDINATE_SYSTEMS.AddCoordinateSystem() SEL=ExtAPI.SelectionManager.AddSelection(NS_VERTEX_FILET) SEL2=ExtAPI.SelectionManager.CurrentSelection COORDINATE_SYSTEM.OriginLocation = SEL2 ExtAPI.SelectionManager.ClearSelection() COORDINATE_SYSTEM.AddTransformation(TransformationType.Rotation, CoordinateSystemAxisType.PositiveZAxis) COORDINATE_SYSTEM.SetTransformationValue(1, 22.2922) COORDINATE_SYSTEM.AddTransformation(TransformationType.Rotation, CoordinateSystemAxisType.PositiveYAxis) COORDINATE_SYSTEM.SetTransformationValue(2, 180) # Scenario 4 Define Mesh controls and generate base mesh MESH.Activate() MESH.SpanAngleCenter = 2 # For setting it to Fine option METHOD_MESH = MESH.AddAutomaticMethod() METHOD_MESH.Location = NS_PIPE_BODY METHOD_MESH.Method=MethodType.AllTriAllTet SIZING_MESH = MESH.AddSizing() SIZING_MESH.Location = NS_FILET_FACE SIZING_MESH.ElementSize = Quantity('5 [mm]') MESH.Activate() MESH.GenerateMesh() # Scenario 5 Add Semi-Elliptical Crack object and Generate Crack Mesh MODEL.Activate() FRACTURE = MODEL.AddFracture() SEMI_ELLIPTICAL_CRACK = FRACTURE.AddSemiEllipticalCrack() SEL=ExtAPI.SelectionManager.AddSelection(NS_PIPE_BODY) SEL2=ExtAPI.SelectionManager.CurrentSelection SEMI_ELLIPTICAL_CRACK.Location=SEL2 ExtAPI.SelectionManager.ClearSelection() SEMI_ELLIPTICAL_CRACK.CoordinateSystem=COORDINATE_SYSTEM SEMI_ELLIPTICAL_CRACK.MajorRadius = Quantity("18.4 [mm]") SEMI_ELLIPTICAL_CRACK.MinorRadius = Quantity("9.5 [mm]") SEMI_ELLIPTICAL_CRACK.LargestContourRadius= Quantity("2 [mm]") SEMI_ELLIPTICAL_CRACK.CrackFrontDivisions = 35 SEMI_ELLIPTICAL_CRACK.CircumferentialDivisions = 18 SEMI_ELLIPTICAL_CRACK.CrackFacesNodes = True SEMI_ELLIPTICAL_CRACK.ContactPairsNodes= True FRACTURE.GenerateAllCrackMesh() # Scenario 6 Define Analysis Settings for Fracture calculations ANALYSIS_SETTINGS.Activate() ANALYSIS_SETTINGS.WeakSprings=WeakSpringsType.ProgramControlled ANALYSIS_SETTINGS.SIFS = True ANALYSIS_SETTINGS.JIntegral = True ANALYSIS_SETTINGS.MaterialForce = True ANALYSIS_SETTINGS.TStress = True # Scenario 7 Define boundary condition STATIC_STRUCTURAL.Activate() PRESSURE = STATIC_STRUCTURAL.AddPressure() PRESSURE.Location = NS_PRESSURE_FACE PRESSURE.Magnitude.Output.DiscreteValues = [Quantity('-100 [MPa]')] # Scenario 8 Add Deformation and Fracture specific results SOLUTION.Activate() TOTAL_DEFORMATION = SOLUTION.AddTotalDeformation() FRACTURE_TOOL = SOLUTION.AddFractureTool() FRACTURE_TOOL.CrackSelection = SEMI_ELLIPTICAL_CRACK SIFS_K1 = [i for i in FRACTURE_TOOL.GetChildren[Ansys.ACT.Automation.Mechanical.Results.FractureToolResults.FractureToolResult](True) if i.Name == 'SIFS (K1)'][0] SIFS_K2 = FRACTURE_TOOL.AddSIFSK2() SIFS_K3 = FRACTURE_TOOL.AddSIFSK3() J_INTEGRAL = FRACTURE_TOOL.AddJINT() MATERIAL_FORCE_X = FRACTURE_TOOL.AddMaterialForceX() MATERIAL_FORCE_Y = FRACTURE_TOOL.AddMaterialForceY() MATERIAL_FORCE_Z = FRACTURE_TOOL.AddMaterialForceZ() T_STRESS = FRACTURE_TOOL.AddTSTRESS() # Scenario 9 Solve and review Results STATIC_STRUCTURAL.Activate() STATIC_STRUCTURAL.Solve(True) TOTAL_DEFORMATION.Activate() MAX_TOTAL_DEFORMATION = TOTAL_DEFORMATION.Maximum.Value SIFS_K1.Activate() MIN_SIFS_K1_C6 = SIFS_K1.Minimum.Value MAX_SIFS_K1_C6 = SIFS_K1.Maximum.Value SIFS_K2.Activate() MIN_SIFS_K2_C6 = SIFS_K2.Minimum.Value MAX_SIFS_K2_C6 = SIFS_K2.Maximum.Value SIFS_K3.Activate() MIN_SIFS_K3_C6 = SIFS_K3.Minimum.Value MAX_SIFS_K3_C6 = SIFS_K3.Maximum.Value J_INTEGRAL.Activate() MIN_J_INTEGRAL_C6 = J_INTEGRAL.Minimum.Value MAX_J_INTEGRAL_C6 = J_INTEGRAL.Maximum.Value MATERIAL_FORCE_X.Activate() MIN_MATERIAL_FORCE_X_C6 = MATERIAL_FORCE_X.Minimum.Value MAX_MATERIAL_FORCE_X_C6 = MATERIAL_FORCE_X.Maximum.Value MATERIAL_FORCE_Y.Activate() MIN_MATERIAL_FORCE_Y_C6 = MATERIAL_FORCE_Y.Minimum.Value MAX_MATERIAL_FORCE_Y_C6 = MATERIAL_FORCE_Y.Maximum.Value MATERIAL_FORCE_Z.Activate() MIN_MATERIAL_FORCE_Z_C6 = MATERIAL_FORCE_Z.Minimum.Value MAX_MATERIAL_FORCE_Z_C6 = MATERIAL_FORCE_Z.Maximum.Value T_STRESS.Activate() MIN_T_STRESS_C6 = T_STRESS.Minimum.Value MAX_T_STRESS_C6 = T_STRESS.Maximum.Value
Summary
This example demonstrates how scripting in Mechanical can be used to automate your actions.