Exemple #1
0
 def __init__(self):
     G = pd.read_csv('bus_config/Ybus_9_real', header=None)
     B = pd.read_csv('bus_config/Ybus_9_imag', header=None)
     self.G = G.values
     self.B = B.values
     self.num_bus = 9
     self.num_lines = 9
     self.network = pypsa.Network()
     ppc = case9()
     self.network.import_from_pypower_ppc(ppc)
     self.network.pf()
     self.bus_num = np.array(self.network.lines[['bus0', 'bus1']].values)
Exemple #2
0
def check_sol(n_out, r):
    (v_tol, pG_tol, qG_tol, br_tol) = tol_pf_sol.tol_pf_sol()
    voltage = r["bus"][:, 7]
    angle = r["bus"][:, 8]
    real_gen = r["gen"][:, 1]
    reactive_gen = r["gen"][:, 2]
    real_flow_fr = r["branch"][:, 13]
    real_flow_to = r["branch"][:, 15]
    reactive_flow_fr = r["branch"][:, 14]
    reactive_flow_to = r["branch"][:, 16]
    apparent_power_flow_fr = np.sqrt(real_flow_fr**2 + reactive_flow_fr**2)
    apparent_power_flow_to = np.sqrt(real_flow_to**2 + reactive_flow_to**2)
    temp = case9()
    nbus = len(temp["bus"])
    ngen = len(temp["gen"])
    nbr = len(temp["branch"])
    #flags for deviation
    flag_v = 0
    flag_p = 0
    flag_q = 0
    flag_l = 0
    #check voltage
    for i in range(0, nbus):
        if r["bus"][i, 7] < (1 - v_tol / 100) or r["bus"][i, 7] > (
                1 + v_tol / 100):
            flag_v += 1
    #check gen bounds
    for i in range(0, ngen):
        if r["gen"][i, 1] < (1 - pG_tol / 100) * temp["gen"][i, 9] or r["gen"][
                i, 1] > (1 + pG_tol / 100) * temp["gen"][i, 8]:
            flag_p += 1
        if r["gen"][i, 2] < (1 - qG_tol / 100) * temp["gen"][i, 4] or r["gen"][
                i, 2] > (1 + qG_tol / 100) * temp["gen"][i, 3]:
            flag_q += 1
    #check branch flows
    for i in range(0, nbr):
        if apparent_power_flow_fr[i] > (1 + br_tol / 100) * temp["branch"][
                i, 5] or (1 + br_tol / 100
                          ) * apparent_power_flow_to[i] > temp["branch"][i, 5]:
            flag_l += 1
    print_sim_results.print_sim_results(r["success"], n_out, r, flag_v, flag_p,
                                        flag_q, flag_l)
Exemple #3
0
els300 = cv.matrix(0, (N, 1), tc='d')
elsX300 = cv.matrix(0, (N, 1), tc='d')
time300 = cv.matrix(0, (N, 4), tc='d')

#for i in range(N):
#mySys = case300()
#start  = time.time()
#A, B, b, C, c = SystemInitPyPower(mySys)
#time300[i,1] = time.time() - start
#sol, I, t_solver, t_decomp = SDPsolver(A, B=B, b=b, C=C, c=c)
#time300[i,0] = time.time() - start
#time300[i,2] = t_decomp
#time300[i,3] = t_solver

for i in range(N):
    mySys = case9()
    start = time.time()
    A, B, b, C, c = SystemInitPyPower(mySys)
    time9[i, 1] = time.time() - start
    sol, I, t_solver, t_decomp = SDPsolver(A, B=B, b=b, C=C, c=c)
    time9[i, 0] = time.time() - start
    time9[i, 2] = t_decomp
    time9[i, 3] = t_solver

    mySys = case9()
    A, B, b, C, c = SystemInitPyPower(mySys)
    start = time.time()
    sol, e = SDPsolverX(A, C=C, c=c, B=B, b=b)
    elapsedX9[i] = (time.time() - start)
    elsX9[i] = e
Exemple #4
0
from pypower.api import case9, ppoption, runpf
import numpy as np

temp = case9()

temp = case9()
ppopt = ppoption(OUT_ALL=0)

(r, s) = runpf(temp, ppopt)
#(r, s) = runpf(temp)

