Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The following script shows two functions that can be used to show the nominal reactive power for fixed and switched shunts respectively in Slider diagrams.

import psspy

def fixshuntq(ibus,id,string='NOM',unit='Mvar'):
    ierr, cmpval = psspy.fxsdt2(ibus, id ,string)
    if ierr>0: return 'Error %s: fixed shunt %s at bus %s' % (ierr,id,ibus)
    return str(round(cmpval.imag,1))+' '+unit

def swshuntb(ibus,string='BINIT',unit='Mvar'):
    ierr, rval = psspy.swsdt1(ibus,string)
    if ierr>0: return 'Error %s: switched shunt at bus %s' % (ierr,ibus)
    return str(round(rval,1))+' '+unit

If the script is called "owngrpg.py" the function to show the fixed capacitor is called in the following way: image description

Here the first two arguments defining the bus number and shunt id are entered, while the rest keep their default values. This writes the nominal value of the shunt to the diagram.

It is the same principle for a switched shunt (function swshuntb), but here only the bus number is given as argument.

The arguments string and unit make it possible to write any other quantity returned by fxsdt2 or swshuntb.

The following script shows two functions that can be used to show the nominal reactive power for fixed and switched shunts respectively in Slider diagrams.

import psspy

def fixshuntq(ibus,id,string='NOM',unit='Mvar'):
    ierr, cmpval = psspy.fxsdt2(ibus, id ,string)
    if ierr>0: return 'Error %s: fixed shunt %s at bus %s' % (ierr,id,ibus)
    return str(round(cmpval.imag,1))+' '+unit

def swshuntb(ibus,string='BINIT',unit='Mvar'):
    ierr, rval = psspy.swsdt1(ibus,string)
    if ierr>0: return 'Error %s: switched shunt at bus %s' % (ierr,ibus)
    return str(round(rval,1))+' '+unit

If the script is called "owngrpg.py" the function to show the fixed capacitor is called in the following way: image description

Here the first two arguments defining the bus number and shunt id are entered, while the rest keep their default values. This writes the nominal value of the shunt to the diagram.

It is the same principle for a switched shunt (function swshuntb), but here only the bus number is given as argument.

The arguments string and unit make it possible to write any other quantity returned by fxsdt2 or swshuntb.

EDIT: The total shunt contribution at a bus is written with the following function:

import psspy

def busshunt(ibus):
    ierr = psspy.inifxs(ibus)
    totq = 0.
    while True:
        ierr, id = psspy.nxtfxs(ibus)
        if ierr>0: break
        ierr, cmpval = psspy.fxsdt2(ibus, id ,'ACT')
        totq += -cmpval.imag
    ierr, binit = psspy.swsdt1(ibus,'BINIT')
    if ierr==0: 
        ierr, vpu = psspy.busdat(ibus ,'PU')
        totq += binit*vpu**2
    return str(round(totq,1))+' Mvar'

Here capacitors are written as positive reactive power. Change in code if you want opposite sign.