pwrs.core.opf_power_balance_fcn#

pwrs.core.opf_power_balance_fcn.opf_power_balance_fcn(x, mpc, Ybus, mpopt, nargout=1)[source]#

Evaluate AC OPF power balance constraints and Jacobian.

Computes the nonlinear equality constraints enforcing real and reactive power balance at each bus for the current OPF state. When requested, it also returns the corresponding Jacobian with respect to the OPF decision variables.

Parameters:
  • x (sequence of array_like) – OPF state blocks. The layout matches MATPOWER: (Va, Vm, Pg, Qg) in polar form or (Vr, Vi, Pg, Qg) in cartesian form.

  • mpc (dict) – Internal MATPOWER case struct.

  • Ybus (sparse matrix) – Bus admittance matrix.

  • mpopt (MatpowerConfig) – Typed MATPOWER options configuration.

  • nargout (int, optional) – MATLAB compatibility flag controlling whether the Jacobian is returned.

Returns:

Constraint vector g containing stacked real and reactive power mismatches, and optionally its Jacobian dg.

Return type:

numpy.ndarray or tuple

pwrs.core.opf_power_balance_fcn.opf_power_balance_fcn_with_jacobian(x, mpc, Ybus, mpopt)[source]#

Evaluate power-balance constraints and return their Jacobian.

Parameters:

mpopt (MatpowerConfig)