Ask Your Question
1

Changing pgen of all the machines at once and solve case for different pgen

asked 2013-09-19 03:53:09 -0600

anonymous user

Anonymous

I am learning python and I have some problems for programming what I want I would like to know how to change the power of all the machines (except from one of them which has Pgen>10 MW) at once. I have tried using machinedata2 , but I don't know the way to change all the machines' pgen I would like to solve the case for diferent values of power but changing the power of all the machines at once. Anybody of you could help me? Thank you!!

edit retag flag offensive close merge delete

Comments

I also try to change all the machine's Pgen, but if I change a large of data input the case may blown up or terminated!

Lam Nguyen gravatar imageLam Nguyen ( 2013-09-19 08:48:25 -0600 )edit

You are going to have to adjust either increase load, or decrease generation in other areas. It is likely blowing up because your swing bus(es) are going negative and having to suck up the extra generation you are providing and voltage is likely tanking near the swing gen.

EBahr gravatar imageEBahr ( 2013-09-19 09:57:36 -0600 )edit

First of all apologise for the delay in sending the answer. It works great! thanks a lot

ane gravatar imageane ( 2013-09-26 07:48:05 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
2

answered 2013-09-19 09:36:33 -0600

EBahr gravatar image

Here is a quick an dirty script that should do what you are requesting. It should distribute the increased MW evenly across all the machines (by percentage), and it also respects PMAX. If PMAX is reached on a machine, it will ignore that machine and the other machines will pick up a bit more. Modify the IGNORE_BUSES and AREA arrays to ignore your specified bus and to choose what areas you would like to include for the generation re-dispatch. Set REQUESTED_MW_INCREASE to the value you desire. This code is far from perfect, but should give you an idea of where to start.

IGNORE_BUSES = [1,2,3...] #Add any buses you want in here
REQUESTED_MW_INCREASE = 50
MW_TOLERANCE = .5 #Tolerance setting
FLAG = 1 #Set to 1 to only look at in-service buses with at least one in service machines
BSYS = 1
AREA = [1,2...] #Set to whatever area(s) you want to adjust

def get_generation():
    err = psspy.bsys(BSYS, 1, 1, 1, AREA)
    err, generator_numbers = psspy.amachint(BSYS,FLAG,['NUMBER'])
    err, generator_pgens = psspy.amachreal(BSYS,FLAG,['PGEN'])
    err, generator_pmaxs = psspy.amachreal(BSYS,FLAG,['PMAX'])
    pgen = 0 
    total_pmax = 0
    for i in range(len(generator_numbers[0])):    
        if generator_numbers[0][i] in IGNORE_BUSES: #SKIP IF IGNORED
            continue
        pgen = pgen + generator_pgens[0][i]
        total_pmax = total_pmax + generator_pmaxs[0][i]
    return pgen, total_pmax

def adjust_generation(percent):
    err = psspy.bsys(BSYS, 1, 1, 1, AREA)
    err, generator_numbers = psspy.amachint(BSYS,FLAG,['NUMBER'])
    err, generator_pgens = psspy.amachreal(BSYS,FLAG,['PGEN'])
    err, generator_pmaxs = psspy.amachreal(BSYS,FLAG,['PMAX'])
    err, generator_ids = psspy.amachchar(BSYS,FLAG,['ID'])
    gen_change = 0
    for i in range(len(generator_numbers[0])):    
        if generator_numbers[0][i] in IGNORE_BUSES: #SKIP IF IGNORED
            continue

        new_mw = generator_pgens[0][i] * percent
        if new_mw > generator_pmaxs[0][i]:
            new_mw = generator_pmaxs[0][i] #SET GEN TO PMAX IF REQUESTED AMOUNT IS GREATER THAN PMAX
            IGNORE_BUSES.append(generator_numbers[0][i]) #IGNORE NOW THAT MAXED

        ierr = psspy.machine_data_2(generator_numbers[0][i],generator_ids[0][i],[],[new_mw]) #CHANGE MW VALUE
        gen_change = gen_change + new_mw - generator_pgens[0][i]
    return gen_change

increase_mw = REQUESTED_MW_INCREASE  
cur_gen, total_pmax = get_generation()
new_gen = cur_gen + increase_mw

while abs(cur_gen - new_gen) > MW_TOLERANCE:    
    #EXIT IF NOT ENOUGH AVAILABLE GENERATION    
    if new_gen > total_pmax:
        print('Not enough available generation')
        break
    percent = new_gen / cur_gen
    change = adjust_generation(percent)    
    increase_mw = increase_mw - change
    cur_gen, total_pmax = get_generation()
    new_gen = cur_gen + increase_mw
edit flag offensive delete link more

Comments

1

All those calls to the subsystem data api can be replaced with this handy function: https://gist.github.com/jtrain/1158488 `subsystem_info('mach', ['NUMBER', 'PGEN', 'PMAX', 'ID'], bsys)`

JervisW gravatar imageJervisW ( 2013-09-28 02:53:06 -0600 )edit
1

answered 2013-09-28 00:59:48 -0600

yfwing gravatar image

I think that you can try psspy.scal_2.

Custome your subsystem definition to exclude the generators with Pgen greater than 10 MW.

But you need scale the loads or generators from different group in order to balance the power.

edit flag offensive delete link more

Comments

SCAL will scale a whole bunch of machines at once, but you could scale a specific subsystem that excludes the machines you don't want to scale.

JervisW gravatar imageJervisW ( 2013-09-28 02:50:02 -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

1 follower

Stats

Asked: 2013-09-19 03:53:09 -0600

Seen: 2,599 times

Last updated: Sep 28 '13