0

Pgen per owner & area

  • retag add tags

Hello everyone!

Is there a dedicated command that returns the total Pgen/Pmax/Pload for a certain owner in a specific "area"?

For example: to sum in area number 6 all the existing Pgen production for a certain owner. If there is no such command, what is the shortest way to do it?

Thanks in advance.

Yoyo's avatar
71
Yoyo
asked 2024-10-07 11:02:49 -0500, updated 2024-10-07 11:20:15 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

3 Answers

0

In a python script, open case and extract bus data and generator data into lists. Get the area and owner data in the bus data list for every generator bus and zip them to the generator data list. Finally, in a loop, select generator data for the target owner and area and add MW and MVAR into corresponding total.

jconto's avatar
2.9k
jconto
answered 2024-10-10 11:18:02 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

In the end I found something like this:

thanks!

Blockquote

def getgenerationdata(owner, selected_areas):

try:

total_pgen = 0

total_pmax = 0

areanumbers = [area[0] for area in selectedareas]

ierr = psspy.bsys(0, 0, [1.0, 220.], len(areanumbers), areanumbers, 0, [], 1, [owner], 0, [])

if error:

print(f"Error defining base system for owner {owner}: {ierr}")

return 0, 0, 0

ierr, pgen = psspy.amachreal(0, 1, 'PGEN') if error:

print(f"Error getting active supplier of {owner}: {ierr}") otherwise:

total_pgen = sum(pgen[0])

ierr, pmax = psspy.amachreal(0, 2, 'PMAX')

if error:

print(f"Error getting maximum power of {owner}: {ierr}") otherwise:

total_pmax = sum(pmax[0])

percentage = (totalpgen / totalpmax * 100) if total_pmax else 0

return totalpgen, totalpmax, percentage

except:

print(f"Unexpected error getting production data for owner {owner}: {sys.exc_info()[0]}") return 0, 0, 0

Blockquote

Yoyo's avatar
71
Yoyo
answered 2024-10-10 11:32:14 -0500, updated 2024-10-11 02:38:16 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

Here is a nice function returning the total for a specified subsystem:

def subssum(areas=[], zones=[], owners=[], buses=[], kv=[]):
    """ Returns total Pgen, Pmax and %-loading for generators in a subsystem"""
    kvopt = 0 if len(kv)==0 else 1
    psspy.bsys(11,kvopt,kv,len(areas),areas,len(buses),buses,len(owners),owners,len(zones),zones)
    ierr, pgen = psspy.amachreal(11, 1, 'PGEN')
    ierr, pmax = psspy.amachreal(11, 1, 'PMAX')
    if pgen is None: pgen = [[]]
    if pmax is None: pmax = [[]]
    pgtot = sum(pgen[0])
    pmtot = sum(pmax[0])
    pct = pgtot/pmtot*100 if pmtot > 0 else 0
    return pgtot, pmtot, pct

For example in savnw network the following returns the total for area 1 and 2 and owner 22:

pgtot, pmaxtot, pct = subssum(areas=[1,2],owners=[22])
perolofl's avatar
3.8k
perolofl
answered 2024-10-11 02:12:34 -0500
edit flag offensive 0 remove flag delete link

Comments

Very good 👍 thanks!

Yoyo's avatar Yoyo (2024-10-11 02:15:55 -0500) edit

I would appreciate it if someone could explain to me how to publish a piece of code in a code format. I tried but something must have gone wrong...🙏

Yoyo's avatar Yoyo (2024-10-11 02:36:59 -0500) edit

Select the text and click on tool "preformatted text", icon 101010 (or ctrl-k).

perolofl's avatar perolofl (2024-10-11 05:20:20 -0500) edit
add a comment see more comments

Your Answer

Login/Signup to Answer