Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    def get_ground_heat(self, surface, weather, G_space, A_noOp_floor,
                        temp_record, space, spaces_dict, Coeff, areaDict,
                        areaWinDict):
        # Calculate the ground heat flux for a floor surface
        #print "here"
        surf = Surface()
        A_total = surf.get_A(surface, areaDict, areaWinDict)
        A_noOp = A_noOp_floor
        # The T2 is the inside surface temperature
        T_space = spaces_dict[space.obj_id][1]
        T2 = temp_record[surface.obj_id + "_inside_surface-1"]
        T1 = weather["t_outside"]
        ground_temp = (T_space - 2)
        # need the surface related information, T_space, U, R3
        U = surf.get_U_surface_e(A_total, A_noOp, surface, areaWinDict)
        R3 = 1 / U
        # Using calculations from: self.surface.constr.layer.C
        C = surf.get_C_surface(A_total, A_noOp, surface, Coeff, areaWinDict)
        dt = 3600.0
        # Assuming it is reduced convection T_space1>T2
        hc = 0.948
        R5 = 1 / hc
        C2 = C / 2
        A1 = ((C2 / dt) * T2) + (T_space / R5) + (ground_temp / R3) + G_space
        A2 = C2 / dt + 1 / R5 + 1 / R3
        T_in = A1 / A2
        if T_space < T_in:
            hc = 4.04
            R5 = 1 / hc
            A1 = C2 / dt * T2 + T_space / R5 + ground_temp / R3 + G_space
            A2 = C2 / dt + 1 / R5 + 1 / R3
            T_in = A1 / A2

        # Update temp_record dictionary
        # Add the newly calculated numbers into the dictionary:
        temp_record[surface.obj_id + "_inside_surface-1"] = T_in

        Q_floor = hc * A_total * (T_in - T_space)

        return round(Q_floor, 6)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    def calculate_space_heatflux(self, space, weather, spaces_dict,
                                 temp_record, Coeff, ShadowsFlag, ns,
                                 shadow_record, shade_surf_list, surfaces_dict,
                                 A, missing_surfaces, terrain, G_space_record,
                                 areaDict, areaWinDict, shadowRatios,
                                 shadowRatioIndex):
        #print "Reaching Space function..."
        #l = space.obj_id
        #TM_coder.info("   Entering function: calculate_space_heatflux()")

        surf = Surface()
        space_hour_q = 0
        heat_calculation = HeatCalculation()
        transmitted_solar = TransmittedSolar()
        G_space = 0
        Q_space = 0
        Q_floor = 0
        floorID = "none"
        A_noOp_floor = 0
        current_floor = 0
        Q_top = 0
        #h_space = self.get_height_floorspace(space) # This will need to get rid of the extra 0,0,0 coordinate appended to match matlab eventually, check that its commented out below
        #print "h_space: ", space.obj_id, h_space
        h_surface = 0

        h_space, current_floor = self.get_height_floorspace(
            space
        )  # Finds the floor surface and gets the height from the ground---note (0,0,0 problem not resolved from Matlab)
        A_noOp_floor = surf.get_A_noOp(current_floor, areaDict, areaWinDict)
        current_floor_type = current_floor.obj_type
        #print h_space

        for surface in space.surfaces:
            #print "found one: ", surface.obj_id, surface.obj_type
            #h_space, current_floor = self.get_height_floorspace(space)
            #A_noOp_floor = surf.get_A_noOp(current_floor)
            #print "h_space: ", space.obj_id, h_space
            #print surface.obj_id
            # Regardless of the type of surface, calculate the heatflux for this surface, adjusting as appropriate
            #h_space = self.get_height_floorspace(space)
            # h_space = Infor_surface{13,i_space} = getHeightSurface
            h_surface = self.get_height(
                surface
            )  # Finds the midpoint of the surface from the ground for all surface locations---note (0,0,0 problem not resolved from Matlab)
            #print "h_surface: ", surface.obj_type, surface.obj_id, h_surface

            # Assuming all floors will be flat--does not yet account for surfaces that are slanted!
            if surface.obj_type == "Ceiling":
                #print "found one: ", surface.obj_id
                #loop coordinates to check for z similarities to determine if it is horizontal or vertical
                z0 = surface.cps[0][2]
                z1 = surface.cps[1][2]
                z2 = surface.cps[2][
                    2]  # If a surface is defined as at least three points
                #for x, y, z in surface.cps:
                #    print z
                if z0 == z1 and z1 == z2:
                    surface.obj_type = "InteriorFloor"
                    #print z0, z1, z2
                else:
                    surface.obj_type = "InteriorWall"
                    #print z0, z1, z2
                #print surface.obj_type

            if surface.obj_type == "ExteriorWall" or surface.obj_type == "Roof" or surface.obj_type == "InteriorWall" or surface.obj_type == "UndergroundWall":
                G_window, Q_surface = surf.calculate_surface_heatflux(
                    weather, spaces_dict, surface, temp_record, Coeff, space,
                    h_surface, ShadowsFlag, ns, shadow_record, shade_surf_list,
                    surfaces_dict, A, terrain, areaDict, areaWinDict,
                    shadowRatios, shadowRatioIndex)
                #print "h_surface: ", surface.obj_type, surface.obj_id, h_surface
                Q_space += Q_surface
                #print Q_surface
                G_space += G_window
            elif surface.obj_type == "Air":
                # According to Na, should skip surfaces of Air for thermal calculations
                continue
            elif surface.obj_type == "InteriorFloor" and h_space < h_surface:
                # means this is the top
                Q_top = heat_calculation.get_top_heat(space, surface, weather,
                                                      spaces_dict, temp_record,
                                                      Coeff, G_space_record,
                                                      areaDict, areaWinDict)
                Q_space += Q_top
                #if surface.obj_id == "su-6":
                #print Q_top    # Known issue with the heat flux for this calculation
                #A_noOp_floor = surf.get_A_noOp(surface)  # for now we are assuming there are no openings in a floor, will have to be adjusted later
                if A == 0:
                    # If it is the first surface of the space, label the space ID in the log file:
                    la = str(surface.obj_id)
                    lb = str(surface.obj_type)
                    #TM_user.info("%s,surface area,%s,%s" % (la, A_noOp_floor, lb))
            elif surface.obj_type == "Column":
                # Not considering columns in the middle of a space for TM for now...embedded in the wall may need further attention
                pass
            # As of version 4 of MatLab, this elif and else was removed...?
            """
            elif surface.obj_type == "InteriorFloor" or surface.obj_type == "RaisedFloor" or surface.obj_type == "UndergroundSlab" or surface.obj_type == "SlabOnGrade":
                if h_space == h_surface:
                    floorSurface = surface
                    current_floor_type = surface.obj_type
                    A_noOp_floor = surf.get_A_noOp(surface)  # for now we are assuming there are no openings in a floor, will have to be adjusted later
                if A == 0:
                    # If it is the first surface of the space, label the space ID in the log file:
                    la = str(surface.obj_id)
                    lb = str(surface.obj_type)
                    TM_user.info("%s,surface area,%s,%s" % (la, A_noOp_floor, lb))

            else:
                print "Surface Not Found: ", surface.obj_type
                if surface.obj_type not in missing_surfaces:
                    missing_surfaces[surface.obj_type] = surface.obj_id
                TM_user.info("Need object type: ,%s" % surface.obj_type)
            """
            #if surface.obj_type == "InteriorFloor" or surface.obj_type == "RaisedFloor" or surface.obj_type == "UndergroundSlab" or surface.obj_type == "SlabOnGrade" or surface.obj_type == "ExteriorWall" or surface.obj_type == "Roof" or surface.obj_type == "InteriorWall" or surface.obj_type == "UndergroundWall":
            #    pass
            #else:
            #    print "Surface Not Found: ", surface.obj_type
            #    if surface.obj_type not in missing_surfaces:
            #        missing_surfaces[surface.obj_type] = surface.obj_id
            #    TM_user.info("Need object type: ,%s" % surface.obj_type)

            #raise Exception("Surface Type Not Found So Nothing Calculated...for this surface")
            #elif surface.obj_type == "InteriorFloor" and h_space == h_surface:
            # means this is the bottom
            #current_floor_type = surface.obj_type
            #A_noOp_floor = surface.get_A_noOp(surface)  # for now we are assuming there are no openings in a floor, will have to be adjusted later
            #Q_floor = self.calculate_Q_floor(space, surface, current_floor_type, A_noOp_floor, weather, G_space, spaces_dict, temp_record, Coeff)
            # could make a seperate floor list to save int he next loop, but since only about 6-12 surfaces, may not be worth another list...
            # may also have to adjust later for multi-floored spaces
            #print "Q_space: ", Q_space

        G_space1 = G_space
        G_space = G_space1 / A_noOp_floor  #Area of the floor, but want noOp eventually to omit stairwell spaces in area as I have accounted for here
        #print "floor type: ", floorSurface.obj_type
        #print "G_space: ", G_space
        #print space.obj_id
        G_space_record[space.obj_id] = G_space
        #print G_space, G_space_record[space.obj_id]
        #C = surf.get_C_surface(A_noOp_floor, A_noOp_floor, current_floor, Coeff)
        #print C, current_floor.obj_type, current_floor.obj_id

        if current_floor_type == "InteriorFloor":
            Q_floor = heat_calculation.get_floor_heat(
                space, current_floor, weather, G_space, spaces_dict,
                A_noOp_floor, temp_record, Coeff, areaDict, areaWinDict)
            #print Q_floor

        elif current_floor_type == "RaisedFloor":
            # UndergroundSlab and SlabOnGrade are like floor, and there is only one space
            Q_floor = heat_calculation.get_raised_floor_heat(
                current_floor, weather, G_space, A_noOp_floor, temp_record,
                space, spaces_dict, h_surface, terrain, Coeff, areaDict,
                areaWinDict)
            #print "Q_floor: ", Q_floor

        elif current_floor_type == "UndergroundSlab" or current_floor_type == "SlabOnGrade":
            Q_floor = heat_calculation.get_ground_heat(current_floor, weather,
                                                       G_space, A_noOp_floor,
                                                       temp_record, space,
                                                       spaces_dict, Coeff,
                                                       areaDict, areaWinDict)
            #print "Q_floor: ", Q_floor

        else:
            Q_floor = 0
            print "Surface Floor Not Found: ", current_floor_type
            if current_floor_type not in missing_surfaces:
                missing_surfaces[current_floor_type] = current_floor_type
            #raise Exception("Surface Type Not Found So Nothing Calculated...for this surface")
            TM_user.info("Need object type: ,%s" % current_floor_type)

        # Sum all the Q for the surfaces of the space
        space_hour_q = Q_space + Q_floor
        if space_hour_q < 0:
            space_hour_q = math.fabs(space_hour_q)

        # Return the heat flux of this whole space from the sum of the surface calculations for this hour
        return round(space_hour_q, 6)
