Basic valve implementation#

This example demonstrates a basic implementation of a valve in Python.

Import the necessary libraries#

from pathlib import Path
from typing import TYPE_CHECKING

from matplotlib import image as mpimg, pyplot as plt
from matplotlib.animation import FuncAnimation
from PIL import Image

from ansys.mechanical.core import App
from ansys.mechanical.core.examples import delete_downloads, download_file

if TYPE_CHECKING:
    import Ansys

Initialize the embedded application#

app = App(globals=globals())
print(app)
Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:261
Software build date: 01/12/2026 14:14:35

Create functions to set camera and display images#

# Set the path for the output files (images, gifs, mechdat)
output_path = Path.cwd() / "out"


def set_camera_and_display_image(
    camera,
    graphics,
    graphics_image_export_settings,
    image_output_path: Path,
    image_name: str,
) -> None:
    """Set the camera to fit the model and display the image.

    Parameters
    ----------
    camera : Ansys.ACT.Common.Graphics.MechanicalCameraWrapper
        The camera object to set the view.
    graphics : Ansys.ACT.Common.Graphics.MechanicalGraphicsWrapper
        The graphics object to export the image.
    graphics_image_export_settings : Ansys.Mechanical.Graphics.GraphicsImageExportSettings
        The settings for exporting the image.
    image_output_path : Path
        The path to save the exported image.
    image_name : str
        The name of the exported image file.
    """
    # Set the camera to fit the mesh
    camera.SetFit()
    # Export the mesh image with the specified settings
    image_path = image_output_path / image_name
    graphics.ExportImage(str(image_path), image_export_format, graphics_image_export_settings)
    # Display the exported mesh image
    display_image(image_path)


def display_image(
    image_path: str,
    pyplot_figsize_coordinates: tuple = (16, 9),
    plot_xticks: list = [],
    plot_yticks: list = [],
    plot_axis: str = "off",
) -> None:
    """Display the image with the specified parameters.

    Parameters
    ----------
    image_path : str
        The path to the image file to display.
    pyplot_figsize_coordinates : tuple
        The size of the figure in inches (width, height).
    plot_xticks : list
        The x-ticks to display on the plot.
    plot_yticks : list
        The y-ticks to display on the plot.
    plot_axis : str
        The axis visibility setting ('on' or 'off').
    """
    # Set the figure size based on the coordinates specified
    plt.figure(figsize=pyplot_figsize_coordinates)
    # Read the image from the file into an array
    plt.imshow(mpimg.imread(image_path))
    # Get or set the current tick locations and labels of the x-axis
    plt.xticks(plot_xticks)
    # Get or set the current tick locations and labels of the y-axis
    plt.yticks(plot_yticks)
    # Turn off the axis
    plt.axis(plot_axis)
    # Display the figure
    plt.show()

Configure graphics for image export#

graphics = app.Graphics
camera = graphics.Camera

# Set the camera orientation to the isometric view
camera.SetSpecificViewOrientation(ViewOrientationType.Iso)

# Set the image export format and settings
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

Download and import the geometry file#

# Download the geometry file
geometry_path = download_file("Valve.pmdb", "pymechanical", "embedding")

Import the geometry

# Define the model
model = app.Model

# Add a geometry import to the geometry import group
geometry_import = model.GeometryImportGroup.AddGeometryImport()

# Set the geometry import settings
geometry_import_format = Ansys.Mechanical.DataModel.Enums.GeometryImportPreference.Format.Automatic
geometry_import_preferences = Ansys.ACT.Mechanical.Utilities.GeometryImportPreferences()
geometry_import_preferences.ProcessNamedSelections = True

# Import the geometry file with the specified settings
geometry_import.Import(geometry_path, geometry_import_format, geometry_import_preferences)

# Visualize the model in 3D
app.plot()
valve
[]

Assign the materials and mesh the geometry#

# Add the material assignment to the model materials
material_assignment = model.Materials.AddMaterialAssignment()

# Set the material to structural steel
material_assignment.Material = "Structural Steel"

# Create selection information for the geometry entities
selection_info = app.ExtAPI.SelectionManager.CreateSelectionInfo(
    Ansys.ACT.Interfaces.Common.SelectionTypeEnum.GeometryEntities
)

# Get the geometric bodies from the model and add their IDs to the selection info IDs list
selection_info.Ids = [
    body.GetGeoBody().Id
    for body in model.Geometry.GetChildren(
        Ansys.Mechanical.DataModel.Enums.DataModelObjectCategory.Body, True
    )
]
# Set the material assignment location to the selected geometry entities
material_assignment.Location = selection_info

Define the mesh settings and generate the mesh

# Define the mesh
mesh = model.Mesh
# Set the mesh element size to 25mm
mesh.ElementSize = Quantity(25, "mm")

# Generate the mesh
mesh.GenerateMesh()

# Activate the mesh and display the image
app.Tree.Activate([mesh])
set_camera_and_display_image(camera, graphics, settings_720p, output_path, "mesh.png")
valve

Add a static structural analysis and apply boundary conditions#

# Add a static structural analysis to the model
analysis = model.AddStaticStructuralAnalysis()

# Add a fixed support to the analysis
fixed_support = analysis.AddFixedSupport()
# Set the fixed support location to the "NSFixedSupportFaces" object
fixed_support.Location = app.ExtAPI.DataModel.GetObjectsByName("NSFixedSupportFaces")[0]

