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

add data structure for expansion candidates #679

Merged
merged 9 commits into from
Sep 16, 2022
Merged

add data structure for expansion candidates #679

merged 9 commits into from
Sep 16, 2022

Conversation

jenhagg
Copy link
Collaborator

@jenhagg jenhagg commented Sep 9, 2022

Purpose

Define a new data structure for expansion candidates and some preliminary validation based on the current grid. The schema is the same as in #641 but I refactored it a bit.

What the code is doing

Add the new class, which can have candidates for branches, plants, and storage. Each one has a set of allowed columns and required columns. When assigning a given type of candidate, there are some basic checks - e.g. buses are in the grid. I imagine more checks could be done in subsequent PRs.

We've discussed expanding the costs over multiple years to account for inflation - this isn't accounted for yet, and I suspect it might be done during the preparation phase, after a user has defined the investment years/time span.

In general there is probably a lot from the original epic that isn't implemented yet. E.g. defining branch candidates by substation instead of buses. This is just meant to be a usable subset of the possible/desired schema.

Testing

New unit tests

Usage Example/Visuals

Create an instance:

from powersimdata import Grid
from powersimdata.input.expansion_candidates import ExpansionCandidates
grid = Grid("Texas")
ec = ExpansionCandidates(grid)

After assigning some values (using the example from the unit test), we can inspect it using the custom repr

In [10]: ec
Out[10]:
ExpansionCandidates(branch: cols=['from_bus', 'to_bus', 'inv_cost', 'max_capacity'], rows=5
plant: cols=['bus_id', 'type', 'marginal_cost', 'inv_cost', 'max_capacity'], rows=5
storage: cols=['bus_id', 'inv_cost_power', 'inv_cost_energy', 'max_capacity_energy', 'max_capacity_power'], rows=0)

Or look at the data frames directly (similar for storage). Note the indexes are not required, that's an artifact of using the existing grid as an example:

In [11]: ec.plant
Out[11]:
           bus_id   type  marginal_cost  inv_cost  max_capacity
plant_id
12875     3001004   wind              4       NaN           NaN
12876     3001006   wind              4       NaN           NaN
12877     3001009   wind              4       NaN           NaN
12878     3001011  solar              4       NaN           NaN
12879     3001021   wind              4       NaN           NaN

In [12]: ec.branch
Out[12]:
           from_bus   to_bus  inv_cost  max_capacity
branch_id
100915      3001001  3001064       NaN           NaN
100916      3001001  3001064       NaN           NaN
100917      3001001  3001071       NaN           NaN
100918      3001001  3001071       NaN           NaN
100919      3001002  3001007       NaN           NaN

Time estimate

30 min

@jenhagg jenhagg self-assigned this Sep 9, 2022
@jenhagg jenhagg added the CEM Capacity Expansion Modeling label Sep 9, 2022
:param pd.DataFrame storage: dataframe of storage candidates
:param powersimdata.input.grid.Grid grid: reference grid
"""
check_bus_id(storage.bus_id, grid)
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems that all these functions could be used in a PCM workflow and hence could live in the powersimdata.input.check module. To illustrate, we could use these functions when adding new storage, branches, plants and storage in the change table.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had the same thought but didn't want to expand the scope. The bus id check could be easy to refactor. I just noticed we have a function _check_line_voltages already but that is used to check the consistency of an existing grid, so we would have to refactor it (or add a separate function) to compare new branches with a given bus dataframe. I'm not seeing a check for that in the change table - is that something we should have? If it's missing, that might be worth adding, but I was planning to hold off on refactoring until there is a bit more cem progress.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good.

I believe we check that the bus(es) exist when adding a new line, a plant or a storage in the change table. You are right, we don't check the voltages. It could be added.

Copy link
Collaborator

@rouille rouille left a comment

Choose a reason for hiding this comment

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

Looks good

Copy link
Collaborator

@BainanXia BainanXia left a comment

Choose a reason for hiding this comment

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

Recall our discussion of data structures to incorporate multiple investment years in CEM. We will either do ec_all[year] = ec or having columns for each year in candidate data frames. With this implementation, I presume we lean towards the former.

@jenhagg
Copy link
Collaborator Author

jenhagg commented Sep 16, 2022

Recall our discussion of data structures to incorporate multiple investment years in CEM. We will either do ec_all[year] = ec or having columns for each year in candidate data frames. With this implementation, I presume we lean towards the former.

Yeah I hadn't figured that part out yet, but I think adding the columns makes sense, and usually prefer not to duplicate data.

@jenhagg jenhagg merged commit a4241ef into develop Sep 16, 2022
@jenhagg jenhagg deleted the jen/cem branch September 16, 2022 20:08
@jenhagg jenhagg mentioned this pull request Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CEM Capacity Expansion Modeling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants