modex-flexmex / oemof-flexmex

oemof-flexmex is an oemof model built for model comparison within the Modex project FlexMex.
https://oemof-flexmex.readthedocs.io
MIT License
0 stars 0 forks source link

Features/usecase 3 #63

Closed jnnr closed 4 years ago

jnnr commented 4 years ago

Introduces use case 3 - hydro reservoir as flexibility option.

To model the reservoir with turbine and pump, the existing Reservoir class of oemof.tabular does not suffice. Therefore, a new facade, ReservoirWithPump, is introduced. The following sketch shows how it is constructed:

skizze_reservoir

TODO

unndreay commented 4 years ago

Run with substitute inflow profiles and fake parameters values for now (Scalars has to be updated).

unndreay commented 4 years ago

Error raised because of old TYPEMAP. Merge with dev.

unndreay commented 4 years ago

I get this error now (the warnings were there from the beginning):

9:45:02-INFO-Creating EnergySystem from datapackage
09:45:55-INFO-Creating the optimization model
WARNING: Element AT-hydro-reservoir-inflow already exists in set NODES; no
    action taken.
09:45:55-WARNING-Element AT-hydro-reservoir-inflow already exists in set NODES; no action taken.
WARNING: Element AT-hydro-reservoir-internal_bus already exists in set NODES;
    no action taken.
09:45:55-WARNING-Element AT-hydro-reservoir-internal_bus already exists in set NODES; no action taken.
WARNING: Element AT-hydro-reservoir-pump already exists in set NODES; no
    action taken.
09:45:55-WARNING-Element AT-hydro-reservoir-pump already exists in set NODES; no action taken.
WARNING: Element BE-hydro-reservoir-inflow already exists in set NODES; no
    action taken.
09:45:55-WARNING-Element BE-hydro-reservoir-inflow already exists in set NODES; no action taken.
WARNING: Element BE-hydro-reservoir-internal_bus already exists in set NODES;
    no action taken.
09:45:55-WARNING-Element BE-hydro-reservoir-internal_bus already exists in set NODES; no action taken.
WARNING: Element BE-hydro-reservoir-pump already exists in set NODES; no
    action taken.
09:45:55-WARNING-Element BE-hydro-reservoir-pump already exists in set NODES; no action taken.
Traceback (most recent call last):
  File "/home/unndreay/Workspaces/oemo-flex/experiment_1/scripts/FlexMex1_3/runall.py", line 16, in <module>
    optimization.main()
  File "/home/unndreay/Workspaces/oemo-flex/experiment_1/scripts/FlexMex1_3/optimization.py", line 23, in main
    optimize(exp_paths.data_preprocessed, exp_paths.results_optimization)
  File "/home/unndreay/Workspaces/oemo-flex/oemoflex/optimization.py", line 26, in optimize
    m = Model(es)
  File "/home/unndreay/.virtualenvs/oemo-flex/lib/python3.7/site-packages/oemof/solph/models.py", line 267, in __init__
    super().__init__(energysystem, **kwargs)
  File "/home/unndreay/.virtualenvs/oemo-flex/lib/python3.7/site-packages/oemof/solph/models.py", line 98, in __init__
    self._construct()
  File "/home/unndreay/.virtualenvs/oemo-flex/lib/python3.7/site-packages/oemof/solph/models.py", line 104, in _construct
    self._add_parent_block_variables()
  File "/home/unndreay/.virtualenvs/oemo-flex/lib/python3.7/site-packages/oemof/solph/models.py", line 311, in _add_parent_block_variables
    self.flows[o, i].nominal_value)
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
unndreay commented 4 years ago

Error was due to wrong profile naming, see #71

unndreay commented 4 years ago

Subcomponents of ReservoirWithPump do not contain carrier information. So, get_sequences_by_tech() fails:

11:33:04-INFO-Restoring attributes will overwrite existing attributes.
Traceback (most recent call last):
  File "/home/unndreay/Workspaces/oemo-flex/experiment_1/scripts/FlexMex1_3/runall.py", line 18, in <module>
    postprocessing.main()
  File "/home/unndreay/Workspaces/oemo-flex/experiment_1/scripts/FlexMex1_3/postprocessing.py", line 16, in main
    run_postprocessing(year, name, exp_paths)
  File "/home/unndreay/Workspaces/oemo-flex/oemoflex/postprocessing.py", line 981, in run_postprocessing
    sequences_by_tech = get_sequences_by_tech(es.results)
  File "/home/unndreay/Workspaces/oemo-flex/oemoflex/postprocessing.py", line 312, in get_sequences_by_tech
    carrier_tech = component.carrier + '-' + component.tech
AttributeError: 'Transformer' object has no attribute 'carrier'

There are 6 flows around the Reservoir to process in 'sequences'. Maybe, some must be ignored anyway?

       ("<oemof.solph.network.Bus: 'AT-electricity'>", "<oemof.tabular.facades.Excess: 'AT-electricity-curtailment'>")
       ("<oemof.solph.network.Bus: 'AT-electricity'>", "<oemof.tabular.facades.Load: 'AT-electricity-demand'>")
#1 ==> ("<oemof.solph.network.Bus: 'AT-electricity'>", "<oemof.solph.network.Transformer: 'AT-hydro-reservoir-pump'>")
       ("<oemof.tabular.facades.Dispatchable: 'AT-electricity-shortage'>", "<oemof.solph.network.Bus: 'AT-electricity'>")