# Add a frictionless support to the analysis
frictionless_support = analysis.AddFrictionlessSupport()
# Set the frictionless support location to the "NSFrictionlessSupportFaces" object
frictionless_support.Location = app.ExtAPI.DataModel.GetObjectsByName("NSFrictionlessSupportFaces")[
    0
]

# Add pressure to the analysis
pressure = analysis.AddPressure()
# Set the pressure location to the "NSInsideFaces" object
pressure.Location = app.ExtAPI.DataModel.GetObjectsByName("NSInsideFaces")[0]

# Set the pressure magnitude's input and output values
pressure.Magnitude.Inputs[0].DiscreteValues = [Quantity("0 [s]"), Quantity("1 [s]")]
pressure.Magnitude.Output.DiscreteValues = [Quantity("0 [Pa]"), Quantity("15 [MPa]")]

# Activate the analysis and display the image
analysis.Activate()
set_camera_and_display_image(
    camera, graphics, settings_720p, output_path, "boundary_conditions.png"
)
valve

Add results to the analysis solution

# Define the solution for the analysis
solution = analysis.Solution

# Add the total deformation and equivalent stress results to the solution
deformation = solution.AddTotalDeformation()
stress = solution.AddEquivalentStress()

Solve the solution#

solution.Solve(True)

Show messages#

# Print all messages from Mechanical
app.messages.show()
Severity: Warning
DisplayString: Some boundaries of protected topologies have been defeatured.  Right click on this message and select "Show Problematic Geometry" to see the affected edges.
Severity: Info
DisplayString: The requested license was received from the License Manager after 34 seconds.

Display the results#

Show the total deformation image

# Activate the total deformation result and display the image
app.Tree.Activate([deformation])
set_camera_and_display_image(
    camera, graphics, settings_720p, output_path, "total_deformation_valve.png"
)
valve

Show the equivalent stress image

# Activate the equivalent stress result and display the image
app.Tree.Activate([stress])
set_camera_and_display_image(camera, graphics, settings_720p, output_path, "stress_valve.png")
valve

Create a function to update the animation frames

def update_animation(frame: int) -> list[mpimg.AxesImage]:
    """Update the animation frame for the GIF.

    Parameters
    ----------
    frame : int
        The frame number to update the animation.

    Returns
    -------
    list[mpimg.AxesImage]
        A list containing the updated image for the animation.
    """
    # Seeks to the given frame in this sequence file
    gif.seek(frame)
    # Set the image array to the current frame of the GIF
    image.set_data(gif.convert("RGBA"))
    # Return the updated image
    return [image]

Export the stress animation

# Set the animation export format and settings
animation_export_format = Ansys.Mechanical.DataModel.Enums.GraphicsAnimationExportFormat.GIF
settings_720p = Ansys.Mechanical.Graphics.AnimationExportSettings()
settings_720p.Width = 1280
settings_720p.Height = 720

# Export the animation of the equivalent stress result
valve_gif = output_path / "valve.gif"
stress.ExportAnimation(str(valve_gif), animation_export_format, settings_720p)

# Open the GIF file and create an animation
gif = Image.open(valve_gif)
# Set the subplots for the animation and turn off the axis
figure, axes = plt.subplots(figsize=(16, 9))
axes.axis("off")
# Change the color of the image
image = axes.imshow(gif.convert("RGBA"))

# Create the animation using the figure, update_animation function, and the GIF frames
# Set the interval between frames to 200 milliseconds and repeat the animation
FuncAnimation(
    figure,
    update_animation,
    frames=range(gif.n_frames),
    interval=100,
    repeat=True,
    blit=True,
)

# Show the animation
plt.show()
valve

Display the output file from the solve#

