Search found 160 matches

by Prafullamalla
Wed Feb 21, 2024 9:20 pm
Forum: OpenSeesPy
Topic: Cyclic Loading Algorithm
Replies: 0
Views: 9636

Cyclic Loading Algorithm

Code: Select all

# -*- coding: utf-8 -*-
"""
Created on Thu Jul 27 17:22:45 2023

@author: praf_
"""
# height is reguired to calculate drift from displacement. This was for experimental specimen
DriftAmp =     [0.25,-0.25,0.25,-0.25
                 ,0.5,-0.5,0.5,-0.5,
                   0.75,-0.75,0.75,-0.75,
                   1,-1,1,-1,
                   1.5,-1.5,1.5,-1.5,
                    2,-2,2,-2,
                    2.5,-2.5,2.5,-2.5,
                    3,-3, 3,-3,
                    4,-4,5,-0.1] 
       
     
                 
RunCyclic2Converge(controlNode, DriftAmp, fsheight,  controlDOF=1)
# ---------RunCyclic2Converge.tcl----------------------------------------------------------------
# Changed into a procedure from Opensees Web-site. Slightly modified
# to stop analyzing if the loadfactor (pseudo-time) falls below zero.
# Also, it accepts an optional input, "dof" which defaults to 1. 
# this is the dof in the POSITIVE OR NEGATIVE direction of which we push.

# Modified from Vam
import openseespy.opensees as ops
import numpy as np

def RunCyclic2Converge(controlNode, Drift, height,  controlDOF=1):
    # Set some parameters
    # Arrays for plotting
    
    currentDisp = ops.nodeDisp(controlNode, controlDOF)
    
    arr=np.array(Drift)  # converting to array to multipy to calculate Displacement from Drift
    arr =height/100*arr  # Displacement-Drift*height/100 max for each cycle  
    Disp = arr.tolist()
    # ------------------------------------------------------------------------------
    # Main analysis - performed as a number of analyses equal to the number of steps
    # ------------------------------------------------------------------------------
    
    ops.system("BandGeneral")    # Overkill, but may need the pivoting!
    ops.test("NormDispIncr", 1.0e-7, 10, 0)
    ops.numberer("Plain")
    ops.constraints("Penalty",1.0e14, 1.0e14)
    ops.algorithm("Newton")
    ops.analysis("Static")
    
    
    for Dmax in Disp:
        
        if Dmax > 0:
            Dincr = 0.001
        elif Dmax < 0:
            Dincr =-0.001
                
        ops.integrator("DisplacementControl",  controlNode, controlDOF, Dincr)
        ops.analysis("Static")
        if Dincr > 0:
            ok = 0
            while (ok == 0 and currentDisp < Dmax):
                            
                ok = ops.analyze(1)
                if ok != 0:
                    print( " ")
                    print ("Trying Newton with Initial Tangent ..")
                    ops.test("NormDispIncr", 1.0e-6, 2000, 0)
                    ops.algorithm('Newton', '-initial')
                    ok = ops.analyze(1)
                    ops.test("NormDispIncr", 1.0e-6, 6, 2)
                    ops.algorithm('Newton')
                               
                if ok != 0:
                      print( " ")
                      print ("Trying Broyden ..")
                      ops.test("NormDispIncr", 1.0e-6, 2000, 0)
                      ops.algorithm('Broyden', 8)
                      ok = ops.analyze(1)
                      ops.algorithm('Newton')   
                      
                if ok != 0:
                      print( " ")
                      print ("Trying NewtonWithLineSearch ..")
                      ops.algorithm('NewtonLineSearch', 0.8)
                      ok = ops.analyze(1)
                      ops.algorithm('Newton')
                
                currentDisp = ops.nodeDisp(controlNode, controlDOF)
                factorLoad  =ops.getTime()
                #outputs["Load"].append(factorLoad)
                #outputs["Displacement"].append(currentDisp)
                #outputs["Drift"].append(currentDisp/height*100)
          
        elif Dincr < 0 :
            ok = 0
            while (ok == 0 and currentDisp > Dmax):
                  
                ok = ops.analyze(1)
                if ok != 0:
                    print( " ")
                    print ("Trying Newton with Initial Tangent ..")
                    ops.test("NormDispIncr", 1.0e-6, 2000, 0)
                    ops.algorithm('Newton', '-initial')
                    ok = ops.analyze(1)
                    ops.test("NormDispIncr", 1.0e-6, 6, 2)
                    ops.algorithm('Newton')
                               
                if ok != 0:
                      print( " ")
                      print ("Trying Broyden ..")
                      ops.test("NormDispIncr", 1.0e-6, 2000, 0)
                      ops.algorithm('Broyden', 8)
                      ok = ops.analyze(1)
                      ops.algorithm('Newton')   
                      
                if ok != 0:
                      print( " ")
                      print ("Trying NewtonWithLineSearch ..")
                      ops.algorithm('NewtonLineSearch', 0.8)
                      ok = ops.analyze(1)
                      ops.algorithm('Newton')
                      
                   
                currentDisp = ops.nodeDisp(controlNode, controlDOF)
                factorLoad  =ops.getTime()
               # outputs["Load"].append(factorLoad)
               # outputs["Displacement"].append(currentDisp)
               # outputs["Drift"].append(currentDisp/height*100)

    errorFileName = "ncerror.out"
    # output success/failure results to a file
    if errorFileName != "":
        with open(errorFileName, "w") as errorFileID:
            errorFileID.write(str(ok))

    if ok != 0:
        print("DispControl Analysis FAILED")
    else:
        print("DispControl Analysis SUCCESSFUL")


by Prafullamalla
Tue Feb 06, 2024 12:55 am
Forum: OpenSeesPy
Topic: Visous Damper example in python version
Replies: 1
Views: 4718

Re: Visous Damper example in python version

problem solved by updating to newer version of
by Prafullamalla
Tue Jan 16, 2024 11:33 pm
Forum: OpenSees.exe Users
Topic: Acceleration Time series format for Uniform Excitation
Replies: 2
Views: 3818

