Ask Your Question
0

Get Q of fictious generator, QV curve

asked 2014-10-07 06:10:58 -0600

Cao Huy gravatar image

updated 2014-10-08 05:24:15 -0600

Hi, folks. I am trying to do multiple QV analyses and wirte data to csv file. Data contain Vsetpoint and Q of fictious generator, write along columns. But when I used:

ierr, cval = psspy.notona(node)
rlst = pssarrays.qv_solution(qvfile1, colabel)
v = rlst.vsetpoint
q = (rlst.mgenmvar)

I got q with size (199*length(v)) more bigger than what I expected (1 * length(v)). All of my monitored buses in .mon file are type 1, so I just don't know why it is so big. Is there anyway to get q of fictious generator contacted with the interested bus in those data or just an simpler way to get direct Q without relating to rlst.mgenmvar.

Also, I got an error message when try to do second interation. It is TypeError: 'float' object is not iterable in

for row,vol in zip(rows,V):
    row.append(vol)
for row,mvar in zip(rows,Q):
    rows.append(mvar)

Here is my code( I edited from code in https://psspy.org/psse-help-forum/que...).

# created by: Waltter Valdez


import sys, os
sys.path.insert(0, r"C:\Program Files\PTI\PSSE33\PSSBIN")
# xx --> substitute xx with Version Number here.
os.environ['PATH'] = r"C:\Program Files\PTI\PSSE33\PSSBIN" + ";" + os.environ['PATH']
#import redirect
#redirect.psse2py()
# this redirects PSS(R)E progress, report output to Python Shell/Console

import psspy
_i = psspy.getdefaultint()
_f = psspy.getdefaultreal()
_s = psspy.getdefaultchar()
import pssarrays
#import matplotlib.pyplot as plt
import csv

psspy.psseinit(50000)

Ruta = os.getcwd()
cases = ('savnw','')
"""Do not remove the single quotes from the end, these allow you to use the
python even a single scenario """

archSub = Ruta + '\\' + 'savnw.sub'
archMon = Ruta + '\\' + 'savnw.mon'
archCon = Ruta + '\\' + 'savnw.con'

nodes = (153,154)
"""# Nodes must be entered in the numbers of the buses in which
you want to get the QV curves"""

#psspy.progress_output(2, 'reportePro', [2, 0])
# Create cases and QV governor
for caseN in cases:
    if caseN != '':
        carpeta = Ruta + '\\' + caseN
        if not os.path.isdir(carpeta):
            os.makedirs(carpeta)
        case = Ruta + '\\' + caseN + '.sav'
        Difaxx = carpeta + '\\' + 'Difaxx-' + caseN + '.dfx'
        progress = carpeta + '\\' + 'progress_' + caseN + '.txt'
        psspy.progress_output(2, progress, [2, 0])
        psspy.case(case)

        psspy.fnsl([1, 0, 0, 1, 1, 0, 0, 0])
        psspy.dfax([1, 1], archSub, archMon, archCon, Difaxx)
        rows=[]
        count=0
        for node in nodes:
            count+=1
            psspy.case(case)
            node1 = str(node)
            archivoqv = carpeta + '\\' + 'QV_' + node1
            ierr2 = psspy.qv_engine_4([0, 0, 0, 0, 0, 0, 1, 1, 0, 1, node, 0, 0],
                [0.5, 1.05, 0.5, 0.01],"",Difaxx,"","",archivoqv,"")
            if ierr2 != 0:
                continue
            # Change these values as required.
            qvfile = 'QV_' + node1 + ".qv"
            qvfile1 = carpeta + '\\''QV_' + node1 + ".qv"
            Q=['Q(MVAr))']
            V=['V'+'_'+str(node)]
            Contingencies = pssarrays.qv_summary(qvfile1).colabel
            colabel=Contingencies[0]
            ierr, cval = psspy.notona(node)
            rlst = pssarrays.qv_solution(qvfile1, colabel)
            v = rlst.vsetpoint
            q = rlst.mgenmvar
            Q.extend(q)
            V.extend(v)
            if count==1:
                rows=[]
                for q,v in zip(Q,V):
                    row=[q]
                    row.extend([v])
                    rows.append(row)
            else:
                for ...
(more)
edit retag flag offensive close merge delete

Comments

I changed another code from https://psspy.org/psse-help-forum/question/341/will-this-generate-a-qv-curve/ and It worked well. Thank Jervis. Still want to know how to get varlist by qv_solution.

Cao Huy gravatar imageCao Huy ( 2014-10-07 20:59:56 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2014-10-07 22:42:55 -0600

jconto gravatar image

Working on the savnw.sav case + *.mon, *.con & *.sub files (available in the examples folder of the psse installation) and load buses 153, 154:

In addition to your correction, "open the case" inside the node loop:

 for node in nodes:
        count+=1
        psspy.case(case)                #fresh copy of base case
        psspy.fnsl([1, 0, 0, 1, 1, 0, 0, 0])

I got a csv file after the run ends but cannot interpret its content. Please add more comments to explain the intended output.

edit flag offensive delete link more

Comments

Intended output is a csv file likes this: ('Q(MVAr)', 'V_153', 'Q(MVAr)','V_154') (1000, 1.05,1000, 1.05) (900, 1.04,900, 1.04) (800, 1.03, 800, 1.03) (700, 1.02,700, 1.02)

Cao Huy gravatar imageCao Huy ( 2014-10-07 23:46:21 -0600 )edit

And thank, I was so careless.

Cao Huy gravatar imageCao Huy ( 2014-10-08 05:52:00 -0600 )edit
0

answered 2014-10-08 05:49:59 -0600

Cao Huy gravatar image

updated 2014-10-09 05:00:22 -0600

I have checked the code again and saw that the 1st of each tuple in nested-tuple q is the fictious MVAr that I want to retrieve. So I have edited the code to run properly. Here it is. ( run with savnw file in the example folder of PSSE)

# created by: Waltter Valdez
#Edited by Huy Cao

import sys, os
sys.path.insert(0, r"C:\Program Files\PTI\PSSE33\PSSBIN")
# xx --> substitute xx with Version Number here.
os.environ['PATH'] = r"C:\Program Files\PTI\PSSE33\PSSBIN" + ";" + os.environ['PATH']
#import redirect
#redirect.psse2py()
# this redirects PSS(R)E progress, report output to Python Shell/Console

import psspy
_i = psspy.getdefaultint()
_f = psspy.getdefaultreal()
_s = psspy.getdefaultchar()
import pssarrays
#import matplotlib.pyplot as plt
import csv

psspy.psseinit(50000)

Ruta = os.getcwd()
cases = ('savnw','')
"""Do not remove the single quotes from the end, these allow you to use the
python even a single scenario """

archSub = Ruta + '\\' + 'savnw.sub'
archMon = Ruta + '\\' + 'savnw.mon'
archCon = Ruta + '\\' + 'savnw.con'

nodes = (153,154)
"""# Nodes must be entered in the numbers of the buses in which
you want to get the QV curves"""

#psspy.progress_output(2, 'reportePro', [2, 0])
# Create cases and QV governor
for caseN in cases:
    if caseN != '':
        carpeta = Ruta + '\\' + caseN
        if not os.path.isdir(carpeta):
            os.makedirs(carpeta)
        case = Ruta + '\\' + caseN + '.sav'
        Difaxx = carpeta + '\\' + 'Difaxx-' + caseN + '.dfx'
        progress = carpeta + '\\' + 'progress_' + caseN + '.txt'
        psspy.progress_output(2, progress, [2, 0])
        psspy.case(case)

        psspy.fnsl([1, 0, 0, 1, 1, 0, 0, 0])
        psspy.dfax([1, 1], archSub, archMon, archCon, Difaxx)
        rows=[]
        count=0
        for node in nodes:
            count+=1
            psspy.case(case)
            node1 = str(node)
            archivoqv = carpeta + '\\' + 'QV_' + node1
            ierr2 = psspy.qv_engine_4([0, 0, 0, 0, 0, 0, 1, 1, 0, 1, node, 0, 0],
                [0.5, 1.05, 0.5, 0.01],"",Difaxx,"","",archivoqv,"")
            if ierr2 != 0:
                continue
            # Change these values as required.
            qvfile = 'QV_' + node1 + ".qv"
            qvfile1 = carpeta + '\\''QV_' + node1 + ".qv"
            Q=['Q(MVAr))']
            V=['V'+'_'+str(node)]
            Contingencies = pssarrays.qv_summary(qvfile1).colabel
            colabel=Contingencies[0]
            ierr, cval = psspy.notona(node)
            rlst = pssarrays.qv_solution(qvfile1, colabel)
            v = rlst.vsetpoint
            q =list(rlst.mgenmvar)
            q1=[]
            for e in q:
                q1.append(e[0])
            Q.extend(q1)
            V.extend(v)
            if count==1:
                rows=[]
                for q,v in zip(Q,V):
                    row=[v]
                    row.extend([q])
                    rows.append(row)
            else:
                for row,vol in zip(rows,V):
                    row.append(vol)
                for row,mvar in zip(rows,Q):
                    row.append(mvar)                        
        Report = carpeta + '\\' + 'Report' + '.csv'
        csv_out = open(Report, 'wb')
        mywriter = csv.writer(csv_out)
        mywriter.writerows(rows)
            #plt.plot(v, q)
        csv_out.close()

Edit: But when I used the code for another file, I got a problem. It turned out that in some cases the fictious MVAr is another elements instead of 1st of each tuple in nested-tuple q. savnw case is just by coincidence.

edit flag offensive delete link more

Comments

Still don't know the meaning of other elements in rlst.mgenmvar.

Cao Huy gravatar imageCao Huy ( 2014-10-08 05:51:13 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

Stats

Asked: 2014-10-07 06:10:58 -0600

Seen: 722 times

Last updated: Oct 09 '14