Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Will this generate a QV curve?

Hi All!

Please correct/improve this QV curve generating script.

# PSS/E Saved case
CASE = r"C:\Program Files\PTI\PSSE32\EXAMPLE\12TH_PLAN_MAR_2017R1.sav"
psspy.psseinit(12000)
psspy.case(CASE)

def getdata(subsystem_data):
    ierr, values = subsystem_data
    return zip(*values)

#--------------------------------
ierr = psspy.bsys(sid=1, numzone=1, zones=[44])
buses = reduce(tuple.__add__, getdata(psspy.abusint(sid=1, string="NUMBER")))
buskv = reduce(tuple.__add__, getdata(psspy.abusreal(sid=1, string="BASE")))
#print zip(buses, buskv)
selected_buses = []
for bus, voltage in zip(buses, buskv):
    if voltage > 100.0:
        selected_buses.append((bus))
print selected_buses

busno = 44999 # Fictitious generator bus
genid = 1
status = 1
pgen = 0.0 # Fict gen P output
Qlimit = 9999.0 # Fict. gen Q limit
pmax = 0.0 # Fict gen P limit
ireg = 44106 # Regulated bus for which QV curve is to be determined

def add_machine():
    psspy.plant_data(busno, intgar1=ireg)
    psspy.machine_data_2(
        busno,
        str(genid),
        [int(status), 1, 0, 0, 0, 0],
        [pgen, 0.0,
        Qlimit,
        -Qlimit,
        pmax, 0.0, 100.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0])
    return

def get_mvar(i):
    psspy.plant_data(busno, realar1=i)
    psspy.solution_parameters_3(intgar2=60)
    ierr = psspy.fnsl()
    mvar = psspy.macdat(busno, str(genid), 'Q')
    return mvar[1]

psspy.bus_data_2(busno, intgar1=2, name='TEST')
psspy.branch_data(i=busno, j=ireg)
add_machine()

import numpy as np
import matplotlib.pyplot as plt
pu = [x for x in np.arange(.8, 1.2, .05)]
varlist = [get_mvar(v) for v in pu]
print varlist
plt.plot(pu, varlist, '-o')
plt.xlabel('PU')
plt.ylabel('MVar')
plt.grid()
plt.show()