Example #1
0
class OpeningTest(unittest.TestCase):

    def setUp(self):
        gbxml = gbXML(os.path.join(os.path.dirname(__file__), 'input/Single_model.xml'))
        spaces = gbxml.get_spaces()
        surfaces = spaces[0].surfaces
        self.surface = Surface()
        self.open = Opening()

        self.surface1 = surfaces[0]
        self.opening1 = surfaces[0].openings[0]

        # Create a fake weather
        self.weather = Weather('Washington', datetime(year=1997,month=1,day=1,hour=3), datetime(year=1997,month=1,day=1,hour=4))

        # And a timestep
        self.tstep2 = datetime(year=1997,month=1,day=1,hour=4)
        # get the weather at the tstep
        self.wtstep2 = self.weather.get_weather_step(self.tstep2)

        # And another timestep
        self.tstep = datetime(year=1997,month=1,day=1,hour=3)
        # get the weather at the tstep
        self.wtstep = self.weather.get_weather_step(self.tstep)

    def test_opening_A(self):
        #self.assertEqual(self.open.get_A(),1.1148,"Opening 1 get A (expected 1.1148) - %s " % self.surface1.get_A())
        this_opening_area = self.open.get_A(self.opening1)
        self.assertEqual(this_opening_area, 1.1148, 'opening area test: %s ' % this_opening_area)