voltage = r["bus"][:, 7]
angle = r["bus"][:, 8]

real_gen = r["gen"][:, 1]
reactive_gen = r["gen"][:, 2]

real_flow_fr = r["branch"][:, 13]
real_flow_to = r["branch"][:, 15]

reactive_flow_fr = r["branch"][:, 14]
reactive_flow_to = r["branch"][:, 16]

apparent_power_flow_fr = np.sqrt(real_flow_fr**2 + reactive_flow_fr**2)
apparent_power_flow_to = np.sqrt(real_flow_to**2 + reactive_flow_to**2)

print type(r["success"])

print(1 - 10.0 / 100)
Exemple #5
0
els300 = cv.matrix(0,(N,1),tc = 'd')
elsX300 = cv.matrix(0,(N,1),tc = 'd')
time300 = cv.matrix(0,(N,4),tc = 'd')

#for i in range(N):
    #mySys = case300()
    #start  = time.time()
    #A, B, b, C, c = SystemInitPyPower(mySys)
    #time300[i,1] = time.time() - start
    #sol, I, t_solver, t_decomp = SDPsolver(A, B=B, b=b, C=C, c=c)
    #time300[i,0] = time.time() - start
    #time300[i,2] = t_decomp
    #time300[i,3] = t_solver

for i in range(N):
    mySys = case9()
    start  = time.time()
    A, B, b, C, c = SystemInitPyPower(mySys)
    time9[i,1] = time.time() - start
    sol, I, t_solver, t_decomp = SDPsolver(A, B=B, b=b, C=C, c=c)
    time9[i,0] = time.time() - start
    time9[i,2] = t_decomp
    time9[i,3] = t_solver

    mySys = case9()
    A, B, b, C, c = SystemInitPyPower(mySys)
    start = time.time()
    sol, e = SDPsolverX(A,C=C,c=c, B=B, b=b)
    elapsedX9[i] = (time.time()- start)
    elsX9[i] = e
Exemple #6
0
from pypower.api import case9, ppoption, runpf, printpf
from constants import *
import numpy as np
# See http://rwl.github.io/PYPOWER/api/ for description of variables
'''
Slack Bus: At the slack bus, the voltage magnitude and angle are fixed and the power
    injections are free. There is only one slack bus in a power system.
Load Bus: At a load bus, or PQ bus, the power injections are fixed while the voltage
    magnitude and angle are free. There are M PQ buses in the system.
Voltage-Controlled Bus: At a voltage controlled bus, or PV bus, the real power
    injection and voltage magnitude are fixed while the reactive power injection
    and the voltage angle are free. (This corresponds to allowing a local source
    of reactive power to regulate the voltage to a desired setpoint.) There are
    N − M − 1 PV buses in the system.
'''
ppc = case9()
ppopt = ppoption(PF_ALG=2, VERBOSE=0, OUT_ALL=0)

r1, succeed = runpf(ppc, ppopt)
print("Success:", succeed)
ppc['gen'][2, PG] = 100000.0
r2, succeed = runpf(ppc, ppopt)
print("Success:", succeed)
Exemple #7
0
        C = 1 * Cbest
        pOption.remove(bestIdx)
        pIdx.append(bestIdx)

    pilotBus = [lIdx[i] for i in pIdx]

    return pilotBus






if __name__ == '__main__':
    print('-----------Start-----------')
    ppc, success = runpf(case9())
    ppc = ext2int(ppc)
    baseMVA = ppc['baseMVA']
    bus = ppc['bus']
    branch = ppc['branch']

    Ybus, Yf, Yt = makeYbus(baseMVA, bus, branch)

    vm = bus[:, VM]
    va = 2 * np.pi * bus[:, VA]
    V = vm * np.exp(1j * va)

    gIdx = [0, 1, 2]
    lIdx = [3, 4, 5, 6, 7, 8]

    nPilot = 2
from pypower.api import case9,runpf
from runPfOptions import ppoption
import const


succes=runpf(case9(),ppopt=ppoption());
# print(succes[0]['branch'])
print(succes[0]['bus'])
for branch in succes[0]['branch']:
    print branch[const.constOut['branch']["Pin"]]
    print branch[const.constOut['branch']["Pout"]]
print("done")