ansys / pymapdl

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

In `mapdl.input_strings(cmd)`, if cmd is very long command, it fails with `MapdlExitedError` #3089

Open DeepLineD opened 1 month ago

DeepLineD commented 1 month ago

๐Ÿ” Before submitting the issue

๐Ÿž Description of the bug

in python, mapdl.input_strings(cmd), cmd is a very long command. If it is not called in the method, it will be executed normally. If it is put in the method, the error "ansys.mapdl.core.errors.MapdlExitedError: MAPDL server connection terminated" will be reported.

๐Ÿ“ Steps to reproduce

1๏ผŒDefine a string containing multiple commands 2๏ผŒThen mapdl calls input_strings(cmd) to execute

๐Ÿ’ป Which operating system are you using?

Windows

๐Ÿ“€ Which ANSYS version are you using?

2023R1

๐Ÿ Which Python version are you using?

3.11

๐Ÿ“ฆ Installed packages

ansys
RobPasMue commented 1 month ago

Transferring to PyMAPDL repository - pinging @ansys/pymapdl-maintainers

germa89 commented 1 month ago

Hi @DeepLineD

The following code runs a very long sequence of APDL commands using mapdl.input_strings:

from ansys.mapdl.core import launch_mapdl

mapdl = launch_mapdl(start_instance=False, port=50082)

cmd = ["/prep7"]

for i in range(1000000):
    cmd.append(f"/com hello {i}")

cmd = "\n".join(cmd)

print(len(cmd))
print("Running...")
out = mapdl.input_strings(cmd)
print(out[-400:])

And it does not fail:

(.venv) โžœ  pymapdl git:(main) python temp.py
17888896
Running...
 999971
 hello 999972
 hello 999973
 hello 999974
 hello 999975
 hello 999976
 hello 999977
 hello 999978
 hello 999979
 hello 999980
 hello 999981
 hello 999982
 hello 999983
 hello 999984
 hello 999985
 hello 999986
 hello 999987
 hello 999988
 hello 999989
 hello 999990
 hello 999991
 hello 999992
 hello 999993
 hello 999994
 hello 999995
 hello 999996
 hello 999997
 hello 999998
 hello 999999

Using MAPDL v24.2 (docker image) and the following configuration:

Details

```text ------------------------------------------------------------------------------- PyAnsys Software and Environment Report ------------------------------------------------------------------------------- Date: Tue May 14 16:59:17 2024 CEST OS : Darwin CPU(s) : 8 Machine : arm64 Architecture : 64bit RAM : 16.0 GiB Environment : Python File system : apfs GPU Vendor : Apple GPU Renderer : Apple M2 GPU Version : 4.1 Metal - 88 Python 3.10.11 (v3.10.11:7d4cc5aa85, Apr 4 2023, 19:05:19) [Clang 13.0.0 (clang-1300.0.29.30)] ansys.mapdl.core : 0.69.dev0 numpy : 1.26.1 platformdirs : 3.11.0 scipy : 1.11.3 grpc : 1.59.0 ansys.api.mapdl.v0 : Version unknown ansys.mapdl.reader : 0.53.0 google.protobuf : 3.20.3 matplotlib : 3.8.3 pyvista : 0.43.4 pyiges : 0.3.1 tqdm : 4.66.1 ansys_sphinx_theme : 0.12.4 ansys.dpf.core : 0.9.0 ansys.dpf.post : Module not found ansys.dpf.gate : 0.4.1 ansys.fluent.core : Module not found ansys.fluent.visualization : Module not found ansys.fluent.parametric : Module not found ansys.grantami.bomanalytics : Module not found ansys.openapi.common : Module not found ansys.platform.instancemanagement : 1.1.2 ansys.seascape : Module not found ansys.tools.report : 0.6.0 ansys.tools.versioning : 0.5.0 pyaedt : Module not found appdirs : 1.4.4 pexpect : 4.8.0 ------------------------------------------------------------------------------- Ansys Environment Report ------------------------------------------------------------------------------- Ansys Installation ****************** No Ansys installations provided Ansys Environment Variables *************************** PYMAPDL_START_INSTANCE False PYMAPDL_PORT 50092 DPF_START_SERVER false DPF_PORT 50056 DPF_DEFAULT_PORT 50056 DPF_DOCKER_IMAGE ghcr.io/ansys/dpf-core:22.2dev ```

Can you provide us with the model and code that fails for you?

germa89 commented 3 weeks ago

Hi @DeepLineD

Do you have any updates?