Skip to content

Change algebraic sign of feed-in tariff in input files + benchmark test#670

Closed
SabineHaas wants to merge 7 commits intodevfrom
fix/feedin_tariff
Closed

Change algebraic sign of feed-in tariff in input files + benchmark test#670
SabineHaas wants to merge 7 commits intodevfrom
fix/feedin_tariff

Conversation

@SabineHaas
Copy link
Copy Markdown
Contributor

@SabineHaas SabineHaas commented Nov 19, 2020

Fix #610

Changes proposed in this pull request:

  • set feed-in tariff to negative in dict_values in C0.all()
  • adapted C1.check_feedin_tariff() to changes
  • (adapted tests to changes)
  • added benchmark test for feed-in tariff
  • make sure that feedin revenue is indeed substracted from the operational costs
  • ❌ give a hint in readthedocs about feed-in tariff sign --> looks fine in rtd: "Price received for feeding electricity into the grid." implies that it's positive.

The following steps were realized, as well (if applies):

  • Use in-line comments to explain your code
  • Write docstrings to your code (example docstring)
  • ❌ For new functionalities: Explain in readthedocs
  • Write test(s) for your new patch of code (pytests, assertion debug messages)
  • Update the CHANGELOG.md
  • Apply black (black . --exclude docs/)
  • Check if benchmark tests pass locally (EXECUTE_TESTS_ON=master pytest)

Please mark above checkboxes as following:

  • Open
  • Done

❌ Check not applicable to this PR

For more information on how to contribute check the CONTRIBUTING.md.

@SabineHaas
Copy link
Copy Markdown
Contributor Author

Plans for feed-in benchmark test:

  • high positive feed-in tariff (feed-in tariff < electr. price) --> feed-in takes place.
  • negative feed-in tariff (pay for feed-in) --> excess bus is used, no feed-in.
  • check revenue from feed-in tariff (probably COST_TOTAL of asset in dict_values)

This could be added e.g. to AB_grid_PV but could also be a new benchmark test - how do you usually handle this / do you have an opinion about where to place the test @smartie2076 ?

@Bachibouzouk Bachibouzouk changed the title First changelog entry Feed-in benchmark test Nov 19, 2020
@smartie2076
Copy link
Copy Markdown
Collaborator

