We have an exciting announcement about badges coming in May 2025. Until then, we will temporarily stop issuing new badges for course completions and certifications. However, all completions will be recorded and fulfilled after May 2025.
General Mechanical

General Mechanical

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

Solve Sequential Load Steps in PyMAPDL Without Creating Separate Solution Files?

    • nils-erik.sanhen
      Subscriber

      Hi everyone,

      I’m working on simulating the behavior of a structure under varying loads in PyMAPDL. After reaching certain load limits, I need to make small adjustments in the definition for subsequent load reactions. I’ve written a loop to generate multiple load steps and would like to solve them one by one, extract data, and use it for the next cycle.

      However, I’m trying to avoid generating 100 separate analysis files. Since the lssolve command doesn’t seem to support restarts according to the documentation, is there a way to:

      1. Use another command to reach this aim?
      2. Change something in the defintion of the existing commands?
      3. Combine all load steps into a single file?
      4. Merge results from individual steps?

      Below is my current code for context.

      Thanks in advance for any help!

      Best regards,
      Nils

      # Number of load steps
      num_loadsteps = 100
      final_time = 1

      # To create displacement and time lists
      time_list = []
      displ_list = []

      for i in range (1,num_loadsteps+1):

          loadstep_time = final_time / (num_loadsteps) * i
          loadstep_time = f"{loadstep_time:.3f}"

          loadstep_displ = Displ / (num_loadsteps) * i 
          loadstep_displ = f"{loadstep_displ:.3f}"

          displ_list.append(loadstep_displ)
          time_list.append(loadstep_time)
          
      mapdl.finish()
      mapdl.slashsolu()
      mapdl.antype("static")  # Static analysis
      # Activate non-linear geometry (optional if large deformations expected)
      mapdl.nlgeom("on")

      # Perform analysis with multiple load steps
      for i in range(1, num_loadsteps + 1):

        
          # Apply displacement for the current load step
          mapdl.d(node="Displ_nodes", lab="UY", value=displ_list[i - 1])
          
          # Set the time for the current load step
          mapdl.time(time = time_list[i - 1])

          # Write the load step definition
          mapdl.lswrite(lsnum=i)  # Store current load step

          # Solve the current load step
          mapdl.lssolve(i,i,1)

          ###
          ###
          #### Do Something here ####
          ###
          ###

      # Save the model
      mapdl.save()

      # Post-process results
      mapdl.post1()
      mapdl.set(1, "LAST")

    • mrife
      Ansys Employee

      Hi nils

      Why use load steps files at all, why not just solve?  Also you can ask PyAnsys scripting questions on the specific GitHub Discussion site for specific the PyAnsys project you are using. For PyMAPDL see here https://github.com/ansys/pymapdl/discussions

       

Viewing 1 reply thread
  • You must be logged in to reply to this topic.