Ejemplo n.º 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)
Ejemplo n.º 6
0
    def get_raised_floor_heat(self, surface, weather, G_space, A_noOp_floor,
                              temp_record, space, spaces_dict, h_surface,
                              terrain, Coeff, areaDict, areaWinDict):
        # For an interior floor that is a top of a space, the transmitted solar energy also needs to be calculated
        dt = 3600
        surf = Surface()
        A_total = surf.get_A(surface, areaDict, areaWinDict)
        A_noOp = A_noOp_floor  # T_space = Infor_space{9, i_space}

        T_space = spaces_dict[space.obj_id][1]
        T2 = temp_record[surface.obj_id + "_inside_surface-1"]
        T3 = temp_record[surface.obj_id + "_outside_surface-1"]
        T1 = weather["t_outside"]
        ground_temp = (T_space - 2)

        hc_external = surf.get_hc_external(weather, surface, h_surface,
                                           terrain)
        solarIs = TransmittedSolar()
        Is = 0
        transmitted_win = 0
        transmitted_win, Is = solarIs.get_transmitted_solar(
            weather, surface, 0, areaWinDict)
        Is *= 0.7
        #print Is

        # Assuming it is reduced convection T_space1 <T2
        hc = 4.04
        R5 = 1 / hc
        R1 = 1 / hc_external
        U = surf.get_U_surface_e(A_total, A_noOp, surface, areaWinDict)
        R3 = 1 / U
        # Using calculations from: self.surface.constr.layer.C
        C = surf.get_C_surface(A_total, A_noOp, surface, Coeff, areaWinDict)
        C2 = C / 2
        C4 = C / 2

        # Assuming we continue to assign Tp = (weather.hour - 1) and Tp_interior = T2:inside temp and T_space = A_noOp
        M1 = (C2 / dt) + (1 / R1) + (1 / R3)
        M2 = ((C2 / dt) * T3) + (T1 / R1) + Is
        M3 = (C4 / dt) + (1 / R3) + (1 / R5)
        M4 = (C4 / dt) * T2 + (T_space / R5)
        T_out = (M4 * R3 + M3 * M2 *
                 (R3**2) + R3 * G_space) / (M3 * M1 *
                                            (R3**2) - 1)  # exterior temp
        T_in = (M1 * T_out - M2) * R3  # interior temp
        if T_space > T_in:
            hc = 0.948
            R5 = 1 / hc
            M1 = (C2 / dt) + (1 / R1) + (1 / R3)
            M2 = ((C2 / dt) * T3) + (T1 / R1) + Is
            M3 = (C4 / dt) + (1 / R3) + (1 / R5)
            M4 = (C4 / dt) * T2 + (T_space / R5)
            T_out = (M4 * R3 + M3 * M2 *
                     (R3**2) + R3 * G_space) / (M3 * M1 *
                                                (R3**2) - 1)  # exterior temp
            T_in = (M1 * T_out - M2) * R3  # interior temp

        # Update temp_record dictionary
        # Add the newly calculated numbers into the dictionary:
        temp_record[surface.obj_id + "_outside_surface-1"] = T_out
        temp_record[surface.obj_id + "_inside_surface-1"] = T_in

        Q_flux = hc * A_total * (T_in - T_space)

        return round(Q_flux, 6)
