Viscous Damper example works in tcl but not in python

Forum for asking and answering questions related to use of the OpenSeesPy module

Moderators: silvia, selimgunay, Moderators

Post Reply
SaeedT
Posts: 7
Joined: Fri Dec 03, 2021 3:59 pm

Viscous Damper example works in tcl but not in python

Post by SaeedT » Sat Jul 08, 2023 6:26 pm

Hello Everyone,
There is tcl viscous damper example provided by OpenSees at: https://opensees.berkeley.edu/wiki/inde ... us_Dampers
Using this code, I prepared a one bay model which is a chevron with one viscous damper mounted on one diagonal only. It worked. Then I converted the data to Python version trying to use OpenSeesPy. Unfortunately, it did not work. I used the same ground motion that is used in the above link, where the viscous damper example in tcl is provided by OpenSees, which is TakY.th. Therefore, I do not include the ground motion file here. I appreciate if the reason for failure can be pointed out. Also, it would be very helpful if a python verification for a viscous damper example could be provided. I have debugged both python and tcl code in VS Code and Komodo IDEs. Since the tcl code works, there is no need to include it here. But the python data is as follows :
# please change the folder address per your system and download the ground motion file, TakY.th in that folder in order to run.)
# The tcl version of this data works to the end. This code fails on the Analyze command with error code: analyze failed, returned: -3 error flag
# The data is originally prepared in Etabs, then converted to OpenSees. The comments on nodes, etc. are related to that and should be ignored here.
import openseespy.opensees as os
import vfo.vfo as vfo
import matplotlib.pyplot as plt
import numpy as np
import math
import os as osw
Model = 'SDOF1'
nModes = 5
plot_node = 61
ele_number = 64
g = 386.2
pi = 3.1415927
E_s = 29000.
v = 0.3 # Poisson's ratio
G_s = float(E_s / 2 / (1 + v)) # Shear modulus

os.wipe()
os.model('basic', '-ndm', 3, '-ndf', 6)
os.node(69, 432, 0, 120, '-mass', 2.184143, 2.184143, 0, 0, 0, 41616.427) # Story Story1, Point 2
os.node(67, 432, 0, 120, '-mass', 0, 0, 0.170248, 0.005, 0.005, 0.005) # Story Story1, Point 4
os.node(65, 288, 0, 120, '-mass', 0, 0, 0.002056, 0, 0, 0) # Story Story1, Point 833
os.node(63, 576, 0, 120, '-mass', 0, 0, 0.002056, 0, 0, 0) # Story Story1, Point 839
os.node(61, 324, 0, 120, '-mass', 0, 0, 0.001631, 0, 0, 0) # Story Story1, Point 3
os.node(59, 360, 0, 120, '-mass', 0, 0, 0.001631, 0, 0, 0) # Story Story1, Point 14
os.node(57, 396, 0, 120, '-mass', 0, 0, 0.001631, 0, 0, 0) # Story Story1, Point 5
os.node(55, 468, 0, 120, '-mass', 0, 0, 0.001631, 0, 0, 0) # Story Story1, Point 26
os.node(53, 504, 0, 120, '-mass', 0, 0, 0.001631, 0, 0, 0) # Story Story1, Point 19
os.node(51, 540, 0, 120, '-mass', 0, 0, 0.001631, 0, 0, 0) # Story Story1, Point 27
os.node(3, 288, 0, 0, '-mass', 0.001253, 0.001253, 0.001253, 0.005, 0.005, 0.005) # Story Base, Point 833
os.node(1, 576, 0, 0, '-mass', 0.003178, 0.003178, 0.003178, 0, 0, 0) # Story Base, Point 839

os.fix(65, 0, 1, 0, 1, 0, 0) # Story: Story1, Point: 833
os.fix(63, 0, 1, 0, 1, 0, 0) # Story: Story1, Point: 839
os.fix(3, 1, 1, 1, 0, 0, 0) # Story: Base, Point: 833
os.fix(1, 1, 1, 1, 0, 0, 0) # Story: Base, Point: 839

# Story: Story1, Point: 2
os.rigidDiaphragm(3, 69 , 67, 65, 63, 61, 59, 57, 55, 53, 51)

os.fix(69, 0, 1, 1, 1, 1, 0) # Story: Story1, Node: 69