class transmittedSolarTest(unittest.TestCase):
    # For now, this test is giving solar transmittance to be 0, which makes sense for 3-4am in the USA.
    # Therefore, I am assuming these are calculating correctly at this time.

    def setUp(self):
        self.gbxml = gbXML(
            os.path.join(os.path.dirname(__file__), 'input/Single_model.xml'))

        # Get the first surface to check:
        spaces = self.gbxml.get_spaces()
        #space_boundaries = list()
        #space_boundaries = spaces[0].surfaces
        surfaces = spaces[0].surfaces
        self.surface1 = surfaces[0]

        self.solar = TransmittedSolar()

        area = Area()
        #print "test"
        self.areaWinDict = area.getWinDictionary

        # Create a fake weather
        self.weather = Weather('Washington',
                               datetime(year=1997, month=1, day=1, hour=3),
                               datetime(year=1997, month=1, day=1, hour=4))

        # And a timestep
        self.tstep2 = datetime(year=1997, month=1, day=1, hour=4)
        # get the weather at the tstep
        self.wtstep2 = self.weather.get_weather_step(self.tstep2)

        # And another timestep
        self.tstep = datetime(year=1997, month=1, day=1, hour=3)
        # get the weather at the tstep
        self.wtstep = self.weather.get_weather_step(self.tstep)

    def test_get_transmitted_solar(self):
        AreaShadowOnlyWin = 0
        transmitted_win = self.solar.get_transmitted_solar(
            self.wtstep, self.surface1, AreaShadowOnlyWin, self.areaWinDict)
        self.assertEqual(transmitted_win, 0,
                         'transmitted_win is currently: %s ' % transmitted_win)

    #def test_get_transmitted_solar_Is(self):  # No longer in the module
    #    Is_calc = self.solar.get_transmitted_solar_Is(self.wtstep, self.surface1)
    #    self.assertEqual(Is_calc, 0, 'transmitted_win is currently: %s ' % Is_calc)

    def test_get_is_surface(self):
        # Assuming for this example that the solar heat gain for the windows in this surface is 0 from 3-4am...true
        tilt = self.surface1.tilt
        incidence = 1.74842841126
        az_d = 4.41808653158
        alt_sun = self.wtstep["alt_sun"]

        Is = self.solar.get_is_surface(self.surface1, tilt, incidence, az_d,
                                       alt_sun, self.wtstep)
        self.assertEqual(Is, 0, 'get_Is_surface is currently: %s ' % Is)

    """
Example #3
0
class transmittedSolarTest(unittest.TestCase):

    def setUp(self):
        self.gbxml = gbXML(os.path.join(os.path.dirname(__file__), 'input/Single_model.xml'))

        # Get the first surface to check:
        spaces = self.gbxml.get_spaces()
        self.shadow_record = self.gbxml.shadow_record
        self.shade_surf_list = self.gbxml.get_shades()
        self.surfaces_dict = self.gbxml.surfaces_dict
        self.ns = ( len(self.shade_surf_list) + len(self.shadow_record) )
        #space_boundaries = list()
        #space_boundaries = spaces[0].surfaces
        surfaces = spaces[0].surfaces
        self.surface1 = surfaces[0]

        self.shade = Shadow()

        # Create a fake weather
        self.weather = Weather('Washington', datetime(year=1997, month=1, day=1, hour=3), datetime(year=1997, month=1, day=1, hour=4))

        # And a timestep
        self.tstep2 = datetime(year=1997,month=1,day=1,hour=4)
        # get the weather at the tstep
        self.wtstep2 = self.weather.get_weather_step(self.tstep2)

        # And another timestep
        self.tstep = datetime(year=1997,month=1,day=1,hour=3)
        # get the weather at the tstep
        self.wtstep = self.weather.get_weather_step(self.tstep)


    def test_shadowsSection(self):
        # for this hour use one of:
        #alt = -0.714277  ,  az = 1.535298
        #alt = -0.511189  ,  az = 1.694248
        azi_sun_rad = 1.535298
        tilt_sun_rad = -0.714277
        Ashadow_no_win, Ashadow_win = self.shade.shadowsSection(self.surface1, azi_sun_rad, tilt_sun_rad, self.ns, self.shadow_record, self.shade_surf_list, self.surfaces_dict)
        self.assertEqual(Ashadow_no_win, 0, 'Ashadow_no_win: %s ' % Ashadow_no_win)
        self.assertEqual(Ashadow_win, 0, 'Ashadow_win: %s ' % Ashadow_win)
class transmittedSolarTest(unittest.TestCase):
    # For now, this test is giving solar transmittance to be 0, which makes sense for 3-4am in the USA.
    # Therefore, I am assuming these are calculating correctly at this time.

    def setUp(self):
        #self.gbxml = gbXML(os.path.join(os.path.dirname(__file__), 'input/Single_model.xml'))
        self.gbxml = gbXML(
            os.path.join(os.path.dirname(__file__),
                         'input/Two_Room_One_Floor_Model.xml'))
        self.temp = Temperature()
        self.shgc_dictionary = self.gbxml.shgc_dictionary
        self.temp_record = self.gbxml.temp_record
        self.spaces_dict = self.gbxml.spaces_dict
        self.shadow_record = self.gbxml.shadow_record
        self.shade_surf_list = self.gbxml.get_shades()
        self.surfaces_dict = self.gbxml.surfaces_dict
        # Get the first surface to check:
        spaces = self.gbxml.get_spaces()

        # Space 1 info, surface "su-8" is [7] and is the interior shared wall here
        space1 = spaces[0]
        surfaces_inspace1 = spaces[0].surfaces
        self.surface1_in_space1 = surfaces_inspace1[0]
        self.surface5_in_space1 = surfaces_inspace1[4]
        self.surface6_in_space1 = surfaces_inspace1[5]

        self.surface8_in_space1 = surfaces_inspace1[7]

        # Space 2 info, surface "su-8" is [7] and is the interior shared wall here
        #space2 = spaces[1]
        #surfaces_inspace2 = spaces[1].surfaces
        #self.surface8_in_space2 = surfaces_inspace1[7]

        # Create a fake weather
        self.weather = Weather('Washington',
                               datetime(year=1997, month=1, day=1, hour=3),
                               datetime(year=1997, month=1, day=1, hour=4))

        area = Area()
        #print "test"
        self.areaWinDict = area.getWinDictionary

        # And a timestep
        self.tstep2 = datetime(year=1997, month=1, day=1, hour=4)
        # get the weather at the tstep
        self.wtstep2 = self.weather.get_weather_step(self.tstep2)

        # And another timestep
        self.tstep = datetime(year=1997, month=1, day=1, hour=3)
        # get the weather at the tstep
        self.wtstep = self.weather.get_weather_step(self.tstep)

    def test_interior_wall(self):
        T_space = 293
        surface = self.surface8_in_space1
        T1 = self.wtstep["t_outside"]
        A = 12.77375
        A_noOp = 12.77375
        C = 317068.2  #set when next model is tested
        R3 = 0

        #Q_flux = 1
        Q_flux = self.temp.interior_wall(surface, A, C, R3, self.spaces_dict,
                                         T_space, self.temp_record)
        self.assertEqual(Q_flux, 1, 'Q_flux is currently: %s ' % Q_flux)

    def test_exterior_wall(self):
        T_space = 293
        surface = self.surface6_in_space1
        T1 = self.wtstep["t_outside"]
        A = 20.554798
        A_noOp = 19.439962
        A_noWin = 19.439962
        hc = 17.65859
        C = 270863.311519
        R3 = 1 / 0.729191
        ShadowsFlag = 0
        ns = (len(self.shade_surf_list) + len(self.shadow_record))

        Q_flux = self.temp.exterior_wall(surface, hc, T1, A, A_noWin,
                                         self.wtstep, R3, C, T_space,
                                         self.temp_record, ShadowsFlag, ns,
                                         self.shadow_record,
                                         self.shade_surf_list,
                                         self.surfaces_dict, self.areaWinDict)
        self.assertEqual(Q_flux, -7.230236,
                         'Q_flux is currently: %s ' % Q_flux)

    def test_roof(self):
        T_space = 293
        surface = self.surface5_in_space1
        T1 = self.wtstep["t_outside"]
        A = 18.580608
        A_noOp = 18.580608
        A_noWin = 18.580608
        hc = 15.24232
        C = 36873.89882
        R3 = 1 / 0.084111
        ShadowsFlag = 0
        ns = (len(self.shade_surf_list) + len(self.shadow_record))

        Q_flux = self.temp.roof(surface, hc, T1, A, A_noWin, self.wtstep, R3,
                                C, A_noOp, T_space, self.temp_record,
                                ShadowsFlag, ns, self.shadow_record,
                                self.shade_surf_list, self.surfaces_dict,
                                self.areaWinDict)
        self.assertEqual(Q_flux, -10.487022,
                         'Q_flux is currently: %s ' % Q_flux)

    def test_underground_wall(self):
        Q_flux = 1
        # Q_flux = self.temp.underground_wall(surface, hc_external, T1, A, A_noWin, weather, R3, C, A_noOp, shgc_dictionary)
        self.assertEqual(Q_flux, 1, 'Q_flux is currently: %s ' % Q_flux)
Example #5
0
class SurfaceTest(unittest.TestCase):
    def setUp(self):
        gbxml = gbXML(
            os.path.join(os.path.dirname(__file__), 'input/Single_model.xml'))
        area = Area()
        area.createAreaDictionary()
        area.createWinAreaDictionary()
        self.areaWinDict = area.getWinDictionary()
        self.areaDict = area.getDictionary()

        spaces = gbxml.get_spaces()
        surfaces = spaces[0].surfaces
        self.surface = Surface()

        self.surface1 = surfaces[0]
        self.surface2 = surfaces[1]
        self.surface3 = surfaces[2]
        self.surface4 = surfaces[3]
        self.surface5 = surfaces[4]
        self.surface6 = surfaces[5]

        # Create a fake weather
        self.weather = Weather('Washington',
                               datetime(year=1997, month=1, day=1, hour=3),
                               datetime(year=1997, month=1, day=1, hour=4))

        # And a timestep
        self.tstep2 = datetime(year=1997, month=1, day=1, hour=4)
        # get the weather at the tstep
        self.wtstep2 = self.weather.get_weather_step(self.tstep2)

        # And another timestep
        self.tstep = datetime(year=1997, month=1, day=1, hour=3)
        # get the weather at the tstep
        self.wtstep = self.weather.get_weather_step(self.tstep)

    def test_get_hc_external(self):
        # These numbers are giving values that are different than Ben's tests, not sure why/where they came from...
        h_surface = 1.685925
        terrain = "Flat or Open Countryside"
        hc1 = self.surface.get_hc_external(self.wtstep, self.surface1,
                                           h_surface, terrain)
        self.assertEqual(hc1, 25.82063, 'get_hc is on surface 1: %s ' % hc1)
        #Ben's test: self.assertEqual(self.surface1.get_hc_external(self.wtstep),17.5617,"Surface 1")

        hc2 = self.surface.get_hc_external(self.wtstep, self.surface2,
                                           h_surface, terrain)
        self.assertEqual(hc2, 25.82063, 'get_hc is on surface 2: %s ' % hc2)
        #Ben's test: self.assertEqual(self.surface2.get_hc_external(self.wtstep),8.7809,"Surface 2")

        hc5 = self.surface.get_hc_external(self.wtstep, self.surface5,
                                           h_surface, terrain)
        self.assertEqual(hc5, 25.82063, 'get_hc is on surface 5: %s ' % hc5)
        #Ben's test: self.assertEqual(self.surface5.get_hc_external(self.wtstep),18.4740,"Surface 5")

        hc6 = self.surface.get_hc_external(self.wtstep, self.surface6,
                                           h_surface, terrain)
        self.assertEqual(hc6, 25.82063, 'get_hc is on surface 6: %s ' % hc6)

    def test_get_A(self):
        A = self.surface.get_A(self.surface1, self.areaDict, self.areaWinDict)
        A = round(A, 3)
        self.assertEqual(A, 20.555, 'Total area of surface 1: %s ' % A)
        A = self.surface.get_A(self.surface2, self.areaDict, self.areaWinDict)
        A = round(A, 3)
        self.assertEqual(A, 10.277, 'Total area of surface 2: %s ' % A)
        A = self.surface.get_A(self.surface3, self.areaDict, self.areaWinDict)
        A = round(A, 3)
        self.assertEqual(A, 20.555, 'Total area of surface 3: %s ' % A)
        A = self.surface.get_A(self.surface4, self.areaDict, self.areaWinDict)
        A = round(A, 3)
        self.assertEqual(A, 10.277, 'Total area of surface 4: %s ' % A)
        A = self.surface.get_A(self.surface5, self.areaDict, self.areaWinDict)
        A = round(A, 3)
        self.assertEqual(A, 18.581, 'Total area of surface 5: %s ' % A)
        A = self.surface.get_A(self.surface6, self.areaDict, self.areaWinDict)
        A = round(A, 3)
        self.assertEqual(A, 18.581, 'Total area of surface 6: %s ' % A)

    def test_get_A_noWin(self):
        A = self.surface.get_A_noWin(self.surface1, self.areaDict,
                                     self.areaWinDict)
        A = round(A, 3)
        self.assertEqual(A, 19.440, 'A_no_windows for surface 1: %s ' % A)
        A = self.surface.get_A_noWin(self.surface2, self.areaDict,
                                     self.areaWinDict)
        A = round(A, 3)
        self.assertEqual(A, 10.277, 'A_no_windows for surface 2: %s ' % A)
        A = self.surface.get_A_noWin(self.surface3, self.areaDict,
                                     self.areaWinDict)
        A = round(A, 3)
        self.assertEqual(A, 19.440, 'A_no_windows for surface 3: %s ' % A)
        A = self.surface.get_A_noWin(
            self.surface4, self.areaDict, self.areaWinDict
        )  # same as total area because doors are not counted here
        A = round(A, 3)
        self.assertEqual(A, 10.277, 'A_no_windows for surface 4: %s ' % A)
        A = self.surface.get_A_noWin(self.surface5, self.areaDict,
                                     self.areaWinDict)
        A = round(A, 3)
        self.assertEqual(A, 18.581, 'A_no_windows for surface 5: %s ' % A)
        A = self.surface.get_A_noWin(self.surface6, self.areaDict,
                                     self.areaWinDict)
        A = round(A, 3)
        self.assertEqual(A, 18.581, 'A_no_windows for surface 6: %s ' % A)

    def test_get_A_noOp(self):
        A = self.surface.get_A_noOp(self.surface1, self.areaDict,
                                    self.areaWinDict)
        A = round(A, 3)
        self.assertEqual(A, 19.440, 'A_no_openings for surface 1: %s ' % A)
        A = self.surface.get_A_noOp(self.surface2, self.areaDict,
                                    self.areaWinDict)
        A = round(A, 3)
        self.assertEqual(A, 10.277, 'A_no_openings for surface 2: %s ' % A)
        A = self.surface.get_A_noOp(self.surface3, self.areaDict,
                                    self.areaWinDict)
        A = round(A, 3)
        self.assertEqual(A, 19.440, 'A_no_openings for surface 3: %s ' % A)
        A = self.surface.get_A_noOp(
            self.surface4, self.areaDict, self.areaWinDict
        )  # same as total area because doors are not counted here
        A = round(A, 3)
        self.assertEqual(A, 8.419, 'A_no_openings for surface 4: %s ' % A)
        A = self.surface.get_A_noOp(self.surface5, self.areaDict,
                                    self.areaWinDict)
        A = round(A, 3)
        self.assertEqual(A, 18.581, 'A_no_openings for surface 5: %s ' % A)
        A = self.surface.get_A_noOp(self.surface6, self.areaDict,
                                    self.areaWinDict)
        A = round(A, 3)
        self.assertEqual(A, 18.581, 'A_no_openings for surface 6: %s ' % A)

    def test_get_C_surface(self):
        A_total = 20.554798
        A_noOp = 19.439962
        Coeff = 1
        C = self.surface.get_C_surface(A_total, A_noOp, self.surface1, Coeff,
                                       self.areaWinDict)
        # Currently calculating the effective C to be 270863.311519, check against Matlab output
        self.assertEqual(C, 270863.311519, 'C of surface 1: %s ' % C)

        A_total = 10.277399
        A_noOp = 8.419338
        Coeff = 1
        # Test surface door which does have a door
        C = self.surface.get_C_surface(A_total, A_noOp, self.surface4, Coeff,
                                       self.areaWinDict)
        # Currently calculating the effective C to be 270863.311519, check against Matlab output
        self.assertEqual(C, 242487.186765, 'C of surface 4: %s ' % C)

        A_total = 18.580608
        A_noOp = 18.580608
        Coeff = 1
        # Test surface door which does have a door
        C = self.surface.get_C_surface(A_total, A_noOp, self.surface5, Coeff,
                                       self.areaWinDict)
        # Currently calculating the effective C to be 270863.311519, check against Matlab output
        self.assertEqual(C, 36873.89882, 'C of surface 5: %s ' % C)

    def test_get_U_surface(self):
        A_noOp = 19.439962
        U = self.surface.get_U_surface(A_noOp, self.surface1)
        self.assertEqual(U, 0.386384, 'U of surface 1: %s ' % U)

        A_noOp = 18.580608
        U = self.surface.get_U_surface(A_noOp, self.surface5)
        self.assertEqual(U, 0.084111, 'U of surface 5: %s ' % U)

    def test_get_U_win(self):
        U = self.surface.get_U_win(self.surface1)
        self.assertEqual(U, 0.0, 'U of surface 1: %s ' % U)
        U = self.surface.get_U_win(self.surface2)
        self.assertEqual(U, 0, 'U of surface 2: %s ' % U)
        U = self.surface.get_U_win(self.surface3)
        self.assertEqual(U, 0.0, 'U of surface 3: %s ' % U)
        U = self.surface.get_U_win(self.surface4)
        self.assertEqual(U, 0, 'U of surface 4: %s ' % U)
        U = self.surface.get_U_win(self.surface5)
        self.assertEqual(U, 0, 'U of surface 5: %s ' % U)
        U = self.surface.get_U_win(self.surface6)
        self.assertEqual(U, 0, 'U of surface 6: %s ' % U)

    def test_get_U_opening(self):
        U = self.surface.get_U_opening(self.surface1)
        self.assertEqual(U, 0, 'U of surface 1: %s ' % U)

        U = self.surface.get_U_opening(self.surface2)
        self.assertEqual(U, 0, 'U of surface 2: %s ' % U)

        U = self.surface.get_U_opening(self.surface3)
        self.assertEqual(U, 0, 'U of surface 3: %s ' % U)

        U = self.surface.get_U_opening(self.surface4)
        self.assertEqual(U, 0.0, 'U of surface 4: %s ' % U)

        U = self.surface.get_U_opening(self.surface5)
        self.assertEqual(U, 0, 'U of surface 5: %s ' % U)

        U = self.surface.get_U_opening(self.surface6)
        self.assertEqual(U, 0, 'U of surface 6: %s ' % U)

    def test_get_U_surface_e(self):
        # Check all these against Matlab output
        A_total = 20.554798
        A_noOp = 19.439962
        # Test surface which does have a window
        U = self.surface.get_U_surface_e(A_total, A_noOp, self.surface1,
                                         self.areaWinDict)
        self.assertEqual(U, 0.729192, 'C of surface 1: %s ' % U)

        A_total = 10.277399
        A_noOp = 8.419338
        # Test surface which does have a door
        U = self.surface.get_U_surface_e(A_total, A_noOp, self.surface4,
                                         self.areaWinDict)
        self.assertEqual(U, 0.985835, 'C of surface 4: %s ' % U)

        A_total = 18.580608
        A_noOp = 18.580608
        U = self.surface.get_U_surface_e(A_total, A_noOp, self.surface5,
                                         self.areaWinDict)
        self.assertEqual(U, 0.084111, 'C of surface 5: %s ' % U)

        A_total = 18.580608
        A_noOp = 18.580608
        U = self.surface.get_U_surface_e(A_total, A_noOp, self.surface6,
                                         self.areaWinDict)
        self.assertEqual(U, 5.147638, 'C of surface 6: %s ' % U)
Example #6
0
class SpaceTest(unittest.TestCase):
    def setUp(self):
        self.gbxml = gbXML(
            os.path.join(os.path.dirname(__file__), 'input/Single_model.xml'))
        #self.gbxml = gbXML(os.path.join(os.path.dirname(__file__), 'input/Four_Room_Two_Floors_Model.xml')) # To test middle interior floor
        area = Area()
        area.createAreaDictionary()
        area.createWinAreaDictionary()
        self.areaWinDict = area.getWinDictionary()
        self.areaDict = area.getDictionary()

        spaces = self.gbxml.get_spaces()
        self.volume = Space()
        self.temp_record = self.gbxml.temp_record
        self.spaces_dict = self.gbxml.spaces_dict
        self.shgc_dictionary = self.gbxml.shgc_dictionary
        self.shadow_record = self.gbxml.shadow_record
        self.shade_surf_list = self.gbxml.get_shades()
        self.surfaces_dict = self.gbxml.surfaces_dict

        self.space1 = spaces[0]
        surfaces = spaces[0].surfaces
        self.surface6 = surfaces[5]
        self.surface5 = surfaces[4]
        self.surface4 = surfaces[3]
        self.surface3 = surfaces[2]
        self.surface2 = surfaces[1]
        self.surface1 = surfaces[0]

        # Create a fake weather
        self.weather = Weather('Washington',
                               datetime(year=1997, month=1, day=1, hour=3),
                               datetime(year=1997, month=1, day=1, hour=4))

        # And a timestep
        self.tstep2 = datetime(year=1997, month=1, day=1, hour=4)
        # get the weather at the tstep
        self.wtstep2 = self.weather.get_weather_step(self.tstep2)

        # And another timestep
        self.tstep = datetime(year=1997, month=1, day=1, hour=3)
        # get the weather at the tstep
        self.wtstep = self.weather.get_weather_step(self.tstep)

    def test_calculate_space_heatflux(self):
        Coeff = 1
        ShadowsFlag = 0
        terrain = "Flat or Open Countryside"
        A = 0
        missing_surfaces = dict()  # Should not matter for this test case
        G_space_record = dict()
        G_space_record["su-1"] = 0
        G_space_record["su-2"] = 0
        G_space_record["su-3"] = 0
        G_space_record["su-4"] = 0
        G_space_record["su-5"] = 0
        G_space_record["su-6"] = 0
        ns = (len(self.shade_surf_list) + len(self.shadow_record))
        heatflux = self.volume.calculate_space_heatflux(
            self.space1, self.wtstep, self.spaces_dict, self.temp_record,
            Coeff, ShadowsFlag, ns, self.shadow_record, self.shade_surf_list,
            self.surfaces_dict, A, missing_surfaces, terrain, G_space_record,
            self.areaDict, self.areaWinDict)
        self.assertEqual(
            heatflux, 45.659443, 'heatflux for this space is: %s ' % heatflux
        )  # Getting 45.256363 for single model until compare with Na

    def test_get_height(self):
        x = self.temp_record
        height = self.volume.get_height(self.surface5)
        self.assertEqual(height, 3.37185, 'height for surface 5: %s ' % height)

        height = self.volume.get_height(self.surface6)
        self.assertEqual(height, 0, 'height for surface 6: %s ' %
                         height)  #This is the floor level = 0

        height = self.volume.get_height(self.surface1)
        self.assertEqual(height, 1.685925,
                         'height for surface 1: %s ' % height)

        height = self.volume.get_height(self.surface2)
        self.assertEqual(height, 1.685925,
                         'height for surface 2: %s ' % height)

        height = self.volume.get_height(self.surface3)
        self.assertEqual(height, 1.685925,
                         'height for surface 3: %s ' % height)

        height = self.volume.get_height(self.surface4)
        self.assertEqual(height, 1.685925,
                         'height for surface 4: %s ' % height)

    def test_get_height_floorspace(self):
        height = self.volume.get_height_floorspace(self.space1)
        #print "height is: ", height
        self.assertEqual(height[0], 0, 'height for surface 6: %s ' %
                         height[0])  # 6 is the only floor to test here
Example #7
0
class HeatCalculationTest(unittest.TestCase):
    def setUp(self):
        self.gbxml = gbXML(
            os.path.join(os.path.dirname(__file__), 'input/Single_model.xml'))
        #self.gbxml = gbXML(os.path.join(os.path.dirname(__file__), 'input/Four_Room_Two_Floors_Model.xml')) # To test middle interior floor
        area = Area()
        area.createAreaDictionary()
        area.createWinAreaDictionary()
        self.areaWinDict = area.getWinDictionary()
        self.areaDict = area.getDictionary()

        spaces = self.gbxml.get_spaces()
        surfaces = spaces[0].surfaces
        self.heat = HeatCalculation()
        self.temp_record = self.gbxml.temp_record
        self.spaces_dict = self.gbxml.spaces_dict
        self.shgc_dictionary = self.gbxml.shgc_dictionary
        self.shadow_record = self.gbxml.shadow_record
        self.shade_surf_list = self.gbxml.get_shades()
        self.surfaces_dict = self.gbxml.surfaces_dict

        self.space1 = spaces[0]
        #surfaces1 = spaces[0].surfaces
        #self.space2 = spaces[1]
        #surfaces2 = spaces[1].surfaces
        #self.surface6 = surfaces1[5]   # su-6
        #self.surface11 = surfaces2[5]  # su-11

        self.surface1 = surfaces[0]
        self.surface2 = surfaces[1]
        self.surface3 = surfaces[2]
        self.surface4 = surfaces[3]
        self.surface5 = surfaces[4]
        self.surface6 = surfaces[5]

        self.G_space_record = dict()
        self.G_space_record["sp-1-Room"] = 0

        # Create a fake weather
        self.weather = Weather('Washington',
                               datetime(year=1997, month=1, day=1, hour=3),
                               datetime(year=1997, month=1, day=1, hour=4))

        # And a timestep
        self.tstep2 = datetime(year=1997, month=1, day=1, hour=4)
        # get the weather at the tstep
        self.wtstep2 = self.weather.get_weather_step(self.tstep2)

        # And another timestep
        self.tstep = datetime(year=1997, month=1, day=1, hour=3)
        # get the weather at the tstep
        self.wtstep = self.weather.get_weather_step(self.tstep)

    def test_get_floor_heat(
            self):  # done with the four room model as gbxml input above
        A_noOp_floor = 9.290304
        G_space = 0
        #floor_heat = self.heat.get_floor_heat(self.surface6, self.wtstep, G_space, self.spaces_dict, A_noOp_floor, self.temp_record)
        #self.assertEqual(floor_heat, -16.112311, 'top heat for surface 6: %s ' % floor_heat)  #Getting -16.112311 but need to check these with Na, also the G_space
        Coeff = 1
        A_noOp_floor = 9.290304
        G_space = 0
        floor_heat = self.heat.get_floor_heat(self.space1, self.surface6,
                                              self.wtstep, G_space,
                                              self.spaces_dict, A_noOp_floor,
                                              self.temp_record, Coeff,
                                              self.areaDict, self.areaWinDict)
        floor_heat = round(floor_heat, 3)
        self.assertEqual(
            floor_heat, -1.984, 'top heat for surface 11: %s ' % floor_heat
        )  #Getting -16.112311 but need to check these with Na, also the G_space

    def test_get_top_heat(self):
        Coeff = 1
        floor_heat = self.heat.get_top_heat(self.space1, self.surface4,
                                            self.wtstep, self.spaces_dict,
                                            self.temp_record, Coeff,
                                            self.G_space_record, self.areaDict,
                                            self.areaWinDict)
        floor_heat = round(floor_heat, 15)
        self.assertEqual(floor_heat, -0.00000000000236,
                         'top heat for surface 5 (roof): %s ' % floor_heat)

    def test_get_raised_floor_heat(self):
        A_noOp_floor = 18.580608
        G_space = 0
        h_surface = 0
        terrain = "Flat or Open Countryside"
        Coeff = 1
        self.wtstep["t_outside"] = 280  # Fake Temp Value
        #self.wtstep["ground_temperature_K"] = 280  # Fake Temp Value
        floor_heat = self.heat.get_raised_floor_heat(
            self.surface6, self.wtstep, G_space, A_noOp_floor,
            self.temp_record, self.space1, self.spaces_dict, h_surface,
            terrain, Coeff, self.areaDict, self.areaWinDict)
        self.assertEqual(
            floor_heat, -5.492465, 'floor heat for surface 6: %s ' % floor_heat
        )  #Getting -40.221503 with G_space = 0, will need updating for model 1

    def test_get_ground_heat(self):
        A_noOp_floor = 18.580608
        G_space = 0
        Coeff = 1
        ground_heat = self.heat.get_ground_heat(self.surface6, self.wtstep,
                                                G_space, A_noOp_floor,
                                                self.temp_record, self.space1,
                                                self.spaces_dict, Coeff,
                                                self.areaDict,
                                                self.areaWinDict)
        self.assertEqual(
            ground_heat, -3.720495,
            'ground heat for surface 6: %s ' % ground_heat
        )  #Getting -38.264154 with G_space = 0, will need updating for model 1