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

wip: loss factor variable #1238

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

wip: loss factor variable #1238

wants to merge 10 commits into from

Conversation

rbolgaryn
Copy link

@rbolgaryn rbolgaryn commented Feb 7, 2025

Here we add the reading of the loss factors after a successful AC power flow calculation in PowerFlows as a new auxiliary variable PowerFlowLossFactors.

  • Create a new auxiliary variable PowerFlowLossFactors
  • Read the value from the results in PowerFlowData (only if calc_loss_factors was set to true in ACPowerFlow)
  • Test that the variable is present when calc_loss_factors is true and that it is not present when it is false. The values of loss factors are tested only in PowerFlows

This PR depends on NREL-Sienna/PowerFlows.jl#98

@rbolgaryn rbolgaryn requested a review from GabrielKS February 7, 2025 00:33
Copy link
Contributor

github-actions bot commented Feb 7, 2025

Performance Results

Version Precompile Time
Main 5.879957595
This Branch 5.960523661
Version Build Time
Main-Build Time Precompile 67.045061176
Main-Build Time Postcompile 0.842208046
This Branch-Build Time Precompile 67.057423338
This Branch-Build Time Postcompile 0.831067391
Version Build Time
Main-Solve Time Precompile 584.134345041
Main-Solve Time Postcompile 551.422622629
This Branch-Solve Time Precompile 967.068214332
This Branch-Solve Time Postcompile 929.240043402

test/test_simulation_results.jl Outdated Show resolved Hide resolved
src/network_models/power_flow_evaluation.jl Outdated Show resolved Hide resolved
rbolgaryn and others added 4 commits February 7, 2025 10:32
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Konar-Steenberg <[email protected]>
Copy link
Contributor

@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.

Looks pretty good, left a few comments. If this has a dependency on NREL-Sienna/PowerFlows.jl#98 or other PRs, can you note that in the PR description? Also can you add a description of what this PR does there for future reference?

src/PowerSimulations.jl Show resolved Hide resolved
test/test_simulation_results.jl Outdated Show resolved Hide resolved
test/test_simulation_results.jl Outdated Show resolved Hide resolved
# here we check if the loss factors are stored in the results, the values are tested in PowerFlows.jl
@test loss_factors !== nothing

loss_factors = first(
Copy link
Contributor

Choose a reason for hiding this comment

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

why are you getting the loss_factors two different ways?

Copy link
Author

Choose a reason for hiding this comment

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

Just to make sure it works. Should I remove one of them?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I would say that the correspondence between read_aux_variable and read_results_with_keys is/ought to be tested elsewhere, so you should only need one of them


# here we check if the loss factors are stored in the results, the values are tested in PowerFlows.jl
@test loss_factors !== nothing
@test nrow(loss_factors) == 576
Copy link
Contributor

@GabrielKS GabrielKS Feb 17, 2025

Choose a reason for hiding this comment

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

Where does 576 come from? Can we do ... == length(get_components(... or something instead to avoid hard-coding this?

Copy link
Author

Choose a reason for hiding this comment

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

It is 48 * 12 (see also line 1067). Do you have an idea where it is best to read it from?

Copy link
Author

Choose a reason for hiding this comment

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

It is coming from the file used ("export_48_12") so expressing it as 48 * 12 should be ok

Copy link
Contributor

Choose a reason for hiding this comment

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

48 * 12 works for me

src/network_models/power_flow_evaluation.jl Outdated Show resolved Hide resolved
Roman Bolgaryn and others added 3 commits February 17, 2025 18:14
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

@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.

Looks good aside from this one comment and the redundant test

src/network_models/power_flow_evaluation.jl Outdated Show resolved Hide resolved
# here we check if the loss factors are stored in the results, the values are tested in PowerFlows.jl
@test loss_factors !== nothing

loss_factors = first(
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I would say that the correspondence between read_aux_variable and read_results_with_keys is/ought to be tested elsewhere, so you should only need one of them


# here we check if the loss factors are stored in the results, the values are tested in PowerFlows.jl
@test loss_factors !== nothing
@test nrow(loss_factors) == 576
Copy link
Contributor

Choose a reason for hiding this comment

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

48 * 12 works for me

@rbolgaryn rbolgaryn requested a review from GabrielKS February 18, 2025 20:24
Copy link
Contributor

@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.

Looks good from a code quality standpoint. Ideally we'd release https://github.com/NREL-Sienna/PowerFlows.jl/pull/98/files and make sure the tests pass on the CI for this before merging it, but I'll let @jd-lara manage

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