Last active
April 2, 2024 02:27
-
-
Save terjehaukaas/c427682b2cd49b75a7ba2eada5836253 to your computer and use it in GitHub Desktop.
G2 Example 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from G2AnalysisSDOFNonlinearDynamic import * | |
from G2MaterialBilinear import * | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# SI units: N, m, kg, sec. | |
# Spectrum range (natural periods) | |
minPeriod = 0.05 | |
maxPeriod = 5.0 | |
numPoints = 100 | |
structuralPeriods = np.linspace(minPeriod, maxPeriod, numPoints) | |
# Stiffness | |
E = 1e4 | |
alpha = 0.0 | |
# Damping ratio | |
dampingRatio = 0.05 | |
# Yield displacement | |
uy = 0.03e6 | |
fy = E * uy | |
# Load ground motion | |
groundMotion = "GroundMotionElCentro.txt" | |
dt = 0.02 | |
gmScaling = 1 | |
gm = [] | |
f = open(groundMotion, "r") | |
lines = f.readlines() | |
for oneline in lines: | |
splitline = oneline.split() | |
for j in range(len(splitline)): | |
value = 9.81 * float(splitline[j]) * gmScaling | |
gm.append(value) | |
gm = np.array(gm) | |
duration = dt * (len(gm)-1) | |
# Loop over natural periods | |
uMax = [] | |
vMax = [] | |
aMax = [] | |
vMaxPseudo = [] | |
aMaxPseudo = [] | |
for i in range(numPoints): | |
# Mass from natural period | |
M = (structuralPeriods[i]/2/np.pi)**2 * E | |
# Run analysis | |
material = bilinearMaterial(['Bilinear', E, fy, alpha]) | |
t, uTrack, vTrack, aTrack, dudx, dvdx, dadx, dnl = nonlinearDynamicSDOFAnalysis(duration, dt, material, M, dampingRatio, gm, gmScaling, []) | |
# Pick up maximum responses | |
Sd = np.max(np.abs(uTrack)) | |
uMax.append(Sd) | |
vMax.append(np.max(np.abs(vTrack))) | |
vMaxPseudo.append(2*np.pi/structuralPeriods[i] * Sd) | |
aMax.append(np.max(np.abs(aTrack))) | |
aMaxPseudo.append((2*np.pi/structuralPeriods[i])**2 * Sd) | |
# Plot displacement response spectrum | |
plt.ion() | |
plt.figure() | |
plt.autoscale(True) | |
plt.grid(True) | |
plt.xlabel("$T_n$ [sec.]") | |
plt.ylabel("$S_d$ [m]") | |
plt.title("Displacement Response Spectrum") | |
plt.plot(structuralPeriods, uMax, 'k-', linewidth=1.0) | |
plt.savefig('Figure1.pdf', format='pdf') | |
print('\n'"Click somewhere in the plot to continue...") | |
plt.waitforbuttonpress() | |
# Plot velocity response spectrum + pseudo-velocity spectrum | |
plt.ion() | |
plt.figure() | |
plt.autoscale(True) | |
plt.grid(True) | |
plt.xlabel("$T_n$ [sec.]") | |
plt.ylabel("$S_v$ [m/s]") | |
plt.title("Velocity Response Spectrum") | |
plt.plot(structuralPeriods, vMax, 'b-', linewidth=1.0, label="Maximum velocity") | |
plt.plot(structuralPeriods, vMaxPseudo, 'r-', linewidth=1.0, label="Pseudo: $\omega_n S_d$") | |
plt.legend(loc='lower right') | |
plt.savefig('Figure2.pdf', format='pdf') | |
print('\n'"Click somewhere in the plot to continue...") | |
plt.waitforbuttonpress() | |
# Plot (total) acceleration response spectrum + pseudo-acceleration spectrum | |
plt.ion() | |
plt.figure() | |
plt.autoscale(True) | |
plt.grid(True) | |
plt.xlabel("$T_n$ [sec.]") | |
plt.ylabel("$S_a$ [$m/s^2$]") | |
plt.title("Acceleration Response Spectrum") | |
plt.plot(structuralPeriods, aMax, 'b-', linewidth=1.0, label="Maximum acceleration") | |
plt.plot(structuralPeriods, aMaxPseudo, 'r-', linewidth=1.0, label="Pseudo: $\omega_n^2 S_d$") | |
plt.legend(loc='upper right') | |
plt.savefig('Figure3.pdf', format='pdf') | |
print('\n'"Click somewhere in the plot to continue...") | |
plt.waitforbuttonpress() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment