roseau.load_flow._solvers#

Module Contents#

Classes#

AbstractSolver

This is an abstract class for all the solvers.

AbstractNewton

This is an abstract class for all the Newton-Raphson solvers.

Newton

The classical Newton-Raphson algorithm.

NewtonGoldstein

The Newton-Raphson algorithm with the Goldstein and Price linear search. It has better stability than the

class AbstractSolver(network: ElectricalNetwork)#

Bases: abc.ABC

This is an abstract class for all the solvers.

AbstractSolver constructor.

Parameters:

network – The electrical network for which the load flow needs to be solved.

classmethod from_dict(data: JsonDict, network: ElectricalNetwork) typing_extensions.Self#

AbstractSolver constructor from dict.

Parameters:
  • data – The solver data.

  • network – The electrical network for which the load flow needs to be solved.

Returns:

The constructed solver.

solve_load_flow(max_iterations: int, tolerance: float) tuple[int, float]#

Solve the load flow for the network the solver was constructed with.

Parameters:
  • tolerance – Required tolerance value on the residuals for the convergence.

  • max_iterations – The maximum number of allowed iterations.

Returns:

The number of iterations and the final residual.

reset_inputs() None#

Reset the input vector (which is used for the first step of the newton algorithm) to its initial value

abstract update_network(network: ElectricalNetwork) None#

If the network has changed, we need to re-create a solver for this new network.

abstract update_params(params: JsonDict) None#

If the network has changed, we need to re-create a solver for this new network.

to_dict() JsonDict#

Return the solver information as a dictionary format.

params() JsonDict#

Return the parameters of the solver.

class AbstractNewton(network: ElectricalNetwork, optimize_tape: bool = DEFAULT_TAPE_OPTIMIZATION)#

Bases: AbstractSolver, abc.ABC

This is an abstract class for all the Newton-Raphson solvers.

AbstractNewton constructor.

Parameters:
  • network – The electrical network for which the load flow needs to be solved.

  • optimize_tape – If True, a tape optimization will be performed. This operation might take a bit of time, but will make every subsequent load flow to run faster.

save_matrix(prefix: str) None#

Output files of the jacobian and vector matrix of the first newton step. Those files can be used to launch an eigen solver benchmark (see https://eigen.tuxfamily.org/dox/group__TopicSparseSystems.html)

Parameters:

prefix – The prefix of the name of the files. They will be output as prefix.mtx and prefix_m.mtx to follow Eigen solver benchmark convention.

current_jacobian() ndarray#

Show the jacobian of the current iteration (useful for debugging)

class Newton(network: ElectricalNetwork, optimize_tape: bool = AbstractNewton.DEFAULT_TAPE_OPTIMIZATION)#

Bases: AbstractNewton

The classical Newton-Raphson algorithm.

Newton constructor.

Parameters:
  • network – The electrical network for which the load flow needs to be solved.

  • optimize_tape – If True, a tape optimization will be performed. This operation might take a bit of time, but will make every subsequent load flow to run faster.

update_network(network: ElectricalNetwork) None#

If the network has changed, we need to re-create a solver for this new network.

update_params(params: JsonDict) None#

If the network has changed, we need to re-create a solver for this new network.

class NewtonGoldstein(network: ElectricalNetwork, m1: float = DEFAULT_M1, m2: float = DEFAULT_M2, optimize_tape: bool = AbstractNewton.DEFAULT_TAPE_OPTIMIZATION)#

Bases: AbstractNewton

The Newton-Raphson algorithm with the Goldstein and Price linear search. It has better stability than the classical Newton-Raphson, without losing performance.

NewtonGoldstein constructor.

Parameters:
  • network – The electrical network for which the load flow needs to be solved.

  • optimize_tape – If True, a tape optimization will be performed. This operation might take a bit of time, but will make every subsequent load flow iteration to run faster.

  • m1 – The first constant of the Goldstein and Price linear search.

  • m2 – The second constant of the Goldstein and Price linear search.

update_network(network: ElectricalNetwork) None#

If the network has changed, we need to re-create a solver for this new network.

update_params(params: JsonDict) None#

If the network has changed, we need to re-create a solver for this new network.

params() JsonDict#

Return the parameters of the solver.