ansys / pymapdl

Pythonic interface to MAPDL
https://mapdl.docs.pyansys.com
MIT License
423 stars 120 forks source link

Bug located in mapdl.inquire #1379

Closed germa89 closed 2 years ago

germa89 commented 2 years ago

Before submitting the issue

Description of the bug

Working on #1279 I found out that the INQUIRE command with the RST option seems to not work in the docker image.

Steps To Reproduce

# In latest PyMAPDL version:
# Using docker as image

from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl(start_instance=False, port=50054)

mapdl.inquire("", "RSTFILE")  # Print ''
mapdl.run("/inquire,asdf,rstfile")  # PARAMETER ASDF     =

mapdl.prep7()
mapdl.et(1, "SOLID5")
mapdl.block(0, 10, 0, 20, 0, 30)
mapdl.esize(10)
mapdl.vmesh("ALL")
mapdl.units("SI")  # SI - International system (m, kg, s, K).
# Define a material (nominal steel in SI)
mapdl.mp("EX", 1, 210e9)  # Elastic moduli in Pa (kg/(m*s**2))
mapdl.mp("DENS", 1, 7800)  # Density in kg/m3
mapdl.mp("NUXY", 1, 0.3)  # Poisson's Ratio
# Fix the left-hand side.
mapdl.nsel("S", "LOC", "Z", 0)
mapdl.d("ALL", "UX")
mapdl.d("ALL", "UY")
mapdl.d("ALL", "UZ")

mapdl.nsel("S", "LOC", "Z", 30)
mapdl.f("ALL", "FX", 1000)
mapdl.run("/SOLU")
mapdl.antype("STATIC")
out = mapdl.solve()
print(out)

mapdl.finish()

assert "file.rst" in mapdl.list_files() # RST file exists!
mapdl.inquire("", "RSTFILE")  # Print ''
mapdl.run("/inquire,asdf,rstfile")  #mapdl.run("/inquire,asdf,rstfile")

Which Operating System are you using?

No response

Which Python version are you using?

3.9

PyMAPDL Report


PyMAPDL Software and Environment Report

Packages Requirements


Core packages

ansys.mapdl.core : 0.62.dev1 numpy : 1.22.0 appdirs : 1.4.4 scipy : 1.8.0 grpc : Package not found ansys.api.mapdl.v0 : Package not found ansys.mapdl.reader : 0.52.dev0 google.protobuf : Package not found

Optional packages

matplotlib : 3.5.1 pyvista : 0.35.dev0 pyiges : 0.2.1 tqdm : 4.62.3

Ansys Installation


Version Location

212 C:\Program Files\ANSYS Inc\v212 222 C:\Program Files\ANSYS Inc\ANSYS Student\v222

Ansys Environment Variables


ANSYS212_DIR C:\Program Files\ANSYS Inc\v212\ANSYS ANSYS222_DIR C:\Program Files\ANSYS Inc\ANSYS Student\v222\ANSYS ANSYSLIC_DIR C:\Program Files\ANSYS Inc\Shared Files\Licensing AWP_LOCALE212 en-us AWP_ROOT212 C:\Program Files\ANSYS Inc\v212 AWP_ROOT222 C:\Program Files\ANSYS Inc\ANSYS Student\v222 CADOE_LIBDIR212 C:\Program Files\ANSYS Inc\v212\CommonFiles\Language\en-us CADOE_LIBDIR222 C:\Program Files\ANSYS Inc\ANSYS Student\v222\CommonFiles\Language\en-us

Installed packages

