def cooling_calculations_of_DC_buildings(locator, master_to_slave_vars, ntwFeat, prices, lca, config, reduced_timesteps_flag): """ Computes the parameters for the cooling of the complete DCN :param locator: path to res folder :param ntwFeat: network features :param prices: Prices imported from the database :type locator: string :type ntwFeat: class :type prices: class :return: costs, co2, prim :rtype: tuple """ ############# Recover the cooling needs # Cooling demands in a neighborhood are divided into three categories currently. They are # 1. Space Cooling in buildings # 2. Data center Cooling # 3. Refrigeration Needs # Data center cooling can also be done by recovering the heat and heating other demands during the same time # whereas Space cooling and refrigeration needs are to be provided by District Cooling Network or decentralized cooling # Currently, all the buildings are assumed to be connected to DCN # In the following code, the cooling demands of Space cooling and refrigeration are first satisfied by using Lake and VCC # This is then followed by checking of the Heat recovery from Data Centre, if it is allowed, then the corresponding # cooling demand is ignored. If not, the corresponding coolind demand is also satisfied by DCN. t0 = time.time() DCN_barcode = master_to_slave_vars.DCN_barcode print ('Cooling Main is Running') # Space cooling previously aggregated in the substation routine if master_to_slave_vars.WasteServersHeatRecovery == 1: df = pd.read_csv(locator.get_optimization_network_data_folder(master_to_slave_vars.network_data_file_cooling), usecols=["T_DCNf_space_cooling_and_refrigeration_sup_K", "T_DCNf_space_cooling_and_refrigeration_re_K", "mdot_cool_space_cooling_and_refrigeration_netw_all_kgpers"]) df = df.fillna(0) T_sup_K = df['T_DCNf_space_cooling_and_refrigeration_sup_K'].values T_re_K = df['T_DCNf_space_cooling_and_refrigeration_re_K'].values mdot_kgpers = df['mdot_cool_space_cooling_and_refrigeration_netw_all_kgpers'].values else: df = pd.read_csv(locator.get_optimization_network_data_folder(master_to_slave_vars.network_data_file_cooling), usecols=["T_DCNf_space_cooling_data_center_and_refrigeration_sup_K", "T_DCNf_space_cooling_data_center_and_refrigeration_re_K", "mdot_cool_space_cooling_data_center_and_refrigeration_netw_all_kgpers"]) df = df.fillna(0) T_sup_K = df['T_DCNf_space_cooling_data_center_and_refrigeration_sup_K'].values T_re_K = df['T_DCNf_space_cooling_data_center_and_refrigeration_re_K'].values mdot_kgpers = df['mdot_cool_space_cooling_data_center_and_refrigeration_netw_all_kgpers'].values DCN_operation_parameters = df.fillna(0) DCN_operation_parameters_array = DCN_operation_parameters.values Qc_DCN_W = np.array( pd.read_csv(locator.get_optimization_network_data_folder(master_to_slave_vars.network_data_file_cooling), usecols=["Q_DCNf_space_cooling_and_refrigeration_W", "Q_DCNf_space_cooling_data_center_and_refrigeration_W"])) # importing the cooling demands of DCN (space cooling + refrigeration) # Data center cooling, (treated separately for each building) df = pd.read_csv(locator.get_total_demand(), usecols=["Name", "Qcdata_sys_MWhyr"]) arrayData = np.array(df) # total cooling requirements based on the Heat Recovery Flag Q_cooling_req_W = np.zeros(8760) if master_to_slave_vars.WasteServersHeatRecovery == 0: for hour in range(8760): # summing cooling loads of space cooling, refrigeration and data center Q_cooling_req_W[hour] = Qc_DCN_W[hour][1] else: for hour in range(8760): # only including cooling loads of space cooling and refrigeration Q_cooling_req_W[hour] = Qc_DCN_W[hour][0] ############# Recover the heat already taken from the Lake by the heat pumps if config.district_heating_network: try: dfSlave = pd.read_csv( locator.get_optimization_slave_heating_activation_pattern(master_to_slave_vars.individual_number, master_to_slave_vars.generation_number), usecols=["Q_coldsource_HPLake_W"]) Q_Lake_Array_W = np.array(dfSlave) except: Q_Lake_Array_W = [0] else: Q_Lake_Array_W = [0] ### input parameters Qc_VCC_max_W = master_to_slave_vars.VCC_cooling_size_W Qc_ACH_max_W = master_to_slave_vars.Absorption_chiller_size_W T_ground_K = calculate_ground_temperature(locator, config) # sizing cold water storage tank if master_to_slave_vars.Storage_cooling_size_W > 0: Qc_tank_discharge_peak_W = master_to_slave_vars.Storage_cooling_size_W Qc_tank_charge_max_W = (Qc_VCC_max_W + Qc_ACH_max_W) * 0.8 # assume reduced capacity when Tsup is lower peak_hour = np.argmax(Q_cooling_req_W) area_HEX_tank_discharege_m2, UA_HEX_tank_discharge_WperK, \ area_HEX_tank_charge_m2, UA_HEX_tank_charge_WperK, \ V_tank_m3 = storage_tank.calc_storage_tank_properties(DCN_operation_parameters, Qc_tank_charge_max_W, Qc_tank_discharge_peak_W, peak_hour, master_to_slave_vars) else: Qc_tank_discharge_peak_W = 0 Qc_tank_charge_max_W = 0 area_HEX_tank_discharege_m2 = 0 UA_HEX_tank_discharge_WperK = 0 area_HEX_tank_charge_m2 = 0 UA_HEX_tank_charge_WperK = 0 V_tank_m3 = 0 VCC_cost_data = pd.read_excel(locator.get_supply_systems(config.region), sheetname="Chiller") VCC_cost_data = VCC_cost_data[VCC_cost_data['code'] == 'CH3'] max_VCC_chiller_size = max(VCC_cost_data['cap_max'].values) Absorption_chiller_cost_data = pd.read_excel(locator.get_supply_systems(config.region), sheetname="Absorption_chiller") Absorption_chiller_cost_data = Absorption_chiller_cost_data[Absorption_chiller_cost_data['type'] == ACH_TYPE_DOUBLE] max_ACH_chiller_size = max(Absorption_chiller_cost_data['cap_max'].values) # deciding the number of chillers and the nominal size based on the maximum chiller size Qc_VCC_max_W = Qc_VCC_max_W * (1 + SIZING_MARGIN) Qc_ACH_max_W = Qc_ACH_max_W * (1 + SIZING_MARGIN) Q_peak_load_W = Q_cooling_req_W.max() * (1 + SIZING_MARGIN) Qc_VCC_backup_max_W = (Q_peak_load_W - Qc_ACH_max_W - Qc_VCC_max_W - Qc_tank_discharge_peak_W) if Qc_VCC_backup_max_W < 0: Qc_VCC_backup_max_W = 0 if Qc_VCC_max_W <= max_VCC_chiller_size: Qnom_VCC_W = Qc_VCC_max_W number_of_VCC_chillers = 1 else: number_of_VCC_chillers = int(ceil(Qc_VCC_max_W / max_VCC_chiller_size)) Qnom_VCC_W = Qc_VCC_max_W / number_of_VCC_chillers if Qc_VCC_backup_max_W <= max_VCC_chiller_size: Qnom_VCC_backup_W = Qc_VCC_backup_max_W number_of_VCC_backup_chillers = 1 else: number_of_VCC_backup_chillers = int(ceil(Qc_VCC_backup_max_W / max_VCC_chiller_size)) Qnom_VCC_backup_W = Qc_VCC_backup_max_W / number_of_VCC_backup_chillers if Qc_ACH_max_W <= max_ACH_chiller_size: Qnom_ACH_W = Qc_ACH_max_W number_of_ACH_chillers = 1 else: number_of_ACH_chillers = int(ceil(Qc_ACH_max_W / max_ACH_chiller_size)) Qnom_ACH_W = Qc_ACH_max_W / number_of_ACH_chillers limits = {'Qc_VCC_max_W': Qc_VCC_max_W, 'Qc_ACH_max_W': Qc_ACH_max_W, 'Qc_peak_load_W': Qc_tank_discharge_peak_W, 'Qnom_VCC_W': Qnom_VCC_W, 'number_of_VCC_chillers': number_of_VCC_chillers, 'Qnom_ACH_W': Qnom_ACH_W, 'number_of_ACH_chillers': number_of_ACH_chillers, 'Qnom_VCC_backup_W': Qnom_VCC_backup_W, 'number_of_VCC_backup_chillers': number_of_VCC_backup_chillers, 'Qc_tank_discharge_peak_W': Qc_tank_discharge_peak_W, 'Qc_tank_charge_max_W': Qc_tank_charge_max_W, 'V_tank_m3': V_tank_m3, 'T_tank_fully_charged_K': T_TANK_FULLY_CHARGED_K, 'area_HEX_tank_discharge_m2': area_HEX_tank_discharege_m2, 'UA_HEX_tank_discharge_WperK': UA_HEX_tank_discharge_WperK, 'area_HEX_tank_charge_m2': area_HEX_tank_charge_m2, 'UA_HEX_tank_charge_WperK': UA_HEX_tank_charge_WperK} ### input variables lake_available_cooling = pd.read_csv(locator.get_lake_potential(), usecols=['lake_potential']) Qc_available_from_lake_W = np.sum(lake_available_cooling).values[0] + np.sum(Q_Lake_Array_W) Qc_from_lake_cumulative_W = 0 cooling_resource_potentials = {'T_tank_K': T_TANK_FULLY_DISCHARGED_K, 'Qc_avail_from_lake_W': Qc_available_from_lake_W, 'Qc_from_lake_cumulative_W': Qc_from_lake_cumulative_W} ############# Output results PipeLifeTime = 40.0 # years, Data from A&W PipeInterestRate = 0.05 # 5% interest rate network_costs_USD = ntwFeat.pipesCosts_DCN_USD * DCN_barcode.count('1') / master_to_slave_vars.total_buildings network_costs_a_USD = network_costs_USD * PipeInterestRate * (1+ PipeInterestRate) ** PipeLifeTime / ((1+PipeInterestRate) ** PipeLifeTime - 1) costs_a_USD = network_costs_a_USD CO2_kgCO2 = 0 prim_MJ = 0 nBuild = int(np.shape(arrayData)[0]) if reduced_timesteps_flag == False: start_t = 0 stop_t = int(np.shape(DCN_operation_parameters)[0]) else: # timesteps in May start_t = 2880 stop_t = 3624 timesteps = range(start_t, stop_t) calfactor_buildings = np.zeros(8760) TotalCool = 0 Qc_from_Lake_W = np.zeros(8760) Qc_from_VCC_W = np.zeros(8760) Qc_from_ACH_W = np.zeros(8760) Qc_from_storage_tank_W = np.zeros(8760) Qc_from_VCC_backup_W = np.zeros(8760) Qc_req_from_CT_W = np.zeros(8760) Qh_req_from_CCGT_W = np.zeros(8760) Qh_from_CCGT_W = np.zeros(8760) E_gen_CCGT_W = np.zeros(8760) opex_var_Lake_USD = np.zeros(8760) opex_var_VCC_USD = np.zeros(8760) opex_var_ACH_USD = np.zeros(8760) opex_var_VCC_backup_USD = np.zeros(8760) opex_var_CCGT_USD = np.zeros(8760) opex_var_CT_USD = np.zeros(8760) E_used_Lake_W = np.zeros(8760) E_used_VCC_W = np.zeros(8760) E_used_VCC_backup_W = np.zeros(8760) E_used_ACH_W = np.zeros(8760) E_used_CT_W = np.zeros(8760) co2_Lake_kgCO2 = np.zeros(8760) co2_VCC_kgCO2 = np.zeros(8760) co2_ACH_kgCO2 = np.zeros(8760) co2_VCC_backup_kgCO2 = np.zeros(8760) co2_CCGT_kgCO2 = np.zeros(8760) co2_CT_kgCO2 = np.zeros(8760) prim_energy_Lake_MJ = np.zeros(8760) prim_energy_VCC_MJ = np.zeros(8760) prim_energy_ACH_MJ = np.zeros(8760) prim_energy_VCC_backup_MJ = np.zeros(8760) prim_energy_CCGT_MJ = np.zeros(8760) prim_energy_CT_MJ = np.zeros(8760) NG_used_CCGT_W = np.zeros(8760) calfactor_total = 0 for hour in timesteps: # cooling supply for all buildings excluding cooling loads from data centers performance_indicators_output, \ Qc_supply_to_DCN, calfactor_output, \ Qc_CT_W, Qh_CHP_ACH_W, \ cooling_resource_potentials = cooling_resource_activator(mdot_kgpers[hour], T_sup_K[hour], T_re_K[hour], limits, cooling_resource_potentials, T_ground_K[hour], prices, lca, master_to_slave_vars, config, Q_cooling_req_W[hour], locator) print (hour) # save results for each time-step opex_var_Lake_USD[hour] = performance_indicators_output['Opex_var_Lake_USD'] opex_var_VCC_USD[hour] = performance_indicators_output['Opex_var_VCC_USD'] opex_var_ACH_USD[hour] = performance_indicators_output['Opex_var_ACH_USD'] opex_var_VCC_backup_USD[hour] = performance_indicators_output['Opex_var_VCC_backup_USD'] E_used_Lake_W[hour] = performance_indicators_output['E_used_Lake_W'] E_used_VCC_W[hour] = performance_indicators_output['E_used_VCC_W'] E_used_VCC_backup_W[hour] = performance_indicators_output['E_used_VCC_backup_W'] E_used_ACH_W[hour] = performance_indicators_output['E_used_ACH_W'] co2_Lake_kgCO2[hour] = performance_indicators_output['CO2_Lake_kgCO2'] co2_VCC_kgCO2[hour] = performance_indicators_output['CO2_VCC_kgCO2'] co2_ACH_kgCO2[hour] = performance_indicators_output['CO2_ACH_kgCO2'] co2_VCC_backup_kgCO2[hour] = performance_indicators_output['CO2_VCC_backup_kgCO2'] prim_energy_Lake_MJ[hour] = performance_indicators_output['Primary_Energy_Lake_MJ'] prim_energy_VCC_MJ[hour] = performance_indicators_output['Primary_Energy_VCC_MJ'] prim_energy_ACH_MJ[hour] = performance_indicators_output['Primary_Energy_ACH_MJ'] prim_energy_VCC_backup_MJ[hour] = performance_indicators_output['Primary_Energy_VCC_backup_MJ'] calfactor_buildings[hour] = calfactor_output Qc_from_Lake_W[hour] = Qc_supply_to_DCN['Qc_from_Lake_W'] Qc_from_storage_tank_W[hour] = Qc_supply_to_DCN['Qc_from_Tank_W'] Qc_from_VCC_W[hour] = Qc_supply_to_DCN['Qc_from_VCC_W'] Qc_from_ACH_W[hour] = Qc_supply_to_DCN['Qc_from_ACH_W'] Qc_from_VCC_backup_W[hour] = Qc_supply_to_DCN['Qc_from_backup_VCC_W'] Qc_req_from_CT_W[hour] = Qc_CT_W Qh_req_from_CCGT_W[hour] = Qh_CHP_ACH_W if reduced_timesteps_flag: reduced_costs_USD = np.sum(opex_var_Lake_USD) + np.sum(opex_var_VCC_USD) + np.sum(opex_var_ACH_USD) + np.sum(opex_var_VCC_backup_USD) reduced_CO2_kgCO2 = np.sum(co2_Lake_kgCO2) + np.sum(co2_Lake_kgCO2) + np.sum(co2_ACH_kgCO2) + np.sum(co2_VCC_backup_kgCO2) reduced_prim_MJ = np.sum(prim_energy_Lake_MJ) + np.sum(prim_energy_VCC_MJ) + np.sum(prim_energy_ACH_MJ) + np.sum( prim_energy_VCC_backup_MJ) costs_a_USD += reduced_costs_USD*(8760/(stop_t-start_t)) CO2_kgCO2 += reduced_CO2_kgCO2*(8760/(stop_t-start_t)) prim_MJ += reduced_prim_MJ*(8760/(stop_t-start_t)) else: costs_a_USD += np.sum(opex_var_Lake_USD) + np.sum(opex_var_VCC_USD) + np.sum(opex_var_ACH_USD) + np.sum(opex_var_VCC_backup_USD) CO2_kgCO2 += np.sum(co2_Lake_kgCO2) + np.sum(co2_Lake_kgCO2) + np.sum(co2_ACH_kgCO2) + np.sum(co2_VCC_backup_kgCO2) prim_MJ += np.sum(prim_energy_Lake_MJ) + np.sum(prim_energy_VCC_MJ) + np.sum(prim_energy_ACH_MJ) + np.sum( prim_energy_VCC_backup_MJ) calfactor_total += np.sum(calfactor_buildings) TotalCool += np.sum(Qc_from_Lake_W) + np.sum(Qc_from_VCC_W) + np.sum(Qc_from_ACH_W) + np.sum(Qc_from_VCC_backup_W) + np.sum(Qc_from_storage_tank_W) Q_VCC_nom_W = limits['Qnom_VCC_W'] Q_ACH_nom_W = limits['Qnom_ACH_W'] Q_VCC_backup_nom_W = limits['Qnom_VCC_backup_W'] Q_CT_nom_W = np.amax(Qc_req_from_CT_W) Qh_req_from_CCGT_max_W = np.amax(Qh_req_from_CCGT_W) # the required heat output from CCGT at peak mdot_Max_kgpers = np.amax(DCN_operation_parameters_array[:, 1]) # sizing of DCN network pumps Q_GT_nom_W = 0 ########## Operation of the cooling tower if Q_CT_nom_W > 0: for hour in timesteps: wdot_CT = CTModel.calc_CT(Qc_req_from_CT_W[hour], Q_CT_nom_W) opex_var_CT_USD[hour] = (wdot_CT) * lca.ELEC_PRICE co2_CT_kgCO2[hour] = (wdot_CT) * lca.EL_TO_CO2 * 3600E-6 prim_energy_CT_MJ[hour] = (wdot_CT) * lca.EL_TO_OIL_EQ * 3600E-6 E_used_CT_W[hour] = wdot_CT if reduced_timesteps_flag: reduced_costs_USD = np.sum(opex_var_CT_USD) reduced_CO2_kgCO2 = np.sum(co2_CT_kgCO2) reduced_prim_MJ = np.sum(prim_energy_CT_MJ) costs_a_USD += reduced_costs_USD * (8760 / (stop_t - start_t)) CO2_kgCO2 += reduced_CO2_kgCO2 * (8760 / (stop_t - start_t)) prim_MJ += reduced_prim_MJ * (8760 / (stop_t - start_t)) else: costs_a_USD += np.sum(opex_var_CT_USD) CO2_kgCO2 += np.sum(co2_CT_kgCO2) prim_MJ += np.sum(prim_energy_CT_MJ) ########## Operation of the CCGT if Qh_req_from_CCGT_max_W > 0: # Sizing of CCGT GT_fuel_type = 'NG' # assumption for scenarios in SG Q_GT_nom_sizing_W = Qh_req_from_CCGT_max_W # starting guess for the size of GT Qh_output_CCGT_max_W = 0 # the heat output of CCGT at currently installed size (Q_GT_nom_sizing_W) while (Qh_output_CCGT_max_W - Qh_req_from_CCGT_max_W) <= 0: Q_GT_nom_sizing_W += 1000 # update GT size # get CCGT performance limits and functions at Q_GT_nom_sizing_W CCGT_performances = cogeneration.calc_cop_CCGT(Q_GT_nom_sizing_W, ACH_T_IN_FROM_CHP, GT_fuel_type, prices, lca) Qh_output_CCGT_max_W = CCGT_performances['q_output_max_W'] # unpack CCGT performance functions Q_GT_nom_W = Q_GT_nom_sizing_W * (1 + SIZING_MARGIN) # installed CCGT capacity CCGT_performances = cogeneration.calc_cop_CCGT(Q_GT_nom_W, ACH_T_IN_FROM_CHP, GT_fuel_type, prices, lca) Q_used_prim_W_CCGT_fn = CCGT_performances['q_input_fn_q_output_W'] cost_per_Wh_th_CCGT_fn = CCGT_performances[ 'fuel_cost_per_Wh_th_fn_q_output_W'] # gets interpolated cost function Qh_output_CCGT_min_W = CCGT_performances['q_output_min_W'] Qh_output_CCGT_max_W = CCGT_performances['q_output_max_W'] eta_elec_interpol = CCGT_performances['eta_el_fn_q_input'] for hour in timesteps: if Qh_req_from_CCGT_W[hour] > Qh_output_CCGT_min_W: # operate above minimal load if Qh_req_from_CCGT_W[hour] < Qh_output_CCGT_max_W: # Normal operation Possible within partload regime cost_per_Wh_th = cost_per_Wh_th_CCGT_fn(Qh_req_from_CCGT_W[hour]) Q_used_prim_CCGT_W = Q_used_prim_W_CCGT_fn(Qh_req_from_CCGT_W[hour]) Qh_from_CCGT_W[hour] = Qh_req_from_CCGT_W[hour].copy() E_gen_CCGT_W[hour] = np.float(eta_elec_interpol(Q_used_prim_CCGT_W)) * Q_used_prim_CCGT_W else: raise ValueError('Incorrect CCGT sizing!') else: # operate at minimum load cost_per_Wh_th = cost_per_Wh_th_CCGT_fn(Qh_output_CCGT_min_W) Q_used_prim_CCGT_W = Q_used_prim_W_CCGT_fn(Qh_output_CCGT_min_W) Qh_from_CCGT_W[hour] = Qh_output_CCGT_min_W E_gen_CCGT_W[hour] = np.float(eta_elec_interpol( Qh_output_CCGT_max_W)) * Q_used_prim_CCGT_W opex_var_CCGT_USD[hour] = cost_per_Wh_th * Qh_from_CCGT_W[hour] - E_gen_CCGT_W[hour] * lca.ELEC_PRICE co2_CCGT_kgCO2[hour] = Q_used_prim_CCGT_W * lca.NG_CC_TO_CO2_STD * WH_TO_J / 1.0E6 - E_gen_CCGT_W[hour] * lca.EL_TO_CO2 * 3600E-6 prim_energy_CCGT_MJ[hour] = Q_used_prim_CCGT_W * lca.NG_CC_TO_OIL_STD * WH_TO_J / 1.0E6 - E_gen_CCGT_W[hour] * lca.EL_TO_OIL_EQ * 3600E-6 NG_used_CCGT_W[hour] = Q_used_prim_CCGT_W if reduced_timesteps_flag: reduced_costs_USD = np.sum(opex_var_CCGT_USD) reduced_CO2_kgCO2 = np.sum(co2_CCGT_kgCO2) reduced_prim_MJ = np.sum(prim_energy_CCGT_MJ) costs_a_USD += reduced_costs_USD * (8760 / (stop_t - start_t)) CO2_kgCO2 += reduced_CO2_kgCO2 * (8760 / (stop_t - start_t)) prim_MJ += reduced_prim_MJ * (8760 / (stop_t - start_t)) else: costs_a_USD += np.sum(opex_var_CCGT_USD) CO2_kgCO2 += np.sum(co2_CCGT_kgCO2) prim_MJ += np.sum(prim_energy_CCGT_MJ) ########## Add investment costs for i in range(limits['number_of_VCC_chillers']): Capex_a_VCC_USD, Opex_fixed_VCC_USD, Capex_VCC_USD = VCCModel.calc_Cinv_VCC(Q_VCC_nom_W, locator, config, 'CH3') costs_a_USD += Capex_a_VCC_USD + Opex_fixed_VCC_USD for i in range(limits['number_of_VCC_backup_chillers']): Capex_a_VCC_backup_USD, Opex_fixed_VCC_backup_USD, Capex_VCC_backup_USD = VCCModel.calc_Cinv_VCC(Q_VCC_backup_nom_W, locator, config, 'CH3') costs_a_USD += Capex_a_VCC_backup_USD + Opex_fixed_VCC_backup_USD master_to_slave_vars.VCC_backup_cooling_size_W = Q_VCC_backup_nom_W * limits['number_of_VCC_backup_chillers'] for i in range(limits['number_of_ACH_chillers']): Capex_a_ACH_USD, Opex_fixed_ACH_USD, Capex_ACH_USD = chiller_absorption.calc_Cinv_ACH(Q_ACH_nom_W, locator, ACH_TYPE_DOUBLE, config) costs_a_USD += Capex_a_ACH_USD + Opex_fixed_ACH_USD Capex_a_CCGT_USD, Opex_fixed_CCGT_USD, Capex_CCGT_USD = cogeneration.calc_Cinv_CCGT(Q_GT_nom_W, locator, config) costs_a_USD += Capex_a_CCGT_USD + Opex_fixed_CCGT_USD Capex_a_Tank_USD, Opex_fixed_Tank_USD, Capex_Tank_USD = thermal_storage.calc_Cinv_storage(V_tank_m3, locator, config, 'TES2') costs_a_USD += Capex_a_Tank_USD + Opex_fixed_Tank_USD Capex_a_CT_USD, Opex_fixed_CT_USD, Capex_CT_USD = CTModel.calc_Cinv_CT(Q_CT_nom_W, locator, config, 'CT1') costs_a_USD += Capex_a_CT_USD + Opex_fixed_CT_USD Capex_a_pump_USD, Opex_fixed_pump_USD, Opex_var_pump_USD, Capex_pump_USD = PumpModel.calc_Ctot_pump(master_to_slave_vars, ntwFeat, locator, lca, config) costs_a_USD += Capex_a_pump_USD + Opex_fixed_pump_USD + Opex_var_pump_USD network_data = pd.read_csv(locator.get_optimization_network_data_folder(master_to_slave_vars.network_data_file_cooling)) date = network_data.DATE.values results = pd.DataFrame({"DATE": date, "Q_total_cooling_W": Q_cooling_req_W, "Opex_var_Lake_USD": opex_var_Lake_USD, "Opex_var_VCC_USD": opex_var_VCC_USD, "Opex_var_ACH_USD": opex_var_ACH_USD, "Opex_var_VCC_backup_USD": opex_var_VCC_backup_USD, "Opex_var_CT_USD": opex_var_CT_USD, "Opex_var_CCGT_USD": opex_var_CCGT_USD, "E_used_Lake_W": E_used_Lake_W, "E_used_VCC_W": E_used_VCC_W, "E_used_VCC_backup_W": E_used_VCC_backup_W, "E_used_ACH_W": E_used_ACH_W, "E_used_CT_W": E_used_CT_W, "NG_used_CCGT_W": NG_used_CCGT_W, "CO2_from_using_Lake": co2_Lake_kgCO2, "CO2_from_using_VCC": co2_VCC_kgCO2, "CO2_from_using_ACH": co2_ACH_kgCO2, "CO2_from_using_VCC_backup": co2_VCC_backup_kgCO2, "CO2_from_using_CT": co2_CT_kgCO2, "CO2_from_using_CCGT": co2_CCGT_kgCO2, "Primary_Energy_from_Lake": prim_energy_Lake_MJ, "Primary_Energy_from_VCC": prim_energy_VCC_MJ, "Primary_Energy_from_ACH": prim_energy_ACH_MJ, "Primary_Energy_from_VCC_backup": prim_energy_VCC_backup_MJ, "Primary_Energy_from_CT": prim_energy_CT_MJ, "Primary_Energy_from_CCGT": prim_energy_CCGT_MJ, "Q_from_Lake_W": Qc_from_Lake_W, "Q_from_VCC_W": Qc_from_VCC_W, "Q_from_ACH_W": Qc_from_ACH_W, "Q_from_VCC_backup_W": Qc_from_VCC_backup_W, "Q_from_storage_tank_W": Qc_from_storage_tank_W, "Qc_CT_associated_with_all_chillers_W": Qc_req_from_CT_W, "Qh_CCGT_associated_with_absorption_chillers_W": Qh_from_CCGT_W, "E_gen_CCGT_associated_with_absorption_chillers_W": E_gen_CCGT_W }) results.to_csv(locator.get_optimization_slave_cooling_activation_pattern(master_to_slave_vars.individual_number, master_to_slave_vars.generation_number), index=False) ########### Adjust and add the pumps for filtering and pre-treatment of the water calibration = calfactor_total / 50976000 extraElec = (127865400 + 85243600) * calibration costs_a_USD += extraElec * lca.ELEC_PRICE CO2_kgCO2 += extraElec * lca.EL_TO_CO2 * 3600E-6 prim_MJ += extraElec * lca.EL_TO_OIL_EQ * 3600E-6 # Converting costs into float64 to avoid longer values costs_a_USD = np.float64(costs_a_USD) CO2_kgCO2 = np.float64(CO2_kgCO2) prim_MJ = np.float64(prim_MJ) # Capex_a and Opex_fixed results = pd.DataFrame({"Capex_a_VCC_USD": [Capex_a_VCC_USD], "Opex_fixed_VCC_USD": [Opex_fixed_VCC_USD], "Capex_a_VCC_backup_USD": [Capex_a_VCC_backup_USD], "Opex_fixed_VCC_backup_USD": [Opex_fixed_VCC_backup_USD], "Capex_a_ACH_USD": [Capex_a_ACH_USD], "Opex_fixed_ACH_USD": [Opex_fixed_ACH_USD], "Capex_a_CCGT_USD": [Capex_a_CCGT_USD], "Opex_fixed_CCGT_USD": [Opex_fixed_CCGT_USD], "Capex_a_Tank_USD": [Capex_a_Tank_USD], "Opex_fixed_Tank_USD": [Opex_fixed_Tank_USD], "Capex_a_CT_USD": [Capex_a_CT_USD], "Opex_fixed_CT_USD": [Opex_fixed_CT_USD], "Capex_a_pump_USD": [Capex_a_pump_USD], "Opex_fixed_pump_USD": [Opex_fixed_pump_USD], "Opex_var_pump_USD": [Opex_var_pump_USD], "Capex_VCC_USD": [Capex_VCC_USD], "Capex_VCC_backup_USD": [Capex_VCC_backup_USD], "Capex_ACH_USD": [Capex_ACH_USD], "Capex_CCGT_USD": [Capex_CCGT_USD], "Capex_Tank_USD": [Capex_Tank_USD], "Capex_CT_USD": [Capex_CT_USD], "Capex_pump_USD": [Capex_pump_USD] }) results.to_csv(locator.get_optimization_slave_investment_cost_detailed_cooling(master_to_slave_vars.individual_number, master_to_slave_vars.generation_number), index=False) # print " Cooling main done (", round(time.time()-t0, 1), " seconds used for this task)" # print ('Cooling costs = ' + str(costs)) # print ('Cooling CO2 = ' + str(CO2)) # print ('Cooling Eprim = ' + str(prim)) return (costs_a_USD, CO2_kgCO2, prim_MJ)
def addCosts(indCombi, buildList, locator, dicoSupply, Q_uncovered_design_W, Q_uncovered_annual_W, solarFeat, ntwFeat, gv): """ Computes additional costs / GHG emisions / primary energy needs for the individual addCosts = additional costs addCO2 = GHG emissions addPrm = primary energy needs :param indCombi: parameter indicating if the building is connected or not :param buildList: list of buildings in the district :param locator: input locator set to scenario :param dicoSupply: class containing the features of a specific individual :param Q_uncovered_design_W: hourly max of the heating uncovered demand :param Q_uncovered_annual_W: total heating uncovered :param solarFeat: solar features :param ntwFeat: network features :param gv: global variables :type indCombi: string :type buildList: list :type locator: string :type dicoSupply: class :type Q_uncovered_design_W: float :type Q_uncovered_annual_W: float :type solarFeat: class :type ntwFeat: class :type gv: class :return: returns the objectives addCosts, addCO2, addPrim :rtype: tuple """ addCosts = 0 addCO2 = 0 addPrim = 0 nBuildinNtw = 0 # Add the features from the disconnected buildings print "\n COSTS FROM DISCONNECTED BUILDINGS" os.chdir(locator.get_optimization_disconnected_folder()) CostDiscBuild = 0 CO2DiscBuild = 0 PrimDiscBuild = 0 FurnaceInvCost = 0 CCInvCost = 0 BoilerBInvCost = 0 BoilerPInvCost = 0 HPLakeInvC = 0 HPSewInvC = 0 GHPInvC = 0 PVInvC = 0 SCInvC = 0 PVTInvC = 0 BoilerAddInvC = 0 StorageHEXCost = 0 StorageHPCost = 0 StorageInvC = 0 NetworkCost = 0 SubstHEXCost = 0 PVTHEXCost = 0 SCHEXCost = 0 pumpCosts = 0 GasConnectionInvCost = 0 for (index, building_name) in zip(indCombi, buildList): if index == "0": discFileName = "DiscOp_" + building_name + "_result.csv" df = pd.read_csv(discFileName) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest["Primary Energy Needs [MJoil-eq]"].iloc[ 0] # [MJ-oil-eq] print dfBest["Total Costs [CHF]"].iloc[ 0], building_name, "disconnected" else: nBuildinNtw += 1 addCosts += CostDiscBuild addCO2 += CO2DiscBuild addPrim += PrimDiscBuild # Add the features for the distribution if indCombi.count("1") > 0: os.chdir(locator.get_optimization_slave_results_folder()) print " \n MACHINERY COSTS" # Add the investment costs of the energy systems # Furnace if dicoSupply.Furnace_on == 1: P_design_W = dicoSupply.Furnace_Q_max fNameSlavePP = locator.get_optimization_slave_pp_activation_pattern( dicoSupply.configKey) dfFurnace = pd.read_csv(fNameSlavePP, usecols=["Q_Furnace_W"]) arrayFurnace_W = np.array(dfFurnace) Q_annual_W = 0 for i in range(int(np.shape(arrayFurnace_W)[0])): Q_annual_W += arrayFurnace_W[i][0] FurnaceInvCost = furnace.calc_Cinv_furnace(P_design_W, Q_annual_W, gv) addCosts += FurnaceInvCost print furnace.calc_Cinv_furnace(P_design_W, Q_annual_W, gv), " Furnace" # CC if dicoSupply.CC_on == 1: CC_size_W = dicoSupply.CC_GT_SIZE CCInvCost = chp.calc_Cinv_CCT(CC_size_W, gv) addCosts += CCInvCost print chp.calc_Cinv_CCT(CC_size_W, gv), " CC" # Boiler Base if dicoSupply.Boiler_on == 1: Q_design_W = dicoSupply.Boiler_Q_max fNameSlavePP = locator.get_optimization_slave_pp_activation_pattern( dicoSupply.configKey) dfBoilerBase = pd.read_csv(fNameSlavePP, usecols=["Q_BoilerBase_W"]) arrayBoilerBase_W = np.array(dfBoilerBase) Q_annual_W = 0 for i in range(int(np.shape(arrayBoilerBase_W)[0])): Q_annual_W += arrayBoilerBase_W[i][0] BoilerBInvCost = boiler.calc_Cinv_boiler(Q_design_W, Q_annual_W, gv) addCosts += BoilerBInvCost print boiler.calc_Cinv_boiler(Q_design_W, Q_annual_W, gv), " Boiler Base " # Boiler Peak if dicoSupply.BoilerPeak_on == 1: Q_design_W = dicoSupply.BoilerPeak_Q_max fNameSlavePP = locator.get_optimization_slave_pp_activation_pattern( dicoSupply.configKey) dfBoilerPeak = pd.read_csv(fNameSlavePP, usecols=["Q_BoilerPeak_W"]) arrayBoilerPeak_W = np.array(dfBoilerPeak) Q_annual_W = 0 for i in range(int(np.shape(arrayBoilerPeak_W)[0])): Q_annual_W += arrayBoilerPeak_W[i][0] BoilerPInvCost = boiler.calc_Cinv_boiler(Q_design_W, Q_annual_W, gv) addCosts += BoilerPInvCost print boiler.calc_Cinv_boiler(Q_design_W, Q_annual_W, gv), " Boiler Peak" # HP Lake if dicoSupply.HP_Lake_on == 1: HP_Size_W = dicoSupply.HPLake_maxSize HPLakeInvC = hp.calc_Cinv_HP(HP_Size_W, gv) addCosts += HPLakeInvC print hp.calc_Cinv_HP(HP_Size_W, gv), " HP Lake" # HP Sewage if dicoSupply.HP_Sew_on == 1: HP_Size_W = dicoSupply.HPSew_maxSize HPSewInvC = hp.calc_Cinv_HP(HP_Size_W, gv) addCosts += HPSewInvC print hp.calc_Cinv_HP(HP_Size_W, gv), "HP Sewage" # GHP if dicoSupply.GHP_on == 1: fNameSlavePP = locator.get_optimization_slave_pp_activation_pattern( dicoSupply.configKey) dfGHP = pd.read_csv(fNameSlavePP, usecols=["E_GHP_req_W"]) arrayGHP_W = np.array(dfGHP) GHP_Enom_W = np.amax(arrayGHP_W) GHPInvC = hp.calc_Cinv_GHP(GHP_Enom_W, gv) * gv.EURO_TO_CHF addCosts += GHPInvC print hp.calc_Cinv_GHP(GHP_Enom_W, gv) * gv.EURO_TO_CHF, " GHP" # Solar technologies PV_peak_kW = dicoSupply.SOLAR_PART_PV * solarFeat.A_PV_m2 * gv.nPV #kW PVInvC = pv.calc_Cinv_pv(PV_peak_kW) addCosts += PVInvC print pv.calc_Cinv_pv(PV_peak_kW), "PV peak" SC_area_m2 = dicoSupply.SOLAR_PART_SC * solarFeat.A_SC_m2 SCInvC = stc.calc_Cinv_SC(SC_area_m2, gv) addCosts += SCInvC print stc.calc_Cinv_SC(SC_area_m2, gv), "SC area" PVT_peak_kW = dicoSupply.SOLAR_PART_PVT * solarFeat.A_PVT_m2 * gv.nPVT #kW PVTInvC = pvt.calc_Cinv_PVT(PVT_peak_kW, gv) addCosts += PVTInvC print pvt.calc_Cinv_PVT(PVT_peak_kW, gv), "PVT peak" # Back-up boiler BoilerAddInvC = boiler.calc_Cinv_boiler(Q_uncovered_design_W, Q_uncovered_annual_W, gv) addCosts += BoilerAddInvC print boiler.calc_Cinv_boiler(Q_uncovered_design_W, Q_uncovered_annual_W, gv), "backup boiler" # Hex and HP for Heat recovery print "\n STORAGE PART COSTS" if dicoSupply.WasteServersHeatRecovery == 1: df = pd.read_csv(os.path.join( locator.get_optimization_network_results_folder(), dicoSupply.NETWORK_DATA_FILE), usecols=["Qcdata_netw_total_kWh"]) array = np.array(df) Q_HEX_max_kWh = np.amax(array) StorageHEXCost += hex.calc_Cinv_HEX(Q_HEX_max_kWh, gv) print hex.calc_Cinv_HEX(Q_HEX_max_kWh, gv), "Hex for data center" df = pd.read_csv( locator.get_optimization_slave_storage_operation_data( dicoSupply.configKey), usecols=["HPServerHeatDesignArray_kWh"]) array = np.array(df) Q_HP_max_kWh = np.amax(array) StorageHEXCost += hp.calc_Cinv_HP(Q_HP_max_kWh, gv) print hp.calc_Cinv_HP(Q_HP_max_kWh, gv), "HP for data center" if dicoSupply.WasteCompressorHeatRecovery == 1: df = pd.read_csv(os.path.join( locator.get_optimization_network_results_folder(), dicoSupply.NETWORK_DATA_FILE), usecols=["Ecaf_netw_total_kWh"]) array = np.array(df) Q_HEX_max_kWh = np.amax(array) StorageHEXCost += hex.calc_Cinv_HEX(Q_HEX_max_kWh, gv) print hex.calc_Cinv_HEX(Q_HEX_max_kWh, gv), "Hex for compressed air" df = pd.read_csv( locator.get_optimization_slave_storage_operation_data( dicoSupply.configKey), usecols=["HPCompAirDesignArray_kWh"]) array = np.array(df) Q_HP_max_kWh = np.amax(array) StorageHEXCost += hp.calc_Cinv_HP(Q_HP_max_kWh, gv) print hp.calc_Cinv_HP(Q_HP_max_kWh, gv), "HP for compressed air" addCosts += StorageHEXCost # Heat pump solar to storage df = pd.read_csv( locator.get_optimization_slave_storage_operation_data( dicoSupply.configKey), usecols=["HPScDesignArray_Wh", "HPpvt_designArray_Wh"]) array = np.array(df) Q_HP_max_PVT_Wh = np.amax(array[:, 1]) QhpMax_SC_Wh = np.amax(array[:, 0]) StorageHPCost += hp.calc_Cinv_HP(Q_HP_max_PVT_Wh, gv) print hp.calc_Cinv_HP(Q_HP_max_PVT_Wh, gv), "HP for PVT" StorageHPCost += hp.calc_Cinv_HP(QhpMax_SC_Wh, gv) print hp.calc_Cinv_HP(QhpMax_SC_Wh, gv), "HP for SC" # HP for storage operation df = pd.read_csv(locator.get_optimization_slave_storage_operation_data( dicoSupply.configKey), usecols=[ "E_aux_ch_W", "E_aux_dech_W", "Q_from_storage_used_W", "Q_to_storage_W" ]) array = np.array(df) Q_HP_max_storage_W = 0 for i in range(gv.DAYS_IN_YEAR * gv.HOURS_IN_DAY): if array[i][0] > 0: Q_HP_max_storage_W = max(Q_HP_max_storage_W, array[i][3] + array[i][0]) elif array[i][1] > 0: Q_HP_max_storage_W = max(Q_HP_max_storage_W, array[i][2] + array[i][1]) StorageHPCost += hp.calc_Cinv_HP(Q_HP_max_storage_W, gv) addCosts += StorageHPCost print hp.calc_Cinv_HP(Q_HP_max_storage_W, gv), "HP for storage" # Storage df = pd.read_csv(locator.get_optimization_slave_storage_operation_data( dicoSupply.configKey), usecols=["Storage_Size_m3"], nrows=1) StorageVol_m3 = np.array(df)[0][0] StorageInvC += storage.calc_Cinv_storage(StorageVol_m3, gv) addCosts += StorageInvC print storage.calc_Cinv_storage(StorageVol_m3, gv), "Storage Costs" # Costs from distribution configuration print "\n COSTS FROM NETWORK CONFIGURATION" if gv.ZernezFlag == 1: NetworkCost += network.calc_Cinv_network_linear( gv.NetworkLengthZernez, gv) * nBuildinNtw / len(buildList) else: NetworkCost += ntwFeat.pipesCosts_DHN * nBuildinNtw / len( buildList) addCosts += NetworkCost print ntwFeat.pipesCosts_DHN * nBuildinNtw / len( buildList), "Pipes Costs" # HEX (1 per building in ntw) for (index, building_name) in zip(indCombi, buildList): if index == "1": df = pd.read_csv( locator.get_optimization_substations_results_file( building_name), usecols=["Q_dhw_W", "Q_heating_W"]) subsArray = np.array(df) Q_max_W = np.amax(subsArray[:, 0] + subsArray[:, 1]) SubstHEXCost += hex.calc_Cinv_HEX(Q_max_W, gv) print hex.calc_Cinv_HEX(Q_max_W, gv), "Hex", building_name addCosts += SubstHEXCost # HEX for solar roof_area_m2 = np.array( pd.read_csv(locator.get_total_demand(), usecols=["Aroof_m2"])) areaAvail = 0 for i in range(len(indCombi)): index = indCombi[i] if index == "1": areaAvail += roof_area_m2[i][0] for i in range(len(indCombi)): index = indCombi[i] if index == "1": share = roof_area_m2[i][0] / areaAvail #print share, "solar area share", buildList[i] Q_max_SC_Wh = solarFeat.Q_nom_SC_Wh * dicoSupply.SOLAR_PART_SC * share SCHEXCost += hex.calc_Cinv_HEX(Q_max_SC_Wh, gv) print hex.calc_Cinv_HEX(Q_max_SC_Wh, gv), "Hex SC", buildList[i] Q_max_PVT_Wh = solarFeat.Q_nom_PVT_Wh * dicoSupply.SOLAR_PART_PVT * share PVTHEXCost += hex.calc_Cinv_HEX(Q_max_PVT_Wh, gv) print hex.calc_Cinv_HEX(Q_max_PVT_Wh, gv), "Hex PVT", buildList[i] addCosts += SCHEXCost addCosts += PVTHEXCost print addCosts, "addCosts in extraCostsMain" # Pump operation costs pumpCosts = pumps.calc_Ctot_pump( dicoSupply, buildList, locator.get_optimization_network_results_folder(), ntwFeat, gv) addCosts += pumpCosts print pumpCosts, "Pump Operation costs in extraCostsMain\n" # import gas consumption data from: if indCombi.count("1") > 0: # import gas consumption data from: E_gas_PrimaryDataframe_W = pd.read_csv( locator.get_optimization_slave_primary_energy_by_source( dicoSupply.configKey), usecols=["E_gas_PrimaryPeakPower_W"]) E_gas_primary_peak_power_W = float(np.array(E_gas_PrimaryDataframe_W)) GasConnectionInvCost = ngas.calc_Cinv_gas(E_gas_primary_peak_power_W, gv) else: GasConnectionInvCost = 0.0 addCosts += GasConnectionInvCost # Save data results = pd.DataFrame({ "SCInvC": [SCInvC], "PVTInvC": [PVTInvC], "BoilerAddInvC": [BoilerAddInvC], "StorageHEXCost": [StorageHEXCost], "StorageHPCost": [StorageHPCost], "StorageInvC": [StorageInvC], "StorageCostSum": [StorageInvC + StorageHPCost + StorageHEXCost], "NetworkCost": [NetworkCost], "SubstHEXCost": [SubstHEXCost], "DHNInvestCost": [addCosts - CostDiscBuild], "PVTHEXCost": [PVTHEXCost], "CostDiscBuild": [CostDiscBuild], "CO2DiscBuild": [CO2DiscBuild], "PrimDiscBuild": [PrimDiscBuild], "FurnaceInvCost": [FurnaceInvCost], "BoilerBInvCost": [BoilerBInvCost], "BoilerPInvCost": [BoilerPInvCost], "HPLakeInvC": [HPLakeInvC], "HPSewInvC": [HPSewInvC], "SCHEXCost": [SCHEXCost], "pumpCosts": [pumpCosts], "SumInvestCost": [addCosts], "GasConnectionInvCa": [GasConnectionInvCost] }) results.to_csv(locator.get_optimization_slave_investment_cost_detailed( dicoSupply.configKey), sep=',') return (addCosts, addCO2, addPrim)
def addCosts(indCombi, buildList, locator, dicoSupply, QUncoveredDesign, QUncoveredAnnual, solarFeat, ntwFeat, gv): """ Computes additional costs / GHG emisions / primary energy needs for the individual Parameters ---------- indCombi : string with 0 if disconnected building, 1 if connected buildList : list list of buildings in the district locator : string path to folders dicoSupply : class context with the features of the specific individual QuncoveredDesign : float hourly max of the heating uncovered demand QuncoveredAnnual : float total heating uncovered solarFeat / ntwFeat : class solarFeatures / ntwFeatures Returns ------- (addCosts, addCO2, addPrim) : tuple """ addCosts = 0 addCO2 = 0 addPrim = 0 nBuildinNtw = 0 # Add the features from the disconnected buildings print "\n COSTS FROM DISCONNECTED BUILDINGS" os.chdir(locator.pathDiscRes) CostDiscBuild = 0 CO2DiscBuild = 0 PrimDiscBuild = 0 FurnaceInvCost = 0 CCInvCost = 0 BoilerBInvCost = 0 BoilerPInvCost = 0 HPLakeInvC = 0 HPSewInvC = 0 GHPInvC = 0 PVInvC = 0 SCInvC = 0 PVTInvC = 0 BoilerAddInvC = 0 StorageHEXCost = 0 StorageHPCost = 0 StorageInvC = 0 NetworkCost = 0 SubstHEXCost = 0 PVTHEXCost = 0 SCHEXCost = 0 pumpCosts = 0 GasConnectionInvCost = 0 for (index, buildName) in zip(indCombi, buildList): if index == "0": discFileName = "DiscOp_" + buildName + "_result.csv" df = pd.read_csv(discFileName) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[0] # [kg CO2] PrimDiscBuild += dfBest["Primary Energy Needs [MJoil-eq]"].iloc[0] # [MJ-oil-eq] print dfBest["Total Costs [CHF]"].iloc[0], buildName, "disconnected" else: nBuildinNtw += 1 addCosts += CostDiscBuild addCO2 += CO2DiscBuild addPrim += PrimDiscBuild # Add the features for the network if indCombi.count("1") > 0: os.chdir(locator.pathSlaveRes) print " \n MACHINERY COSTS" # Add the investment costs of the energy systems # Furnace if dicoSupply.Furnace_on == 1: P_design = dicoSupply.Furnace_Q_max fNameSlavePP = dicoSupply.configKey + "PPActivationPattern.csv" dfFurnace = pd.read_csv(fNameSlavePP, usecols=["Q_Furnace"]) arrayFurnace = np.array(dfFurnace) Q_annual = 0 for i in range(int(np.shape(arrayFurnace)[0])): Q_annual += arrayFurnace[i][0] FurnaceInvCost = furnace.calc_Cinv_furnace(P_design, Q_annual, gv) addCosts += FurnaceInvCost print furnace.calc_Cinv_furnace(P_design, Q_annual, gv), " Furnace" # CC if dicoSupply.CC_on == 1: CC_size = dicoSupply.CC_GT_SIZE CCInvCost = chp.calc_Cinv_CCT(CC_size, gv) addCosts += CCInvCost print chp.calc_Cinv_CCT(CC_size, gv), " CC" # Boiler Base if dicoSupply.Boiler_on == 1: Q_design = dicoSupply.Boiler_Q_max fNameSlavePP = dicoSupply.configKey + "PPActivationPattern.csv" dfBoilerBase = pd.read_csv(fNameSlavePP, usecols=["Q_BoilerBase"]) arrayBoilerBase = np.array(dfBoilerBase) Q_annual = 0 for i in range(int(np.shape(arrayBoilerBase)[0])): Q_annual += arrayBoilerBase[i][0] BoilerBInvCost = boiler.calc_Cinv_boiler(Q_design, Q_annual, gv) addCosts += BoilerBInvCost print boiler.calc_Cinv_boiler(Q_design, Q_annual, gv), " Boiler Base " # Boiler Peak if dicoSupply.BoilerPeak_on == 1: Q_design = dicoSupply.BoilerPeak_Q_max fNameSlavePP = dicoSupply.configKey + "PPActivationPattern.csv" dfBoilerPeak = pd.read_csv(fNameSlavePP, usecols=["Q_BoilerPeak"]) arrayBoilerPeak = np.array(dfBoilerPeak) Q_annual = 0 for i in range(int(np.shape(arrayBoilerPeak)[0])): Q_annual += arrayBoilerPeak[i][0] BoilerPInvCost = boiler.calc_Cinv_boiler(Q_design, Q_annual, gv) addCosts += BoilerPInvCost print boiler.calc_Cinv_boiler(Q_design, Q_annual, gv), " Boiler Peak" # HP Lake if dicoSupply.HP_Lake_on == 1: HP_Size = dicoSupply.HPLake_maxSize HPLakeInvC = hp.calc_Cinv_HP(HP_Size, gv) addCosts += HPLakeInvC print hp.calc_Cinv_HP(HP_Size, gv), " HP Lake" # HP Sewage if dicoSupply.HP_Sew_on == 1: HP_Size = dicoSupply.HPSew_maxSize HPSewInvC = hp.calc_Cinv_HP(HP_Size, gv) addCosts += HPSewInvC print hp.calc_Cinv_HP(HP_Size, gv), "HP Sewage" # GHP if dicoSupply.GHP_on == 1: fNameSlavePP = dicoSupply.configKey + "PPActivationPattern.csv" dfGHP = pd.read_csv(fNameSlavePP, usecols=["E_GHP"]) arrayGHP = np.array(dfGHP) GHP_Enom = np.amax(arrayGHP) GHPInvC = hp.calc_Cinv_GHP(GHP_Enom, gv) * gv.EURO_TO_CHF addCosts += GHPInvC print hp.calc_Cinv_GHP(GHP_Enom, gv) * gv.EURO_TO_CHF, " GHP" # Solar technologies PV_peak = dicoSupply.SOLAR_PART_PV * solarFeat.SolarAreaPV * gv.nPV #kW PVInvC = pv.calc_Cinv_PV(PV_peak) addCosts += PVInvC print pv.calc_Cinv_PV(PV_peak), "PV peak" SC_area = dicoSupply.SOLAR_PART_SC * solarFeat.SolarAreaSC SCInvC = stc.calc_Cinv_SC(SC_area) addCosts += SCInvC print stc.calc_Cinv_SC(SC_area), "SC area" PVT_peak = dicoSupply.SOLAR_PART_PVT * solarFeat.SolarAreaPVT * gv.nPVT #kW PVTInvC = pvt.calc_Cinv_PVT(PVT_peak) addCosts += PVTInvC print pvt.calc_Cinv_PVT(PVT_peak), "PVT peak" # Back-up boiler BoilerAddInvC = boiler.calc_Cinv_boiler(QUncoveredDesign, QUncoveredAnnual, gv) addCosts += BoilerAddInvC print boiler.calc_Cinv_boiler(QUncoveredDesign, QUncoveredAnnual, gv), "backup boiler" # Hex and HP for Heat recovery print "\n STORAGE PART COSTS" if dicoSupply.WasteServersHeatRecovery == 1: df = pd.read_csv(locator.pathNtwRes + "/" + dicoSupply.NETWORK_DATA_FILE, usecols = ["Qcdata_netw_total"]) array = np.array(df) QhexMax = np.amax(array) StorageHEXCost += hex.calc_Cinv_HEX(QhexMax, gv) print hex.calc_Cinv_HEX(QhexMax, gv), "Hex for data center" df = pd.read_csv(locator.pathSlaveRes + "/" + dicoSupply.configKey + "StorageOperationData.csv", usecols = ["HPServerHeatDesignArray"]) array = np.array(df) QhpMax = np.amax(array) StorageHEXCost += hp.calc_Cinv_HP(QhpMax, gv) print hp.calc_Cinv_HP(QhpMax, gv), "HP for data center" if dicoSupply.WasteCompressorHeatRecovery == 1: df = pd.read_csv(locator.pathNtwRes + "/" + dicoSupply.NETWORK_DATA_FILE, usecols = ["Ecaf_netw_total"]) array = np.array(df) QhexMax = np.amax(array) StorageHEXCost += hex.calc_Cinv_HEX(QhexMax, gv) print hex.calc_Cinv_HEX(QhexMax, gv), "Hex for compressed air" df = pd.read_csv(locator.pathSlaveRes + "/" + dicoSupply.configKey + "StorageOperationData.csv", usecols = ["HPCompAirDesignArray"]) array = np.array(df) QhpMax = np.amax(array) StorageHEXCost += hp.calc_Cinv_HP(QhpMax, gv) print hp.calc_Cinv_HP(QhpMax, gv), "HP for compressed air" addCosts += StorageHEXCost # Heat pump solar to storage df = pd.read_csv(locator.pathSlaveRes + "/" + dicoSupply.configKey + "StorageOperationData.csv", usecols = ["HPScDesignArray", "HPpvt_designArray"]) array = np.array(df) QhpMax_PVT = np.amax(array[:,1]) QhpMax_SC = np.amax(array[:,0]) StorageHPCost += hp.calc_Cinv_HP(QhpMax_PVT, gv) print hp.calc_Cinv_HP(QhpMax_PVT, gv), "HP for PVT" StorageHPCost += hp.calc_Cinv_HP(QhpMax_SC, gv) print hp.calc_Cinv_HP(QhpMax_SC, gv), "HP for SC" # HP for storage operation df = pd.read_csv(locator.pathSlaveRes + "/" + dicoSupply.configKey + "StorageOperationData.csv", usecols = ["E_aux_ch", "E_aux_dech", "Q_from_storage_used", "Q_to_storage"]) array = np.array(df) QmaxHPStorage = 0 for i in range(gv.DAYS_IN_YEAR * gv.HOURS_IN_DAY): if array[i][0] > 0: QmaxHPStorage = max(QmaxHPStorage, array[i][3] + array[i][0]) elif array[i][1] > 0: QmaxHPStorage = max(QmaxHPStorage, array[i][2] + array[i][1]) StorageHPCost += hp.calc_Cinv_HP(QmaxHPStorage, gv) addCosts += StorageHPCost print hp.calc_Cinv_HP(QmaxHPStorage, gv), "HP for storage" # Storage df = pd.read_csv(locator.pathSlaveRes + "/" + dicoSupply.configKey + "StorageOperationData.csv", usecols = ["Storage_Size"], nrows = 1) StorageVol = np.array(df)[0][0] StorageInvC += storage.calc_Cinv_storage(StorageVol, gv) addCosts += StorageInvC print storage.calc_Cinv_storage(StorageVol, gv), "Storage Costs" # Costs from network configuration print "\n COSTS FROM NETWORK CONFIGURATION" if gv.ZernezFlag == 1: NetworkCost += network.calc_Cinv_network_linear(gv.NetworkLengthZernez, gv) * nBuildinNtw / len(buildList) else: NetworkCost += ntwFeat.pipesCosts_DHN * nBuildinNtw / len(buildList) addCosts += NetworkCost print ntwFeat.pipesCosts_DHN * nBuildinNtw / len(buildList), "Pipes Costs" # HEX (1 per building in ntw) for (index, buildName) in zip(indCombi, buildList): if index == "1": subsFileName = buildName + "_result.csv" df = pd.read_csv(locator.pathSubsRes + "/" + subsFileName, usecols = ["Q_dhw", "Q_heating"]) subsArray = np.array(df) Qmax = np.amax( subsArray[:,0] + subsArray[:,1] ) SubstHEXCost += hex.calc_Cinv_HEX(Qmax, gv) print hex.calc_Cinv_HEX(Qmax, gv), "Hex", buildName addCosts += SubstHEXCost # HEX for solar roof_area = np.array(pd.read_csv(locator.get_total_demand(), usecols=["Aroof_m2"])) areaAvail = 0 for i in range( len(indCombi) ): index = indCombi[i] if index == "1": areaAvail += roof_area[i][0] for i in range( len(indCombi) ): index = indCombi[i] if index == "1": share = roof_area[i][0] / areaAvail #print share, "solar area share", buildList[i] SC_Qmax = solarFeat.SC_Qnom * dicoSupply.SOLAR_PART_SC * share SCHEXCost += hex.calc_Cinv_HEX(SC_Qmax, gv) print hex.calc_Cinv_HEX(SC_Qmax, gv), "Hex SC", buildList[i] PVT_Qmax = solarFeat.PVT_Qnom * dicoSupply.SOLAR_PART_PVT * share PVTHEXCost += hex.calc_Cinv_HEX(PVT_Qmax, gv) print hex.calc_Cinv_HEX(PVT_Qmax, gv), "Hex PVT", buildList[i] addCosts += SCHEXCost addCosts += PVTHEXCost print addCosts,"addCosts in extraCostsMain" # Pump operation costs pumpCosts = pumps.calc_Ctot_pump(dicoSupply, buildList, locator.pathNtwRes, ntwFeat, gv) addCosts += pumpCosts print pumpCosts, "Pump Operation costs in extraCostsMain\n" # import gas consumption data from: if indCombi.count("1") > 0: # import gas consumption data from: FileName = locator.pathSlaveRes + "/" + dicoSupply.configKey + "PrimaryEnergyBySource.csv" colName = "EgasPrimaryPeakPower" EgasPrimaryDataframe = pd.read_csv(FileName, usecols=[colName]) #print EgasPrimaryDataframe #print np.array(EgasPrimaryDataframe) #print float(np.array(EgasPrimaryDataframe)) EgasPrimaryPeakPower = float(np.array(EgasPrimaryDataframe)) GasConnectionInvCost = ngas.calc_Cinv_gas(EgasPrimaryPeakPower, gv) else: GasConnectionInvCost = 0.0 addCosts += GasConnectionInvCost # Save data results = pd.DataFrame({ "SCInvC":[SCInvC], "PVTInvC":[PVTInvC], "BoilerAddInvC":[BoilerAddInvC], "StorageHEXCost":[StorageHEXCost], "StorageHPCost":[StorageHPCost], "StorageInvC":[StorageInvC], "StorageCostSum":[StorageInvC+StorageHPCost+StorageHEXCost], "NetworkCost":[NetworkCost], "SubstHEXCost":[SubstHEXCost], "DHNInvestCost":[addCosts - CostDiscBuild], "PVTHEXCost":[PVTHEXCost], "CostDiscBuild":[CostDiscBuild], "CO2DiscBuild":[CO2DiscBuild], "PrimDiscBuild":[PrimDiscBuild], "FurnaceInvCost":[FurnaceInvCost], "BoilerBInvCost":[BoilerBInvCost], "BoilerPInvCost":[BoilerPInvCost], "HPLakeInvC":[HPLakeInvC], "HPSewInvC":[HPSewInvC], "SCHEXCost":[SCHEXCost], "pumpCosts":[pumpCosts], "SumInvestCost":[addCosts], "GasConnectionInvCa":[GasConnectionInvCost] }) Name = "/" + dicoSupply.configKey + "_InvestmentCostDetailed.csv" results.to_csv(locator.pathSlaveRes + Name, sep=',') return (addCosts, addCO2, addPrim)
def addCosts(indCombi, buildList, locator, dicoSupply, QUncoveredDesign, QUncoveredAnnual, solarFeat, ntwFeat, gv): """ Computes additional costs / GHG emisions / primary energy needs for the individual Parameters ---------- indCombi : string with 0 if disconnected building, 1 if connected buildList : list list of buildings in the district locator : string path to folders dicoSupply : class context with the features of the specific individual QuncoveredDesign : float hourly max of the heating uncovered demand QuncoveredAnnual : float total heating uncovered solarFeat / ntwFeat : class solarFeatures / ntwFeatures Returns ------- (addCosts, addCO2, addPrim) : tuple """ addCosts = 0 addCO2 = 0 addPrim = 0 nBuildinNtw = 0 # Add the features from the disconnected buildings print "\n COSTS FROM DISCONNECTED BUILDINGS" os.chdir(locator.pathDiscRes) CostDiscBuild = 0 CO2DiscBuild = 0 PrimDiscBuild = 0 FurnaceInvCost = 0 CCInvCost = 0 BoilerBInvCost = 0 BoilerPInvCost = 0 HPLakeInvC = 0 HPSewInvC = 0 GHPInvC = 0 PVInvC = 0 SCInvC = 0 PVTInvC = 0 BoilerAddInvC = 0 StorageHEXCost = 0 StorageHPCost = 0 StorageInvC = 0 NetworkCost = 0 SubstHEXCost = 0 PVTHEXCost = 0 SCHEXCost = 0 pumpCosts = 0 GasConnectionInvCost = 0 for (index, buildName) in zip(indCombi, buildList): if index == "0": discFileName = "DiscOp_" + buildName + "_result.csv" df = pd.read_csv(discFileName) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest["Primary Energy Needs [MJoil-eq]"].iloc[ 0] # [MJ-oil-eq] print dfBest["Total Costs [CHF]"].iloc[ 0], buildName, "disconnected" else: nBuildinNtw += 1 addCosts += CostDiscBuild addCO2 += CO2DiscBuild addPrim += PrimDiscBuild # Add the features for the network if indCombi.count("1") > 0: os.chdir(locator.pathSlaveRes) print " \n MACHINERY COSTS" # Add the investment costs of the energy systems # Furnace if dicoSupply.Furnace_on == 1: P_design = dicoSupply.Furnace_Q_max fNameSlavePP = dicoSupply.configKey + "PPActivationPattern.csv" dfFurnace = pd.read_csv(fNameSlavePP, usecols=["Q_Furnace"]) arrayFurnace = np.array(dfFurnace) Q_annual = 0 for i in range(int(np.shape(arrayFurnace)[0])): Q_annual += arrayFurnace[i][0] FurnaceInvCost = furnace.calc_Cinv_furnace(P_design, Q_annual, gv) addCosts += FurnaceInvCost print furnace.calc_Cinv_furnace(P_design, Q_annual, gv), " Furnace" # CC if dicoSupply.CC_on == 1: CC_size = dicoSupply.CC_GT_SIZE CCInvCost = chp.calc_Cinv_CCT(CC_size, gv) addCosts += CCInvCost print chp.calc_Cinv_CCT(CC_size, gv), " CC" # Boiler Base if dicoSupply.Boiler_on == 1: Q_design = dicoSupply.Boiler_Q_max fNameSlavePP = dicoSupply.configKey + "PPActivationPattern.csv" dfBoilerBase = pd.read_csv(fNameSlavePP, usecols=["Q_BoilerBase"]) arrayBoilerBase = np.array(dfBoilerBase) Q_annual = 0 for i in range(int(np.shape(arrayBoilerBase)[0])): Q_annual += arrayBoilerBase[i][0] BoilerBInvCost = boiler.calc_Cinv_boiler(Q_design, Q_annual, gv) addCosts += BoilerBInvCost print boiler.calc_Cinv_boiler(Q_design, Q_annual, gv), " Boiler Base " # Boiler Peak if dicoSupply.BoilerPeak_on == 1: Q_design = dicoSupply.BoilerPeak_Q_max fNameSlavePP = dicoSupply.configKey + "PPActivationPattern.csv" dfBoilerPeak = pd.read_csv(fNameSlavePP, usecols=["Q_BoilerPeak"]) arrayBoilerPeak = np.array(dfBoilerPeak) Q_annual = 0 for i in range(int(np.shape(arrayBoilerPeak)[0])): Q_annual += arrayBoilerPeak[i][0] BoilerPInvCost = boiler.calc_Cinv_boiler(Q_design, Q_annual, gv) addCosts += BoilerPInvCost print boiler.calc_Cinv_boiler(Q_design, Q_annual, gv), " Boiler Peak" # HP Lake if dicoSupply.HP_Lake_on == 1: HP_Size = dicoSupply.HPLake_maxSize HPLakeInvC = hp.calc_Cinv_HP(HP_Size, gv) addCosts += HPLakeInvC print hp.calc_Cinv_HP(HP_Size, gv), " HP Lake" # HP Sewage if dicoSupply.HP_Sew_on == 1: HP_Size = dicoSupply.HPSew_maxSize HPSewInvC = hp.calc_Cinv_HP(HP_Size, gv) addCosts += HPSewInvC print hp.calc_Cinv_HP(HP_Size, gv), "HP Sewage" # GHP if dicoSupply.GHP_on == 1: fNameSlavePP = dicoSupply.configKey + "PPActivationPattern.csv" dfGHP = pd.read_csv(fNameSlavePP, usecols=["E_GHP"]) arrayGHP = np.array(dfGHP) GHP_Enom = np.amax(arrayGHP) GHPInvC = hp.calc_Cinv_GHP(GHP_Enom, gv) * gv.EURO_TO_CHF addCosts += GHPInvC print hp.calc_Cinv_GHP(GHP_Enom, gv) * gv.EURO_TO_CHF, " GHP" # Solar technologies PV_peak = dicoSupply.SOLAR_PART_PV * solarFeat.SolarAreaPV * gv.nPV #kW PVInvC = pv.calc_Cinv_PV(PV_peak) addCosts += PVInvC print pv.calc_Cinv_PV(PV_peak), "PV peak" SC_area = dicoSupply.SOLAR_PART_SC * solarFeat.SolarAreaSC SCInvC = stc.calc_Cinv_SC(SC_area) addCosts += SCInvC print stc.calc_Cinv_SC(SC_area), "SC area" PVT_peak = dicoSupply.SOLAR_PART_PVT * solarFeat.SolarAreaPVT * gv.nPVT #kW PVTInvC = pvt.calc_Cinv_PVT(PVT_peak) addCosts += PVTInvC print pvt.calc_Cinv_PVT(PVT_peak), "PVT peak" # Back-up boiler BoilerAddInvC = boiler.calc_Cinv_boiler(QUncoveredDesign, QUncoveredAnnual, gv) addCosts += BoilerAddInvC print boiler.calc_Cinv_boiler(QUncoveredDesign, QUncoveredAnnual, gv), "backup boiler" # Hex and HP for Heat recovery print "\n STORAGE PART COSTS" if dicoSupply.WasteServersHeatRecovery == 1: df = pd.read_csv(locator.pathNtwRes + "/" + dicoSupply.NETWORK_DATA_FILE, usecols=["Qcdata_netw_total"]) array = np.array(df) QhexMax = np.amax(array) StorageHEXCost += hex.calc_Cinv_HEX(QhexMax, gv) print hex.calc_Cinv_HEX(QhexMax, gv), "Hex for data center" df = pd.read_csv(locator.pathSlaveRes + "/" + dicoSupply.configKey + "StorageOperationData.csv", usecols=["HPServerHeatDesignArray"]) array = np.array(df) QhpMax = np.amax(array) StorageHEXCost += hp.calc_Cinv_HP(QhpMax, gv) print hp.calc_Cinv_HP(QhpMax, gv), "HP for data center" if dicoSupply.WasteCompressorHeatRecovery == 1: df = pd.read_csv(locator.pathNtwRes + "/" + dicoSupply.NETWORK_DATA_FILE, usecols=["Ecaf_netw_total"]) array = np.array(df) QhexMax = np.amax(array) StorageHEXCost += hex.calc_Cinv_HEX(QhexMax, gv) print hex.calc_Cinv_HEX(QhexMax, gv), "Hex for compressed air" df = pd.read_csv(locator.pathSlaveRes + "/" + dicoSupply.configKey + "StorageOperationData.csv", usecols=["HPCompAirDesignArray"]) array = np.array(df) QhpMax = np.amax(array) StorageHEXCost += hp.calc_Cinv_HP(QhpMax, gv) print hp.calc_Cinv_HP(QhpMax, gv), "HP for compressed air" addCosts += StorageHEXCost # Heat pump solar to storage df = pd.read_csv(locator.pathSlaveRes + "/" + dicoSupply.configKey + "StorageOperationData.csv", usecols=["HPScDesignArray", "HPpvt_designArray"]) array = np.array(df) QhpMax_PVT = np.amax(array[:, 1]) QhpMax_SC = np.amax(array[:, 0]) StorageHPCost += hp.calc_Cinv_HP(QhpMax_PVT, gv) print hp.calc_Cinv_HP(QhpMax_PVT, gv), "HP for PVT" StorageHPCost += hp.calc_Cinv_HP(QhpMax_SC, gv) print hp.calc_Cinv_HP(QhpMax_SC, gv), "HP for SC" # HP for storage operation df = pd.read_csv(locator.pathSlaveRes + "/" + dicoSupply.configKey + "StorageOperationData.csv", usecols=[ "E_aux_ch", "E_aux_dech", "Q_from_storage_used", "Q_to_storage" ]) array = np.array(df) QmaxHPStorage = 0 for i in range(gv.DAYS_IN_YEAR * gv.HOURS_IN_DAY): if array[i][0] > 0: QmaxHPStorage = max(QmaxHPStorage, array[i][3] + array[i][0]) elif array[i][1] > 0: QmaxHPStorage = max(QmaxHPStorage, array[i][2] + array[i][1]) StorageHPCost += hp.calc_Cinv_HP(QmaxHPStorage, gv) addCosts += StorageHPCost print hp.calc_Cinv_HP(QmaxHPStorage, gv), "HP for storage" # Storage df = pd.read_csv(locator.pathSlaveRes + "/" + dicoSupply.configKey + "StorageOperationData.csv", usecols=["Storage_Size"], nrows=1) StorageVol = np.array(df)[0][0] StorageInvC += storage.calc_Cinv_storage(StorageVol, gv) addCosts += StorageInvC print storage.calc_Cinv_storage(StorageVol, gv), "Storage Costs" # Costs from network configuration print "\n COSTS FROM NETWORK CONFIGURATION" if gv.ZernezFlag == 1: NetworkCost += network.calc_Cinv_network_linear( gv.NetworkLengthZernez, gv) * nBuildinNtw / len(buildList) else: NetworkCost += ntwFeat.pipesCosts_DHN * nBuildinNtw / len( buildList) addCosts += NetworkCost print ntwFeat.pipesCosts_DHN * nBuildinNtw / len( buildList), "Pipes Costs" # HEX (1 per building in ntw) for (index, buildName) in zip(indCombi, buildList): if index == "1": subsFileName = buildName + "_result.csv" df = pd.read_csv(locator.pathSubsRes + "/" + subsFileName, usecols=["Q_dhw", "Q_heating"]) subsArray = np.array(df) Qmax = np.amax(subsArray[:, 0] + subsArray[:, 1]) SubstHEXCost += hex.calc_Cinv_HEX(Qmax, gv) print hex.calc_Cinv_HEX(Qmax, gv), "Hex", buildName addCosts += SubstHEXCost # HEX for solar roof_area = np.array( pd.read_csv(locator.get_total_demand(), usecols=["Aroof_m2"])) areaAvail = 0 for i in range(len(indCombi)): index = indCombi[i] if index == "1": areaAvail += roof_area[i][0] for i in range(len(indCombi)): index = indCombi[i] if index == "1": share = roof_area[i][0] / areaAvail #print share, "solar area share", buildList[i] SC_Qmax = solarFeat.SC_Qnom * dicoSupply.SOLAR_PART_SC * share SCHEXCost += hex.calc_Cinv_HEX(SC_Qmax, gv) print hex.calc_Cinv_HEX(SC_Qmax, gv), "Hex SC", buildList[i] PVT_Qmax = solarFeat.PVT_Qnom * dicoSupply.SOLAR_PART_PVT * share PVTHEXCost += hex.calc_Cinv_HEX(PVT_Qmax, gv) print hex.calc_Cinv_HEX(PVT_Qmax, gv), "Hex PVT", buildList[i] addCosts += SCHEXCost addCosts += PVTHEXCost print addCosts, "addCosts in extraCostsMain" # Pump operation costs pumpCosts = pumps.calc_Ctot_pump(dicoSupply, buildList, locator.pathNtwRes, ntwFeat, gv) addCosts += pumpCosts print pumpCosts, "Pump Operation costs in extraCostsMain\n" # import gas consumption data from: if indCombi.count("1") > 0: # import gas consumption data from: FileName = locator.pathSlaveRes + "/" + dicoSupply.configKey + "PrimaryEnergyBySource.csv" colName = "EgasPrimaryPeakPower" EgasPrimaryDataframe = pd.read_csv(FileName, usecols=[colName]) #print EgasPrimaryDataframe #print np.array(EgasPrimaryDataframe) #print float(np.array(EgasPrimaryDataframe)) EgasPrimaryPeakPower = float(np.array(EgasPrimaryDataframe)) GasConnectionInvCost = ngas.calc_Cinv_gas(EgasPrimaryPeakPower, gv) else: GasConnectionInvCost = 0.0 addCosts += GasConnectionInvCost # Save data results = pd.DataFrame({ "SCInvC": [SCInvC], "PVTInvC": [PVTInvC], "BoilerAddInvC": [BoilerAddInvC], "StorageHEXCost": [StorageHEXCost], "StorageHPCost": [StorageHPCost], "StorageInvC": [StorageInvC], "StorageCostSum": [StorageInvC + StorageHPCost + StorageHEXCost], "NetworkCost": [NetworkCost], "SubstHEXCost": [SubstHEXCost], "DHNInvestCost": [addCosts - CostDiscBuild], "PVTHEXCost": [PVTHEXCost], "CostDiscBuild": [CostDiscBuild], "CO2DiscBuild": [CO2DiscBuild], "PrimDiscBuild": [PrimDiscBuild], "FurnaceInvCost": [FurnaceInvCost], "BoilerBInvCost": [BoilerBInvCost], "BoilerPInvCost": [BoilerPInvCost], "HPLakeInvC": [HPLakeInvC], "HPSewInvC": [HPSewInvC], "SCHEXCost": [SCHEXCost], "pumpCosts": [pumpCosts], "SumInvestCost": [addCosts], "GasConnectionInvCa": [GasConnectionInvCost] }) Name = "/" + dicoSupply.configKey + "_InvestmentCostDetailed.csv" results.to_csv(locator.pathSlaveRes + Name, sep=',') return (addCosts, addCO2, addPrim)
def addCosts(buildList, locator, master_to_slave_vars, Q_uncovered_design_W, Q_uncovered_annual_W, solar_features, network_features, gv, config, prices, lca): """ Computes additional costs / GHG emisions / primary energy needs for the individual addCosts = additional costs addCO2 = GHG emissions addPrm = primary energy needs :param DHN_barcode: parameter indicating if the building is connected or not :param buildList: list of buildings in the district :param locator: input locator set to scenario :param master_to_slave_vars: class containing the features of a specific individual :param Q_uncovered_design_W: hourly max of the heating uncovered demand :param Q_uncovered_annual_W: total heating uncovered :param solar_features: solar features :param network_features: network features :param gv: global variables :type indCombi: string :type buildList: list :type locator: string :type master_to_slave_vars: class :type Q_uncovered_design_W: float :type Q_uncovered_annual_W: float :type solar_features: class :type network_features: class :type gv: class :return: returns the objectives addCosts, addCO2, addPrim :rtype: tuple """ DHN_barcode = master_to_slave_vars.DHN_barcode DCN_barcode = master_to_slave_vars.DCN_barcode addcosts_Capex_a_USD = 0 addcosts_Opex_fixed_USD = 0 addcosts_Capex_USD = 0 addCO2 = 0 addPrim = 0 nBuildinNtw = 0 # Add the features from the disconnected buildings CostDiscBuild = 0 CO2DiscBuild = 0 PrimDiscBuild = 0 Capex_Disconnected = 0 Opex_Disconnected = 0 Capex_a_furnace_USD = 0 Capex_a_CHP_USD = 0 Capex_a_Boiler_USD = 0 Capex_a_Boiler_peak_USD = 0 Capex_a_Lake_USD = 0 Capex_a_Sewage_USD = 0 Capex_a_GHP_USD = 0 Capex_a_PV_USD = 0 Capex_a_SC_ET_USD = 0 Capex_a_SC_FP_USD = 0 Capex_a_PVT_USD = 0 Capex_a_Boiler_backup_USD = 0 Capex_a_HEX = 0 Capex_a_storage_HP = 0 Capex_a_HP_storage_USD = 0 Opex_fixed_SC = 0 Opex_fixed_PVT_USD = 0 Opex_fixed_HP_PVT_USD = 0 Opex_fixed_furnace_USD = 0 Opex_fixed_CHP_USD = 0 Opex_fixed_Boiler_USD = 0 Opex_fixed_Boiler_peak_USD = 0 Opex_fixed_Boiler_backup_USD = 0 Opex_fixed_Lake_USD = 0 Opex_fixed_wasteserver_HEX_USD = 0 Opex_fixed_wasteserver_HP_USD = 0 Opex_fixed_PV_USD = 0 Opex_fixed_GHP_USD = 0 Opex_fixed_storage_USD = 0 Opex_fixed_Sewage_USD = 0 Opex_fixed_HP_storage_USD = 0 StorageInvC = 0 NetworkCost_a_USD = 0 SubstHEXCost_capex = 0 SubstHEXCost_opex = 0 PVTHEXCost_Capex = 0 PVTHEXCost_Opex = 0 SCHEXCost_Capex = 0 SCHEXCost_Opex = 0 pumpCosts = 0 GasConnectionInvCost = 0 cost_PV_disconnected = 0 CO2_PV_disconnected = 0 Eprim_PV_disconnected = 0 Capex_furnace_USD = 0 Capex_CHP_USD = 0 Capex_Boiler_USD = 0 Capex_Boiler_peak_USD = 0 Capex_Lake_USD = 0 Capex_Sewage_USD = 0 Capex_GHP = 0 Capex_PV_USD = 0 Capex_SC = 0 Capex_PVT_USD = 0 Capex_Boiler_backup_USD = 0 Capex_HEX = 0 Capex_storage_HP = 0 Capex_HP_storage = 0 Capex_SC_ET_USD = 0 Capex_SC_FP_USD = 0 Capex_PVT_USD = 0 Capex_Boiler_backup_USD = 0 Capex_HP_storage_USD = 0 Capex_storage_HP = 0 Capex_CHP_USD = 0 Capex_furnace_USD = 0 Capex_Boiler_USD = 0 Capex_Boiler_peak_USD = 0 Capex_Lake_USD = 0 Capex_Sewage_USD = 0 Capex_pump_USD = 0 if config.district_heating_network: for (index, building_name) in zip(DHN_barcode, buildList): if index == "0": df = pd.read_csv( locator. get_optimization_decentralized_folder_building_result_heating( building_name)) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest[ "Primary Energy Needs [MJoil-eq]"].iloc[0] # [MJ-oil-eq] Capex_Disconnected += dfBest[ "Annualized Investment Costs [CHF]"].iloc[0] Opex_Disconnected += dfBest["Operation Costs [CHF]"].iloc[0] else: nBuildinNtw += 1 if config.district_cooling_network: PV_barcode = '' for (index, building_name) in zip(DCN_barcode, buildList): if index == "0": # choose the best decentralized configuration df = pd.read_csv( locator. get_optimization_decentralized_folder_building_result_cooling( building_name, configuration='AHU_ARU_SCU')) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest[ "Primary Energy Needs [MJoil-eq]"].iloc[0] # [MJ-oil-eq] Capex_Disconnected += dfBest[ "Annualized Investment Costs [CHF]"].iloc[0] Opex_Disconnected += dfBest["Operation Costs [CHF]"].iloc[0] to_PV = 1 if dfBest["single effect ACH to AHU_ARU_SCU Share (FP)"].iloc[ 0] == 1: to_PV = 0 if dfBest["single effect ACH to AHU_ARU_SCU Share (ET)"].iloc[ 0] == 1: to_PV = 0 if dfBest["single effect ACH to SCU Share (FP)"].iloc[0] == 1: to_PV = 0 else: # adding costs for buildings in which the centralized plant provides a part of the load requirements DCN_unit_configuration = master_to_slave_vars.DCN_supplyunits if DCN_unit_configuration == 1: # corresponds to AHU in the central plant, so remaining load need to be provided by decentralized plant decentralized_configuration = 'ARU_SCU' df = pd.read_csv( locator. get_optimization_decentralized_folder_building_result_cooling( building_name, decentralized_configuration)) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[ 0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest[ "Primary Energy Needs [MJoil-eq]"].iloc[ 0] # [MJ-oil-eq] Capex_Disconnected += dfBest[ "Annualized Investment Costs [CHF]"].iloc[0] Opex_Disconnected += dfBest["Operation Costs [CHF]"].iloc[ 0] to_PV = 1 if dfBest["single effect ACH to ARU_SCU Share (FP)"].iloc[ 0] == 1: to_PV = 0 if dfBest["single effect ACH to ARU_SCU Share (ET)"].iloc[ 0] == 1: to_PV = 0 if DCN_unit_configuration == 2: # corresponds to ARU in the central plant, so remaining load need to be provided by decentralized plant decentralized_configuration = 'AHU_SCU' df = pd.read_csv( locator. get_optimization_decentralized_folder_building_result_cooling( building_name, decentralized_configuration)) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[ 0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest[ "Primary Energy Needs [MJoil-eq]"].iloc[ 0] # [MJ-oil-eq] Capex_Disconnected += dfBest[ "Annualized Investment Costs [CHF]"].iloc[0] Opex_Disconnected += dfBest["Operation Costs [CHF]"].iloc[ 0] to_PV = 1 if dfBest["single effect ACH to AHU_SCU Share (FP)"].iloc[ 0] == 1: to_PV = 0 if dfBest["single effect ACH to AHU_SCU Share (ET)"].iloc[ 0] == 1: to_PV = 0 if DCN_unit_configuration == 3: # corresponds to SCU in the central plant, so remaining load need to be provided by decentralized plant decentralized_configuration = 'AHU_ARU' df = pd.read_csv( locator. get_optimization_decentralized_folder_building_result_cooling( building_name, decentralized_configuration)) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[ 0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest[ "Primary Energy Needs [MJoil-eq]"].iloc[ 0] # [MJ-oil-eq] Capex_Disconnected += dfBest[ "Annualized Investment Costs [CHF]"].iloc[0] Opex_Disconnected += dfBest["Operation Costs [CHF]"].iloc[ 0] to_PV = 1 if dfBest["single effect ACH to AHU_ARU Share (FP)"].iloc[ 0] == 1: to_PV = 0 if dfBest["single effect ACH to AHU_ARU Share (ET)"].iloc[ 0] == 1: to_PV = 0 if DCN_unit_configuration == 4: # corresponds to AHU + ARU in the central plant, so remaining load need to be provided by decentralized plant decentralized_configuration = 'SCU' df = pd.read_csv( locator. get_optimization_decentralized_folder_building_result_cooling( building_name, decentralized_configuration)) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[ 0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest[ "Primary Energy Needs [MJoil-eq]"].iloc[ 0] # [MJ-oil-eq] Capex_Disconnected += dfBest[ "Annualized Investment Costs [CHF]"].iloc[0] Opex_Disconnected += dfBest["Operation Costs [CHF]"].iloc[ 0] to_PV = 1 if dfBest["single effect ACH to SCU Share (FP)"].iloc[ 0] == 1: to_PV = 0 if dfBest["single effect ACH to SCU Share (ET)"].iloc[ 0] == 1: to_PV = 0 if DCN_unit_configuration == 5: # corresponds to AHU + SCU in the central plant, so remaining load need to be provided by decentralized plant decentralized_configuration = 'ARU' df = pd.read_csv( locator. get_optimization_decentralized_folder_building_result_cooling( building_name, decentralized_configuration)) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[ 0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest[ "Primary Energy Needs [MJoil-eq]"].iloc[ 0] # [MJ-oil-eq] Capex_Disconnected += dfBest[ "Annualized Investment Costs [CHF]"].iloc[0] Opex_Disconnected += dfBest["Operation Costs [CHF]"].iloc[ 0] to_PV = 1 if dfBest["single effect ACH to ARU Share (FP)"].iloc[ 0] == 1: to_PV = 0 if dfBest["single effect ACH to ARU Share (ET)"].iloc[ 0] == 1: to_PV = 0 if DCN_unit_configuration == 6: # corresponds to ARU + SCU in the central plant, so remaining load need to be provided by decentralized plant decentralized_configuration = 'AHU' df = pd.read_csv( locator. get_optimization_decentralized_folder_building_result_cooling( building_name, decentralized_configuration)) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[ 0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest[ "Primary Energy Needs [MJoil-eq]"].iloc[ 0] # [MJ-oil-eq] Capex_Disconnected += dfBest[ "Annualized Investment Costs [CHF]"].iloc[0] Opex_Disconnected += dfBest["Operation Costs [CHF]"].iloc[ 0] to_PV = 1 if dfBest["single effect ACH to AHU Share (FP)"].iloc[ 0] == 1: to_PV = 0 if dfBest["single effect ACH to AHU Share (ET)"].iloc[ 0] == 1: to_PV = 0 if DCN_unit_configuration == 7: # corresponds to AHU + ARU + SCU from central plant to_PV = 1 nBuildinNtw += 1 PV_barcode = PV_barcode + str(to_PV) addcosts_Capex_a_USD += CostDiscBuild addCO2 += CO2DiscBuild addPrim += PrimDiscBuild # Solar technologies PV_installed_area_m2 = master_to_slave_vars.SOLAR_PART_PV * solar_features.A_PV_m2 # kW Capex_a_PV_USD, Opex_fixed_PV_USD, Capex_PV_USD = pv.calc_Cinv_pv( PV_installed_area_m2, locator, config) addcosts_Capex_a_USD += Capex_a_PV_USD addcosts_Opex_fixed_USD += Opex_fixed_PV_USD addcosts_Capex_USD += Capex_PV_USD SC_ET_area_m2 = master_to_slave_vars.SOLAR_PART_SC_ET * solar_features.A_SC_ET_m2 Capex_a_SC_ET_USD, Opex_fixed_SC_ET_USD, Capex_SC_ET_USD = stc.calc_Cinv_SC( SC_ET_area_m2, locator, config, 'ET') addcosts_Capex_a_USD += Capex_a_SC_ET_USD addcosts_Opex_fixed_USD += Opex_fixed_SC_ET_USD addcosts_Capex_USD += Capex_SC_ET_USD SC_FP_area_m2 = master_to_slave_vars.SOLAR_PART_SC_FP * solar_features.A_SC_FP_m2 Capex_a_SC_FP_USD, Opex_fixed_SC_FP_USD, Capex_SC_FP_USD = stc.calc_Cinv_SC( SC_FP_area_m2, locator, config, 'FP') addcosts_Capex_a_USD += Capex_a_SC_FP_USD addcosts_Opex_fixed_USD += Opex_fixed_SC_FP_USD addcosts_Capex_USD += Capex_SC_FP_USD PVT_peak_kW = master_to_slave_vars.SOLAR_PART_PVT * solar_features.A_PVT_m2 * N_PVT # kW Capex_a_PVT_USD, Opex_fixed_PVT_USD, Capex_PVT_USD = pvt.calc_Cinv_PVT( PVT_peak_kW, locator, config) addcosts_Capex_a_USD += Capex_a_PVT_USD addcosts_Opex_fixed_USD += Opex_fixed_PVT_USD addcosts_Capex_USD += Capex_PVT_USD # Add the features for the distribution if DHN_barcode.count("1") > 0 and config.district_heating_network: os.chdir( locator.get_optimization_slave_results_folder( master_to_slave_vars.generation_number)) # Add the investment costs of the energy systems # Furnace if master_to_slave_vars.Furnace_on == 1: P_design_W = master_to_slave_vars.Furnace_Q_max_W fNameSlavePP = locator.get_optimization_slave_heating_activation_pattern_heating( master_to_slave_vars.configKey, master_to_slave_vars.individual_number, master_to_slave_vars.generation_number) dfFurnace = pd.read_csv(fNameSlavePP, usecols=["Q_Furnace_W"]) arrayFurnace_W = np.array(dfFurnace) Q_annual_W = 0 for i in range(int(np.shape(arrayFurnace_W)[0])): Q_annual_W += arrayFurnace_W[i][0] Capex_a_furnace_USD, Opex_fixed_furnace_USD, Capex_furnace_USD = furnace.calc_Cinv_furnace( P_design_W, Q_annual_W, config, locator, 'FU1') addcosts_Capex_a_USD += Capex_a_furnace_USD addcosts_Opex_fixed_USD += Opex_fixed_furnace_USD addcosts_Capex_USD += Capex_furnace_USD # CC if master_to_slave_vars.CC_on == 1: CC_size_W = master_to_slave_vars.CC_GT_SIZE_W Capex_a_CHP_USD, Opex_fixed_CHP_USD, Capex_CHP_USD = chp.calc_Cinv_CCGT( CC_size_W, locator, config) addcosts_Capex_a_USD += Capex_a_CHP_USD addcosts_Opex_fixed_USD += Opex_fixed_CHP_USD addcosts_Capex_USD += Capex_CHP_USD # Boiler Base if master_to_slave_vars.Boiler_on == 1: Q_design_W = master_to_slave_vars.Boiler_Q_max_W fNameSlavePP = locator.get_optimization_slave_heating_activation_pattern( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number) dfBoilerBase = pd.read_csv(fNameSlavePP, usecols=["Q_BaseBoiler_W"]) arrayBoilerBase_W = np.array(dfBoilerBase) Q_annual_W = 0 for i in range(int(np.shape(arrayBoilerBase_W)[0])): Q_annual_W += arrayBoilerBase_W[i][0] Capex_a_Boiler_USD, Opex_fixed_Boiler_USD, Capex_Boiler_USD = boiler.calc_Cinv_boiler( Q_design_W, locator, config, 'BO1') addcosts_Capex_a_USD += Capex_a_Boiler_USD addcosts_Opex_fixed_USD += Opex_fixed_Boiler_USD addcosts_Capex_USD += Capex_Boiler_USD # Boiler Peak if master_to_slave_vars.BoilerPeak_on == 1: Q_design_W = master_to_slave_vars.BoilerPeak_Q_max_W fNameSlavePP = locator.get_optimization_slave_heating_activation_pattern( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number) dfBoilerPeak = pd.read_csv(fNameSlavePP, usecols=["Q_PeakBoiler_W"]) arrayBoilerPeak_W = np.array(dfBoilerPeak) Q_annual_W = 0 for i in range(int(np.shape(arrayBoilerPeak_W)[0])): Q_annual_W += arrayBoilerPeak_W[i][0] Capex_a_Boiler_peak_USD, Opex_fixed_Boiler_peak_USD, Capex_Boiler_peak_USD = boiler.calc_Cinv_boiler( Q_design_W, locator, config, 'BO1') addcosts_Capex_a_USD += Capex_a_Boiler_peak_USD addcosts_Opex_fixed_USD += Opex_fixed_Boiler_peak_USD addcosts_Capex_USD += Capex_Boiler_peak_USD # HP Lake if master_to_slave_vars.HP_Lake_on == 1: HP_Size_W = master_to_slave_vars.HPLake_maxSize_W Capex_a_Lake_USD, Opex_fixed_Lake_USD, Capex_Lake_USD = hp.calc_Cinv_HP( HP_Size_W, locator, config, 'HP2') addcosts_Capex_a_USD += Capex_a_Lake_USD addcosts_Opex_fixed_USD += Opex_fixed_Lake_USD addcosts_Capex_USD += Capex_Lake_USD # HP Sewage if master_to_slave_vars.HP_Sew_on == 1: HP_Size_W = master_to_slave_vars.HPSew_maxSize_W Capex_a_Sewage_USD, Opex_fixed_Sewage_USD, Capex_Sewage_USD = hp.calc_Cinv_HP( HP_Size_W, locator, config, 'HP2') addcosts_Capex_a_USD += Capex_a_Sewage_USD addcosts_Opex_fixed_USD += Opex_fixed_Sewage_USD addcosts_Capex_USD += Capex_Sewage_USD # GHP if master_to_slave_vars.GHP_on == 1: fNameSlavePP = locator.get_optimization_slave_electricity_activation_pattern_heating( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number) dfGHP = pd.read_csv(fNameSlavePP, usecols=["E_used_GHP_W"]) arrayGHP_W = np.array(dfGHP) GHP_Enom_W = np.amax(arrayGHP_W) Capex_a_GHP_USD, Opex_fixed_GHP_USD, Capex_GHP_USD = hp.calc_Cinv_GHP( GHP_Enom_W, locator, config) addcosts_Capex_a_USD += Capex_a_GHP_USD * prices.EURO_TO_CHF addcosts_Opex_fixed_USD += Opex_fixed_GHP_USD * prices.EURO_TO_CHF addcosts_Capex_USD += Capex_GHP_USD # Back-up boiler Capex_a_Boiler_backup_USD, Opex_fixed_Boiler_backup_USD, Capex_Boiler_backup_USD = boiler.calc_Cinv_boiler( Q_uncovered_design_W, locator, config, 'BO1') addcosts_Capex_a_USD += Capex_a_Boiler_backup_USD addcosts_Opex_fixed_USD += Opex_fixed_Boiler_backup_USD addcosts_Capex_USD += Capex_Boiler_backup_USD master_to_slave_vars.BoilerBackup_Q_max_W = Q_uncovered_design_W # Hex and HP for Heat recovery if master_to_slave_vars.WasteServersHeatRecovery == 1: df = pd.read_csv(os.path.join( locator.get_optimization_network_results_folder(), master_to_slave_vars.network_data_file_heating), usecols=["Qcdata_netw_total_kWh"]) array = np.array(df) Q_HEX_max_kWh = np.amax(array) Capex_a_wasteserver_HEX_USD, Opex_fixed_wasteserver_HEX_USD, Capex_wasteserver_HEX_USD = hex.calc_Cinv_HEX( Q_HEX_max_kWh, locator, config, 'HEX1') addcosts_Capex_a_USD += (Capex_a_wasteserver_HEX_USD) addcosts_Opex_fixed_USD += Opex_fixed_wasteserver_HEX_USD addcosts_Capex_USD += Capex_wasteserver_HEX_USD df = pd.read_csv( locator.get_optimization_slave_storage_operation_data( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number), usecols=["HPServerHeatDesignArray_kWh"]) array = np.array(df) Q_HP_max_kWh = np.amax(array) Capex_a_wasteserver_HP_USD, Opex_fixed_wasteserver_HP_USD, Capex_wasteserver_HP_USD = hp.calc_Cinv_HP( Q_HP_max_kWh, locator, config, 'HP2') addcosts_Capex_a_USD += (Capex_a_wasteserver_HP_USD) addcosts_Opex_fixed_USD += Opex_fixed_wasteserver_HP_USD addcosts_Capex_USD += Capex_wasteserver_HP_USD # Heat pump from solar to DH df = pd.read_csv( locator.get_optimization_slave_storage_operation_data( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number), usecols=["HPScDesignArray_Wh", "HPpvt_designArray_Wh"]) array = np.array(df) Q_HP_max_PVT_wh = np.amax(array[:, 1]) Q_HP_max_SC_Wh = np.amax(array[:, 0]) Capex_a_HP_PVT_USD, Opex_fixed_HP_PVT_USD, Capex_HP_PVT_USD = hp.calc_Cinv_HP( Q_HP_max_PVT_wh, locator, config, 'HP2') Capex_a_storage_HP += (Capex_a_HP_PVT_USD) addcosts_Opex_fixed_USD += Opex_fixed_HP_PVT_USD addcosts_Capex_USD += Capex_HP_PVT_USD Capex_a_HP_SC_USD, Opex_fixed_HP_SC_USD, Capex_HP_SC_USD = hp.calc_Cinv_HP( Q_HP_max_SC_Wh, locator, config, 'HP2') Capex_a_storage_HP += (Capex_a_HP_SC_USD) addcosts_Opex_fixed_USD += Opex_fixed_HP_SC_USD addcosts_Capex_USD += Capex_HP_SC_USD # HP for storage operation for charging from solar and discharging to DH df = pd.read_csv(locator.get_optimization_slave_storage_operation_data( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number), usecols=[ "E_aux_ch_W", "E_aux_dech_W", "Q_from_storage_used_W", "Q_to_storage_W" ]) array = np.array(df) Q_HP_max_storage_W = 0 for i in range(DAYS_IN_YEAR * HOURS_IN_DAY): if array[i][0] > 0: Q_HP_max_storage_W = max(Q_HP_max_storage_W, array[i][3] + array[i][0]) elif array[i][1] > 0: Q_HP_max_storage_W = max(Q_HP_max_storage_W, array[i][2] + array[i][1]) Capex_a_HP_storage_USD, Opex_fixed_HP_storage_USD, Capex_HP_storage_USD = hp.calc_Cinv_HP( Q_HP_max_storage_W, locator, config, 'HP2') addcosts_Capex_a_USD += (Capex_a_HP_storage_USD) addcosts_Opex_fixed_USD += Opex_fixed_HP_storage_USD addcosts_Capex_USD += Capex_HP_storage_USD # Storage df = pd.read_csv(locator.get_optimization_slave_storage_operation_data( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number), usecols=["Storage_Size_m3"], nrows=1) StorageVol_m3 = np.array(df)[0][0] Capex_a_storage_USD, Opex_fixed_storage_USD, Capex_storage_USD = storage.calc_Cinv_storage( StorageVol_m3, locator, config, 'TES2') addcosts_Capex_a_USD += Capex_a_storage_USD addcosts_Opex_fixed_USD += Opex_fixed_storage_USD addcosts_Capex_USD += Capex_storage_USD # Costs from distribution configuration if gv.ZernezFlag == 1: NetworkCost_a_USD, NetworkCost_USD = network.calc_Cinv_network_linear( gv.NetworkLengthZernez, gv) NetworkCost_a_USD = NetworkCost_a_USD * nBuildinNtw / len( buildList) NetworkCost_USD = NetworkCost_USD * nBuildinNtw / len(buildList) else: NetworkCost_USD = network_features.pipesCosts_DHN_USD NetworkCost_USD = NetworkCost_USD * nBuildinNtw / len(buildList) NetworkCost_a_USD = NetworkCost_USD * gv.PipeInterestRate * ( 1 + gv.PipeInterestRate)**gv.PipeLifeTime / ( (1 + gv.PipeInterestRate)**gv.PipeLifeTime - 1) addcosts_Capex_a_USD += NetworkCost_a_USD addcosts_Capex_USD += NetworkCost_USD # HEX (1 per building in ntw) for (index, building_name) in zip(DHN_barcode, buildList): if index == "1": df = pd.read_csv( locator.get_optimization_substations_results_file( building_name), usecols=["Q_dhw_W", "Q_heating_W"]) subsArray = np.array(df) Q_max_W = np.amax(subsArray[:, 0] + subsArray[:, 1]) Capex_a_HEX_building_USD, Opex_fixed_HEX_building_USD, Capex_HEX_building_USD = hex.calc_Cinv_HEX( Q_max_W, locator, config, 'HEX1') addcosts_Capex_a_USD += Capex_a_HEX_building_USD addcosts_Opex_fixed_USD += Opex_fixed_HEX_building_USD addcosts_Capex_USD += Capex_HEX_building_USD # HEX for solar roof_area_m2 = np.array( pd.read_csv(locator.get_total_demand(), usecols=["Aroof_m2"])) areaAvail = 0 for i in range(len(DHN_barcode)): index = DHN_barcode[i] if index == "1": areaAvail += roof_area_m2[i][0] for i in range(len(DHN_barcode)): index = DHN_barcode[i] if index == "1": share = roof_area_m2[i][0] / areaAvail #print share, "solar area share", buildList[i] Q_max_SC_ET_Wh = solar_features.Q_nom_SC_ET_Wh * master_to_slave_vars.SOLAR_PART_SC_ET * share Capex_a_HEX_SC_ET_USD, Opex_fixed_HEX_SC_ET_USD, Capex_HEX_SC_ET_USD = hex.calc_Cinv_HEX( Q_max_SC_ET_Wh, locator, config, 'HEX1') addcosts_Capex_a_USD += Capex_a_HEX_SC_ET_USD addcosts_Opex_fixed_USD += Opex_fixed_HEX_SC_ET_USD addcosts_Capex_USD += Capex_HEX_SC_ET_USD Q_max_SC_FP_Wh = solar_features.Q_nom_SC_FP_Wh * master_to_slave_vars.SOLAR_PART_SC_FP * share Capex_a_HEX_SC_FP_USD, Opex_fixed_HEX_SC_FP_USD, Capex_HEX_SC_FP_USD = hex.calc_Cinv_HEX( Q_max_SC_FP_Wh, locator, config, 'HEX1') addcosts_Capex_a_USD += Capex_a_HEX_SC_FP_USD addcosts_Opex_fixed_USD += Opex_fixed_HEX_SC_FP_USD addcosts_Capex_USD += Capex_HEX_SC_FP_USD Q_max_PVT_Wh = solar_features.Q_nom_PVT_Wh * master_to_slave_vars.SOLAR_PART_PVT * share Capex_a_HEX_PVT_USD, Opex_fixed_HEX_PVT_USD, Capex_HEX_PVT_USD = hex.calc_Cinv_HEX( Q_max_PVT_Wh, locator, config, 'HEX1') addcosts_Capex_a_USD += Capex_a_HEX_PVT_USD addcosts_Opex_fixed_USD += Opex_fixed_HEX_PVT_USD addcosts_Capex_USD += Capex_HEX_PVT_USD # Pump operation costs Capex_a_pump_USD, Opex_fixed_pump_USD, Opex_var_pump_USD, Capex_pump_USD = pumps.calc_Ctot_pump( master_to_slave_vars, network_features, gv, locator, lca, config) addcosts_Capex_a_USD += Capex_a_pump_USD addcosts_Opex_fixed_USD += Opex_fixed_pump_USD addcosts_Capex_USD += Capex_pump_USD # import gas consumption data from: if DHN_barcode.count("1") > 0 and config.district_heating_network: # import gas consumption data from: EgasPrimaryDataframe_W = pd.read_csv( locator.get_optimization_slave_natural_gas_imports( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number)) E_gas_primary_peak_power_W = np.amax( EgasPrimaryDataframe_W['NG_total_W']) GasConnectionInvCost = ngas.calc_Cinv_gas(E_gas_primary_peak_power_W, gv) elif DCN_barcode.count("1") > 0 and config.district_cooling_network: EgasPrimaryDataframe_W = pd.read_csv( locator.get_optimization_slave_natural_gas_imports( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number)) E_gas_primary_peak_power_W = np.amax( EgasPrimaryDataframe_W['NG_total_W']) GasConnectionInvCost = ngas.calc_Cinv_gas(E_gas_primary_peak_power_W, gv) else: GasConnectionInvCost = 0.0 addcosts_Capex_a_USD += GasConnectionInvCost # Save data results = pd.DataFrame({ "Capex_a_SC_ET_USD": [Capex_a_SC_ET_USD], "Capex_a_SC_FP_USD": [Capex_a_SC_FP_USD], "Opex_fixed_SC": [Opex_fixed_SC], "Capex_a_PVT": [Capex_a_PVT_USD], "Opex_fixed_PVT": [Opex_fixed_PVT_USD], "Capex_a_Boiler_backup": [Capex_a_Boiler_backup_USD], "Opex_fixed_Boiler_backup": [Opex_fixed_Boiler_backup_USD], "Capex_a_storage_HEX": [Capex_a_HP_storage_USD], "Opex_fixed_storage_HEX": [Opex_fixed_HP_storage_USD], "Capex_a_storage_HP": [Capex_a_storage_HP], "Capex_a_CHP": [Capex_a_CHP_USD], "Opex_fixed_CHP": [Opex_fixed_CHP_USD], "StorageInvC": [StorageInvC], "StorageCostSum": [StorageInvC + Capex_a_storage_HP + Capex_a_HEX], "NetworkCost": [NetworkCost_a_USD], "SubstHEXCost": [SubstHEXCost_capex], "DHNInvestCost": [addcosts_Capex_a_USD - CostDiscBuild], "PVTHEXCost_Capex": [PVTHEXCost_Capex], "CostDiscBuild": [CostDiscBuild], "CO2DiscBuild": [CO2DiscBuild], "PrimDiscBuild": [PrimDiscBuild], "Capex_a_furnace": [Capex_a_furnace_USD], "Opex_fixed_furnace": [Opex_fixed_furnace_USD], "Capex_a_Boiler": [Capex_a_Boiler_USD], "Opex_fixed_Boiler": [Opex_fixed_Boiler_USD], "Capex_a_Boiler_peak": [Capex_a_Boiler_peak_USD], "Opex_fixed_Boiler_peak": [Opex_fixed_Boiler_peak_USD], "Capex_Disconnected": [Capex_Disconnected], "Opex_Disconnected": [Opex_Disconnected], "Capex_a_Lake": [Capex_a_Lake_USD], "Opex_fixed_Lake": [Opex_fixed_Lake_USD], "Capex_a_Sewage": [Capex_a_Sewage_USD], "Opex_fixed_Sewage": [Opex_fixed_Sewage_USD], "SCHEXCost_Capex": [SCHEXCost_Capex], "Capex_a_pump": [Capex_a_pump_USD], "Opex_fixed_pump": [Opex_fixed_pump_USD], "Opex_var_pump": [Opex_var_pump_USD], "Sum_CAPEX": [addcosts_Capex_a_USD], "Sum_OPEX_fixed": [addcosts_Opex_fixed_USD], "GasConnectionInvCa": [GasConnectionInvCost], "CO2_PV_disconnected": [CO2_PV_disconnected], "cost_PV_disconnected": [cost_PV_disconnected], "Eprim_PV_disconnected": [Eprim_PV_disconnected], "Capex_SC_ET_USD": [Capex_SC_ET_USD], "Capex_SC_FP_USD": [Capex_SC_FP_USD], "Capex_PVT": [Capex_PVT_USD], "Capex_Boiler_backup": [Capex_Boiler_backup_USD], "Capex_storage_HEX": [Capex_HP_storage_USD], "Capex_storage_HP": [Capex_storage_HP], "Capex_CHP": [Capex_CHP_USD], "Capex_furnace": [Capex_furnace_USD], "Capex_Boiler_base": [Capex_Boiler_USD], "Capex_Boiler_peak": [Capex_Boiler_peak_USD], "Capex_Lake": [Capex_Lake_USD], "Capex_Sewage": [Capex_Sewage_USD], "Capex_pump": [Capex_pump_USD], }) results.to_csv(locator.get_optimization_slave_investment_cost_detailed( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number), sep=',') return (addcosts_Capex_a_USD + addcosts_Opex_fixed_USD, addCO2, addPrim)
def calc_network_costs_cooling(locator, master_to_slave_vars, network_features, lca, network_type): # Intitialize class pipesCosts_USD = network_features.pipesCosts_DCN_USD num_buildings_connected = master_to_slave_vars.number_of_buildings_connected_cooling num_all_buildings = master_to_slave_vars.num_total_buildings ratio_connected = num_buildings_connected / num_all_buildings # Capital costs Inv_IR = 0.05 Inv_LT = 20 Inv_OM = 0.10 Capex_Network_USD = pipesCosts_USD * ratio_connected Capex_a_Network_USD = Capex_Network_USD * (Inv_IR) * ( 1 + Inv_IR)**Inv_LT / ((1 + Inv_IR)**Inv_LT - 1) Opex_fixed_Network_USD = Capex_Network_USD * Inv_OM # costs of pumps Capex_a_pump_USD, Opex_fixed_pump_USD, Opex_var_pump_USD, Capex_pump_USD, P_motor_tot_W = PumpModel.calc_Ctot_pump( master_to_slave_vars, network_features, locator, lca, network_type) # COOLING SUBSTATIONS DCN_barcode = master_to_slave_vars.DCN_barcode building_names = master_to_slave_vars.building_names_cooling Capex_Substations_USD, \ Capex_a_Substations_USD, \ Opex_fixed_Substations_USD, \ Opex_var_Substations_USD = calc_substations_costs_cooling(building_names, master_to_slave_vars, DCN_barcode, locator) # summarize Capex_Network_USD += Capex_pump_USD Capex_a_Network_USD += Capex_a_pump_USD Opex_fixed_Network_USD += Opex_fixed_pump_USD Opex_var_Network_USD = Opex_var_pump_USD performance = { 'Capex_a_DCN_connected_USD': Capex_a_Network_USD, "Capex_a_SubstationsCooling_connected_USD": Capex_a_Substations_USD, "Capex_total_DCN_connected_USD": Capex_Network_USD, "Capex_total_SubstationsCooling_connected_USD": Capex_Substations_USD, "Opex_fixed_DCN_connected_USD": Opex_fixed_Network_USD, "Opex_fixed_SubstationsCooling_connected_USD": Opex_fixed_Substations_USD, } return performance, P_motor_tot_W
def addCosts(DHN_barcode, DCN_barcode, buildList, locator, master_to_slave_vars, Q_uncovered_design_W, Q_uncovered_annual_W, solarFeat, ntwFeat, gv, config, prices, lca): """ Computes additional costs / GHG emisions / primary energy needs for the individual addCosts = additional costs addCO2 = GHG emissions addPrm = primary energy needs :param DHN_barcode: parameter indicating if the building is connected or not :param buildList: list of buildings in the district :param locator: input locator set to scenario :param master_to_slave_vars: class containing the features of a specific individual :param Q_uncovered_design_W: hourly max of the heating uncovered demand :param Q_uncovered_annual_W: total heating uncovered :param solarFeat: solar features :param ntwFeat: network features :param gv: global variables :type indCombi: string :type buildList: list :type locator: string :type master_to_slave_vars: class :type Q_uncovered_design_W: float :type Q_uncovered_annual_W: float :type solarFeat: class :type ntwFeat: class :type gv: class :return: returns the objectives addCosts, addCO2, addPrim :rtype: tuple """ addcosts_Capex_a = 0 addcosts_Opex_fixed = 0 addCO2 = 0 addPrim = 0 nBuildinNtw = 0 # Add the features from the disconnected buildings CostDiscBuild = 0 CO2DiscBuild = 0 PrimDiscBuild = 0 Capex_Disconnected = 0 Opex_Disconnected = 0 Capex_a_furnace = 0 Capex_a_CHP = 0 Capex_a_Boiler = 0 Capex_a_Boiler_peak = 0 Capex_a_Lake = 0 Capex_a_Sewage = 0 Capex_a_GHP = 0 Capex_a_PV = 0 Capex_a_SC = 0 Capex_a_PVT = 0 Capex_a_Boiler_backup = 0 Capex_a_HEX = 0 Capex_a_storage_HP = 0 Capex_a_HP_storage = 0 Opex_fixed_SC = 0 Opex_fixed_PVT = 0 Opex_fixed_HP_PVT = 0 Opex_fixed_furnace = 0 Opex_fixed_CHP = 0 Opex_fixed_Boiler = 0 Opex_fixed_Boiler_peak = 0 Opex_fixed_Boiler_backup = 0 Opex_fixed_Lake = 0 Opex_fixed_wasteserver_HEX = 0 Opex_fixed_wasteserver_HP = 0 Opex_fixed_PV = 0 Opex_fixed_GHP = 0 Opex_fixed_storage = 0 Opex_fixed_Sewage = 0 Opex_fixed_HP_storage = 0 StorageInvC = 0 NetworkCost = 0 SubstHEXCost_capex = 0 SubstHEXCost_opex = 0 PVTHEXCost_Capex = 0 PVTHEXCost_Opex = 0 SCHEXCost_Capex = 0 SCHEXCost_Opex = 0 pumpCosts = 0 GasConnectionInvCost = 0 cost_PV_disconnected = 0 CO2_PV_disconnected = 0 Eprim_PV_disconnected = 0 if config.optimization.isheating: for (index, building_name) in zip(DHN_barcode, buildList): if index == "0": df = pd.read_csv( locator. get_optimization_disconnected_folder_building_result_heating( building_name)) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest[ "Primary Energy Needs [MJoil-eq]"].iloc[0] # [MJ-oil-eq] Capex_Disconnected += dfBest[ "Annualized Investment Costs [CHF]"].iloc[0] Opex_Disconnected += dfBest["Operation Costs [CHF]"].iloc[0] else: nBuildinNtw += 1 if config.optimization.iscooling: PV_barcode = '' for (index, building_name) in zip(DCN_barcode, buildList): if index == "0": # choose the best decentralized configuration df = pd.read_csv( locator. get_optimization_disconnected_folder_building_result_cooling( building_name, configuration='AHU_ARU_SCU')) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest[ "Primary Energy Needs [MJoil-eq]"].iloc[0] # [MJ-oil-eq] Capex_Disconnected += dfBest[ "Annualized Investment Costs [CHF]"].iloc[0] Opex_Disconnected += dfBest["Operation Costs [CHF]"].iloc[0] to_PV = 1 if dfBest["single effect ACH to AHU_ARU_SCU Share (FP)"].iloc[ 0] == 1: to_PV = 0 if dfBest["single effect ACH to AHU_ARU_SCU Share (ET)"].iloc[ 0] == 1: to_PV = 0 if dfBest["single effect ACH to SCU Share (FP)"].iloc[0] == 1: to_PV = 0 else: # adding costs for buildings in which the centralized plant provides a part of the load requirements DCN_unit_configuration = master_to_slave_vars.DCN_supplyunits if DCN_unit_configuration == 1: # corresponds to AHU in the central plant, so remaining load need to be provided by decentralized plant decentralized_configuration = 'ARU_SCU' df = pd.read_csv( locator. get_optimization_disconnected_folder_building_result_cooling( building_name, decentralized_configuration)) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[ 0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest[ "Primary Energy Needs [MJoil-eq]"].iloc[ 0] # [MJ-oil-eq] Capex_Disconnected += dfBest[ "Annualized Investment Costs [CHF]"].iloc[0] Opex_Disconnected += dfBest["Operation Costs [CHF]"].iloc[ 0] to_PV = 1 if dfBest["single effect ACH to ARU_SCU Share (FP)"].iloc[ 0] == 1: to_PV = 0 if dfBest["single effect ACH to ARU_SCU Share (ET)"].iloc[ 0] == 1: to_PV = 0 if DCN_unit_configuration == 2: # corresponds to ARU in the central plant, so remaining load need to be provided by decentralized plant decentralized_configuration = 'AHU_SCU' df = pd.read_csv( locator. get_optimization_disconnected_folder_building_result_cooling( building_name, decentralized_configuration)) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[ 0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest[ "Primary Energy Needs [MJoil-eq]"].iloc[ 0] # [MJ-oil-eq] Capex_Disconnected += dfBest[ "Annualized Investment Costs [CHF]"].iloc[0] Opex_Disconnected += dfBest["Operation Costs [CHF]"].iloc[ 0] to_PV = 1 if dfBest["single effect ACH to AHU_SCU Share (FP)"].iloc[ 0] == 1: to_PV = 0 if dfBest["single effect ACH to AHU_SCU Share (ET)"].iloc[ 0] == 1: to_PV = 0 if DCN_unit_configuration == 3: # corresponds to SCU in the central plant, so remaining load need to be provided by decentralized plant decentralized_configuration = 'AHU_ARU' df = pd.read_csv( locator. get_optimization_disconnected_folder_building_result_cooling( building_name, decentralized_configuration)) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[ 0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest[ "Primary Energy Needs [MJoil-eq]"].iloc[ 0] # [MJ-oil-eq] Capex_Disconnected += dfBest[ "Annualized Investment Costs [CHF]"].iloc[0] Opex_Disconnected += dfBest["Operation Costs [CHF]"].iloc[ 0] to_PV = 1 if dfBest["single effect ACH to AHU_ARU Share (FP)"].iloc[ 0] == 1: to_PV = 0 if dfBest["single effect ACH to AHU_ARU Share (ET)"].iloc[ 0] == 1: to_PV = 0 if DCN_unit_configuration == 4: # corresponds to AHU + ARU in the central plant, so remaining load need to be provided by decentralized plant decentralized_configuration = 'SCU' df = pd.read_csv( locator. get_optimization_disconnected_folder_building_result_cooling( building_name, decentralized_configuration)) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[ 0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest[ "Primary Energy Needs [MJoil-eq]"].iloc[ 0] # [MJ-oil-eq] Capex_Disconnected += dfBest[ "Annualized Investment Costs [CHF]"].iloc[0] Opex_Disconnected += dfBest["Operation Costs [CHF]"].iloc[ 0] to_PV = 1 if dfBest["single effect ACH to SCU Share (FP)"].iloc[ 0] == 1: to_PV = 0 if dfBest["single effect ACH to SCU Share (ET)"].iloc[ 0] == 1: to_PV = 0 if DCN_unit_configuration == 5: # corresponds to AHU + SCU in the central plant, so remaining load need to be provided by decentralized plant decentralized_configuration = 'ARU' df = pd.read_csv( locator. get_optimization_disconnected_folder_building_result_cooling( building_name, decentralized_configuration)) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[ 0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest[ "Primary Energy Needs [MJoil-eq]"].iloc[ 0] # [MJ-oil-eq] Capex_Disconnected += dfBest[ "Annualized Investment Costs [CHF]"].iloc[0] Opex_Disconnected += dfBest["Operation Costs [CHF]"].iloc[ 0] to_PV = 1 if dfBest["single effect ACH to ARU Share (FP)"].iloc[ 0] == 1: to_PV = 0 if dfBest["single effect ACH to ARU Share (ET)"].iloc[ 0] == 1: to_PV = 0 if DCN_unit_configuration == 6: # corresponds to ARU + SCU in the central plant, so remaining load need to be provided by decentralized plant decentralized_configuration = 'AHU' df = pd.read_csv( locator. get_optimization_disconnected_folder_building_result_cooling( building_name, decentralized_configuration)) dfBest = df[df["Best configuration"] == 1] CostDiscBuild += dfBest["Total Costs [CHF]"].iloc[ 0] # [CHF] CO2DiscBuild += dfBest["CO2 Emissions [kgCO2-eq]"].iloc[ 0] # [kg CO2] PrimDiscBuild += dfBest[ "Primary Energy Needs [MJoil-eq]"].iloc[ 0] # [MJ-oil-eq] Capex_Disconnected += dfBest[ "Annualized Investment Costs [CHF]"].iloc[0] Opex_Disconnected += dfBest["Operation Costs [CHF]"].iloc[ 0] to_PV = 1 if dfBest["single effect ACH to AHU Share (FP)"].iloc[ 0] == 1: to_PV = 0 if dfBest["single effect ACH to AHU Share (ET)"].iloc[ 0] == 1: to_PV = 0 if DCN_unit_configuration == 7: # corresponds to AHU + ARU + SCU from central plant to_PV = 1 nBuildinNtw += 1 PV_barcode = PV_barcode + str(to_PV) addcosts_Capex_a += CostDiscBuild addCO2 += CO2DiscBuild addPrim += PrimDiscBuild if not config.optimization.isheating: if PV_barcode.count("1") > 0: df1 = pd.DataFrame({'A': []}) for (i, index) in enumerate(PV_barcode): if index == str(1): if df1.empty: data = pd.read_csv(locator.PV_results(buildList[i])) df1 = data else: data = pd.read_csv(locator.PV_results(buildList[i])) df1 = df1 + data if not df1.empty: df1.to_csv(locator.PV_network(PV_barcode), index=True, float_format='%.2f') solar_data = pd.read_csv(locator.PV_network(PV_barcode), usecols=['E_PV_gen_kWh', 'Area_PV_m2'], nrows=8760) E_PV_sum_kW = np.sum(solar_data['E_PV_gen_kWh']) E_PV_W = solar_data['E_PV_gen_kWh'] * 1000 Area_AvailablePV_m2 = np.max(solar_data['Area_PV_m2']) Q_PowerPeakAvailablePV_kW = Area_AvailablePV_m2 * ETA_AREA_TO_PEAK KEV_RpPerkWhPV = calc_Crem_pv(Q_PowerPeakAvailablePV_kW * 1000.0) KEV_total = KEV_RpPerkWhPV / 100 * np.sum(E_PV_sum_kW) addcosts_Capex_a = addcosts_Capex_a - KEV_total addCO2 = addCO2 - (E_PV_sum_kW * 1000 * (lca.EL_PV_TO_CO2 - lca.EL_TO_CO2_GREEN) * WH_TO_J / 1.0E6) addPrim = addPrim - (E_PV_sum_kW * 1000 * (lca.EL_PV_TO_OIL_EQ - lca.EL_TO_OIL_EQ_GREEN) * WH_TO_J / 1.0E6) cost_PV_disconnected = KEV_total CO2_PV_disconnected = (E_PV_sum_kW * 1000 * (lca.EL_PV_TO_CO2 - lca.EL_TO_CO2_GREEN) * WH_TO_J / 1.0E6) Eprim_PV_disconnected = ( E_PV_sum_kW * 1000 * (lca.EL_PV_TO_OIL_EQ - lca.EL_TO_OIL_EQ_GREEN) * WH_TO_J / 1.0E6) network_data = pd.read_csv( locator.get_optimization_network_data_folder( master_to_slave_vars.network_data_file_cooling)) E_total_req_W = np.array(network_data['Electr_netw_total_W']) cooling_data = pd.read_csv( locator.get_optimization_slave_cooling_activation_pattern( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number)) E_from_CHP_W = np.array(cooling_data[ 'E_gen_CCGT_associated_with_absorption_chillers_W']) E_CHP_to_directload_W = np.zeros(8760) E_CHP_to_grid_W = np.zeros(8760) E_PV_to_directload_W = np.zeros(8760) E_PV_to_grid_W = np.zeros(8760) E_from_grid_W = np.zeros(8760) for hour in range(8760): E_hour_W = E_total_req_W[hour] if E_hour_W > 0: if E_PV_W[hour] > E_hour_W: E_PV_to_directload_W[hour] = E_hour_W E_PV_to_grid_W[ hour] = E_PV_W[hour] - E_total_req_W[hour] E_hour_W = 0 else: E_hour_W = E_hour_W - E_PV_W[hour] E_PV_to_directload_W[hour] = E_PV_W[hour] if E_from_CHP_W[hour] > E_hour_W: E_CHP_to_directload_W[hour] = E_hour_W E_CHP_to_grid_W[hour] = E_from_CHP_W[hour] - E_hour_W E_hour_W = 0 else: E_hour_W = E_hour_W - E_from_CHP_W[hour] E_CHP_to_directload_W[hour] = E_from_CHP_W[hour] E_from_grid_W[hour] = E_hour_W date = network_data.DATE.values results = pd.DataFrame({ "DATE": date, "E_total_req_W": E_total_req_W, "E_PV_W": solar_data['E_PV_gen_kWh'] * 1000, "Area_PV_m2": solar_data['Area_PV_m2'], "KEV": KEV_RpPerkWhPV / 100 * solar_data['E_PV_gen_kWh'], "E_from_grid_W": E_from_grid_W, "E_PV_to_directload_W": E_PV_to_directload_W, "E_CHP_to_directload_W": E_CHP_to_directload_W, "E_CHP_to_grid_W": E_CHP_to_grid_W, "E_PV_to_grid_W": E_PV_to_grid_W }) results.to_csv( locator. get_optimization_slave_electricity_activation_pattern_cooling( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number), index=False) # Add the features for the distribution if DHN_barcode.count("1") > 0 and config.optimization.isheating: os.chdir( locator.get_optimization_slave_results_folder( master_to_slave_vars.generation_number)) # Add the investment costs of the energy systems # Furnace if master_to_slave_vars.Furnace_on == 1: P_design_W = master_to_slave_vars.Furnace_Q_max fNameSlavePP = locator.get_optimization_slave_heating_activation_pattern_heating( master_to_slave_vars.configKey, master_to_slave_vars.individual_number, master_to_slave_vars.generation_number) dfFurnace = pd.read_csv(fNameSlavePP, usecols=["Q_Furnace_W"]) arrayFurnace_W = np.array(dfFurnace) Q_annual_W = 0 for i in range(int(np.shape(arrayFurnace_W)[0])): Q_annual_W += arrayFurnace_W[i][0] Capex_a_furnace, Opex_fixed_furnace = furnace.calc_Cinv_furnace( P_design_W, Q_annual_W, config, locator, 'FU1') addcosts_Capex_a += Capex_a_furnace addcosts_Opex_fixed += Opex_fixed_furnace # CC if master_to_slave_vars.CC_on == 1: CC_size_W = master_to_slave_vars.CC_GT_SIZE Capex_a_CHP, Opex_fixed_CHP = chp.calc_Cinv_CCGT( CC_size_W, locator, config) addcosts_Capex_a += Capex_a_CHP addcosts_Opex_fixed += Opex_fixed_CHP # Boiler Base if master_to_slave_vars.Boiler_on == 1: Q_design_W = master_to_slave_vars.Boiler_Q_max fNameSlavePP = locator.get_optimization_slave_heating_activation_pattern( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number) dfBoilerBase = pd.read_csv(fNameSlavePP, usecols=["Q_BaseBoiler_W"]) arrayBoilerBase_W = np.array(dfBoilerBase) Q_annual_W = 0 for i in range(int(np.shape(arrayBoilerBase_W)[0])): Q_annual_W += arrayBoilerBase_W[i][0] Capex_a_Boiler, Opex_fixed_Boiler = boiler.calc_Cinv_boiler( Q_design_W, locator, config, 'BO1') addcosts_Capex_a += Capex_a_Boiler addcosts_Opex_fixed += Opex_fixed_Boiler # Boiler Peak if master_to_slave_vars.BoilerPeak_on == 1: Q_design_W = master_to_slave_vars.BoilerPeak_Q_max fNameSlavePP = locator.get_optimization_slave_heating_activation_pattern( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number) dfBoilerPeak = pd.read_csv(fNameSlavePP, usecols=["Q_PeakBoiler_W"]) arrayBoilerPeak_W = np.array(dfBoilerPeak) Q_annual_W = 0 for i in range(int(np.shape(arrayBoilerPeak_W)[0])): Q_annual_W += arrayBoilerPeak_W[i][0] Capex_a_Boiler_peak, Opex_fixed_Boiler_peak = boiler.calc_Cinv_boiler( Q_design_W, locator, config, 'BO1') addcosts_Capex_a += Capex_a_Boiler_peak addcosts_Opex_fixed += Opex_fixed_Boiler_peak # HP Lake if master_to_slave_vars.HP_Lake_on == 1: HP_Size_W = master_to_slave_vars.HPLake_maxSize Capex_a_Lake, Opex_fixed_Lake = hp.calc_Cinv_HP( HP_Size_W, locator, config, 'HP2') addcosts_Capex_a += Capex_a_Lake addcosts_Opex_fixed += Opex_fixed_Lake # HP Sewage if master_to_slave_vars.HP_Sew_on == 1: HP_Size_W = master_to_slave_vars.HPSew_maxSize Capex_a_Sewage, Opex_fixed_Sewage = hp.calc_Cinv_HP( HP_Size_W, locator, config, 'HP2') addcosts_Capex_a += Capex_a_Sewage addcosts_Opex_fixed += Opex_fixed_Sewage # GHP if master_to_slave_vars.GHP_on == 1: fNameSlavePP = locator.get_optimization_slave_electricity_activation_pattern_heating( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number) dfGHP = pd.read_csv(fNameSlavePP, usecols=["E_GHP_req_W"]) arrayGHP_W = np.array(dfGHP) GHP_Enom_W = np.amax(arrayGHP_W) Capex_a_GHP, Opex_fixed_GHP = hp.calc_Cinv_GHP( GHP_Enom_W, locator, config) addcosts_Capex_a += Capex_a_GHP * prices.EURO_TO_CHF addcosts_Opex_fixed += Opex_fixed_GHP * prices.EURO_TO_CHF # Solar technologies PV_installed_area_m2 = master_to_slave_vars.SOLAR_PART_PV * solarFeat.A_PV_m2 #kW Capex_a_PV, Opex_fixed_PV = pv.calc_Cinv_pv(PV_installed_area_m2, locator, config) addcosts_Capex_a += Capex_a_PV addcosts_Opex_fixed += Opex_fixed_PV SC_ET_area_m2 = master_to_slave_vars.SOLAR_PART_SC_ET * solarFeat.A_SC_ET_m2 Capex_a_SC_ET, Opex_fixed_SC_ET = stc.calc_Cinv_SC( SC_ET_area_m2, locator, config, 'ET') addcosts_Capex_a += Capex_a_SC_ET addcosts_Opex_fixed += Opex_fixed_SC_ET SC_FP_area_m2 = master_to_slave_vars.SOLAR_PART_SC_FP * solarFeat.A_SC_FP_m2 Capex_a_SC_FP, Opex_fixed_SC_FP = stc.calc_Cinv_SC( SC_FP_area_m2, locator, config, 'FP') addcosts_Capex_a += Capex_a_SC_FP addcosts_Opex_fixed += Opex_fixed_SC_FP PVT_peak_kW = master_to_slave_vars.SOLAR_PART_PVT * solarFeat.A_PVT_m2 * N_PVT #kW Capex_a_PVT, Opex_fixed_PVT = pvt.calc_Cinv_PVT( PVT_peak_kW, locator, config) addcosts_Capex_a += Capex_a_PVT addcosts_Opex_fixed += Opex_fixed_PVT # Back-up boiler Capex_a_Boiler_backup, Opex_fixed_Boiler_backup = boiler.calc_Cinv_boiler( Q_uncovered_design_W, locator, config, 'BO1') addcosts_Capex_a += Capex_a_Boiler_backup addcosts_Opex_fixed += Opex_fixed_Boiler_backup # Hex and HP for Heat recovery if master_to_slave_vars.WasteServersHeatRecovery == 1: df = pd.read_csv(os.path.join( locator.get_optimization_network_results_folder(), master_to_slave_vars.network_data_file_heating), usecols=["Qcdata_netw_total_kWh"]) array = np.array(df) Q_HEX_max_kWh = np.amax(array) Capex_a_wasteserver_HEX, Opex_fixed_wasteserver_HEX = hex.calc_Cinv_HEX( Q_HEX_max_kWh, locator, config, 'HEX1') addcosts_Capex_a += (Capex_a_wasteserver_HEX) addcosts_Opex_fixed += Opex_fixed_wasteserver_HEX df = pd.read_csv( locator.get_optimization_slave_storage_operation_data( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number), usecols=["HPServerHeatDesignArray_kWh"]) array = np.array(df) Q_HP_max_kWh = np.amax(array) Capex_a_wasteserver_HP, Opex_fixed_wasteserver_HP = hp.calc_Cinv_HP( Q_HP_max_kWh, locator, config, 'HP2') addcosts_Capex_a += (Capex_a_wasteserver_HP) addcosts_Opex_fixed += Opex_fixed_wasteserver_HP # if master_to_slave_vars.WasteCompressorHeatRecovery == 1: # df = pd.read_csv( # os.path.join(locator.get_optimization_network_results_folder(), master_to_slave_vars.network_data_file_heating), # usecols=["Ecaf_netw_total_kWh"]) # array = np.array(df) # Q_HEX_max_kWh = np.amax(array) # # Capex_a_wastecompressor_HEX, Opex_fixed_wastecompressor_HEX = hex.calc_Cinv_HEX(Q_HEX_max_kWh, locator, # config, 'HEX1') # addcosts_Capex_a += (Capex_a_wastecompressor_HEX) # addcosts_Opex_fixed += Opex_fixed_wastecompressor_HEX # df = pd.read_csv( # locator.get_optimization_slave_storage_operation_data(master_to_slave_vars.individual_number, # master_to_slave_vars.generation_number), # usecols=["HPCompAirDesignArray_kWh"]) # array = np.array(df) # Q_HP_max_kWh = np.amax(array) # Capex_a_wastecompressor_HP, Opex_fixed_wastecompressor_HP = hp.calc_Cinv_HP(Q_HP_max_kWh, locator, config, 'HP2') # addcosts_Capex_a += (Capex_a_wastecompressor_HP) # addcosts_Opex_fixed += Opex_fixed_wastecompressor_HP # Heat pump from solar to DH df = pd.read_csv( locator.get_optimization_slave_storage_operation_data( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number), usecols=["HPScDesignArray_Wh", "HPpvt_designArray_Wh"]) array = np.array(df) Q_HP_max_PVT_wh = np.amax(array[:, 1]) Q_HP_max_SC_Wh = np.amax(array[:, 0]) Capex_a_HP_PVT, Opex_fixed_HP_PVT = hp.calc_Cinv_HP( Q_HP_max_PVT_wh, locator, config, 'HP2') Capex_a_storage_HP += (Capex_a_HP_PVT) addcosts_Opex_fixed += Opex_fixed_HP_PVT Capex_a_HP_SC, Opex_fixed_HP_SC = hp.calc_Cinv_HP( Q_HP_max_SC_Wh, locator, config, 'HP2') Capex_a_storage_HP += (Capex_a_HP_SC) addcosts_Opex_fixed += Opex_fixed_HP_SC # HP for storage operation for charging from solar and discharging to DH df = pd.read_csv(locator.get_optimization_slave_storage_operation_data( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number), usecols=[ "E_aux_ch_W", "E_aux_dech_W", "Q_from_storage_used_W", "Q_to_storage_W" ]) array = np.array(df) Q_HP_max_storage_W = 0 for i in range(DAYS_IN_YEAR * HOURS_IN_DAY): if array[i][0] > 0: Q_HP_max_storage_W = max(Q_HP_max_storage_W, array[i][3] + array[i][0]) elif array[i][1] > 0: Q_HP_max_storage_W = max(Q_HP_max_storage_W, array[i][2] + array[i][1]) Capex_a_HP_storage, Opex_fixed_HP_storage = hp.calc_Cinv_HP( Q_HP_max_storage_W, locator, config, 'HP2') addcosts_Capex_a += (Capex_a_HP_storage) addcosts_Opex_fixed += Opex_fixed_HP_storage # Storage df = pd.read_csv(locator.get_optimization_slave_storage_operation_data( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number), usecols=["Storage_Size_m3"], nrows=1) StorageVol_m3 = np.array(df)[0][0] Capex_a_storage, Opex_fixed_storage = storage.calc_Cinv_storage( StorageVol_m3, locator, config, 'TES2') addcosts_Capex_a += Capex_a_storage addcosts_Opex_fixed += Opex_fixed_storage # Costs from distribution configuration if gv.ZernezFlag == 1: NetworkCost += network.calc_Cinv_network_linear( gv.NetworkLengthZernez, gv) * nBuildinNtw / len(buildList) else: NetworkCost += ntwFeat.pipesCosts_DHN * nBuildinNtw / len( buildList) addcosts_Capex_a += NetworkCost # HEX (1 per building in ntw) for (index, building_name) in zip(DHN_barcode, buildList): if index == "1": df = pd.read_csv( locator.get_optimization_substations_results_file( building_name), usecols=["Q_dhw_W", "Q_heating_W"]) subsArray = np.array(df) Q_max_W = np.amax(subsArray[:, 0] + subsArray[:, 1]) Capex_a_HEX_building, Opex_fixed_HEX_building = hex.calc_Cinv_HEX( Q_max_W, locator, config, 'HEX1') addcosts_Capex_a += Capex_a_HEX_building addcosts_Opex_fixed += Opex_fixed_HEX_building # HEX for solar roof_area_m2 = np.array( pd.read_csv(locator.get_total_demand(), usecols=["Aroof_m2"])) areaAvail = 0 for i in range(len(DHN_barcode)): index = DHN_barcode[i] if index == "1": areaAvail += roof_area_m2[i][0] for i in range(len(DHN_barcode)): index = DHN_barcode[i] if index == "1": share = roof_area_m2[i][0] / areaAvail #print share, "solar area share", buildList[i] Q_max_SC_ET_Wh = solarFeat.Q_nom_SC_ET_Wh * master_to_slave_vars.SOLAR_PART_SC_ET * share Capex_a_HEX_SC_ET, Opex_fixed_HEX_SC_ET = hex.calc_Cinv_HEX( Q_max_SC_ET_Wh, locator, config, 'HEX1') addcosts_Capex_a += Capex_a_HEX_SC_ET addcosts_Opex_fixed += Opex_fixed_HEX_SC_ET Q_max_SC_FP_Wh = solarFeat.Q_nom_SC_FP_Wh * master_to_slave_vars.SOLAR_PART_SC_FP * share Capex_a_HEX_SC_FP, Opex_fixed_HEX_SC_FP = hex.calc_Cinv_HEX( Q_max_SC_FP_Wh, locator, config, 'HEX1') addcosts_Capex_a += Capex_a_HEX_SC_FP addcosts_Opex_fixed += Opex_fixed_HEX_SC_FP Q_max_PVT_Wh = solarFeat.Q_nom_PVT_Wh * master_to_slave_vars.SOLAR_PART_PVT * share Capex_a_HEX_PVT, Opex_fixed_HEX_PVT = hex.calc_Cinv_HEX( Q_max_PVT_Wh, locator, config, 'HEX1') addcosts_Capex_a += Capex_a_HEX_PVT addcosts_Opex_fixed += Opex_fixed_HEX_PVT # Pump operation costs Capex_a_pump, Opex_fixed_pump, Opex_var_pump = pumps.calc_Ctot_pump( master_to_slave_vars, ntwFeat, gv, locator, lca, config) addcosts_Capex_a += Capex_a_pump addcosts_Opex_fixed += Opex_fixed_pump # import gas consumption data from: if DHN_barcode.count("1") > 0 and config.optimization.isheating: # import gas consumption data from: EgasPrimaryDataframe_W = pd.read_csv( locator.get_optimization_slave_cost_prime_primary_energy_data( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number), usecols=["E_gas_PrimaryPeakPower_W"]) E_gas_primary_peak_power_W = float(np.array(EgasPrimaryDataframe_W)) GasConnectionInvCost = ngas.calc_Cinv_gas(E_gas_primary_peak_power_W, gv) else: GasConnectionInvCost = 0.0 addcosts_Capex_a += GasConnectionInvCost # Save data results = pd.DataFrame({ "Capex_a_SC": [Capex_a_SC], "Opex_fixed_SC": [Opex_fixed_SC], "Capex_a_PVT": [Capex_a_PVT], "Opex_fixed_PVT": [Opex_fixed_PVT], "Capex_a_Boiler_backup": [Capex_a_Boiler_backup], "Opex_fixed_Boiler_backup": [Opex_fixed_Boiler_backup], "Capex_a_storage_HEX": [Capex_a_HP_storage], "Opex_fixed_storage_HEX": [Opex_fixed_HP_storage], "Capex_a_storage_HP": [Capex_a_storage_HP], "Capex_a_CHP": [Capex_a_CHP], "Opex_fixed_CHP": [Opex_fixed_CHP], "StorageInvC": [StorageInvC], "StorageCostSum": [StorageInvC + Capex_a_storage_HP + Capex_a_HEX], "NetworkCost": [NetworkCost], "SubstHEXCost": [SubstHEXCost_capex], "DHNInvestCost": [addcosts_Capex_a - CostDiscBuild], "PVTHEXCost_Capex": [PVTHEXCost_Capex], "CostDiscBuild": [CostDiscBuild], "CO2DiscBuild": [CO2DiscBuild], "PrimDiscBuild": [PrimDiscBuild], "Capex_a_furnace": [Capex_a_furnace], "Opex_fixed_furnace": [Opex_fixed_furnace], "Capex_a_Boiler": [Capex_a_Boiler], "Opex_fixed_Boiler": [Opex_fixed_Boiler], "Capex_a_Boiler_peak": [Capex_a_Boiler_peak], "Opex_fixed_Boiler_peak": [Opex_fixed_Boiler_peak], "Capex_Disconnected": [Capex_Disconnected], "Opex_Disconnected": [Opex_Disconnected], "Capex_a_Lake": [Capex_a_Lake], "Opex_fixed_Lake": [Opex_fixed_Lake], "Capex_a_Sewage": [Capex_a_Sewage], "Opex_fixed_Sewage": [Opex_fixed_Sewage], "SCHEXCost_Capex": [SCHEXCost_Capex], "Capex_a_pump": [Capex_a_pump], "Opex_fixed_pump": [Opex_fixed_pump], "Opex_var_pump": [Opex_var_pump], "Sum_CAPEX": [addcosts_Capex_a], "Sum_OPEX_fixed": [addcosts_Opex_fixed], "GasConnectionInvCa": [GasConnectionInvCost], "CO2_PV_disconnected": [CO2_PV_disconnected], "cost_PV_disconnected": [cost_PV_disconnected], "Eprim_PV_disconnected": [Eprim_PV_disconnected] }) results.to_csv(locator.get_optimization_slave_investment_cost_detailed( master_to_slave_vars.individual_number, master_to_slave_vars.generation_number), sep=',') return (addcosts_Capex_a + addcosts_Opex_fixed, addCO2, addPrim)