rl-institut / multi-vector-simulator

Multi-vector Simulation Tool assessing and optimizing Local Energy Systems (LES) for the E-LAND project
GNU General Public License v2.0
21 stars 10 forks source link

[Bug] minimal_degree_of_autonomy in constraints.csv not optional #780

Open MaGering opened 3 years ago

MaGering commented 3 years ago

The parameter minimal_degree_of_autonomy in constraints.csv, which is a known_extra_parameter and has been implemented in this PR, should be set to its default value if not provided, according to @smartie2076 .

So far however, if not provided, the simulation exits with KeyError.

You can reproduce this

  1. setting EXECUTE_TESTS_ON on "master" in /tests/_constants.py,
  2. Removing the line with minimal_degree_of_autonomy as input parameter for example in /tests/benchmark_test_inputs/AE_grid_battery/csv_elements/constraints.csv and
  3. running the benchmark test pytest test_benchmark_scenarios.py.

Doing this you'll get:

E       KeyError: 'minimal_degree_of_autonomy'

../src/multi_vector_simulator/D2_model_constraints.py:92: KeyError

I've attached the full error message here: KeyError_DoA_mvs.txt

Checklist to make sure that the bug report ist complete:

Please mark above checkboxes as following:

:x: Checkbox is not applicable to this bug report

smartie2076 commented 3 years ago

This also happens with the nze constraint:

I've checked whether a simulation runs without the parameter net_zero_energy in constraint.csv - it does not. See error below (run with /tests/benchmark_test_inputs/AB_grid_PV).

I cannot find your comment about this @smartie2076 but you had said something about it. I guess the desired behavior is, that in case of missing parameter net_zero_energy its default value is used, right? Did you find out why this is not the case for minimal_DA?

/home/sabine/virtualenvs/multi_vector_simulator/multi-vector-simulator/src/multi_vector_simulator/C0_data_processing.py:1763: UserWarning: The stated maximumCap in energyProduction pv_plant_01 is smaller than the installedCap (826.0/1000). Please enter a greater maximumCap.For this simulation, the maximumCap will be disregarded and not be used in the simulation
  warnings.warn(UserWarning(message))
Traceback (most recent call last):
  File "/home/sabine/virtualenvs/multi_vector_simulator/multi-vector-simulator/mvs_tool.py", line 9, in <module>
    path_input_folder="/home/sabine/virtualenvs/multi_vector_simulator/multi-vector-simulator/tests/benchmark_test_inputs/AB_grid_PV",
  File "/home/sabine/virtualenvs/multi_vector_simulator/multi-vector-simulator/src/multi_vector_simulator/cli.py", line 175, in main
    dict_values, save_energy_system_graph=save_energy_system_graph,
  File "/home/sabine/virtualenvs/multi_vector_simulator/multi-vector-simulator/src/multi_vector_simulator/D0_modelling_and_optimization.py", line 98, in run_oemof
    local_energy_system, dict_values, dict_model
  File "/home/sabine/virtualenvs/multi_vector_simulator/multi-vector-simulator/src/multi_vector_simulator/D2_model_constraints.py", line 103, in add_constraints
    if dict_values[CONSTRAINTS][NET_ZERO_ENERGY][VALUE] == True:
KeyError: 'net_zero_energy'

@SabineHaas thank you for checking this! We have not found the reason yet. I can however imagine that somehow this happens when we loop though the dict_values. Maybe we loop though the levels, eg. group/asset/parameter in the parsing process, and only exceute the check for default values in the 3rd level. For group/parameter (in simulation_settings.csv but also constraints.csv) this check might not be run! So, possibly the fix can be easy. I did not check the code though.