#2 ==> ("<oemoflex.facades.ReservoirWithPump: 'AT-hydro-reservoir'>", None)
#3 ==> ("<oemoflex.facades.ReservoirWithPump: 'AT-hydro-reservoir'>", "<oemof.solph.network.Bus: 'AT-electricity'>")
#4 ==> ("<oemof.solph.network.Source: 'AT-hydro-reservoir-inflow'>", "<oemof.solph.network.Bus: 'AT-hydro-reservoir-internal_bus'>")
#5 ==> ("<oemof.solph.network.Bus: 'AT-hydro-reservoir-internal_bus'>", "<oemoflex.facades.ReservoirWithPump: 'AT-hydro-reservoir'>")
#6 ==> ("<oemof.solph.network.Transformer: 'AT-hydro-reservoir-pump'>", "<oemof.solph.network.Bus: 'AT-hydro-reservoir-internal_bus'>")
       ("<oemof.tabular.facades.Volatile: 'AT-solar-pv'>", "<oemof.solph.network.Bus: 'AT-electricity'>")
       ("<oemof.tabular.facades.Volatile: 'AT-wind-offshore'>", "<oemof.solph.network.Bus: 'AT-electricity'>")
       ("<oemof.tabular.facades.Volatile: 'AT-wind-onshore'>", "<oemof.solph.network.Bus: 'AT-electricity'>")
unndreay commented 4 years ago

Parameters in output Scalars.csv are still missing. To be continued as soon as this is updated.

unndreay commented 4 years ago

Concerning ReservoirWithPump's subnodes: We have to pick flows #1, #2, #3 (see listing above), not #2, #3, #5 as intended by https://github.com/modex-flexmex/oemo-flex/pull/63/commits/80b2a30fb727f0c25b7318329f2c64c0f463357a

The reason why I chose these to be dropped was that "Transformer" does not have a carrier attribute as so it seemed to have to be ignored anyway:

16:29:59-INFO-Restoring attributes will overwrite existing attributes.
Traceback (most recent call last):
  File "/home/unndreay/Workspaces/oemo-flex/experiment_1/scripts/FlexMex1_3/runall.py", line 18, in <module>
    postprocessing.main()
  File "/home/unndreay/Workspaces/oemo-flex/experiment_1/scripts/FlexMex1_3/postprocessing.py", line 16, in main
    run_postprocessing(year, name, exp_paths)
  File "/home/unndreay/Workspaces/oemo-flex/oemoflex/postprocessing.py", line 1001, in run_postprocessing
    sequences_by_tech = get_sequences_by_tech(es.results)
  File "/home/unndreay/Workspaces/oemo-flex/oemoflex/postprocessing.py", line 331, in get_sequences_by_tech
    carrier_tech = component.carrier + '-' + component.tech
AttributeError: 'Transformer' object has no attribute 'carrier'

But Transformer is important because it represents the "flow_in" from the electricity bus to the reservoir. So, the changes in https://github.com/modex-flexmex/oemo-flex/pull/63/commits/344ed1bc433b748da37fbc395dfa1efb3cecde90 are not sufficient. They exclude the right sequences (all those connected to the internal busses) but Transformer's missing carrier property persists.

unndreay commented 4 years ago

Updated input (EDIT: and output) Scalars.csv to the latest version (with hydro data, no new number!)

unndreay commented 4 years ago

Still missing:

unndreay commented 4 years ago

https://github.com/modex-flexmex/oemo-flex/pull/63/commits/11d20fcc9c1b91e66fc33754fba330ed28077161 affects the merge statement (on=name) in get_summed_sequences():

https://github.com/modex-flexmex/oemo-flex/blob/11d20fcc9c1b91e66fc33754fba330ed28077161/oemoflex/postprocessing.py#L368-L376

If the pump parameter rows are not renamed, only flow_out and storage_content are merged with the DataFrame df derived from preprocessing (line 371). flow_out is linked to *-hydro-reservoir-pump and thus is dropped. image

unndreay commented 4 years ago

The last commits implement inflow postprocessing to be able to check the new inflow calculation introduced by 08fe8ebbd3544e650e6efa0ed49311545a70822e (Source-type inflow in hydro-reservoir) and as a prerequisite for correct loss calculation.

The hourly inflow values into the reservoir are handed over to a new timeseries/sequences called flow_inflow and are output into <postprocessing path>/Hydro/Reservoir/Inflow EDIT 2020/08/18: <postprocessing path>/Storage/Electricity/HydroRes

EDIT 2020/08/18 A comparison of given and calculated values reveals that there is a deviation between the scalar Energy_PrimaryEnergy_Hydro_Reservoir_ReservoirAnnualInflow (not used though) given in Scalars.csv and the calculated inflow value (turbine capacity * timestep values) if added up, probably due to rounded timestep values.

More over, the inflow timeseries at input and the inflow timeseries after optimization are not identical anymore. In some timesteps, inflow is curtailed to values below the input value or to 0 (intended by Flow parameter max?). So, the calculated sum of inflow is sometimes lower than the input sum. This loss is not taken into account by the loss calculation yet (also not in DIETER)!