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

Corner cases catches #70

Merged
merged 10 commits into from
Jan 19, 2024
Merged

Corner cases catches #70

merged 10 commits into from
Jan 19, 2024

Conversation

jd-lara
Copy link
Member

@jd-lara jd-lara commented Jan 18, 2024

This PR addresses some bugs to catch corner cases exposed by the NTP data set.

@jd-lara jd-lara self-assigned this Jan 18, 2024
Copy link
Contributor

github-actions bot commented Jan 18, 2024

Performance Results

Version Precompile Time
Main 1.049109022
This Branch 1.054386853
Version Execute Time
Main-Build PTDF First 5.270918559
Main-Build PTDF Second 0.111224798
Main-Build Ybus First 0.373544996
Main-Build Ybus Second 0.007425593
Main-Build LODF First 1.216131939
Main-Build LODF Second 0.177557688
This Branch-Build PTDF First 5.219798597
This Branch-Build PTDF Second 0.107301006
This Branch-Build Ybus First 0.365615692
This Branch-Build Ybus Second 0.007276515
This Branch-Build LODF First 1.038142719
This Branch-Build LODF Second 0.299990418

Copy link

codecov bot commented Jan 18, 2024

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (2c988a8) 78.02% compared to head (f983a81) 77.93%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #70      +/-   ##
==========================================
- Coverage   78.02%   77.93%   -0.09%     
==========================================
  Files          15       15              
  Lines        1388     1396       +8     
==========================================
+ Hits         1083     1088       +5     
- Misses        305      308       +3     
Flag Coverage Δ
unittests 77.93% <80.00%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/ptdf_calculations.jl 93.06% <100.00%> (ø)
src/system_utils.jl 100.00% <100.00%> (ø)
src/virtual_lodf_calculations.jl 89.88% <100.00%> (ø)
src/virtual_ptdf_calculations.jl 88.76% <100.00%> (ø)
src/common.jl 93.37% <85.71%> (+0.64%) ⬆️
src/network_radial_reduction.jl 80.85% <60.00%> (-3.24%) ⬇️

Copy link

@GabrielKS GabrielKS left a comment

Choose a reason for hiding this comment

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

A few typos and minor things, some requests either for tests or notes about the lack of tests.

src/common.jl Outdated Show resolved Hide resolved
subnetworks::Dict{Int, Set{Int}},
ref_bus_positions::Set{Int},
ref_buses::Vector{Int},

Choose a reason for hiding this comment

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

Why is this now a Vector rather than a Set?

Copy link
Member Author

Choose a reason for hiding this comment

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

because before it was incorrectly using the ref buses positions and not the ref buses values.

src/network_radial_reduction.jl Outdated Show resolved Hide resolved
# system with small islands that represent larger interconnected areas.
if length(SparseArrays.nzrange(A, new_parent_val)) < 2
@warn "Bus $parent_bus_number Parent $new_parent_bus_number is a leaf node. Indicating there is an island."
push!(bus_reduction_map_index[parent_bus_number], new_parent_bus_number)

Choose a reason for hiding this comment

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

Would it be possible to get a test case of the element of the public interface that depends on this that fails without this change and passes with it? Nothing fails when I comment this line out.

Choose a reason for hiding this comment

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

or a # TODO or issue if this is too complicated to do on the current timeframe

Choose a reason for hiding this comment

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

Codecov concurs and points out a few other untested regions

Copy link
Member Author

Choose a reason for hiding this comment

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

I will create an issue to implement the test. This is a corner case catch.

src/network_radial_reduction.jl Outdated Show resolved Hide resolved
)
if j ∈ ref_bus_positions
Copy link

@GabrielKS GabrielKS Jan 18, 2024

Choose a reason for hiding this comment

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

I don't really understand why we're doing this, but that may be due to my lack of familiarity with PNM

Copy link
Member Author

Choose a reason for hiding this comment

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

We never want to reduce the reference buses. It creates issues depending on the model once we remove tha bus that is meant to absorb all the power differences.

sbn, ref_bus_positions = _find_subnetworks(sys)
return assign_reference_buses(sbn, ref_bus_positions)
sbn, ref_buses = _find_subnetworks(sys)
return assign_reference_buses!(sbn, ref_buses)

Choose a reason for hiding this comment

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

All the other existing assign_reference_buses calls have been edited to add a bus_ax_ref — this one doesn't need one?

Copy link
Member Author

Choose a reason for hiding this comment

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

in some cases we already have the references buses so there is no need to recalculate them based on the ref_ax and location.

src/common.jl Outdated Show resolved Hide resolved
@@ -336,6 +333,15 @@ function assign_reference_buses(
return bus_groups
end

function assign_reference_buses!(

Choose a reason for hiding this comment

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

Ideally we'd get a test case that demonstrates what breaks without this new layer of indirection — if too complicated to do now but potentially feasible in the future, add a # TODO or GitHub Issue

@GabrielKS
Copy link

Added #71 for the tests

@jd-lara jd-lara disabled auto-merge January 19, 2024 00:56
@jd-lara jd-lara merged commit 51c22ce into main Jan 19, 2024
9 checks passed
@jd-lara jd-lara deleted the jd/bugfix_ntp branch January 19, 2024 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants