Esempio n. 1
0
def calc_PVT_generation(sensor_groups, weather_data, date_local,
                        solar_properties, latitude, tot_bui_height_m,
                        panel_properties_SC, panel_properties_PV, config):
    """
    To calculate the heat and electricity generated from PVT panels.

    :param sensor_groups: properties of sensors in each group
    :type sensor_groups: dict
    :param weather_data: weather data read from .epw
    :type weather_data: dataframe
    :param solar_properties:
    :param latitude: latitude of the case study location
    :param tot_bui_height_m: total height of all buildings [m]
    :param panel_properties_SC: properties of solar thermal collectors
    :param panel_properties_PV: properties of photovoltaic panels
    :param config: user settings from cea.config
    :return:
    """

    # read variables
    number_groups = sensor_groups[
        'number_groups']  # number of groups of sensor points
    prop_observers = sensor_groups[
        'prop_observers']  # mean values of sensor properties of each group of sensors
    hourly_radiation_Wperm2 = sensor_groups[
        'hourlydata_groups']  # mean hourly radiation of sensors in each group [Wh/m2]
    T_in_C = get_t_in_pvt(config)

    # convert degree to radians
    lat_rad = radians(latitude)
    g_rad = np.radians(solar_properties.g)
    ha_rad = np.radians(solar_properties.ha)
    Sz_rad = np.radians(solar_properties.Sz)

    # calculate equivalent length of pipes
    total_area_module_m2 = prop_observers['area_installed_module_m2'].sum(
    )  # total area for panel installation
    total_pipe_lengths = calc_pipe_equivalent_length(panel_properties_PV,
                                                     panel_properties_SC,
                                                     tot_bui_height_m,
                                                     total_area_module_m2)

    # empty lists to store results
    list_groups_area = [0 for i in range(number_groups)]
    total_el_output_PV_kWh = [0 for i in range(number_groups)]
    total_radiation_kWh = [0 for i in range(number_groups)]
    total_mcp_kWperC = [0 for i in range(number_groups)]
    total_qloss_kWh = [0 for i in range(number_groups)]
    total_aux_el_kWh = [0 for i in range(number_groups)]
    total_Qh_output_kWh = [0 for i in range(number_groups)]

    list_results_from_PVT = list(range(number_groups))

    potential = pd.DataFrame(index=[range(HOURS_IN_YEAR)])
    panel_orientations = [
        'walls_south', 'walls_north', 'roofs_top', 'walls_east', 'walls_west'
    ]
    for panel_orientation in panel_orientations:
        potential['PVT_' + panel_orientation + '_Q_kWh'] = 0.0
        potential['PVT_' + panel_orientation + '_E_kWh'] = 0.0
        potential['PVT_' + panel_orientation + '_m2'] = 0.0

    # assign default number of subsdivisions for the calculation
    if panel_properties_SC['type'] == 'ET':  # ET: evacuated tubes
        panel_properties_SC[
            'Nseg'] = 100  # default number of subsdivisions for the calculation
    else:
        panel_properties_SC['Nseg'] = 10

    for group in range(number_groups):
        # read panel properties of each group
        teta_z_deg = prop_observers.loc[group, 'surface_azimuth_deg']
        module_area_per_group_m2 = prop_observers.loc[
            group, 'area_installed_module_m2']
        tilt_angle_deg = prop_observers.loc[group,
                                            'B_deg']  # tilt angle of panels

        # degree to radians
        tilt_rad = radians(tilt_angle_deg)  # tilt angle
        teta_z_rad = radians(teta_z_deg)  # surface azimuth

        # calculate radiation types (direct/diffuse) in group
        radiation_Wperm2 = solar_equations.cal_radiation_type(
            group, hourly_radiation_Wperm2, weather_data)

        ## calculate absorbed solar irradiation on tilt surfaces
        # calculate effective indicent angles necessary
        teta_rad = np.vectorize(solar_equations.calc_angle_of_incidence)(
            g_rad, lat_rad, ha_rad, tilt_rad, teta_z_rad)
        teta_ed_rad, teta_eg_rad = calc_diffuseground_comp(tilt_rad)

        # absorbed radiation and Tcell
        absorbed_radiation_PV_Wperm2 = np.vectorize(
            calc_absorbed_radiation_PV)(radiation_Wperm2.I_sol,
                                        radiation_Wperm2.I_direct,
                                        radiation_Wperm2.I_diffuse, tilt_rad,
                                        Sz_rad, teta_rad, teta_ed_rad,
                                        teta_eg_rad, panel_properties_PV)

        T_cell_C = np.vectorize(calc_cell_temperature)(
            absorbed_radiation_PV_Wperm2, weather_data.drybulb_C,
            panel_properties_PV)

        ## SC heat generation
        # calculate incidence angle modifier for beam radiation
        IAM_b = calc_IAM_beam_SC(solar_properties, teta_z_deg, tilt_angle_deg,
                                 panel_properties_SC['type'], latitude)
        list_results_from_PVT[group] = calc_PVT_module(
            config, radiation_Wperm2, panel_properties_SC, panel_properties_PV,
            weather_data.drybulb_C, IAM_b, tilt_angle_deg, total_pipe_lengths,
            absorbed_radiation_PV_Wperm2, T_cell_C, module_area_per_group_m2)

        # calculate results from each group
        panel_orientation = prop_observers.loc[group, 'type_orientation']
        number_modules_per_group = module_area_per_group_m2 / (
            panel_properties_PV['module_length_m']**2)

        PVT_Q_kWh = list_results_from_PVT[group][1] * number_modules_per_group
        PVT_E_kWh = list_results_from_PVT[group][6]

        # write results
        potential['PVT_' + panel_orientation +
                  '_Q_kWh'] = potential['PVT_' + panel_orientation +
                                        '_Q_kWh'] + PVT_Q_kWh
        potential['PVT_' + panel_orientation +
                  '_E_kWh'] = potential['PVT_' + panel_orientation +
                                        '_E_kWh'] + PVT_E_kWh
        potential['PVT_' + panel_orientation +
                  '_m2'] = potential['PVT_' + panel_orientation +
                                     '_m2'] + module_area_per_group_m2

        # aggregate results from all modules
        list_groups_area[group] = module_area_per_group_m2
        total_mcp_kWperC[
            group] = list_results_from_PVT[group][5] * number_modules_per_group
        total_qloss_kWh[
            group] = list_results_from_PVT[group][0] * number_modules_per_group
        total_aux_el_kWh[
            group] = list_results_from_PVT[group][2] * number_modules_per_group
        total_Qh_output_kWh[
            group] = list_results_from_PVT[group][1] * number_modules_per_group
        total_el_output_PV_kWh[group] = list_results_from_PVT[group][6]
        total_radiation_kWh[group] = hourly_radiation_Wperm2[
            group] * module_area_per_group_m2 / 1000

    potential['Area_PVT_m2'] = sum(list_groups_area)
    potential['radiation_kWh'] = sum(total_radiation_kWh).values
    potential['E_PVT_gen_kWh'] = sum(total_el_output_PV_kWh)
    potential['Q_PVT_gen_kWh'] = sum(total_Qh_output_kWh)
    potential['mcp_PVT_kWperC'] = sum(total_mcp_kWperC)
    potential['Eaux_PVT_kWh'] = sum(total_aux_el_kWh)
    potential['Q_PVT_l_kWh'] = sum(total_qloss_kWh)
    potential['T_PVT_sup_C'] = np.zeros(HOURS_IN_YEAR) + T_in_C
    T_out_C = (potential['Q_PVT_gen_kWh'] /
               potential['mcp_PVT_kWperC']) + T_in_C
    potential[
        'T_PVT_re_C'] = T_out_C if T_out_C is not np.nan else np.nan  # assume parallel connections for all panels

    potential['Date'] = date_local
    potential = potential.set_index('Date')

    return potential
def calc_pv_generation(sensor_groups, weather_data, date_local, solar_properties, latitude, panel_properties_PV):
    """
    To calculate the electricity generated from PV panels.

    :param hourly_radiation: mean hourly radiation of sensors in each group [Wh/m2]
    :type hourly_radiation: dataframe
    :param number_groups: number of groups of sensor points
    :type number_groups: float
    :param number_points: number of sensor points in each group
    :type number_points: float
    :param prop_observers: mean values of sensor properties of each group of sensors
    :type prop_observers: dataframe
    :param weather_data: weather data read from the epw file
    :type weather_data: dataframe
    :param g: declination
    :type g: float
    :param Sz: zenith angle
    :type Sz: float
    :param Az: solar azimuth
    :param ha: hour angle
    :param latitude: latitude of the case study location
    :return:

    """

    # local variables
    number_groups = sensor_groups['number_groups']  # number of groups of sensor points
    prop_observers = sensor_groups['prop_observers']  # mean values of sensor properties of each group of sensors
    hourly_radiation = sensor_groups['hourlydata_groups']  # mean hourly radiation of sensors in each group [Wh/m2]

    # convert degree to radians
    lat = radians(latitude)
    g_rad = np.radians(solar_properties.g)
    ha_rad = np.radians(solar_properties.ha)
    Sz_rad = np.radians(solar_properties.Sz)
    Az_rad = np.radians(solar_properties.Az)

    # empty list to store results
    list_groups_area = [0 for i in range(number_groups)]
    total_el_output_PV_kWh = [0 for i in range(number_groups)]
    total_radiation_kWh = [0 for i in range(number_groups)]

    potential = pd.DataFrame(index=[range(HOURS_IN_YEAR)])
    panel_orientations = ['walls_south', 'walls_north', 'roofs_top', 'walls_east', 'walls_west']
    for panel_orientation in panel_orientations:
        potential['PV_' + panel_orientation + '_E_kWh'] = 0
        potential['PV_' + panel_orientation + '_m2'] = 0

    eff_nom = panel_properties_PV['PV_n']

    Bref = panel_properties_PV['PV_Bref']

    misc_losses = panel_properties_PV['misc_losses']  # cabling, resistances etc..

    for group in prop_observers.index.values:
        # calculate radiation types (direct/diffuse) in group
        radiation_Wperm2 = solar_equations.cal_radiation_type(group, hourly_radiation, weather_data)

        # read panel properties of each group
        teta_z_deg = prop_observers.loc[group, 'surface_azimuth_deg']
        tot_module_area_m2 = prop_observers.loc[group, 'area_installed_module_m2']
        tilt_angle_deg = prop_observers.loc[group, 'B_deg']  # tilt angle of panels
        # degree to radians
        tilt_rad = radians(tilt_angle_deg)  # tilt angle
        teta_z_deg = radians(teta_z_deg)  # surface azimuth

        # calculate effective indicent angles necessary
        teta_rad = np.vectorize(solar_equations.calc_angle_of_incidence)(g_rad, lat, ha_rad, tilt_rad, teta_z_deg)
        teta_ed_rad, teta_eg_rad = calc_diffuseground_comp(tilt_rad)

        absorbed_radiation_Wperm2 = np.vectorize(calc_absorbed_radiation_PV)(radiation_Wperm2.I_sol,
                                                                             radiation_Wperm2.I_direct,
                                                                             radiation_Wperm2.I_diffuse, tilt_rad,
                                                                             Sz_rad, teta_rad, teta_ed_rad,
                                                                             teta_eg_rad, panel_properties_PV)

        T_cell_C = np.vectorize(calc_cell_temperature)(absorbed_radiation_Wperm2, weather_data.drybulb_C,
                                                       panel_properties_PV)

        el_output_PV_kW = np.vectorize(calc_PV_power)(absorbed_radiation_Wperm2, T_cell_C, eff_nom, tot_module_area_m2,
                                                      Bref, misc_losses)

        # write results from each group
        panel_orientation = prop_observers.loc[group, 'type_orientation']
        potential['PV_' + panel_orientation + '_E_kWh'] = potential[
                                                              'PV_' + panel_orientation + '_E_kWh'] + el_output_PV_kW
        potential['PV_' + panel_orientation + '_m2'] = potential['PV_' + panel_orientation + '_m2'] + tot_module_area_m2

        # aggregate results from all modules
        list_groups_area[group] = tot_module_area_m2
        total_el_output_PV_kWh[group] = el_output_PV_kW
        total_radiation_kWh[group] = (radiation_Wperm2['I_sol'] * tot_module_area_m2 / 1000)  # kWh

    # check for missing groups and asign 0 as el_output_PV_kW
    # panel_orientations = ['walls_south', 'walls_north', 'roofs_top', 'walls_east', 'walls_west']
    # for panel_orientation in panel_orientations:
    #     if panel_orientation not in prop_observers['type_orientation'].values:
    #         potential['PV_' + panel_orientation + '_E_kWh'] = 0
    #         potential['PV_' + panel_orientation + '_m2'] = 0

    potential['E_PV_gen_kWh'] = sum(total_el_output_PV_kWh)
    potential['radiation_kWh'] = sum(total_radiation_kWh).values
    potential['Area_PV_m2'] = sum(list_groups_area)
    potential['Date'] = date_local
    potential = potential.set_index('Date')

    return potential
