Last active
April 2, 2024 02:40
-
-
Save terjehaukaas/049d17f3a1a2eb1e4ad576c204e3b561 to your computer and use it in GitHub Desktop.
G2 Example 13
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
# ------------------------------------------------------------------------ | |
# 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 | |
L = 5.0 | |
nel = 5 | |
F = 200e3 | |
E = 200e9 | |
fy = 350e6 | |
alpha = 0.02 | |
hw = 0.355 | |
bf = 0.365 | |
tf = 0.018 | |
tw = 0.011 | |
nf = 2 | |
nw = 8 | |
nsec = 7 | |
nsteps = 20 | |
dt = 1/nsteps | |
KcalcFrequency = 1 | |
maxIter = 100 | |
tol = 1e-5 | |
trackNode = nel+1 | |
trackDOF = 1 | |
# *************************** # | |
# G2 # | |
# *************************** # | |
from G2AnalysisNonlinearStatic import * | |
from G2Model import * | |
NODES = [] | |
for i in range(nel+1): | |
NODES.append([0.0, i*L/nel]) | |
CONSTRAINTS = [[1, 1, 1]] | |
for i in range(nel): | |
CONSTRAINTS.append([0, 0, 0]) | |
ELEMENTS = [] | |
for i in range(nel): | |
ELEMENTS.append([elementType, nsec, 0.0, i+1, i+2]) | |
SECTIONS = [] | |
for i in range(nel): | |
SECTIONS.append(['WideFlange', hw, bf, tf, tw, nf, nw]) | |
MATERIALS = [] | |
for i in range(nel): | |
MATERIALS.append(['Bilinear', E, fy, alpha]) | |
LOADS = np.zeros((nel+1, 3)) | |
LOADS[nel, 0] = F | |
MASS = [[0, 0, 0]] | |
for i in range(nel): | |
MASS.append([0, 0, 0]) | |
a = [NODES, CONSTRAINTS, ELEMENTS, SECTIONS, MATERIALS, LOADS, MASS] | |
m = model(a) | |
loadFactor, u, dudx = nonlinearStaticAnalysis(m, nsteps, dt, maxIter, KcalcFrequency, tol, trackNode, trackDOF, []) | |
# *************************** # | |
# OpenSees # | |
# *************************** # | |
import matplotlib.pyplot as plt | |
from sys import platform | |
if platform == "darwin": | |
from openseespymac.opensees import * | |
elif platform == "win32": | |
from openseespy.opensees import * | |
else: | |
print("Cannot handle this type of operating system") | |
import sys | |
sys.exit() | |
model('basic', '-ndm', 2, '-ndf', 3) | |
uniaxialMaterial('Steel01', 1, fy, E, alpha) | |
section('WFSection2d', 1, 1, hw, tw, bf, tf, nw, nf) | |
for i in range(nel+1): | |
node(i+1, 0.0, i*L/nel) | |
fix(1, 1, 1, 1) | |
beamIntegration('Legendre', 1, 1, nsec) | |
geomTransf('Linear', 1) | |
for i in range(nel): | |
element('dispBeamColumn', i+1, i+1, i+2, 1, 1) | |
timeSeries("Linear", 1) | |
pattern("Plain", 1, 1) | |
load(nel+1, F, 0.0, 0.0) | |
system("ProfileSPD") | |
numberer("Plain") | |
constraints("Plain") | |
integrator('LoadControl', dt) | |
algorithm("Newton") | |
test('NormDispIncr', 1e-8, 100, 0) | |
analysis("Static") | |
timeArray = [0.0] | |
dispArray = [0.0] | |
for i in range(nsteps): | |
analyze(1) | |
timeArray.append(getTime()) | |
dispArray.append(nodeDisp(nel+1, 1)) | |
plt.ion() | |
plt.figure() | |
plt.plot(dispArray, timeArray, 'bs-', label='Top displacement') | |
plt.xlabel("Displacement") | |
plt.ylabel("Pseudo Time") | |
plt.title("Response (G2-max=%.3f, OpenSees-max=%.3f)" % (np.max(u), np.max(dispArray))) | |
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