def test_renewable_share_of_local_generation_one_sector(): """ """ dict_res = { PROJECT_DATA: {LES_ENERGY_VECTOR_S: {electricity: electricity}}, KPI: { KPI_SCALARS_DICT: { TOTAL_NON_RENEWABLE_GENERATION_IN_LES: 50, TOTAL_RENEWABLE_GENERATION_IN_LES: 50, }, KPI_UNCOUPLED_DICT: { TOTAL_RENEWABLE_GENERATION_IN_LES: {electricity: 50}, TOTAL_NON_RENEWABLE_GENERATION_IN_LES: {electricity: 50}, }, }, } E3.add_renewable_share_of_local_generation(dict_res) assert ( RENEWABLE_SHARE_OF_LOCAL_GENERATION in dict_res[KPI][KPI_UNCOUPLED_DICT] ), f"KPI {RENEWABLE_SHARE_OF_LOCAL_GENERATION} not added to dict_values[KPI][KPI_UNCOUPLED_DICT]" assert ( electricity in dict_res[KPI][KPI_UNCOUPLED_DICT][RENEWABLE_SHARE_OF_LOCAL_GENERATION] ), f"{RENEWABLE_SHARE_OF_LOCAL_GENERATION} of sector {electricity} not defined." assert ( dict_res[KPI][KPI_UNCOUPLED_DICT][RENEWABLE_SHARE_OF_LOCAL_GENERATION][ electricity ] == 0.5 ), f"{RENEWABLE_SHARE_OF_LOCAL_GENERATION} of sector {electricity} not of expected value." assert ( dict_res[KPI][KPI_SCALARS_DICT][RENEWABLE_SHARE_OF_LOCAL_GENERATION] == 0.5 ), f"System-wide {RENEWABLE_SHARE_OF_LOCAL_GENERATION} not of expected value."
def test_renewable_share_of_local_generation_two_sectors(): dict_res = { PROJECT_DATA: {LES_ENERGY_VECTOR_S: {electricity: electricity, h2: h2}}, KPI: { KPI_SCALARS_DICT: { TOTAL_NON_RENEWABLE_GENERATION_IN_LES: 100, TOTAL_RENEWABLE_GENERATION_IN_LES: 100, }, KPI_UNCOUPLED_DICT: { TOTAL_RENEWABLE_GENERATION_IN_LES: {electricity: 50, h2: 50}, TOTAL_NON_RENEWABLE_GENERATION_IN_LES: {electricity: 50, h2: 50}, }, }, } E3.add_renewable_share_of_local_generation(dict_res) exp_res_sector = {electricity: 0.5, h2: 0.5} assert RENEWABLE_SHARE_OF_LOCAL_GENERATION in dict_res[KPI][KPI_UNCOUPLED_DICT] for k in [electricity, h2]: assert ( k in dict_res[KPI][KPI_UNCOUPLED_DICT][RENEWABLE_SHARE_OF_LOCAL_GENERATION] ), f"{RENEWABLE_SHARE_OF_LOCAL_GENERATION} of sector {k} not added." assert ( dict_res[KPI][KPI_UNCOUPLED_DICT][RENEWABLE_SHARE_OF_LOCAL_GENERATION][k] == exp_res_sector[k] ), f"Expected value of {RENEWABLE_SHARE_OF_LOCAL_GENERATION} for vector {k} not reached." assert ( dict_res[KPI][KPI_SCALARS_DICT][RENEWABLE_SHARE_OF_LOCAL_GENERATION] == 0.5 ), f"Expected value of sector-wide {RENEWABLE_SHARE_OF_LOCAL_GENERATION} not reached."
def evaluate_dict(dict_values, results_main, results_meta): """ Parameters ---------- dict_values: dict simulation parameters results_main: DataFrame oemof simulation results as output by processing.results() results_meta: DataFrame oemof simulation meta information as output by processing.meta_results() Returns ------- """ dict_values.update( { KPI: { KPI_COST_MATRIX: pd.DataFrame(columns=KPI_COST_MATRIX_ENTRIES), KPI_SCALAR_MATRIX: pd.DataFrame(columns=KPI_SCALAR_MATRIX_ENTRIES), KPI_SCALARS_DICT: {}, } } ) bus_data = {} # Store all information related to busses in bus_data for bus in dict_values[ENERGY_BUSSES]: # Read all energy flows from busses bus_data.update({bus: solph.views.node(results_main, bus)}) logging.info("Evaluating optimized capacities and dispatch.") # Evaluate timeseries and store to a large DataFrame for each bus: E1.get_timeseries_per_bus(dict_values, bus_data) # Store all information related to storages in bus_data, as storage capacity acts as a bus for storage in dict_values[ENERGY_STORAGE]: bus_data.update( { dict_values[ENERGY_STORAGE][storage][LABEL]: solph.views.node( results_main, dict_values[ENERGY_STORAGE][storage][LABEL], ) } ) E1.get_storage_results( dict_values[SIMULATION_SETTINGS], bus_data[dict_values[ENERGY_STORAGE][storage][LABEL]], dict_values[ENERGY_STORAGE][storage], ) for storage_item in [STORAGE_CAPACITY, INPUT_POWER, OUTPUT_POWER]: E2.get_costs( dict_values[ENERGY_STORAGE][storage][storage_item], dict_values[ECONOMIC_DATA], ) E2.lcoe_assets(dict_values[ENERGY_STORAGE][storage], ENERGY_STORAGE) for storage_item in [STORAGE_CAPACITY, INPUT_POWER, OUTPUT_POWER]: store_result_matrix( dict_values[KPI], dict_values[ENERGY_STORAGE][storage][storage_item] ) if ( dict_values[ENERGY_STORAGE][storage][INPUT_BUS_NAME] in dict_values[OPTIMIZED_FLOWS].keys() ) or ( dict_values[ENERGY_STORAGE][storage][OUTPUT_BUS_NAME] in dict_values[OPTIMIZED_FLOWS].keys() ): bus_name = dict_values[ENERGY_STORAGE][storage][INPUT_BUS_NAME] timeseries_name = ( dict_values[ENERGY_STORAGE][storage][LABEL] + " (" + str( round( dict_values[ENERGY_STORAGE][storage][STORAGE_CAPACITY][ OPTIMIZED_ADD_CAP ][VALUE], 1, ) ) + dict_values[ENERGY_STORAGE][storage][STORAGE_CAPACITY][ OPTIMIZED_ADD_CAP ][UNIT] + ") SOC" ) dict_values[OPTIMIZED_FLOWS][bus_name][timeseries_name] = dict_values[ ENERGY_STORAGE ][storage]["timeseries_soc"] for group in [ENERGY_CONVERSION, ENERGY_PRODUCTION, ENERGY_CONSUMPTION]: for asset in dict_values[group]: E1.get_results( settings=dict_values[SIMULATION_SETTINGS], bus_data=bus_data, dict_asset=dict_values[group][asset], asset_group=group, ) E2.get_costs(dict_values[group][asset], dict_values[ECONOMIC_DATA]) E2.lcoe_assets(dict_values[group][asset], group) store_result_matrix(dict_values[KPI], dict_values[group][asset]) logging.info("Evaluating key performance indicators of the system") E3.all_totals(dict_values) E3.total_demand_and_excess_each_sector(dict_values) E3.add_total_feedin_electricity_equivaluent(dict_values) E3.add_levelized_cost_of_energy_carriers(dict_values) E3.add_total_renewable_and_non_renewable_energy_origin(dict_values) E3.add_renewable_share_of_local_generation(dict_values) E3.add_renewable_factor(dict_values) # E3.add_degree_of_sector_coupling(dict_values) feature not finished E3.add_onsite_energy_fraction(dict_values) E3.add_onsite_energy_matching(dict_values) E3.add_degree_of_autonomy(dict_values) # Tests and checks logging.info("Running validity checks.") E4.minimal_renewable_share_test(dict_values) E4.detect_excessive_excess_generation_in_bus(dict_values)