Skip to content

Instantly share code, notes, and snippets.

@terjehaukaas
terjehaukaas / HalfSineWave.py
Last active April 2, 2024 02:25
Half Sine Wave
# ------------------------------------------------------------------------
# The following Python code is implemented by Professor Terje Haukaas at
# the University of British Columbia in Vancouver, Canada. It is made
# freely available online at terje.civil.ubc.ca together with notes,
# examples, and additional Python code. Please be cautious when using
# this code; it may contain bugs and comes without warranty of any kind.
# ------------------------------------------------------------------------
import numpy as np
@terjehaukaas
terjehaukaas / ReadPEERRecord.py
Last active April 2, 2024 02:25
Read PEER Record
import numpy as np
import os
def readPEERrecord(f):
rawGroundMotion = []
dt = 0
file = open(f, "r")
lines = file.readlines()
@terjehaukaas
terjehaukaas / G2Example17.py
Last active April 2, 2024 02:42
G2 Example 17
# ------------------------------------------------------------------------
# The following Python code is implemented by Professor Terje Haukaas at
# the University of British Columbia in Vancouver, Canada. It is made
# freely available online at terje.civil.ubc.ca together with notes,
# examples, and additional Python code. Please be cautious when using
# this code; it may contain bugs and comes without warranty of any kind.
# ------------------------------------------------------------------------
from G2AnalysisLinearStatic import *
from G2Model import *
@terjehaukaas
terjehaukaas / G2Example16.py
Last active April 2, 2024 02:42
G2 Example 16
# ------------------------------------------------------------------------
# The following Python code is implemented by Professor Terje Haukaas at
# the University of British Columbia in Vancouver, Canada. It is made
# freely available online at terje.civil.ubc.ca together with notes,
# examples, and additional Python code. Please be cautious when using
# this code; it may contain bugs and comes without warranty of any kind.
# ------------------------------------------------------------------------
from G2AnalysisLinearDynamic import *
from G2Model import *
@terjehaukaas
terjehaukaas / G2Example15.py
Last active April 2, 2024 02:41
G2 Example 15
# ------------------------------------------------------------------------
# The following Python code is implemented by Professor Terje Haukaas at
# the University of British Columbia in Vancouver, Canada. It is made
# freely available online at terje.civil.ubc.ca together with notes,
# examples, and additional Python code. Please be cautious when using
# this code; it may contain bugs and comes without warranty of any kind.
# ------------------------------------------------------------------------
from G2AnalysisLinearStatic import *
from G2Model import *
@terjehaukaas
terjehaukaas / G2Example14.py
Last active April 2, 2024 02:40
G2 Example 14
# ------------------------------------------------------------------------
# The following Python code is implemented by Professor Terje Haukaas at
# the University of British Columbia in Vancouver, Canada. It is made
# freely available online at terje.civil.ubc.ca together with notes,
# examples, and additional Python code. Please be cautious when using
# this code; it may contain bugs and comes without warranty of any kind.
# ------------------------------------------------------------------------
# Input [N, m, kg, sec]
elementType = 12
@terjehaukaas
terjehaukaas / G2Example13.py
Last active April 2, 2024 02:40
G2 Example 13
# ------------------------------------------------------------------------
# The following Python code is implemented by Professor Terje Haukaas at
# the University of British Columbia in Vancouver, Canada. It is made
# freely available online at terje.civil.ubc.ca together with notes,
# examples, and additional Python code. Please be cautious when using
# this code; it may contain bugs and comes without warranty of any kind.
# ------------------------------------------------------------------------
# Input [N, m, kg, sec]
elementType = 12
@terjehaukaas
terjehaukaas / G2Example12.py
Last active April 2, 2024 02:39
G2 Example 12
from G2AnalysisNonlinearDynamic import *
from G2Model import *
from GroundMotionHalfSineWave import *
font = {'family' : 'Times New Roman','size' : 12}
plt.rc('font', **font)
# This example takes features from Figure 3 in the paper by John F. Hall entitled
# Problems encountered from the use (or misuse) of Rayleigh damping, published in
# 2006 in Earthquake Engineering & Structural Dynamics, Volume 35.
@terjehaukaas
terjehaukaas / G2Example11.py
Last active April 2, 2024 02:39
G2 Example 11
# ------------------------------------------------------------------------
# The following Python code is implemented by Professor Terje Haukaas at
# the University of British Columbia in Vancouver, Canada. It is made
# freely available online at terje.civil.ubc.ca together with notes,
# examples, and additional Python code. Please be cautious when using
# this code; it may contain bugs and comes without warranty of any kind.
# ------------------------------------------------------------------------
from G2AnalysisNonlinearDynamic import *
from G2Model import *
@terjehaukaas
terjehaukaas / G2Example10.py
Last active April 2, 2024 02:36
G2 Example 10
from G2AnalysisSDOFNonlinearDynamic import *
from G2MaterialBilinear import *
import numpy as np
import matplotlib.pyplot as plt
# Target natural period of structure
structuralPeriod = 0.5
# Material parameters [N, m]
E = 1e4