first commit

This commit is contained in:
Senad Uka
2017-11-07 09:23:57 +01:00
commit 0eee92660a
356 changed files with 747259 additions and 0 deletions

View File

View File

View File

@@ -0,0 +1,122 @@
import unittest
from unittest.mock import MagicMock
from nose.tools import eq_
from helix.calculators.ballast_calculator import BallastCalculator
from helix.constants.module_type import ModuleType
from helix.constants.panel_type import PanelType
from helix.constants.system_type import SystemType
class BallastAndTrayCountTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
self.system_type = SystemType.singleTilt
self.module_type = ModuleType.Cell128
self.values.system_type.return_value = self.system_type
self.values.module_system_constants.return_value = self.system_type.module_constants(self.module_type)
self.subject = BallastCalculator(self.values)
self.panel_type = PanelType.EastWest
self.ballast_block_weight = 20
self.anchor_count = 0
def test_no_ballast(self):
self.force_to_resist = 0
result = self.subject.ballast_and_tray_count(self.force_to_resist, self.panel_type, self.ballast_block_weight, self.anchor_count)
eq_(result.ballast_count, 0)
eq_(result.link_tray_count, 0)
eq_(result.cross_tray_count, 0)
eq_(result.system_weight, 69.75)
eq_(result.needs_anchor, False)
def test_ballast_no_trays(self):
self.force_to_resist = 140
result = self.subject.ballast_and_tray_count(self.force_to_resist, self.panel_type, self.ballast_block_weight, self.anchor_count)
eq_(result.ballast_count, 4)
eq_(result.link_tray_count, 0)
eq_(result.cross_tray_count, 0)
eq_(result.system_weight, 69.75)
eq_(result.needs_anchor, False)
def test_ballast_and_link_trays(self):
self.force_to_resist = 230
result = self.subject.ballast_and_tray_count(self.force_to_resist, self.panel_type, self.ballast_block_weight, self.anchor_count)
eq_(result.ballast_count, 8)
eq_(result.link_tray_count, 1)
eq_(result.cross_tray_count, 0)
eq_(result.system_weight, 72.05)
eq_(result.needs_anchor, False)
def test_ballast_and_oscillate_between_0_and_1_link_trays(self):
self.force_to_resist = 210
result = self.subject.ballast_and_tray_count(self.force_to_resist, self.panel_type, self.ballast_block_weight, self.anchor_count)
eq_(result.ballast_count, 7)
eq_(result.link_tray_count, 1)
eq_(result.cross_tray_count, 0)
eq_(result.system_weight, 72.05)
eq_(result.needs_anchor, False)
def test_ballast_and_link_tray_and_cross_tray(self):
self.force_to_resist = 390
result = self.subject.ballast_and_tray_count(self.force_to_resist, self.panel_type, self.ballast_block_weight, self.anchor_count)
eq_(result.ballast_count, 16)
eq_(result.link_tray_count, 1)
eq_(result.cross_tray_count, 1)
eq_(result.system_weight, 75.23)
eq_(result.needs_anchor, False)
def test_ballast_and_link_tray_and_oscillate_between_0_and_1_cross_trays(self):
self.force_to_resist = 330
result = self.subject.ballast_and_tray_count(self.force_to_resist, self.panel_type, self.ballast_block_weight, self.anchor_count)
eq_(result.ballast_count, 13)
eq_(result.link_tray_count, 1)
eq_(result.cross_tray_count, 0)
eq_(result.system_weight, 72.05)
eq_(result.needs_anchor, False)
def test_ballast_and_link_tray_and_2_cross_trays(self):
self.force_to_resist = 570
result = self.subject.ballast_and_tray_count(self.force_to_resist, self.panel_type, self.ballast_block_weight, self.anchor_count)
eq_(result.ballast_count, 25)
eq_(result.link_tray_count, 1)
eq_(result.cross_tray_count, 2)
eq_(result.system_weight, 78.41)
eq_(result.needs_anchor, False)
def test_ballast_and_link_tray_and_at_first_2_then_1_cross_trays(self):
self.force_to_resist = 515
result = self.subject.ballast_and_tray_count(self.force_to_resist, self.panel_type, self.ballast_block_weight, self.anchor_count)
eq_(result.ballast_count, 22)
eq_(result.link_tray_count, 1)
eq_(result.cross_tray_count, 1)
eq_(result.system_weight, 75.23)
eq_(result.needs_anchor, False)
def test_ballast_and_all_trays_and_anchor(self):
self.force_to_resist = 770
result = self.subject.ballast_and_tray_count(self.force_to_resist, self.panel_type, self.ballast_block_weight, self.anchor_count)
eq_(result.ballast_count, 35)
eq_(result.link_tray_count, 1)
eq_(result.cross_tray_count, 2)
eq_(result.system_weight, 78.41)
eq_(result.needs_anchor, True)
def test_ballast_and_all_trays_and_at_first_anchor_then_no_anchor(self):
self.force_to_resist = 675
result = self.subject.ballast_and_tray_count(self.force_to_resist, self.panel_type, self.ballast_block_weight, self.anchor_count)
eq_(result.ballast_count, 30)
eq_(result.link_tray_count, 1)
eq_(result.cross_tray_count, 2)
eq_(result.system_weight, 78.41)
eq_(result.needs_anchor, False)

View File

@@ -0,0 +1,252 @@
import unittest
from unittest.mock import MagicMock
from nose.tools import assert_almost_equal, eq_
from numpy import array
from numpy.testing import assert_array_equal
from helix.calculators.ballast_calculator import BallastCalculator
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type import ModuleType
from helix.constants.panel_type import PanelType
from helix.constants.system_type import SystemType
from helix.models.panel import Panel, PanelWarnings
from test.test_helpers import assert_array_is_close
class BallastCalculatorWhenDualTiltAnd128CellTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
"""
Generated using site parameters:
height: 100
length: 1000
width: 1500
parapet: 0
wind_speed: 110
exposure_category: D
"""
self.c_p_matrix = array([[0.751977, 0.656898, 0.662582, 0.570086],
[0.568747, 0.491495, 0.496113, 0.420960],
[0.352521, 0.304321, 0.307202, 0.260312],
[0.197385, 0.171634, 0.173174, 0.148123],
[0.060000, 0.050000, 0.052000, 0.039000]
])
self.system_type = SystemType.dualTilt
self.module_type = ModuleType.Cell128
self.values.max_system_pressure.return_value = 100
self.values.system_type.return_value = self.system_type
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip
self.values.module_system_constants.return_value = self.system_type.module_constants(self.module_type)
self.q_z = 37.72825742
self.subject = BallastCalculator(self.values)
def test_summary_table(self):
self.values.ballast_block_weight.return_value = 20
self.values.max_system_pressure.return_value = 17
expected_value = {
PanelType.Corner: {
'anchors': [3, 2, 0, 0, 0],
'ballast blocks': [15, 14, 25, 12, 0],
'pressure': ['8.14', '7.74', '12.11', '6.88', '2.12']
},
PanelType.NorthSouth: {
'anchors': [3, 2, 0, 0, 0],
'ballast blocks': [7, 8, 22, 10, 0],
'pressure': ['4.90', '5.29', '10.83', '6.05', '2.10']
},
PanelType.EastWest: {
'anchors': [3, 2, 0, 0, 0],
'ballast blocks': [8, 8, 22, 10, 0],
'pressure': ['5.25', '5.25', '10.78', '5.97', '2.02']
},
PanelType.Middle: {
'anchors': [2, 0, 0, 0, 0],
'ballast blocks': [15, 32, 18, 8, 0],
'pressure': ['8.02', '14.73', '9.13', '5.17', '1.99']
},
}
received_table = self.subject.summary_table(self.c_p_matrix, self.q_z)
eq_(received_table.keys(), expected_value.keys())
for key in expected_value.keys():
received_table[key].pop('warnings')
self.assertDictEqual(received_table[key], expected_value[key])
# Because the above is way more explicit than simply 'eq_(received_table, expected_value)'
def test_ballast_and_trays_matrix(self):
raw_data = [
Panel(wind_zone=2, panel_type=PanelType.Corner),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth),
Panel(wind_zone=4, panel_type=PanelType.EastWest),
Panel(wind_zone=0, panel_type=PanelType.Corner),
Panel(wind_zone=1, panel_type=PanelType.Middle),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth),
Panel(wind_zone=1, panel_type=PanelType.Corner)
]
self.values.ballast_block_weight.return_value = 20
expected_value = [
Panel(wind_zone=2, panel_type=PanelType.Corner, ballast=25, link_tray=2, cross_tray=2, wind_anchors=0,
pressure=12.11),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, ballast=22, link_tray=2, cross_tray=1, wind_anchors=0,
pressure=10.83),
Panel(wind_zone=4, panel_type=PanelType.EastWest, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0,
pressure=2.02),
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=15, link_tray=2, cross_tray=1, wind_anchors=3,
pressure=8.14),
Panel(wind_zone=1, panel_type=PanelType.Middle, ballast=32, link_tray=2, cross_tray=3, wind_anchors=0,
pressure=14.73),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, ballast=10, link_tray=1, cross_tray=0, wind_anchors=0,
pressure=6.05),
Panel(wind_zone=1, panel_type=PanelType.Corner, ballast=44, link_tray=2, cross_tray=4, wind_anchors=0,
pressure=19.65)
]
assert_array_is_close(self.subject.ballast_and_trays_matrix(self.c_p_matrix, self.q_z, raw_data),
expected_value, decimal=2)
def test_ballast_and_trays_matrix_ups_ballast_for_fuzzy_wind_zone(self):
raw_data = [
Panel(wind_zone=2, panel_type=PanelType.Corner, fuzzy_wind_zone=True),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, fuzzy_wind_zone=True),
Panel(wind_zone=4, panel_type=PanelType.EastWest, fuzzy_wind_zone=True),
Panel(wind_zone=0, panel_type=PanelType.Corner, fuzzy_wind_zone=True),
Panel(wind_zone=1, panel_type=PanelType.Middle, fuzzy_wind_zone=True),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, fuzzy_wind_zone=True),
Panel(wind_zone=1, panel_type=PanelType.Corner, fuzzy_wind_zone=True)
]
self.values.ballast_block_weight.return_value = 20
expected_value = [
Panel(wind_zone=2, panel_type=PanelType.Corner, ballast=30, link_tray=2, cross_tray=2, wind_anchors=0,
pressure=14.06, fuzzy_wind_zone=True),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, ballast=25, link_tray=2, cross_tray=2, wind_anchors=0,
pressure=12.06, fuzzy_wind_zone=True),
Panel(wind_zone=4, panel_type=PanelType.EastWest, ballast=1, link_tray=0, cross_tray=0, wind_anchors=0,
pressure=2.41, fuzzy_wind_zone=True),
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=10, link_tray=2, cross_tray=1, wind_anchors=4,
pressure=6.18, fuzzy_wind_zone=True, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=1, panel_type=PanelType.Middle, ballast=37, link_tray=2, cross_tray=4, wind_anchors=0,
pressure=16.75, fuzzy_wind_zone=True),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, ballast=12, link_tray=2, cross_tray=0, wind_anchors=0,
pressure=6.86, fuzzy_wind_zone=True),
Panel(wind_zone=1, panel_type=PanelType.Corner, ballast=7, link_tray=2, cross_tray=0, wind_anchors=3,
pressure=4.93, fuzzy_wind_zone=True)
]
assert_array_is_close(self.subject.ballast_and_trays_matrix(self.c_p_matrix, self.q_z, raw_data),
expected_value, decimal=2)
def test_update_ballast(self):
self.values.ballast_block_weight.return_value = 20
self.values.max_system_pressure.return_value = 17
panels = [
Panel(wind_zone=2, panel_type=PanelType.Corner, wind_anchors=0, seismic_anchors=1),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, wind_anchors=0, seismic_anchors=1),
Panel(wind_zone=4, panel_type=PanelType.EastWest, wind_anchors=0, seismic_anchors=1),
Panel(wind_zone=0, panel_type=PanelType.Corner, wind_anchors=3, seismic_anchors=0),
Panel(wind_zone=1, panel_type=PanelType.Middle, wind_anchors=0, seismic_anchors=1),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, wind_anchors=0, seismic_anchors=1),
Panel(wind_zone=1, panel_type=PanelType.Corner, wind_anchors=2, seismic_anchors=0)
]
expected = [
Panel(wind_zone=2, panel_type=PanelType.Corner, wind_anchors=0, seismic_anchors=1,
ballast=11, link_tray=2, cross_tray=0, pressure=6.49),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, wind_anchors=0, seismic_anchors=1,
ballast=6, link_tray=1, cross_tray=0, pressure=4.49),
Panel(wind_zone=4, panel_type=PanelType.EastWest, wind_anchors=0, seismic_anchors=1,
ballast=0, link_tray=0, cross_tray=0, pressure=2.02),
Panel(wind_zone=0, panel_type=PanelType.Corner, wind_anchors=3, seismic_anchors=0,
ballast=15, link_tray=2, cross_tray=1, pressure=8.14),
Panel(wind_zone=1, panel_type=PanelType.Middle, wind_anchors=0, seismic_anchors=1,
ballast=17, link_tray=2, cross_tray=2, pressure=8.81),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, wind_anchors=0, seismic_anchors=1,
ballast=0, link_tray=0, cross_tray=0, pressure=2.10),
Panel(wind_zone=1, panel_type=PanelType.Corner, wind_anchors=2, seismic_anchors=0,
ballast=14, link_tray=2, cross_tray=1, pressure=7.74),
]
result = self.subject.update_ballast(self.c_p_matrix, self.q_z, panels)
assert_array_is_close(result, expected, decimal=2)
def test_presented_link_trays(self):
panels = [
Panel(panel_type=PanelType.Corner, link_tray=2),
Panel(panel_type=PanelType.NorthSouth, link_tray=2),
Panel(panel_type=PanelType.EastWest, link_tray=0),
Panel(panel_type=PanelType.Corner, link_tray=2),
Panel(panel_type=PanelType.Middle, link_tray=2),
Panel(panel_type=PanelType.NorthSouth, link_tray=1),
Panel(panel_type=PanelType.Corner, link_tray=2),
]
expected = [
Panel(presented_link_tray=2, panel_type=PanelType.Corner, link_tray=2),
Panel(presented_link_tray=2, panel_type=PanelType.NorthSouth, link_tray=2),
Panel(presented_link_tray=1, panel_type=PanelType.EastWest, link_tray=0),
Panel(presented_link_tray=2, panel_type=PanelType.Corner, link_tray=2),
Panel(presented_link_tray=1, panel_type=PanelType.Middle, link_tray=2),
Panel(presented_link_tray=2, panel_type=PanelType.NorthSouth, link_tray=1),
Panel(presented_link_tray=2, panel_type=PanelType.Corner, link_tray=2)
]
assert_array_equal(self.subject.show_presented_link_trays(panels), expected)
def test_pressure_exceeeding_max_system_pressure(self):
self.values.ballast_block_weight.return_value = 20
self.values.max_system_pressure.return_value = 17
panel_data = [
Panel(wind_zone=2, panel_type=PanelType.Corner),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth),
Panel(wind_zone=4, panel_type=PanelType.EastWest),
Panel(wind_zone=0, panel_type=PanelType.Corner),
Panel(wind_zone=1, panel_type=PanelType.Middle),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth),
Panel(wind_zone=1, panel_type=PanelType.Corner)
]
expected_value = [
Panel(wind_zone=2, panel_type=PanelType.Corner, ballast=25, link_tray=2, cross_tray=2, wind_anchors=0, pressure=12.11),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, ballast=22, link_tray=2, cross_tray=1, wind_anchors=0, pressure=10.83),
Panel(wind_zone=4, panel_type=PanelType.EastWest, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, pressure=2.02),
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=15, link_tray=2, cross_tray=1, wind_anchors=3, pressure=8.14),
Panel(wind_zone=1, panel_type=PanelType.Middle, ballast=32, link_tray=2, cross_tray=3, wind_anchors=0, pressure=14.73),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, ballast=10, link_tray=1, cross_tray=0, wind_anchors=0, pressure=6.05),
Panel(wind_zone=1, panel_type=PanelType.Corner, ballast=14, link_tray=2, cross_tray=1, wind_anchors=2, pressure=7.74)
]
assert_array_is_close(self.subject.ballast_and_trays_matrix(self.c_p_matrix, self.q_z, panel_data), expected_value, decimal=2)
def test_ballast_count_when_base_weight_greater_than_uplift(self):
expected = Panel(wind_zone=4, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, pressure=1.99)
assert self.subject.ballast_tray_and_anchor_count(4, PanelType.Middle, 14, 100, self.c_p_matrix, self.q_z).almost_equal(expected, decimal=2)
def test_individual_ballast_block_uplift_greater_than_base_weight(self):
expected = Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=21, link_tray=2, cross_tray=2, wind_anchors=2, pressure=7.91)
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Middle, 14, 100, self.c_p_matrix, self.q_z).almost_equal(expected, decimal=2)
expected = Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=15, link_tray=2, cross_tray=2, wind_anchors=2, pressure=8.02)
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Middle, 20, 100, self.c_p_matrix, self.q_z).almost_equal(expected, decimal=2)
def test_ballast_blocks_exceeding_tray_capacity(self):
expected = Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=24, link_tray=2, cross_tray=3, wind_anchors=2, pressure=7.85)
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Middle, 12, 100, self.c_p_matrix, self.q_z).almost_equal(expected, decimal=2)
def test_when_max_system_pressure_is_lower_than_base_weight_pressure(self):
max_system_pressure = 0
expected = Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=3, pressure=1.99)
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Middle, 12, max_system_pressure, self.c_p_matrix, self.q_z).almost_equal(
expected,
decimal=2)
def test_uplift(self):
assert_almost_equal(self.subject.uplift(0.62717, self.q_z), 1102.2, 1)
def test_calculate_single_unit_pressure_on_roof(self):
assert_almost_equal(self.subject.calculate_pressure_on_roof(78, 12, 105.23), 20.3417625, 6)

View File

@@ -0,0 +1,245 @@
import unittest
from unittest.mock import MagicMock
from nose.tools import assert_almost_equal, eq_
from numpy import array
from numpy.testing import assert_array_equal
from helix.calculators.ballast_calculator import BallastCalculator
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type import ModuleType
from helix.constants.panel_type import PanelType
from helix.constants.system_type import SystemType
from helix.models.panel import Panel
from test.test_helpers import assert_array_is_close
class BallastCalculatorWhenDualTiltAnd96CellTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
"""
Generated using site parameters:
height: 100
length: 1000
width: 1500
parapet: 0
wind_speed: 110
exposure_category: D
"""
self.c_p_matrix = array([[0.7800, 0.70, 0.68, 0.546],
[0.5949, 0.52, 0.51, 0.400],
[0.3700, 0.32, 0.32, 0.250],
[0.2100, 0.18, 0.18, 0.140],
[0.0600, 0.05, 0.05, 0.040]])
self.system_type = SystemType.dualTilt
self.module_type = ModuleType.Cell96
self.values.max_system_pressure.return_value = 100
self.values.system_type.return_value = self.system_type
self.values.module_type.return_value = self.module_type
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip
self.values.module_system_constants.return_value = self.system_type.module_constants(self.module_type)
self.q_z = 37.729
self.subject = BallastCalculator(self.values)
def test_summary_table(self):
self.values.ballast_block_weight.return_value = 20
self.values.max_system_pressure.return_value = 17
expected_value = {
PanelType.Corner: {
'anchors': [3, 2, 0, 0, 0],
'ballast blocks': [2, 5, 20, 10, 0],
'pressure': ['3.48', '5.03', '12.90', '7.62', '2.40']
},
PanelType.NorthSouth: {
'anchors': [2, 1, 0, 0, 0],
'ballast blocks': [11, 15, 17, 8, 0],
'pressure': ['8.24', '10.32', '11.35', '6.59', '2.40']
},
PanelType.EastWest: {
'anchors': [2, 1, 0, 0, 0],
'ballast blocks': [10, 14, 17, 8, 0],
'pressure': ['7.55', '9.63', '11.18', '6.46', '2.26']
},
PanelType.Middle: {
'anchors': [2, 0, 0, 0, 0],
'ballast blocks': [2, 22, 12, 5, 0],
'pressure': ['3.34', '13.83', '8.59', '4.85', '2.26']
},
}
received_table = self.subject.summary_table(self.c_p_matrix, self.q_z)
eq_(received_table.keys(), expected_value.keys())
for key in expected_value.keys():
received_table[key].pop('warnings')
self.assertDictEqual(received_table[key], expected_value[key])
# Because the above is way more explicit than simply 'eq_(received_table, expected_value)'
def test_ballast_and_trays_matrix(self):
panels = [
Panel(wind_zone=2, panel_type=PanelType.Corner),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth),
Panel(wind_zone=4, panel_type=PanelType.EastWest),
Panel(wind_zone=0, panel_type=PanelType.Corner),
Panel(wind_zone=1, panel_type=PanelType.Middle),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth),
Panel(wind_zone=1, panel_type=PanelType.Corner),
]
self.values.ballast_block_weight.return_value = 20
# Ballast, link tray, cross tray, anchor count, psf
expected_value = [
Panel(wind_zone=2, panel_type=PanelType.Corner, ballast=20, link_tray=2, cross_tray=1, wind_anchors=0, pressure=12.90),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, ballast=17, link_tray=2, cross_tray=1, wind_anchors=0, pressure=11.35),
Panel(wind_zone=4, panel_type=PanelType.EastWest, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, pressure=2.26),
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=47, link_tray=2, cross_tray=4, wind_anchors=0, pressure=27.07),
Panel(wind_zone=1, panel_type=PanelType.Middle, ballast=22, link_tray=2, cross_tray=2, wind_anchors=0, pressure=13.82),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, ballast=8, link_tray=1, cross_tray=0, wind_anchors=0, pressure=6.59),
Panel(wind_zone=1, panel_type=PanelType.Corner, ballast=35, link_tray=2, cross_tray=3, wind_anchors=0, pressure=20.79)
]
assert_array_is_close(self.subject.ballast_and_trays_matrix(self.c_p_matrix, self.q_z, panels), expected_value, decimal=2)
def test_update_ballast(self):
self.values.ballast_block_weight.return_value = 20
self.values.max_system_pressure.return_value = 17
panels = [
Panel(wind_zone=2, panel_type=PanelType.Corner, wind_anchors=0, seismic_anchors=1),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, wind_anchors=0, seismic_anchors=1),
Panel(wind_zone=4, panel_type=PanelType.EastWest, wind_anchors=0, seismic_anchors=1),
Panel(wind_zone=0, panel_type=PanelType.Corner, wind_anchors=3, seismic_anchors=0),
Panel(wind_zone=1, panel_type=PanelType.Middle, wind_anchors=0, seismic_anchors=1),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, wind_anchors=0, seismic_anchors=1),
Panel(wind_zone=1, panel_type=PanelType.Corner, wind_anchors=2, seismic_anchors=0)
]
expected_value = [
Panel(wind_zone=2, panel_type=PanelType.Corner, wind_anchors=0, seismic_anchors=1, ballast=5, link_tray=0, cross_tray=0, pressure=4.99),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, wind_anchors=0, seismic_anchors=1, ballast=2, link_tray=0, cross_tray=0, pressure=3.43),
Panel(wind_zone=4, panel_type=PanelType.EastWest, wind_anchors=0, seismic_anchors=1, ballast=0, link_tray=0, cross_tray=0, pressure=2.26),
Panel(wind_zone=0, panel_type=PanelType.Corner, wind_anchors=3, seismic_anchors=0, ballast=2, link_tray=1, cross_tray=0, pressure=3.48),
Panel(wind_zone=1, panel_type=PanelType.Middle, wind_anchors=0, seismic_anchors=1, ballast=7, link_tray=2, cross_tray=0, pressure=5.94),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, wind_anchors=0, seismic_anchors=1, ballast=0, link_tray=0, cross_tray=0, pressure=2.40),
Panel(wind_zone=1, panel_type=PanelType.Corner, wind_anchors=2, seismic_anchors=0, ballast=5, link_tray=1, cross_tray=0, pressure=5.03)
]
result = self.subject.update_ballast(self.c_p_matrix, self.q_z, panels)
assert_array_is_close(result, expected_value, decimal=2)
def test_update_ballast_with_fuzzy_wind_zone(self):
self.values.ballast_block_weight.return_value = 20
self.values.max_system_pressure.return_value = 17
panels = [
Panel(wind_zone=2, panel_type=PanelType.Corner, wind_anchors=0, seismic_anchors=1, fuzzy_wind_zone=True),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, wind_anchors=0, seismic_anchors=1, fuzzy_wind_zone=True),
Panel(wind_zone=4, panel_type=PanelType.EastWest, wind_anchors=0, seismic_anchors=1, fuzzy_wind_zone=True),
Panel(wind_zone=0, panel_type=PanelType.Corner, wind_anchors=3, seismic_anchors=0, fuzzy_wind_zone=True),
Panel(wind_zone=1, panel_type=PanelType.Middle, wind_anchors=0, seismic_anchors=1, fuzzy_wind_zone=True),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, wind_anchors=0, seismic_anchors=1, fuzzy_wind_zone=True),
Panel(wind_zone=1, panel_type=PanelType.Corner, wind_anchors=2, seismic_anchors=0, fuzzy_wind_zone=True)
]
expected_value = [
Panel(wind_zone=2, panel_type=PanelType.Corner, wind_anchors=0, seismic_anchors=1, ballast=9, link_tray=2, cross_tray=0, pressure=7.15, fuzzy_wind_zone=True),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, wind_anchors=0, seismic_anchors=1, ballast=5, link_tray=0, cross_tray=0, pressure=4.99, fuzzy_wind_zone=True),
Panel(wind_zone=4, panel_type=PanelType.EastWest, wind_anchors=0, seismic_anchors=1, ballast=0, link_tray=0, cross_tray=0, pressure=2.26, fuzzy_wind_zone=True),
Panel(wind_zone=0, panel_type=PanelType.Corner, wind_anchors=3, seismic_anchors=0, ballast=9, link_tray=2, cross_tray=0, pressure=7.15, fuzzy_wind_zone=True),
Panel(wind_zone=1, panel_type=PanelType.Middle, wind_anchors=0, seismic_anchors=1, ballast=11, link_tray=2, cross_tray=1, pressure=8.07, fuzzy_wind_zone=True),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, wind_anchors=0, seismic_anchors=1, ballast=0, link_tray=0, cross_tray=0, pressure=2.40, fuzzy_wind_zone=True),
Panel(wind_zone=1, panel_type=PanelType.Corner, wind_anchors=2, seismic_anchors=0, ballast=11, link_tray=2, cross_tray=0, pressure=8.18, fuzzy_wind_zone=True)
]
result = self.subject.update_ballast(self.c_p_matrix, self.q_z, panels)
assert_array_is_close(result, expected_value, decimal=2)
def test_presented_link_trays(self):
panels = [
Panel(panel_type=PanelType.Corner, link_tray=2),
Panel(panel_type=PanelType.NorthSouth, link_tray=2),
Panel(panel_type=PanelType.EastWest, link_tray=0),
Panel(panel_type=PanelType.Corner, link_tray=2),
Panel(panel_type=PanelType.Middle, link_tray=2),
Panel(panel_type=PanelType.NorthSouth, link_tray=1),
Panel(panel_type=PanelType.Corner, link_tray=2)
]
expected_value = [
Panel(presented_link_tray=2, panel_type=PanelType.Corner, link_tray=2),
Panel(presented_link_tray=2, panel_type=PanelType.NorthSouth, link_tray=2),
Panel(presented_link_tray=1, panel_type=PanelType.EastWest, link_tray=0),
Panel(presented_link_tray=2, panel_type=PanelType.Corner, link_tray=2),
Panel(presented_link_tray=1, panel_type=PanelType.Middle, link_tray=2),
Panel(presented_link_tray=2, panel_type=PanelType.NorthSouth, link_tray=1),
Panel(presented_link_tray=2, panel_type=PanelType.Corner, link_tray=2)
]
assert_array_equal(self.subject.show_presented_link_trays(panels), expected_value)
def test_pressure_exceeeding_max_system_pressure(self):
self.values.ballast_block_weight.return_value = 20
self.values.max_system_pressure.return_value = 17
panels = [
Panel(wind_zone=2, panel_type=PanelType.Corner),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth),
Panel(wind_zone=4, panel_type=PanelType.EastWest),
Panel(wind_zone=0, panel_type=PanelType.Corner),
Panel(wind_zone=1, panel_type=PanelType.Middle),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth),
Panel(wind_zone=1, panel_type=PanelType.Corner)
]
expected_value = [
Panel(wind_zone=2, panel_type=PanelType.Corner, ballast=20, link_tray=2, cross_tray=1, wind_anchors=0, pressure=12.90),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, ballast=17, link_tray=2, cross_tray=1, wind_anchors=0, pressure=11.35),
Panel(wind_zone=4, panel_type=PanelType.EastWest, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, pressure=2.26),
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=2, link_tray=1, cross_tray=0, wind_anchors=3, pressure=3.48),
Panel(wind_zone=1, panel_type=PanelType.Middle, ballast=22, link_tray=2, cross_tray=2, wind_anchors=0, pressure=13.83),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, ballast=8, link_tray=1, cross_tray=0, wind_anchors=0, pressure=6.59),
Panel(wind_zone=1, panel_type=PanelType.Corner, ballast=5, link_tray=1, cross_tray=0, wind_anchors=2, pressure=5.03)
]
assert_array_is_close(self.subject.ballast_and_trays_matrix(self.c_p_matrix, self.q_z, panels), expected_value, decimal=2)
def test_ballast_count_when_base_weight_greater_than_uplift(self):
assert self.subject.ballast_tray_and_anchor_count(4, PanelType.Middle, 14, 100, self.c_p_matrix,
self.q_z).almost_equal(
Panel(wind_zone=4, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, pressure=2.26),
decimal=2)
def test_individual_ballast_block_uplift_greater_than_base_weight(self):
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Middle, 14, 100, self.c_p_matrix,
self.q_z).almost_equal(
Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=45, link_tray=2, cross_tray=4, wind_anchors=0, pressure=18.87),
decimal=2)
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Middle, 20, 100, self.c_p_matrix,
self.q_z).almost_equal(
Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=32, link_tray=2, cross_tray=3, wind_anchors=0, pressure=19.07),
decimal=2)
def test_ballast_blocks_exceeding_tray_capacity(self):
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Middle, 12, 100, self.c_p_matrix,
self.q_z).almost_equal(
Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=3, link_tray=1, cross_tray=0, wind_anchors=2, pressure=3.23),
decimal=2)
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Corner, 12, 100, self.c_p_matrix,
self.q_z).almost_equal(
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=3, link_tray=1, cross_tray=0, wind_anchors=3, pressure=3.37),
decimal=2)
def test_when_max_system_pressure_is_lower_than_base_weight_pressure(self):
max_system_pressure = 0
expected = Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0,
wind_anchors=3, pressure=2.26)
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Middle, 12,
max_system_pressure, self.c_p_matrix, self.q_z).almost_equal(expected, decimal=2)
def test_uplift(self):
assert_almost_equal(self.subject.uplift(0.62717, self.q_z), 831.50, 1)
def test_calculate_single_unit_pressure_on_roof(self):
assert_almost_equal(self.subject.calculate_pressure_on_roof(78, 12, 105.23), 26.96, 2)

