某三节点系统如下图所示。线路阻抗标幺值 $Z_{L}=j0.1,\frac{Y_{l}}{2}=j0.01$ ,节点1: $S_{1}=2.8653+j1.2244$ ,节点2:$P_{2}=0.6661,U_{2}=1.05$ ,节点3:$U_{3}=1,\theta=0$ ,用牛顿拉夫逊法和P-Q解耦法计算潮流。并计算线路功率 。


In [25]:
from  pypower.runpf import runpf
from numpy import array
from pypower.ppoption import ppoption


"""
    Power flow data for 3 bus, 2 gen case from CTS.
    Require pypower to run.
"""

from numpy import array

def case3():
    """Power flow data for 3 bus, 2 gen case from Cheng Tianshi.
    Please see L{caseformat} for details on the case file format.


    @return: Power flow data for 3 bus, 2 gen case from Cheng Tianshi.
    """
    ppc = {"version": '2'}
    ZL=0.1
    YL=0.02
    S1=2.8653+1.2244j
    P2=0.6661
    U2=1.05
    ##-----  Power Flow Data  -----##
    ## system MVA base
    ppc["baseMVA"] = 100
    S1=S1*ppc["baseMVA"]
    P2=P2*ppc["baseMVA"]
    ## bus data
    # bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin
    ppc["bus"] = array([
        [1, 1,S1.real,S1.imag,0, 0, 1, 1, 0, 110, 1, 1.1, 0.9],
        [2, 2, P2, 0, 0, 0, 1, 1, 0, 1, 110, 1.1, 0.9],
        [3, 3, 0, 0, 0, 0, 1, 1, 0, 1, 110, 1.1, 0.9]
    ])

    ## generator data
    # bus, Pg, Qg, Qmax, Qmin, Vg, mBase, status, Pmax, Pmin, Pc1, Pc2,
    # Qc1min, Qc1max, Qc2min, Qc2max, ramp_agc, ramp_10, ramp_30, ramp_q, apf
    ppc["gen"] = array([
         [2, 0,   0, 300, -300, U2, 100, 1, 250, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [3, 0,   0, 300, -300, 1, 100, 1, 250, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    ])

    ## branch data
    #fbus, tbus, r, x, b, rateA, rateB, rateC, ratio, angle, status, angmin, angmax
    ppc["branch"] = array([
        [1, 2, 0, ZL, YL, 0, 0, 0, 0, 0, 1, -360, 360],
        [1, 3, 0, ZL, YL, 0, 0, 0, 0, 0,  1, -360, 360],
        [2, 3, 0, ZL, YL, 0, 0, 0, 0, 0,  1, -360, 360]
    ])

    return ppc
ppopt=ppoption()
ppopt['PF_ALG']=1
ppopt['PF_MAX_IT']=10
ppopt['PF_TOL']=1e-3

result=runpf(casedata=case3(),ppopt=ppopt)


PYPOWER Version 5.0.0, 29-May-2015 -- AC Power Flow (Newton)


Newton's method power flow converged in 3 iterations.

Converged in 0.02 seconds
================================================================================
|     System Summary                                                           |
================================================================================

How many?                How much?              P (MW)            Q (MVAr)
---------------------    -------------------  -------------  -----------------
Buses              3     Total Gen Capacity     500.0        -600.0 to 600.0
Generators         2     On-line Capacity       500.0        -600.0 to 600.0
Committed Gens     2     Generation (actual)    353.1             204.7
Loads              2     Load                   353.1             122.4
  Fixed            2       Fixed                353.1             122.4
  Dispatchable     0       Dispatchable           0.0 of 0.0        0.0
Shunts             0     Shunt (inj)              0.0               0.0
Branches           3     Losses (I^2 * Z)         0.00             88.31
Transformers       0     Branch Charging (inj)     -                6.0
Inter-ties         0     Total Inter-tie Flow     0.0               0.0
Areas              1

                          Minimum                      Maximum
                 -------------------------  --------------------------------
Voltage Magnitude   0.948 p.u. @ bus 1          1.050 p.u. @ bus 2   
Voltage Angle     -12.61 deg   @ bus 1          0.00 deg   @ bus 3   
P Losses (I^2*R)             -                 -0.00 MW    @ line 1-2
Q Losses (I^2*X)             -                 48.43 MVAr  @ line 1-3

================================================================================
|     Bus Data                                                                 |
================================================================================
 Bus      Voltage          Generation             Load        
  #   Mag(pu) Ang(deg)   P (MW)   Q (MVAr)   P (MW)   Q (MVAr)
----- ------- --------  --------  --------  --------  --------
    1  0.948  -12.606       -         -      286.53    122.44 
    2  1.050   -8.011      0.00    171.26     66.61      0.00 
    3  1.000    0.000*   353.14     33.49       -         -   
                        --------  --------  --------  --------
               Total:    353.14    204.75    353.14    122.44

================================================================================
|     Branch Data                                                              |
================================================================================
Brnch   From   To    From Bus Injection   To Bus Injection     Loss (I^2 * Z)  
  #     Bus    Bus    P (MW)   Q (MVAr)   P (MW)   Q (MVAr)   P (MW)   Q (MVAr)
-----  -----  -----  --------  --------  --------  --------  --------  --------
   0      1      2    -79.72    -94.73     79.72    109.61    -0.000     16.88
   1      1      3   -206.81    -27.71    206.81     74.24    -0.000     48.43
   2      2      3   -146.33     61.64    146.33    -40.75    -0.000     22.99
                                                             --------  --------
                                                    Total:     0.000     88.31

In [26]:
from math import cos ,sin,radians
cp=lambda m,d: complex(m*cos(radians(d)),m*sin(radians(d)))
U1=cp(0.948,-12.6)
U2=cp(1.05,-8.011)
Y12=10j
Y10=0.01j
S12=(U1**2)*Y10.conjugate()+(U1*(U1.conjugate()-U2.conjugate())*Y12.conjugate())
S12


Out[26]:
(0.7925687073958795+0.9269183189994782j)

In [27]:
ppopt['PF_ALG']=2
ppopt['PF_MAX_IT']=10
result=runpf(casedata=case3(),ppopt=ppopt)


PYPOWER Version 5.0.0, 29-May-2015 -- AC Power Flow (fast-decoupled, XB)


Fast-decoupled power flow converged in 4 P-iterations and 3 Q-iterations.

Converged in 0.01 seconds
================================================================================
|     System Summary                                                           |
================================================================================

How many?                How much?              P (MW)            Q (MVAr)
---------------------    -------------------  -------------  -----------------
Buses              3     Total Gen Capacity     500.0        -600.0 to 600.0
Generators         2     On-line Capacity       500.0        -600.0 to 600.0
Committed Gens     2     Generation (actual)    353.1             204.7
Loads              2     Load                   353.1             122.4
  Fixed            2       Fixed                353.1             122.4
  Dispatchable     0       Dispatchable           0.0 of 0.0        0.0
Shunts             0     Shunt (inj)              0.0               0.0
Branches           3     Losses (I^2 * Z)         0.00             88.30
Transformers       0     Branch Charging (inj)     -                6.0
Inter-ties         0     Total Inter-tie Flow     0.0               0.0
Areas              1

                          Minimum                      Maximum
                 -------------------------  --------------------------------
Voltage Magnitude   0.948 p.u. @ bus 1          1.050 p.u. @ bus 2   
Voltage Angle     -12.61 deg   @ bus 1          0.00 deg   @ bus 3   
P Losses (I^2*R)             -                 -0.00 MW    @ line 1-2
Q Losses (I^2*X)             -                 48.43 MVAr  @ line 1-3

================================================================================
|     Bus Data                                                                 |
================================================================================
 Bus      Voltage          Generation             Load        
  #   Mag(pu) Ang(deg)   P (MW)   Q (MVAr)   P (MW)   Q (MVAr)
----- ------- --------  --------  --------  --------  --------
    1  0.948  -12.606       -         -      286.53    122.44 
    2  1.050   -8.011      0.00    171.22     66.61      0.00 
    3  1.000    0.000*   353.14     33.45       -         -   
                        --------  --------  --------  --------
               Total:    353.14    204.67    353.14    122.44

================================================================================
|     Branch Data                                                              |
================================================================================
Brnch   From   To    From Bus Injection   To Bus Injection     Loss (I^2 * Z)  
  #     Bus    Bus    P (MW)   Q (MVAr)   P (MW)   Q (MVAr)   P (MW)   Q (MVAr)
-----  -----  -----  --------  --------  --------  --------  --------  --------
   0      1      2    -79.71    -94.70     79.71    109.58    -0.000     16.87
   1      1      3   -206.82    -27.68    206.82     74.21    -0.000     48.43
   2      2      3   -146.33     61.64    146.33    -40.75    -0.000     22.99
                                                             --------  --------
                                                    Total:     0.000     88.30