Ejemplo n.º 7
0
    def get_top_heat(self, space, surface, weather, spaces_dict, temp_record,
                     Coeff, G_space_record, areaDict, areaWinDict):
        # Calculates the heat flux for the top-most horizontal surface
        surf = Surface()
        A_total = surf.get_A(surface, areaDict, areaWinDict)
        A_noOp = surf.get_A_noOp(surface, areaDict, areaWinDict)
        T_space = spaces_dict[space.obj_id][1]
        T2 = temp_record[surface.obj_id +
                         "_inside_surface-1"]  # A2 in Nas new set of code
        T3 = temp_record[surface.obj_id +
                         "_outside_surface-1"]  # A1 in Nas new set of code
        T1 = weather["t_outside"]
        #print T2

        # need the surface related information, T_space, U, R3
        U = surf.get_U_surface_e(A_total, A_noOp, surface, areaWinDict)
        R3 = 1 / U
        # Using calculations from: self.surface.constr.layer.C
        C = surf.get_C_surface(A_total, A_noOp, surface, Coeff, areaWinDict)
        #print C
        dt = 3600
        C2 = C / 2
        C4 = C / 2

        #if weather["hour"] == 8:
        #print weather.hour

        if surface.adjacent_space_id == "none":  # If there is not an adjacent space use current space temperature
            T_space2 = T_space
            space2 = space.obj_id
        else:  # If there is an adjacent space use the temperature of that space
            # Eventually may have to loop to consider spanning shared surfaces, but there's only be one option now...
            space2 = surface.adjacent_space_id
            T_space2 = spaces_dict[space2][1]

        #print "lookup: ", space2

        transmitted_space2 = G_space_record[space2]
        #T_in = round(transmitted_space2, 6)
        hc1 = 4.04  # T_space-AnoOp > T_in
        hc2 = 0.948  # T_space-AnoOp > T_out
        R5 = 1 / hc2
        R1 = 1 / hc1

        #print ((C2*T3/dt+T_space/R1)*R3)
        # T_in is the interior surface temperature in the space that we pick
        T_in = (transmitted_space2 + C4 * T2 / dt + T_space2 / R5 +
                (C4 / dt + 1 / R3 + 1 / R5) *
                (C2 * T3 / dt + T_space / R1) * R3) / (
                    (C4 / dt + 1 / R3 + 1 / R5) *
                    (C2 / dt + 1 / R3 + 1 / R1) * R3 - 1 / R3)
        #T_in = (Transmitted_space+C4*A2/dt+T_space2/R5+(C4/dt+1/R3+1/R5)*(C2*A1/dt+T_space/R1)*R3)/  ((C4/dt+1/R3+1/R5)*(C2/dt+1/R3+1/R1)*R3-1/R3);
        T_out = ((((C2 / dt) + (1 / R1) + (1 / R3)) * T_in) - (C2 / dt * T3) -
                 (T_space / R1)) * R3
        #T_out = ((  C2/dt+  1/R1+  1/R3)* T_in-  C2/dt*A1-  T_space/R1)*R3;
        #print T_in
        #T_in = round(T_in, 6)
        #T_out = round(T_out, 6)

        if T_in > T_space and T_out > T_space2:
            hc1 = 0.948
            hc2 = 4.04
            R5 = 1 / hc2
            R1 = 1 / hc1
            # T_in is the interior surface temperature in the space that we pick
            T_in = (transmitted_space2 + C4 * T2 / dt + T_space2 / R5 +
                    (C4 / dt + 1 / R3 + 1 / R5) *
                    (C2 * T3 / dt + T_space / R1) * R3) / (
                        (C4 / dt + 1 / R3 + 1 / R5) *
                        (C2 / dt + 1 / R3 + 1 / R1) * R3 - 1 / R3)
            #T_in = ( Transmitted_space+C4*A2/dt+T_space2/R5+(C4/dt+1/R3+1/R5)*(C2*A1/dt+T_space/R1)*R3)/((C4/dt+1/R3+1/R5)*(C2/dt+1/R3+1/R1)*R3-1/R3);
            T_out = ((C2 / dt + 1 / R1 + 1 / R3) * T_in - C2 / dt * T3 -
                     T_space / R1) * R3
            #T_out = ((C2/dt+1/R1+1/R3)*T_in-C2/dt*A1-T_space/R1)*R3;
            #T_in = round(T_in, 6)
            #T_out = round(T_out, 6)
            #print "one", T_in #, T_space2, T_out, T_in
            #print transmitted_space2
        elif T_in > T_space and T_out < T_space2:
            hc1 = 0.948
            hc2 = 0.948
            R5 = 1 / hc2
            R1 = 1 / hc1
            # T_in is the interior surface temperature in the space that we pick
            T_in = (transmitted_space2 + C4 * T2 / dt + T_space2 / R5 +
                    (C4 / dt + 1 / R3 + 1 / R5) *
                    (C2 * T3 / dt + T_space / R1) * R3) / (
                        (C4 / dt + 1 / R3 + 1 / R5) *
                        (C2 / dt + 1 / R3 + 1 / R1) * R3 - 1 / R3)
            T_out = ((C2 / dt + 1 / R1 + 1 / R3) * T_in - C2 / dt * T3 -
                     T_space / R1) * R3
            #T_in = round(T_in, 6)
            #T_out = round(T_out, 6)
            #print "two", T_in #, T_space2, T_out, T_in
        else:  #T_in < T_space and T_out > T_space2:
            hc1 = 4.04
            hc2 = 4.04
            R5 = 1 / hc2
            R1 = 1 / hc1
            # T_in is the interior surface temperature in the space that we pick
            T_in = (transmitted_space2 + C4 * T2 / dt + T_space2 / R5 +
                    (C4 / dt + 1 / R3 + 1 / R5) *
                    (C2 * T3 / dt + T_space / R1) * R3) / (
                        (C4 / dt + 1 / R3 + 1 / R5) *
                        (C2 / dt + 1 / R3 + 1 / R1) * R3 - 1 / R3)
            T_out = ((C2 / dt + 1 / R1 + 1 / R3) * T_in - C2 / dt * T3 -
                     T_space / R1) * R3
            #T_in = round(T_in, 6)
            #T_out = round(T_out, 6)
            #print "three", T_in #, T_space2, T_out, T_in

        # Update temp_record dictionary
        # Add the newly calculated numbers into the dictionary:
        temp_record[surface.obj_id + "_outside_surface"] = T_out
        temp_record[surface.obj_id + "_inside_surface"] = T_in
        #print T_out, T_in

        # from: Q_top =  hc1 * A *(T_in-T_space)
        #Q_top = round(hc1 * A_total * (T_in-T_space), 6)
        Q_top = hc1 * A_total * (T_in - T_space)

        return Q_top