View File

@@ -0,0 +1,306 @@
import unittest
from unittest.mock import MagicMock
from nose.tools import assert_almost_equal, eq_
from numpy import array
from numpy.testing import assert_array_equal
from helix.calculators.ballast_calculator import BallastCalculator
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type import ModuleType
from helix.constants.panel_type import PanelType
from helix.constants.system_type import SystemType
from helix.models.panel import Panel, PanelWarnings
from test.test_helpers import assert_array_is_close
class BallastCalculatorWhenDualTiltAndPSeriesTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
"""
Generated using site parameters:
height: 100
length: 1000
width: 1500
parapet: 0
wind_speed: 110
exposure_category: D
"""
self.c_p_matrix = array([[0.964647, 0.843638, 0.850871, 0.733149],
[0.730023, 0.631703, 0.637580, 0.541930],
[0.452508, 0.391163, 0.394830, 0.335151],
[0.253272, 0.220498, 0.222457, 0.190574],
[0.060000, 0.050000, 0.052000, 0.039000]])
self.system_type = SystemType.dualTilt
self.module_type = ModuleType.PSeries
self.values.max_system_pressure.return_value = 100
self.values.system_type.return_value = self.system_type
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip
self.values.module_system_constants.return_value = self.system_type.module_constants(self.module_type)
self.q_z = 37.72825742
self.subject = BallastCalculator(self.values)
def test_summary_table(self):
self.values.ballast_block_weight.return_value = 20
self.values.max_system_pressure.return_value = 17
expected_value = {
PanelType.Corner: {
'anchors': [4, 3, 0, 0, 0],
'ballast blocks': [15, 10, 33, 16, 0],
'pressure': ['8.43', '6.38', '15.93', '8.83', '2.12']
},
PanelType.NorthSouth: {
'anchors': [4, 3, 0, 0, 0],
'ballast blocks': [5, 2, 28, 14, 0],
'pressure': ['4.22', '2.97', '13.77', '7.90', '2.10']
},
PanelType.EastWest: {
'anchors': [4, 3, 0, 0, 0],
'ballast blocks': [6, 3, 28, 14, 0],
'pressure': ['4.58', '3.29', '13.72', '7.86', '2.01']
},
PanelType.Middle: {
'anchors': [3, 2, 0, 0, 0],
'ballast blocks': [11, 10, 23, 11, 0],
'pressure': ['6.61', '6.20', '11.59', '6.61', '1.99']
},
}
received_table = self.subject.summary_table(self.c_p_matrix, self.q_z)
eq_(received_table.keys(), expected_value.keys())
for key in expected_value.keys():
received_table[key].pop('warnings')
self.assertDictEqual(received_table[key], expected_value[key])
# Because the above is way more explicit than simply 'eq_(received_table, expected_value)'
def test_summary_table_when_special_small_building(self):
"""
Generated using site parameters:
height: 15
length: 100
width: 100
parapet: 0
wind_speed: 110
exposure_category: B
"""
self.c_p_matrix = array([[0.277131, 0.182052, 0.187735, 0.129774],
[0.182934, 0.115506, 0.118940, 0.084465],
[0.111800, 0.075909, 0.077290, 0.066873],
[0.068781, 0.050000, 0.052000, 0.039068],
[0.060000, 0.050000, 0.052000, 0.039000]])
self.system_type = SystemType.dualTilt
self.module_type = ModuleType.PSeries
self.values.max_system_pressure.return_value = 8
self.values.ballast_block_weight.return_value = 16
self.values.system_type.return_value = self.system_type
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip
self.values.module_system_constants.return_value = self.system_type.module_constants(self.module_type)
self.q_z = 18.43072
self.subject = BallastCalculator(self.values)
expected_value = {
PanelType.Corner: {
'anchors': [0, 0, 0, 0, 0],
'ballast blocks': [8, 3, 0, 0, 0],
'pressure': ['4.79', '3.11', '2.12', '2.12', '2.12']
},
PanelType.NorthSouth: {
'anchors': [0, 0, 0, 0, 0],
'ballast blocks': [3, 0, 0, 0, 0],
'pressure': ['3.08', '2.10', '2.10', '2.10', '2.10']
},
PanelType.EastWest: {
'anchors': [0, 0, 0, 0, 0],
'ballast blocks': [4, 0, 0, 0, 0],
'pressure': ['3.32', '2.01', '2.01', '2.01', '2.01']
},
PanelType.Middle: {
'anchors': [0, 0, 0, 0, 0],
'ballast blocks': [1, 0, 0, 0, 0],
'pressure': ['2.32', '1.99', '1.99', '1.99', '1.99']
},
}
received_table = self.subject.summary_table(self.c_p_matrix, self.q_z)
eq_(received_table.keys(), expected_value.keys())
for key in expected_value.keys():
received_table[key].pop('warnings')
self.assertDictEqual(received_table[key], expected_value[key])
def test_ballast_and_trays_matrix(self):
raw_data = [
Panel(wind_zone=2, panel_type=PanelType.Corner),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth),
Panel(wind_zone=4, panel_type=PanelType.EastWest),
Panel(wind_zone=0, panel_type=PanelType.Corner),
Panel(wind_zone=1, panel_type=PanelType.Middle),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth),
Panel(wind_zone=1, panel_type=PanelType.Corner)
]
self.values.ballast_block_weight.return_value = 20
expected_value = [
Panel(wind_zone=2, panel_type=PanelType.Corner, ballast=33, link_tray=2, cross_tray=3, wind_anchors=0,
pressure=15.93),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, ballast=28, link_tray=2, cross_tray=2, wind_anchors=0,
pressure=13.77),
Panel(wind_zone=4, panel_type=PanelType.EastWest, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0,
pressure=2.01),
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=15, link_tray=2, cross_tray=1, wind_anchors=4,
pressure=8.43, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=1, panel_type=PanelType.Middle, ballast=40, link_tray=2, cross_tray=4, wind_anchors=0,
pressure=18.68),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, ballast=14, link_tray=2, cross_tray=0, wind_anchors=0,
pressure=7.90),
Panel(wind_zone=1, panel_type=PanelType.Corner, ballast=10, link_tray=2, cross_tray=1, wind_anchors=3,
pressure=6.38),
]
assert_array_is_close(self.subject.ballast_and_trays_matrix(self.c_p_matrix, self.q_z, raw_data),
expected_value, decimal=2)
def test_update_ballast(self):
self.values.ballast_block_weight.return_value = 20
self.values.max_system_pressure.return_value = 17
panels = [
Panel(wind_zone=2, panel_type=PanelType.Corner, wind_anchors=0, seismic_anchors=1),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, wind_anchors=0, seismic_anchors=1),
Panel(wind_zone=4, panel_type=PanelType.EastWest, wind_anchors=0, seismic_anchors=1),
Panel(wind_zone=0, panel_type=PanelType.Corner, wind_anchors=4, seismic_anchors=0),
Panel(wind_zone=1, panel_type=PanelType.Middle, wind_anchors=0, seismic_anchors=1),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, wind_anchors=0, seismic_anchors=1),
Panel(wind_zone=1, panel_type=PanelType.Corner, wind_anchors=3, seismic_anchors=0)
]
expected = [
Panel(wind_zone=2, panel_type=PanelType.Corner, wind_anchors=0, seismic_anchors=1,
ballast=18, link_tray=2, cross_tray=1, pressure=9.65),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, wind_anchors=0, seismic_anchors=1,
ballast=13, link_tray=2, cross_tray=0, pressure=7.50),
Panel(wind_zone=4, panel_type=PanelType.EastWest, wind_anchors=0, seismic_anchors=1,
ballast=0, link_tray=0, cross_tray=0, pressure=2.01),
Panel(wind_zone=0, panel_type=PanelType.Corner, wind_anchors=4, seismic_anchors=0,
ballast=15, link_tray=2, cross_tray=1, pressure=8.43),
Panel(wind_zone=1, panel_type=PanelType.Middle, wind_anchors=0, seismic_anchors=1,
ballast=25, link_tray=2, cross_tray=3, pressure=12.47),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, wind_anchors=0, seismic_anchors=1,
ballast=0, link_tray=0, cross_tray=0, pressure=2.10),
Panel(wind_zone=1, panel_type=PanelType.Corner, wind_anchors=3, seismic_anchors=0,
ballast=10, link_tray=2, cross_tray=1, pressure=6.38),
]
result = self.subject.update_ballast(self.c_p_matrix, self.q_z, panels)
assert_array_is_close(result, expected, decimal=2)
def test_presented_link_trays(self):
panels = [
Panel(panel_type=PanelType.Corner, link_tray=2),
Panel(panel_type=PanelType.NorthSouth, link_tray=2),
Panel(panel_type=PanelType.EastWest, link_tray=0),
Panel(panel_type=PanelType.Corner, link_tray=2),
Panel(panel_type=PanelType.Middle, link_tray=2),
Panel(panel_type=PanelType.NorthSouth, link_tray=1),
Panel(panel_type=PanelType.Corner, link_tray=2),
]
expected = [
Panel(presented_link_tray=2, panel_type=PanelType.Corner, link_tray=2),
Panel(presented_link_tray=2, panel_type=PanelType.NorthSouth, link_tray=2),
Panel(presented_link_tray=1, panel_type=PanelType.EastWest, link_tray=0),
Panel(presented_link_tray=2, panel_type=PanelType.Corner, link_tray=2),
Panel(presented_link_tray=1, panel_type=PanelType.Middle, link_tray=2),
Panel(presented_link_tray=2, panel_type=PanelType.NorthSouth, link_tray=1),
Panel(presented_link_tray=2, panel_type=PanelType.Corner, link_tray=2)
]
assert_array_equal(self.subject.show_presented_link_trays(panels), expected)
def test_pressure_exceeeding_max_system_pressure(self):
self.values.ballast_block_weight.return_value = 20
self.values.max_system_pressure.return_value = 17
panel_data = [
Panel(wind_zone=2, panel_type=PanelType.Corner),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth),
Panel(wind_zone=4, panel_type=PanelType.EastWest),
Panel(wind_zone=0, panel_type=PanelType.Corner),
Panel(wind_zone=1, panel_type=PanelType.Middle),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth),
Panel(wind_zone=1, panel_type=PanelType.Corner)
]
expected_value = [
Panel(wind_zone=2, panel_type=PanelType.Corner, ballast=33, link_tray=2, cross_tray=3, wind_anchors=0, pressure=15.93),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, ballast=28, link_tray=2, cross_tray=2, wind_anchors=0, pressure=13.77),
Panel(wind_zone=4, panel_type=PanelType.EastWest, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, pressure=2.01),
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=15, link_tray=2, cross_tray=1, wind_anchors=4, pressure=8.43, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=1, panel_type=PanelType.Middle, ballast=10, link_tray=2, cross_tray=1, wind_anchors=2, pressure=6.20),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, ballast=14, link_tray=2, cross_tray=0, wind_anchors=0, pressure=7.90),
Panel(wind_zone=1, panel_type=PanelType.Corner, ballast=10, link_tray=2, cross_tray=1, wind_anchors=3, pressure=6.38)
]
assert_array_is_close(self.subject.ballast_and_trays_matrix(self.c_p_matrix, self.q_z, panel_data), expected_value, decimal=2)
def test_ballast_count_when_special_small_building(self):
"""
Generated using site parameters:
height: 15
length: 100
width: 100
parapet: 0
wind_speed: 110
exposure_category: B
"""
self.c_p_matrix = array([[0.277131, 0.182052, 0.187735, 0.129774],
[0.182934, 0.115506, 0.118940, 0.084465],
[0.111800, 0.075909, 0.077290, 0.066873],
[0.068781, 0.050000, 0.052000, 0.039068],
[0.060000, 0.050000, 0.052000, 0.039000]])
self.system_type = SystemType.dualTilt
self.module_type = ModuleType.PSeries
self.values.max_system_pressure.return_value = 8
self.values.ballast_block_weight.return_value = 16
self.values.system_type.return_value = self.system_type
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip
self.values.module_system_constants.return_value = self.system_type.module_constants(self.module_type)
self.q_z = 18.43072
self.subject = BallastCalculator(self.values)
expected = Panel(wind_zone=0, panel_type=PanelType.NorthSouth, ballast=3, link_tray=0, cross_tray=0, wind_anchors=0, pressure=3.08)
received = self.subject.ballast_tray_and_anchor_count(0, PanelType.NorthSouth, 16, 8, self.c_p_matrix, self.q_z)
assert received.almost_equal(expected, decimal=2)
def test_ballast_count_when_base_weight_greater_than_uplift(self):
expected = Panel(wind_zone=4, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, pressure=1.99)
assert self.subject.ballast_tray_and_anchor_count(4, PanelType.Middle, 14, 100, self.c_p_matrix, self.q_z).almost_equal(expected, decimal=2)
def test_individual_ballast_block_uplift_greater_than_base_weight(self):
expected = Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=15, link_tray=2, cross_tray=2, wind_anchors=3, pressure=6.47)
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Middle, 14, 100, self.c_p_matrix, self.q_z).almost_equal(expected, decimal=2)
expected = Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=11, link_tray=2, cross_tray=1, wind_anchors=3, pressure=6.61)
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Middle, 20, 100, self.c_p_matrix, self.q_z).almost_equal(expected, decimal=2)
def test_ballast_blocks_exceeding_tray_capacity(self):
expected = Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=18, link_tray=2, cross_tray=2, wind_anchors=3, pressure=6.59)
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Middle, 12, 100, self.c_p_matrix, self.q_z).almost_equal(expected, decimal=2)
def test_when_max_system_pressure_is_lower_than_base_weight_pressure(self):
max_system_pressure = 0
expected = Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=4, pressure=1.99)
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Middle, 12, max_system_pressure, self.c_p_matrix, self.q_z).almost_equal(
expected,
decimal=2)
def test_uplift(self):
assert_almost_equal(self.subject.uplift(0.62717, self.q_z), 1051.54, 1)
def test_calculate_single_unit_pressure_on_roof(self):
assert_almost_equal(self.subject.calculate_pressure_on_roof(78, 12, 105.23), 21.3213163825, 6)

View File

@@ -0,0 +1,270 @@
import unittest
from unittest.mock import MagicMock
from nose.tools import assert_almost_equal, eq_
from numpy import array
from numpy.testing import assert_array_equal
from helix.calculators.ballast_calculator import BallastCalculator
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type import ModuleType
from helix.constants.panel_type import PanelType
from helix.constants.system_type import SystemType
from helix.models.panel import Panel, PanelWarnings
from test.test_helpers import assert_array_is_close
class BallastCalculatorWhenSingleTiltAnd128CellTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
"""
Generated using site parameters:
height: 100
length: 1000
width: 1500
parapet: 0
wind_speed: 150
exposure_category: D
"""
self.c_p_matrix = array([[1.464330, 1.334027, 1.111689, 1.079155],
[1.152100, 1.046580, 0.872150, 0.845805],
[0.660541, 0.610771, 0.436265, 0.425614],
[0.663595, 0.595406, 0.425290, 0.410697],
[0.446503, 0.269616, 0.404423, 0.261210],
[0.425368, 0.384182, 0.295525, 0.286033],
[0.201015, 0.184521, 0.184521, 0.179580],
[0.542408, 0.486253, 0.486253, 0.469428],
[1.487760, 1.301254, 1.301254, 1.245374],
[0.888854, 0.789797, 0.394899, 0.380059],
[0.172217, 0.151210, 0.108007, 0.103511]])
self.system_type = SystemType.singleTilt
self.module_type = ModuleType.Cell128
self.values.max_system_pressure.return_value = 1000
self.values.system_type.return_value = self.system_type
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip
self.values.module_system_constants.return_value = self.system_type.module_constants(self.module_type)
self.q_z = 70.155851
self.subject = BallastCalculator(self.values)
def test_summary_table(self):
self.values.ballast_block_weight.return_value = 20
self.values.max_system_pressure.return_value = 17
expected_value = {
PanelType.Corner: {
'anchors': [7, 5, 3, 3, 2, 2, 0, 2, 7, 4, 0],
'ballast blocks': [9, 14, 5, 5, 3, 1, 13, 11, 11, 8, 11],
'pressure': ['7.43', '10.31', '4.95', '4.95', '3.79', '2.64', '9.55', '8.49', '8.58', '6.76', '8.40']
},
PanelType.NorthSouth: {
'anchors': [6, 5, 3, 2, 0, 1, 0, 2, 6, 4, 0],
'ballast blocks': [14, 6, 1, 15, 19, 13, 12, 6, 12, 1, 10],
'pressure': ['10.13', '5.44', '2.47', '10.71', '13.01', '9.46', '8.89', '5.35', '8.98', '2.47', '7.65']
},
PanelType.EastWest: {
'anchors': [5, 4, 2, 2, 1, 0, 0, 2, 6, 1, 0],
'ballast blocks': [11, 7, 2, 1, 15, 21, 12, 6, 11, 14, 6],
'pressure': ['8.49', '6.19', '3.16', '2.58', '10.79', '14.25', '8.98', '5.52', '8.58', '10.22', '5.46']
},
PanelType.Middle: {
'anchors': [5, 4, 2, 1, 0, 0, 0, 2, 6, 1, 0],
'ballast blocks': [9, 5, 2, 15, 18, 20, 12, 5, 7, 13, 6],
'pressure': ['7.21', '4.91', '3.02', '10.66', '12.39', '13.63', '8.93', '4.82', '6.06', '9.51', '5.32']
},
}
received_table = self.subject.summary_table(self.c_p_matrix, self.q_z)
eq_(received_table.keys(), expected_value.keys())
for key in expected_value.keys():
received_table[key].pop('warnings')
self.assertDictEqual(received_table[key], expected_value[key])
def test_ballast_and_trays_matrix(self):
panels = array([
Panel(wind_zone=5, panel_type=PanelType.Corner),
Panel(wind_zone=6, panel_type=PanelType.NorthSouth),
Panel(wind_zone=7, panel_type=PanelType.EastWest),
Panel(wind_zone=0, panel_type=PanelType.Corner),
Panel(wind_zone=8, panel_type=PanelType.Middle),
Panel(wind_zone=9, panel_type=PanelType.NorthSouth),
Panel(wind_zone=6, panel_type=PanelType.Corner),
Panel(wind_zone=6, panel_type=PanelType.EastWest)
])
self.values.ballast_block_weight.return_value = 20
expected_value = [
Panel(wind_zone=5, panel_type=PanelType.Corner, ballast=1, link_tray=0, cross_tray=0, wind_anchors=2,
pressure=2.64),
Panel(wind_zone=6, panel_type=PanelType.NorthSouth, ballast=12, link_tray=0, cross_tray=1, wind_anchors=0,
pressure=8.89),
Panel(wind_zone=7, panel_type=PanelType.EastWest, ballast=6, link_tray=2, cross_tray=0, wind_anchors=2,
pressure=5.52, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=9, link_tray=0, cross_tray=2, wind_anchors=7,
pressure=7.43, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=8, panel_type=PanelType.Middle, ballast=7, link_tray=1, cross_tray=1, wind_anchors=6,
pressure=6.06, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=9, panel_type=PanelType.NorthSouth, ballast=1, link_tray=0, cross_tray=0, wind_anchors=4,
pressure=2.47, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=6, panel_type=PanelType.Corner, ballast=13, link_tray=0, cross_tray=0, wind_anchors=0,
pressure=9.55),
Panel(wind_zone=6, panel_type=PanelType.EastWest, ballast=12, link_tray=2, cross_tray=0, wind_anchors=0,
pressure=8.98)
]
assert_array_is_close(self.subject.ballast_and_trays_matrix(self.c_p_matrix, self.q_z, panels),
expected_value, decimal=2)
def test_presented_link_trays(self):
panels = [
Panel(panel_type=PanelType.Corner, link_tray=0),
Panel(panel_type=PanelType.NorthSouth, link_tray=0),
Panel(panel_type=PanelType.EastWest, link_tray=2),
Panel(panel_type=PanelType.Corner, link_tray=0),
Panel(panel_type=PanelType.Middle, link_tray=1),
Panel(panel_type=PanelType.NorthSouth, link_tray=0),
Panel(panel_type=PanelType.Corner, link_tray=0),
Panel(panel_type=PanelType.NorthSouth, link_tray=0),
Panel(panel_type=PanelType.EastWest, link_tray=2),
Panel(panel_type=PanelType.Middle, link_tray=1),
Panel(panel_type=PanelType.Corner, link_tray=0),
Panel(panel_type=PanelType.NorthSouth, link_tray=0),
Panel(panel_type=PanelType.EastWest, link_tray=2),
Panel(panel_type=PanelType.Middle, link_tray=1),
]
expected = [
Panel(presented_link_tray=0, panel_type=PanelType.Corner, link_tray=0),
Panel(presented_link_tray=0, panel_type=PanelType.NorthSouth, link_tray=0),
Panel(presented_link_tray=2, panel_type=PanelType.EastWest, link_tray=2),
Panel(presented_link_tray=0, panel_type=PanelType.Corner, link_tray=0),
Panel(presented_link_tray=1, panel_type=PanelType.Middle, link_tray=1),
Panel(presented_link_tray=0, panel_type=PanelType.NorthSouth, link_tray=0),
Panel(presented_link_tray=0, panel_type=PanelType.Corner, link_tray=0),
Panel(presented_link_tray=0, panel_type=PanelType.NorthSouth, link_tray=0),
Panel(presented_link_tray=2, panel_type=PanelType.EastWest, link_tray=2),
Panel(presented_link_tray=1, panel_type=PanelType.Middle, link_tray=1),
Panel(presented_link_tray=0, panel_type=PanelType.Corner, link_tray=0),
Panel(presented_link_tray=0, panel_type=PanelType.NorthSouth, link_tray=0),
Panel(presented_link_tray=2, panel_type=PanelType.EastWest, link_tray=2),
Panel(presented_link_tray=1, panel_type=PanelType.Middle, link_tray=1)
]
assert_array_equal(self.subject.show_presented_link_trays(panels), expected)
def test_pressure_exceeding_max_system_pressure(self):
self.values.ballast_block_weight.return_value = 20
self.values.max_system_pressure.return_value = 25
panel_data = [
Panel(wind_zone=7, panel_type=PanelType.Corner),
Panel(wind_zone=7, panel_type=PanelType.NorthSouth),
Panel(wind_zone=9, panel_type=PanelType.EastWest),
Panel(wind_zone=5, panel_type=PanelType.Corner),
Panel(wind_zone=6, panel_type=PanelType.Middle),
Panel(wind_zone=8, panel_type=PanelType.NorthSouth),
Panel(wind_zone=6, panel_type=PanelType.Corner)
]
expected_value = [
Panel(wind_zone=7, panel_type=PanelType.Corner, ballast=11, link_tray=0, cross_tray=1,
wind_anchors=2, pressure=8.49, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=7, panel_type=PanelType.NorthSouth, ballast=6, link_tray=0, cross_tray=0,
wind_anchors=2, pressure=5.35, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=9, panel_type=PanelType.EastWest, ballast=29, link_tray=2, cross_tray=2,
wind_anchors=0, pressure=18.94),
Panel(wind_zone=5, panel_type=PanelType.Corner, ballast=1, link_tray=0, cross_tray=0,
wind_anchors=2, pressure=2.64),
Panel(wind_zone=6, panel_type=PanelType.Middle, ballast=12, link_tray=1, cross_tray=1,
wind_anchors=0, pressure=8.93),
Panel(wind_zone=8, panel_type=PanelType.NorthSouth, ballast=12, link_tray=0, cross_tray=2,
wind_anchors=6, pressure=8.98, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=6, panel_type=PanelType.Corner, ballast=13, link_tray=0, cross_tray=0,
wind_anchors=0, pressure=9.55)
]
assert_array_is_close(self.subject.ballast_and_trays_matrix(self.c_p_matrix, self.q_z, panel_data),
expected_value, decimal=2)
def test_ballast_count_when_base_weight_greater_than_uplift(self):
# Need to regenerate a c_p matrix to get to this case
"""
Generated using site parameters:
height: 30
length: 100
width: 100
parapet: 0
wind_speed: 110
exposure_category: B
"""
self.c_p_matrix = array([[0.788942, 0.628471, 0.523726, 0.350229],
[0.605171, 0.475222, 0.396018, 0.255521],
[0.402570, 0.341277, 0.243769, 0.186968],
[0.310157, 0.226181, 0.161558, 0.114584],
[0.228394, 0.153519, 0.176571, 0.085682],
[0.211896, 0.161175, 0.123981, 0.085682],
[0.179390, 0.153519, 0.109657, 0.085682],
[0.251345, 0.182189, 0.182189, 0.116534],
[0.521059, 0.291372, 0.291372, 0.127381],
[0.375420, 0.253428, 0.126714, 0.085682],
[0.179390, 0.153519, 0.109657, 0.085682]])
self.q_z = 18.446284
expected = Panel(wind_zone=10, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0,
wind_anchors=0, pressure=1.87)
assert self.subject.ballast_tray_and_anchor_count(10, PanelType.Middle, 14, 1000, self.c_p_matrix,
self.q_z).almost_equal(expected, decimal=2)
def test_individual_ballast_block_uplift_greater_than_base_weight(self):
expected = Panel(wind_zone=6, panel_type=PanelType.Middle, ballast=16, link_tray=1, cross_tray=1,
wind_anchors=0, pressure=8.47)
assert self.subject.ballast_tray_and_anchor_count(6, PanelType.Middle, 14, 1000, self.c_p_matrix,
self.q_z).almost_equal(expected, decimal=2)
expected = Panel(wind_zone=6, panel_type=PanelType.Middle, ballast=12, link_tray=1, cross_tray=1,
wind_anchors=0, pressure=8.93)
assert self.subject.ballast_tray_and_anchor_count(6, PanelType.Middle, 20, 1000, self.c_p_matrix,
self.q_z).almost_equal(expected, decimal=2)
def test_ballast_blocks_exceeding_tray_capacity(self):
expected = Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=9, link_tray=0, cross_tray=2,
wind_anchors=7, pressure=7.43, warnings=[PanelWarnings.MaxPsf])
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Corner, 20, 1000, self.c_p_matrix,
self.q_z).almost_equal(expected, decimal=2)
expected = Panel(wind_zone=8, panel_type=PanelType.Middle, ballast=7, link_tray=1, cross_tray=1,
wind_anchors=6, pressure=6.06, warnings=[PanelWarnings.MaxPsf])
assert self.subject.ballast_tray_and_anchor_count(8, PanelType.Middle, 20, 1000, self.c_p_matrix,
self.q_z).almost_equal(expected, decimal=2)
def test_ballast_blocks_when_panel_exceeds_max_system_pressure(self):
expected = Panel(wind_zone=5, panel_type=PanelType.Middle, ballast=7, link_tray=1, cross_tray=0,
wind_anchors=1, pressure=4.76)
assert self.subject.ballast_tray_and_anchor_count(5, PanelType.Middle, 14, 10, self.c_p_matrix,
self.q_z).almost_equal(expected, decimal=2)
expected = Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=13, link_tray=0, cross_tray=2,
wind_anchors=7, pressure=7.49, warnings=[PanelWarnings.MaxPsf])
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Corner, 14, 10, self.c_p_matrix,
self.q_z).almost_equal(expected, decimal=2)
def test_when_max_system_pressure_is_lower_than_base_weight_pressure(self):
max_system_pressure = 0
expected = Panel(wind_zone=5, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0,
wind_anchors=2, pressure=1.87)
assert self.subject.ballast_tray_and_anchor_count(5, PanelType.Middle, 12, max_system_pressure,
self.c_p_matrix, self.q_z).almost_equal(
expected,
decimal=2
)
def test_uplift(self):
assert_almost_equal(self.subject.uplift(1.506920, self.q_z), 2462.20, 2)
def test_calculate_single_unit_pressure_on_roof(self):
assert_almost_equal(self.subject.calculate_pressure_on_roof(90, 20, 59.1), 53.48, 2)
assert_almost_equal(self.subject.calculate_pressure_on_roof(15, 14, 54.5), 7.61, 2)