Re: Acceleration Time series format for Uniform Excitation

Error is clear. timeseries with tag 1 already exist
by Prafullamalla
Tue Jan 16, 2024 10:11 pm
Forum: OpenSeesPy
Topic: Visous Damper example in python version
Replies: 1
Views: 4718

Visous Damper example in python version

There is some error while computing Time period using viscous damper in python and Tcl. I think there is error in tcl version as time period does not changes with addition of viscous damper. Change the viscous damper with # uniaxialmaterial

Code: Select all

# -*- coding: utf-8 -*-
"""
Created on Wed Jan 17 11:07:53 2024

@author: praf_
"""

# -*- coding: utf-8 -*-
"""
Created on Wed Jan 17 11:02:09 2024

@author: praf_malla@hotmail.com
"""


import os
import sys

import openseespy.opensees as ops
import opsvis as opsv
import numpy as np
import matplotlib.pyplot as plt

PathData ='D:/Openseespy/Viscous_Damper_Example'
sys.path.append(PathData)
# Clear memory of past model definitions

ops.wipe()

# Define the model builder
ops.model('basic', '-ndm', 2, '-ndf', 3)

# Create data directory
output_directory = 'Output'
# Check if the directory already exists
if not os.path.exists(output_directory):
    # Create the directory if it doesn't exist
    os.makedirs(output_directory)
else:
    print(f"The directory '{output_directory}' already exists.")


#

# SET UP ----------------------------------------------------------------------------
ops.wipe()						       # clear opensees model
ops.model('basic', '-ndm', 2, '-ndf', 3)	       # 2 dimensions, 3 dof per node
# file mkdir data 				   # create data directory

# define GEOMETRY -------------------------------------------------------------
# nodal coordinates:
# Define geometry
L = 5000.0  # Bay width
h = 3000.0  # Story height

# Define nodal coordinates
ops.node(1, 0.0, 0.0)
ops.node(2, L, 0.0)
ops.node(3, 0.0, h)
ops.node(4, L, h)
ops.node(5, L, h)
# Single point constraints -- Boundary Conditions
ops.fix(1, 1, 1, 1)
ops.fix(2, 1, 1, 1)

# MP constraints
ops.equalDOF(3, 4, 2, 3)  # Shear Beam
# Mass
W = 1000.0  # KN
g = 9810.0  # mm/sec^2
m = W / g
print(m)
# Assign mass
ops.mass(3, 0.5 * m, 0.0, 0.0)
ops.mass(4, 0.5 * m, 0.0, 0.0)

# Define dynamic properties
Tnn = 0.7  # sec (Natural Period)
pi = 3.141592653589793238462643383279502884197

# Columns and Beam Properties
K = (2 * pi / Tnn) ** 2 * m  # KN/mm
print(f"stiffness = {K} ")
E = 200.0  # KN/mm^2
Ic = K * h ** 3 / (24 * E)  # mm^4 (K=24EIc/h^3) Take half of stiffness because of 2 column
Ib = 1e12 * Ic  # mm^4
A = 1e12  # mm^2
print(Ic)

# Damper Properties
Kd = 25.0
Cd = 20.7452
ad = 0.35

# Define ViscousDamper Material
#ops.uniaxialMaterial('ViscousDamper', 1, Kd, Cd, ad)
ops.uniaxialMaterial('Elastic', 1, K)
ops.uniaxialMaterial('Elastic', 2, K*999999)
# Define ELEMENTS -------------------------------------------------------------
# define geometric transformation: performs a linear geometric transformation of beam stiffness and resisting force from the basic system to the global-coordinate system
TransfTag = 1
ops.geomTransf('Linear', TransfTag)

# connectivity:
# Define Elements------------------------------------------------------------
# Columns
ops.element('elasticBeamColumn', 1, 1, 3, A, E, Ic, TransfTag)
ops.element('elasticBeamColumn', 2, 2, 4, A, E, Ic, TransfTag)
# Beam
ops.element('elasticBeamColumn', 3, 3, 4, A, E, Ib, TransfTag)
# Damper
#ops.element('twoNodeLink', 4, 1, 4, '-mat', 1, '-dir', 1)
ops.element('elasticBeamColumn', 4, 1, 5, A, E, Ib, TransfTag)
ops.element('zeroLength', 5, 5, 4, '-mat',1,2,2,'-dir',1,2,3)
print('Model Built')	
print("Eigen analysis before")
lamda1 = ops.eigen('-fullGenLapack', 1)[0]
freq = lamda1**0.5
print("freq = ", freq)
t1 = 2*pi/freq
print(f"T1 = {t1} sec")
by Prafullamalla
Tue Jan 16, 2024 10:07 pm
Forum: OpenSees.exe Users
Topic: No change in time period with addition of viscous damper
Replies: 0
Views: 10243

No change in time period with addition of viscous damper

I used the single bay frame with viscous damper from the example. When I checked the time period with and without viscous damper it is same in tcl version. In python version the time period changes when using viscous damper. Change the uniaxialmaterial with # for viscous damper
wipe all; # clear memory of past model definitions
model BasicBuilder -ndm 2 -ndf 3; # Define the model builder, ndm = #dimension, ndf = #dofs

set L 5000.0
set h 3000.0
node 1 0 0
node 2 $L 0
node 3 0 $h
node 4 $L $h
node 5 $L $h
fix 1 1 1 1
fix 2 1 1 1


set W 1000.0
set g 9810.0
set m [expr $W/$g]
puts "mass = $m "

set Tn 0.7; # sec (Natural Period)
set pi [expr acos(-1.0)];


set K [expr pow(2*$pi/$Tn,2)*$m]; # KN/mm
set E 200.0
set Ic [expr $K*pow($h,3)/(24*$E)];
set Ib [expr 1e12*$Ic]
set A 1e12
puts "STIFFNESS = $K "
set Tstiff [expr 2*$pi*pow($m/$K,0.5)]
puts "Tstiff = $Tstiff "

