def test_add_levelized_cost_of_energy_carriers_two_sectors(): dict_values[KPI][KPI_SCALARS_DICT].update({TOTAL_DEMAND + h2: 100}) dict_values[KPI][KPI_SCALARS_DICT].update({ TOTAL_DEMAND + h2 + SUFFIX_ELECTRICITY_EQUIVALENT: dict_values[KPI][KPI_SCALARS_DICT][TOTAL_DEMAND + h2] * DEFAULT_WEIGHTS_ENERGY_CARRIERS[h2][VALUE] }) dict_values[KPI][KPI_SCALARS_DICT].update({ TOTAL_DEMAND + SUFFIX_ELECTRICITY_EQUIVALENT: dict_values[KPI][KPI_SCALARS_DICT][TOTAL_DEMAND + electricity + SUFFIX_ELECTRICITY_EQUIVALENT] + dict_values[KPI][KPI_SCALARS_DICT][TOTAL_DEMAND + h2 + SUFFIX_ELECTRICITY_EQUIVALENT] }) dict_values[PROJECT_DATA][SECTORS].update({h2: h2}) E3.add_levelized_cost_of_energy_carriers(dict_values) expected_value = { ATTRIBUTED_COSTS + electricity: 1000 * dict_values[KPI][KPI_SCALARS_DICT][TOTAL_DEMAND + electricity + SUFFIX_ELECTRICITY_EQUIVALENT] / dict_values[KPI][KPI_SCALARS_DICT][TOTAL_DEMAND + SUFFIX_ELECTRICITY_EQUIVALENT], ATTRIBUTED_COSTS + h2: 1000 * dict_values[KPI][KPI_SCALARS_DICT][TOTAL_DEMAND + h2 + SUFFIX_ELECTRICITY_EQUIVALENT] / dict_values[KPI][KPI_SCALARS_DICT][TOTAL_DEMAND + SUFFIX_ELECTRICITY_EQUIVALENT], } expected_value.update({ LCOeleq + electricity: dict_values[KPI][KPI_SCALARS_DICT][ATTRIBUTED_COSTS + electricity] * dict_values[ECONOMIC_DATA][CRF][VALUE] / dict_values[KPI][KPI_SCALARS_DICT][TOTAL_DEMAND + electricity], LCOeleq + electricity: dict_values[KPI][KPI_SCALARS_DICT][ATTRIBUTED_COSTS + h2] * dict_values[ECONOMIC_DATA][CRF][VALUE] / dict_values[KPI][KPI_SCALARS_DICT][TOTAL_DEMAND + h2], LCOeleq: 1000 * dict_values[ECONOMIC_DATA][CRF][VALUE] / dict_values[KPI][KPI_SCALARS_DICT][TOTAL_DEMAND + SUFFIX_ELECTRICITY_EQUIVALENT], }) for kpi in [ATTRIBUTED_COSTS, LCOeleq]: assert kpi + electricity in dict_values[KPI][KPI_SCALARS_DICT] assert (dict_values[KPI][KPI_SCALARS_DICT][kpi + electricity] == expected_value[kpi + electricity]) assert LCOeleq in dict_values[KPI][KPI_SCALARS_DICT] assert dict_values[KPI][KPI_SCALARS_DICT][LCOeleq] == expected_value[ LCOeleq]
def test_add_levelized_cost_of_energy_carriers_one_sector(): E3.add_levelized_cost_of_energy_carriers(dict_values) expected_value = { ATTRIBUTED_COSTS + electricity: 1000, LCOeleq + electricity: 1000 * dict_values[ECONOMIC_DATA][CRF][VALUE] / total_demand, LCOeleq: 1000 * dict_values[ECONOMIC_DATA][CRF][VALUE] / total_demand, } for kpi in [ATTRIBUTED_COSTS, LCOeleq]: assert kpi + electricity in dict_values[KPI][KPI_SCALARS_DICT] assert (dict_values[KPI][KPI_SCALARS_DICT][kpi + electricity] == expected_value[kpi + electricity]) assert LCOeleq in dict_values[KPI][KPI_SCALARS_DICT] assert dict_values[KPI][KPI_SCALARS_DICT][LCOeleq] == expected_value[ LCOeleq]
def test_add_levelized_cost_of_energy_carriers_two_sectors(): dict_values[KPI][KPI_SCALARS_DICT].update({TOTAL_DEMAND + h2: total_demand}) dict_values[KPI][KPI_SCALARS_DICT].update( { TOTAL_DEMAND + h2 + SUFFIX_ELECTRICITY_EQUIVALENT: dict_values[KPI][KPI_SCALARS_DICT][ TOTAL_DEMAND + h2 ] * DEFAULT_WEIGHTS_ENERGY_CARRIERS[h2][VALUE] } ) dict_values[KPI][KPI_SCALARS_DICT].update( { TOTAL_DEMAND + SUFFIX_ELECTRICITY_EQUIVALENT: dict_values[KPI][KPI_SCALARS_DICT][ TOTAL_DEMAND + electricity + SUFFIX_ELECTRICITY_EQUIVALENT ] + dict_values[KPI][KPI_SCALARS_DICT][ TOTAL_DEMAND + h2 + SUFFIX_ELECTRICITY_EQUIVALENT ] } ) dict_values[PROJECT_DATA][LES_ENERGY_VECTOR_S].update({h2: h2}) E3.add_levelized_cost_of_energy_carriers(dict_values) expected_value = { ATTRIBUTED_COSTS + electricity: npc * dict_values[KPI][KPI_SCALARS_DICT][ TOTAL_DEMAND + electricity + SUFFIX_ELECTRICITY_EQUIVALENT ] / dict_values[KPI][KPI_SCALARS_DICT][ TOTAL_DEMAND + SUFFIX_ELECTRICITY_EQUIVALENT ], ATTRIBUTED_COSTS + h2: npc * dict_values[KPI][KPI_SCALARS_DICT][ TOTAL_DEMAND + h2 + SUFFIX_ELECTRICITY_EQUIVALENT ] / dict_values[KPI][KPI_SCALARS_DICT][ TOTAL_DEMAND + SUFFIX_ELECTRICITY_EQUIVALENT ], } expected_value.update( { LCOeleq + electricity: dict_values[KPI][KPI_SCALARS_DICT][ ATTRIBUTED_COSTS + electricity ] * dict_values[ECONOMIC_DATA][CRF][VALUE] / dict_values[KPI][KPI_SCALARS_DICT][TOTAL_DEMAND + electricity], LCOeleq + h2: dict_values[KPI][KPI_SCALARS_DICT][ATTRIBUTED_COSTS + h2] * dict_values[ECONOMIC_DATA][CRF][VALUE] / dict_values[KPI][KPI_SCALARS_DICT][TOTAL_DEMAND + h2], LCOeleq: npc * dict_values[ECONOMIC_DATA][CRF][VALUE] / dict_values[KPI][KPI_SCALARS_DICT][ TOTAL_DEMAND + SUFFIX_ELECTRICITY_EQUIVALENT ], } ) for sector in [electricity, h2]: for kpi in [ATTRIBUTED_COSTS, LCOeleq]: assert ( kpi + sector in dict_values[KPI][KPI_SCALARS_DICT] ), f"The KPI {kpi+sector} is not in dict_values[KPI][KPI_SCALARS_DICT]." assert ( dict_values[KPI][KPI_SCALARS_DICT][kpi + sector] == expected_value[kpi + sector] ), f"The expected {kpi + sector} of {expected_value[kpi + sector]} is not equal to the calculated result {dict_values[KPI][KPI_SCALARS_DICT][kpi + sector]}." assert ( LCOeleq in dict_values[KPI][KPI_SCALARS_DICT] ), f"The KPI {LCOeleq} is not in dict_values[KPI][KPI_SCALARS_DICT]" assert ( dict_values[KPI][KPI_SCALARS_DICT][LCOeleq] == expected_value[LCOeleq] ), f"The expected {LCOeleq} of {expected_value[LCOeleq]} is not equal to the calculated result {dict_values[KPI][KPI_SCALARS_DICT][LCOeleq]}."
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)