def preproccessing(locator, total_demand, buildings_heating_demand, buildings_cooling_demand, weather_file, district_heating_network, district_cooling_network): """ This function aims at preprocessing all data for the optimization. :param locator: path to locator function :param total_demand: dataframe with total demand and names of all building in the area :param building_names: dataframe with names of all buildings in the area :param weather_file: path to wather file :type locator: class :type total_demand: list :type building_names: list :type weather_file: string :return: - extraCosts: extra pareto optimal costs due to electricity and process heat ( these are treated separately and not considered inside the optimization) - extraCO2: extra pareto optimal emissions due to electricity and process heat ( these are treated separately and not considered inside the optimization) - extraPrim: extra pareto optimal primary energy due to electricity and process heat ( these are treated separately and not considered inside the optimization) - solar_features: extraction of solar features form the results of the solar technologies calculation. :rtype: float, float, float, float """ # local variables network_depth_m = Z0 print("PRE-PROCESSING 1/2: weather properties") T_ambient = epwreader.epw_reader(weather_file)['drybulb_C'] ground_temp = calc_ground_temperature(locator, T_ambient, depth_m=network_depth_m) print("PRE-PROCESSING 2/2: thermal networks") # at first estimate a distribution with all the buildings connected if district_heating_network: num_tot_buildings = len(buildings_heating_demand) DHN_barcode = ''.join(str(1) for e in range(num_tot_buildings)) substation.substation_main_heating(locator, total_demand, buildings_heating_demand, DHN_barcode=DHN_barcode) summarize_network.network_main(locator, buildings_heating_demand, ground_temp, num_tot_buildings, "DH", DHN_barcode) # "_all" key for all buildings if district_cooling_network: num_tot_buildings = len(buildings_cooling_demand) DCN_barcode = ''.join(str(1) for e in range(num_tot_buildings)) substation.substation_main_cooling(locator, total_demand, buildings_cooling_demand, DCN_barcode=DCN_barcode) summarize_network.network_main(locator, buildings_cooling_demand, ground_temp, num_tot_buildings, "DC", DCN_barcode) # "_all" key for all buildings network_features = NetworkOptimizationFeatures(district_heating_network, district_cooling_network, locator) return network_features
def calc_Ctot_cs_district(network_info): """ Calculates the total costs for cooling of the entire district, which includes the cooling networks and disconnected loads & buildings. Maintenance of network neglected, see Documentation Master Thesis Lennart Rogenhofer :param Thermal_Network network_info: an object storing information of the current network :return: """ # read in general values for cost calculation # network_info.config.detailed_electricity_pricing = False # ensure getting the average value network_info.prices = Prices(network_info.supply_systems) network_info.prices.ELEC_PRICE = np.mean(network_info.prices.ELEC_PRICE, dtype=np.float64) # [USD/W] network_info.network_features = NetworkOptimizationFeatures( district_heating_network=network_info.network_type == "DH", district_cooling_network=network_info.network_type == "DC", locator=network_info.locator) cost_storage_df = pd.DataFrame(index=network_info.cost_info, columns=[0]) ## calculate network costs # Network pipes Capex_a_netw = calc_Capex_a_network_pipes(network_info) # Network Pumps Capex_a_pump, Opex_fixed_pump, Opex_var_pump = calc_Ctot_network_pump( network_info) # Centralized plant Opex_fixed_plant, Opex_var_plant, Capex_a_chiller, Capex_a_CT = calc_Ctot_cooling_plants( network_info) if Opex_var_plant < 1: # no heat supplied by centralized plant/network, this makes sure that the network cost is 0. Capex_a_netw = 0 # calculate costs of disconnected loads Ctot_dis_loads, Opex_tot_dis_loads, Capex_a_dis_loads = calc_Ctot_cs_building_scale_loads( network_info) # calculate costs of disconnected buildings Ctot_dis_buildings, Opex_tot_dis_buildings, Capex_a_dis_buildings = calc_Ctot_cs_building_scale_buildings( network_info) # calculate costs of HEX at connected buildings Capex_a_hex, Opex_fixed_hex = calc_Cinv_HEX_hisaka(network_info) # calculate electricity consumption el_price_per_Wh = network_info.prices.ELEC_PRICE el_MWh = (Opex_var_pump + Opex_var_plant) / el_price_per_Wh / 1e6 # store results Capex_a_total = Capex_a_netw + Capex_a_pump + Capex_a_dis_loads + Capex_a_dis_buildings + \ Capex_a_chiller + Capex_a_CT + Capex_a_hex Opex_total = Opex_fixed_pump + Opex_var_pump + Opex_var_plant + Opex_tot_dis_loads + \ Opex_tot_dis_buildings + Opex_fixed_plant + Opex_fixed_hex Costs_total = Capex_a_netw + Capex_a_pump + Capex_a_chiller + Capex_a_CT + Capex_a_hex + \ Opex_fixed_pump + Opex_var_pump + Opex_var_plant + Ctot_dis_loads + Ctot_dis_buildings + \ Opex_fixed_plant + Opex_fixed_hex cost_storage_df.ix['total'][0] = Capex_a_total + Opex_total cost_storage_df.ix['opex'][0] = Opex_total cost_storage_df.ix['capex'][0] = Capex_a_total cost_storage_df.ix['capex_network'][0] = Capex_a_netw cost_storage_df.ix['capex_pump'][0] = Capex_a_pump cost_storage_df.ix['capex_hex'][0] = Capex_a_hex cost_storage_df.ix['capex_dis_loads'][0] = Capex_a_dis_loads cost_storage_df.ix['capex_dis_build'][0] = Capex_a_dis_buildings cost_storage_df.ix['capex_chiller'][0] = Capex_a_chiller cost_storage_df.ix['capex_CT'][0] = Capex_a_CT cost_storage_df.ix['opex_plant'][0] = Opex_fixed_plant + Opex_var_plant cost_storage_df.ix['opex_pump'][0] = Opex_fixed_pump + Opex_var_pump cost_storage_df.ix['opex_hex'][0] = Opex_fixed_hex cost_storage_df.ix['opex_dis_loads'][0] = Opex_tot_dis_loads cost_storage_df.ix['opex_dis_build'][0] = Opex_tot_dis_buildings cost_storage_df.ix['el_network_MWh'][0] = el_MWh return Capex_a_total, Opex_total, Costs_total, cost_storage_df
def preproccessing(locator, total_demand, buildings_heating_demand, buildings_cooling_demand, weather_file, district_heating_network, district_cooling_network): """ This function aims at preprocessing all data for the optimization. :param locator: path to locator function :param total_demand: dataframe with total demand and names of all building in the area :param building_names: dataframe with names of all buildings in the area :param weather_file: path to wather file :type locator: class :type total_demand: list :type building_names: list :type weather_file: string :return: - extraCosts: extra pareto optimal costs due to electricity and process heat ( these are treated separately and not considered inside the optimization) - extraCO2: extra pareto optimal emissions due to electricity and process heat ( these are treated separately and not considered inside the optimization) - extraPrim: extra pareto optimal primary energy due to electricity and process heat ( these are treated separately and not considered inside the optimization) - solar_features: extraction of solar features form the results of the solar technologies calculation. :rtype: float, float, float, float """ print("PRE-PROCESSING 0/4: initialize directory") shutil.rmtree(locator.get_optimization_master_results_folder()) shutil.rmtree(locator.get_optimization_network_results_folder()) shutil.rmtree(locator.get_optimization_slave_results_folder()) shutil.rmtree(locator.get_optimization_substations_folder()) print("PRE-PROCESSING 1/4: weather features") # at first estimate a distribution with all the buildings connected weather_features = WeatherFeatures(weather_file, locator) print("PRE-PROCESSING 2/4: conversion systems database") # at first estimate a distribution with all the buildings connected supply_systems = SupplySystemsDatabase(locator) print("PRE-PROCESSING 3/4: feedstocks systems database") # at first estimate a distribution with all the buildings connected prices = Prices(supply_systems) lca = LcaCalculations(supply_systems) print("PRE-PROCESSING 4/4: network features") # at first estimate a distribution with all the buildings connected if district_heating_network: num_tot_buildings = len(buildings_heating_demand) DHN_barcode = ''.join(str(1) for e in range(num_tot_buildings)) substation.substation_main_heating(locator, total_demand, buildings_heating_demand, DHN_barcode=DHN_barcode) summarize_network.network_main(locator, buildings_heating_demand, weather_features.ground_temp, num_tot_buildings, "DH", DHN_barcode) # "_all" key for all buildings if district_cooling_network: num_tot_buildings = len(buildings_cooling_demand) DCN_barcode = ''.join(str(1) for e in range(num_tot_buildings)) substation.substation_main_cooling(locator, total_demand, buildings_cooling_demand, DCN_barcode=DCN_barcode) summarize_network.network_main(locator, buildings_cooling_demand, weather_features.ground_temp, num_tot_buildings, "DC", DCN_barcode) # "_all" key for all buildings network_features = NetworkOptimizationFeatures(district_heating_network, district_cooling_network, locator) return weather_features, network_features, prices, lca