.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/technology_showcase/conact_wear_simulation.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_technology_showcase_conact_wear_simulation.py: .. _ref_contact_wear_simulation: Contact Surface Wear Simulation ------------------------------- Using a Archard wear model, this example demonstrates contact sliding of a hemispherical ring on a flat ring to produce wear. The model includes: - Hemispherical ring with a radius of 30 mm made of copper. - Flat ring with an inner radius of 50 mm and an outer radius of 150 mm made of steel. The hemispherical ring is in contact with the flat ring at the center from the axis of rotation at 100 mm and is subjected to a 1) pressure of 4000 N/mm2 and 2) a rotation with a frequency of 100,000 revolutions/sec. The application evaluates total deformation and normal stress results, in loading direction, prior to and following wear. In addition, contact pressure prior to wear is evaluated. .. GENERATED FROM PYTHON SOURCE LINES 25-27 Import necessary libraries ~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 27-37 .. code-block:: Python import os from PIL import Image import ansys.mechanical.core as mech from ansys.mechanical.core.examples import delete_downloads, download_file from matplotlib import image as mpimg from matplotlib import pyplot as plt from matplotlib.animation import FuncAnimation .. GENERATED FROM PYTHON SOURCE LINES 38-39 Embed mechanical and set global variables .. GENERATED FROM PYTHON SOURCE LINES 39-56 .. code-block:: Python app = mech.App(version=241) globals().update(mech.global_variables(app, True)) print(app) cwd = os.path.join(os.getcwd(), "out") def display_image(image_name): plt.figure(figsize=(16, 9)) plt.imshow(mpimg.imread(os.path.join(cwd, image_name))) plt.xticks([]) plt.yticks([]) plt.axis("off") plt.show() .. rst-class:: sphx-glr-script-out .. code-block:: none Ansys Mechanical [Ansys Mechanical Enterprise] Product Version:241 Software build date: 11/27/2023 10:24:20 .. GENERATED FROM PYTHON SOURCE LINES 57-59 Configure graphics for image export ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 59-70 .. code-block:: Python ExtAPI.Graphics.Camera.SetSpecificViewOrientation(ViewOrientationType.Front) image_export_format = GraphicsImageExportFormat.PNG settings_720p = Ansys.Mechanical.Graphics.GraphicsImageExportSettings() settings_720p.Resolution = GraphicsResolutionType.EnhancedResolution settings_720p.Background = GraphicsBackgroundType.White settings_720p.Width = 1280 settings_720p.Height = 720 settings_720p.CurrentGraphicsDisplay = False ExtAPI.Graphics.Camera.Rotate(180, CameraAxisType.ScreenY) .. GENERATED FROM PYTHON SOURCE LINES 71-73 Download geometry and materials files ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 73-78 .. code-block:: Python geometry_path = download_file("example_07_td43_wear.agdb", "pymechanical", "00_basic") mat1_path = download_file("example_07_Mat_Copper.xml", "pymechanical", "00_basic") mat2_path = download_file("example_07_Mat_Steel.xml", "pymechanical", "00_basic") .. GENERATED FROM PYTHON SOURCE LINES 79-81 Import geometry ~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 81-99 .. code-block:: Python geometry_import = Model.GeometryImportGroup.AddGeometryImport() geometry_import_format = ( Ansys.Mechanical.DataModel.Enums.GeometryImportPreference.Format.Automatic ) geometry_import_preferences = Ansys.ACT.Mechanical.Utilities.GeometryImportPreferences() geometry_import_preferences.ProcessNamedSelections = True geometry_import_preferences.ProcessCoordinateSystems = True geometry_import.Import( geometry_path, geometry_import_format, geometry_import_preferences ) ExtAPI.Graphics.Camera.SetFit() ExtAPI.Graphics.ExportImage( os.path.join(cwd, "geometry.png"), image_export_format, settings_720p ) display_image("geometry.png") .. image-sg:: /examples/technology_showcase/images/sphx_glr_conact_wear_simulation_001.png :alt: conact wear simulation :srcset: /examples/technology_showcase/images/sphx_glr_conact_wear_simulation_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 100-102 Import materials ~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 102-109 .. code-block:: Python MAT = Model.Materials MAT.Import(mat1_path) MAT.Import(mat2_path) print("Material import done !") .. rst-class:: sphx-glr-script-out .. code-block:: none Material import done ! .. GENERATED FROM PYTHON SOURCE LINES 110-113 Setup the Analysis ~~~~~~~~~~~~~~~~~~ Set up the unit system .. GENERATED FROM PYTHON SOURCE LINES 113-116 .. code-block:: Python ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardNMM .. GENERATED FROM PYTHON SOURCE LINES 117-118 Store all main tree nodes as variables .. GENERATED FROM PYTHON SOURCE LINES 118-126 .. code-block:: Python MODEL = ExtAPI.DataModel.Project.Model GEOM = ExtAPI.DataModel.Project.Model.Geometry CS_GRP = ExtAPI.DataModel.Project.Model.CoordinateSystems CONN_GRP = ExtAPI.DataModel.Project.Model.Connections MSH = ExtAPI.DataModel.Project.Model.Mesh NS_GRP = ExtAPI.DataModel.Project.Model.NamedSelections .. GENERATED FROM PYTHON SOURCE LINES 127-128 Add static structural analysis .. GENERATED FROM PYTHON SOURCE LINES 128-134 .. code-block:: Python Model.AddStaticStructuralAnalysis() STAT_STRUC = Model.Analyses[0] STAT_STRUC_SOLN = STAT_STRUC.Solution STAT_STRUC_ANA_SETTING = STAT_STRUC.Children[0] .. GENERATED FROM PYTHON SOURCE LINES 135-136 Store name selection .. GENERATED FROM PYTHON SOURCE LINES 136-147 .. code-block:: Python CURVE_NS = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == "curve"][0] DIA_NS = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == "dia"][0] VER_EDGE1 = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == "v1"][0] VER_EDGE2 = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == "v2"][0] HOR_EDGE1 = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == "h1"][0] HOR_EDGE2 = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == "h2"][0] ALL_BODIES_NS = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == "all_bodies"][ 0 ] .. GENERATED FROM PYTHON SOURCE LINES 148-149 Assign material to bodies and change behavior to axisymmetric .. GENERATED FROM PYTHON SOURCE LINES 149-160 .. code-block:: Python GEOM.Model2DBehavior = Model2DBehavior.AxiSymmetric SURFACE1 = GEOM.Children[0].Children[0] SURFACE1.Material = "Steel" SURFACE1.Dimension = ShellBodyDimension.Two_D SURFACE2 = GEOM.Children[1].Children[0] SURFACE2.Material = "Copper" SURFACE2.Dimension = ShellBodyDimension.Two_D .. GENERATED FROM PYTHON SOURCE LINES 161-162 Change contact settings .. GENERATED FROM PYTHON SOURCE LINES 162-172 .. code-block:: Python CONT_REG = CONN_GRP.AddContactRegion() CONT_REG.SourceLocation = NS_GRP.Children[6] CONT_REG.TargetLocation = NS_GRP.Children[3] # CONT_REG.FlipContactTarget() CONT_REG.ContactType = ContactType.Frictionless CONT_REG.Behavior = ContactBehavior.Asymmetric CONT_REG.ContactFormulation = ContactFormulation.AugmentedLagrange CONT_REG.DetectionMethod = ContactDetectionPoint.NodalNormalToTarget .. GENERATED FROM PYTHON SOURCE LINES 173-174 Add a command snippet to use Archard Wear Model .. GENERATED FROM PYTHON SOURCE LINES 174-193 .. code-block:: Python AWM = """keyo,cid,5,1 keyo,cid,10,2 pi=acos(-1) slide_velocity=1e5 Uring_offset=100 kcopper=10e-13*slide_velocity*2*pi*Uring_offset TB,WEAR,cid,,,ARCD TBFIELD,TIME,0 TBDATA,1,0,1,1,0,0 TBFIELD,TIME,1 TBDATA,1,0,1,1,0,0 TBFIELD,TIME,1.01 TBDATA,1,kcopper,1,1,0,0 TBFIELD,TIME,4 TBDATA,1,kcopper,1,1,0,0""" CMD1 = CONT_REG.AddCommandSnippet() CMD1.AppendText(AWM) .. GENERATED FROM PYTHON SOURCE LINES 194-195 Insert remote point .. GENERATED FROM PYTHON SOURCE LINES 195-200 .. code-block:: Python REM_PT = MODEL.AddRemotePoint() REM_PT.Location = DIA_NS REM_PT.Behavior = LoadBehavior.Rigid .. GENERATED FROM PYTHON SOURCE LINES 201-203 Mesh ~~~~ .. GENERATED FROM PYTHON SOURCE LINES 203-245 .. code-block:: Python MSH.ElementOrder = ElementOrder.Linear MSH.ElementSize = Quantity("1 [mm]") EDGE_SIZING1 = MSH.AddSizing() EDGE_SIZING1.Location = HOR_EDGE1 EDGE_SIZING1.Type = SizingType.NumberOfDivisions EDGE_SIZING1.NumberOfDivisions = 70 EDGE_SIZING2 = MSH.AddSizing() EDGE_SIZING2.Location = HOR_EDGE2 EDGE_SIZING2.Type = SizingType.NumberOfDivisions EDGE_SIZING2.NumberOfDivisions = 70 EDGE_SIZING3 = MSH.AddSizing() EDGE_SIZING3.Location = VER_EDGE1 EDGE_SIZING3.Type = SizingType.NumberOfDivisions EDGE_SIZING3.NumberOfDivisions = 35 EDGE_SIZING4 = MSH.AddSizing() EDGE_SIZING4.Location = VER_EDGE2 EDGE_SIZING4.Type = SizingType.NumberOfDivisions EDGE_SIZING4.NumberOfDivisions = 35 EDGE_SIZING5 = MSH.AddSizing() EDGE_SIZING5.Location = DIA_NS EDGE_SIZING5.Type = SizingType.NumberOfDivisions EDGE_SIZING5.NumberOfDivisions = 40 EDGE_SIZING6 = MSH.AddSizing() EDGE_SIZING6.Location = CURVE_NS EDGE_SIZING6.Type = SizingType.NumberOfDivisions EDGE_SIZING6.NumberOfDivisions = 60 MSH.GenerateMesh() ExtAPI.Graphics.Camera.SetFit() ExtAPI.Graphics.ExportImage( os.path.join(cwd, "mesh.png"), image_export_format, settings_720p ) display_image("mesh.png") .. image-sg:: /examples/technology_showcase/images/sphx_glr_conact_wear_simulation_002.png :alt: conact wear simulation :srcset: /examples/technology_showcase/images/sphx_glr_conact_wear_simulation_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 246-248 Analysis settings ~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 248-267 .. code-block:: Python STAT_STRUC_ANA_SETTING.NumberOfSteps = 2 STAT_STRUC_ANA_SETTING.CurrentStepNumber = 1 STAT_STRUC_ANA_SETTING.AutomaticTimeStepping = AutomaticTimeStepping.On STAT_STRUC_ANA_SETTING.DefineBy = TimeStepDefineByType.Time STAT_STRUC_ANA_SETTING.InitialTimeStep = Quantity("0.1 [s]") STAT_STRUC_ANA_SETTING.MinimumTimeStep = Quantity("0.0001 [s]") STAT_STRUC_ANA_SETTING.MaximumTimeStep = Quantity("1 [s]") STAT_STRUC_ANA_SETTING.CurrentStepNumber = 2 STAT_STRUC_ANA_SETTING.Activate() STAT_STRUC_ANA_SETTING.StepEndTime = Quantity("4 [s]") STAT_STRUC_ANA_SETTING.AutomaticTimeStepping = AutomaticTimeStepping.On STAT_STRUC_ANA_SETTING.DefineBy = TimeStepDefineByType.Time STAT_STRUC_ANA_SETTING.InitialTimeStep = Quantity("0.01 [s]") STAT_STRUC_ANA_SETTING.MinimumTimeStep = Quantity("0.000001 [s]") STAT_STRUC_ANA_SETTING.MaximumTimeStep = Quantity("0.02 [s]") STAT_STRUC_ANA_SETTING.LargeDeflection = True .. GENERATED FROM PYTHON SOURCE LINES 268-270 Insert loading and boundary conditions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 270-300 .. code-block:: Python FIX_SUP = STAT_STRUC.AddFixedSupport() FIX_SUP.Location = HOR_EDGE1 REM_DISP = STAT_STRUC.AddRemoteDisplacement() REM_DISP.Location = REM_PT REM_DISP.XComponent.Output.DiscreteValues = [Quantity("0[mm]")] REM_DISP.RotationZ.Output.DiscreteValues = [Quantity("0[deg]")] REM_FRC = STAT_STRUC.AddRemoteForce() REM_FRC.Location = REM_PT REM_FRC.DefineBy = LoadDefineBy.Components REM_FRC.YComponent.Output.DiscreteValues = [Quantity("-150796320 [N]")] # Nonlinear Adaptivity does not support contact criterion yet hence command snippet used NLAD = """NLADAPTIVE,all,add,contact,wear,0.50 NLADAPTIVE,all,on,all,all,1,,4 NLADAPTIVE,all,list,all,all""" CMD2 = STAT_STRUC.AddCommandSnippet() CMD2.AppendText(NLAD) CMD2.StepSelectionMode = SequenceSelectionType.All STAT_STRUC.Activate() ExtAPI.Graphics.Camera.SetFit() ExtAPI.Graphics.ExportImage( os.path.join(cwd, "mesh.png"), image_export_format, settings_720p ) display_image("mesh.png") .. image-sg:: /examples/technology_showcase/images/sphx_glr_conact_wear_simulation_003.png :alt: conact wear simulation :srcset: /examples/technology_showcase/images/sphx_glr_conact_wear_simulation_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 301-303 Insert results ~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 303-328 .. code-block:: Python TOT_DEF = STAT_STRUC_SOLN.AddTotalDeformation() NORM_STRS1 = STAT_STRUC_SOLN.AddNormalStress() NORM_STRS1.NormalOrientation = NormalOrientationType.YAxis NORM_STRS1.DisplayTime = Quantity("1 [s]") NORM_STRS1.DisplayOption = ResultAveragingType.Unaveraged NORM_STRS2 = STAT_STRUC_SOLN.AddNormalStress() NORM_STRS2.NormalOrientation = NormalOrientationType.YAxis NORM_STRS2.DisplayTime = Quantity("4 [s]") NORM_STRS2.DisplayOption = ResultAveragingType.Unaveraged CONT_TOOL = STAT_STRUC_SOLN.AddContactTool() CONT_TOOL.ScopingMethod = GeometryDefineByType.Geometry SEL1 = ExtAPI.SelectionManager.AddSelection(ALL_BODIES_NS) SEL2 = ExtAPI.SelectionManager.CurrentSelection CONT_TOOL.Location = SEL2 ExtAPI.SelectionManager.ClearSelection() CONT_PRES1 = CONT_TOOL.AddPressure() CONT_PRES1.DisplayTime = Quantity("1 [s]") CONT_PRES2 = CONT_TOOL.AddPressure() CONT_PRES2.DisplayTime = Quantity("4 [s]") .. GENERATED FROM PYTHON SOURCE LINES 329-331 Solve ~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 331-335 .. code-block:: Python STAT_STRUC_SOLN.Solve(True) STAT_STRUC_SS = STAT_STRUC_SOLN.Status .. GENERATED FROM PYTHON SOURCE LINES 339-342 Postprocessing ~~~~~~~~~~~~~~ Normal stress .. GENERATED FROM PYTHON SOURCE LINES 342-349 .. code-block:: Python Tree.Activate([NORM_STRS1]) ExtAPI.Graphics.ExportImage( os.path.join(cwd, "normal_stresss.png"), image_export_format, settings_720p ) display_image("normal_stresss.png") .. image-sg:: /examples/technology_showcase/images/sphx_glr_conact_wear_simulation_004.png :alt: conact wear simulation :srcset: /examples/technology_showcase/images/sphx_glr_conact_wear_simulation_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 350-351 Total deformation animation .. GENERATED FROM PYTHON SOURCE LINES 351-380 .. code-block:: Python animation_export_format = ( Ansys.Mechanical.DataModel.Enums.GraphicsAnimationExportFormat.GIF ) settings_720p = Ansys.Mechanical.Graphics.AnimationExportSettings() settings_720p.Width = 1280 settings_720p.Height = 720 TOT_DEF.ExportAnimation( os.path.join(cwd, "totaldeformation.gif"), animation_export_format, settings_720p ) gif = Image.open(os.path.join(cwd, "totaldeformation.gif")) fig, ax = plt.subplots(figsize=(16, 9)) ax.axis("off") img = ax.imshow(gif.convert("RGBA")) def update(frame): gif.seek(frame) img.set_array(gif.convert("RGBA")) return [img] ani = FuncAnimation( fig, update, frames=range(gif.n_frames), interval=200, repeat=True, blit=True ) plt.show() .. container:: sphx-glr-animation .. raw:: html
.. GENERATED FROM PYTHON SOURCE LINES 381-383 Project tree ~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 383-401 .. code-block:: Python def print_tree(node, indentation=""): print(f"{indentation}├── {node.Name}") if ( hasattr(node, "Children") and node.Children is not None and node.Children.Count > 0 ): for child in node.Children: print_tree(child, indentation + "| ") root_node = DataModel.Project print_tree(root_node) .. rst-class:: sphx-glr-script-out .. code-block:: none ├── Project | ├── Model | | ├── Geometry Imports | | | ├── Geometry Import | | ├── Geometry | | | ├── Steel_Ring | | | | ├── Steel_Ring | | | ├── Hemispherical_Copper_Ring | | | | ├── Hemispherical_Copper_Ring | | ├── Materials | | | ├── Structural Steel | | | ├── Copper | | | ├── Steel | | ├── Coordinate Systems | | | ├── Global Coordinate System | | ├── Remote Points | | | ├── Remote Point | | ├── Connections | | | ├── Connection Group | | | | ├── Contact Region | | | | | ├── Commands (APDL) | | ├── Mesh | | | ├── Edge Sizing | | | ├── Edge Sizing 2 | | | ├── Edge Sizing 3 | | | ├── Edge Sizing 4 | | | ├── Edge Sizing 5 | | | ├── Edge Sizing 6 | | ├── Named Selections | | | ├── all_bodies | | | ├── dia | | | ├── h1 | | | ├── h2 | | | ├── v1 | | | ├── v2 | | | ├── curve | | ├── Static Structural | | | ├── Analysis Settings | | | ├── Fixed Support | | | ├── Remote Displacement | | | ├── Remote Force | | | ├── Commands (APDL) | | | ├── Solution | | | | ├── Solution Information | | | | ├── Total Deformation | | | | ├── Normal Stress | | | | ├── Normal Stress 2 | | | | ├── Contact Tool | | | | | ├── Status | | | | | ├── Pressure | | | | | ├── Pressure 2 .. GENERATED FROM PYTHON SOURCE LINES 402-405 Cleanup ~~~~~~~ Save project .. GENERATED FROM PYTHON SOURCE LINES 405-411 .. code-block:: Python app.save(os.path.join(cwd, "contact_wear.mechdat")) app.new() # delete example file delete_downloads() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. rst-class:: sphx-glr-timing **Total running time of the script:** (6 minutes 36.622 seconds) .. _sphx_glr_download_examples_technology_showcase_conact_wear_simulation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: conact_wear_simulation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: conact_wear_simulation.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_