Skip to content

Conversation

@figueroa1395
Copy link
Member

@figueroa1395 figueroa1395 commented Oct 24, 2025

This PR is aimed to remove all the stuff related to preparing the calculation/solvers out of the main model. This PR should be an enabler to unit test the touched logic more easily, keep trimming the main model, and get it ready to remove everything related to the calculation logic in a followup.

Signed-off-by: Santiago Figueroa Manrique <[email protected]>
Signed-off-by: Santiago Figueroa Manrique <[email protected]>
Signed-off-by: Santiago Figueroa Manrique <[email protected]>
Signed-off-by: Santiago Figueroa Manrique <[email protected]>
Signed-off-by: Santiago Figueroa Manrique <[email protected]>
@figueroa1395 figueroa1395 self-assigned this Oct 24, 2025
@figueroa1395 figueroa1395 added improvement Improvement on internal implementation do-not-merge This should not be merged labels Oct 24, 2025
Signed-off-by: Santiago Figueroa Manrique <[email protected]>
Copy link
Member

@mgovers mgovers left a comment

Choose a reason for hiding this comment

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

This is a global review, not an in-depth one. Awesome cleanup!

namespace power_grid_model {
struct SolverPreparationContext {
main_core::MathState math_state;
Idx n_math_solvers{0};
Copy link
Member

Choose a reason for hiding this comment

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

Is it required to keep n_math_solvers?
Is it ever not equivalent to math_state.topology.size()?

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 removed it (in 4f0d589) in favor of a helper function that does the calling from state.math_topology.size() indeed. It should be fine and

assert(n_math_solvers == static_cast<Idx>(main_core::get_y_bus<sym>(solver_context.math_state).size()));|

still remains as a sanity check.

Let me know what you think.

Copy link
Member

Choose a reason for hiding this comment

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

i think this is indeed legacy from the era when we would re-use a math solver when our amount of connected components in the grid remained the same, even when our topology changed (i.e. we would reuse preallocated math solver memory, but it doesn't make sense because the elephant in the room is not the math solver but the y bus structure/topology. therefore, we changed that)

as long as our cache invalidation works correctly, with the current state of the code base, that should work as intended

Signed-off-by: Santiago Figueroa Manrique <[email protected]>
Signed-off-by: Santiago Figueroa Manrique <[email protected]>
Signed-off-by: Santiago Figueroa Manrique <[email protected]>
@figueroa1395 figueroa1395 removed the do-not-merge This should not be merged label Oct 29, 2025
@figueroa1395 figueroa1395 marked this pull request as ready for review October 29, 2025 08:54
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement on internal implementation

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants