mp.net_model_ac

class mp.net_model_ac

Bases: mp.net_model

mp.net_model_ac - Abstract base class for MATPOWER AC network model objects.

Explicitly a subclass of mp.net_model and implicitly assumed to be a subclass of mp.form_ac as well.

mp.net_model_ac Properties:
  • zr - vector of real part of complex non-voltage states, \(\zr\)

  • zi - vector of imaginary part of complex non-voltage states, \(\zi\)

mp.net_model_ac Methods:

See also mp.net_model, mp.form, mp.form_ac, mp.nm_element.

Method Summary
def_set_types()

Add non-voltage state variable set types for mp_idx_manager.

nm.def_set_types()

Add the following set types:

  • 'zr' - NON-VOLTAGE VARS REAL (zr)

  • 'zi' - NON-VOLTAGE VARS IMAG (zi)

See also mp.net_model.def_set_types(), mp_idx_manager.

build_params(nm, dm)

Build incidence matrices and parameters, and add ports for each element.

nm.build_params(nm, dm)
Inputs:

Call the parent method to do most() of the work, then build the aggregate network model parameters and add the general nonlinear function terms, \(\Snln(\X)\) or \(\Inln(\X)\), for any elements that define them.

port_inj_nln(si, x_, sysx, idx)

Compute general nonlinear port injection functions and Jacobians

g = nm.port_inj_nln(si, x_, sysx, idx)
[g, gv1, gv2] = nm.port_inj_nln(si, x_, sysx, idx)
[g, gv1, gv2, gzr, gzi] = nm.port_inj_nln(si, x_, sysx, idx)

Compute and assemble the functions, and optionally Jacobians, for the general nonlinear injection functions \(\Snln(\X)\) and \(\Inln(\X)\) for the full aggregate network model, for all or a selected subset of ports.

Inputs:
  • si ('S' or 'I') – select power or current injection function:

    • 'S' for complex power \(\Snln(\X)\)

    • 'I' for complex current \(\Inln(\X)\)

  • x_ (complex double) – state vector \(\X\)

  • sysx (0 or 1) – which state is provided in x_

    • 0 – class aggregate state

    • 1 – (default) full system state

  • idx (integer) – (optional) vector of indices of ports of interest, if empty or missing, returns results corresponding to all ports

Outputs:
  • g (complex double) – nonlinear injection function, \(\Snln(\X)\) (or \(\Inln(\X)\))

  • gv1 (complex double) – Jacobian w.r.t. 1st voltage variable, \(\Snln_\Va\) or \(\Snln_\Vr\) (or \(\Inln_\Va\) or \(\Inln_\Vr\))

  • gv2 (complex double) – Jacobian w.r.t. 2nd voltage variable, \(\Snln_\Vm\) or \(\Snln_\Vi\) (or \(\Inln_\Vm\) or \(\Inln_\Vi\))

  • gzr (complex double) – Jacobian w.r.t. real non-voltage variable, \(\Snln_\zr\) (or \(\Inln_\zr\))

  • gzi (complex double) – Jacobian w.r.t. imaginary non-voltage variable, \(\Snln_\zi\) (or \(\Inln_\zi\))

See also port_inj_nln_hess().

port_inj_nln_hess(si, x_, lam, sysx, idx)

Compute general nonlinear port injection Hessian.

H = nm.port_inj_nln_hess(si, x_, lam)
H = nm.port_inj_nln_hess(si, x_, lam, sysx)
H = nm.port_inj_nln_hess(si, x_, lam, sysx, idx)

Compute and assemble the Hessian for the general nonlinear injection functions \(\Snln(\X)\) and \(\Inln(\X)\) for the full aggregate network model, for all or a selected subset of ports. Rather than a full, 3-dimensional Hessian, it computes the Jacobian of the vector obtained by muliplying the transpose of the corresponding Jacobian by a vector \(\lam\).

Inputs:
  • si ('S' or 'I') – select power or current injection function:

    • 'S' for complex power \(\Snln(\X)\)

    • 'I' for complex current \(\Inln(\X)\)

  • x_ (complex double) – state vector \(\X\)

  • lam (double) – vector \(\lam\) of multipliers, one for each port

  • sysx (0 or 1) – which state is provided in x_

    • 0 – class aggregate state

    • 1 – (default) full system state

  • idx (integer) – (optional) vector of indices of ports of interest, if empty or missing, returns results corresponding to all ports

Output:

H (complex double) – sparse Hessian matrix, \(\Snln_{\x\x}(\lam)\) or \(\Inln_{\x\x}(\lam)\)

See also port_inj_nln().

nodal_complex_current_balance(x_)

Compute nodal complex current balance constraints.

