Skip to content

Instantly share code, notes, and snippets.

@terjehaukaas
Created June 11, 2019 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terjehaukaas/7a950c8effcdbcca6f3914ce547466e0 to your computer and use it in GitHub Desktop.
Save terjehaukaas/7a950c8effcdbcca6f3914ce547466e0 to your computer and use it in GitHub Desktop.
Get Truss Stiffness 2D
# ------------------------------------------------------------------------
# The following function is implemented in Python 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 any form of warranty.
# ------------------------------------------------------------------------
def getTrussStiffness2D(E, A, L, delta_x, delta_y, N):
# Local stiffness matrix
Kl = np.array([(E*A/L, 0, -E*A/L, 0),
(0, 0, 0, 0),
(-E*A/L, 0, E*A/L, 0),
(0, 0, 0, 0)])
# Geometric stiffness matrix
Kgeometric = np.array([(0, 0, 0, 0),
(0, N/L, 0, -N/L),
(0, 0, 0, 0),
(0, -N/L, 0, N/L)])
# Transformation matrix Tlg
if delta_x == 0:
if delta_y < 0:
theta = -np.pi/2.0
else:
theta = np.pi/2.0
else:
theta = np.arctan(delta_y/delta_x)
c = np.cos(theta)
s = np.sin(theta)
Tlg = np.array([(c, s, 0, 0),
(-s, c, 0, 0),
(0, 0, c, s),
(0, 0, -s, c)])
return [Kl, Kgeometric, Tlg]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment