Ask Your Question
0

Problems running large number of simulations using same raw and dyr file

asked 2018-10-24 11:05:47 -0500

bikiran1991 gravatar image

I tried running around a 1000 different N-2 line outages followed by a fault on the savnw raw and dyr set using psspy. The script abruptly terminates after 800-900 simulations, with the following message in the output:

Array allocation failed in DYRE

Here is the gist of my script: It tries to run every event in simList. The event string itself contains the simulation info. I am guessing there is some memory allocation problem while using DYRE. Is there a way to change the script so that i dont have to read the dyr file for every simulation.

# Local imports
import redirect
import psspy
import dyntools
##### Get everything set up on the PSSE side
redirect.psse2py()



psspy.psseinit(buses=80000)
_i=psspy.getdefaultint()
_f=psspy.getdefaultreal()
_s=psspy.getdefaultchar()



for event in simList:
    #Parameters. 
    settings = {
    # #####################################
        'filename':rawFile,
    ################################################################################
        'dyr_file':dyrFile,
        'out_file':'output2.out',
        'pf_options':[
            0,  #disable taps
            0,  #disable area exchange
            0,  #disable phase-shift
            0,  #disable dc-tap
            0,  #disable switched shunts
            0,  #do not flat start
            0,  #apply var limits immediately
            0,  #disable non-div solution
        ]
    }


        ierr = psspy.read(0, settings['filename'])
        ierr = psspy.fnsl(settings['pf_options'])


        ##### Prepare case for dynamic simulation
        # Load conversion (multiple-step)
        psspy.conl(_i,_i,1,[0,_i],[_f,_f,_f,_f])
        psspy.conl(1,1,2,[_i,_i],[100.0, 0.0,0.0, 100.0]) 
        psspy.conl(_i,_i,3,[_i,_i],[_f,_f,_f,_f])


        ierr = psspy.cong(0) #converting generators
        ierr = psspy.ordr(0) #order the network nodes to maintain sparsity
        ierr = psspy.fact()  #factorise the network admittance matrix
        ierr = psspy.tysl(0) #solving the converted case
        ierr = psspy.dynamicsmode(0) #enter dynamics mode

        ierr = psspy.dyre_new([1,1,1,1], settings['dyr_file'])
        ierr=psspy.docu(0,1,[0,3,1]) #print the starting point of state variables

        # select time step ##############################################################
        ierr = psspy.dynamics_solution_params([_i,_i,_i,_i,_i,_i,_i,_i], [_f,_f,0.00833333333333333,_f,_f,_f,_f,_f], 'out_file') # the number here is the time step
        ################################################################################

        ##### select channels
        ierr = psspy.delete_all_plot_channels() # clear channels

        BusDataDict = getBusData(rawFile)
        # get all the bus voltages, angles and frequencies
        for bus  in BusDataDict:
            bus = int(bus)
            ierr = psspy.voltage_and_angle_channel([-1, -1, -1, bus])
            ierr = psspy.bus_frequency_channel([-1, bus])


    # get the nominal voltages as well as the fault impedance in ohms
    FaultBusNomVolt = float(BusDataDict[str(FaultBus)].NominalVolt)
    Zbase = FaultBusNomVolt**2/Sbase  # float since Sbase is a float
    Rohm = FaultRpu*Zbase # fault impedance in ohms 





    ierr = psspy.strt(0,settings['out_file'])
    ierr = psspy.run(0,0.1,1,1,1)
    ierr = psspy.dist_branch_trip(L1Bus1, L1Bus2, L1cktID)


    ierr = psspy.run(0,0.2,1,1,1) #fault on time




    ierr = psspy.dist_bus_fault(int(FaultBus), 3, 0.0, [Rohm, 0.0])
    ierr = psspy.run(0,0.3,1,1,1) #fault off time
    ierr = psspy.dist_clear_fault(1)

    ierr = psspy.run(0,0.31,1,1,1) #fault off time
    ierr = psspy.dist_branch_trip(L2Bus1, L2Bus2,L2cktID)
    ierr = psspy.run(0,0.35,1,1,1) #fault off time
    ierr = psspy.run(0,10.0,1,1,1) #exit time (second argument ...
(more)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-10-24 12:17:11 -0500

jconto gravatar image

Some ideas:

Do not mix running simulation with plotting. Use a second script (or loop) to perform the plotting. Plotting within a loop, if not coded properly, is known to eat memory.

Run the code outside PSSe GUI. Increase bus allocation to its max. -> psspy.psseinit(buses=200000).

Minimize commands within the main loop. save the case after:

ierr = psspy.tysl(0) #solving the converted case
ierr = psspy.sav('case_cnv.sav')   #as example

save a snap file after defining the channels:

       ierr = psspy.bus_frequency_channel([-1, bus])
ierr = psspy.snap([-1,-1,-1,-1,-1],'case.snp')   #as example

and move all that code before the main loop, since it does not change per iteration. Within the loop, load the converted case and load the snp file. This way previous memory allocation and temporary files in the background may be deleted.

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: 2018-10-24 11:05:47 -0500

Seen: 624 times

Last updated: Oct 24 '18