refactor: make PowerGridModelInterface._setup_model a public method#59
Merged
refactor: make PowerGridModelInterface._setup_model a public method#59
Conversation
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
|
Member
vincentkoppen
left a comment
There was a problem hiding this comment.
Looks good to me, would be nice to have some tests since it is now a public method.
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com> # Conflicts: # tests/integration/loadflow/test_power_grid_model.py
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
…blic # Conflicts: # tests/integration/loadflow/conftest.py # tests/integration/loadflow/test_power_grid_model.py
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
…nto feat/setup-model-public # Conflicts: # src/power_grid_model_ds/_core/load_flow.py
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
jaapschoutenalliander
approved these changes
Jul 18, 2025
Member
jaapschoutenalliander
left a comment
There was a problem hiding this comment.
The PR is fine, I do wonder what use case you have for making the method public?
# Conflicts: # tests/integration/loadflow/test_power_grid_model.py
|
Member
Author
Mostly to keep the code readable. def get_high_and_low_power_flow_results(grid) -> dict[str, dict]:
pgm = _setup_pgm_model(grid) # uses .setup_model()
pgm_output = {}
for peak_load in [PeakLoad.HIGH, PeakLoad.LOW]:
sources = get_sources(grid, peak_load)
sym_loads = get_loads_per_component(grid, peak_load)
pgm_output[peak_load] = _calculate_power_flow(pgm, sym_loads, source)
)
return pgm_output
def _calculate_power_flow(pgm: PowerGridModelInterface, sym_loads: np.ndarray, source: SourceArray) -> dict[str, np.ndarray]:
pgm.update_model(update_data={"sym_load": _get_sym_load_updates(sym_loads)})
pgm.update_model(update_data={"source": _get_source_updates(source)})
pgm.calculate_power_flow(calculation_method=CalculationMethod.linear)
return copy(pgm.output_data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



See title.