<jupyter_start><jupyter_text>EQE512 MATRIX METHODS IN STRUCTURAL ANALYSIS ---Week 11 - Frame Systems - Dynamic Properties  Dr. <NAME> (<EMAIL>) 2020 Fall --- **Let's calculate the modal parameters of the given MDOF system** This code is composed of two (2) main parts, namely 1- Hand Calculation2- OpenSeesPy---  Hand Calculations Material is C25 ($E = 32GPA$)<jupyter_code>E = 32_000_000 # kN/m2

conc_weight = 25 # kN/m

UDL = 10 # kN/m

g = 9.81 # m7s2

# *********************** GEOMETRY
L , H1 , H2 , h_beam , b_beam, h_col , b_col = 5 , 3 , 3, 0.5 , 0.2 , 0.5 , 0.5 # m<jupyter_output><empty_output><jupyter_text>**Mass Matrix**<jupyter_code># Load on beam
beam_load = UDL * L
beam_sw = ( h_beam * b_beam * L) * conc_weight
# Load on columns
column_sw = (h_col * b_col * H1) * conc_weight
# Mass of stories
M1 = ( 4 * column_sw / 2 + beam_load + beam_sw) / g
M1 = round( M1 ,2)

M2 = ( 2 * column_sw / 2 + beam_load + beam_sw) / g
M2 = round( M2 ,2)
# CONSTRUCT THE MASS MATRIX

import numpy as np

Mass_sys = np.array( [[ M1, 0] , [ 0, M2]])

print( Mass_sys)<jupyter_output>[[10.19  0.  ]
 [ 0.    8.28]]<jupyter_text>**Stiffness Matrix**<jupyter_code>Mom_inertia = (b_col * h_col **3 ) / 12

K1 = 2 * (( 12 * E * Mom_inertia)/ ( H1**3))
K1 = round( K1 ,0)

K2 = 2 * (( 12 * E * Mom_inertia)/ ( H2**3))
K2 = round( K2 ,0)
# CONSTRUCT THE SYSTEM STIFFNESS MATRIX
K_sys = np.array( [[K1 + K2 , -K2],[-K2 , K2]])

print( K_sys)<jupyter_output>[[ 296296. -148148.]
 [-148148.  148148.]]<jupyter_text>**Calculation of the Natural Circular Frequencies**<jupyter_code># Calculation of natural circular frequencies

w2 = np.dot( np.linalg.inv( Mass_sys) , K_sys)

print( w2)
# Calculaiton of mode shape vectors and values

V , D = np.linalg.eigh( w2)
V
D
w = [ item**0.5 for item in V]
w
T = [ round( 2* (22/7) / item ,2)  for item in w]
for count, item in enumerate( T ) :
    print( f"{count+1} Mode Period is {item}sec.")
import matplotlib.pyplot as plt
%matplotlib inline

for mode_no , mode_shape in enumerate( D ):
    
    vector = list(D[:][mode_no])
    vector.insert(0,0)
    plt.subplot( 1,len(Mass_sys), mode_no + 1)
    plt.plot( vector , range(len(Mass_sys)+1) , "o-" , MS = 10)
    plt.plot( [0 for item in range( len(Mass_sys)+1) ], range(len(Mass_sys)+1) , "o--" , MS = 10 ,color="gray")<jupyter_output><empty_output><jupyter_text>OPENSEESPY --- 2- OpenSeesPy Modeling<jupyter_code># from openseespy import *

import openseespy.opensees as os
os.wipe() # Clear all OS values
os.model( "Basic", "-ndm", 2 , "-ndf", 3) # This is a 2D Frame
numBay = 1
numFloor = 2
bayWidht = 5.0 # m
storyHeight = 3.0 # m
E = 32000000 # kN/m2
massX = 5 * 2 # we'll discuss
M = 0. 
coordTransfer = "Linear" # Linear Transformation
massType = "-lMass" # Lumped mass
beams = [ "B20X50" for item in range( numFloor)]
eColumn = [ "C50X50" for item in range( numFloor)]
iColumn = [ "C50X50" for item in range( numFloor)]

columns = [eColumn , iColumn , eColumn]
Section = { "C50X50" : [ 0.5 * .5 , (0.5*0.5**3)/12],
          "B20X50": [0.2*.5 , (.2*0.5**3)/12]}
Section
def ElasticBeamColum( eleTag, iNode, jNode, sectType, E, transfTag, M, massType) :
    
    prop = Section[sectType]
    Area = prop[0]
    I = prop[1]
    
    os.element( "elasticBeamColumn", eleTag ,iNode, jNode, Area, E , I , transfTag , "-mass", M, massType)
import numpy as np
axis_h = np.linspace( 0 , (numBay * bayWidht)  ,numBay+1)
axis_v = np.linspace( 0 , (numFloor * storyHeight)  ,numFloor+1)