# Get the path to the solve output file
solve_path = Path(analysis.WorkingDir)
# Get the solve output file path
solve_out_path = solve_path / "solve.out"
# If the solve output file exists, print its contents
if solve_out_path:
    with solve_out_path.open("rt") as file:
        for line in file:
            print(line, end="")
 Ansys Mechanical Enterprise


 *------------------------------------------------------------------*
 |                                                                  |
 |   W E L C O M E   T O   T H E   A N S Y S (R)  P R O G R A M     |
 |                                                                  |
 *------------------------------------------------------------------*




 ***************************************************************
 *         ANSYS MAPDL 2026 R1          LEGAL NOTICES          *
 ***************************************************************
 *                                                             *
 * Copyright (c) 2026 Synopsys, Inc. and ANSYS, Inc.           *
 * All rights reserved.                                        *
 * Unauthorized use, distribution or duplication is            *
 * prohibited.                                                 *
 *                                                             *
 * Ansys is a registered trademark of Ansys, Inc. or its       *
 * subsidiaries in the United States or other countries.       *
 * See the Ansys, Inc. online documentation or the Ansys, Inc. *
 * documentation CD or online help for the complete Legal      *
 * Notice.                                                     *
 *                                                             *
 ***************************************************************
 *                                                             *
 * THIS ANSYS SOFTWARE PRODUCT AND PROGRAM DOCUMENTATION       *
 * INCLUDE TRADE SECRETS AND CONFIDENTIAL AND PROPRIETARY      *
 * PRODUCTS OF ANSYS, INC., ITS SUBSIDIARIES, OR LICENSORS.    *
 * The software products and documentation are furnished by    *
 * Ansys, Inc. or its subsidiaries under a software license    *
 * agreement that contains provisions concerning               *
 * non-disclosure, copying, length and nature of use,          *
 * compliance with exporting laws, warranties, disclaimers,    *
 * limitations of liability, and remedies, and other           *
 * provisions.  The software products and documentation may be *
 * used, disclosed, transferred, or copied only in accordance  *
 * with the terms and conditions of that software license      *
 * agreement.                                                  *
 *                                                             *
 * Ansys, Inc. is a UL registered                              *
 * ISO 9001:2015 company.                                      *
 *                                                             *
 ***************************************************************
 *                                                             *
 * This product is subject to U.S. laws governing export and   *
 * re-export.                                                  *
 *                                                             *
 * For U.S. Government users, except as specifically granted   *
 * by the Ansys, Inc. software license agreement, the use,     *
 * duplication, or disclosure by the United States Government  *
 * is subject to restrictions stated in the Ansys, Inc.        *
 * software license agreement and FAR 12.212 (for non-DOD      *
 * licenses).                                                  *
 *                                                             *
 ***************************************************************

 2026 R1

 Point Releases and Patches installed:

 Ansys, Inc. License Manager 2026 R1
 LS-DYNA 2026 R1
 Core WB Files 2026 R1
 Mechanical Products 2026 R1


          *****  MAPDL COMMAND LINE ARGUMENTS  *****
  BATCH MODE REQUESTED (-b)    = NOLIST
  INPUT FILE COPY MODE (-c)    = COPY
  DISTRIBUTED MEMORY PARALLEL REQUESTED
       4 PARALLEL PROCESSES REQUESTED WITH SINGLE THREAD PER PROCESS
    TOTAL OF     4 CORES REQUESTED
  INPUT FILE NAME              = /github/home/.mw/Application Data/Ansys/v261/AnsysMech797D/Project_Mech_Files/StaticStructural/dummy.dat
  OUTPUT FILE NAME             = /github/home/.mw/Application Data/Ansys/v261/AnsysMech797D/Project_Mech_Files/StaticStructural/solve.out
  START-UP FILE MODE           = NOREAD
  STOP FILE MODE               = NOREAD

 RELEASE= 2026 R1              BUILD= 26.1      UP20260112   VERSION=LINUX x64
 CURRENT JOBNAME=file0  22:15:43  JAN 27, 2026  Elapsed Time=       0.238


 PARAMETER _DS_PROGRESS =     999.0000000

 /INPUT FILE= ds.dat  LINE=       0



 *** NOTE ***                            ELAPSED TIME =       0.601   TIME= 22:15:43
 The /CONFIG,NOELDB command is not valid in a distributed memory
 parallel solution.  Command is ignored.

 *GET  _WALLSTRT  FROM  ACTI  ITEM=TIME WALL  VALUE= 0.167634453E-03

 TITLE=
 --Static Structural


 SET PARAMETER DIMENSIONS ON  _WB_PROJECTSCRATCH_DIR
  TYPE=STRI  DIMENSIONS=      248        1        1

 PARAMETER _WB_PROJECTSCRATCH_DIR(1) = /github/home/.mw/Application Data/Ansys/v261/AnsysMech797D/Project_Mech_Files/StaticStructural/

 SET PARAMETER DIMENSIONS ON  _WB_SOLVERFILES_DIR
  TYPE=STRI  DIMENSIONS=      248        1        1

 PARAMETER _WB_SOLVERFILES_DIR(1) = /github/home/.mw/Application Data/Ansys/v261/AnsysMech797D/Project_Mech_Files/StaticStructural/

 SET PARAMETER DIMENSIONS ON  _WB_USERFILES_DIR
  TYPE=STRI  DIMENSIONS=      248        1        1

 PARAMETER _WB_USERFILES_DIR(1) = /github/home/.mw/Application Data/Ansys/v261/AnsysMech797D/Project_Mech_Files/UserFiles/
 --- Data in consistent MKS units. See Solving Units in the help system for more

 MKS UNITS SPECIFIED FOR INTERNAL
  LENGTH        (l)  = METER (M)
  MASS          (M)  = KILOGRAM (KG)
  TIME          (t)  = SECOND (SEC)
  TEMPERATURE   (T)  = CELSIUS (C)
  TOFFSET            = 273.0
  CHARGE        (Q)  = COULOMB
  FORCE         (f)  = NEWTON (N) (KG-M/SEC2)
  HEAT               = JOULE (N-M)

  PRESSURE           = PASCAL (NEWTON/M**2)
  ENERGY        (W)  = JOULE (N-M)
  POWER         (P)  = WATT (N-M/SEC)
  CURRENT       (i)  = AMPERE (COULOMBS/SEC)
  CAPACITANCE   (C)  = FARAD
  INDUCTANCE    (L)  = HENRY
  MAGNETIC FLUX      = WEBER
  RESISTANCE    (R)  = OHM
  ELECTRIC POTENTIAL = VOLT

 INPUT  UNITS ARE ALSO SET TO MKS

 *** MAPDL - ENGINEERING ANALYSIS SYSTEM  RELEASE 2026 R1          26.1     ***
 Ansys Mechanical Enterprise
 00000000  VERSION=LINUX x64     22:15:43  JAN 27, 2026 Elapsed Time=      0.604

 --Static Structural



          ***** MAPDL ANALYSIS DEFINITION (PREP7) *****
 *********** Send User Defined Coordinate System(s) ***********
 *********** Nodes for the whole assembly ***********
 *********** Elements for Body 1 'Connector\Solid1' ***********
 *********** Elements for Body 2 'Right_elbow\Solid1' ***********
 *********** Elements for Body 3 'Left_elbow\Solid1' ***********
 *********** Set Reference Temperature ***********
 *********** Send Materials ***********
 *********** Create Contact "Contact Region" ***********
             Real Constant Set For Above Contact Is 5 & 4
 *********** Create Contact "Contact Region 2" ***********
             Real Constant Set For Above Contact Is 7 & 6
 *********** Send Named Selection as Node Component ***********
 *********** Send Named Selection as Node Component ***********
 *********** Send Named Selection as Node Component ***********
 *********** Fixed Supports ***********
 ********* Frictionless Supports X *********
 ********* Frictionless Supports Z *********
 *********** Node Rotations ***********
 *********** Define Pressure Using Surface Effect Elements "Pressure" **********


 ***** ROUTINE COMPLETED *****  ELAPSED TIME =         0.859


 --- Number of total nodes = 75886
 --- Number of contact elements = 4698
 --- Number of spring elements = 0
 --- Number of bearing elements = 0
 --- Number of solid elements = 47698
 --- Number of condensed parts = 0
 --- Number of total elements = 52396

 *GET  _WALLBSOL  FROM  ACTI  ITEM=TIME WALL  VALUE= 0.240223712E-03
 ****************************************************************************
 *************************    SOLUTION       ********************************
 ****************************************************************************

 *****  MAPDL SOLUTION ROUTINE  *****


 PERFORM A STATIC ANALYSIS
  THIS WILL BE A NEW ANALYSIS

 PARAMETER _THICKRATIO =    0.3330000000

 USE SPARSE MATRIX DIRECT SOLVER

 CONTACT INFORMATION PRINTOUT LEVEL       1

 CHECK INITIAL OPEN/CLOSED STATUS OF SELECTED CONTACT ELEMENTS
      AND LIST DETAILED CONTACT PAIR INFORMATION

 SPLIT CONTACT SURFACES AT SOLVE PHASE

    NUMBER OF SPLITTING TBD BY PROGRAM

 DO NOT COMBINE ELEMENT MATRIX FILES (.emat) AFTER DISTRIBUTED PARALLEL SOLUTION

 DO NOT COMBINE ELEMENT SAVE DATA FILES (.esav) AFTER DISTRIBUTED PARALLEL SOLUTION

 NLDIAG: Nonlinear diagnostics CONT option is set to ON.
         Writing frequency : each ITERATION.

 DO NOT SAVE ANY RESTART FILES AT ALL
 ****************************************************
 ******************* SOLVE FOR LS 1 OF 1 ****************

 SELECT       FOR ITEM=TYPE COMPONENT=
  IN RANGE         8 TO          8 STEP          1

       1664  ELEMENTS (OF      52396  DEFINED) SELECTED BY  ESEL  COMMAND.

 SELECT      ALL NODES HAVING ANY ELEMENT IN ELEMENT SET.

       3460 NODES (OF      75886  DEFINED) SELECTED FROM
     1664 SELECTED ELEMENTS BY NSLE COMMAND.

 GENERATE SURFACE LOAD PRES ON SURFACE DEFINED BY ALL SELECTED NODES
 SET ACCORDING TO TABLE PARAMETER = _LOADVARI56

 NUMBER OF PRES ELEMENT FACE LOADS STORED =       1664

 ALL SELECT   FOR ITEM=NODE COMPONENT=
  IN RANGE         1 TO      75886 STEP          1

      75886  NODES (OF      75886  DEFINED) SELECTED BY NSEL  COMMAND.

 ALL SELECT   FOR ITEM=ELEM COMPONENT=
  IN RANGE         1 TO      64302 STEP          1

      52396  ELEMENTS (OF      52396  DEFINED) SELECTED BY  ESEL  COMMAND.

 ALL SELECT   FOR ITEM=ELEM COMPONENT=
  IN RANGE         1 TO      64302 STEP          1

      52396  ELEMENTS (OF      52396  DEFINED) SELECTED BY  ESEL  COMMAND.

 PRINTOUT RESUMED BY /GOP

 USE       1 SUBSTEPS INITIALLY THIS LOAD STEP FOR ALL  DEGREES OF FREEDOM
 FOR AUTOMATIC TIME STEPPING:
   USE      1 SUBSTEPS AS A MAXIMUM
   USE      1 SUBSTEPS AS A MINIMUM

 TIME=  1.0000

 ERASE THE CURRENT DATABASE OUTPUT CONTROL TABLE.


 WRITE ALL  ITEMS TO THE DATABASE WITH A FREQUENCY OF NONE
   FOR ALL APPLICABLE ENTITIES

 WRITE NSOL ITEMS TO THE DATABASE WITH A FREQUENCY OF ALL
   FOR ALL APPLICABLE ENTITIES

 WRITE RSOL ITEMS TO THE DATABASE WITH A FREQUENCY OF ALL
   FOR ALL APPLICABLE ENTITIES

 WRITE EANG ITEMS TO THE DATABASE WITH A FREQUENCY OF ALL
   FOR ALL APPLICABLE ENTITIES

 WRITE ETMP ITEMS TO THE DATABASE WITH A FREQUENCY OF ALL
   FOR ALL APPLICABLE ENTITIES

 WRITE VENG ITEMS TO THE DATABASE WITH A FREQUENCY OF ALL
   FOR ALL APPLICABLE ENTITIES

 WRITE STRS ITEMS TO THE DATABASE WITH A FREQUENCY OF ALL
   FOR ALL APPLICABLE ENTITIES

 WRITE EPEL ITEMS TO THE DATABASE WITH A FREQUENCY OF ALL
   FOR ALL APPLICABLE ENTITIES

 WRITE EPPL ITEMS TO THE DATABASE WITH A FREQUENCY OF ALL
   FOR ALL APPLICABLE ENTITIES

 WRITE CONT ITEMS TO THE DATABASE WITH A FREQUENCY OF ALL
   FOR ALL APPLICABLE ENTITIES

 *GET  ANSINTER_  FROM  ACTI  ITEM=INT        VALUE=  0.00000000

 *IF  ANSINTER_  ( =   0.00000     )  NE
      0  ( =   0.00000     )  THEN

 *ENDIF

 *** NOTE ***                            ELAPSED TIME =       0.951   TIME= 22:15:43
 The automatic domain decomposition logic has selected the MESH domain
 decomposition method with 4 processes per solution.

 *****  MAPDL SOLVE    COMMAND  *****

 *** WARNING ***                         ELAPSED TIME =       1.009   TIME= 22:15:43
 Element shape checking is currently inactive.  Issue SHPP,ON or
 SHPP,WARN to reactivate, if desired.

 *** NOTE ***                            ELAPSED TIME =       1.068   TIME= 22:15:43
 The model data was checked and warning messages were found.
  Please review output or errors file ( /github/home/.mw/Application
 Data/Ansys/v261/AnsysMech797D/Project_Mech_Files/StaticStructural/file0
 0.err ) for these warning messages.

 *** SELECTION OF ELEMENT TECHNOLOGIES FOR APPLICABLE ELEMENTS ***
      --- GIVE SUGGESTIONS AND RESET THE KEY OPTIONS ---

 ELEMENT TYPE         1 IS SOLID187. IT IS NOT ASSOCIATED WITH FULLY INCOMPRESSIBLE
 HYPERELASTIC MATERIALS. NO SUGGESTION IS AVAILABLE AND NO RESETTING IS NEEDED.

 ELEMENT TYPE         2 IS SOLID187. IT IS NOT ASSOCIATED WITH FULLY INCOMPRESSIBLE
 HYPERELASTIC MATERIALS. NO SUGGESTION IS AVAILABLE AND NO RESETTING IS NEEDED.

 ELEMENT TYPE         3 IS SOLID187. IT IS NOT ASSOCIATED WITH FULLY INCOMPRESSIBLE
 HYPERELASTIC MATERIALS. NO SUGGESTION IS AVAILABLE AND NO RESETTING IS NEEDED.



 *** MAPDL - ENGINEERING ANALYSIS SYSTEM  RELEASE 2026 R1          26.1     ***
 Ansys Mechanical Enterprise
 00000000  VERSION=LINUX x64     22:15:43  JAN 27, 2026 Elapsed Time=      1.077

 --Static Structural



                       S O L U T I O N   O P T I O N S

   PROBLEM DIMENSIONALITY. . . . . . . . . . . . .3-D
   DEGREES OF FREEDOM. . . . . . UX   UY   UZ
   ANALYSIS TYPE . . . . . . . . . . . . . . . . .STATIC (STEADY-STATE)
   OFFSET TEMPERATURE FROM ABSOLUTE ZERO . . . . .  273.15
   EQUATION SOLVER OPTION. . . . . . . . . . . . .SPARSE
   GLOBALLY ASSEMBLED MATRIX . . . . . . . . . . .SYMMETRIC

 *** WARNING ***                         ELAPSED TIME =       1.104   TIME= 22:15:43
 Material number 8 (used by element 62639) should normally have at least
 one MP or one TB type command associated with it.  Output of energy by
 material may not be available.

 *** NOTE ***                            ELAPSED TIME =       1.112   TIME= 22:15:43
 The step data was checked and warning messages were found.
  Please review output or errors file ( /github/home/.mw/Application
 Data/Ansys/v261/AnsysMech797D/Project_Mech_Files/StaticStructural/file0
 0.err ) for these warning messages.

 *** NOTE ***                            ELAPSED TIME =       1.112   TIME= 22:15:43
 The conditions for direct assembly have been met.  No .emat or .erot
 files will be produced.

 TRIM CONTACT/TARGET SURFACE
 START TRIMMING SMALL/BONDED CONTACT PAIRS FOR DMP RUN.

     741 CONTACT ELEMENTS &     776 TARGET ELEMENTS ARE DELETED DUE TO TRIMMING LOGIC.
       2 CONTACT PAIRS ARE REMOVED.

 CHECK INITIAL OPEN/CLOSED STATUS OF SELECTED CONTACT ELEMENTS
      AND LIST DETAILED CONTACT PAIR INFORMATION

 *** NOTE ***                            ELAPSED TIME =       1.690   TIME= 22:15:44
 The maximum number of contact elements in any single contact pair is
 396, which is smaller than the optimal domain size of 3029 elements
 for the given number of CPU domains (4).  Therefore, no contact pairs
 are being split by the CNCH,DMP logic.

 *** NOTE ***                            ELAPSED TIME =       1.931   TIME= 22:15:44
 Deformable-deformable contact pair identified by real constant set 4
 and contact element type 4 has been set up.
 Auto surface constraint is built
 Contact algorithm: MPC based approach

 *** NOTE ***                            ELAPSED TIME =       1.931   TIME= 22:15:44
 Contact related postprocess items (ETABLE, pressure ...) are not
 available.
 Contact detection at: nodal point (normal to target surface)
 MPC will be built internally to handle bonded contact.
 Average contact surface length               0.96911E-02
 Average contact pair depth                   0.61248E-02
 Average target surface length                0.99228E-02
 Default pinball region factor PINB           0.25000
 The resulting pinball region                 0.15312E-02
 Default target edge extension factor TOLS     2.0000
 Initial penetration/gap is excluded.
 Bonded contact (always) is defined.

 *** NOTE ***                            ELAPSED TIME =       1.931   TIME= 22:15:44
 Max.  Initial penetration 8.326672685E-17 was detected between contact
 element 60043 and target element 61062.
 ****************************************


 *** NOTE ***                            ELAPSED TIME =       1.931   TIME= 22:15:44
 Deformable-deformable contact pair identified by real constant set 7
 and contact element type 6 has been set up.
 Auto surface constraint is built
 Contact algorithm: MPC based approach

 *** NOTE ***                            ELAPSED TIME =       1.931   TIME= 22:15:44
 Contact related postprocess items (ETABLE, pressure ...) are not
 available.
 Contact detection at: nodal point (normal to target surface)
 MPC will be built internally to handle bonded contact.
 Average contact surface length               0.99792E-02
 Average contact pair depth                   0.59035E-02
 Average target surface length                0.97921E-02
 Default pinball region factor PINB           0.25000
 The resulting pinball region                 0.14759E-02
 Default target edge extension factor TOLS     2.0000
 Initial penetration/gap is excluded.
 Bonded contact (always) is defined.

 *** NOTE ***                            ELAPSED TIME =       1.931   TIME= 22:15:44
 Max.  Initial penetration 9.153579117E-17 was detected between contact
 element 61983 and target element 61240.
 ****************************************






     D I S T R I B U T E D   D O M A I N   D E C O M P O S E R

  ...Number of elements: 50879
  ...Number of nodes:    75886
  ...Decompose to 4 CPU domains
  ...Element load balance ratio =     1.012


                      L O A D   S T E P   O P T I O N S

   LOAD STEP NUMBER. . . . . . . . . . . . . . . .     1
   TIME AT END OF THE LOAD STEP. . . . . . . . . .  1.0000
   NUMBER OF SUBSTEPS. . . . . . . . . . . . . . .     1
   STEP CHANGE BOUNDARY CONDITIONS . . . . . . . .    NO
   PRINT OUTPUT CONTROLS . . . . . . . . . . . . .NO PRINTOUT
   DATABASE OUTPUT CONTROLS
      ITEM     FREQUENCY   COMPONENT
       ALL       NONE
      NSOL        ALL
      RSOL        ALL
      EANG        ALL
      ETMP        ALL
      VENG        ALL
      STRS        ALL
      EPEL        ALL
      EPPL        ALL
      CONT        ALL


 SOLUTION MONITORING INFO IS WRITTEN TO FILE= file.mntr



                         ***********  PRECISE MASS SUMMARY  ***********

   TOTAL RIGID BODY MASS MATRIX ABOUT ORIGIN
               Translational mass               |   Coupled translational/rotational mass
         138.26        0.0000        0.0000     |     0.0000       -56.527        30.290
         0.0000        138.26        0.0000     |     56.527        0.0000       0.75668E-02
         0.0000        0.0000        138.26     |    -30.290      -0.75668E-02    0.0000
     ------------------------------------------ | ------------------------------------------
                                                |         Rotational mass (inertia)
                                                |     31.206       0.16551E-02   0.31942E-02
                                                |    0.16551E-02    27.750       -12.384
                                                |    0.31942E-02   -12.384        11.101

   TOTAL MASS =  138.26
     The mass principal axes coincide with the global Cartesian axes

   CENTER OF MASS (X,Y,Z)=   0.54728E-04  -0.21908      -0.40884

   TOTAL INERTIA ABOUT CENTER OF MASS
         1.4602      -0.26388E-05   0.10066E-03
       -0.26388E-05    4.6400       0.62632E-06
        0.10066E-03   0.62632E-06    4.4655
     The inertia principal axes coincide with the global Cartesian axes


  *** MASS SUMMARY BY ELEMENT TYPE ***

  TYPE      MASS
     1   100.154
     2   19.0543
     3   19.0544

 Range of element maximum matrix coefficients in global coordinates
 Maximum = 1.367915649E+10 at element 35624.
 Minimum = 285637981 at element 9309.

   *** ELEMENT MATRIX FORMULATION TIMES
     TYPE    NUMBER     ENAME   TOTAL ELAPSED   AVG ELAPSED

        1     34745  SOLID187          1.6845   0.000048481
        2      6392  SOLID187          0.3135   0.000049048
        3      6561  SOLID187          0.3109   0.000047388
        4       396  CONTA174          0.0704   0.000177834
        5       370  TARGE170          0.0007   0.000001759
        6       380  CONTA174          0.0670   0.000176233
        7       371  TARGE170          0.0007   0.000001765
        8      1664   SURF154          0.0536   0.000032201
 Elapsed Time at end of element matrix formulation = 3.31186056.

 DISTRIBUTED SPARSE MATRIX DIRECT SOLVER.
  Number of equations =      221211,    Maximum wavefront =    552


  Memory allocated on only this MPI rank (rank     0)
  -------------------------------------------------------------------
  Equation solver memory allocated                     =   441.067 MB
  Equation solver memory required for in-core mode     =   422.285 MB
  Equation solver memory required for out-of-core mode =   126.772 MB
  Total (solver and non-solver) memory allocated       =  1440.551 MB


  Total memory summed across all MPI ranks on this machines
  -------------------------------------------------------------------
  Equation solver memory allocated                     =  1623.512 MB
  Equation solver memory required for in-core mode     =  1554.324 MB
  Equation solver memory required for out-of-core mode =   478.227 MB
  Total (solver and non-solver) memory allocated       =  4005.094 MB

 *** NOTE ***                            ELAPSED TIME =       3.922   TIME= 22:15:46
 The Distributed Sparse Matrix Solver is currently running in the
 in-core memory mode.  This memory mode uses the most amount of memory
 in order to avoid using the hard drive as much as possible, which most
 often results in the fastest solution time.  This mode is recommended
 if enough physical memory is present to accommodate all of the solver
 data.
 curEqn=  53280  totEqn=  54953 Job CP sec=      9.692
      Factor Done=  51% Factor Wall sec=      0.818 rate=      29.3 GFlops
 curEqn=  54953  totEqn=  54953 Job CP sec=     10.427
      Factor Done= 100% Factor Wall sec=      1.550 rate=      30.2 GFlops
 Distributed sparse solver maximum pivot= 1.734901639E+10 at node 60529
 UX.
 Distributed sparse solver minimum pivot= 129870096 at node 53832 UY.
 Distributed sparse solver minimum pivot in absolute value= 129870096 at
 node 53832 UY.

   *** ELEMENT RESULT CALCULATION TIMES
     TYPE    NUMBER     ENAME   TOTAL ELAPSED   AVG ELAPSED

        1     34745  SOLID187          1.4349   0.000041297
        2      6392  SOLID187          0.2621   0.000041009
        3      6561  SOLID187          0.2655   0.000040464
        4       396  CONTA174          0.0056   0.000014183
        6       380  CONTA174          0.0055   0.000014396
        8      1664   SURF154          0.0405   0.000024342

   *** NODAL LOAD CALCULATION TIMES
     TYPE    NUMBER     ENAME   TOTAL ELAPSED   AVG ELAPSED

        1     34745  SOLID187          0.3792   0.000010914
        2      6392  SOLID187          0.0695   0.000010869
        3      6561  SOLID187          0.0702   0.000010693
        4       396  CONTA174          0.0003   0.000000882
        6       380  CONTA174          0.0003   0.000000908
        8      1664   SURF154          0.0027   0.000001612
 *** LOAD STEP     1   SUBSTEP     1  COMPLETED.    CUM ITER =      1
 *** TIME =   1.00000         TIME INC =   1.00000      NEW TRIANG MATRIX


 *** MAPDL BINARY FILE STATISTICS
  BUFFER SIZE USED= 16384
        3.688 MB WRITTEN ON ELEMENT SAVED DATA FILE: file0.esav
       35.812 MB WRITTEN ON ASSEMBLED MATRIX FILE: file0.full
        8.500 MB WRITTEN ON RESULTS FILE: file0.rst
 *************** Write FE CONNECTORS *********

 WRITE OUT CONSTRAINT EQUATIONS TO FILE= file.ce
 ****************************************************
 *************** FINISHED SOLVE FOR LS 1 *************

 FINISH SOLUTION PROCESSING


 ***** ROUTINE COMPLETED *****  ELAPSED TIME =         6.874



 *GET  _WALLASOL  FROM  ACTI  ITEM=TIME WALL  VALUE= 0.190960835E-02

 PRINTOUT RESUMED BY /GOP

 *** MAPDL - ENGINEERING ANALYSIS SYSTEM  RELEASE 2026 R1          26.1     ***
 Ansys Mechanical Enterprise
 00000000  VERSION=LINUX x64     22:15:49  JAN 27, 2026 Elapsed Time=      6.880

 --Static Structural



          ***** MAPDL RESULTS INTERPRETATION (POST1) *****

 *** NOTE ***                            ELAPSED TIME =       6.880   TIME= 22:15:49
 Reading results into the database (SET command) will update the current
 displacement and force boundary conditions in the database with the
 values from the results file for that load set.  Note that any
 subsequent solutions will use these values unless action is taken to
 either SAVE the current values or not overwrite them (/EXIT,NOSAVE).

 Set Encoding of XML File to:ISO-8859-1

 Set Output of XML File to:
     PARM,     ,     ,     ,     ,     ,     ,     ,     ,     ,     ,     ,
         ,     ,     ,     ,     ,     ,     ,

 DATABASE WRITTEN ON FILE  parm.xml

 EXIT THE MAPDL POST1 DATABASE PROCESSOR


 ***** ROUTINE COMPLETED *****  ELAPSED TIME =         6.880



 PRINTOUT RESUMED BY /GOP

 *GET  _WALLDONE  FROM  ACTI  ITEM=TIME WALL  VALUE= 0.191127176E-02

 PARAMETER _PREPTIME =    0.2613213347

 PARAMETER _SOLVTIME =     6.009784701

 PARAMETER _POSTTIME =    0.5988257236E-02

 PARAMETER _TOTALTIM =     6.277094293

 *GET  _DLBRATIO  FROM  ACTI  ITEM=SOLU DLBR  VALUE=  1.01186967

 *GET  _COMBTIME  FROM  ACTI  ITEM=SOLU COMB  VALUE= 0.103186360

 *GET  _SSMODE   FROM  ACTI  ITEM=SOLU SSMM  VALUE=  2.00000000

 *GET  _NDOFS    FROM  ACTI  ITEM=SOLU NDOF  VALUE=  221211.000

 *GET  _SOL_END_TIME  FROM  ACTI  ITEM=SET  TIME  VALUE=  1.00000000

 *IF  _sol_end_time  ( =   1.00000     )  EQ
      1.000000  ( =   1.00000     )  THEN

 /FCLEAN COMMAND REMOVING ALL LOCAL FILES

 *ENDIF
 --- Total number of nodes = 75886
 --- Total number of elements = 50879
 --- Element load balance ratio = 1.01186967
 --- Time to combine distributed files = 0.10318636
 --- Sparse memory mode = 2
 --- Number of DOF = 221211

 EXIT MAPDL WITHOUT SAVING DATABASE


 NUMBER OF WARNING MESSAGES ENCOUNTERED=          2
 NUMBER OF ERROR   MESSAGES ENCOUNTERED=          0