View File

@@ -0,0 +1,231 @@
import unittest
from unittest.mock import MagicMock
from nose.tools import assert_almost_equal, eq_
from numpy import array
from numpy.testing import assert_array_equal
from helix.calculators.ballast_calculator import BallastCalculator
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type import ModuleType
from helix.constants.panel_type import PanelType
from helix.constants.system_type import SystemType
from helix.models.panel import Panel, PanelWarnings
from test.test_helpers import assert_array_is_close
class BallastCalculatorWhenSingleTiltAnd96CellTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
"""
Generated using site parameters:
height: 100
length: 1000
width: 1500
parapet: 0
wind_speed: 150
exposure_category: D
"""
self.c_p_matrix = array([[1.506920, 1.347220, 1.122684, 0.948795],
[1.186590, 1.057265, 0.881054, 0.740239],
[0.676809, 0.615810, 0.439865, 0.382935],
[0.685883, 0.602310, 0.430222, 0.352224],
[0.460258, 0.272456, 0.408684, 0.227532],
[0.438829, 0.388352, 0.298733, 0.247999],
[0.206406, 0.186191, 0.186191, 0.159779],
[0.560763, 0.491939, 0.491939, 0.402013],
[1.548721, 1.320138, 1.320138, 1.021469],
[0.921232, 0.799827, 0.399914, 0.320599],
[0.168333, 0.142587, 0.101848, 0.078692]])
self.system_type = SystemType.singleTilt
self.module_type = ModuleType.Cell96
self.values.max_system_pressure.return_value = 1000
self.values.system_type.return_value = self.system_type
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip
self.values.module_system_constants.return_value = self.system_type.module_constants(self.module_type)
self.q_z = 70.155851
self.subject = BallastCalculator(self.values)
def test_summary_table(self):
self.values.ballast_block_weight.return_value = 20
self.values.max_system_pressure.return_value = 17
expected_value = {
PanelType.Corner: {
'anchors': [5, 4, 2, 2, 1, 1, 0, 2, 6, 3, 0],
'ballast blocks': [14, 10, 9, 9, 11, 10, 10, 2, 2, 9, 8],
'pressure': ['12.93', '9.79', '9.03', '9.03', '10.56', '9.70', '9.70', '3.60', '3.69', '9.03', '8.18']
},
PanelType.NorthSouth: {
'anchors': [5, 4, 2, 2, 0, 1, 0, 1, 5, 3, 0],
'ballast blocks': [5, 2, 5, 5, 15, 7, 9, 13, 3, 2, 7],
'pressure': ['5.79', '3.50', '5.70', '5.70', '13.41', '7.23', '8.84', '11.89', '4.26', '3.41', '7.23']
},
PanelType.EastWest: {
'anchors': [4, 3, 1, 1, 1, 0, 0, 1, 5, 1, 0],
'ballast blocks': [6, 6, 10, 9, 8, 16, 9, 13, 3, 7, 4],
'pressure': ['6.79', '6.70', '9.75', '8.99', '8.23', '14.42', '8.99', '12.13', '4.41', '7.46', '5.09']
},
PanelType.Middle: {
'anchors': [3, 2, 1, 0, 0, 0, 0, 1, 3, 0, 0],
'ballast blocks': [11, 13, 6, 19, 12, 13, 8, 7, 15, 18, 3],
'pressure': ['10.42', '11.95', '6.52', '16.61', '11.19', '11.95', '8.05', '7.29', '13.56', '15.76',
'4.15']
},
}
received_table = self.subject.summary_table(self.c_p_matrix, self.q_z)
eq_(received_table.keys(), expected_value.keys())
for key in expected_value.keys():
received_table[key].pop('warnings')
self.assertDictEqual(received_table[key], expected_value[key])
def test_ballast_and_trays_matrix(self):
panels = [
Panel(wind_zone=5, panel_type=PanelType.Corner),
Panel(wind_zone=6, panel_type=PanelType.NorthSouth),
Panel(wind_zone=7, panel_type=PanelType.EastWest),
Panel(wind_zone=0, panel_type=PanelType.Corner),
Panel(wind_zone=8, panel_type=PanelType.Middle),
Panel(wind_zone=9, panel_type=PanelType.NorthSouth),
Panel(wind_zone=6, panel_type=PanelType.Corner),
Panel(wind_zone=6, panel_type=PanelType.EastWest)
]
self.values.ballast_block_weight.return_value = 20
expected_value = [
Panel(wind_zone=5, panel_type=PanelType.Corner, ballast=25, link_tray=0, cross_tray=2, wind_anchors=0, pressure=21.32),
Panel(wind_zone=6, panel_type=PanelType.NorthSouth, ballast=9, link_tray=0, cross_tray=1, wind_anchors=0, pressure=8.84),
Panel(wind_zone=7, panel_type=PanelType.EastWest, ballast=28, link_tray=2, cross_tray=2, wind_anchors=0, pressure=23.65),
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=14, link_tray=0, cross_tray=2, wind_anchors=5, pressure=12.93, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=8, panel_type=PanelType.Middle, ballast=15, link_tray=1, cross_tray=2, wind_anchors=3, pressure=13.56, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=9, panel_type=PanelType.NorthSouth, ballast=2, link_tray=0, cross_tray=0, wind_anchors=3, pressure=3.41, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=6, panel_type=PanelType.Corner, ballast=10, link_tray=0, cross_tray=0, wind_anchors=0, pressure=9.70),
Panel(wind_zone=6, panel_type=PanelType.EastWest, ballast=9, link_tray=2, cross_tray=0, wind_anchors=0, pressure=8.99)
]
assert_array_is_close(self.subject.ballast_and_trays_matrix(self.c_p_matrix, self.q_z, panels), expected_value, decimal=2)
def test_presented_link_trays(self):
panels = [
Panel(panel_type=PanelType.Corner, link_tray=0),
Panel(panel_type=PanelType.NorthSouth, link_tray=0),
Panel(panel_type=PanelType.EastWest, link_tray=2),
Panel(panel_type=PanelType.Corner, link_tray=0),
Panel(panel_type=PanelType.Middle, link_tray=1),
Panel(panel_type=PanelType.NorthSouth, link_tray=0),
Panel(panel_type=PanelType.Corner, link_tray=0),
Panel(panel_type=PanelType.NorthSouth, link_tray=0),
Panel(panel_type=PanelType.EastWest, link_tray=2),
Panel(panel_type=PanelType.Middle, link_tray=1),
Panel(panel_type=PanelType.Corner, link_tray=0),
Panel(panel_type=PanelType.NorthSouth, link_tray=0),
Panel(panel_type=PanelType.EastWest, link_tray=2),
Panel(panel_type=PanelType.Middle, link_tray=1),
]
self.values.ballast_block_weight.return_value = 20
expected_value = [
Panel(presented_link_tray=0, panel_type=PanelType.Corner, link_tray=0),
Panel(presented_link_tray=0, panel_type=PanelType.NorthSouth, link_tray=0),
Panel(presented_link_tray=2, panel_type=PanelType.EastWest, link_tray=2),
Panel(presented_link_tray=0, panel_type=PanelType.Corner, link_tray=0),
Panel(presented_link_tray=1, panel_type=PanelType.Middle, link_tray=1),
Panel(presented_link_tray=0, panel_type=PanelType.NorthSouth, link_tray=0),
Panel(presented_link_tray=0, panel_type=PanelType.Corner, link_tray=0),
Panel(presented_link_tray=0, panel_type=PanelType.NorthSouth, link_tray=0),
Panel(presented_link_tray=2, panel_type=PanelType.EastWest, link_tray=2),
Panel(presented_link_tray=1, panel_type=PanelType.Middle, link_tray=1),
Panel(presented_link_tray=0, panel_type=PanelType.Corner, link_tray=0),
Panel(presented_link_tray=0, panel_type=PanelType.NorthSouth, link_tray=0),
Panel(presented_link_tray=2, panel_type=PanelType.EastWest, link_tray=2),
Panel(presented_link_tray=1, panel_type=PanelType.Middle, link_tray=1)
]
assert_array_equal(self.subject.show_presented_link_trays(panels), expected_value)
def test_pressure_exceeding_max_system_pressure(self):
self.values.ballast_block_weight.return_value = 20
self.values.max_system_pressure.return_value = 25
panels = [
Panel(wind_zone=7, panel_type=PanelType.Corner),
Panel(wind_zone=7, panel_type=PanelType.NorthSouth),
Panel(wind_zone=9, panel_type=PanelType.EastWest),
Panel(wind_zone=5, panel_type=PanelType.Corner),
Panel(wind_zone=6, panel_type=PanelType.Middle),
Panel(wind_zone=8, panel_type=PanelType.NorthSouth),
Panel(wind_zone=6, panel_type=PanelType.Corner)
]
expected_value = array([
Panel(wind_zone=7, panel_type=PanelType.Corner, ballast=2, link_tray=0, cross_tray=0, wind_anchors=2, pressure=3.60),
Panel(wind_zone=7, panel_type=PanelType.NorthSouth, ballast=13, link_tray=0, cross_tray=1, wind_anchors=1, pressure=11.89),
Panel(wind_zone=9, panel_type=PanelType.EastWest, ballast=22, link_tray=2, cross_tray=1, wind_anchors=0, pressure=18.99),
Panel(wind_zone=5, panel_type=PanelType.Corner, ballast=25, link_tray=0, cross_tray=2, wind_anchors=0, pressure=21.32),
Panel(wind_zone=6, panel_type=PanelType.Middle, ballast=8, link_tray=1, cross_tray=0, wind_anchors=0, pressure=8.05),
Panel(wind_zone=8, panel_type=PanelType.NorthSouth, ballast=3, link_tray=0, cross_tray=1, wind_anchors=5, pressure=4.26, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=6, panel_type=PanelType.Corner, ballast=10, link_tray=0, cross_tray=0, wind_anchors=0, pressure=9.70),
])
assert_array_is_close(self.subject.ballast_and_trays_matrix(self.c_p_matrix, self.q_z, panels), expected_value, decimal=2)
def test_ballast_count_when_base_weight_greater_than_uplift(self):
assert self.subject.ballast_tray_and_anchor_count(10, PanelType.Middle, 14, 1000, self.c_p_matrix,
30.155851).almost_equal(
Panel(wind_zone=10, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0,
wind_anchors=0, pressure=1.86),
decimal=2)
def test_individual_ballast_block_uplift_greater_than_base_weight(self):
assert self.subject.ballast_tray_and_anchor_count(6, PanelType.Middle, 14, 1000, self.c_p_matrix,
self.q_z).almost_equal(
Panel(wind_zone=6, panel_type=PanelType.Middle, ballast=11, link_tray=1, cross_tray=1,
wind_anchors=0, pressure=7.91),
decimal=2)
assert self.subject.ballast_tray_and_anchor_count(6, PanelType.Middle, 20, 1000, self.c_p_matrix,
self.q_z).almost_equal(
Panel(wind_zone=6, panel_type=PanelType.Middle, ballast=8, link_tray=1, cross_tray=0,
wind_anchors=0, pressure=8.05),
decimal=2)
def test_ballast_blocks_exceeding_tray_capacity(self):
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Corner, 20, 1000, self.c_p_matrix,
self.q_z).almost_equal(
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=14, link_tray=0, cross_tray=2,
wind_anchors=5, pressure=12.93, warnings=[PanelWarnings.MaxPsf]),
decimal=2)
assert self.subject.ballast_tray_and_anchor_count(8, PanelType.Middle, 20, 1000, self.c_p_matrix,
self.q_z).almost_equal(
Panel(wind_zone=8, panel_type=PanelType.Middle, ballast=15, link_tray=1, cross_tray=2,
wind_anchors=3, pressure=13.56, warnings=[PanelWarnings.MaxPsf]),
decimal=2)
def test_ballast_blocks_when_panel_exceeds_max_system_pressure(self):
assert self.subject.ballast_tray_and_anchor_count(5, PanelType.Middle, 14, 10, self.c_p_matrix,
self.q_z).almost_equal(
Panel(wind_zone=5, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0,
wind_anchors=1, pressure=1.86),
decimal=2)
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Corner, 14, 10, self.c_p_matrix,
self.q_z).almost_equal(
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0,
wind_anchors=6, pressure=2.08, warnings=[PanelWarnings.MaxPsf]),
decimal=2)
def test_when_max_system_pressure_is_lower_than_base_weight_pressure(self):
max_system_pressure = 0
assert self.subject.ballast_tray_and_anchor_count(5, PanelType.Middle, 12, max_system_pressure, self.c_p_matrix,
self.q_z).almost_equal(
Panel(wind_zone=5, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0,
wind_anchors=1, pressure=1.86),
decimal=2)
def test_uplift(self):
assert_almost_equal(self.subject.uplift(1.506920, self.q_z), 1857.49, 1)
def test_calculate_single_unit_pressure_on_roof(self):
assert_almost_equal(self.subject.calculate_pressure_on_roof(90, 20, 59.1), 70.89, 2)
assert_almost_equal(self.subject.calculate_pressure_on_roof(15, 14, 54.5), 10.09, 2)

View File

@@ -0,0 +1,276 @@
import unittest
from unittest.mock import MagicMock
from nose.tools import assert_almost_equal, eq_
from numpy import array
from numpy.testing import assert_array_equal
from helix.calculators.ballast_calculator import BallastCalculator
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type import ModuleType
from helix.constants.panel_type import PanelType
from helix.constants.system_type import SystemType
from helix.models.panel import Panel, PanelWarnings
from test.test_helpers import assert_array_is_close
class BallastCalculatorWhenSingleTiltAndPSeriesTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
"""
Generated using site parameters:
height: 100
length: 1000
width: 1500
parapet: 0
wind_speed: 150
exposure_category: D
"""
self.c_p_matrix = array([[1.475479, 1.345176, 1.120980, 1.088447],
[1.161129, 1.055610, 0.879675, 0.853329],
[0.664800, 0.615030, 0.439307, 0.428656],
[0.669430, 0.601241, 0.429458, 0.414865],
[0.450104, 0.272016, 0.408024, 0.263611],
[0.428892, 0.387706, 0.298236, 0.288744],
[0.202426, 0.185933, 0.185933, 0.180991],
[0.547213, 0.491058, 0.491058, 0.474234],
[1.503719, 1.317213, 1.317213, 1.261333],
[0.897331, 0.798273, 0.399137, 0.384297],
[0.172217, 0.151210, 0.108007, 0.103511]])
self.system_type = SystemType.singleTilt
self.module_type = ModuleType.PSeries
self.values.max_system_pressure.return_value = 1000
self.values.system_type.return_value = self.system_type
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip
self.values.module_system_constants.return_value = self.system_type.module_constants(self.module_type)
self.q_z = 70.155851
self.subject = BallastCalculator(self.values)
def test_summary_table(self):
self.values.ballast_block_weight.return_value = 20
self.values.max_system_pressure.return_value = 17
expected_value = {
PanelType.Corner: {
'anchors': [7, 5, 3, 3, 2, 1, 0, 2, 7, 4, 0],
'ballast blocks': [5, 11, 3, 4, 2, 15, 13, 9, 7, 6, 11],
'pressure': ['5.13', '8.75', '3.83', '4.43', '3.22', '11.16', '9.86', '7.45', '6.33', '5.73', '8.65']
},
PanelType.NorthSouth: {
'anchors': [6, 5, 2, 2, 0, 1, 0, 2, 6, 3, 0],
'ballast blocks': [10, 3, 15, 14, 18, 12, 12, 5, 8, 14, 9],
'pressure': ['8.06', '3.74', '11.07', '10.37', '12.88', '9.17', '9.17', '4.85', '6.85', '10.47', '7.26']
},
PanelType.EastWest: {
'anchors': [5, 4, 2, 1, 1, 0, 0, 2, 6, 1, 0],
'ballast blocks': [8, 5, 1, 15, 14, 20, 12, 5, 8, 13, 6],
'pressure': ['6.94', '5.04', '2.56', '11.16', '10.56', '14.18', '9.26', '5.04', '6.94', '9.96', '5.57']
},
PanelType.Middle: {
'anchors': [5, 4, 1, 1, 0, 0, 0, 2, 6, 1, 0],
'ballast blocks': [6, 3, 15, 14, 18, 20, 11, 4, 4, 12, 6],
'pressure': ['5.60', '3.69', '11.02', '10.42', '12.83', '14.13', '8.51', '4.29', '4.39', '9.21', '5.43']
},
}
received_table = self.subject.summary_table(self.c_p_matrix, self.q_z)
eq_(received_table.keys(), expected_value.keys())
for key in expected_value.keys():
received_table[key].pop('warnings')
self.assertDictEqual(received_table[key], expected_value[key])
def test_ballast_and_trays_matrix(self):
panels = array([
Panel(wind_zone=5, panel_type=PanelType.Corner),
Panel(wind_zone=6, panel_type=PanelType.NorthSouth),
Panel(wind_zone=7, panel_type=PanelType.EastWest),
Panel(wind_zone=0, panel_type=PanelType.Corner),
Panel(wind_zone=8, panel_type=PanelType.Middle),
Panel(wind_zone=9, panel_type=PanelType.NorthSouth),
Panel(wind_zone=6, panel_type=PanelType.Corner),
Panel(wind_zone=6, panel_type=PanelType.EastWest)
])
self.values.ballast_block_weight.return_value = 20
expected_value = [
Panel(wind_zone=5, panel_type=PanelType.Corner, ballast=15, link_tray=0, cross_tray=1, wind_anchors=1,
pressure=11.16),
Panel(wind_zone=6, panel_type=PanelType.NorthSouth, ballast=12, link_tray=0, cross_tray=1, wind_anchors=0,
pressure=9.17),
Panel(wind_zone=7, panel_type=PanelType.EastWest, ballast=5, link_tray=2, cross_tray=0, wind_anchors=2,
pressure=5.04, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=5, link_tray=0, cross_tray=1, wind_anchors=7,
pressure=5.13, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=8, panel_type=PanelType.Middle, ballast=4, link_tray=1, cross_tray=1, wind_anchors=6,
pressure=4.39, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=9, panel_type=PanelType.NorthSouth, ballast=14, link_tray=0, cross_tray=2, wind_anchors=3,
pressure=10.47, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=6, panel_type=PanelType.Corner, ballast=13, link_tray=0, cross_tray=0, wind_anchors=0,
pressure=9.86),
Panel(wind_zone=6, panel_type=PanelType.EastWest, ballast=12, link_tray=2, cross_tray=0, wind_anchors=0,
pressure=9.26)
]
assert_array_is_close(self.subject.ballast_and_trays_matrix(self.c_p_matrix, self.q_z, panels),
expected_value, decimal=2)
def test_presented_link_trays(self):
panels = [
Panel(panel_type=PanelType.Corner, link_tray=0),
Panel(panel_type=PanelType.NorthSouth, link_tray=0),
Panel(panel_type=PanelType.EastWest, link_tray=2),
Panel(panel_type=PanelType.Corner, link_tray=0),
Panel(panel_type=PanelType.Middle, link_tray=1),
Panel(panel_type=PanelType.NorthSouth, link_tray=0),
Panel(panel_type=PanelType.Corner, link_tray=0),
Panel(panel_type=PanelType.NorthSouth, link_tray=0),
Panel(panel_type=PanelType.EastWest, link_tray=2),
Panel(panel_type=PanelType.Middle, link_tray=1),
Panel(panel_type=PanelType.Corner, link_tray=0),
Panel(panel_type=PanelType.NorthSouth, link_tray=0),
Panel(panel_type=PanelType.EastWest, link_tray=2),
Panel(panel_type=PanelType.Middle, link_tray=1),
]
expected = [
Panel(presented_link_tray=0, panel_type=PanelType.Corner, link_tray=0),
Panel(presented_link_tray=0, panel_type=PanelType.NorthSouth, link_tray=0),
Panel(presented_link_tray=2, panel_type=PanelType.EastWest, link_tray=2),
Panel(presented_link_tray=0, panel_type=PanelType.Corner, link_tray=0),
Panel(presented_link_tray=1, panel_type=PanelType.Middle, link_tray=1),
Panel(presented_link_tray=0, panel_type=PanelType.NorthSouth, link_tray=0),
Panel(presented_link_tray=0, panel_type=PanelType.Corner, link_tray=0),
Panel(presented_link_tray=0, panel_type=PanelType.NorthSouth, link_tray=0),
Panel(presented_link_tray=2, panel_type=PanelType.EastWest, link_tray=2),
Panel(presented_link_tray=1, panel_type=PanelType.Middle, link_tray=1),
Panel(presented_link_tray=0, panel_type=PanelType.Corner, link_tray=0),
Panel(presented_link_tray=0, panel_type=PanelType.NorthSouth, link_tray=0),
Panel(presented_link_tray=2, panel_type=PanelType.EastWest, link_tray=2),
Panel(presented_link_tray=1, panel_type=PanelType.Middle, link_tray=1)
]
assert_array_equal(self.subject.show_presented_link_trays(panels), expected)
def test_pressure_exceeding_max_system_pressure(self):
self.values.ballast_block_weight.return_value = 20
self.values.max_system_pressure.return_value = 25
panel_data = [
Panel(wind_zone=7, panel_type=PanelType.Corner),
Panel(wind_zone=7, panel_type=PanelType.NorthSouth),
Panel(wind_zone=9, panel_type=PanelType.EastWest),
Panel(wind_zone=5, panel_type=PanelType.Corner),
Panel(wind_zone=6, panel_type=PanelType.Middle),
Panel(wind_zone=8, panel_type=PanelType.NorthSouth),
Panel(wind_zone=6, panel_type=PanelType.Corner)
]
expected_value = [
Panel(wind_zone=7, panel_type=PanelType.Corner, ballast=9, link_tray=0, cross_tray=0,
wind_anchors=2, pressure=7.44, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=7, panel_type=PanelType.NorthSouth, ballast=5, link_tray=0, cross_tray=0,
wind_anchors=2, pressure=4.85, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=9, panel_type=PanelType.EastWest, ballast=28, link_tray=2, cross_tray=2,
wind_anchors=0, pressure=19.10),
Panel(wind_zone=5, panel_type=PanelType.Corner, ballast=15, link_tray=0, cross_tray=1,
wind_anchors=1, pressure=11.16),
Panel(wind_zone=6, panel_type=PanelType.Middle, ballast=11, link_tray=1, cross_tray=0,
wind_anchors=0, pressure=8.51),
Panel(wind_zone=8, panel_type=PanelType.NorthSouth, ballast=8, link_tray=0, cross_tray=2,
wind_anchors=6, pressure=6.85, warnings=[PanelWarnings.MaxPsf]),
Panel(wind_zone=6, panel_type=PanelType.Corner, ballast=13, link_tray=0, cross_tray=0,
wind_anchors=0, pressure=9.86)
]
assert_array_is_close(self.subject.ballast_and_trays_matrix(self.c_p_matrix, self.q_z, panel_data),
expected_value, decimal=2)
def test_ballast_count_when_base_weight_greater_than_uplift(self):
# Need to regenerate a c_p matrix to get to this case
"""
Generated using site parameters:
height: 30
length: 100
width: 100
parapet: 0
wind_speed: 110
exposure_category: B
"""
self.c_p_matrix = array([[0.831094, 0.670280, 0.558567, 0.384751],
[0.639306, 0.509079, 0.424233, 0.283477],
[0.418671, 0.357246, 0.255176, 0.198270],
[0.332216, 0.248060, 0.177186, 0.122119],
[0.242006, 0.158462, 0.190073, 0.089168],
[0.225219, 0.174390, 0.134146, 0.089168],
[0.184388, 0.158462, 0.113187, 0.089168],
[0.269511, 0.200207, 0.200207, 0.127913],
[0.581392, 0.351215, 0.351215, 0.150139],
[0.407464, 0.285212, 0.142606, 0.089168],
[0.184388, 0.158462, 0.113187, 0.089168]])
self.q_z = 18.446284
expected = Panel(wind_zone=10, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0,
wind_anchors=0, pressure=1.81)
assert self.subject.ballast_tray_and_anchor_count(10, PanelType.Middle, 14, 1000, self.c_p_matrix,
self.q_z).almost_equal(expected, decimal=2)
def test_ballast_and_tray_count_iterates_on_link_and_cross_trays_changing_weight_and_ballast_requirements(self):
panel = self.subject.ballast_tray_and_anchor_count(3, PanelType.NorthSouth, 20, 17, self.c_p_matrix, self.q_z)
assert_almost_equal(panel.pressure, 10.37, 2)
def test_individual_ballast_block_uplift_greater_than_base_weight(self):
expected = Panel(wind_zone=6, panel_type=PanelType.Middle, ballast=16, link_tray=1, cross_tray=1,
wind_anchors=0, pressure=8.73)
assert self.subject.ballast_tray_and_anchor_count(6, PanelType.Middle, 14, 1000, self.c_p_matrix,
self.q_z).almost_equal(expected, decimal=2)
expected = Panel(wind_zone=6, panel_type=PanelType.Middle, ballast=11, link_tray=1, cross_tray=0,
wind_anchors=0, pressure=8.51)
assert self.subject.ballast_tray_and_anchor_count(6, PanelType.Middle, 20, 1000, self.c_p_matrix,
self.q_z).almost_equal(expected, decimal=2)
def test_ballast_blocks_exceeding_tray_capacity(self):
expected = Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=5, link_tray=0, cross_tray=1,
wind_anchors=7, pressure=5.13, warnings=[PanelWarnings.MaxPsf])
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Corner, 20, 1000, self.c_p_matrix,
self.q_z).almost_equal(expected, decimal=2)
expected = Panel(wind_zone=8, panel_type=PanelType.Middle, ballast=4, link_tray=1, cross_tray=1,
wind_anchors=6, pressure=4.39, warnings=[PanelWarnings.MaxPsf])
assert self.subject.ballast_tray_and_anchor_count(8, PanelType.Middle, 20, 1000, self.c_p_matrix,
self.q_z).almost_equal(expected, decimal=2)
def test_ballast_blocks_when_panel_exceeds_max_system_pressure(self):
expected = Panel(wind_zone=5, panel_type=PanelType.Middle, ballast=6, link_tray=1, cross_tray=0,
wind_anchors=1, pressure=4.41)
assert self.subject.ballast_tray_and_anchor_count(5, PanelType.Middle, 14, 10, self.c_p_matrix,
self.q_z).almost_equal(expected, decimal=2)
expected = Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=7, link_tray=0, cross_tray=1,
wind_anchors=7, pressure=5.07, warnings=[PanelWarnings.MaxPsf])
assert self.subject.ballast_tray_and_anchor_count(0, PanelType.Corner, 14, 10, self.c_p_matrix,
self.q_z).almost_equal(expected, decimal=2)
def test_when_max_system_pressure_is_lower_than_base_weight_pressure(self):
max_system_pressure = 0
expected = Panel(wind_zone=5, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0,
wind_anchors=2, pressure=1.81)
assert self.subject.ballast_tray_and_anchor_count(5, PanelType.Middle, 12, max_system_pressure,
self.c_p_matrix, self.q_z).almost_equal(
expected,
decimal=2
)
def test_uplift(self):
assert_almost_equal(self.subject.uplift(1.506920, self.q_z), 2349.08, 2)
def test_calculate_single_unit_pressure_on_roof(self): # Do manually, don't need excel
assert_almost_equal(self.subject.calculate_pressure_on_roof(90, 20, 59.1), 56.06, 2)
assert_almost_equal(self.subject.calculate_pressure_on_roof(15, 14, 54.5), 7.98, 2)

