Skip to main content

solve_batch_block_diagonal

Function solve_batch_block_diagonal 

Source
pub fn solve_batch_block_diagonal<S: LinearSolver>(
    buses_template: &[Bus],
    ybus: &YBusSparse,
    scenarios: &[Scenario],
    tol: f64,
    max_iter: usize,
) -> Vec<BdeScenarioResult>
Expand description

Runs Newton-Raphson on all scenarios at once through a single stacked sparse factorization per iteration, with per-scenario convergence masking.

Scenarios converge at different iteration counts and some contingency scenarios never converge at all, which makes masking a hard requirement rather than an optimization. A scenario that has converged (or gone singular, or hit max_iter) is masked out by writing an identity into its block — its Δx is then exactly zero and it stops moving, while every other scenario continues undisturbed and the stacked matrix keeps the pattern its cached symbolic factorization was built for.

Returns one result per scenario, in scenario order.

Unlike crate::batch::BatchSolver this does not partition islands — it is an architecture validator for the GPU path, not a production entry point. Use BatchSolver for real work on a CPU.