Ejemplo n.º 1
0
def main(config):
    assert os.path.exists(
        config.scenario), 'Scenario not found: %s' % config.scenario
    locator = cea.inputlocator.InputLocator(scenario=config.scenario)

    print('Running photovoltaic with scenario = %s' % config.scenario)
    print('Running photovoltaic with annual-radiation-threshold-kWh/m2 = %s' %
          config.solar.annual_radiation_threshold)
    print('Running photovoltaic with panel-on-roof = %s' %
          config.solar.panel_on_roof)
    print('Running photovoltaic with panel-on-wall = %s' %
          config.solar.panel_on_wall)
    print('Running photovoltaic with solar-window-solstice = %s' %
          config.solar.solar_window_solstice)
    print('Running photovoltaic with type-pvpanel = %s' %
          config.solar.type_pvpanel)
    if config.solar.custom_tilt_angle:
        print(
            'Running photovoltaic with custom-tilt-angle = %s and panel-tilt-angle = %s'
            % (config.solar.custom_tilt_angle, config.solar.panel_tilt_angle))
    else:
        print('Running photovoltaic with custom-tilt-angle = %s' %
              config.solar.custom_tilt_angle)
    if config.solar.custom_roof_coverage:
        print(
            'Running photovoltaic with custom-roof-coverage = %s and max-roof-coverage = %s'
            % (config.solar.custom_roof_coverage,
               config.solar.max_roof_coverage))
    else:
        print('Running photovoltaic with custom-roof-coverage = %s' %
              config.solar.custom_roof_coverage)

    building_names = locator.get_zone_building_names()
    zone_geometry_df = gdf.from_file(locator.get_zone_geometry())
    latitude, longitude = get_lat_lon_projected_shapefile(zone_geometry_df)

    # list_buildings_names =['B026', 'B036', 'B039', 'B043', 'B050'] for missing buildings
    weather_data = epwreader.epw_reader(locator.get_weather_file())
    date_local = solar_equations.calc_datetime_local_from_weather_file(
        weather_data, latitude, longitude)

    num_process = config.get_number_of_processes()
    n = len(building_names)
    cea.utilities.parallel.vectorize(calc_PV,
                                     num_process)(repeat(locator, n),
                                                  repeat(config, n),
                                                  repeat(latitude, n),
                                                  repeat(longitude, n),
                                                  repeat(weather_data, n),
                                                  repeat(date_local, n),
                                                  building_names)

    # aggregate results from all buildings
    write_aggregate_results(locator, building_names, num_process)
def main(config):
    assert os.path.exists(config.scenario), 'Scenario not found: %s' % config.scenario
    locator = cea.inputlocator.InputLocator(scenario=config.scenario)

    print('Running photovoltaic with scenario = %s' % config.scenario)
    print('Running photovoltaic with annual-radiation-threshold-kWh/m2 = %s' % config.solar.annual_radiation_threshold)
    print('Running photovoltaic with panel-on-roof = %s' % config.solar.panel_on_roof)
    print('Running photovoltaic with panel-on-wall = %s' % config.solar.panel_on_wall)
    print('Running photovoltaic with solar-window-solstice = %s' % config.solar.solar_window_solstice)
    print('Running photovoltaic with type-pvpanel = %s' % config.solar.type_pvpanel)

    buildings_names = locator.get_zone_building_names()
    zone_geometry_df = gdf.from_file(locator.get_zone_geometry())
    latitude, longitude = get_lat_lon_projected_shapefile(zone_geometry_df)

    # list_buildings_names =['B026', 'B036', 'B039', 'B043', 'B050'] for missing buildings
    weather_data = epwreader.epw_reader(locator.get_weather_file())
    date_local = solar_equations.calc_datetime_local_from_weather_file(weather_data, latitude, longitude)

    n = len(buildings_names)
    cea.utilities.parallel.vectorize(calc_PV, config.get_number_of_processes())(repeat(locator, n),
                                                                                repeat(config, n),
                                                                                repeat(latitude, n),
                                                                                repeat(longitude, n),
                                                                                repeat(weather_data, n),
                                                                                repeat(date_local, n),
                                                                                buildings_names)

    # aggregate results from all buildings
    aggregated_annual_results = {}
    for i, building in enumerate(buildings_names):
        hourly_results_per_building = pd.read_csv(locator.PV_results(building))
        if i == 0:
            aggregated_hourly_results_df = hourly_results_per_building
        else:
            aggregated_hourly_results_df = aggregated_hourly_results_df + hourly_results_per_building

        annual_energy_production = hourly_results_per_building.filter(like='_kWh').sum()
        panel_area_per_building = hourly_results_per_building.filter(like='_m2').iloc[0]
        building_annual_results = annual_energy_production.append(panel_area_per_building)
        aggregated_annual_results[building] = building_annual_results

    # save hourly results
    aggregated_hourly_results_df = aggregated_hourly_results_df.set_index('Date')
    aggregated_hourly_results_df.to_csv(locator.PV_totals(), index=True, float_format='%.2f')
    # save annual results
    aggregated_annual_results_df = pd.DataFrame(aggregated_annual_results).T
    aggregated_annual_results_df.to_csv(locator.PV_total_buildings(), index=True, float_format='%.2f')
