electricpy.sim.nr_pq

electricpy.sim.nr_pq(Ybus, V_set, P_set, Q_set, extend=True, argshape=False, verbose=False)[source]

Newton Raphson Real/Reactive Power Function Generator.

Given specified parameters, will generate the necessary real and reactive power functions necessary to compute the system’s power flow.

Parameters:
Ybus : array_like

Postitive Sequence Y-Bus Matrix for Network.

V_set : list of list of float

List of known and unknown voltages. Known voltages should be provided as a list of floating values in the form of: [mag, ang], unknown voltages should be provided as None.

P_set : list of float

List of known and unknown real powers. Known powers should be provided as a floating point value, unknown powers should be provided as None. Generated power should be noted as positive, consumed power should be noted as negative.

Q_set : list of float

List of known and unknown reactive powers. Known powers should be provided as a floating point value, unknown powers should be provided as None. Generated power should be noted as positive, consumed power should be noted as negative.

extend : bool, optional

Control argument to format returned value as singular function handle or lists of function handles. default=True; singular function

argshape : bool, optional

Control argument to force return of the voltage argument array as a tuple of: (Θ-len, V-len). default=False

verbose : bool, optional

Control argument to print verbose information about function generation, useful for debugging. default=False

Returns:

retset – An array of function handles corresponding to the appropriate voltage magnitude and angle calculation functions based on the real and reactive power values. Function(s) will accept an argument of the form: [Θ1, Θ2,…, Θn, V1, V2,…, Vm] where n is the number of busses with unknown voltage angle, and m is the number of busses with unknown voltage magnitude.

Return type:

array_like

Examples

>>> 
>>> import numpy as np
>>> from electricpy import sim # Import Simulation Submodule
>>> ybustest = [[-10j,10j],
...             [10j,-10j]]
>>> Vlist = [[1,0],[None,None]] # We don't know the voltage or angle at bus 2
>>> Plist = [None,-2.0] # 2pu watts consumed
>>> Qlist = [None,-1.0] # 1pu vars consumed
>>> F = nr_pq(ybustest,Vlist,Plist,Qlist)
>>> X0 = [0,1] # Define Initial Conditions
>>> J = sim.jacobian(F) # Find Jacobian
>>> # Now use Newton-Raphson to Solve
>>> results, iter = sim.NewtonRaphson(F,J,X0)
>>> print(results)
[-0.236,0.8554]
>>> print(iter) # Iteration Counter
4

See also

NewtonRaphson

Newton-Raphson System Solver

mbuspowerflow

Multi-Bus Power Flow Calculator