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 PIL import Image
from ansys.mechanical.core import App
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

if TYPE_CHECKING:
    import Ansys

Initialize the embedded application#

app = App(globals=globals())
print(app)
Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

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: The application requires the use of OpenGL version 4.3. The detected version 3.1 Mesa 21.2.6 does not meet this requirement. This discrepancy may produce graphical display issues for certain features. Furthermore, future versions of Mechanical may not support systems that do not meet this requirement.
Severity: Warning
DisplayString: The license manager is delayed in its response. The latest requests were answered after 30 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 = 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 open(solve_out_path, "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 2025 R1          LEGAL NOTICES          *
 ***************************************************************
 *                                                             *
 * Copyright 1971-2025 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).                                                  *
 *                                                             *
 ***************************************************************

 2025 R1

 Point Releases and Patches installed:

 Ansys, Inc. License Manager 2025 R1
 LS-DYNA 2025 R1
 Core WB Files 2025 R1
 Mechanical Products 2025 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/v251/AnsysMech622F/Project_Mech_Files/StaticStructural/dummy.dat
  OUTPUT FILE NAME             = /github/home/.mw/Application Data/Ansys/v251/AnsysMech622F/Project_Mech_Files/StaticStructural/solve.out
  START-UP FILE MODE           = NOREAD
  STOP FILE MODE               = NOREAD

 RELEASE= 2025 R1              BUILD= 25.1      UP20241202   VERSION=LINUX x64
 CURRENT JOBNAME=file0  16:17:35  JUN 20, 2025 CP=      0.246


 PARAMETER _DS_PROGRESS =     999.0000000

 /INPUT FILE= ds.dat  LINE=       0



 *** NOTE ***                            CP =       0.346   TIME= 16:17:36
 The /CONFIG,NOELDB command is not valid in a distributed memory
 parallel solution.  Command is ignored.

 *GET  _WALLSTRT  FROM  ACTI  ITEM=TIME WALL  VALUE=  16.2933333

 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/v251/AnsysMech622F/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/v251/AnsysMech622F/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/v251/AnsysMech622F/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 2025 R1          25.1     ***
 Ansys Mechanical Enterprise
 00000000  VERSION=LINUX x64     16:17:36  JUN 20, 2025 CP=      0.350

 --Static Structural



          ***** MAPDL ANALYSIS DEFINITION (PREP7) *****
 *********** 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' ***********
 *********** Send User Defined Coordinate System(s) ***********
 *********** 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 *****  CP =         0.768


 --- Number of total nodes = 26882
 --- Number of contact elements = 3294
 --- Number of spring elements = 0
 --- Number of bearing elements = 0
 --- Number of solid elements = 14427
 --- Number of condensed parts = 0
 --- Number of total elements = 17721

 *GET  _WALLBSOL  FROM  ACTI  ITEM=TIME WALL  VALUE=  16.2933333
 ****************************************************************************
 *************************    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

       1694  ELEMENTS (OF      17721  DEFINED) SELECTED BY  ESEL  COMMAND.

 SELECT      ALL NODES HAVING ANY ELEMENT IN ELEMENT SET.

       3556 NODES (OF      26882  DEFINED) SELECTED FROM
     1694 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 =       1694

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

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

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

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

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

      17721  ELEMENTS (OF      17721  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 ***                            CP =       0.951   TIME= 16:17:36
 The automatic domain decomposition logic has selected the MESH domain
 decomposition method with 4 processes per solution.

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

 *** WARNING ***                         CP =       1.038   TIME= 16:17:36
 Element shape checking is currently inactive.  Issue SHPP,ON or
 SHPP,WARN to reactivate, if desired.

 *** NOTE ***                            CP =       1.188   TIME= 16:17:36
 The model data was checked and warning messages were found.
  Please review output or errors file ( /github/home/.mw/Application
 Data/Ansys/v251/AnsysMech622F/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 2025 R1          25.1     ***
 Ansys Mechanical Enterprise
 00000000  VERSION=LINUX x64     16:17:36  JUN 20, 2025 CP=      1.215

 --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 ***                         CP =       1.291   TIME= 16:17:36
 Material number 8 (used by element 23368) 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 ***                            CP =       1.326   TIME= 16:17:36
 The step data was checked and warning messages were found.
  Please review output or errors file ( /github/home/.mw/Application
 Data/Ansys/v251/AnsysMech622F/Project_Mech_Files/StaticStructural/file0
 0.err ) for these warning messages.

 *** NOTE ***                            CP =       1.326   TIME= 16:17:36
 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.

     400 CONTACT ELEMENTS &     400 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 ***                            CP =       2.515   TIME= 16:17:36
 The maximum number of contact elements in any single contact pair is
 200, which is smaller than the optimal domain size of 926 elements for
 the given number of CPU domains (4).  Therefore, no contact pairs are
 being split by the CNCH,DMP logic.

 *** NOTE ***                            CP =       2.994   TIME= 16:17:36
 Deformable-deformable contact pair identified by real constant set 5
 and contact element type 4 has been set up.
 Auto surface constraint is built
 Contact algorithm: MPC based approach

 *** NOTE ***                            CP =       2.994   TIME= 16:17:36
 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.14033E-01
 Average contact pair depth                   0.82697E-02
 Average target surface length                0.13762E-01
 Default pinball region factor PINB           0.25000
 The resulting pinball region                 0.20674E-02
 Default target edge extension factor TOLS     2.0000
 Initial penetration/gap is excluded.
 Bonded contact (always) is defined.

 *** NOTE ***                            CP =       2.994   TIME= 16:17:36
 Max.  Initial penetration 8.326672685E-17 was detected between contact
 element 22262 and target element 21953.
 ****************************************


 *** NOTE ***                            CP =       2.995   TIME= 16:17:36
 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 ***                            CP =       2.995   TIME= 16:17:36
 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.14121E-01
 Average contact pair depth                   0.81425E-02
 Average target surface length                0.13762E-01
 Default pinball region factor PINB           0.25000
 The resulting pinball region                 0.20356E-02
 Default target edge extension factor TOLS     2.0000
 Initial penetration/gap is excluded.
 Bonded contact (always) is defined.

 *** NOTE ***                            CP =       2.995   TIME= 16:17:36
 Max.  Initial penetration 8.326672685E-17 was detected between contact
 element 22977 and target element 22681.
 ****************************************






     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: 16921
  ...Number of nodes:    26882
  ...Decompose to 4 CPU domains
  ...Element load balance ratio =     1.020


                      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

 *** NOTE ***                            CP =       4.076   TIME= 16:17:37
 Deformable-deformable contact pair identified by real constant set 5
 and contact element type 4 has been set up.
 Auto surface constraint is built
 Contact algorithm: MPC based approach

 *** NOTE ***                            CP =       4.077   TIME= 16:17:37
 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.14033E-01
 Average contact pair depth                   0.82697E-02
 Average target surface length                0.13762E-01
 Default pinball region factor PINB           0.25000
 The resulting pinball region                 0.20674E-02
 Default target edge extension factor TOLS     2.0000
 Initial penetration/gap is excluded.
 Bonded contact (always) is defined.

 *** NOTE ***                            CP =       4.077   TIME= 16:17:37
 Max.  Initial penetration 8.326672685E-17 was detected between contact
 element 22262 and target element 21953.
 ****************************************



 The FEA model contains 0 external CE equations and 2829 internal CE
 equations.

 *************************************************
  SUMMARY FOR CONTACT PAIR IDENTIFIED BY REAL CONSTANT SET           5
 Max.  Penetration of 0 has been detected between contact element 22168
 and target element 21830.

 Max.  Geometrical gap of 8.326672685E-17 has been detected between
 contact element 22235 and target element 21774.

 Max.  Geometrical penetration of -8.326672685E-17 has been detected
 between contact element 22235 and target element 21774.
 For total 200 contact elements, there are 200 elements are in contact.
 There are 200 elements are in sticking.
 Max.  Pinball distance 2.067419789E-03.
 One of the contact searching regions contains at least 20 target
 elements.
 *************************************************


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

   TOTAL RIGID BODY MASS MATRIX ABOUT ORIGIN
               Translational mass               |   Coupled translational/rotational mass
         138.29        0.0000        0.0000     |     0.0000       -56.537        30.296
         0.0000        138.29        0.0000     |     56.537        0.0000       0.73844E-02
         0.0000        0.0000        138.29     |    -30.296      -0.73844E-02    0.0000
     ------------------------------------------ | ------------------------------------------
                                                |         Rotational mass (inertia)
                                                |     31.211       0.16359E-02   0.31000E-02
                                                |    0.16359E-02    27.754       -12.386
                                                |    0.31000E-02   -12.386        11.103

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

   CENTER OF MASS (X,Y,Z)=   0.53397E-04  -0.21907      -0.40882

   TOTAL INERTIA ABOUT CENTER OF MASS
         1.4604       0.18127E-04   0.81110E-04
        0.18127E-04    4.6403       0.19281E-05
        0.81110E-04   0.19281E-05    4.4656
     The inertia principal axes coincide with the global Cartesian axes


  *** MASS SUMMARY BY ELEMENT TYPE ***

  TYPE      MASS
     1   100.182
     2   19.0548
     3   19.0556

 Range of element maximum matrix coefficients in global coordinates
 Maximum = 2.93408494E+10 at element 11441.
 Minimum = 518803319 at element 2355.

   *** ELEMENT MATRIX FORMULATION TIMES
     TYPE    NUMBER   ENAME      TOTAL CP  AVE CP

        1      8724  SOLID187      0.431   0.000049
        2      2759  SOLID187      0.139   0.000050
        3      2944  SOLID187      0.139   0.000047
        4       200  CONTA174      0.045   0.000226
        5       200  TARGE170      0.001   0.000004
        6       200  CONTA174      0.045   0.000226
        7       200  TARGE170      0.001   0.000004
        8      1694  SURF154       0.058   0.000034
 Time at end of element matrix formulation CP = 4.46772242.

 DISTRIBUTED SPARSE MATRIX DIRECT SOLVER.
  Number of equations =       76728,    Maximum wavefront =    465


  Memory allocated on only this MPI rank (rank     0)
  -------------------------------------------------------------------
  Equation solver memory allocated                     =   104.604 MB
  Equation solver memory required for in-core mode     =   100.392 MB
  Equation solver memory required for out-of-core mode =    43.231 MB
  Total (solver and non-solver) memory allocated       =   830.510 MB


  Total memory summed across all MPI ranks on this machines
  -------------------------------------------------------------------
  Equation solver memory allocated                     =   419.477 MB
  Equation solver memory required for in-core mode     =   402.170 MB
  Equation solver memory required for out-of-core mode =   158.276 MB
  Total (solver and non-solver) memory allocated       =  2168.149 MB

 *** NOTE ***                            CP =       4.665   TIME= 16:17:37
 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=  19193  totEqn=  19193 Job CP sec=      4.802
      Factor Done= 100% Factor Wall sec=      0.259 rate=      20.9 GFlops
 Distributed sparse solver maximum pivot= 2.775534833E+10 at node 3047
 UX.
 Distributed sparse solver minimum pivot= 243125111 at node 20937 UY.
 Distributed sparse solver minimum pivot in absolute value= 243125111 at
 node 20937 UY.

   *** ELEMENT RESULT CALCULATION TIMES
     TYPE    NUMBER   ENAME      TOTAL CP  AVE CP

        1      8724  SOLID187      0.380   0.000044
        2      2759  SOLID187      0.120   0.000043
        3      2944  SOLID187      0.132   0.000045
        4       200  CONTA174      0.004   0.000019
        6       200  CONTA174      0.004   0.000020
        8      1694  SURF154       0.047   0.000028

   *** NODAL LOAD CALCULATION TIMES
     TYPE    NUMBER   ENAME      TOTAL CP  AVE CP

        1      8724  SOLID187      0.137   0.000016
        2      2759  SOLID187      0.045   0.000016
        3      2944  SOLID187      0.048   0.000016
        4       200  CONTA174      0.001   0.000003
        6       200  CONTA174      0.001   0.000003
        8      1694  SURF154       0.006   0.000004
 *** 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
        4.875 MB WRITTEN ON ELEMENT SAVED DATA FILE: file0.esav
       12.688 MB WRITTEN ON ASSEMBLED MATRIX FILE: file0.full
        2.938 MB WRITTEN ON RESULTS FILE: file0.rst
 *************** Write FE CONNECTORS *********

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

 *GET  _WALLASOL  FROM  ACTI  ITEM=TIME WALL  VALUE=  16.2938889

 PRINTOUT RESUMED BY /GOP

 FINISH SOLUTION PROCESSING


 ***** ROUTINE COMPLETED *****  CP =         5.726



 *** MAPDL - ENGINEERING ANALYSIS SYSTEM  RELEASE 2025 R1          25.1     ***
 Ansys Mechanical Enterprise
 00000000  VERSION=LINUX x64     16:17:38  JUN 20, 2025 CP=      5.731

 --Static Structural



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

 *** NOTE ***                            CP =       5.732   TIME= 16:17:38
 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 *****  CP =         5.734



 PRINTOUT RESUMED BY /GOP

 *GET  _WALLDONE  FROM  ACTI  ITEM=TIME WALL  VALUE=  16.2938889

 PARAMETER _PREPTIME =     0.000000000

 PARAMETER _SOLVTIME =     2.000000000

 PARAMETER _POSTTIME =     0.000000000

 PARAMETER _TOTALTIM =     2.000000000

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

 *GET  _COMBTIME  FROM  ACTI  ITEM=SOLU COMB  VALUE= 0.378180942E-01

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

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

 *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 = 26882
 --- Total number of elements = 16921
 --- Element load balance ratio = 1.02028986
 --- Time to combine distributed files = 3.781809425E-02
 --- Sparse memory mode = 2
 --- Number of DOF = 76728

 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: 2025 R1            Build: 25.1       Update: UP20241202   Platform: LINUX x64
Date Run: 06/20/2025   Time: 16:17     Process ID: 18360
Operating System: Ubuntu 20.04.6 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 4.2.1 Build 20240303

Number of machines requested            :    1
Total number of cores available         :    8
Number of physical cores available      :    4
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.0.5

GPU Acceleration: Not Requested

Job Name: file0
Input File: dummy.dat

  Core                Machine Name   Working Directory
 -----------------------------------------------------
     0                b3cf268bae46   /github/home/.mw/Application Data/Ansys/v251/AnsysMech622F/Project_Mech_Files/StaticStructural
     1                b3cf268bae46   /github/home/.mw/Application Data/Ansys/v251/AnsysMech622F/Project_Mech_Files/StaticStructural
     2                b3cf268bae46   /github/home/.mw/Application Data/Ansys/v251/AnsysMech622F/Project_Mech_Files/StaticStructural
     3                b3cf268bae46   /github/home/.mw/Application Data/Ansys/v251/AnsysMech622F/Project_Mech_Files/StaticStructural

Latency time from master to core     1 =    2.048 microseconds
Latency time from master to core     2 =    2.033 microseconds
Latency time from master to core     3 =    2.034 microseconds

Communication speed from master to core     1 = 18483.88 MB/sec
Communication speed from master to core     2 = 21394.36 MB/sec
Communication speed from master to core     3 = 20657.21 MB/sec

Total CPU time for main thread                    :        2.7 seconds
Total CPU time summed for all threads             :        6.0 seconds

Elapsed time spent obtaining a license            :        0.4 seconds
Elapsed time spent pre-processing model (/PREP7)  :        0.1 seconds
Elapsed time spent solution - preprocessing       :        0.7 seconds
Elapsed time spent computing solution             :        1.3 seconds
Elapsed time spent solution - postprocessing      :        0.0 seconds
Elapsed time spent post-processing model (/POST1) :        0.0 seconds

Equation solver used                              :            Sparse (symmetric)
Equation solver computational rate                :       86.8 Gflops
Equation solver effective I/O rate                :       30.2 GB/sec

Sum of disk space used on all processes           :       78.5 MB

Sum of memory used on all processes               :      588.0 MB
Sum of memory allocated on all processes          :     3072.0 MB
Physical memory available                         :         31 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 2025 R1         Build 25.1         UP20241202    LINUX x64     |
 |                                                                             |
 |-----------------------------------------------------------------------------|
 |                                                                             |
 |  Database Requested(-db)     1024 MB     Scratch Memory Requested   1024 MB |
 |  Max Database Used(Master)     23 MB     Max Scratch Used(Master)    152 MB |
 |  Max Database Used(Workers)     1 MB     Max Scratch Used(Workers)   139 MB |
 |  Sum Database Used(All)        26 MB     Sum Scratch Used(All)       562 MB |
 |                                                                             |
 |-----------------------------------------------------------------------------|
 |                                                                             |
 |        CP Time      (sec) =          5.994       Time  =  16:17:38          |
 |        Elapsed Time (sec) =          4.000       Date  =  06/20/2025        |
 |                                                                             |
 *-----------------------------------------------------------------------------*

Clean up the project#

# Save the project
mechdat_file = output_path / "valve.mechdat"
app.save(str(mechdat_file))

# Close the app
app.close()

# Delete the example files
delete_downloads()
True

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

Gallery generated by Sphinx-Gallery