Skip to content

Commit 109ffb0

Browse files
committed
add weaver
1 parent 0ecf4c2 commit 109ffb0

File tree

2 files changed

+184
-0
lines changed

2 files changed

+184
-0
lines changed

examples/weaver_1.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
"""
2+
Created on 01/12/2025
3+
4+
Example 5.8 from Matrix Structural Analysis: Second Edition 2nd Edition by
5+
William McGuire, Richard H. Gallagher, Ronald D. Ziemian
6+
7+
The section properties are not completely defined in the book. They are
8+
taken from example 4.8, which does not provide both second moments of area.
9+
They are taken here as both the same.
10+
"""
11+
12+
from numpy.linalg import norm
13+
from context import pystran
14+
from pystran import model
15+
from pystran import section
16+
from pystran import plots
17+
18+
# US customary units, inches, pounds, seconds
19+
L = 120.0
20+
E = 30000
21+
G = E / (2 * (1 + 0.3))
22+
A = 11
23+
Iz = 56
24+
Iy = 56
25+
Ix = 83
26+
J = Ix # Torsional constant
27+
F = 2
28+
P = 1
29+
M = 120
30+
31+
m = model.create(3)
32+
33+
model.add_joint(m, 3, [0.0, 0.0, 0.0])
34+
model.add_joint(m, 1, [0.0, L, 0.0])
35+
model.add_joint(m, 2, [2 * L, L, 0.0])
36+
model.add_joint(m, 4, [3 * L, 0.0, L])
37+
38+
model.add_support(m["joints"][3], model.CLAMPED)
39+
model.add_support(m["joints"][4], model.CLAMPED)
40+
41+
xz_vector = [1, 0, 0]
42+
sect_1 = section.beam_3d_section(
43+
"sect_1", E=E, G=G, A=A, Ix=Ix, Iy=Iy, Iz=Iz, J=J, xz_vector=xz_vector
44+
)
45+
model.add_beam_member(m, 1, [3, 1], sect_1)
46+
xz_vector = [0, 1, 0]
47+
sect_2 = section.beam_3d_section(
48+
"sect_2", E=E, G=G, A=A, Ix=Ix, Iy=Iy, Iz=Iz, J=J, xz_vector=xz_vector
49+
)
50+
model.add_beam_member(m, 2, [1, 2], sect_2)
51+
model.add_beam_member(m, 3, [2, 4], sect_2)
52+
53+
model.add_load(m["joints"][1], model.U1, F)
54+
model.add_load(m["joints"][2], model.U2, -P)
55+
model.add_load(m["joints"][2], model.UR3, -M)
56+
57+
model.number_dofs(m)
58+
59+
# print("Number of free degrees of freedom = ", m["nfreedof"])
60+
# print("Number of all degrees of freedom = ", m["ntotaldof"])
61+
62+
# print([j['dof'] for j in m['joints'].values()])
63+
64+
model.solve(m)
65+
66+
for jid in [1, 2]:
67+
j = m["joints"][jid]
68+
print(jid, j["displacements"])
69+
70+
# print(m['K'][0:m['nfreedof'], 0:m['nfreedof']])
71+
72+
# print(m['U'][0:m['nfreedof']])
73+
74+
# 0.22267 0.00016 -0.17182 -0.00255 0.00217 -0.00213
75+
# 0.22202 -0.48119 -0.70161 -0.00802 0.00101 -0.00435
76+
ref1 = [0.22267, 0.00016, -0.17182, -0.00255, 0.00217, -0.00213]
77+
if norm(m["joints"][1]["displacements"] - ref1) > 1.0e-1 * norm(ref1):
78+
raise ValueError("Displacement calculation error")
79+
else:
80+
print("Displacement calculation OK")
81+
ref2 = [0.22202, -0.48119, -0.70161, -0.00802, 0.00101, -0.00435]
82+
if norm(m["joints"][2]["displacements"] - ref2) > 1.0e-1 * norm(ref2):
83+
raise ValueError("Displacement calculation error")
84+
else:
85+
print("Displacement calculation OK")
86+
87+
88+
plots.plot_setup(m)
89+
plots.plot_members(m)
90+
# plots.plot_member_numbers(m)
91+
plots.plot_deformations(m, 30.0)
92+
# ax = plots.plot_shear_forces(m, scale=0.50e-3)
93+
# ax.set_title('Shear forces')
94+
plots.show(m)

unittests.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,96 @@ def test_spfr_weaver_gere_1(self):
245245
# # ax.set_title('Shear forces')
246246
# plots.show(m)
247247

248+
def test_weaver_1(self):
249+
"""
250+
Created on 01/20/2025
251+
252+
Weaver Jr., W., Computer Programs for Structural Analysis, page 146,
253+
problem 8. From: STAAD.Pro 2023.00.03
254+
"""
255+
256+
from numpy.linalg import norm
257+
from pystran import model
258+
from pystran import section
259+
from pystran import plots
260+
261+
# US customary units, inches, pounds, seconds
262+
L = 120.0
263+
E = 30000
264+
G = E / (2 * (1 + 0.3))
265+
A = 11
266+
Iz = 56
267+
Iy = 56
268+
Ix = 83
269+
J = Ix # Torsional constant
270+
F = 2
271+
P = 1
272+
M = 120
273+
274+
m = model.create(3)
275+
276+
model.add_joint(m, 3, [0.0, 0.0, 0.0])
277+
model.add_joint(m, 1, [0.0, L, 0.0])
278+
model.add_joint(m, 2, [2 * L, L, 0.0])
279+
model.add_joint(m, 4, [3 * L, 0.0, L])
280+
281+
model.add_support(m["joints"][3], model.CLAMPED)
282+
model.add_support(m["joints"][4], model.CLAMPED)
283+
284+
xz_vector = [1, 0, 0]
285+
sect_1 = section.beam_3d_section(
286+
"sect_1", E=E, G=G, A=A, Ix=Ix, Iy=Iy, Iz=Iz, J=J, xz_vector=xz_vector
287+
)
288+
model.add_beam_member(m, 1, [3, 1], sect_1)
289+
xz_vector = [0, 1, 0]
290+
sect_2 = section.beam_3d_section(
291+
"sect_2", E=E, G=G, A=A, Ix=Ix, Iy=Iy, Iz=Iz, J=J, xz_vector=xz_vector
292+
)
293+
model.add_beam_member(m, 2, [1, 2], sect_2)
294+
model.add_beam_member(m, 3, [2, 4], sect_2)
295+
296+
model.add_load(m["joints"][1], model.U1, F)
297+
model.add_load(m["joints"][2], model.U2, -P)
298+
model.add_load(m["joints"][2], model.UR3, -M)
299+
300+
model.number_dofs(m)
301+
302+
# print("Number of free degrees of freedom = ", m["nfreedof"])
303+
# print("Number of all degrees of freedom = ", m["ntotaldof"])
304+
305+
# print([j['dof'] for j in m['joints'].values()])
306+
307+
model.solve(m)
308+
309+
for jid in [1, 2]:
310+
j = m["joints"][jid]
311+
print(jid, j["displacements"])
312+
313+
# print(m['K'][0:m['nfreedof'], 0:m['nfreedof']])
314+
315+
# print(m['U'][0:m['nfreedof']])
316+
317+
# 0.22267 0.00016 -0.17182 -0.00255 0.00217 -0.00213
318+
# 0.22202 -0.48119 -0.70161 -0.00802 0.00101 -0.00435
319+
ref1 = [0.22267, 0.00016, -0.17182, -0.00255, 0.00217, -0.00213]
320+
if norm(m["joints"][1]["displacements"] - ref1) > 1.0e-1 * norm(ref1):
321+
raise ValueError("Displacement calculation error")
322+
else:
323+
print("Displacement calculation OK")
324+
ref2 = [0.22202, -0.48119, -0.70161, -0.00802, 0.00101, -0.00435]
325+
if norm(m["joints"][2]["displacements"] - ref2) > 1.0e-1 * norm(ref2):
326+
raise ValueError("Displacement calculation error")
327+
else:
328+
print("Displacement calculation OK")
329+
330+
# plots.plot_setup(m)
331+
# plots.plot_members(m)
332+
# # plots.plot_member_numbers(m)
333+
# plots.plot_deformations(m, 30.0)
334+
# # ax = plots.plot_shear_forces(m, scale=0.50e-3)
335+
# # ax.set_title('Shear forces')
336+
# plots.show(m)
337+
248338

249339
def main():
250340
unittest.main()

0 commit comments

Comments
 (0)