node_no =  1
node_dict = {}
floorNo = 0
floorNodes = {}
nodes = []
for i in axis_v:
    floorNodes[floorNo] = []
    
    for j in axis_h:
        nodes.append(node_no)

        # OPENSEES COMMAND
        os.node( node_no , float(j) , float(i))
        
        node_dict[node_no] = [float(j) , float(i)]
        floorNodes[floorNo].append(node_no)
        
        
        node_no += 1
    floorNo += 1
for nodeNumber in floorNodes[0]:
    os.fix( nodeNumber , 1,1,1)
# Rigid Diaphram Assignment
floorNodes
for key, value in floorNodes.items():
    for item in value[:]:
        if item == value[0]:
            os.mass( item , massX , 0.0000000001 , 0.0000000001 )
        else: 
            os.equalDOF( value[0] , item , 1)
os.geomTransf(coordTransfer, 1)
column_dict = {}
eleTag = 1 
for  j in range(0 , numBay + 1):
    end1 = j + 1
    end2 = end1 + numBay + 1
    thisColumn = columns[j]
    
    for i in range( 0 ,numFloor):
        secType = thisColumn[ i]
        ElasticBeamColum( eleTag, end1 , end2 , secType , E , 1, M , massType)
        column_dict[eleTag] = [end1, end2]
        end1 =end2
        end2 += numBay + 1

        
        eleTag += 1
        
import matplotlib.pyplot as plt
%matplotlib inline

for key in node_dict.keys():
    plt.plot( node_dict[key][0] ,  node_dict[key][1] , "o"  )
import matplotlib.pyplot as plt
%matplotlib inline

for key in column_dict.keys():
    plt.plot([ node_dict[column_dict[key][0]][0] ,node_dict[column_dict[key][1]][0]],
              [ node_dict[column_dict[key][0]][1] ,node_dict[column_dict[key][1]][1]]  )
    
beam_dict = {}
for j in range( 1 , numFloor +1):
    end1 = (numBay + 1) * j + 1
    end2 = end1+1
    secType = beams[j -1 ]
    for i in range(0, numBay):
        ElasticBeamColum(eleTag, end1, end2, secType, E, 1, M, massType) 
        beam_dict[eleTag] = [end1, end2]
        end1 = end2
        end2 = end1 + 1
        eleTag += 1
import matplotlib.pyplot as plt
%matplotlib inline

for key in beam_dict.keys():
    plt.plot([ node_dict[beam_dict[key][0]][0] ,node_dict[beam_dict[key][1]][0]],
              [ node_dict[beam_dict[key][0]][1] ,node_dict[beam_dict[key][1]][1]]  )
    
plt.figure(figsize= (5,5))


for key in node_dict.keys():
    plt.plot( node_dict[key][0] ,  node_dict[key][1] , "o" , MS = 10 , color="blue")
    plt.text(node_dict[key][0] ,  node_dict[key][1] , key , fontsize=20 , color="blue" )
    
for key in column_dict.keys():
    plt.plot([ node_dict[column_dict[key][0]][0] ,node_dict[column_dict[key][1]][0]],
              [ node_dict[column_dict[key][0]][1] ,node_dict[column_dict[key][1]][1]]  
            , color="red")
    plt.text(0.5*( node_dict[column_dict[key][0]][0] + node_dict[column_dict[key][1]][0]),
             0.5*(node_dict[column_dict[key][0]][1] + node_dict[column_dict[key][1]][1]), key , fontsize=22 ,color="r" , horizontalalignment="right")
    
for key in beam_dict.keys():
    plt.plot([ node_dict[beam_dict[key][0]][0] ,node_dict[beam_dict[key][1]][0]],
              [ node_dict[beam_dict[key][0]][1] ,node_dict[beam_dict[key][1]][1]] 
            , color="k")
    plt.text(0.5*( node_dict[beam_dict[key][0]][0] + node_dict[beam_dict[key][1]][0]),
             0.5*(node_dict[beam_dict[key][0]][1] + node_dict[beam_dict[key][1]][1]), key , fontsize=24 , color = "k" , verticalalignment="center")
    
numEigen = 2 
eigenValues = os.eigen( numEigen)
eigenValues
T_ospy = [ round( 2* (22/7) / item ,5)  for item in eigenValues]
for count, item in enumerate( T_ospy ) :
    print( f"{count+1} Mode Period is {item}sec.")
T_ospy<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16454442558007923, 'fraction_numerical': 0.05178268251273345, 'mean_word_length': 3.2816474863718956, 'pattern_counts': {'":': 1, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '366203', 'license': 'MIT', 'n_tokens_mistral': 3049, 'n_tokens_neox': 2840, 'n_words': 692, 'path': '.ipynb_checkpoints/EQE512-Week11-Lecture-checkpoint.ipynb', 'repo_name': 'ahmetanildindar/EQE512-Matrix-Methods-In-Structural-Analysis', 'size': '7090'}