def district_cooling_network(locator,
                             master_to_slave_variables,
                             config,
                             prices,
                             network_features):
    """
    Computes the parameters for the cooling of the complete DCN

    :param cea.inputlocator.InputLocator locator: path to res folder
    :param network_features: network features
    :param prices: Prices imported from the database
    :type network_features: class
    :type prices: class
    :return: costs, co2, prim
    :rtype: tuple
    """

    if master_to_slave_variables.DCN_exists:
        # THERMAL STORAGE + NETWORK
        # Import Temperatures from Network Summary:
        Q_thermal_req_W, \
        T_district_cooling_return_K, \
        T_district_cooling_supply_K, \
        mdot_kgpers = calc_network_summary_DCN(master_to_slave_variables)

        # Initialize daily storage calss
        T_ground_K = calculate_ground_temperature(locator)
        daily_storage = LoadLevelingDailyStorage(master_to_slave_variables.Storage_cooling_on,
                                                 master_to_slave_variables.Storage_cooling_size_W,
                                                 min(T_district_cooling_supply_K) - DT_COOL,
                                                 max(T_district_cooling_return_K) - DT_COOL,
                                                 T_TANK_FULLY_DISCHARGED_K,
                                                 np.mean(T_ground_K)
                                                 )

        # Import Data - potentials lake heat
        if master_to_slave_variables.WS_BaseVCC_on == 1 or master_to_slave_variables.WS_PeakVCC_on == 1:
            HPlake_Data = pd.read_csv(locator.get_water_body_potential())
            Q_therm_Lake = np.array(HPlake_Data['QLake_kW']) * 1E3
            total_WS_VCC_installed = master_to_slave_variables.WS_BaseVCC_size_W + master_to_slave_variables.WS_PeakVCC_size_W
            Q_therm_Lake_W = [x if x < total_WS_VCC_installed else total_WS_VCC_installed for x in Q_therm_Lake]
            T_source_average_Lake_K = np.array(HPlake_Data['Ts_C']) + 273
        else:
            Q_therm_Lake_W = np.zeros(HOURS_IN_YEAR)
            T_source_average_Lake_K = np.zeros(HOURS_IN_YEAR)

        # get properties of technology used in this script
        absorption_chiller = AbsorptionChiller(pd.read_excel(locator.get_database_conversion_systems(), sheet_name="Absorption_chiller"), 'double')
        CCGT_prop = calc_cop_CCGT(master_to_slave_variables.NG_Trigen_ACH_size_W, ACH_T_IN_FROM_CHP_K, "NG")

        VCC_database = pd.read_excel(locator.get_database_conversion_systems(), sheet_name="Chiller")
        technology_type = VCC_CODE_CENTRALIZED
        VCC_database = VCC_database[VCC_database['code'] == technology_type]
        max_VCC_capacity = int(VCC_database['cap_max'])
        min_VCC_capacity = int(VCC_database['cap_min'])
        # G_VALUE = VCC_database['ISENTROPIC_EFFICIENCY'] # create vessel to carry down gvalue and max_VCC_capacity, min_VCC_capacity to VCC module

        # initialize variables
        Q_Trigen_NG_gen_W = np.zeros(HOURS_IN_YEAR)
        Q_BaseVCC_WS_gen_W = np.zeros(HOURS_IN_YEAR)
        Q_PeakVCC_WS_gen_W = np.zeros(HOURS_IN_YEAR)
        Q_BaseVCC_AS_gen_W = np.zeros(HOURS_IN_YEAR)
        Q_PeakVCC_AS_gen_W = np.zeros(HOURS_IN_YEAR)
        Q_DailyStorage_gen_directload_W = np.zeros(HOURS_IN_YEAR)

        E_Trigen_NG_gen_W = np.zeros(HOURS_IN_YEAR)
        E_BaseVCC_AS_req_W = np.zeros(HOURS_IN_YEAR)
        E_PeakVCC_AS_req_W = np.zeros(HOURS_IN_YEAR)
        E_BaseVCC_WS_req_W = np.zeros(HOURS_IN_YEAR)
        E_PeakVCC_WS_req_W = np.zeros(HOURS_IN_YEAR)
        NG_Trigen_req_W = np.zeros(HOURS_IN_YEAR)
        Q_BackupVCC_AS_gen_W = np.zeros(HOURS_IN_YEAR)

        Q_Trigen_NG_gen_directload_W = np.zeros(HOURS_IN_YEAR)
        Q_BaseVCC_WS_gen_directload_W = np.zeros(HOURS_IN_YEAR)
        Q_PeakVCC_WS_gen_directload_W = np.zeros(HOURS_IN_YEAR)
        Q_BaseVCC_AS_gen_directload_W = np.zeros(HOURS_IN_YEAR)
        Q_PeakVCC_AS_gen_directload_W = np.zeros(HOURS_IN_YEAR)
        Q_BackupVCC_AS_directload_W = np.zeros(HOURS_IN_YEAR)

        for hour in range(HOURS_IN_YEAR):  # cooling supply for all buildings excluding cooling loads from data centers
            if Q_thermal_req_W[hour] > 0.0:  # only if there is a cooling load!
                daily_storage, \
                thermal_output, \
                electricity_output, \
                gas_output = cooling_resource_activator(Q_thermal_req_W[hour],
                                                        T_district_cooling_supply_K[hour],
                                                        T_district_cooling_return_K[hour],
                                                        Q_therm_Lake_W[hour],
                                                        T_source_average_Lake_K[hour],
                                                        daily_storage,
                                                        T_ground_K[hour],
                                                        master_to_slave_variables,
                                                        absorption_chiller,
                                                        CCGT_prop,
                                                        min_VCC_capacity,
                                                        max_VCC_capacity)

                Q_DailyStorage_gen_directload_W[hour] = thermal_output['Q_DailyStorage_gen_directload_W']
                Q_Trigen_NG_gen_directload_W[hour] = thermal_output['Q_Trigen_NG_gen_directload_W']
                Q_BaseVCC_WS_gen_directload_W[hour] = thermal_output['Q_BaseVCC_WS_gen_directload_W']
                Q_PeakVCC_WS_gen_directload_W[hour] = thermal_output['Q_PeakVCC_WS_gen_directload_W']
                Q_BaseVCC_AS_gen_directload_W[hour] = thermal_output['Q_BaseVCC_AS_gen_directload_W']
                Q_PeakVCC_AS_gen_directload_W[hour] = thermal_output['Q_PeakVCC_AS_gen_directload_W']
                Q_BackupVCC_AS_directload_W[hour] = thermal_output['Q_BackupVCC_AS_directload_W']

                Q_Trigen_NG_gen_W[hour] = thermal_output['Q_Trigen_NG_gen_W']
                Q_BaseVCC_WS_gen_W[hour] = thermal_output['Q_BaseVCC_WS_gen_W']
                Q_PeakVCC_WS_gen_W[hour] = thermal_output['Q_PeakVCC_WS_gen_W']
                Q_BaseVCC_AS_gen_W[hour] = thermal_output['Q_BaseVCC_AS_gen_W']
                Q_PeakVCC_AS_gen_W[hour] = thermal_output['Q_PeakVCC_AS_gen_W']
                Q_BackupVCC_AS_gen_W[hour] = thermal_output['Q_BackupVCC_AS_gen_W']

                E_BaseVCC_WS_req_W[hour] = electricity_output['E_BaseVCC_WS_req_W']
                E_PeakVCC_WS_req_W[hour] = electricity_output['E_PeakVCC_WS_req_W']
                E_BaseVCC_AS_req_W[hour] = electricity_output['E_BaseVCC_AS_req_W']
                E_PeakVCC_AS_req_W[hour] = electricity_output['E_PeakVCC_AS_req_W']
                E_Trigen_NG_gen_W[hour] = electricity_output['E_Trigen_NG_gen_W']

                NG_Trigen_req_W[hour] = gas_output['NG_Trigen_req_W']

        #calculate the electrical capacity as a function of the peak produced by the turbine
        master_to_slave_variables.NG_Trigen_CCGT_size_electrical_W = E_Trigen_NG_gen_W.max()

        # BACK-UPP VCC - AIR SOURCE
        scale = 'DISTRICT'
        master_to_slave_variables.AS_BackupVCC_size_W = np.amax(Q_BackupVCC_AS_gen_W)
        size_chiller_CT = master_to_slave_variables.AS_BackupVCC_size_W
        if master_to_slave_variables.AS_BackupVCC_size_W != 0.0:
            master_to_slave_variables.AS_BackupVCC_on = 1
            Q_BackupVCC_AS_gen_W, E_BackupVCC_AS_req_W = np.vectorize(calc_vcc_CT_operation)(Q_BackupVCC_AS_gen_W,
                                                                                             T_district_cooling_return_K,
                                                                                             T_district_cooling_supply_K,
                                                                                             VCC_T_COOL_IN,
                                                                                             size_chiller_CT,
                                                                                             min_VCC_capacity,
                                                                                             max_VCC_capacity,
                                                                                             scale)
        else:
            E_BackupVCC_AS_req_W = np.zeros(HOURS_IN_YEAR)

        # CAPEX (ANNUAL, TOTAL) AND OPEX (FIXED, VAR, ANNUAL) GENERATION UNITS
        supply_systems = SupplySystemsDatabase(locator)
        mdotnMax_kgpers = np.amax(mdot_kgpers)
        performance_costs_generation, \
        district_cooling_capacity_installed = cost_model.calc_generation_costs_capacity_installed_cooling(locator,
                                                                                                          master_to_slave_variables,
                                                                                                          supply_systems,
                                                                                                          mdotnMax_kgpers
                                                                                                          )
        # CAPEX (ANNUAL, TOTAL) AND OPEX (FIXED, VAR, ANNUAL) STORAGE UNITS
        performance_costs_storage = cost_model.calc_generation_costs_cooling_storage(locator,
                                                                                     master_to_slave_variables,
                                                                                     config,
                                                                                     daily_storage
                                                                                     )

        # CAPEX (ANNUAL, TOTAL) AND OPEX (FIXED, VAR, ANNUAL) NETWORK
        performance_costs_network, \
        E_used_district_cooling_network_W = cost_model.calc_network_costs_cooling(locator,
                                                                                  master_to_slave_variables,
                                                                                  network_features,
                                                                                  "DC",
                                                                                  prices)

        # MERGE COSTS AND EMISSIONS IN ONE FILE
        performance = dict(performance_costs_generation, **performance_costs_storage)
        district_cooling_costs = dict(performance, **performance_costs_network)
    else:
        Q_thermal_req_W = np.zeros(HOURS_IN_YEAR)
        Q_DailyStorage_gen_directload_W = np.zeros(HOURS_IN_YEAR)
        Q_Trigen_NG_gen_directload_W = np.zeros(HOURS_IN_YEAR)
        Q_BaseVCC_WS_gen_directload_W = np.zeros(HOURS_IN_YEAR)
        Q_PeakVCC_WS_gen_directload_W = np.zeros(HOURS_IN_YEAR)
        Q_BaseVCC_AS_gen_directload_W = np.zeros(HOURS_IN_YEAR)
        Q_PeakVCC_AS_gen_directload_W = np.zeros(HOURS_IN_YEAR)
        Q_BackupVCC_AS_directload_W = np.zeros(HOURS_IN_YEAR)
        Q_Trigen_NG_gen_W = np.zeros(HOURS_IN_YEAR)
        Q_BaseVCC_WS_gen_W = np.zeros(HOURS_IN_YEAR)
        Q_PeakVCC_WS_gen_W = np.zeros(HOURS_IN_YEAR)
        Q_BaseVCC_AS_gen_W = np.zeros(HOURS_IN_YEAR)
        Q_PeakVCC_AS_gen_W = np.zeros(HOURS_IN_YEAR)
        Q_BackupVCC_AS_gen_W = np.zeros(HOURS_IN_YEAR)
        E_Trigen_NG_gen_W = np.zeros(HOURS_IN_YEAR)
        E_used_district_cooling_network_W = np.zeros(HOURS_IN_YEAR)
        E_BaseVCC_WS_req_W = np.zeros(HOURS_IN_YEAR)
        E_PeakVCC_WS_req_W = np.zeros(HOURS_IN_YEAR)
        E_BaseVCC_AS_req_W = np.zeros(HOURS_IN_YEAR)
        E_PeakVCC_AS_req_W = np.zeros(HOURS_IN_YEAR)
        E_BackupVCC_AS_req_W = np.zeros(HOURS_IN_YEAR)
        NG_Trigen_req_W = np.zeros(HOURS_IN_YEAR)
        district_cooling_costs = {}
        district_cooling_capacity_installed = {}

    # SAVE
    district_cooling_generation_dispatch = {
        # demand of the network
        "Q_districtcooling_sys_req_W": Q_thermal_req_W,

        # ENERGY GENERATION TO DIRECT LOAD
        # from storage
        "Q_DailyStorage_gen_directload_W": Q_DailyStorage_gen_directload_W,
        # cooling
        "Q_Trigen_NG_gen_directload_W": Q_Trigen_NG_gen_directload_W,
        "Q_BaseVCC_WS_gen_directload_W": Q_BaseVCC_WS_gen_directload_W,
        "Q_PeakVCC_WS_gen_directload_W": Q_PeakVCC_WS_gen_directload_W,
        "Q_BaseVCC_AS_gen_directload_W": Q_BaseVCC_AS_gen_directload_W,
        "Q_PeakVCC_AS_gen_directload_W": Q_PeakVCC_AS_gen_directload_W,
        "Q_BackupVCC_AS_directload_W": Q_BackupVCC_AS_directload_W,

        # ENERGY GENERATION TOTAL
        # cooling
        "Q_Trigen_NG_gen_W": Q_Trigen_NG_gen_W,
        "Q_BaseVCC_WS_gen_W": Q_BaseVCC_WS_gen_W,
        "Q_PeakVCC_WS_gen_W": Q_PeakVCC_WS_gen_W,
        "Q_BaseVCC_AS_gen_W": Q_BaseVCC_AS_gen_W,
        "Q_PeakVCC_AS_gen_W": Q_PeakVCC_AS_gen_W,
        "Q_BackupVCC_AS_W": Q_BackupVCC_AS_gen_W,

        # electricity
        "E_Trigen_NG_gen_W": E_Trigen_NG_gen_W
    }

    district_cooling_electricity_requirements_dispatch = {
        # ENERGY REQUIREMENTS
        # Electricity
        "E_DCN_req_W": E_used_district_cooling_network_W,
        "E_BaseVCC_WS_req_W": E_BaseVCC_WS_req_W,
        "E_PeakVCC_WS_req_W": E_PeakVCC_WS_req_W,
        "E_BaseVCC_AS_req_W": E_BaseVCC_AS_req_W,
        "E_PeakVCC_AS_req_W": E_PeakVCC_AS_req_W,
        "E_BackupVCC_AS_req_W": E_BackupVCC_AS_req_W,
    }

    district_cooling_fuel_requirements_dispatch = {
        # fuels
        "NG_Trigen_req_W": NG_Trigen_req_W
    }

    # PLOT RESULTS

    return district_cooling_costs, \
           district_cooling_generation_dispatch, \
           district_cooling_electricity_requirements_dispatch, \
           district_cooling_fuel_requirements_dispatch, \
           district_cooling_capacity_installed
