Ask Your Question
0

Pgen per owner & area

asked 2024-10-07 11:02:49 -0600

Yoyo gravatar image

updated 2024-10-07 11:20:15 -0600

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.

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
0

answered 2024-10-11 02:12:34 -0600

perolofl gravatar image

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])
edit flag offensive delete link more

Comments

Very good ๐Ÿ‘ thanks!

Yoyo gravatar imageYoyo ( 2024-10-11 02:15:55 -0600 )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 gravatar imageYoyo ( 2024-10-11 02:36:59 -0600 )edit

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

perolofl gravatar imageperolofl ( 2024-10-11 05:20:20 -0600 )edit
0

answered 2024-10-10 11:32:14 -0600

Yoyo gravatar image

updated 2024-10-11 02:38:16 -0600

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

edit flag offensive delete link more
0

answered 2024-10-10 11:18:02 -0600

jconto gravatar image

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.

edit flag offensive delete link more

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

1 follower

Stats

Asked: 2024-10-07 11:02:49 -0600

Seen: 264 times

Last updated: Oct 11