WARNING: Ignoring invalid distribution -nsys-mapdl-reader (c:\programdata\miniconda3\envs\pymapdl_0\lib\site-packages)
aiohttp==3.8.1
aiosignal==1.2.0
alabaster==0.7.12
ansys-api-mapdl==0.5.1
ansys-api-platform-instancemanagement==1.0.0b1
-e git+https://github.com/pyansys/pydpf-core.git@1e21e317dd02f3a742c48f0052bd50b6f2e7e9fd#egg=ansys_dpf_core
-e git+https://github.com/pyansys/pydpf-post.git@ad8d1dc343a4adc5b4158a9fa019e94158e4da62#egg=ansys_dpf_post
ansys-grpc-dpf==0.4.0
-e git+https://github.com/pyansys/pymapdl.git@115f68192e7fa34febad5dbdd9f49f0b52b8278f#egg=ansys_mapdl_core
-e git+https://github.com/pyansys/pymapdl-reader@d835194d46f44db7c2eb77e9bb20390d150cbe9c#egg=ansys_mapdl_reader
ansys-platform-instancemanagement==0.2.0
-e git+https://github.com/ansys/ansys-sphinx-theme.git@ce0099e4a538e827523382c0c39633bcab66fff5#egg=ansys_sphinx_theme
anyio==3.5.0
appdirs==1.4.4
argcomplete==2.0.0
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
async-timeout==4.0.2
atomicwrites==1.4.0
attrs==21.4.0
autobahn==21.11.1
Automat==20.2.0
autopep8 @ file:///opt/conda/conda-bld/autopep8_1639166893812/work
Babel==2.9.1
backcall==0.2.0
beautifulsoup4==4.11.1
bleach==4.1.0
cachetools==4.2.4
certifi==2021.10.8
cffi==1.15.0
cfgv==3.3.1
charset-normalizer==2.0.10
click==8.1.2
codespell==2.1.0
colorama==0.4.4
constantly==15.1.0
coverage==6.2
cryptography==36.0.1
cycler==0.11.0
debugpy==1.5.1
decorator==5.1.1
defusedxml==0.7.1
distlib==0.3.4
dnspython==2.2.0
docopt==0.6.2
docutils==0.17.1
entrypoints==0.3
fett==0.3.2
filelock==3.6.0
flake8==3.9.2
fonttools==4.28.5
frozenlist==1.2.0
geomdl==5.3.1
google==3.0.0
google-api-core==2.3.2
google-api-python-client==2.34.0
google-auth==2.3.3
google-auth-httplib2==0.1.0
googleapis-common-protos==1.54.0
grpcio==1.43.0
httplib2==0.20.2
hyperlink==21.0.0
identify==2.4.11
idna==3.3
imageio==2.14.1
imageio-ffmpeg==0.4.5
imagesize==1.3.0
importlib-metadata==4.10.1
incremental==21.3.0
iniconfig==1.1.1
ipycanvas==0.10.2
ipydatawidgets==4.2.0
ipyevents==2.0.1
ipykernel==6.6.1
ipython==7.31.0
ipython-genutils==0.2.0
ipyvtklink==0.2.2
ipywidgets==7.6.5
jedi==0.18.1
Jinja2==3.1.2
json5==0.9.6
jsonschema==4.4.0
jupyter==1.0.0
jupyter-client==7.1.1
jupyter-console==6.4.0
jupyter-core==4.9.1
jupyter-server==1.13.1
jupyter-sphinx==0.3.2
jupyterlab==3.2.8
jupyterlab-pygments==0.1.2
jupyterlab-server==2.10.3
jupyterlab-widgets==1.0.2
kiwisolver==1.3.2
livereload==2.6.3
mapdl @ file:///C:/Program%20Files/ANSYS%20Inc/v212/ANSYS/syslib/ansGRPC/User/mapdl-pyupf.tar.gz
MarkupSafe==2.0.1
matplotlib==3.5.1
matplotlib-inline==0.1.3
mccabe==0.6.1
mistune==0.8.4
mpmath==1.2.1
multidict==5.2.0
nbclassic==0.3.5
nbclient==0.5.10
nbconvert==6.4.0
nbformat==5.1.3
nest-asyncio==1.5.4
networkx==2.6.3
nodeenv==1.6.0
nose==1.3.7
notebook==6.4.7
numpy==1.22.0
numpydoc==1.2
packaging==21.3
pandas==1.4.1
pandocfilters==1.5.0
parso==0.8.3
pickleshare==0.7.5
Pillow==9.0.0
pipx==1.0.0
platformdirs==2.5.1
plotly==5.5.0
pluggy==1.0.0
pre-commit==2.17.0
progressbar2==4.0.0
prometheus-client==0.12.0
prompt-toolkit==3.0.24
protobuf==3.19.1
protoc-gen-swagger==0.1.0
psutil==5.9.1
py==1.11.0
pyansys-sphinx-theme==0.2.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.8.0
pycparser==2.21
pydata-sphinx-theme==0.9.0
pyflakes==2.3.1
Pygments==2.11.2
pyiges==0.2.1
pymongo==3.12.3
pypandoc==1.7.2
pyparsing==3.0.8
pyrsistent==0.18.1
pytest==7.0.1
pytest-cov==3.0.0
pytest-repeat==0.9.1
pytest-sphinx==0.3.1
python-dateutil==2.8.2
python-jsonrpc-server==0.3.4
python-utils==3.3.3
pythreejs==2.3.0
pytz==2021.3
-e git+https://github.com/germa89/pyvista.git@807fa2a83199e05364eb0966b32dcf3b90b5631d#egg=pyvista
pywin32==303
pywinpty==1.1.6
PyYAML==5.4.1
pyzmq==22.3.0
qtconsole==5.2.2
QtPy==2.0.0
requests==2.27.1
rsa==4.8
rstcheck==3.3.1
scipy==1.8.0
scooby==0.5.12
Send2Trash==1.8.0
six==1.16.0
sniffio==1.2.0
snooty-lextudio==1.12.0
snowballstemmer==2.2.0
soupsieve==2.3.2.post1
Sphinx==4.4.0
sphinx-autobuild==2021.3.14
sphinx-autodoc-typehints==1.16.0
sphinx-copybutton==0.4.0
sphinx-gallery==0.10.1
txaio==21.2.1
typing_extensions==4.0.1
uritemplate==4.1.1
urllib3==1.26.8
userpath==1.8.0
virtualenv==20.13.2
vtk==9.0.3
watchdog==1.0.2
wcwidth==0.2.5
webencodings==0.5.1
websocket-client==1.2.3
widgetsnbextension==3.5.2
wincertstore==0.2
wslink==1.3.1
yarl==1.7.2
zipp==3.7.0
zope.interface==5.4.0
germa89 commented 2 years ago