Ejemplo n.º 8
0
    def get_floor_heat(self, space, surface, weather, G_space, spaces_dict,
                       A_noOp_floor, temp_record, Coeff, areaDict,
                       areaWinDict):
        # for a top roof / interiorfloor, the transmitted solar energy of another- the side also need to be calculated
        surf = Surface()
        A_total = surf.get_A(surface, areaDict, areaWinDict)
        A_noOp = surf.get_A_noOp(surface, areaDict, areaWinDict)

        T_space = spaces_dict[space.obj_id][1]
        T2 = temp_record[surface.obj_id + "_inside_surface-1"]
        T3 = temp_record[surface.obj_id + "_outside_surface-1"]
        T1 = weather["t_outside"]
        ground_temp = (T_space - 2)

        # Using calculations from: self.surface.constr.layer.C
        C = surf.get_C_surface(A_total, A_noOp, surface, Coeff, areaWinDict)
        #print C

        if surface.adjacent_space_id == "none":  # If there is not an adjacent space use current space temperature
            T_space2 = T_space
            space2 = space.obj_id
        else:  # If there is an adjacent space use the temperature of that space
            # Eventually may have to loop to consider spanning shared surfaces, but there's only be one option now...
            space2 = surface.adjacent_space_id
            T_space2 = spaces_dict[space2][1]

        # need the surface related information, T_space, U, R3
        #A_noOp_floor = surf.get_A_noOp(current_floor)
        U = surf.get_U_surface_e(A_total, A_noOp, surface, areaWinDict)
        R3 = 1 / U
        dt = 3600

        #print surface.obj_id, surface.adjacent_space_id

        if surface.adjacent_space_id == "none":
            # Means there is no adjacent space or space temp so thus the floor must be the bottom floor
            # assuming it is reduced convection T_space1 > T2
            #print surface.obj_id
            hc1 = 0.948
            R5 = 1 / hc1
            A1 = C / dt * T2 + T_space / R5 + ground_temp / R3 + G_space
            A2 = C / dt + 1 / R5 + 1 / R3
            T_in = A1 / A2
            #print T_in
            if T_space < T_in:
                hc1 = 4.04
                R5 = 1 / hc1
                A1 = C / dt * T2 + T_space / R5 + ground_temp / R3 + G_space
                A2 = C / dt + 1 / R5 + 1 / R3
                T_in = A1 / A2
            T_out = ground_temp
            #T_in = round(T_in, 6)
            #T_out = round(T_out, 6)
        else:
            #print surface.obj_id
            # This is an Intermediate Floor, so it will have an adjacent space temp T_space2
            C2 = C / 2
            C4 = C / 2
            # else continues but indents seem to make the following outside of this else...???
            #h_space = self.get_height_floorspace(surface)
            #h_surface = self.get_height(surface)
            #print "h_space: ", h_space
            #print "h_surface: ", h_surface
            hc1 = 0.948  # T_space-AnoOp > T_in
            hc2 = 4.04  # T_space-AnoOp > T_out
            R5 = 1 / hc2
            R1 = 1 / hc1
            T_in = (C4 * T3 / dt + T_space2 / R5 +
                    (C4 / dt + 1 / R3 + 1 / R5) *
                    (C2 * T2 / dt + T_space / R1 + G_space) * R3) / (
                        (C4 / dt + 1 / R3 + 1 / R5) *
                        (C2 / dt + 1 / R3 + 1 / R1) * R3 - 1 / R3)
            T_out = (C2 * T2 / dt + T_space / R1 +
                     (C2 / dt + 1 / R3 + 1 / R1) *
                     (C4 * T3 / dt + T_space2 / R5) * R3) / (
                         (C4 / dt + 1 / R3 + 1 / R5) *
                         (C2 / dt + 1 / R3 + 1 / R1) * R3 - 1 / R3)
            #T_in = round(T_in, 6)
            #T_out = round(T_out, 6)

            #if h_space == h_surface:
            #    # if the interiorfloor is the space's floor
            #    hc1 = 0.948   # T_space-AnoOp > T_in
            #    hc2 = 4.04  # T_space-AnoOp > T_out
            #    R5 = 1/hc2
            #    R1 = 1/hc1
            # T_in is the interior surface temperature in the space that we pick, or of the current_space
            #    T_in = (C4*T2/dt+T_space2/R5+(C4/dt+1/R3+1/R5)*(C2*T3/dt+T_space/R1+G_space)*R3)/((C4/dt+1/R3+1/R5)*(C2/dt+1/R3+1/R1)*R3-1/R3)
            #    T_out = (C2*T3/dt+T_space/R1+(C2/dt+1/R3+1/R1)*(C4*T2/dt+T_space2/R5)*R3)/((C4/dt+1/R3+1/R5)*(C2/dt+1/R3+1/R1)*R3-1/R3)
            if T_in > T_space and T_out > T_space2:
                hc1 = 4.04
                hc2 = 0.948
                R5 = 1 / hc2
                R1 = 1 / hc1
                # T_in is the interior surface temperature in the space that we pick
                T_in = (C4 * T3 / dt + T_space2 / R5 +
                        (C4 / dt + 1 / R3 + 1 / R5) *
                        (C2 * T2 / dt + T_space / R1 + G_space) * R3) / (
                            (C4 / dt + 1 / R3 + 1 / R5) *
                            (C2 / dt + 1 / R3 + 1 / R1) * R3 - 1 / R3)
                T_out = (C2 * T2 / dt + T_space / R1 +
                         (C2 / dt + 1 / R3 + 1 / R1) *
                         (C4 * T3 / dt + T_space2 / R5) * R3) / (
                             (C4 / dt + 1 / R3 + 1 / R5) *
                             (C2 / dt + 1 / R3 + 1 / R1) * R3 - 1 / R3)
                #T_in = round(T_in, 6)
                #T_out = round(T_out, 6)
                #print "one", T_in
            elif T_in > T_space and T_out < T_space2:
                hc1 = 4.04
                hc2 = 4.04
                R5 = 1 / hc2
                R1 = 1 / hc1
                # T_in is the interior surface temperature in the space that we pick
                T_in = (C4 * T3 / dt + T_space2 / R5 +
                        (C4 / dt + 1 / R3 + 1 / R5) *
                        (C2 * T2 / dt + T_space / R1 + G_space) * R3) / (
                            (C4 / dt + 1 / R3 + 1 / R5) *
                            (C2 / dt + 1 / R3 + 1 / R1) * R3 - 1 / R3)
                T_out = (C2 * T2 / dt + T_space / R1 +
                         (C2 / dt + 1 / R3 + 1 / R1) *
                         (C4 * T3 / dt + T_space2 / R5) * R3) / (
                             (C4 / dt + 1 / R3 + 1 / R5) *
                             (C2 / dt + 1 / R3 + 1 / R1) * R3 - 1 / R3)
                #T_in = round(T_in, 6)
                #T_out = round(T_out, 6)
                #print "two", T_in
            else:  # T_in < T_space and T_out > T_space2:  # This was what was intended, but will cause the else below to trigger if not left in the current format...
                hc1 = 0.948
                hc2 = 0.948
                R5 = 1 / hc2
                R1 = 1 / hc1
                # T_in is the interior surface temperature in the space that we pick
                T_in = (C4 * T3 / dt + T_space2 / R5 +
                        (C4 / dt + 1 / R3 + 1 / R5) *
                        (C2 * T2 / dt + T_space / R1 + G_space) * R3) / (
                            (C4 / dt + 1 / R3 + 1 / R5) *
                            (C2 / dt + 1 / R3 + 1 / R1) * R3 - 1 / R3)
                T_out = (C2 * T2 / dt + T_space / R1 +
                         (C2 / dt + 1 / R3 + 1 / R1) *
                         (C4 * T3 / dt + T_space2 / R5) * R3) / (
                             (C4 / dt + 1 / R3 + 1 / R5) *
                             (C2 / dt + 1 / R3 + 1 / R1) * R3 - 1 / R3)
                #T_in = round(T_in, 6)
                #T_out = round(T_out, 6)
                #print "three", T_in
            #else:
            #    print "Surface Floor Not Found matching case?: ", surface.obj_id, surface.obj_type
            #    if surface.obj_id not in missing_surfaces:
            #        missing_surfaces[surface.obj_id] = surface.obj_type
            #    #raise Exception("Did not meet any condition in get_floor_heat() for surface id: ", surface.obj_id)

        # Update temp_record dictionary
        # Add the newly calculated numbers into the dictionary:
        temp_record[surface.obj_id + "_outside_surface"] = T_out
        temp_record[surface.obj_id + "_inside_surface"] = T_in
        temp_record[surface.obj_id + "_outside_surface-1"] = T_out
        temp_record[surface.obj_id + "_inside_surface-1"] = T_in

        #Q_floor = round(hc1 * A_total * (T_in-T_space), 6)
        Q_floor = hc1 * A_total * (T_in - T_space)
        #print A_total

        return Q_floor