Ejemplo n.º 3
0
def main(config):
    assert os.path.exists(
        config.scenario), 'Scenario not found: %s' % config.scenario
    locator = cea.inputlocator.InputLocator(scenario=config.scenario)

    print('Running photovoltaic-thermal with scenario = %s' % config.scenario)
    print(
        'Running photovoltaic-thermal with annual-radiation-threshold-kWh/m2 = %s'
        % config.solar.annual_radiation_threshold)
    print('Running photovoltaic-thermal with panel-on-roof = %s' %
          config.solar.panel_on_roof)
    print('Running photovoltaic-thermal with panel-on-wall = %s' %
          config.solar.panel_on_wall)
    print('Running photovoltaic-thermal with solar-window-solstice = %s' %
          config.solar.solar_window_solstice)
    print('Running photovoltaic-thermal with t-in-pvt = %s' %
          config.solar.t_in_pvt)
    print('Running photovoltaic-thermal with type-pvpanel = %s' %
          config.solar.type_pvpanel)

    building_names = config.solar.buildings
    if not building_names:
        building_names = locator.get_zone_building_names()

    hourly_results_per_building = gdf.from_file(locator.get_zone_geometry())
    latitude, longitude = get_lat_lon_projected_shapefile(
        hourly_results_per_building)

    # weather hourly_results_per_building
    weather_data = epwreader.epw_reader(locator.get_weather_file())
    date_local = solar_equations.calc_datetime_local_from_weather_file(
        weather_data, latitude, longitude)
    print('reading weather hourly_results_per_building done.')

    n = len(building_names)
    cea.utilities.parallel.vectorize(
        calc_PVT, config.get_number_of_processes())(repeat(locator, n),
                                                    repeat(config, n),
                                                    repeat(latitude, n),
                                                    repeat(longitude, n),
                                                    repeat(weather_data, n),
                                                    repeat(date_local, n),
                                                    building_names)

    # aggregate results from all buildings
    aggregated_annual_results = {}
    for i, building in enumerate(building_names):
        hourly_results_per_building = pd.read_csv(
            locator.PVT_results(building))
        if i == 0:
            aggregated_hourly_results_df = hourly_results_per_building
            temperature_sup = []
            temperature_re = []
            temperature_sup.append(hourly_results_per_building['T_PVT_sup_C'])
            temperature_re.append(hourly_results_per_building['T_PVT_re_C'])
        else:
            aggregated_hourly_results_df = aggregated_hourly_results_df + hourly_results_per_building
            temperature_sup.append(hourly_results_per_building['T_PVT_sup_C'])
            temperature_re.append(hourly_results_per_building['T_PVT_re_C'])

        annual_energy_production = hourly_results_per_building.filter(
            like='_kWh').sum()
        panel_area_per_building = hourly_results_per_building.filter(
            like='_m2').iloc[0]
        building_annual_results = annual_energy_production.append(
            panel_area_per_building)
        aggregated_annual_results[building] = building_annual_results

    # save hourly results
    aggregated_hourly_results_df['T_PVT_sup_C'] = pd.DataFrame(
        temperature_sup).mean(axis=0)
    aggregated_hourly_results_df['T_PVT_re_C'] = pd.DataFrame(
        temperature_re).mean(axis=0)
    aggregated_hourly_results_df = aggregated_hourly_results_df[
        aggregated_hourly_results_df.columns.drop(
            aggregated_hourly_results_df.filter(
                like='Tout', axis=1).columns)]  # drop columns with Tout
    aggregated_hourly_results_df = aggregated_hourly_results_df.set_index(
        'Date')
    aggregated_hourly_results_df.to_csv(locator.PVT_totals(),
                                        index=True,
                                        float_format='%.2f',
                                        na_rep='nan')
    # save annual results
    aggregated_annual_results_df = pd.DataFrame(aggregated_annual_results).T
    aggregated_annual_results_df.to_csv(locator.PVT_total_buildings(),
                                        index=True,
                                        index_label="Name",
                                        float_format='%.2f')