View File

@@ -0,0 +1,60 @@
import unittest
from unittest.mock import MagicMock
from nose.tools import assert_almost_equal, eq_
from numpy import array
from numpy.testing import assert_array_equal
from helix.calculators.ballast_calculator import BallastCalculator
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type import ModuleType
from helix.constants.panel_type import PanelType
from helix.constants.system_type import SystemType
from helix.models.panel import Panel, PanelWarnings
from test.test_helpers import assert_array_is_close
class BallastCalculatorUpliftWarningsTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
"""
Generated using site parameters:
height: 100
length: 1000
width: 1500
parapet: 0
wind_speed: 150
exposure_category: D
"""
self.c_p_matrix = array([[1.506920, 1.347220, 1.122684, 0.948795],
[1.186590, 1.057265, 0.881054, 0.740239],
[0.676809, 0.615810, 0.439865, 0.382935],
[0.685883, 0.602310, 0.430222, 0.352224],
[0.460258, 0.272456, 0.408684, 0.227532],
[0.438829, 0.388352, 0.298733, 0.247999],
[0.206406, 0.186191, 0.186191, 0.159779],
[0.560763, 0.491939, 0.491939, 0.402013],
[1.548721, 1.320138, 1.320138, 1.021469],
[0.921232, 0.799827, 0.399914, 0.320599],
[0.168333, 0.142587, 0.101848, 0.078692]])
self.system_type = SystemType.singleTilt
self.module_type = ModuleType.Cell96
self.values.max_system_pressure.return_value = 1000
self.values.system_type.return_value = self.system_type
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip
self.values.module_system_constants.return_value = self.system_type.module_constants(self.module_type)
self.q_z = 70.155851
self.subject = BallastCalculator(self.values)
def test_exceeding_maximal_uplift(self):
expected = [PanelWarnings.MaxPsf]
for i in range(0,1):
actual = self.subject.ballast_tray_and_anchor_count(i, PanelType.Middle, 14, 100, self.c_p_matrix, self.q_z)
assert_array_equal(expected, actual.warnings)
def test_not_exceeding_maximal_uplift(self):
expected = []
for i in range(2,7):
actual = self.subject.ballast_tray_and_anchor_count(i, PanelType.Middle, 14, 100, self.c_p_matrix, self.q_z)
assert_array_equal(expected, actual.warnings)

View File

@@ -0,0 +1,564 @@
import csv
import json
import unittest
import mockredis
from nose.tools import eq_
from numpy import array
from numpy.testing import assert_array_equal
import time
from helix.calculators.calculator import Calculator
from helix.constants.anchor_type import AnchorType
from helix.constants.exposure_category import ExposureCategory
from helix.constants.inverter_type import InverterType
from helix.constants.module_type import ModuleType
from helix.constants.panel_type import PanelType
from helix.constants.system_type import SystemType
from helix.models.coordinate import Coordinate
from helix.models.panel import Panel
from helix.models.sql.inverters import Inverter
from helix.models.sql.power_stations import PowerStation
from helix.models.sql.sites import Site
from helix.models.subarray import Subarray
from helix.store import Store
from helix.user_values import UserValues
from test.test_helpers import assert_array_is_close
class CalculatorTest(unittest.TestCase):
def setUp(self):
self.store = Store(mockredis.mock_redis_client(), "foo")
self.site = Site(
building_height=35,
building_width=450,
building_length=500,
parapet_height=5,
wind_speed=120,
exposure_category='B',
ballast_block_weight=14,
max_psf=10,
system_type=SystemType.dualTilt.value,
module_type=ModuleType.Cell96.value,
spectral_response=1.5,
anchor_type=AnchorType.OMG_PowerGrip_Plus.value,
seismic_importance_factor=1,
)
self.values = UserValues(self.store, self.site)
def test_compute_subarray_summary_dual_tilt(self):
self.site.system_type = SystemType.dualTilt.value
with open('test/fixtures/input_dual_tilt_csv_for_bom.csv', 'r', newline='') as csv_file:
csv_content = csv_file.read()
self.site.cad_file = csv_content
self.subject = Calculator(self.values)
expected = [
Subarray(subarray_number=1, origin=Coordinate(0, 0), required_seismic_anchors=435, weight=170237,
start_row=0, size=863, column_counted_geometrically=False, row_counted_geometrically=False,
row_count=130.5, column_count=98)
]
assert_array_is_close(self.subject.subarray_summary(), expected, decimal=0)
def test_compute_subarray_summary_single_tilt(self):
self.site.system_type = SystemType.singleTilt.value
with open('test/fixtures/input_single_tilt_csv_for_bom.csv', 'r', newline='') as csv_file:
csv_content = csv_file.read()
self.site.cad_file = csv_content
self.subject = Calculator(self.values)
expected = [
Subarray(subarray_number=1, origin=Coordinate(0, 0), required_seismic_anchors=11, weight=23783, start_row=0,
size=192, column_counted_geometrically=False, row_counted_geometrically=False,
row_count=18, column_count=20),
Subarray(subarray_number=2, origin=Coordinate(0, 0), required_seismic_anchors=0, weight=13113,
start_row=192, size=96, column_counted_geometrically=False, row_counted_geometrically=False,
row_count=4, column_count=24),
Subarray(subarray_number=3, origin=Coordinate(0, 0), required_seismic_anchors=110, weight=40406,
start_row=288, size=312, column_counted_geometrically=False, row_counted_geometrically=False,
row_count=25, column_count=29),
Subarray(subarray_number=4, origin=Coordinate(0, 0), required_seismic_anchors=72, weight=23404,
start_row=600, size=168, column_counted_geometrically=False, row_counted_geometrically=False,
row_count=22, column_count=13),
Subarray(subarray_number=5, origin=Coordinate(0, 0), required_seismic_anchors=75, weight=35365,
start_row=768, size=234, column_counted_geometrically=False, row_counted_geometrically=False,
row_count=26, column_count=14),
Subarray(subarray_number=6, origin=Coordinate(0, 0), required_seismic_anchors=0, weight=10897,
start_row=1002, size=96, column_counted_geometrically=False, row_counted_geometrically=False,
row_count=10, column_count=12),
Subarray(subarray_number=7, origin=Coordinate(0, 0), required_seismic_anchors=29, weight=10951,
start_row=1098, size=96, column_counted_geometrically=False, row_counted_geometrically=False,
row_count=8, column_count=16),
Subarray(subarray_number=8, origin=Coordinate(0, 0), required_seismic_anchors=11, weight=10596,
start_row=1194, size=96, column_counted_geometrically=False, row_counted_geometrically=False,
row_count=15, column_count=17.5),
Subarray(subarray_number=9, origin=Coordinate(0, 0), required_seismic_anchors=0, weight=10544,
start_row=1290, size=96, column_counted_geometrically=False, row_counted_geometrically=False,
row_count=8, column_count=16),
Subarray(subarray_number=10, origin=Coordinate(0, 0), required_seismic_anchors=0, weight=4819,
start_row=1386, size=48, column_counted_geometrically=False, row_counted_geometrically=False,
row_count=8, column_count=6),
Subarray(subarray_number=11, origin=Coordinate(0, 0), required_seismic_anchors=0, weight=10857,
start_row=1434, size=96, column_counted_geometrically=False, row_counted_geometrically=False,
row_count=13, column_count=13),
Subarray(subarray_number=12, origin=Coordinate(0, 0), required_seismic_anchors=0, weight=6330,
start_row=1530, size=54, column_counted_geometrically=False, row_counted_geometrically=False,
row_count=8, column_count=8),
Subarray(subarray_number=13, origin=Coordinate(0, 0), required_seismic_anchors=0, weight=4201,
start_row=1584, size=48, column_counted_geometrically=False, row_counted_geometrically=False,
row_count=6, column_count=8)
]
assert_array_is_close(self.subject.subarray_summary(), expected, decimal=0)
def test_does_not_operate_on_panels_if_told_not_to(self):
with open('test/fixtures/input_dual_tilt_coordinates_seismic_anchors.txt', 'r', newline='') as csv_file:
csv_content = csv_file.read()
self.site.cad_file = csv_content
self.subject = Calculator(self.values, calculate_panel_data=False)
for panel in self.subject.panels:
assert panel.seismic_anchors is None
assert self.subject.subarrays is None
def test_compute_summary_values(self):
self.site.building_width = 200
self.site.building_height = 30
self.site.building_length = 75.5
self.site.wind_speed = 130
self.site.exposure_category = ExposureCategory.C.value
self.site.ballast_block_weight = 13
self.site.parapet_height = 0
self.site.max_psf = 10
self.site.anchor_type = AnchorType.OMG_PowerGrip_Plus.value
self.site.spectral_response = 1.02
self.site.system_type = SystemType.singleTilt.value
with open('test/fixtures/input_single_tilt.csv', 'r', newline='') as csv_file:
csv_content = csv_file.read()
self.site.cad_file = csv_content
self.subject = Calculator(self.values)
received_values = self.subject.summary_values()
expected_values = array([
{'label': 'Total System Weight (lbs)', 'value': 2684},
{'label': 'Max PSF', 'value': 8.03},
{'label': 'Avg PSF', 'value': 5.39},
{'label': 'Total Anchors', 'value': 5},
{'label': 'Total Ballast', 'value': 131},
{'label': 'Max Possible System Weight', 'value': 2789.0},
{'label': 'Max System Weight Ballast Block', 'value': 16},
{'label': 'Seismic Anchor Max. Spacing', 'value': 12},
])
assert_array_equal(received_values, expected_values)
def test_compute_documentation_summary_values(self):
self.site.building_width = 200
self.site.building_height = 30
self.site.building_length = 75.5
self.site.wind_speed = 130
self.site.exposure_category = ExposureCategory.C.value
self.site.ballast_block_weight = 13
self.site.parapet_height = 0
self.site.max_psf = 10
self.site.anchor_type = AnchorType.OMG_PowerGrip_Plus.value
self.site.spectral_response = 1.02
self.site.system_type = SystemType.singleTilt.value
with open('test/fixtures/input_single_tilt.csv', 'r', newline='') as csv_file:
csv_content = csv_file.read()
self.site.cad_file = csv_content
self.subject = Calculator(self.values)
received_values = self.subject.documentation_summary_values()
expected_values = {
'total_system_weight': 2684,
'max_psf': 8.03,
'ave_psf': 5.39,
'total_anchors': 5,
'total_ballast': 131,
'max_possible_system_weight': 2789.0,
'max_system_weight_ballast_block': 16,
'seismic_anchor_max_spacing': 12
}
eq_(received_values, expected_values)
def test_recomputes_ballast_after_seismic_calculations(self):
self.site.building_width = 200
self.site.building_height = 30
self.site.building_length = 75.5
self.site.wind_speed = 110
self.site.exposure_category = ExposureCategory.C.value
self.site.ballast_block_weight = 13
self.site.parapet_height = 0
self.site.max_psf = 10
self.site.anchor_type = AnchorType.EcoFasten.value
self.site.spectral_response = 1.0
self.site.system_type = SystemType.dualTilt.value
with open('test/fixtures/input_dual_tilt_coordinates.csv', 'r', newline='') as csv_file:
csv_content = csv_file.read()
self.site.cad_file = csv_content
self.subject = Calculator(self.values)
required_seismic_anchors = sum(subarray.required_seismic_anchors for subarray in self.subject.subarrays)
eq_(required_seismic_anchors, 2)
self.site.spectral_response = 1.7
self.subject = Calculator(self.values)
required_seismic_anchors = sum(subarray.required_seismic_anchors for subarray in self.subject.subarrays)
eq_(required_seismic_anchors, 6)
def test_uses_user_provided_seismic_anchor_placement_if_available(self):
self.site.building_width = 200
self.site.building_height = 30
self.site.building_length = 75.5
self.site.wind_speed = 110
self.site.exposure_category = ExposureCategory.C.value
self.site.ballast_block_weight = 13
self.site.parapet_height = 0
self.site.max_psf = 10
self.site.anchor_type = AnchorType.EcoFasten.value
self.site.spectral_response = 1.0
self.site.system_type = SystemType.dualTilt.value
with open('test/fixtures/input_dual_tilt_coordinates.csv', 'r', newline='') as csv_file:
csv_content = csv_file.read()
self.site.cad_file = csv_content
self.store.set('user_override_seismic_anchors', json.dumps([
{'panel_id': 1, 'seismic_anchors': 0},
{'panel_id': 2, 'seismic_anchors': 1},
{'panel_id': 3, 'seismic_anchors': 1},
{'panel_id': 4, 'seismic_anchors': 0},
{'panel_id': 5, 'seismic_anchors': 1},
{'panel_id': 6, 'seismic_anchors': 0},
{'panel_id': 7, 'seismic_anchors': 0},
{'panel_id': 8, 'seismic_anchors': 1},
{'panel_id': 9, 'seismic_anchors': 1},
{'panel_id': 10, 'seismic_anchors': 1},
{'panel_id': 11, 'seismic_anchors': 1},
{'panel_id': 12, 'seismic_anchors': 1},
{'panel_id': 13, 'seismic_anchors': 1},
{'panel_id': 14, 'seismic_anchors': 1},
{'panel_id': 15, 'seismic_anchors': 1},
{'panel_id': 16, 'seismic_anchors': 0},
]))
self.subject = Calculator(self.values)
eq_(sum(panel.seismic_anchors for panel in self.subject.panels), 11)
expected = [
Panel(seismic_anchors=0, ballast=0),
Panel(seismic_anchors=1, ballast=0),
Panel(seismic_anchors=1, ballast=0),
Panel(seismic_anchors=0, ballast=0),
Panel(seismic_anchors=1, ballast=0),
Panel(seismic_anchors=0, ballast=10),
Panel(seismic_anchors=0, ballast=10),
Panel(seismic_anchors=1, ballast=0),
Panel(seismic_anchors=1, ballast=0),
Panel(seismic_anchors=1, ballast=0),
Panel(seismic_anchors=1, ballast=0),
Panel(seismic_anchors=1, ballast=0),
Panel(seismic_anchors=1, ballast=0),
Panel(seismic_anchors=1, ballast=0),
Panel(seismic_anchors=1, ballast=0),
Panel(seismic_anchors=0, ballast=0)
]
for idx, received_panel in enumerate(self.subject.panels):
received_seismic = received_panel.seismic_anchors
expected_seismic = expected[idx].seismic_anchors
eq_(received_seismic, expected_seismic,
"Panel at index %d had %d seismic anchors, expected %d" % (
idx, received_seismic, expected_seismic))
received_ballast = received_panel.ballast
expected_ballast = expected[idx].ballast
eq_(received_ballast, expected_ballast,
"Panel at index %d had %d ballast, expected %d" % (
idx, received_ballast, expected_ballast))
eq_(sum(subarray.required_seismic_anchors for subarray in self.subject.subarrays), 2)
def test_get_computed_csv_columns(self):
self.site.system_type = SystemType.dualTilt.value
self.subject = Calculator(self.values)
panels = [
Panel(panel_type=PanelType.Corner, link_tray=3),
Panel(panel_type=PanelType.NorthSouth, link_tray=3),
Panel(panel_type=PanelType.EastWest, link_tray=3),
Panel(panel_type=PanelType.Middle, link_tray=3),
]
self.subject.panels = panels
expected = [
Panel(panel_type=PanelType.Corner, link_tray=3, presented_link_tray=2),
Panel(panel_type=PanelType.NorthSouth, link_tray=3, presented_link_tray=2),
Panel(panel_type=PanelType.EastWest, link_tray=3, presented_link_tray=1),
Panel(panel_type=PanelType.Middle, link_tray=3, presented_link_tray=1),
]
eq_(self.subject.get_computed_csv_columns(), expected)
def test_computes_bom(self):
self.site.building_width = 200
self.site.building_height = 30
self.site.building_length = 75.5
self.site.wind_speed = 125
self.site.exposure_category = ExposureCategory.C.value
self.site.ballast_block_weight = 13
self.site.parapet_height = 0
self.site.max_psf = 10
self.site.anchor_type = AnchorType.OMG_PowerGrip_Plus.value
self.site.spectral_response = 1
self.site.system_type = SystemType.dualTilt.value
with open('test/fixtures/input_dual_tilt_csv_for_bom.csv', 'r', newline='') as csv_file:
csv_content = csv_file.read()
self.site.cad_file = csv_content
self.subject = Calculator(self.values)
with open('test/fixtures/expected_dual_tilt_ebom.csv', 'r', newline='') as expected_file:
expected_csv = expected_file.read()
reader = csv.reader(expected_csv.splitlines(), dialect='excel-tab')
expected = array([row for row in reader])
power_station_1 = PowerStation(
description='1',
quantity=1,
ac_run_length=55,
inverters=[
Inverter(
model=str(InverterType.SMA.MODEL_12KW.value),
strings_per_inverter=2
),
Inverter(
model=str(InverterType.SMA.MODEL_15KW.value),
strings_per_inverter=5
)
]
)
power_station_2 = PowerStation(
description='2',
quantity=3,
ac_run_length=89,
inverters=[
Inverter(
model=str(InverterType.SMA.MODEL_20KW.value),
strings_per_inverter=6
),
Inverter(
model=str(InverterType.SMA.MODEL_24KW.value),
strings_per_inverter=8
),
Inverter(
model=str(InverterType.SMA.MODEL_24KW.value),
strings_per_inverter=8
),
Inverter(
model=str(InverterType.SMA.MODEL_24KW.value),
strings_per_inverter=7
)
]
)
self.site.power_stations = [power_station_1, power_station_2]
assert_array_equal(self.subject.compute_bom(), expected)
def test_documentation_bom(self):
self.site.building_width = 200
self.site.building_height = 30
self.site.building_length = 75.5
self.site.wind_speed = 125
self.site.exposure_category = ExposureCategory.C.value
self.site.ballast_block_weight = 13
self.site.parapet_height = 0
self.site.max_psf = 10
self.site.anchor_type = AnchorType.OMG_PowerGrip_Plus.value
self.site.spectral_response = 1
self.site.power_stations = [
PowerStation(
quantity=1,
ac_run_length=10,
description='Test',
id=30,
inverters=[
Inverter(
model=str(InverterType.SMA.MODEL_12KW.value),
sunshade=True,
dc_switch=True,
strings_per_inverter=4
)
]
)
]
self.site.system_type = SystemType.dualTilt.value
with open('test/fixtures/input_dual_tilt_csv_for_bom.csv', 'r', newline='') as csv_file:
csv_content = csv_file.read()
self.site.cad_file = csv_content
self.subject = Calculator(self.values)
expected = [
('104813', 50),
('105317', 0),
('106925', 50),
('107538', 0),
('107549', 100),
('107551', 50),
('107586', 100),
('111147', 0),
('114961', 50),
('507985', 0),
('512021', 9),
('512199', 140),
('512200', 3480),
('512510', 196),
('512511', 196),
('512575', 1),
('512660', 2),
('512661', 2),
('512662', 4),
('512663', 2),
('512676', 0),
('512910', 1),
('513007', 50),
('513299', 0),
('513300', 0),
('513301', 0),
('513302', 0),
('513303', 1),
('513304', 0),
('513586', 0),
('513831', 0),
('513832', 0),
('513833', 670),
('513836', 0),
('513841', 196),
('513842', 196),
('513843', 262),
('513844', 214),
('514056', 1000),
('514057', 1000),
('514265', 179),
('514435', 0),
('514436', 0),
('514437', 2),
('514438', 2),
('514439', 0),
('514440', 0),
('514477', 2),
('514478', 0),
('514685', 0),
('514686', 1),
('514687', 0),
('514697', 1),
('514698', 1),
('514865', 50),
('515059', 2),
('515063', 4000),
('515928', 261),
('515929', 0),
('516043', 0),
('516045', 0),
('517463', 0),
('517871', 139),
('518058', 2),
('518059', 0),
('518331', 2),
('518477', 275),
('519008', 0),
('520301', 0),
('520302', 0),
('520303', 0),
('520306', 0),
('521031', 2),
('521363', 0),
('521794', 0),
('521795', 0),
('521797', 0),
('521798', 0),
('522020', 0),
('805615', 2),
('anchors', 262),
('ballast', 6786),
('modules', 1726)
]
assert_array_equal(sorted(self.subject.documentation_bom()), expected)
# Performance Tests
def test_performance_with_1000ish_module_site(self):
store = Store(mockredis.mock_redis_client(), "foo")
site = Site()
values = UserValues(store, site)
site.building_width = 200
site.building_height = 30
site.building_length = 75.5
site.wind_speed = 110
site.exposure_category = ExposureCategory.C.value
site.ballast_block_weight = 13
site.parapet_height = 0
site.max_psf = 10
site.anchor_type = AnchorType.EcoFasten.value
site.spectral_response = 1.0
site.system_type = SystemType.dualTilt.value
site.module_type = ModuleType.Cell96.value
with open('test/fixtures/input_dual_tilt_coordinates_seismic_anchors.txt', 'r', newline='') as csv_file:
csv_content = csv_file.read()
site.cad_file = csv_content
run_count = 1
runtimes = []
for _ in range(run_count):
start = time.clock()
Calculator(values) # Do all calculations, including seismic anchor placement
end = time.clock()
runtimes.append(end - start)
print("%d runs took %f time on average" % (run_count, sum(runtimes) / run_count))
def test_performance_with_giant_module_site(self):
store = Store(mockredis.mock_redis_client(), "foo")
site = Site()
values = UserValues(store, site)
site.building_width = 200
site.building_height = 30
site.building_length = 75.5
site.wind_speed = 110
site.exposure_category = ExposureCategory.C.value
site.ballast_block_weight = 13
site.parapet_height = 0
site.max_psf = 10
site.anchor_type = AnchorType.EcoFasten.value
site.spectral_response = 1.0
site.system_type = SystemType.singleTilt.value
site.module_type = ModuleType.Cell96.value
with open('test/fixtures/input_single_tilt_96_cell_giant_site.txt', 'r', newline='') as csv_file:
csv_content = csv_file.read()
site.cad_file = csv_content
run_count = 1
runtimes = []
for _ in range(run_count):
start = time.clock()
Calculator(values) # Do all calculations, including seismic anchor placement
end = time.clock()
runtimes.append(end - start)
import sys
print("%d runs took %f time on average" % (run_count, sum(runtimes) / run_count), file=sys.stderr)

View File

@@ -0,0 +1,175 @@
import unittest
from unittest.mock import MagicMock
from numpy import array
from numpy.testing import assert_almost_equal, assert_array_equal
from helix.calculators.coordinates_calculator import CoordinatesCalculator
from helix.calculators.subarray_helper import get_subarray_sizes_and_rows
from helix.constants.module_type_constants.dual_tilt_128_cell_constants import DualTilt128CellConstants
from helix.constants.module_type_constants.dual_tilt_96_cell_constants import DualTilt96CellConstants
from helix.constants.module_type_constants.single_tilt_128_cell_constants import SingleTilt128CellConstants
from helix.models.coordinate import Coordinate
from helix.models.panel import Panel
from helix.models.subarray import Subarray
from test.test_helpers import assert_array_is_close
class CoordinatesCalculatorTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
self.subject = CoordinatesCalculator(self.values)
def test_transform_coordinates_96(self):
panel_data = [
Panel(subarray=0, coordinate=Coordinate(1595.70588, 1231.8347999999999, 30.054994934422535)),
Panel(subarray=0, coordinate=Coordinate(1564.66923, 1285.4784, 30.06673752750664)),
Panel(subarray=0, coordinate=Coordinate(1533.615, 1339.0778999999998, 30.06584756995154)),
Panel(subarray=0, coordinate=Coordinate(1672.0707, 1276.0557, 30.066617663124482)),
Panel(subarray=0, coordinate=Coordinate(1641.0339, 1329.6552, 30.055034861122245)),
Panel(subarray=0, coordinate=Coordinate(1609.997106, 1383.2988, 30.066609672196513)),
Panel(subarray=0, coordinate=Coordinate(1748.4354, 1320.2328, 30.054994934422535)),
Panel(subarray=0, coordinate=Coordinate(1717.3987200000001, 1373.8763999999999, 30.066617663124553)),
Panel(subarray=0, coordinate=Coordinate(1686.344487, 1427.4765, 30.066613667660015)),
Panel(subarray=1, coordinate=Coordinate(1471.54131, 1446.3216, 30.06665761782229)),
Panel(subarray=1, coordinate=Coordinate(1440.5046, 1499.96526, 30.05521279184761)),
Panel(subarray=1, coordinate=Coordinate(1409.4678, 1553.6091, 30.066519581447444)),
Panel(subarray=1, coordinate=Coordinate(1378.431, 1607.2090859999998, 30.054950584052726))
]
# List of subarrays and size/origin info about them
subarray_data = get_subarray_sizes_and_rows(panel_data)
expected_panels = [
Panel(subarray=0, coordinate=Coordinate(0, 0)),
Panel(subarray=0, coordinate=Coordinate(0, 1)),
Panel(subarray=0, coordinate=Coordinate(0, 2)),
Panel(subarray=0, coordinate=Coordinate(1, 0)),
Panel(subarray=0, coordinate=Coordinate(1, 1)),
Panel(subarray=0, coordinate=Coordinate(1, 2)),
Panel(subarray=0, coordinate=Coordinate(2, 0)),
Panel(subarray=0, coordinate=Coordinate(2, 1)),
Panel(subarray=0, coordinate=Coordinate(2, 2)),
Panel(subarray=1, coordinate=Coordinate(0, 0)),
Panel(subarray=1, coordinate=Coordinate(0, 1)),
Panel(subarray=1, coordinate=Coordinate(0, 2)),
Panel(subarray=1, coordinate=Coordinate(0, 3)),
]
subarrays = [
Subarray(origin=Coordinate(0.0007, 0), subarray_number=0, start_row=0, size=9),
Subarray(origin=Coordinate(0, 3.9971), subarray_number=1, start_row=9, size=4),
]
self.values.module_system_constants.return_value = DualTilt96CellConstants()
received_panels, received_subarrays, recieved_buildings = self.subject.transform_coordinates(panel_data, subarray_data,[])
assert_array_is_close(received_panels, expected_panels, decimal=4)
assert_array_equal(received_subarrays, subarrays)
assert_array_equal(recieved_buildings, [])
def test_transform_coordinates_128(self):
panel_data = [
Panel(subarray=0, coordinate=Coordinate(19284.676, 12690.022, 345.000)),
Panel(subarray=0, coordinate=Coordinate(19205.229, 12711.31, 345.000)),
Panel(subarray=0, coordinate=Coordinate(19125.781, 12732.598, 345.000)),
Panel(subarray=0, coordinate=Coordinate(19300.205, 12747.978, 345.000)),
Panel(subarray=0, coordinate=Coordinate(19220.758, 12769.266, 345.000)),
Panel(subarray=0, coordinate=Coordinate(19141.311, 12790.553, 345.000)),
Panel(subarray=0, coordinate=Coordinate(19315.734, 12805.933, 345.000)),
Panel(subarray=0, coordinate=Coordinate(19236.287, 12827.221, 345.000)),
Panel(subarray=0, coordinate=Coordinate(19156.84, 12848.509, 345.000)),
Panel(subarray=1, coordinate=Coordinate(19331.264, 12863.889, 345.000)),
Panel(subarray=1, coordinate=Coordinate(19251.816, 12885.177, 345.000)),
Panel(subarray=1, coordinate=Coordinate(19172.369, 12906.465, 345.000)),
]
subarray_data = get_subarray_sizes_and_rows(panel_data)
expected_panels = [
Panel(subarray=0, coordinate=Coordinate(2, 0)),
Panel(subarray=0, coordinate=Coordinate(1, 0)),
Panel(subarray=0, coordinate=Coordinate(0, 0)),
Panel(subarray=0, coordinate=Coordinate(2, 1)),
Panel(subarray=0, coordinate=Coordinate(1, 1)),
Panel(subarray=0, coordinate=Coordinate(0, 1)),
Panel(subarray=0, coordinate=Coordinate(2, 2)),
Panel(subarray=0, coordinate=Coordinate(1, 2)),
Panel(subarray=0, coordinate=Coordinate(0, 2)),
Panel(subarray=1, coordinate=Coordinate(2, 0)),
Panel(subarray=1, coordinate=Coordinate(1, 0)),
Panel(subarray=1, coordinate=Coordinate(0, 0)),
]
subarrays = [
Subarray(origin=Coordinate(0, 0), subarray_number=0, start_row=0, size=9),
Subarray(origin=Coordinate(0.000006, 3.000008), subarray_number=1, start_row=9, size=3),
]
self.values.module_system_constants.return_value = SingleTilt128CellConstants()
received_panels, received_subarrays, _ = self.subject.transform_coordinates(panel_data, subarray_data, [])
assert_array_is_close(received_panels, expected_panels, decimal=4)
assert_array_equal(received_subarrays, subarrays)
def test_transform_coordinates_doesnt_round_subarray_origins(self):
panel_data = [
Panel(subarray=7, coordinate=Coordinate(81260236.94, 24512483.07, 346)),
Panel(subarray=7, coordinate=Coordinate(81260322.53, 24512461.63, 346)),
Panel(subarray=4, coordinate=Coordinate(81260345.21, 24512649.57, 346)),
Panel(subarray=4, coordinate=Coordinate(81260259.62, 24512671.01, 346)),
]
# List of subarrays and size/origin info about them
subarray_data = get_subarray_sizes_and_rows(panel_data)
expected_panels = [
Panel(subarray=7, coordinate=Coordinate(0, 0)),
Panel(subarray=7, coordinate=Coordinate(1, 0)),
Panel(subarray=4, coordinate=Coordinate(1, 0)),
Panel(subarray=4, coordinate=Coordinate(0, 0)),
]
subarrays = [
Subarray(origin=Coordinate(0.265871, 0), subarray_number=7, start_row=0, size=2),
Subarray(origin=Coordinate(0, 3.029744), subarray_number=4, start_row=2, size=2),
]
self.values.module_system_constants.return_value = DualTilt96CellConstants()
received_panels, received_subarrays, _ = self.subject.transform_coordinates(panel_data, subarray_data, [])
assert_array_is_close(received_panels, expected_panels, decimal=4)
assert_array_equal(received_subarrays, subarrays)
def test_rotation(self):
assert_almost_equal(self.subject.rotate(Coordinate(0, 1, 90)),
Coordinate(1, 0))
assert_almost_equal(self.subject.rotate(Coordinate(4, 7, 53)),
Coordinate(8.00, 1.02), decimal=2)
assert_almost_equal(self.subject.rotate(Coordinate(23, 79.5, -22.8)),
Coordinate(-9.605, 82.201), decimal=2)
def test_scale_96(self):
self.values.module_system_constants.return_value = DualTilt96CellConstants()
coordinate = Coordinate(3, 4)
assert_almost_equal(self.subject.scale(coordinate), Coordinate(3/DualTilt96CellConstants.panel_spacing[0], 4/DualTilt96CellConstants.panel_spacing[1]), decimal=6)
def test_scale_128(self):
self.values.module_system_constants.return_value = DualTilt128CellConstants()
coordinate = Coordinate(3, 4)
assert_almost_equal(self.subject.scale(coordinate), Coordinate(3/DualTilt128CellConstants.panel_spacing[0], 4/DualTilt128CellConstants.panel_spacing[1]), decimal=6)
def test_find_origin(self):
input_matrix = array([Coordinate(3, 4), Coordinate(28, 36), Coordinate(-57, 10)])
assert_almost_equal(self.subject.find_origin(input_matrix), Coordinate(-57, 4))

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,117 @@
import unittest
from unittest.mock import MagicMock
from helix.calculators.mechanical_bom_calculator import MechanicalBomCalculator
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type import ModuleType
from helix.constants.panel_type import PanelType
from helix.constants.parts import *
from helix.constants.system_type import SystemType
from helix.models.panel import Panel
from helix.models.subarray import Subarray
from test.test_helpers import assert_dictionary_equal
class MechanicalBomCalculatorWhenDualTilt128CellTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
self.values.system_type.return_value = SystemType.dualTilt
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip_Plus
self.values.module_type.return_value = ModuleType.Cell128
"""
Generated using the following parameters:
Building Height = 30
Building Length = 200
Building Width = 76
Parapet Height = 0
Wind Speed = 125
Exposure Category = C
Ballast Block Weight = 13
Max Allowable System Pressure = 10
System type = Dual Tilt
"""
self.panels = [
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=4, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=4, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.NorthSouth, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.EastWest, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=15, link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=2, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.NorthSouth, ballast=18, link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.EastWest, ballast=17, link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.Middle, ballast=7, link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.Corner, ballast=12, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=1, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, ballast=9, link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.EastWest, ballast=8, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.Middle, ballast=2, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.Corner, ballast=5, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=1, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, ballast=2, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.EastWest, ballast=3, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.NorthSouth, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.EastWest, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
]
self.subarrays = [
Subarray(subarray_number=0, required_seismic_anchors=4, row_count=10, column_count=2, row_counted_geometrically=True, column_counted_geometrically=True),
]
self.subject = MechanicalBomCalculator(self.values, self.panels, self.subarrays)
def build_panel_type_counts(self, corner, north_south, east_west, middle):
return {
PanelType.Corner: corner,
PanelType.NorthSouth: north_south,
PanelType.EastWest: east_west,
PanelType.Middle: middle
}
def test_compute_mechanical_bom(self):
expected_output = {
wire_clip: 80,
link_tray: 9,
left_deflector: 10,
right_deflector: 10,
anchor_plate: 12,
cross_tray_1_1: 3,
dual_tilt_chassis: 26,
dual_tilt_platform: 26,
rubber_foot: 4,
platform_bolt: 104,
front_skirt_1_1: 20,
leading_tray: 11,
ballast: 102,
anchor: 12, # 4 + the 8 seismic anchors
anchor_washer: 12,
module: 40
}
assert_dictionary_equal(self.subject.mechanical_bom(), expected_output)
def test_compute_mechanical_bom_with_fallback_used(self):
self.subarrays = [
Subarray(subarray_number=0, required_seismic_anchors=4, row_count=10, column_count=2, row_counted_geometrically=False, column_counted_geometrically=False),
]
self.subject = MechanicalBomCalculator(self.values, self.panels, self.subarrays)
expected_output = {
wire_clip: 80,
link_tray: 9,
left_deflector: 10,
right_deflector: 10,
anchor_plate: 12,
cross_tray_1_1: 3,
dual_tilt_chassis: 26,
dual_tilt_platform: 26,
rubber_foot: 4,
platform_bolt: 104,
front_skirt_1_1: 20,
leading_tray: 11.55,
ballast: 102,
anchor: 12, # 4 + the 8 seismic anchors
anchor_washer: 12,
module: 40
}
assert_dictionary_equal(self.subject.mechanical_bom(), expected_output)

View File

@@ -0,0 +1,118 @@
import unittest
from unittest.mock import MagicMock
from helix.calculators.mechanical_bom_calculator import MechanicalBomCalculator
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type import ModuleType
from helix.constants.panel_type import PanelType
from helix.constants.parts import *
from helix.constants.system_type import SystemType
from helix.models.panel import Panel
from helix.models.subarray import Subarray
from test.test_helpers import assert_dictionary_equal
class MechanicalBomCalculatorWhenDualTilt96CellTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
self.values.system_type.return_value = SystemType.dualTilt
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip_Plus
self.values.module_type.return_value = ModuleType.Cell96
"""
Generated using the following parameters:
Building Height = 30
Building Length = 200
Building Width = 76
Parapet Height = 0
Wind Speed = 125
Exposure Category = C
Ballast Block Weight = 13
Max Allowable System Pressure = 10
System type = Dual Tilt
"""
self.panels = [
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=4, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=4, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.NorthSouth, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.EastWest, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=15, link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=2, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.NorthSouth, ballast=18, link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.EastWest, ballast=17, link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.Middle, ballast=7, link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.Corner, ballast=12, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=1, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, ballast=9, link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.EastWest, ballast=8, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.Middle, ballast=2, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.Corner, ballast=5, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=1, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, ballast=2, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.EastWest, ballast=3, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.NorthSouth, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.EastWest, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
]
self.subarrays = [
Subarray(subarray_number=0, required_seismic_anchors=4, row_count=10, column_count=2, row_counted_geometrically=True, column_counted_geometrically=True)
]
self.subject = MechanicalBomCalculator(self.values, self.panels, self.subarrays)
def build_panel_type_counts(self, corner, north_south, east_west, middle):
return {
PanelType.Corner: corner,
PanelType.NorthSouth: north_south,
PanelType.EastWest: east_west,
PanelType.Middle: middle
}
def test_compute_mechanical_bom(self):
expected_output = {
wire_clip: 80,
link_tray: 9,
left_deflector: 10,
right_deflector: 10,
anchor_plate: 12,
cross_tray: 3,
dual_tilt_chassis: 26,
dual_tilt_platform: 26,
rubber_foot: 4,
platform_bolt: 104,
front_skirt: 20,
leading_tray: 11,
ballast: 102,
anchor: 12,
anchor_washer: 12,
module: 40
}
assert_dictionary_equal(self.subject.mechanical_bom(), expected_output)
def test_compute_mechanical_bom_with_fallback_used(self):
self.subarrays = [
Subarray(subarray_number=0, required_seismic_anchors=4, row_count=4, column_count=5, row_counted_geometrically=True, column_counted_geometrically=True)
]
self.subject = MechanicalBomCalculator(self.values, self.panels, self.subarrays)
expected_output = {
wire_clip: 80,
link_tray: 18,
left_deflector: 10,
right_deflector: 10,
anchor_plate: 12,
cross_tray: 3,
dual_tilt_chassis: 26,
dual_tilt_platform: 26,
rubber_foot: 4,
platform_bolt: 104,
front_skirt: 8,
leading_tray: 5,
ballast: 102,
anchor: 12,
anchor_washer: 12,
module: 40
}
assert_dictionary_equal(self.subject.mechanical_bom(), expected_output)

View File

@@ -0,0 +1,116 @@
import unittest
from unittest.mock import MagicMock
from helix.calculators.mechanical_bom_calculator import MechanicalBomCalculator
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type import ModuleType
from helix.constants.panel_type import PanelType
from helix.constants.parts import *
from helix.constants.system_type import SystemType
from helix.models.panel import Panel
from helix.models.subarray import Subarray
from test.test_helpers import assert_dictionary_equal
class MechanicalBomCalculatorWhenDualTiltPSeriesTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
self.values.system_type.return_value = SystemType.dualTilt
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip_Plus
self.values.module_type.return_value = ModuleType.PSeries
"""
Generated using the following parameters:
Building Height = 30
Building Length = 200
Building Width = 76
Parapet Height = 0
Wind Speed = 125
Exposure Category = C
Ballast Block Weight = 13
Max Allowable System Pressure = 10
System type = Dual Tilt
"""
self.panels = [
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=4, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=4, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.NorthSouth, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.EastWest, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=15, link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=2, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.NorthSouth, ballast=18, link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.EastWest, ballast=17, link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.Middle, ballast=7, link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.Corner, ballast=12, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=1, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, ballast=9, link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.EastWest, ballast=8, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.Middle, ballast=2, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.Corner, ballast=5, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=1, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, ballast=2, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.EastWest, ballast=3, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.NorthSouth, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.EastWest, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
]
self.subarrays = [
Subarray(subarray_number=0, required_seismic_anchors=4, row_count=4, column_count=5, row_counted_geometrically=True, column_counted_geometrically=True)
]
self.subject = MechanicalBomCalculator(self.values, self.panels, self.subarrays)
def build_panel_type_counts(self, corner, north_south, east_west, middle):
return {
PanelType.Corner: corner,
PanelType.NorthSouth: north_south,
PanelType.EastWest: east_west,
PanelType.Middle: middle
}
def test_compute_mechanical_bom(self):
expected_output = {
wire_clip: 80,
link_tray: 18,
left_deflector_1_1: 10,
right_deflector_1_1: 10,
anchor_plate: 12,
cross_tray_1_1: 3,
dual_tilt_chassis: 26,
dual_tilt_platform: 26,
rubber_foot: 4,
platform_bolt: 104,
front_skirt_1_1: 8,
leading_tray: 5,
ballast: 102,
anchor: 12, # 4 + the 8 seismic anchors
anchor_washer: 12,
module: 40
}
assert_dictionary_equal(self.subject.mechanical_bom(), expected_output)
def test_compute_mechanical_bom_with_fallback_used(self):
self.subarrays = [
Subarray(subarray_number=0, required_seismic_anchors=4, row_count=4, column_count=5, row_counted_geometrically=True, column_counted_geometrically=True)
]
self.subject = MechanicalBomCalculator(self.values, self.panels, self.subarrays)
expected_output = {
wire_clip: 80,
link_tray: 18,
left_deflector_1_1: 10,
right_deflector_1_1: 10,
anchor_plate: 12,
cross_tray_1_1: 3,
dual_tilt_chassis: 26,
dual_tilt_platform: 26,
rubber_foot: 4,
platform_bolt: 104,
front_skirt_1_1: 8,
leading_tray: 5,
ballast: 102,
anchor: 12, # 4 + the 8 seismic anchors
anchor_washer: 12,
module: 40
}
assert_dictionary_equal(self.subject.mechanical_bom(), expected_output)

View File

@@ -0,0 +1,110 @@
import unittest
from unittest.mock import MagicMock
from helix.calculators.mechanical_bom_calculator import MechanicalBomCalculator
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type import ModuleType
from helix.constants.panel_type import PanelType
from helix.constants.parts import *
from helix.constants.system_type import SystemType
from helix.models.panel import Panel
from helix.models.subarray import Subarray
from test.test_helpers import assert_dictionary_equal
class MechanicalBomCalculatorWhenSingleTilt128CellTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
self.values.system_type.return_value = SystemType.singleTilt
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip_Plus
self.values.module_type.return_value = ModuleType.Cell128
"""
Generated using the following parameters:
Building Height = 30
Building Length = 200
Building Width = 76
Parapet Height = 0
Wind Speed = 125
Exposure Category = C
Anchor type = OMG PowerGrip Plus
Ballast Block Weight = 13
Max Allowable System Pressure = 10
System type = Single Tilt
"""
panels = [
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=6, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=1, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.NorthSouth, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=1, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.EastWest, ballast=0, link_tray=2, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=1, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.NorthSouth, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.EastWest, ballast=0, link_tray=2, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.Middle, ballast=12, link_tray=1, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, ballast=14, link_tray=0, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.EastWest, ballast=9, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.Middle, ballast=7, link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.Corner, ballast=14, link_tray=0, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, ballast=10, link_tray=0, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.EastWest, ballast=6, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.Middle, ballast=3, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.Corner, ballast=9, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.NorthSouth, ballast=3, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.EastWest, ballast=6, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.Middle, ballast=1, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=5, panel_type=PanelType.Corner, ballast=8, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=5, panel_type=PanelType.NorthSouth, ballast=6, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=5, panel_type=PanelType.EastWest, ballast=4, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=5, panel_type=PanelType.Middle, ballast=1, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=6, panel_type=PanelType.Corner, ballast=4, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=1),
Panel(wind_zone=6, panel_type=PanelType.NorthSouth, ballast=3, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=1),
Panel(wind_zone=6, panel_type=PanelType.EastWest, ballast=2, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=1),
Panel(wind_zone=6, panel_type=PanelType.Middle, ballast=1, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=1),
Panel(wind_zone=7, panel_type=PanelType.Corner, ballast=11, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=1),
Panel(wind_zone=7, panel_type=PanelType.NorthSouth, ballast=8, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=1),
Panel(wind_zone=7, panel_type=PanelType.EastWest, ballast=7, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=1),
Panel(wind_zone=7, panel_type=PanelType.Middle, ballast=4, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=1),
Panel(wind_zone=8, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=1),
Panel(wind_zone=8, panel_type=PanelType.NorthSouth, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=1),
Panel(wind_zone=8, panel_type=PanelType.EastWest, ballast=0, link_tray=2, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=1),
Panel(wind_zone=8, panel_type=PanelType.Middle, ballast=6, link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=1),
Panel(wind_zone=9, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=1),
Panel(wind_zone=9, panel_type=PanelType.NorthSouth, ballast=13, link_tray=0, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=1),
Panel(wind_zone=9, panel_type=PanelType.EastWest, ballast=5, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=1),
Panel(wind_zone=9, panel_type=PanelType.Middle, ballast=1, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=1),
Panel(wind_zone=10, panel_type=PanelType.Corner, ballast=4, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=1),
Panel(wind_zone=10, panel_type=PanelType.NorthSouth, ballast=3, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=1),
Panel(wind_zone=10, panel_type=PanelType.EastWest, ballast=1, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=1),
Panel(wind_zone=10, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=1)
]
subarrays = [
Subarray(subarray_number=0, required_seismic_anchors=2, row_count=11, column_count=2, row_counted_geometrically=True, column_counted_geometrically=True),
Subarray(subarray_number=1, required_seismic_anchors=0, row_count=11, column_count=2, row_counted_geometrically=True, column_counted_geometrically=True)
]
self.subject = MechanicalBomCalculator(self.values, panels, subarrays)
def test_compute_mechanical_bom(self):
expected_output = {
wire_clip: 88,
single_tilt_chassis: 46.31,
following_tray: 6,
link_tray: 28,
spoiler_1_1: 44,
left_deflector: 11,
right_deflector: 11,
anchor_plate: 15,
cross_tray_1_1: 5,
rubber_foot: 4.4,
front_skirt_1_1: 4,
rear_skirt_1_1: 44,
leading_tray: 6,
ballast: 192,
anchor: 15, # 12 + the 3 seismic anchors
anchor_washer: 15,
module: 44
}
assert_dictionary_equal(self.subject.mechanical_bom(), expected_output)

View File

@@ -0,0 +1,110 @@
import unittest
from unittest.mock import MagicMock
from helix.calculators.mechanical_bom_calculator import MechanicalBomCalculator
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type import ModuleType
from helix.constants.panel_type import PanelType
from helix.constants.parts import *
from helix.constants.system_type import SystemType
from helix.models.panel import Panel
from helix.models.subarray import Subarray
from test.test_helpers import assert_dictionary_equal
class MechanicalBomCalculatorWhenSingleTilt96CellTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
self.values.system_type.return_value = SystemType.singleTilt
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip_Plus
self.values.module_type.return_value = ModuleType.Cell96
"""
Generated using the following parameters:
Building Height = 30
Building Length = 200
Building Width = 76
Parapet Height = 0
Wind Speed = 125
Exposure Category = C
Anchor type = OMG PowerGrip Plus
Ballast Block Weight = 13
Max Allowable System Pressure = 10
System type = Single Tilt
"""
panels = [
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=6, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=1, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.NorthSouth, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=1, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.EastWest, ballast=0, link_tray=2, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=1, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.NorthSouth, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.EastWest, ballast=0, link_tray=2, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.Middle, ballast=12, link_tray=1, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, ballast=14, link_tray=0, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.EastWest, ballast=9, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.Middle, ballast=7, link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.Corner, ballast=14, link_tray=0, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, ballast=10, link_tray=0, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.EastWest, ballast=6, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.Middle, ballast=3, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.Corner, ballast=9, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.NorthSouth, ballast=3, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.EastWest, ballast=6, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.Middle, ballast=1, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=5, panel_type=PanelType.Corner, ballast=8, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=5, panel_type=PanelType.NorthSouth, ballast=6, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=5, panel_type=PanelType.EastWest, ballast=4, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=5, panel_type=PanelType.Middle, ballast=1, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=6, panel_type=PanelType.Corner, ballast=4, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=6, panel_type=PanelType.NorthSouth, ballast=3, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=6, panel_type=PanelType.EastWest, ballast=2, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=6, panel_type=PanelType.Middle, ballast=1, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=7, panel_type=PanelType.Corner, ballast=11, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=7, panel_type=PanelType.NorthSouth, ballast=8, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=7, panel_type=PanelType.EastWest, ballast=7, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=7, panel_type=PanelType.Middle, ballast=4, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=8, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=8, panel_type=PanelType.NorthSouth, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=8, panel_type=PanelType.EastWest, ballast=0, link_tray=2, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=8, panel_type=PanelType.Middle, ballast=6, link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=9, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=9, panel_type=PanelType.NorthSouth, ballast=13, link_tray=0, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=9, panel_type=PanelType.EastWest, ballast=5, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=9, panel_type=PanelType.Middle, ballast=1, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=10, panel_type=PanelType.Corner, ballast=4, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=10, panel_type=PanelType.NorthSouth, ballast=3, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=10, panel_type=PanelType.EastWest, ballast=1, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=10, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0)
]
subarrays = [
Subarray(subarray_number=0, required_seismic_anchors=2, row_count=2, column_count=24, row_counted_geometrically=True, column_counted_geometrically=True)
]
self.subject = MechanicalBomCalculator(self.values, panels, subarrays)
def test_compute_mechanical_bom(self):
expected_output = {
wire_clip: 88,
single_tilt_chassis: 46.31,
following_tray: 25,
link_tray: 28,
spoiler: 44,
left_deflector: 11,
right_deflector: 11,
anchor_plate: 15,
cross_tray: 5,
rubber_foot: 4.4,
front_skirt: 24,
rear_skirt: 44,
leading_tray: 25,
ballast: 192,
anchor: 15, # 12 + the 3 seismic anchors
anchor_washer: 15,
module: 44
}
assert_dictionary_equal(self.subject.mechanical_bom(), expected_output)

View File

@@ -0,0 +1,110 @@
import unittest
from unittest.mock import MagicMock
from helix.calculators.mechanical_bom_calculator import MechanicalBomCalculator
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type import ModuleType
from helix.constants.panel_type import PanelType
from helix.constants.parts import *
from helix.constants.system_type import SystemType
from helix.models.panel import Panel
from helix.models.subarray import Subarray
from test.test_helpers import assert_dictionary_equal
class MechanicalBomCalculatorWhenSingleTiltPSeriesTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
self.values.system_type.return_value = SystemType.singleTilt
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip_Plus
self.values.module_type.return_value = ModuleType.PSeries
"""
Generated using the following parameters:
Building Height = 30
Building Length = 200
Building Width = 76
Parapet Height = 0
Wind Speed = 125
Exposure Category = C
Anchor type = OMG PowerGrip Plus
Ballast Block Weight = 13
Max Allowable System Pressure = 10
System type = Single Tilt
"""
panels = [
Panel(wind_zone=0, panel_type=PanelType.Corner, ballast=6, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=1, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.NorthSouth, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=1, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.EastWest, ballast=0, link_tray=2, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=0, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=1, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.NorthSouth, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.EastWest, ballast=0, link_tray=2, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=1, panel_type=PanelType.Middle, ballast=12, link_tray=1, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.NorthSouth, ballast=14, link_tray=0, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.EastWest, ballast=9, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=2, panel_type=PanelType.Middle, ballast=7, link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.Corner, ballast=14, link_tray=0, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.NorthSouth, ballast=10, link_tray=0, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.EastWest, ballast=6, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=3, panel_type=PanelType.Middle, ballast=3, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.Corner, ballast=9, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.NorthSouth, ballast=3, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.EastWest, ballast=6, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=4, panel_type=PanelType.Middle, ballast=1, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=5, panel_type=PanelType.Corner, ballast=8, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=5, panel_type=PanelType.NorthSouth, ballast=6, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=5, panel_type=PanelType.EastWest, ballast=4, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=5, panel_type=PanelType.Middle, ballast=1, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=6, panel_type=PanelType.Corner, ballast=4, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=6, panel_type=PanelType.NorthSouth, ballast=3, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=6, panel_type=PanelType.EastWest, ballast=2, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=6, panel_type=PanelType.Middle, ballast=1, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=7, panel_type=PanelType.Corner, ballast=11, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=7, panel_type=PanelType.NorthSouth, ballast=8, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=7, panel_type=PanelType.EastWest, ballast=7, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=7, panel_type=PanelType.Middle, ballast=4, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=8, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=8, panel_type=PanelType.NorthSouth, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=8, panel_type=PanelType.EastWest, ballast=0, link_tray=2, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=8, panel_type=PanelType.Middle, ballast=6, link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=9, panel_type=PanelType.Corner, ballast=0, link_tray=0, cross_tray=0, wind_anchors=1, seismic_anchors=0, subarray=0),
Panel(wind_zone=9, panel_type=PanelType.NorthSouth, ballast=13, link_tray=0, cross_tray=1, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=9, panel_type=PanelType.EastWest, ballast=5, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=9, panel_type=PanelType.Middle, ballast=1, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=10, panel_type=PanelType.Corner, ballast=4, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=10, panel_type=PanelType.NorthSouth, ballast=3, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=10, panel_type=PanelType.EastWest, ballast=1, link_tray=2, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0),
Panel(wind_zone=10, panel_type=PanelType.Middle, ballast=0, link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=0, subarray=0)
]
subarrays = [
Subarray(subarray_number=0, required_seismic_anchors=2, row_count=2, column_count=24, row_counted_geometrically=True, column_counted_geometrically=True)
]
self.subject = MechanicalBomCalculator(self.values, panels, subarrays)
def test_compute_mechanical_bom(self):
expected_output = {
wire_clip: 88,
single_tilt_chassis: 46.31,
following_tray: 25,
link_tray: 28,
spoiler_1_1: 44,
left_deflector_1_1: 11,
right_deflector_1_1: 11,
anchor_plate: 15,
cross_tray_1_1: 5,
rubber_foot: 4.4,
front_skirt_1_1: 24,
rear_skirt_1_1: 44,
leading_tray: 25,
ballast: 192,
anchor: 15, # 12 + the 3 seismic anchors
anchor_washer: 15,
module: 44
}
assert_dictionary_equal(self.subject.mechanical_bom(), expected_output)

View File