+--------------------- M A P D L   S T A T I S T I C S ------------------------+

Release: 2026 R1            Build: 26.1       Update: UP20260112   Platform: LINUX x64
Date Run: 01/27/2026   Time: 22:15     Process ID: 26411
Operating System: Ubuntu 22.04.5 LTS

Processor Model: AMD EPYC 7763 64-Core Processor

Compiler: Intel(R) Fortran Compiler Classic Version 2021.9  (Build: 20230302)
          Intel(R) C/C++ Compiler Classic Version 2021.9  (Build: 20230302)
          AOCL-BLAS 5.1.1 Build 20251007
          Intel(R) oneAPI Math Kernel Library Version 2024.2-Product Build 20240605

Number of machines requested            :    1
Total number of cores available         :   16
Number of physical cores available      :    8
Number of processes requested           :    4
Number of threads per process requested :    1
Total number of cores requested         :    4 (Distributed Memory Parallel)
MPI Type: OPENMPI
MPI Version: Open MPI v4.1.8


GPU Acceleration: Not Requested

Job Name: file0
Input File: dummy.dat

  Core                Machine Name   Working Directory
 -----------------------------------------------------
     0                d42525df87ef   /github/home/.mw/Application Data/Ansys/v261/AnsysMech797D/Project_Mech_Files/StaticStructural
     1                d42525df87ef   /github/home/.mw/Application Data/Ansys/v261/AnsysMech797D/Project_Mech_Files/StaticStructural
     2                d42525df87ef   /github/home/.mw/Application Data/Ansys/v261/AnsysMech797D/Project_Mech_Files/StaticStructural
     3                d42525df87ef   /github/home/.mw/Application Data/Ansys/v261/AnsysMech797D/Project_Mech_Files/StaticStructural