mass 3 [expr 0.5*$m] 0 0
mass 4 [expr 0.5*$m] 0 0
geomTransf Linear 1
element elasticBeamColumn 1 1 3 $A $E $Ic 1
element elasticBeamColumn 2 2 4 $A $E $Ic 1
element elasticBeamColumn 3 3 4 $A $E $Ib 1
# Damper properties
set Kd 25.
set Cd 20.7452
set ad 0.35
#uniaxialMaterial ViscousDamper 1 $Kd $Cd $ad
uniaxialMaterial Elastic 1 $K
uniaxialMaterial Elastic 2 [expr 9999*$K]
#element twoNodeLink 4 1 3 -mat 1 2 2 -dir 1 2 3

element elasticBeamColumn 4 1 5 $A $E $Ib 1
element zeroLength 5 5 4 -mat 1 2 2 -dir 1 2 3


# set damping based on first eigen mode
set freq [expr [eigen 1]**0.5]
set period [expr 2*$pi/$freq]
puts ("freq",$freq)
puts ("period",$period)
set damp 0.02;
rayleigh [expr 2*$damp*$freq] 0. 0. 0.
by Prafullamalla
Thu May 11, 2023 1:01 am
Forum: OpenSeesPy
Topic: asdconcrete3D material is unknown
Replies: 6
Views: 5890

Re: asdconcrete3D material is unknown

I downgraded to version 3.4.0.7 but it didn't work. Got same error
by Prafullamalla
Sun May 07, 2023 4:52 am
Forum: OpenSeesPy
Topic: asdconcrete3D material is unknown
Replies: 6
Views: 5890

Re: asdconcrete3D material is unknown

Code: Select all

from openseespy import opensees as ops

ops.wipe()
ops.model('basic', '-ndm', 2, '-ndf', 2)
	
# the isotropic material
E = 30000.0
v = 0.2
sig0 = 30.0
	# define a perfect bilinear behavior in tension and compression to record the failure surface
fc = sig0
ec = fc/E
ft = fc/10.0
et = ft/E
ops.nDMaterial('ASDConcrete3D', 1, E, v,
	'-Ce', 0.0, ec, ec+1,
	'-Cs', 0.0, fc, fc,
	'-Cd', 0.0, 0.0, 0.0,
	'-Te', 0.0, et, et+1,
	'-Ts', 0.0, ft, ft,
	'-Td', 0.0, 0.0, 0.0)
by Prafullamalla
Fri Apr 28, 2023 8:08 pm
Forum: OpenSeesPy
Topic: asdconcrete3D material is unknown
Replies: 6
Views: 5890

Re: asdconcrete3D material is unknown

I upgraded to version 3.4.0.8 but still I got WARNING material type ASDConcrete3D is unknown.
by Prafullamalla
Tue Apr 18, 2023 6:08 am
Forum: OpenSeesPy
Topic: asdconcrete3D material is unknown
Replies: 6
Views: 5890

asdconcrete3D material is unknown

Although the material is available in the opensees documentation. But it gives WARNING material type ASDConcrete3D is unknown
by Prafullamalla
Tue Feb 14, 2023 8:29 pm
Forum: OpenSeesPy
Topic: Example Eigenvalue analysis of a three-dimensional frame
Replies: 0
Views: 8777

Example Eigenvalue analysis of a three-dimensional frame

Code: Select all

[code]# -*- coding: utf-8 -*-
"""
Created on Wed Feb 15 10:26:02 2023

@author: praf_malla@hotmail.com
"""
# Seismostruct Example
# EXAMPLE 12 – Eigenvalue analysis of a three-dimensional frame with rigid floor diaphragm
 


import openseespy.opensees as ops
import opsvis as opsv
from math import asin, sqrt
ops.wipe()
ops.model('basic','-ndm',3,'-ndf',6)
ops.node(	1	,	0	,	0	,	0	)
ops.node(	2	,	35	,	0	,	0	)
ops.node(	3	,	70	,	0	,	0	)
ops.node(	4	,	0	,	25	,	0	)
ops.node(	5	,	35	,	25	,	0	)
ops.node(	6	,	70	,	25	,	0	)
ops.node(	7	,	0	,	50	,	0	)
ops.node(	8	,	35	,	50	,	0	)
ops.node(	9	,	70	,	50	,	0	)
ops.node(	10	,	0	,	0	,	13	)
ops.node(	11	,	35	,	0	,	13	)
ops.node(	12	,	70	,	0	,	13	)
ops.node(	13	,	0	,	25	,	13	)
ops.node(	14	,	35	,	25	,	13	)
ops.node(	15	,	70	,	25	,	13	)
ops.node(	16	,	0	,	50	,	13	)
ops.node(	17	,	35	,	50	,	13	)
ops.node(	18	,	70	,	50	,	13	)
ops.node(	19	,	0	,	0	,	26	)
ops.node(	20	,	35	,	0	,	26	)
ops.node(	21	,	70	,	0	,	26	)
ops.node(	22	,	0	,	25	,	26	)
ops.node(	23	,	35	,	25	,	26	)
ops.node(	24	,	70	,	25	,	26	)
ops.node(	25	,	0	,	50	,	26	)
ops.node(	26	,	35	,	50	,	26	)
ops.node(	27	,	70	,	50	,	26	)

ops.fix(	1	,1,1,1,1,1,1)	
ops.fix(	2	,1,1,1,1,1,1)	
ops.fix(	3	,1,1,1,1,1,1)	
ops.fix(	4	,1,1,1,1,1,1)	
ops.fix(	5	,1,1,1,1,1,1)	
ops.fix(	6	,1,1,1,1,1,1)	
ops.fix(	7	,1,1,1,1,1,1)	
ops.fix(	8	,1,1,1,1,1,1)	
ops.fix(	9	,1,1,1,1,1,1)	

# Column 
Ac = 4
Ic = 1.25
Jc = 2*Ic
Ec = 350000
v = 0.3
Gc = 0.5*Ec/(1+v)