@@ -0,0 +1,140 @@
import unittest
import numpy
from nose.tools import assert_almost_equal, eq_
from numpy.testing import assert_array_almost_equal
from helix.calculators.pressure_coefficient_calculator import PressureCoefficientCalculator
from helix.constants.module_type import ModuleType
from helix.constants.system_type import SystemType
from helix.models.sql.sites import Site
from helix.user_values import UserValues
class PressureCoefficientCalculatorWhenDualTiltAnd128CellTest(unittest.TestCase):
def setUp(self):
self.site = Site(
building_height=0,
building_width=0,
building_length=0,
parapet_height=0,
wind_speed=0,
exposure_category='C',
ballast_block_weight=0,
max_psf=0,
system_type=SystemType.dualTilt.value,
module_type=ModuleType.Cell128.value,
spectral_response=0,
seismic_importance_factor=1,
)
self.subject = PressureCoefficientCalculator(UserValues(None, self.site))
def test_A_n(self):
result = self.subject.A_n(35.777)
numpy.testing.assert_almost_equal(result, [58.771147, 124.456547, 118.997927, 246.911600], 6)
def test_c_p_in_wind_zone_A(self):
assert_almost_equal(self.subject.c_p(597.17, 'A', 1, 1), 0.22, 2)
assert_almost_equal(self.subject.c_p(597.17, 'A', 0.8, 1), 0.18, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'A', 1, 1), 0.15, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'A', 0.8, 1), 0.12, 2)
def test_c_p_in_wind_zone_B(self):
assert_almost_equal(self.subject.c_p(182.39, 'B', 1, 1), 0.27, 2)
assert_almost_equal(self.subject.c_p(182.39, 'B', 0.8, 1), 0.22, 2)
assert_almost_equal(self.subject.c_p(659.25, 'B', 1, 1), 0.13, 2)
assert_almost_equal(self.subject.c_p(659.25, 'B', 0.8, 1), 0.11, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'B', 1, 1), 0.10, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'B', 0.8, 1), 0.08, 2)
def test_c_p_in_wind_zone_C(self):
assert_almost_equal(self.subject.c_p(182.39, 'C', 1, 1), 0.17, 2)
assert_almost_equal(self.subject.c_p(182.39, 'C', 0.8, 1), 0.13, 2)
assert_almost_equal(self.subject.c_p(659.25, 'C', 1, 1), 0.09, 2)
assert_almost_equal(self.subject.c_p(659.25, 'C', 0.8, 1), 0.07, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'C', 1, 1), 0.08, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'C', 0.8, 1), 0.06, 2)
def test_c_p_in_wind_zone_D(self):
assert_almost_equal(self.subject.c_p(182.39, 'D', 1, 1), 0.10, 2)
assert_almost_equal(self.subject.c_p(182.39, 'D', 0.8, 1), 0.08, 2)
assert_almost_equal(self.subject.c_p(659.25, 'D', 1, 1), 0.05, 2)
assert_almost_equal(self.subject.c_p(659.25, 'D', 0.8, 1), 0.04, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'D', 1, 1), 0.05, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'D', 0.8, 1), 0.04, 2)
def test_c_p_matrix_when_building_dimensions_are_zero(self):
self.site.building_height = 0
self.site.building_width = 0
self.site.building_length = 0
self.site.parapet_height = 1.6 # so that parapet factor equals 1
expected_matrix = [[0.06, 0.05, 0.05, 0.04],
[0.06, 0.05, 0.05, 0.04],
[0.06, 0.05, 0.05, 0.04],
[0.06, 0.05, 0.05, 0.04],
[0.06, 0.05, 0.05, 0.04]]
numpy.testing.assert_almost_equal(self.subject.c_p_matrix(self.subject.L_B()), expected_matrix, 2)
def test_c_p_matrix_compiles_all_the_panel_types_and_wind_zones_correctly(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
self.site.parapet_height = 10.0 # so that parapet factor equals
eq_(self.subject.parapet_factor(), 1)
expected_matrix = [[0.854519, 0.746475, 0.752934, 0.647825],
[0.646303, 0.558517, 0.563765, 0.478364],
[0.400592, 0.345819, 0.349094, 0.295809],
[0.224301, 0.195039, 0.196788, 0.168321],
[0.060000, 0.050000, 0.052000, 0.039000]]
numpy.testing.assert_almost_equal(self.subject.c_p_matrix(self.subject.L_B()), expected_matrix, 6)
def test_c_p_matrix_compiles_all_the_panel_types_and_wind_zones_correctly_using_parapet_factor(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
self.site.parapet_height = 20
expected_matrix = [[0.957062, 0.836052, 0.843286, 0.725564],
[0.723860, 0.625540, 0.631417, 0.535768],
[0.448663, 0.387318, 0.390985, 0.331306],
[0.251217, 0.218444, 0.220403, 0.188520],
[0.060000, 0.050000, 0.052000, 0.039000]]
numpy.testing.assert_almost_equal(self.subject.c_p_matrix(self.subject.L_B()), expected_matrix, 6)
def test_minimum_array_cp(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
self.site.parapet_height = 5
expected = [0.675935, 0.501203, 0.310059, 0.175934, 0.042343]
assert_array_almost_equal(self.subject.ideal_subarray_average_uplift_c_p(self.subject.L_B()), expected, decimal=6)
def test_minimum_A_n(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
self.site.parapet_height = 5
expected = [96.531228, 84.051118, 100.871967, 85.479467, None]
received = self.subject.minimum_A_n(self.subject.L_B())
assert_array_almost_equal(received[:-1], expected[:-1], decimal=6)
eq_(received[-1], expected[-1])
def test_minimum_array_size(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
self.site.parapet_height = 5
expected = [21, 19, 22, 19, 6]
eq_(self.subject.minimum_array_size(self.subject.L_B()), expected)

View File

@@ -0,0 +1,135 @@
import unittest
import numpy
from nose.tools import assert_almost_equal, eq_
from numpy.testing import assert_array_almost_equal
from helix.calculators.pressure_coefficient_calculator import PressureCoefficientCalculator
from helix.constants.module_type import ModuleType
from helix.constants.system_type import SystemType
from helix.models.sql.sites import Site
from helix.user_values import UserValues
class PressureCoefficientCalculatorWhenDualTiltAnd96CellTest(unittest.TestCase):
def setUp(self):
self.site = Site(
building_height=0,
building_width=0,
building_length=0,
parapet_height=0,
wind_speed=0,
exposure_category='C',
ballast_block_weight=0,
max_psf=0,
system_type=SystemType.dualTilt.value,
module_type=ModuleType.Cell96.value,
spectral_response=0,
seismic_importance_factor=1,
)
self.subject = PressureCoefficientCalculator(UserValues(None, self.site))
def test_A_n(self):
result = self.subject.A_n(35.777)
numpy.testing.assert_almost_equal(result, [45.6, 90.37, 100.12, 298.59], 2)
def test_c_p_in_wind_zone_A(self):
assert_almost_equal(self.subject.c_p(597.17, 'A', 1, 1), 0.22, 2)
assert_almost_equal(self.subject.c_p(597.17, 'A', 0.8, 1), 0.18, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'A', 1, 1), 0.15, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'A', 0.8, 1), 0.12, 2)
def test_c_p_in_wind_zone_B(self):
assert_almost_equal(self.subject.c_p(182.39, 'B', 1, 1), 0.27, 2)
assert_almost_equal(self.subject.c_p(182.39, 'B', 0.8, 1), 0.22, 2)
assert_almost_equal(self.subject.c_p(659.25, 'B', 1, 1), 0.13, 2)
assert_almost_equal(self.subject.c_p(659.25, 'B', 0.8, 1), 0.11, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'B', 1, 1), 0.10, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'B', 0.8, 1), 0.08, 2)
def test_c_p_in_wind_zone_C(self):
assert_almost_equal(self.subject.c_p(182.39, 'C', 1, 1), 0.17, 2)
assert_almost_equal(self.subject.c_p(182.39, 'C', 0.8, 1), 0.13, 2)
assert_almost_equal(self.subject.c_p(659.25, 'C', 1, 1), 0.09, 2)
assert_almost_equal(self.subject.c_p(659.25, 'C', 0.8, 1), 0.07, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'C', 1, 1), 0.08, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'C', 0.8, 1), 0.06, 2)
def test_c_p_in_wind_zone_D(self):
assert_almost_equal(self.subject.c_p(182.39, 'D', 1, 1), 0.10, 2)
assert_almost_equal(self.subject.c_p(182.39, 'D', 0.8, 1), 0.08, 2)
assert_almost_equal(self.subject.c_p(659.25, 'D', 1, 1), 0.05, 2)
assert_almost_equal(self.subject.c_p(659.25, 'D', 0.8, 1), 0.04, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'D', 1, 1), 0.05, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'D', 0.8, 1), 0.04, 2)
def test_c_p_matrix_when_building_dimensions_are_zero(self):
self.site.building_height = 0
self.site.building_width = 0
self.site.building_length = 0
self.site.parapet_height = 1.6 # so that parapet factor equals 1
expected_matrix = [[0.06, 0.05, 0.05, 0.04],
[0.06, 0.05, 0.05, 0.04],
[0.06, 0.05, 0.05, 0.04],
[0.06, 0.05, 0.05, 0.04],
[0.06, 0.05, 0.05, 0.04]]
numpy.testing.assert_almost_equal(self.subject.c_p_matrix(self.subject.L_B()), expected_matrix, 2)
def test_c_p_matrix_compiles_all_the_panel_types_and_wind_zones_correctly(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
self.site.parapet_height = 10.71428571 # so that parapet factor equals 1
expected_matrix = [[0.89, 0.79, 0.78, 0.62],
[0.68, 0.60, 0.58, 0.46],
[0.42, 0.37, 0.36, 0.28],
[0.23, 0.21, 0.20, 0.16],
[0.06, 0.05, 0.05, 0.04]]
numpy.testing.assert_almost_equal(self.subject.c_p_matrix(self.subject.L_B()), expected_matrix, 2)
def test_c_p_matrix_compiles_all_the_panel_types_and_wind_zones_correctly_using_parapet_factor(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
self.site.parapet_height = 20
expected_matrix = [[1.00, 0.89, 0.87, 0.69],
[0.76, 0.67, 0.65, 0.51],
[0.47, 0.41, 0.41, 0.32],
[0.26, 0.23, 0.23, 0.18],
[0.07, 0.06, 0.06, 0.04]]
numpy.testing.assert_almost_equal(self.subject.c_p_matrix(self.subject.L_B()), expected_matrix, 2)
def test_minimum_array_cp(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
expected = [0.663381, 0.491003, 0.303695, 0.172534, 0.042343]
assert_array_almost_equal(self.subject.ideal_subarray_average_uplift_c_p(self.subject.L_B()), expected, decimal=6)
def test_minimum_A_n(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
expected = [103.23, 89.62, 107.24, 91.62, None]
received = self.subject.minimum_A_n(self.subject.L_B())
assert_array_almost_equal(received[:-1], expected[:-1], decimal=2)
eq_(received[-1], expected[-1])
def test_minimum_array_size(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
expected = [30, 26, 31, 27, 6]
eq_(self.subject.minimum_array_size(self.subject.L_B()), expected)

View File

@@ -0,0 +1,140 @@
import unittest
import numpy
from nose.tools import assert_almost_equal, eq_
from numpy.testing import assert_array_almost_equal
from helix.calculators.pressure_coefficient_calculator import PressureCoefficientCalculator
from helix.constants.module_type import ModuleType
from helix.constants.system_type import SystemType
from helix.models.sql.sites import Site
from helix.user_values import UserValues
class PressureCoefficientCalculatorWhenDualTiltAndPSeriesTest(unittest.TestCase):
def setUp(self):
self.site = Site(
building_height=0,
building_width=0,
building_length=0,
parapet_height=0,
wind_speed=0,
exposure_category='C',
ballast_block_weight=0,
max_psf=0,
system_type=SystemType.dualTilt.value,
module_type=ModuleType.PSeries.value,
spectral_response=0,
seismic_importance_factor=1,
)
self.subject = PressureCoefficientCalculator(UserValues(None, self.site))
def test_A_n(self):
result = self.subject.A_n(35.777)
numpy.testing.assert_almost_equal(result, [56.071056, 118.738707, 113.530869, 235.567873], 6)
def test_c_p_in_wind_zone_A(self):
assert_almost_equal(self.subject.c_p(597.17, 'A', 1, 1), 0.22, 2)
assert_almost_equal(self.subject.c_p(597.17, 'A', 0.8, 1), 0.18, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'A', 1, 1), 0.15, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'A', 0.8, 1), 0.12, 2)
def test_c_p_in_wind_zone_B(self):
assert_almost_equal(self.subject.c_p(182.39, 'B', 1, 1), 0.27, 2)
assert_almost_equal(self.subject.c_p(182.39, 'B', 0.8, 1), 0.22, 2)
assert_almost_equal(self.subject.c_p(659.25, 'B', 1, 1), 0.13, 2)
assert_almost_equal(self.subject.c_p(659.25, 'B', 0.8, 1), 0.11, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'B', 1, 1), 0.10, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'B', 0.8, 1), 0.08, 2)
def test_c_p_in_wind_zone_C(self):
assert_almost_equal(self.subject.c_p(182.39, 'C', 1, 1), 0.17, 2)
assert_almost_equal(self.subject.c_p(182.39, 'C', 0.8, 1), 0.13, 2)
assert_almost_equal(self.subject.c_p(659.25, 'C', 1, 1), 0.09, 2)
assert_almost_equal(self.subject.c_p(659.25, 'C', 0.8, 1), 0.07, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'C', 1, 1), 0.08, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'C', 0.8, 1), 0.06, 2)
def test_c_p_in_wind_zone_D(self):
assert_almost_equal(self.subject.c_p(182.39, 'D', 1, 1), 0.10, 2)
assert_almost_equal(self.subject.c_p(182.39, 'D', 0.8, 1), 0.08, 2)
assert_almost_equal(self.subject.c_p(659.25, 'D', 1, 1), 0.05, 2)
assert_almost_equal(self.subject.c_p(659.25, 'D', 0.8, 1), 0.04, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'D', 1, 1), 0.05, 2)
assert_almost_equal(self.subject.c_p(1194.34, 'D', 0.8, 1), 0.04, 2)
def test_c_p_matrix_when_building_dimensions_are_zero(self):
self.site.building_height = 0
self.site.building_width = 0
self.site.building_length = 0
self.site.building_parapet_height = 1.6 # so that parapet factor equals 1
expected_matrix = [[0.06, 0.05, 0.05, 0.04],
[0.06, 0.05, 0.05, 0.04],
[0.06, 0.05, 0.05, 0.04],
[0.06, 0.05, 0.05, 0.04],
[0.06, 0.05, 0.05, 0.04]]
numpy.testing.assert_almost_equal(self.subject.c_p_matrix(self.subject.L_B()), expected_matrix, 2)
def test_c_p_matrix_compiles_all_the_panel_types_and_wind_zones_correctly(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
self.site.parapet_height = 10.0 # so that parapet factor equals 1
eq_(self.subject.parapet_factor(), 1)
expected_matrix = [[0.861292, 0.753248, 0.759706, 0.654597],
[0.651806, 0.564020, 0.569268, 0.483867],
[0.404025, 0.349253, 0.352527, 0.299242],
[0.226135, 0.196873, 0.198623, 0.170156],
[0.060000, 0.050000, 0.052000, 0.039000]]
numpy.testing.assert_almost_equal(self.subject.c_p_matrix(self.subject.L_B()), expected_matrix, 6)
def test_c_p_matrix_compiles_all_the_panel_types_and_wind_zones_correctly_using_parapet_factor(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
self.site.parapet_height = 20
expected_matrix = [[0.964647, 0.843638, 0.850871, 0.733149],
[0.730023, 0.631703, 0.637580, 0.541930],
[0.452508, 0.391163, 0.394830, 0.335151],
[0.253272, 0.220498, 0.222457, 0.190574],
[0.060000, 0.050000, 0.052000, 0.039000]]
numpy.testing.assert_almost_equal(self.subject.c_p_matrix(self.subject.L_B()), expected_matrix, 6)
def test_minimum_array_cp(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
self.site.parapet_height = 5
expected = [0.682707, 0.506706, 0.313493, 0.177769, 0.042343]
assert_array_almost_equal(self.subject.ideal_subarray_average_uplift_c_p(self.subject.L_B()), expected, decimal=6)
def test_minimum_A_n(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
self.site.parapet_height = 5
expected = [93.097743, 81.192041, 97.596312, 82.338856, None]
received = self.subject.minimum_A_n(self.subject.L_B())
assert_array_almost_equal(received[:-1], expected[:-1], decimal=6)
eq_(received[-1], expected[-1])
def test_minimum_array_size(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
self.site.parapet_height = 5
expected = [21, 19, 22, 19, 6]
eq_(self.subject.minimum_array_size(self.subject.L_B()), expected)

View File

@@ -0,0 +1,82 @@
import unittest
from nose.tools import assert_almost_equal
from helix.calculators.pressure_coefficient_calculator import PressureCoefficientCalculator
from helix.constants.module_type import ModuleType
from helix.constants.system_type import SystemType
from helix.models.sql.sites import Site
from helix.user_values import UserValues
class PressureCoefficientCalculatorTest(unittest.TestCase):
def setUp(self):
self.site = Site(
building_height=0,
building_width=0,
building_length=0,
parapet_height=0,
wind_speed=0,
exposure_category='C',
ballast_block_weight=0,
max_psf=0,
system_type=SystemType.dualTilt.value,
module_type=ModuleType.Cell128.value,
spectral_response=0,
seismic_importance_factor=1,
)
self.subject = PressureCoefficientCalculator(UserValues(None, self.site))
def test_L_B_when_building_dimensions_are_zero(self):
self.site.building_height = 0
self.site.building_width = 0
self.site.building_length = 0
assert_almost_equal(self.subject.L_B(), 1.549193338, 2)
def test_L_B_when_limited_by_building_height(self):
self.site.building_height = 35
self.site.building_width = 250
self.site.building_length = 250
assert_almost_equal(self.subject.L_B(), 35.000, 2)
def test_L_B_when_limited_by_width(self):
self.site.building_height = 35
self.site.building_width = 80
self.site.building_length = 75
assert_almost_equal(self.subject.L_B(), 21.166, 2)
def test_L_B_when_limited_by_length(self):
self.site.building_height = 80
self.site.building_width = 90
self.site.building_length = 100
assert_almost_equal(self.subject.L_B(), 35.777, 2)
def test_L_B_when_building_height_less_than_15(self):
self.site.building_height = 12
self.site.building_width = 250
self.site.building_length = 250
assert_almost_equal(self.subject.L_B(), 15.000, 2)
def test_parapet_factor_when_parapet_height_over_building_height_greater_than_point_2(self):
self.site.building_height = 20
self.site.parapet_height = 10
assert_almost_equal(self.subject.parapet_factor(), 1.12, 2)
self.site.building_height = 0
assert_almost_equal(self.subject.parapet_factor(), 1.12, 2)
def test_parapet_factor_when_parapet_height_over_building_height_less_than_point_2(self):
self.site.building_height = 20
self.site.parapet_height = 1
assert_almost_equal(self.subject.parapet_factor(), 0.94, 2)
self.site.building_height = 0
assert_almost_equal(self.subject.parapet_factor(), 0.96, 2)
self.site.parapet_height = 0
assert_almost_equal(self.subject.parapet_factor(), 0.88, 2)

View File

@@ -0,0 +1,166 @@
import unittest
import numpy
from nose.tools import assert_almost_equal, eq_
from numpy.testing import assert_array_almost_equal
from helix.calculators.pressure_coefficient_calculator import PressureCoefficientCalculator
from helix.constants.module_type import ModuleType
from helix.constants.system_type import SystemType
from helix.models.sql.sites import Site
from helix.user_values import UserValues
class PressureCoefficientCalculatorWhenSingleTiltAnd128CellTest(unittest.TestCase):
def setUp(self):
self.site = Site(
building_height=0,
building_width=0,
building_length=0,
parapet_height=0,
wind_speed=0,
exposure_category='C',
ballast_block_weight=0,
max_psf=0,
system_type=SystemType.singleTilt.value,
module_type=ModuleType.Cell128.value,
spectral_response=0,
seismic_importance_factor=1,
)
self.subject = PressureCoefficientCalculator(UserValues(None, self.site))
def test_A_n(self):
result = self.subject.A_n(63.25)
numpy.testing.assert_almost_equal(result, [10.886544, 18.862247, 18.862247, 22.238823], 6)
def test_c_p_in_wind_zone_A(self):
assert_almost_equal(self.subject.c_p(9.10, 'A', 1, 1), 1.22, 2)
assert_almost_equal(self.subject.c_p(500.0, 'A', 1, 1), 0.34, 2)
assert_almost_equal(self.subject.c_p(3000.0, 'A', 1, 1), 0.13, 2)
def test_c_p_in_wind_zone_B(self):
assert_almost_equal(self.subject.c_p(9.10, 'B', 1, 1), 0.96, 2)
assert_almost_equal(self.subject.c_p(500.0, 'B', 1, 1), 0.25, 2)
assert_almost_equal(self.subject.c_p(3000.0, 'B', 1, 1), 0.13, 2)
def test_c_p_in_wind_zone_C(self):
assert_almost_equal(self.subject.c_p(9.10, 'C', 1, 1), 0.48, 2)
assert_almost_equal(self.subject.c_p(500.0, 'C', 1, 1), 0.19, 2)
assert_almost_equal(self.subject.c_p(3000.0, 'C', 1, 1), 0.09, 2)
def test_c_p_in_wind_zone_D(self):
assert_almost_equal(self.subject.c_p(9.10, 'D', 1, 1), 0.46, 2)
assert_almost_equal(self.subject.c_p(200, 'D', 1, 1), 0.16, 2)
assert_almost_equal(self.subject.c_p(500.0, 'D', 1, 1), 0.12, 2)
def test_c_p_in_wind_zone_E(self):
assert_almost_equal(self.subject.c_p(9.10, 'E', 1, 1), 0.30, 2)
assert_almost_equal(self.subject.c_p(200, 'E', 1, 1), 0.12, 2)
assert_almost_equal(self.subject.c_p(317.22133, 'E', 1, 1), 0.09265, 4)
assert_almost_equal(self.subject.c_p(500.0, 'E', 1, 1), 0.08, 2)
def test_c_p_in_wind_zone_F(self):
assert_almost_equal(self.subject.c_p(9.10, 'F', 1, 1), 0.32, 2)
assert_almost_equal(self.subject.c_p(200, 'F', 1, 1), 0.12, 2)
assert_almost_equal(self.subject.c_p(500.0, 'F', 1, 1), 0.08, 2)
def test_c_p_in_wind_zone_G(self):
assert_almost_equal(self.subject.c_p(9.10, 'G', 1, 1), 0.20, 2)
assert_almost_equal(self.subject.c_p(200, 'G', 1, 1), 0.10, 2)
assert_almost_equal(self.subject.c_p(500.0, 'G', 1, 1), 0.08, 2)
def test_c_p_in_wind_zone_H(self):
assert_almost_equal(self.subject.c_p(9.10, 'H', 1, 1), 0.53, 2)
assert_almost_equal(self.subject.c_p(200, 'H', 1, 1), 0.18, 2)
assert_almost_equal(self.subject.c_p(500.0, 'H', 1, 1), 0.11, 2)
assert_almost_equal(self.subject.c_p(3000.0, 'H', 1, 1), 0.05, 2)
def test_c_p_in_wind_zone_I(self):
assert_almost_equal(self.subject.c_p(9.10, 'I', 1, 1), 1.41, 2)
assert_almost_equal(self.subject.c_p(200, 'I', 1, 1), 0.23, 2)
assert_almost_equal(self.subject.c_p(500.0, 'I', 1, 1), 0.11, 2)
assert_almost_equal(self.subject.c_p(3000.0, 'I', 1, 1), 0.05, 2)
def test_c_p_in_wind_zone_J(self):
assert_almost_equal(self.subject.c_p(9.10, 'J', 1, 1), 0.43, 2)
assert_almost_equal(self.subject.c_p(200, 'J', 1, 1), 0.12, 2)
assert_almost_equal(self.subject.c_p(500.0, 'J', 1, 1), 0.08, 2)
def test_c_p_matrix_when_building_dimensions_are_zero(self):
self.site.building_height = 0
self.site.building_width = 0
self.site.building_length = 0
self.site.building_parapet_height = 1.6 # so that parapet factor equals 1
expected_matrix = [[0.17, 0.15, 0.11, 0.10],
[0.17, 0.15, 0.11, 0.10],
[0.17, 0.15, 0.11, 0.10],
[0.17, 0.15, 0.11, 0.10],
[0.17, 0.15, 0.11, 0.10],
[0.17, 0.15, 0.11, 0.10],
[0.17, 0.15, 0.11, 0.10],
[0.17, 0.15, 0.11, 0.10],
[0.17, 0.15, 0.11, 0.10],
[0.17, 0.15, 0.11, 0.10],
[0.17, 0.15, 0.11, 0.10]]
numpy.testing.assert_almost_equal(self.subject.c_p_matrix(self.subject.L_B()), expected_matrix, 2)
def test_c_p_matrix_compiles_all_the_panel_types_and_wind_zones_correctly(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
self.site.parapet_height = 20
expected_matrix = numpy.array([[1.86, 1.70, 1.41, 1.37],
[1.47, 1.33, 1.11, 1.08],
[0.84, 0.78, 0.56, 0.54],
[0.84, 0.76, 0.54, 0.52],
[0.57, 0.34, 0.51, 0.33],
[0.54, 0.49, 0.38, 0.36],
[0.26, 0.23, 0.23, 0.23],
[0.69, 0.62, 0.62, 0.60],
[1.89, 1.66, 1.66, 1.59],
[1.13, 1.01, 0.50, 0.48],
[0.17, 0.15, 0.11, 0.10]])
numpy.testing.assert_almost_equal(self.subject.c_p_matrix(self.subject.L_B()), expected_matrix, 2)
def test_minimum_array_cp(self):
# FIXME: Revisit this after Ian figures out how minimum array sizes change
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
expected = [1.249994, 0.979863, 0.499699, 0.483089, 0.308544, 0.333895,
0.204906, 0.536295, 1.424674, 0.466723, 0.107297]
assert_array_almost_equal(self.subject.ideal_subarray_average_uplift_c_p(self.subject.L_B()), expected, decimal=6)
def test_minimum_A_n(self):
# FIXME: Revisit this after Ian figures out how minimum array sizes change
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
expected = [141.98, 144.67, 298.73, 849.16, 169.66, 63.78, 394.38, 162.38, 66.49, 15.88, 69.08]
received = self.subject.minimum_A_n(self.subject.L_B())
assert_array_almost_equal(received, expected, decimal=2)
def test_minimum_array_size(self):
# FIXME: Revisit this after Ian figures out how minimum array sizes change
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
expected = [61, 63, 129, 365, 73, 28, 170, 70, 29, 7, 30]
eq_(self.subject.minimum_array_size(self.subject.L_B()), expected)
def test_minimum_array_size_smaller_array(self):
# FIXME: Revisit this after Ian figures out how minimum array sizes change
self.site.building_height = 15
self.site.building_width = 500
self.site.building_length = 500
expected = [14, 17, 11, 29, 13, 16, 16, 14, 9, 20, 1]
eq_(self.subject.minimum_array_size(self.subject.L_B()), expected)

View File

@@ -0,0 +1,163 @@
import unittest
import mockredis
import numpy
from nose.tools import assert_almost_equal, eq_
from numpy.testing import assert_array_almost_equal
from helix.calculators.pressure_coefficient_calculator import PressureCoefficientCalculator
from helix.constants.module_type import ModuleType
from helix.constants.system_type import SystemType
from helix.models.sql.sites import Site
from helix.user_values import UserValues
class PressureCoefficientCalculatorWhenSingleTiltAnd96CellTest(unittest.TestCase):
def setUp(self):
self.site = Site(
building_height=0,
building_width=0,
building_length=0,
parapet_height=0,
wind_speed=0,
exposure_category='C',
ballast_block_weight=0,
max_psf=0,
system_type=SystemType.singleTilt.value,
module_type=ModuleType.Cell96.value,
spectral_response=0,
seismic_importance_factor=1,
)
self.subject = PressureCoefficientCalculator(UserValues(None, self.site))
def test_A_n(self):
result = self.subject.A_n(63.25)
numpy.testing.assert_almost_equal(result, [9.10, 17.84, 17.84, 43.03], 2)
def test_c_p_in_wind_zone_A(self):
assert_almost_equal(self.subject.c_p(9.10, 'A', 1, 1), 1.22, 2)
assert_almost_equal(self.subject.c_p(500.0, 'A', 1, 1), 0.34, 2)
assert_almost_equal(self.subject.c_p(3000.0, 'A', 1, 1), 0.13, 2)
def test_c_p_in_wind_zone_B(self):
assert_almost_equal(self.subject.c_p(9.10, 'B', 1, 1), 0.96, 2)
assert_almost_equal(self.subject.c_p(500.0, 'B', 1, 1), 0.25, 2)
assert_almost_equal(self.subject.c_p(3000.0, 'B', 1, 1), 0.13, 2)
def test_c_p_in_wind_zone_C(self):
assert_almost_equal(self.subject.c_p(9.10, 'C', 1, 1), 0.48, 2)
assert_almost_equal(self.subject.c_p(500.0, 'C', 1, 1), 0.19, 2)
assert_almost_equal(self.subject.c_p(3000.0, 'C', 1, 1), 0.09, 2)
def test_c_p_in_wind_zone_D(self):
assert_almost_equal(self.subject.c_p(9.10, 'D', 1, 1), 0.46, 2)
assert_almost_equal(self.subject.c_p(200, 'D', 1, 1), 0.16, 2)
assert_almost_equal(self.subject.c_p(500.0, 'D', 1, 1), 0.12, 2)
def test_c_p_in_wind_zone_E(self):
assert_almost_equal(self.subject.c_p(9.10, 'E', 1, 1), 0.30, 2)
assert_almost_equal(self.subject.c_p(200, 'E', 1, 1), 0.12, 2)
assert_almost_equal(self.subject.c_p(317.22133, 'E', 1, 1), 0.09265, 4)
assert_almost_equal(self.subject.c_p(500.0, 'E', 1, 1), 0.08, 2)
def test_c_p_in_wind_zone_F(self):
assert_almost_equal(self.subject.c_p(9.10, 'F', 1, 1), 0.32, 2)
assert_almost_equal(self.subject.c_p(200, 'F', 1, 1), 0.12, 2)
assert_almost_equal(self.subject.c_p(500.0, 'F', 1, 1), 0.08, 2)
def test_c_p_in_wind_zone_G(self):
assert_almost_equal(self.subject.c_p(9.10, 'G', 1, 1), 0.20, 2)
assert_almost_equal(self.subject.c_p(200, 'G', 1, 1), 0.10, 2)
assert_almost_equal(self.subject.c_p(500.0, 'G', 1, 1), 0.08, 2)
def test_c_p_in_wind_zone_H(self):
assert_almost_equal(self.subject.c_p(9.10, 'H', 1, 1), 0.53, 2)
assert_almost_equal(self.subject.c_p(200, 'H', 1, 1), 0.18, 2)
assert_almost_equal(self.subject.c_p(500.0, 'H', 1, 1), 0.11, 2)
assert_almost_equal(self.subject.c_p(3000.0, 'H', 1, 1), 0.05, 2)
def test_c_p_in_wind_zone_I(self):
assert_almost_equal(self.subject.c_p(9.10, 'I', 1, 1), 1.41, 2)
assert_almost_equal(self.subject.c_p(200, 'I', 1, 1), 0.23, 2)
assert_almost_equal(self.subject.c_p(500.0, 'I', 1, 1), 0.11, 2)
assert_almost_equal(self.subject.c_p(3000.0, 'I', 1, 1), 0.05, 2)
def test_c_p_in_wind_zone_J(self):
assert_almost_equal(self.subject.c_p(9.10, 'J', 1, 1), 0.43, 2)
assert_almost_equal(self.subject.c_p(200, 'J', 1, 1), 0.12, 2)
assert_almost_equal(self.subject.c_p(500.0, 'J', 1, 1), 0.08, 2)
def test_c_p_matrix_when_building_dimensions_are_zero(self):
self.site.building_height = 0
self.site.building_width = 0
self.site.building_length = 0
self.site.building_parapet_height = 1.6 # so that parapet factor equals 1
expected_matrix = [[0.17, 0.14, 0.10, 0.08],
[0.17, 0.14, 0.10, 0.08],
[0.17, 0.14, 0.10, 0.08],
[0.17, 0.14, 0.10, 0.08],
[0.17, 0.14, 0.10, 0.08],
[0.17, 0.14, 0.10, 0.08],
[0.17, 0.14, 0.10, 0.08],
[0.17, 0.14, 0.10, 0.08],
[0.17, 0.14, 0.10, 0.08],
[0.17, 0.14, 0.10, 0.08],
[0.17, 0.14, 0.10, 0.08]]
numpy.testing.assert_almost_equal(self.subject.c_p_matrix(self.subject.L_B()), expected_matrix, 2)
def test_c_p_matrix_compiles_all_the_panel_types_and_wind_zones_correctly(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
self.site.parapet_height = 20
expected_matrix = numpy.array([[1.92, 1.71, 1.43, 1.21],
[1.51, 1.35, 1.12, 0.94],
[0.86, 0.78, 0.56, 0.49],
[0.87, 0.77, 0.55, 0.45],
[0.59, 0.35, 0.52, 0.29],
[0.56, 0.49, 0.38, 0.32],
[0.26, 0.24, 0.24, 0.20],
[0.71, 0.63, 0.63, 0.51],
[1.97, 1.68, 1.68, 1.30],
[1.17, 1.02, 0.51, 0.41],
[0.17, 0.14, 0.10, 0.08]])
numpy.testing.assert_almost_equal(self.subject.c_p_matrix(self.subject.L_B()), expected_matrix, 2)
def test_minimum_array_cp(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
expected = [1.123613, 0.877519, 0.458390, 0.426493, 0.275965, 0.297052,
0.185678, 0.470831, 1.207250, 0.409452, 0.084812]
assert_array_almost_equal(self.subject.ideal_subarray_average_uplift_c_p(self.subject.L_B()), expected, decimal=4)
def test_minimum_A_n(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
expected = [198.55, 208.32, 362.01, 1038.86, 236.88, 107.32, 517.44, 210.44, 90.72, 30.20, 113.23]
received = self.subject.minimum_A_n(self.subject.L_B())
assert_array_almost_equal(received, expected, decimal=2)
def test_minimum_array_size(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
expected = [113, 119, 206, 591, 135, 62, 295, 120, 52, 18, 65]
eq_(self.subject.minimum_array_size(self.subject.L_B()), expected)
def test_minimum_array_size_smaller_array(self):
self.site.building_height = 15
self.site.building_width = 500
self.site.building_length = 500
expected = [38, 64, 66, 123, 21, 28, 28, 37, 33, 37, 2]
eq_(self.subject.minimum_array_size(self.subject.L_B()), expected)

View File

@@ -0,0 +1,168 @@
import unittest
import numpy
from nose.tools import assert_almost_equal, eq_
from numpy.testing import assert_array_almost_equal
from helix.calculators.pressure_coefficient_calculator import PressureCoefficientCalculator
from helix.constants.module_type import ModuleType
from helix.constants.system_type import SystemType
from helix.models.sql.sites import Site
from helix.user_values import UserValues
class PressureCoefficientCalculatorWhenSingleTiltAndPSeriesTest(unittest.TestCase):
def setUp(self):
self.site = Site(
building_height=0,
building_width=0,
building_length=0,
parapet_height=0,
wind_speed=0,
exposure_category='C',
ballast_block_weight=0,
max_psf=0,
system_type=SystemType.singleTilt.value,
module_type=ModuleType.PSeries.value,
spectral_response=0,
seismic_importance_factor=1,
)
self.subject = PressureCoefficientCalculator(UserValues(None, self.site))
def test_A_n(self):
result = self.subject.A_n(63.25)
numpy.testing.assert_almost_equal(result, [10.386389, 17.995669, 17.995669, 21.217116], 6)
def test_c_p_in_wind_zone_A(self):
assert_almost_equal(self.subject.c_p(9.10, 'A', 1, 1), 1.22, 2)
assert_almost_equal(self.subject.c_p(500.0, 'A', 1, 1), 0.34, 2)
assert_almost_equal(self.subject.c_p(3000.0, 'A', 1, 1), 0.13, 2)
def test_c_p_in_wind_zone_B(self):
assert_almost_equal(self.subject.c_p(9.10, 'B', 1, 1), 0.96, 2)
assert_almost_equal(self.subject.c_p(500.0, 'B', 1, 1), 0.25, 2)
assert_almost_equal(self.subject.c_p(3000.0, 'B', 1, 1), 0.13, 2)
def test_c_p_in_wind_zone_C(self):
assert_almost_equal(self.subject.c_p(9.10, 'C', 1, 1), 0.48, 2)
assert_almost_equal(self.subject.c_p(500.0, 'C', 1, 1), 0.19, 2)
assert_almost_equal(self.subject.c_p(3000.0, 'C', 1, 1), 0.09, 2)
def test_c_p_in_wind_zone_D(self):
assert_almost_equal(self.subject.c_p(9.10, 'D', 1, 1), 0.46, 2)
assert_almost_equal(self.subject.c_p(200, 'D', 1, 1), 0.16, 2)
assert_almost_equal(self.subject.c_p(500.0, 'D', 1, 1), 0.12, 2)
def test_c_p_in_wind_zone_E(self):
assert_almost_equal(self.subject.c_p(9.10, 'E', 1, 1), 0.30, 2)
assert_almost_equal(self.subject.c_p(200, 'E', 1, 1), 0.12, 2)
assert_almost_equal(self.subject.c_p(317.22133, 'E', 1, 1), 0.09265, 4)
assert_almost_equal(self.subject.c_p(500.0, 'E', 1, 1), 0.08, 2)
def test_c_p_in_wind_zone_F(self):
assert_almost_equal(self.subject.c_p(9.10, 'F', 1, 1), 0.32, 2)
assert_almost_equal(self.subject.c_p(200, 'F', 1, 1), 0.12, 2)
assert_almost_equal(self.subject.c_p(500.0, 'F', 1, 1), 0.08, 2)
def test_c_p_in_wind_zone_G(self):
assert_almost_equal(self.subject.c_p(9.10, 'G', 1, 1), 0.20, 2)
assert_almost_equal(self.subject.c_p(200, 'G', 1, 1), 0.10, 2)
assert_almost_equal(self.subject.c_p(500.0, 'G', 1, 1), 0.08, 2)
def test_c_p_in_wind_zone_H(self):
assert_almost_equal(self.subject.c_p(9.10, 'H', 1, 1), 0.53, 2)
assert_almost_equal(self.subject.c_p(200, 'H', 1, 1), 0.18, 2)
assert_almost_equal(self.subject.c_p(500.0, 'H', 1, 1), 0.11, 2)
assert_almost_equal(self.subject.c_p(3000.0, 'H', 1, 1), 0.05, 2)
def test_c_p_in_wind_zone_I(self):
assert_almost_equal(self.subject.c_p(9.10, 'I', 1, 1), 1.41, 2)
assert_almost_equal(self.subject.c_p(200, 'I', 1, 1), 0.23, 2)
assert_almost_equal(self.subject.c_p(500.0, 'I', 1, 1), 0.11, 2)
assert_almost_equal(self.subject.c_p(3000.0, 'I', 1, 1), 0.05, 2)
def test_c_p_in_wind_zone_J(self):
assert_almost_equal(self.subject.c_p(9.10, 'J', 1, 1), 0.43, 2)
assert_almost_equal(self.subject.c_p(200, 'J', 1, 1), 0.12, 2)
assert_almost_equal(self.subject.c_p(500.0, 'J', 1, 1), 0.08, 2)
def test_c_p_matrix_when_building_dimensions_are_zero(self):
self.site.building_height = 0
self.site.building_width = 0
self.site.building_length = 0
self.site.building_parapet_height = 1.6 # so that parapet factor equals 1
expected_matrix = [[0.18, 0.16, 0.11, 0.09],
[0.18, 0.16, 0.11, 0.09],
[0.18, 0.16, 0.11, 0.09],
[0.18, 0.16, 0.11, 0.09],
[0.18, 0.16, 0.11, 0.09],
[0.18, 0.16, 0.11, 0.09],
[0.18, 0.16, 0.11, 0.09],
[0.18, 0.16, 0.11, 0.09],
[0.18, 0.16, 0.11, 0.09],
[0.18, 0.16, 0.11, 0.09],
[0.18, 0.16, 0.11, 0.09]]
numpy.testing.assert_almost_equal(self.subject.c_p_matrix(self.subject.L_B()), expected_matrix, 2)
def test_c_p_matrix_compiles_all_the_panel_types_and_wind_zones_correctly(self):
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
self.site.parapet_height = 20
expected_matrix = numpy.array([[1.88, 1.71, 1.43, 1.39],
[1.48, 1.34, 1.12, 1.09],
[0.85, 0.78, 0.56, 0.55],
[0.85, 0.77, 0.55, 0.53],
[0.57, 0.35, 0.52, 0.34],
[0.55, 0.49, 0.38, 0.37],
[0.26, 0.24, 0.24, 0.23],
[0.70, 0.62, 0.62, 0.60],
[1.91, 1.68, 1.68, 1.61],
[1.14, 1.02, 0.51, 0.49],
[0.17, 0.15, 0.11, 0.10]])
numpy.testing.assert_almost_equal(self.subject.c_p_matrix(self.subject.L_B()), expected_matrix, 2)
def test_minimum_array_cp(self):
# FIXME: Revisit this after Ian figures out how minimum array sizes change
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
expected = [1.260703, 0.988535, 0.503255, 0.487961, 0.311363, 0.337041,
0.20651, 0.541755, 1.442809, 0.471883, 0.107297]
assert_array_almost_equal(self.subject.ideal_subarray_average_uplift_c_p(self.subject.L_B()), expected, decimal=6)
def test_minimum_A_n(self):
# FIXME: Revisit this after Ian figures out how minimum array sizes change
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
expected = [138.01, 140.27, 293.83, 834.55, 164.83, 61.01, 385.55,
158.9, 64.79, 14.99, 69.08]
received = self.subject.minimum_A_n(self.subject.L_B())
assert_array_almost_equal(received, expected, decimal=2)
def test_minimum_array_size(self):
# FIXME: Revisit this after Ian figures out how minimum array sizes change
self.site.building_height = 100
self.site.building_width = 1000
self.site.building_length = 1500
expected = [63, 64, 133, 376, 75, 28, 174, 72, 30, 7, 32]
eq_(self.subject.minimum_array_size(self.subject.L_B()), expected)
def test_minimum_array_size_smaller_array(self):
# FIXME: Revisit this after Ian figures out how minimum array sizes change
self.site.building_height = 15
self.site.building_width = 500
self.site.building_length = 500
expected = [14, 18, 12, 30, 14, 16, 16, 14, 9, 21, 1]
eq_(self.subject.minimum_array_size(self.subject.L_B()), expected)

View File

@@ -0,0 +1 @@
__author__ = 'pivotal'

View File

@@ -0,0 +1,459 @@
import copy
import unittest
from unittest.mock import MagicMock
from nose.tools import eq_
from numpy import array
from numpy.testing import assert_array_equal
from helix.calculators.seismic_calculator import SeismicCalculator
from helix.calculators.subarray_graph import SubarrayGraph
from helix.calculators.subarray_helper import extract_subarray
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type_constants.dual_tilt_128_cell_constants import DualTilt128CellConstants
from helix.constants.module_type_constants.dual_tilt_96_cell_constants import DualTilt96CellConstants
from helix.constants.module_type_constants.dual_tilt_pseries_constants import DualTiltPSeriesConstants
from helix.constants.system_type import SystemType
from helix.models.subarray import Subarray
from test.fixtures.sample_arrays import *
class SeismicCalculatorDualTiltTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
self.system_type = SystemType.dualTilt
self.values.system_type.return_value = self.system_type
self.values.module_system_constants.return_value = DualTilt96CellConstants()
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip_Plus
self.values.spectral_response.return_value = 2.5
self.values.importance_factor.return_value = 1
"""
Generated using:
height: 100
length: 1000
width: 1500
parapet: 0
wind_speed: 110
exposure: C
anchor: OMG PowerGrip Plus
ballast_block_weight: 12
pressure: 15
Design Spectral Response: 1.02
"""
self.panels = array([
Panel(panel_type=PanelType.Corner, wind_anchors=0, pressure=11.31, subarray=0),
Panel(panel_type=PanelType.Corner, wind_anchors=0, pressure=11.31, subarray=0),
Panel(panel_type=PanelType.Corner, wind_anchors=1, pressure=7.37, subarray=0),
Panel(panel_type=PanelType.NorthSouth, wind_anchors=0, pressure=10.00, subarray=1),
Panel(panel_type=PanelType.Middle, wind_anchors=0, pressure=12.44, subarray=1),
Panel(panel_type=PanelType.NorthSouth, wind_anchors=0, pressure=10.00, subarray=2),
Panel(panel_type=PanelType.NorthSouth, wind_anchors=1, pressure=5.19, subarray=2),
])
self.graph_repository = MagicMock()
self.subject = SeismicCalculator(self.values, self.graph_repository)
def test_computes_seismic_anchors_per_subarray(self):
self.values.spectral_response.return_value = 1.02
eq_(self.subject.required_force_seismic_anchors(0, self.panels), 1)
eq_(self.subject.required_force_seismic_anchors(1, self.panels), 0)
eq_(self.subject.required_force_seismic_anchors(2, self.panels), 0)
def test_computes_seismic_anchors_per_subarray_for_geometrically_constrained_arrays(self):
copy_long_array_wind_anchors = copy.deepcopy(long_array_wind_anchors)
self.values.spectral_response.return_value = 1
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_long_array_wind_anchors, self.system_type)
eq_(self.subject.required_geometric_seismic_anchors(0, copy_long_array_wind_anchors), 1)
def test_computes_required_seismic_anchors_ignores_geometric_constraint_when_sds_is_less_than_1(self):
copy_long_array_single_wind_anchor = copy.deepcopy(long_array_single_wind_anchor)
self.values.spectral_response.return_value = 0.5
eq_(self.subject.required_force_seismic_anchors(0, copy_long_array_single_wind_anchor), 0)
eq_(self.subject.required_geometric_seismic_anchors(0, copy_long_array_single_wind_anchor), 0)
def test_assign_seismic_anchors_when_required_seismic_anchors_is_0_sets_panels_seismic_anchors(self):
subarray0 = Subarray(subarray_number=0, required_seismic_anchors=0)
subarray1 = Subarray(subarray_number=1, required_seismic_anchors=0)
subarray2 = Subarray(subarray_number=2, required_seismic_anchors=0)
self.subject.assign_seismic_anchors(subarray0, self.panels)
self.subject.assign_seismic_anchors(subarray1, self.panels)
self.subject.assign_seismic_anchors(subarray2, self.panels)
for panel in self.panels:
eq_(panel.seismic_anchors, 0)
def test_computes_required_seismic_anchors_calculates_geometric_constraints_when_at_least_one_seismic_anchor(self):
panels = [
Panel(coordinate=Coordinate(0, 3), wind_anchors=0, seismic_anchors=1, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(1, 3), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(2, 3), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(3, 3), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
Panel(coordinate=Coordinate(0, 2), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(1, 2), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(2, 2), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(3, 2), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
Panel(coordinate=Coordinate(0, 1), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(1, 1), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(2, 1), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(3, 1), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
Panel(coordinate=Coordinate(0, 0), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(1, 0), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(2, 0), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(3, 0), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0)
]
eq_(self.subject.required_force_seismic_anchors(0, panels), 9)
def test_computes_seismic_anchor_interval_correctly_on_96cell(self):
self.values.spectral_response.return_value = 0.2
eq_(self.subject.seismic_anchor_interval(), 15)
# this would actually return a negative number, but short-circuit to return 15
self.values.spectral_response.return_value = 1.0
eq_(self.subject.seismic_anchor_interval(), 14)
self.values.spectral_response.return_value = 1.5
eq_(self.subject.seismic_anchor_interval(), 8)
self.values.spectral_response.return_value = 2.0
eq_(self.subject.seismic_anchor_interval(), 5)
self.values.spectral_response.return_value = 2.5
eq_(self.subject.seismic_anchor_interval(), 4)
def test_computes_seismic_anchor_interval_taking_importance_factor_into_account_on_96cell(self):
self.values.importance_factor.return_value = 1.5
self.values.spectral_response.return_value = 1.0
eq_(self.subject.seismic_anchor_interval(), 8)
self.values.spectral_response.return_value = 1.5
eq_(self.subject.seismic_anchor_interval(), 5)
self.values.spectral_response.return_value = 2.0
eq_(self.subject.seismic_anchor_interval(), 3)
self.values.spectral_response.return_value = 2.5
eq_(self.subject.seismic_anchor_interval(), 2)
def test_computes_seismic_anchor_interval_correctly_on_128cell(self):
self.values.module_system_constants.return_value = DualTilt128CellConstants()
self.subject = SeismicCalculator(self.values, None)
self.values.spectral_response.return_value = 0.2
eq_(self.subject.seismic_anchor_interval(), 15)
# this would actually return a negative number, but short-circuit to return 15
self.values.spectral_response.return_value = 1.0
eq_(self.subject.seismic_anchor_interval(), 18)
self.values.spectral_response.return_value = 1.5
eq_(self.subject.seismic_anchor_interval(), 8)
self.values.spectral_response.return_value = 2.0
eq_(self.subject.seismic_anchor_interval(), 5)
self.values.spectral_response.return_value = 2.5
eq_(self.subject.seismic_anchor_interval(), 4)
def test_computes_seismic_anchor_interval_taking_importance_factor_into_account_on_128cell(self):
self.values.module_system_constants.return_value = DualTilt128CellConstants()
self.subject = SeismicCalculator(self.values, None)
self.values.importance_factor.return_value = 1.5
self.values.spectral_response.return_value = 1.0
eq_(self.subject.seismic_anchor_interval(), 9)
self.values.spectral_response.return_value = 1.5
eq_(self.subject.seismic_anchor_interval(), 5)
self.values.spectral_response.return_value = 2.0
eq_(self.subject.seismic_anchor_interval(), 3)
self.values.spectral_response.return_value = 2.5
eq_(self.subject.seismic_anchor_interval(), 2)
def test_computes_seismic_anchor_interval_correctly_on_p_series(self):
self.values.module_system_constants.return_value = DualTiltPSeriesConstants()
self.subject = SeismicCalculator(self.values, None)
self.values.spectral_response.return_value = 0.2
eq_(self.subject.seismic_anchor_interval(), 15)
# this would actually return a negative number, but short-circuit to return 15
self.values.spectral_response.return_value = 1.0
eq_(self.subject.seismic_anchor_interval(), 17)
self.values.spectral_response.return_value = 1.5
eq_(self.subject.seismic_anchor_interval(), 8)
self.values.spectral_response.return_value = 2.0
eq_(self.subject.seismic_anchor_interval(), 5)
self.values.spectral_response.return_value = 2.5
eq_(self.subject.seismic_anchor_interval(), 4)
def test_computes_seismic_anchor_interval_taking_importance_factor_into_account_on_p_series(self):
self.values.module_system_constants.return_value = DualTiltPSeriesConstants()
self.subject = SeismicCalculator(self.values, None)
self.values.importance_factor.return_value = 1.5
self.values.spectral_response.return_value = 1.0
eq_(self.subject.seismic_anchor_interval(), 9)
self.values.spectral_response.return_value = 1.5
eq_(self.subject.seismic_anchor_interval(), 5)
self.values.spectral_response.return_value = 2.0
eq_(self.subject.seismic_anchor_interval(), 3)
self.values.spectral_response.return_value = 2.5
eq_(self.subject.seismic_anchor_interval(), 2)
def test_assign_seismic_anchors(self):
copy_four_by_four_no_wind_anchors = copy.deepcopy(four_by_four_no_wind_anchors)
copy_six_by_seven_no_wind_anchors = copy.deepcopy(six_by_seven_no_wind_anchors)
[setattr(panel, 'subarray', 1) for panel in copy_four_by_four_no_wind_anchors]
[setattr(panel, 'subarray', 2) for panel in copy_six_by_seven_no_wind_anchors]
panels = copy_four_by_four_no_wind_anchors + copy_six_by_seven_no_wind_anchors
subarrays = [
Subarray(subarray_number=1, required_seismic_anchors=2),
Subarray(subarray_number=2, required_seismic_anchors=1)
]
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_four_by_four_no_wind_anchors, self.system_type)
output = self.subject.assign_seismic_anchors(subarrays[0], panels)
eq_(len(output), 58)
subarray_1_panels = extract_subarray(panels, 1)
subarray1_seismic_anchors = sum(panel.seismic_anchors for panel in subarray_1_panels if panel.seismic_anchors)
eq_(subarray1_seismic_anchors, 4)
subarray_2_panels = extract_subarray(panels, 2)
subarray2_seismic_anchors = sum(panel.seismic_anchors for panel in subarray_2_panels if panel.seismic_anchors)
eq_(subarray2_seismic_anchors, 0)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_six_by_seven_no_wind_anchors, self.system_type)
output = self.subject.assign_seismic_anchors(subarrays[1], panels)
eq_(len(output), 58)
subarray_1_panels = extract_subarray(panels, 1)
subarray1_seismic_anchors = sum(panel.seismic_anchors for panel in subarray_1_panels if panel.seismic_anchors)
eq_(subarray1_seismic_anchors, 4)
subarray_2_panels = extract_subarray(panels, 2)
subarray2_seismic_anchors = sum(panel.seismic_anchors for panel in subarray_2_panels if panel.seismic_anchors)
eq_(subarray2_seismic_anchors, 6)
def test_assign_anchors_to_subarray_four_by_four_no_wind_anchors(self):
copy_four_by_four_no_wind_anchors = copy.deepcopy(four_by_four_no_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_four_by_four_no_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_four_by_four_no_wind_anchors, Subarray(required_seismic_anchors=3))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0),
]
assert_array_equal(result, expected_result)
def test_assign_anchors_to_subarray_with_neck(self):
copy_dumbell_no_wind_anchors = copy.deepcopy(dumbell_no_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_dumbell_no_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_dumbell_no_wind_anchors, Subarray(required_seismic_anchors=20))
expected_result = [
Panel(seismic_anchors=1, coordinate=Coordinate(0, 8), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 8), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 8), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 8), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 7), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 7), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 7), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 7), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0),
]
eq_(result, expected_result)
seismic_anchors = sum(panel.seismic_anchors for panel in expected_result if panel.seismic_anchors)
eq_(seismic_anchors, 20)
def test_assign_anchors_to_subarray_with_neck_more_than_one_walk(self):
copy_dumbell_no_wind_anchors = copy.deepcopy(dumbell_no_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_dumbell_no_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_dumbell_no_wind_anchors, Subarray(required_seismic_anchors=30))
expected_result = [
Panel(seismic_anchors=1, coordinate=Coordinate(0, 8), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 8), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 8), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 8), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 7), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 7), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 7), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 7), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 6), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(2, 4), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0),
]
eq_(result, expected_result)
seismic_anchors = sum(panel.seismic_anchors for panel in expected_result if panel.seismic_anchors)
eq_(seismic_anchors, 30)
def test_assign_anchors_to_subarray_4_x_3_with_wind_anchors(self):
copy_four_by_three_wind_anchors = copy.deepcopy(four_by_three_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_four_by_three_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_four_by_three_wind_anchors, Subarray(required_seismic_anchors=4))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=1), Panel(seismic_anchors=1, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=1),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=1),
]
eq_(result, expected_result)
seismic_anchors = sum(panel.seismic_anchors for panel in expected_result if panel.seismic_anchors)
eq_(seismic_anchors, 4)
def test_assign_seismic_anchors_4_x_3(self):
copy_four_by_three_wind_anchors = copy.deepcopy(four_by_three_wind_anchors)
[setattr(panel, 'subarray', 1) for panel in copy_four_by_three_wind_anchors]
subarray = Subarray(subarray_number=1, required_seismic_anchors=4)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_four_by_three_wind_anchors, self.system_type)
output = self.subject.assign_seismic_anchors(subarray, copy_four_by_three_wind_anchors)
eq_(len(output), len(copy_four_by_three_wind_anchors))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=1, subarray=1), Panel(seismic_anchors=1, coordinate=Coordinate(1, 2), wind_anchors=0, subarray=1), Panel(seismic_anchors=1, coordinate=Coordinate(2, 2), wind_anchors=0, subarray=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=1, subarray=1),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 1), wind_anchors=0, subarray=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0, subarray=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0, subarray=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0, subarray=1),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1, subarray=1), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0, subarray=1), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0, subarray=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=1, subarray=1),
]
eq_(output, expected_result)
seismic_anchors = sum(panel.seismic_anchors for panel in output if panel.seismic_anchors)
eq_(seismic_anchors, 4)
def test_assign_anchors_to_subarray_with_wind_anchors_funny_shape(self):
copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=2))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=1),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=1),
]
eq_(result, expected_result)
def test_assign_anchors_to_subarray_wind_anchors_when_not_all_anchors_fit_on_perimeter(self):
copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=25))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=1),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 4), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=1),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 25)
def test_assign_anchors_to_subarray_wind_anchors_filling_array_completely(self):
copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=30))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=1),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 4), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=1),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 30)
def test_assign_anchors_to_subarray_wind_anchors_overfilling_array(self):
copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=35))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=1),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=2, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 4), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=2, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=2, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=2, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=1),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 35)
def test_assign_anchors_to_subarray_places_anchors_when_wind_anchors_but_no_required_anchors(self):
copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=0))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=1),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=1),
]
eq_(result, expected_result)
def test_assign_anchors_to_subarray_ignores_geometric_constraint_when_sds_below_1(self):
copy_six_by_seven_single_wind_anchor = copy.deepcopy(six_by_seven_single_wind_anchor)
self.values.spectral_response.return_value = 0.9
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_six_by_seven_single_wind_anchor, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_six_by_seven_single_wind_anchor, Subarray(required_seismic_anchors=1))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 4), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 3), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=0)
]
eq_(result, expected_result)
def test_assign_anchors_to_subarray_places_no_seismic_anchors_when_sds_less_1_and_required_anchors_0(self):
copy_six_by_seven_single_wind_anchor_not_at_bottom_left = copy.deepcopy(six_by_seven_single_wind_anchor_not_at_bottom_left)
self.values.spectral_response.return_value = 0.9
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_six_by_seven_single_wind_anchor_not_at_bottom_left, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_six_by_seven_single_wind_anchor_not_at_bottom_left, Subarray(required_seismic_anchors=0))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 4), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 3), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 1), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=0)
]
eq_(result, expected_result)

