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

@@ -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)