def test_windowSolarGains(self):

        hoy = 3993
        # 9:00 am 16 June 2015

        Zurich = Location(epwfile_path=os.path.join(
            mainPath, 'auxiliary', 'Zurich-Kloten_2013.epw'))
        Altitude, Azimuth = Zurich.calc_sun_position(
            latitude_deg=47.480, longitude_deg=8.536, year=2015, hoy=hoy)

        SouthWindow = Window(azimuth_tilt=0, alititude_tilt=90, glass_solar_transmittance=0.7,
                             glass_light_transmittance=0.8, area=1)
        EastWindow = Window(azimuth_tilt=90, alititude_tilt=90, glass_solar_transmittance=0.7,
                            glass_light_transmittance=0.8, area=1)
        WestWindow = Window(azimuth_tilt=180, alititude_tilt=90, glass_solar_transmittance=0.7,
                            glass_light_transmittance=0.8, area=1)
        NorthWindow = Window(azimuth_tilt=270, alititude_tilt=90, glass_solar_transmittance=0.7,
                             glass_light_transmittance=0.8, area=1)
        RoofAtrium = Window(azimuth_tilt=0, alititude_tilt=0, glass_solar_transmittance=0.7,
                            glass_light_transmittance=0.8, area=1)

        for selected_window in [SouthWindow, EastWindow, WestWindow, NorthWindow, RoofAtrium]:

            selected_window.calc_solar_gains(sun_altitude=Altitude, sun_azimuth=Azimuth,
                                             normal_direct_radiation=Zurich.weather_data[
                                                 'dirnorrad_Whm2'][hoy],
                                             horizontal_diffuse_radiation=Zurich.weather_data['difhorrad_Whm2'][hoy])

            selected_window.calc_illuminance(sun_altitude=Altitude, sun_azimuth=Azimuth,
                                             normal_direct_illuminance=Zurich.weather_data[
                                                 'dirnorillum_lux'][hoy],
                                             horizontal_diffuse_illuminance=Zurich.weather_data['difhorillum_lux'][hoy])

        self.assertEqual(round(SouthWindow.incident_solar, 2), 315.85)
        self.assertEqual(round(EastWindow.incident_solar, 2), 570.06)
        self.assertEqual(round(WestWindow.incident_solar, 2), 58.0)
        self.assertEqual(round(NorthWindow.incident_solar, 2), 58.0)
        self.assertEqual(round(RoofAtrium.incident_solar, 2), 1113.72)

        self.assertEqual(round(SouthWindow.solar_gains, 2), 221.1)
        self.assertEqual(round(EastWindow.solar_gains, 2), 399.04)
        self.assertEqual(round(WestWindow.solar_gains, 2), 40.6)
        self.assertEqual(round(NorthWindow.solar_gains, 2), 40.6)
        self.assertEqual(round(RoofAtrium.solar_gains, 2), 779.61)

        self.assertEqual(
            round(SouthWindow.transmitted_illuminance, 2), 27330.46)
        self.assertEqual(
            round(EastWindow.transmitted_illuminance, 2), 47989.19)
        self.assertEqual(round(WestWindow.transmitted_illuminance, 2), 6375.2)
        self.assertEqual(round(NorthWindow.transmitted_illuminance, 2), 6375.2)
        self.assertEqual(
            round(RoofAtrium.transmitted_illuminance, 2), 93833.62)
Example #2
0
def calculate_sun_angles():
    Zurich = Location(epwfile_path=os.path.join(mainPath, 'auxiliary',
                                                'Zurich-Kloten_2013.epw'))

    Zurich.calc_sun_position(latitude_deg=47.480,
                             longitude_deg=8.536,
                             year=2015,
                             hoy=3708)

    Azimuth = []
    Altitude = []
    Sunnyhoy = []

    for hoy in range(8760):
        sun = Zurich.calc_sun_position(latitude_deg=47.480,
                                       longitude_deg=8.536,
                                       year=2015,
                                       hoy=hoy)
        Altitude.append(sun[0])
        Azimuth.append(sun[1])
        Sunnyhoy.append(hoy + 1)

    sunPosition = pd.read_csv(os.path.join(mainPath, 'auxiliary',
                                           'SunPosition.csv'),
                              skiprows=1)

    transSunPos = sunPosition.transpose()
    hoy_check = transSunPos.index.tolist()
    hoy_check = [float(ii) for ii in hoy_check]
    Azimuth_check = (180 - transSunPos[1]).tolist()

    Altitude_check = transSunPos[0].tolist()

    plt.style.use('ggplot')

    plt.plot(Sunnyhoy, Azimuth, hoy_check, Azimuth_check, Sunnyhoy, Altitude,
             hoy_check, Altitude_check)
    plt.legend(['Azimuth', 'Azimuth Check', 'Altitude', 'Altitude_check'])

    plt.show()
def calculate_sun_angles():
    Zurich = Location(epwfile_path=os.path.join(
        mainPath, 'auxiliary', 'Zurich-Kloten_2013.epw'))


    Zurich.calc_sun_position(latitude_deg=47.480, longitude_deg=8.536, year=2015, hoy=3708)


    Azimuth = []
    Altitude = []
    Sunnyhoy = []

    for hoy in range(8760):
        sun = Zurich.calc_sun_position(
            latitude_deg=47.480, longitude_deg=8.536, year=2015, hoy=hoy)
        Altitude.append(sun[0])
        Azimuth.append(sun[1])
        Sunnyhoy.append(hoy + 1)

    sunPosition = pd.read_csv(os.path.join(
        mainPath, 'auxiliary', 'SunPosition.csv'), skiprows=1)

    transSunPos = sunPosition.transpose()
    hoy_check = transSunPos.index.tolist()
    hoy_check = [float(ii) for ii in hoy_check]
    Azimuth_check = (180 - transSunPos[1]).tolist()

    Altitude_check = transSunPos[0].tolist()

    plt.style.use('ggplot')

    plt.plot(Sunnyhoy, Azimuth, hoy_check, Azimuth_check,
             Sunnyhoy, Altitude, hoy_check, Altitude_check)
    plt.legend(['Azimuth', 'Azimuth Check', 'Altitude', 'Altitude_check'])

    plt.show()
Example #4
0
    def test_sunPosition(self):

        Zurich = Location(epwfile_path=os.path.join(mainPath, 'auxiliary',
                                                    'Zurich-Kloten_2013.epw'))

        Azimuth = []
        Altitude = []
        Sunnyhoy = []

        for hoy in range(8760):
            angles = Zurich.calc_sun_position(latitude_deg=47.480,
                                              longitude_deg=8.536,
                                              year=2015,
                                              hoy=hoy)

            Altitude.append(angles[0])
            Azimuth.append(angles[1])
            Sunnyhoy.append(hoy + 1)

        sunPosition = pd.read_csv(os.path.join(mainPath, 'auxiliary',
                                               'SunPosition.csv'),
                                  skiprows=1)

        transSunPos = sunPosition.transpose()
        hoy_check = transSunPos.index.tolist()
        hoy_check = [float(ii) for ii in hoy_check]
        Azimuth_check = (180 - transSunPos[1]).tolist()

        Altitude_check = transSunPos[0].tolist()

        self.assertEqual(round(Altitude[9], 1), round(Altitude_check[1], 1))
        self.assertEqual(round(Azimuth[9], 1), round(Azimuth_check[1], 1))

        self.assertEqual(round(Altitude[3993], 1),
                         round(Altitude_check[2023], 1))
        self.assertEqual(round(Azimuth[3993], 1),
                         round(Azimuth_check[2023], 1))

        # Azimuth Angles go out of sync with data, however the sin and cosine
        # must still match
        self.assertEqual(round(Altitude[4000], 1),
                         round(Altitude_check[2030], 1))
        self.assertEqual(round(math.cos(math.radians(Azimuth[4000])), 1),
                         round(math.cos(math.radians(Azimuth_check[2030])), 1))
        self.assertEqual(round(math.sin(math.radians(Azimuth[4000])), 1),
                         round(math.sin(math.radians(Azimuth_check[2030])), 1))
    def test_sunPosition(self):

        Zurich = Location(epwfile_path=os.path.join(
            mainPath, 'auxiliary', 'Zurich-Kloten_2013.epw'))

        Azimuth = []
        Altitude = []
        Sunnyhoy = []

        for hoy in range(8760):
            angles = Zurich.calc_sun_position(
                latitude_deg=47.480, longitude_deg=8.536, year=2015, hoy=hoy)

            Altitude.append(angles[0])
            Azimuth.append(angles[1])
            Sunnyhoy.append(hoy + 1)

        sunPosition = pd.read_csv(os.path.join(
            mainPath, 'auxiliary', 'SunPosition.csv'), skiprows=1)

        transSunPos = sunPosition.transpose()
        hoy_check = transSunPos.index.tolist()
        hoy_check = [float(ii) for ii in hoy_check]
        Azimuth_check = (180 - transSunPos[1]).tolist()

        Altitude_check = transSunPos[0].tolist()

        self.assertEqual(round(Altitude[9], 1), round(Altitude_check[1], 1))
        self.assertEqual(round(Azimuth[9], 1), round(Azimuth_check[1], 1))

        self.assertEqual(round(Altitude[3993], 1),
                         round(Altitude_check[2023], 1))
        self.assertEqual(round(Azimuth[3993], 1),
                         round(Azimuth_check[2023], 1))

        # Azimuth Angles go out of sync with data, however the sin and cosine
        # must still match
        self.assertEqual(round(Altitude[4000], 1),
                         round(Altitude_check[2030], 1))
        self.assertEqual(round(math.cos(math.radians(Azimuth[4000])), 1), round(
            math.cos(math.radians(Azimuth_check[2030])), 1))
        self.assertEqual(round(math.sin(math.radians(Azimuth[4000])), 1), round(
            math.sin(math.radians(Azimuth_check[2030])), 1))
Example #6
0
# Starting temperature of the builidng
t_m_prev = 20