View File

@@ -0,0 +1,563 @@
import copy
import unittest
from unittest.mock import MagicMock
from nose.tools import eq_
from helix.calculators.seismic_calculator import SeismicCalculator
from helix.calculators.subarray_graph import SubarrayGraph
from helix.calculators.subarray_helper import extract_subarray
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type_constants.single_tilt_128_cell_constants import SingleTilt128CellConstants
from helix.constants.module_type_constants.single_tilt_96_cell_constants import SingleTilt96CellConstants
from helix.constants.module_type_constants.single_tilt_pseries_constants import SingleTiltPSeriesConstants
from helix.constants.system_type import SystemType
from helix.models.subarray import Subarray
from test.fixtures.sample_arrays import *
class SeismicCalculatorSingleTiltTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
self.system_type = SystemType.singleTilt
self.values.system_type.return_value = self.system_type
self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip_Plus
self.values.module_system_constants.return_value = SingleTilt96CellConstants()
self.values.spectral_response.return_value = 2.5
self.values.importance_factor.return_value = 1
"""
Generated using:
height: 100
length: 1000
width: 1500
parapet: 0
wind_speed: 150
exposure: C
anchor: OMG PowerGrip Plus
ballast_block_weight: 14
pressure: 20
spectral_response: 1.02
"""
self.panels = [
Panel(panel_type=PanelType.Corner, wind_anchors=1, pressure=3.68, subarray=0),
Panel(panel_type=PanelType.Corner, wind_anchors=0, pressure=18.27, subarray=0),
Panel(panel_type=PanelType.Corner, wind_anchors=0, pressure=18.27, subarray=0),
Panel(panel_type=PanelType.NorthSouth, wind_anchors=0, pressure=16.48, subarray=1),
Panel(panel_type=PanelType.Middle, wind_anchors=0, pressure=17.07, subarray=1),
Panel(panel_type=PanelType.EastWest, wind_anchors=0, pressure=12.89, subarray=1),
Panel(panel_type=PanelType.EastWest, wind_anchors=0, pressure=8.00, subarray=2),
Panel(panel_type=PanelType.NorthSouth, wind_anchors=3, pressure=7.23, subarray=2)
]
self.graph_repository = MagicMock()
self.subject = SeismicCalculator(self.values, self.graph_repository)
def test_computes_seismic_anchors_per_subarray(self):
self.values.spectral_response.return_value = 1.02
eq_(self.subject.required_force_seismic_anchors(0, self.panels), 2)
eq_(self.subject.required_force_seismic_anchors(1, self.panels), 0)
eq_(self.subject.required_force_seismic_anchors(2, self.panels), 0)
def test_computes_seismic_anchors_per_subarray_for_geometrically_constrained_arrays(self):
copy_long_array_wind_anchors = copy.deepcopy(long_array_wind_anchors)
self.values.spectral_response.return_value = 1
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_long_array_wind_anchors, self.system_type)
eq_(self.subject.required_geometric_seismic_anchors(0, copy_long_array_wind_anchors), 1)
def test_assign_seismic_anchors_when_required_seismic_anchors_is_0_sets_panels_seismic_anchors(self):
subarray0 = Subarray(subarray_number=0, required_seismic_anchors=0)
subarray1 = Subarray(subarray_number=1, required_seismic_anchors=0)
subarray2 = Subarray(subarray_number=2, required_seismic_anchors=0)
self.subject.assign_seismic_anchors(subarray0, self.panels)
self.subject.assign_seismic_anchors(subarray1, self.panels)
self.subject.assign_seismic_anchors(subarray2, self.panels)
for panel in self.panels:
eq_(panel.seismic_anchors, 0)
def test_computes_required_seismic_anchors_calculates_geometric_constraints_when_at_least_one_seismic_anchor(self):
panels = [
Panel(coordinate=Coordinate(0, 3), wind_anchors=0, seismic_anchors=1, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(1, 3), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
Panel(coordinate=Coordinate(2, 3), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(3, 3), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
Panel(coordinate=Coordinate(0, 2), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(1, 2), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
Panel(coordinate=Coordinate(2, 2), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(3, 2), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
Panel(coordinate=Coordinate(0, 1), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(1, 1), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
Panel(coordinate=Coordinate(2, 1), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(3, 1), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
Panel(coordinate=Coordinate(0, 0), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(1, 0), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
Panel(coordinate=Coordinate(2, 0), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(3, 0), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
]
eq_(self.subject.required_force_seismic_anchors(0, panels), 6)
def test_computes_seismic_anchor_interval_correctly_on_96cell(self):
self.values.spectral_response.return_value = 0.2
eq_(self.subject.seismic_anchor_interval(), 15)
# this would actually return a negative number, but short-circuit to return 15
self.values.spectral_response.return_value = 1.02
eq_(self.subject.seismic_anchor_interval(), 12)
self.values.spectral_response.return_value = 1.5
eq_(self.subject.seismic_anchor_interval(), 7)
self.values.spectral_response.return_value = 2.0
eq_(self.subject.seismic_anchor_interval(), 5)
self.values.spectral_response.return_value = 2.5
eq_(self.subject.seismic_anchor_interval(), 4)
def test_computes_seismic_anchor_interval_taking_importance_factor_into_account_on_96cell(self):
self.values.importance_factor.return_value = 1.5
self.values.spectral_response.return_value = 1.0
eq_(self.subject.seismic_anchor_interval(), 7)
self.values.spectral_response.return_value = 1.5
eq_(self.subject.seismic_anchor_interval(), 4)
self.values.spectral_response.return_value = 2.0
eq_(self.subject.seismic_anchor_interval(), 3)
self.values.spectral_response.return_value = 2.5
eq_(self.subject.seismic_anchor_interval(), 2)
def test_computes_seismic_anchor_interval_correctly_on_128cell(self):
self.values.module_system_constants.return_value = SingleTilt128CellConstants()
self.subject = SeismicCalculator(self.values, None)
self.values.spectral_response.return_value = 0.2
eq_(self.subject.seismic_anchor_interval(), 15)
# this would actually return a negative number, but short-circuit to return 15
self.values.spectral_response.return_value = 1.02
eq_(self.subject.seismic_anchor_interval(), 14)
self.values.spectral_response.return_value = 1.5
eq_(self.subject.seismic_anchor_interval(), 8)
self.values.spectral_response.return_value = 2.0
eq_(self.subject.seismic_anchor_interval(), 5)
self.values.spectral_response.return_value = 2.5
eq_(self.subject.seismic_anchor_interval(), 4)
def test_computes_seismic_anchor_interval_taking_importance_factor_into_account_on_128cell(self):
self.values.module_system_constants.return_value = SingleTilt128CellConstants()
self.subject = SeismicCalculator(self.values, None)
self.values.importance_factor.return_value = 1.5
self.values.spectral_response.return_value = 1.0
eq_(self.subject.seismic_anchor_interval(), 8)
self.values.spectral_response.return_value = 1.5
eq_(self.subject.seismic_anchor_interval(), 4)
self.values.spectral_response.return_value = 2.0
eq_(self.subject.seismic_anchor_interval(), 3)
self.values.spectral_response.return_value = 2.5
eq_(self.subject.seismic_anchor_interval(), 2)
def test_computes_seismic_anchor_interval_correctly_on_p_series(self):
self.values.module_system_constants.return_value = SingleTiltPSeriesConstants()
self.subject = SeismicCalculator(self.values, None)
self.values.spectral_response.return_value = 0.2
eq_(self.subject.seismic_anchor_interval(), 15)
# this would actually return a negative number, but short-circuit to return 15
self.values.spectral_response.return_value = 1.02
eq_(self.subject.seismic_anchor_interval(), 13)
self.values.spectral_response.return_value = 1.5
eq_(self.subject.seismic_anchor_interval(), 7)
self.values.spectral_response.return_value = 2.0
eq_(self.subject.seismic_anchor_interval(), 5)
self.values.spectral_response.return_value = 2.5
eq_(self.subject.seismic_anchor_interval(), 4)
def test_computes_seismic_anchor_interval_taking_importance_factor_into_account_on_p_series(self):
self.values.module_system_constants.return_value = SingleTiltPSeriesConstants()
self.subject = SeismicCalculator(self.values, None)
self.values.importance_factor.return_value = 1.5
self.values.spectral_response.return_value = 1.0
eq_(self.subject.seismic_anchor_interval(), 8)
self.values.spectral_response.return_value = 1.5
eq_(self.subject.seismic_anchor_interval(), 4)
self.values.spectral_response.return_value = 2.0
eq_(self.subject.seismic_anchor_interval(), 3)
self.values.spectral_response.return_value = 2.5
eq_(self.subject.seismic_anchor_interval(), 2)
def test_assign_seismic_anchors(self):
copy_four_by_four_no_wind_anchors = copy.deepcopy(four_by_four_no_wind_anchors)
copy_six_by_seven_no_wind_anchors = copy.deepcopy(six_by_seven_no_wind_anchors)
[setattr(panel, 'subarray', 1) for panel in copy_four_by_four_no_wind_anchors]
[setattr(panel, 'subarray', 2) for panel in copy_six_by_seven_no_wind_anchors]
panels = copy_four_by_four_no_wind_anchors + copy_six_by_seven_no_wind_anchors
subarrays = [
Subarray(subarray_number=1, required_seismic_anchors=2),
Subarray(subarray_number=2, required_seismic_anchors=1)
]
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_four_by_four_no_wind_anchors, self.system_type)
output = self.subject.assign_seismic_anchors(subarrays[0], panels)
eq_(len(output), len(panels))
subarray_1_panels = extract_subarray(panels, 1)
subarray1_seismic_anchors = sum(panel.seismic_anchors for panel in subarray_1_panels if panel.seismic_anchors)
eq_(subarray1_seismic_anchors, 3)
subarray_2_panels = extract_subarray(panels, 2)
subarray2_seismic_anchors = sum(panel.seismic_anchors for panel in subarray_2_panels if panel.seismic_anchors)
eq_(subarray2_seismic_anchors, 0)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_six_by_seven_no_wind_anchors, self.system_type)
panels_with_assigned_seismic_anchors = self.subject.assign_seismic_anchors(subarrays[1], panels)
eq_(len(panels_with_assigned_seismic_anchors), len(panels))
subarray_1_panels = extract_subarray(panels, 1)
subarray1_seismic_anchors = sum(panel.seismic_anchors for panel in subarray_1_panels if panel.seismic_anchors)
eq_(subarray1_seismic_anchors, 3)
subarray_2_panels = extract_subarray(panels, 2)
subarray2_seismic_anchors = sum(panel.seismic_anchors for panel in subarray_2_panels if panel.seismic_anchors)
eq_(subarray2_seismic_anchors, 5)
def test_assign_anchors_to_subarray_four_by_four_no_wind_anchors(self):
copy_four_by_four_no_wind_anchors = copy.deepcopy(four_by_four_no_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_four_by_four_no_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_four_by_four_no_wind_anchors, Subarray(required_seismic_anchors=3))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 3)
def test_assign_anchors_to_subarray_six_by_seven_no_wind_anchors(self):
copy_six_by_seven_no_wind_anchors = copy.deepcopy(six_by_seven_no_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_six_by_seven_no_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_six_by_seven_no_wind_anchors, Subarray(required_seismic_anchors=3))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 4), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 3), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=1 ,coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 0), wind_anchors=0),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 5)
def test_assign_anchors_to_subarray_no_wind_anchors_funny_shape(self):
copy_c_shape_no_wind_anchors = copy.deepcopy(c_shape_no_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_no_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_c_shape_no_wind_anchors, Subarray(required_seismic_anchors=3))
expected_result = [
Panel(seismic_anchors=1, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 6), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 0), wind_anchors=0),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 6)
def test_assign_anchors_to_subarray_no_seismic_anchors_required(self):
copy_four_by_four_no_wind_anchors = copy.deepcopy(four_by_four_no_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_four_by_four_no_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_four_by_four_no_wind_anchors, Subarray(required_seismic_anchors=0))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 0)
def test_assign_anchors_to_subarray_with_neck(self):
copy_dumbell_no_wind_anchors = copy.deepcopy(dumbell_no_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_dumbell_no_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_dumbell_no_wind_anchors, Subarray(required_seismic_anchors=20))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 8), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 8), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 8), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 8), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 7), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 7), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 7), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 7), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 6), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(2, 4), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 20)
def test_assign_anchors_to_subarray_with_neck_more_than_one_walk(self):
copy_dumbell_no_wind_anchors = copy.deepcopy(dumbell_no_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_dumbell_no_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_dumbell_no_wind_anchors, Subarray(required_seismic_anchors=30))
expected_result = [
Panel(seismic_anchors=1, coordinate=Coordinate(0, 8), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 8), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 8), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 8), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 7), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 7), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 7), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 7), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 6), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(2, 4), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 30)
def test_assign_anchors_to_subarray_no_wind_anchors_more_than_one_walk_through_funny_shape(self):
copy_c_shape_no_wind_anchors = copy.deepcopy(c_shape_no_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_no_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_c_shape_no_wind_anchors, Subarray(required_seismic_anchors=20))
expected_result = [
Panel(seismic_anchors=1, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 6), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 0), wind_anchors=0),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 20)
def test_assign_anchors_to_subarray_when_not_all_anchors_fit_on_perimeter(self):
copy_c_shape_no_wind_anchors = copy.deepcopy(c_shape_no_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_no_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_c_shape_no_wind_anchors, Subarray(required_seismic_anchors=30))
expected_result = [
Panel(seismic_anchors=1, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 6), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 4), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 0), wind_anchors=0),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 30)
def test_assign_anchors_to_subarray_rectangle_when_not_all_anchors_fit_on_perimeter(self):
copy_six_by_seven_no_wind_anchors = copy.deepcopy(six_by_seven_no_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_six_by_seven_no_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_six_by_seven_no_wind_anchors, Subarray(required_seismic_anchors=30))
expected_result = [
Panel(seismic_anchors=1, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 6), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 4), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 3), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 0), wind_anchors=0),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 30)
def test_assign_anchors_to_subarray_with_wind_anchors_funny_shape(self):
copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=2))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=1),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=1),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 2)
def test_assign_anchors_to_subarray_with_wind_anchors_more_than_one_walk_through_funny_shape(self):
copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=10))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=1),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=1),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 10)
def test_assign_anchors_to_subarray_wind_anchors_when_not_all_anchors_fit_on_perimeter(self):
copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=25))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=1),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 4), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=1),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 25)
def test_assign_anchors_to_subarray_wind_anchors_filling_array_completely(self):
copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=30))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=1),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 4), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=1),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 30)
def test_assign_anchors_to_subarray_wind_anchors_overfilling_array(self):
copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=35))
expected_result = [
Panel(seismic_anchors=1, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=1, coordinate=Coordinate(5, 6), wind_anchors=1),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 4), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=2, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 0), wind_anchors=1),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 35)
def test_assign_anchors_to_subarray_places_anchors_when_wind_anchors_but_no_required_anchors(self):
copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=0))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=1),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=1),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 2) # TODO why is this 2, not 0?
def test_assign_anchors_to_subarray_ignores_geometric_constraint_when_sds_below_1(self):
copy_six_by_seven_no_wind_anchors = copy.deepcopy(six_by_seven_no_wind_anchors)
self.values.spectral_response.return_value = 0.9
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_six_by_seven_no_wind_anchors, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_six_by_seven_no_wind_anchors, Subarray(required_seismic_anchors=1))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 4), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 3), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=0),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 1)
def test_assign_anchors_to_subarray_places_no_seismic_anchors_when_sds_less_1_and_required_anchors_0(self):
copy_six_by_seven_single_wind_anchor_not_at_bottom_left = copy.deepcopy(six_by_seven_single_wind_anchor_not_at_bottom_left)
self.values.spectral_response.return_value = 0.9
self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_six_by_seven_single_wind_anchor_not_at_bottom_left, self.system_type)
result = self.subject.assign_anchors_to_subarray(copy_six_by_seven_single_wind_anchor_not_at_bottom_left, Subarray(required_seismic_anchors=0))
expected_result = [
Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 4), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 3), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 2), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 1), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=0),
]
eq_(result, expected_result)
seismic_anchors = sum(x.seismic_anchors for x in result)
eq_(seismic_anchors, 0)

