Naming conventions: “solver” vs “algorithm”
This page explains how the terms solver and algorithm are used in
LightSim2Grid, and how to read and build the names of the
AlgorithmType enum values and the corresponding
Python classes.
Three distinct meanings of “solver”
The word solver appears in three different contexts in LightSim2Grid, and they should not be confused:
The linear solver — a numerical library that solves a sparse linear system
eg at each Newton-Raphson iteration.
Examples: SparseLULinearSolver(Eigen built-in), KLU (SuiteSparse), NICSLU, CKTSO. These names end inLinearSolverin C++.The powerflow algorithm — the outer numerical method used to solve the power-flow equations. Examples: Newton-Raphson (NR), DC approximation, Fast-Decoupled Power Flow (FDPF), Gauss-Seidel. Each algorithm can use one linear solver internally (where applicable). This is what
AlgorithmTypeenumerates, and whatAlgorithmSelectordispatches.Solver bus numbering — the compact internal bus index used by the sparse matrices, which only includes connected buses (not disconnected ones). Methods like
get_Ybus_solver(),get_pv_solver(),id_me_to_ac_solver()etc. use “solver” in this third sense. These are low-level diagnostic accessors; the naming is intentionally kept for clarity.
How AlgorithmType enum names are built
Each enum value encodes both the outer powerflow algorithm and the linear solver library used for its internal linear algebra. The naming pattern is:
{Algorithm}_{LinearSolver}
Where the algorithm prefix is:
Prefix |
Meaning |
|---|---|
|
Newton-Raphson with distributed (multi-) slack |
|
Newton-Raphson with single slack (slightly faster when only one slack bus exists) |
|
DC approximation (linearised power flow) |
|
Fast-Decoupled Power Flow, XB variant ( |
|
Fast-Decoupled Power Flow, BX variant ( |
And the linear-solver suffix is:
Suffix |
Library |
|---|---|
|
Eigen’s built-in sparse LU — always available, no extra dependency |
|
SuiteSparse KLU — available when lightsim2grid is compiled with KLU support |
|
NICSLU — requires a license and a source build |
|
CKTSO — requires a license and a source build |
Special cases (no linear solver choice):
GaussSeidelAlgo— the Gauss-Seidel iterative method. No sparse factorisation is involved.GaussSeidelSynchAlgo— synchronous (all-buses-at-once) Gauss-Seidel variant.
Complete table
|
Python class |
Description |
|---|---|---|
|
|
NR multi-slack + SparseLU (default when KLU unavailable) |
|
|
NR single-slack + SparseLU |
|
|
DC + SparseLU |
|
|
Fast-Decoupled XB + SparseLU |
|
|
Fast-Decoupled BX + SparseLU |
|
|
NR multi-slack + KLU (default when KLU available) |
|
|
NR single-slack + KLU |
|
|
DC + KLU |
|
|
Fast-Decoupled XB + KLU |
|
|
Fast-Decoupled BX + KLU |
|
|
NR multi-slack + NICSLU (requires license) |
|
|
NR single-slack + NICSLU (requires license) |
|
|
DC + NICSLU (requires license) |
|
|
Fast-Decoupled XB + NICSLU |
|
|
Fast-Decoupled BX + NICSLU |
|
|
NR multi-slack + CKTSO (requires license) |
|
|
NR single-slack + CKTSO (requires license) |
|
|
DC + CKTSO (requires license) |
|
|
Fast-Decoupled XB + CKTSO |
|
|
Fast-Decoupled BX + CKTSO |
|
|
Gauss-Seidel iterative (no sparse factorisation) |
|
|
Synchronous Gauss-Seidel iterative |
Usage example
import lightsim2grid
from lightsim2grid.algorithm import AlgorithmType
env = grid2op.make("l2rpn_case14_sandbox", backend=lightsim2grid.LightSimBackend())
# switch to NR with KLU (if available)
env.backend.set_algo_type(AlgorithmType.NR_KLU)
# inspect what algorithm is currently active
print(env.backend.get_algo_types())
# >>> (<AlgorithmType.NRSing_KLU: 7>, <AlgorithmType.DC_KLU: 9>)
# list all algorithms available in this build
env.backend._grid.available_algorithm_names()
Note
The method is called change_algorithm(type) in the C++ LSGrid
Python binding (env.backend._grid.change_algorithm(AlgorithmType.NR_KLU)),
consistent with pandapower’s algorithm= parameter and MATPOWER’s
pf.alg option.
Migration from old names
Before version 0.14, the enum values and class names used shorter names that
did not make the algorithm component explicit (KLU, SparseLU, DC,
etc.). These old names are kept as deprecated aliases in the Python enum
so that existing code continues to work, but they will be removed in a future
release:
Old name (deprecated) |
New canonical name |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
See also
Available powerflow algorithms for performance comparisons and practical guidance on choosing an algorithm.