# Loop through all 8760 hours of the year
for hour in range(8760):

    # Occupancy for the time step
    occupancy = occupancyProfile.loc[hour, 'People'] * max_occupancy
    # Gains from occupancy and appliances
    internal_gains = occupancy * gain_per_person + \
        appliance_gains * Office.floor_area

    # Extract the outdoor temperature in Zurich for that hour
    t_out = Zurich.weather_data['drybulb_C'][hour]

    Altitude, Azimuth = Zurich.calc_sun_position(
        latitude_deg=47.480, longitude_deg=8.536, year=2015, hoy=hour)

    SouthWindow.calc_solar_gains(sun_altitude=Altitude, sun_azimuth=Azimuth,
                                 normal_direct_radiation=Zurich.weather_data[
                                     'dirnorrad_Whm2'][hour],
                                 horizontal_diffuse_radiation=Zurich.weather_data['difhorrad_Whm2'][hour])

    SouthWindow.calc_illuminance(sun_altitude=Altitude, sun_azimuth=Azimuth,
                                 normal_direct_illuminance=Zurich.weather_data[
                                     'dirnorillum_lux'][hour],
                                 horizontal_diffuse_illuminance=Zurich.weather_data['difhorillum_lux'][hour])

    Office.solve_energy(internal_gains=internal_gains,
                        solar_gains=SouthWindow.solar_gains,
                        t_out=t_out,
                        t_m_prev=t_m_prev)
Example #7
0
    def test_windowSolarGains(self):

        hoy = 3993
        # 9:00 am 16 June 2015

        Zurich = Location(epwfile_path=os.path.join(mainPath, 'auxiliary',
                                                    'Zurich-Kloten_2013.epw'))
        Altitude, Azimuth = Zurich.calc_sun_position(latitude_deg=47.480,
                                                     longitude_deg=8.536,
                                                     year=2015,
                                                     hoy=hoy)

        SouthWindow = Window(azimuth_tilt=0,
                             alititude_tilt=90,
                             glass_solar_transmittance=0.7,
                             glass_light_transmittance=0.8,
                             area=1)
        EastWindow = Window(azimuth_tilt=90,
                            alititude_tilt=90,
                            glass_solar_transmittance=0.7,
                            glass_light_transmittance=0.8,
                            area=1)
        WestWindow = Window(azimuth_tilt=180,
                            alititude_tilt=90,
                            glass_solar_transmittance=0.7,
                            glass_light_transmittance=0.8,
                            area=1)
        NorthWindow = Window(azimuth_tilt=270,
                             alititude_tilt=90,
                             glass_solar_transmittance=0.7,
                             glass_light_transmittance=0.8,
                             area=1)
        RoofAtrium = Window(azimuth_tilt=0,
                            alititude_tilt=0,
                            glass_solar_transmittance=0.7,
                            glass_light_transmittance=0.8,
                            area=1)

        for selected_window in [
                SouthWindow, EastWindow, WestWindow, NorthWindow, RoofAtrium
        ]:

            selected_window.calc_solar_gains(
                sun_altitude=Altitude,
                sun_azimuth=Azimuth,
                normal_direct_radiation=Zurich.weather_data['dirnorrad_Whm2']
                [hoy],
                horizontal_diffuse_radiation=Zurich.
                weather_data['difhorrad_Whm2'][hoy])

            selected_window.calc_illuminance(
                sun_altitude=Altitude,
                sun_azimuth=Azimuth,
                normal_direct_illuminance=Zurich.
                weather_data['dirnorillum_lux'][hoy],
                horizontal_diffuse_illuminance=Zurich.
                weather_data['difhorillum_lux'][hoy])

        self.assertEqual(round(SouthWindow.incident_solar, 2), 315.85)
        self.assertEqual(round(EastWindow.incident_solar, 2), 570.06)
        self.assertEqual(round(WestWindow.incident_solar, 2), 58.0)
        self.assertEqual(round(NorthWindow.incident_solar, 2), 58.0)
        self.assertEqual(round(RoofAtrium.incident_solar, 2), 855.87)

        self.assertEqual(round(SouthWindow.solar_gains, 2), 221.1)
        self.assertEqual(round(EastWindow.solar_gains, 2), 399.04)
        self.assertEqual(round(WestWindow.solar_gains, 2), 40.6)
        self.assertEqual(round(NorthWindow.solar_gains, 2), 40.6)
        self.assertEqual(round(RoofAtrium.solar_gains, 2), 599.11)

        self.assertEqual(round(SouthWindow.transmitted_illuminance, 2),
                         27330.46)
        self.assertEqual(round(EastWindow.transmitted_illuminance, 2),
                         47989.19)
        self.assertEqual(round(WestWindow.transmitted_illuminance, 2), 6375.2)
        self.assertEqual(round(NorthWindow.transmitted_illuminance, 2), 6375.2)
        self.assertEqual(round(RoofAtrium.transmitted_illuminance, 2),
                         72878.36)
