PyMechanical integration#
This example demonstrates how to use PyWorkbench and PyMechanical together to upload geometry, run simulations, and visualize results. It covers launching services, running scripts, and handling files between the client and server.
First, import the necessary modules. We import pathlib
for handling filesystem paths, os
for interacting with the operating system, and pyvista
for visualization. The launch_workbench
function from ansys.workbench.core
is imported to start a Workbench session, and connect_to_mechanical
from ansys.mechanical.core
to start a Mechanical session.
[1]:
import os
import pathlib
import pyvista as pv
[2]:
from ansys.workbench.core import launch_workbench
from ansys.mechanical.core import connect_to_mechanical
Define several directories that will be used during the session. workdir
is set to the parent directory of the current file. assets
, scripts
, and agdb
are subdirectories within the working directory. The launch_workbench
function is called to start a Workbench session with specified directories.
[3]:
workdir = pathlib.Path("__file__").parent
assets = workdir / "assets"
scripts = workdir / "scripts"
agdb = workdir / "agdb"
[4]:
wb = launch_workbench(client_workdir=str(workdir.absolute()))
Upload a geometry file (two_pipes.agdb
) from the example database to the server using the upload_file_from_example_repo
method.
[5]:
wb.upload_file_from_example_repo("pymechanical-integration/agdb/two_pipes.agdb")
Uploading two_pipes.agdb: 100%|██████████| 2.27M/2.27M [00:00<00:00, 50.8MB/s]
Execute a Workbench script (project.wbjn
) to create a mechanical system and load the geometry using the run_script_file
method. The name of the system created is stored in system_name
.
[6]:
system_name = wb.run_script_file(str((assets / "project.wbjn").absolute()))
Start a PyMechanical service for the specified system using the start_mechanical_server
method. Create a PyMechanical client connected to this service using connect_to_mechanical
method. The project directory is printed to verify the connection.
[7]:
pymech_port = wb.start_mechanical_server(system_name=system_name)
[8]:
mechanical = connect_to_mechanical(ip='localhost', port=pymech_port)
print(mechanical.project_directory)
C:\Users\ansys\AppData\Local\Temp\WB_ansys_8664_2\wbnew_files\
Read and execute the script solve.py
via the PyMechanical client using run_python_script
. This script typically contains commands to mesh and solve the model. The output of the script is printed.
[9]:
with open(scripts / "solve.py") as sf:
mech_script = sf.read()
print(mechanical.run_python_script(mech_script))
{"total_deformation": "1.9647094770595032E-06 [mm]"}
Fetch output files (*solve.out
and *deformation.png
) from the solver directory to the client’s working directory using the download
method.
[10]:
mechanical.download("*solve.out", target_dir=str(workdir.absolute()))
mechanical.download("*deformation.png", target_dir=str(workdir.absolute()))
Downloading dns:///127.0.0.1:59577:C:\Users\ansys\AppData\Local\Temp\WB_ansys_8664_2\wbnew_files\dp0\SYS\MECH\solve.out to C:\Users\ansys\actions-runner\_work\pyworkbench-examples\pyworkbench-examples\pyworkbench-examples\doc\source\examples\pymechanical-integration\solve.out: 100%|██████████| 37.8k/37.8k [00:00<?, ?B/s]
Downloading dns:///127.0.0.1:59577:C:\Users\ansys\AppData\Local\Temp\WB_ansys_8664_2\wbnew_files\dp0\SYS\MECH\deformation.png to C:\Users\ansys\actions-runner\_work\pyworkbench-examples\pyworkbench-examples\pyworkbench-examples\doc\source\examples\pymechanical-integration\deformation.png: 100%|██████████| 11.6k/11.6k [00:00<?, ?B/s]
[10]:
['C:\\Users\\ansys\\actions-runner\\_work\\pyworkbench-examples\\pyworkbench-examples\\pyworkbench-examples\\doc\\source\\examples\\pymechanical-integration\\deformation.png']
Read and print the content of the solver output file (solve.out
) to the console.
[11]:
with open(os.path.join(str(workdir.absolute()), "solve.out"), "r") as f:
print(f.read())
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 2024 R2 LEGAL NOTICES *
***************************************************************
* *
* Copyright 1971-2024 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). *
* *
***************************************************************
2024 R2
Point Releases and Patches installed:
Ansys Service Pack 2024 R2.01
Ansys Service Pack 2024 R2.02
Ansys Service Pack 2024 R2.03
Ansys, Inc. License Manager 2024 R2
Ansys, Inc. License Manager 2024 R2.01
Ansys, Inc. License Manager 2024 R2.02
Ansys, Inc. License Manager 2024 R2.03
Discovery 2024 R2
Discovery 2024 R2.01
Discovery 2024 R2.02
Discovery 2024 R2.03
Core WB Files 2024 R2
Core WB Files 2024 R2.01
Core WB Files 2024 R2.02
Core WB Files 2024 R2.03
SpaceClaim 2024 R2
SpaceClaim 2024 R2.01
SpaceClaim 2024 R2.02
SpaceClaim 2024 R2.03
Icepak (includes CFD-Post) 2024 R2
Icepak (includes CFD-Post) 2024 R2.01
Icepak (includes CFD-Post) 2024 R2.02
Icepak (includes CFD-Post) 2024 R2.03
CFD-Post only 2024 R2
CFD-Post only 2024 R2.01
CFD-Post only 2024 R2.02
CFD-Post only 2024 R2.03
CFX (includes CFD-Post) 2024 R2
CFX (includes CFD-Post) 2024 R2.01
CFX (includes CFD-Post) 2024 R2.02
CFX (includes CFD-Post) 2024 R2.03
Chemkin 2024 R2
Chemkin 2024 R2.01
Chemkin 2024 R2.02
Chemkin 2024 R2.03
EnSight 2024 R2
EnSight 2024 R2.01
EnSight 2024 R2.02
EnSight 2024 R2.03
FENSAP-ICE 2024 R2
FENSAP-ICE 2024 R2.01
FENSAP-ICE 2024 R2.02
FENSAP-ICE 2024 R2.03
Fluent (includes CFD-Post) 2024 R2
Fluent (includes CFD-Post) 2024 R2.01
Fluent (includes CFD-Post) 2024 R2.02
Fluent (includes CFD-Post) 2024 R2.03
Polyflow (includes CFD-Post) 2024 R2
Polyflow (includes CFD-Post) 2024 R2.01
Polyflow (includes CFD-Post) 2024 R2.02
Polyflow (includes CFD-Post) 2024 R2.03
Forte (includes EnSight) 2024 R2
Forte (includes EnSight) 2024 R2.01
Forte (includes EnSight) 2024 R2.02
Forte (includes EnSight) 2024 R2.03
ICEM CFD 2024 R2
ICEM CFD 2024 R2.01
ICEM CFD 2024 R2.02
ICEM CFD 2024 R2.03
TurboGrid 2024 R2
TurboGrid 2024 R2.01
TurboGrid 2024 R2.02
TurboGrid 2024 R2.03
Speos 2024 R2
Speos 2024 R2.01
Speos 2024 R2.02
Speos 2024 R2.03
Speos HPC 2024 R2
Speos HPC 2024 R2.01
Speos HPC 2024 R2.02
Speos HPC 2024 R2.03
optiSLang 2024 R2
optiSLang 2024 R2.01
optiSLang 2024 R2.02
optiSLang 2024 R2.03
Remote Solve Manager Standalone Services 2024 R2
Remote Solve Manager Standalone Services 2024 R2.01
Remote Solve Manager Standalone Services 2024 R2.02
Remote Solve Manager Standalone Services 2024 R2.03
Additive 2024 R2
Additive 2024 R2.01
Additive 2024 R2.02
Additive 2024 R2.03
Aqwa 2024 R2
Aqwa 2024 R2.01
Aqwa 2024 R2.02
Aqwa 2024 R2.03
Autodyn 2024 R2
Autodyn 2024 R2.01
Autodyn 2024 R2.02
Autodyn 2024 R2.03
Customization Files for User Programmable Features 2024 R2
Customization Files for User Programmable Features 2024 R2.01
Customization Files for User Programmable Features 2024 R2.02
Customization Files for User Programmable Features 2024 R2.03
LS-DYNA 2024 R2
LS-DYNA 2024 R2.01
LS-DYNA 2024 R2.02
LS-DYNA 2024 R2.03
Mechanical Products 2024 R2
Mechanical Products 2024 R2.01
Mechanical Products 2024 R2.02
Mechanical Products 2024 R2.03
Motion 2024 R2
Motion 2024 R2.01
Motion 2024 R2.02
Motion 2024 R2.03
Sherlock 2024 R2
Sherlock 2024 R2.01
Sherlock 2024 R2.02
Sherlock 2024 R2.03
Sound - SAS 2024 R2
Sound - SAS 2024 R2.01
Sound - SAS 2024 R2.02
Sound - SAS 2024 R2.03
ACIS Geometry Interface 2024 R2
ACIS Geometry Interface 2024 R2.01
ACIS Geometry Interface 2024 R2.02
ACIS Geometry Interface 2024 R2.03
AutoCAD Geometry Interface 2024 R2
AutoCAD Geometry Interface 2024 R2.01
AutoCAD Geometry Interface 2024 R2.02
AutoCAD Geometry Interface 2024 R2.03
Catia, Version 4 Geometry Interface 2024 R2
Catia, Version 4 Geometry Interface 2024 R2.01
Catia, Version 4 Geometry Interface 2024 R2.02
Catia, Version 4 Geometry Interface 2024 R2.03
Catia, Version 5 Geometry Interface 2024 R2
Catia, Version 5 Geometry Interface 2024 R2.01
Catia, Version 5 Geometry Interface 2024 R2.02
Catia, Version 5 Geometry Interface 2024 R2.03
Catia, Version 6 Geometry Interface 2024 R2
Catia, Version 6 Geometry Interface 2024 R2.01
Catia, Version 6 Geometry Interface 2024 R2.02
Catia, Version 6 Geometry Interface 2024 R2.03
Creo Elements/Direct Modeling Geometry Interface 2024 R2
Creo Elements/Direct Modeling Geometry Interface 2024 R2.01
Creo Elements/Direct Modeling Geometry Interface 2024 R2.02
Creo Elements/Direct Modeling Geometry Interface 2024 R2.03
Creo Parametric Geometry Interface 2024 R2
Creo Parametric Geometry Interface 2024 R2.01
Creo Parametric Geometry Interface 2024 R2.02
Creo Parametric Geometry Interface 2024 R2.03
Inventor Geometry Interface 2024 R2
Inventor Geometry Interface 2024 R2.01
Inventor Geometry Interface 2024 R2.02
Inventor Geometry Interface 2024 R2.03
JTOpen Geometry Interface 2024 R2
JTOpen Geometry Interface 2024 R2.01
JTOpen Geometry Interface 2024 R2.02
JTOpen Geometry Interface 2024 R2.03
NX Geometry Interface 2024 R2
NX Geometry Interface 2024 R2.01
NX Geometry Interface 2024 R2.02
NX Geometry Interface 2024 R2.03
Parasolid Geometry Interface 2024 R2
Parasolid Geometry Interface 2024 R2.01
Parasolid Geometry Interface 2024 R2.02
Parasolid Geometry Interface 2024 R2.03
Solid Edge Geometry Interface 2024 R2
Solid Edge Geometry Interface 2024 R2.01
Solid Edge Geometry Interface 2024 R2.02
Solid Edge Geometry Interface 2024 R2.03
SOLIDWORKS Geometry Interface 2024 R2
SOLIDWORKS Geometry Interface 2024 R2.01
SOLIDWORKS Geometry Interface 2024 R2.02
SOLIDWORKS Geometry Interface 2024 R2.03
***** 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 = C:\Users\ansys\AppData\Local\Temp\WB_ansys_8664_2\_ProjectScratch\Scr01DE\dummy.dat
OUTPUT FILE NAME = C:\Users\ansys\AppData\Local\Temp\WB_ansys_8664_2\_ProjectScratch\Scr01DE\solve.out
START-UP FILE MODE = NOREAD
STOP FILE MODE = NOREAD
RELEASE= 2024 R2 BUILD= 24.2 UP20240603 VERSION=WINDOWS x64
CURRENT JOBNAME=file0 18:26:08 JAN 08, 2025 CP= 0.094
PARAMETER _DS_PROGRESS = 999.0000000
/INPUT FILE= ds.dat LINE= 0
*** NOTE *** CP = 0.359 TIME= 18:26:08
The /CONFIG,NOELDB command is not valid in a distributed memory
parallel solution. Command is ignored.
*GET _WALLSTRT FROM ACTI ITEM=TIME WALL VALUE= 18.4355556
TITLE=
wbnew--Static Structural (A5)
ACT Extensions:
LSDYNA, 2024.2
5f463412-bd3e-484b-87e7-cbc0a665e474, wbex
/COM, ANSYSMotion, 2024.2
20180725-3f81-49eb-9f31-41364844c769, wbex
SET PARAMETER DIMENSIONS ON _WB_PROJECTSCRATCH_DIR
TYPE=STRI DIMENSIONS= 248 1 1
PARAMETER _WB_PROJECTSCRATCH_DIR(1) = C:\Users\ansys\AppData\Local\Temp\WB_ansys_8664_2\_ProjectScratch\Scr01DE\
SET PARAMETER DIMENSIONS ON _WB_SOLVERFILES_DIR
TYPE=STRI DIMENSIONS= 248 1 1
PARAMETER _WB_SOLVERFILES_DIR(1) = C:\Users\ansys\AppData\Local\Temp\WB_ansys_8664_2\wbnew_files\dp0\SYS\MECH\
SET PARAMETER DIMENSIONS ON _WB_USERFILES_DIR
TYPE=STRI DIMENSIONS= 248 1 1
PARAMETER _WB_USERFILES_DIR(1) = C:\Users\ansys\AppData\Local\Temp\WB_ansys_8664_2\wbnew_files\user_files\
--- Data in consistent NMM units. See Solving Units in the help system for more
MPA UNITS SPECIFIED FOR INTERNAL
LENGTH = MILLIMETERS (mm)
MASS = TONNE (Mg)
TIME = SECONDS (sec)
TEMPERATURE = CELSIUS (C)
TOFFSET = 273.0
FORCE = NEWTON (N)
HEAT = MILLIJOULES (mJ)
INPUT UNITS ARE ALSO SET TO MPA
*** MAPDL - ENGINEERING ANALYSIS SYSTEM RELEASE 2024 R2 24.2 ***
Ansys Mechanical Enterprise
00000000 VERSION=WINDOWS x64 18:26:08 JAN 08, 2025 CP= 0.391
wbnew--Static Structural (A5)
***** MAPDL ANALYSIS DEFINITION (PREP7) *****
*********** Nodes for the whole assembly ***********
*********** Elements for Body 1 'Solid' ***********
*********** Elements for Body 2 'Solid' ***********
*********** Send User Defined Coordinate System(s) ***********
*********** Set Reference Temperature ***********
*********** Send Materials ***********
*********** Create Contact "Contact Region" ***********
Real Constant Set For Above Contact Is 4 & 3
*********** Fixed Supports ***********
*********** Define Force Using Surface Effect Elements ***********
***** ROUTINE COMPLETED ***** CP = 0.438
--- Number of total nodes = 4879
--- Number of contact elements = 198
--- Number of spring elements = 0
--- Number of bearing elements = 0
--- Number of solid elements = 711
--- Number of condensed parts = 0
--- Number of total elements = 909
*GET _WALLBSOL FROM ACTI ITEM=TIME WALL VALUE= 18.4355556
****************************************************************************
************************* SOLUTION ********************************
****************************************************************************
***** MAPDL SOLUTION ROUTINE *****
PERFORM A STATIC ANALYSIS
THIS WILL BE A NEW ANALYSIS
PARAMETER _THICKRATIO = 0.000000000
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 5 TO 5 STEP 1
40 ELEMENTS (OF 909 DEFINED) SELECTED BY ESEL COMMAND.
SELECT ALL NODES HAVING ANY ELEMENT IN ELEMENT SET.
182 NODES (OF 4879 DEFINED) SELECTED FROM
40 SELECTED ELEMENTS BY NSLE COMMAND.
SPECIFIED SURFACE LOAD PRES FOR ALL SELECTED ELEMENTS LKEY = 1 KVAL = 1
VALUES = 0.0000 0.0000 0.0000 0.0000
SPECIFIED SURFACE LOAD PRES FOR ALL SELECTED ELEMENTS LKEY = 2 KVAL = 1
VALUES = 0.0000 0.0000 0.0000 0.0000
SPECIFIED SURFACE LOAD PRES FOR ALL SELECTED ELEMENTS LKEY = 3 KVAL = 1
VALUES = -0.19417E-04 -0.19417E-04 -0.19417E-04 -0.19417E-04
ALL SELECT FOR ITEM=NODE COMPONENT=
IN RANGE 1 TO 4879 STEP 1
4879 NODES (OF 4879 DEFINED) SELECTED BY NSEL COMMAND.
ALL SELECT FOR ITEM=ELEM COMPONENT=
IN RANGE 1 TO 2291 STEP 1
909 ELEMENTS (OF 909 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.625 TIME= 18:26:08
The automatic domain decomposition logic has selected the MESH domain
decomposition method with 4 processes per solution.
***** MAPDL SOLVE COMMAND *****
*** WARNING *** CP = 0.641 TIME= 18:26:08
Element shape checking is currently inactive. Issue SHPP,ON or
SHPP,WARN to reactivate, if desired.
*** NOTE *** CP = 0.641 TIME= 18:26:08
The model data was checked and warning messages were found.
Please review output or errors file (
C:\Users\ansys\AppData\Local\Temp\WB_ansys_8664_2\_ProjectScratch\Scr01
1DE\file0.err ) for these warning messages.
*** SELECTION OF ELEMENT TECHNOLOGIES FOR APPLICABLE ELEMENTS ***
--- GIVE SUGGESTIONS AND RESET THE KEY OPTIONS ---
ELEMENT TYPE 1 IS SOLID186. KEYOPT(2)=0 IS SUGGESTED AND HAS BEEN RESET.
KEYOPT(1-12)= 0 0 0 0 0 0 0 0 0 0 0 0
ELEMENT TYPE 2 IS SOLID186. KEYOPT(2)=0 IS SUGGESTED AND HAS BEEN RESET.
KEYOPT(1-12)= 0 0 0 0 0 0 0 0 0 0 0 0
*** MAPDL - ENGINEERING ANALYSIS SYSTEM RELEASE 2024 R2 24.2 ***
Ansys Mechanical Enterprise
00000000 VERSION=WINDOWS x64 18:26:08 JAN 08, 2025 CP= 0.641
wbnew--Static Structural (A5)
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 = 0.656 TIME= 18:26:08
Material number 5 (used by element 2252) 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 = 0.656 TIME= 18:26:08
The step data was checked and warning messages were found.
Please review output or errors file (
C:\Users\ansys\AppData\Local\Temp\WB_ansys_8664_2\_ProjectScratch\Scr01
1DE\file0.err ) for these warning messages.
*** NOTE *** CP = 0.656 TIME= 18:26:08
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.
39 CONTACT ELEMENTS & 40 TARGET ELEMENTS ARE DELETED DUE TO TRIMMING LOGIC.
1 CONTACT PAIRS ARE REMOVED.
CHECK INITIAL OPEN/CLOSED STATUS OF SELECTED CONTACT ELEMENTS
AND LIST DETAILED CONTACT PAIR INFORMATION
*** NOTE *** CP = 0.750 TIME= 18:26:08
The maximum number of contact elements in any single contact pair is
40, which is smaller than the optimal domain size of 120 elements for
the given number of CPU domains (4). Therefore, no contact pairs are
being split by the CNCH,DMP logic.
*** NOTE *** CP = 0.812 TIME= 18:26:08
Deformable-deformable contact pair identified by real constant set 3
and contact element type 3 has been set up.
Auto surface constraint is built
Contact algorithm: MPC based approach
*** NOTE *** CP = 0.812 TIME= 18:26:08
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 1160.1
Average contact pair depth 1111.1
Average target surface length 1164.4
Default pinball region factor PINB 0.25000
The resulting pinball region 277.78
Default target edge extension factor TOLS 2.0000
Initial penetration/gap is excluded.
Bonded contact (always) is defined.
*** NOTE *** CP = 0.812 TIME= 18:26:08
Max. Initial penetration 0 was detected between contact element 2134
and target element 2242.
****************************************
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: 830
...Number of nodes: 4879
...Decompose to 4 CPU domains
...Element load balance ratio = 1.116
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 = 1.031 TIME= 18:26:08
Deformable-deformable contact pair identified by real constant set 3
and contact element type 3 has been set up.
Auto surface constraint is built
Contact algorithm: MPC based approach
*** NOTE *** CP = 1.031 TIME= 18:26:08
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 1160.1
Average contact pair depth 1111.1
Average target surface length 1164.4
Default pinball region factor PINB 0.25000
The resulting pinball region 277.78
Default target edge extension factor TOLS 2.0000
Initial penetration/gap is excluded.
Bonded contact (always) is defined.
*** NOTE *** CP = 1.031 TIME= 18:26:08
Max. Initial penetration 0 was detected between contact element 2134
and target element 2242.
****************************************
The FEA model contains 0 external CE equations and 546 internal CE
equations.
*************************************************
SUMMARY FOR CONTACT PAIR IDENTIFIED BY REAL CONSTANT SET 3
Max. Penetration of 0 has been detected between contact element 2134
and target element 2242.
For total 40 contact elements, there are 40 elements are in contact.
There are 40 elements are in sticking.
Max. Pinball distance 277.777778.
One of the contact searching regions contains at least 6 target
elements.
*************************************************
*********** PRECISE MASS SUMMARY ***********
TOTAL RIGID BODY MASS MATRIX ABOUT ORIGIN
Translational mass | Coupled translational/rotational mass
6468.7 0.0000 0.0000 | 0.0000 -0.25146E-06 0.46560E-02
0.0000 6468.7 0.0000 | 0.25146E-06 0.0000 -0.96697
0.0000 0.0000 6468.7 | -0.46560E-02 0.96697 0.0000
------------------------------------------ | ------------------------------------------
| Rotational mass (inertia)
| 0.35551E+12 -121.48 -5879.1
| -121.48 0.35551E+12 -23669.
| -5879.1 -23669. 0.27977E+12
TOTAL MASS = 6468.7
The mass principal axes coincide with the global Cartesian axes
CENTER OF MASS (X,Y,Z)= -0.14949E-03 -0.71978E-06 -0.38873E-10
TOTAL INERTIA ABOUT CENTER OF MASS
0.35551E+12 -121.48 -5879.1
-121.48 0.35551E+12 -23669.
-5879.1 -23669. 0.27977E+12
The inertia principal axes coincide with the global Cartesian axes
*** MASS SUMMARY BY ELEMENT TYPE ***
TYPE MASS
1 3234.34
2 3234.34
Range of element maximum matrix coefficients in global coordinates
Maximum = 392679482 at element 58.
Minimum = 182655886 at element 658.
*** ELEMENT MATRIX FORMULATION TIMES
TYPE NUMBER ENAME TOTAL CP AVE CP
1 360 SOLID186 0.109 0.000304
2 351 SOLID186 0.062 0.000178
3 40 CONTA174 0.047 0.001172
4 39 TARGE170 0.000 0.000000
5 40 SURF154 0.000 0.000000
Time at end of element matrix formulation CP = 1.3125.
DISTRIBUTED SPARSE MATRIX DIRECT SOLVER.
Number of equations = 13554, Maximum wavefront = 192
Memory allocated on only this MPI rank (rank 0)
-------------------------------------------------------------------
Equation solver memory allocated = 17.843 MB
Equation solver memory required for in-core mode = 17.166 MB
Equation solver memory required for out-of-core mode = 10.409 MB
Total (solver and non-solver) memory allocated = 425.816 MB
Total memory summed across all MPI ranks on this machines
-------------------------------------------------------------------
Equation solver memory allocated = 73.101 MB
Equation solver memory required for in-core mode = 70.301 MB
Equation solver memory required for out-of-core mode = 40.411 MB
Total (solver and non-solver) memory allocated = 840.269 MB
*** NOTE *** CP = 1.469 TIME= 18:26:09
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= 3423 totEqn= 3423 Job CP sec= 1.609
Factor Done= 100% Factor Wall sec= 0.077 rate= 4.5 GFlops
Distributed sparse solver maximum pivot= 1.17008542E+09 at node 780 UY.
Distributed sparse solver minimum pivot= 18229767.9 at node 934 UX.
Distributed sparse solver minimum pivot in absolute value= 18229767.9
at node 934 UX.
*** ELEMENT RESULT CALCULATION TIMES
TYPE NUMBER ENAME TOTAL CP AVE CP
1 360 SOLID186 0.047 0.000130
2 351 SOLID186 0.062 0.000178
3 40 CONTA174 0.016 0.000391
5 40 SURF154 0.000 0.000000
*** NODAL LOAD CALCULATION TIMES
TYPE NUMBER ENAME TOTAL CP AVE CP
1 360 SOLID186 0.000 0.000000
2 351 SOLID186 0.000 0.000000
3 40 CONTA174 0.000 0.000000
5 40 SURF154 0.000 0.000000
*** 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
0.875 MB WRITTEN ON ELEMENT SAVED DATA FILE: file0.esav
2.750 MB WRITTEN ON ASSEMBLED MATRIX FILE: file0.full
0.562 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= 18.4358333
PRINTOUT RESUMED BY /GOP
FINISH SOLUTION PROCESSING
***** ROUTINE COMPLETED ***** CP = 1.750
*** MAPDL - ENGINEERING ANALYSIS SYSTEM RELEASE 2024 R2 24.2 ***
Ansys Mechanical Enterprise
00000000 VERSION=WINDOWS x64 18:26:09 JAN 08, 2025 CP= 1.750
wbnew--Static Structural (A5)
***** MAPDL RESULTS INTERPRETATION (POST1) *****
*** NOTE *** CP = 1.750 TIME= 18:26:09
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 = 1.750
PRINTOUT RESUMED BY /GOP
*GET _WALLDONE FROM ACTI ITEM=TIME WALL VALUE= 18.4358333
PARAMETER _PREPTIME = 0.000000000
PARAMETER _SOLVTIME = 1.000000000
PARAMETER _POSTTIME = 0.000000000
PARAMETER _TOTALTIM = 1.000000000
*GET _DLBRATIO FROM ACTI ITEM=SOLU DLBR VALUE= 1.11616162
*GET _COMBTIME FROM ACTI ITEM=SOLU COMB VALUE= 0.305359000E-01
*GET _SSMODE FROM ACTI ITEM=SOLU SSMM VALUE= 2.00000000
*GET _NDOFS FROM ACTI ITEM=SOLU NDOF VALUE= 13554.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 = 4879
--- Total number of elements = 830
--- Element load balance ratio = 1.11616162
--- Time to combine distributed files = 3.05359E-02
--- Sparse memory mode = 2
--- Number of DOF = 13554
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: 2024 R2 Build: 24.2 Update: UP20240603 Platform: WINDOWS x64
Date Run: 01/08/2025 Time: 18:26 Process ID: 12592
Operating System: Windows 11 (Build: 22631)
Processor Model: Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz
Compiler: Intel(R) Fortran Compiler Classic Version 2021.9 (Build: 20230302)
Intel(R) C/C++ Compiler Classic Version 2021.9 (Build: 20230302)
Intel(R) oneAPI Math Kernel Library Version 2023.1-Product Build 20230303
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: INTELMPI
MPI Version: Intel(R) MPI Library 2021.11 for Windows* OS
GPU Acceleration: Not Requested
Job Name: file0
Input File: dummy.dat
Core Machine Name Working Directory
-----------------------------------------------------
0 pyworkbench C:\Users\ansys\AppData\Local\Temp\WB_ansys_8664_2\_ProjectScratch\Scr01DE
1 pyworkbench C:\Users\ansys\AppData\Local\Temp\WB_ansys_8664_2\_ProjectScratch\Scr01DE
2 pyworkbench C:\Users\ansys\AppData\Local\Temp\WB_ansys_8664_2\_ProjectScratch\Scr01DE
3 pyworkbench C:\Users\ansys\AppData\Local\Temp\WB_ansys_8664_2\_ProjectScratch\Scr01DE
Latency time from master to core 1 = 3.052 microseconds
Latency time from master to core 2 = 4.044 microseconds
Latency time from master to core 3 = 3.278 microseconds
Communication speed from master to core 1 = 3531.68 MB/sec
Communication speed from master to core 2 = 4505.65 MB/sec
Communication speed from master to core 3 = 4411.14 MB/sec
Total CPU time for main thread : 1.6 seconds
Total CPU time summed for all threads : 2.5 seconds
Elapsed time spent obtaining a license : 0.5 seconds
Elapsed time spent pre-processing model (/PREP7) : 0.0 seconds
Elapsed time spent solution - preprocessing : 0.2 seconds
Elapsed time spent computing solution : 0.6 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 : 17.7 Gflops
Sum of disk space used on all processes : 15.2 MB
Sum of memory used on all processes : 557.0 MB
Sum of memory allocated on all processes : 2880.0 MB
Physical memory available : 32 GB
Total amount of I/O written to disk : 0.0 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 2024 R2 Build 24.2 UP20240603 WINDOWS x64 |
| |
|-----------------------------------------------------------------------------|
| |
| Database Requested(-db) 1024 MB Scratch Memory Requested 1024 MB |
| Max Database Used(Master) 3 MB Max Scratch Used(Master) 140 MB |
| Max Database Used(Workers) 1 MB Max Scratch Used(Workers) 137 MB |
| Sum Database Used(All) 6 MB Sum Scratch Used(All) 551 MB |
| |
|-----------------------------------------------------------------------------|
| |
| CP Time (sec) = 2.453 Time = 18:26:10 |
| Elapsed Time (sec) = 4.000 Date = 01/08/2025 |
| |
*-----------------------------------------------------------------------------*
Plot the deformation result (deformation.png
) using pyvista
. A Plotter
object is created, and the image is added as a background. The plot is then displayed.
[12]:
pl = pv.Plotter()
pl.add_background_image(os.path.join(str(workdir.absolute()), "deformation.png"))
pl.show()
Finally, the exit
method is called on both the PyMechanical and Workbench clients to gracefully shut down the services, ensuring that all resources are properly released.
[13]:
mechanical.exit()
wb.exit()