View File

@@ -0,0 +1,78 @@
import copy
from time import clock
import unittest
from nose.tools import eq_
from helix.calculators.subarray_graph import SubarrayGraph
from test.fixtures.sample_arrays import *
from helix.constants.system_type import SystemType
class SubarrayGraphTest(unittest.TestCase):
def test_find_disconnected_subgraphs(self):
copy_dumbell_no_wind_anchors = copy.deepcopy(dumbell_no_wind_anchors)
graph = SubarrayGraph(copy_dumbell_no_wind_anchors, SystemType.singleTilt)
graph.pop_rung()
subgraphs = graph.find_disconnected_subgraphs()
eq_(len(subgraphs), 2)
eq_(len(subgraphs[0]), 4)
eq_(len(subgraphs[1]), 4)
def test_find_disconnected_subgraphs_more_complicated(self):
copy_odd_shape_no_wind_anchors = copy.deepcopy(odd_shape_no_wind_anchors)
graph = SubarrayGraph(copy_odd_shape_no_wind_anchors, SystemType.singleTilt)
graph.pop_rung()
subgraphs = graph.find_disconnected_subgraphs()
eq_(len(subgraphs), 3)
eq_(len(subgraphs[0]), 4)
eq_(len(subgraphs[1]), 8)
eq_(len(subgraphs[2]), 1)
def test_find_node(self):
copy_odd_shape_no_wind_anchors = copy.deepcopy(odd_shape_no_wind_anchors)
graph = SubarrayGraph(copy_odd_shape_no_wind_anchors, SystemType.singleTilt)
eq_(graph.find_node(Coordinate(-1, -1)), None)
lower_left_node = self.naive_find_node(graph, Coordinate(0, 0))
eq_(graph.find_node(Coordinate(0, 0)), lower_left_node)
middle_ish_node = self.naive_find_node(graph, Coordinate(2, 7))
eq_(graph.find_node(Coordinate(2, 7)), middle_ish_node)
# def test_find_node_performance(self):
# copy_odd_shape_no_wind_anchors = copy.deepcopy(odd_shape_no_wind_anchors)
# graph = SubarrayGraph(copy_odd_shape_no_wind_anchors, SystemType.singleTilt)
#
# iteration_count = 100
#
# invalid_base = self.check_performance(lambda: self.naive_find_node(graph, Coordinate(-1, -1)), iteration_count)
# lower_left_base = self.check_performance(lambda: self.naive_find_node(graph, Coordinate(0, 0)), iteration_count)
# middle_ish_base = self.check_performance(lambda: self.naive_find_node(graph, Coordinate(2, 7)), iteration_count)
#
# invalid_test = self.check_performance(lambda: graph.find_node(Coordinate(-1, -1)), iteration_count)
# lower_left_test = self.check_performance(lambda: graph.find_node(Coordinate(0, 0)), iteration_count)
# middle_ish_test = self.check_performance(lambda: graph.find_node(Coordinate(2, 7)), iteration_count)
#
# print("Invalid coordinate: %f base, %f actual" % (invalid_base, invalid_test))
# print("0, 0 coordinate: %f base, %f actual" % (lower_left_base, lower_left_test))
# print("2, 7 coordinate: %f base, %f actual" % (middle_ish_base, middle_ish_test))
#
# assert invalid_test < (invalid_base / 10), "Expected invalid coordinate to almost no-op, didn't"
# assert lower_left_test < lower_left_base, "Expected 0, 0 coordinate to be better than naive approach"
# assert middle_ish_base < middle_ish_test, "Expected 2, 7 coordinate to be better than naive approach"
def naive_find_node(self, graph, coordinate):
for node in graph.nodes:
if node.location == coordinate:
return node
def check_performance(self, function, iterations):
start = clock()
for _ in range(iterations):
function()
end = clock()
return (end - start) / iterations

View File

@@ -0,0 +1,129 @@
import unittest
from unittest.mock import MagicMock
from nose.tools import eq_
from numpy import array
from numpy.testing import assert_almost_equal
from helix.calculators.ballast_calculator import BallastCalculator
from helix.calculators.summary_values_calculator import SummaryValuesCalculator
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type_constants.dual_tilt_96_cell_constants import DualTilt96CellConstants
from helix.constants.panel_type import PanelType
from helix.constants.system_type import SystemType
from helix.models.panel import Panel
from helix.models.subarray import Subarray
class SummaryValuesTest(unittest.TestCase):
def setUp(self):
self.user_values = MagicMock()
self.user_values.anchor_type.return_value = AnchorType.OMG_PowerGrip
self.user_values.max_system_pressure.return_value = 100
self.user_values.module_system_constants.return_value = DualTilt96CellConstants()
self.user_values.system_type.return_value = SystemType.dualTilt
self.c_p_matrix = array([[0.784136, 0.697451, 0.684466, 0.546005],
[0.594876, 0.524444, 0.513894, 0.401395],
[0.368824, 0.324879, 0.318296, 0.248104],
[0.206095, 0.182617, 0.179101, 0.141601],
[0.060000, 0.050000, 0.052000, 0.039000]])
self.q_z = 37.72825742
self.subject = SummaryValuesCalculator(self.user_values)
self.ballast_calculator = BallastCalculator(self.user_values)
def test_summary_values(self):
panels = [
Panel(id=1, ballast=1, wind_anchors=2, pressure=12.89, wind_zone=0, panel_type=PanelType.Corner),
Panel(id=2, ballast=5, wind_anchors=0, pressure=11.22, wind_zone=1, panel_type=PanelType.NorthSouth),
Panel(id=3, ballast=0, wind_anchors=4, pressure=2.02, wind_zone=2, panel_type=PanelType.EastWest),
Panel(id=4, ballast=2, wind_anchors=1, pressure=3.36, wind_zone=3, panel_type=PanelType.Middle),
Panel(id=5, ballast=0, wind_anchors=0, pressure=20.83, wind_zone=4, panel_type=PanelType.Corner),
]
subarrays = [
Subarray(subarray_number=0, start_row=0, size=5, required_seismic_anchors=0)
]
seismic_interval = 10
result = self.subject.summary_values(panels, subarrays, self.c_p_matrix, self.q_z, seismic_interval, self.ballast_calculator)
expected = [
{'label': 'Total System Weight (lbs)', 'value': 1943},
{'label': 'Max PSF', 'value': 20.83},
{'label': 'Avg PSF', 'value': 10.06},
{'label': 'Total Anchors', 'value': 7},
{'label': 'Total Ballast', 'value': 8},
{'label': 'Max Possible System Weight', 'value': 1568.0},
{'label': 'Max System Weight Ballast Block', 'value': 14},
{'label': 'Seismic Anchor Max. Spacing', 'value': seismic_interval}
]
eq_(result, expected)
def test_documentation_summary_values(self):
panels = [
Panel(id=1, ballast=1, wind_anchors=2, pressure=12.89, wind_zone=0, panel_type=PanelType.Corner),
Panel(id=2, ballast=5, wind_anchors=0, pressure=11.22, wind_zone=1, panel_type=PanelType.NorthSouth),
Panel(id=3, ballast=0, wind_anchors=4, pressure=2.02, wind_zone=2, panel_type=PanelType.EastWest),
Panel(id=4, ballast=2, wind_anchors=1, pressure=3.36, wind_zone=3, panel_type=PanelType.Middle),
Panel(id=5, ballast=0, wind_anchors=0, pressure=20.83, wind_zone=4, panel_type=PanelType.Corner),
]
subarrays = [
Subarray(subarray_number=0, start_row=0, size=5, required_seismic_anchors=0)
]
seismic_interval = 10
result = self.subject.documentation_summary_values(panels, subarrays, self.c_p_matrix, self.q_z, seismic_interval, self.ballast_calculator)
expected = {
'total_system_weight': 1943,
'max_psf': 20.83,
'ave_psf': 10.06,
'total_anchors': 7,
'total_ballast': 8,
'max_possible_system_weight': 1568.0,
'max_system_weight_ballast_block': 14,
'seismic_anchor_max_spacing': 10
}
eq_(result, expected)
def test_system_weight_and_pressure(self):
panels = [
Panel(id=1, pressure=12.89),
Panel(id=2, pressure=11.22),
Panel(id=3, pressure=2.02),
Panel(id=4, pressure=3.36),
Panel(id=5, pressure=20.83),
]
assert_almost_equal(self.subject.system_weight_and_pressure(panels), (1943.1261538, 10.064), decimal=6)
def test_find_max_system_weight(self):
panels = [
Panel(id=1, wind_zone=0, panel_type=PanelType.Corner),
Panel(id=2, wind_zone=1, panel_type=PanelType.NorthSouth),
Panel(id=3, wind_zone=2, panel_type=PanelType.EastWest),
Panel(id=4, wind_zone=3, panel_type=PanelType.Middle),
Panel(id=5, wind_zone=4, panel_type=PanelType.Corner),
]
result = self.subject.find_max_system_weight(panels, self.c_p_matrix, self.q_z, self.ballast_calculator)
assert_almost_equal(result, (1568, 14), decimal=0)
def test_find_max_system_weight_does_not_modify_panels_list(self):
panels = [
Panel(id=1, wind_zone=0, panel_type=PanelType.Corner),
Panel(id=2, wind_zone=1, panel_type=PanelType.NorthSouth),
Panel(id=3, wind_zone=2, panel_type=PanelType.EastWest),
Panel(id=4, wind_zone=3, panel_type=PanelType.Middle),
Panel(id=5, wind_zone=4, panel_type=PanelType.Corner),
]
original_panels = list(panels)
self.subject.find_max_system_weight(panels, self.c_p_matrix, self.q_z, self.ballast_calculator)
eq_(panels, original_panels)

View File

@@ -0,0 +1,63 @@
import unittest
from unittest.mock import MagicMock
from nose.tools import assert_almost_equal
from helix.calculators.wind_pressure_calculator import WindPressureCalculator
from helix.constants.exposure_category import ExposureCategory
class WindPressureCalculatorTest(unittest.TestCase):
def setUp(self):
self.values = MagicMock()
self.values.wind_speed.return_value = 110
self.values.exposure_category_transition_distance.return_value = 1000
self.subject = WindPressureCalculator(self.values)
def test_kz_with_exposure_BC_and_roof_height_less_than_15_feet(self):
assert_almost_equal(self.subject.calculate_k_z(12, ExposureCategory.B_C, 1000), 0.686, 3)
def test_kz_with_exposure_BC_and_roof_height_greater_than_15_feet(self):
assert_almost_equal(self.subject.calculate_k_z(100, ExposureCategory.B_C, 1000), 1.023, 3)
def test_kz_with_exposure_CB_and_roof_height_less_than_30_feet(self):
assert_almost_equal(self.subject.calculate_k_z(25, ExposureCategory.C_B, 1000), 0.856, 3)
def test_kz_with_exposure_CB_and_roof_height_greater_than_30_feet(self):
assert_almost_equal(self.subject.calculate_k_z(100, ExposureCategory.C_B, 1000), 1.139, 3)
def test_qz_with_exposure_B_and_roof_height_greater_than_30_feet(self):
self.values.building_height.return_value = 35
self.values.exposure_category.return_value = ExposureCategory.B
assert_almost_equal(self.subject.q_z(self.subject.K_z()), 19.276, 2)
def test_qz_with_exposure_B_and_roof_height_less_than_30_feet(self):
self.values.building_height.return_value = 12
self.values.exposure_category.return_value = ExposureCategory.B
assert_almost_equal(self.subject.q_z(self.subject.K_z()), 18.430, 2)
def test_qz_with_exposure_C_and_roof_height_greater_than_15_feet(self):
self.values.building_height.return_value = 35
self.values.exposure_category.return_value = ExposureCategory.C
assert_almost_equal(self.subject.q_z(self.subject.K_z()), 26.715, 2)
def test_qz_with_exposure_C_and_roof_height_less_than_15_feet(self):
self.values.building_height.return_value = 12
self.values.exposure_category.return_value = ExposureCategory.C
assert_almost_equal(self.subject.q_z(self.subject.K_z()), 22.35078017, 2)
def test_qz_with_exposure_D_and_roof_height_greater_than_15_feet(self):
self.values.building_height.return_value = 35
self.values.exposure_category.return_value = ExposureCategory.D
assert_almost_equal(self.subject.q_z(self.subject.K_z()), 31.432, 2)
def test_qz_with_exposure_D_and_roof_height_less_than_15_feet(self):
self.values.building_height.return_value = 12
self.values.exposure_category.return_value = ExposureCategory.D
assert_almost_equal(self.subject.q_z(self.subject.K_z()), 27.126, 2)