Example #8
0
    # Loop through all 8760 hours of the year
    for hour in range(8760):

        # Occupancy for the time step
        occupancy = occupancyProfile.loc[hour, 'People'] * max_occupancy
        appliance = occupancyProfile.loc[hour, 'People'] * appliance_gains
        lighting = occupancyProfile.loc[hour, 'People'] * lighting_gains
        # Gains from occupancy and appliances
        internal_gains = occupancy * gain_per_person + \
            appliance * Office.floor_area + lighting * Office.floor_area

        # Extract the outdoor temperature in Boston for that hour
        t_out = Boston.weather_data['drybulb_C'][hour]

        Altitude, Azimuth = Boston.calc_sun_position(latitude_deg=42.37,
                                                     longitude_deg=-71.02,
                                                     year=2019,
                                                     hoy=hour)

        SouthWindow.calc_solar_gains(
            sun_altitude=Altitude,
            sun_azimuth=Azimuth,
            normal_direct_radiation=Boston.weather_data['dirnorrad_Whm2']
            [hour],
            horizontal_diffuse_radiation=Boston.weather_data['difhorrad_Whm2']
            [hour])

        SouthWindow.calc_illuminance(
            sun_altitude=Altitude,
            sun_azimuth=Azimuth,
            normal_direct_illuminance=Boston.weather_data['dirnorillum_lux']
            [hour],
Example #9
0
    def run_rc_simulation(self, weatherfile_path, occupancy_path,
                          cooling_setpoint):
        """
        ACHTUNG. Im Vergleich zum SIA Modul sind hier im Moment noch Wh als output zu finden.
        :param weatherfile_path:
        :param occupancy_path:
        :return:
        """
        standard_raumtemperaturen = {
            1: 20.,
            2: 20.,
            3: 20.,
            4: 20.,
            5: 20.,
            6: 20,
            7: 20,
            8: 22,
            9: 18,
            10: 18,
            11: 18,
            12: 28
        }  # 380-1 Tab7
        warmeabgabe_p_p = {
            1: 70.,
            2: 70.,
            3: 80.,
            4: 70.,
            5: 90.,
            6: 100.,
            7: 80.,
            8: 80.,
            9: 100.,
            10: 100.,
            11: 100.,
            12: 60.
        }  # 380-1 Tab10 (W)

        elektrizitatsbedarf = {
            1: 28.,
            2: 22.,
            3: 22.,
            4: 11.,
            5: 33.,
            6: 33.,
            7: 17.,
            8: 28.,
            9: 17.,
            10: 6.,
            11: 6.,
            12: 56.
        }  # 380-1 Tab12 (kWh/m2a)

        personenflachen = {
            1: 40.,
            2: 60.,
            3: 20.,
            4: 10.,
            5: 10.,
            6: 5,
            7: 5.,
            8: 30.,
            9: 20.,
            10: 100.,
            11: 20.,
            12: 20.
        }  # 380-1 Tab9

        aussenluft_strome = {
            1: 0.7,
            2: 0.7,
            3: 0.7,
            4: 0.7,
            5: 0.7,
            6: 1.2,
            7: 1.0,
            8: 1.0,
            9: 0.7,
            10: 0.3,
            11: 0.7,
            12: 0.7
        }  # 380-1 Tab14
        # aussenluft_strome = {1:2.1}

        annual_dhw_demand = {
            1.1: 19.8,
            1.2: 13.5,
            2.1: 39.5,
            2.2: 0.,
            3.1: 3.6,
            3.2: 3.6,
            3.3: 0.0,
            3.4: 0.0,
            4.1: 5.3,
            4.2: 0.0,
            4.3: 0.0,
            4.4: 7.9,
            5.1: 2.7,
            5.2: 2.7,
            5.3: 1.5,
            6.1: 108.9,
            7.1: 7.3,
            7.2: 7.3,
            8.1: 67.7,
            8.2: 0.0,
            8.3: 0.0,
            9.1: 2.4,
            9.2: 2.4,
            9.3: 2.4,
            10.1: 0.9,
            11.1: 52.9,
            11.2: 87.1,
            12: None
        }
        # in kWh/m2a according to SIA2024 possbily needs to be changed to SIA 385/2

        self.t_set_heating = standard_raumtemperaturen[int(
            self.gebaeudekategorie_sia)]
        Loc = Location(epwfile_path=weatherfile_path)
        gain_per_person = warmeabgabe_p_p[int(
            self.gebaeudekategorie_sia)]  # W/m2
        appliance_gains = elektrizitatsbedarf[int(
            self.gebaeudekategorie_sia
        )] / 365 / 24  # W per sqm (constant over the year)
        max_occupancy = self.energy_reference_area / personenflachen[int(
            self.gebaeudekategorie_sia)]
        self.ach_vent = aussenluft_strome[int(
            self.gebaeudekategorie_sia
        )] / self.room_height  # here we switch from SIA m3/hm2 to air change rate /h
        heating_supply_system = dp.translate_system_sia_to_rc(
            self.heating_system)
        cooling_supply_system = dp.translate_system_sia_to_rc(
            self.cooling_system)
        self.annual_dhw_demand = annual_dhw_demand[
            self.
            gebaeudekategorie_sia] * 1000  # Sia calculates in kWh, RC Simulator in Wh

        Office = Building(
            window_area=self.window_area,
            external_envelope_area=self.external_envelope_area,
            room_depth=self.room_depth,
            room_width=self.room_width,
            room_height=self.room_height,
            lighting_load=self.lighting_load,
            lighting_control=self.lighting_control,
            lighting_utilisation_factor=self.lighting_utilisation_factor,
            lighting_maintenance_factor=self.lighting_maintenance_factor,
            u_walls=self.u_walls,
            u_windows=self.u_windows,
            ach_vent=self.ach_vent,
            ach_infl=self.ach_infl,
            ventilation_efficiency=self.ventilation_efficiency,
            thermal_capacitance_per_floor_area=self.
            thermal_capacitance_per_floor_area * 3600 *
            1000,  # Comes as kWh/m2K and needs to be J/m2K
            t_set_heating=self.t_set_heating,
            t_set_cooling=
            cooling_setpoint,  # maybe this can be added to the simulation object as well
            max_cooling_energy_per_floor_area=self.
            max_cooling_energy_per_floor_area,
            max_heating_energy_per_floor_area=self.
            max_heating_energy_per_floor_area,
            heating_supply_system=heating_supply_system,
            cooling_supply_system=cooling_supply_system,
            heating_emission_system=emission_system.
            FloorHeating,  # define this!
            cooling_emission_system=emission_system.
            AirConditioning,  # define this!
            dhw_supply_temperature=self.dhw_supply_temperature,
        )

        SouthWindow = Window(
            azimuth_tilt=0.,
            alititude_tilt=90.0,
            glass_solar_transmittance=self.g_windows,
            glass_light_transmittance=0.5,
            area=self.window_area)  # az and alt are hardcoded because
        # they are assumed to be vertical south facing windows (IMPROVE!)

        # RoofPV = PhotovoltaicSurface(azimuth_tilt=pv_azimuth, alititude_tilt=pv_tilt, stc_efficiency=pv_efficiency,
        #                              performance_ratio=0.8, area=pv_area)  # Performance ratio is still hard coded.
        # Temporarily disabled. Add again later

        ## Define occupancy
        occupancyProfile = pd.read_csv(occupancy_path)

        t_m_prev = 20.0  # This is only for the very first step in therefore is hard coded.

        self.electricity_demand = np.empty(8760)
        self.total_heat_demand = np.empty(8760)
        self.heating_electricity_demand = np.empty(8760)
        self.heating_fossil_demand = np.empty(8760)
        self.heating_demand = np.empty(8760)
        self.cooling_electricity_demand = np.empty(8760)
        self.cooling_fossil_demand = np.empty(8760)
        self.cooling_demand = np.empty(8760)
        self.dhw_electricity_demand = np.empty(8760)
        self.dhw_fossil_demand = np.empty(8760)
        self.dhw_demand = np.empty(8760)
        self.solar_gains = np.empty(8760)
        self.indoor_temperature = np.empty(8760)

        for hour in range(8760):
            # Occupancy for the time step
            occupancy = occupancyProfile.loc[hour, 'People'] * max_occupancy
            # Gains from occupancy and appliances
            internal_gains = occupancy * gain_per_person + appliance_gains * Office.floor_area

            # Domestic hot water schedule  ### add this in a later stage
            dhw_demand = self.annual_dhw_demand / occupancyProfile['People'].sum()\
                         * occupancyProfile.loc[hour, 'People'] * self.energy_reference_area # Wh

            # Extract the outdoor temperature in Zurich for that hour
            t_out = Loc.weather_data['drybulb_C'][hour]

            Altitude, Azimuth = Loc.calc_sun_position(latitude_deg=47.480,
                                                      longitude_deg=8.536,
                                                      year=2015,
                                                      hoy=hour)

            SouthWindow.calc_solar_gains(
                sun_altitude=Altitude,
                sun_azimuth=Azimuth,
                normal_direct_radiation=Loc.weather_data['dirnorrad_Whm2']
                [hour],
                horizontal_diffuse_radiation=Loc.weather_data['difhorrad_Whm2']
                [hour])

            SouthWindow.calc_illuminance(
                sun_altitude=Altitude,
                sun_azimuth=Azimuth,
                normal_direct_illuminance=Loc.weather_data['dirnorillum_lux']
                [hour],
                horizontal_diffuse_illuminance=Loc.
                weather_data['difhorillum_lux'][hour])

            Office.solve_building_energy(internal_gains=internal_gains,
                                         solar_gains=SouthWindow.solar_gains,
                                         t_out=t_out,
                                         t_m_prev=t_m_prev,
                                         dhw_demand=dhw_demand)

            Office.solve_building_lighting(
                illuminance=SouthWindow.transmitted_illuminance,
                occupancy=occupancy)

            # Set the previous temperature for the next time step

            t_m_prev = Office.t_m_next

            self.heating_electricity_demand[
                hour] = Office.heating_sys_electricity  # unit? heating electricity demand
            self.heating_fossil_demand[hour] = Office.heating_sys_fossils
            self.cooling_electricity_demand[
                hour] = Office.cooling_sys_electricity  # unit?
            self.cooling_fossil_demand[hour] = Office.cooling_sys_fossils
            self.solar_gains[hour] = SouthWindow.solar_gains
            self.electricity_demand[
                hour] = Office.heating_sys_electricity + Office.dhw_sys_electricity + Office.cooling_sys_electricity  # in Wh
            self.heating_demand[
                hour] = Office.heating_demand  # this is the actual heat emitted, unit?
            self.cooling_demand[hour] = Office.cooling_demand
            self.dhw_electricity_demand[hour] = Office.dhw_sys_electricity
            self.dhw_fossil_demand[hour] = Office.dhw_sys_fossils
            self.dhw_demand[hour] = dhw_demand
            self.indoor_temperature[hour] = Office.t_air
Example #10
0
def run_rc_asdfsimulation(
        external_envelope_area, window_area, room_width, room_depth,
        room_height, thermal_capacitance_per_floor_area, u_walls, u_windows,
        ach_vent, ach_infl, ventilation_efficiency,
        max_heating_energy_per_floor_area, max_cooling_energy_per_floor_area,
        pv_area, pv_efficiency, pv_tilt, pv_azimuth, lifetime, strom_mix,
        weatherfile_path, grid_decarbonization_factors, t_set_heating,
        t_set_cooling, annual_dhw_p_person, dhw_supply_temperature, use_type):

    Loc = Location(epwfile_path=weatherfile_path)

    ## Define constants

    gain_per_person = 100  # W per sqm (why is that per sqm when it says per person?)
    appliance_gains = 14  #W per sqm
    max_occupancy = 50  # number of occupants (could be simplified by using area per person values)
    floor_area = room_width * room_depth

    Office = Building(
        window_area=window_area,
        external_envelope_area=external_envelope_area,
        room_depth=room_depth,
        room_width=room_width,
        room_height=room_height,
        lighting_load=lighting_load,
        lighting_control=lighting_control,
        lighting_utilisation_factor=lighting_utilisation_factor,
        lighting_maintenance_factor=lighting_maintenance_factor,
        u_walls=u_walls,
        u_windows=u_windows,
        ach_vent=ach_vent,
        ach_infl=ach_infl,
        ventilation_efficiency=ventilation_efficiency,
        thermal_capacitance_per_floor_area=thermal_capacitance_per_floor_area,
        t_set_heating=t_set_heating,
        t_set_cooling=t_set_cooling,
        max_cooling_energy_per_floor_area=max_cooling_energy_per_floor_area[0],
        max_heating_energy_per_floor_area=max_heating_energy_per_floor_area[0],
        heating_supply_system=supply_system.ElectricHeating,
        cooling_supply_system=supply_system.
        DirectCooler,  # What can we choose here for purely electric case?
        heating_emission_system=emission_system.FloorHeating,
        cooling_emission_system=emission_system.AirConditioning,
        dhw_supply_temperature=dhw_supply_temperature,
    )

    SouthWindow = Window(azimuth_tilt=0.,
                         alititude_tilt=90.0,
                         glass_solar_transmittance=0.5,
                         glass_light_transmittance=0.5,
                         area=window_area)

    ## Define PV to this building

    RoofPV = PhotovoltaicSurface(
        azimuth_tilt=pv_azimuth,
        alititude_tilt=pv_tilt,
        stc_efficiency=pv_efficiency,
        performance_ratio=0.8,
        area=pv_area)  # Performance ratio is still hard coded.

    ## Define occupancy
    occupancyProfile = pd.read_csv(
        r"C:\Users\walkerl\Documents\code\RC_BuildingSimulator\rc_simulator\auxiliary\occupancy_office.csv"
    )

    ## Define embodied emissions: # In a later stage this could be included in the RC model "supply_system.py file"
    coeq_gshp = dp.embodied_emissions_heat_generation_kbob_per_kW(
        "gshp")  # kgCO2/kW ## zusätzlich automatisieren
    coeq_borehole = dp.embodied_emissions_borehole_per_m()  #kg/m
    coeq_ashp = dp.embodied_emissions_heat_generation_kbob_per_kW(
        "ashp")  # kgCO2/kW ## zusätzlich automatisieren
    coeq_underfloor_heating = dp.embodied_emissions_heat_emission_system_per_m2(
        "underfloor heating")  #kg/m2
    coeq_pv = dp.embodied_emissions_pv_per_kW()  # kg/kWp
    coeq_el_heater = dp.embodied_emissions_heat_generation_kbob_per_kW(
        "electric heater")  #kg/kW

    #electricity demand from appliances

    electric_appliances = dp.electric_appliances_sia(
        energy_reference_area=room_depth * room_width,
        type=use_type,
        value="ziel")

    #Starting temperature of the builidng:
    t_m_prev = 20.0  # This is only for the very first step in therefore is hard coded.

    # hourly_emission_factors = dp.build_yearly_emission_factors(strom_mix)
    # hourly_emission_factors = dp.build_monthly_emission_factors(strom_mix)
    hourly_emission_factors = dp.build_yearly_emission_factors(strom_mix)
    hourly_emission_factors = hourly_emission_factors * grid_decarbonization_factors.mean(
    )

    electricity_demand = np.empty(8760)
    pv_yield = np.empty(8760)
    total_heat_demand = np.empty(8760)
    heating_electricity_demand = np.empty(8760)
    heating_demand = np.empty(8760)
    cooling_electricity_demand = np.empty(8760)
    cooling_demand = np.empty(8760)
    solar_gains = np.empty(8760)
    indoor_temperature = np.empty(8760)

    for hour in range(8760):

        #Occupancy for the time step
        occupancy = occupancyProfile.loc[hour, 'People'] * max_occupancy
        #Gains from occupancy and appliances
        internal_gains = occupancy * gain_per_person + appliance_gains * Office.floor_area

        # Domestic hot water schedule
        dhw_demand = annual_dhw_p_person / occupancyProfile['People'].sum(
        ) * occupancy  # Wh

        #Extract the outdoor temperature in Zurich for that hour
        t_out = Loc.weather_data['drybulb_C'][hour]

        Altitude, Azimuth = Loc.calc_sun_position(latitude_deg=47.480,
                                                  longitude_deg=8.536,
                                                  year=2015,
                                                  hoy=hour)

        SouthWindow.calc_solar_gains(
            sun_altitude=Altitude,
            sun_azimuth=Azimuth,
            normal_direct_radiation=Loc.weather_data['dirnorrad_Whm2'][hour],
            horizontal_diffuse_radiation=Loc.weather_data['difhorrad_Whm2']
            [hour])

        SouthWindow.calc_illuminance(
            sun_altitude=Altitude,
            sun_azimuth=Azimuth,
            normal_direct_illuminance=Loc.weather_data['dirnorillum_lux']
            [hour],
            horizontal_diffuse_illuminance=Loc.weather_data['difhorillum_lux']
            [hour])

        RoofPV.calc_solar_yield(
            sun_altitude=Altitude,
            sun_azimuth=Azimuth,
            normal_direct_radiation=Loc.weather_data['dirnorrad_Whm2'][hour],
            horizontal_diffuse_radiation=Loc.weather_data['difhorrad_Whm2']
            [hour])

        Office.solve_building_energy(internal_gains=internal_gains,
                                     solar_gains=SouthWindow.solar_gains,
                                     t_out=t_out,
                                     t_m_prev=t_m_prev,
                                     dhw_demand=dhw_demand)

        Office.solve_building_lighting(
            illuminance=SouthWindow.transmitted_illuminance,
            occupancy=occupancy)

        #Set the previous temperature for the next time step

        t_m_prev = Office.t_m_next

        heating_electricity_demand[
            hour] = Office.heating_sys_electricity  # unit? heating electricity demand
        cooling_electricity_demand[
            hour] = Office.cooling_sys_electricity  # unit?
        solar_gains[hour] = SouthWindow.solar_gains
        electricity_demand[
            hour] = Office.heating_sys_electricity + Office.dhw_sys_electricity + Office.cooling_sys_electricity  # in Wh
        pv_yield[hour] = RoofPV.solar_yield  # in Wh
        heating_demand[
            hour] = Office.heating_demand  # this is the actual heat emitted, unit?
        cooling_demand[hour] = Office.cooling_demand
        indoor_temperature[hour] = Office.t_air

        total_heat_demand[hour] = Office.heating_demand + Office.dhw_demand

    electricity_demand = electricity_demand + electric_appliances

    max_required_heating_per_floor_area = max(
        heating_demand) / floor_area  # W/m2
    max_required_cooling_per_floor_area = min(
        cooling_demand) / floor_area  # W/m2

    net_electricity_demand = np.subtract(electricity_demand, pv_yield)

    net_self_consumption = np.empty(8760)
    for hour in range(8760):
        net_self_consumption[hour] = min(pv_yield[hour],
                                         electricity_demand[hour])

    # this is the ratio of electricity used to electricity produced and thus the emissions that are allocated to the building.
    # This is highly questionable, meaning, it is discussed a lot
    embodied_pv_ratio = net_self_consumption.sum() / pv_yield.sum()

    net_operational_emissions = np.multiply(net_electricity_demand / 1000.,
                                            hourly_emission_factors)
    operational_emissions = np.copy(net_operational_emissions)
    operational_emissions[operational_emissions < 0] = 0.00

    ## heat calculations:
    annual_normalized_heat_demand = heating_demand.sum() / 1000 / floor_area

    print("Annual_normalized_heat_demand:")
    print(annual_normalized_heat_demand)

    ## embodied emissions:    DO NOT YET USE THIS PART OF THE SIMULATION!!!!!
    #
    # #PV
    # kwp_pv = RoofPV.area * RoofPV.efficiency # = kWp
    # pv_embodied = kwp_pv*coeq_pv
    #
    #
    # # direct electrical
    # embodied_direct = coeq_el_heater * np.percentile(heating_electricity_demand, 97.5)/1000. \
    #                   + pv_embodied * embodied_pv_ratio #_embodied emissions of the electrical heating system
    #
    # # ASHP
    # ashp_power = np.percentile(heating_el_demands_list[1],97.5)/1000. #kW
    # ashp_embodied = coeq_ashp*ashp_power # kgCO2eq
    # underfloor_heating_embodied = coeq_underfloor_heating * Office_2X.floor_area # kgCO2eq
    # embodied_ashp = ashp_embodied + underfloor_heating_embodied + pv_embodied*embodied_pv_ratio[1]
    #
    # # GSHP
    # borehole_depth = 20 #m/kW - entspricht einer spezifischen Entzugsleistung von 50W/m
    # gshp_power = np.percentile(heating_el_demands_list[2],97.5)/1000 #kW
    # gshp_embodied = coeq_gshp * gshp_power # kgCO2eq
    # # underfloor_heating_embodied = coeq_underfloor_heating * Office_2X.floor_area # kgCO2eq
    # borehole_embodied = coeq_borehole * borehole_depth * gshp_power
    # embodied_gshp = gshp_embodied + underfloor_heating_embodied + borehole_embodied + pv_embodied * embodied_pv_ratio[2]
    # embodied_emissions = np.array([embodied_direct, embodied_ashp, embodied_gshp])
    #
    #
    # # Annual for 25years lifetime
    # annual_embodied_emissions = embodied_emissions/lifetime
    # normalized_annual_embodied_emissions = annual_embodied_emissions/(room_width*room_depth)

    #### Total emissions
    annual_operational_emissions = operational_emissions.sum()
    normalized_annual_operational_emissions = annual_operational_emissions / (
        room_width * room_depth)

    # normalized_total_emissions = normalized_annual_embodied_emissions+normalized_annual_operational_emissions

    normalized_total_emissions = 0  # placeholder
    normalized_annual_embodied_emissions = 0  # placeholder




    return normalized_total_emissions, normalized_annual_operational_emissions, normalized_annual_embodied_emissions,\
           u_windows, u_walls, thermal_capacitance_per_floor_area, max_required_heating_per_floor_area,\
           max_required_cooling_per_floor_area, indoor_temperature
# Starting temperature of the builidng
t_m_prev = 20

# Loop through all 8760 hours of the year
for hour in range(8760):

    # Occupancy for the time step
    occupancy = occupancyProfile.loc[hour, 'People'] * max_occupancy
    # Gains from occupancy and appliances
    internal_gains = occupancy * gain_per_person + \
        appliance_gains * Office.floor_area

    # Extract the outdoor temperature in Zurich for that hour
    t_out = Zurich.weather_data['drybulb_C'][hour]

    Altitude, Azimuth = Zurich.calc_sun_position(
        latitude_deg=47.480, longitude_deg=8.536, year=2015, hoy=hour)

    SouthWindow.calc_solar_gains(sun_altitude=Altitude, sun_azimuth=Azimuth,
                                 normal_direct_radiation=Zurich.weather_data[
                                     'dirnorrad_Whm2'][hour],
                                 horizontal_diffuse_radiation=Zurich.weather_data['difhorrad_Whm2'][hour])

    SouthWindow.calc_illuminance(sun_altitude=Altitude, sun_azimuth=Azimuth,
                                 normal_direct_illuminance=Zurich.weather_data[
                                     'dirnorillum_lux'][hour],
                                 horizontal_diffuse_illuminance=Zurich.weather_data['difhorillum_lux'][hour])

    Office.solve_building_energy(internal_gains=internal_gains,
                                 solar_gains=SouthWindow.solar_gains, t_out=t_out, t_m_prev=t_m_prev)

    Office.solve_building_lighting(
Example #12
0
import matplotlib.pyplot as plt
import matplotlib

# Set root folder one level up, just for this example
mainPath = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.insert(0, mainPath)

from radiation import Location

matplotlib.style.use('ggplot')

Zurich = Location(epwfile_path=os.path.join(
    mainPath, 'auxiliary', 'Zurich-Kloten_2013.epw'))


Zurich.calc_sun_position(latitude_deg=47.480, longitude_deg=8.536, year=2015, hoy=3708)


Azimuth = []
Altitude = []
Sunnyhoy = []

for hoy in range(8760):
    sun = Zurich.calc_sun_position(
        latitude_deg=47.480, longitude_deg=8.536, year=2015, hoy=hoy)
    Altitude.append(sun[0])
    Azimuth.append(sun[1])
    Sunnyhoy.append(hoy + 1)

sunPosition = pd.read_csv(os.path.join(
    mainPath, 'auxiliary', 'SunPosition.csv'), skiprows=1)
h_ve_adj_default = Greenhouse.h_ve_adj
print("default h_ve_sdj is:", h_ve_adj_default)

# Starting temperature of the builidng
t_m_prev = 20

heating_hours = 0

# Loop through all 8760 hours of the year
for hour in range(8760):

    # Extract the outdoor temperature in Wellington for that hour
    t_out = Wellington.weather_data['drybulb_C'][hour]

    Altitude, Azimuth = Wellington.calc_sun_position(latitude_deg=-40.750,
                                                     longitude_deg=175.13,
                                                     year=2020,
                                                     hoy=hour)

    # Loop through all windows
    total_solar_gains = 0
    for selected_window in [
            EastWall, WestWall, EastRoof, WestRoof, SouthWall, NorthWall
    ]:
        selected_window.calc_solar_gains(
            sun_altitude=Altitude,
            sun_azimuth=Azimuth,
            normal_direct_radiation=Wellington.weather_data['dirnorrad_Whm2']
            [hour],
            horizontal_diffuse_radiation=Wellington.
            weather_data['difhorrad_Whm2'][hour])