Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a variable electricity import price #170

Open
oum96-mah opened this issue Apr 11, 2022 · 4 comments
Open

Implement a variable electricity import price #170

oum96-mah opened this issue Apr 11, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@oum96-mah
Copy link

Hi.
I have a variable electricity price for my project site. Is there a method to switch from fixed to variable price?

@smartie2076
Copy link
Collaborator

smartie2076 commented Apr 11, 2022

Hi @oum96-mah! Sadly, it is not possible to define an electricity provide with an electricity price based on the hour of the year. If you have coding experience, you could introduce this feature. Otherwise, I would recommend to check out the not-as-user-friendly Multi Vector Simulator (https://github.com/rl-institut/multi-vector-simulator/). There, you can define your energy system via csv files, and also define specific parameters (like efficiencies, dispatch prices and energy prices) as a timeseries.

Related to #169

@smartie2076 smartie2076 changed the title FIXED ELECTRICITY_PRICE Implement a variable electricity import price Apr 11, 2022
@smartie2076 smartie2076 added the enhancement New feature or request label Apr 11, 2022
@smartie2076
Copy link
Collaborator

smartie2076 commented Apr 25, 2022

Here is a list of what would need to be done to implement a variable electricity (import) price. Variable or function names are suggestions and might be improved on, looking at existing naming conventions.

There are two options:
a) Push offgridders to accept both string and float for maingrid_electricity_price
b) Properly define a new parameter in case_definitions, eg. maingrid_electricity_price_is_fix== FALSE / TRUE, and depending on that require a title_maingrid_electricity_price in project_sites or not.

I explain the option a) here now, as it works well if you have a pilot site that has a variable price, or does not. The scenarios are not based on the electricity price timeseries (ie. focussing on sizing implications). If the focus was more on creating multiple cases applied to one test stite, where either the electricity price was variable or it was not (ie. impact assessment of that) then b) would be better.

  • Create a simple benchmark test that assesses the functionality of the maingrid electricity price (see comment below), before you change anything. The electricity price must be a scalar here.
  • Add a column in ./inputs/timeseries and test_site.csv for your electricty price timeseries
  • Change description of parameter maingrid_electricity_price on tab input_constants from /kWh to float in /kWh or title of timeseries in input file with each value in /kWh
  • Try to define maingrid_electricity_price as a string, and see where it gives you an error message (that is where you need to change code)
  • Allow maingrid_electricity_price to both be a string or a float: If it is a value, then use that, if it is a string, parse as string
  • If string, then use functions that also parse title_pv etc. to parse the new column. For this, the approach b) would be a bit easier, as then you could simple add a title_maingrid_electricy_price in
    def from_file(project_site, path_from):
    in this list
    list_columns = [
    TITLE_TIME,
    TITLE_DEMAND_AC,
    TITLE_DEMAND_DC,
    TITLE_PV,
    TITLE_WIND,
    TITLE_GRID_AVAILABILITY,
    ]
    . Maybe it is easiest to create one or multiple new functions from the lines
    for column_item in list_columns:
    until the end of the function, this would also make writing pytests easier and you could re-use existing functions.
  • The values should be in a pandas.series format at the end.
  • Make sure the maingrid source is defined with the new pandas.series as variable_cost in
    def pointofcoupling_consumption_fix(
    and pointofcoupling_consumption_oem.
    variable_costs=experiment[PCOUPLING_COST_VAR]
    + experiment[MAINGRID_ELECTRICITY_PRICE],
    and
    variable_costs=experiment[PCOUPLING_COST_VAR]
    + experiment[MAINGRID_ELECTRICITY_PRICE],
    must result in a pandas.series again.
  • You can check if the price series is integrated correctly by assessing the lp file that can be exported
  • Make sure that in
    def expenditures_main_grid_consumption(oemof_results, experiment):
    the cost are is calculated correctly, ie. that
    oemof_results.update(
    {
    EXPENDITURES_MAIN_GRID_CONSUMPTION_ANNUAL: oemof_results[
    CONSUMPTION_MAIN_GRID_MG_SIDE_ANNUAL_KWH
    ]
    * experiment[MAINGRID_ELECTRICITY_PRICE]
    }
    )
    can deal with an pandas.series
  • Create a benchmark test for your function, ie. a variable maingrid_electricity_price. This one and the one from the beginning must run though with Offgridders. If this becomes an issue, you could also generate an imaginative pandas.series from the scalar value in the pre-processing steps.

@smartie2076
Copy link
Collaborator

I highly recommend creating pytest unit-tests along the way to test if what you want to change is working or not, ie. for the different functions that you are changing.

@smartie2076
Copy link
Collaborator

smartie2076 commented Apr 25, 2022

As two simple benchmark tests, I would suggest the following:

  • Case with only demand and connection to the main grid for consumption (no PV, no battery, no feedin)
  • No costs connected to any assets (also the PCC), only to the maingrid_electricity_price
  • Simple, first benchmark test with maingrid_electricity_price as a scalar, that makes sure that sum(demand)*maingrid_electricity_price==costs calculated by Offgridders. This should already pass right now, but by creating the test you make sure that it still passes after you have introduced your changes.
  • Second benchmark test, in which maingrid_electricity_price is a timeseries, where you assess that sum(demand(t)*maingrid_electricity_price(t)) == costs calculated by Offgridders. This will proove that your introduced algorithm works properly.

The actual values of the demand or electricity price timeseries (as long as they are not 0 all the time) does not matter. You can limit the evaluated timeframe to a day or a week, as we are not dealing with a plausibility test of renewables here.

You would probably create two duplicates of \tests\inputs and its contents for this in the test folder, and those contain the inputs to the benchmark test. You can add a new file test_benchmark_maingrid_electricity_price.py to the test folder to write the benchmark tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants