<jupyter_start><jupyter_text>EQE512 MATRIX METHODS IN STRUCTURAL ANALYSIS ---Week 10 - OpenSeesPy - Frame Systems  Dr. <NAME> (<EMAIL>) 2020 Fall   --- This code is composed of three sections, namely A. Pre-processB. ProcessC. Post-Process---Problem: This is a multistory 2D Elastic RC frame under static loads  A. Pre-Process<jupyter_code># from openseespy import *

import openseespy.opensees as ops
ops.wipe() # Clear all OS values
ops.model( "Basic", "-ndm", 2 , "-ndf", 3) # This is a 2D Frame
numBay = 2
numFloor = 7
bayWidht = 3.0 # m
storyHeight = 3.0 # m
E = 295000000 # kN/m2
massX = 0.49
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]
    
    ops.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
        ops.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]:
    ops.fix( nodeNumber , 1,1,1)
# Rigid Diaphram Assignment
floorNodes
for key, value in floorNodes.items():
    for item in value[:]:
        if item == value[0]:
            ops.mass( item , massX , 0.000001 , 0.0000001 )
        else: 
            ops.equalDOF( value[0] , item , 1)<jupyter_output><empty_output><jupyter_text>Adding columns<jupyter_code>ops.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
        
eleTag
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="gray")
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")
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")
    
from math import asin, sqrt


numEigen = 7 
eigenValues = ops.eigen( numEigen) 

PI = 3.14
eigenValues<jupyter_output><empty_output><jupyter_text>**LOADS**<jupyter_code>ops.timeSeries("Linear",1)
ops.pattern( "Plain" ,1,1)

load_dict = {4 : 20000 , 7 : 20000}

for key in load_dict.keys():
    ops.load( key , load_dict[key] , 0  , 0)<jupyter_output><empty_output><jupyter_text>B. Process<jupyter_code>ops.integrator('LoadControl', 1.0)
ops.algorithm('Linear')
ops.analysis('Static')
ops.analyze(1)<jupyter_output><empty_output><jupyter_text>C. Post-Process<jupyter_code>node_dict[1][0]
scale = 5
node_deform_dict = {}
for i in node_dict.keys():
    node_deform_dict[i] = [node_dict[i][0] + scale*(ops.nodeDisp(i,1)) , node_dict[i][1]]
#    print( f"{i} node disp = {round( ops.nodeDisp(i,1),5)}")

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="gray")
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="gray")
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="gray")

for key in node_deform_dict.keys():
    plt.plot( node_deform_dict[key][0] ,  node_deform_dict[key][1] , "o" , MS = 10 , color="b")
for key in column_dict.keys():
    plt.plot([ node_deform_dict[column_dict[key][0]][0] ,node_deform_dict[column_dict[key][1]][0]],
              [ node_deform_dict[column_dict[key][0]][1] ,node_deform_dict[column_dict[key][1]][1]]  
            , color="b")
for key in beam_dict.keys():
    plt.plot([ node_deform_dict[beam_dict[key][0]][0] ,node_deform_dict[beam_dict[key][1]][0]],
              [ node_deform_dict[beam_dict[key][0]][1] ,node_deform_dict[beam_dict[key][1]][1]] 
            , color="b")
plt.box(False)<jupyter_output><empty_output><jupyter_text>**Modal Analysis Results**<jupyter_code>periods = [ 2* PI / sqrt(lamb)  for lamb in eigenValues ]
for count, i in enumerate( periods) : 
    print(f"{count+1} mode number and period ={round(i ,4 )}sn")<jupyter_output>1 mode number and period =0.0311sn
2 mode number and period =0.0097sn
3 mode number and period =0.0052sn
4 mode number and period =0.0034sn
5 mode number and period =0.0024sn
6 mode number and period =0.0019sn
7 mode number and period =0.0016sn
{'fraction_non_alphanumeric': 0.1621859850154253, 'fraction_numerical': 0.044659908917291026, 'mean_word_length': 3.5568942436412314, 'pattern_counts': {'":': 1, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '551339', 'license': 'MIT', 'n_tokens_mistral': 2824, 'n_tokens_neox': 2653, 'n_words': 580, 'path': '.ipynb_checkpoints/EQE512-Week10-Lecture-checkpoint.ipynb', 'repo_name': 'ahmetanildindar/EQE512-Matrix-Methods-In-Structural-Analysis', 'size': '6829'}