First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!

Ask Your Question
0

Pgen per owner & area

asked Oct 7 '4

Yoyo gravatar image

updated Oct 7 '4

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.

3 answers

Sort by » oldest newest most voted
0

answered Oct 11 '4

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])
link

Comments

Very good 👍 thanks!

Yoyo gravatar imageYoyo (Oct 11 '4)

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 (Oct 11 '4)

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

perolofl gravatar imageperolofl (Oct 11 '4)
0

answered Oct 10 '4

Yoyo gravatar image

updated Oct 11 '4

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

link
0

answered Oct 10 '4

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.

link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.
Want to format code in your answer? Here is a one minute demo on Youtube

Add Answer

[hide preview]

Question Tools

1 follower

Stats

Asked: Oct 7 '4

Seen: 280 times

Last updated: Oct 11 '24