Beispiel #2
0
def disconnected_buildings_cooling_main(locator, building_names, total_demand, config, prices, lca):
    """
    Computes the parameters for the operation of disconnected buildings output results in csv files.
    There is no optimization at this point. The different cooling energy supply system configurations are calculated
    and compared 1 to 1 to each other. it is a classical combinatorial problem.
    The six supply system configurations include:
    (VCC: Vapor Compression Chiller, ACH: Absorption Chiller, CT: Cooling Tower, Boiler)
    (AHU: Air Handling Units, ARU: Air Recirculation Units, SCU: Sensible Cooling Units)
    - config 0: Direct Expansion / Mini-split units (NOTE: this configuration is not fully built yet)
    - config 1: VCC_to_AAS (AHU + ARU + SCU) + CT
    - config 2: FP + single-effect ACH_to_AAS (AHU + ARU + SCU) + Boiler + CT
    - config 3: ET + single-effect ACH_to_AAS (AHU + ARU + SCU) + Boiler + CT
    - config 4: VCC_to_AA (AHU + ARU) + VCC_to_S (SCU) + CT
    - config 5: VCC_to_AA (AHU + ARU) + single effect ACH_S (SCU) + CT + Boiler

    Note:
    1. Only cooling supply configurations are compared here. The demand for electricity is supplied from the grid,
    and the demand for domestic hot water is supplied from electric boilers.
    2. Single-effect chillers are coupled with flat-plate solar collectors, and the double-effect chillers are coupled
    with evacuated tube solar collectors.
    :param locator: locator class with paths to input/output files
    :param building_names: list with names of buildings
    :param config: cea.config
    :param prices: prices class
    :return: one .csv file with results of operations of disconnected buildings; one .csv file with operation of the
    best configuration (Cost, CO2, Primary Energy)
    """

    t0 = time.clock()
    for building_name in building_names:
        ## Calculate cooling loads for different combinations
        # SENSIBLE COOLING UNIT
        Qc_nom_SCU_W, \
        T_re_SCU_K, \
        T_sup_SCU_K, \
        mdot_SCU_kgpers = calc_combined_cooling_loads(building_name, locator, total_demand,
                                                      cooling_configuration=['scu'])
        # AIR HANDLING UNIT + AIR RECIRCULATION UNIT
        Qc_nom_AHU_ARU_W, \
        T_re_AHU_ARU_K, \
        T_sup_AHU_ARU_K, \
        mdot_AHU_ARU_kgpers = calc_combined_cooling_loads(building_name, locator, total_demand,
                                                          cooling_configuration=['ahu', 'aru'])
        # SENSIBLE COOLING UNIT + AIR HANDLING UNIT + AIR RECIRCULATION UNIT
        Qc_nom_AHU_ARU_SCU_W, \
        T_re_AHU_ARU_SCU_K, \
        T_sup_AHU_ARU_SCU_K, \
        mdot_AHU_ARU_SCU_kgpers = calc_combined_cooling_loads(building_name, locator, total_demand,
                                                              cooling_configuration=['ahu', 'aru', 'scu'])

        ## Get hourly hot water supply condition of Solar Collectors (SC)
        # Flate Plate Solar Collectors
        SC_FP_data, T_hw_in_FP_C, el_aux_SC_FP_Wh, q_sc_gen_FP_Wh = get_SC_data(building_name, locator, panel_type="FP")
        Capex_a_SC_FP_USD, Opex_SC_FP_USD, Capex_SC_FP_USD = solar_collector.calc_Cinv_SC(SC_FP_data['Area_SC_m2'][0],
                                                                                          locator,
                                                                                          panel_type="FP")

        # Evacuated Tube Solar Collectors
        SC_ET_data, T_hw_in_ET_C, el_aux_SC_ET_Wh, q_sc_gen_ET_Wh = get_SC_data(building_name, locator, panel_type="ET")
        Capex_a_SC_ET_USD, Opex_SC_ET_USD, Capex_SC_ET_USD = solar_collector.calc_Cinv_SC(SC_ET_data['Area_SC_m2'][0],
                                                                                          locator,
                                                                                          panel_type="ET")


        ## Calculate ground temperatures to estimate cold water supply temperatures for absorption chiller
        T_ground_K = calculate_ground_temperature(locator,
                                                  config)  # FIXME: change to outlet temperature from the cooling towers

        ## Initialize table to save results
        # save costs of all supply configurations
        operation_results = initialize_result_tables_for_supply_configurations(Qc_nom_SCU_W)
        # save supply system activation of all supply configurations
        cooling_dispatch = {}

        ## HOURLY OPERATION
        print building_name, ' decentralized cooling supply system simulations...'
        T_re_AHU_ARU_SCU_K = np.where(T_re_AHU_ARU_SCU_K > 0.0, T_re_AHU_ARU_SCU_K, T_sup_AHU_ARU_SCU_K)

        ## 0. DX operation
        print 'Config 0: Direct Expansion Units -> AHU,ARU,SCU'
        el_DX_hourly_Wh,\
        q_DX_chw_Wh = np.vectorize(dx.calc_DX)(mdot_AHU_ARU_SCU_kgpers, T_sup_AHU_ARU_SCU_K, T_re_AHU_ARU_SCU_K)
        DX_Status = np.where(q_DX_chw_Wh > 0.0, 1, 0)
        # add electricity costs, CO2, PE
        operation_results[0][7] += sum(lca.ELEC_PRICE * el_DX_hourly_Wh)
        operation_results[0][8] += sum(el_DX_hourly_Wh * WH_TO_J / 1E6 * lca.EL_TO_CO2 / 1E3)  # ton CO2
        operation_results[0][9] += sum(el_DX_hourly_Wh * WH_TO_J / 1E6 * lca.EL_TO_OIL_EQ)  # MJ oil
        # activation
        cooling_dispatch[0] = {'Q_DX_gen_directload_W': q_DX_chw_Wh,
                               'E_DX_req_W': el_DX_hourly_Wh,
                               'DX_Status': DX_Status,
                               'E_cs_cre_cdata_req_W': el_DX_hourly_Wh,
                               }

        ## 1. VCC (AHU + ARU + SCU) + CT
        print 'Config 1: Vapor Compression Chillers -> AHU,ARU,SCU'
        # VCC operation
        el_VCC_Wh, q_VCC_cw_Wh, q_VCC_chw_Wh = calc_VCC_operation(T_re_AHU_ARU_SCU_K, T_sup_AHU_ARU_SCU_K,
                                                                  mdot_AHU_ARU_SCU_kgpers)
        VCC_Status = np.where(q_VCC_chw_Wh > 0.0, 1, 0)
        # CT operation
        q_CT_VCC_to_AHU_ARU_SCU_Wh = q_VCC_cw_Wh
        Q_nom_CT_VCC_to_AHU_ARU_SCU_W, el_CT_Wh = calc_CT_operation(q_CT_VCC_to_AHU_ARU_SCU_Wh)
        # add costs
        el_total_Wh = el_VCC_Wh + el_CT_Wh
        operation_results[1][7] += sum(lca.ELEC_PRICE * el_total_Wh)  # CHF
        operation_results[1][8] += sum(el_total_Wh * WH_TO_J / 1E6 * lca.EL_TO_CO2 / 1E3)  # ton CO2
        operation_results[1][9] += sum(el_total_Wh * WH_TO_J / 1E6 * lca.EL_TO_OIL_EQ)  # MJ-oil-eq
        cooling_dispatch[1] = {'Q_VCC_gen_directload_W': q_VCC_chw_Wh,
                               'E_VCC_req_W': el_VCC_Wh,
                               'E_CT_req_W': el_CT_Wh,
                               'E_cs_cre_cdata_req_W': el_total_Wh,
                               'VCC_Status': VCC_Status
                               }

        ## 2: SC_FP + single-effect ACH (AHU + ARU + SCU) + CT + Boiler + SC_FP
        print 'Config 2: Flat-plate Solar Collectors + Single-effect Absorption chillers -> AHU,ARU,SCU'
        # ACH operation
        T_hw_out_single_ACH_K, \
        el_single_ACH_Wh, \
        q_cw_single_ACH_Wh, \
        q_hw_single_ACH_Wh,\
        q_chw_single_ACH_Wh = calc_ACH_operation(T_ground_K, T_hw_in_FP_C, T_re_AHU_ARU_SCU_K, T_sup_AHU_ARU_SCU_K,
                                                 locator, mdot_AHU_ARU_SCU_kgpers, ACH_TYPE_SINGLE)

        ACH_Status = np.where(q_chw_single_ACH_Wh > 0.0, 1, 0)
        # CT operation
        q_CT_FP_to_single_ACH_to_AHU_ARU_SCU_Wh = q_cw_single_ACH_Wh
        Q_nom_CT_FP_to_single_ACH_to_AHU_ARU_SCU_W, el_CT_Wh = calc_CT_operation(
            q_CT_FP_to_single_ACH_to_AHU_ARU_SCU_Wh)
        # boiler operation
        q_gas_Boiler_FP_to_single_ACH_to_AHU_ARU_SCU_Wh, \
        Q_nom_Boiler_FP_to_single_ACH_to_AHU_ARU_SCU_W, \
        q_load_Boiler_FP_to_single_ACH_to_AHU_ARU_SCU_Wh = calc_boiler_operation(Qc_nom_AHU_ARU_SCU_W,
                                                                                 T_hw_out_single_ACH_K,
                                                                                 q_hw_single_ACH_Wh,
                                                                                 q_sc_gen_FP_Wh)
        # add electricity costs
        el_total_Wh = el_single_ACH_Wh + el_aux_SC_FP_Wh + el_CT_Wh
        operation_results[2][7] += sum(lca.ELEC_PRICE * el_total_Wh)  # CHF
        operation_results[2][8] += sum(el_total_Wh * WH_TO_J / 1E6 * lca.EL_TO_CO2 / 1E3)  # ton CO2
        operation_results[2][9] += sum(el_total_Wh * WH_TO_J / 1E6 * lca.EL_TO_OIL_EQ)  # MJ-oil-eq
        # add gas costs
        q_gas_total_Wh = q_gas_Boiler_FP_to_single_ACH_to_AHU_ARU_SCU_Wh
        operation_results[2][7] += sum(prices.NG_PRICE * q_gas_total_Wh)  # CHF
        operation_results[2][8] += sum(q_gas_total_Wh * WH_TO_J / 1E6 * lca.NG_BACKUPBOILER_TO_CO2_STD / 1E3)  # ton CO2
        operation_results[2][9] += sum(q_gas_total_Wh * WH_TO_J / 1E6 * lca.NG_BACKUPBOILER_TO_OIL_STD)  # MJ-oil-eq
        # add activation
        cooling_dispatch[2] = {'Q_ACH_gen_directload_W': q_chw_single_ACH_Wh,
                               'ACH_Status': ACH_Status,
                               'Q_Boiler_ACH_W': q_load_Boiler_FP_to_single_ACH_to_AHU_ARU_SCU_Wh,
                               'Q_SC_FP_ACH_W': q_sc_gen_FP_Wh,
                               'E_ACH_req_W': el_single_ACH_Wh,
                               'E_CT_req_W': el_CT_Wh,
                               'E_SC_FP_req_W': el_aux_SC_FP_Wh,
                               'E_cs_cre_cdata_req_W': el_total_Wh,
                               'NG_Boiler_req': q_gas_Boiler_FP_to_single_ACH_to_AHU_ARU_SCU_Wh,
                               }

        # 3: SC_ET + single-effect ACH (AHU + ARU + SCU) + CT + Boiler + SC_ET
        print 'Config 3: Evacuated Tube Solar Collectors + Single-effect Absorption chillers -> AHU,ARU,SCU'
        # ACH operation
        T_hw_out_single_ACH_K, \
        el_single_ACH_Wh, \
        q_cw_single_ACH_Wh, \
        q_hw_single_ACH_Wh,\
        q_chw_single_ACH_Wh = calc_ACH_operation(T_ground_K, T_hw_in_ET_C, T_re_AHU_ARU_SCU_K, T_sup_AHU_ARU_SCU_K,
                                                 locator, mdot_AHU_ARU_SCU_kgpers, ACH_TYPE_SINGLE)
        # CT operation
        q_CT_ET_to_single_ACH_to_AHU_ARU_SCU_W = q_cw_single_ACH_Wh
        Q_nom_CT_ET_to_single_ACH_to_AHU_ARU_SCU_W, el_CT_Wh = calc_CT_operation(q_CT_ET_to_single_ACH_to_AHU_ARU_SCU_W)
        # burner operation
        q_gas_for_burner_Wh, \
        Q_nom_Burner_ET_to_single_ACH_to_AHU_ARU_SCU_W,\
        q_burner_load_Wh = calc_burner_operation(Qc_nom_AHU_ARU_SCU_W, q_hw_single_ACH_Wh, q_sc_gen_ET_Wh)
        # add electricity costs
        el_total_Wh = el_single_ACH_Wh + el_aux_SC_ET_Wh + el_CT_Wh
        operation_results[3][7] += sum(lca.ELEC_PRICE * el_total_Wh)  # CHF
        operation_results[3][8] += sum(el_total_Wh * WH_TO_J / 1E6 * lca.EL_TO_CO2 / 1E3)  # ton CO2
        operation_results[3][9] += sum(el_total_Wh * WH_TO_J / 1E6 * lca.EL_TO_OIL_EQ)  # MJ-oil-eq
        # add gas costs
        operation_results[3][7] += sum(prices.NG_PRICE * q_gas_for_burner_Wh)  # CHF
        operation_results[3][8] += sum(
            q_gas_for_burner_Wh * WH_TO_J / 1E6 * lca.NG_BACKUPBOILER_TO_CO2_STD / 1E3)  # ton CO2
        operation_results[3][9] += sum(
            q_gas_for_burner_Wh * WH_TO_J / 1E6 * lca.NG_BACKUPBOILER_TO_OIL_STD)  # MJ-oil-eq
        # add activation
        cooling_dispatch[3] = {'Q_ACH_gen_directload_W': q_chw_single_ACH_Wh,
                               'ACH_Status': ACH_Status,
                               'Q_Burner_ACH_W': q_burner_load_Wh,
                               'Q_SC_ET_ACH_W': q_sc_gen_ET_Wh,
                               'E_ACH_req_W': el_single_ACH_Wh,
                               'E_CT_req_W': el_CT_Wh,
                               'E_SC_FP_req_W': el_aux_SC_ET_Wh,
                               'E_cs_cre_cdata_req_W': el_total_Wh,
                               'NG_Burner_req': q_gas_for_burner_Wh,
                               }

        # these two configurations are only activated when SCU is in use
        if Qc_nom_SCU_W > 0.0:
            # 4: VCC (AHU + ARU) + VCC (SCU) + CT
            print 'Config 4: Vapor Compression Chillers(HT) -> SCU & Vapor Compression Chillers(LT) -> AHU,ARU'
            # VCC (AHU + ARU) operation
            el_VCC_to_AHU_ARU_Wh, \
            q_cw_VCC_to_AHU_ARU_Wh,\
            q_chw_VCC_to_AHU_ARU_Wh = calc_VCC_operation(T_re_AHU_ARU_K, T_sup_AHU_ARU_K, mdot_AHU_ARU_kgpers)
            VCC_LT_Status = np.where(q_chw_VCC_to_AHU_ARU_Wh > 0.0, 1, 0)
            # VCC(SCU) operation
            el_VCC_to_SCU_Wh, \
            q_cw_VCC_to_SCU_Wh,\
            q_chw_VCC_to_SCU_Wh = calc_VCC_operation(T_re_SCU_K, T_sup_SCU_K, mdot_SCU_kgpers)
            VCC_HT_Status = np.where(q_chw_VCC_to_AHU_ARU_Wh > 0.0, 1, 0)
            # CT operation
            q_CT_VCC_to_AHU_ARU_and_VCC_to_SCU_W = q_cw_VCC_to_AHU_ARU_Wh + q_cw_VCC_to_SCU_Wh
            Q_nom_CT_VCC_to_AHU_ARU_and_VCC_to_SCU_W, el_CT_Wh = calc_CT_operation(q_CT_VCC_to_AHU_ARU_and_VCC_to_SCU_W)
            # add el costs
            el_total_Wh = el_VCC_to_AHU_ARU_Wh + el_VCC_to_SCU_Wh + el_CT_Wh
            operation_results[4][7] += sum(lca.ELEC_PRICE * el_total_Wh)  # CHF
            operation_results[4][8] += sum(el_total_Wh * WH_TO_J / 1E6 * lca.EL_TO_CO2 / 1E3)  # ton CO2
            operation_results[4][9] += sum(el_total_Wh * WH_TO_J / 1E6 * lca.EL_TO_OIL_EQ)  # MJ-oil-eq
            # add activation
            cooling_dispatch[4] = {'Q_VCC_LT_gen_directload_W': q_chw_VCC_to_AHU_ARU_Wh,
                                   'Q_VCC_HT_gen_directload_W': q_chw_VCC_to_SCU_Wh,
                                   'VCC_LT_Status': VCC_LT_Status,
                                   'VCC_HT_Status': VCC_HT_Status,
                                   'E_VCC_LT_req_W': el_VCC_to_AHU_ARU_Wh,
                                   'E_VCC_HT_req_W': el_VCC_to_SCU_Wh,
                                   'E_CT_req_W': el_CT_Wh,
                                   'E_cs_cre_cdata_req_W': el_total_Wh
                                   }

            # 5: VCC (AHU + ARU) + ACH (SCU) + CT
            print 'Config 5: Vapor Compression Chillers(LT) -> AHU,ARU & Flate-place SC + Absorption Chillers(HT) -> SCU'
            # ACH (SCU) operation
            T_hw_FP_ACH_to_SCU_K, \
            el_FP_ACH_to_SCU_Wh, \
            q_cw_FP_ACH_to_SCU_Wh, \
            q_hw_FP_ACH_to_SCU_Wh,\
            q_chw_FP_ACH_to_SCU_Wh = calc_ACH_operation(T_ground_K, T_hw_in_FP_C, T_re_SCU_K, T_sup_SCU_K, locator,
                                                        mdot_SCU_kgpers, ACH_TYPE_SINGLE)
            ACH_HT_Status = np.where(q_chw_FP_ACH_to_SCU_Wh > 0.0, 1, 0)
            # boiler operation
            q_gas_for_boiler_Wh, \
            Q_nom_boiler_VCC_to_AHU_ARU_and_FP_to_single_ACH_to_SCU_W,\
            q_load_from_boiler_Wh = calc_boiler_operation(Qc_nom_SCU_W, T_hw_FP_ACH_to_SCU_K,
                                                          q_hw_FP_ACH_to_SCU_Wh, q_sc_gen_FP_Wh)
            # CT operation
            q_CT_VCC_to_AHU_ARU_and_single_ACH_to_SCU_Wh = q_cw_VCC_to_AHU_ARU_Wh + q_cw_FP_ACH_to_SCU_Wh
            Q_nom_CT_VCC_to_AHU_ARU_and_FP_to_single_ACH_to_SCU_W, \
            el_CT_Wh = calc_CT_operation(q_CT_VCC_to_AHU_ARU_and_single_ACH_to_SCU_Wh)

            # add electricity costs
            el_total_Wh = el_VCC_to_AHU_ARU_Wh + el_FP_ACH_to_SCU_Wh + el_aux_SC_FP_Wh + el_CT_Wh
            operation_results[5][7] += sum(lca.ELEC_PRICE * el_total_Wh)  # CHF
            operation_results[5][8] += sum(el_total_Wh * WH_TO_J / 1E6 * lca.EL_TO_CO2 / 1E3)  # ton CO2
            operation_results[5][9] += sum(el_total_Wh * WH_TO_J / 1E6 * lca.EL_TO_OIL_EQ)  # MJ-oil-eq
            # add gas costs
            q_gas_total_Wh = q_gas_for_boiler_Wh
            operation_results[5][7] += sum(prices.NG_PRICE * q_gas_total_Wh)  # CHF
            operation_results[5][8] += sum(
                q_gas_total_Wh * WH_TO_J / 1E6 * lca.NG_BACKUPBOILER_TO_CO2_STD / 1E3)  # ton CO2
            operation_results[5][9] += sum(q_gas_total_Wh * WH_TO_J / 1E6 * lca.NG_BACKUPBOILER_TO_OIL_STD)  # MJ-oil-eq
            # add activation
            cooling_dispatch[5] = {'Q_VCC_LT_gen_directload_W': q_chw_VCC_to_AHU_ARU_Wh,
                                   'Q_ACH_HT_gen_directload_W': q_chw_FP_ACH_to_SCU_Wh,
                                   'VCC_LT_Status': VCC_LT_Status,
                                   'ACH_HT_Status': ACH_HT_Status,
                                   'E_VCC_LT_req_W': el_VCC_to_AHU_ARU_Wh,
                                   'E_ACH_HT_req_W': el_FP_ACH_to_SCU_Wh,
                                   'E_SC_FP_req_W': el_aux_SC_FP_Wh,
                                   'E_CT_req_W': el_CT_Wh,
                                   'E_cs_cre_cdata_req_W': el_total_Wh,
                                   'NG_Boiler_req': q_gas_for_boiler_Wh,
                                   }

        ## Calculate Capex/Opex
        # Initialize arrays
        number_of_configurations = len(operation_results)
        Capex_a_USD = np.zeros((number_of_configurations, 1))
        Capex_total_USD = np.zeros((number_of_configurations, 1))
        Opex_a_fixed_USD = np.zeros((number_of_configurations, 1))

        print 'Cost calculation...'
        # 0: DX
        Capex_a_DX_USD, Opex_fixed_DX_USD, Capex_DX_USD = dx.calc_Cinv_DX(Qc_nom_AHU_ARU_SCU_W)
        # add costs
        Capex_a_USD[0][0] = Capex_a_DX_USD
        Capex_total_USD[0][0] = Capex_DX_USD
        Opex_a_fixed_USD[0][0] = Opex_fixed_DX_USD

        # 1: VCC + CT
        Capex_a_VCC_USD, Opex_fixed_VCC_USD, Capex_VCC_USD = chiller_vapor_compression.calc_Cinv_VCC(
            Qc_nom_AHU_ARU_SCU_W, locator, config, 'CH3')
        Capex_a_CT_USD, Opex_fixed_CT_USD, Capex_CT_USD = cooling_tower.calc_Cinv_CT(
            Q_nom_CT_VCC_to_AHU_ARU_SCU_W, locator, 'CT1')
        # add costs
        Capex_a_USD[1][0] = Capex_a_CT_USD + Capex_a_VCC_USD
        Capex_total_USD[1][0] = Capex_CT_USD + Capex_VCC_USD
        Opex_a_fixed_USD[1][0] = Opex_fixed_CT_USD + Opex_fixed_VCC_USD

        # 2: single effect ACH + CT + Boiler + SC_FP
        Capex_a_ACH_USD, Opex_fixed_ACH_USD, Capex_ACH_USD = chiller_absorption.calc_Cinv_ACH(
            Qc_nom_AHU_ARU_SCU_W, locator, ACH_TYPE_SINGLE)
        Capex_a_CT_USD, Opex_fixed_CT_USD, Capex_CT_USD = cooling_tower.calc_Cinv_CT(
            Q_nom_CT_FP_to_single_ACH_to_AHU_ARU_SCU_W, locator, 'CT1')
        Capex_a_boiler_USD, Opex_fixed_boiler_USD, Capex_boiler_USD = boiler.calc_Cinv_boiler(
            Q_nom_Boiler_FP_to_single_ACH_to_AHU_ARU_SCU_W, locator, config, 'BO1')
        Capex_a_USD[2][0] = Capex_a_CT_USD + Capex_a_ACH_USD + Capex_a_boiler_USD + Capex_a_SC_FP_USD
        Capex_total_USD[2][0] = Capex_CT_USD + Capex_ACH_USD + Capex_boiler_USD + Capex_SC_FP_USD
        Opex_a_fixed_USD[2][
            0] = Opex_fixed_CT_USD + Opex_fixed_ACH_USD + Opex_fixed_boiler_USD + Opex_SC_FP_USD

        # 3: double effect ACH + CT + Boiler + SC_ET
        Capex_a_ACH_USD, Opex_fixed_ACH_USD, Capex_ACH_USD = chiller_absorption.calc_Cinv_ACH(
            Qc_nom_AHU_ARU_SCU_W, locator, ACH_TYPE_SINGLE)
        Capex_a_CT_USD, Opex_fixed_CT_USD, Capex_CT_USD = cooling_tower.calc_Cinv_CT(
            Q_nom_CT_ET_to_single_ACH_to_AHU_ARU_SCU_W, locator, 'CT1')
        Capex_a_burner_USD, Opex_fixed_burner_USD, Capex_burner_USD = burner.calc_Cinv_burner(
            Q_nom_Burner_ET_to_single_ACH_to_AHU_ARU_SCU_W, locator, config, 'BO1')
        Capex_a_USD[3][0] = Capex_a_CT_USD + Capex_a_ACH_USD + Capex_a_burner_USD + Capex_a_SC_ET_USD
        Capex_total_USD[3][0] = Capex_CT_USD + Capex_ACH_USD + Capex_burner_USD + Capex_SC_ET_USD
        Opex_a_fixed_USD[3][
            0] = Opex_fixed_CT_USD + Opex_fixed_ACH_USD + Opex_fixed_burner_USD + Opex_SC_ET_USD

        # these two configurations are only activated when SCU is in use
        if Qc_nom_SCU_W > 0.0:
            # 4: VCC (AHU + ARU) + VCC (SCU) + CT
            Capex_a_VCC_AA_USD, Opex_VCC_AA_USD, Capex_VCC_AA_USD = chiller_vapor_compression.calc_Cinv_VCC(
                Qc_nom_AHU_ARU_W, locator, config, 'CH3')
            Capex_a_VCC_S_USD, Opex_VCC_S_USD, Capex_VCC_S_USD = chiller_vapor_compression.calc_Cinv_VCC(
                Qc_nom_SCU_W, locator, config, 'CH3')
            Capex_a_CT_USD, Opex_fixed_CT_USD, Capex_CT_USD = cooling_tower.calc_Cinv_CT(
                Q_nom_CT_VCC_to_AHU_ARU_and_VCC_to_SCU_W, locator, 'CT1')
            Capex_a_USD[4][0] = Capex_a_CT_USD + Capex_a_VCC_AA_USD + Capex_a_VCC_S_USD
            Capex_total_USD[4][0] = Capex_CT_USD + Capex_VCC_AA_USD + Capex_VCC_S_USD
            Opex_a_fixed_USD[4][0] = Opex_fixed_CT_USD + Opex_VCC_AA_USD + Opex_VCC_S_USD

            # 5: VCC (AHU + ARU) + ACH (SCU) + CT + Boiler + SC_FP
            Capex_a_ACH_S_USD, Opex_fixed_ACH_S_USD, Capex_ACH_S_USD = chiller_absorption.calc_Cinv_ACH(
                Qc_nom_SCU_W, locator, ACH_TYPE_SINGLE)
            Capex_a_CT_USD, Opex_fixed_CT_USD, Capex_CT_USD = cooling_tower.calc_Cinv_CT(
                Q_nom_CT_VCC_to_AHU_ARU_and_FP_to_single_ACH_to_SCU_W, locator, 'CT1')
            Capex_a_boiler_USD, Opex_fixed_boiler_USD, Capex_boiler_USD = boiler.calc_Cinv_boiler(
                Q_nom_boiler_VCC_to_AHU_ARU_and_FP_to_single_ACH_to_SCU_W, locator, config, 'BO1')
            Capex_a_USD[5][0] = Capex_a_CT_USD + Capex_a_VCC_AA_USD + Capex_a_ACH_S_USD + \
                                Capex_a_SC_FP_USD + Capex_a_boiler_USD
            Capex_total_USD[5][0] = Capex_CT_USD + Capex_VCC_AA_USD + Capex_ACH_S_USD + \
                                    Capex_SC_FP_USD + Capex_boiler_USD
            Opex_a_fixed_USD[5][0] = Opex_fixed_CT_USD + Opex_VCC_AA_USD + Opex_fixed_ACH_S_USD + \
                                     Opex_SC_FP_USD + Opex_fixed_boiler_USD

        ## write all results from the configurations into TotalCosts, TotalCO2, TotalPrim
        Opex_a_USD, TAC_USD, TotalCO2, TotalPrim = compile_TAC_CO2_Prim(Capex_a_USD, Opex_a_fixed_USD,
                                                                        number_of_configurations, operation_results)

        ## Determine the best configuration
        Best, indexBest = rank_results(TAC_USD, TotalCO2, TotalPrim, number_of_configurations)

        # Save results in csv file
        performance_results = {
            "DX to AHU_ARU_SCU Share": operation_results[:, 0],
            "VCC to AHU_ARU_SCU Share": operation_results[:, 1],
            "single effect ACH to AHU_ARU_SCU Share (FP)": operation_results[:, 2],
            "single effect ACH to AHU_ARU_SCU Share (ET)": operation_results[:, 3],
            "VCC to AHU_ARU Share": operation_results[:, 4],
            "VCC to SCU Share": operation_results[:, 5],
            "single effect ACH to SCU Share (FP)": operation_results[:, 6],
            "Capex_a_USD": Capex_a_USD[:, 0],
            "Capex_total_USD": Capex_total_USD[:, 0],
            "Opex_a_USD": Opex_a_USD[:, 1],
            "Opex_a_fixed_USD": Opex_a_fixed_USD[:, 0],
            "Opex_a_var_USD": operation_results[:, 7],
            "GHG_tonCO2": operation_results[:, 8],
            "PEN_MJoil": operation_results[:, 9],
            "TAC_USD": TAC_USD[:, 1],
            "Best configuration": Best[:, 0]
        }
        performance_results_df = pd.DataFrame(performance_results)
        performance_results_df.to_csv(
            locator.get_optimization_decentralized_folder_building_result_cooling(building_name))

        # save activation for the best supply system configuration
        best_activation_df = pd.DataFrame.from_dict(cooling_dispatch[indexBest])  #
        best_activation_df.to_csv(
            locator.get_optimization_decentralized_folder_building_cooling_activation(building_name))

    print time.clock() - t0, "seconds process time for the decentralized Building Routine \n"