Yeah, your planned changes sound good. You might have to change PFs benchmark test (#613) as well with the feedin - but it can also be that no feed in occurs in that scenario.
https://github.com/rl-institut/multi-vector-simulator/blob/dev/src/multi_vector_simulator/C1_verification.py#L86

Plans for feed-in benchmark test:

* high positive feed-in tariff (feed-in tariff < electr. price) --> feed-in takes place.

Yes, that is a good one. Please include an assertion for the costs part as well as for the timeseries.

* negative feed-in tariff (pay for feed-in) -->  excess bus is used, no feed-in.

Good

* check revenue from feed-in tariff (probably `COST_TOTAL` of asset in `dict_values`)

Yeah, but also you could check COST_OPERATIONAL_TOTAL, COST_OM, COST_DISPATCH

This could be added e.g. to AB_grid_PV but could also be a new benchmark test - how do you usually handle this / do you have an opinion about where to place the test @smartie2076

Make it a seperate benchmark test anyway. I dream of aggregating the DSO cost at some point (currently all peak demand pricing months are seperate), and then we can join it there.

Do you plan to do an investment optimization as well or only a dispatch optimization?

@SabineHaas SabineHaas changed the title Feed-in benchmark test Change algebraic sign of feed-in tariff in input files + benchmark test Nov 25, 2020
@SabineHaas SabineHaas self-assigned this Nov 26, 2020
@SabineHaas SabineHaas marked this pull request as ready for review November 26, 2020 13:05
@SabineHaas
Copy link
Copy Markdown
Contributor Author

@smartie2076 @Bachibouzouk I'm facing an issue with the benchmark test for renewable constraint (test_benchmark_constraint.py). Both tests (constraint = 0, constraint = 0.7) fail with the changes concerning the feed-in tariff. Could you please run simulations with them and check why they fail? I couldn't find the problem.

  • test_benchmark_constraint.py works when feedin_tariff of provider is set to -0.4
  • comparing lp files of simulations with feedin_tariff=-0.4 and feedin_tariff=0.4 (done for constraint=0): look the same apart from the values -0.4 and 0.4 of course
  • png graph: all components connected
  • optimizeCap=True for all assets and no maximumCap for PV

Copy link
Copy Markdown
Collaborator

@smartie2076 smartie2076 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @SabineHaas! I actually moved some functions around because I think we should not mess with the value of the feedin tariff in energy providers. With my solution, I also have no issues with the benchmark test for the minimal renewable share. Please check #685 for my proposal (based on this branch).

Comment on lines +1605 to +1641


def change_sign_of_feedin_tariff_to_minus(dict_values):
r"""
Change the sign of the feed-in tariff to minus.

Additionally, prints a logging.warning in case of the feed-in tariff is entered as
negative value to 'energyProviders.csv'.

Parameters
----------
dict_values: dict
All input data in dict format

Returns
-------
Updated `dict_values`.
"""
# check feed-in tariff of each provider
for provider, provider_dict in dict_values[ENERGY_PROVIDERS].items():
feedin_tariff = provider_dict[FEEDIN_TARIFF][VALUE]
# change sign of feed-in tariff and add a info msg in case it was positive and
# a warning msg in case it was negative as might have been meant to be a
# negative feed-in tariff.
if feedin_tariff > 0:
logging.info(
f"The {FEEDIN_TARIFF} of {provider} has been changed to a negative value, which means to earn money by feeding into the grid."
)
elif feedin_tariff < 0:
logging.warning(
f"The {FEEDIN_TARIFF} of {provider} has been changed to a positive value, which means to pay for feed-in to the grid. If you intended the value to be negative (earning) please set a positive value."
)
else:
pass
dict_values[ENERGY_PROVIDERS][provider][FEEDIN_TARIFF].update(
{VALUE: -feedin_tariff}
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that one would use this part of the code to influence how the minus is interpreted:

# define feed-in sink of the DSO
    define_sink(
        dict_values=dict_values,
        asset_key=dso + DSO_FEEDIN + AUTO_SINK,
        price=dict_values[ENERGY_PROVIDERS][dso][FEEDIN_TARIFF],
        inflow_direction=dict_values[ENERGY_PROVIDERS][dso][INFLOW_DIRECTION],
        specific_costs={VALUE: 0, UNIT: CURR + "/" + UNIT},
        energy_vector=dict_values[ENERGY_PROVIDERS][dso][ENERGY_VECTOR],
    )

This would change it to the wanted behaviour:

# define feed-in sink of the DSO
    define_sink(
        dict_values=dict_values,
        asset_key=dso + DSO_FEEDIN + AUTO_SINK,
        price=-dict_values[ENERGY_PROVIDERS][dso][FEEDIN_TARIFF],
        inflow_direction=dict_values[ENERGY_PROVIDERS][dso][INFLOW_DIRECTION],
        specific_costs={VALUE: 0, UNIT: CURR + "/" + UNIT},
        energy_vector=dict_values[ENERGY_PROVIDERS][dso][ENERGY_VECTOR],
    )

I think this is also better, because we would otherwise change the data that we receive from the EPA to something else.

Have you checked with this what happens with the revenue stream or anything? Otherwise we need to check it in #613.

feedin_tariff = dict_values[ENERGY_PROVIDERS][provider][FEEDIN_TARIFF]
electricity_price = dict_values[ENERGY_PROVIDERS][provider][ENERGY_PRICE]
diff = feedin_tariff[VALUE] - electricity_price[VALUE]
diff = electricity_price[VALUE] - abs(feedin_tariff[VALUE])
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have to pay for feed-in, ie. in your csv file you enter a negative value, and use abs() here, having to pay a lot for feedin into the grid (ie. more than if you buy electricity) would suggest an infeasible problem. This problem, however, is solvable: oemof would try to route everything into excess sinks instead.

With my above suggestion from above (changing sign when defining source only), this change could be dropped.

Suggested change
diff = electricity_price[VALUE] - abs(feedin_tariff[VALUE])
diff = feedin_tariff[VALUE] - electricity_price[VALUE]

diff = electricity_price[VALUE] - abs(feedin_tariff[VALUE])
if isinstance(diff, float) or isinstance(diff, int):
if diff > 0:
if diff < 0:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped as suggested above

Suggested change
if diff < 0:
if diff > 0:

else:
boolean = [
k > 0 for k in diff.values
k < 0 for k in diff.values
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped as suggested above:

Suggested change
k < 0 for k in diff.values
k > 0 for k in diff.values

@SabineHaas SabineHaas mentioned this pull request Dec 7, 2020
12 tasks
@SabineHaas SabineHaas closed this Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feed-in tariff in 'energyProvider.csv' should be negative

2 participants