ansys / pymechanical

Pythonic interface to Ansys Mechanical ™
https://mechanical.docs.pyansys.com/
MIT License
36 stars 18 forks source link

Analysis fails only in Embedded instances when multiple analysis systems are added. #874

Closed rokamoto26 closed 1 month ago

rokamoto26 commented 1 month ago

🔍 Before submitting the issue

🐞 Description of the bug

Only in Embedded instances, the analysis fails with the following error in Mechanical on the second static structural system when I used Model.AddStaticStructuralAnalysis() twice in one session. The same process works fine with Mechanical scripting and Remote sessions.

[Error] An unknown error occurred during solution. Check the Solver Output on the Solution Information object for possible causes.

📝 Steps to reproduce

Run PyMechanicalTest_EmbeddedInstance.py in the ZIP file attached. Scripts for Remote Session is also included in ZIP for reference. test_codes.zip

💻 Which operating system are you using?

Windows

📀 Which ANSYS version are you using?

2024R2

🐍 Which Python version are you using?

3.11

📦 Installed packages

aiohappyeyeballs==2.3.5
aiohttp==3.10.3
aiosignal==1.3.1
ansys-api-mechanical==0.1.2
ansys-api-platform-instancemanagement==1.1.0
ansys-mechanical-core==0.11.5
ansys-mechanical-env==0.1.7
ansys-platform-instancemanagement==1.1.2
ansys-pythonnet==3.1.0rc3
ansys-tools-path==0.6.0
ansys-tools-visualization-interface==0.4.0
anyio==4.4.0
appdirs==1.4.4
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==2.4.1
attrs==24.2.0
beartype==0.18.5
beautifulsoup4==4.12.3
bleach==6.1.0
certifi==2024.7.4
cffi==1.17.0
charset-normalizer==3.3.2
click==8.1.7
clr-loader==0.2.6
cmocean==4.0.3
colorama==0.4.6
colorcet==3.1.0
comm==0.2.2
contourpy==1.2.1
cycler==0.12.1
decorator==5.1.1
defusedxml==0.7.1
executing==2.0.1
fastjsonschema==2.20.0
fonttools==4.53.1
fqdn==1.5.1
frozenlist==1.4.1
grpcio==1.65.4
idna==3.7
imageio==2.35.0
importlib_metadata==8.2.0
ipython==8.26.0
ipywidgets==8.1.3
isoduration==20.11.0
jedi==0.19.1
Jinja2==3.1.4
joblib==1.4.2
jsonpointer==3.0.0
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
jupyter-events==0.10.0
jupyter_client==8.6.2
jupyter_core==5.7.2
jupyter_server==2.14.2
jupyter_server_proxy==4.3.0
jupyter_server_terminals==0.5.3
jupyterlab_pygments==0.3.0
jupyterlab_widgets==3.0.11
kiwisolver==1.4.5
markdown-it-py==3.0.0
MarkupSafe==2.1.5
matplotlib==3.9.2
matplotlib-inline==0.1.7
mdurl==0.1.2
meshio==5.3.5
mistune==3.0.2
more-itertools==10.4.0
msgpack==1.0.8
multidict==6.0.5
nbclient==0.10.0
nbconvert==7.16.4
nbformat==5.10.4
nest-asyncio==1.6.0
numpy==1.26.4
overrides==7.7.0
packaging==24.1
pandas==2.2.2
pandocfilters==1.5.1
parso==0.8.4
pillow==10.4.0
platformdirs==4.2.2
pooch==1.8.2
prometheus_client==0.20.0
prompt_toolkit==3.0.47
protobuf==5.27.3
pure_eval==0.2.3
pycparser==2.22
Pygments==2.18.0
pyparsing==3.1.2
python-dateutil==2.9.0.post0
python-json-logger==2.0.7
pytz==2024.1
pyvista==0.44.1
pywin32==306
pywinpty==2.0.13
PyYAML==6.0.2
pyzmq==26.1.0
referencing==0.35.1
requests==2.32.3
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rich==13.7.1
rpds-py==0.20.0
scikit-learn==1.5.1
scipy==1.14.0
scooby==0.10.0
Send2Trash==1.8.3
simpervisor==1.0.0
six==1.16.0
sniffio==1.3.1
soupsieve==2.6
stack-data==0.6.3
terminado==0.18.1
threadpoolctl==3.5.0
tinycss2==1.3.0
tornado==6.4.1
tqdm==4.66.5
traitlets==5.14.3
trame==3.6.3
trame-client==3.2.3
trame-server==3.0.3
trame-vtk==2.8.10
trame-vuetify==2.6.2
types-python-dateutil==2.9.0.20240316
typing_extensions==4.12.2
tzdata==2024.1
uri-template==1.3.0
urllib3==2.2.2
usd-core==24.8
vtk==9.3.1
wcwidth==0.2.13
webcolors==24.8.0
webencodings==0.5.1
websocket-client==1.8.0
websockets==12.0
widgetsnbextension==4.0.11
wslink==2.1.2
yarl==1.9.4
zipp==3.20.0
dipinknair commented 1 month ago

@rokamoto26 , GetResultsData() creates a lock on results file unless Dispose() is called. Please see modified code below

analysis = ExtAPI.DataModel.Project.Model.Analyses[_num]
meshObj = analysis.MeshData
elementids = meshObj.ElementIds
# Get nodes 
# element = meshObj.ElementById(elementid)

reader = analysis.GetResultsData()
DataSets=reader.ListTimeFreq
print ("_num:",_num)
print ("DataSets:",list(DataSets))
print ("DataSets:",str(DataSets[0]))
reader.Dispose()
rokamoto26 commented 1 month ago

@dipinknair, Thank you for your help. I confirmed the issue was solved by applying the modification you proposed. Thanks again!