Ejemplo n.º 4
0
def calc_PV(locator, config, radiation_path, metadata_csv, latitude, longitude,
            weather_path, building_name):
    """
    This function first determines the surface area with sufficient solar radiation, and then calculates the optimal
    tilt angles of panels at each surface location. The panels are categorized into groups by their surface azimuths,
    tilt angles, and global irradiation. In the last, electricity generation from PV panels of each group is calculated.

    :param locator: An InputLocator to locate input files
    :type locator: cea.inputlocator.InputLocator
    :param radiation_path: solar insulation data on all surfaces of each building (path
    :type radiation_path: String
    :param metadata_csv: data of sensor points measuring solar insulation of each building
    :type metadata_csv: .csv
    :param latitude: latitude of the case study location
    :type latitude: float
    :param longitude: longitude of the case study location
    :type longitude: float
    :param weather_path: path to the weather data file of the case study location
    :type weather_path: .epw
    :param building_name: list of building names in the case study
    :type building_name: Series
    :return: Building_PV.csv with PV generation potential of each building, Building_sensors.csv with sensor data of
        each PV panel.

    """

    t0 = time.clock()

    # weather data
    weather_data = epwreader.epw_reader(weather_path)
    datetime_local = solar_equations.calc_datetime_local_from_weather_file(
        weather_data, latitude, longitude)
    print('reading weather data done')

    # solar properties
    solar_properties = solar_equations.calc_sun_properties(
        latitude, longitude, weather_data, datetime_local, config)
    print('calculating solar properties done')

    # calculate properties of PV panel
    panel_properties_PV = calc_properties_PV_db(
        locator.get_supply_systems(config.region), config)
    print('gathering properties of PV panel')

    # select sensor point with sufficient solar radiation
    max_annual_radiation, annual_radiation_threshold, sensors_rad_clean, sensors_metadata_clean = \
        solar_equations.filter_low_potential(radiation_path, metadata_csv, config)

    print('filtering low potential sensor points done')

    if not sensors_metadata_clean.empty:
        # calculate optimal angle and tilt for panels
        sensors_metadata_cat = solar_equations.optimal_angle_and_tilt(
            sensors_metadata_clean, latitude, solar_properties,
            max_annual_radiation, panel_properties_PV)
        print('calculating optimal tile angle and separation done')

        # group the sensors with the same tilt, surface azimuth, and total radiation
        sensor_groups = solar_equations.calc_groups(sensors_rad_clean,
                                                    sensors_metadata_cat)

        print('generating groups of sensor points done')

        final = calc_pv_generation(sensor_groups, weather_data, datetime_local,
                                   solar_properties, latitude,
                                   panel_properties_PV)

        final.to_csv(locator.PV_results(building_name=building_name),
                     index=True,
                     float_format='%.2f')  # print PV generation potential
        sensors_metadata_cat.to_csv(
            locator.PV_metadata_results(building_name=building_name),
            index=True,
            index_label='SURFACE',
            float_format='%.2f'
        )  # print selected metadata of the selected sensors

        print(building_name,
              'done - time elapsed: %.2f seconds' % (time.clock() - t0))
    else:  # This loop is activated when a building has not sufficient solar potential
        final = pd.DataFrame(
            {
                'PV_walls_north_E_kWh': 0,
                'PV_walls_north_m2': 0,
                'PV_walls_south_E_kWh': 0,
                'PV_walls_south_m2': 0,
                'PV_walls_east_E_kWh': 0,
                'PV_walls_east_m2': 0,
                'PV_walls_west_E_kWh': 0,
                'PV_walls_west_m2': 0,
                'PV_roofs_top_E_kWh': 0,
                'PV_roofs_top_m2': 0,
                'E_PV_gen_kWh': 0,
                'Area_PV_m2': 0,
                'radiation_kWh': 0
            },
            index=range(8760))
        final.to_csv(locator.PV_results(building_name=building_name),
                     index=True,
                     float_format='%.2f')
        sensors_metadata_cat = pd.DataFrame(
            {
                'SURFACE': 0,
                'AREA_m2': 0,
                'BUILDING': 0,
                'TYPE': 0,
                'Xcoor': 0,
                'Xdir': 0,
                'Ycoor': 0,
                'Ydir': 0,
                'Zcoor': 0,
                'Zdir': 0,
                'orientation': 0,
                'total_rad_Whm2': 0,
                'tilt_deg': 0,
                'B_deg': 0,
                'array_spacing_m': 0,
                'surface_azimuth_deg': 0,
                'area_installed_module_m2': 0,
                'CATteta_z': 0,
                'CATB': 0,
                'CATGB': 0,
                'type_orientation': 0
            },
            index=range(2))
        sensors_metadata_cat.to_csv(
            locator.PV_metadata_results(building_name=building_name),
            index=True,
            float_format='%.2f')

    return