在 Ansys WB 中的地震加载的每个时间步之后,我编写了一个 python 脚本来更改弹簧连接的属性(刚度和阻尼)。我希望脚本在每个时间步之后运行,并且基于下一个时间步的完成时间步,弹簧的属性应该根据我在脚本中提供的条件进行更改。我注意到我的脚本没有按照我想要的方式进行交互。我正在使用的脚本已附加,任何帮助都非常感谢。
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]
此致