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

Inputs are prepared with gen_full_load_heat_rate equal to 0 #117

Closed
1 task done
danielolsen opened this issue Jul 26, 2021 · 3 comments · Fixed by #118
Closed
1 task done

Inputs are prepared with gen_full_load_heat_rate equal to 0 #117

danielolsen opened this issue Jul 26, 2021 · 3 comments · Fixed by #118
Assignees
Labels
bug Something isn't working

Comments

@danielolsen
Copy link
Contributor

danielolsen commented Jul 26, 2021

🪲

  • I have checked that this issue has not already been reported.

Bug summary

When a grid with non-variable generators with Pmax = 0 is used to prepare inputs for SwitchWrapper, the corresponding expansion candidate generators have gen_full_load_heat_rate = 0.

Code for reproduction

>>> import pandas as pd
>>> from powersimdata import Scenario
>>> from switchwrapper.prepare import prepare_inputs
>>>
>>> scenario = Scenario(599)
>>> grid = scenario.get_grid()
>>> profiles = {
...     "demand": scenario.get_demand(),
...     "hydro": scenario.get_hydro(),
...     "solar": scenario.get_solar(),
...     "wind": scenario.get_wind(),
... }
>>> timepoints = pd.read_csv("timepoints.csv", index_col=0)
>>> timestamp_to_timepoints = pd.read_csv("timestamp_to_timepoints.csv", index_col=0).squeeze()
>>> prepare_inputs(grid, profiles, timepoints, timestamp_to_timepoints, "prepared")
Please enter base study year (normally PowerSimData scenario year): 2019
Please enter the number of investment stages: 1
Single stage expansion identified.
Please enter investment period year, separate by space: 2030
Please enter start year for each period, separate by space: 2030
Please enter end year for each period, separate by space: 2030

Actual outcome

Code runs, but gen_full_load_heat_rate is 0 for the ten natural gas generators with Pmax = 0.

variable_types = {"hydro", "solar", "wind", "wind_offshore"}
grid.plant.query("Pmax == 0 and type not in @variable_types")
           bus_id   Pg   Qg  Qmax  ...      lon  GenIOB   GenIOC  GenIOD
plant_id                           ...
13935     2040940  0.0  0.0   0.0  ... -111.912   5.029  0.00026     0.0
13936     2040940  0.0  0.0   0.0  ... -111.912   4.889  0.00026     0.0
13937     2040940  0.0  0.0   0.0  ... -111.912   4.713  0.00026     0.0
13938     2040940  0.0  0.0   0.0  ... -111.912   4.510  0.00026     0.0
13939     2040940  0.0  0.0   0.0  ... -111.912   4.068  0.00026     0.0
13940     2029025  0.0  0.0   0.0  ... -117.336   5.592  0.00026     0.0
13941     2029025  0.0  0.0   0.0  ... -117.336   5.185  0.00026     0.0
13942     2029025  0.0  0.0   0.0  ... -117.336   4.885  0.00026     0.0
13943     2029025  0.0  0.0   0.0  ... -117.336   4.556  0.00026     0.0
13944     2029025  0.0  0.0   0.0  ... -117.336   4.510  0.00026     0.0

[10 rows x 35 columns]

Expected outcome

Meaningful heat rates for these generators or in absence of that, gen_capacity_limit_mw = 0.

Environment

Please specify your platform and versions of the relevant libraries you are using:

  • Operating system: Windows
  • SwitchWrapper revision (run git rev-parse origin/HEAD): 6f18ade
  • Python version: 3.9.6

Additional context

The problem seems to come from the linearize_gencost function:

>>> from switchwrapper.grid_to_switch import linearize_gencost
>>> cost_at_min_power, single_segment_slope = linearize_gencost(grid)
>>> free_fuel_types = {"geothermal", "hydro", "solar", "wind", "wind_offshore"}
>>> single_segment_slope.loc[~grid.plant.type.isin(free_fuel_types) & (single_segment_slope == 0)]
plant_id
13935    0.0
13936    0.0
13937    0.0
13938    0.0
13939    0.0
13940    0.0
13941    0.0
13942    0.0
13943    0.0
13944    0.0
dtype: float64

The only entries in single_segment_slope that are zero, but correspond to a generat

@danielolsen danielolsen added the bug Something isn't working label Jul 26, 2021
@YifanLi86
Copy link
Contributor

FYI, the logic originally exist in the research exploration code: https://github.com/Breakthrough-Energy/switch/pull/1/files, line 62, 189, 190. It seems like that part is not being passed along into Switch Wrapper.

@danielolsen
Copy link
Contributor Author

FYI, the logic originally exist in the research exploration code: https://github.com/Breakthrough-Energy/switch/pull/1/files, line 62, 189, 190. It seems like that part is not being passed along into Switch Wrapper.

You're right, this issue was not caught in either the review for this function (#35) or in any subsequent testing. If I'm reading that exploratory code correctly, it's neither adding a meaningful heat rate nor constraining the build decisions to zero, but adding an arbitrarily high heat rate such that this generator would not be chosen to be built except in extreme circumstances.

@YifanLi86
Copy link
Contributor

FYI, the logic originally exist in the research exploration code: https://github.com/Breakthrough-Energy/switch/pull/1/files, line 62, 189, 190. It seems like that part is not being passed along into Switch Wrapper.

You're right, this issue was not caught in either the review for this function (#35) or in any subsequent testing. If I'm reading that exploratory code correctly, it's neither adding a meaningful heat rate nor constraining the build decisions to zero, but adding an arbitrarily high heat rate such that this generator would not be chosen to be built except in extreme circumstances.

Yep that's right, it is quick and dirty in research exploration. Just put the link here so that we know it is not "hided" somewhere:), but no need to follow that 999 temp logic. It is certainly better to make it more robust in the design phase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
6 participants