Beispiel #3
0
def disconnected_cooling_for_building(building_name, supply_systems, lca,
                                      locator, prices, total_demand):
    chiller_prop = supply_systems.Absorption_chiller
    boiler_cost_data = supply_systems.Boiler

    scale = 'BUILDING'
    VCC_chiller = chiller_vapor_compression.VaporCompressionChiller(
        locator, scale)

    ## Calculate cooling loads for different combinations
    # SENSIBLE COOLING UNIT
    Qc_nom_SCU_W, \
    T_re_SCU_K, \
    T_sup_SCU_K, \
    mdot_SCU_kgpers = calc_combined_cooling_loads(building_name, locator, total_demand,
                                                  cooling_configuration=['scu'])
    # AIR HANDLING UNIT + AIR RECIRCULATION UNIT
    Qc_nom_AHU_ARU_W, \
    T_re_AHU_ARU_K, \
    T_sup_AHU_ARU_K, \
    mdot_AHU_ARU_kgpers = calc_combined_cooling_loads(building_name, locator, total_demand,
                                                      cooling_configuration=['ahu', 'aru'])
    # SENSIBLE COOLING UNIT + AIR HANDLING UNIT + AIR RECIRCULATION UNIT
    Qc_nom_AHU_ARU_SCU_W, \
    T_re_AHU_ARU_SCU_K, \
    T_sup_AHU_ARU_SCU_K, \
    mdot_AHU_ARU_SCU_kgpers = calc_combined_cooling_loads(building_name, locator, total_demand,
                                                          cooling_configuration=['ahu', 'aru', 'scu'])
    ## Get hourly hot water supply condition of Solar Collectors (SC)
    # Flate Plate Solar Collectors
    SC_FP_data, T_hw_in_FP_C, el_aux_SC_FP_Wh, q_sc_gen_FP_Wh = get_SC_data(
        building_name, locator, panel_type="FP")
    Capex_a_SC_FP_USD, Opex_SC_FP_USD, Capex_SC_FP_USD = solar_collector.calc_Cinv_SC(
        SC_FP_data['Area_SC_m2'][0], locator, panel_type="FP")
    # Evacuated Tube Solar Collectors
    SC_ET_data, T_hw_in_ET_C, el_aux_SC_ET_Wh, q_sc_gen_ET_Wh = get_SC_data(
        building_name, locator, panel_type="ET")
    Capex_a_SC_ET_USD, Opex_SC_ET_USD, Capex_SC_ET_USD = solar_collector.calc_Cinv_SC(
        SC_ET_data['Area_SC_m2'][0], locator, panel_type="ET")
    ## Calculate ground temperatures to estimate cold water supply temperatures for absorption chiller
    T_ground_K = calculate_ground_temperature(
        locator)  # FIXME: change to outlet temperature from the cooling towers
    ## Initialize table to save results
    # save costs of all supply configurations
    operation_results = initialize_result_tables_for_supply_configurations(
        Qc_nom_SCU_W)
    # save supply system activation of all supply configurations
    cooling_dispatch = {}
    ## HOURLY OPERATION
    print('{building_name} decentralized cooling supply system simulations...'.
          format(building_name=building_name))
    T_re_AHU_ARU_SCU_K = np.where(T_re_AHU_ARU_SCU_K > 0.0, T_re_AHU_ARU_SCU_K,
                                  T_sup_AHU_ARU_SCU_K)
    ## 0. DX operation
    print('{building_name} Config 0: Direct Expansion Units -> AHU,ARU,SCU'.
          format(building_name=building_name))
    el_DX_hourly_Wh, \
    q_DX_chw_Wh = np.vectorize(dx.calc_DX)(mdot_AHU_ARU_SCU_kgpers, T_sup_AHU_ARU_SCU_K, T_re_AHU_ARU_SCU_K)
    DX_Status = np.where(q_DX_chw_Wh > 0.0, 1, 0)
    # add electricity costs, CO2, PE
    operation_results[0][7] += sum(prices.ELEC_PRICE * el_DX_hourly_Wh)
    operation_results[0][8] += sum(
        calc_emissions_Whyr_to_tonCO2yr(el_DX_hourly_Wh,
                                        lca.EL_TO_CO2_EQ))  # ton CO2
    # activation
    cooling_dispatch[0] = {
        'Q_DX_AS_gen_directload_W': q_DX_chw_Wh,
        'E_DX_AS_req_W': el_DX_hourly_Wh,
        'E_cs_cre_cdata_req_W': el_DX_hourly_Wh,
    }
    # capacity of cooling technologies
    operation_results[0][0] = Qc_nom_AHU_ARU_SCU_W
    operation_results[0][1] = Qc_nom_AHU_ARU_SCU_W  # 1: DX_AS
    system_COP = np.nanmedian(
        np.divide(q_DX_chw_Wh[None, :], el_DX_hourly_Wh[None, :]).flatten())
    operation_results[0][9] += system_COP
    ## 1. VCC (AHU + ARU + SCU) + CT
    print(
        '{building_name} Config 1: Vapor Compression Chillers -> AHU,ARU,SCU'.
        format(building_name=building_name))
    # VCC operation
    el_VCC_Wh, q_VCC_cw_Wh, q_VCC_chw_Wh = calc_VCC_operation(
        T_re_AHU_ARU_SCU_K, T_sup_AHU_ARU_SCU_K, mdot_AHU_ARU_SCU_kgpers,
        VCC_chiller)
    VCC_Status = np.where(q_VCC_chw_Wh > 0.0, 1, 0)
    # CT operation
    q_CT_VCC_to_AHU_ARU_SCU_Wh = q_VCC_cw_Wh
    Q_nom_CT_VCC_to_AHU_ARU_SCU_W, el_CT_Wh = calc_CT_operation(
        q_CT_VCC_to_AHU_ARU_SCU_Wh)
    # add costs
    el_total_Wh = el_VCC_Wh + el_CT_Wh
    operation_results[1][7] += sum(prices.ELEC_PRICE * el_total_Wh)  # CHF
    operation_results[1][8] += sum(
        calc_emissions_Whyr_to_tonCO2yr(el_total_Wh,
                                        lca.EL_TO_CO2_EQ))  # ton CO2
    system_COP_list = np.divide(q_VCC_chw_Wh[None, :],
                                el_total_Wh[None, :]).flatten()
    system_COP = np.nansum(
        q_VCC_chw_Wh[None, :] * system_COP_list) / np.nansum(
            q_VCC_chw_Wh[None, :])  # weighted average of the system efficiency
    operation_results[1][9] += system_COP
    cooling_dispatch[1] = {
        'Q_BaseVCC_AS_gen_directload_W': q_VCC_chw_Wh,
        'E_BaseVCC_AS_req_W': el_VCC_Wh,
        'E_CT_req_W': el_CT_Wh,
        'E_cs_cre_cdata_req_W': el_total_Wh,
    }
    # capacity of cooling technologies
    operation_results[1][0] = Qc_nom_AHU_ARU_SCU_W
    operation_results[1][2] = Qc_nom_AHU_ARU_SCU_W  # 2: BaseVCC_AS
    ## 2: SC_FP + single-effect ACH (AHU + ARU + SCU) + CT + Boiler + SC_FP
    print(
        '{building_name} Config 2: Flat-plate Solar Collectors + Single-effect Absorption chillers -> AHU,ARU,SCU'
        .format(building_name=building_name))
    # ACH operation
    T_hw_out_single_ACH_K, \
    el_single_ACH_Wh, \
    q_cw_single_ACH_Wh, \
    q_hw_single_ACH_Wh, \
    q_chw_single_ACH_Wh = calc_ACH_operation(T_ground_K, T_hw_in_FP_C, T_re_AHU_ARU_SCU_K, T_sup_AHU_ARU_SCU_K,
                                             chiller_prop, mdot_AHU_ARU_SCU_kgpers, ACH_TYPE_SINGLE)
    ACH_Status = np.where(q_chw_single_ACH_Wh > 0.0, 1, 0)
    # CT operation
    q_CT_FP_to_single_ACH_to_AHU_ARU_SCU_Wh = q_cw_single_ACH_Wh
    Q_nom_CT_FP_to_single_ACH_to_AHU_ARU_SCU_W, el_CT_Wh = calc_CT_operation(
        q_CT_FP_to_single_ACH_to_AHU_ARU_SCU_Wh)
    # boiler operation
    q_gas_Boiler_FP_to_single_ACH_to_AHU_ARU_SCU_Wh, \
    Q_nom_Boiler_FP_to_single_ACH_to_AHU_ARU_SCU_W, \
    q_load_Boiler_FP_to_single_ACH_to_AHU_ARU_SCU_Wh = calc_boiler_operation(Qc_nom_AHU_ARU_SCU_W,
                                                                             T_hw_out_single_ACH_K,
                                                                             q_hw_single_ACH_Wh,
                                                                             q_sc_gen_FP_Wh)
    # add electricity costs
    el_total_Wh = el_single_ACH_Wh + el_aux_SC_FP_Wh + el_CT_Wh
    operation_results[2][7] += sum(prices.ELEC_PRICE * el_total_Wh)  # CHF
    operation_results[2][8] += sum(
        calc_emissions_Whyr_to_tonCO2yr(el_total_Wh,
                                        lca.EL_TO_CO2_EQ))  # ton CO2
    # add gas costs
    q_gas_total_Wh = q_gas_Boiler_FP_to_single_ACH_to_AHU_ARU_SCU_Wh
    operation_results[2][7] += sum(prices.NG_PRICE * q_gas_total_Wh)  # CHF
    operation_results[2][8] += sum(
        calc_emissions_Whyr_to_tonCO2yr(q_gas_total_Wh,
                                        lca.NG_TO_CO2_EQ))  # ton CO2
    # add activation
    cooling_dispatch[2] = {
        'Q_ACH_gen_directload_W': q_chw_single_ACH_Wh,
        'Q_Boiler_NG_ACH_W': q_load_Boiler_FP_to_single_ACH_to_AHU_ARU_SCU_Wh,
        'Q_SC_FP_ACH_W': q_sc_gen_FP_Wh,
        'E_ACH_req_W': el_single_ACH_Wh,
        'E_CT_req_W': el_CT_Wh,
        'E_SC_FP_req_W': el_aux_SC_FP_Wh,
        'E_cs_cre_cdata_req_W': el_total_Wh,
        'NG_Boiler_req': q_gas_Boiler_FP_to_single_ACH_to_AHU_ARU_SCU_Wh,
    }
    # capacity of cooling technologies
    operation_results[2][0] = Qc_nom_AHU_ARU_SCU_W
    operation_results[2][4] = Qc_nom_AHU_ARU_SCU_W  # 4: ACH_SC_FP
    q_total_load = q_chw_single_ACH_Wh[None, :] + q_sc_gen_FP_Wh[
        None, :] + q_load_Boiler_FP_to_single_ACH_to_AHU_ARU_SCU_Wh[None, :]
    system_COP_list = np.divide(
        q_total_load,
        (el_total_Wh[None, :] +
         q_gas_Boiler_FP_to_single_ACH_to_AHU_ARU_SCU_Wh[None, :])).flatten()
    system_COP = np.nansum(q_total_load * system_COP_list) / np.nansum(
        q_total_load)  # weighted average of the system efficiency
    operation_results[2][9] += system_COP

    # 3: SC_ET + single-effect ACH (AHU + ARU + SCU) + CT + Boiler + SC_ET
    print(
        '{building_name} Config 3: Evacuated Tube Solar Collectors + Single-effect Absorption chillers -> AHU,ARU,SCU'
        .format(building_name=building_name))
    # ACH operation
    T_hw_out_single_ACH_K, \
    el_single_ACH_Wh, \
    q_cw_single_ACH_Wh, \
    q_hw_single_ACH_Wh, \
    q_chw_single_ACH_Wh = calc_ACH_operation(T_ground_K, T_hw_in_ET_C, T_re_AHU_ARU_SCU_K, T_sup_AHU_ARU_SCU_K,
                                             chiller_prop, mdot_AHU_ARU_SCU_kgpers, ACH_TYPE_SINGLE)
    # CT operation
    q_CT_ET_to_single_ACH_to_AHU_ARU_SCU_W = q_cw_single_ACH_Wh
    Q_nom_CT_ET_to_single_ACH_to_AHU_ARU_SCU_W, el_CT_Wh = calc_CT_operation(
        q_CT_ET_to_single_ACH_to_AHU_ARU_SCU_W)
    # burner operation
    q_gas_for_burner_Wh, \
    Q_nom_Burner_ET_to_single_ACH_to_AHU_ARU_SCU_W, \
    q_burner_load_Wh = calc_burner_operation(Qc_nom_AHU_ARU_SCU_W, q_hw_single_ACH_Wh, q_sc_gen_ET_Wh)
    # add electricity costs
    el_total_Wh = el_single_ACH_Wh + el_aux_SC_ET_Wh + el_CT_Wh
    operation_results[3][7] += sum(prices.ELEC_PRICE * el_total_Wh)  # CHF
    operation_results[3][8] += sum(
        calc_emissions_Whyr_to_tonCO2yr(el_total_Wh,
                                        lca.EL_TO_CO2_EQ))  # ton CO2
    # add gas costs
    operation_results[3][7] += sum(prices.NG_PRICE *
                                   q_gas_for_burner_Wh)  # CHF
    operation_results[3][8] += sum(
        calc_emissions_Whyr_to_tonCO2yr(q_gas_for_burner_Wh,
                                        lca.NG_TO_CO2_EQ))  # ton CO2
    # add activation
    cooling_dispatch[3] = {
        'Q_ACH_gen_directload_W': q_chw_single_ACH_Wh,
        'Q_Burner_NG_ACH_W': q_burner_load_Wh,
        'Q_SC_ET_ACH_W': q_sc_gen_ET_Wh,
        'E_ACH_req_W': el_single_ACH_Wh,
        'E_CT_req_W': el_CT_Wh,
        'E_SC_ET_req_W': el_aux_SC_ET_Wh,
        'E_cs_cre_cdata_req_W': el_total_Wh,
        'NG_Burner_req': q_gas_for_burner_Wh,
    }
    # capacity of cooling technologies
    operation_results[3][0] = Qc_nom_AHU_ARU_SCU_W
    operation_results[3][5] = Qc_nom_AHU_ARU_SCU_W
    q_total_load = (q_burner_load_Wh[None, :] + q_chw_single_ACH_Wh[None, :] +
                    q_sc_gen_ET_Wh[None, :])
    system_COP_list = np.divide(
        q_total_load,
        (el_total_Wh[None, :] + q_gas_for_burner_Wh[None, :])).flatten()
    system_COP = np.nansum(q_total_load * system_COP_list) / np.nansum(
        q_total_load)  # weighted average of the system efficiency
    operation_results[3][9] += system_COP

    # these two configurations are only activated when SCU is in use
    if Qc_nom_SCU_W > 0.0:
        # 4: VCC (AHU + ARU) + VCC (SCU) + CT
        print(
            '{building_name} Config 4: Vapor Compression Chillers(HT) -> SCU & Vapor Compression Chillers(LT) -> AHU,ARU'
            .format(building_name=building_name))
        # VCC (AHU + ARU) operation
        el_VCC_to_AHU_ARU_Wh, \
        q_cw_VCC_to_AHU_ARU_Wh, \
        q_chw_VCC_to_AHU_ARU_Wh = calc_VCC_operation(T_re_AHU_ARU_K, T_sup_AHU_ARU_K, mdot_AHU_ARU_kgpers, VCC_chiller)
        VCC_LT_Status = np.where(q_chw_VCC_to_AHU_ARU_Wh > 0.0, 1, 0)
        # VCC(SCU) operation
        el_VCC_to_SCU_Wh, \
        q_cw_VCC_to_SCU_Wh, \
        q_chw_VCC_to_SCU_Wh = calc_VCC_operation(T_re_SCU_K, T_sup_SCU_K, mdot_SCU_kgpers, VCC_chiller)
        VCC_HT_Status = np.where(q_chw_VCC_to_AHU_ARU_Wh > 0.0, 1, 0)
        # CT operation
        q_CT_VCC_to_AHU_ARU_and_VCC_to_SCU_W = q_cw_VCC_to_AHU_ARU_Wh + q_cw_VCC_to_SCU_Wh
        Q_nom_CT_VCC_to_AHU_ARU_and_VCC_to_SCU_W, el_CT_Wh = calc_CT_operation(
            q_CT_VCC_to_AHU_ARU_and_VCC_to_SCU_W)
        # add el costs
        el_total_Wh = el_VCC_to_AHU_ARU_Wh + el_VCC_to_SCU_Wh + el_CT_Wh
        operation_results[4][7] += sum(prices.ELEC_PRICE * el_total_Wh)  # CHF
        operation_results[4][8] += sum(
            calc_emissions_Whyr_to_tonCO2yr(el_total_Wh,
                                            lca.EL_TO_CO2_EQ))  # ton CO2
        # add activation
        cooling_dispatch[4] = {
            'Q_BaseVCC_AS_gen_directload_W': q_chw_VCC_to_AHU_ARU_Wh,
            'Q_BaseVCCHT_AS_gen_directload_W': q_chw_VCC_to_SCU_Wh,
            'E_BaseVCC_req_W': el_VCC_to_AHU_ARU_Wh,
            'E_VCC_HT_req_W': el_VCC_to_SCU_Wh,
            'E_CT_req_W': el_CT_Wh,
            'E_cs_cre_cdata_req_W': el_total_Wh
        }
        # capacity of cooling technologies
        operation_results[4][0] = Qc_nom_AHU_ARU_SCU_W
        operation_results[4][2] = Qc_nom_AHU_ARU_W  # 2: BaseVCC_AS
        operation_results[4][3] = Qc_nom_SCU_W  # 3: VCCHT_AS
        system_COP_list = np.divide(
            q_CT_VCC_to_AHU_ARU_and_VCC_to_SCU_W[None, :],
            el_total_Wh[None, :]).flatten()
        system_COP = np.nansum(
            q_CT_VCC_to_AHU_ARU_and_VCC_to_SCU_W[None, :] *
            system_COP_list) / np.nansum(q_CT_VCC_to_AHU_ARU_and_VCC_to_SCU_W[
                None, :])  # weighted average of the system efficiency
        operation_results[4][9] += system_COP

        # 5: VCC (AHU + ARU) + ACH (SCU) + CT
        print(
            '{building_name} Config 5: Vapor Compression Chillers(LT) -> AHU,ARU & Flate-place SC + Absorption Chillers(HT) -> SCU'
            .format(building_name=building_name))
        # ACH (SCU) operation
        T_hw_FP_ACH_to_SCU_K, \
        el_FP_ACH_to_SCU_Wh, \
        q_cw_FP_ACH_to_SCU_Wh, \
        q_hw_FP_ACH_to_SCU_Wh, \
        q_chw_FP_ACH_to_SCU_Wh = calc_ACH_operation(T_ground_K, T_hw_in_FP_C, T_re_SCU_K, T_sup_SCU_K, chiller_prop,
                                                    mdot_SCU_kgpers, ACH_TYPE_SINGLE)
        ACH_HT_Status = np.where(q_chw_FP_ACH_to_SCU_Wh > 0.0, 1, 0)
        # boiler operation
        q_gas_for_boiler_Wh, \
        Q_nom_boiler_VCC_to_AHU_ARU_and_FP_to_single_ACH_to_SCU_W, \
        q_load_from_boiler_Wh = calc_boiler_operation(Qc_nom_SCU_W, T_hw_FP_ACH_to_SCU_K,
                                                      q_hw_FP_ACH_to_SCU_Wh, q_sc_gen_FP_Wh)
        # CT operation
        q_CT_VCC_to_AHU_ARU_and_single_ACH_to_SCU_Wh = q_cw_VCC_to_AHU_ARU_Wh + q_cw_FP_ACH_to_SCU_Wh
        Q_nom_CT_VCC_to_AHU_ARU_and_FP_to_single_ACH_to_SCU_W, \
        el_CT_Wh = calc_CT_operation(q_CT_VCC_to_AHU_ARU_and_single_ACH_to_SCU_Wh)

        # add electricity costs
        el_total_Wh = el_VCC_to_AHU_ARU_Wh + el_FP_ACH_to_SCU_Wh + el_aux_SC_FP_Wh + el_CT_Wh
        operation_results[5][7] += sum(prices.ELEC_PRICE * el_total_Wh)  # CHF
        operation_results[5][8] += sum(
            calc_emissions_Whyr_to_tonCO2yr(el_total_Wh,
                                            lca.EL_TO_CO2_EQ))  # ton CO2
        # add gas costs
        q_gas_total_Wh = q_gas_for_boiler_Wh
        operation_results[5][7] += sum(prices.NG_PRICE * q_gas_total_Wh)  # CHF
        operation_results[5][8] += sum(
            calc_emissions_Whyr_to_tonCO2yr(q_gas_total_Wh,
                                            lca.NG_TO_CO2_EQ))  # ton CO2
        # add activation
        cooling_dispatch[5] = {
            'Q_BaseVCC_AS_gen_directload_W': q_chw_VCC_to_AHU_ARU_Wh,
            'Q_ACHHT_AS_gen_directload_W': q_chw_FP_ACH_to_SCU_Wh,
            'E_BaseVCC_req_W': el_VCC_to_AHU_ARU_Wh,
            'E_ACHHT_req_W': el_FP_ACH_to_SCU_Wh,
            'E_SC_FP_ACH_req_W': el_aux_SC_FP_Wh,
            'E_CT_req_W': el_CT_Wh,
            'E_cs_cre_cdata_req_W': el_total_Wh,
            'Q_BaseBoiler_NG_req': q_gas_for_boiler_Wh,
        }
        # capacity of cooling technologies
        operation_results[5][0] = Qc_nom_AHU_ARU_SCU_W
        operation_results[5][2] = Qc_nom_AHU_ARU_W  # 2: BaseVCC_AS
        operation_results[5][6] = Qc_nom_SCU_W  # 6: ACHHT_SC_FP
        q_total_load = q_CT_VCC_to_AHU_ARU_and_single_ACH_to_SCU_Wh[
            None, :] + q_gas_for_boiler_Wh[None, :]
        system_COP_list = np.divide(q_total_load,
                                    el_total_Wh[None, :]).flatten()
        system_COP = np.nansum(q_total_load * system_COP_list) / np.nansum(
            q_total_load)  # weighted average of the system efficiency
        operation_results[5][9] += system_COP

    ## Calculate Capex/Opex
    # Initialize arrays
    number_of_configurations = len(operation_results)
    Capex_a_USD = np.zeros((number_of_configurations, 1))
    Capex_total_USD = np.zeros((number_of_configurations, 1))
    Opex_a_fixed_USD = np.zeros((number_of_configurations, 1))
    print('{building_name} Cost calculation...'.format(
        building_name=building_name))
    # 0: DX
    Capex_a_DX_USD, Opex_fixed_DX_USD, Capex_DX_USD = dx.calc_Cinv_DX(
        Qc_nom_AHU_ARU_SCU_W)
    # add costs
    Capex_a_USD[0][0] = Capex_a_DX_USD
    Capex_total_USD[0][0] = Capex_DX_USD
    Opex_a_fixed_USD[0][0] = Opex_fixed_DX_USD
    # 1: VCC + CT
    Capex_a_VCC_USD, Opex_fixed_VCC_USD, Capex_VCC_USD = chiller_vapor_compression.calc_Cinv_VCC(
        Qc_nom_AHU_ARU_SCU_W, locator, 'CH3')
    Capex_a_CT_USD, Opex_fixed_CT_USD, Capex_CT_USD = cooling_tower.calc_Cinv_CT(
        Q_nom_CT_VCC_to_AHU_ARU_SCU_W, locator, 'CT1')
    # add costs
    Capex_a_USD[1][0] = Capex_a_CT_USD + Capex_a_VCC_USD
    Capex_total_USD[1][0] = Capex_CT_USD + Capex_VCC_USD
    Opex_a_fixed_USD[1][0] = Opex_fixed_CT_USD + Opex_fixed_VCC_USD
    # 2: single effect ACH + CT + Boiler + SC_FP
    Capex_a_ACH_USD, Opex_fixed_ACH_USD, Capex_ACH_USD = chiller_absorption.calc_Cinv_ACH(
        Qc_nom_AHU_ARU_SCU_W, supply_systems.Absorption_chiller,
        ACH_TYPE_SINGLE)
    Capex_a_CT_USD, Opex_fixed_CT_USD, Capex_CT_USD = cooling_tower.calc_Cinv_CT(
        Q_nom_CT_FP_to_single_ACH_to_AHU_ARU_SCU_W, locator, 'CT1')
    Capex_a_boiler_USD, Opex_fixed_boiler_USD, Capex_boiler_USD = boiler.calc_Cinv_boiler(
        Q_nom_Boiler_FP_to_single_ACH_to_AHU_ARU_SCU_W, 'BO1',
        boiler_cost_data)
    Capex_a_USD[2][
        0] = Capex_a_CT_USD + Capex_a_ACH_USD + Capex_a_boiler_USD + Capex_a_SC_FP_USD
    Capex_total_USD[2][
        0] = Capex_CT_USD + Capex_ACH_USD + Capex_boiler_USD + Capex_SC_FP_USD
    Opex_a_fixed_USD[2][
        0] = Opex_fixed_CT_USD + Opex_fixed_ACH_USD + Opex_fixed_boiler_USD + Opex_SC_FP_USD
    # 3: double effect ACH + CT + Boiler + SC_ET
    Capex_a_ACH_USD, Opex_fixed_ACH_USD, Capex_ACH_USD = chiller_absorption.calc_Cinv_ACH(
        Qc_nom_AHU_ARU_SCU_W, supply_systems.Absorption_chiller,
        ACH_TYPE_SINGLE)
    Capex_a_CT_USD, Opex_fixed_CT_USD, Capex_CT_USD = cooling_tower.calc_Cinv_CT(
        Q_nom_CT_ET_to_single_ACH_to_AHU_ARU_SCU_W, locator, 'CT1')
    Capex_a_burner_USD, Opex_fixed_burner_USD, Capex_burner_USD = burner.calc_Cinv_burner(
        Q_nom_Burner_ET_to_single_ACH_to_AHU_ARU_SCU_W, boiler_cost_data,
        'BO1')
    Capex_a_USD[3][
        0] = Capex_a_CT_USD + Capex_a_ACH_USD + Capex_a_burner_USD + Capex_a_SC_ET_USD
    Capex_total_USD[3][
        0] = Capex_CT_USD + Capex_ACH_USD + Capex_burner_USD + Capex_SC_ET_USD
    Opex_a_fixed_USD[3][
        0] = Opex_fixed_CT_USD + Opex_fixed_ACH_USD + Opex_fixed_burner_USD + Opex_SC_ET_USD
    # these two configurations are only activated when SCU is in use
    if Qc_nom_SCU_W > 0.0:
        # 4: VCC (AHU + ARU) + VCC (SCU) + CT
        Capex_a_VCC_AA_USD, Opex_VCC_AA_USD, Capex_VCC_AA_USD = chiller_vapor_compression.calc_Cinv_VCC(
            Qc_nom_AHU_ARU_W, locator, 'CH3')
        Capex_a_VCC_S_USD, Opex_VCC_S_USD, Capex_VCC_S_USD = chiller_vapor_compression.calc_Cinv_VCC(
            Qc_nom_SCU_W, locator, 'CH3')
        Capex_a_CT_USD, Opex_fixed_CT_USD, Capex_CT_USD = cooling_tower.calc_Cinv_CT(
            Q_nom_CT_VCC_to_AHU_ARU_and_VCC_to_SCU_W, locator, 'CT1')
        Capex_a_USD[4][
            0] = Capex_a_CT_USD + Capex_a_VCC_AA_USD + Capex_a_VCC_S_USD
        Capex_total_USD[4][
            0] = Capex_CT_USD + Capex_VCC_AA_USD + Capex_VCC_S_USD
        Opex_a_fixed_USD[4][
            0] = Opex_fixed_CT_USD + Opex_VCC_AA_USD + Opex_VCC_S_USD

        # 5: VCC (AHU + ARU) + ACH (SCU) + CT + Boiler + SC_FP
        Capex_a_ACH_S_USD, Opex_fixed_ACH_S_USD, Capex_ACH_S_USD = chiller_absorption.calc_Cinv_ACH(
            Qc_nom_SCU_W, supply_systems.Absorption_chiller, ACH_TYPE_SINGLE)
        Capex_a_CT_USD, Opex_fixed_CT_USD, Capex_CT_USD = cooling_tower.calc_Cinv_CT(
            Q_nom_CT_VCC_to_AHU_ARU_and_FP_to_single_ACH_to_SCU_W, locator,
            'CT1')
        Capex_a_boiler_USD, Opex_fixed_boiler_USD, Capex_boiler_USD = boiler.calc_Cinv_boiler(
            Q_nom_boiler_VCC_to_AHU_ARU_and_FP_to_single_ACH_to_SCU_W, 'BO1',
            boiler_cost_data)
        Capex_a_USD[5][0] = Capex_a_CT_USD + Capex_a_VCC_AA_USD + Capex_a_ACH_S_USD + \
                            Capex_a_SC_FP_USD + Capex_a_boiler_USD
        Capex_total_USD[5][0] = Capex_CT_USD + Capex_VCC_AA_USD + Capex_ACH_S_USD + \
                                Capex_SC_FP_USD + Capex_boiler_USD
        Opex_a_fixed_USD[5][0] = Opex_fixed_CT_USD + Opex_VCC_AA_USD + Opex_fixed_ACH_S_USD + \
                                 Opex_SC_FP_USD + Opex_fixed_boiler_USD
    ## write all results from the configurations into TotalCosts, TotalCO2, TotalPrim
    Opex_a_USD, TAC_USD, TotalCO2, TotalPrim = compile_TAC_CO2_Prim(
        Capex_a_USD, Opex_a_fixed_USD, number_of_configurations,
        operation_results)
    ## Determine the best configuration
    Best, indexBest = rank_results(TAC_USD, TotalCO2, TotalPrim,
                                   number_of_configurations)
    # Save results in csv file
    performance_results = {
        "Nominal heating load": operation_results[:, 0],
        "Capacity_DX_AS_W": operation_results[:, 1],
        "Capacity_BaseVCC_AS_W": operation_results[:, 2],
        "Capacity_VCCHT_AS_W": operation_results[:, 3],
        "Capacity_ACH_SC_FP_W": operation_results[:, 4],
        "Capaticy_ACH_SC_ET_W": operation_results[:, 5],
        "Capacity_ACHHT_FP_W": operation_results[:, 6],
        "Capex_a_USD": Capex_a_USD[:, 0],
        "Capex_total_USD": Capex_total_USD[:, 0],
        "Opex_fixed_USD": Opex_a_fixed_USD[:, 0],
        "Opex_var_USD": operation_results[:, 7],
        "GHG_tonCO2": operation_results[:, 8],
        "TAC_USD": TAC_USD[:, 1],
        "Best configuration": Best[:, 0],
        "system_COP": operation_results[:, 9],
    }
    performance_results_df = pd.DataFrame(performance_results)
    performance_results_df.to_csv(
        locator.get_optimization_decentralized_folder_building_result_cooling(
            building_name),
        index=False)
    # save activation for the best supply system configuration
    best_activation_df = pd.DataFrame.from_dict(cooling_dispatch[indexBest])  #
    best_activation_df.to_csv(
        locator.
        get_optimization_decentralized_folder_building_cooling_activation(
            building_name),
        index=False)
Beispiel #4
0
def district_cooling_network(locator, master_to_slave_variables, config,
                             prices, lca, network_features):
    """
    Computes the parameters for the cooling of the complete DCN

    :param locator: path to res folder
    :param network_features: network features
    :param prices: Prices imported from the database
    :type locator: string
    :type network_features: class
    :type prices: class
    :return: costs, co2, prim
    :rtype: tuple
    """

    # THERMAL STORAGE + NETWORK
    # Import Temperatures from Network Summary:
    Q_thermal_req_W, \
    T_district_cooling_return_K, \
    T_district_cooling_supply_K,\
    mdot_kgpers = calc_network_summary_DCN(locator, master_to_slave_variables)

    print(
        "CALCULATING ECOLOGICAL COSTS OF DAILY COOLING STORAGE - DUE TO OPERATION (IF ANY)"
    )
    # Initialize daily storage calss
    T_ground_K = calculate_ground_temperature(locator, config)
    daily_storage = LoadLevelingDailyStorage(
        master_to_slave_variables.Storage_cooling_on,
        master_to_slave_variables.Storage_cooling_size_W,
        min(T_district_cooling_supply_K) - DT_COOL,
        max(T_district_cooling_return_K) - DT_COOL, T_TANK_FULLY_DISCHARGED_K,
        np.mean(T_ground_K))

    # Import Data - potentials lake heat
    if master_to_slave_variables.WS_BaseVCC_on == 1 or master_to_slave_variables.WS_PeakVCC_on == 1:
        HPlake_Data = pd.read_csv(locator.get_lake_potential())
        Q_therm_Lake = np.array(HPlake_Data['QLake_kW']) * 1E3
        total_WS_VCC_installed = master_to_slave_variables.WS_BaseVCC_size_W + master_to_slave_variables.WS_PeakVCC_size_W
        Q_therm_Lake_W = [
            x if x < total_WS_VCC_installed else total_WS_VCC_installed
            for x in Q_therm_Lake
        ]
        T_source_average_Lake_K = np.array(HPlake_Data['Ts_C']) + 273
    else:
        Q_therm_Lake_W = np.zeros(HOURS_IN_YEAR)
        T_source_average_Lake_K = np.zeros(HOURS_IN_YEAR)

    Q_Trigen_NG_gen_W = np.zeros(HOURS_IN_YEAR)
    Q_BaseVCC_WS_gen_W = np.zeros(HOURS_IN_YEAR)
    Q_PeakVCC_WS_gen_W = np.zeros(HOURS_IN_YEAR)
    Q_BaseVCC_AS_gen_W = np.zeros(HOURS_IN_YEAR)
    Q_PeakVCC_AS_gen_W = np.zeros(HOURS_IN_YEAR)
    Q_BackupVCC_AS_gen_W = np.zeros(HOURS_IN_YEAR)
    Q_DailyStorage_gen_W = np.zeros(HOURS_IN_YEAR)

    opex_var_Trigen_NG_USDhr = np.zeros(HOURS_IN_YEAR)
    opex_var_BaseVCC_WS_USDhr = np.zeros(HOURS_IN_YEAR)
    opex_var_PeakVCC_WS_USDhr = np.zeros(HOURS_IN_YEAR)
    opex_var_BaseVCC_AS_USDhr = np.zeros(HOURS_IN_YEAR)
    opex_var_PeakVCC_AS_USDhr = np.zeros(HOURS_IN_YEAR)
    opex_var_BackupVCC_AS_USDhr = np.zeros(HOURS_IN_YEAR)

    E_Trigen_NG_gen_W = np.zeros(HOURS_IN_YEAR)
    E_BaseVCC_AS_req_W = np.zeros(HOURS_IN_YEAR)
    E_PeakVCC_AS_req_W = np.zeros(HOURS_IN_YEAR)
    E_BaseVCC_WS_req_W = np.zeros(HOURS_IN_YEAR)
    E_PeakVCC_WS_req_W = np.zeros(HOURS_IN_YEAR)
    E_BackupVCC_AS_req_W = np.zeros(HOURS_IN_YEAR)

    NG_Trigen_req_W = np.zeros(HOURS_IN_YEAR)

    source_Trigen_NG = np.zeros(HOURS_IN_YEAR)
    source_BaseVCC_WS = np.zeros(HOURS_IN_YEAR)
    source_PeakVCC_WS = np.zeros(HOURS_IN_YEAR)
    source_BaseVCC_AS = np.zeros(HOURS_IN_YEAR)
    source_PeakVCC_AS = np.zeros(HOURS_IN_YEAR)

    for hour in range(
            HOURS_IN_YEAR
    ):  # cooling supply for all buildings excluding cooling loads from data centers
        if Q_thermal_req_W[hour] > 0.0:  # only if there is a cooling load!
            daily_storage, \
            activation_output, \
            thermal_output, \
            electricity_output, \
            gas_output = cooling_resource_activator(Q_thermal_req_W[hour],
                                                    T_district_cooling_supply_K[hour],
                                                    T_district_cooling_return_K[hour],
                                                    Q_therm_Lake_W[hour],
                                                    T_source_average_Lake_K[hour],
                                                    daily_storage,
                                                    T_ground_K[hour],
                                                    lca,
                                                    master_to_slave_variables,
                                                    hour,
                                                    prices,
                                                    locator)

            source_Trigen_NG[hour] = activation_output["source_Trigen_NG"]
            source_BaseVCC_WS[hour] = activation_output["source_BaseVCC_WS"]
            source_PeakVCC_WS[hour] = activation_output["source_PeakVCC_WS"]
            source_BaseVCC_AS[hour] = activation_output["source_BaseVCC_AS"]
            source_PeakVCC_AS[hour] = activation_output["source_PeakVCC_AS"]

            Q_Trigen_NG_gen_W[hour] = thermal_output['Q_Trigen_NG_gen_W']
            Q_BaseVCC_WS_gen_W[hour] = thermal_output['Q_BaseVCC_WS_gen_W']
            Q_PeakVCC_WS_gen_W[hour] = thermal_output['Q_PeakVCC_WS_gen_W']
            Q_BaseVCC_AS_gen_W[hour] = thermal_output['Q_BaseVCC_AS_gen_W']
            Q_PeakVCC_AS_gen_W[hour] = thermal_output['Q_PeakVCC_AS_gen_W']
            Q_BackupVCC_AS_gen_W[hour] = thermal_output['Q_BackupVCC_AS_gen_W']
            Q_DailyStorage_gen_W[hour] = thermal_output[
                'Q_DailyStorage_WS_gen_W']

            E_BaseVCC_WS_req_W[hour] = electricity_output['E_BaseVCC_WS_req_W']
            E_PeakVCC_WS_req_W[hour] = electricity_output['E_PeakVCC_WS_req_W']
            E_BaseVCC_AS_req_W[hour] = electricity_output['E_BaseVCC_AS_req_W']
            E_PeakVCC_AS_req_W[hour] = electricity_output['E_PeakVCC_AS_req_W']
            E_BackupVCC_AS_req_W[hour] = electricity_output[
                'E_BackupVCC_AS_req_W']
            E_Trigen_NG_gen_W[hour] = electricity_output['E_Trigen_NG_gen_W']

            NG_Trigen_req_W = gas_output['NG_Trigen_req_W']

    # BACK-UPP VCC - AIR SOURCE
    master_to_slave_variables.AS_BackupVCC_size_W = np.amax(
        Q_BackupVCC_AS_gen_W)
    if master_to_slave_variables.AS_BackupVCC_size_W != 0:
        master_to_slave_variables.AS_BackupVCC_on = 1
        for hour in range(HOURS_IN_YEAR):
            opex_var_BackupVCC_AS_USDhr[hour], \
            Q_BackupVCC_AS_gen_W[hour], \
            E_BackupVCC_AS_req_W[hour] = calc_vcc_CT_operation(Q_BackupVCC_AS_gen_W[hour],
                                                               T_district_cooling_return_K[hour],
                                                               T_district_cooling_supply_K[hour],
                                                               VCC_T_COOL_IN,
                                                               lca)

    # CAPEX (ANNUAL, TOTAL) AND OPEX (FIXED, VAR, ANNUAL) GENERATION UNITS
    performance_costs_generation = cost_model.calc_generation_costs_cooling(
        locator, master_to_slave_variables, config)
    # CAPEX (ANNUAL, TOTAL) AND OPEX (FIXED, VAR, ANNUAL) STORAGE UNITS
    performance_costs_storage = cost_model.calc_generation_costs_cooling_storage(
        locator, master_to_slave_variables, config, daily_storage)

    # CAPEX (ANNUAL, TOTAL) AND OPEX (FIXED, VAR, ANNUAL) NETWORK
    performance_costs_network, \
    E_used_district_cooling_network_W = cost_model.calc_network_costs_cooling(locator,
                                                                              master_to_slave_variables,
                                                                              network_features,
                                                                              lca,
                                                                              "DC")

    # MERGE COSTS AND EMISSIONS IN ONE FILE
    performance = dict(performance_costs_generation,
                       **performance_costs_storage)
    district_cooling_costs = dict(performance, **performance_costs_network)

    # SAVE
    district_cooling_generation_dispatch = {
        # demand of the network
        "Q_districtcooling_sys_req_W": Q_thermal_req_W,

        # Status of each technology 1 = on, 0 = off in every hour
        "Trigen_NG_Status": source_Trigen_NG,
        "BaseVCC_WS_Status": source_BaseVCC_WS,
        "PeakVCC_WS_Status": source_PeakVCC_WS,
        "BaseVCC_AS_Status": source_BaseVCC_AS,
        "PeakVCC_AS_Status": source_PeakVCC_AS,

        # ENERGY GENERATION
        # from storage
        "Q_DailyStorage_gen_directload_W": Q_DailyStorage_gen_W,
        # cooling
        "Q_Trigen_NG_gen_directload_W": Q_Trigen_NG_gen_W,
        "Q_BaseVCC_WS_gen_directload_W": Q_BaseVCC_WS_gen_W,
        "Q_PeakVCC_WS_gen_directload_W": Q_PeakVCC_WS_gen_W,
        "Q_BaseVCC_AS_gen_directload_W": Q_BaseVCC_AS_gen_W,
        "Q_PeakVCC_AS_gen_directload_W": Q_PeakVCC_AS_gen_W,
        "Q_BackupVCC_AS_directload_W": Q_BackupVCC_AS_gen_W,
        # electricity
        "E_Trigen_NG_gen_W": E_Trigen_NG_gen_W
    }

    district_cooling_electricity_requirements_dispatch = {
        # ENERGY REQUIREMENTS
        # Electricity
        "E_DCN_req_W": E_used_district_cooling_network_W,
        "E_BaseVCC_WS_req_W": E_BaseVCC_WS_req_W,
        "E_PeakVCC_WS_req_W": E_PeakVCC_WS_req_W,
        "E_BaseVCC_AS_req_W": E_BaseVCC_AS_req_W,
        "E_PeakVCC_AS_req_W": E_PeakVCC_AS_req_W,
        "E_BackupVCC_AS_req_W": E_BackupVCC_AS_req_W,
    }

    district_cooling_fuel_requirements_dispatch = {
        # fuels
        "NG_Trigen_req_W": NG_Trigen_req_W
    }

    # PLOT RESULTS

    return district_cooling_costs, \
           district_cooling_generation_dispatch, \
           district_cooling_electricity_requirements_dispatch,\
           district_cooling_fuel_requirements_dispatch