feat: improve flexibility of MW-miles calculation, for Create state and new branches#463
Conversation
|
I have two questions regarding the logic:
|
For (1), I agree, maybe we want to keep TransformGrid the way it is so that there is no confusion where the user specifies one branch capacity and then it gets zone-scaled. I remember conversations with you and @rouille along those same lines for plants. For (2), |
89e9555 to
ec8590f
Compare
|
I've removed the re-ordering of the TransformGrid so that this PR can be more focused. I have follow-up ideas about the TransformGrid, but I will save them for a separate issue. |
b7b3b74 to
5fc4afd
Compare
| upgrades["num_transformers"] += 1 | ||
| else: | ||
| raise Exception("Unknown branch: " + str(b)) | ||
| raise Exception("Unknown branch type: " + str(b)) |
There was a problem hiding this comment.
Would it be helpful to include the unknown branch type device_type in the error message and clarify that b is the branch id?
There was a problem hiding this comment.
This else is more for debugging than anything else, since the code should never in normal operation get here. There are no branch device types in our current grid model that are not covered by these three options.
| upgraded_branch_ids = set(ct["branch"]["branch_id"].keys()) | ||
| transformed_branch = TransformGrid(original_grid, ct).get_grid().branch | ||
| if "new_branch" in ct: | ||
| upgraded_branch_ids |= set(transformed_branch.index) |
There was a problem hiding this comment.
Am I reading this correctly - we could technically use upgraded_branch_ids = set(transformed_branch.index) to begin with, but in the case where there are no new branches, it's easier to just grab the scaled branch ids from the change table since there will be fewer to consider?
There was a problem hiding this comment.
Good catch, I made a mistake when simplifying something here. We don't want the full transformed branch index, we want the entries in the change table plus any new entries, which is the difference between the transformed branch and the base one. I've pushed a commit to fix.
2877995 to
c599b9f
Compare
Purpose
Allow branches not in the base grid to be scaled via the change table.EDIT: removed. See comment: feat: improve flexibility of MW-miles calculation, for Create state and new branches #463 (comment)What the code is doing
infoparameter to theScenario(see Allow calculate_mw_miles to be used for Scenario in Create state #457 for a discussion).In transform_grid.py: we move branch and DC line scaling after branch and DC line additions, to enable scaling of newly-added branches (we could equivalently scale the entries inEDIT: removed. See comment: feat: improve flexibility of MW-miles calculation, for Create state and new branches #463 (comment)"new_branch"and "new_dcline", but this way allowsscale_congested_mesh_branchesto continue to work without modifications even when it identifies that a branch not in the base grid should be upgraded).TransformGridclass to be able to easily calculate differences in branchrateAfor both scaled and new branches, and to automatically look up branch types, lats, and lons.TransformGridworks properly.Testing
All unit tests still pass, and calculations work as expected on Scenarios with new branches (see 3822 or 3828 for examples). Testing on previously-analyzed scenarios with lots of branch upgrades (existing branches only) still produces identical results.
Time estimate
15-30 minutes.