Exemplo n.º 1
0
    system.initDevices(dae)

    #Compute matrices
    dae.reInitG()
    dae.reInitF()

    system.computeF(dae)
    system.computeG(dae, system.Ybus)


    # # Dynamic simulation!!!!
    tMax = 10 #(s)
    dT = 10e-3 #(s)
    event = lambda t, dtMin:  stepChange(1, system, dae, t, dtMin)
    # dSimulation(system, dae, tMax=tMax, dT = 1e-3, event=event, control=agent)
    cSimulation(system, dae, tMax = tMax, dT = dT,  iterMax = 10, tol = 1e-4, event = event, control= None)

    fig, axs = plt.subplots(2,2)
    #Voltages
    axs[0,0].plot(dae.tOut, dae.yOut[:,19])
    axs[0,0].plot(dae.tOut, dae.yOut[:,21])
    axs[0,0].plot(dae.tOut, dae.yOut[:,23])
    axs[0,0].plot(dae.tOut, dae.yOut[:,25])
    axs[0,0].plot(dae.tOut, dae.yOut[:,27])

    #Angle
    axs[0,1].plot(dae.tOut, dae.xOut[:,0])
    #Speed
    axs[1,0].plot(dae.tOut, dae.xOut[:,1])    

    #AVR
Exemplo n.º 2
0
if __name__ == '__main__':
    #Load test system
    system, dae = ieee9()

    # Dynamic simulation!!!!
    tMax = 5  #(s)
    dT = 100e-3  #(s)
    tEvent = 1
    event = lambda t, dtMin: anEvent(tEvent, system, dae, t, dtMin)
    t1 = time.time()
    # Simulation using trapezoidal method
    cSimulation(system,
                dae,
                tMax=tMax,
                dT=dT,
                iterMax=10,
                tol=1e-4,
                event=event)

    # Simulation using a linearized version of the system
    # dSimulation(system, dae, tMax = tMax, dT = dT,  event = event)
    print('\n Elapsed time: ' + str(time.time() - t1))

    # ======================================================================
    # Graphs
    # Variables of interest
    idxqh = system.syn4.qh
    idxvm = system.bus.vm
    idxAVR = system.ieee1.vref
    fig, axs = plt.subplots(3, 1)