G = nm.nodal_complex_current_balance(x_)
[G, Gv1, Gv2, Gzr, Gzi] = nm.nodal_complex_current_balance(x_)

Compute constraint function and optionally the Jacobian for the complex current balance equality constraints based on outputs of mp.form_ac.port_inj_current() and the node incidence matrix.

Input:

x_ (complex double) – state vector \(\X\) (full system state)

Outputs:
  • G (complex double) – nodal complex current balance constraint function, \(\G^\mathrm{kcl}(\x)\)

  • Gv1 (complex double) – Jacobian w.r.t. 1st voltage variable, \(\G^\mathrm{kcl}_\Va\) or \(\G^\mathrm{kcl}_\Vr\)

  • Gv2 (complex double) – Jacobian w.r.t. 2nd voltage variable, \(\G^\mathrm{kcl}_\Vm\) or \(\G^\mathrm{kcl}_\Vi\)

  • Gzr (complex double) – Jacobian w.r.t. real non-voltage variable, \(\G^\mathrm{kcl}_\zr\)

  • Gzi (complex double) – Jacobian w.r.t. imaginary non-voltage variable, \(\G^\mathrm{kcl}_\zi\)

See also mp.form_ac.port_inj_current(), nodal_complex_current_balance_hess().

nodal_complex_power_balance(x_)

Compute nodal complex power balance constraints.

G = nm.nodal_complex_power_balance(x_)
[G, Gv1, Gv2, Gzr, Gzi] = nm.nodal_complex_power_balance(x_)

Compute constraint function and optionally the Jacobian for the complex power balance equality constraints based on outputs of mp.form_ac.port_inj_power() and the node incidence matrix.

Input:

x_ (complex double) – state vector \(\X\) (full system state)

Outputs:
  • G (complex double) – nodal complex power balance constraint function, \(\G^\mathrm{kcl}(\x)\)

  • Gv1 (complex double) – Jacobian w.r.t. 1st voltage variable, \(\G^\mathrm{kcl}_\Va\) or \(\G^\mathrm{kcl}_\Vr\)

  • Gv2 (complex double) – Jacobian w.r.t. 2nd voltage variable, \(\G^\mathrm{kcl}_\Vm\) or \(\G^\mathrm{kcl}_\Vi\)

  • Gzr (complex double) – Jacobian w.r.t. real non-voltage variable, \(\G^\mathrm{kcl}_\zr\)

  • Gzi (complex double) – Jacobian w.r.t. imaginary non-voltage variable, \(\G^\mathrm{kcl}_\zi\)

See also mp.form_ac.port_inj_power(), nodal_complex_power_balance_hess().

nodal_complex_current_balance_hess(x_, lam)

Compute nodal complex current balance Hessian.

d2G = nm.nodal_complex_current_balance_hess(x_, lam)

Compute the Hessian of the nodal complex current balance constraint. Rather than a full, 3-dimensional Hessian, it computes the Jacobian of the vector obtained by muliplying the transpose of the constraint Jacobian by a vector \(\lam\). Based on mp.form_ac.port_inj_current_hess().

Inputs:
  • x_ (complex double) – state vector \(\X\) (full system state)

  • lam (double) – vector \(\lam\) of multipliers, one for each node

Output:

d2G (complex double) – sparse Hessian matrix, \(\G^\mathrm{kcl}_{\x\x}(\lam)\)

See also mp.form_ac.port_inj_current_hess(), nodal_complex_current_balance().

nodal_complex_power_balance_hess(x_, lam)

Compute nodal complex power balance Hessian.

d2G = nm.nodal_complex_power_balance_hess(x_, lam)

Compute the Hessian of the nodal complex power balance constraint. Rather than a full, 3-dimensional Hessian, it computes the Jacobian of the vector obtained by muliplying the transpose of the constraint Jacobian by a vector \(\lam\). Based on mp.form_ac.port_inj_power_hess().

Inputs:
  • x_ (complex double) – state vector \(\X\) (full system state)

  • lam (double) – vector \(\lam\) of multipliers, one for each node

Output:

d2G (complex double) – sparse Hessian matrix, \(\G^\mathrm{kcl}_{\x\x}(\lam)\)

See also mp.form_ac.port_inj_power_hess(), nodal_complex_power_balance().

port_inj_soln()

Compute the network port power injections at the solution.

nm.port_inj_soln()

Takes the solved network state, computes the port power injections, and saves them in nm.soln.gs_.

get_va(idx)

Get node voltage angle vector.

va = nm.get_va()
va = nm.get_va(idx)

Get vector of node voltage angles for all or a selected subset of nodes. Values come from the solution if available, otherwise from the provided initial voltages.

Input:

idx (integer) – index of subset of voltages of interest; if missing or empty, include all

Output:

va (double) – vector of voltage angles