ansys / pydyna

Python interface to the LS-DYNA solver
https://dyna.docs.pyansys.com
MIT License
39 stars 9 forks source link

Cannot get "ball_plate_solver.py" example to run #459

Open jacovanniek opened 6 months ago

jacovanniek commented 6 months ago

πŸ” Before submitting the issue

🐞 Description of the bug

I am trying to get started with PyDyna and have managed to run the ball_plate.py "pre" example succesfully. However, when running the "ball_plate_solver.py" script (https://github.com/ansys/pydyna/blob/main/examples/solver/ball_plate_solver.py),

import ansys.dyna.core.solver as solver

hostname = "localhost"
port = "5000"
dyna=solver.DynaSolver(hostname,port)           # connect to the container
dyna.push("./output/ball_plate.k")                            # push an input file
dyna.start(4)                                   # start 4 ranks of mppdyna
dyna.run("i=ball_plate.k memory=10m ncycle=20000")   # begin execution

I get this error: "CRITICAL:root:Can not connect to Solver Server".

If I modify ball_plate_solver.py slightly and run it:

import ansys.dyna.core.solver as solver
from ansys.dyna.core.solver.launcher import launch_dyna

hostname = "localhost"
port = "5000"
dyna=launch_dyna(ip = hostname,port = port)            # connect to the container
dyna.push("./output/ball_plate.k")                            # push an input file
dyna.start(4)                                   # start 4 ranks of mppdyna
dyna.run("i=ball_plate.k memory=10m ncycle=20000")   # begin execution

I get this in the terminal:

grpc Server listening on: localhost:5000 CRITICAL - - dynalogging - handle_exception - Uncaught exception Traceback (most recent call last): File "e:\pydyna\pyDyna\examples\solver\ball_plate_solver.py", line 23, in dyna.run("i=ball_plate.k memory=10m ncycle=20000") # begin execution ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\pydyna\pyDyna\src\ansys\dyna\core\solver\dynasolver.py", line 415, in run response = self.stub.send_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\Lib\site-packages\grpc_channel.py", line 1181, in call return _end_unary_response_blocking(state, call, False, None) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\Lib\site-packages\grpc_channel.py", line 1006, in _end_unary_response_blocking raise _InactiveRpcError(state) # pytype: disable=not-instantiable ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with: status = StatusCode.UNKNOWN details = "Exception calling application: [Errno 2] No such file or directory: './tmp/g0PJvoBl_g2d'" debug_error_string = "UNKNOWN:Error received from peer {created_time:"2024-06-04T12:37:55.3322125+00:00", grpc_status:2, grpc_message:"Exception calling application: [Errno 2] No such file or directory: \'./tmp/g0PJvoBl_g2d\'"}"

CRITICAL:pydyna_global:Uncaught exception Traceback (most recent call last): File "e:\pydyna\pyDyna\examples\solver\ball_plate_solver.py", line 23, in dyna.run("i=ball_plate.k memory=10m ncycle=20000") # begin execution ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\pydyna\pyDyna\src\ansys\dyna\core\solver\dynasolver.py", line 415, in run response = self.stub.send_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\Lib\site-packages\grpc_channel.py", line 1181, in call return _end_unary_response_blocking(state, call, False, None) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\Lib\site-packages\grpc_channel.py", line 1006, in _end_unary_response_blocking raise _InactiveRpcError(state) # pytype: disable=not-instantiable ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with: status = StatusCode.UNKNOWN details = "Exception calling application: [Errno 2] No such file or directory: './tmp/g0PJvoBl_g2d'" debug_error_string = "UNKNOWN:Error received from peer {created_time:"2024-06-04T12:37:55.3322125+00:00", grpc_status:2, grpc_message:"Exception calling application: [Errno 2] No such file or directory: \'./tmp/g0PJvoBl_g2d\'"}"

πŸ“ Steps to reproduce

  1. Clone and install pyDyna repository
  2. Run "ball_plate.py" pre example
  3. Run "ball_plate_solver.py" example

πŸ’» Which operating system are you using?

Windows

πŸ“€ Which ANSYS version are you using?

2023 R1

🐍 Which Python version are you using?

3.11

πŸ“¦ Installed packages

ansys-api-dyna==0.3.6
ansys-api-platform-instancemanagement==1.1.0
ansys-dpf-core==0.12.2
-e git+https://github.com/pyansys/pyDyna@0a7798c31cdc259ec2a3cac0a29c609aa6e91ccb#egg=ansys_dyna_core
ansys-platform-instancemanagement==1.1.2
cachetools==5.3.3
certifi==2024.6.2
charset-normalizer==3.3.2
colorama==0.4.6
contourpy==1.2.1
cycler==0.12.1
et-xmlfile==1.1.0
fonttools==4.53.0
google-api-core==2.19.0
google-api-python-client==2.131.0
google-auth==2.29.0
google-auth-httplib2==0.2.0
googleapis-common-protos==1.63.1
grpcio==1.64.1
httplib2==0.22.0
idna==3.7
importlib_metadata==7.1.0
kiwisolver==1.4.5
matplotlib==3.9.0
numpy==1.26.4
openpyxl==3.1.3
packaging==24.0
pandas==2.2.2
pillow==10.3.0
platformdirs==4.2.2
pooch==1.8.1
proto-plus==1.23.0
protobuf==3.20.3
psutil==5.9.8
pyasn1==0.6.0
pyasn1_modules==0.4.0
pyparsing==3.1.2
python-dateutil==2.9.0.post0
pytz==2024.1
pyvista==0.43.8
requests==2.32.3
rsa==4.9
scipy==1.13.1
scooby==0.10.0
seaborn==0.13.2
six==1.16.0
tqdm==4.66.4
tzdata==2024.1
uritemplate==4.1.1
urllib3==2.2.1
vtk==9.3.0
zipp==3.19.1
RobPasMue commented 6 months ago

@ansys/pydyna team, some support here?

zhangzhanqun commented 5 months ago

Hi @jacovanniek if there is no pydyna server started in the docker, please try this script, it will start the server locally and run dyna. ball_plate_solver_local.zip please have a try, any suggestions we can have a discussion.

jacovanniek commented 5 months ago

Hi @zhangzhanqun, thank you for the script.

I've run it with the complete path to the input file specified:

import ansys.dyna.core.solver as solver
from ansys.dyna.core.solver import launch_dyna

hostname = "localhost"
port = "5000"
#dyna=solver.DynaSolver(hostname,port)           # connect to the container
dyna = launch_dyna(ip = hostname,port = port)  
# dyna.push("./output/ball_plate.k")                            # push an input file                            # start 4 ranks of mppdyna
dyna.push("E:/pydyna/pyDyna/output/ball_plate.k")  
dyna.start_locally(preset = "SMP", input = "ball_plate.k",nproc=1)   # begin execution

And here is the result:

PS E:\pydyna> & C:/python/python.exe e:/pydyna/pyDyna/examples/solver/ball_plate_solver_local.py "E:\softwareInstalls\ANSYS Inc\v232\ANSYS\bin\winx64\lsdyna_dp.exe" i=ball_plate.k ncup=1 memory=20m > dyna.out 2> dyna.err

Could it be something to do with the Ansys installation path? I've verified that the input file runs normally with LS-Run.

zhangzhanqun commented 5 months ago

Hi @jacovanniek , how about to replace dyna.start_locally(preset = "SMP", input = "ball_plate.k",nproc=1) with dyna.start_locally(preset = "SMP", input = "E:/pydyna/pyDyna/output/ball_plate.k",nproc=1) ?

jacovanniek commented 5 months ago

Hi @zhangzhanqun, same result, unfortunately:

import ansys.dyna.core.solver as solver
from ansys.dyna.core.solver import launch_dyna

hostname = "localhost"
port = "5000"
#dyna=solver.DynaSolver(hostname,port)  # connect to the container
dyna = launch_dyna(ip = hostname,port = port)  
# dyna.push("./output/ball_plate.k") # push an input file 
dyna.push("E:/pydyna/pyDyna/output/ball_plate.k")  
dyna.start_locally(preset = "SMP", input = "E:/pydyna/pyDyna/output/ball_plate.k",nproc=1)   # begin execution

C:/python/python.exe e:/pydyna/pyDyna/examples/solver/ball_plate_solver_local.py "E:\softwareInstalls\ANSYS Inc\v232\ANSYS\bin\winx64\lsdyna_dp.exe" i=E:/pydyna/pyDyna/output/ball_plate.k ncup=1 memory=20m > dyna.out 2> dyna.err

zhangzhanqun commented 5 months ago

image this is my outputted message, do you have the message like this?

jacovanniek commented 5 months ago

I don't get the "ansys-pydyna-solver-server.zip" installing, but it is already in the Roaming folder.

image

Here is what i see on my terminal:

image

grpc Server listening on: localhost: 5000 is a good sign.

zhangzhanqun commented 5 months ago

Hi @jacovanniek It seems that no error message outputted, so I guess the dyna is running on the other background process. please check if there are d3plot files outputted in your C:\Users\Jacovn\AppData\Roaming\PYDYNA\ansys-pydyna-solver-server file folder?

jacovanniek commented 5 months ago

Hi @zhangzhanqun here is what's created in the folder:

image

And the contents of the "dyna.err" file:

image

Not sure if this helps? Sorry for only replying to your comment now.

zhangzhanqun commented 5 months ago

Hi @jacovanniek according to your dyna.err file, it seems that the MPI have not been installed in your computer, I remember that there is an option of "intel MPI" when I installed the Ansys, please install the MPI and try again.

PProfizi commented 3 months ago

Hi @zhangzhanqun , hi @jacovanniek, I am having the same issue, I can't seem to make the solver run.

Did you find a solution?

I installed Intel MPI as advised above, and still have an error when trying to :

dyna.start_locally(
    preset="SMP",
    input="D:\\ANSYSDev\\Sandbox\\pydyna\\examples\\Explicit\\output\\ball_plate.k",
    nproc=1
)

I get

CRITICAL -  -  dynalogging - handle_exception - Uncaught exception
Traceback (most recent call last):
  File "D:\ANSYSDev\Sandbox\pydyna\examples\solver\ball_plate_solver.py", line 12, in <module>
    dyna.start_locally(
  File "D:\ANSYSDev\Sandbox\pydyna\src\ansys\dyna\core\solver\dynasolver.py", line 487, in start_locally
    response = self.stub.start_solver_locally(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\temp\pydyna\pydyna\Lib\site-packages\grpc\_channel.py", line 1181, in __call__
    return _end_unary_response_blocking(state, call, False, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\temp\pydyna\pydyna\Lib\site-packages\grpc\_channel.py", line 1006, in _end_unary_response_blocking
    raise _InactiveRpcError(state)  # pytype: disable=not-instantiable
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.UNKNOWN
    details = "Exception calling application: [Errno 22] Invalid argument"
    debug_error_string = "UNKNOWN:Error received from peer  {grpc_message:"Exception calling application: [Errno 22] Invalid argument", grpc_status:2, created_time:"2024-08-07T09:18:38.6981545+00:00"}"
>
CRITICAL:pydyna_global:Uncaught exception
Traceback (most recent call last):
  File "D:\ANSYSDev\Sandbox\pydyna\examples\solver\ball_plate_solver.py", line 12, in <module>
    dyna.start_locally(
  File "D:\ANSYSDev\Sandbox\pydyna\src\ansys\dyna\core\solver\dynasolver.py", line 487, in start_locally
    response = self.stub.start_solver_locally(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\temp\pydyna\pydyna\Lib\site-packages\grpc\_channel.py", line 1181, in __call__
    return _end_unary_response_blocking(state, call, False, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\temp\pydyna\pydyna\Lib\site-packages\grpc\_channel.py", line 1006, in _end_unary_response_blocking
    raise _InactiveRpcError(state)  # pytype: disable=not-instantiable
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.UNKNOWN
    details = "Exception calling application: [Errno 22] Invalid argument"
    debug_error_string = "UNKNOWN:Error received from peer  {grpc_message:"Exception calling application: [Errno 22] Invalid argument", grpc_status:2, created_time:"2024-08-07T09:18:38.6981545+00:00"}"
>
jacovanniek commented 3 months ago

Hi @PProfizi, no, unfortunately not.

I checked my MPI install as @zhangzhanqun suggested and did a clean install of Python but still couldn't get to work. I also consulted with my local Ansys vendor who got it to work on their side, but couldn't get PyDyna running on my machine.

So I ended up just writing my own scripts for post processing Dyna results files. Maybe I'll give it another try when updating to Ansys 2024R2...

kmahajan-cadfem commented 3 months ago

@RobPasMue, these are exactly the issues that have been already reported to the lsdyna team and we had to make many adjustments(only for our case) to the server.py which is not an open source and also not part of this repo as a source code.

RobPasMue commented 3 months ago

Thanks for letting us know @kmahajan-cadfem! @zhangzhanqun @wenhuiuy @kanthadya - can we work on solving this problems and provide proper documentation?