Skip to content

Commit d935eb8

Browse files
authored
Merge pull request #281 from connorferster/fixes/incorrect_moments_test
tests: add test that fails for Pynite 1.2.0, 1.3.0
2 parents e965df8 + 287956f commit d935eb8

File tree

1 file changed

+44
-18
lines changed

1 file changed

+44
-18
lines changed

Testing/test_continuous_beam.py

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
import math
33
# import matplotlib, matplotlib.pyplot as plt
44

5-
def create_model():
6-
5+
def create_3_support_model():
76
continuous_beam = FEModel3D()
87

98
continuous_beam.add_node('N1', 0, 0, 0)
@@ -26,30 +25,57 @@ def create_model():
2625

2726
return continuous_beam
2827

29-
def test_continuous_beam_moments():
30-
model = create_model()
28+
def test_3_support_beam_moments():
29+
model = create_3_support_model()
3130
member = model.members['M1']
3231
assert math.isclose(member.max_moment('Mz', '1.0D'), 18000.0), 'Incorrect max moment during continuous beam test'
3332
assert math.isclose(max(member.moment_array('Mz', 11, '1.0D')[1]), 18000.00), 'Incorrect max moment in moment array during continuous beam test.'
3433

35-
# def test_plots():
36-
37-
# model = create_model()
38-
39-
# assert isinstance(model.members['M1'].plot_shear('Fy', '1.0D', 100), matplotlib.figure.Figure)
40-
# plt.close()
4134

42-
# assert isinstance(model.members['M1'].plot_moment('Mz', '1.0D', 100), matplotlib.figure.Figure)
43-
# plt.close()
35+
def create_2_support_model():
36+
model = FEModel3D()
4437

45-
# assert isinstance(model.members['M1'].plot_torque('1.0D', 100), matplotlib.figure.Figure)
46-
# plt.close()
38+
model.add_material("default", 1, 1, 1, 1, 1)
39+
model.add_section("default", 1, 1, 1, 1)
4740

48-
# assert isinstance(model.members['M1'].plot_axial('1.0D', 100), matplotlib.figure.Figure)
49-
# plt.close()
41+
model.add_node("0", 0, 0, 0)
42+
model.add_node("1", 10, 0, 0)
43+
model.add_node("2", 13, 0, 0)
44+
45+
model.def_support("0", 1, 1, 1, 1, 1, 0)
46+
model.def_support("1", 0, 1, 0, 0, 0, 0)
47+
48+
model.add_member("M0", "0", "2", "default", "default")
49+
model.add_member_dist_load("M0", "Fy", -10, -10, 0, 13, case='load')
50+
model.add_load_combo("combo", {"load": 1.0})
51+
52+
model.analyze(check_statics=True)
53+
54+
return model
55+
56+
def test_2_support_beam_moments():
57+
# The following test passes on Pynite==1.1.2 but fails with Pynite==1.2.0, Pynite==1.3.0
58+
59+
model = create_2_support_model()
60+
member = model.members['M0']
61+
fe_max_moment = member.max_moment("Mz", "combo")
62+
fe_min_moment = member.min_moment("Mz", "combo")
63+
member.plot_moment("Mz", "combo", 2000)
64+
65+
# Analytic solution
66+
w = -10
67+
l = 10
68+
a = 3
69+
70+
# Beam formula source: Handbook of Steel Construction, CISC, 11th Ed. Pg. 5-138 diag. 24
71+
analytic_min_moment = (w * (l + a)**2 * (l - a)**2 )/ (8 * l**2)
72+
analytic_max_moment = -w * a**2 / 2
5073

51-
# assert isinstance(model.members['M1'].plot_deflection('dy', '1.0D', 100), matplotlib.figure.Figure)
52-
# plt.close()
74+
try:
75+
assert math.isclose(fe_max_moment, analytic_max_moment)
76+
except AssertionError:
77+
print(fe_max_moment, analytic_max_moment)
78+
assert math.isclose(fe_min_moment, analytic_min_moment)
5379

5480
if __name__ == '__main__':
5581
pass

0 commit comments

Comments
 (0)