I have a wrote a python script to change the properties of spring connections (stiffness and damping) after every time step of my earthquake loading in Ansys WB. I want the script to run after each time step and based on the completed time step for next time step the properties of the spring should changed based on the conditions I have provided in the script. I noticed my script is not interacting the way I wanted. Script I am using is attached and any help is highly appreciated.
model=ExtAPI.DataModel.Project.Model
analysis=model.Analyses[0]
solution=analysis.Solution
# Defining lists for stiffness and damping to be used
damp = [Quantity(16.5,"N sec/mm"),Quantity(816,"N sec/mm"),Quantity(1666,"N sec/mm"),Quantity(2203,"N sec/mm"),Quantity(0,"N sec/mm")]
stiff = [Quantity(33,"N/mm"),Quantity(833,"N/mm"),Quantity(2000,"N/mm"),Quantity(3333,"N/mm"),Quantity(25000,"N/mm")]
# Accessing Springs
s3 = ExtAPI.DataModel.GetObjectsByName("s_third")[0]
s2 = ExtAPI.DataModel.GetObjectsByName("s_second")[0]
s1 = ExtAPI.DataModel.GetObjectsByName("s_first")[0]
# Accessing the stiffness and damping of the springs
damp1 = s1.LongitudinalDamping
stiff1 = s1.LongitudinalStiffness
damp2 = s2.LongitudinalDamping
stiff2 = s2.LongitudinalStiffness
damp3 = s3.LongitudinalDamping
stiff3 = s3.LongitudinalStiffness
dis = ExtAPI.DataModel.GetObjectsByName("Displacement")
# Accessing the results to be traced
deformationL3 = DataModel.GetObjectsByName("deformL3")
deformationL2 = DataModel.GetObjectsByName("deformL2")
deformationL1 = DataModel.GetObjectsByName("deformL1")
for i in dis:
if deformationL3 <= -40:
damp3 = damp[3]
stiff3 = stiff[3]
elif -40 < deformationL3 <= -20:
damp3 = damp[2]
stiff3 = stiff[2]
elif -20 < deformationL2 < 0:
damp3 = damp[1]
stiff3 = stiff[1]
elif 0 <deformationL3 < 20:
damp3 = damp[1]
stiff3 = stiff[1]
elif 20 <= deformationL3 < 40:
damp3 = damp[2]
stiff3 = stiff[2]
elif deformationL3 >= 40:
damp3 = damp[3]
stiff3 = stiff[3]
elif deformationL3 == 0:
damp3 = damp[0]
stiff3 = stiff[0]
#Level2 spring
if deformationL2 <= -40:
damp2 = damp[3]
stiff2 = stiff[3]
elif -40 < deformationL2 <= -20:
damp2 = damp[2]
stiff2 = stiff[2]
elif -20 < deformationL2 < 0:
damp2 = damp[1]
stiff2 = stiff[1]
elif 0 <deformationL2 < 20:
damp2 = damp[1]
stiff2 = stiff[1]
elif 20 <= deformationL2 < 40:
damp2 = damp[2]
stiff2 = stiff[2]
elif deformationL2 >= 40:
damp2 = damp[3]
stiff2 = stiff[3]
elif deformationL2 == 0:
damp2 = damp[0]
stiff2 = stiff[0]
# Level 1 spring
if deformationL1 <= -40:
damp1 = damp[3]
stiff1 = stiff[3]
elif -40 < deformationL1 <= -20:
damp1 = damp[2]
stiff1 = stiff[2]
elif -20 < deformationL1 < 0:
damp1 = damp[1]
stiff1 = stiff[1]
elif 0 <deformationL1 < 20:
damp1 = damp[1]
stiff1 = stiff[1]
elif 20 <= deformationL1 < 40:
damp1 = damp[2]
stiff1 = stiff[2]
elif deformationL1 >= 40:
damp1 = damp[3]
stiff1 = stiff[3]
elif deformationL1 == 0:
damp1 = damp[0]
stiff1 = stiff[0]
Best regards