def calc_SC_generation(sensor_groups, weather_data, date_local, solar_properties, tot_bui_height, panel_properties_SC,
                       latitude_deg, config):
    """
    To calculate the heat generated from SC panels.
    :param sensor_groups: properties of sensors in each group
    :type sensor_groups: dict
    :param weather_data: weather data read from the epw file
    :type weather_data: dataframe
    :param solar_properties:
    :param tot_bui_height: total height of all buildings [m]
    :param panel_properties_SC: properties of solar panels
    :type panel_properties_SC: dataframe
    :param latitude_deg: latitude of the case study location
    :param config: user settings from cea.config
    :return: dataframe
    """

    # local variables
    number_groups = sensor_groups['number_groups']  # number of groups of sensor points
    prop_observers = sensor_groups['prop_observers']  # mean values of sensor properties of each group of sensors
    hourly_radiation = sensor_groups['hourlydata_groups']  # mean hourly radiation of sensors in each group [Wh/m2]

    T_in_C = get_t_in_sc(config)
    Tin_array_C = np.zeros(8760) + T_in_C

    # create lists to store results
    list_results_from_SC = [0 for i in range(number_groups)]
    list_areas_groups = [0 for i in range(number_groups)]
    total_radiation_kWh = [0 for i in range(number_groups)]
    total_mcp_kWperC = [0 for i in range(number_groups)]
    total_qloss_kWh = [0 for i in range(number_groups)]
    total_aux_el_kWh = [0 for i in range(number_groups)]
    total_Qh_output_kWh = [0 for i in range(number_groups)]

    potential = pd.DataFrame(index=[range(8760)])
    panel_orientations = ['walls_south', 'walls_north', 'roofs_top', 'walls_east', 'walls_west']
    for panel_orientation in panel_orientations:
        potential['SC_' + panel_orientation + '_Q_kWh'] = 0
        potential['SC_' + panel_orientation + '_m2'] = 0

    # calculate equivalent length of pipes
    total_area_module_m2 = prop_observers['area_installed_module_m2'].sum()  # total area for panel installation
    total_pipe_length = cal_pipe_equivalent_length(tot_bui_height, panel_properties_SC, total_area_module_m2)

    # assign default number of subsdivisions for the calculation
    if panel_properties_SC['type'] == 'ET':  # ET: evacuated tubes
        panel_properties_SC['Nseg'] = 100  # default number of subsdivisions for the calculation
    else:
        panel_properties_SC['Nseg'] = 10

    for group in range(number_groups):
        # calculate radiation types (direct/diffuse) in group
        radiation_Wperm2 = solar_equations.cal_radiation_type(group, hourly_radiation, weather_data)

        # load panel angles from each group
        teta_z_deg = prop_observers.loc[group, 'surface_azimuth_deg']  # azimuth of panels of group
        tilt_angle_deg = prop_observers.loc[group, 'B_deg']  # tilt angle of panels

        # calculate incidence angle modifier for beam radiation
        IAM_b = calc_IAM_beam_SC(solar_properties, teta_z_deg, tilt_angle_deg, panel_properties_SC['type'],
                                 latitude_deg)

        # calculate heat production from a solar collector of each group
        list_results_from_SC[group] = calc_SC_module(config, radiation_Wperm2, panel_properties_SC,
                                                     weather_data.drybulb_C,
                                                     IAM_b, tilt_angle_deg, total_pipe_length)

        # calculate results from each group
        panel_orientation = prop_observers.loc[group, 'type_orientation']
        module_area_per_group_m2 = prop_observers.loc[group, 'area_installed_module_m2']
        number_modules_per_group = module_area_per_group_m2 / panel_properties_SC['module_area_m2']

        SC_Q_kWh = list_results_from_SC[group][1] * number_modules_per_group

        potential['SC_' + panel_orientation + '_Q_kWh'] = potential['SC_' + panel_orientation + '_Q_kWh'] + SC_Q_kWh
        potential['SC_' + panel_orientation + '_m2'] = potential[
                                                           'SC_' + panel_orientation + '_m2'] + module_area_per_group_m2  # assume parallel connections in this group

        # aggregate results from all modules
        list_areas_groups[group] = module_area_per_group_m2
        total_mcp_kWperC[group] = list_results_from_SC[group][5] * number_modules_per_group
        total_qloss_kWh[group] = list_results_from_SC[group][0] * number_modules_per_group
        total_aux_el_kWh[group] = list_results_from_SC[group][2] * number_modules_per_group
        total_Qh_output_kWh[group] = list_results_from_SC[group][1] * number_modules_per_group
        total_radiation_kWh[group] = (radiation_Wperm2['I_sol'] * module_area_per_group_m2 / 1000)

    potential['Area_SC_m2'] = sum(list_areas_groups)
    potential['radiation_kWh'] = sum(total_radiation_kWh)
    potential['Q_SC_gen_kWh'] = sum(total_Qh_output_kWh)
    potential['mcp_SC_kWperC'] = sum(total_mcp_kWperC)
    potential['Eaux_SC_kWh'] = sum(total_aux_el_kWh)
    potential['Q_SC_l_kWh'] = sum(total_qloss_kWh)
    potential['T_SC_sup_C'] = Tin_array_C
    T_out_C = (potential['Q_SC_gen_kWh'] / potential['mcp_SC_kWperC']) + T_in_C
    potential[
        'T_SC_re_C'] = T_out_C if T_out_C is not np.nan else np.nan  # assume parallel connections for all panels #FIXME: change here when the flow rate is zero

    potential['Date'] = date_local
    potential = potential.set_index('Date')

    return potential