Pinging @dts12263 I believe this is probably due to the docker image lacking some file?

Pinging @FredAns @mikerife for visibility.

mikerife commented 2 years ago

Hi @germa89 @FredAns that should return a blank - that Inquire function is returning the result file name used in the last File command; which has not yet been issued. Mike

germa89 commented 2 years ago

I would expect that after the solve it should return the newly created RST file name.

Ok. Then I will update the unit test and check again. Thank you Mike!

germa89 commented 2 years ago

Mmmhh...

It does not work... I ran this again and with the debugger I did:

(Pdb) mapdl.post1()
*** MAPDL - ENGINEERING ANALYSIS SYSTEM  RELEASE 2022 R2          22.2BETA ***
 Ansys Mechanical Enterprise
 00000000  VERSION=LINUX x64     21:00:16  AUG 21, 2022 CP=     23.537

 ** WARNING: PRE-RELEASE VERSION OF MAPDL 22.2BETA
  ANSYS,INC TESTING IS NOT COMPLETE - CHECK RESULTS CAREFULLY **

          ***** MAPDL RESULTS INTERPRETATION (POST1) *****
(Pdb) mapdl.set('last')
USE LAST SUBSTEP ON RESULT FILE  FOR LOAD CASE 0

 SET COMMAND GOT LOAD STEP=     1  SUBSTEP=     1  CUMULATIVE ITERATION=     1
   TIME/FREQUENCY=  1.0000
 TITLE=
(Pdb) mapdl.reswrite('new_rst')
PUT THIS LOAD CASE ON THE RESULT FILE new_rst.rst
  AS RESULT SET     1 (LOAD STEP     1 SUBSTEP     1 TIME=  1.0000    )
(Pdb) mapdl.file('new_rst.rst')
DATA FILE CHANGED TO FILE= new_rst.rst
(Pdb) mapdl.result_file  # Prints None

But still mapdl.result_file is None.

germa89 commented 2 years ago

Any idea @mikerife ??

mikerife commented 2 years ago

@germa89 Still waiting on internal IT to get me on the Docker group. Works for me on non-Docker...

Capture

germa89 commented 2 years ago

Conclusion of this issue.

The mapdl.inquire does not return a name until you enter in mapdl.post1. So the solution will be:

mapdl.post1()
mapdl.inquire("","RSTFILE")