-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird performance of solution #1084
Comments
@Sega7654, Hi Thanks for opening the issue. Could you please provide the geometry if possible? you can email to [email protected] with "PyMechanical issue #1084" in subject. |
@Sega7654 in your code you have used pymechanical remote and embedding and there are other inconsistencies. Geometry does not have Material where in code you are using it.
Then at the end you are removing the geometry itself in code which is unnecessary. import os
from matplotlib import image as mpimg
from matplotlib import pyplot as plt
from ansys.mechanical.core import App
app = App(version=242)
app.update_globals(globals())
cwd = os.path.join(os.getcwd(), "out")
def display_image(image_name):
plt.figure(figsize=(16, 9))
plt.imshow(mpimg.imread(os.path.join(cwd, image_name)))
plt.xticks([])
plt.yticks([])
plt.axis("off")
plt.show()
Graphics.Camera.SetSpecificViewOrientation(ViewOrientationType.Iso)
Graphics.Camera.SetFit()
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
Graphics.Camera.Rotate(180, CameraAxisType.ScreenY)
geometry_import_group_11 = Model.GeometryImportGroup
geometry_import_19 = geometry_import_group_11.AddGeometryImport()
geometry_import_19_format = Ansys.Mechanical.DataModel.Enums.GeometryImportPreference.Format.Automatic
geometry_import_19_preferences = Ansys.ACT.Mechanical.Utilities.GeometryImportPreferences()
geometry_import_19.Import(r"C:\Users\miste\Desktop\Python_Ansys_training\PyAnsysGeometry\ma_huynya\import_from_CAD_test.scdocx", geometry_import_19_format, geometry_import_19_preferences)
#endregion
model_10 = Model
analysis_30 = model_10.AddStaticStructuralAnalysis()
ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardMKS
STATIC_STRUCTURAL = DataModel.AnalysisByName("Static Structural")
ANALYSIS_SETTINGS = STATIC_STRUCTURAL.AnalysisSettings
SOLUTION = STATIC_STRUCTURAL.Solution
MESH = Model.Mesh
STATIC_STRUCTURAL.SolveConfiguration.SolveProcessSettings.MaxNumberOfCores = 2
ANALYSIS_SETTINGS.Activate()
ANALYSIS_SETTINGS.AutomaticTimeStepping = AutomaticTimeStepping.On
ANALYSIS_SETTINGS.DefineBy = TimeStepDefineByType.Substeps
ANALYSIS_SETTINGS.MaximumSubsteps = 100
ANALYSIS_SETTINGS.InitialSubsteps = 100
ANALYSIS_SETTINGS.MinimumSubsteps = 100
ANALYSIS_SETTINGS.LargeDeflection = True
MESH.Activate()
mesh_13 = Model.Mesh
automatic_method_27 = mesh_13.AddAutomaticMethod()
selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
selection.Ids = [4]
automatic_method_27.Location = selection
mesh_13.GenerateMesh()
STATIC_STRUCTURAL.Activate()
fixed_support_34 = STATIC_STRUCTURAL.AddFixedSupport()
selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
selection.Ids = [7]
fixed_support_34.Location = selection
STATIC_STRUCTURAL.Activate()
moment_36 = STATIC_STRUCTURAL.AddMoment()
selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
selection.Ids = [6]
moment_36.Location = selection
moment_36.Magnitude.Output.SetDiscreteValue(0, Quantity(500, "N mm"))
STATIC_STRUCTURAL.Activate()
STATIC_STRUCTURAL.Solution.Solve(True)
#STAT_STRUC_SS=SOLUTION.Status
SOLUTION.Activate()
#DIRECTIONAL_DEFORMATION = SOLUTION.AddDirectionalDeformation()
#DIRECTIONAL_DEFORMATION.NormalOrientation = NormalOrientationType.YAxis
#TOTAL_DEFORMATION = SOLUTION.AddTotalDeformation()
SOLUTION.AddEquivalentStress()
#DIRECTIONAL_DEFORMATION.NormalOrientation = NormalOrientationType.YAxis
SOLUTION.EvaluateAllResults()
def write_file_contents_to_console(path):
"""Write file contents to console."""
with open(path, "rt") as file:
for line in file:
print(line, end="")
solve_path = STATIC_STRUCTURAL.WorkingDir
solve_out_path = os.path.join(solve_path, "solve.out")
if solve_out_path:
write_file_contents_to_console(solve_out_path)
STATIC_STRUCTURAL.Activate()
Graphics.Camera.SetFit()
Graphics.ExportImage(
os.path.join(cwd, "analysis_30.png"), image_export_format, settings_720p
)
display_image("analysis_30.png")
#DataModel.Remove(geometry_import_19)
app.save(os.path.join(cwd, "save_test_2.mechdb")) Let me know what errors you are seeing after running this script. |
🔍 Before submitting the issue
🐞 Description of the bug
I'm Gleb, master srudent in Centrale Lyon university. I'm working with student Ansys (version 2024 R2) license on a project. I'm developing a code (You can find my code with geometry in the attachments) with PyAnsys for optimization. And I got a problem with the code. In the code I created a project (which was launcing Ansys Mechanical in batch mode) in Ansys Mechanical, set up mesh, BC, loads and soltion. After solving my instance with 2 cores, I got this error (I put the whole solution report in the Annex):
"The element option SOLID186 was either not ordered with this Ansys
installation or the appropriate product was not selected for this
session. "
I did not specify the solid type and my mesh was with automatic method.
Also, by printing a project tree, I can see this:
├── Project
| ├── Model
| | ├── Geometry Imports (✓)
| | | ├── Geometry Import (✓)
| | ├── Geometry (✓)
| | | ├── import_from_CAD_test
| | | | ├── import_from_CAD_test\comp_3_circle
| | ├── Materials (✓)
| | | ├── Structural Steel (✓)
| | ├── Coordinate Systems (✓)
| | | ├── Global Coordinate System (✓)
| | ├── Remote Points (✓)
| | | ├── Internal Remote Point (✓)
| | ├── Mesh (✓)
| | | ├── Automatic Method (✓)
| | ├── Static Structural (⚡︎)
| | | ├── Analysis Settings (✓)
| | | ├── Fixed Support (✓)
| | | ├── Moment (✓)
| | | ├── Solution (✕)
| | | | ├── Solution Information (✕)
| | | | ├── Equivalent Stress (⚡︎)
As You can see, everyting is done, except the solution. And here is "strange" things according this problem:
https://embedding.examples.mechanical.docs.pyansys.com/examples/01_basic/fracture_analysis_contact_debonding.html#sphx-glr-examples-01-basic-fracture-analysis-contact-debonding-py
With this, I want to ask for your help. Could You please say, what could be the problem? Is this a limitation of a Student verison of Ansys? If it is, what are other limitations? Why do the exampe woked, but my code did not?
Annex
The full solution report:
Ansys Mechanical Enterprise Academic Student
------------------------------------------------------------------
| |
| 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 |
| |
------------------------------------------------------------------
2024 R2
Point Releases and Patches installed:
Ansys Service Pack 2024 R2.10483252
Discovery 2024 R2.10483252
Core WB Files 2024 R2.10483252
Ansys Dynamic Reporting 2024 R2.10483252
SpaceClaim 2024 R2.10483252
CFX (includes CFD-Post) 2024 R2.10483252
Chemkin 2024 R2.10483252
EnSight 2024 R2.10483252
FENSAP-ICE 2024 R2.10483252
Fluent (includes CFD-Post) 2024 R2.10483252
Polyflow (includes CFD-Post) 2024 R2.10483252
Forte (includes EnSight) 2024 R2.10483252
TurboGrid 2024 R2.10483252
ACIS Geometry Interface 2024 R2.10483252
AutoCAD Geometry Interface 2024 R2.10483252
Catia, Version 4 Geometry Interface 2024 R2.10483252
Catia, Version 5 Geometry Interface 2024 R2.10483252
Catia, Version 6 Geometry Interface 2024 R2.10483252
Creo Elements/Direct Modeling Geometry Interface 2024 R2.10483252
Creo Parametric Geometry Interface 2024 R2.10483252
Inventor Geometry Interface 2024 R2.10483252
JTOpen Geometry Interface 2024 R2.10483252
NX Geometry Interface 2024 R2.10483252
Parasolid Geometry Interface 2024 R2.10483252
Solid Edge Geometry Interface 2024 R2.10483252
SOLIDWORKS Geometry Interface 2024 R2.10483252
Speos 2024 R2.10483252
Aqwa 2024 R2.10483252
Autodyn 2024 R2.10483252
Material Calibration App 2024 R2.10483252
Customization Files for User Programmable Features 2024 R2.10483252
Mechanical Products 2024 R2.10483252
Motion 2024 R2.10483252
Academic Student 2024 R2.10483252
BATCH MODE REQUESTED (-b) = NOLIST
INPUT FILE COPY MODE (-c) = COPY
DISTRIBUTED MEMORY PARALLEL REQUESTED
2 PARALLEL PROCESSES REQUESTED WITH SINGLE THREAD PER PROCESS
TOTAL OF 2 CORES REQUESTED
INPUT FILE NAME = C:\Users\miste\AppData\Local\Temp\AnsysMech0430\Project_Mech_Files\StaticStructural\dummy.dat
OUTPUT FILE NAME = C:\Users\miste\AppData\Local\Temp\AnsysMech0430\Project_Mech_Files\StaticStructural\solve.out
START-UP FILE MODE = NOREAD
STOP FILE MODE = NOREAD
RELEASE= 2024 R2 BUILD= 24.2 UP20240513 VERSION=WINDOWS x64
CURRENT JOBNAME=file0 15:29:55 FEB 05, 2025 CP= 0.000
PARAMETER _DS_PROGRESS = 999.0000000
/INPUT FILE= ds.dat LINE= 0
*** NOTE *** CP = 0.016 TIME= 15:29:55
The /CONFIG,NOELDB command is not valid in a distributed memory
parallel solution. Command is ignored.
*GET _WALLSTRT FROM ACTI ITEM=TIME WALL VALUE= 15.4986111
TITLE=
--Static Structural
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\miste\AppData\Local\Temp\AnsysMech0430\Project_Mech_Files\StaticStructural\
SET PARAMETER DIMENSIONS ON _WB_SOLVERFILES_DIR
TYPE=STRI DIMENSIONS= 248 1 1
PARAMETER _WB_SOLVERFILES_DIR(1) = C:\Users\miste\AppData\Local\Temp\AnsysMech0430\Project_Mech_Files\StaticStructural\
SET PARAMETER DIMENSIONS ON _WB_USERFILES_DIR
TYPE=STRI DIMENSIONS= 248 1 1
PARAMETER _WB_USERFILES_DIR(1) = C:\Users\miste\AppData\Local\Temp\AnsysMech0430\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 2024 R2 24.2 ***
Ansys Mechanical Enterprise Academic Student
01055371 VERSION=WINDOWS x64 15:29:55 FEB 05, 2025 CP= 0.016
--Static Structural
*********** Nodes for the whole assembly ***********
*********** Nodes for all Remote Points ***********
*********** Elements for Body 1 'import_from_CAD_test\comp_3_circle' **********
*** ERROR *** CP = 0.016 TIME= 15:29:55
The element option SOLID186 was either not ordered with this Ansys
installation or the appropriate product was not selected for this
session.
Contact your Ansys support person for more information.
NUMBER OF WARNING MESSAGES ENCOUNTERED= 0
NUMBER OF ERROR MESSAGES ENCOUNTERED= 1
***** PROBLEM TERMINATED BY INDICATED ERROR(S) OR BY END OF INPUT DATA *****
+--------------------- M A P D L S T A T I S T I C S ------------------------+
Release: 2024 R2 Build: 24.2 Update: UP20240513 Platform: WINDOWS x64
Date Run: 02/05/2025 Time: 15:29 Process ID: 20808
Operating System: Windows 11 (Build: 22631)
Processor Model: AMD Ryzen 9 7940HS w/ Radeon 780M Graphics
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 20240304
Number of machines requested : 1
Total number of cores available : 16
Number of physical cores available : 8
Number of processes requested : 2
Number of threads per process requested : 1
Total number of cores requested : 2 (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
Latency time from master to core 1 = 2.458 microseconds
Communication speed from master to core 1 = 14374.27 MB/sec
Total CPU time for main thread : 0.0 seconds
Total CPU time summed for all threads : 0.1 seconds
Elapsed time spent obtaining a license : 0.4 seconds
Elapsed time spent pre-processing model (/PREP7) : 0.0 seconds
Elapsed time spent solution - preprocessing : 0.0 seconds
Elapsed time spent computing solution : 0.0 seconds
Elapsed time spent solution - postprocessing : 0.0 seconds
Elapsed time spent post-processing model (/POST1) : 0.0 seconds
Sum of disk space used on all processes : 0.0 MB
Sum of memory used on all processes : 40.0 MB
Sum of memory allocated on all processes : 2496.0 MB
Physical memory available : 31 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 |
📝 Steps to reproduce
import os
from ansys.mechanical.core import launch_mechanical
from ansys.mechanical.core.examples import download_file
from matplotlib import image as mpimg
from matplotlib import pyplot as plt
from PIL import Image
from ansys.mechanical.core import App
from matplotlib.animation import FuncAnimation
mechanical = launch_mechanical(batch=True, cleanup_on_exit=False)
app = App()
app.update_globals(globals())
cwd = os.path.join(os.getcwd(), "out")
def display_image(image_name):
plt.figure(figsize=(16, 9))
plt.imshow(mpimg.imread(os.path.join(cwd, image_name)))
plt.xticks([])
plt.yticks([])
plt.axis("off")
plt.show()
Graphics.Camera.SetSpecificViewOrientation(ViewOrientationType.Iso)
Graphics.Camera.SetFit()
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
Graphics.Camera.Rotate(180, CameraAxisType.ScreenY)
'''NOTE : All workflows will not be recorded, as recording is under development.'''
#region Context Menu Action
geometry_import_group_11 = Model.GeometryImportGroup
geometry_import_19 = geometry_import_group_11.AddGeometryImport()
#endregion
#region Context Menu Action
geometry_import_19_format = Ansys.Mechanical.DataModel.Enums.GeometryImportPreference.Format.Automatic
geometry_import_19_preferences = Ansys.ACT.Mechanical.Utilities.GeometryImportPreferences()
geometry_import_19.Import(r"C:\Users\miste\Desktop\Python_Ansys_training\PyAnsysGeometry\ma_huynya\import_from_CAD_test.scdocx", geometry_import_19_format, geometry_import_19_preferences)
#endregion
GEOM = Model.Geometry
GEOM.Material = "Steel"
model_10 = Model
analysis_30 = model_10.AddStaticStructuralAnalysis()
ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardMKS
STATIC_STRUCTURAL = DataModel.AnalysisByName("Static Structural")
ANALYSIS_SETTINGS = STATIC_STRUCTURAL.AnalysisSettings
SOLUTION = STATIC_STRUCTURAL.Solution
MESH = Model.Mesh
STATIC_STRUCTURAL.SolveConfiguration.SolveProcessSettings.MaxNumberOfCores = 2
ANALYSIS_SETTINGS.Activate()
ANALYSIS_SETTINGS.AutomaticTimeStepping = AutomaticTimeStepping.On
ANALYSIS_SETTINGS.DefineBy = TimeStepDefineByType.Substeps
ANALYSIS_SETTINGS.MaximumSubsteps = 100
ANALYSIS_SETTINGS.InitialSubsteps = 100
ANALYSIS_SETTINGS.MinimumSubsteps = 100
ANALYSIS_SETTINGS.LargeDeflection = True
MESH.Activate()
mesh_13 = Model.Mesh
automatic_method_27 = mesh_13.AddAutomaticMethod()
selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
selection.Ids = [4]
automatic_method_27.Location = selection
mesh_13.GenerateMesh()
STATIC_STRUCTURAL.Activate()
fixed_support_34 = STATIC_STRUCTURAL.AddFixedSupport()
selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
selection.Ids = [7]
fixed_support_34.Location = selection
STATIC_STRUCTURAL.Activate()
moment_36 = STATIC_STRUCTURAL.AddMoment()
selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
selection.Ids = [6]
moment_36.Location = selection
moment_36.Magnitude.Output.SetDiscreteValue(0, Quantity(500, "N mm"))
STATIC_STRUCTURAL.Activate()
STATIC_STRUCTURAL.Solution.Solve()
#STAT_STRUC_SS=SOLUTION.Status
SOLUTION.Activate()
#DIRECTIONAL_DEFORMATION = SOLUTION.AddDirectionalDeformation()
#DIRECTIONAL_DEFORMATION.NormalOrientation = NormalOrientationType.YAxis
#TOTAL_DEFORMATION = SOLUTION.AddTotalDeformation()
SOLUTION.AddEquivalentStress()
#DIRECTIONAL_DEFORMATION.NormalOrientation = NormalOrientationType.YAxis
def write_file_contents_to_console(path):
"""Write file contents to console."""
with open(path, "rt") as file:
for line in file:
print(line, end="")
solve_path = STATIC_STRUCTURAL.WorkingDir
solve_out_path = os.path.join(solve_path, "solve.out")
if solve_out_path:
write_file_contents_to_console(solve_out_path)
app.update_globals(globals())
app.print_tree()
#Tree.Activate([analysis_30])
STATIC_STRUCTURAL.Activate()
Graphics.Camera.SetFit()
Graphics.ExportImage(
os.path.join(cwd, "analysis_30.png"), image_export_format, settings_720p
)
display_image("analysis_30.png")
DataModel.Remove(geometry_import_19)
app.save(os.path.join(cwd, "save_test_2.mechdat"))
app.new()
mechanical.exit()
💻 Which operating system are you using?
Windows
📀 Which ANSYS version are you using?
Ansys R2 2024, Student version.
🐍 Which Python version are you using?
3.12
📦 Installed packages
The text was updated successfully, but these errors were encountered: