Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.
General Mechanical

General Mechanical

Topics related to Mechanical Enterprise, Motion, Additive Print and more.

Memory Leak PyMapdl

    • Luca Dannemann
      Subscriber

      Hello everyone, 
      does anyone have experience with simulating in a loop? I am running many (>1000) simple simulations within an optimization algorithm. I use PyMapdl for this. With each simulation the required RAM in Python increases. If I do not run the simulations, the problem does not occur. Enclosed is a highly simplified Psyeudocode where the problem also occurs. Even starting and closing Ansys in each run does not solve the problem (apart from a considerable increase in runtime).

      import os
      from ansys.mapdl.core import launch_mapdl
      path = os.path.abspath(__file__)
      directory = os.path.dirname(path)
      temp_dir = os.path.join(directory, 'temp_ansys')
      if not os.path.exists(temp_dir):
          os.makedirs(temp_dir)
      mapdl = launch_mapdl(nproc=4,run_location=temp_dir, override=True)

      def calculate_energy():
          mapdl.clear()
          mapdl.prep7()
          mapdl.blc4(0, 0, 1000, 1000)
          mapdl.blc4(1000, 0, 1000, 1000)
          mapdl.aglue('ALL')
          # BC
          mapdl.ksel("S", "LOC", "X", 0)
          mapdl.ksel("A", "LOC", "X", 1000)
          mapdl.ksel("R", "LOC", "Y", 0)
          mapdl.dk("ALL", 'UX', 0)
          mapdl.dk("ALL", "UY", 0)  
          mapdl.allsel()
          mapdl.clear()

          return 1


      for i in range(0,1000):
          a = calculate_energy()

       

    • mjmiddle
      Ansys Employee

      Try posting over:

      https://discuss.ansys.com

    • ErKo
      Ansys Employee

      Our colleagues are helping :

      https://github.com/ansys/pymapdl/discussions/3041

       

      Closing here

      Erik

Viewing 2 reply threads
  • The topic ‘Memory Leak PyMapdl’ is closed to new replies.
[bingo_chatbox]