ansys / pymapdl

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

Processor is exited after `non_interactive` block when using Corba #1360

Closed rileychall closed 9 months ago

rileychall commented 2 years ago

Before submitting the issue

Description of the bug

When using Corba, the current processor is preserved when entering a non_interactive block, but is not preserved when exiting the block, as if non_interactive is silently appending a FINISH command. This is both unexpected and differs from gRPC, which preserves the current processor throughout. This leads to confusing instances of the [command] is not a recognized BEGIN command... error.

Steps To Reproduce

from ansys.mapdl.core import launch_mapdl

mapdl = launch_mapdl(mode="corba")

mapdl.prep7()
print(mapdl.parameters.routine)
with mapdl.non_interactive:
    mapdl.n(1)
print(mapdl.parameters.routine)

This code outputs

PREP7
Begin level

However, this code behaves as expected when run through gRPC (launch_mapdl(mode="grpc")), outputting

PREP7
PREP7

Which Operating System are you using?

Windows

Which Python version are you using?

3.8

PyMAPDL Report

-------------------------------------------------------------------------------

PyMAPDL Software and Environment Report

Packages Requirements
*********************

Core packages
-------------
ansys.mapdl.core    : 0.63.1
numpy               : 1.23.1
appdirs             : 1.4.4
scipy               : 1.8.1
grpc                : Package not found
ansys.api.mapdl.v0  : Package not found
ansys.mapdl.reader  : 0.51.14
google.protobuf     : Package not found

Optional packages
-----------------
matplotlib          : 3.5.2
pyvista             : 0.35.1
pyiges              : 0.2.1
tqdm                : 4.52.0
ansys_corba         : 0.1.1

Ansys Installation
******************
Version   Location
------------------
222       C:\Program Files\ANSYS INC\v222

Ansys Environment Variables
***************************
ANSYSLMD_LICENSE_FILE          1055@egr-services3.rams.adp.vcu.edu
ANSYS_SYSDIR                   winx64
ANSYS_SYSDIR32                 win32
CADOE_LIBDIR222                C:\Program Files\ANSYS Inc\v222\CommonFiles\Language\en-us

Installed packages

aiohttp==3.8.1
aiosignal==1.2.0
ansys-api-mapdl==0.5.1
ansys-api-platform-instancemanagement==1.0.0b3
ansys-corba==0.1.1
ansys-mapdl-core==0.63.1
ansys-mapdl-reader==0.51.14
ansys-platform-instancemanagement==1.0.2
appdirs==1.4.4
async-timeout==4.0.2
attrs==21.4.0
bleach==3.2.1
charset-normalizer==2.1.0
colorama==0.4.4
cycler==0.11.0
docutils==0.16
fonttools==4.34.4
frozenlist==1.3.0
geomdl==5.3.1
googleapis-common-protos==1.56.4
grpcio==1.47.0
idna==3.3
imageio==2.19.3
importlib-metadata==4.12.0
keyring==21.5.0
kiwisolver==1.4.3
line-profiler==3.5.1
loguru @ file:///D:/bld/loguru_1649443371013/work
matplotlib==3.5.2
multidict==6.0.2
numpy @ file:///D:/bld/numpy_1657483969318/work
packaging==20.4
pandas @ file:///D:/bld/pandas_1656001298215/work
Pillow==9.2.0
pkginfo==1.6.1
protobuf==3.20.1
protoc-gen-swagger==0.1.0
Pygments==2.7.2
pyiges==0.2.1
pyparsing==2.4.7
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1626286286081/work
pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1647961439546/work
pyvista==0.35.1
pywin32-ctypes==0.2.0
readme-renderer==28.0
requests-toolbelt==0.9.1
rfc3986==1.4.0
scipy==1.8.1
scooby==0.5.12
six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work
tqdm==4.52.0
twine==3.2.0
vtk==9.1.0
webencodings==0.5.1
win32-setctime @ file:///home/conda/feedstock_root/build_artifacts/win32_setctime_1642883564726/work
wslink==1.6.6
yarl==1.7.2
zipp==3.8.1
akaszynski commented 2 years ago

Unable to reproduce this error on Ansys 2022R2 with ansys-mapdl-core==0.63.1 on Linux:

from ansys.mapdl.core import launch_mapdl

mapdl = launch_mapdl(mode="corba")

mapdl.prep7()
print(mapdl.parameters.routine)
with mapdl.non_interactive:
    mapdl.n(1)
print(mapdl.parameters.routine)
/home/akaszyns/source/pymapdl/src/ansys/mapdl/core/launcher.py:1566: UserWarning: CORBA AAS mode not recommended in MAPDL 2021R1 or newer.
Recommend using gRPC mode instead.
  warnings.warn(
PREP7
PREP7
akaszynski commented 2 years ago

@mikerife, could you please attempt to reproduce this error Windows?

mikerife commented 2 years ago

Hi @akaszynski I am unable to test this - MAPDL seems to start but I get the following message:

MapdlRuntimeError: Unable to connect to APDL server

And there is something odd (to me) with the MAPDL processes that started up - two instances of ansys222.exe are running (one w/ -aas flag and one without, but with a -rcp flag and value shared with the ansys.exe instance.

Mike

akaszynski commented 2 years ago

I've got another windows machine, debugging once #1378 is done.

germa89 commented 9 months ago

Closing issue because #2517

Please @rileychall use the gRPC interface.