Latency time from master to core     1 =    1.850 microseconds
Latency time from master to core     2 =    1.826 microseconds
Latency time from master to core     3 =    1.846 microseconds

Communication speed from master to core     1 = 14042.44 MB/sec
Communication speed from master to core     2 = 16991.00 MB/sec
Communication speed from master to core     3 = 16751.67 MB/sec

Total CPU time for main thread                    :        6.5 seconds
Total CPU time summed for all threads             :       12.8 seconds

Elapsed time spent obtaining a license            :        0.4 seconds
Elapsed time spent pre-processing model (/PREP7)  :        0.3 seconds
Elapsed time spent solution - preprocessing       :        1.4 seconds
Elapsed time spent computing solution             :        4.2 seconds
   Elapsed time in element formation & assembly   :        0.8 seconds
   Elapsed time in equation solver                :        2.5 seconds
   Elapsed time in element result calculations    :        0.8 seconds
Elapsed time spent solution - postprocessing      :        0.1 seconds
Elapsed time spent post-processing model (/POST1) :        0.0 seconds

Equation solver used                              :            Sparse (symmetric)
Sparse direct equation solver computational rate  :      109.1 Gflops
Sparse direct equation solver effective I/O rate  :       30.4 GB/sec

Sum of disk space used on all processes           :      223.1 MB

