def test_calculation_of_lcoe_of_asset_total_flow_is_0(): """Tests if LCOE is set to None with TOTAL_FLOW of asset is 0""" for group in [ENERGY_CONVERSION, ENERGY_STORAGE]: for asset in dict_values[group]: E2.lcoe_assets(dict_values[group][asset], group) assert dict_values[ENERGY_CONVERSION]["inverter"][LCOE_ASSET][VALUE] is 0 assert dict_values[ENERGY_STORAGE]["battery_2"][LCOE_ASSET][VALUE] is 0
def test_calculation_of_lcoe_asset_storage_flow_not_0_provider_flow_not_0(): """Tests whether the LCOE is correctly calculated for each asset in the different asset groups""" for group in [ENERGY_PRODUCTION, ENERGY_CONSUMPTION, ENERGY_STORAGE]: for asset in dict_values[group]: E2.lcoe_assets(dict_values[group][asset], group) assert dict_values[ENERGY_PRODUCTION]["PV"][LCOE_ASSET][ VALUE] == exp_lcoe_pv assert (dict_values[ENERGY_CONSUMPTION]["demand"][LCOE_ASSET][VALUE] == exp_lcoe_demand) assert (dict_values[ENERGY_STORAGE]["battery_1"][LCOE_ASSET][VALUE] == exp_lcoe_battery_1) for component in [INPUT_POWER, OUTPUT_POWER, STORAGE_CAPACITY]: assert LCOE_ASSET in dict_values[ENERGY_STORAGE]["battery_1"][ component]
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)