ops.section('Elastic',1,Ec,Ac,Ic,Ic,Gc,Jc)
ops.beamIntegration('Legendre',1,1,2)

#ops.geomTransf('Linear',1,1,0,0,'-jntOffset',0,0,0,0,0,-d)
ops.geomTransf('Linear',1,1,0,0)

ops.element('forceBeamColumn'	,	1	,	1	,	10	,1,1)
ops.element('forceBeamColumn'	,	2	,	2	,	11	,1,1)
ops.element('forceBeamColumn'	,	3	,	3	,	12	,1,1)
ops.element('forceBeamColumn'	,	4	,	4	,	13	,1,1)
ops.element('forceBeamColumn'	,	5	,	5	,	14	,1,1)
ops.element('forceBeamColumn'	,	6	,	6	,	15	,1,1)
ops.element('forceBeamColumn'	,	7	,	7	,	16	,1,1)
ops.element('forceBeamColumn'	,	8	,	8	,	17	,1,1)
ops.element('forceBeamColumn'	,	9	,	9	,	18	,1,1)
ops.element('forceBeamColumn'	,	10	,	10	,	19	,1,1)
ops.element('forceBeamColumn'	,	11	,	11	,	20	,1,1)
ops.element('forceBeamColumn'	,	12	,	12	,	21	,1,1)
ops.element('forceBeamColumn'	,	13	,	13	,	22	,1,1)
ops.element('forceBeamColumn'	,	14	,	14	,	23	,1,1)
ops.element('forceBeamColumn'	,	15	,	15	,	24	,1,1)
ops.element('forceBeamColumn'	,	16	,	16	,	25	,1,1)
ops.element('forceBeamColumn'	,	17	,	17	,	26	,1,1)
ops.element('forceBeamColumn'	,	18,		18	,	27	,1,1)

# Beam
Ab = 5
Ib = 2.61
Jb = 2*Ib
Eb = 500000
v = 0.3
Gb = 0.5*Ec/(1+v)

ops.section('Elastic',3,Eb,Ab,Ib,Ib,1000*Gb,Jb)
ops.beamIntegration('Legendre',3,3,2)

# Beam  X direction
ops.geomTransf('Linear',3,0,1,0)
ops.element('forceBeamColumn'	,	19	,	10	,	11	,3,3)
ops.element('forceBeamColumn'	,	20	,	11	,	12	,3,3)
ops.element('forceBeamColumn'	,	21	,	13	,	14	,3,3)
ops.element('forceBeamColumn'	,	22	,	14	,	15	,3,3)
ops.element('forceBeamColumn'	,	23	,	16	,	17	,3,3)
ops.element('forceBeamColumn'	,	24	,	17	,	18	,3,3)

ops.element('forceBeamColumn'	,	31	,	19	,	20	,3,3)
ops.element('forceBeamColumn'	,	32	,	20	,	21	,3,3)
ops.element('forceBeamColumn'	,	33	,	22	,	23	,3,3)
ops.element('forceBeamColumn'	,	34	,	23	,	24	,3,3)
ops.element('forceBeamColumn'	,	35	,	25	,	26	,3,3)
ops.element('forceBeamColumn'	,	36	,	26	,	27	,3,3)

# Beam Y direction
ops.geomTransf('Linear',4,1,0,0)
ops.element('forceBeamColumn'	,	25	,	10	,	13	,4,3)
ops.element('forceBeamColumn'	,	26	,	13	,	16	,4,3)
ops.element('forceBeamColumn'	,	27	,	11	,	14	,4,3)
ops.element('forceBeamColumn'	,	28	,	14	,	17	,4,3)
ops.element('forceBeamColumn'	,	29	,	12	,	15	,4,3)
ops.element('forceBeamColumn'	,	30	,	15	,	18	,4,3)

ops.element('forceBeamColumn'	,	37	,	19	,	22	,4,3)
ops.element('forceBeamColumn'	,	38	,	22	,	25	,4,3)
ops.element('forceBeamColumn'	,	39	,	20	,	23	,4,3)
ops.element('forceBeamColumn'	,	40	,	23	,	26	,4,3)
ops.element('forceBeamColumn'	,	41	,	21	,	24	,4,3)
ops.element('forceBeamColumn'	,	42	,	24	,	27	,4,3)


ops.node(	28	,	38	,	27	,	13	) #CM1
ops.node(	29	,	38	,	27	,	26	) #CM2
ops.fix(28,0,0,1,1,1,0)
ops.fix(29,0,0,1,1,1,0)
ops.rigidDiaphragm(	3,28,	10,11,12,13,14,15,16,17,18			)
ops.rigidDiaphragm(	3,29,	19,20,21,22,23,24,25,26,27			)
# Display Model
m = 6.2112
L1=70
L2=50
mz =0 # m*L1*L2/6 # Rotational mass about vertical

ops.mass(28,6.2112,6.2112,0,0,0,mz)	
ops.mass(29,6.2112,6.2112,0,0,0,mz)	


# calculate eigenvalues & print results     
numEigen = 4
eigenValues = ops.eigen('-fullGenLapack', numEigen)
print(eigenValues)
PI = 2 * asin(1.0)

# Display Model
opsv.plot_model()

# Display specific mode shape
for n in range(numEigen):
    opsv.plot_mode_shape(n+1)

# Modal Participation factors
N = numEigen
ndf = 6 # Nodal degrees of freedom
omega2 = eigenValues
for n in range(N):
   Mn = 0.0
   Ln = 0.0
   for nd in ops.getNodeTags():
      ndMass = ops.nodeMass(nd)
      ndEigen = ops.nodeEigenvector(nd,n+1)
      Ln += ndEigen[0]*ndMass[0] # 0 for X, 1 for Y, 2 for Z excitation
      for dof in range(ndf):
         Mn += (ndEigen[dof]**2)*ndMass[dof]
   Gamman = Ln/Mn
   Tn = 2*3.14159/omega2[n]**0.5
   print(f'Mode {n+1}, Tn = {Tn}, Mn = {Mn}, Gamma = {Gamman}')   