Sum of memory used on all processes               :     2011.0 MB
Sum of memory allocated on all processes          :     4227.0 MB
Physical memory available                         :         63 GB
Total amount of I/O written to disk               :        0.1 GB
Total amount of I/O read from disk                :        0.0 GB

+------------------ E N D   M A P D L   S T A T I S T I C S -------------------+


 *-----------------------------------------------------------------------------*
 |                                                                             |
 |                               RUN COMPLETED                                 |
 |                                                                             |
 |-----------------------------------------------------------------------------|
 |                                                                             |
 |  Ansys MAPDL 2026 R1         Build 26.1         UP20260112    LINUX x64     |
 |                                                                             |
 |-----------------------------------------------------------------------------|
 |                                                                             |
 |  Database Requested(-db)     1024 MB     Scratch Memory Requested   1024 MB |
 |  Max Database Used(Master)     62 MB     Max Scratch Used(Master)    544 MB |
 |  Max Database Used(Workers)     1 MB     Max Scratch Used(Workers)   484 MB |
 |  Sum Database Used(All)        65 MB     Sum Scratch Used(All)      1946 MB |
 |                                                                             |
 |-----------------------------------------------------------------------------|
 |                                                                             |
 |        CP Time      (sec) =         12.825       Time  =  22:15:49          |
 |        Elapsed Time (sec) =          7.102       Date  =  01/27/2026        |
 |                                                                             |
 *-----------------------------------------------------------------------------*

Clean up the project#

# Save the project
mechdat_file = output_path / "valve.mechdat"
app.save_as(str(mechdat_file), overwrite=True)

# Close the app
app.close()

# Delete the example files
delete_downloads()
True

Total running time of the script: (0 minutes 25.891 seconds)

Gallery generated by Sphinx-Gallery