os.geomTransf('Linear', 0, 0, 1, 0)
os.geomTransf('Linear', 1, 0, 1, 0)
os.geomTransf('Linear', 2, 0, -1, 0)
os.geomTransf('Linear', 3, -1, 0, 0)

# os.section('Elastic', secTag, E_mod, A, Iz, Iy, G_mod, Jxx, alphaY=None, alphaZ=None)
os.section('Elastic', 1, 29000, 28.2, 833, 270, 11154, 6.8, 7, 22)
os.section('Elastic', 2, 29000, 113.51, 1526, 4037, 11154, 5884, 94.6, 94.6)
os.section('Elastic', 3, 29000, 61.8, 2140, 664, 11154, 64.7, 17.35, 48.6)

# Format: os.element('elasticBeamColumn', eleTag, *eleNodes, secTag, transfTag, <'-releasey', releaseCode>, <'-releasez', releaseCode>)
os.element('elasticBeamColumn', 3, 1, 67, 3, 1, '-releasez', 3) # Story1, D1
os.element('elasticBeamColumn', 4, 65, 61, 2, 2, '-releasez', 1) # Story1, B43
os.element('elasticBeamColumn', 5, 61, 59, 2, 2) # Story1, B44
os.element('elasticBeamColumn', 6, 59, 57, 2, 2) # Story1, B45
os.element('elasticBeamColumn', 7, 57, 67, 2, 2) # Story1, B46
os.element('elasticBeamColumn', 8, 67, 55, 2, 2) # Story1, B47
os.element('elasticBeamColumn', 9, 55, 53, 2, 2) # Story1, B48
os.element('elasticBeamColumn', 10, 53, 51, 2, 2) # Story1, B49
os.element('elasticBeamColumn', 11, 51, 63, 2, 2) # Story1, B50
os.element('elasticBeamColumn', 1, 3, 65, 3, 3) # Story1, C14
os.element('elasticBeamColumn', 2, 1, 63, 3, 3) # Story1, C20

print("the model is built.")
# render the model after defining all the nodes and elements
vfo.plot_model()

os.constraints('Transformation')
Lambda = os.eigen('-genBandArpack', nModes)
periods = [2 * math.pi / math.sqrt(eigenvalue) for eigenvalue in Lambda]

Omega = Lambda[0] ** 0.5
xDamp = 0.03 # 3% damping ratio
beta_k_comm = 2 * (xDamp / Omega)
os.rayleigh(0.0, 0.0, 0.0, beta_k_comm)
print("Rayleigh damping specified.")
os.uniaxialMaterial('ViscousDamper', 1, 5000, 200, 0.2)
os.element('twoNodeLink', 69, 67, 3, '-mat', 1, '-dir', 1) # K1 in DAMPER

vfo.plot_model()

gmFolder = 'C:\_OpenSees\DRS-SDOF\OpenSeesData'
record = gmFolder + '\\' + "TakY.th"
GM_fact = g
time_series_tag = 100
npts = 4096
dt = 0.01
os.timeSeries('Path', time_series_tag, '-dt', dt, '-filePath', record, '-factor', GM_fact, '-startTime', 0.0)
print("Ground motion loaded:"+record)
GM_direction = 1
pattern_tag = 10
os.pattern('UniformExcitation', pattern_tag, GM_direction, '-accel', time_series_tag)
os.wipeAnalysis()
os.constraints('Transformation')
os.numberer('RCM')
os.system('UmfPack')
os.test('EnergyIncr', 1e-10, 100)
os.algorithm('KrylovNewton')
os.integrator('Newmark', 0.5, 0.25)
os.analysis('Transient')
os.analyze(10*npts, dt/10)

print("done!")
os.wipe()

mhscott
Posts: 874
Joined: Tue Jul 06, 2004 3:38 pm
Location: Corvallis, Oregon USA
Contact:

Re: Viscous Damper example works in tcl but not in python

Post by mhscott » Sun Jul 09, 2023 5:06 am

What version of OpenSeesPy are you using? Make sure you use the latest as there were some minor updates in the damper materials.

SaeedT
Posts: 7
Joined: Fri Dec 03, 2021 3:59 pm

Re: Viscous Damper example works in tcl but not in python

Post by SaeedT » Sun Jul 09, 2023 5:28 pm

Thank you for your quick response and valuable information. After upgrading to the latest version of OpenSeesPy, it worked.

Post Reply