-
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
Add ability to add DC lines with different Pmin and Pmax #355
Conversation
powersimdata/input/change_table.py
Outdated
return | ||
elif ( | ||
if start == end: | ||
raise ValueError("buses of line #%d must be different" % (i + 1)) |
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.
We could rephrase the error message to be more explicit, e.g., buses at each extremity of line #%d must be different
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.
Is this a subset of the start lat/lon == end lat/lon
condition?
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.
Yes. Same bus will have same coordinates. So it can be removed since it will be satisfied by the check on the distance.
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.
Maybe we keep it for now, so that we don't forget to check when we expand this to be able to add transformers (which can be at the same lat/lon but not the same bus)? It doesn't hurt.
powersimdata/input/change_table.py
Outdated
if not isinstance(line[p], (int, float)): | ||
raise ValueError(f"'{p}' must be a number (int/float)") | ||
if line["Pmin"] > line["Pmax"]: | ||
raise ValueError("Pmin cannot be greater than Pmax") |
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.
Given either symmetric dclines or one-way dclines are supported, should we force "Pmin" to be greater or equal to 0 at this point?
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.
Let's give the user maximum flexibility. If they want to do a line bounded within [-100, 200], or [100, 200], let's let them.
Don't forget to update the README with this new feature and the previous one (new bus) |
98018af
to
ffcff81
Compare
Done. |
05bba1a
to
a3a513d
Compare
Integration testing has been successfully performed. I created two scenarios using this branch: one using the new feature, and one control. Common to both:
For the test scenario, I disabled the biggest HVDC line in the interconnect, and replaced it with a pair of opposing one-way lines:
Resulting in an anticipated DC line table of:
These were both run with the code in Breakthrough-Energy/REISE.jl#91. Let's see what we get!
As hoped, the new DC lines follow the bounds we have set for them, and the sum of the two of them is almost exactly equal (subject to some barrier cruft) to the behavior of the bi-directional line over the course of a one-month test! |
[{"lat": 48, "lon": -125, "zone_id": 201, "baseKV": 138}]) | ||
scenario.state.builder.change_table.add_dcline( | ||
[{"from_bus_id": 2090023, "to_bus_id": 20090024, "Pmin": 0, "Pmax": 200}]) | ||
|
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
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.
Looks good. Thanks for the test.
2cd2d70
to
70711dd
Compare
refactor: refactor TransformGrid to match new ChangeTable refactor: refactor tests for new ChangeTable/TransformGrid doc: add new change table features to README
refactor: use _check_new_entry in _add_line, add_plant, add_bus refactor: update ChangeTable tests to match new Exceptions
70711dd
to
1ed6ed2
Compare
Purpose
Add ability to add DC lines with different Pmin and Pmax from the ChangeTable. Along with #352, this will enable us to model 'hybrid' power plants.
Closes #342.
At the same time, refactor the checking of new additions to the Grid via the ChangeTable. A new function is added which systematically checks for the right combinations of keys, and incorrect values now induce ValueErrors, rather than printing and returning, which a careless user might overlook in the middle of a large script.
What the code is doing
In change_table.py:
ChangeTable._add_line
method is refactored to allow new entries to be specified with either {"capacity"
(for AC lines or DC)} or {"Pmax"
&"Pmin"
} (DC only) keys.ChangeTable._check_entry_keys
method is added to provide a consistent interface to check keys for"new_bus"
,"new_plant"
,"new_branch"
, and"new_dcline"
. Right now we aren't checking much when we add storage capacity, but in the future we will probably want to enhance it to be able to specify more things (e.g. power to energy ratio, efficiency, etc.) and that feature will be able to use this checking function as well.add_bus
,add_plant
, and_add_line
methods are updated to use the new_check_entry_keys
method for checking keys, and to raise ValueErrors when something is wrong rather than printing an error and returning (the appropriate entry is still cleared either way).In test_change_table.py:
test_add_dcline_Pmin_and_Pmax_success
test_add_dcline_Pmin_gt_Pmax
test_add_dcline_Pmin_and_Pmax_and_capacity
Pmin
andPmax
keys, rather thancapacity
:test_add_dcline_output
test_add_dcline_in_different_interconnect
capsys
, now they're expecting an exception with a certain text viawith pytest.raises(FooError) as excinfo
.In transform_grid.py, we interpret the new change table entries as appropriate.
Testing
Unit tests have been added for the new ways that we may specify DC lines.
Time estimate
Half an hour to an hour. There are a decent amount of changes, but mostly it's doing the same thing many times.