-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethod_of_Joints_Tests.py
More file actions
173 lines (132 loc) · 5.88 KB
/
Method_of_Joints_Tests.py
File metadata and controls
173 lines (132 loc) · 5.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 6 12:21:14 2025
@author: kendrickshepherd
"""
import Main_for_Final_Testing as Main
# import Master.Method_of_Joints_Master as moj
import Method_of_Joints as moj
import unittest
class TestStructureOperations(unittest.TestCase):
def test_Example_3_2_Reactions(self):
nodes,bars = Main.MethodOfJoints("Example_3_2.csv")
decimal_place = 3
self.assertAlmostEqual(0, nodes[0].xforce_reaction, decimal_place)
self.assertAlmostEqual(4, nodes[3].yforce_reaction, decimal_place)
self.assertAlmostEqual(4, nodes[3].yforce_reaction, decimal_place)
def test_Example_3_3_Reactions(self):
nodes,bars = Main.MethodOfJoints("Example_3_3.csv")
decimal_place = 3
self.assertAlmostEqual(-141.42136, nodes[0].xforce_reaction, decimal_place)
self.assertAlmostEqual(125.39385, nodes[0].yforce_reaction, decimal_place)
self.assertAlmostEqual(191.0275, nodes[4].yforce_reaction, decimal_place)
def test_Unknown_Bars_Example_3_3(self):
nodes, bars = Main.LoadAndComputeReactions("Example_3_3.csv")
num_unknowns = [2,3,3,3,2,5]
for i in range(0,len(nodes)):
node = nodes[i]
unknowns = moj.UnknownBars(node)
self.assertEqual(num_unknowns[i], len(unknowns))
# artificially set some of these bars to be known
bars[0].is_computed = True
bars[1].is_computed = True
bars[5].is_computed = True
num_unknowns_now = [0,2,2,3,2,3]
for i in range(0,len(nodes)):
node = nodes[i]
unknowns = moj.UnknownBars(node)
self.assertEqual(num_unknowns_now[i], len(unknowns))
def test_NodeIsViable_Bars_Example_3_3(self):
nodes, bars = Main.LoadAndComputeReactions("Example_3_3.csv")
viable_node = [True,False,False,False,True,False]
for i in range(0,len(nodes)):
node = nodes[i]
viable = moj.NodeIsViable(node)
self.assertEqual(viable_node[i], viable)
# artificially set some of these bars to be known
bars[0].is_computed = True
bars[1].is_computed = True
bars[5].is_computed = True
viable_node_now = [False,True,True,False,True,False]
for i in range(0,len(nodes)):
node = nodes[i]
viable = moj.NodeIsViable(node)
self.assertEqual(viable_node_now[i], viable)
def test_SumofForcesY_Example_3_3_Init(self):
decimal_place = 2
nodes, bars = Main.LoadAndComputeReactions("Example_3_3.csv")
self.assertEqual(False,bars[1].is_computed)
moj.SumOfForcesInLocalY(nodes[0], nodes[0].bars)
self.assertEqual(True,bars[1].is_computed)
self.assertAlmostEqual(728.95, bars[1].axial_load, decimal_place)
def test_SumofForcesX_Example_3_3_Init(self):
decimal_place = 2
nodes, bars = Main.LoadAndComputeReactions("Example_3_3.csv")
self.assertEqual(False,bars[1].is_computed)
bars[1].axial_load = 728.952
bars[1].is_computed = True
moj.SumOfForcesInLocalX(nodes[0], bars[0])
self.assertEqual(True,bars[0].is_computed)
self.assertAlmostEqual(-692.781, bars[0].axial_load, decimal_place)
def test_SumofForcesY_Example_3_3_Next(self):
decimal_place = 2
nodes, bars = Main.LoadAndComputeReactions("Example_3_3.csv")
self.assertEqual(False,bars[1].is_computed)
self.assertEqual(False,bars[0].is_computed)
bars[1].axial_load = 728.952
bars[1].is_computed = True
bars[0].axial_load = -692.781
bars[0].is_computed = True
moj.SumOfForcesInLocalY(nodes[1], [bars[2],bars[3]])
self.assertEqual(True,bars[3].is_computed)
self.assertAlmostEqual(-639.19, bars[3].axial_load, decimal_place)
def test_SumofForcesX_Example_3_3_Next(self):
decimal_place = 2
nodes, bars = Main.LoadAndComputeReactions("Example_3_3.csv")
self.assertEqual(False,bars[1].is_computed)
self.assertEqual(False,bars[0].is_computed)
self.assertEqual(False,bars[3].is_computed)
bars[1].axial_load = 728.952
bars[1].is_computed = True
bars[0].axial_load = -692.781
bars[0].is_computed = True
bars[3].axial_load = -639.190
bars[3].is_computed = True
moj.SumOfForcesInLocalX(nodes[1], bars[2])
self.assertEqual(True,bars[2].is_computed)
self.assertAlmostEqual(-207.055, bars[2].axial_load, decimal_place)
def test_MethodOfJoints_Example_3_3(self):
decimal_place = 2
nodes, bars = Main.MethodOfJoints("Example_3_3.csv")
bar_forces = [-692.781,
728.952,
-207.055,
-639.190,
-639.190,
728.951,
0.00,
-639.190,
521.896]
for i in range(0,len(bars)):
bar = bars[i]
self.assertAlmostEqual(bar_forces[i], bar.axial_load, decimal_place)
def test_MethodOfJoints_Example_3_2(self):
decimal_place = 2
nodes, bars = Main.MethodOfJoints("Example_3_2.csv")
bar_forces = [-8.00,
6.928,
-3.00,
-5.00,
1.732,
3.464,
1.732,
-5.00,
-3.00,
6.928,
-8.00]
for i in range(0,len(bars)):
bar = bars[i]
self.assertAlmostEqual(bar_forces[i], bar.axial_load, decimal_place)
if __name__ == '__main__':
unittest.main()