commonpower.core.PowerFlowModel

class PowerFlowModel[source]

Bases: object

Generic class to model power flow constraints.

Methods

add_to_model

Specifies the power flow constraints and adds them to the given model instance.

empty_copy

Creates a fresh copy of the power flow model.

_set_bus_constraint(model: ConcreteModel, nid: int, node: Node, connected_lines: list[Line]) None[source]

Adds constraint for the given bus to the given model instance. Optional for subclasses.

Parameters:
  • model (ConcreteModel) – Pyomo root model (sys).

  • nid (int) – Node index.

  • node (Node) – Node instance.

  • connected_lines (list[Line]) – List of lines connected to the node.

_set_line_constraint(model: ConcreteModel, lid: int, line: Line)[source]

Adds constraint for the given bus to the given model instance. Optional for subclasses.

Parameters:
  • model (ConcreteModel) – Pyomo root model (sys).

  • lid (int) – Line index.

  • line (Line) – Line instance.

_set_sys_constraints(model: ConcreteModel, nodes: List[Node], lines: List[Line]) None[source]

Adds system-wide constraint(s) to the given model instance. Optional for subclasses.

Parameters:
  • model (ConcreteModel) – Pyomo root model (sys).

  • nodes (List[Node]) – Nodes to consider.

  • lines (List[Line]) – Lines to consider.

add_to_model(model: ConcreteModel, nodes: List[Node], lines: List[Line]) None[source]

Specifies the power flow constraints and adds them to the given model instance. This method is called by system.add_to_model().

Parameters:
  • model (ConcreteModel) – Pyomo root model (sys).

  • nodes (List[Node]) – Nodes to consider.

  • lines (List[Line]) – Lines to consider.

empty_copy() PowerFlowModel[source]

Creates a fresh copy of the power flow model.

Returns:

PowerFlowModel – Cloned power flow model instance.