# compute the modal properties
ops.modalProperties("-print", "-file", "ModalReport.txt", "-unorm")     
[/code]
by Prafullamalla
Tue Jan 31, 2023 11:00 pm
Forum: OpenSeesPy
Topic: Fixing boundary condition for zero length section
Replies: 3
Views: 3848

Re: Fixing boundary condition for zero length section

There is problem if I dont restraing Node 3 in global Y direction

Code: Select all

# -*- coding: utf-8 -*-
"""
Created on Fri Jan 20 09:46:58 2023

@author: praf_
"""
import openseespy.opensees as ops
import opsvis as opsv
import numpy as np
import matplotlib.pyplot as plt
from math import asin, sqrt
import os

# Units in kip/in
# column.tcl
# This model is a 2D model

# SET UP ----------------------------------------------------------------------------
ops.wipe()
ops.model('basic', '-ndm', 2, '-ndf', 3); 

# -----------------------------------------------------
# define section geometry
Dcol =24.0; # Column Diameter (in)
LCol =96.0; # column length (in) 
P =147.0 ; # weight (kips)
Weight= P
g =386.22; #[inch/s2]
# calculated parameters
Mass = P/g; # nodal mass

# nodal coordinates:
ops.node(3, 0.0,0.0)
ops.node(1, 0.0,0.0); # node#, X, Y
ops.node(2, 0.0, LCol)


# Single point constraints -- Boundary Conditions
ops.fix (3, 1, 1, 1);
# Fix all degrees of freedom except axial and bending

ops.fix (1,1,0, 0);



# we need to set up parameters that are particular to the model.
IDctrlNode =2; # node where displacement is read for displacement control
IDctrlDOF =1; # degree of freedom of displacement read for displacement control
iSupportNode ="3"; # define support node, if needed.

# Define Column geometry
#-------------------------------------------------------------------
coverSec =0.874; # Column cover to reinforcing steel (in)
numBarsSec =22; # number of longitudinal-reinforcement bars in the column section
dlSec =0.626; # [in] Steel diameter T15.9
PI =3.14;
barAreaSec = PI*dlSec**2/4; #area of longitudinal-reinforcement bars # (in^2)


# MATERIAL parameters
#-------------------------------------------------------------------
IDconcC =1; # material ID tag -- confined core concrete
IDconcU =2; # material ID tag -- unconfined cover concrete
IDreinf =3; # material ID tag -- reinforcement

# Define uniaxial materials
#-------------------------------------------------------------------
# Mander concrete model for confined and unconfined concrete
# characteristics of materials test of Lehman et al. (PEER 98-01)

# confined concrete (core)
#-------------------------
fc =4.496; # [Ksi] CONCRETE Compressive Strength
ec =0.002294; # concrete strain at maximum strength ??????
ecu= 0.008101; # [Ksi] concrete strain at crushing strength ????
Ec =3822.0; # [Ksi]Concrete Elastic Modulus
fct =0.5046; #[Ksi] maximum tensile strength of concrete
et =0.000132; # ultimate tensile strain of concrete
#set beta 0.1; #value defining the exponential curve parameter to define the residual stress

#uniaxialMaterial Concrete04 $matTag $fc $ec $ecu $Ec <$fct $et> <$beta>;
#uniaxialMaterial Concrete04 $IDconcC $fc $ec $ecu $Ec $fct $et;
#uniaxialMaterial Concrete04 $IDconcC [expr -$fc] [expr -$ec] [expr -$ecu] $Ec $fct $et;
ops.uniaxialMaterial ('Concrete04', IDconcC, -fc ,-ec ,-ecu ,Ec ,fct, et);



# unconfined concrete (cover)
#----------------------------
fcU =4.496; # [Ksi] CONCRETE Compressive Strength
ecU =0.002; # concrete strain at maximum strength (#I did not find the experimentation values)
ecuU= 0.0035; # [Ksi] concrete strain at crushing strength (#I did not find the experimentation values)
EcU =3822.0; # [Ksi]Concrete Elastic Modulus
fctU= 0.5046; #[Ksi] maximum tensile strength of concrete
etU =0.000132; # ultimate tensile strain of concrete
#set betaU 0.1; #value defining the exponential curve parameter to define the residual stress

# uniaxialMaterial Concrete04 $matTag $fc $ec $ecu $Ec <$fct $et> <$beta>;
# niaxialMaterial Concrete04 $IDconcU [expr -$fcU] [expr -$ecU] [expr -$ecuU] $EcU $fctU $etU;
ops.uniaxialMaterial ('Concrete04', IDconcU, -fcU, -ecU, -ecuU, EcU, fctU, etU);

IDconcU2 =11
ops.uniaxialMaterial ('Concrete01', IDconcU2, -fcU, -ecU, -fcU*0.99, -ecuU)

# ----------- Reinforcing Steel --------
Es =29000.0 ; # modulus of steel (Ksi)??????
Fy =67.0; # [Ksi] yield stress Lehman et al.2000 (specimen 415.)
Fu= 91.37; #[Ksi] ultimate stress Lehman et al.2000
B =0.01; # strain-hardening ratio (Lehman et al. 2000)
R0 =18.5; # control the transition from elastic to plastic branches
cR1 =0.925; # control the transition from elastic to plastic branches
cR2 =0.15; # control the transition from elastic to plastic branches
#set a1 0.04;
#set a2 1.0;
#set a3 0.04;
#set a4 1.0;

#uniaxialMaterial Steel02 $IDreinf $Fy $Es $B $R0 $cR1 $cR2 $a1 $a2 $a3 $a4;
ops.uniaxialMaterial ('Steel02', IDreinf ,Fy, Es, B, R0, cR1, cR2);

print("materials defined")

#===============================================================Bond-Slip=================================================================
alphaBS= 0.4 ; #alphaBS is a parameter used in the local bond-slip relation and can be taken as 0.4
Pow = (1.0/alphaBS)

#Eq for a model with units (ksi, kips, inches)
#set Sy [expr (((((($dlSec*$Fy*1000.0)/(4000.0*(sqrt($fc*-1000.0))))*((2.0*$alphaBS)+1.0))*pow($Pow,1))*0.1)+0.013)]
Sy =0.08337;
Su = Sy*35.0
b =0.5
R =0.7
bondslipMat= 5

#uniaxialMaterial Bond_SP01 $matTag $Fy $Sy $Fu $Su $b $R
ops.uniaxialMaterial ('Bond_SP01' ,bondslipMat, Fy, Sy, Fu ,Su, b, R)

print ("materials defined ")

#----------------------------------------------------------------
# Generate a circular reinforced concrete section
# with one layer of steel evenly distributed around the perimeter and a confined core.
# confined core.
# by: Michael H. Scott, 2003
# Notes
# The center of the reinforcing bars are placed at the inner radius
# The core concrete ends at the inner radius (same as reinforcing bars)
# The reinforcing bars are all the same size
# The center of the section is at (0,0) in the local axis system
# Zero degrees is along section y-axis
#Following recommendations using uniformly distibutions ratdial disretization shema

ri= 0.0; # inner radius of the section, only for hollow sections
ro = Dcol/2; # overall (outer) radius of the section
nfCoreR =10; # number of radial divisions in the core (number of "rings")
nfCoreT= 20; # number of theta divisions in the core (number of "wedges")
nfCoverR= 1; # number of radial divisions in the cover
nfCoverT= 20; # number of theta divisions in the cover

# Define ELEMENTS & SECTIONS
#----------------------------
ColSecTag =1; # assign a tag number to the column section

# Define the fiber section
#-------------------------
rc = ro-coverSec; # Core radius
bcent= 6.39 ; # expr[$coversec+$Dsec/2]
rb = ro-bcent;

fib_sec_3 = [['section', 'Fiber', 1, '-GJ', 1.0e6],
             ['patch', 'circ', IDconcC, nfCoreT, nfCoreR, 0., 0., ri, rc, 0, 360],
             ['patch', 'circ', IDconcC,  nfCoreT, nfCoverR, 0., 0., rc, ro, 0, 360],
             ['layer', 'circ', IDreinf, numBarsSec, barAreaSec, 0, 0, rc],
             ]


matcolor = ['r', 'lightgrey', 'gold', 'w', 'w', 'w']
opsv.plot_fiber_section(fib_sec_3, matcolor=matcolor)
plt.axis('equal')

ops.section('Fiber', ColSecTag)

# Create the concrete core fibers
ops.patch('circ', IDconcC, nfCoreT, nfCoreR, 0., 0., ri, rc, 0, 360)
ops.patch('circ', IDconcU2,  nfCoreT, nfCoverR, 0., 0., rc, ro, 0, 360)
ops.layer('circ', IDreinf, numBarsSec, barAreaSec, 0, 0, rc)

print ("section geometry defined of Column")
Area=PI/4*Dcol**2
Iy=Iz=PI/64*Dcol**4
Jxx=PI/32*Dcol**4


# Create the concrete core fibers
SecTagBS= 3
ops.section('Fiber', SecTagBS)
ops.patch('circ', IDconcC, nfCoreT, nfCoreR, 0., 0., ri, rc, 0, 360)
ops.patch('circ', IDconcC,  nfCoreT, nfCoverR, 0., 0., rc, ro, 0, 360)
ops.layer('circ', bondslipMat, numBarsSec, barAreaSec, 0, 0, rc)
print ( "section geometry defined of Bond Slip")

#Aggregator
#------------------------
shearsec =4;
TagsecAgg =6;
AreaSec = PI*Dcol**2/4; #gross cross-sectional area (in^2)
G = Ec/2.4;
GA = G*AreaSec;
E_mod=Ec
G_mod=G
#Assign shear to the model of flexure
#------------------------------------

ops.uniaxialMaterial ('Elastic', shearsec, 1e8)
print ("shear defined")

#section Aggregator $TagsecAgg $shearsec Vy -section $ColSecTag
ops.section ('Aggregator', TagsecAgg, shearsec, 'Vy', '-section' ,SecTagBS)

print ("section aggregator defined")


# define geometric transformation
#--------------------------------
#performs a linear geometric transformation of beam stiffness and resisting force
#from the basic system to the global-coordinate system

# Define column elements
# ----------------------
geomTag    = 1
colIntTag  = 1
# Geometry of column elements
#                tag Corotational
ops.geomTransf('Linear', geomTag)

nIP = 3                             # Number of integration points along length of element
# Lobatto integration
ops.beamIntegration('Lobatto', colIntTag, ColSecTag, nIP)
# element connectivity:
eleType = 'forceBeamColumn'                 # accuracy improved by increasing ip or elements
#eleType = 'elasticBeamColumn' 
#eleType = 'nonlinearBeamColumn' 

ops.element(eleType, 1, 1, 2, colIntTag, geomTag)




print ("element nonlinear defined")

######ZeroElement of Bond-Slip
#element zeroLengthSection $EleTag $ibNode $jbNode $SecTagBS
ops.element ('zeroLengthSection' ,2, 3, 1, TagsecAgg ,'-orient' ,0, 1, 0)

# Define gravity loads
#  a parameter for the axial load

# Create a Plain load pattern with a Linear TimeSeries
ops.timeSeries ('Linear', 1)
ops.pattern    ('Plain', 1, 1)

# Create nodal loads at nodes 3 & 4
#    nd  FX,  FY, MZ
ops.load(2, 0.0, -P , 0.0)
# ------------------------------
# End of model generation
# ------------------------------

# ------------------------------
# Start of analysis generation
# ------------------------------
# Gravity Analysis
# Create the system of equation, a sparse solver with partial pivoting
Tol = 1.0e-6
ops.system      ('BandGeneral')
ops.constraints ('Plain')
ops.numberer    ('RCM')
ops.test        ('NormDispIncr', Tol, 10, 3)
ops.algorithm   ('Newton')
ops.integrator  ('LoadControl', 0.1)
ops.analysis    ('Static')
ops.analyze     (10)

#-----maintain constant gravity loads and reset time to zero------
# Set the gravity loads to be constant & reset the time in the domain
ops.loadConst  ('-time', 0.0)
ops.printModel('-node',2)

print ("Model Built")


# Display Model
opsv.plot_model()


print("Pushover Analysis Started!")

# Set some parameters
LateralLoad = 1.0  # Reference lateral load of 1kN
# Set lateral load pattern with a Linear TimeSeries
ops.pattern('Plain', 2, 1)

# Create nodal loads at nodes 3 & 4
#    nd    FX  FY  MZ
ops.load(IDctrlNode, LateralLoad, 0.0, 0.0)

# ----------------------------------------------------
# Start of push over analysis
# ----------------------------------------------------
print("Starting RC column analysis")
maxU = 0.3  # Max displacement
print("Maximum top node displacement", maxU)
# Set some parameters
dU    = 0.002       # Displacement increment
dUMin = 0.002
dUMax = 0.0020

(Tol, MaxIter) = (1.0e-6, 6)      # Tolerance and Maximum iteration (1.0e-12, 10) 
(controlNode, controlDOF) =(2, 1)   # Control node and control DOF
ops.system       ('BandGeneral')
ops.constraints  ('Plain')
ops.numberer     ('RCM')
ops.test         ('NormDispIncr', Tol, MaxIter)
ops.analysis     ('Static');

# Change the integration scheme to be displacement control
#                             node dof init Jd min max
ops.integrator   ('DisplacementControl', controlNode, controlDOF, dU, 1, dUMin,dUMax)
ops.algorithm    ('Newton')

# Set some parameters
currentDisp = ops.nodeDisp(controlNode, controlDOF)
ok          = 0
# Arrays for plotting
Uplot = [0]
LpPlot = [0]
# perform the analysis
Nsteps=int(maxU/dU)

                         # Counter to store data
while (ok == 0 and currentDisp < maxU):
    ops.analyze(1)
    # if the analysis fails try initial tangent iteration
    if ok != 0:
        print("regular newton failed .. lets try an initail stiffness for this step")
        ops.test('NormDispIncr', 1.0e-6, 10,0)
        ops.algorithm('ModifiedNewton', '-initial')
        ok = ops.analyze(1)
        ops.algorithm('Newton')
    currentDisp = ops.nodeDisp(controlNode, controlDOF)
    Uplot.append(currentDisp)
    factorLoad  =ops.getTime()
    LpPlot.append(factorLoad)
    print( "Horizontal load", factorLoad, 'kips,','displacement at control node',currentDisp,'inch')

#P PLOTTING CURVE    
# x axis values
x = Uplot
# corresponding y axis values
y = LpPlot

import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots(figsize=(4, 3))
#plt.ylim(-25,25)
#plt.xlim(-45,45)
ax.plot(x,y)
ax.plot(x,y, color='r', linewidth = 1.0)

ax.set_title('Load Vs Displacement curve', fontsize=10)
ax.set_xlabel('Disp [inch]', fontsize=10)
ax.set_ylabel('Load [kips]', fontsize=10)
#leg = ax.legend()
plt.tick_params(labelsize=6)
plt.tight_layout()
plt.show()
ops.wipe
by Prafullamalla
Tue Jan 31, 2023 6:19 pm
Forum: OpenSeesPy
Topic: Fixing boundary condition for zero length section
Replies: 3
Views: 3848

Re: Fixing boundary condition for zero length section

Thankyou. I understood the local axis x will orient along the global Y-axis with the zeroLengthSection [0,1,0]. But what is the reason, why we are restraining in X direction?
by Prafullamalla
Sun Jan 22, 2023 6:15 pm
Forum: OpenSeesPy
Topic: Fixing boundary condition for zero length section
Replies: 3
Views: 3848

Fixing boundary condition for zero length section

