def calc_Cinv_CCGT(CC_size_W, locator, config, technology=0): """ Annualized investment costs for the Combined cycle :type CC_size_W : float :param CC_size_W: Electrical size of the CC :rtype InvCa : float :returns InvCa: annualized investment costs in CHF ..[C. Weber, 2008] C.Weber, Multi-objective design and optimization of district energy systems including polygeneration energy conversion technologies., PhD Thesis, EPFL """ CCGT_cost_data = pd.read_excel(locator.get_database_supply_systems(), sheet_name="CCGT") technology_code = list(set(CCGT_cost_data['code'])) CCGT_cost_data[CCGT_cost_data['code'] == technology_code[technology]] # if the Q_design is below the lowest capacity available for the technology, then it is replaced by the least # capacity for the corresponding technology from the database if CC_size_W < CCGT_cost_data['cap_min'][0]: CC_size_W = CCGT_cost_data['cap_min'][0] CCGT_cost_data = CCGT_cost_data[(CCGT_cost_data['cap_min'] <= CC_size_W) & (CCGT_cost_data['cap_max'] > CC_size_W)] #costs of connection connection_costs = ngas.calc_Cinv_gas(CC_size_W) Inv_a = CCGT_cost_data.iloc[0]['a'] Inv_b = CCGT_cost_data.iloc[0]['b'] Inv_c = CCGT_cost_data.iloc[0]['c'] Inv_d = CCGT_cost_data.iloc[0]['d'] Inv_e = CCGT_cost_data.iloc[0]['e'] Inv_IR = (CCGT_cost_data.iloc[0]['IR_%']) / 100 Inv_LT = CCGT_cost_data.iloc[0]['LT_yr'] Inv_OM = CCGT_cost_data.iloc[0]['O&M_%'] / 100 InvC = Inv_a + Inv_b * (CC_size_W)**Inv_c + ( Inv_d + Inv_e * CC_size_W) * log(CC_size_W) Capex_a_CCGT_USD = (InvC + connection_costs) * (Inv_IR) * ( 1 + Inv_IR)**Inv_LT / ((1 + Inv_IR)**Inv_LT - 1) Opex_fixed_CCGT_USD = InvC * Inv_OM Capex_CCGT_USD = InvC return Capex_a_CCGT_USD, Opex_fixed_CCGT_USD, Capex_CCGT_USD
def calc_Cinv_CCGT(CC_size_W, CCGT_cost_data): """ Annualized investment costs for the Combined cycle :type CC_size_W : float :param CC_size_W: Electrical size of the CC :rtype InvCa : float :returns InvCa: annualized investment costs in CHF ..[C. Weber, 2008] C.Weber, Multi-objective design and optimization of district energy systems including polygeneration energy conversion technologies., PhD Thesis, EPFL """ # if the Q_design is below the lowest capacity available for the technology, then it is replaced by the least # capacity for the corresponding technology from the database if CC_size_W < CCGT_cost_data['cap_min'][0]: CC_size_W = CCGT_cost_data['cap_min'][0] CCGT_cost_data = CCGT_cost_data[(CCGT_cost_data['cap_min'] <= CC_size_W) & (CCGT_cost_data['cap_max'] > CC_size_W)] #costs of connection connection_costs = ngas.calc_Cinv_gas(CC_size_W) Inv_a = CCGT_cost_data.iloc[0]['a'] Inv_b = CCGT_cost_data.iloc[0]['b'] Inv_c = CCGT_cost_data.iloc[0]['c'] Inv_d = CCGT_cost_data.iloc[0]['d'] Inv_e = CCGT_cost_data.iloc[0]['e'] Inv_IR = CCGT_cost_data.iloc[0]['IR_%'] Inv_LT = CCGT_cost_data.iloc[0]['LT_yr'] Inv_OM = CCGT_cost_data.iloc[0]['O&M_%'] / 100 InvC = Inv_a + Inv_b * (CC_size_W)**Inv_c + ( Inv_d + Inv_e * CC_size_W) * log(CC_size_W) Capex_a_CCGT_USD = calc_capex_annualized((InvC + connection_costs), Inv_IR, Inv_LT) Opex_fixed_CCGT_USD = InvC * Inv_OM Capex_CCGT_USD = InvC return Capex_a_CCGT_USD, Opex_fixed_CCGT_USD, Capex_CCGT_USD
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 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)