TAGGED: mechanical-apdl, PyMAPDL
-
-
February 13, 2025 at 3:00 pm
nils-erik.sanhen
SubscriberHi 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:- Use another command to reach this aim?
- Change something in the defintion of the existing commands?
- Combine all load steps into a single file?
- 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") -
February 14, 2025 at 3:24 pm
mrife
Ansys EmployeeHi 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
Â
-
- You must be logged in to reply to this topic.
-
2137
-
918
-
599
-
591
-
483
© 2025 Copyright ANSYS, Inc. All rights reserved.