I am confused to fix boundary for zerolengthsection. Should I fix x and y direction and release the rotation?
ops.node(3, 0.0,0.0)
ops.node(1, 0.0,0.0);
ops.node(2, 0.0, H)
ops.fix (3, 1, 1, 1);
# Fix for zerolengthsection
ops.fix (1, 1, 1, 0);
ops.element ('zeroLengthSection' ,2, 3, 1,.....
by Prafullamalla
Sat Dec 31, 2022 9:14 pm
Forum: OpenSeesPy
Topic: Is analysis('Creep') command available?
Replies: 0
Views: 9796

Is analysis('Creep') command available?

Is there analysis('Creep') command for time dependent material TDConcreteMC10
by Prafullamalla
Thu Dec 22, 2022 5:22 am
Forum: OpenSeesPy
Topic: Cyclic Loading Algorithm
Replies: 0
Views: 9952

Cyclic Loading Algorithm

Its converted from the available TCL file.

Code: Select all

# -*- coding: utf-8 -*-
"""
Created on Wed Nov 30 10:53:29 2022

@author: praf_
"""

import openseespy.opensees as ops
import numpy as np

ops.wipe()
ops.model('basic','-ndm',1,'-ndf',1)

m = 1
g = 981

ops.node(1,0); ops.fix(1,1)
ops.node(2,0); ops.mass(2,m)

F=10000
k = 1000;#24*36000*250**4/12/3000**3


#ops.uniaxialMaterial('Elastic',1,k)
ops.uniaxialMaterial('Steel01 ',1,F,k,-2)
#ops.uniaxialMaterial('Steel02', 1, F,k,0.005, 18, 0.925, 0.15)
ops.element('zeroLength',1,1,2,'-mat',1,'-dir',1)

print("Cyclic Analysis Started!")
(controlNode, controlDOF) =(2, 1)  
# Set the gravity loads to be constant & reset the time in the domain
ops.loadConst  ('-time', 0.0)
# Set some parameters
LateralLoad = 1000.0    # Reference lateral load of 1kN in N

# Set lateral load pattern with a Linear TimeSeries
# Create a Plain load pattern with a Linear TimeSeries
ops.timeSeries ('Linear', 1)
ops.pattern('Plain', 1, 1)

# Create nodal loads at nodes 
#    nd    FX  FY  MZ
ops.load(controlNode, LateralLoad)

# Set some parameters
currentDisp = ops.nodeDisp(controlNode, controlDOF)

# Arrays for plotting
outputs = {
    "Load": [],
    "Displacement": [],
    "Drift":["Drift"]
    }

# ------------------------
# Displacement steps
# ------------------------
  
#Drift =           [15,0] 
height=1
#arr=np.array(Drift)  # converting to array to multipy to calculate Displacement from Drift
#arr =height/100*arr  # Displacement-Drift*height/100 max for each cycle  
#Disp = arr.tolist()
Disp =           [5,0,-5,40,0,-40,15,0,-15,35,0,-35,0,10]#,15,0,-15,0,20,0,-20,35,0,-35,35,0,-35,40,0,-40,] 

# Set some parameters
currentDisp = ops.nodeDisp(controlNode, controlDOF)
ok          = 0                         # Counter to store data
currentDisp = ops.nodeDisp(controlNode, controlDOF)
factorLoad  =ops.getTime()

outputs["Load"].append(factorLoad)
outputs["Displacement"].append(currentDisp)
outputs["Drift"].append(currentDisp/height*100)
# ------------------------------------------------------------------------------
# Main analysis - performed as a number of analyses equal to the number of steps
# ------------------------------------------------------------------------------

ops.system("BandGeneral")    # Overkill, but may need the pivoting!
ops.test("NormDispIncr", 1.0e-7, 10, 0)
ops.numberer("Plain")
ops.constraints("Penalty",1.0e14, 1.0e14)
ops.algorithm("Newton")
ops.analysis("Static")

cycle=0
for Dmax in Disp:
    cycle=cycle+1
    print('Cycle Number',cycle)
    if Dmax > 0:
        Dincr = 1
    elif Dmax < 0:
        Dincr =-1
            
    ops.integrator("DisplacementControl",  controlNode, controlDOF, Dincr)
    ops.analysis("Static")
    if Dincr > 0:
        ok = 0
        while (ok == 0 and currentDisp < Dmax):
                        
            ok = ops.analyze(1)
            if ok != 0:
                print( " ")
                print ("Trying Newton with Initial Tangent ..")
                ops.test("NormDispIncr", 1.0e-6, 2000, 0)
                ops.algorithm('Newton', '-initial')
                ops.analysis("Static")
                ok = ops.analyze(1)
                ops.test("NormDispIncr", 1.0e-6, 6, 2)
                ops.algorithm('Newton')
                           
            if ok != 0:
                  print( " ")
                  print ("Trying Broyden ..")
                  ops.test("NormDispIncr", 1.0e-6, 2000, 0)
                  ops.algorithm('Broyden', 8)
                  ops.analysis("Static")
                  ok = ops.analyze(1)
                  ops.algorithm('Newton')   
                  
            if ok != 0:
                  print( " ")
                  print ("Trying NewtonWithLineSearch ..")
                  ops.algorithm('NewtonLineSearch', 0.8)
                  ok = ops.analyze(1)
                  ops.algorithm('Newton')
            
            currentDisp = ops.nodeDisp(controlNode, controlDOF)
            factorLoad  =ops.getTime()
            outputs["Load"].append(factorLoad)
            outputs["Displacement"].append(currentDisp)
            outputs["Drift"].append(currentDisp/height*100)
      
    elif Dincr < 0 :
        ok = 0
        while (ok == 0 and currentDisp > Dmax):
              
            ok = ops.analyze(1)
            if ok != 0:
                print( " ")
                print ("Trying Newton with Initial Tangent ..")
                ops.test("NormDispIncr", 1.0e-6, 2000, 0)
                ops.algorithm('Newton', '-initial')
                ok = ops.analyze(1)
                ops.test("NormDispIncr", 1.0e-6, 6, 2)
                ops.algorithm('Newton')
                           
            if ok != 0:
                  print( " ")
                  print ("Trying Broyden ..")
                  ops.test("NormDispIncr", 1.0e-6, 2000, 0)
                  ops.algorithm('Broyden', 8)
                  ok = ops.analyze(1)
                  ops.algorithm('Newton')   
                  
            if ok != 0:
                  print( " ")
                  print ("Trying NewtonWithLineSearch ..")
                  ops.algorithm('NewtonLineSearch', 0.8)
                  ok = ops.analyze(1)
                  ops.algorithm('Newton')
                  
               
            currentDisp = ops.nodeDisp(controlNode, controlDOF)
            factorLoad  =ops.getTime()
            outputs["Load"].append(factorLoad)
            outputs["Displacement"].append(currentDisp)
            outputs["Drift"].append(currentDisp/height*100)
 
if ok ==0:
    print ('Cyclic analysis completed SUCCESSFULLY ')
else:
    print ("Cyclic analysis FAILED");                       

for item in outputs:
    outputs[item] = np.array(outputs[item])    
    
#P PLOTTING CURVE    
# x axis values
x = outputs["Displacement"]
# corresponding y axis values
y = outputs["Load"]

import matplotlib.pyplot as plt
import numpy as np


ops.wipe


# Deflection
## Set parameters for the plot
plt.rcParams.update({'font.size': 7})
plt.figure(figsize=(6,5), dpi=200)
plt.rc('font', family='serif')
plt.plot(x,y, color="red", linewidth=0.8, linestyle="-", label='Cyclic')
plt.axhline(0, color='black', linewidth=0.4)
plt.axvline(0, color='black', linewidth=0.4)
#plt.xlim(-15, 15)
#plt.xticks(np.linspace(-9,9,10,endpoint=True)) 
plt.grid(linestyle='dotted') 
plt.xlabel('Displacement (mm)')
plt.ylabel('Base Shear (kN)')
plt.legend()
#plt.savefig("RCC1_PushoverCurve.png",dpi=1200)
plt.show()