-
Notifications
You must be signed in to change notification settings - Fork 40
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
feat: allow the user to remove lines, buses, plants, and DC lines #554
Conversation
6845812
to
2d1cd87
Compare
powersimdata/input/change_table.py
Outdated
for subkey, subdict in self.ct.get(k, {}).items() | ||
] | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you lost me here. What if modification
is a single element, i.e., table
is not plant
? Won't modification_keys[1:]
raise an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we'll just get an empty list:
>>> foo = ["a"]
>>> foo[1:]
[]
The current implementation is clunky for sure. If table == "plant"
, then we want to reliably create a tuple that includes all plant additions and plant scaling information. If table != "plant"
, we should be creating a tuple as before, just with one new top-level string entry for "new_bus"
or "new_branch"
or whatever.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if we should not, for readability, purpose have a modified_elements_tuple
for plants (within if table == "plants"
statement) and another one for the other (bus, branch, etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've refactored this a bit to try to make it a little clearer what's going on.
I guess at some point we should use the generators' type in the grid model (defined in
Same in the I wil take care of it in a follow up PR |
Should we update the |
Done. |
27e6a12
to
d0abf3d
Compare
Do you plan to remove the other objects (DC lines, plants, etc) in this PR? |
d0abf3d
to
5989d5f
Compare
Done. |
5989d5f
to
5b3b48d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I think it will be nice to develop some checks to ensure that demand does not exceed generation and so forth.
def _check_for_islanded_load_buses(self): | ||
"""Identifies buses with non-zero demand, with no connected lines, and warns.""" | ||
bus = self._get_transformed_df("bus") | ||
connected_buses = set().union( | ||
*[ | ||
set(self.grid.branch["from_bus_id"]), | ||
set(self.grid.branch["to_bus_id"]), | ||
set(self.grid.dcline["from_bus_id"]), | ||
set(self.grid.dcline["to_bus_id"]), | ||
] | ||
) | ||
load_buses = set(bus.query("Pd > 0").index) | ||
diff = load_buses - connected_buses | ||
if len(diff) > 0: | ||
print(f"Warning: load buses connected to no lines exist: {sorted(diff)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a neat check. Following the same logic, do we want to _check_for_islanded_generation_buses
, or a comprehensive check that covers all the potential disconnected issues when removing entries from the grid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are two levels of potential issues: branches or DC lines or plants that connect to non-existent buses will crash the simulation engine, but islanded load buses should be okay since the simulation engine will just shed the load and continue. That's why I had one check raise an exception, but the other just printed a warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. Thinking a little further, here is my list of potential issues:
- branches, DC lines, plants or storage that result in connecting to non-existent buses (error)
- removing entries makes the resultant grid multiple connected components (isolated load/generation buses are special cases in this situation)
- on each island, if load (we only know
Pd
instead of actual load anyways) > generation, it is okay since load shedding will take care of it (warning) - on each island, if
sum(Pmin)
> load, it will crash the engine, however, I'm not sure how to check this though (maybe also warning instead of error?).
- on each island, if load (we only know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pmin issues are also tricky since we're re-setting some Pmins within REISE.jl, which PowerSimData doesn't know about. If we add generation spillage to REISE.jl that should take care of things I think, and make the big problem into a smaller once (since we'll eventually get to a feasible solution).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will leave this thread open for future PRs.
e1d6f82
to
afe6366
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
afe6366
to
1bbd03c
Compare
Pull Request doc
Purpose
Partial fulfilment ofCloses #423. Plants and DC lines can already be effectively removed by scaling them down to zero, this allows branches and buses to be removed as well. If we like the structure of the branch and bus removal, and want to enable full removal of plants, DC lines, storage, etc., then I can amend this PR to include those analogous methods as well.What the code is doing
Within the
ChangeTable
class:remove_bus
andremove_branch
, which check that the elements to be removed are actually in the grid before adding to the change table dictionary.remove_bus
has a check to ensure that a bus cannot be removed if there's at least one plant with non-zero capacity at it, and to implement this we modify_get_df_with_new_elements
so that if we request theplant
table, we apply any plant scaling.Within the
TransformGrid
class:"remove_bus"
and"remove_branch"
change table keys.Testing
New unit tests added.
Time estimate
15-30 minutes.