Using mapdl.input() with the new gRPC sometimes crashes APDL
See original GitHub issueI’m using pymapdl to automate a large number of FE simulations which involves creating a mesh by defining nodes and elements in input files. The input files are passed on to APDL using the mapdl.input()
function.
(I’m using input files because the overhead added by the mapdl.n()
and mapdl.e()
functions is too big for large numbers of nodes and elements)
This works fine most of the time, but sometimes the mapdl.input()
crashes APDL when using the new gRPC interface over network.
By ‘sometimes’ I mean that the crash can be reproduced quite consistently but does not always happen at the same time.
The following code aims to provide a minimum example that reliably triggers the crash on my machine:
from ansys.mapdl import core as pymapdl
def create_dummy_file(size):
# create some dummy files with lots of nodes
with open('nodes.win','w') as f:
f.write('n,1, 0, 0, 0\n')
f.write('n,2, 1, 0, 0\n')
f.write('n,3, 0, 1, 0\n')
f.writelines([f'n,{i},{i},0,0\n' for i in range(4,size+1)])
create_dummy_file(20000)
# connect to remote ansys APDL
mapdl = pymapdl.Mapdl(ip='<your-ip-here>', port=50052, request_instance=True,
log_level='DEBUG')
for i in range(500):
print(i)
mapdl.finish()
mapdl.clear()
mapdl.prep7()
mapdl.et(1, "SHELL157")
# send nodes file to remote ansys server for execution
mapdl.input('nodes.win')
mapdl.e(1,2,3,3)
# -> eventually crashes with Exception MapdlExitedError: MAPDL server connection terminated
First , I start the APDL gRPC server by start "MAPDL" "%ANSYS211_DIR%\bin\winx64\ANSYS211.exe" -port 50052 -grpc
.
Then, I run the above code which first creates a dummy nodes file and repeatedly sends that on to APDL using the gRPC interface. This works well for a while, but eventually (in my case at i = 85
though it can also take longer) APDL will crash with the following error:
On the python side, I see the following exception (caused by the server shutting down):
Some things I noticed:
- The error only happens when using the actual IP address of the
gRPC
server. When I’m working on the same machine as the APDL instance and I uselocalhost
or127.0.0.1
everything works fine. - The ‘frequency’ of the crash (i.e. at what point the crash occurs) seems to correlate with the size of the nodes file. For small sizes it rarely happens, while with a large file it’s pretty much guaranteed to happen.
- The APDL error log (
file0.err
) contains the following (nothing useful, I guess):
/COM,ANSYS RELEASE 2021 R1 BUILD 21.1 UP20201109 10:15:26
*** WARNING *** CP = 0.438 TIME= 10:15:33
Altering the abort level key is not recommended.
file1.err
is empty.
- The file
fort.39
mentioned in the APDL error message exists and contains the following:
NODE 19704 KCS= 0 X,Y,Z= 19704. 0.0000 0.0000
(the node index is different for repeated runs)
Some information about the version I’m running:
- ANSYS2021
- ansys-mapdl-core version: 0.58.3
Unrelated to the actual issue I noticed that the mapdl.input()
function only uploads the local input file to the server if no file with the same name exists in the Ansys working directory on the server. This can lead to problems since when changing the local file it won’t be uploaded again automatically.
I would suggest taking the timestamp of the files into account (if its possible to obtain that from the server side) or at least add a note to the documentation of the mapdl.input()
function.
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (8 by maintainers)
Awesome! I really appreciate the feedback. Please let me know either here or at my ansys email (alexander.kaszynski@ansys.com) if you have anything else to say.
Dear Alex,
Thank you so much for your continuous support, it’s really stuff like this that makes PyAnsys even greater! I am happy to tell you that I have adapted my code to the suggested methods now, and it’s working absolutely fine. looking forward for the 2021R2 update!