question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using mapdl.input() with the new gRPC sometimes crashes APDL

See original GitHub issue

I’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: mapdl_failure

On the python side, I see the following exception (caused by the server shutting down): mapdl_exception

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 use localhost or 127.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:closed
  • Created 2 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
akaszynskicommented, Apr 8, 2021

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!

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.

0reactions
Ahmed-Zeidcommented, Apr 7, 2021

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multi input model crashes TRITON server without errors #14
Description Using a multi input DALI model the TRITON server crashes when sending an inference request from a python client.
Read more >
Mechanical APDL crashes with “SIG$ILL” during solving
Hi, everytime I try to solve mechanical APDL, it crashes. In ... If so try putting "-blas intel" on the MAPDL command line...
Read more >
APDL crashes: How to get rid of it? : r/ANSYS - Reddit
The /BATCH command must be the first line of input. ... seeing that you're using a rather new AMD processor with a rather...
Read more >
How to avoid ANSYS APDL from shutting automatically ...
Hi All,. I am simulating a structure using electrostatic analysis but whenever i execute the solve command in the ANSYS APDL, it automatically...
Read more >
Ansys APDL crashes by MATLAB - MathWorks
I am trying to run Ansys APDL through MATLAB by the following command: system('"c:\Program Files\ANSYS Inc\v145\ANSYS\bin\winx64\ansys145" -b -i ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found