def main(config):
    print('Running decentralized model for buildings with scenario = %s' % config.scenario)
    locator = cea.inputlocator.InputLocator(config.scenario)
    supply_systems = SupplySystemsDatabase(locator)
    total_demand = pd.read_csv(locator.get_total_demand())
    prices = Prices(supply_systems)
    lca = LcaCalculations(supply_systems)
    disconnected_building_main(locator=locator,  total_demand=total_demand,
                               config=config, prices=prices, lca=lca)
Пример #2
0
def main(config):
    print('Running decentralized model for buildings with scenario = %s' % config.scenario)
    locator = cea.inputlocator.InputLocator(config.scenario)
    total_demand = pd.read_csv(locator.get_total_demand())
    detailed_electricity_pricing = config.decentralized.detailed_electricity_pricing
    prices = Prices(locator, detailed_electricity_pricing)
    lca = LcaCalculations(locator)
    disconnected_building_main(locator=locator,  total_demand=total_demand,
                               config=config, prices=prices, lca=lca)
Пример #3
0
def main(config):
    """
    run the whole preprocessing routine
    """
    from cea.optimization.prices import Prices as Prices
    print('Running decentralized model for buildings with scenario = %s' % config.scenario)

    locator = cea.inputlocator.InputLocator(scenario=config.scenario)
    total_demand = pd.read_csv(locator.get_total_demand())
    building_names = total_demand.Name
    prices = Prices(locator, config)
    lca = LcaCalculations(locator, config.optimization.detailed_electricity_pricing)
    disconnected_buildings_cooling_main(locator, building_names, total_demand, config, prices, lca)

    print 'test_decentralized_buildings_cooling() succeeded'
Пример #4
0
def main(config):
    """
    run the whole preprocessing routine
    """
    from cea.optimization.prices import Prices as Prices
    print("Running decentralized model for buildings with scenario = %s" %
          config.scenario)

    locator = cea.inputlocator.InputLocator(scenario=config.scenario)
    supply_systems = SupplySystemsDatabase(locator)
    total_demand = pd.read_csv(locator.get_total_demand())
    building_names = total_demand.Name
    prices = Prices(supply_systems)
    lca = LcaCalculations(supply_systems)
    disconnected_buildings_cooling_main(locator, building_names, total_demand,
                                        config, prices, lca)

    print("test_decentralized_buildings_cooling() succeeded")
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
def moo_optimization(locator, weather_file, config):
    '''
    This function optimizes the conversion, storage and distribution systems of a heating distribution for the case
    study. It requires that the energy demand, technology potential and thermal networks are simulated, as follows:

        - energy demand simulation: run cea/demand/demand_main.py
        - PV potential: run cea/technologies/solar/photovoltaic.py
        - PVT potential: run cea/technologies/solar/photovoltaic_thermal.py
        - flat plate solar collector potential: run cea/technologies/solar/solar_collector.py with
          config.solar.type_scpanel = 'FP'
        - evacuated tube solar collector potential: run cea/technologies/solar/solar_collector.py with
          config.solar.type_scpanel = 'ET'
        - waste water heat recovery: run cea/resources/sewage_heat_exchanger.py
        - lake water potential: run cea/resources/water_body_potential.py
        - thermal network simulation: run cea/technologies/thermal_network/thermal_network.py
          if no network is currently present in the case study, consider running network_layout/main.py first
        - decentralized building simulation: run cea/optimization/preprocessing/decentralized_building_main.py

    :param locator: path to input locator
    :param weather_file: path to weather file
    :type locator: cea.inputlocator.InputLocator
    :type weather_file: string

    :returns: None
    :rtype: Nonetype
    '''
    t0 = time.clock()

    # read total demand file and names and number of all buildings
    total_demand = pd.read_csv(locator.get_total_demand())
    building_names_all = list(total_demand.Name.values)  # needs to be a list to avoid errors
    lca = LcaCalculations(locator)
    prices = Prices(locator, config.optimization.detailed_electricity_pricing)

    # local flags
    district_heating_network = config.optimization.district_heating_network
    district_cooling_network = config.optimization.district_cooling_network

    #GET NAMES_OF BUILDINGS THAT HAVE HEATING, COOLING AND ELECTRICITY LOAD SEPARATELY

    buildings_heating_demand = get_building_names_with_load(total_demand, load_name='QH_sys_MWhyr')
    buildings_cooling_demand = get_building_names_with_load(total_demand, load_name='QC_sys_MWhyr')
    buildings_electricity_demand = get_building_names_with_load(total_demand, load_name='E_sys_MWhyr')

    # pre-process information regarding resources and technologies (they are treated before the optimization)
    # optimize best systems for every individual building (they will compete against a district distribution solution)
    print("PRE-PROCESSING")
    network_features = preproccessing(locator, total_demand, buildings_heating_demand, buildings_cooling_demand,
                                      weather_file, district_heating_network, district_cooling_network)

    # optimize conversion systems
    print("SUPPLY SYSTEMS OPTIMIZATION")
    master_main.non_dominated_sorting_genetic_algorithm(locator,
                                                        building_names_all,
                                                        district_heating_network,
                                                        district_cooling_network,
                                                        buildings_heating_demand,
                                                        buildings_cooling_demand,
                                                        buildings_electricity_demand,
                                                        network_features, config, prices, lca)

    t1 = time.clock()
    print('Centralized Optimization succeeded after %s seconds' %(t1-t0))
Пример #7
0
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 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
    detailed_electricity_pricing = network_info.config.detailed_electricity_pricing
    lca = LcaCalculations(network_info.locator, detailed_electricity_pricing)
    network_info.prices = Prices(network_info.locator, network_info.config)
    network_info.prices.ELEC_PRICE = np.mean(lca.ELEC_PRICE,
                                             dtype=np.float64)  # [USD/W]
    network_info.network_features = NetworkOptimizationFeatures(
        network_info.config, 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_disconnected_loads(
        network_info)
    # calculate costs of disconnected buildings
    Ctot_dis_buildings, Opex_tot_dis_buildings, Capex_a_dis_buildings = calc_Ctot_cs_disconnected_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