From d29348bfffd750db2aca96b6dd62eaf7fd19f477 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Thu, 30 Jan 2020 19:27:39 -0800 Subject: [PATCH 01/13] added tests --- test/{old_tests => }/test_case1_OMIB.jl | 98 +++++++++------ test/{old_tests => }/test_case2_4th_order.jl | 117 ++++++++++++------ test/{old_tests => }/test_case3_6th_order.jl | 116 ++++++++++------- test/{old_tests => }/test_case4_8th_order.jl | 116 ++++++++++------- test/{old_tests => }/test_case5_5shaft.jl | 107 ++++++++++------ test/{old_tests => }/test_case6_DAIB.jl | 67 +++++----- .../test_case7_4th_order_Inverter.jl | 108 +++++++++------- 7 files changed, 451 insertions(+), 278 deletions(-) rename test/{old_tests => }/test_case1_OMIB.jl (64%) rename test/{old_tests => }/test_case2_4th_order.jl (57%) rename test/{old_tests => }/test_case3_6th_order.jl (61%) rename test/{old_tests => }/test_case4_8th_order.jl (60%) rename test/{old_tests => }/test_case5_5shaft.jl (60%) rename test/{old_tests => }/test_case6_DAIB.jl (74%) rename test/{old_tests => }/test_case7_4th_order_Inverter.jl (66%) diff --git a/test/old_tests/test_case1_OMIB.jl b/test/test_case1_OMIB.jl similarity index 64% rename from test/old_tests/test_case1_OMIB.jl rename to test/test_case1_OMIB.jl index e680388..5688a3c 100644 --- a/test/old_tests/test_case1_OMIB.jl +++ b/test/test_case1_OMIB.jl @@ -18,7 +18,7 @@ nodes_case1 = [PSY.Bus(1 , #number 1.05, #Voltage in pu (min=0.94, max=1.06), #Voltage limits in pu 69), #Base voltage in kV - Bus(2 , "Bus 2" , "PV" , 0 , 1.0 , (min=0.94, max=1.06), 69)] + PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.0 , (min=0.94, max=1.06), 69)] branch_case1 = [PSY.Line("Line1", #name true, #available @@ -43,13 +43,21 @@ branch_case1_fault = [PSY.Line("Line1", #name 18.046, #rate in MW 1.04)] #angle limits (-min and max) -loads_case1 = [PowerLoad("Bus1", true, nodes_case1[2], PowerSystems.ConstantPower, 0.3, 0.01, 0.3, 0.01)] +loads_case1 = [PSY.PowerLoad("LBus1", #name + true, #availability + nodes_case1[2], #bus + PowerSystems.ConstantPower, #type + 0.3, #P + 0.01, #Q + 0.3, #P_max + 0.01)] #Q_max ############### Data devices ######################## -inf_gen_case1 = StaticSource(1, #number - :InfBus, #name +inf_gen_case1 = PSY.Source( + "InfBus", #name + true, #availability nodes_case1[1], #bus 1.05, #VR 0.0, #VI @@ -58,7 +66,7 @@ inf_gen_case1 = StaticSource(1, #number ######## Machine Data ######### ### Case 1: Classical machine against infinite bus ### -case1_machine = BaseMachine(0.0, #R +case1_machine = PSY.BaseMachine(0.0, #R 0.2995, #Xd_p 0.7087, #eq_p 100.0) #MVABase @@ -66,30 +74,31 @@ case1_machine = BaseMachine(0.0, #R ######## Shaft Data ######### ### Shaft for Case 1 ### -case1_shaft = SingleMass(3.148, #H +case1_shaft = PSY.SingleMass(3.148, #H 2.0) #D ######## PSS Data ######### -cases_no_pss = PSSFixed(0.0) +cases_no_pss = PSY.PSSFixed(0.0) ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### -case1234_no_tg = TGFixed(1.0) #eff +case1234_no_tg = PSY.TGFixed(1.0) #eff ######## AVR Data ######### -case1_avr = AVRFixed(0.0) #Vf not applicable in Classic Machines +case1_avr = PSY.AVRFixed(0.0) #Vf not applicable in Classic Machines ### Case 1 Generator ### case1_gen = PSY.DynamicGenerator(1, #Number - :Case1Gen, + "Case1Gen", nodes_case1[2], #bus 1.0, # ω_ref, 1.0, #V_ref 0.5, #P_ref + 0.0, #Q_ref case1_machine, #machine case1_shaft, #shaft case1_avr, #avr @@ -99,12 +108,29 @@ case1_gen = PSY.DynamicGenerator(1, #Number ######################### Dynamical System ######################## -case1_DynSystem = PSY.System(nodes_case1, - branch_case1, - [case1_gen], - vcat(inf_gen_case1,loads_case1), - 100.0, - 60.0) +#Create system with BasePower = 100 MVA and nominal frequency 60 Hz. +sys = PSY.System(100.0, frequency = 60.0); + +#Add buses +for bus in nodes_case1 + PSY.add_component!(sys,bus) +end + +#Add lines +for lines in branch_case1 + PSY.add_component!(sys,lines) +end + +#Add loads +for loads in loads_case1 + PSY.add_component!(sys,loads) +end + +#Add infinite source +PSY.add_component!(sys,inf_gen_case1) + +#Add generator +PSY.add_component!(sys,case1_gen) ################################################## @@ -112,33 +138,35 @@ case1_DynSystem = PSY.System(nodes_case1, ################################################## #Compute Y_bus after fault -Ybus_fault = PSY.Ybus(branch_case1_fault, nodes_case1)[:,:] - -#Initialize variables -dx0 = zeros(LITS.get_total_rows(case1_DynSystem)) -x0 = [1.05, #VR_1 - 1.0, #VR_2 - 0.0, #VI_1 - 0.01, #VI_2 - 0.2, #δ - 1.0] #ω -tspan = (0.0, 30.0); +sys2 = PSY.System(100.0, frequency = 60.0); +#Add buses +for bus in nodes_case1 + PSY.add_component!(sys2, bus) +end + +#Add lines +for lines in branch_case1_fault + PSY.add_component!(sys2, lines) +end +Ybus_fault = PSY.Ybus(sys2)[:,:] -#Find initial condition -inif! = (out,x) -> LITS.system_model!(out, dx0 ,x, (Ybus_fault,case1_DynSystem), 0.0) -sys_solve = nlsolve(inif!, x0) -x0_init = sys_solve.zero +tspan = (0.0, 30.0); -#Define Fault using Callbacks -cb = DiffEqBase.DiscreteCallback(LITS.change_t_one, LITS.Y_change!) +#Define Fault: Change of YBus +Ybus_change = ThreePhaseFault(1.0, #change at t = 1.0 + Ybus_fault) #New YBus #Define Simulation Problem -sim = Simulation(case1_DynSystem, tspan, Ybus_fault, cb, x0_init) +sim = Simulation(sys, #system + tspan, #time span + Ybus_change) #Type of Fault #Solve problem in equilibrium run_simulation!(sim, IDA(), dtmax=0.02); #Obtain data for angles -series = get_state_series(sim, (:Case1Gen, :δ)); +series = get_state_series(sim, ("Case1Gen", :δ)); +series2 = get_voltagemag_series(sim, 2) +LITS.print_init_states(sim) @test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case2_4th_order.jl b/test/test_case2_4th_order.jl similarity index 57% rename from test/old_tests/test_case2_4th_order.jl rename to test/test_case2_4th_order.jl index 4c19bc6..0191034 100644 --- a/test/old_tests/test_case2_4th_order.jl +++ b/test/test_case2_4th_order.jl @@ -11,27 +11,28 @@ and the generator located in bus 3. ############### Data Network ######################## -nodes_case234 = [Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] +nodes_case234 = [PSY.Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), + PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), + PSY.Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] -branch_case234 = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +branch_case234 = [PSY.Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] #Trip of Line 1. -branch_case234_fault = [Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +branch_case234_fault = [PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] -loads_case234 = [PowerLoad("Bus1", true, nodes_case234[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), - PowerLoad("Bus2", true, nodes_case234[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), - PowerLoad("Bus3", true, nodes_case234[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] +loads_case234 = [PSY.PowerLoad("Bus1", true, nodes_case234[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), + PSY.PowerLoad("Bus2", true, nodes_case234[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), + PSY.PowerLoad("Bus3", true, nodes_case234[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] ############### Data devices ######################## -inf_gen_case234 = StaticSource(1, #number - :InfBus, #name +inf_gen_case234 = PSY.Source( + "InfBus", #name + true, #availability nodes_case234[1], #bus 1.02, #VR 0.0, #VI @@ -40,7 +41,7 @@ inf_gen_case234 = StaticSource(1, #number ######## Machine Data ######### ### Case 2: 4th Order Model with AVR (3-bus case) ### -case2_machine2 = OneDOneQMachine(0.0, #R +case2_machine2 = PSY.OneDOneQMachine(0.0, #R 1.3125, #Xd 1.2578, #Xq 0.1813, #Xd_p @@ -49,7 +50,7 @@ case2_machine2 = OneDOneQMachine(0.0, #R 0.6, #Tq0_p 100.0) #MVABase -case2_machine3 = OneDOneQMachine(0.0, #R +case2_machine3 = PSY.OneDOneQMachine(0.0, #R 1.3125, #Xd 1.2578, #Xq 0.1813, #Xd_p @@ -61,26 +62,26 @@ case2_machine3 = OneDOneQMachine(0.0, #R ######## Shaft Data ######### ### Shafts for Gens 2 and 3: Cases 2, 3 and 4 ### -case234_shaft2 = SingleMass(3.01, #H (M = 6.02 -> H = M/2) +case234_shaft2 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) 0.0) #D -case234_shaft3 = SingleMass(3.01, #H (M = 6.02 -> H = M/2) +case234_shaft3 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) 0.0) #D ######## PSS Data ######### -cases_no_pss = PSSFixed(0.0) +cases_no_pss = PSY.PSSFixed(0.0) ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### -case1234_no_tg = TGFixed(1.0) #eff +case1234_no_tg = PSY.TGFixed(1.0) #eff ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case2345_avr2 = AVRTypeI(20.0, #Ka - Gain +case2345_avr2 = PSY.AVRTypeI(20.0, #Ka - Gain 0.01, #Ke 0.063, #Kf 0.2, #Ta @@ -92,7 +93,7 @@ case2345_avr2 = AVRTypeI(20.0, #Ka - Gain 0.0039, #Ae - 1st ceiling coefficient 1.555) #Be - 2nd ceiling coefficient -case2345_avr3 = AVRTypeI(20.0, #Ka - Gain +case2345_avr3 = PSY.AVRTypeI(20.0, #Ka - Gain 0.01, #Ke 0.063, #Kf 0.2, #Ta @@ -106,11 +107,12 @@ case2345_avr3 = AVRTypeI(20.0, #Ka - Gain ### Case 2 Generators ### case2_gen2 = PSY.DynamicGenerator(1, #Number - :Case2Gen2, + "Case2Gen2", nodes_case234[2], #bus 1.0, # ω_ref, 1.0142, #V_ref 1.0, #P_ref + 0.0, #Q_ref case2_machine2, #machine case234_shaft2, #shaft case2345_avr2, #avr @@ -118,11 +120,12 @@ case2_gen2 = PSY.DynamicGenerator(1, #Number cases_no_pss) #pss case2_gen3 = PSY.DynamicGenerator(2, #Number - :Case2Gen3, + "Case2Gen3", nodes_case234[3], #bus 1.0, # ω_ref, 1.0059, #V_ref 1.0, #P_ref + 0.0, #Q_ref case2_machine3, #machine case234_shaft3, #shaft case2345_avr3, #avr @@ -131,12 +134,31 @@ case2_gen3 = PSY.DynamicGenerator(2, #Number ######################### Dynamical System ######################## -case2_DynSystem = PSY.System(nodes_case234, - branch_case234, - [case2_gen2, case2_gen3], - vcat(inf_gen_case234,loads_case234), - 100.0, - 60.0) + +#Create system with BasePower = 100 MVA and nominal frequency 60 Hz. +sys = PSY.System(100.0, frequency = 60.0); + +#Add buses +for bus in nodes_case234 + PSY.add_component!(sys,bus) +end + +#Add lines +for lines in branch_case234 + PSY.add_component!(sys,lines) +end + +#Add loads +for loads in loads_case234 + PSY.add_component!(sys,loads) +end + +#Add infinite source +PSY.add_component!(sys,inf_gen_case234) + +#Add generators +PSY.add_component!(sys,case2_gen2) +PSY.add_component!(sys,case2_gen3) ################################################## @@ -145,11 +167,22 @@ case2_DynSystem = PSY.System(nodes_case234, #Compute Y_bus after fault -Ybus_fault = PSY.Ybus(branch_case234_fault, nodes_case234)[:,:] +sys2 = PSY.System(100.0, frequency = 60.0); +#Add buses +for bus in nodes_case234 + PSY.add_component!(sys2, bus) +end +#Add lines +for lines in branch_case234_fault + PSY.add_component!(sys2, lines) +end +Ybus_fault = PSY.Ybus(sys2)[:,:] + +#time span +tspan = (0.0, 30.0); -#Initialize variables -dx0 = zeros(LITS.get_total_rows(case2_DynSystem)) -x0 = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, +#Initial guess +x0_guess = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, 1.0, #eq_p 0.47, #ed_p 0.6, #δ @@ -166,20 +199,22 @@ x0 = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, 0.11, #Vr1 -0.31, #Vr2, 1.0] #Vm -tspan = (0.0, 30.0); -#Find initial condition -inif! = (out,x) -> LITS.system_model!(out, dx0 ,x, (Ybus_fault,case2_DynSystem), 0.0) -sys_solve = nlsolve(inif!, x0) -x0_init = sys_solve.zero -cb = DiffEqBase.DiscreteCallback(LITS.change_t_one, LITS.Y_change!) -sim = Simulation(case2_DynSystem, tspan, Ybus_fault, cb, x0_init) +#Define Fault: Change of YBus +Ybus_change = ThreePhaseFault(1.0, #change at t = 1.0 + Ybus_fault) #New YBus + +#Define Simulation Problem +sim = Simulation(sys, #system + tspan, #time span + Ybus_change, #Type of Fault + initial_guess = x0_guess) #initial guess #Solve problem in equilibrium run_simulation!(sim, IDA()); #Obtain data for angles -series = get_state_series(sim, (:Case2Gen2, :δ)); +series = get_state_series(sim, ("Case2Gen2", :δ)); @test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case3_6th_order.jl b/test/test_case3_6th_order.jl similarity index 61% rename from test/old_tests/test_case3_6th_order.jl rename to test/test_case3_6th_order.jl index cd33a0f..9377e13 100644 --- a/test/old_tests/test_case3_6th_order.jl +++ b/test/test_case3_6th_order.jl @@ -11,27 +11,28 @@ and the generator located in bus 3. ############### Data Network ######################## -nodes_case234 = [Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] +nodes_case234 = [PSY.Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), + PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), + PSY.Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] -branch_case234 = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +branch_case234 = [PSY.Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] #Trip of Line 1. -branch_case234_fault = [Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +branch_case234_fault = [PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] -loads_case234 = [PowerLoad("Bus1", true, nodes_case234[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), - PowerLoad("Bus2", true, nodes_case234[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), - PowerLoad("Bus3", true, nodes_case234[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] +loads_case234 = [PSY.PowerLoad("Bus1", true, nodes_case234[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), + PSY.PowerLoad("Bus2", true, nodes_case234[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), + PSY.PowerLoad("Bus3", true, nodes_case234[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] ############### Data devices ######################## -inf_gen_case234 = StaticSource(1, #number - :InfBus, #name +inf_gen_case234 = PSY.Source( + "InfBus", #name + true, #availability nodes_case234[1], #bus 1.02, #VR 0.0, #VI @@ -40,7 +41,7 @@ inf_gen_case234 = StaticSource(1, #number ######## Machine Data ######### ### Case 3: 6th Order Model with AVR (3-bus case) ### -case3_machine2 = SimpleMarconatoMachine(0.0, +case3_machine2 = PSY.SimpleMarconatoMachine(0.0, 1.3125, #Xd 1.2578, #Xq 0.1813, #Xd_p @@ -54,7 +55,7 @@ case3_machine2 = SimpleMarconatoMachine(0.0, 0.0, #T_AA 100.0) #MVABase -case3_machine3 = SimpleMarconatoMachine(0.0, +case3_machine3 = PSY.SimpleMarconatoMachine(0.0, 1.3125, #Xd 1.2578, #Xq 0.1813, #Xd_p @@ -71,26 +72,26 @@ case3_machine3 = SimpleMarconatoMachine(0.0, ######## Shaft Data ######### ### Shafts for Gens 2 and 3: Cases 2, 3 and 4 ### -case234_shaft2 = SingleMass(3.01, #H (M = 6.02 -> H = M/2) +case234_shaft2 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) 0.0) #D -case234_shaft3 = SingleMass(3.01, #H (M = 6.02 -> H = M/2) +case234_shaft3 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) 0.0) #D ######## PSS Data ######### -cases_no_pss = PSSFixed(0.0) +cases_no_pss = PSY.PSSFixed(0.0) ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### -case1234_no_tg = TGFixed(1.0) #eff +case1234_no_tg = PSY.TGFixed(1.0) #eff ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case2345_avr2 = AVRTypeI(20.0, #Ka - Gain +case2345_avr2 = PSY.AVRTypeI(20.0, #Ka - Gain 0.01, #Ke 0.063, #Kf 0.2, #Ta @@ -102,7 +103,7 @@ case2345_avr2 = AVRTypeI(20.0, #Ka - Gain 0.0039, #Ae - 1st ceiling coefficient 1.555) #Be - 2nd ceiling coefficient -case2345_avr3 = AVRTypeI(20.0, #Ka - Gain +case2345_avr3 = PSY.AVRTypeI(20.0, #Ka - Gain 0.01, #Ke 0.063, #Kf 0.2, #Ta @@ -116,11 +117,12 @@ case2345_avr3 = AVRTypeI(20.0, #Ka - Gain ### Case 3 Generators ### case3_gen2 = PSY.DynamicGenerator(1, #Number - :Case3Gen2, + "Case3Gen2", nodes_case234[2], #bus 1.0, # ω_ref, 1.0142, #V_ref 1.0, #P_ref + 0.0, #Q_ref case3_machine2, #machine case234_shaft2, #shaft case2345_avr2, #avr @@ -128,11 +130,12 @@ case3_gen2 = PSY.DynamicGenerator(1, #Number cases_no_pss) #pss case3_gen3 = PSY.DynamicGenerator(2, #Number - :Case3Gen3, + "Case3Gen3", nodes_case234[3], #bus 1.0, # ω_ref, 1.0059, #V_ref 1.0, #P_ref + 0.0, #Q_ref case3_machine3, #machine case234_shaft3, #shaft case2345_avr3, #avr @@ -142,12 +145,30 @@ case3_gen3 = PSY.DynamicGenerator(2, #Number ######################### Dynamical System ######################## -case3_DynSystem = PSY.System(nodes_case234, - branch_case234, - [case3_gen2, case3_gen3], - vcat(inf_gen_case234,loads_case234), - 100.0, - 60.0) +#Create system with BasePower = 100 MVA and nominal frequency 60 Hz. +sys = PSY.System(100.0, frequency = 60.0); + +#Add buses +for bus in nodes_case234 + PSY.add_component!(sys,bus) +end + +#Add lines +for lines in branch_case234 + PSY.add_component!(sys,lines) +end + +#Add loads +for loads in loads_case234 + PSY.add_component!(sys,loads) +end + +#Add infinite source +PSY.add_component!(sys,inf_gen_case234) + +#Add generators +PSY.add_component!(sys,case3_gen2) +PSY.add_component!(sys,case3_gen3) ################################################## @@ -157,11 +178,22 @@ case3_DynSystem = PSY.System(nodes_case234, #Compute Y_bus after fault -Ybus_fault = PSY.Ybus(branch_case234_fault, nodes_case234)[:,:] +sys2 = PSY.System(100.0, frequency = 60.0); +#Add buses +for bus in nodes_case234 + PSY.add_component!(sys2, bus) +end +#Add lines +for lines in branch_case234_fault + PSY.add_component!(sys2, lines) +end +Ybus_fault = PSY.Ybus(sys2)[:,:] + +#time span +tspan = (0.0, 20.0); -#Initialize variables -dx0 = zeros(LITS.get_total_rows(case3_DynSystem)) -x0 = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, +#Initial guess +x0_guess = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, 1.0, #eq_p 0.47, #ed_p 0.95, #eq_pp @@ -182,23 +214,21 @@ x0 = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, 0.11, #Vr1 -0.31, #Vr2, 1.0] #Vm -tspan = (0.0, 20.0); - -#Find initial condition -inif! = (out,x) -> LITS.system_model!(out, dx0 ,x, (Ybus_fault,case3_DynSystem), 0.0) -sys_solve = nlsolve(inif!, x0) -x0_init = sys_solve.zero -#Define Fault using Callbacks -cb = DiffEqBase.DiscreteCallback(LITS.change_t_one, LITS.Y_change!) +#Define Fault: Change of YBus +Ybus_change = ThreePhaseFault(1.0, #change at t = 1.0 + Ybus_fault) #New YBus #Define Simulation Problem -sim = Simulation(case3_DynSystem, tspan, Ybus_fault, cb, x0_init) +sim = Simulation(sys, #system + tspan, #time span + Ybus_change, #Type of Fault + initial_guess = x0_guess) #initial guess #Solve problem in equilibrium run_simulation!(sim, IDA()); #Obtain data for angles -series = get_state_series(sim, (:Case3Gen2, :δ)); +series = get_state_series(sim, ("Case3Gen2", :δ)); @test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case4_8th_order.jl b/test/test_case4_8th_order.jl similarity index 60% rename from test/old_tests/test_case4_8th_order.jl rename to test/test_case4_8th_order.jl index d0d9f6e..5d83a38 100644 --- a/test/old_tests/test_case4_8th_order.jl +++ b/test/test_case4_8th_order.jl @@ -12,27 +12,28 @@ and the generator located in bus 3. ############### Data Network ######################## -nodes_case234 = [Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] +nodes_case234 = [PSY.Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), + PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), + PSY.Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] -branch_case234 = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +branch_case234 = [PSY.Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] #Trip of Line 1. -branch_case234_fault = [Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +branch_case234_fault = [PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] -loads_case234 = [PowerLoad("Bus1", true, nodes_case234[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), - PowerLoad("Bus2", true, nodes_case234[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), - PowerLoad("Bus3", true, nodes_case234[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] +loads_case234 = [PSY.PowerLoad("Bus1", true, nodes_case234[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), + PSY.PowerLoad("Bus2", true, nodes_case234[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), + PSY.PowerLoad("Bus3", true, nodes_case234[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] ############### Data devices ######################## -inf_gen_case234 = StaticSource(1, #number - :InfBus, #name +inf_gen_case234 = PSY.Source( + "InfBus", #name + true, #availability nodes_case234[1], #bus 1.02, #VR 0.0, #VI @@ -41,7 +42,7 @@ inf_gen_case234 = StaticSource(1, #number ######## Machine Data ######### ### Case 4: 8th Order Model with AVR (3-bus case) ### -case4_machine2 = MarconatoMachine(0.0, +case4_machine2 = PSY.MarconatoMachine(0.0, 1.3125, #Xd 1.2578, #Xq 0.1813, #Xd_p @@ -56,7 +57,7 @@ case4_machine2 = MarconatoMachine(0.0, 100.0) #MVABase -case4_machine3 = MarconatoMachine(0.0, +case4_machine3 = PSY.MarconatoMachine(0.0, 1.3125, #Xd 1.2578, #Xq 0.1813, #Xd_p @@ -73,26 +74,26 @@ case4_machine3 = MarconatoMachine(0.0, ######## Shaft Data ######### ### Shafts for Gens 2 and 3: Cases 2, 3 and 4 ### -case234_shaft2 = SingleMass(3.01, #H (M = 6.02 -> H = M/2) +case234_shaft2 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) 0.0) #D -case234_shaft3 = SingleMass(3.01, #H (M = 6.02 -> H = M/2) +case234_shaft3 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) 0.0) #D ######## PSS Data ######### -cases_no_pss = PSSFixed(0.0) +cases_no_pss = PSY.PSSFixed(0.0) ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### -case1234_no_tg = TGFixed(1.0) #eff +case1234_no_tg = PSY.TGFixed(1.0) #eff ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case2345_avr2 = AVRTypeI(20.0, #Ka - Gain +case2345_avr2 = PSY.AVRTypeI(20.0, #Ka - Gain 0.01, #Ke 0.063, #Kf 0.2, #Ta @@ -104,7 +105,7 @@ case2345_avr2 = AVRTypeI(20.0, #Ka - Gain 0.0039, #Ae - 1st ceiling coefficient 1.555) #Be - 2nd ceiling coefficient -case2345_avr3 = AVRTypeI(20.0, #Ka - Gain +case2345_avr3 = PSY.AVRTypeI(20.0, #Ka - Gain 0.01, #Ke 0.063, #Kf 0.2, #Ta @@ -118,11 +119,12 @@ case2345_avr3 = AVRTypeI(20.0, #Ka - Gain ### Case 4 Generators ### case4_gen2 = PSY.DynamicGenerator(1, #Number - :Case4Gen2, + "Case4Gen2", nodes_case234[2], #bus 1.0, # ω_ref, 1.0142, #V_ref 1.0, #P_ref + 0.0, #Q_ref case4_machine2, #machine case234_shaft2, #shaft case2345_avr2, #avr @@ -130,11 +132,12 @@ case4_gen2 = PSY.DynamicGenerator(1, #Number cases_no_pss) #pss case4_gen3 = PSY.DynamicGenerator(2, #Number - :Case4Gen3, + "Case4Gen3", nodes_case234[3], #bus 1.0, # ω_ref, 1.0059, #V_ref 1.0, #P_ref + 0.0, #Q_ref case4_machine3, #machine case234_shaft3, #shaft case2345_avr3, #avr @@ -144,25 +147,53 @@ case4_gen3 = PSY.DynamicGenerator(2, #Number ######################### Dynamical System ######################## -case4_DynSystem = PSY.System(nodes_case234, - branch_case234, - [case4_gen2, case4_gen3], - vcat(inf_gen_case234,loads_case234), - 100.0, - 60.0) +#Create system with BasePower = 100 MVA and nominal frequency 60 Hz. +sys = PSY.System(100.0, frequency = 60.0); + +#Add buses +for bus in nodes_case234 + PSY.add_component!(sys,bus) +end + +#Add lines +for lines in branch_case234 + PSY.add_component!(sys,lines) +end + +#Add loads +for loads in loads_case234 + PSY.add_component!(sys,loads) +end + +#Add infinite source +PSY.add_component!(sys,inf_gen_case234) + +#Add generators +PSY.add_component!(sys,case4_gen2) +PSY.add_component!(sys,case4_gen3) ################################################## ############### SOLVE PROBLEM #################### ################################################## - #Compute Y_bus after fault -Ybus_fault = PSY.Ybus(branch_case234_fault, nodes_case234)[:,:]; +sys2 = PSY.System(100.0, frequency = 60.0); +#Add buses +for bus in nodes_case234 + PSY.add_component!(sys2, bus) +end +#Add lines +for lines in branch_case234_fault + PSY.add_component!(sys2, lines) +end +Ybus_fault = PSY.Ybus(sys2)[:,:] + +#time span +tspan = (0.0, 20.0); -#Initialize variables -dx0 = zeros(LITS.get_total_rows(case4_DynSystem)) -x0 = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, +#Initial guess +x0_guess = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, -0.5, #ψq 0.8, #ψd 1.0, #eq_p @@ -187,23 +218,22 @@ x0 = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, 0.11, #Vr1 -0.31, #Vr2, 1.0] #Vm -tspan = (0.0, 20.0); -#Find initial condition -inif! = (out,x) -> LITS.system_model!(out, dx0 ,x, (Ybus_fault,case4_DynSystem), 0.0) -sys_solve = nlsolve(inif!, x0) -x0_init = sys_solve.zero -#Define Fault using Callbacks -cb = DiffEqBase.DiscreteCallback(LITS.change_t_one, LITS.Y_change!) +#Define Fault: Change of YBus +Ybus_change = ThreePhaseFault(1.0, #change at t = 1.0 + Ybus_fault) #New YBus #Define Simulation Problem -sim = Simulation(case4_DynSystem, tspan, Ybus_fault, cb, x0_init) +sim = Simulation(sys, #system + tspan, #time span + Ybus_change, #Type of Fault + initial_guess = x0_guess) #initial guess #Solve problem in equilibrium run_simulation!(sim, IDA()); #Obtain data for angles -series = get_state_series(sim, (:Case4Gen2, :δ)); +series = get_state_series(sim, ("Case4Gen2", :δ)); @test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case5_5shaft.jl b/test/test_case5_5shaft.jl similarity index 60% rename from test/old_tests/test_case5_5shaft.jl rename to test/test_case5_5shaft.jl index ba0a370..df37ded 100644 --- a/test/old_tests/test_case5_5shaft.jl +++ b/test/test_case5_5shaft.jl @@ -11,27 +11,28 @@ The fault disconnects a circuit between buses 1 and 2, doubling its impedance. ############### Data Network ######################## -nodes_case5 = [Bus(1 , "Bus 1" , "REF" , 0 , 1.05 , (min=0.94, max=1.06), 138), - Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] +nodes_case5 = [PSY.Bus(1 , "Bus 1" , "REF" , 0 , 1.05 , (min=0.94, max=1.06), 138), + PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), + PSY.Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] -branch_case5 = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[2]), 0.01, 0.05, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case5[2], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04)] +branch_case5 = [PSY.Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[2]), 0.01, 0.05, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case5[2], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04)] #Trip of a single circuit of Line 1 -> Resistance and Reactance doubled. -branch_case5_fault = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[2]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case5[2], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04)] +branch_case5_fault = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[2]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), + Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case5[2], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), + Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04)] -loads_case5 = [PowerLoad("Bus2", true, nodes_case5[2], PowerSystems.ConstantPower, 0.3, 0.05, 0.3, 0.05), - PowerLoad("Bus3", true, nodes_case5[3], PowerSystems.ConstantPower, 0.3, 0.05, 0.3, 0.05)] +loads_case5 = [PSY.PowerLoad("Bus2", true, nodes_case5[2], PowerSystems.ConstantPower, 0.3, 0.05, 0.3, 0.05), + PSY.PowerLoad("Bus3", true, nodes_case5[3], PowerSystems.ConstantPower, 0.3, 0.05, 0.3, 0.05)] ############### Data devices ######################## -inf_gen_case5 = StaticSource(1, #number - :InfBus, #name +inf_gen_case5 = PSY.Source( + "InfBus", #name + true, #availability nodes_case5[1], #bus 1.00, #VR 0.0, #VI @@ -40,7 +41,7 @@ inf_gen_case5 = StaticSource(1, #number ######## Machine Data ######### ### Case 5: 4th Order Model with AVR + TG + Multishaft ### -case5_machine = OneDOneQMachine(0.0, #R +case5_machine = PSY.OneDOneQMachine(0.0, #R 1.3125, #Xd 1.2578, #Xq 0.1813, #Xd_p @@ -51,7 +52,7 @@ case5_machine = OneDOneQMachine(0.0, #R ######## Shaft Data ######### -case5_shaft = FiveMassShaft(3.01, #5.148, #H +case5_shaft = PSY.FiveMassShaft(3.01, #5.148, #H 0.3348, #H_hp 0.7306, #H_ip 0.8154, #H_lp @@ -72,13 +73,13 @@ case5_shaft = FiveMassShaft(3.01, #5.148, #H ######## PSS Data ######### -cases_no_pss = PSSFixed(0.0) +cases_no_pss = PSY.PSSFixed(0.0) ######## TG Data ######### ### TG for Case 5 ### -case5_tg = TGTypeII(0.05, #R +case5_tg = PSY.TGTypeII(0.05, #R 1.0, #T1 2.0, #T2 1.5, #τ_max @@ -86,7 +87,7 @@ case5_tg = TGTypeII(0.05, #R ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case5_avr = AVRTypeI(20.0, #Ka - Gain +case5_avr = PSY.AVRTypeI(20.0, #Ka - Gain 0.01, #Ke 0.063, #Kf 0.2, #Ta @@ -102,11 +103,12 @@ case5_avr = AVRTypeI(20.0, #Ka - Gain ### Case 5 Generator ### case5_gen = PSY.DynamicGenerator(1, #Number - :Case5Gen, + "Case5Gen", nodes_case5[2], #bus 1.0, # ω_ref, 1.0155, #V_ref 0.5, #P_ref + 0.0, #Q_ref case5_machine, #machine case5_shaft, #shaft case5_avr, #avr @@ -116,25 +118,52 @@ case5_gen = PSY.DynamicGenerator(1, #Number ######################### Dynamical System ######################## -case5_DynSystem = PSY.System(nodes_case5, - branch_case5, - [case5_gen], - vcat(inf_gen_case5,loads_case5), - 100.0, - 60.0) +#Create system with BasePower = 100 MVA and nominal frequency 60 Hz. +sys = PSY.System(100.0, frequency = 60.0); + +#Add buses +for bus in nodes_case5 + PSY.add_component!(sys,bus) +end + +#Add lines +for lines in branch_case5 + PSY.add_component!(sys,lines) +end + +#Add loads +for loads in loads_case5 + PSY.add_component!(sys,loads) +end + +#Add infinite source +PSY.add_component!(sys,inf_gen_case5) + +#Add generators +PSY.add_component!(sys,case5_gen) ################################################## ############### SOLVE PROBLEM #################### ################################################## - #Compute Y_bus after fault -Ybus_fault = PSY.Ybus(branch_case5_fault, nodes_case5)[:,:]; +sys2 = PSY.System(100.0, frequency = 60.0); +#Add buses +for bus in nodes_case5 + PSY.add_component!(sys2, bus) +end +#Add lines +for lines in branch_case5_fault + PSY.add_component!(sys2, lines) +end +Ybus_fault = PSY.Ybus(sys2)[:,:] + +#time span +tspan = (0.0, 20.0); -#Initialize variables -dx0 = zeros(LITS.get_total_rows(case5_DynSystem)) -x0 = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, +#Initial guess +x0_guess = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, 1.0, #eq_p 0.0, #ed_p 0.05, #δ @@ -152,23 +181,21 @@ x0 = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, -0.1, #Vr2, 1.0, #Vm 0.0] #xg -tspan = (0.0, 20.0); - -#Find initial condition -inif! = (out,x) -> LITS.system_model!(out, dx0 ,x, (Ybus_fault,case5_DynSystem), 0.0) -sys_solve = nlsolve(inif!, x0) -x0_init = sys_solve.zero -#Define Fault using Callbacks -cb = DiffEqBase.DiscreteCallback(LITS.change_t_one, LITS.Y_change!) +#Define Fault: Change of YBus +Ybus_change = ThreePhaseFault(1.0, #change at t = 1.0 + Ybus_fault) #New YBus #Define Simulation Problem -sim = Simulation(case5_DynSystem, tspan, Ybus_fault, cb, x0_init) +sim = Simulation(sys, #system + tspan, #time span + Ybus_change, #Type of Fault + initial_guess = x0_guess) #initial guess #Solve problem in equilibrium run_simulation!(sim, IDA()); #Obtain data for angles -series = get_state_series(sim, (:Case5Gen, :δ)); +series = get_state_series(sim, ("Case5Gen", :δ)); @test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case6_DAIB.jl b/test/test_case6_DAIB.jl similarity index 74% rename from test/old_tests/test_case6_DAIB.jl rename to test/test_case6_DAIB.jl index f8b85de..bd549eb 100644 --- a/test/old_tests/test_case6_DAIB.jl +++ b/test/test_case6_DAIB.jl @@ -10,17 +10,17 @@ The perturbation increase the reference power (analogy for mechanical power) fro ############### Data Network ######################## -nodes_DAIB= [Bus(1 , #number +nodes_DAIB= [PSY.Bus(1 , #number "Bus 1", #Name "REF" , #BusType (REF, PV, PQ) 0, #Angle in radians 1.04, #Voltage in pu (min=0.94, max=1.06), #Voltage limits in pu 0.69), #Base voltage in kV - Bus(2 , "Bus 2" , "PV" , 0 , 1.0 , (min=0.94, max=1.06), 0.69)] + PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.0 , (min=0.94, max=1.06), 0.69)] -branch_DAIB = [Line("Line1", #name +branch_DAIB = [PSY.Line("Line1", #name true, #available 0.0, #active power flow initial condition (from-to) 0.0, #reactive power flow initial condition (from-to) @@ -33,8 +33,8 @@ branch_DAIB = [Line("Line1", #name ############### Data devices ######################## -inf_gen_DAIB = StaticSource(1, #number - :InfBus, #name +inf_gen_DAIB = PSY.Source("InfBus", #name + true, #availability nodes_DAIB[1],#bus 1.00, #VR 0.0, #VI @@ -42,32 +42,32 @@ inf_gen_DAIB = StaticSource(1, #number ############### Inverter Data ######################## -converter = AvgCnvFixedDC(690.0, #Rated Voltage +converter = PSY.AvgCnvFixedDC(690.0, #Rated Voltage 2.75) #Rated MVA -dc_source = FixedDCSource(600.0) #Not in the original data, guessed. +dc_source = PSY.FixedDCSource(600.0) #Not in the original data, guessed. -filt = LCLFilter(0.08, #Series inductance lf in pu +filt = PSY.LCLFilter(0.08, #Series inductance lf in pu 0.003, #Series resitance rf in pu 0.074, #Shunt capacitance cf in pu 0.2, #Series ractance rg to grid connection (#Step up transformer or similar) 0.01) #Series resistance lg to grid connection (#Step up transformer or similar) -pll = PLL(500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. +pll = PSY.PLL(500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. 0.084, #k_p: PLL proportional gain 4.69) #k_i: PLL integral gain -virtual_H = VirtualInertia(2.0, #Ta:: VSM inertia constant +virtual_H = PSY.VirtualInertia(2.0, #Ta:: VSM inertia constant 400.0, #kd:: VSM damping coefficient 20.0, #kω:: Frequency droop gain in pu 2*pi*50.0) #ωb:: Rated angular frequency -Q_control = ReactivePowerDroop(0.2, #kq:: Reactive power droop gain in pu +Q_control = PSY.ReactivePowerDroop(0.2, #kq:: Reactive power droop gain in pu 1000.0) #ωf:: Reactive power cut-off low pass filter frequency -outer_control = VirtualInertiaQdroop(virtual_H, Q_control) +outer_control = PSY.VirtualInertiaQdroop(virtual_H, Q_control) -vsc = CombinedVIwithVZ(0.59, #kpv:: Voltage controller proportional gain +vsc = PSY.CombinedVIwithVZ(0.59, #kpv:: Voltage controller proportional gain 736.0, #kiv:: Voltage controller integral gain 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers 0.0, #rv:: Virtual resistance in pu @@ -79,7 +79,7 @@ vsc = CombinedVIwithVZ(0.59, #kpv:: Voltage controller proportional gain 0.2) #kad:: Active damping gain Darco_Inverter = PSY.DynamicInverter(1, #number - :DARCO, #name + "DARCO", #name nodes_DAIB[2], #bus location 1.0, #ω_ref 1.02, #V_ref @@ -96,16 +96,31 @@ Darco_Inverter = PSY.DynamicInverter(1, #number ######################### Dynamical System ######################## -DAIB = PSY.System(nodes_DAIB, branch_DAIB, [Darco_Inverter], [inf_gen_DAIB], 100.0, 50.0); +#Create system with BasePower = 100 MVA and nominal frequency 50 Hz. +sys = PSY.System(100, frequency=50.0) +#Add buses +for bus in nodes_DAIB + PSY.add_component!(sys,bus) +end +#Add lines +for lines in branch_DAIB + PSY.add_component!(sys,lines) +end +#Add infinite source +PSY.add_component!(sys,inf_gen_DAIB) +#Add inverter +PSY.add_component!(sys,Darco_Inverter) ################################################## ############### SOLVE PROBLEM #################### ################################################## -#Initialize variables -dx0 = zeros(LITS.get_total_rows(DAIB)) -x0 = [1.00, #V1_R +#time span +tspan = (0.0, 4.0); + +#Initial guess +x0_guess = [1.00, #V1_R 1.0648, #V2_R 0.0, #V1_I 0.001, #V2_I @@ -128,26 +143,18 @@ x0 = [1.00, #V1_R -0.1, #voq 0.49, #iod -0.1] #ioq -Darco_Inverter.inner_vars[13] = 0.95 #Vd_cnv var -Darco_Inverter.inner_vars[14] = -0.1 #Vq_cnv var -u0 = [0.2] #Increase in P_ref -tspan = (0.0, 4.0); -#Find initial condition -inif! = (out,x) -> LITS.system_model!(out, dx0 ,x, (u0,DAIB), 0.0) -sys_solve = nlsolve(inif!, x0, xtol=:1e-8,ftol=:1e-8,method=:trust_region) -x0_init = sys_solve.zero #Define Fault using Callbacks -cb = DiffEqBase.DiscreteCallback(LITS.change_t_one, LITS.step_change_first!) +Pref_change = LITS.ControlReferenceChange(1.0, Darco_Inverter, LITS.P_ref_index, 0.7) #Define Simulation Problem -sim = Simulation(DAIB, tspan, u0, cb, x0_init) +sim = LITS.Simulation(sys, tspan, Pref_change, initial_guess = x0_guess) #Solve problem in equilibrium -run_simulation!(sim, IDA()); +run_simulation!(sim, Sundials.IDA()); #Obtain data for angles -series = get_state_series(sim, (:DARCO, :δω_vsm)); +series = get_state_series(sim, ("DARCO", :δω_vsm)) @test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case7_4th_order_Inverter.jl b/test/test_case7_4th_order_Inverter.jl similarity index 66% rename from test/old_tests/test_case7_4th_order_Inverter.jl rename to test/test_case7_4th_order_Inverter.jl index db86a66..402f10e 100644 --- a/test/old_tests/test_case7_4th_order_Inverter.jl +++ b/test/test_case7_4th_order_Inverter.jl @@ -11,28 +11,28 @@ The perturbation increase the reference power (analogy for mechanical power) of ############### Data Network ######################## -nodes_case7 = [Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - Bus(3 , "Bus 3" , "PQ" , 0 , 1.00 , (min=0.94, max=1.06), 138)] +nodes_case7 = [PSY.Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), + PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), + PSY.Bus(3 , "Bus 3" , "PQ" , 0 , 1.00 , (min=0.94, max=1.06), 138)] -branch_case7 = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case7[1], to=nodes_case7[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case7[1], to=nodes_case7[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case7[2], to=nodes_case7[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +branch_case7 = [PSY.Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case7[1], to=nodes_case7[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case7[1], to=nodes_case7[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case7[2], to=nodes_case7[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] #Trip of Line 1. -branch_case7_fault = [Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case7[1], to=nodes_case7[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case7[2], to=nodes_case7[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +branch_case7_fault = [PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case7[1], to=nodes_case7[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case7[2], to=nodes_case7[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] - -loads_case7 = [PowerLoad("Bus1", true, nodes_case7[1], PowerSystems.ConstantPower, 0.5, 0.1, 1.5, 0.8), - PowerLoad("Bus2", true, nodes_case7[2], PowerSystems.ConstantPower, 1.0, 0.3, 1.5, 0.8), - PowerLoad("Bus3", true, nodes_case7[3], PowerSystems.ConstantPower, 0.3, 0.1, 0.5, 0.3)] +loads_case7 = [PSY.PowerLoad("Bus1", true, nodes_case7[1], PowerSystems.ConstantPower, 0.5, 0.1, 1.5, 0.8), + PSY.PowerLoad("Bus2", true, nodes_case7[2], PowerSystems.ConstantPower, 1.0, 0.3, 1.5, 0.8), + PSY.PowerLoad("Bus3", true, nodes_case7[3], PowerSystems.ConstantPower, 0.3, 0.1, 0.5, 0.3)] ############### Data devices ######################## -inf_gen_case7 = StaticSource(1, #number - :InfBus, #name +inf_gen_case7 = PSY.Source( + "InfBus", #name + true, #availability nodes_case7[1],#bus 1.00, #VR 0.0, #VI @@ -42,7 +42,7 @@ inf_gen_case7 = StaticSource(1, #number ######## Machine Data ######### ### Case 2: 4th Order Model with AVR (3-bus case) ### -case7_machine = OneDOneQMachine(0.0, #R +case7_machine = PSY.OneDOneQMachine(0.0, #R 1.3125, #Xd 1.2578, #Xq 0.1813, #Xd_p @@ -54,22 +54,22 @@ case7_machine = OneDOneQMachine(0.0, #R ######## Shaft Data ######### ### Shafts for Gen ### -case7_shaft = SingleMass(3.01, #H (M = 6.02 -> H = M/2) +case7_shaft = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) 0.0) #D ######## PSS Data ######### -cases_no_pss = PSSFixed(0.0) +cases_no_pss = PSY.PSSFixed(0.0) ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### -case7_no_tg = TGFixed(1.0) #eff +case7_no_tg = PSY.TGFixed(1.0) #eff ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case7_avr = AVRTypeI(20.0, #Ka - Gain +case7_avr = PSY.AVRTypeI(20.0, #Ka - Gain 0.01, #Ke 0.063, #Kf 0.2, #Ta @@ -83,11 +83,12 @@ case7_avr = AVRTypeI(20.0, #Ka - Gain ### Case 7 Generators ### case7_gen = PSY.DynamicGenerator(1, #Number - :Case7Gen, + "Case7Gen", nodes_case7[2], #bus 1.0, # ω_ref, 1.0142, #V_ref 0.6, #P_ref + 0.0, #Q_ref case7_machine, #machine case7_shaft, #shaft case7_avr, #avr @@ -96,32 +97,32 @@ case7_gen = PSY.DynamicGenerator(1, #Number ############### Inverter Data ######################## -converter = AvgCnvFixedDC(138.0, #Rated Voltage +converter = PSY.AvgCnvFixedDC(138.0, #Rated Voltage 100.0) #Rated MVA -dc_source = FixedDCSource(1500.0) #Not in the original data, guessed. +dc_source = PSY.FixedDCSource(1500.0) #Not in the original data, guessed. -filt = LCLFilter(0.08, #Series inductance lf in pu +filt = PSY.LCLFilter(0.08, #Series inductance lf in pu 0.003, #Series resitance rf in pu 0.074, #Shunt capacitance cf in pu 0.2, #Series reactance rg to grid connection (#Step up transformer or similar) 0.01) #Series resistance lg to grid connection (#Step up transformer or similar) -pll = PLL(500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. +pll = PSY.PLL(500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. 0.084, #k_p: PLL proportional gain 4.69) #k_i: PLL integral gain -virtual_H = VirtualInertia(2.0, #Ta:: VSM inertia constant +virtual_H = PSY.VirtualInertia(2.0, #Ta:: VSM inertia constant 400.0, #kd:: VSM damping coefficient 20.0, #kω:: Frequency droop gain in pu 2*pi*50.0) #ωb:: Rated angular frequency -Q_control = ReactivePowerDroop(0.2, #kq:: Reactive power droop gain in pu +Q_control = PSY.ReactivePowerDroop(0.2, #kq:: Reactive power droop gain in pu 1000.0) #ωf:: Reactive power cut-off low pass filter frequency -outer_control = VirtualInertiaQdroop(virtual_H, Q_control) +outer_control = PSY.VirtualInertiaQdroop(virtual_H, Q_control) -vsc = CombinedVIwithVZ(0.59, #kpv:: Voltage controller proportional gain +vsc = PSY.CombinedVIwithVZ(0.59, #kpv:: Voltage controller proportional gain 736.0, #kiv:: Voltage controller integral gain 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers 0.0, #rv:: Virtual resistance in pu @@ -133,7 +134,7 @@ vsc = CombinedVIwithVZ(0.59, #kpv:: Voltage controller proportional gain 0.2) #kad:: Active damping gain case7_inv = PSY.DynamicInverter(2, #number - :DARCO, #name + "DARCO", #name nodes_case7[3], #bus location 1.0, #ω_ref 1.02, #V_ref @@ -150,15 +151,41 @@ case7_inv = PSY.DynamicInverter(2, #number ######################### Dynamical System ######################## -case7_DynSystem = PSY.System(nodes_case7, branch_case7, [case7_inv, case7_gen], vcat(inf_gen_case7, loads_case7), 100.0, 50.0); +#Create system with BasePower = 100 MVA and nominal frequency 50 Hz. +sys = PSY.System(100, frequency=50.0) + +#Add buses +for bus in nodes_case7 + PSY.add_component!(sys,bus) +end + +#Add lines +for lines in branch_case7 + PSY.add_component!(sys,lines) +end + +#Add loads +for loads in loads_case7 + PSY.add_component!(sys,loads) +end + +#Add infinite source +PSY.add_component!(sys,inf_gen_case7) + +#Add inverter +PSY.add_component!(sys,case7_inv) +#Add generator +PSY.add_component!(sys,case7_gen) ################################################## ############### SOLVE PROBLEM #################### ################################################## -dx0 = zeros(LITS.get_total_rows(case7_DynSystem)) -x0 = [1.00, #V1_R +#time span +tspan = (0.0, 20.0); + +x0_guess = [1.00, #V1_R 1.00, #V2_R 1.00, #V3_R 0.0, #V1_I @@ -192,27 +219,16 @@ x0 = [1.00, #V1_R -0.39, #Vr2, 1.0] #Vm -case7_inv.inner_vars[13] = 0.95 #Vd_cnv var -case7_inv.inner_vars[14] = -0.1 #Vq_cnv var -Ybus_fault = Ybus(branch_case7_fault, nodes_case7)[:,:] -u0 = [0.2] -tspan = (0.0, 20.0); - -#Find initial condition -inif! = (out,x) -> LITS.system_model!(out, dx0 ,x, (u0,case7_DynSystem), 0.0) -sys_solve = nlsolve(inif!, x0, xtol=:1e-8,ftol=:1e-8,method=:trust_region) -x0_init = sys_solve.zero - #Define Fault using Callbacks -cb = DiffEqBase.DiscreteCallback(LITS.change_t_one, LITS.step_change_second!) +Pref_change = LITS.ControlReferenceChange(1.0, case7_gen, LITS.P_ref_index, 0.8) #Define Simulation Problem -sim = Simulation(case7_DynSystem, tspan, u0, cb, x0_init) +sim = LITS.Simulation(sys, tspan, Pref_change, initial_guess = x0_guess) #Solve problem in equilibrium run_simulation!(sim, IDA()); #Obtain data for angles -series = get_state_series(sim, (:Case7Gen, :δ)); +series = get_state_series(sim, ("Case7Gen", :δ)); @test sim.solution.retcode == :Success From fad66d54484f8a44b028483995b3a5c78ec3093a Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Thu, 30 Jan 2020 19:27:39 -0800 Subject: [PATCH 02/13] added tests --- test/{old_tests => }/test_case1_OMIB.jl | 98 +++++++++------ test/{old_tests => }/test_case2_4th_order.jl | 117 ++++++++++++------ test/{old_tests => }/test_case3_6th_order.jl | 116 ++++++++++------- test/{old_tests => }/test_case4_8th_order.jl | 116 ++++++++++------- test/{old_tests => }/test_case5_5shaft.jl | 107 ++++++++++------ test/{old_tests => }/test_case6_DAIB.jl | 67 +++++----- .../test_case7_4th_order_Inverter.jl | 108 +++++++++------- 7 files changed, 451 insertions(+), 278 deletions(-) rename test/{old_tests => }/test_case1_OMIB.jl (64%) rename test/{old_tests => }/test_case2_4th_order.jl (57%) rename test/{old_tests => }/test_case3_6th_order.jl (61%) rename test/{old_tests => }/test_case4_8th_order.jl (60%) rename test/{old_tests => }/test_case5_5shaft.jl (60%) rename test/{old_tests => }/test_case6_DAIB.jl (74%) rename test/{old_tests => }/test_case7_4th_order_Inverter.jl (66%) diff --git a/test/old_tests/test_case1_OMIB.jl b/test/test_case1_OMIB.jl similarity index 64% rename from test/old_tests/test_case1_OMIB.jl rename to test/test_case1_OMIB.jl index e680388..5688a3c 100644 --- a/test/old_tests/test_case1_OMIB.jl +++ b/test/test_case1_OMIB.jl @@ -18,7 +18,7 @@ nodes_case1 = [PSY.Bus(1 , #number 1.05, #Voltage in pu (min=0.94, max=1.06), #Voltage limits in pu 69), #Base voltage in kV - Bus(2 , "Bus 2" , "PV" , 0 , 1.0 , (min=0.94, max=1.06), 69)] + PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.0 , (min=0.94, max=1.06), 69)] branch_case1 = [PSY.Line("Line1", #name true, #available @@ -43,13 +43,21 @@ branch_case1_fault = [PSY.Line("Line1", #name 18.046, #rate in MW 1.04)] #angle limits (-min and max) -loads_case1 = [PowerLoad("Bus1", true, nodes_case1[2], PowerSystems.ConstantPower, 0.3, 0.01, 0.3, 0.01)] +loads_case1 = [PSY.PowerLoad("LBus1", #name + true, #availability + nodes_case1[2], #bus + PowerSystems.ConstantPower, #type + 0.3, #P + 0.01, #Q + 0.3, #P_max + 0.01)] #Q_max ############### Data devices ######################## -inf_gen_case1 = StaticSource(1, #number - :InfBus, #name +inf_gen_case1 = PSY.Source( + "InfBus", #name + true, #availability nodes_case1[1], #bus 1.05, #VR 0.0, #VI @@ -58,7 +66,7 @@ inf_gen_case1 = StaticSource(1, #number ######## Machine Data ######### ### Case 1: Classical machine against infinite bus ### -case1_machine = BaseMachine(0.0, #R +case1_machine = PSY.BaseMachine(0.0, #R 0.2995, #Xd_p 0.7087, #eq_p 100.0) #MVABase @@ -66,30 +74,31 @@ case1_machine = BaseMachine(0.0, #R ######## Shaft Data ######### ### Shaft for Case 1 ### -case1_shaft = SingleMass(3.148, #H +case1_shaft = PSY.SingleMass(3.148, #H 2.0) #D ######## PSS Data ######### -cases_no_pss = PSSFixed(0.0) +cases_no_pss = PSY.PSSFixed(0.0) ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### -case1234_no_tg = TGFixed(1.0) #eff +case1234_no_tg = PSY.TGFixed(1.0) #eff ######## AVR Data ######### -case1_avr = AVRFixed(0.0) #Vf not applicable in Classic Machines +case1_avr = PSY.AVRFixed(0.0) #Vf not applicable in Classic Machines ### Case 1 Generator ### case1_gen = PSY.DynamicGenerator(1, #Number - :Case1Gen, + "Case1Gen", nodes_case1[2], #bus 1.0, # ω_ref, 1.0, #V_ref 0.5, #P_ref + 0.0, #Q_ref case1_machine, #machine case1_shaft, #shaft case1_avr, #avr @@ -99,12 +108,29 @@ case1_gen = PSY.DynamicGenerator(1, #Number ######################### Dynamical System ######################## -case1_DynSystem = PSY.System(nodes_case1, - branch_case1, - [case1_gen], - vcat(inf_gen_case1,loads_case1), - 100.0, - 60.0) +#Create system with BasePower = 100 MVA and nominal frequency 60 Hz. +sys = PSY.System(100.0, frequency = 60.0); + +#Add buses +for bus in nodes_case1 + PSY.add_component!(sys,bus) +end + +#Add lines +for lines in branch_case1 + PSY.add_component!(sys,lines) +end + +#Add loads +for loads in loads_case1 + PSY.add_component!(sys,loads) +end + +#Add infinite source +PSY.add_component!(sys,inf_gen_case1) + +#Add generator +PSY.add_component!(sys,case1_gen) ################################################## @@ -112,33 +138,35 @@ case1_DynSystem = PSY.System(nodes_case1, ################################################## #Compute Y_bus after fault -Ybus_fault = PSY.Ybus(branch_case1_fault, nodes_case1)[:,:] - -#Initialize variables -dx0 = zeros(LITS.get_total_rows(case1_DynSystem)) -x0 = [1.05, #VR_1 - 1.0, #VR_2 - 0.0, #VI_1 - 0.01, #VI_2 - 0.2, #δ - 1.0] #ω -tspan = (0.0, 30.0); +sys2 = PSY.System(100.0, frequency = 60.0); +#Add buses +for bus in nodes_case1 + PSY.add_component!(sys2, bus) +end + +#Add lines +for lines in branch_case1_fault + PSY.add_component!(sys2, lines) +end +Ybus_fault = PSY.Ybus(sys2)[:,:] -#Find initial condition -inif! = (out,x) -> LITS.system_model!(out, dx0 ,x, (Ybus_fault,case1_DynSystem), 0.0) -sys_solve = nlsolve(inif!, x0) -x0_init = sys_solve.zero +tspan = (0.0, 30.0); -#Define Fault using Callbacks -cb = DiffEqBase.DiscreteCallback(LITS.change_t_one, LITS.Y_change!) +#Define Fault: Change of YBus +Ybus_change = ThreePhaseFault(1.0, #change at t = 1.0 + Ybus_fault) #New YBus #Define Simulation Problem -sim = Simulation(case1_DynSystem, tspan, Ybus_fault, cb, x0_init) +sim = Simulation(sys, #system + tspan, #time span + Ybus_change) #Type of Fault #Solve problem in equilibrium run_simulation!(sim, IDA(), dtmax=0.02); #Obtain data for angles -series = get_state_series(sim, (:Case1Gen, :δ)); +series = get_state_series(sim, ("Case1Gen", :δ)); +series2 = get_voltagemag_series(sim, 2) +LITS.print_init_states(sim) @test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case2_4th_order.jl b/test/test_case2_4th_order.jl similarity index 57% rename from test/old_tests/test_case2_4th_order.jl rename to test/test_case2_4th_order.jl index 4c19bc6..0191034 100644 --- a/test/old_tests/test_case2_4th_order.jl +++ b/test/test_case2_4th_order.jl @@ -11,27 +11,28 @@ and the generator located in bus 3. ############### Data Network ######################## -nodes_case234 = [Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] +nodes_case234 = [PSY.Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), + PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), + PSY.Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] -branch_case234 = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +branch_case234 = [PSY.Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] #Trip of Line 1. -branch_case234_fault = [Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +branch_case234_fault = [PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] -loads_case234 = [PowerLoad("Bus1", true, nodes_case234[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), - PowerLoad("Bus2", true, nodes_case234[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), - PowerLoad("Bus3", true, nodes_case234[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] +loads_case234 = [PSY.PowerLoad("Bus1", true, nodes_case234[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), + PSY.PowerLoad("Bus2", true, nodes_case234[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), + PSY.PowerLoad("Bus3", true, nodes_case234[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] ############### Data devices ######################## -inf_gen_case234 = StaticSource(1, #number - :InfBus, #name +inf_gen_case234 = PSY.Source( + "InfBus", #name + true, #availability nodes_case234[1], #bus 1.02, #VR 0.0, #VI @@ -40,7 +41,7 @@ inf_gen_case234 = StaticSource(1, #number ######## Machine Data ######### ### Case 2: 4th Order Model with AVR (3-bus case) ### -case2_machine2 = OneDOneQMachine(0.0, #R +case2_machine2 = PSY.OneDOneQMachine(0.0, #R 1.3125, #Xd 1.2578, #Xq 0.1813, #Xd_p @@ -49,7 +50,7 @@ case2_machine2 = OneDOneQMachine(0.0, #R 0.6, #Tq0_p 100.0) #MVABase -case2_machine3 = OneDOneQMachine(0.0, #R +case2_machine3 = PSY.OneDOneQMachine(0.0, #R 1.3125, #Xd 1.2578, #Xq 0.1813, #Xd_p @@ -61,26 +62,26 @@ case2_machine3 = OneDOneQMachine(0.0, #R ######## Shaft Data ######### ### Shafts for Gens 2 and 3: Cases 2, 3 and 4 ### -case234_shaft2 = SingleMass(3.01, #H (M = 6.02 -> H = M/2) +case234_shaft2 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) 0.0) #D -case234_shaft3 = SingleMass(3.01, #H (M = 6.02 -> H = M/2) +case234_shaft3 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) 0.0) #D ######## PSS Data ######### -cases_no_pss = PSSFixed(0.0) +cases_no_pss = PSY.PSSFixed(0.0) ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### -case1234_no_tg = TGFixed(1.0) #eff +case1234_no_tg = PSY.TGFixed(1.0) #eff ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case2345_avr2 = AVRTypeI(20.0, #Ka - Gain +case2345_avr2 = PSY.AVRTypeI(20.0, #Ka - Gain 0.01, #Ke 0.063, #Kf 0.2, #Ta @@ -92,7 +93,7 @@ case2345_avr2 = AVRTypeI(20.0, #Ka - Gain 0.0039, #Ae - 1st ceiling coefficient 1.555) #Be - 2nd ceiling coefficient -case2345_avr3 = AVRTypeI(20.0, #Ka - Gain +case2345_avr3 = PSY.AVRTypeI(20.0, #Ka - Gain 0.01, #Ke 0.063, #Kf 0.2, #Ta @@ -106,11 +107,12 @@ case2345_avr3 = AVRTypeI(20.0, #Ka - Gain ### Case 2 Generators ### case2_gen2 = PSY.DynamicGenerator(1, #Number - :Case2Gen2, + "Case2Gen2", nodes_case234[2], #bus 1.0, # ω_ref, 1.0142, #V_ref 1.0, #P_ref + 0.0, #Q_ref case2_machine2, #machine case234_shaft2, #shaft case2345_avr2, #avr @@ -118,11 +120,12 @@ case2_gen2 = PSY.DynamicGenerator(1, #Number cases_no_pss) #pss case2_gen3 = PSY.DynamicGenerator(2, #Number - :Case2Gen3, + "Case2Gen3", nodes_case234[3], #bus 1.0, # ω_ref, 1.0059, #V_ref 1.0, #P_ref + 0.0, #Q_ref case2_machine3, #machine case234_shaft3, #shaft case2345_avr3, #avr @@ -131,12 +134,31 @@ case2_gen3 = PSY.DynamicGenerator(2, #Number ######################### Dynamical System ######################## -case2_DynSystem = PSY.System(nodes_case234, - branch_case234, - [case2_gen2, case2_gen3], - vcat(inf_gen_case234,loads_case234), - 100.0, - 60.0) + +#Create system with BasePower = 100 MVA and nominal frequency 60 Hz. +sys = PSY.System(100.0, frequency = 60.0); + +#Add buses +for bus in nodes_case234 + PSY.add_component!(sys,bus) +end + +#Add lines +for lines in branch_case234 + PSY.add_component!(sys,lines) +end + +#Add loads +for loads in loads_case234 + PSY.add_component!(sys,loads) +end + +#Add infinite source +PSY.add_component!(sys,inf_gen_case234) + +#Add generators +PSY.add_component!(sys,case2_gen2) +PSY.add_component!(sys,case2_gen3) ################################################## @@ -145,11 +167,22 @@ case2_DynSystem = PSY.System(nodes_case234, #Compute Y_bus after fault -Ybus_fault = PSY.Ybus(branch_case234_fault, nodes_case234)[:,:] +sys2 = PSY.System(100.0, frequency = 60.0); +#Add buses +for bus in nodes_case234 + PSY.add_component!(sys2, bus) +end +#Add lines +for lines in branch_case234_fault + PSY.add_component!(sys2, lines) +end +Ybus_fault = PSY.Ybus(sys2)[:,:] + +#time span +tspan = (0.0, 30.0); -#Initialize variables -dx0 = zeros(LITS.get_total_rows(case2_DynSystem)) -x0 = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, +#Initial guess +x0_guess = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, 1.0, #eq_p 0.47, #ed_p 0.6, #δ @@ -166,20 +199,22 @@ x0 = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, 0.11, #Vr1 -0.31, #Vr2, 1.0] #Vm -tspan = (0.0, 30.0); -#Find initial condition -inif! = (out,x) -> LITS.system_model!(out, dx0 ,x, (Ybus_fault,case2_DynSystem), 0.0) -sys_solve = nlsolve(inif!, x0) -x0_init = sys_solve.zero -cb = DiffEqBase.DiscreteCallback(LITS.change_t_one, LITS.Y_change!) -sim = Simulation(case2_DynSystem, tspan, Ybus_fault, cb, x0_init) +#Define Fault: Change of YBus +Ybus_change = ThreePhaseFault(1.0, #change at t = 1.0 + Ybus_fault) #New YBus + +#Define Simulation Problem +sim = Simulation(sys, #system + tspan, #time span + Ybus_change, #Type of Fault + initial_guess = x0_guess) #initial guess #Solve problem in equilibrium run_simulation!(sim, IDA()); #Obtain data for angles -series = get_state_series(sim, (:Case2Gen2, :δ)); +series = get_state_series(sim, ("Case2Gen2", :δ)); @test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case3_6th_order.jl b/test/test_case3_6th_order.jl similarity index 61% rename from test/old_tests/test_case3_6th_order.jl rename to test/test_case3_6th_order.jl index cd33a0f..9377e13 100644 --- a/test/old_tests/test_case3_6th_order.jl +++ b/test/test_case3_6th_order.jl @@ -11,27 +11,28 @@ and the generator located in bus 3. ############### Data Network ######################## -nodes_case234 = [Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] +nodes_case234 = [PSY.Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), + PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), + PSY.Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] -branch_case234 = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +branch_case234 = [PSY.Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] #Trip of Line 1. -branch_case234_fault = [Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +branch_case234_fault = [PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] -loads_case234 = [PowerLoad("Bus1", true, nodes_case234[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), - PowerLoad("Bus2", true, nodes_case234[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), - PowerLoad("Bus3", true, nodes_case234[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] +loads_case234 = [PSY.PowerLoad("Bus1", true, nodes_case234[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), + PSY.PowerLoad("Bus2", true, nodes_case234[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), + PSY.PowerLoad("Bus3", true, nodes_case234[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] ############### Data devices ######################## -inf_gen_case234 = StaticSource(1, #number - :InfBus, #name +inf_gen_case234 = PSY.Source( + "InfBus", #name + true, #availability nodes_case234[1], #bus 1.02, #VR 0.0, #VI @@ -40,7 +41,7 @@ inf_gen_case234 = StaticSource(1, #number ######## Machine Data ######### ### Case 3: 6th Order Model with AVR (3-bus case) ### -case3_machine2 = SimpleMarconatoMachine(0.0, +case3_machine2 = PSY.SimpleMarconatoMachine(0.0, 1.3125, #Xd 1.2578, #Xq 0.1813, #Xd_p @@ -54,7 +55,7 @@ case3_machine2 = SimpleMarconatoMachine(0.0, 0.0, #T_AA 100.0) #MVABase -case3_machine3 = SimpleMarconatoMachine(0.0, +case3_machine3 = PSY.SimpleMarconatoMachine(0.0, 1.3125, #Xd 1.2578, #Xq 0.1813, #Xd_p @@ -71,26 +72,26 @@ case3_machine3 = SimpleMarconatoMachine(0.0, ######## Shaft Data ######### ### Shafts for Gens 2 and 3: Cases 2, 3 and 4 ### -case234_shaft2 = SingleMass(3.01, #H (M = 6.02 -> H = M/2) +case234_shaft2 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) 0.0) #D -case234_shaft3 = SingleMass(3.01, #H (M = 6.02 -> H = M/2) +case234_shaft3 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) 0.0) #D ######## PSS Data ######### -cases_no_pss = PSSFixed(0.0) +cases_no_pss = PSY.PSSFixed(0.0) ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### -case1234_no_tg = TGFixed(1.0) #eff +case1234_no_tg = PSY.TGFixed(1.0) #eff ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case2345_avr2 = AVRTypeI(20.0, #Ka - Gain +case2345_avr2 = PSY.AVRTypeI(20.0, #Ka - Gain 0.01, #Ke 0.063, #Kf 0.2, #Ta @@ -102,7 +103,7 @@ case2345_avr2 = AVRTypeI(20.0, #Ka - Gain 0.0039, #Ae - 1st ceiling coefficient 1.555) #Be - 2nd ceiling coefficient -case2345_avr3 = AVRTypeI(20.0, #Ka - Gain +case2345_avr3 = PSY.AVRTypeI(20.0, #Ka - Gain 0.01, #Ke 0.063, #Kf 0.2, #Ta @@ -116,11 +117,12 @@ case2345_avr3 = AVRTypeI(20.0, #Ka - Gain ### Case 3 Generators ### case3_gen2 = PSY.DynamicGenerator(1, #Number - :Case3Gen2, + "Case3Gen2", nodes_case234[2], #bus 1.0, # ω_ref, 1.0142, #V_ref 1.0, #P_ref + 0.0, #Q_ref case3_machine2, #machine case234_shaft2, #shaft case2345_avr2, #avr @@ -128,11 +130,12 @@ case3_gen2 = PSY.DynamicGenerator(1, #Number cases_no_pss) #pss case3_gen3 = PSY.DynamicGenerator(2, #Number - :Case3Gen3, + "Case3Gen3", nodes_case234[3], #bus 1.0, # ω_ref, 1.0059, #V_ref 1.0, #P_ref + 0.0, #Q_ref case3_machine3, #machine case234_shaft3, #shaft case2345_avr3, #avr @@ -142,12 +145,30 @@ case3_gen3 = PSY.DynamicGenerator(2, #Number ######################### Dynamical System ######################## -case3_DynSystem = PSY.System(nodes_case234, - branch_case234, - [case3_gen2, case3_gen3], - vcat(inf_gen_case234,loads_case234), - 100.0, - 60.0) +#Create system with BasePower = 100 MVA and nominal frequency 60 Hz. +sys = PSY.System(100.0, frequency = 60.0); + +#Add buses +for bus in nodes_case234 + PSY.add_component!(sys,bus) +end + +#Add lines +for lines in branch_case234 + PSY.add_component!(sys,lines) +end + +#Add loads +for loads in loads_case234 + PSY.add_component!(sys,loads) +end + +#Add infinite source +PSY.add_component!(sys,inf_gen_case234) + +#Add generators +PSY.add_component!(sys,case3_gen2) +PSY.add_component!(sys,case3_gen3) ################################################## @@ -157,11 +178,22 @@ case3_DynSystem = PSY.System(nodes_case234, #Compute Y_bus after fault -Ybus_fault = PSY.Ybus(branch_case234_fault, nodes_case234)[:,:] +sys2 = PSY.System(100.0, frequency = 60.0); +#Add buses +for bus in nodes_case234 + PSY.add_component!(sys2, bus) +end +#Add lines +for lines in branch_case234_fault + PSY.add_component!(sys2, lines) +end +Ybus_fault = PSY.Ybus(sys2)[:,:] + +#time span +tspan = (0.0, 20.0); -#Initialize variables -dx0 = zeros(LITS.get_total_rows(case3_DynSystem)) -x0 = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, +#Initial guess +x0_guess = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, 1.0, #eq_p 0.47, #ed_p 0.95, #eq_pp @@ -182,23 +214,21 @@ x0 = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, 0.11, #Vr1 -0.31, #Vr2, 1.0] #Vm -tspan = (0.0, 20.0); - -#Find initial condition -inif! = (out,x) -> LITS.system_model!(out, dx0 ,x, (Ybus_fault,case3_DynSystem), 0.0) -sys_solve = nlsolve(inif!, x0) -x0_init = sys_solve.zero -#Define Fault using Callbacks -cb = DiffEqBase.DiscreteCallback(LITS.change_t_one, LITS.Y_change!) +#Define Fault: Change of YBus +Ybus_change = ThreePhaseFault(1.0, #change at t = 1.0 + Ybus_fault) #New YBus #Define Simulation Problem -sim = Simulation(case3_DynSystem, tspan, Ybus_fault, cb, x0_init) +sim = Simulation(sys, #system + tspan, #time span + Ybus_change, #Type of Fault + initial_guess = x0_guess) #initial guess #Solve problem in equilibrium run_simulation!(sim, IDA()); #Obtain data for angles -series = get_state_series(sim, (:Case3Gen2, :δ)); +series = get_state_series(sim, ("Case3Gen2", :δ)); @test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case4_8th_order.jl b/test/test_case4_8th_order.jl similarity index 60% rename from test/old_tests/test_case4_8th_order.jl rename to test/test_case4_8th_order.jl index d0d9f6e..5d83a38 100644 --- a/test/old_tests/test_case4_8th_order.jl +++ b/test/test_case4_8th_order.jl @@ -12,27 +12,28 @@ and the generator located in bus 3. ############### Data Network ######################## -nodes_case234 = [Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] +nodes_case234 = [PSY.Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), + PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), + PSY.Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] -branch_case234 = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +branch_case234 = [PSY.Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] #Trip of Line 1. -branch_case234_fault = [Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +branch_case234_fault = [PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] -loads_case234 = [PowerLoad("Bus1", true, nodes_case234[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), - PowerLoad("Bus2", true, nodes_case234[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), - PowerLoad("Bus3", true, nodes_case234[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] +loads_case234 = [PSY.PowerLoad("Bus1", true, nodes_case234[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), + PSY.PowerLoad("Bus2", true, nodes_case234[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), + PSY.PowerLoad("Bus3", true, nodes_case234[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] ############### Data devices ######################## -inf_gen_case234 = StaticSource(1, #number - :InfBus, #name +inf_gen_case234 = PSY.Source( + "InfBus", #name + true, #availability nodes_case234[1], #bus 1.02, #VR 0.0, #VI @@ -41,7 +42,7 @@ inf_gen_case234 = StaticSource(1, #number ######## Machine Data ######### ### Case 4: 8th Order Model with AVR (3-bus case) ### -case4_machine2 = MarconatoMachine(0.0, +case4_machine2 = PSY.MarconatoMachine(0.0, 1.3125, #Xd 1.2578, #Xq 0.1813, #Xd_p @@ -56,7 +57,7 @@ case4_machine2 = MarconatoMachine(0.0, 100.0) #MVABase -case4_machine3 = MarconatoMachine(0.0, +case4_machine3 = PSY.MarconatoMachine(0.0, 1.3125, #Xd 1.2578, #Xq 0.1813, #Xd_p @@ -73,26 +74,26 @@ case4_machine3 = MarconatoMachine(0.0, ######## Shaft Data ######### ### Shafts for Gens 2 and 3: Cases 2, 3 and 4 ### -case234_shaft2 = SingleMass(3.01, #H (M = 6.02 -> H = M/2) +case234_shaft2 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) 0.0) #D -case234_shaft3 = SingleMass(3.01, #H (M = 6.02 -> H = M/2) +case234_shaft3 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) 0.0) #D ######## PSS Data ######### -cases_no_pss = PSSFixed(0.0) +cases_no_pss = PSY.PSSFixed(0.0) ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### -case1234_no_tg = TGFixed(1.0) #eff +case1234_no_tg = PSY.TGFixed(1.0) #eff ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case2345_avr2 = AVRTypeI(20.0, #Ka - Gain +case2345_avr2 = PSY.AVRTypeI(20.0, #Ka - Gain 0.01, #Ke 0.063, #Kf 0.2, #Ta @@ -104,7 +105,7 @@ case2345_avr2 = AVRTypeI(20.0, #Ka - Gain 0.0039, #Ae - 1st ceiling coefficient 1.555) #Be - 2nd ceiling coefficient -case2345_avr3 = AVRTypeI(20.0, #Ka - Gain +case2345_avr3 = PSY.AVRTypeI(20.0, #Ka - Gain 0.01, #Ke 0.063, #Kf 0.2, #Ta @@ -118,11 +119,12 @@ case2345_avr3 = AVRTypeI(20.0, #Ka - Gain ### Case 4 Generators ### case4_gen2 = PSY.DynamicGenerator(1, #Number - :Case4Gen2, + "Case4Gen2", nodes_case234[2], #bus 1.0, # ω_ref, 1.0142, #V_ref 1.0, #P_ref + 0.0, #Q_ref case4_machine2, #machine case234_shaft2, #shaft case2345_avr2, #avr @@ -130,11 +132,12 @@ case4_gen2 = PSY.DynamicGenerator(1, #Number cases_no_pss) #pss case4_gen3 = PSY.DynamicGenerator(2, #Number - :Case4Gen3, + "Case4Gen3", nodes_case234[3], #bus 1.0, # ω_ref, 1.0059, #V_ref 1.0, #P_ref + 0.0, #Q_ref case4_machine3, #machine case234_shaft3, #shaft case2345_avr3, #avr @@ -144,25 +147,53 @@ case4_gen3 = PSY.DynamicGenerator(2, #Number ######################### Dynamical System ######################## -case4_DynSystem = PSY.System(nodes_case234, - branch_case234, - [case4_gen2, case4_gen3], - vcat(inf_gen_case234,loads_case234), - 100.0, - 60.0) +#Create system with BasePower = 100 MVA and nominal frequency 60 Hz. +sys = PSY.System(100.0, frequency = 60.0); + +#Add buses +for bus in nodes_case234 + PSY.add_component!(sys,bus) +end + +#Add lines +for lines in branch_case234 + PSY.add_component!(sys,lines) +end + +#Add loads +for loads in loads_case234 + PSY.add_component!(sys,loads) +end + +#Add infinite source +PSY.add_component!(sys,inf_gen_case234) + +#Add generators +PSY.add_component!(sys,case4_gen2) +PSY.add_component!(sys,case4_gen3) ################################################## ############### SOLVE PROBLEM #################### ################################################## - #Compute Y_bus after fault -Ybus_fault = PSY.Ybus(branch_case234_fault, nodes_case234)[:,:]; +sys2 = PSY.System(100.0, frequency = 60.0); +#Add buses +for bus in nodes_case234 + PSY.add_component!(sys2, bus) +end +#Add lines +for lines in branch_case234_fault + PSY.add_component!(sys2, lines) +end +Ybus_fault = PSY.Ybus(sys2)[:,:] + +#time span +tspan = (0.0, 20.0); -#Initialize variables -dx0 = zeros(LITS.get_total_rows(case4_DynSystem)) -x0 = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, +#Initial guess +x0_guess = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, -0.5, #ψq 0.8, #ψd 1.0, #eq_p @@ -187,23 +218,22 @@ x0 = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, 0.11, #Vr1 -0.31, #Vr2, 1.0] #Vm -tspan = (0.0, 20.0); -#Find initial condition -inif! = (out,x) -> LITS.system_model!(out, dx0 ,x, (Ybus_fault,case4_DynSystem), 0.0) -sys_solve = nlsolve(inif!, x0) -x0_init = sys_solve.zero -#Define Fault using Callbacks -cb = DiffEqBase.DiscreteCallback(LITS.change_t_one, LITS.Y_change!) +#Define Fault: Change of YBus +Ybus_change = ThreePhaseFault(1.0, #change at t = 1.0 + Ybus_fault) #New YBus #Define Simulation Problem -sim = Simulation(case4_DynSystem, tspan, Ybus_fault, cb, x0_init) +sim = Simulation(sys, #system + tspan, #time span + Ybus_change, #Type of Fault + initial_guess = x0_guess) #initial guess #Solve problem in equilibrium run_simulation!(sim, IDA()); #Obtain data for angles -series = get_state_series(sim, (:Case4Gen2, :δ)); +series = get_state_series(sim, ("Case4Gen2", :δ)); @test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case5_5shaft.jl b/test/test_case5_5shaft.jl similarity index 60% rename from test/old_tests/test_case5_5shaft.jl rename to test/test_case5_5shaft.jl index ba0a370..df37ded 100644 --- a/test/old_tests/test_case5_5shaft.jl +++ b/test/test_case5_5shaft.jl @@ -11,27 +11,28 @@ The fault disconnects a circuit between buses 1 and 2, doubling its impedance. ############### Data Network ######################## -nodes_case5 = [Bus(1 , "Bus 1" , "REF" , 0 , 1.05 , (min=0.94, max=1.06), 138), - Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] +nodes_case5 = [PSY.Bus(1 , "Bus 1" , "REF" , 0 , 1.05 , (min=0.94, max=1.06), 138), + PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), + PSY.Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] -branch_case5 = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[2]), 0.01, 0.05, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case5[2], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04)] +branch_case5 = [PSY.Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[2]), 0.01, 0.05, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case5[2], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04)] #Trip of a single circuit of Line 1 -> Resistance and Reactance doubled. -branch_case5_fault = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[2]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case5[2], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04)] +branch_case5_fault = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[2]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), + Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case5[2], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), + Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04)] -loads_case5 = [PowerLoad("Bus2", true, nodes_case5[2], PowerSystems.ConstantPower, 0.3, 0.05, 0.3, 0.05), - PowerLoad("Bus3", true, nodes_case5[3], PowerSystems.ConstantPower, 0.3, 0.05, 0.3, 0.05)] +loads_case5 = [PSY.PowerLoad("Bus2", true, nodes_case5[2], PowerSystems.ConstantPower, 0.3, 0.05, 0.3, 0.05), + PSY.PowerLoad("Bus3", true, nodes_case5[3], PowerSystems.ConstantPower, 0.3, 0.05, 0.3, 0.05)] ############### Data devices ######################## -inf_gen_case5 = StaticSource(1, #number - :InfBus, #name +inf_gen_case5 = PSY.Source( + "InfBus", #name + true, #availability nodes_case5[1], #bus 1.00, #VR 0.0, #VI @@ -40,7 +41,7 @@ inf_gen_case5 = StaticSource(1, #number ######## Machine Data ######### ### Case 5: 4th Order Model with AVR + TG + Multishaft ### -case5_machine = OneDOneQMachine(0.0, #R +case5_machine = PSY.OneDOneQMachine(0.0, #R 1.3125, #Xd 1.2578, #Xq 0.1813, #Xd_p @@ -51,7 +52,7 @@ case5_machine = OneDOneQMachine(0.0, #R ######## Shaft Data ######### -case5_shaft = FiveMassShaft(3.01, #5.148, #H +case5_shaft = PSY.FiveMassShaft(3.01, #5.148, #H 0.3348, #H_hp 0.7306, #H_ip 0.8154, #H_lp @@ -72,13 +73,13 @@ case5_shaft = FiveMassShaft(3.01, #5.148, #H ######## PSS Data ######### -cases_no_pss = PSSFixed(0.0) +cases_no_pss = PSY.PSSFixed(0.0) ######## TG Data ######### ### TG for Case 5 ### -case5_tg = TGTypeII(0.05, #R +case5_tg = PSY.TGTypeII(0.05, #R 1.0, #T1 2.0, #T2 1.5, #τ_max @@ -86,7 +87,7 @@ case5_tg = TGTypeII(0.05, #R ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case5_avr = AVRTypeI(20.0, #Ka - Gain +case5_avr = PSY.AVRTypeI(20.0, #Ka - Gain 0.01, #Ke 0.063, #Kf 0.2, #Ta @@ -102,11 +103,12 @@ case5_avr = AVRTypeI(20.0, #Ka - Gain ### Case 5 Generator ### case5_gen = PSY.DynamicGenerator(1, #Number - :Case5Gen, + "Case5Gen", nodes_case5[2], #bus 1.0, # ω_ref, 1.0155, #V_ref 0.5, #P_ref + 0.0, #Q_ref case5_machine, #machine case5_shaft, #shaft case5_avr, #avr @@ -116,25 +118,52 @@ case5_gen = PSY.DynamicGenerator(1, #Number ######################### Dynamical System ######################## -case5_DynSystem = PSY.System(nodes_case5, - branch_case5, - [case5_gen], - vcat(inf_gen_case5,loads_case5), - 100.0, - 60.0) +#Create system with BasePower = 100 MVA and nominal frequency 60 Hz. +sys = PSY.System(100.0, frequency = 60.0); + +#Add buses +for bus in nodes_case5 + PSY.add_component!(sys,bus) +end + +#Add lines +for lines in branch_case5 + PSY.add_component!(sys,lines) +end + +#Add loads +for loads in loads_case5 + PSY.add_component!(sys,loads) +end + +#Add infinite source +PSY.add_component!(sys,inf_gen_case5) + +#Add generators +PSY.add_component!(sys,case5_gen) ################################################## ############### SOLVE PROBLEM #################### ################################################## - #Compute Y_bus after fault -Ybus_fault = PSY.Ybus(branch_case5_fault, nodes_case5)[:,:]; +sys2 = PSY.System(100.0, frequency = 60.0); +#Add buses +for bus in nodes_case5 + PSY.add_component!(sys2, bus) +end +#Add lines +for lines in branch_case5_fault + PSY.add_component!(sys2, lines) +end +Ybus_fault = PSY.Ybus(sys2)[:,:] + +#time span +tspan = (0.0, 20.0); -#Initialize variables -dx0 = zeros(LITS.get_total_rows(case5_DynSystem)) -x0 = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, +#Initial guess +x0_guess = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, 1.0, #eq_p 0.0, #ed_p 0.05, #δ @@ -152,23 +181,21 @@ x0 = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, -0.1, #Vr2, 1.0, #Vm 0.0] #xg -tspan = (0.0, 20.0); - -#Find initial condition -inif! = (out,x) -> LITS.system_model!(out, dx0 ,x, (Ybus_fault,case5_DynSystem), 0.0) -sys_solve = nlsolve(inif!, x0) -x0_init = sys_solve.zero -#Define Fault using Callbacks -cb = DiffEqBase.DiscreteCallback(LITS.change_t_one, LITS.Y_change!) +#Define Fault: Change of YBus +Ybus_change = ThreePhaseFault(1.0, #change at t = 1.0 + Ybus_fault) #New YBus #Define Simulation Problem -sim = Simulation(case5_DynSystem, tspan, Ybus_fault, cb, x0_init) +sim = Simulation(sys, #system + tspan, #time span + Ybus_change, #Type of Fault + initial_guess = x0_guess) #initial guess #Solve problem in equilibrium run_simulation!(sim, IDA()); #Obtain data for angles -series = get_state_series(sim, (:Case5Gen, :δ)); +series = get_state_series(sim, ("Case5Gen", :δ)); @test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case6_DAIB.jl b/test/test_case6_DAIB.jl similarity index 74% rename from test/old_tests/test_case6_DAIB.jl rename to test/test_case6_DAIB.jl index f8b85de..bd549eb 100644 --- a/test/old_tests/test_case6_DAIB.jl +++ b/test/test_case6_DAIB.jl @@ -10,17 +10,17 @@ The perturbation increase the reference power (analogy for mechanical power) fro ############### Data Network ######################## -nodes_DAIB= [Bus(1 , #number +nodes_DAIB= [PSY.Bus(1 , #number "Bus 1", #Name "REF" , #BusType (REF, PV, PQ) 0, #Angle in radians 1.04, #Voltage in pu (min=0.94, max=1.06), #Voltage limits in pu 0.69), #Base voltage in kV - Bus(2 , "Bus 2" , "PV" , 0 , 1.0 , (min=0.94, max=1.06), 0.69)] + PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.0 , (min=0.94, max=1.06), 0.69)] -branch_DAIB = [Line("Line1", #name +branch_DAIB = [PSY.Line("Line1", #name true, #available 0.0, #active power flow initial condition (from-to) 0.0, #reactive power flow initial condition (from-to) @@ -33,8 +33,8 @@ branch_DAIB = [Line("Line1", #name ############### Data devices ######################## -inf_gen_DAIB = StaticSource(1, #number - :InfBus, #name +inf_gen_DAIB = PSY.Source("InfBus", #name + true, #availability nodes_DAIB[1],#bus 1.00, #VR 0.0, #VI @@ -42,32 +42,32 @@ inf_gen_DAIB = StaticSource(1, #number ############### Inverter Data ######################## -converter = AvgCnvFixedDC(690.0, #Rated Voltage +converter = PSY.AvgCnvFixedDC(690.0, #Rated Voltage 2.75) #Rated MVA -dc_source = FixedDCSource(600.0) #Not in the original data, guessed. +dc_source = PSY.FixedDCSource(600.0) #Not in the original data, guessed. -filt = LCLFilter(0.08, #Series inductance lf in pu +filt = PSY.LCLFilter(0.08, #Series inductance lf in pu 0.003, #Series resitance rf in pu 0.074, #Shunt capacitance cf in pu 0.2, #Series ractance rg to grid connection (#Step up transformer or similar) 0.01) #Series resistance lg to grid connection (#Step up transformer or similar) -pll = PLL(500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. +pll = PSY.PLL(500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. 0.084, #k_p: PLL proportional gain 4.69) #k_i: PLL integral gain -virtual_H = VirtualInertia(2.0, #Ta:: VSM inertia constant +virtual_H = PSY.VirtualInertia(2.0, #Ta:: VSM inertia constant 400.0, #kd:: VSM damping coefficient 20.0, #kω:: Frequency droop gain in pu 2*pi*50.0) #ωb:: Rated angular frequency -Q_control = ReactivePowerDroop(0.2, #kq:: Reactive power droop gain in pu +Q_control = PSY.ReactivePowerDroop(0.2, #kq:: Reactive power droop gain in pu 1000.0) #ωf:: Reactive power cut-off low pass filter frequency -outer_control = VirtualInertiaQdroop(virtual_H, Q_control) +outer_control = PSY.VirtualInertiaQdroop(virtual_H, Q_control) -vsc = CombinedVIwithVZ(0.59, #kpv:: Voltage controller proportional gain +vsc = PSY.CombinedVIwithVZ(0.59, #kpv:: Voltage controller proportional gain 736.0, #kiv:: Voltage controller integral gain 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers 0.0, #rv:: Virtual resistance in pu @@ -79,7 +79,7 @@ vsc = CombinedVIwithVZ(0.59, #kpv:: Voltage controller proportional gain 0.2) #kad:: Active damping gain Darco_Inverter = PSY.DynamicInverter(1, #number - :DARCO, #name + "DARCO", #name nodes_DAIB[2], #bus location 1.0, #ω_ref 1.02, #V_ref @@ -96,16 +96,31 @@ Darco_Inverter = PSY.DynamicInverter(1, #number ######################### Dynamical System ######################## -DAIB = PSY.System(nodes_DAIB, branch_DAIB, [Darco_Inverter], [inf_gen_DAIB], 100.0, 50.0); +#Create system with BasePower = 100 MVA and nominal frequency 50 Hz. +sys = PSY.System(100, frequency=50.0) +#Add buses +for bus in nodes_DAIB + PSY.add_component!(sys,bus) +end +#Add lines +for lines in branch_DAIB + PSY.add_component!(sys,lines) +end +#Add infinite source +PSY.add_component!(sys,inf_gen_DAIB) +#Add inverter +PSY.add_component!(sys,Darco_Inverter) ################################################## ############### SOLVE PROBLEM #################### ################################################## -#Initialize variables -dx0 = zeros(LITS.get_total_rows(DAIB)) -x0 = [1.00, #V1_R +#time span +tspan = (0.0, 4.0); + +#Initial guess +x0_guess = [1.00, #V1_R 1.0648, #V2_R 0.0, #V1_I 0.001, #V2_I @@ -128,26 +143,18 @@ x0 = [1.00, #V1_R -0.1, #voq 0.49, #iod -0.1] #ioq -Darco_Inverter.inner_vars[13] = 0.95 #Vd_cnv var -Darco_Inverter.inner_vars[14] = -0.1 #Vq_cnv var -u0 = [0.2] #Increase in P_ref -tspan = (0.0, 4.0); -#Find initial condition -inif! = (out,x) -> LITS.system_model!(out, dx0 ,x, (u0,DAIB), 0.0) -sys_solve = nlsolve(inif!, x0, xtol=:1e-8,ftol=:1e-8,method=:trust_region) -x0_init = sys_solve.zero #Define Fault using Callbacks -cb = DiffEqBase.DiscreteCallback(LITS.change_t_one, LITS.step_change_first!) +Pref_change = LITS.ControlReferenceChange(1.0, Darco_Inverter, LITS.P_ref_index, 0.7) #Define Simulation Problem -sim = Simulation(DAIB, tspan, u0, cb, x0_init) +sim = LITS.Simulation(sys, tspan, Pref_change, initial_guess = x0_guess) #Solve problem in equilibrium -run_simulation!(sim, IDA()); +run_simulation!(sim, Sundials.IDA()); #Obtain data for angles -series = get_state_series(sim, (:DARCO, :δω_vsm)); +series = get_state_series(sim, ("DARCO", :δω_vsm)) @test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case7_4th_order_Inverter.jl b/test/test_case7_4th_order_Inverter.jl similarity index 66% rename from test/old_tests/test_case7_4th_order_Inverter.jl rename to test/test_case7_4th_order_Inverter.jl index db86a66..402f10e 100644 --- a/test/old_tests/test_case7_4th_order_Inverter.jl +++ b/test/test_case7_4th_order_Inverter.jl @@ -11,28 +11,28 @@ The perturbation increase the reference power (analogy for mechanical power) of ############### Data Network ######################## -nodes_case7 = [Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - Bus(3 , "Bus 3" , "PQ" , 0 , 1.00 , (min=0.94, max=1.06), 138)] +nodes_case7 = [PSY.Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), + PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), + PSY.Bus(3 , "Bus 3" , "PQ" , 0 , 1.00 , (min=0.94, max=1.06), 138)] -branch_case7 = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case7[1], to=nodes_case7[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case7[1], to=nodes_case7[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case7[2], to=nodes_case7[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +branch_case7 = [PSY.Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case7[1], to=nodes_case7[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case7[1], to=nodes_case7[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case7[2], to=nodes_case7[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] #Trip of Line 1. -branch_case7_fault = [Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case7[1], to=nodes_case7[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case7[2], to=nodes_case7[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +branch_case7_fault = [PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case7[1], to=nodes_case7[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), + PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case7[2], to=nodes_case7[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] - -loads_case7 = [PowerLoad("Bus1", true, nodes_case7[1], PowerSystems.ConstantPower, 0.5, 0.1, 1.5, 0.8), - PowerLoad("Bus2", true, nodes_case7[2], PowerSystems.ConstantPower, 1.0, 0.3, 1.5, 0.8), - PowerLoad("Bus3", true, nodes_case7[3], PowerSystems.ConstantPower, 0.3, 0.1, 0.5, 0.3)] +loads_case7 = [PSY.PowerLoad("Bus1", true, nodes_case7[1], PowerSystems.ConstantPower, 0.5, 0.1, 1.5, 0.8), + PSY.PowerLoad("Bus2", true, nodes_case7[2], PowerSystems.ConstantPower, 1.0, 0.3, 1.5, 0.8), + PSY.PowerLoad("Bus3", true, nodes_case7[3], PowerSystems.ConstantPower, 0.3, 0.1, 0.5, 0.3)] ############### Data devices ######################## -inf_gen_case7 = StaticSource(1, #number - :InfBus, #name +inf_gen_case7 = PSY.Source( + "InfBus", #name + true, #availability nodes_case7[1],#bus 1.00, #VR 0.0, #VI @@ -42,7 +42,7 @@ inf_gen_case7 = StaticSource(1, #number ######## Machine Data ######### ### Case 2: 4th Order Model with AVR (3-bus case) ### -case7_machine = OneDOneQMachine(0.0, #R +case7_machine = PSY.OneDOneQMachine(0.0, #R 1.3125, #Xd 1.2578, #Xq 0.1813, #Xd_p @@ -54,22 +54,22 @@ case7_machine = OneDOneQMachine(0.0, #R ######## Shaft Data ######### ### Shafts for Gen ### -case7_shaft = SingleMass(3.01, #H (M = 6.02 -> H = M/2) +case7_shaft = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) 0.0) #D ######## PSS Data ######### -cases_no_pss = PSSFixed(0.0) +cases_no_pss = PSY.PSSFixed(0.0) ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### -case7_no_tg = TGFixed(1.0) #eff +case7_no_tg = PSY.TGFixed(1.0) #eff ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case7_avr = AVRTypeI(20.0, #Ka - Gain +case7_avr = PSY.AVRTypeI(20.0, #Ka - Gain 0.01, #Ke 0.063, #Kf 0.2, #Ta @@ -83,11 +83,12 @@ case7_avr = AVRTypeI(20.0, #Ka - Gain ### Case 7 Generators ### case7_gen = PSY.DynamicGenerator(1, #Number - :Case7Gen, + "Case7Gen", nodes_case7[2], #bus 1.0, # ω_ref, 1.0142, #V_ref 0.6, #P_ref + 0.0, #Q_ref case7_machine, #machine case7_shaft, #shaft case7_avr, #avr @@ -96,32 +97,32 @@ case7_gen = PSY.DynamicGenerator(1, #Number ############### Inverter Data ######################## -converter = AvgCnvFixedDC(138.0, #Rated Voltage +converter = PSY.AvgCnvFixedDC(138.0, #Rated Voltage 100.0) #Rated MVA -dc_source = FixedDCSource(1500.0) #Not in the original data, guessed. +dc_source = PSY.FixedDCSource(1500.0) #Not in the original data, guessed. -filt = LCLFilter(0.08, #Series inductance lf in pu +filt = PSY.LCLFilter(0.08, #Series inductance lf in pu 0.003, #Series resitance rf in pu 0.074, #Shunt capacitance cf in pu 0.2, #Series reactance rg to grid connection (#Step up transformer or similar) 0.01) #Series resistance lg to grid connection (#Step up transformer or similar) -pll = PLL(500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. +pll = PSY.PLL(500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. 0.084, #k_p: PLL proportional gain 4.69) #k_i: PLL integral gain -virtual_H = VirtualInertia(2.0, #Ta:: VSM inertia constant +virtual_H = PSY.VirtualInertia(2.0, #Ta:: VSM inertia constant 400.0, #kd:: VSM damping coefficient 20.0, #kω:: Frequency droop gain in pu 2*pi*50.0) #ωb:: Rated angular frequency -Q_control = ReactivePowerDroop(0.2, #kq:: Reactive power droop gain in pu +Q_control = PSY.ReactivePowerDroop(0.2, #kq:: Reactive power droop gain in pu 1000.0) #ωf:: Reactive power cut-off low pass filter frequency -outer_control = VirtualInertiaQdroop(virtual_H, Q_control) +outer_control = PSY.VirtualInertiaQdroop(virtual_H, Q_control) -vsc = CombinedVIwithVZ(0.59, #kpv:: Voltage controller proportional gain +vsc = PSY.CombinedVIwithVZ(0.59, #kpv:: Voltage controller proportional gain 736.0, #kiv:: Voltage controller integral gain 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers 0.0, #rv:: Virtual resistance in pu @@ -133,7 +134,7 @@ vsc = CombinedVIwithVZ(0.59, #kpv:: Voltage controller proportional gain 0.2) #kad:: Active damping gain case7_inv = PSY.DynamicInverter(2, #number - :DARCO, #name + "DARCO", #name nodes_case7[3], #bus location 1.0, #ω_ref 1.02, #V_ref @@ -150,15 +151,41 @@ case7_inv = PSY.DynamicInverter(2, #number ######################### Dynamical System ######################## -case7_DynSystem = PSY.System(nodes_case7, branch_case7, [case7_inv, case7_gen], vcat(inf_gen_case7, loads_case7), 100.0, 50.0); +#Create system with BasePower = 100 MVA and nominal frequency 50 Hz. +sys = PSY.System(100, frequency=50.0) + +#Add buses +for bus in nodes_case7 + PSY.add_component!(sys,bus) +end + +#Add lines +for lines in branch_case7 + PSY.add_component!(sys,lines) +end + +#Add loads +for loads in loads_case7 + PSY.add_component!(sys,loads) +end + +#Add infinite source +PSY.add_component!(sys,inf_gen_case7) + +#Add inverter +PSY.add_component!(sys,case7_inv) +#Add generator +PSY.add_component!(sys,case7_gen) ################################################## ############### SOLVE PROBLEM #################### ################################################## -dx0 = zeros(LITS.get_total_rows(case7_DynSystem)) -x0 = [1.00, #V1_R +#time span +tspan = (0.0, 20.0); + +x0_guess = [1.00, #V1_R 1.00, #V2_R 1.00, #V3_R 0.0, #V1_I @@ -192,27 +219,16 @@ x0 = [1.00, #V1_R -0.39, #Vr2, 1.0] #Vm -case7_inv.inner_vars[13] = 0.95 #Vd_cnv var -case7_inv.inner_vars[14] = -0.1 #Vq_cnv var -Ybus_fault = Ybus(branch_case7_fault, nodes_case7)[:,:] -u0 = [0.2] -tspan = (0.0, 20.0); - -#Find initial condition -inif! = (out,x) -> LITS.system_model!(out, dx0 ,x, (u0,case7_DynSystem), 0.0) -sys_solve = nlsolve(inif!, x0, xtol=:1e-8,ftol=:1e-8,method=:trust_region) -x0_init = sys_solve.zero - #Define Fault using Callbacks -cb = DiffEqBase.DiscreteCallback(LITS.change_t_one, LITS.step_change_second!) +Pref_change = LITS.ControlReferenceChange(1.0, case7_gen, LITS.P_ref_index, 0.8) #Define Simulation Problem -sim = Simulation(case7_DynSystem, tspan, u0, cb, x0_init) +sim = LITS.Simulation(sys, tspan, Pref_change, initial_guess = x0_guess) #Solve problem in equilibrium run_simulation!(sim, IDA()); #Obtain data for angles -series = get_state_series(sim, (:Case7Gen, :δ)); +series = get_state_series(sim, ("Case7Gen", :δ)); @test sim.solution.retcode == :Success From 54855b2e4a566353a09201f19009c258266efbae Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Thu, 30 Jan 2020 19:39:27 -0800 Subject: [PATCH 03/13] fix generator construction. Add Q_ref --- test/test_create_gen_component.jl | 4 ++++ test/test_system_construction.jl | 2 ++ 2 files changed, 6 insertions(+) diff --git a/test/test_create_gen_component.jl b/test/test_create_gen_component.jl index 941fd59..5f3b92a 100644 --- a/test/test_create_gen_component.jl +++ b/test/test_create_gen_component.jl @@ -237,6 +237,7 @@ end 1.0, # ω_ref, 1.05, 0.4, + 0.0, Basic, BaseShaft, proportional_avr, #avr @@ -252,6 +253,7 @@ end 1.0, # ω_ref, 1.05, 0.4, + 0.0, Basic, BaseShaft, fixed_avr, #avr @@ -267,6 +269,7 @@ end 1.0, # ω_ref, 1.02, 0.4, + 0.0, oneDoneQ, BaseShaft, fixed_avr, #avr @@ -282,6 +285,7 @@ end 1.0, # ω_ref, 1.02, 0.4, + 0.0, oneDoneQ, BaseShaft, proportional_avr, #avr diff --git a/test/test_system_construction.jl b/test/test_system_construction.jl index 918e86b..b0342ea 100644 --- a/test/test_system_construction.jl +++ b/test/test_system_construction.jl @@ -52,6 +52,7 @@ Gen1AVR = PSY.DynamicGenerator( 1.0, # ω_ref, 1.05, 0.4, + 0.0, Basic, BaseShaft, proportional_avr, #avr @@ -66,6 +67,7 @@ Gen2AVR = PSY.DynamicGenerator( 1.0, # ω_ref, 1.05, 0.4, + 0.0, Basic, BaseShaft, proportional_avr, #avr From 06effc974872307b6ad97103bd734a38713882ab Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Fri, 31 Jan 2020 14:19:18 -0800 Subject: [PATCH 04/13] update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6a0683a..46c911c 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ docs/site/ *.ipynb Manifest.toml +.vscode ################################################################################ # Operating systems # From 05df0aeae0818fd5c0e60c6edc1fa2ebe28541b2 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Fri, 31 Jan 2020 14:19:26 -0800 Subject: [PATCH 05/13] fix formatter code --- .github/workflows/formatter_code.jl | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/formatter_code.jl b/.github/workflows/formatter_code.jl index 76741ec..c3d8a31 100644 --- a/.github/workflows/formatter_code.jl +++ b/.github/workflows/formatter_code.jl @@ -1,14 +1,9 @@ -main_paths = ["./src", "./test"] +main_paths = ["."] for main_path in main_paths - for folder in readdir(main_path) - @show folder_path = joinpath(main_path, folder) - if isfile(folder_path) - !occursin(".jl", folder_path) && continue - end - format(folder_path; - whitespace_ops_in_indices = true, - remove_extra_newlines = true, - verbose = true - ) - end + format( + main_path; + whitespace_ops_in_indices = true, + remove_extra_newlines = true, + verbose = true, + ) end From ec7b2f8aba5c718e7faef776c2810d882dba2b02 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Fri, 31 Jan 2020 14:19:52 -0800 Subject: [PATCH 06/13] fix tests --- docs/make.jl | 16 +- test/data/DAIB.jl | 110 ----- test/data/devices.jl | 517 -------------------- test/data/devices_bench.jl | 109 ----- test/data/devices_benchmark.jl | 403 --------------- test/data/devices_test.jl | 123 ----- test/data/inverter.jl | 27 - test/data/machines.jl | 498 ------------------- test/data/network.jl | 88 ---- test/data/network_benchmark.jl | 75 --- test/data/network_test.jl | 88 ---- test/old_tests/test_case8_staticbranches.jl | 385 +++++++++------ test/old_tests/test_case9_dynbranches.jl | 376 ++++++++------ test/test_case1_OMIB.jl | 176 ++++--- test/test_case2_4th_order.jl | 362 +++++++++----- test/test_case3_6th_order.jl | 390 +++++++++------ test/test_case4_8th_order.jl | 399 +++++++++------ test/test_case5_5shaft.jl | 327 ++++++++----- test/test_case6_DAIB.jl | 222 +++++---- test/test_case7_4th_order_Inverter.jl | 393 +++++++++------ test/test_create_gen_component.jl | 1 - test/test_system_construction.jl | 1 - 22 files changed, 1908 insertions(+), 3178 deletions(-) delete mode 100644 test/data/DAIB.jl delete mode 100755 test/data/devices.jl delete mode 100644 test/data/devices_bench.jl delete mode 100644 test/data/devices_benchmark.jl delete mode 100644 test/data/devices_test.jl delete mode 100644 test/data/inverter.jl delete mode 100644 test/data/machines.jl delete mode 100644 test/data/network.jl delete mode 100644 test/data/network_benchmark.jl delete mode 100644 test/data/network_test.jl diff --git a/docs/make.jl b/docs/make.jl index 39ed468..6938f0c 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -6,16 +6,16 @@ makedocs( format = Documenter.HTML(), sitename = "LITS.jl", pages = Any[ # Compat: `Any` for 0.4 compat - "Home"=>"index.md", + "Home" => "index.md", # "User Guide" => "man/guide.md", - "Tutorials"=>Any[ - "Tutorial 1: OMIB"=>"Examples/example_OMIB.md", - "Tutorial 2: Dynamic Lines"=>"Examples/example_lines.md", + "Tutorials" => Any[ + "Tutorial 1: OMIB" => "Examples/example_OMIB.md", + "Tutorial 2: Dynamic Lines" => "Examples/example_lines.md", ], - "Models"=>Any[ - "Network"=>"Models/network.md", - "Generator"=>"Models/gens.md", - "Inverter"=>"Models/inverters.md", + "Models" => Any[ + "Network" => "Models/network.md", + "Generator" => "Models/gens.md", + "Inverter" => "Models/inverters.md", ], ], ) diff --git a/test/data/DAIB.jl b/test/data/DAIB.jl deleted file mode 100644 index baa8f2e..0000000 --- a/test/data/DAIB.jl +++ /dev/null @@ -1,110 +0,0 @@ -using PowerSystems - -##Nodes -nodes_DAIB = [ - Bus( - 1, #number - "Bus 1", #Name - "REF", #BusType (REF, PV, PQ) - 0, #Angle in radians - 1.04, #Voltage in pu - (min = 0.94, max = 1.06), #Voltage limits in pu - 0.69, - ), #Base voltage in kV - Bus(2, "Bus 2", "PV", 0, 1.0, (min = 0.94, max = 1.06), 0.69), -] - -branch_DAIB = [Line( - "Line1", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from = nodes_DAIB[1], to = nodes_DAIB[2]), #Connection between buses - 0.0, #resistance in pu - 0.075, #reactance in pu - (from = 0.0, to = 0.0), #susceptance in pu - 5.0, #rate in MW - 1.04, -)] #angle limits (-min and max) - -##Inf bus -inf_gen_DAIB = StaticSource( - 1, #number - :InfBus, #name - nodes_DAIB[1],#bus - 1.00, #VR - 0.0, #VI - 0.000005, -) #Xth - -## Inverter - -converter = AvgCnvFixedDC( - 690.0, #Rated Voltage - 2.75, -) #Rated MVA -dc_source = FixedDCSource(600.0) #Not in the original data, guessed. - -filter = LCLFilter( - 0.08, #Series inductance lf in pu - 0.003, #Series resitance rf in pu - 0.074, #Shunt capacitance cf in pu - 0.2, #Series ractance rg to grid connection (#Step up transformer or similar) - 0.01, -) #Series resistance lg to grid connection (#Step up transformer or similar) -pll = PLL( - 500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. - 0.084, #k_p: PLL proportional gain - 4.69, -) #k_i: PLL integral gain - -virtual_H = VirtualInertia( - 2.0, #Ta:: VSM inertia constant - 400.0, #kd:: VSM damping coefficient - 20.0, #kω:: Frequency droop gain in pu - 2 * pi * 50.0, -) #ωb:: Rated angular frequency - -Q_control = ReactivePowerDroop( - 0.2, #kq:: Reactive power droop gain in pu - 1000.0, -) #ωf:: Reactive power cut-off low pass filter frequency - -outer_control = VirtualInertiaQdroop(virtual_H, Q_control) - -vsc = CombinedVIwithVZ( - 0.59, #kpv:: Voltage controller proportional gain - 736.0, #kiv:: Voltage controller integral gain - 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers - 0.0, #rv:: Virtual resistance in pu - 0.2, #lv: Virtual inductance in pu - 1.27, #kpc:: Current controller proportional gain - 14.3, #kiv:: Current controller integral gain - 0.0, #kffi:: Binary variable enabling the current feed-forward in output of current controllers - 50.0, #ωad:: Active damping low pass filter cut-off frequency - 0.2, -) #kad:: Active damping gain - -Darco_Inverter = PSY.DynamicInverter( - 1, #number - :DARCO, #name - nodes_DAIB[2], #bus location - 1.0, #ω_ref - 1.02, #V_ref - 0.5, #P_ref - 0.0, #Q_ref - 2.75, #MVABase - converter, #Converter - outer_control, #OuterControl - vsc, #Voltage Source Controller - dc_source, #DC Source - pll, #Frequency Estimator - filter, -) #Output Filter - -loads_DAIB = - [PowerLoad("Bus1", true, nodes_DAIB[1], PowerSystems.ConstantPower, 0.0, 0.0, 0.0, 0.0)] - -DAIB = PSY.System(nodes_DAIB, branch_DAIB, [Darco_Inverter], [inf_gen_DAIB], 100.0, 50.0); - -#DAIB = PSY.System(nodes_DAIB, branch_DAIB, [Darco_Inverter], loads_DAIB, 100.0, 50.0) diff --git a/test/data/devices.jl b/test/data/devices.jl deleted file mode 100755 index d00cf77..0000000 --- a/test/data/devices.jl +++ /dev/null @@ -1,517 +0,0 @@ -#include("src/LITS.jl") -#include("data/network.jl") -# Electrical Parameters of Machine 1, Milano's Book Page 526 -################## Machine Data ##################### -Basic = BaseMachine( - 0.0, #R - 0.2995, #Xd_p - 1.05, #eq_p - 615.0, -) #MVABase - -oneDoneQ = OneDOneQMachine( - 0.0, #R - 0.8979, #Xd - 0.646, #Xq - 0.2995, #Xd_p - 0.04, #Xq_p - 7.4, #Td0_p - 0.033, #Tq0_p - 615.0, -) #MVABase - -AndersonFouad = AndersonFouadMachine( - 0.0, #R - 0.8979, #Xd - 0.646, #Xq - 0.2995, #Xd_p - 0.646, #Xq_p - 0.23, #Xd_pp - 0.4, #Xq_pp - 7.4, #Td0_p - 0.01, #Tq0_p #Data not available in Milano: Used 0.01 - 0.03, #Td0_pp - 0.033, #Tq0_pp - 615.0, -) #MVABase - -KundurMachine = SimpleFullMachine( - 0.003, #R on Example 3.1 and 4.1 of Kundur - 0.0006, #R_f - 0.0284, #R_1d or RD in Machowski - 0.0062, #R_1q or RQ on Machowski - 1.81, #L_d - 1.76, #L_q - 1.66, #L_ad or k*M_f or k*M_D in Machowski - 1.61, #L_aq or k*M_Q in Machowski - 1.66, #L_f1d or L_fD in Machowski. Assumed to be equal to L_ad - 1.825, #L_ff - 0.1713, #L_1d or L_D in Machowski - 0.7525, #L_1q or L_Q in Machowski - 555.0, -) #MVABase - -KundurFullMachine = FullMachine( - 0.003, #R on Example 3.1 and 4.1 of Kundur - 0.0006, #R_f - #0.003, #R_f - 0.0284, #R_1d or RD in Machowski - 0.0062, #R_1q or RQ on Machowski - 1.81, #L_d - 1.76, #L_q - 1.66, #L_ad or k*M_f or k*M_D in Machowski - 1.61, #L_aq or k*M_Q in Machowski - 1.66, #L_f1d or L_fD in Machowski. Assumed to be equal to L_ad - 1.825, #L_ff - 0.1713, #L_1d or L_D in Machowski - 0.7525, #L_1q or L_Q in Machowski - 555.0, -) #MVABase - -Mach2_benchmark = OneDOneQMachine( - 0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0, -) #MVABase - -Mach3_benchmark = OneDOneQMachine( - 0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0, -) #MVABase - -################ Shaft Data ##################### -BaseShaft = SingleMass( - 5.148, #H - 2.0, -) #D - -FiveShaft = FiveMassShaft( - 5.148, #H - 0.3348, #H_hp - 0.7306, #H_ip - 0.8154, #H_lp - 0.0452, #H_ex, - 2.0, #D - 0.5180, #D_hp - 0.2240, #D_ip - 0.2240, #D_lp - 0.1450, #D_ex - 0.0518, #D_12 - 0.0224, #D_23 - 0.0224, #D_34 - 0.0145, #D_45 - 33.07, #K_hp - 28.59, #K_ip - 44.68, #K_lp - 21.984, -) #K_ex - -KundurShaft = SingleMass( - 3.525, #H given in example 3.5 in Kundur - 2.0, -) #D: Damping is not given, so I assume the value 2.0 - -Shaft2_benchmark = SingleMass( - 3.01, #H (M = 6.02 -> H = M/2) - 0.0, -) #D - -Shaft3_benchmark = SingleMass( - 3.01, #H (M = 6.02 -> H = M/2) - 0.0, -) #D - -################# PSS Data ##################### -no_pss = PSSFixed(0.0) - -################ TG Data ##################### -fixed_tg = TGFixed(1.0) #eff - -typeI_tg = TGTypeI( - 0.02, #R - 0.1, #Ts - 0.45, #Tc - 0.0, #T3 - 0.0, #T4 - 50.0, #T5 - 0.3, #P_min - 1.2, -) #P_max - -typeII_tg = TGTypeII( - 0.05, #R - 0.3, #T1 - 0.1, #T2 - 1.0, #τ_max - 0.1, -) #τ_min - -################ AVR Data ##################### -proportional_avr = AVRSimple(5000.0) #Kv - -fixed_avr = AVRFixed(1.05) #Emf - -typeI_avr = AVRTypeI( - 200.0, #Ka - 1.0, #Ke - 0.0012, #Kf - 0.02, #Ta - 0.19, #Te - 1.0, #Tf - 0.001, #Tr - 9.9, #Vr_max - 0.0, #Vr_min - 0.0006, #Ae - 0.9, -) - -kundur_avr = AVRFixed(0.00043) #Emf - -gen_avr_bench = AVRFixed(1.7613) #Vf - -gen2_avr_benchmark_m = AVRTypeI( - 20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555, -) #Be - 2nd ceiling coefficient - -gen3_avr_benchmark_m = AVRTypeI( - 20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555, -) #Be - 2nd ceiling coefficient - -gen2_avr_fixed = AVRFixed(2.1996) -gen3_avr_fixed = AVRFixed(1.7327) - -######################### Generators ######################## - -Gen1AVR = PSY.DynamicGenerator( - 1, #Number - :TestGen, - nodes_OMIB[2], #bus - 1.0, # ω_ref, - 1.05, - 0.4, - Basic, - BaseShaft, - proportional_avr, #avr - fixed_tg, #tg - no_pss, -) - -Gen1AVRnoAVR = PSY.DynamicGenerator( - 1, #Number - :TestGen, - nodes_OMIB[2], #bus - 1.0, # ω_ref, - 1.05, - 0.4, - Basic, - BaseShaft, - fixed_avr, #avr - fixed_tg, #tg - no_pss, -) - -Gen2AVRnoAVR = PSY.DynamicGenerator( - 1, #Number - :TestGen, - nodes_OMIB[2], #bus - 1.0, # ω_ref, - 1.02, - 0.4, - oneDoneQ, - BaseShaft, - fixed_avr, #avr - fixed_tg, #tg - no_pss, -) - -Gen2AVR = PSY.DynamicGenerator( - 1, #Number - :TestGen, - nodes_OMIB[2], #bus - 1.0, # ω_ref, - 1.02, - 0.4, - oneDoneQ, - BaseShaft, - proportional_avr, #avr - fixed_tg, #tg - no_pss, -) - -Gen3AVR = PSY.DynamicGenerator( - 1, #number - :TestGen, #name - nodes_OMIB[2], #bus - 1.0, # ω_ref - 1.02, - 0.4, - oneDoneQ, #machine - BaseShaft, - typeI_avr, #avr - fixed_tg, #tg - no_pss, -) - -Gen4AVRTG = PSY.DynamicGenerator( - 1, #number - :TestGen, #name - nodes_OMIB[2], #bus - 1.0, # ω_ref - 1.02, - 0.4, - oneDoneQ, #machine - BaseShaft, - typeI_avr, #avr - typeI_tg, #tg - no_pss, -) - -Gen5AVR = PSY.DynamicGenerator( - 1, #number - :TestGen, #name - nodes_OMIB[2], #bus - 1.0, # ω_ref - 1.02, - 0.4, - AndersonFouad, #machine - BaseShaft, - typeI_avr, #avr - fixed_tg, #tg - no_pss, -) - -Gen6AVR = PSY.DynamicGenerator( - 1, #number - :TestGen, #name - nodes_OMIB[2], #bus - 1.0, #ω_ref - 1.02, #V_ref - 0.4, #P_ref - oneDoneQ, #machine - FiveShaft, #shaft - typeI_avr, #avr - fixed_tg, #tg - no_pss, -) - -GenKundur = PSY.DynamicGenerator( - 1, #number - :KundurGen, #name - nodes_kundur[1], - 1.0, #ω_ref - 1.02, #V_ref - 0.2, #P_ref - KundurMachine, #machine - KundurShaft, #shaft - kundur_avr, #avr - fixed_tg, #tg - no_pss, -) #pss - -GenFullKundur = PSY.DynamicGenerator( - 1, #number - :KundurGen, #name - nodes_kundur[1], - 1.0, #ω_ref - 1.02, #V_ref - 0.20, #P_ref - KundurFullMachine, #machine - KundurShaft, #shaft - kundur_avr, #avr - fixed_tg, #tg - no_pss, -) #pss - -Gen2_benchmark = PSY.DynamicGenerator( - 1, #number - :Gen1, #name - nodes_benchmark[2], - 1.0, #ω_ref - 1.0142, #V_ref - 1.0, #P_ref - Mach2_benchmark, #machine - Shaft2_benchmark, #shaft - gen2_avr_benchmark_m, #avr - fixed_tg, #tg - no_pss, -) #pss - -Gen2_benchmark_tg = PSY.DynamicGenerator( - 1, #number - :Gen1, #name - nodes_benchmark[2], - 1.0, #ω_ref - 1.0142, #V_ref - 1.0, #P_ref - Mach2_benchmark, #machine - Shaft2_benchmark, #shaft - gen2_avr_benchmark_m, #avr - typeII_tg, #tg - no_pss, -) #pss - -Gen3_benchmark = PSY.DynamicGenerator( - 2, #number - :Gen2, #name - nodes_benchmark[3], - 1.0, #ω_ref - 1.0059, #V_ref - 1.0, #P_ref - Mach3_benchmark, #machine - Shaft3_benchmark, #shaft - gen3_avr_benchmark_m, #avr - fixed_tg, #tg - no_pss, -) #pss - -Gen2_benchmark_fixedavr = PSY.DynamicGenerator( - 1, #number - :Gen1, #name - nodes_benchmark[2], - 1.0, #ω_ref - 1.0142, #V_ref - 1.0, #P_ref - Mach2_benchmark, #machine - Shaft2_benchmark, #shaft - gen2_avr_fixed, #avr - fixed_tg, #tg - no_pss, -) #pss - -Gen3_benchmark_fixedavr = PSY.DynamicGenerator( - 2, #number - :Gen2, #name - nodes_benchmark[3], - 1.0, #ω_ref - 1.00586, #V_ref - 1.0, #P_ref - Mach3_benchmark, #machine - Shaft3_benchmark, #shaft - gen3_avr_fixed, #avr - fixed_tg, #tg - no_pss, -) #pss - -Gen_bench = PSY.DynamicGenerator( - 1, #number - :Gen1, #name - nodes_bench[2], - 1.0, #ω_ref - 1.0, #V_ref - 1.0, #P_ref - Mach2_benchmark, #machine - Shaft2_benchmark, #shaft - gen_avr_bench, #avr - fixed_tg, #tg - no_pss, -) #pss - -################### StaticSources ##################### - -inf_gen = StaticSource( - 1, #number - :InfBus, #name - nodes_OMIB[1], #bus - 1.05, #VR - 0.0, #VI - 0.000005, -) #Xth - -inf_gen_kundur = StaticSource(1, :InfBus, nodes_kundur[2], 1.01, 0.0, 0.000005) - -inf_gen_benchmark = StaticSource( - 1, #number - :InfBus, #name - nodes_benchmark[1], #bus - 1.02, #VR - 0.0, #VI - 0.000001, -) #Xth - -################### StaticSources ##################### - -OMIB = PSY.System(nodes_OMIB, branch_OMIB, [Gen1AVR], [inf_gen], 100.0, 60.0) -#include("src/LITS.jl") -OMIB_dyn_line = - PSY.System(nodes_OMIB, branch_OMIB, [Gen1AVR], [inf_gen], 100.0, 60.0, Dynbranch_OMIB) - -OMIBA = PSY.System(nodes_OMIB, branch_OMIB, [Gen5AVR], [inf_gen], 100.0, 60.0) -OMIB_Kundur = - PSY.System(nodes_kundur, branch_kundur, [GenKundur], [inf_gen_kundur], 100.0, 60.0) -OMIB_FullKundur = - PSY.System(nodes_kundur, branch_kundur, [GenFullKundur], [inf_gen_kundur], 100.0, 60.0) -TwoBus_Benchmark = PSY.System( - nodes_bench, #buses - branch_bench, #branches - [Gen_bench], #dynamic injections - [inf_gen_benchmark, loads_bench[1]], #static injections - 100.0, #Sbase - 60.0, -) #fbase - -ThreeBus_Benchmark = PSY.System( - nodes_benchmark, #buses - branch_benchmark, #branches - [Gen2_benchmark, Gen3_benchmark], #dynamic injections - [inf_gen_benchmark, loads_benchmark[1], loads_benchmark[2], loads_benchmark[3]], #static injections - 100.0, #Sbase - 60.0, -) #fbase - -ThreeBus_Benchmark = PSY.System( - nodes_benchmark, #buses - branch_benchmark, #branches - [Gen2_benchmark, Gen3_benchmark], #dynamic injections - [inf_gen_benchmark, loads_benchmark[1], loads_benchmark[2], loads_benchmark[3]], #static injections - 100.0, #Sbase - 60.0, -) #fbase - -ThreeBus_Benchmark_tg = PSY.System( - nodes_benchmark, #buses - branch_benchmark, #branches - [Gen2_benchmark_tg, Gen3_benchmark], #dynamic injections - [inf_gen_benchmark, loads_benchmark[1], loads_benchmark[2], loads_benchmark[3]], #static injections - 100.0, #Sbase - 60.0, -) #fbase - -ThreeBus_Benchmark_fixedavr = PSY.System( - nodes_benchmark, #buses - branch_benchmark, #branches - [Gen2_benchmark_fixedavr, Gen3_benchmark_fixedavr], #dynamic injections - [inf_gen_benchmark, loads_benchmark[1], loads_benchmark[2], loads_benchmark[3]], #static injections - 100.0, #Sbase - 60.0, -); diff --git a/test/data/devices_bench.jl b/test/data/devices_bench.jl deleted file mode 100644 index 3550c11..0000000 --- a/test/data/devices_bench.jl +++ /dev/null @@ -1,109 +0,0 @@ -Mach2_benchmark = OneDOneQMachine( - 0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0, -) #MVABase - -Mach3_benchmark = OneDOneQMachine( - 0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0, -) #MVABase - -Shaft2_benchmark = SingleMass( - 3.01, #H (M = 6.02 -> H = M/2) - 0.0, -) #D - -Shaft3_benchmark = SingleMass( - 3.01, #H (M = 6.02 -> H = M/2) - 0.0, -) #D - -no_pss = PSSFixed(0.0) - -fixed_tg = TGFixed(1.0) #eff - -gen2_avr_benchmark_m = AVRTypeI( - 20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555, -) #Be - 2nd ceiling coefficient - -gen3_avr_benchmark_m = AVRTypeI( - 20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555, -) #Be - 2nd ceiling coefficient - -Gen2_benchmark = PSY.DynamicGenerator( - 1, #number - :Gen1, #name - nodes_benchmark[2], - 1.0, #ω_ref - 1.0142, #V_ref - 1.0, #P_ref - Mach2_benchmark, #machine - Shaft2_benchmark, #shaft - gen2_avr_benchmark_m, #avr - fixed_tg, #tg - no_pss, -) #pss - -Gen3_benchmark = PSY.DynamicGenerator( - 2, #number - :Gen2, #name - nodes_benchmark[3], - 1.0, #ω_ref - 1.0059, #V_ref - 1.0, #P_ref - Mach3_benchmark, #machine - Shaft3_benchmark, #shaft - gen3_avr_benchmark_m, #avr - fixed_tg, #tg - no_pss, -) #pss - -inf_gen_benchmark = StaticSource( - 1, #number - :InfBus, #name - nodes_benchmark[1], #bus - 1.02, #VR - 0.0, #VI - 0.000001, -) #Xth - -ThreeBus_Benchmark = PSY.System( - nodes_benchmark, #buses - branch_benchmark, #branches - [Gen2_benchmark, Gen3_benchmark], #dynamic injections - [inf_gen_benchmark, loads_benchmark[1], loads_benchmark[2], loads_benchmark[3]], - 100.0, #Sbase - 60.0, -) #fbase diff --git a/test/data/devices_benchmark.jl b/test/data/devices_benchmark.jl deleted file mode 100644 index b0f0627..0000000 --- a/test/data/devices_benchmark.jl +++ /dev/null @@ -1,403 +0,0 @@ -""" -Sources data -""" - -inf_gen_case1 = StaticSource( - 1, #number - :InfBus, #name - nodes_case1[1], #bus - 1.05, #VR - 0.0, #VI - 0.000001, -) #Xth - -inf_gen_case234 = StaticSource( - 1, #number - :InfBus, #name - nodes_case234[1], #bus - 1.02, #VR - 0.0, #VI - 0.000001, -) #Xth - -inf_gen_case5 = StaticSource( - 1, #number - :InfBus, #name - nodes_case5[1], #bus - 1.00, #VR - 0.0, #VI - 0.000001, -) #Xth - -""" -Generators data -""" - -######## Machine Data ######### - -### Case 1: Classical machine against infinite bus ### -case1_machine = BaseMachine( - 0.0, #R - 0.2995, #Xd_p - 0.7087, #eq_p - 100.0, -) #MVABase - -### Case 2: 4th Order Model with AVR (3-bus case) ### -case2_machine2 = OneDOneQMachine( - 0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0, -) #MVABase - -case2_machine3 = OneDOneQMachine( - 0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0, -) #MVABase - -### Case 3: 6th Order Model with AVR (3-bus case) ### -case3_machine2 = SimpleMarconatoMachine( - 0.0, - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 0.14, #Xd_pp - 0.18, #Xq_pp - 5.89, #Td0_p - 0.6, #Tq0_p - 0.5, #Td0_pp - 0.023, #Tq0_pp - 0.0, #T_AA - 100.0, -) #MVABase - -case3_machine3 = SimpleMarconatoMachine( - 0.0, - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 0.14, #Xd_pp - 0.18, #Xq_pp - 5.89, #Td0_p - 0.6, #Tq0_p - 0.5, #Td0_pp - 0.023, #Tq0_pp - 0.0, #T_AA - 100.0, -) #MVABase - -### Case 4: 8th Order Model with AVR (3-bus case) ### -case4_machine2 = MarconatoMachine( - 0.0, - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 0.14, #Xd_pp - 0.18, #Xq_pp - 5.89, #Td0_p - 0.6, #Tq0_p - 0.5, #Td0_pp - 0.023, #Tq0_pp - 0.0, #T_AA - 100.0, -) #MVABase - -case4_machine3 = MarconatoMachine( - 0.0, - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 0.14, #Xd_pp - 0.18, #Xq_pp - 5.89, #Td0_p - 0.6, #Tq0_p - 0.5, #Td0_pp - 0.023, #Tq0_pp - 0.0, #T_AA - 100.0, -) #MVABase - -### Case 5: 4th Order Model with AVR + TG + Multishaft ### -case5_machine = OneDOneQMachine( - 0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0, -) #MVABase - -######## Shaft Data ######### - -### Shaft for Case 1 ### -case1_shaft = SingleMass( - 3.148, #H - 2.0, -) #D - -### Shafts for Gens 2 and 3: Cases 2, 3 and 4 ### -case234_shaft2 = SingleMass( - 3.01, #H (M = 6.02 -> H = M/2) - 0.0, -) #D - -case234_shaft3 = SingleMass( - 3.01, #H (M = 6.02 -> H = M/2) - 0.0, -) #D - -case5_shaft = FiveMassShaft( - 3.01, #5.148, #H - 0.3348, #H_hp - 0.7306, #H_ip - 0.8154, #H_lp - 0.0452, #H_ex, - 0.0, #2.0, #D - 0.5180, #D_hp - 0.2240, #D_ip - 0.2240, #D_lp - 0.1450, #D_ex - 0.0518, #D_12 - 0.0224, #D_23 - 0.0224, #D_34 - 0.0145, #D_45 - 33.07, #K_hp - 28.59, #K_ip - 44.68, #K_lp - 21.984, -) #K_ex - -######## PSS Data ######### -cases_no_pss = PSSFixed(0.0) - -######## TG Data ######### - -### No TG for Cases 1, 2, 3, 4 ### -case1234_no_tg = TGFixed(1.0) #eff - -### TG for Case 5 ### -case5_tg = TGTypeII( - 0.05, #R - 1.0, #T1 - 2.0, #T2 - 1.5, #τ_max - 0.1, -) #τ_min - -######## AVR Data ######### - -### AVR for Case 1 ### -case1_avr = AVRFixed(0.0) #Vf not applicable in Classic Machines - -### AVRs for Case 2, 3, 4 and 5 ### -case2345_avr2 = AVRTypeI( - 20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555, -) #Be - 2nd ceiling coefficient - -case2345_avr3 = AVRTypeI( - 20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555, -) #Be - 2nd ceiling coefficient - -######################### Generators ######################## - -### Case 1 Generator ### -case1_gen = PSY.DynamicGenerator( - 1, #Number - :Case1Gen, - nodes_case1[2], #bus - 1.0, # ω_ref, - 1.0, #V_ref - 0.5, #P_ref - case1_machine, #machine - case1_shaft, #shaft - case1_avr, #avr - case1234_no_tg, #tg - cases_no_pss, -) #pss - -### Case 2 Generators ### -case2_gen2 = PSY.DynamicGenerator( - 1, #Number - :Case2Gen2, - nodes_case234[2], #bus - 1.0, # ω_ref, - 1.0142, #V_ref - 1.0, #P_ref - case2_machine2, #machine - case234_shaft2, #shaft - case2345_avr2, #avr - case1234_no_tg, #tg - cases_no_pss, -) #pss - -case2_gen3 = PSY.DynamicGenerator( - 2, #Number - :Case2Gen3, - nodes_case234[3], #bus - 1.0, # ω_ref, - 1.0059, #V_ref - 1.0, #P_ref - case2_machine3, #machine - case234_shaft3, #shaft - case2345_avr3, #avr - case1234_no_tg, #tg - cases_no_pss, -) #pss - -### Case 3 Generators ### -case3_gen2 = PSY.DynamicGenerator( - 1, #Number - :Case3Gen2, - nodes_case234[2], #bus - 1.0, # ω_ref, - 1.0142, #V_ref - 1.0, #P_ref - case3_machine2, #machine - case234_shaft2, #shaft - case2345_avr2, #avr - case1234_no_tg, #tg - cases_no_pss, -) #pss - -case3_gen3 = PSY.DynamicGenerator( - 2, #Number - :Case3Gen3, - nodes_case234[3], #bus - 1.0, # ω_ref, - 1.0059, #V_ref - 1.0, #P_ref - case3_machine3, #machine - case234_shaft3, #shaft - case2345_avr3, #avr - case1234_no_tg, #tg - cases_no_pss, -) #pss - -### Case 4 Generators ### -case4_gen2 = PSY.DynamicGenerator( - 1, #Number - :Case4Gen2, - nodes_case234[2], #bus - 1.0, # ω_ref, - 1.0142, #V_ref - 1.0, #P_ref - case4_machine2, #machine - case234_shaft2, #shaft - case2345_avr2, #avr - case1234_no_tg, #tg - cases_no_pss, -) #pss - -case4_gen3 = PSY.DynamicGenerator( - 2, #Number - :Case4Gen3, - nodes_case234[3], #bus - 1.0, # ω_ref, - 1.0059, #V_ref - 1.0, #P_ref - case4_machine3, #machine - case234_shaft3, #shaft - case2345_avr3, #avr - case1234_no_tg, #tg - cases_no_pss, -) #pss - -### Case 5 Generator ### -case5_gen = PSY.DynamicGenerator( - 1, #Number - :Case5Gen, - nodes_case5[2], #bus - 1.0, # ω_ref, - 1.0155, #V_ref - 0.5, #P_ref - case5_machine, #machine - case5_shaft, #shaft - case2345_avr2, #avr - case5_tg, #tg - #case1234_no_tg, - cases_no_pss, -) #pss - -######################### Dynamical System ######################## - -case1_DynSystem = PSY.System( - nodes_case1, - branch_case1, - [case1_gen], - vcat(inf_gen_case1, loads_case1), - 100.0, - 60.0, -) - -case2_DynSystem = PSY.System( - nodes_case234, - branch_case234, - [case2_gen2, case2_gen3], - vcat(inf_gen_case234, loads_case234), - 100.0, - 60.0, -) - -case3_DynSystem = PSY.System( - nodes_case234, - branch_case234, - [case3_gen2, case3_gen3], - vcat(inf_gen_case234, loads_case234), - 100.0, - 60.0, -) - -case4_DynSystem = PSY.System( - nodes_case234, - branch_case234, - [case4_gen2, case4_gen3], - vcat(inf_gen_case234, loads_case234), - 100.0, - 60.0, -) - -case5_DynSystem = PSY.System( - nodes_case5, - branch_case5, - [case5_gen], - vcat(inf_gen_case5, loads_case5), - 100.0, - 60.0, -) diff --git a/test/data/devices_test.jl b/test/data/devices_test.jl deleted file mode 100644 index 1e01dda..0000000 --- a/test/data/devices_test.jl +++ /dev/null @@ -1,123 +0,0 @@ -mach_test = BaseMachine( - 0.0, #R - 0.2995, #Xd_p - 0.588, #eq_p - 100.0, -) #MVABase - -mach2_test = OneDOneQMachine( - 0.0, #R - 0.8, #Xd - 0.2, #Xq - 0.1813, #Xd_p - 0.05, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0, -) #MVABase - -shaft_test = SingleMass( - 3.148, #H - 2.0, -) #D - -shaft_test2 = SingleMass( - 3.01, #H - 2.0, -) #D - -pss_test = PSSFixed(0.0) -tg_test = TGFixed(1.0) -avr_test = AVRFixed(1.0) -avr_test2 = AVRFixed(0.26854) -#avr_test3 = AVRFixed(0.3337) -avr_test3 = AVRFixed(0.34992) - -load_test = - PowerLoad("Bus3", true, nodes_test[1], PowerSystems.ConstantPower, 0.0, 0.0, 0.0, 0.0) -load_test2 = PowerLoad( - "Bus3", - true, - nodes_test2[3], - PowerSystems.ConstantPower, - 0.6, - 0.05, - 0.6, - 0.05, -) - -load_test3a = PowerLoad( - "Bus3", - true, - nodes_test2[2], - PowerSystems.ConstantPower, - 0.3, - 0.05, - 0.6, - 0.05, -) -load_test3b = PowerLoad( - "Bus3", - true, - nodes_test2[3], - PowerSystems.ConstantPower, - 0.3, - 0.05, - 0.6, - 0.05, -) - -Gen_test = PSY.DynamicGenerator( - 1, #Number - :TestGen, - nodes_test[2], #bus - 1.0, # ω_ref, - 1.0, #V_ref - 1.0, #P_ref - mach_test, - shaft_test, - avr_test, #avr - tg_test, #tg - pss_test, -) - -Gen_test2 = PSY.DynamicGenerator( - 1, #Number - :TestGen, - nodes_test[2], #bus - 1.0, # ω_ref, - 1.0, #V_ref - 1.0, #P_ref - mach2_test, - shaft_test, - avr_test2, #avr - tg_test, #tg - pss_test, -) - -Gen_test3 = PSY.DynamicGenerator( - 1, #Number - :TestGen, - nodes_test[2], #bus - 1.0, # ω_ref, - 1.0, #V_ref - 0.5, #P_ref - mach2_test, - shaft_test, - avr_test3, #avr - tg_test, #tg - pss_test, -) - -OMIB_test = PSY.System(nodes_test, branch_test, [Gen_test], [load_test], 100.0, 60.0) -OMIB_test2 = PSY.System(nodes_test, branch_test, [Gen_test2], [load_test], 100.0, 60.0) -OMIB_test_load = - PSY.System(nodes_test2, branch_test2, [Gen_test3], [load_test2], 100.0, 60.0) -OMIB_test_load2 = PSY.System( - nodes_test2, - branch_test2, - [Gen_test3], - [load_test3a, load_test3b], - 100.0, - 60.0, -) diff --git a/test/data/inverter.jl b/test/data/inverter.jl deleted file mode 100644 index 515613f..0000000 --- a/test/data/inverter.jl +++ /dev/null @@ -1,27 +0,0 @@ -converter = AvgCnvFixedDC(690.0, 2750000.0) #S_rated goes in Watts -dc_source = FixedDCSource(600.0) #Not in the original data, guessed. -filter = LCLFilter(0.08, 0.003, 0.074, 0.2, 0.01) -pll = PLL(500.0, 0.084, 4.69) - -virtual_H = VirtualInertia(2.0, 400.0, 20.0, 2 * pi * 50.0) -Q_control = ReactivePowerDroop(0.2, 1000.0) -outer_control = VirtualInertiaQdroop(virtual_H, Q_control) - -vsc = CurrentControl(1.27, 14.3, 0.59, 736.0, 50.0, 0.5, 0.2, 0.00) - -PSY.DynamicInverter( - 1, - :DARCO, - nodes_OMIB[2], - 1.0, - 1.0, - 0.4, - 0.0, - 2.75e3, - converter, - outer_control, - vsc, - dc_source, - pll, - filter, -) diff --git a/test/data/machines.jl b/test/data/machines.jl deleted file mode 100644 index bfa31c8..0000000 --- a/test/data/machines.jl +++ /dev/null @@ -1,498 +0,0 @@ -# Electrical Parameters of Machine 1, Milano's Book Page 526 -################## Machine Data ##################### -Basic = BaseMachine( 0.0, #R - 0.2995, #Xd_p - 1.05, #eq_p - 615.0) #MVABase - -oneDoneQ = OneDOneQMachine(0.0, #R - 0.8979, #Xd - 0.646, #Xq - 0.2995, #Xd_p - 0.04, #Xq_p - 7.4, #Td0_p - 0.033, #Tq0_p - 615.0) #MVABase - -AndersonFouad = AndersonFouadMachine(0.0, #R - 0.8979, #Xd - 0.646, #Xq - 0.2995, #Xd_p - 0.646, #Xq_p - 0.23, #Xd_pp - 0.4, #Xq_pp - 7.4, #Td0_p - 0.01, #Tq0_p #Data not available in Milano: Used 0.01 - 0.03, #Td0_pp - 0.033, #Tq0_pp - 615.0) #MVABase - -KundurMachine = SimpleFullMachine(0.003, #R on Example 3.1 and 4.1 of Kundur - 0.0006, #R_f - 0.0284, #R_1d or RD in Machowski - 0.0062, #R_1q or RQ on Machowski - 1.81, #L_d - 1.76, #L_q - 1.66, #L_ad or k*M_f or k*M_D in Machowski - 1.61, #L_aq or k*M_Q in Machowski - 1.66, #L_f1d or L_fD in Machowski. Assumed to be equal to L_ad - 1.825, #L_ff - 0.1713, #L_1d or L_D in Machowski - 0.7525, #L_1q or L_Q in Machowski - 555.0) #MVABase - -KundurFullMachine = FullMachine(0.003, #R on Example 3.1 and 4.1 of Kundur - 0.0006, #R_f - #0.003, #R_f - 0.0284, #R_1d or RD in Machowski - 0.0062, #R_1q or RQ on Machowski - 1.81, #L_d - 1.76, #L_q - 1.66, #L_ad or k*M_f or k*M_D in Machowski - 1.61, #L_aq or k*M_Q in Machowski - 1.66, #L_f1d or L_fD in Machowski. Assumed to be equal to L_ad - 1.825, #L_ff - 0.1713, #L_1d or L_D in Machowski - 0.7525, #L_1q or L_Q in Machowski - 555.0) #MVABase - -Mach2_benchmark = OneDOneQMachine(0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0) #MVABase - -Mach3_benchmark = OneDOneQMachine(0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0) #MVABase - - -################ Shaft Data ##################### -BaseShaft = SingleMass(5.148, #H - 2.0) #D - -FiveShaft = FiveMassShaft(5.148, #H - 0.3348, #H_hp - 0.7306, #H_ip - 0.8154, #H_lp - 0.0452, #H_ex, - 2.0, #D - 0.5180, #D_hp - 0.2240, #D_ip - 0.2240, #D_lp - 0.1450, #D_ex - 0.0518, #D_12 - 0.0224, #D_23 - 0.0224, #D_34 - 0.0145, #D_45 - 33.07, #K_hp - 28.59, #K_ip - 44.68, #K_lp - 21.984) #K_ex - -KundurShaft = SingleMass(3.525, #H given in example 3.5 in Kundur - 2.0) #D: Damping is not given, so I assume the value 2.0 - -Shaft2_benchmark = SingleMass(3.01, #H (M = 6.02 -> H = M/2) - 0.0) #D - -Shaft3_benchmark = SingleMass(3.01, #H (M = 6.02 -> H = M/2) - 0.0) #D - -################# PSS Data ##################### -no_pss = PSSFixed(0.0) - -################ TG Data ##################### -fixed_tg = TGFixed(1.0) #eff - -typeI_tg = TGTypeI(0.02, #R - 0.1, #Ts - 0.45, #Tc - 0.0, #T3 - 0.0, #T4 - 50.0, #T5 - 0.3, #P_min - 1.2) #P_max - -typeII_tg = TGTypeII(0.05, #R - 0.3, #T1 - 0.1, #T2 - 1.0, #τ_max - 0.1) #τ_min - -################ AVR Data ##################### -proportional_avr = AVRSimple(5000.0) #Kv - -fixed_avr = AVRFixed(1.05) #Emf - -typeI_avr = AVRTypeI(200.0, #Ka - 1.0, #Ke - 0.0012, #Kf - 0.02, #Ta - 0.19, #Te - 1.0, #Tf - 0.001, #Tr - 9.9, #Vr_max - 0.0, #Vr_min - 0.0006, #Ae - 0.9) - -kundur_avr = AVRFixed(0.00043) #Emf -gen_avr_bench = AVRFixed(1.7613) #Vf - -gen2_avr_benchmark_m = AVRTypeI(20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr -gen2_avr_benchmark = AVRTypeII(20.0, #K0 - Gain - 0.2, #T1 - 1st pole - 0.063, #T2 - 1st zero - 0.35, #T3 - 2nd pole - 0.01, #T4 - 2nd zero - 0.314, #Te - Field current time constant - 0.001, #Tr - Measurement time constant - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555) #Be - 2nd ceiling coefficient - -gen3_avr_benchmark = AVRTypeII(20.0, #K0 - Gain - 0.2, #T1 - 1st pole - 0.063, #T2 - 1st zero - 0.35, #T3 - 2nd pole - 0.01, #T4 - 2nd zero - 0.314, #Te - Field current time constant - 0.001, #Tr - Measurement time constant - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555) #Be - 2nd ceiling coefficient - -gen2_avr_benchmark_m = AVRTypeIIManual(20.0, #Ka - Gain - 0.2, #Ta - 1st pole - 0.063, #Kf - 1st zero - 0.35, #Tf - 2nd pole - 0.01, #Te - 2nd zero - 0.314, #Tr - Field current time constant - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555) #Be - 2nd ceiling coefficient -gen3_avr_benchmark_m = AVRTypeI(20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555) #Be - 2nd ceiling coefficient - -gen2_avr_fixed = AVRFixed(2.1996) -gen3_avr_fixed = AVRFixed(1.7327) -gen3_avr_benchmark_m = AVRTypeIIManual(20.0, #Ka - Gain - 0.2, #Ta - 1st pole - 0.063, #Kf - 1st zero - 0.35, #Tf - 2nd pole - 0.01, #Te - 2nd zero - 0.314, #Tr - Field current time constant - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555) #Be - 2nd ceiling coefficient - -######################### Generators ######################## - -Gen1AVR = PSY.DynamicGenerator(1, #Number - :TestGen, - nodes_OMIB[2],#bus - 1.0, # ω_ref, - 1.05, - 0.4, - Basic, - BaseShaft, - proportional_avr, #avr - fixed_tg, #tg - no_pss) - -Gen1AVRnoAVR = PSY.DynamicGenerator(1, #Number - :TestGen, - nodes_OMIB[2],#bus - 1.0, # ω_ref, - 1.05, - 0.4, - Basic, - BaseShaft, - fixed_avr, #avr - fixed_tg, #tg - no_pss) - -Gen2AVRnoAVR = PSY.DynamicGenerator(1, #Number - :TestGen, - nodes_OMIB[2],#bus - 1.0, # ω_ref, - 1.02, - 0.4, - oneDoneQ, - BaseShaft, - fixed_avr, #avr - fixed_tg, #tg - no_pss) - -Gen2AVR = PSY.DynamicGenerator(1, #Number - :TestGen, - nodes_OMIB[2],#bus - 1.0, # ω_ref, - 1.02, - 0.4, - oneDoneQ, - BaseShaft, - proportional_avr, #avr - fixed_tg, #tg - no_pss) - -Gen3AVR = PSY.DynamicGenerator(1, #number - :TestGen, #name - nodes_OMIB[2], #bus - 1.0, # ω_ref - 1.02, - 0.4, - oneDoneQ, #machine - BaseShaft, - typeI_avr, #avr - fixed_tg, #tg - no_pss) - -Gen4AVRTG = PSY.DynamicGenerator(1, #number - :TestGen, #name - nodes_OMIB[2], #bus - 1.0, # ω_ref - 1.02, - 0.4, - oneDoneQ, #machine - BaseShaft, - typeI_avr, #avr - typeI_tg, #tg - no_pss) - -Gen5AVR = PSY.DynamicGenerator(1, #number - :TestGen, #name - nodes_OMIB[2], #bus - 1.0, # ω_ref - 1.02, - 0.4, - AndersonFouad, #machine - BaseShaft, - typeI_avr, #avr - fixed_tg, #tg - no_pss) - -Gen6AVR = PSY.DynamicGenerator(1, #number - :TestGen, #name - nodes_OMIB[2], #bus - 1.0, #ω_ref - 1.02, #V_ref - 0.4, #P_ref - oneDoneQ, #machine - FiveShaft, #shaft - typeI_avr, #avr - fixed_tg, #tg - no_pss) - -GenKundur = PSY.DynamicGenerator(1, #number - :KundurGen, #name - nodes_kundur[1], - 1.0, #ω_ref - 1.02, #V_ref - 0.2, #P_ref - KundurMachine, #machine - KundurShaft, #shaft - kundur_avr, #avr - fixed_tg, #tg - no_pss) #pss - -GenFullKundur = PSY.DynamicGenerator(1, #number - :KundurGen, #name - nodes_kundur[1], - 1.0, #ω_ref - 1.02, #V_ref - 0.20, #P_ref - KundurFullMachine, #machine - KundurShaft, #shaft - kundur_avr, #avr - fixed_tg, #tg - no_pss) #pss - - -Gen2_benchmark = PSY.DynamicGenerator(1, #number - :Gen1, #name - nodes_benchmark[2], - 1.0, #ω_ref - 1.0142, #V_ref - 1.0, #P_ref - Mach2_benchmark, #machine - Shaft2_benchmark, #shaft - gen2_avr_benchmark_m, #avr - fixed_tg, #tg - no_pss) #pss -Gen2_benchmark_tg = PSY.DynamicGenerator(1, #number - :Gen1, #name - nodes_benchmark[2], - 1.0, #ω_ref - 1.0142, #V_ref - 1.0, #P_ref - Mach2_benchmark, #machine - Shaft2_benchmark, #shaft - gen2_avr_benchmark_m, #avr - typeII_tg, #tg - no_pss) #pss - -Gen3_benchmark = PSY.DynamicGenerator(2, #number - :Gen2, #name - nodes_benchmark[3], - 1.0, #ω_re - 1.0059, #V_ref - 1.0, #P_ref - Mach3_benchmark, #machine - Shaft3_benchmark, #shaft - gen3_avr_benchmark_m, #avr - fixed_tg, #tg - no_pss) #pss - -Gen2_benchmark_fixedavr = PSY.DynamicGenerator(1, #number - :Gen1, #name - nodes_benchmark[2], - 1.0, #ω_ref - 1.0142, #V_ref - 1.0, #P_ref - Mach2_benchmark, #machine - Shaft2_benchmark, #shaft - gen2_avr_fixed, #avr - fixed_tg, #tg - no_pss) #pss - -Gen3_benchmark_fixedavr = PSY.DynamicGenerator(2, #number - :Gen2, #name - nodes_benchmark[3], - 1.0, #ω_ref - 1.00586, #V_ref - 1.0, #P_ref - Mach3_benchmark, #machine - Shaft3_benchmark, #shaf - gen3_avr_fixed, #avr - fixed_tg, #tg - no_pss) #pss - -Gen_bench = PSY.DynamicGenerator(1, #number - :Gen1, #name - nodes_bench[2], - 1.0, #ω_ref - 1.0, #V_ref - 1.0, #P_ref - Mach2_benchmark, #machine - Shaft2_benchmark, #shaft - gen_avr_bench, #avr - fixed_tg, #tg - no_pss) #pss - gen3_avr_benchmark_m, #avr - fixed_tg, #tg - no_pss) #pss - -################### Sources ##################### - -inf_gen = StaticSource(1, #number - :InfBus, #name - nodes_OMIB[1],#bus - 1.05, #VR - 0.0, #VI - 0.000005) #Xth - -inf_gen_kundur = StaticSource(1, - :InfBus, - nodes_kundur[2], - 1.01, - 0.0, - 0.000005) - -inf_gen_benchmark = StaticSource(1, #number - :InfBus, #name - nodes_benchmark[1],#bus - 1.02, #VR - 0.0, #VI - 0.000001) #Xth - - -################### Sources ##################### -inf_gen_kundur = Source(1, - :InfBus, - nodes_kundur[2], - 1.01, - 0.0, - 0.000005) - -inf_gen_benchmark = Source(1, #number - :InfBus, #name - nodes_benchmark[1],#bus - 1.02, #VR - 0.0, #VI - 0.000001) #Xth - - -################### Sources ##################### -OMIB = PSY.System(nodes_OMIB, branch_OMIB, [Gen1AVR], [inf_gen], 100.0, 60.0) -OMIBA = PSY.System(nodes_OMIB, branch_OMIB, [Gen5AVR], [inf_gen], 100.0, 60.0) -OMIB_Kundur = PSY.System(nodes_kundur, branch_kundur, [GenKundur], [inf_gen_kundur], 100.0, 60.0) -OMIB_FullKundur = PSY.System(nodes_kundur, branch_kundur, [GenFullKundur], [inf_gen_kundur], 100.0, 60.0 -TwoBus_Benchmark = PSY.System(nodes_bench, #buses - branch_bench, #branches - [Gen_bench], #dynamic injections - [inf_gen_benchmark, loads_bench[1]], #static injections - 100.0, #Sbase - 60.0) #fbase - -ThreeBus_Benchmark = PSY.System(nodes_benchmark, #buses - branch_benchmark, #branches - [Gen2_benchmark, Gen3_benchmark], #dynamic injections - [inf_gen_benchmark, loads_benchmark[1], loads_benchmark[2], loads_benchmark[3]], #static injections - 100.0, #Sbase - 60.0) #fbase - -ThreeBus_Benchmark = PSY.System(nodes_benchmark, #buses - branch_benchmark, #branches - [Gen2_benchmark, Gen3_benchmark], #dynamic injections - [inf_gen_benchmark, loads_benchmark[1], loads_benchmark[2], loads_benchmark[3]], #static injections - 100.0, #Sbase - 60.0) #fbase - -ThreeBus_Benchmark_tg = PSY.System(nodes_benchmark, #buses - branch_benchmark, #branches - [Gen2_benchmark_tg, Gen3_benchmark], #dynamic injections - [inf_gen_benchmark, loads_benchmark[1], loads_benchmark[2], loads_benchmark[3]], #static injections - 100.0, #Sbase - 60.0) #fbase - -ThreeBus_Benchmark_fixedavr = PSY.System(nodes_benchmark, #buses - branch_benchmark, #branches - [Gen2_benchmark_fixedavr, Gen3_benchmark_fixedavr], #dynamic injections - [inf_gen_benchmark,loads_benchmark[1], loads_benchmark[2], loads_benchmark[3]], #static injections - 100.0, #Sbase - 60.0) #fbase -ThreeBus_Benchmark = PSY.System(nodes_benchmark, #buses - branch_benchmark, #branches - [Gen2_benchmark, Gen3_benchmark], #dynamic injections - [inf_gen_benchmark, loads_benchmark[1], loads_benchmark[2], loads_benchmark[3]], #static injections - 100.0, #Sbase - 60.0) #fbase diff --git a/test/data/network.jl b/test/data/network.jl deleted file mode 100644 index edd33d7..0000000 --- a/test/data/network.jl +++ /dev/null @@ -1,88 +0,0 @@ -using PowerSystems - - -################## OMIB data ##################### - -nodes_OMIB= [Bus(1 , #number - "Bus 1", #Name - "REF" , #BusType (REF, PV, PQ) - 0, #Angle in radians - 1.06, #Voltage in pu - (min=0.94, max=1.06), #Voltage limits in pu - 69), #Base voltage in kV - Bus(2 , "Bus 2" , "PV" , 0 , 1.045 , (min=0.94, max=1.06), 69)] - -branch_OMIB = [Line("Line1", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from=nodes_OMIB[1], to=nodes_OMIB[2]), #Connection between buses - 0.01938, #resistance in pu - 0.05917, #reactance in pu - (from=0.0264, to=0.0264), #susceptance in pu - 18.046, #rate in MW - 1.04)] #angle limits (-min and max) - -Dynbranch_OMIB = [DynLine("Line1", #name - true, #available - Arc(from=nodes_OMIB[1], to=nodes_OMIB[2]), #Connection between buses - 0.01938, #resistance in pu - 0.05917, #reactance in pu - (from=0.0264, to=0.0264))] #susceptance in pu - -loads = [PowerLoad("Bus2", #name - true, #available - nodes_OMIB[1], #bus - PowerSystems.ConstantPower, #model - 0.217, #active power in pu - 0.127, #reactive power in pu - 0.217, #max active power in pu - 0.127)] #max reactive power in pu - -################## Kundur machine case data ##################### - -nodes_kundur= [Bus(1 , "Bus 1" , "PQ" , 0 , 1.02 , (min=0.94, max=1.06), 24), - Bus(2 , "Bus 2" , "REF" , 0 , 1.01 , (min=0.94, max=1.06), 24)] - -branch_kundur = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_kundur[1], to=nodes_kundur[2]), - 0.01938, 0.05917, (from=0.0, to=0.0), 18.046, 1.04)] - -loads_kundur = [PowerLoad("Bus1", true, nodes_kundur[1], PowerSystems.ConstantPower, 0.0, 0.0, 0.0, 0.0)] - -################ Benchmark 3 Bus case ######################## - -nodes_benchmark = [Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] - -branch_benchmark = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_benchmark[1], to=nodes_benchmark[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_benchmark[1], to=nodes_benchmark[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_benchmark[2], to=nodes_benchmark[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] - - -branch_benchmark_noline = [Line("Line2", true, 0.0, 0.0, Arc(from=nodes_benchmark[1], to=nodes_benchmark[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_benchmark[2], to=nodes_benchmark[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] - -loads_benchmark = [PowerLoad("Bus1", true, nodes_benchmark[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), - PowerLoad("Bus2", true, nodes_benchmark[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), - PowerLoad("Bus3", true, nodes_benchmark[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] - -################ Benchmark 2 Bus case ######################## - -nodes_bench = [Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] - -branch_bench = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_bench[1], to=nodes_bench[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] - -loads_bench = [PowerLoad("Bus1", true, nodes_bench[2], PowerSystems.ConstantPower, 1.0, 0.3, 1.5, 0.8)] - -############## Static Kundur Machines for PF ####################### - -machine_Kundur = ThermalStandard("Bus1", true, nodes_kundur[1], 2.22, 0, - TechThermal(5.55, PowerSystems.ST, PowerSystems.COAL, (min=0.0, max=5.55), (min=-1.0, max=1.0), nothing, nothing), - ThreePartCost((430.292599, 2000.0), 0.0, 0.0, 0.0) - ) -infinite_bus = ThermalStandard("Bus2", true, nodes_kundur[2], -2.22, 0, - TechThermal(5.55, PowerSystems.ST, PowerSystems.COAL, (min=-500.55, max=500.55), (min=-5.55, max=5.55), nothing, nothing), - ThreePartCost((430.292599, 2000.0), 0.0, 0.0, 0.0) - ) diff --git a/test/data/network_benchmark.jl b/test/data/network_benchmark.jl deleted file mode 100644 index 6bdaa3a..0000000 --- a/test/data/network_benchmark.jl +++ /dev/null @@ -1,75 +0,0 @@ -using PowerSystems - -############### OMIB Benchmark (Case 1 and 5) ######################## - -nodes_case1 = [Bus(1 , #number - "Bus 1", #Name - "REF" , #BusType (REF, PV, PQ) - 0, #Angle in radians - 1.05, #Voltage in pu - (min=0.94, max=1.06), #Voltage limits in pu - 69), #Base voltage in kV - Bus(2 , "Bus 2" , "PV" , 0 , 1.0 , (min=0.94, max=1.06), 69)] - -branch_case1 = [Line("Line1", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from=nodes_case1[1], to=nodes_case1[2]), #Connection between buses - 0.01, #resistance in pu - 0.05, #reactance in pu - (from=0.0, to=0.0), #susceptance in pu - 18.046, #rate in MW - 1.04)] #angle limits (-min and max) - -#Trip of a single circuit of Line 1 -> Resistance and Reactance doubled. -branch_case1_fault = [Line("Line1", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from=nodes_case1[1], to=nodes_case1[2]), #Connection between buses - 0.02, #resistance in pu - 0.1, #reactance in pu - (from=0.0, to=0.0), #susceptance in pu - 18.046, #rate in MW - 1.04)] #angle limits (-min and max) - -loads_case1 = [PowerLoad("Bus1", true, nodes_case1[2], PowerSystems.ConstantPower, 0.3, 0.01, 0.3, 0.01)] - - -################ Benchmark 3 Bus case (Cases 2, 3 and 4)######################## - -nodes_case234 = [Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] - -branch_case234 = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] - -#Trip of Line 1. -branch_case234_fault = [Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] - -loads_case234 = [PowerLoad("Bus1", true, nodes_case234[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), - PowerLoad("Bus2", true, nodes_case234[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), - PowerLoad("Bus3", true, nodes_case234[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] - - -################ Benchmark 3 Bus case TG (Case 5)######################## - -nodes_case5 = [Bus(1 , "Bus 1" , "REF" , 0 , 1.05 , (min=0.94, max=1.06), 138), - Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] - -branch_case5 = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[2]), 0.01, 0.05, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case5[2], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04)] - -#Trip of a single circuit of Line 1 -> Resistance and Reactance doubled. -branch_case5_fault = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[2]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case5[2], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04)] - -loads_case5 = [PowerLoad("Bus2", true, nodes_case5[2], PowerSystems.ConstantPower, 0.3, 0.05, 0.3, 0.05), - PowerLoad("Bus3", true, nodes_case5[3], PowerSystems.ConstantPower, 0.3, 0.05, 0.3, 0.05)] diff --git a/test/data/network_test.jl b/test/data/network_test.jl deleted file mode 100644 index a4bb95f..0000000 --- a/test/data/network_test.jl +++ /dev/null @@ -1,88 +0,0 @@ -nodes_test= [Bus(1 , #number - "Bus 1", #Name - "REF" , #BusType (REF, PV, PQ) - 0, #Angle in radians - 1.02, #Voltage in pu - (min=0.94, max=1.06), #Voltage limits in pu - 69), #Base voltage in kV - Bus(2 , "Bus 2" , "PV" , 0 , 1.0 , (min=0.94, max=1.06), 69)] - -nodes_test2= [Bus(1 , #number - "Bus 1", #Name - "REF" , #BusType (REF, PV, PQ) - 0, #Angle in radians - 1.02, #Voltage in pu - (min=0.94, max=1.06), #Voltage limits in pu - 69), #Base voltage in kV - Bus(2 , "Bus 2" , "PV" , 0 , 1.0 , (min=0.94, max=1.06), 69), - Bus(3 , "Bus 3" , "PQ" , 0 , 1.0 , (min=0.94, max=1.06), 69)] - -branch_test = [Line("Line1", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from=nodes_test[1], to=nodes_test[2]), #Connection between buses - 0.01, #resistance in pu - 0.05, #reactance in pu - (from=0.0, to=0.0), #susceptance in pu - 18.046, #rate in MW - 1.04)] #angle limits (-min and max) - - - - -branch_test_fault = [Line("Line1", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from=nodes_test[1], to=nodes_test[2]), #Connection between buses - 0.02, #resistance in pu - 0.1, #reactance in pu - (from=0.0, to=0.0), #susceptance in pu - 18.046, #rate in MW - 1.04)] #angle limits (-min and max) - - -#### - -branch_test2 = [Line("Line1", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from=nodes_test2[1], to=nodes_test2[2]), #Connection between buses - 0.01, #resistance in pu - 0.05, #reactance in pu - (from=0.0, to=0.0), #susceptance in pu - 18.046, #rate in MW - 1.04), - Line("Line2", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from=nodes_test2[2], to=nodes_test2[3]), #Connection between buses - 0.02, #resistance in pu - 0.1, #reactance in pu - (from=0.0, to=0.0), #susceptance in pu - 18.046, #rate in MW - 1.04)] #angle limits (-min and max) - -branch_test2_fault = [Line("Line1", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from=nodes_test2[1], to=nodes_test2[2]), #Connection between buses - 0.02, #resistance in pu - 0.1, #reactance in pu - (from=0.0, to=0.0), #susceptance in pu - 18.046, #rate in MW - 1.04), - Line("Line2", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from=nodes_test2[2], to=nodes_test2[3]), #Connection between buses - 0.02, #resistance in pu - 0.1, #reactance in pu - (from=0.0, to=0.0), #susceptance in pu - 18.046, #rate in MW - 1.04)] #angle limits (-min and max) diff --git a/test/old_tests/test_case8_staticbranches.jl b/test/old_tests/test_case8_staticbranches.jl index ff8013e..8bc3d77 100644 --- a/test/old_tests/test_case8_staticbranches.jl +++ b/test/old_tests/test_case8_staticbranches.jl @@ -10,197 +10,297 @@ The perturbation trips two of the three circuits of line between buses 1 and 2, ############### Data Network ######################## -nodes_case8 = [Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - Bus(3 , "Bus 3" , "PQ" , 0 , 1.00 , (min=0.94, max=1.06), 138)] - -branch_case8 = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case8[1], to=nodes_case8[3]), 0.01, 0.12, (from=0.1, to=0.1), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case8[1], to=nodes_case8[2]), 0.01, 0.12, (from=0.1, to=0.1), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case8[2], to=nodes_case8[3]), 0.02, 0.9, (from=0.5, to=0.5), 100, 1.04)] +nodes_case8 = [ + Bus(1, "Bus 1", "REF", 0, 1.02, (min = 0.94, max = 1.06), 138), + Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), + Bus(3, "Bus 3", "PQ", 0, 1.00, (min = 0.94, max = 1.06), 138), +] + +branch_case8 = [ + Line( + "Line1", + true, + 0.0, + 0.0, + Arc(from = nodes_case8[1], to = nodes_case8[3]), + 0.01, + 0.12, + (from = 0.1, to = 0.1), + 100, + 1.04, + ), + Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_case8[1], to = nodes_case8[2]), + 0.01, + 0.12, + (from = 0.1, to = 0.1), + 100, + 1.04, + ), + Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_case8[2], to = nodes_case8[3]), + 0.02, + 0.9, + (from = 0.5, to = 0.5), + 100, + 1.04, + ), +] #Trip of Line 1. -branch_case8_fault = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case8[1], to=nodes_case8[3]), 0.03, 0.36, (from=0.03, to=0.03), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case8[1], to=nodes_case8[2]), 0.01, 0.12, (from=0.1, to=0.1), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case8[2], to=nodes_case8[3]), 0.02, 0.9, (from=0.5, to=0.5), 100, 1.04)] - - -loads_case8 = [PowerLoad("Bus1", true, nodes_case8[1], PowerSystems.ConstantPower, 0.5, 0.1, 1.5, 0.8), - PowerLoad("Bus2", true, nodes_case8[2], PowerSystems.ConstantPower, 1.0, 0.3, 1.5, 0.8), - PowerLoad("Bus3", true, nodes_case8[3], PowerSystems.ConstantPower, 0.3, 0.1, 0.5, 0.3)] - +branch_case8_fault = [ + Line( + "Line1", + true, + 0.0, + 0.0, + Arc(from = nodes_case8[1], to = nodes_case8[3]), + 0.03, + 0.36, + (from = 0.03, to = 0.03), + 100, + 1.04, + ), + Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_case8[1], to = nodes_case8[2]), + 0.01, + 0.12, + (from = 0.1, to = 0.1), + 100, + 1.04, + ), + Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_case8[2], to = nodes_case8[3]), + 0.02, + 0.9, + (from = 0.5, to = 0.5), + 100, + 1.04, + ), +] + +loads_case8 = [ + PowerLoad("Bus1", true, nodes_case8[1], PowerSystems.ConstantPower, 0.5, 0.1, 1.5, 0.8), + PowerLoad("Bus2", true, nodes_case8[2], PowerSystems.ConstantPower, 1.0, 0.3, 1.5, 0.8), + PowerLoad("Bus3", true, nodes_case8[3], PowerSystems.ConstantPower, 0.3, 0.1, 0.5, 0.3), +] ############### Data devices ######################## -inf_gen_case8 = StaticSource(1, #number - :InfBus, #name - nodes_case8[1],#bus - 1.00, #VR - 0.0, #VI - 0.000005) #Xth - +inf_gen_case8 = StaticSource( + 1, #number + :InfBus, #name + nodes_case8[1],#bus + 1.00, #VR + 0.0, #VI + 0.000005, +) #Xth ######## Machine Data ######### ### Case 2: 4th Order Model with AVR (3-bus case) ### -case8_machine = OneDOneQMachine(0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0) #MVABase +case8_machine = OneDOneQMachine( + 0.0, #R + 1.3125, #Xd + 1.2578, #Xq + 0.1813, #Xd_p + 0.25, #Xq_p + 5.89, #Td0_p + 0.6, #Tq0_p + 100.0, +) #MVABase ######## Shaft Data ######### ### Shafts for Gen ### -case8_shaft = SingleMass(3.01, #H (M = 6.02 -> H = M/2) - 0.0) #D +case8_shaft = SingleMass( + 3.01, #H (M = 6.02 -> H = M/2) + 0.0, +) #D ######## PSS Data ######### cases_no_pss = PSSFixed(0.0) - ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### case8_no_tg = TGFixed(1.0) #eff - ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case8_avr = AVRTypeI(20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555) #Be - 2nd ceiling coefficient +case8_avr = AVRTypeI( + 20.0, #Ka - Gain + 0.01, #Ke + 0.063, #Kf + 0.2, #Ta + 0.314, #Te + 0.35, #Tf + 0.001, #Tr + 5.0, #Vrmax + -5.0, #Vrmin + 0.0039, #Ae - 1st ceiling coefficient + 1.555, +) #Be - 2nd ceiling coefficient ### Case 7 Generators ### -case8_gen = PSY.DynamicGenerator(1, #Number - :Case8Gen, - nodes_case8[2], #bus - 1.0, # ω_ref, - 1.0124, #V_ref - 0.6, #P_ref - case8_machine, #machine - case8_shaft, #shaft - case8_avr, #avr - case8_no_tg, #tg - cases_no_pss) #pss +case8_gen = PSY.DynamicGenerator( + 1, #Number + :Case8Gen, + nodes_case8[2], #bus + 1.0, # ω_ref, + 1.0124, #V_ref + 0.6, #P_ref + case8_machine, #machine + case8_shaft, #shaft + case8_avr, #avr + case8_no_tg, #tg + cases_no_pss, +) #pss ############### Inverter Data ######################## -converter = AvgCnvFixedDC(138.0, #Rated Voltage - 100.0) #Rated MVA +converter = AvgCnvFixedDC( + 138.0, #Rated Voltage + 100.0, +) #Rated MVA dc_source = FixedDCSource(1500.0) #Not in the original data, guessed. -filt = LCLFilter(0.08, #Series inductance lf in pu - 0.003, #Series resitance rf in pu - 0.074, #Shunt capacitance cf in pu - 0.2, #Series reactance rg to grid connection (#Step up transformer or similar) - 0.01) #Series resistance lg to grid connection (#Step up transformer or similar) - -pll = PLL(500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. - 0.084, #k_p: PLL proportional gain - 4.69) #k_i: PLL integral gain - -virtual_H = VirtualInertia(2.0, #Ta:: VSM inertia constant - 400.0, #kd:: VSM damping coefficient - 20.0, #kω:: Frequency droop gain in pu - 2*pi*50.0) #ωb:: Rated angular frequency - -Q_control = ReactivePowerDroop(0.2, #kq:: Reactive power droop gain in pu - 1000.0) #ωf:: Reactive power cut-off low pass filter frequency +filt = LCLFilter( + 0.08, #Series inductance lf in pu + 0.003, #Series resitance rf in pu + 0.074, #Shunt capacitance cf in pu + 0.2, #Series reactance rg to grid connection (#Step up transformer or similar) + 0.01, +) #Series resistance lg to grid connection (#Step up transformer or similar) + +pll = PLL( + 500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. + 0.084, #k_p: PLL proportional gain + 4.69, +) #k_i: PLL integral gain + +virtual_H = VirtualInertia( + 2.0, #Ta:: VSM inertia constant + 400.0, #kd:: VSM damping coefficient + 20.0, #kω:: Frequency droop gain in pu + 2 * pi * 50.0, +) #ωb:: Rated angular frequency + +Q_control = ReactivePowerDroop( + 0.2, #kq:: Reactive power droop gain in pu + 1000.0, +) #ωf:: Reactive power cut-off low pass filter frequency outer_control = VirtualInertiaQdroop(virtual_H, Q_control) -vsc = CombinedVIwithVZ(0.59, #kpv:: Voltage controller proportional gain - 736.0, #kiv:: Voltage controller integral gain - 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers - 0.0, #rv:: Virtual resistance in pu - 0.2, #lv: Virtual inductance in pu - 1.27, #kpc:: Current controller proportional gain - 14.3, #kiv:: Current controller integral gain - 0.0, #kffi:: Binary variable enabling the current feed-forward in output of current controllers - 50.0, #ωad:: Active damping low pass filter cut-off frequency - 0.2) #kad:: Active damping gain - -case8_inv = PSY.DynamicInverter(2, #number - :DARCO, #name - nodes_case8[3], #bus location - 1.0, #ω_ref - 0.8, #V_ref - 0.5, #P_ref - -0.3, #Q_ref - 100.0, #MVABase - converter, #Converter - outer_control, #OuterControl - vsc, #Voltage Source Controller - dc_source, #DC Source - pll, #Frequency Estimator - filt) #Output Filter - +vsc = CombinedVIwithVZ( + 0.59, #kpv:: Voltage controller proportional gain + 736.0, #kiv:: Voltage controller integral gain + 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers + 0.0, #rv:: Virtual resistance in pu + 0.2, #lv: Virtual inductance in pu + 1.27, #kpc:: Current controller proportional gain + 14.3, #kiv:: Current controller integral gain + 0.0, #kffi:: Binary variable enabling the current feed-forward in output of current controllers + 50.0, #ωad:: Active damping low pass filter cut-off frequency + 0.2, +) #kad:: Active damping gain + +case8_inv = PSY.DynamicInverter( + 2, #number + :DARCO, #name + nodes_case8[3], #bus location + 1.0, #ω_ref + 0.8, #V_ref + 0.5, #P_ref + -0.3, #Q_ref + 100.0, #MVABase + converter, #Converter + outer_control, #OuterControl + vsc, #Voltage Source Controller + dc_source, #DC Source + pll, #Frequency Estimator + filt, +) #Output Filter ######################### Dynamical System ######################## -case8_DynSystem = PSY.System(nodes_case8, branch_case8, [case8_inv, case8_gen], vcat(inf_gen_case8, loads_case8), 100.0, 50.0); - +case8_DynSystem = PSY.System( + nodes_case8, + branch_case8, + [case8_inv, case8_gen], + vcat(inf_gen_case8, loads_case8), + 100.0, + 50.0, +); ################################################## ############### SOLVE PROBLEM #################### ################################################## dx0 = zeros(LITS.get_total_rows(case8_DynSystem)) -x0 = [1.00, #V1_R - 1.00, #V2_R - 1.00, #V3_R - 0.0, #V1_I - -0.01, #V2_I - -0.01, #V3_I - 0.0, #δω_vsm - 0.2, #δθ_vsm - 0.025, #qm - 0.0015, #ξ_d - -0.07, #ξ_q - 0.05, #γ_d - -0.001, #γ_q - 0.95, #ϕ_d - -0.10, #ϕ_q - 1.004, #vpll_d - 0.0, #vpll_q - 0.0, #ε_pll - 0.1, #δθ_pll - 0.5, #id_cv - 0.0, #iq_cv - 0.95, #vod - -0.1, #voq - 0.49, #iod - -0.1, #ioq - 1.0, #eq_p - 0.47, #ed_p - 0.6, #δ - 1.0, #ω - 2.1, #Vf - 0.28, #Vr1 - -0.39, #Vr2, - 1.0] #Vm +x0 = [ + 1.00, #V1_R + 1.00, #V2_R + 1.00, #V3_R + 0.0, #V1_I + -0.01, #V2_I + -0.01, #V3_I + 0.0, #δω_vsm + 0.2, #δθ_vsm + 0.025, #qm + 0.0015, #ξ_d + -0.07, #ξ_q + 0.05, #γ_d + -0.001, #γ_q + 0.95, #ϕ_d + -0.10, #ϕ_q + 1.004, #vpll_d + 0.0, #vpll_q + 0.0, #ε_pll + 0.1, #δθ_pll + 0.5, #id_cv + 0.0, #iq_cv + 0.95, #vod + -0.1, #voq + 0.49, #iod + -0.1, #ioq + 1.0, #eq_p + 0.47, #ed_p + 0.6, #δ + 1.0, #ω + 2.1, #Vf + 0.28, #Vr1 + -0.39, #Vr2, + 1.0, +] #Vm case8_inv.inner_vars[13] = 0.95 #Vd_cnv var case8_inv.inner_vars[14] = -0.1 #Vq_cnv var -Ybus_fault = Ybus(branch_case8_fault, nodes_case8)[:,:] +Ybus_fault = Ybus(branch_case8_fault, nodes_case8)[:, :] u0 = [0.2] tspan = (0.0, 30.0); #Find initial condition -inif! = (out,x) -> LITS.system_model!(out, dx0 ,x, (Ybus_fault,case8_DynSystem), 0.0) -sys_solve = nlsolve(inif!, x0, xtol=:1e-8,ftol=:1e-8,method=:trust_region) +inif! = (out, x) -> LITS.system_model!(out, dx0, x, (Ybus_fault, case8_DynSystem), 0.0) +sys_solve = nlsolve(inif!, x0, xtol = :1e-8, ftol = :1e-8, method = :trust_region) x0_init = sys_solve.zero #Define Fault using Callbacks @@ -214,6 +314,9 @@ run_simulation!(sim, IDA()); #Obtain data for voltages series = get_voltagemag_series(sim, 2) -zoom = [(series[1][ix], series[2][ix]) for (ix, s) in enumerate(series[1]) if (s > 0.90 && s < 1.6)] +zoom = [ + (series[1][ix], series[2][ix]) + for (ix, s) in enumerate(series[1]) if (s > 0.90 && s < 1.6) +] @test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case9_dynbranches.jl b/test/old_tests/test_case9_dynbranches.jl index 3677352..d428a8a 100644 --- a/test/old_tests/test_case9_dynbranches.jl +++ b/test/old_tests/test_case9_dynbranches.jl @@ -10,200 +10,285 @@ The perturbation trips two of the three circuits of line between buses 1 and 2, ############### Data Network ######################## -nodes_case9 = [Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - Bus(3 , "Bus 3" , "PQ" , 0 , 1.00 , (min=0.94, max=1.06), 138)] - -branch_case9 = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case9[1], to=nodes_case9[3]), 0.01, 0.12, (from=0.1, to=0.1), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case9[1], to=nodes_case9[2]), 0.01, 0.12, (from=0.1, to=0.1), 100, 1.04)] +nodes_case9 = [ + Bus(1, "Bus 1", "REF", 0, 1.02, (min = 0.94, max = 1.06), 138), + Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), + Bus(3, "Bus 3", "PQ", 0, 1.00, (min = 0.94, max = 1.06), 138), +] + +branch_case9 = [ + Line( + "Line1", + true, + 0.0, + 0.0, + Arc(from = nodes_case9[1], to = nodes_case9[3]), + 0.01, + 0.12, + (from = 0.1, to = 0.1), + 100, + 1.04, + ), + Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_case9[1], to = nodes_case9[2]), + 0.01, + 0.12, + (from = 0.1, to = 0.1), + 100, + 1.04, + ), +] #Trip of Line 1. -branch_case9_fault = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case9[1], to=nodes_case9[3]), 0.03, 0.36, (from=0.03, to=0.03), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case9[1], to=nodes_case9[2]), 0.01, 0.12, (from=0.1, to=0.1), 100, 1.04)] - - -loads_case9 = [PowerLoad("Bus1", true, nodes_case9[1], PowerSystems.ConstantPower, 0.5, 0.1, 1.5, 0.8), - PowerLoad("Bus2", true, nodes_case9[2], PowerSystems.ConstantPower, 1.0, 0.3, 1.5, 0.8), - PowerLoad("Bus3", true, nodes_case9[3], PowerSystems.ConstantPower, 0.3, 0.1, 0.5, 0.3)] - -dyn_branch9 = [LITS.DynLine("Line3", true, Arc(from=nodes_case9[2], to=nodes_case9[3]), 0.02, 0.9, (from=0.5, to=0.5))] - - +branch_case9_fault = [ + Line( + "Line1", + true, + 0.0, + 0.0, + Arc(from = nodes_case9[1], to = nodes_case9[3]), + 0.03, + 0.36, + (from = 0.03, to = 0.03), + 100, + 1.04, + ), + Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_case9[1], to = nodes_case9[2]), + 0.01, + 0.12, + (from = 0.1, to = 0.1), + 100, + 1.04, + ), +] + +loads_case9 = [ + PowerLoad("Bus1", true, nodes_case9[1], PowerSystems.ConstantPower, 0.5, 0.1, 1.5, 0.8), + PowerLoad("Bus2", true, nodes_case9[2], PowerSystems.ConstantPower, 1.0, 0.3, 1.5, 0.8), + PowerLoad("Bus3", true, nodes_case9[3], PowerSystems.ConstantPower, 0.3, 0.1, 0.5, 0.3), +] + +dyn_branch9 = [LITS.DynLine( + "Line3", + true, + Arc(from = nodes_case9[2], to = nodes_case9[3]), + 0.02, + 0.9, + (from = 0.5, to = 0.5), +)] ############### Data devices ######################## -inf_gen_case9 = StaticSource(1, #number - :InfBus, #name - nodes_case9[1],#bus - 1.00, #VR - 0.0, #VI - 0.000005) #Xth - +inf_gen_case9 = StaticSource( + 1, #number + :InfBus, #name + nodes_case9[1],#bus + 1.00, #VR + 0.0, #VI + 0.000005, +) #Xth ######## Machine Data ######### ### Case 2: 4th Order Model with AVR (3-bus case) ### -case9_machine = OneDOneQMachine(0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0) #MVABase +case9_machine = OneDOneQMachine( + 0.0, #R + 1.3125, #Xd + 1.2578, #Xq + 0.1813, #Xd_p + 0.25, #Xq_p + 5.89, #Td0_p + 0.6, #Tq0_p + 100.0, +) #MVABase ######## Shaft Data ######### ### Shafts for Gen ### -case9_shaft = SingleMass(3.01, #H (M = 6.02 -> H = M/2) - 0.0) #D +case9_shaft = SingleMass( + 3.01, #H (M = 6.02 -> H = M/2) + 0.0, +) #D ######## PSS Data ######### cases_no_pss = PSSFixed(0.0) - ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### case9_no_tg = TGFixed(1.0) #eff - ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case9_avr = AVRTypeI(20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555) #Be - 2nd ceiling coefficient +case9_avr = AVRTypeI( + 20.0, #Ka - Gain + 0.01, #Ke + 0.063, #Kf + 0.2, #Ta + 0.314, #Te + 0.35, #Tf + 0.001, #Tr + 5.0, #Vrmax + -5.0, #Vrmin + 0.0039, #Ae - 1st ceiling coefficient + 1.555, +) #Be - 2nd ceiling coefficient ### Case 7 Generators ### -case9_gen = PSY.DynamicGenerator(1, #Number - :Case9Gen, - nodes_case9[2], #bus - 1.0, # ω_ref, - 1.0124, #V_ref - 0.6, #P_ref - case9_machine, #machine - case9_shaft, #shaft - case9_avr, #avr - case9_no_tg, #tg - cases_no_pss) #pss +case9_gen = PSY.DynamicGenerator( + 1, #Number + :Case9Gen, + nodes_case9[2], #bus + 1.0, # ω_ref, + 1.0124, #V_ref + 0.6, #P_ref + case9_machine, #machine + case9_shaft, #shaft + case9_avr, #avr + case9_no_tg, #tg + cases_no_pss, +) #pss ############### Inverter Data ######################## -converter = AvgCnvFixedDC(138.0, #Rated Voltage - 100.0) #Rated MVA +converter = AvgCnvFixedDC( + 138.0, #Rated Voltage + 100.0, +) #Rated MVA dc_source = FixedDCSource(1500.0) #Not in the original data, guessed. -filt = LCLFilter(0.08, #Series inductance lf in pu - 0.003, #Series resitance rf in pu - 0.074, #Shunt capacitance cf in pu - 0.2, #Series reactance rg to grid connection (#Step up transformer or similar) - 0.01) #Series resistance lg to grid connection (#Step up transformer or similar) - -pll = PLL(500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. - 0.084, #k_p: PLL proportional gain - 4.69) #k_i: PLL integral gain - -virtual_H = VirtualInertia(2.0, #Ta:: VSM inertia constant - 400.0, #kd:: VSM damping coefficient - 20.0, #kω:: Frequency droop gain in pu - 2*pi*50.0) #ωb:: Rated angular frequency - -Q_control = ReactivePowerDroop(0.2, #kq:: Reactive power droop gain in pu - 1000.0) #ωf:: Reactive power cut-off low pass filter frequency +filt = LCLFilter( + 0.08, #Series inductance lf in pu + 0.003, #Series resitance rf in pu + 0.074, #Shunt capacitance cf in pu + 0.2, #Series reactance rg to grid connection (#Step up transformer or similar) + 0.01, +) #Series resistance lg to grid connection (#Step up transformer or similar) + +pll = PLL( + 500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. + 0.084, #k_p: PLL proportional gain + 4.69, +) #k_i: PLL integral gain + +virtual_H = VirtualInertia( + 2.0, #Ta:: VSM inertia constant + 400.0, #kd:: VSM damping coefficient + 20.0, #kω:: Frequency droop gain in pu + 2 * pi * 50.0, +) #ωb:: Rated angular frequency + +Q_control = ReactivePowerDroop( + 0.2, #kq:: Reactive power droop gain in pu + 1000.0, +) #ωf:: Reactive power cut-off low pass filter frequency outer_control = VirtualInertiaQdroop(virtual_H, Q_control) -vsc = CombinedVIwithVZ(0.59, #kpv:: Voltage controller proportional gain - 736.0, #kiv:: Voltage controller integral gain - 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers - 0.0, #rv:: Virtual resistance in pu - 0.2, #lv: Virtual inductance in pu - 1.27, #kpc:: Current controller proportional gain - 14.3, #kiv:: Current controller integral gain - 0.0, #kffi:: Binary variable enabling the current feed-forward in output of current controllers - 50.0, #ωad:: Active damping low pass filter cut-off frequency - 0.2) #kad:: Active damping gain - -case9_inv = PSY.DynamicInverter(2, #number - :DARCO, #name - nodes_case9[3], #bus location - 1.0, #ω_ref - 0.8, #V_ref - 0.5, #P_ref - -0.3, #Q_ref - 100.0, #MVABase - converter, #Converter - outer_control, #OuterControl - vsc, #Voltage Source Controller - dc_source, #DC Source - pll, #Frequency Estimator - filt) #Output Filter - +vsc = CombinedVIwithVZ( + 0.59, #kpv:: Voltage controller proportional gain + 736.0, #kiv:: Voltage controller integral gain + 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers + 0.0, #rv:: Virtual resistance in pu + 0.2, #lv: Virtual inductance in pu + 1.27, #kpc:: Current controller proportional gain + 14.3, #kiv:: Current controller integral gain + 0.0, #kffi:: Binary variable enabling the current feed-forward in output of current controllers + 50.0, #ωad:: Active damping low pass filter cut-off frequency + 0.2, +) #kad:: Active damping gain + +case9_inv = PSY.DynamicInverter( + 2, #number + :DARCO, #name + nodes_case9[3], #bus location + 1.0, #ω_ref + 0.8, #V_ref + 0.5, #P_ref + -0.3, #Q_ref + 100.0, #MVABase + converter, #Converter + outer_control, #OuterControl + vsc, #Voltage Source Controller + dc_source, #DC Source + pll, #Frequency Estimator + filt, +) #Output Filter ######################### Dynamical System ######################## -case9_DynSystem = PSY.System(nodes_case9, branch_case9, [case9_inv, case9_gen], vcat(inf_gen_case9, loads_case9), 100.0, 50.0, dyn_branch9); - +case9_DynSystem = PSY.System( + nodes_case9, + branch_case9, + [case9_inv, case9_gen], + vcat(inf_gen_case9, loads_case9), + 100.0, + 50.0, + dyn_branch9, +); ################################################## ############### SOLVE PROBLEM #################### ################################################## dx0 = zeros(LITS.get_total_rows(case9_DynSystem)) -x0 = [1.00, #V1_R - 1.00, #V2_R - 1.00, #V3_R - 0.0, #V1_I - -0.01, #V2_I - -0.01, #V3_I - 0.0, #δω_vsm - 0.2, #δθ_vsm - 0.025, #qm - 0.0015, #ξ_d - -0.07, #ξ_q - 0.05, #γ_d - -0.001, #γ_q - 0.95, #ϕ_d - -0.10, #ϕ_q - 1.004, #vpll_d - 0.0, #vpll_q - 0.0, #ε_pll - 0.1, #δθ_pll - 0.5, #id_cv - 0.0, #iq_cv - 0.95, #vod - -0.1, #voq - 0.49, #iod - -0.1, #ioq - 1.0, #eq_p - 0.47, #ed_p - 0.6, #δ - 1.0, #ω - 2.1, #Vf - 0.28, #Vr1 - -0.39, #Vr2, - 1.0, #Vm - 0.5, #IL1_R - 0.5] #IL1_I +x0 = [ + 1.00, #V1_R + 1.00, #V2_R + 1.00, #V3_R + 0.0, #V1_I + -0.01, #V2_I + -0.01, #V3_I + 0.0, #δω_vsm + 0.2, #δθ_vsm + 0.025, #qm + 0.0015, #ξ_d + -0.07, #ξ_q + 0.05, #γ_d + -0.001, #γ_q + 0.95, #ϕ_d + -0.10, #ϕ_q + 1.004, #vpll_d + 0.0, #vpll_q + 0.0, #ε_pll + 0.1, #δθ_pll + 0.5, #id_cv + 0.0, #iq_cv + 0.95, #vod + -0.1, #voq + 0.49, #iod + -0.1, #ioq + 1.0, #eq_p + 0.47, #ed_p + 0.6, #δ + 1.0, #ω + 2.1, #Vf + 0.28, #Vr1 + -0.39, #Vr2, + 1.0, #Vm + 0.5, #IL1_R + 0.5, +] #IL1_I case9_inv.inner_vars[13] = 0.95 #Vd_cnv var case9_inv.inner_vars[14] = -0.1 #Vq_cnv var -Ybus_fault = Ybus(branch_case9_fault, nodes_case9)[:,:] +Ybus_fault = Ybus(branch_case9_fault, nodes_case9)[:, :] u0 = [0.2] tspan = (0.0, 30.0); #Find initial condition -inif! = (out,x) -> LITS.system_model!(out, dx0 ,x, (Ybus_fault,case9_DynSystem), 0.0) -sys_solve = nlsolve(inif!, x0, xtol=:1e-8,ftol=:1e-8,method=:trust_region) +inif! = (out, x) -> LITS.system_model!(out, dx0, x, (Ybus_fault, case9_DynSystem), 0.0) +sys_solve = nlsolve(inif!, x0, xtol = :1e-8, ftol = :1e-8, method = :trust_region) x0_init = sys_solve.zero #Define Fault using Callbacks @@ -217,6 +302,9 @@ run_simulation!(sim, IDA()); #Obtain data for voltages series = get_voltagemag_series(sim, 2) -zoom = [(series[1][ix], series[2][ix]) for (ix, s) in enumerate(series[1]) if (s > 0.90 && s < 1.6)] +zoom = [ + (series[1][ix], series[2][ix]) + for (ix, s) in enumerate(series[1]) if (s > 0.90 && s < 1.6) +] @test sim.solution.retcode == :Success diff --git a/test/test_case1_OMIB.jl b/test/test_case1_OMIB.jl index 5688a3c..89c691c 100644 --- a/test/test_case1_OMIB.jl +++ b/test/test_case1_OMIB.jl @@ -4,85 +4,95 @@ This case study defines a classical machine against an infinite bus. The fault drop a circuit on the (double circuit) line connecting the two buses, doubling its impedance """ - ################################################## ############### LOAD DATA ######################## ################################################## ############### Data Network ######################## -nodes_case1 = [PSY.Bus(1 , #number - "Bus 1", #Name - "REF" , #BusType (REF, PV, PQ) - 0, #Angle in radians - 1.05, #Voltage in pu - (min=0.94, max=1.06), #Voltage limits in pu - 69), #Base voltage in kV - PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.0 , (min=0.94, max=1.06), 69)] - -branch_case1 = [PSY.Line("Line1", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from=nodes_case1[1], to=nodes_case1[2]), #Connection between buses - 0.01, #resistance in pu - 0.05, #reactance in pu - (from=0.0, to=0.0), #susceptance in pu - 18.046, #rate in MW - 1.04)] #angle limits (-min and max) +nodes_case1 = [ + PSY.Bus( + 1, #number + "Bus 1", #Name + "REF", #BusType (REF, PV, PQ) + 0, #Angle in radians + 1.05, #Voltage in pu + (min = 0.94, max = 1.06), #Voltage limits in pu + 69, + ), #Base voltage in kV + PSY.Bus(2, "Bus 2", "PV", 0, 1.0, (min = 0.94, max = 1.06), 69), +] + +branch_case1 = [PSY.Line( + "Line1", #name + true, #available + 0.0, #active power flow initial condition (from-to) + 0.0, #reactive power flow initial condition (from-to) + Arc(from = nodes_case1[1], to = nodes_case1[2]), #Connection between buses + 0.01, #resistance in pu + 0.05, #reactance in pu + (from = 0.0, to = 0.0), #susceptance in pu + 18.046, #rate in MW + 1.04, +)] #angle limits (-min and max) #Trip of a single circuit of Line 1 -> Resistance and Reactance doubled. -branch_case1_fault = [PSY.Line("Line1", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from=nodes_case1[1], to=nodes_case1[2]), #Connection between buses - 0.02, #resistance in pu - 0.1, #reactance in pu - (from=0.0, to=0.0), #susceptance in pu - 18.046, #rate in MW - 1.04)] #angle limits (-min and max) - -loads_case1 = [PSY.PowerLoad("LBus1", #name - true, #availability - nodes_case1[2], #bus - PowerSystems.ConstantPower, #type - 0.3, #P - 0.01, #Q - 0.3, #P_max - 0.01)] #Q_max - +branch_case1_fault = [PSY.Line( + "Line1", #name + true, #available + 0.0, #active power flow initial condition (from-to) + 0.0, #reactive power flow initial condition (from-to) + Arc(from = nodes_case1[1], to = nodes_case1[2]), #Connection between buses + 0.02, #resistance in pu + 0.1, #reactance in pu + (from = 0.0, to = 0.0), #susceptance in pu + 18.046, #rate in MW + 1.04, +)] #angle limits (-min and max) + +loads_case1 = [PSY.PowerLoad( + "LBus1", #name + true, #availability + nodes_case1[2], #bus + PowerSystems.ConstantPower, #type + 0.3, #P + 0.01, #Q + 0.3, #P_max + 0.01, +)] #Q_max ############### Data devices ######################## inf_gen_case1 = PSY.Source( - "InfBus", #name - true, #availability - nodes_case1[1], #bus - 1.05, #VR - 0.0, #VI - 0.000001) #Xth + "InfBus", #name + true, #availability + nodes_case1[1], #bus + 1.05, #VR + 0.0, #VI + 0.000001, +) #Xth ######## Machine Data ######### ### Case 1: Classical machine against infinite bus ### -case1_machine = PSY.BaseMachine(0.0, #R - 0.2995, #Xd_p - 0.7087, #eq_p - 100.0) #MVABase +case1_machine = PSY.BaseMachine( + 0.0, #R + 0.2995, #Xd_p + 0.7087, #eq_p + 100.0, +) #MVABase ######## Shaft Data ######### ### Shaft for Case 1 ### -case1_shaft = PSY.SingleMass(3.148, #H - 2.0) #D - - +case1_shaft = PSY.SingleMass( + 3.148, #H + 2.0, +) #D ######## PSS Data ######### cases_no_pss = PSY.PSSFixed(0.0) - ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### @@ -92,19 +102,20 @@ case1234_no_tg = PSY.TGFixed(1.0) #eff case1_avr = PSY.AVRFixed(0.0) #Vf not applicable in Classic Machines ### Case 1 Generator ### -case1_gen = PSY.DynamicGenerator(1, #Number - "Case1Gen", - nodes_case1[2], #bus - 1.0, # ω_ref, - 1.0, #V_ref - 0.5, #P_ref - 0.0, #Q_ref - case1_machine, #machine - case1_shaft, #shaft - case1_avr, #avr - case1234_no_tg, #tg - cases_no_pss) #pss - +case1_gen = PSY.DynamicGenerator( + 1, #Number + "Case1Gen", + nodes_case1[2], #bus + 1.0, # ω_ref, + 1.0, #V_ref + 0.5, #P_ref + 0.0, #Q_ref + case1_machine, #machine + case1_shaft, #shaft + case1_avr, #avr + case1234_no_tg, #tg + cases_no_pss, +) #pss ######################### Dynamical System ######################## @@ -113,25 +124,24 @@ sys = PSY.System(100.0, frequency = 60.0); #Add buses for bus in nodes_case1 - PSY.add_component!(sys,bus) + PSY.add_component!(sys, bus) end #Add lines for lines in branch_case1 - PSY.add_component!(sys,lines) + PSY.add_component!(sys, lines) end #Add loads for loads in loads_case1 - PSY.add_component!(sys,loads) + PSY.add_component!(sys, loads) end #Add infinite source -PSY.add_component!(sys,inf_gen_case1) +PSY.add_component!(sys, inf_gen_case1) #Add generator -PSY.add_component!(sys,case1_gen) - +PSY.add_component!(sys, case1_gen) ################################################## ############### SOLVE PROBLEM #################### @@ -148,21 +158,25 @@ end for lines in branch_case1_fault PSY.add_component!(sys2, lines) end -Ybus_fault = PSY.Ybus(sys2)[:,:] +Ybus_fault = PSY.Ybus(sys2)[:, :] tspan = (0.0, 30.0); #Define Fault: Change of YBus -Ybus_change = ThreePhaseFault(1.0, #change at t = 1.0 - Ybus_fault) #New YBus +Ybus_change = ThreePhaseFault( + 1.0, #change at t = 1.0 + Ybus_fault, +) #New YBus #Define Simulation Problem -sim = Simulation(sys, #system - tspan, #time span - Ybus_change) #Type of Fault +sim = Simulation( + sys, #system + tspan, #time span + Ybus_change, +) #Type of Fault #Solve problem in equilibrium -run_simulation!(sim, IDA(), dtmax=0.02); +run_simulation!(sim, IDA(), dtmax = 0.02); #Obtain data for angles series = get_state_series(sim, ("Case1Gen", :δ)); diff --git a/test/test_case2_4th_order.jl b/test/test_case2_4th_order.jl index 0191034..87d803a 100644 --- a/test/test_case2_4th_order.jl +++ b/test/test_case2_4th_order.jl @@ -11,161 +11,261 @@ and the generator located in bus 3. ############### Data Network ######################## -nodes_case234 = [PSY.Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - PSY.Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] - -branch_case234 = [PSY.Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +nodes_case234 = [ + PSY.Bus(1, "Bus 1", "REF", 0, 1.02, (min = 0.94, max = 1.06), 138), + PSY.Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), + PSY.Bus(3, "Bus 3", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), +] + +branch_case234 = [ + PSY.Line( + "Line1", + true, + 0.0, + 0.0, + Arc(from = nodes_case234[1], to = nodes_case234[3]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_case234[1], to = nodes_case234[2]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_case234[2], to = nodes_case234[3]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), +] #Trip of Line 1. -branch_case234_fault = [PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] - -loads_case234 = [PSY.PowerLoad("Bus1", true, nodes_case234[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), - PSY.PowerLoad("Bus2", true, nodes_case234[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), - PSY.PowerLoad("Bus3", true, nodes_case234[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] - +branch_case234_fault = [ + PSY.Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_case234[1], to = nodes_case234[2]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_case234[2], to = nodes_case234[3]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), +] + +loads_case234 = [ + PSY.PowerLoad( + "Bus1", + true, + nodes_case234[1], + PowerSystems.ConstantPower, + 1.5, + 0.8, + 1.5, + 0.8, + ), + PSY.PowerLoad( + "Bus2", + true, + nodes_case234[2], + PowerSystems.ConstantPower, + 1.5, + 0.7, + 1.5, + 0.8, + ), + PSY.PowerLoad( + "Bus3", + true, + nodes_case234[3], + PowerSystems.ConstantPower, + 0.5, + 0.3, + 0.5, + 0.3, + ), +] ############### Data devices ######################## inf_gen_case234 = PSY.Source( - "InfBus", #name - true, #availability - nodes_case234[1], #bus - 1.02, #VR - 0.0, #VI - 0.000001) #Xth + "InfBus", #name + true, #availability + nodes_case234[1], #bus + 1.02, #VR + 0.0, #VI + 0.000001, +) #Xth ######## Machine Data ######### ### Case 2: 4th Order Model with AVR (3-bus case) ### -case2_machine2 = PSY.OneDOneQMachine(0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0) #MVABase - -case2_machine3 = PSY.OneDOneQMachine(0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0) #MVABase +case2_machine2 = PSY.OneDOneQMachine( + 0.0, #R + 1.3125, #Xd + 1.2578, #Xq + 0.1813, #Xd_p + 0.25, #Xq_p + 5.89, #Td0_p + 0.6, #Tq0_p + 100.0, +) #MVABase + +case2_machine3 = PSY.OneDOneQMachine( + 0.0, #R + 1.3125, #Xd + 1.2578, #Xq + 0.1813, #Xd_p + 0.25, #Xq_p + 5.89, #Td0_p + 0.6, #Tq0_p + 100.0, +) #MVABase ######## Shaft Data ######### ### Shafts for Gens 2 and 3: Cases 2, 3 and 4 ### -case234_shaft2 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) - 0.0) #D +case234_shaft2 = PSY.SingleMass( + 3.01, #H (M = 6.02 -> H = M/2) + 0.0, +) #D - -case234_shaft3 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) - 0.0) #D +case234_shaft3 = PSY.SingleMass( + 3.01, #H (M = 6.02 -> H = M/2) + 0.0, +) #D ######## PSS Data ######### cases_no_pss = PSY.PSSFixed(0.0) - ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### case1234_no_tg = PSY.TGFixed(1.0) #eff - ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case2345_avr2 = PSY.AVRTypeI(20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555) #Be - 2nd ceiling coefficient - -case2345_avr3 = PSY.AVRTypeI(20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555) #Be - 2nd ceiling coefficient +case2345_avr2 = PSY.AVRTypeI( + 20.0, #Ka - Gain + 0.01, #Ke + 0.063, #Kf + 0.2, #Ta + 0.314, #Te + 0.35, #Tf + 0.001, #Tr + 5.0, #Vrmax + -5.0, #Vrmin + 0.0039, #Ae - 1st ceiling coefficient + 1.555, +) #Be - 2nd ceiling coefficient + +case2345_avr3 = PSY.AVRTypeI( + 20.0, #Ka - Gain + 0.01, #Ke + 0.063, #Kf + 0.2, #Ta + 0.314, #Te + 0.35, #Tf + 0.001, #Tr + 5.0, #Vrmax + -5.0, #Vrmin + 0.0039, #Ae - 1st ceiling coefficient + 1.555, +) #Be - 2nd ceiling coefficient ### Case 2 Generators ### -case2_gen2 = PSY.DynamicGenerator(1, #Number - "Case2Gen2", - nodes_case234[2], #bus - 1.0, # ω_ref, - 1.0142, #V_ref - 1.0, #P_ref - 0.0, #Q_ref - case2_machine2, #machine - case234_shaft2, #shaft - case2345_avr2, #avr - case1234_no_tg, #tg - cases_no_pss) #pss - -case2_gen3 = PSY.DynamicGenerator(2, #Number - "Case2Gen3", - nodes_case234[3], #bus - 1.0, # ω_ref, - 1.0059, #V_ref - 1.0, #P_ref - 0.0, #Q_ref - case2_machine3, #machine - case234_shaft3, #shaft - case2345_avr3, #avr - case1234_no_tg, #tg - cases_no_pss) #pss +case2_gen2 = PSY.DynamicGenerator( + 1, #Number + "Case2Gen2", + nodes_case234[2], #bus + 1.0, # ω_ref, + 1.0142, #V_ref + 1.0, #P_ref + 0.0, #Q_ref + case2_machine2, #machine + case234_shaft2, #shaft + case2345_avr2, #avr + case1234_no_tg, #tg + cases_no_pss, +) #pss + +case2_gen3 = PSY.DynamicGenerator( + 2, #Number + "Case2Gen3", + nodes_case234[3], #bus + 1.0, # ω_ref, + 1.0059, #V_ref + 1.0, #P_ref + 0.0, #Q_ref + case2_machine3, #machine + case234_shaft3, #shaft + case2345_avr3, #avr + case1234_no_tg, #tg + cases_no_pss, +) #pss ######################### Dynamical System ######################## - #Create system with BasePower = 100 MVA and nominal frequency 60 Hz. sys = PSY.System(100.0, frequency = 60.0); #Add buses for bus in nodes_case234 - PSY.add_component!(sys,bus) + PSY.add_component!(sys, bus) end #Add lines for lines in branch_case234 - PSY.add_component!(sys,lines) + PSY.add_component!(sys, lines) end #Add loads for loads in loads_case234 - PSY.add_component!(sys,loads) + PSY.add_component!(sys, loads) end #Add infinite source -PSY.add_component!(sys,inf_gen_case234) +PSY.add_component!(sys, inf_gen_case234) #Add generators -PSY.add_component!(sys,case2_gen2) -PSY.add_component!(sys,case2_gen3) - +PSY.add_component!(sys, case2_gen2) +PSY.add_component!(sys, case2_gen3) ################################################## ############### SOLVE PROBLEM #################### ################################################## - #Compute Y_bus after fault sys2 = PSY.System(100.0, frequency = 60.0); #Add buses @@ -176,40 +276,50 @@ end for lines in branch_case234_fault PSY.add_component!(sys2, lines) end -Ybus_fault = PSY.Ybus(sys2)[:,:] +Ybus_fault = PSY.Ybus(sys2)[:, :] #time span tspan = (0.0, 30.0); #Initial guess -x0_guess = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, - 1.0, #eq_p - 0.47, #ed_p - 0.6, #δ - 1.0, #ω - 2.1, #Vf - 0.28, #Vr1 - -0.39, #Vr2, - 1.0, #Vm - 0.81, #eq_p - 0.59, #ed_p - 0.86, #δ - 1.0, #ω - 1.7, #Vf - 0.11, #Vr1 - -0.31, #Vr2, - 1.0] #Vm - +x0_guess = [ + 1.02, + 1.0, + 1.0, + 0.0, + -0.01, + -0.01, + 1.0, #eq_p + 0.47, #ed_p + 0.6, #δ + 1.0, #ω + 2.1, #Vf + 0.28, #Vr1 + -0.39, #Vr2, + 1.0, #Vm + 0.81, #eq_p + 0.59, #ed_p + 0.86, #δ + 1.0, #ω + 1.7, #Vf + 0.11, #Vr1 + -0.31, #Vr2, + 1.0, +] #Vm #Define Fault: Change of YBus -Ybus_change = ThreePhaseFault(1.0, #change at t = 1.0 - Ybus_fault) #New YBus +Ybus_change = ThreePhaseFault( + 1.0, #change at t = 1.0 + Ybus_fault, +) #New YBus #Define Simulation Problem -sim = Simulation(sys, #system - tspan, #time span - Ybus_change, #Type of Fault - initial_guess = x0_guess) #initial guess +sim = Simulation( + sys, #system + tspan, #time span + Ybus_change, #Type of Fault + initial_guess = x0_guess, +) #initial guess #Solve problem in equilibrium run_simulation!(sim, IDA()); diff --git a/test/test_case3_6th_order.jl b/test/test_case3_6th_order.jl index 9377e13..ac371bd 100644 --- a/test/test_case3_6th_order.jl +++ b/test/test_case3_6th_order.jl @@ -11,137 +11,239 @@ and the generator located in bus 3. ############### Data Network ######################## -nodes_case234 = [PSY.Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - PSY.Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] - -branch_case234 = [PSY.Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +nodes_case234 = [ + PSY.Bus(1, "Bus 1", "REF", 0, 1.02, (min = 0.94, max = 1.06), 138), + PSY.Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), + PSY.Bus(3, "Bus 3", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), +] + +branch_case234 = [ + PSY.Line( + "Line1", + true, + 0.0, + 0.0, + Arc(from = nodes_case234[1], to = nodes_case234[3]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_case234[1], to = nodes_case234[2]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_case234[2], to = nodes_case234[3]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), +] #Trip of Line 1. -branch_case234_fault = [PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] - -loads_case234 = [PSY.PowerLoad("Bus1", true, nodes_case234[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), - PSY.PowerLoad("Bus2", true, nodes_case234[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), - PSY.PowerLoad("Bus3", true, nodes_case234[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] - +branch_case234_fault = [ + PSY.Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_case234[1], to = nodes_case234[2]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_case234[2], to = nodes_case234[3]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), +] + +loads_case234 = [ + PSY.PowerLoad( + "Bus1", + true, + nodes_case234[1], + PowerSystems.ConstantPower, + 1.5, + 0.8, + 1.5, + 0.8, + ), + PSY.PowerLoad( + "Bus2", + true, + nodes_case234[2], + PowerSystems.ConstantPower, + 1.5, + 0.7, + 1.5, + 0.8, + ), + PSY.PowerLoad( + "Bus3", + true, + nodes_case234[3], + PowerSystems.ConstantPower, + 0.5, + 0.3, + 0.5, + 0.3, + ), +] ############### Data devices ######################## inf_gen_case234 = PSY.Source( - "InfBus", #name - true, #availability - nodes_case234[1], #bus - 1.02, #VR - 0.0, #VI - 0.000001) #Xth + "InfBus", #name + true, #availability + nodes_case234[1], #bus + 1.02, #VR + 0.0, #VI + 0.000001, +) #Xth ######## Machine Data ######### ### Case 3: 6th Order Model with AVR (3-bus case) ### -case3_machine2 = PSY.SimpleMarconatoMachine(0.0, - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 0.14, #Xd_pp - 0.18, #Xq_pp - 5.89, #Td0_p - 0.6, #Tq0_p - 0.5, #Td0_pp - 0.023, #Tq0_pp - 0.0, #T_AA - 100.0) #MVABase - -case3_machine3 = PSY.SimpleMarconatoMachine(0.0, - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 0.14, #Xd_pp - 0.18, #Xq_pp - 5.89, #Td0_p - 0.6, #Tq0_p - 0.5, #Td0_pp - 0.023, #Tq0_pp - 0.0, #T_AA - 100.0) #MVABase +case3_machine2 = PSY.SimpleMarconatoMachine( + 0.0, + 1.3125, #Xd + 1.2578, #Xq + 0.1813, #Xd_p + 0.25, #Xq_p + 0.14, #Xd_pp + 0.18, #Xq_pp + 5.89, #Td0_p + 0.6, #Tq0_p + 0.5, #Td0_pp + 0.023, #Tq0_pp + 0.0, #T_AA + 100.0, +) #MVABase + +case3_machine3 = PSY.SimpleMarconatoMachine( + 0.0, + 1.3125, #Xd + 1.2578, #Xq + 0.1813, #Xd_p + 0.25, #Xq_p + 0.14, #Xd_pp + 0.18, #Xq_pp + 5.89, #Td0_p + 0.6, #Tq0_p + 0.5, #Td0_pp + 0.023, #Tq0_pp + 0.0, #T_AA + 100.0, +) #MVABase ######## Shaft Data ######### ### Shafts for Gens 2 and 3: Cases 2, 3 and 4 ### -case234_shaft2 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) - 0.0) #D +case234_shaft2 = PSY.SingleMass( + 3.01, #H (M = 6.02 -> H = M/2) + 0.0, +) #D - -case234_shaft3 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) - 0.0) #D +case234_shaft3 = PSY.SingleMass( + 3.01, #H (M = 6.02 -> H = M/2) + 0.0, +) #D ######## PSS Data ######### cases_no_pss = PSY.PSSFixed(0.0) - ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### case1234_no_tg = PSY.TGFixed(1.0) #eff - ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case2345_avr2 = PSY.AVRTypeI(20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555) #Be - 2nd ceiling coefficient - -case2345_avr3 = PSY.AVRTypeI(20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555) #Be - 2nd ceiling coefficient +case2345_avr2 = PSY.AVRTypeI( + 20.0, #Ka - Gain + 0.01, #Ke + 0.063, #Kf + 0.2, #Ta + 0.314, #Te + 0.35, #Tf + 0.001, #Tr + 5.0, #Vrmax + -5.0, #Vrmin + 0.0039, #Ae - 1st ceiling coefficient + 1.555, +) #Be - 2nd ceiling coefficient + +case2345_avr3 = PSY.AVRTypeI( + 20.0, #Ka - Gain + 0.01, #Ke + 0.063, #Kf + 0.2, #Ta + 0.314, #Te + 0.35, #Tf + 0.001, #Tr + 5.0, #Vrmax + -5.0, #Vrmin + 0.0039, #Ae - 1st ceiling coefficient + 1.555, +) #Be - 2nd ceiling coefficient ### Case 3 Generators ### -case3_gen2 = PSY.DynamicGenerator(1, #Number - "Case3Gen2", - nodes_case234[2], #bus - 1.0, # ω_ref, - 1.0142, #V_ref - 1.0, #P_ref - 0.0, #Q_ref - case3_machine2, #machine - case234_shaft2, #shaft - case2345_avr2, #avr - case1234_no_tg, #tg - cases_no_pss) #pss - -case3_gen3 = PSY.DynamicGenerator(2, #Number - "Case3Gen3", - nodes_case234[3], #bus - 1.0, # ω_ref, - 1.0059, #V_ref - 1.0, #P_ref - 0.0, #Q_ref - case3_machine3, #machine - case234_shaft3, #shaft - case2345_avr3, #avr - case1234_no_tg, #tg - cases_no_pss) #pss - +case3_gen2 = PSY.DynamicGenerator( + 1, #Number + "Case3Gen2", + nodes_case234[2], #bus + 1.0, # ω_ref, + 1.0142, #V_ref + 1.0, #P_ref + 0.0, #Q_ref + case3_machine2, #machine + case234_shaft2, #shaft + case2345_avr2, #avr + case1234_no_tg, #tg + cases_no_pss, +) #pss + +case3_gen3 = PSY.DynamicGenerator( + 2, #Number + "Case3Gen3", + nodes_case234[3], #bus + 1.0, # ω_ref, + 1.0059, #V_ref + 1.0, #P_ref + 0.0, #Q_ref + case3_machine3, #machine + case234_shaft3, #shaft + case2345_avr3, #avr + case1234_no_tg, #tg + cases_no_pss, +) #pss ######################### Dynamical System ######################## @@ -150,33 +252,30 @@ sys = PSY.System(100.0, frequency = 60.0); #Add buses for bus in nodes_case234 - PSY.add_component!(sys,bus) + PSY.add_component!(sys, bus) end #Add lines for lines in branch_case234 - PSY.add_component!(sys,lines) + PSY.add_component!(sys, lines) end #Add loads for loads in loads_case234 - PSY.add_component!(sys,loads) + PSY.add_component!(sys, loads) end #Add infinite source -PSY.add_component!(sys,inf_gen_case234) +PSY.add_component!(sys, inf_gen_case234) #Add generators -PSY.add_component!(sys,case3_gen2) -PSY.add_component!(sys,case3_gen3) - +PSY.add_component!(sys, case3_gen2) +PSY.add_component!(sys, case3_gen3) ################################################## ############### SOLVE PROBLEM #################### ################################################## - - #Compute Y_bus after fault sys2 = PSY.System(100.0, frequency = 60.0); #Add buses @@ -187,43 +286,54 @@ end for lines in branch_case234_fault PSY.add_component!(sys2, lines) end -Ybus_fault = PSY.Ybus(sys2)[:,:] +Ybus_fault = PSY.Ybus(sys2)[:, :] #time span tspan = (0.0, 20.0); #Initial guess -x0_guess = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, - 1.0, #eq_p - 0.47, #ed_p - 0.95, #eq_pp - 0.8, #ed_pp - 0.6, #δ - 1.0, #ω - 2.1, #Vf - 0.28, #Vr1 - -0.39, #Vr2, - 1.0, #Vm - 0.81, #eq_p - 0.59, #ed_p - 0.75, #eq_pp - 0.6, #ed_pp - 0.86, #δ - 1.0, #ω - 1.7, #Vf - 0.11, #Vr1 - -0.31, #Vr2, - 1.0] #Vm +x0_guess = [ + 1.02, + 1.0, + 1.0, + 0.0, + -0.01, + -0.01, + 1.0, #eq_p + 0.47, #ed_p + 0.95, #eq_pp + 0.8, #ed_pp + 0.6, #δ + 1.0, #ω + 2.1, #Vf + 0.28, #Vr1 + -0.39, #Vr2, + 1.0, #Vm + 0.81, #eq_p + 0.59, #ed_p + 0.75, #eq_pp + 0.6, #ed_pp + 0.86, #δ + 1.0, #ω + 1.7, #Vf + 0.11, #Vr1 + -0.31, #Vr2, + 1.0, +] #Vm #Define Fault: Change of YBus -Ybus_change = ThreePhaseFault(1.0, #change at t = 1.0 - Ybus_fault) #New YBus +Ybus_change = ThreePhaseFault( + 1.0, #change at t = 1.0 + Ybus_fault, +) #New YBus #Define Simulation Problem -sim = Simulation(sys, #system - tspan, #time span - Ybus_change, #Type of Fault - initial_guess = x0_guess) #initial guess +sim = Simulation( + sys, #system + tspan, #time span + Ybus_change, #Type of Fault + initial_guess = x0_guess, +) #initial guess #Solve problem in equilibrium run_simulation!(sim, IDA()); diff --git a/test/test_case4_8th_order.jl b/test/test_case4_8th_order.jl index 5d83a38..c0748be 100644 --- a/test/test_case4_8th_order.jl +++ b/test/test_case4_8th_order.jl @@ -5,145 +5,245 @@ The fault drop the connection between buses 1 and 3, eliminating the direct conn and the generator located in bus 3. """ - ################################################## ############### LOAD DATA ######################## ################################################## ############### Data Network ######################## -nodes_case234 = [PSY.Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - PSY.Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] - -branch_case234 = [PSY.Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +nodes_case234 = [ + PSY.Bus(1, "Bus 1", "REF", 0, 1.02, (min = 0.94, max = 1.06), 138), + PSY.Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), + PSY.Bus(3, "Bus 3", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), +] + +branch_case234 = [ + PSY.Line( + "Line1", + true, + 0.0, + 0.0, + Arc(from = nodes_case234[1], to = nodes_case234[3]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_case234[1], to = nodes_case234[2]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_case234[2], to = nodes_case234[3]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), +] #Trip of Line 1. -branch_case234_fault = [PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case234[1], to=nodes_case234[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case234[2], to=nodes_case234[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] - -loads_case234 = [PSY.PowerLoad("Bus1", true, nodes_case234[1], PowerSystems.ConstantPower, 1.5, 0.8, 1.5, 0.8), - PSY.PowerLoad("Bus2", true, nodes_case234[2], PowerSystems.ConstantPower, 1.5, 0.7, 1.5, 0.8), - PSY.PowerLoad("Bus3", true, nodes_case234[3], PowerSystems.ConstantPower, 0.5, 0.3, 0.5, 0.3)] - +branch_case234_fault = [ + PSY.Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_case234[1], to = nodes_case234[2]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_case234[2], to = nodes_case234[3]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), +] + +loads_case234 = [ + PSY.PowerLoad( + "Bus1", + true, + nodes_case234[1], + PowerSystems.ConstantPower, + 1.5, + 0.8, + 1.5, + 0.8, + ), + PSY.PowerLoad( + "Bus2", + true, + nodes_case234[2], + PowerSystems.ConstantPower, + 1.5, + 0.7, + 1.5, + 0.8, + ), + PSY.PowerLoad( + "Bus3", + true, + nodes_case234[3], + PowerSystems.ConstantPower, + 0.5, + 0.3, + 0.5, + 0.3, + ), +] ############### Data devices ######################## inf_gen_case234 = PSY.Source( - "InfBus", #name - true, #availability - nodes_case234[1], #bus - 1.02, #VR - 0.0, #VI - 0.000001) #Xth + "InfBus", #name + true, #availability + nodes_case234[1], #bus + 1.02, #VR + 0.0, #VI + 0.000001, +) #Xth ######## Machine Data ######### ### Case 4: 8th Order Model with AVR (3-bus case) ### -case4_machine2 = PSY.MarconatoMachine(0.0, - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 0.14, #Xd_pp - 0.18, #Xq_pp - 5.89, #Td0_p - 0.6, #Tq0_p - 0.5, #Td0_pp - 0.023, #Tq0_pp - 0.0, #T_AA - 100.0) #MVABase - - -case4_machine3 = PSY.MarconatoMachine(0.0, - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 0.14, #Xd_pp - 0.18, #Xq_pp - 5.89, #Td0_p - 0.6, #Tq0_p - 0.5, #Td0_pp - 0.023, #Tq0_pp - 0.0, #T_AA - 100.0) #MVABase +case4_machine2 = PSY.MarconatoMachine( + 0.0, + 1.3125, #Xd + 1.2578, #Xq + 0.1813, #Xd_p + 0.25, #Xq_p + 0.14, #Xd_pp + 0.18, #Xq_pp + 5.89, #Td0_p + 0.6, #Tq0_p + 0.5, #Td0_pp + 0.023, #Tq0_pp + 0.0, #T_AA + 100.0, +) #MVABase + +case4_machine3 = PSY.MarconatoMachine( + 0.0, + 1.3125, #Xd + 1.2578, #Xq + 0.1813, #Xd_p + 0.25, #Xq_p + 0.14, #Xd_pp + 0.18, #Xq_pp + 5.89, #Td0_p + 0.6, #Tq0_p + 0.5, #Td0_pp + 0.023, #Tq0_pp + 0.0, #T_AA + 100.0, +) #MVABase ######## Shaft Data ######### ### Shafts for Gens 2 and 3: Cases 2, 3 and 4 ### -case234_shaft2 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) - 0.0) #D - +case234_shaft2 = PSY.SingleMass( + 3.01, #H (M = 6.02 -> H = M/2) + 0.0, +) #D -case234_shaft3 = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) - 0.0) #D +case234_shaft3 = PSY.SingleMass( + 3.01, #H (M = 6.02 -> H = M/2) + 0.0, +) #D ######## PSS Data ######### cases_no_pss = PSY.PSSFixed(0.0) - ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### case1234_no_tg = PSY.TGFixed(1.0) #eff - ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case2345_avr2 = PSY.AVRTypeI(20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555) #Be - 2nd ceiling coefficient - -case2345_avr3 = PSY.AVRTypeI(20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555) #Be - 2nd ceiling coefficient +case2345_avr2 = PSY.AVRTypeI( + 20.0, #Ka - Gain + 0.01, #Ke + 0.063, #Kf + 0.2, #Ta + 0.314, #Te + 0.35, #Tf + 0.001, #Tr + 5.0, #Vrmax + -5.0, #Vrmin + 0.0039, #Ae - 1st ceiling coefficient + 1.555, +) #Be - 2nd ceiling coefficient + +case2345_avr3 = PSY.AVRTypeI( + 20.0, #Ka - Gain + 0.01, #Ke + 0.063, #Kf + 0.2, #Ta + 0.314, #Te + 0.35, #Tf + 0.001, #Tr + 5.0, #Vrmax + -5.0, #Vrmin + 0.0039, #Ae - 1st ceiling coefficient + 1.555, +) #Be - 2nd ceiling coefficient ### Case 4 Generators ### -case4_gen2 = PSY.DynamicGenerator(1, #Number - "Case4Gen2", - nodes_case234[2], #bus - 1.0, # ω_ref, - 1.0142, #V_ref - 1.0, #P_ref - 0.0, #Q_ref - case4_machine2, #machine - case234_shaft2, #shaft - case2345_avr2, #avr - case1234_no_tg, #tg - cases_no_pss) #pss - -case4_gen3 = PSY.DynamicGenerator(2, #Number - "Case4Gen3", - nodes_case234[3], #bus - 1.0, # ω_ref, - 1.0059, #V_ref - 1.0, #P_ref - 0.0, #Q_ref - case4_machine3, #machine - case234_shaft3, #shaft - case2345_avr3, #avr - case1234_no_tg, #tg - cases_no_pss) #pss - +case4_gen2 = PSY.DynamicGenerator( + 1, #Number + "Case4Gen2", + nodes_case234[2], #bus + 1.0, # ω_ref, + 1.0142, #V_ref + 1.0, #P_ref + 0.0, #Q_ref + case4_machine2, #machine + case234_shaft2, #shaft + case2345_avr2, #avr + case1234_no_tg, #tg + cases_no_pss, +) #pss + +case4_gen3 = PSY.DynamicGenerator( + 2, #Number + "Case4Gen3", + nodes_case234[3], #bus + 1.0, # ω_ref, + 1.0059, #V_ref + 1.0, #P_ref + 0.0, #Q_ref + case4_machine3, #machine + case234_shaft3, #shaft + case2345_avr3, #avr + case1234_no_tg, #tg + cases_no_pss, +) #pss ######################### Dynamical System ######################## @@ -152,26 +252,25 @@ sys = PSY.System(100.0, frequency = 60.0); #Add buses for bus in nodes_case234 - PSY.add_component!(sys,bus) + PSY.add_component!(sys, bus) end #Add lines for lines in branch_case234 - PSY.add_component!(sys,lines) + PSY.add_component!(sys, lines) end #Add loads for loads in loads_case234 - PSY.add_component!(sys,loads) + PSY.add_component!(sys, loads) end #Add infinite source -PSY.add_component!(sys,inf_gen_case234) +PSY.add_component!(sys, inf_gen_case234) #Add generators -PSY.add_component!(sys,case4_gen2) -PSY.add_component!(sys,case4_gen3) - +PSY.add_component!(sys, case4_gen2) +PSY.add_component!(sys, case4_gen3) ################################################## ############### SOLVE PROBLEM #################### @@ -187,48 +286,58 @@ end for lines in branch_case234_fault PSY.add_component!(sys2, lines) end -Ybus_fault = PSY.Ybus(sys2)[:,:] +Ybus_fault = PSY.Ybus(sys2)[:, :] #time span tspan = (0.0, 20.0); #Initial guess -x0_guess = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, - -0.5, #ψq - 0.8, #ψd - 1.0, #eq_p - 0.47, #ed_p - 0.95, #eq_pp - 0.8, #ed_pp - 0.6, #δ - 1.0, #ω - 2.1, #Vf - 0.28, #Vr1 - -0.39, #Vr2, - 1.0, #Vm - -0.7, #ψq - 0.6, #ψd - 0.81, #eq_p - 0.59, #ed_p - 0.75, #eq_pp - 0.6, #ed_pp - 0.86, #δ - 1.0, #ω - 1.7, #Vf - 0.11, #Vr1 - -0.31, #Vr2, - 1.0] #Vm - +x0_guess = [ + 1.02, + 1.0, + 1.0, + 0.0, + -0.01, + -0.01, + -0.5, #ψq + 0.8, #ψd + 1.0, #eq_p + 0.47, #ed_p + 0.95, #eq_pp + 0.8, #ed_pp + 0.6, #δ + 1.0, #ω + 2.1, #Vf + 0.28, #Vr1 + -0.39, #Vr2, + 1.0, #Vm + -0.7, #ψq + 0.6, #ψd + 0.81, #eq_p + 0.59, #ed_p + 0.75, #eq_pp + 0.6, #ed_pp + 0.86, #δ + 1.0, #ω + 1.7, #Vf + 0.11, #Vr1 + -0.31, #Vr2, + 1.0, +] #Vm #Define Fault: Change of YBus -Ybus_change = ThreePhaseFault(1.0, #change at t = 1.0 - Ybus_fault) #New YBus +Ybus_change = ThreePhaseFault( + 1.0, #change at t = 1.0 + Ybus_fault, +) #New YBus #Define Simulation Problem -sim = Simulation(sys, #system - tspan, #time span - Ybus_change, #Type of Fault - initial_guess = x0_guess) #initial guess +sim = Simulation( + sys, #system + tspan, #time span + Ybus_change, #Type of Fault + initial_guess = x0_guess, +) #initial guess #Solve problem in equilibrium run_simulation!(sim, IDA()); diff --git a/test/test_case5_5shaft.jl b/test/test_case5_5shaft.jl index df37ded..13ec784 100644 --- a/test/test_case5_5shaft.jl +++ b/test/test_case5_5shaft.jl @@ -11,110 +11,207 @@ The fault disconnects a circuit between buses 1 and 2, doubling its impedance. ############### Data Network ######################## -nodes_case5 = [PSY.Bus(1 , "Bus 1" , "REF" , 0 , 1.05 , (min=0.94, max=1.06), 138), - PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - PSY.Bus(3 , "Bus 3" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138)] - -branch_case5 = [PSY.Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[2]), 0.01, 0.05, (from=0.0, to=0.0), 100, 1.04), - PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case5[2], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), - PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04)] +nodes_case5 = [ + PSY.Bus(1, "Bus 1", "REF", 0, 1.05, (min = 0.94, max = 1.06), 138), + PSY.Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), + PSY.Bus(3, "Bus 3", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), +] + +branch_case5 = [ + PSY.Line( + "Line1", + true, + 0.0, + 0.0, + Arc(from = nodes_case5[1], to = nodes_case5[2]), + 0.01, + 0.05, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_case5[2], to = nodes_case5[3]), + 0.02, + 0.1, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_case5[1], to = nodes_case5[3]), + 0.02, + 0.1, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), +] #Trip of a single circuit of Line 1 -> Resistance and Reactance doubled. -branch_case5_fault = [Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[2]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), - Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case5[2], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04), - Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case5[1], to=nodes_case5[3]), 0.02, 0.1, (from=0.0, to=0.0), 100, 1.04)] - -loads_case5 = [PSY.PowerLoad("Bus2", true, nodes_case5[2], PowerSystems.ConstantPower, 0.3, 0.05, 0.3, 0.05), - PSY.PowerLoad("Bus3", true, nodes_case5[3], PowerSystems.ConstantPower, 0.3, 0.05, 0.3, 0.05)] - +branch_case5_fault = [ + Line( + "Line1", + true, + 0.0, + 0.0, + Arc(from = nodes_case5[1], to = nodes_case5[2]), + 0.02, + 0.1, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_case5[2], to = nodes_case5[3]), + 0.02, + 0.1, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_case5[1], to = nodes_case5[3]), + 0.02, + 0.1, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), +] + +loads_case5 = [ + PSY.PowerLoad( + "Bus2", + true, + nodes_case5[2], + PowerSystems.ConstantPower, + 0.3, + 0.05, + 0.3, + 0.05, + ), + PSY.PowerLoad( + "Bus3", + true, + nodes_case5[3], + PowerSystems.ConstantPower, + 0.3, + 0.05, + 0.3, + 0.05, + ), +] ############### Data devices ######################## inf_gen_case5 = PSY.Source( - "InfBus", #name - true, #availability - nodes_case5[1], #bus - 1.00, #VR - 0.0, #VI - 0.000001) #Xth + "InfBus", #name + true, #availability + nodes_case5[1], #bus + 1.00, #VR + 0.0, #VI + 0.000001, +) #Xth ######## Machine Data ######### ### Case 5: 4th Order Model with AVR + TG + Multishaft ### -case5_machine = PSY.OneDOneQMachine(0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0) #MVABase +case5_machine = PSY.OneDOneQMachine( + 0.0, #R + 1.3125, #Xd + 1.2578, #Xq + 0.1813, #Xd_p + 0.25, #Xq_p + 5.89, #Td0_p + 0.6, #Tq0_p + 100.0, +) #MVABase ######## Shaft Data ######### -case5_shaft = PSY.FiveMassShaft(3.01, #5.148, #H - 0.3348, #H_hp - 0.7306, #H_ip - 0.8154, #H_lp - 0.0452, #H_ex, - 0.0, #2.0, #D - 0.5180, #D_hp - 0.2240, #D_ip - 0.2240, #D_lp - 0.1450, #D_ex - 0.0518, #D_12 - 0.0224, #D_23 - 0.0224, #D_34 - 0.0145, #D_45 - 33.07, #K_hp - 28.59, #K_ip - 44.68, #K_lp - 21.984) #K_ex - +case5_shaft = PSY.FiveMassShaft( + 3.01, #5.148, #H + 0.3348, #H_hp + 0.7306, #H_ip + 0.8154, #H_lp + 0.0452, #H_ex, + 0.0, #2.0, #D + 0.5180, #D_hp + 0.2240, #D_ip + 0.2240, #D_lp + 0.1450, #D_ex + 0.0518, #D_12 + 0.0224, #D_23 + 0.0224, #D_34 + 0.0145, #D_45 + 33.07, #K_hp + 28.59, #K_ip + 44.68, #K_lp + 21.984, +) #K_ex ######## PSS Data ######### cases_no_pss = PSY.PSSFixed(0.0) - ######## TG Data ######### ### TG for Case 5 ### -case5_tg = PSY.TGTypeII(0.05, #R - 1.0, #T1 - 2.0, #T2 - 1.5, #τ_max - 0.1) #τ_min +case5_tg = PSY.TGTypeII( + 0.05, #R + 1.0, #T1 + 2.0, #T2 + 1.5, #τ_max + 0.1, +) #τ_min ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case5_avr = PSY.AVRTypeI(20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555) #Be - 2nd ceiling coefficient - - +case5_avr = PSY.AVRTypeI( + 20.0, #Ka - Gain + 0.01, #Ke + 0.063, #Kf + 0.2, #Ta + 0.314, #Te + 0.35, #Tf + 0.001, #Tr + 5.0, #Vrmax + -5.0, #Vrmin + 0.0039, #Ae - 1st ceiling coefficient + 1.555, +) #Be - 2nd ceiling coefficient ### Case 5 Generator ### -case5_gen = PSY.DynamicGenerator(1, #Number - "Case5Gen", - nodes_case5[2], #bus - 1.0, # ω_ref, - 1.0155, #V_ref - 0.5, #P_ref - 0.0, #Q_ref - case5_machine, #machine - case5_shaft, #shaft - case5_avr, #avr - case5_tg, #tg - cases_no_pss) #pss - +case5_gen = PSY.DynamicGenerator( + 1, #Number + "Case5Gen", + nodes_case5[2], #bus + 1.0, # ω_ref, + 1.0155, #V_ref + 0.5, #P_ref + 0.0, #Q_ref + case5_machine, #machine + case5_shaft, #shaft + case5_avr, #avr + case5_tg, #tg + cases_no_pss, +) #pss ######################### Dynamical System ######################## @@ -123,25 +220,24 @@ sys = PSY.System(100.0, frequency = 60.0); #Add buses for bus in nodes_case5 - PSY.add_component!(sys,bus) + PSY.add_component!(sys, bus) end #Add lines for lines in branch_case5 - PSY.add_component!(sys,lines) + PSY.add_component!(sys, lines) end #Add loads for loads in loads_case5 - PSY.add_component!(sys,loads) + PSY.add_component!(sys, loads) end #Add infinite source -PSY.add_component!(sys,inf_gen_case5) +PSY.add_component!(sys, inf_gen_case5) #Add generators -PSY.add_component!(sys,case5_gen) - +PSY.add_component!(sys, case5_gen) ################################################## ############### SOLVE PROBLEM #################### @@ -157,40 +253,51 @@ end for lines in branch_case5_fault PSY.add_component!(sys2, lines) end -Ybus_fault = PSY.Ybus(sys2)[:,:] +Ybus_fault = PSY.Ybus(sys2)[:, :] #time span tspan = (0.0, 20.0); #Initial guess -x0_guess = [1.02, 1.0, 1.0, 0.0, -0.01, -0.01, - 1.0, #eq_p - 0.0, #ed_p - 0.05, #δ - 1.0, #ω - 0.05, #δ_HP - 1.0, #ω_HP - 0.05, #δ_IP - 1.0, #ω_LP - 0.05, #δ_LP - 1.0, #ω_LP - 0.05, #δ_Ex - 1.0, #ω_Ex - 1.0, #Vf - 0.01, #Vr1 - -0.1, #Vr2, - 1.0, #Vm - 0.0] #xg +x0_guess = [ + 1.02, + 1.0, + 1.0, + 0.0, + -0.01, + -0.01, + 1.0, #eq_p + 0.0, #ed_p + 0.05, #δ + 1.0, #ω + 0.05, #δ_HP + 1.0, #ω_HP + 0.05, #δ_IP + 1.0, #ω_LP + 0.05, #δ_LP + 1.0, #ω_LP + 0.05, #δ_Ex + 1.0, #ω_Ex + 1.0, #Vf + 0.01, #Vr1 + -0.1, #Vr2, + 1.0, #Vm + 0.0, +] #xg #Define Fault: Change of YBus -Ybus_change = ThreePhaseFault(1.0, #change at t = 1.0 - Ybus_fault) #New YBus +Ybus_change = ThreePhaseFault( + 1.0, #change at t = 1.0 + Ybus_fault, +) #New YBus #Define Simulation Problem -sim = Simulation(sys, #system - tspan, #time span - Ybus_change, #Type of Fault - initial_guess = x0_guess) #initial guess +sim = Simulation( + sys, #system + tspan, #time span + Ybus_change, #Type of Fault + initial_guess = x0_guess, +) #initial guess #Solve problem in equilibrium run_simulation!(sim, IDA()); diff --git a/test/test_case6_DAIB.jl b/test/test_case6_DAIB.jl index bd549eb..0c96ec9 100644 --- a/test/test_case6_DAIB.jl +++ b/test/test_case6_DAIB.jl @@ -10,107 +10,126 @@ The perturbation increase the reference power (analogy for mechanical power) fro ############### Data Network ######################## -nodes_DAIB= [PSY.Bus(1 , #number - "Bus 1", #Name - "REF" , #BusType (REF, PV, PQ) - 0, #Angle in radians - 1.04, #Voltage in pu - (min=0.94, max=1.06), #Voltage limits in pu - 0.69), #Base voltage in kV - PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.0 , (min=0.94, max=1.06), 0.69)] - - -branch_DAIB = [PSY.Line("Line1", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from=nodes_DAIB[1],to=nodes_DAIB[2]), #Connection between buses - 0.0, #resistance in pu - 0.075, #reactance in pu - (from=0.0, to=0.0), #susceptance in pu - 5.0, #rate in MW - 1.04)] #angle limits (-min and max) +nodes_DAIB = [ + PSY.Bus( + 1, #number + "Bus 1", #Name + "REF", #BusType (REF, PV, PQ) + 0, #Angle in radians + 1.04, #Voltage in pu + (min = 0.94, max = 1.06), #Voltage limits in pu + 0.69, + ), #Base voltage in kV + PSY.Bus(2, "Bus 2", "PV", 0, 1.0, (min = 0.94, max = 1.06), 0.69), +] + +branch_DAIB = [PSY.Line( + "Line1", #name + true, #available + 0.0, #active power flow initial condition (from-to) + 0.0, #reactive power flow initial condition (from-to) + Arc(from = nodes_DAIB[1], to = nodes_DAIB[2]), #Connection between buses + 0.0, #resistance in pu + 0.075, #reactance in pu + (from = 0.0, to = 0.0), #susceptance in pu + 5.0, #rate in MW + 1.04, +)] #angle limits (-min and max) ############### Data devices ######################## -inf_gen_DAIB = PSY.Source("InfBus", #name - true, #availability - nodes_DAIB[1],#bus - 1.00, #VR - 0.0, #VI - 0.000005) #Xth +inf_gen_DAIB = PSY.Source( + "InfBus", #name + true, #availability + nodes_DAIB[1],#bus + 1.00, #VR + 0.0, #VI + 0.000005, +) #Xth ############### Inverter Data ######################## -converter = PSY.AvgCnvFixedDC(690.0, #Rated Voltage - 2.75) #Rated MVA +converter = PSY.AvgCnvFixedDC( + 690.0, #Rated Voltage + 2.75, +) #Rated MVA dc_source = PSY.FixedDCSource(600.0) #Not in the original data, guessed. -filt = PSY.LCLFilter(0.08, #Series inductance lf in pu - 0.003, #Series resitance rf in pu - 0.074, #Shunt capacitance cf in pu - 0.2, #Series ractance rg to grid connection (#Step up transformer or similar) - 0.01) #Series resistance lg to grid connection (#Step up transformer or similar) - -pll = PSY.PLL(500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. - 0.084, #k_p: PLL proportional gain - 4.69) #k_i: PLL integral gain - -virtual_H = PSY.VirtualInertia(2.0, #Ta:: VSM inertia constant - 400.0, #kd:: VSM damping coefficient - 20.0, #kω:: Frequency droop gain in pu - 2*pi*50.0) #ωb:: Rated angular frequency - -Q_control = PSY.ReactivePowerDroop(0.2, #kq:: Reactive power droop gain in pu - 1000.0) #ωf:: Reactive power cut-off low pass filter frequency +filt = PSY.LCLFilter( + 0.08, #Series inductance lf in pu + 0.003, #Series resitance rf in pu + 0.074, #Shunt capacitance cf in pu + 0.2, #Series ractance rg to grid connection (#Step up transformer or similar) + 0.01, +) #Series resistance lg to grid connection (#Step up transformer or similar) + +pll = PSY.PLL( + 500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. + 0.084, #k_p: PLL proportional gain + 4.69, +) #k_i: PLL integral gain + +virtual_H = PSY.VirtualInertia( + 2.0, #Ta:: VSM inertia constant + 400.0, #kd:: VSM damping coefficient + 20.0, #kω:: Frequency droop gain in pu + 2 * pi * 50.0, +) #ωb:: Rated angular frequency + +Q_control = PSY.ReactivePowerDroop( + 0.2, #kq:: Reactive power droop gain in pu + 1000.0, +) #ωf:: Reactive power cut-off low pass filter frequency outer_control = PSY.VirtualInertiaQdroop(virtual_H, Q_control) -vsc = PSY.CombinedVIwithVZ(0.59, #kpv:: Voltage controller proportional gain - 736.0, #kiv:: Voltage controller integral gain - 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers - 0.0, #rv:: Virtual resistance in pu - 0.2, #lv: Virtual inductance in pu - 1.27, #kpc:: Current controller proportional gain - 14.3, #kiv:: Current controller integral gain - 0.0, #kffi:: Binary variable enabling the current feed-forward in output of current controllers - 50.0, #ωad:: Active damping low pass filter cut-off frequency - 0.2) #kad:: Active damping gain - -Darco_Inverter = PSY.DynamicInverter(1, #number - "DARCO", #name - nodes_DAIB[2], #bus location - 1.0, #ω_ref - 1.02, #V_ref - 0.5, #P_ref - 0.0, #Q_ref - 2.75, #MVABase - converter, #Converter - outer_control, #OuterControl - vsc, #Voltage Source Controller - dc_source, #DC Source - pll, #Frequency Estimator - filt) #Output Filter - +vsc = PSY.CombinedVIwithVZ( + 0.59, #kpv:: Voltage controller proportional gain + 736.0, #kiv:: Voltage controller integral gain + 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers + 0.0, #rv:: Virtual resistance in pu + 0.2, #lv: Virtual inductance in pu + 1.27, #kpc:: Current controller proportional gain + 14.3, #kiv:: Current controller integral gain + 0.0, #kffi:: Binary variable enabling the current feed-forward in output of current controllers + 50.0, #ωad:: Active damping low pass filter cut-off frequency + 0.2, +) #kad:: Active damping gain + +Darco_Inverter = PSY.DynamicInverter( + 1, #number + "DARCO", #name + nodes_DAIB[2], #bus location + 1.0, #ω_ref + 1.02, #V_ref + 0.5, #P_ref + 0.0, #Q_ref + 2.75, #MVABase + converter, #Converter + outer_control, #OuterControl + vsc, #Voltage Source Controller + dc_source, #DC Source + pll, #Frequency Estimator + filt, +) #Output Filter ######################### Dynamical System ######################## #Create system with BasePower = 100 MVA and nominal frequency 50 Hz. -sys = PSY.System(100, frequency=50.0) +sys = PSY.System(100, frequency = 50.0) #Add buses for bus in nodes_DAIB - PSY.add_component!(sys,bus) + PSY.add_component!(sys, bus) end #Add lines for lines in branch_DAIB - PSY.add_component!(sys,lines) + PSY.add_component!(sys, lines) end #Add infinite source -PSY.add_component!(sys,inf_gen_DAIB) +PSY.add_component!(sys, inf_gen_DAIB) #Add inverter -PSY.add_component!(sys,Darco_Inverter) - +PSY.add_component!(sys, Darco_Inverter) ################################################## ############### SOLVE PROBLEM #################### @@ -120,30 +139,31 @@ PSY.add_component!(sys,Darco_Inverter) tspan = (0.0, 4.0); #Initial guess -x0_guess = [1.00, #V1_R - 1.0648, #V2_R - 0.0, #V1_I - 0.001, #V2_I - 0.0, #δω_vsm - 0.2, #δθ_vsm - 0.025, #qm - 0.0015, #ξ_d - -0.07, #ξ_q - 0.05, #γ_d - -0.001, #γ_q - 0.95, #ϕ_d - -0.10, #ϕ_q - 1.004, #vpll_d - 0.0, #vpll_q - 0.0, #ε_pll - 0.1, #δθ_pll - 0.5, #id_cv - 0.0, #iq_cv - 0.95, #vod - -0.1, #voq - 0.49, #iod - -0.1] #ioq - +x0_guess = [ + 1.00, #V1_R + 1.0648, #V2_R + 0.0, #V1_I + 0.001, #V2_I + 0.0, #δω_vsm + 0.2, #δθ_vsm + 0.025, #qm + 0.0015, #ξ_d + -0.07, #ξ_q + 0.05, #γ_d + -0.001, #γ_q + 0.95, #ϕ_d + -0.10, #ϕ_q + 1.004, #vpll_d + 0.0, #vpll_q + 0.0, #ε_pll + 0.1, #δθ_pll + 0.5, #id_cv + 0.0, #iq_cv + 0.95, #vod + -0.1, #voq + 0.49, #iod + -0.1, +] #ioq #Define Fault using Callbacks Pref_change = LITS.ControlReferenceChange(1.0, Darco_Inverter, LITS.P_ref_index, 0.7) diff --git a/test/test_case7_4th_order_Inverter.jl b/test/test_case7_4th_order_Inverter.jl index 402f10e..d4a26b1 100644 --- a/test/test_case7_4th_order_Inverter.jl +++ b/test/test_case7_4th_order_Inverter.jl @@ -4,179 +4,286 @@ This case study a three bus system with 1 machine (One d- One q-: 4th order mode The perturbation increase the reference power (analogy for mechanical power) of the machine from 0.6 to 0.8. """ - ################################################## ############### LOAD DATA ######################## ################################################## ############### Data Network ######################## -nodes_case7 = [PSY.Bus(1 , "Bus 1" , "REF" , 0 , 1.02 , (min=0.94, max=1.06), 138), - PSY.Bus(2 , "Bus 2" , "PV" , 0 , 1.00 , (min=0.94, max=1.06), 138), - PSY.Bus(3 , "Bus 3" , "PQ" , 0 , 1.00 , (min=0.94, max=1.06), 138)] - -branch_case7 = [PSY.Line("Line1", true, 0.0, 0.0, Arc(from=nodes_case7[1], to=nodes_case7[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case7[1], to=nodes_case7[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case7[2], to=nodes_case7[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] +nodes_case7 = [ + PSY.Bus(1, "Bus 1", "REF", 0, 1.02, (min = 0.94, max = 1.06), 138), + PSY.Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), + PSY.Bus(3, "Bus 3", "PQ", 0, 1.00, (min = 0.94, max = 1.06), 138), +] + +branch_case7 = [ + PSY.Line( + "Line1", + true, + 0.0, + 0.0, + Arc(from = nodes_case7[1], to = nodes_case7[3]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_case7[1], to = nodes_case7[2]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_case7[2], to = nodes_case7[3]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), +] #Trip of Line 1. -branch_case7_fault = [PSY.Line("Line2", true, 0.0, 0.0, Arc(from=nodes_case7[1], to=nodes_case7[2]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04), - PSY.Line("Line3", true, 0.0, 0.0, Arc(from=nodes_case7[2], to=nodes_case7[3]), 0.01, 0.12, (from=0.0, to=0.0), 100, 1.04)] - -loads_case7 = [PSY.PowerLoad("Bus1", true, nodes_case7[1], PowerSystems.ConstantPower, 0.5, 0.1, 1.5, 0.8), - PSY.PowerLoad("Bus2", true, nodes_case7[2], PowerSystems.ConstantPower, 1.0, 0.3, 1.5, 0.8), - PSY.PowerLoad("Bus3", true, nodes_case7[3], PowerSystems.ConstantPower, 0.3, 0.1, 0.5, 0.3)] - +branch_case7_fault = [ + PSY.Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_case7[1], to = nodes_case7[2]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_case7[2], to = nodes_case7[3]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), +] + +loads_case7 = [ + PSY.PowerLoad( + "Bus1", + true, + nodes_case7[1], + PowerSystems.ConstantPower, + 0.5, + 0.1, + 1.5, + 0.8, + ), + PSY.PowerLoad( + "Bus2", + true, + nodes_case7[2], + PowerSystems.ConstantPower, + 1.0, + 0.3, + 1.5, + 0.8, + ), + PSY.PowerLoad( + "Bus3", + true, + nodes_case7[3], + PowerSystems.ConstantPower, + 0.3, + 0.1, + 0.5, + 0.3, + ), +] ############### Data devices ######################## inf_gen_case7 = PSY.Source( - "InfBus", #name - true, #availability - nodes_case7[1],#bus - 1.00, #VR - 0.0, #VI - 0.000005) #Xth - + "InfBus", #name + true, #availability + nodes_case7[1],#bus + 1.00, #VR + 0.0, #VI + 0.000005, +) #Xth ######## Machine Data ######### ### Case 2: 4th Order Model with AVR (3-bus case) ### -case7_machine = PSY.OneDOneQMachine(0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0) #MVABase +case7_machine = PSY.OneDOneQMachine( + 0.0, #R + 1.3125, #Xd + 1.2578, #Xq + 0.1813, #Xd_p + 0.25, #Xq_p + 5.89, #Td0_p + 0.6, #Tq0_p + 100.0, +) #MVABase ######## Shaft Data ######### ### Shafts for Gen ### -case7_shaft = PSY.SingleMass(3.01, #H (M = 6.02 -> H = M/2) - 0.0) #D +case7_shaft = PSY.SingleMass( + 3.01, #H (M = 6.02 -> H = M/2) + 0.0, +) #D ######## PSS Data ######### cases_no_pss = PSY.PSSFixed(0.0) - ######## TG Data ######### ### No TG for Cases 1, 2, 3, 4 ### case7_no_tg = PSY.TGFixed(1.0) #eff - ######## AVR Data ######### ### AVRs for Case 2, 3, 4 and 5 ### -case7_avr = PSY.AVRTypeI(20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555) #Be - 2nd ceiling coefficient +case7_avr = PSY.AVRTypeI( + 20.0, #Ka - Gain + 0.01, #Ke + 0.063, #Kf + 0.2, #Ta + 0.314, #Te + 0.35, #Tf + 0.001, #Tr + 5.0, #Vrmax + -5.0, #Vrmin + 0.0039, #Ae - 1st ceiling coefficient + 1.555, +) #Be - 2nd ceiling coefficient ### Case 7 Generators ### -case7_gen = PSY.DynamicGenerator(1, #Number - "Case7Gen", - nodes_case7[2], #bus - 1.0, # ω_ref, - 1.0142, #V_ref - 0.6, #P_ref - 0.0, #Q_ref - case7_machine, #machine - case7_shaft, #shaft - case7_avr, #avr - case7_no_tg, #tg - cases_no_pss) #pss +case7_gen = PSY.DynamicGenerator( + 1, #Number + "Case7Gen", + nodes_case7[2], #bus + 1.0, # ω_ref, + 1.0142, #V_ref + 0.6, #P_ref + 0.0, #Q_ref + case7_machine, #machine + case7_shaft, #shaft + case7_avr, #avr + case7_no_tg, #tg + cases_no_pss, +) #pss ############### Inverter Data ######################## -converter = PSY.AvgCnvFixedDC(138.0, #Rated Voltage - 100.0) #Rated MVA +converter = PSY.AvgCnvFixedDC( + 138.0, #Rated Voltage + 100.0, +) #Rated MVA dc_source = PSY.FixedDCSource(1500.0) #Not in the original data, guessed. -filt = PSY.LCLFilter(0.08, #Series inductance lf in pu - 0.003, #Series resitance rf in pu - 0.074, #Shunt capacitance cf in pu - 0.2, #Series reactance rg to grid connection (#Step up transformer or similar) - 0.01) #Series resistance lg to grid connection (#Step up transformer or similar) - -pll = PSY.PLL(500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. - 0.084, #k_p: PLL proportional gain - 4.69) #k_i: PLL integral gain - -virtual_H = PSY.VirtualInertia(2.0, #Ta:: VSM inertia constant - 400.0, #kd:: VSM damping coefficient - 20.0, #kω:: Frequency droop gain in pu - 2*pi*50.0) #ωb:: Rated angular frequency - -Q_control = PSY.ReactivePowerDroop(0.2, #kq:: Reactive power droop gain in pu - 1000.0) #ωf:: Reactive power cut-off low pass filter frequency +filt = PSY.LCLFilter( + 0.08, #Series inductance lf in pu + 0.003, #Series resitance rf in pu + 0.074, #Shunt capacitance cf in pu + 0.2, #Series reactance rg to grid connection (#Step up transformer or similar) + 0.01, +) #Series resistance lg to grid connection (#Step up transformer or similar) + +pll = PSY.PLL( + 500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. + 0.084, #k_p: PLL proportional gain + 4.69, +) #k_i: PLL integral gain + +virtual_H = PSY.VirtualInertia( + 2.0, #Ta:: VSM inertia constant + 400.0, #kd:: VSM damping coefficient + 20.0, #kω:: Frequency droop gain in pu + 2 * pi * 50.0, +) #ωb:: Rated angular frequency + +Q_control = PSY.ReactivePowerDroop( + 0.2, #kq:: Reactive power droop gain in pu + 1000.0, +) #ωf:: Reactive power cut-off low pass filter frequency outer_control = PSY.VirtualInertiaQdroop(virtual_H, Q_control) -vsc = PSY.CombinedVIwithVZ(0.59, #kpv:: Voltage controller proportional gain - 736.0, #kiv:: Voltage controller integral gain - 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers - 0.0, #rv:: Virtual resistance in pu - 0.2, #lv: Virtual inductance in pu - 1.27, #kpc:: Current controller proportional gain - 14.3, #kiv:: Current controller integral gain - 0.0, #kffi:: Binary variable enabling the current feed-forward in output of current controllers - 50.0, #ωad:: Active damping low pass filter cut-off frequency - 0.2) #kad:: Active damping gain - -case7_inv = PSY.DynamicInverter(2, #number - "DARCO", #name - nodes_case7[3], #bus location - 1.0, #ω_ref - 1.02, #V_ref - 0.5, #P_ref - 0.0, #Q_ref - 100.0, #MVABase - converter, #Converter - outer_control, #OuterControl - vsc, #Voltage Source Controller - dc_source, #DC Source - pll, #Frequency Estimator - filt) #Output Filter - +vsc = PSY.CombinedVIwithVZ( + 0.59, #kpv:: Voltage controller proportional gain + 736.0, #kiv:: Voltage controller integral gain + 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers + 0.0, #rv:: Virtual resistance in pu + 0.2, #lv: Virtual inductance in pu + 1.27, #kpc:: Current controller proportional gain + 14.3, #kiv:: Current controller integral gain + 0.0, #kffi:: Binary variable enabling the current feed-forward in output of current controllers + 50.0, #ωad:: Active damping low pass filter cut-off frequency + 0.2, +) #kad:: Active damping gain + +case7_inv = PSY.DynamicInverter( + 2, #number + "DARCO", #name + nodes_case7[3], #bus location + 1.0, #ω_ref + 1.02, #V_ref + 0.5, #P_ref + 0.0, #Q_ref + 100.0, #MVABase + converter, #Converter + outer_control, #OuterControl + vsc, #Voltage Source Controller + dc_source, #DC Source + pll, #Frequency Estimator + filt, +) #Output Filter ######################### Dynamical System ######################## #Create system with BasePower = 100 MVA and nominal frequency 50 Hz. -sys = PSY.System(100, frequency=50.0) +sys = PSY.System(100, frequency = 50.0) #Add buses for bus in nodes_case7 - PSY.add_component!(sys,bus) + PSY.add_component!(sys, bus) end #Add lines for lines in branch_case7 - PSY.add_component!(sys,lines) + PSY.add_component!(sys, lines) end #Add loads for loads in loads_case7 - PSY.add_component!(sys,loads) + PSY.add_component!(sys, loads) end #Add infinite source -PSY.add_component!(sys,inf_gen_case7) +PSY.add_component!(sys, inf_gen_case7) #Add inverter -PSY.add_component!(sys,case7_inv) +PSY.add_component!(sys, case7_inv) #Add generator -PSY.add_component!(sys,case7_gen) +PSY.add_component!(sys, case7_gen) ################################################## ############### SOLVE PROBLEM #################### @@ -185,39 +292,41 @@ PSY.add_component!(sys,case7_gen) #time span tspan = (0.0, 20.0); -x0_guess = [1.00, #V1_R - 1.00, #V2_R - 1.00, #V3_R - 0.0, #V1_I - -0.01, #V2_I - -0.01, #V3_I - 0.0, #δω_vsm - 0.2, #δθ_vsm - 0.025, #qm - 0.0015, #ξ_d - -0.07, #ξ_q - 0.05, #γ_d - -0.001, #γ_q - 0.95, #ϕ_d - -0.10, #ϕ_q - 1.004, #vpll_d - 0.0, #vpll_q - 0.0, #ε_pll - 0.1, #δθ_pll - 0.5, #id_cv - 0.0, #iq_cv - 0.95, #vod - -0.1, #voq - 0.49, #iod - -0.1, #ioq - 1.0, #eq_p - 0.47, #ed_p - 0.6, #δ - 1.0, #ω - 2.1, #Vf - 0.28, #Vr1 - -0.39, #Vr2, - 1.0] #Vm +x0_guess = [ + 1.00, #V1_R + 1.00, #V2_R + 1.00, #V3_R + 0.0, #V1_I + -0.01, #V2_I + -0.01, #V3_I + 0.0, #δω_vsm + 0.2, #δθ_vsm + 0.025, #qm + 0.0015, #ξ_d + -0.07, #ξ_q + 0.05, #γ_d + -0.001, #γ_q + 0.95, #ϕ_d + -0.10, #ϕ_q + 1.004, #vpll_d + 0.0, #vpll_q + 0.0, #ε_pll + 0.1, #δθ_pll + 0.5, #id_cv + 0.0, #iq_cv + 0.95, #vod + -0.1, #voq + 0.49, #iod + -0.1, #ioq + 1.0, #eq_p + 0.47, #ed_p + 0.6, #δ + 1.0, #ω + 2.1, #Vf + 0.28, #Vr1 + -0.39, #Vr2, + 1.0, +] #Vm #Define Fault using Callbacks Pref_change = LITS.ControlReferenceChange(1.0, case7_gen, LITS.P_ref_index, 0.8) diff --git a/test/test_create_gen_component.jl b/test/test_create_gen_component.jl index 5f3b92a..721a95d 100644 --- a/test/test_create_gen_component.jl +++ b/test/test_create_gen_component.jl @@ -64,7 +64,6 @@ nodes_OMIB = [ ) #MVABase @test KundurMachine isa PSY.DynamicComponent - KundurFullMachine = PSY.FullMachine( 0.003, #R on Example 3.1 and 4.1 of Kundur 0.0006, #R_f diff --git a/test/test_system_construction.jl b/test/test_system_construction.jl index b0342ea..a494fe1 100644 --- a/test/test_system_construction.jl +++ b/test/test_system_construction.jl @@ -139,7 +139,6 @@ test_inverter = PSY.DynamicInverter( filt, ); #Output Filter - @testset "Dynamic Generator in System" begin sys = PSY.System(100) From 1d2ce8ab512a475270304a84b0abd97b64c5ce11 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Fri, 31 Jan 2020 15:53:18 -0800 Subject: [PATCH 07/13] change nlsolve tolerance --- src/base/simulation.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/base/simulation.jl b/src/base/simulation.jl index cac9eec..1a0c6f2 100644 --- a/src/base/simulation.jl +++ b/src/base/simulation.jl @@ -103,7 +103,13 @@ function _calculate_initial_conditions(sys::PSY.System, initial_guess::Vector{Fl sys, #Parameters 0.0, ) #time equals to zero. - sys_solve = NLsolve.nlsolve(inif!, initial_guess) #Solve using initial guess x0 + sys_solve = NLsolve.nlsolve( + inif!, + initial_guess, + xtol = :1e-9, + ftol = :1e-9, + method = :trust_region, + ) #Solve using initial guess x0 if !NLsolve.converged(sys_solve) @warn("Initialization failed, initial conditions do not meet conditions for an stable equilibrium") end From 9a2013a49b6a64694c04a1ec512b3553ee20b271 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Fri, 31 Jan 2020 16:15:38 -0800 Subject: [PATCH 08/13] fix DAE bug --- src/base/simulation.jl | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/base/simulation.jl b/src/base/simulation.jl index 1a0c6f2..60cf2de 100644 --- a/src/base/simulation.jl +++ b/src/base/simulation.jl @@ -20,9 +20,7 @@ function Simulation( ) initialized = false - n_buses = length(PSY.get_components(PSY.Bus, system)) - DAE_vector = collect(falses(n_buses * 2)) - _index_dynamic_system!(DAE_vector, system) + DAE_vector = _index_dynamic_system!(system) var_count = get_variable_count(system) if initialize_simulation @@ -35,7 +33,6 @@ function Simulation( dx0 = zeros(var_count) callback_set, tstops = _build_perturbations(perturbations::Vector{<:Perturbation}) - prob = DiffEqBase.DAEProblem( system_model!, dx0, @@ -202,8 +199,9 @@ function _make_device_index!(device::PSY.DynamicInjection) return end -function _index_dynamic_system!(DAE_vector::Vector{Bool}, sys::PSY.System) - +function _index_dynamic_system!(sys::PSY.System) + n_buses = length(PSY.get_components(PSY.Bus, sys)) + DAE_vector = collect(falses(n_buses * 2)) global_state_index = Dict{String,Dict{Symbol,Int64}}() n_buses = length(PSY.get_components(PSY.Bus, sys)) state_space_ix = n_buses * 2 @@ -280,7 +278,7 @@ function _index_dynamic_system!(DAE_vector::Vector{Bool}, sys::PSY.System) sys_ext[YBUS] = Ybus sys.internal.ext = sys_ext - return + return DAE_vector end get_injection_pointer(sys::PSY.System) = From 39bc107c1d16b206a8b1293a057f7c19b408d9fa Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Fri, 31 Jan 2020 19:31:58 -0800 Subject: [PATCH 09/13] added data and functions for tests --- test/data_tests/dynamic_test_data.jl | 494 +++++++++++++++++++++++++++ test/data_tests/network_test_data.jl | 379 ++++++++++++++++++++ 2 files changed, 873 insertions(+) create mode 100644 test/data_tests/dynamic_test_data.jl create mode 100644 test/data_tests/network_test_data.jl diff --git a/test/data_tests/dynamic_test_data.jl b/test/data_tests/dynamic_test_data.jl new file mode 100644 index 0000000..4a7a0a6 --- /dev/null +++ b/test/data_tests/dynamic_test_data.jl @@ -0,0 +1,494 @@ +using PowerSystems +const PSY = PowerSystems + +###################################### +############ Generators ############## +###################################### + +######## Machine Data ######### + +machine_OMIB() = PSY.BaseMachine( + 0.0, #R + 0.2995, #Xd_p + 0.7087, #eq_p + 100.0, +) #MVABase + +machine_4th() = PSY.OneDOneQMachine( + 0.0, #R + 1.3125, #Xd + 1.2578, #Xq + 0.1813, #Xd_p + 0.25, #Xq_p + 5.89, #Td0_p + 0.6, #Tq0_p + 100.0, +) #MVABase + +machine_6th() = PSY.SimpleMarconatoMachine( + 0.0, + 1.3125, #Xd + 1.2578, #Xq + 0.1813, #Xd_p + 0.25, #Xq_p + 0.14, #Xd_pp + 0.18, #Xq_pp + 5.89, #Td0_p + 0.6, #Tq0_p + 0.5, #Td0_pp + 0.023, #Tq0_pp + 0.0, #T_AA + 100.0, +) #MVABase + +machine_8th() = PSY.MarconatoMachine( + 0.0, + 1.3125, #Xd + 1.2578, #Xq + 0.1813, #Xd_p + 0.25, #Xq_p + 0.14, #Xd_pp + 0.18, #Xq_pp + 5.89, #Td0_p + 0.6, #Tq0_p + 0.5, #Td0_pp + 0.023, #Tq0_pp + 0.0, #T_AA + 100.0, +) #MVABase + +machine_anderson() = PSY.AndersonFouadMachine( + 0.0, #R + 0.8979, #Xd + 0.646, #Xq + 0.2995, #Xd_p + 0.646, #Xq_p + 0.23, #Xd_pp + 0.4, #Xq_pp + 7.4, #Td0_p + 0.01, #Tq0_p #Data not available in Milano: Used 0.01 + 0.03, #Td0_pp + 0.033, #Tq0_pp + 615.0, +) #MVABase + +machine_kundur() = PSY.SimpleFullMachine( + 0.003, #R on Example 3.1 and 4.1 of Kundur + 0.0006, #R_f + 0.0284, #R_1d or RD in Machowski + 0.0062, #R_1q or RQ on Machowski + 1.81, #L_d + 1.76, #L_q + 1.66, #L_ad or k*M_f or k*M_D in Machowski + 1.61, #L_aq or k*M_Q in Machowski + 1.66, #L_f1d or L_fD in Machowski. Assumed to be equal to L_ad + 1.825, #L_ff + 0.1713, #L_1d or L_D in Machowski + 0.7525, #L_1q or L_Q in Machowski + 555.0, +) #MVABase + +machine_full_kundur() = PSY.FullMachine( + 0.003, #R on Example 3.1 and 4.1 of Kundur + 0.0006, #R_f + #0.003, #R_f + 0.0284, #R_1d or RD in Machowski + 0.0062, #R_1q or RQ on Machowski + 1.81, #L_d + 1.76, #L_q + 1.66, #L_ad or k*M_f or k*M_D in Machowski + 1.61, #L_aq or k*M_Q in Machowski + 1.66, #L_f1d or L_fD in Machowski. Assumed to be equal to L_ad + 1.825, #L_ff + 0.1713, #L_1d or L_D in Machowski + 0.7525, #L_1q or L_Q in Machowski + 555.0, +) #MVABase + + + +######## Shaft Data ######### + +shaft_damping() = PSY.SingleMass( + 3.148, #H + 2.0, +) #D + +shaft_no_damping() = PSY.SingleMass( + 3.01, #H (M = 6.02 -> H = M/2) + 0.0, +) #D + +shaft_fivemass() = PSY.FiveMassShaft( + 3.01, #5.148, #H + 0.3348, #H_hp + 0.7306, #H_ip + 0.8154, #H_lp + 0.0452, #H_ex, + 0.0, #2.0, #D + 0.5180, #D_hp + 0.2240, #D_ip + 0.2240, #D_lp + 0.1450, #D_ex + 0.0518, #D_12 + 0.0224, #D_23 + 0.0224, #D_34 + 0.0145, #D_45 + 33.07, #K_hp + 28.59, #K_ip + 44.68, #K_lp + 21.984, +) #K_ex + + +######## PSS Data ######### + +pss_none() = PSY.PSSFixed(0.0) + + +######## TG Data ######### + +tg_none() = PSY.TGFixed(1.0) #eff + +tg_type1() = PSY.TGTypeI( + 0.02, #R + 0.1, #Ts + 0.45, #Tc + 0.0, #T3 + 0.0, #T4 + 50.0, #T5 + 0.3, #P_min + 1.2, +) #P_max + +tg_type2() = PSY.TGTypeII( + 0.05, #R + 1.0, #T1 + 2.0, #T2 + 1.5, #τ_max + 0.1, +) #τ_min + + +######## AVR Data ######### + +avr_none() = PSY.AVRFixed(0.0) + +avr_propr() = PSY.AVRSimple(5000.0) #Kv + +avr_fixed() = PSY.AVRFixed(1.05) #Emf + +avr_type1() = PSY.AVRTypeI( + 20.0, #Ka - Gain + 0.01, #Ke + 0.063, #Kf + 0.2, #Ta + 0.314, #Te + 0.35, #Tf + 0.001, #Tr + 5.0, #Vrmax + -5.0, #Vrmin + 0.0039, #Ae - 1st ceiling coefficient + 1.555, +) #Be - 2nd ceiling coefficient + +avr_type2() = PSY.AVRTypeII( + 20.0, #K0 - Gain + 0.2, #T1 - 1st pole + 0.063, #T2 - 1st zero + 0.35, #T3 - 2nd pole + 0.01, #T4 - 2nd zero + 0.314, #Te - Field current time constant + 0.001, #Tr - Measurement time constant + 5.0, #Vrmax + -5.0, #Vrmin + 0.0039, #Ae - 1st ceiling coefficient + 1.555, +) #Be - 2nd ceiling coefficient + + +###### Dynamic Generators constructors ###### + +function dyn_gen_OMIB(nodes) + return PSY.DynamicGenerator( + 1, #Number + "Case1Gen", + nodes[2], #bus + 1.0, # ω_ref, + 1.0, #V_ref + 0.5, #P_ref + 0.0, #Q_ref + machine_OMIB(), #machine + shaft_damping(), #shaft + avr_none(), #avr + tg_none(), #tg + pss_none(), + ) #pss +end + +function dyn_gen2_case2(nodes) + return PSY.DynamicGenerator( + 1, #Number + "Case2Gen2", + nodes[2], #bus + 1.0, # ω_ref, + 1.0142, #V_ref + 1.0, #P_ref + 0.0, #Q_ref + machine_4th(), #machine + shaft_no_damping(), #shaft + avr_type1(), #avr + tg_none(), #tg + pss_none(), + ) #pss +end + +function dyn_gen3_case2(nodes) + return PSY.DynamicGenerator( + 2, #Number + "Case2Gen3", + nodes[3], #bus + 1.0, # ω_ref, + 1.0059, #V_ref + 1.0, #P_ref + 0.0, #Q_ref + machine_4th(), #machine + shaft_no_damping(), #shaft + avr_type1(), #avr + tg_none(), #tg + pss_none(), + ) #pss +end + +function dyn_gen2_case3(nodes) + return PSY.DynamicGenerator( + 1, #Number + "Case3Gen2", + nodes[2], #bus + 1.0, # ω_ref, + 1.0142, #V_ref + 1.0, #P_ref + 0.0, #Q_ref + machine_6th(), #machine + shaft_no_damping(), #shaft + avr_type1(), #avr + tg_none(), #tg + pss_none(), + ) #pss +end + +function dyn_gen3_case3(nodes) + return PSY.DynamicGenerator( + 2, #Number + "Case3Gen3", + nodes[3], #bus + 1.0, # ω_ref, + 1.0059, #V_ref + 1.0, #P_ref + 0.0, #Q_ref + machine_6th(), #machine + shaft_no_damping(), #shaft + avr_type1(), #avr + tg_none(), #tg + pss_none(), + ) #pss +end + +function dyn_gen2_case4(nodes) + return PSY.DynamicGenerator( + 1, #Number + "Case4Gen2", + nodes[2], #bus + 1.0, # ω_ref, + 1.0142, #V_ref + 1.0, #P_ref + 0.0, #Q_ref + machine_8th(), #machine + shaft_no_damping(), #shaft + avr_type1(), #avr + tg_none(), #tg + pss_none(), + ) #pss +end + +function dyn_gen3_case4(nodes) + return PSY.DynamicGenerator( + 2, #Number + "Case4Gen3", + nodes[3], #bus + 1.0, # ω_ref, + 1.0059, #V_ref + 1.0, #P_ref + 0.0, #Q_ref + machine_8th(), #machine + shaft_no_damping(), #shaft + avr_type1(), #avr + tg_none(), #tg + pss_none(), + ) #pss +end + +function dyn_gen_case5(nodes) + return PSY.DynamicGenerator( + 1, #Number + "Case5Gen", + nodes[2], #bus + 1.0, # ω_ref, + 1.0155, #V_ref + 0.5, #P_ref + 0.0, #Q_ref + machine_4th(), #machine + shaft_fivemass(), #shaft + avr_type1(), #avr + tg_type2(), #tg + pss_none(), + ) #pss +end + +function dyn_gen_case7(nodes) + return PSY.DynamicGenerator( + 1, #Number + "Case7Gen", + nodes[2], #bus + 1.0, # ω_ref, + 1.0142, #V_ref + 0.6, #P_ref + 0.0, #Q_ref + machine_4th(), #machine + shaft_no_damping(), #shaft + avr_type1(), #avr + tg_none(), #tg + pss_none(), + ) #pss +end + +function dyn_gen_case8(nodes) + return PSY.DynamicGenerator( + 1, #Number + "Case8Gen", + nodes[2], #bus + 1.0, # ω_ref, + 1.0124, #V_ref + 0.6, #P_ref + 0.0, #Q_ref + machine_4th(), #machine + shaft_no_damping(), #shaft + avr_type1(), #avr + tg_none(), #tg + pss_none(), + ) #pss +end + +###################################### +############# Inverters ############## +###################################### + + +###### Converter Data ###### + +converter_DAIB() = PSY.AvgCnvFixedDC( + 690.0, #Rated Voltage + 2.75, +) #Rated MVA + +converter_case78() = PSY.AvgCnvFixedDC( + 138.0, #Rated Voltage + 100.0, +) #Rated MVA + +###### DC Source Data ###### + +dc_source_DAIB() = PSY.FixedDCSource(600.0) #Not in the original data, guessed. + +dc_source_case78() = PSY.FixedDCSource(1500.0) #Not in the original data, guessed. + +###### Filter Data ###### + +filter_test() = PSY.LCLFilter( + 0.08, #Series inductance lf in pu + 0.003, #Series resitance rf in pu + 0.074, #Shunt capacitance cf in pu + 0.2, #Series ractance rg to grid connection (#Step up transformer or similar) + 0.01, +) #Series resistance lg to grid connection (#Step up transformer or similar) + + +###### PLL Data ###### + +pll_test() = PSY.PLL( + 500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. + 0.084, #k_p: PLL proportional gain + 4.69, +) #k_i: PLL integral gain + +###### Outer Control ###### + +virtual_inertia_test() = PSY.VirtualInertia( + 2.0, #Ta:: VSM inertia constant + 400.0, #kd:: VSM damping coefficient + 20.0, #kω:: Frequency droop gain in pu + 2 * pi * 50.0, +) #ωb:: Rated angular frequency + +reactive_droop_test() = PSY.ReactivePowerDroop( + 0.2, #kq:: Reactive power droop gain in pu + 1000.0, +) #ωf:: Reactive power cut-off low pass filter frequency + +outer_control_test() = PSY.VirtualInertiaQdroop(virtual_inertia_test(), reactive_droop_test()) + +######## Inner Control ###### + +vsc_test() = PSY.CombinedVIwithVZ( + 0.59, #kpv:: Voltage controller proportional gain + 736.0, #kiv:: Voltage controller integral gain + 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers + 0.0, #rv:: Virtual resistance in pu + 0.2, #lv: Virtual inductance in pu + 1.27, #kpc:: Current controller proportional gain + 14.3, #kiv:: Current controller integral gain + 0.0, #kffi:: Binary variable enabling the current feed-forward in output of current controllers + 50.0, #ωad:: Active damping low pass filter cut-off frequency + 0.2, +) #kad:: Active damping gain + + +###### Inverters constructors ###### + +function inv_DAIB(nodes) + return PSY.DynamicInverter( + 1, #Number + "DARCO", #name + nodes[2], #bus + 1.0, # ω_ref, + 1.02, #V_ref + 0.5, #P_ref + 0.0, #Q_ref + 2.75, #MVABase + converter_DAIB(), #converter + outer_control_test(), #outer control + vsc_test(), #inner control voltage source + dc_source_DAIB(), #dc source + pll_test(), #pll + filter_test(), + ) #filter +end + +function inv_case78(nodes) + return PSY.DynamicInverter( + 1, #Number + "DARCO", #name + nodes[2], #bus + 1.0, # ω_ref, + 1.02, #V_ref + 0.5, #P_ref + 0.0, #Q_ref + 2.75, #MVABase + converter_case78(), #converter + outer_control_test(), #outer control + vsc_test(), #inner control voltage source + dc_source_case78(), #dc source + pll_test(), #pll + filter_test(), + ) #filter +end diff --git a/test/data_tests/network_test_data.jl b/test/data_tests/network_test_data.jl new file mode 100644 index 0000000..a61bf2e --- /dev/null +++ b/test/data_tests/network_test_data.jl @@ -0,0 +1,379 @@ +using PowerSystems +const PSY = PowerSystems + + +############### Buses Data ######################## + +nodes_OMIB() = [ + PSY.Bus( + 1, #number + "Bus 1", #Name + "REF", #BusType (REF, PV, PQ) + 0, #Angle in radians + 1.05, #Voltage in pu + (min = 0.94, max = 1.06), #Voltage limits in pu + 69, + ), #Base voltage in kV + PSY.Bus(2, "Bus 2", "PV", 0, 1.0, (min = 0.94, max = 1.06), 69), +] + + +nodes_3bus() = [ + PSY.Bus(1, "Bus 1", "REF", 0, 1.02, (min = 0.94, max = 1.06), 138), + PSY.Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), + PSY.Bus(3, "Bus 3", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), +] + +nodes_3bus_case5() = [ + PSY.Bus(1, "Bus 1", "REF", 0, 1.05, (min = 0.94, max = 1.06), 138), + PSY.Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), + PSY.Bus(3, "Bus 3", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), +] + +nodes_DArco_IB() = [ + PSY.Bus( + 1, #number + "Bus 1", #Name + "REF", #BusType (REF, PV, PQ) + 0, #Angle in radians + 1.04, #Voltage in pu + (min = 0.94, max = 1.06), #Voltage limits in pu + 0.69, + ), #Base voltage in kV + PSY.Bus(2, "Bus 2", "PV", 0, 1.0, (min = 0.94, max = 1.06), 0.69), +] + + +############### Branches Data ######################## + + +branches_OMIB(nodes_OMIB) = [PSY.Line( + "Line1", #name + true, #available + 0.0, #active power flow initial condition (from-to) + 0.0, #reactive power flow initial condition (from-to) + Arc(from = nodes_OMIB[1], to = nodes_OMIB[2]), #Connection between buses + 0.01, #resistance in pu + 0.05, #reactance in pu + (from = 0.0, to = 0.0), #susceptance in pu + 18.046, #rate in MW + 1.04, +)] #angle limits (-min and max) + +branches_OMIB_fault(nodes_OMIB) = [PSY.Line( + "Line1", #name + true, #available + 0.0, #active power flow initial condition (from-to) + 0.0, #reactive power flow initial condition (from-to) + Arc(from = nodes_OMIB[1], to = nodes_OMIB[2]), #Connection between buses + 0.02, #resistance in pu + 0.1, #reactance in pu + (from = 0.0, to = 0.0), #susceptance in pu + 18.046, #rate in MW + 1.04, +)] #angle limits (-min and max) + +branches_3lines(nodes_3bus) = [ + PSY.Line( + "Line1", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus[1], to = nodes_3bus[3]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus[1], to = nodes_3bus[2]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus[2], to = nodes_3bus[3]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), +] + +branches_3lines_fault(nodes_3bus) = [ + PSY.Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus[1], to = nodes_3bus[2]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus[2], to = nodes_3bus[3]), + 0.01, + 0.12, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), +] + +branches_3lines_case5(nodes_3bus_case5) = [ + PSY.Line( + "Line1", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus_case5[1], to = nodes_3bus_case5[2]), + 0.01, + 0.05, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus_case5[2], to = nodes_3bus_case5[3]), + 0.02, + 0.1, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + PSY.Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus_case5[1], to = nodes_3bus_case5[3]), + 0.02, + 0.1, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), +] + +branches_3lines_case5_fault(nodes_3bus_case5) = [ + Line( + "Line1", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus_case5[1], to = nodes_3bus_case5[2]), + 0.02, + 0.1, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus_case5[2], to = nodes_3bus_case5[3]), + 0.02, + 0.1, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), + Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus_case5[1], to = nodes_3bus_case5[3]), + 0.02, + 0.1, + (from = 0.0, to = 0.0), + 100, + 1.04, + ), +] + +branches_DArco_IB(nodes_DArco_IB) = [PSY.Line( + "Line1", #name + true, #available + 0.0, #active power flow initial condition (from-to) + 0.0, #reactive power flow initial condition (from-to) + Arc(from = nodes_DArco_IB[1], to = nodes_DArco_IB[2]), #Connection between buses + 0.0, #resistance in pu + 0.075, #reactance in pu + (from = 0.0, to = 0.0), #susceptance in pu + 5.0, #rate in MW + 1.04, +)] #angle limits (-min and max) + + +branches_3lines_case8(nodes_3bus) = [ + PSY.Line( + "Line1", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus[1], to = nodes_3bus[3]), + 0.01, + 0.12, + (from = 0.1, to = 0.1), + 100, + 1.04, + ), + PSY.Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus[1], to = nodes_3bus[2]), + 0.01, + 0.12, + (from = 0.1, to = 0.1), + 100, + 1.04, + ), + PSY.Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus[2], to = nodes_3bus[3]), + 0.02, + 0.9, + (from = 0.5, to = 0.5), + 100, + 1.04, + ), +] + +branches_3lines_case8_fault(nodes_3bus) = [ + PSY.Line( + "Line1", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus[1], to = nodes_3bus[3]), + 0.03, + 0.36, + (from = 0.03, to = 0.03), + 100, + 1.04, + ), + PSY.Line( + "Line2", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus[1], to = nodes_3bus[2]), + 0.01, + 0.12, + (from = 0.1, to = 0.1), + 100, + 1.04, + ), + PSY.Line( + "Line3", + true, + 0.0, + 0.0, + Arc(from = nodes_3bus[2], to = nodes_3bus[3]), + 0.02, + 0.9, + (from = 0.5, to = 0.5), + 100, + 1.04, + ), +] + + +############### Load Data ######################## + +loads_OMIB(nodes_OMIB) = [PSY.PowerLoad( + "LBus1", #name + true, #availability + nodes_OMIB[2], #bus + PSY.ConstantPower, #type + 0.3, #P + 0.01, #Q + 0.3, #P_max + 0.01, +)] #Q_max + + +loads_3bus(nodes_3bus) = [ + PSY.PowerLoad("Bus1", true, nodes_3bus[1], PSY.ConstantPower, 1.5, 0.8, 1.5, 0.8), + PSY.PowerLoad("Bus2", true, nodes_3bus[2], PSY.ConstantPower, 1.5, 0.7, 1.5, 0.8), + PSY.PowerLoad("Bus3", true, nodes_3bus[3], PSY.ConstantPower, 0.5, 0.3, 0.5, 0.3), +] + +loads_3bus_case5(nodes_3bus) = [ + PSY.PowerLoad("Bus2", true, nodes_3bus[2], PSY.ConstantPower, 0.3, 0.05, 0.3, 0.05), + PSY.PowerLoad("Bus3", true, nodes_3bus[3], PSY.ConstantPower, 0.3, 0.05, 0.3, 0.05), +] + + +loads_3bus_case7(nodes_3bus) = [ + PSY.PowerLoad("Bus1", true, nodes_3bus[1], PSY.ConstantPower, 0.5, 0.1, 1.5, 0.8), + PSY.PowerLoad("Bus2", true, nodes_3bus[2], PSY.ConstantPower, 1.0, 0.3, 1.5, 0.8), + PSY.PowerLoad("Bus3", true, nodes_3bus[3], PSY.ConstantPower, 0.3, 0.1, 0.5, 0.3), +] + +loads_3bus_case8(nodes_3bus) = [ + PSY.PowerLoad("Bus1", true, nodes_3bus[1], PSY.ConstantPower, 0.5, 0.1, 1.5, 0.8), + PSY.PowerLoad("Bus2", true, nodes_3bus[2], PSY.ConstantPower, 1.0, 0.3, 1.5, 0.8), + PSY.PowerLoad("Bus3", true, nodes_3bus[3], PSY.ConstantPower, 0.3, 0.1, 0.5, 0.3), +] + + +############### Infinite Sources Data ######################## + +inf_gen_1_pu(nodes) = PSY.Source( + "InfBus", #name + true, #availability + nodes[1], #bus + 1.00, #VR + 0.0, #VI + 0.000005, +) #Xth + +inf_gen_102_pu(nodes) = PSY.Source( + "InfBus", #name + true, #availability + nodes[1], #bus + 1.02, #VR + 0.0, #VI + 0.000001, +) #Xth + +inf_gen_105_pu(nodes) = PSY.Source( + "InfBus", #name + true, #availability + nodes[1], #bus + 1.05, #VR + 0.0, #VI + 0.000001, +) #Xth From bb2cf7ab72d0449035c6efe0e738ebcd935672dc Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Fri, 31 Jan 2020 19:32:32 -0800 Subject: [PATCH 10/13] test updated to use functions --- test/old_tests/test_case8_staticbranches.jl | 322 -------------------- test/runtests.jl | 3 + test/test_case1_OMIB.jl | 108 +------ test/test_case2_4th_order.jl | 221 +------------- test/test_case3_6th_order.jl | 231 +------------- test/test_case4_8th_order.jl | 231 +------------- test/test_case5_5shaft.jl | 199 +----------- test/test_case6_DAIB.jl | 102 +------ test/test_case7_4th_order_Inverter.jl | 241 +-------------- test/test_case8_staticbranches.jl | 147 +++++++++ test/test_create_gen_component.jl | 211 ++----------- test/test_system_construction.jl | 38 +-- 12 files changed, 240 insertions(+), 1814 deletions(-) delete mode 100644 test/old_tests/test_case8_staticbranches.jl create mode 100644 test/test_case8_staticbranches.jl diff --git a/test/old_tests/test_case8_staticbranches.jl b/test/old_tests/test_case8_staticbranches.jl deleted file mode 100644 index 8bc3d77..0000000 --- a/test/old_tests/test_case8_staticbranches.jl +++ /dev/null @@ -1,322 +0,0 @@ -""" -Case 8: -This case study a three bus system with 1 machine (One d- One q-: 4th order model), a VSM of 19 states and an infinite source. All lines are modeled as a static lines. -The perturbation trips two of the three circuits of line between buses 1 and 2, triplicating its impedance. -""" - -################################################## -############### LOAD DATA ######################## -################################################## - -############### Data Network ######################## - -nodes_case8 = [ - Bus(1, "Bus 1", "REF", 0, 1.02, (min = 0.94, max = 1.06), 138), - Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), - Bus(3, "Bus 3", "PQ", 0, 1.00, (min = 0.94, max = 1.06), 138), -] - -branch_case8 = [ - Line( - "Line1", - true, - 0.0, - 0.0, - Arc(from = nodes_case8[1], to = nodes_case8[3]), - 0.01, - 0.12, - (from = 0.1, to = 0.1), - 100, - 1.04, - ), - Line( - "Line2", - true, - 0.0, - 0.0, - Arc(from = nodes_case8[1], to = nodes_case8[2]), - 0.01, - 0.12, - (from = 0.1, to = 0.1), - 100, - 1.04, - ), - Line( - "Line3", - true, - 0.0, - 0.0, - Arc(from = nodes_case8[2], to = nodes_case8[3]), - 0.02, - 0.9, - (from = 0.5, to = 0.5), - 100, - 1.04, - ), -] - -#Trip of Line 1. -branch_case8_fault = [ - Line( - "Line1", - true, - 0.0, - 0.0, - Arc(from = nodes_case8[1], to = nodes_case8[3]), - 0.03, - 0.36, - (from = 0.03, to = 0.03), - 100, - 1.04, - ), - Line( - "Line2", - true, - 0.0, - 0.0, - Arc(from = nodes_case8[1], to = nodes_case8[2]), - 0.01, - 0.12, - (from = 0.1, to = 0.1), - 100, - 1.04, - ), - Line( - "Line3", - true, - 0.0, - 0.0, - Arc(from = nodes_case8[2], to = nodes_case8[3]), - 0.02, - 0.9, - (from = 0.5, to = 0.5), - 100, - 1.04, - ), -] - -loads_case8 = [ - PowerLoad("Bus1", true, nodes_case8[1], PowerSystems.ConstantPower, 0.5, 0.1, 1.5, 0.8), - PowerLoad("Bus2", true, nodes_case8[2], PowerSystems.ConstantPower, 1.0, 0.3, 1.5, 0.8), - PowerLoad("Bus3", true, nodes_case8[3], PowerSystems.ConstantPower, 0.3, 0.1, 0.5, 0.3), -] - -############### Data devices ######################## - -inf_gen_case8 = StaticSource( - 1, #number - :InfBus, #name - nodes_case8[1],#bus - 1.00, #VR - 0.0, #VI - 0.000005, -) #Xth - -######## Machine Data ######### - -### Case 2: 4th Order Model with AVR (3-bus case) ### -case8_machine = OneDOneQMachine( - 0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0, -) #MVABase - -######## Shaft Data ######### - -### Shafts for Gen ### -case8_shaft = SingleMass( - 3.01, #H (M = 6.02 -> H = M/2) - 0.0, -) #D - -######## PSS Data ######### -cases_no_pss = PSSFixed(0.0) - -######## TG Data ######### - -### No TG for Cases 1, 2, 3, 4 ### -case8_no_tg = TGFixed(1.0) #eff - -######## AVR Data ######### -### AVRs for Case 2, 3, 4 and 5 ### -case8_avr = AVRTypeI( - 20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555, -) #Be - 2nd ceiling coefficient - -### Case 7 Generators ### -case8_gen = PSY.DynamicGenerator( - 1, #Number - :Case8Gen, - nodes_case8[2], #bus - 1.0, # ω_ref, - 1.0124, #V_ref - 0.6, #P_ref - case8_machine, #machine - case8_shaft, #shaft - case8_avr, #avr - case8_no_tg, #tg - cases_no_pss, -) #pss - -############### Inverter Data ######################## - -converter = AvgCnvFixedDC( - 138.0, #Rated Voltage - 100.0, -) #Rated MVA - -dc_source = FixedDCSource(1500.0) #Not in the original data, guessed. - -filt = LCLFilter( - 0.08, #Series inductance lf in pu - 0.003, #Series resitance rf in pu - 0.074, #Shunt capacitance cf in pu - 0.2, #Series reactance rg to grid connection (#Step up transformer or similar) - 0.01, -) #Series resistance lg to grid connection (#Step up transformer or similar) - -pll = PLL( - 500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. - 0.084, #k_p: PLL proportional gain - 4.69, -) #k_i: PLL integral gain - -virtual_H = VirtualInertia( - 2.0, #Ta:: VSM inertia constant - 400.0, #kd:: VSM damping coefficient - 20.0, #kω:: Frequency droop gain in pu - 2 * pi * 50.0, -) #ωb:: Rated angular frequency - -Q_control = ReactivePowerDroop( - 0.2, #kq:: Reactive power droop gain in pu - 1000.0, -) #ωf:: Reactive power cut-off low pass filter frequency - -outer_control = VirtualInertiaQdroop(virtual_H, Q_control) - -vsc = CombinedVIwithVZ( - 0.59, #kpv:: Voltage controller proportional gain - 736.0, #kiv:: Voltage controller integral gain - 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers - 0.0, #rv:: Virtual resistance in pu - 0.2, #lv: Virtual inductance in pu - 1.27, #kpc:: Current controller proportional gain - 14.3, #kiv:: Current controller integral gain - 0.0, #kffi:: Binary variable enabling the current feed-forward in output of current controllers - 50.0, #ωad:: Active damping low pass filter cut-off frequency - 0.2, -) #kad:: Active damping gain - -case8_inv = PSY.DynamicInverter( - 2, #number - :DARCO, #name - nodes_case8[3], #bus location - 1.0, #ω_ref - 0.8, #V_ref - 0.5, #P_ref - -0.3, #Q_ref - 100.0, #MVABase - converter, #Converter - outer_control, #OuterControl - vsc, #Voltage Source Controller - dc_source, #DC Source - pll, #Frequency Estimator - filt, -) #Output Filter - -######################### Dynamical System ######################## - -case8_DynSystem = PSY.System( - nodes_case8, - branch_case8, - [case8_inv, case8_gen], - vcat(inf_gen_case8, loads_case8), - 100.0, - 50.0, -); - -################################################## -############### SOLVE PROBLEM #################### -################################################## - -dx0 = zeros(LITS.get_total_rows(case8_DynSystem)) -x0 = [ - 1.00, #V1_R - 1.00, #V2_R - 1.00, #V3_R - 0.0, #V1_I - -0.01, #V2_I - -0.01, #V3_I - 0.0, #δω_vsm - 0.2, #δθ_vsm - 0.025, #qm - 0.0015, #ξ_d - -0.07, #ξ_q - 0.05, #γ_d - -0.001, #γ_q - 0.95, #ϕ_d - -0.10, #ϕ_q - 1.004, #vpll_d - 0.0, #vpll_q - 0.0, #ε_pll - 0.1, #δθ_pll - 0.5, #id_cv - 0.0, #iq_cv - 0.95, #vod - -0.1, #voq - 0.49, #iod - -0.1, #ioq - 1.0, #eq_p - 0.47, #ed_p - 0.6, #δ - 1.0, #ω - 2.1, #Vf - 0.28, #Vr1 - -0.39, #Vr2, - 1.0, -] #Vm - -case8_inv.inner_vars[13] = 0.95 #Vd_cnv var -case8_inv.inner_vars[14] = -0.1 #Vq_cnv var -Ybus_fault = Ybus(branch_case8_fault, nodes_case8)[:, :] -u0 = [0.2] -tspan = (0.0, 30.0); - -#Find initial condition -inif! = (out, x) -> LITS.system_model!(out, dx0, x, (Ybus_fault, case8_DynSystem), 0.0) -sys_solve = nlsolve(inif!, x0, xtol = :1e-8, ftol = :1e-8, method = :trust_region) -x0_init = sys_solve.zero - -#Define Fault using Callbacks -cb = DiffEqBase.DiscreteCallback(LITS.change_t_one, LITS.Y_change!) - -#Define Simulation Problem -sim = Simulation(case8_DynSystem, tspan, Ybus_fault, cb, x0_init) - -#Solve problem in equilibrium -run_simulation!(sim, IDA()); - -#Obtain data for voltages -series = get_voltagemag_series(sim, 2) -zoom = [ - (series[1][ix], series[2][ix]) - for (ix, s) in enumerate(series[1]) if (s > 0.90 && s < 1.6) -] - -@test sim.solution.retcode == :Success diff --git a/test/runtests.jl b/test/runtests.jl index 0470fa7..13657a1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -7,6 +7,9 @@ using Sundials const PSY = PowerSystems +include("./data_tests/network_test_data.jl") +include("./data_tests/dynamic_test_data.jl") + tests = readdir(dirname(@__FILE__)) tests = filter( f -> startswith(f, "test_") && endswith(f, ".jl") && f != basename(@__FILE__), diff --git a/test/test_case1_OMIB.jl b/test/test_case1_OMIB.jl index 89c691c..9a8383c 100644 --- a/test/test_case1_OMIB.jl +++ b/test/test_case1_OMIB.jl @@ -10,112 +10,22 @@ drop a circuit on the (double circuit) line connecting the two buses, doubling i ############### Data Network ######################## -nodes_case1 = [ - PSY.Bus( - 1, #number - "Bus 1", #Name - "REF", #BusType (REF, PV, PQ) - 0, #Angle in radians - 1.05, #Voltage in pu - (min = 0.94, max = 1.06), #Voltage limits in pu - 69, - ), #Base voltage in kV - PSY.Bus(2, "Bus 2", "PV", 0, 1.0, (min = 0.94, max = 1.06), 69), -] - -branch_case1 = [PSY.Line( - "Line1", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from = nodes_case1[1], to = nodes_case1[2]), #Connection between buses - 0.01, #resistance in pu - 0.05, #reactance in pu - (from = 0.0, to = 0.0), #susceptance in pu - 18.046, #rate in MW - 1.04, -)] #angle limits (-min and max) +nodes_case1 = nodes_OMIB() -#Trip of a single circuit of Line 1 -> Resistance and Reactance doubled. -branch_case1_fault = [PSY.Line( - "Line1", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from = nodes_case1[1], to = nodes_case1[2]), #Connection between buses - 0.02, #resistance in pu - 0.1, #reactance in pu - (from = 0.0, to = 0.0), #susceptance in pu - 18.046, #rate in MW - 1.04, -)] #angle limits (-min and max) - -loads_case1 = [PSY.PowerLoad( - "LBus1", #name - true, #availability - nodes_case1[2], #bus - PowerSystems.ConstantPower, #type - 0.3, #P - 0.01, #Q - 0.3, #P_max - 0.01, -)] #Q_max - -############### Data devices ######################## - -inf_gen_case1 = PSY.Source( - "InfBus", #name - true, #availability - nodes_case1[1], #bus - 1.05, #VR - 0.0, #VI - 0.000001, -) #Xth - -######## Machine Data ######### - -### Case 1: Classical machine against infinite bus ### -case1_machine = PSY.BaseMachine( - 0.0, #R - 0.2995, #Xd_p - 0.7087, #eq_p - 100.0, -) #MVABase +branch_case1 = branches_OMIB(nodes_case1) -######## Shaft Data ######### - -### Shaft for Case 1 ### -case1_shaft = PSY.SingleMass( - 3.148, #H - 2.0, -) #D - -######## PSS Data ######### -cases_no_pss = PSY.PSSFixed(0.0) +#Trip of a single circuit of Line 1 -> Resistance and Reactance doubled. +branch_case1_fault = branches_OMIB_fault(nodes_case1) -######## TG Data ######### +loads_case1 = loads_OMIB(nodes_case1) -### No TG for Cases 1, 2, 3, 4 ### -case1234_no_tg = PSY.TGFixed(1.0) #eff +############### Data devices ######################## -######## AVR Data ######### -case1_avr = PSY.AVRFixed(0.0) #Vf not applicable in Classic Machines +inf_gen_case1 = inf_gen_105_pu(nodes_case1) ### Case 1 Generator ### -case1_gen = PSY.DynamicGenerator( - 1, #Number - "Case1Gen", - nodes_case1[2], #bus - 1.0, # ω_ref, - 1.0, #V_ref - 0.5, #P_ref - 0.0, #Q_ref - case1_machine, #machine - case1_shaft, #shaft - case1_avr, #avr - case1234_no_tg, #tg - cases_no_pss, -) #pss + +case1_gen = dyn_gen_OMIB(nodes_case1) ######################### Dynamical System ######################## diff --git a/test/test_case2_4th_order.jl b/test/test_case2_4th_order.jl index 87d803a..c42d8ee 100644 --- a/test/test_case2_4th_order.jl +++ b/test/test_case2_4th_order.jl @@ -11,229 +11,24 @@ and the generator located in bus 3. ############### Data Network ######################## -nodes_case234 = [ - PSY.Bus(1, "Bus 1", "REF", 0, 1.02, (min = 0.94, max = 1.06), 138), - PSY.Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), - PSY.Bus(3, "Bus 3", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), -] +nodes_case234 = nodes_3bus() -branch_case234 = [ - PSY.Line( - "Line1", - true, - 0.0, - 0.0, - Arc(from = nodes_case234[1], to = nodes_case234[3]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), - PSY.Line( - "Line2", - true, - 0.0, - 0.0, - Arc(from = nodes_case234[1], to = nodes_case234[2]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), - PSY.Line( - "Line3", - true, - 0.0, - 0.0, - Arc(from = nodes_case234[2], to = nodes_case234[3]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), -] +branch_case234 = branches_3lines(nodes_case234) #Trip of Line 1. -branch_case234_fault = [ - PSY.Line( - "Line2", - true, - 0.0, - 0.0, - Arc(from = nodes_case234[1], to = nodes_case234[2]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), - PSY.Line( - "Line3", - true, - 0.0, - 0.0, - Arc(from = nodes_case234[2], to = nodes_case234[3]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), -] +branch_case234_fault = branches_3lines_fault(nodes_case234) -loads_case234 = [ - PSY.PowerLoad( - "Bus1", - true, - nodes_case234[1], - PowerSystems.ConstantPower, - 1.5, - 0.8, - 1.5, - 0.8, - ), - PSY.PowerLoad( - "Bus2", - true, - nodes_case234[2], - PowerSystems.ConstantPower, - 1.5, - 0.7, - 1.5, - 0.8, - ), - PSY.PowerLoad( - "Bus3", - true, - nodes_case234[3], - PowerSystems.ConstantPower, - 0.5, - 0.3, - 0.5, - 0.3, - ), -] +loads_case234 = loads_3bus(nodes_case234) ############### Data devices ######################## -inf_gen_case234 = PSY.Source( - "InfBus", #name - true, #availability - nodes_case234[1], #bus - 1.02, #VR - 0.0, #VI - 0.000001, -) #Xth - -######## Machine Data ######### - -### Case 2: 4th Order Model with AVR (3-bus case) ### -case2_machine2 = PSY.OneDOneQMachine( - 0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0, -) #MVABase - -case2_machine3 = PSY.OneDOneQMachine( - 0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0, -) #MVABase - -######## Shaft Data ######### - -### Shafts for Gens 2 and 3: Cases 2, 3 and 4 ### -case234_shaft2 = PSY.SingleMass( - 3.01, #H (M = 6.02 -> H = M/2) - 0.0, -) #D - -case234_shaft3 = PSY.SingleMass( - 3.01, #H (M = 6.02 -> H = M/2) - 0.0, -) #D - -######## PSS Data ######### -cases_no_pss = PSY.PSSFixed(0.0) - -######## TG Data ######### - -### No TG for Cases 1, 2, 3, 4 ### -case1234_no_tg = PSY.TGFixed(1.0) #eff - -######## AVR Data ######### -### AVRs for Case 2, 3, 4 and 5 ### -case2345_avr2 = PSY.AVRTypeI( - 20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555, -) #Be - 2nd ceiling coefficient - -case2345_avr3 = PSY.AVRTypeI( - 20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555, -) #Be - 2nd ceiling coefficient +inf_gen_case234 = inf_gen_102_pu(nodes_case234) ### Case 2 Generators ### -case2_gen2 = PSY.DynamicGenerator( - 1, #Number - "Case2Gen2", - nodes_case234[2], #bus - 1.0, # ω_ref, - 1.0142, #V_ref - 1.0, #P_ref - 0.0, #Q_ref - case2_machine2, #machine - case234_shaft2, #shaft - case2345_avr2, #avr - case1234_no_tg, #tg - cases_no_pss, -) #pss -case2_gen3 = PSY.DynamicGenerator( - 2, #Number - "Case2Gen3", - nodes_case234[3], #bus - 1.0, # ω_ref, - 1.0059, #V_ref - 1.0, #P_ref - 0.0, #Q_ref - case2_machine3, #machine - case234_shaft3, #shaft - case2345_avr3, #avr - case1234_no_tg, #tg - cases_no_pss, -) #pss +case2_gen2 = dyn_gen2_case2(nodes_case234) + +case2_gen3 = dyn_gen3_case2(nodes_case234) ######################### Dynamical System ######################## diff --git a/test/test_case3_6th_order.jl b/test/test_case3_6th_order.jl index ac371bd..ab0d4f7 100644 --- a/test/test_case3_6th_order.jl +++ b/test/test_case3_6th_order.jl @@ -11,239 +11,24 @@ and the generator located in bus 3. ############### Data Network ######################## -nodes_case234 = [ - PSY.Bus(1, "Bus 1", "REF", 0, 1.02, (min = 0.94, max = 1.06), 138), - PSY.Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), - PSY.Bus(3, "Bus 3", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), -] +nodes_case234 = nodes_3bus() -branch_case234 = [ - PSY.Line( - "Line1", - true, - 0.0, - 0.0, - Arc(from = nodes_case234[1], to = nodes_case234[3]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), - PSY.Line( - "Line2", - true, - 0.0, - 0.0, - Arc(from = nodes_case234[1], to = nodes_case234[2]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), - PSY.Line( - "Line3", - true, - 0.0, - 0.0, - Arc(from = nodes_case234[2], to = nodes_case234[3]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), -] +branch_case234 = branches_3lines(nodes_case234) #Trip of Line 1. -branch_case234_fault = [ - PSY.Line( - "Line2", - true, - 0.0, - 0.0, - Arc(from = nodes_case234[1], to = nodes_case234[2]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), - PSY.Line( - "Line3", - true, - 0.0, - 0.0, - Arc(from = nodes_case234[2], to = nodes_case234[3]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), -] +branch_case234_fault = branches_3lines_fault(nodes_case234) -loads_case234 = [ - PSY.PowerLoad( - "Bus1", - true, - nodes_case234[1], - PowerSystems.ConstantPower, - 1.5, - 0.8, - 1.5, - 0.8, - ), - PSY.PowerLoad( - "Bus2", - true, - nodes_case234[2], - PowerSystems.ConstantPower, - 1.5, - 0.7, - 1.5, - 0.8, - ), - PSY.PowerLoad( - "Bus3", - true, - nodes_case234[3], - PowerSystems.ConstantPower, - 0.5, - 0.3, - 0.5, - 0.3, - ), -] +loads_case234 = loads_3bus(nodes_case234) ############### Data devices ######################## -inf_gen_case234 = PSY.Source( - "InfBus", #name - true, #availability - nodes_case234[1], #bus - 1.02, #VR - 0.0, #VI - 0.000001, -) #Xth - -######## Machine Data ######### - -### Case 3: 6th Order Model with AVR (3-bus case) ### -case3_machine2 = PSY.SimpleMarconatoMachine( - 0.0, - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 0.14, #Xd_pp - 0.18, #Xq_pp - 5.89, #Td0_p - 0.6, #Tq0_p - 0.5, #Td0_pp - 0.023, #Tq0_pp - 0.0, #T_AA - 100.0, -) #MVABase - -case3_machine3 = PSY.SimpleMarconatoMachine( - 0.0, - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 0.14, #Xd_pp - 0.18, #Xq_pp - 5.89, #Td0_p - 0.6, #Tq0_p - 0.5, #Td0_pp - 0.023, #Tq0_pp - 0.0, #T_AA - 100.0, -) #MVABase - -######## Shaft Data ######### - -### Shafts for Gens 2 and 3: Cases 2, 3 and 4 ### -case234_shaft2 = PSY.SingleMass( - 3.01, #H (M = 6.02 -> H = M/2) - 0.0, -) #D - -case234_shaft3 = PSY.SingleMass( - 3.01, #H (M = 6.02 -> H = M/2) - 0.0, -) #D - -######## PSS Data ######### -cases_no_pss = PSY.PSSFixed(0.0) - -######## TG Data ######### - -### No TG for Cases 1, 2, 3, 4 ### -case1234_no_tg = PSY.TGFixed(1.0) #eff - -######## AVR Data ######### -### AVRs for Case 2, 3, 4 and 5 ### -case2345_avr2 = PSY.AVRTypeI( - 20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555, -) #Be - 2nd ceiling coefficient - -case2345_avr3 = PSY.AVRTypeI( - 20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555, -) #Be - 2nd ceiling coefficient +inf_gen_case234 = inf_gen_102_pu(nodes_case234) ### Case 3 Generators ### -case3_gen2 = PSY.DynamicGenerator( - 1, #Number - "Case3Gen2", - nodes_case234[2], #bus - 1.0, # ω_ref, - 1.0142, #V_ref - 1.0, #P_ref - 0.0, #Q_ref - case3_machine2, #machine - case234_shaft2, #shaft - case2345_avr2, #avr - case1234_no_tg, #tg - cases_no_pss, -) #pss -case3_gen3 = PSY.DynamicGenerator( - 2, #Number - "Case3Gen3", - nodes_case234[3], #bus - 1.0, # ω_ref, - 1.0059, #V_ref - 1.0, #P_ref - 0.0, #Q_ref - case3_machine3, #machine - case234_shaft3, #shaft - case2345_avr3, #avr - case1234_no_tg, #tg - cases_no_pss, -) #pss +case3_gen2 = dyn_gen2_case3(nodes_case234) + +case3_gen3 = dyn_gen3_case3(nodes_case234) ######################### Dynamical System ######################## diff --git a/test/test_case4_8th_order.jl b/test/test_case4_8th_order.jl index c0748be..e654622 100644 --- a/test/test_case4_8th_order.jl +++ b/test/test_case4_8th_order.jl @@ -11,239 +11,24 @@ and the generator located in bus 3. ############### Data Network ######################## -nodes_case234 = [ - PSY.Bus(1, "Bus 1", "REF", 0, 1.02, (min = 0.94, max = 1.06), 138), - PSY.Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), - PSY.Bus(3, "Bus 3", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), -] +nodes_case234 = nodes_3bus() -branch_case234 = [ - PSY.Line( - "Line1", - true, - 0.0, - 0.0, - Arc(from = nodes_case234[1], to = nodes_case234[3]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), - PSY.Line( - "Line2", - true, - 0.0, - 0.0, - Arc(from = nodes_case234[1], to = nodes_case234[2]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), - PSY.Line( - "Line3", - true, - 0.0, - 0.0, - Arc(from = nodes_case234[2], to = nodes_case234[3]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), -] +branch_case234 = branches_3lines(nodes_case234) #Trip of Line 1. -branch_case234_fault = [ - PSY.Line( - "Line2", - true, - 0.0, - 0.0, - Arc(from = nodes_case234[1], to = nodes_case234[2]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), - PSY.Line( - "Line3", - true, - 0.0, - 0.0, - Arc(from = nodes_case234[2], to = nodes_case234[3]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), -] +branch_case234_fault = branches_3lines_fault(nodes_case234) -loads_case234 = [ - PSY.PowerLoad( - "Bus1", - true, - nodes_case234[1], - PowerSystems.ConstantPower, - 1.5, - 0.8, - 1.5, - 0.8, - ), - PSY.PowerLoad( - "Bus2", - true, - nodes_case234[2], - PowerSystems.ConstantPower, - 1.5, - 0.7, - 1.5, - 0.8, - ), - PSY.PowerLoad( - "Bus3", - true, - nodes_case234[3], - PowerSystems.ConstantPower, - 0.5, - 0.3, - 0.5, - 0.3, - ), -] +loads_case234 = loads_3bus(nodes_case234) ############### Data devices ######################## -inf_gen_case234 = PSY.Source( - "InfBus", #name - true, #availability - nodes_case234[1], #bus - 1.02, #VR - 0.0, #VI - 0.000001, -) #Xth - -######## Machine Data ######### - -### Case 4: 8th Order Model with AVR (3-bus case) ### -case4_machine2 = PSY.MarconatoMachine( - 0.0, - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 0.14, #Xd_pp - 0.18, #Xq_pp - 5.89, #Td0_p - 0.6, #Tq0_p - 0.5, #Td0_pp - 0.023, #Tq0_pp - 0.0, #T_AA - 100.0, -) #MVABase - -case4_machine3 = PSY.MarconatoMachine( - 0.0, - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 0.14, #Xd_pp - 0.18, #Xq_pp - 5.89, #Td0_p - 0.6, #Tq0_p - 0.5, #Td0_pp - 0.023, #Tq0_pp - 0.0, #T_AA - 100.0, -) #MVABase - -######## Shaft Data ######### - -### Shafts for Gens 2 and 3: Cases 2, 3 and 4 ### -case234_shaft2 = PSY.SingleMass( - 3.01, #H (M = 6.02 -> H = M/2) - 0.0, -) #D - -case234_shaft3 = PSY.SingleMass( - 3.01, #H (M = 6.02 -> H = M/2) - 0.0, -) #D - -######## PSS Data ######### -cases_no_pss = PSY.PSSFixed(0.0) - -######## TG Data ######### - -### No TG for Cases 1, 2, 3, 4 ### -case1234_no_tg = PSY.TGFixed(1.0) #eff - -######## AVR Data ######### -### AVRs for Case 2, 3, 4 and 5 ### -case2345_avr2 = PSY.AVRTypeI( - 20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555, -) #Be - 2nd ceiling coefficient - -case2345_avr3 = PSY.AVRTypeI( - 20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555, -) #Be - 2nd ceiling coefficient +inf_gen_case234 = inf_gen_102_pu(nodes_case234) ### Case 4 Generators ### -case4_gen2 = PSY.DynamicGenerator( - 1, #Number - "Case4Gen2", - nodes_case234[2], #bus - 1.0, # ω_ref, - 1.0142, #V_ref - 1.0, #P_ref - 0.0, #Q_ref - case4_machine2, #machine - case234_shaft2, #shaft - case2345_avr2, #avr - case1234_no_tg, #tg - cases_no_pss, -) #pss -case4_gen3 = PSY.DynamicGenerator( - 2, #Number - "Case4Gen3", - nodes_case234[3], #bus - 1.0, # ω_ref, - 1.0059, #V_ref - 1.0, #P_ref - 0.0, #Q_ref - case4_machine3, #machine - case234_shaft3, #shaft - case2345_avr3, #avr - case1234_no_tg, #tg - cases_no_pss, -) #pss +case4_gen2 = dyn_gen2_case4(nodes_case234) + +case4_gen3 = dyn_gen3_case4(nodes_case234) ######################### Dynamical System ######################## diff --git a/test/test_case5_5shaft.jl b/test/test_case5_5shaft.jl index 13ec784..96898fd 100644 --- a/test/test_case5_5shaft.jl +++ b/test/test_case5_5shaft.jl @@ -11,207 +11,22 @@ The fault disconnects a circuit between buses 1 and 2, doubling its impedance. ############### Data Network ######################## -nodes_case5 = [ - PSY.Bus(1, "Bus 1", "REF", 0, 1.05, (min = 0.94, max = 1.06), 138), - PSY.Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), - PSY.Bus(3, "Bus 3", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), -] +nodes_case5 = nodes_3bus_case5() -branch_case5 = [ - PSY.Line( - "Line1", - true, - 0.0, - 0.0, - Arc(from = nodes_case5[1], to = nodes_case5[2]), - 0.01, - 0.05, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), - PSY.Line( - "Line2", - true, - 0.0, - 0.0, - Arc(from = nodes_case5[2], to = nodes_case5[3]), - 0.02, - 0.1, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), - PSY.Line( - "Line3", - true, - 0.0, - 0.0, - Arc(from = nodes_case5[1], to = nodes_case5[3]), - 0.02, - 0.1, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), -] +branch_case5 = branches_3lines_case5(nodes_case5) #Trip of a single circuit of Line 1 -> Resistance and Reactance doubled. -branch_case5_fault = [ - Line( - "Line1", - true, - 0.0, - 0.0, - Arc(from = nodes_case5[1], to = nodes_case5[2]), - 0.02, - 0.1, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), - Line( - "Line2", - true, - 0.0, - 0.0, - Arc(from = nodes_case5[2], to = nodes_case5[3]), - 0.02, - 0.1, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), - Line( - "Line3", - true, - 0.0, - 0.0, - Arc(from = nodes_case5[1], to = nodes_case5[3]), - 0.02, - 0.1, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), -] +branch_case5_fault = branches_3lines_case5_fault(nodes_case5) -loads_case5 = [ - PSY.PowerLoad( - "Bus2", - true, - nodes_case5[2], - PowerSystems.ConstantPower, - 0.3, - 0.05, - 0.3, - 0.05, - ), - PSY.PowerLoad( - "Bus3", - true, - nodes_case5[3], - PowerSystems.ConstantPower, - 0.3, - 0.05, - 0.3, - 0.05, - ), -] +loads_case5 = loads_3bus_case5(nodes_case5) ############### Data devices ######################## -inf_gen_case5 = PSY.Source( - "InfBus", #name - true, #availability - nodes_case5[1], #bus - 1.00, #VR - 0.0, #VI - 0.000001, -) #Xth - -######## Machine Data ######### - -### Case 5: 4th Order Model with AVR + TG + Multishaft ### -case5_machine = PSY.OneDOneQMachine( - 0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0, -) #MVABase - -######## Shaft Data ######### - -case5_shaft = PSY.FiveMassShaft( - 3.01, #5.148, #H - 0.3348, #H_hp - 0.7306, #H_ip - 0.8154, #H_lp - 0.0452, #H_ex, - 0.0, #2.0, #D - 0.5180, #D_hp - 0.2240, #D_ip - 0.2240, #D_lp - 0.1450, #D_ex - 0.0518, #D_12 - 0.0224, #D_23 - 0.0224, #D_34 - 0.0145, #D_45 - 33.07, #K_hp - 28.59, #K_ip - 44.68, #K_lp - 21.984, -) #K_ex - -######## PSS Data ######### -cases_no_pss = PSY.PSSFixed(0.0) - -######## TG Data ######### - -### TG for Case 5 ### -case5_tg = PSY.TGTypeII( - 0.05, #R - 1.0, #T1 - 2.0, #T2 - 1.5, #τ_max - 0.1, -) #τ_min - -######## AVR Data ######### -### AVRs for Case 2, 3, 4 and 5 ### -case5_avr = PSY.AVRTypeI( - 20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555, -) #Be - 2nd ceiling coefficient +inf_gen_case5 = inf_gen_1_pu(nodes_case5) ### Case 5 Generator ### -case5_gen = PSY.DynamicGenerator( - 1, #Number - "Case5Gen", - nodes_case5[2], #bus - 1.0, # ω_ref, - 1.0155, #V_ref - 0.5, #P_ref - 0.0, #Q_ref - case5_machine, #machine - case5_shaft, #shaft - case5_avr, #avr - case5_tg, #tg - cases_no_pss, -) #pss + +case5_gen = dyn_gen_case5(nodes_case5) ######################### Dynamical System ######################## diff --git a/test/test_case6_DAIB.jl b/test/test_case6_DAIB.jl index 0c96ec9..22f4fc5 100644 --- a/test/test_case6_DAIB.jl +++ b/test/test_case6_DAIB.jl @@ -10,109 +10,17 @@ The perturbation increase the reference power (analogy for mechanical power) fro ############### Data Network ######################## -nodes_DAIB = [ - PSY.Bus( - 1, #number - "Bus 1", #Name - "REF", #BusType (REF, PV, PQ) - 0, #Angle in radians - 1.04, #Voltage in pu - (min = 0.94, max = 1.06), #Voltage limits in pu - 0.69, - ), #Base voltage in kV - PSY.Bus(2, "Bus 2", "PV", 0, 1.0, (min = 0.94, max = 1.06), 0.69), -] - -branch_DAIB = [PSY.Line( - "Line1", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from = nodes_DAIB[1], to = nodes_DAIB[2]), #Connection between buses - 0.0, #resistance in pu - 0.075, #reactance in pu - (from = 0.0, to = 0.0), #susceptance in pu - 5.0, #rate in MW - 1.04, -)] #angle limits (-min and max) +nodes_DAIB = nodes_DArco_IB() + +branch_DAIB = branches_DArco_IB(nodes_DAIB) ############### Data devices ######################## -inf_gen_DAIB = PSY.Source( - "InfBus", #name - true, #availability - nodes_DAIB[1],#bus - 1.00, #VR - 0.0, #VI - 0.000005, -) #Xth +inf_gen_DAIB = inf_gen_1_pu(nodes_DAIB) ############### Inverter Data ######################## -converter = PSY.AvgCnvFixedDC( - 690.0, #Rated Voltage - 2.75, -) #Rated MVA - -dc_source = PSY.FixedDCSource(600.0) #Not in the original data, guessed. - -filt = PSY.LCLFilter( - 0.08, #Series inductance lf in pu - 0.003, #Series resitance rf in pu - 0.074, #Shunt capacitance cf in pu - 0.2, #Series ractance rg to grid connection (#Step up transformer or similar) - 0.01, -) #Series resistance lg to grid connection (#Step up transformer or similar) - -pll = PSY.PLL( - 500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. - 0.084, #k_p: PLL proportional gain - 4.69, -) #k_i: PLL integral gain - -virtual_H = PSY.VirtualInertia( - 2.0, #Ta:: VSM inertia constant - 400.0, #kd:: VSM damping coefficient - 20.0, #kω:: Frequency droop gain in pu - 2 * pi * 50.0, -) #ωb:: Rated angular frequency - -Q_control = PSY.ReactivePowerDroop( - 0.2, #kq:: Reactive power droop gain in pu - 1000.0, -) #ωf:: Reactive power cut-off low pass filter frequency - -outer_control = PSY.VirtualInertiaQdroop(virtual_H, Q_control) - -vsc = PSY.CombinedVIwithVZ( - 0.59, #kpv:: Voltage controller proportional gain - 736.0, #kiv:: Voltage controller integral gain - 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers - 0.0, #rv:: Virtual resistance in pu - 0.2, #lv: Virtual inductance in pu - 1.27, #kpc:: Current controller proportional gain - 14.3, #kiv:: Current controller integral gain - 0.0, #kffi:: Binary variable enabling the current feed-forward in output of current controllers - 50.0, #ωad:: Active damping low pass filter cut-off frequency - 0.2, -) #kad:: Active damping gain - -Darco_Inverter = PSY.DynamicInverter( - 1, #number - "DARCO", #name - nodes_DAIB[2], #bus location - 1.0, #ω_ref - 1.02, #V_ref - 0.5, #P_ref - 0.0, #Q_ref - 2.75, #MVABase - converter, #Converter - outer_control, #OuterControl - vsc, #Voltage Source Controller - dc_source, #DC Source - pll, #Frequency Estimator - filt, -) #Output Filter +Darco_Inverter = inv_DAIB(nodes_DAIB) ######################### Dynamical System ######################## diff --git a/test/test_case7_4th_order_Inverter.jl b/test/test_case7_4th_order_Inverter.jl index d4a26b1..519ed4e 100644 --- a/test/test_case7_4th_order_Inverter.jl +++ b/test/test_case7_4th_order_Inverter.jl @@ -10,251 +10,26 @@ The perturbation increase the reference power (analogy for mechanical power) of ############### Data Network ######################## -nodes_case7 = [ - PSY.Bus(1, "Bus 1", "REF", 0, 1.02, (min = 0.94, max = 1.06), 138), - PSY.Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), - PSY.Bus(3, "Bus 3", "PQ", 0, 1.00, (min = 0.94, max = 1.06), 138), -] +nodes_case7 = nodes_3bus() -branch_case7 = [ - PSY.Line( - "Line1", - true, - 0.0, - 0.0, - Arc(from = nodes_case7[1], to = nodes_case7[3]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), - PSY.Line( - "Line2", - true, - 0.0, - 0.0, - Arc(from = nodes_case7[1], to = nodes_case7[2]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), - PSY.Line( - "Line3", - true, - 0.0, - 0.0, - Arc(from = nodes_case7[2], to = nodes_case7[3]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), -] +branch_case7 = branches_3lines(nodes_case7) #Trip of Line 1. -branch_case7_fault = [ - PSY.Line( - "Line2", - true, - 0.0, - 0.0, - Arc(from = nodes_case7[1], to = nodes_case7[2]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), - PSY.Line( - "Line3", - true, - 0.0, - 0.0, - Arc(from = nodes_case7[2], to = nodes_case7[3]), - 0.01, - 0.12, - (from = 0.0, to = 0.0), - 100, - 1.04, - ), -] +branch_case7_fault = branches_3lines_fault(nodes_case7) -loads_case7 = [ - PSY.PowerLoad( - "Bus1", - true, - nodes_case7[1], - PowerSystems.ConstantPower, - 0.5, - 0.1, - 1.5, - 0.8, - ), - PSY.PowerLoad( - "Bus2", - true, - nodes_case7[2], - PowerSystems.ConstantPower, - 1.0, - 0.3, - 1.5, - 0.8, - ), - PSY.PowerLoad( - "Bus3", - true, - nodes_case7[3], - PowerSystems.ConstantPower, - 0.3, - 0.1, - 0.5, - 0.3, - ), -] +loads_case7 = loads_3bus_case7(nodes_case7) ############### Data devices ######################## -inf_gen_case7 = PSY.Source( - "InfBus", #name - true, #availability - nodes_case7[1],#bus - 1.00, #VR - 0.0, #VI - 0.000005, -) #Xth - -######## Machine Data ######### - -### Case 2: 4th Order Model with AVR (3-bus case) ### -case7_machine = PSY.OneDOneQMachine( - 0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0, -) #MVABase - -######## Shaft Data ######### - -### Shafts for Gen ### -case7_shaft = PSY.SingleMass( - 3.01, #H (M = 6.02 -> H = M/2) - 0.0, -) #D - -######## PSS Data ######### -cases_no_pss = PSY.PSSFixed(0.0) - -######## TG Data ######### - -### No TG for Cases 1, 2, 3, 4 ### -case7_no_tg = PSY.TGFixed(1.0) #eff - -######## AVR Data ######### -### AVRs for Case 2, 3, 4 and 5 ### -case7_avr = PSY.AVRTypeI( - 20.0, #Ka - Gain - 0.01, #Ke - 0.063, #Kf - 0.2, #Ta - 0.314, #Te - 0.35, #Tf - 0.001, #Tr - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555, -) #Be - 2nd ceiling coefficient +inf_gen_case7 = inf_gen_1_pu(nodes_case7) ### Case 7 Generators ### -case7_gen = PSY.DynamicGenerator( - 1, #Number - "Case7Gen", - nodes_case7[2], #bus - 1.0, # ω_ref, - 1.0142, #V_ref - 0.6, #P_ref - 0.0, #Q_ref - case7_machine, #machine - case7_shaft, #shaft - case7_avr, #avr - case7_no_tg, #tg - cases_no_pss, -) #pss -############### Inverter Data ######################## +case7_gen = dyn_gen_case7(nodes_case7) -converter = PSY.AvgCnvFixedDC( - 138.0, #Rated Voltage - 100.0, -) #Rated MVA - -dc_source = PSY.FixedDCSource(1500.0) #Not in the original data, guessed. - -filt = PSY.LCLFilter( - 0.08, #Series inductance lf in pu - 0.003, #Series resitance rf in pu - 0.074, #Shunt capacitance cf in pu - 0.2, #Series reactance rg to grid connection (#Step up transformer or similar) - 0.01, -) #Series resistance lg to grid connection (#Step up transformer or similar) - -pll = PSY.PLL( - 500.0, #ω_lp: Cut-off frequency for LowPass filter of PLL filter. - 0.084, #k_p: PLL proportional gain - 4.69, -) #k_i: PLL integral gain - -virtual_H = PSY.VirtualInertia( - 2.0, #Ta:: VSM inertia constant - 400.0, #kd:: VSM damping coefficient - 20.0, #kω:: Frequency droop gain in pu - 2 * pi * 50.0, -) #ωb:: Rated angular frequency - -Q_control = PSY.ReactivePowerDroop( - 0.2, #kq:: Reactive power droop gain in pu - 1000.0, -) #ωf:: Reactive power cut-off low pass filter frequency - -outer_control = PSY.VirtualInertiaQdroop(virtual_H, Q_control) - -vsc = PSY.CombinedVIwithVZ( - 0.59, #kpv:: Voltage controller proportional gain - 736.0, #kiv:: Voltage controller integral gain - 0.0, #kffv:: Binary variable enabling the voltage feed-forward in output of current controllers - 0.0, #rv:: Virtual resistance in pu - 0.2, #lv: Virtual inductance in pu - 1.27, #kpc:: Current controller proportional gain - 14.3, #kiv:: Current controller integral gain - 0.0, #kffi:: Binary variable enabling the current feed-forward in output of current controllers - 50.0, #ωad:: Active damping low pass filter cut-off frequency - 0.2, -) #kad:: Active damping gain +############### Inverter Data ######################## -case7_inv = PSY.DynamicInverter( - 2, #number - "DARCO", #name - nodes_case7[3], #bus location - 1.0, #ω_ref - 1.02, #V_ref - 0.5, #P_ref - 0.0, #Q_ref - 100.0, #MVABase - converter, #Converter - outer_control, #OuterControl - vsc, #Voltage Source Controller - dc_source, #DC Source - pll, #Frequency Estimator - filt, -) #Output Filter +case7_inv = inv_case78(nodes_case7) ######################### Dynamical System ######################## diff --git a/test/test_case8_staticbranches.jl b/test/test_case8_staticbranches.jl new file mode 100644 index 0000000..ed4a509 --- /dev/null +++ b/test/test_case8_staticbranches.jl @@ -0,0 +1,147 @@ +""" +Case 8: +This case study a three bus system with 1 machine (One d- One q-: 4th order model), a VSM of 19 states and an infinite source. All lines are modeled as a static lines. +The perturbation trips two of the three circuits of line between buses 1 and 2, triplicating its impedance. +""" + +################################################## +############### LOAD DATA ######################## +################################################## + +############### Data Network ######################## + +nodes_case8 = nodes_3bus() + +branch_case8 = branches_3lines_case8(nodes_case8) + +#Two of three lines lost in Line 1 +branch_case8_fault = branches_3lines_case8_fault(nodes_case8) + +loads_case8 = loads_3bus_case8(nodes_case8) + +############### Data devices ######################## + +inf_gen_case8 = inf_gen_1_pu(nodes_case8) + +### Case 8 Generators ### + +case8_gen = dyn_gen_case8(nodes_case8) + +############### Inverter Data ######################## + +case8_inv = inv_case78(nodes_case8) + +######################### Dynamical System ######################## + +#Create system with BasePower = 100 MVA and nominal frequency 50 Hz. +sys = PSY.System(100.0, frequency = 50.0) + +#Add buses +for bus in nodes_case8 + PSY.add_component!(sys, bus) +end + +#Add lines +for lines in branch_case8 + PSY.add_component!(sys, lines) +end + +#Add loads +for loads in loads_case8 + PSY.add_component!(sys, loads) +end + +#Add infinite source +PSY.add_component!(sys, inf_gen_case8) + +#Add inverter +PSY.add_component!(sys, case8_inv) + +#Add generator +PSY.add_component!(sys, case8_gen) + +################################################## +############### SOLVE PROBLEM #################### +################################################## + +#time span +tspan = (0.0, 20.0) + +#initial_guess +x0_guess = [ + 1.00, #V1_R + 1.00, #V2_R + 1.00, #V3_R + 0.0, #V1_I + -0.01, #V2_I + -0.01, #V3_I + 0.0, #δω_vsm + 0.2, #δθ_vsm + 0.025, #qm + 0.0015, #ξ_d + -0.07, #ξ_q + 0.05, #γ_d + -0.001, #γ_q + 0.95, #ϕ_d + -0.10, #ϕ_q + 1.004, #vpll_d + 0.0, #vpll_q + 0.0, #ε_pll + 0.1, #δθ_pll + 0.5, #id_cv + 0.0, #iq_cv + 0.95, #vod + -0.1, #voq + 0.49, #iod + -0.1, #ioq + 1.0, #eq_p + 0.47, #ed_p + 0.6, #δ + 1.0, #ω + 2.1, #Vf + 0.28, #Vr1 + -0.39, #Vr2, + 1.0, +] #Vm + +#Compute Y_bus after fault +sys2 = PSY.System(100.0, frequency = 50.0); + +#Add buses +for bus in nodes_case8 + PSY.add_component!(sys2, bus) +end + +#Add lines +for lines in branch_case8_fault + PSY.add_component!(sys2, lines) +end + +Ybus_fault = PSY.Ybus(sys2)[:, :] + +#Define Fault: Change of YBus +Ybus_change = LITS.ThreePhaseFault( + 1.0, #change at t = 1.0 + Ybus_fault, +) #New YBus + +#Define Simulation Problem +sim = Simulation( + sys, #system + tspan, #time span + Ybus_change, #Type of Fault + initial_guess = x0_guess, +) #initial guess + +#Solve problem in equilibrium +run_simulation!(sim, IDA()); + +#Obtain data for voltages +series = get_voltagemag_series(sim, 2) + +zoom = [ + (series[1][ix], series[2][ix]) + for (ix, s) in enumerate(series[1]) if (s > 0.90 && s < 1.6) +] + +@test sim.solution.retcode == :Success diff --git a/test/test_create_gen_component.jl b/test/test_create_gen_component.jl index 721a95d..e1183e8 100644 --- a/test/test_create_gen_component.jl +++ b/test/test_create_gen_component.jl @@ -1,238 +1,85 @@ -nodes_OMIB = [ - PSY.Bus( - 1, #number - "Bus 1", #Name - "REF", #BusType (REF, PV, PQ) - 0, #Angle in radians - 1.06, #Voltage in pu - (min = 0.94, max = 1.06), #Voltage limits in pu - 69, - ), #Base voltage in kV - PSY.Bus(2, "Bus 2", "PV", 0, 1.045, (min = 0.94, max = 1.06), 69), -] +OMIB_nodes = nodes_OMIB() + @testset "Dynamic Machines" begin - Basic = PSY.BaseMachine( - 0.0, #R - 0.2995, #Xd_p - 1.05, #eq_p - 615.0, - ) #MVABase + Basic = machine_OMIB() @test Basic isa PSY.DynamicComponent - oneDoneQ = PSY.OneDOneQMachine( - 0.0, #R - 0.8979, #Xd - 0.646, #Xq - 0.2995, #Xd_p - 0.04, #Xq_p - 7.4, #Td0_p - 0.033, #Tq0_p - 615.0, - ) #MVABase + oneDoneQ = machine_4th() @test oneDoneQ isa PSY.DynamicComponent - AndersonFouad = PSY.AndersonFouadMachine( - 0.0, #R - 0.8979, #Xd - 0.646, #Xq - 0.2995, #Xd_p - 0.646, #Xq_p - 0.23, #Xd_pp - 0.4, #Xq_pp - 7.4, #Td0_p - 0.01, #Tq0_p #Data not available in Milano: Used 0.01 - 0.03, #Td0_pp - 0.033, #Tq0_pp - 615.0, - ) #MVABase + AndersonFouad = machine_anderson() @test AndersonFouad isa PSY.DynamicComponent - KundurMachine = PSY.SimpleFullMachine( - 0.003, #R on Example 3.1 and 4.1 of Kundur - 0.0006, #R_f - 0.0284, #R_1d or RD in Machowski - 0.0062, #R_1q or RQ on Machowski - 1.81, #L_d - 1.76, #L_q - 1.66, #L_ad or k*M_f or k*M_D in Machowski - 1.61, #L_aq or k*M_Q in Machowski - 1.66, #L_f1d or L_fD in Machowski. Assumed to be equal to L_ad - 1.825, #L_ff - 0.1713, #L_1d or L_D in Machowski - 0.7525, #L_1q or L_Q in Machowski - 555.0, - ) #MVABase + KundurMachine = machine_kundur() @test KundurMachine isa PSY.DynamicComponent - KundurFullMachine = PSY.FullMachine( - 0.003, #R on Example 3.1 and 4.1 of Kundur - 0.0006, #R_f - #0.003, #R_f - 0.0284, #R_1d or RD in Machowski - 0.0062, #R_1q or RQ on Machowski - 1.81, #L_d - 1.76, #L_q - 1.66, #L_ad or k*M_f or k*M_D in Machowski - 1.61, #L_aq or k*M_Q in Machowski - 1.66, #L_f1d or L_fD in Machowski. Assumed to be equal to L_ad - 1.825, #L_ff - 0.1713, #L_1d or L_D in Machowski - 0.7525, #L_1q or L_Q in Machowski - 555.0, - ) #MVABase + KundurFullMachine = machine_full_kundur() @test KundurFullMachine isa PSY.DynamicComponent - Mach2_benchmark = PSY.OneDOneQMachine( - 0.0, #R - 1.3125, #Xd - 1.2578, #Xq - 0.1813, #Xd_p - 0.25, #Xq_p - 5.89, #Td0_p - 0.6, #Tq0_p - 100.0, - ) #MVABase + Mach2_benchmark = machine_4th() @test Mach2_benchmark isa PSY.DynamicComponent end ################ Shaft Data ##################### @testset "Dynamic Shaft" begin - BaseShaft = PSY.SingleMass( - 5.148, #H - 2.0, - ) #D + BaseShaft = shaft_damping() @test BaseShaft isa PSY.DynamicComponent - FiveShaft = PSY.FiveMassShaft( - 5.148, #H - 0.3348, #H_hp - 0.7306, #H_ip - 0.8154, #H_lp - 0.0452, #H_ex, - 2.0, #D - 0.5180, #D_hp - 0.2240, #D_ip - 0.2240, #D_lp - 0.1450, #D_ex - 0.0518, #D_12 - 0.0224, #D_23 - 0.0224, #D_34 - 0.0145, #D_45 - 33.07, #K_hp - 28.59, #K_ip - 44.68, #K_lp - 21.984, - ) #K_ex + FiveShaft = shaft_fivemass() @test FiveShaft isa PSY.DynamicComponent end ################# PSS Data ##################### @testset "Dynamic PSS" begin - no_pss = PSY.PSSFixed(0.0) + no_pss = pss_none() @test no_pss isa PSY.DynamicComponent end ################ TG Data ##################### @testset "Dynamic Turbine Governor Constructors" begin - fixed_tg = PSY.TGFixed(1.0) #eff + fixed_tg = tg_none() @test fixed_tg isa PSY.DynamicComponent - typeI_tg = PSY.TGTypeI( - 0.02, #R - 0.1, #Ts - 0.45, #Tc - 0.0, #T3 - 0.0, #T4 - 50.0, #T5 - 0.3, #P_min - 1.2, - ) #P_max + typeI_tg = tg_type1() @test typeI_tg isa PSY.DynamicComponent - typeII_tg = PSY.TGTypeII( - 0.05, #R - 0.3, #T1 - 0.1, #T2 - 1.0, #τ_max - 0.1, - ) #τ_min + typeII_tg = tg_type2() @test typeII_tg isa PSY.DynamicComponent end ################ AVR Data ##################### @testset "Dynamic AVR Constructors" begin - proportional_avr = PSY.AVRSimple(5000.0) #Kv + proportional_avr = avr_propr() @test proportional_avr isa PSY.DynamicComponent - fixed_avr = PSY.AVRFixed(1.05) #Emf + fixed_avr = avr_fixed() @test fixed_avr isa PSY.DynamicComponent - typeI_avr = PSY.AVRTypeI( - 200.0, #Ka - 1.0, #Ke - 0.0012, #Kf - 0.02, #Ta - 0.19, #Te - 1.0, #Tf - 0.001, #Tr - 9.9, #Vr_max - 0.0, #Vr_min - 0.0006, #Ae - 0.9, - ) + typeI_avr = avr_type1() @test typeI_avr isa PSY.DynamicComponent - gen2_avr_benchmark = PSY.AVRTypeII( - 20.0, #K0 - Gain - 0.2, #T1 - 1st pole - 0.063, #T2 - 1st zero - 0.35, #T3 - 2nd pole - 0.01, #T4 - 2nd zero - 0.314, #Te - Field current time constant - 0.001, #Tr - Measurement time constant - 5.0, #Vrmax - -5.0, #Vrmin - 0.0039, #Ae - 1st ceiling coefficient - 1.555, - ) #Be - 2nd ceiling coefficient + gen2_avr_benchmark = avr_type2() @test gen2_avr_benchmark isa PSY.DynamicComponent end ######################### Generators ######################## @testset "Dynamic Generators" begin #Components for the test - Basic = PSY.BaseMachine( - 0.0, #R - 0.2995, #Xd_p - 1.05, #eq_p - 615.0, - ) #MVABase + Basic = machine_OMIB() - BaseShaft = PSY.SingleMass( - 5.148, #H - 2.0, - ) #D + BaseShaft = shaft_damping() - fixed_avr = PSY.AVRFixed(1.05) #Emf + fixed_avr = avr_fixed() - proportional_avr = PSY.AVRSimple(5000.0) #Kv + proportional_avr = avr_propr() - fixed_tg = PSY.TGFixed(1.0) #eff + fixed_tg = tg_none() - no_pss = PSY.PSSFixed(0.0) + no_pss = pss_none() - oneDoneQ = PSY.OneDOneQMachine( - 0.0, #R - 0.8979, #Xd - 0.646, #Xq - 0.2995, #Xd_p - 0.04, #Xq_p - 7.4, #Td0_p - 0.033, #Tq0_p - 615.0, - ) #MVABase + oneDoneQ = machine_4th() Gen1AVR = PSY.DynamicGenerator( 1, #Number "TestGen", - nodes_OMIB[2],#bus + OMIB_nodes[2],#bus 1.0, # ω_ref, 1.05, 0.4, @@ -248,7 +95,7 @@ end Gen1AVRnoAVR = PSY.DynamicGenerator( 1, #Number "TestGen", - nodes_OMIB[2],#bus + OMIB_nodes[2],#bus 1.0, # ω_ref, 1.05, 0.4, @@ -264,7 +111,7 @@ end Gen2AVRnoAVR = PSY.DynamicGenerator( 1, #Number "TestGen", - nodes_OMIB[2],#bus + OMIB_nodes[2],#bus 1.0, # ω_ref, 1.02, 0.4, @@ -280,7 +127,7 @@ end Gen2AVR = PSY.DynamicGenerator( 1, #Number "TestGen", - nodes_OMIB[2],#bus + OMIB_nodes[2],#bus 1.0, # ω_ref, 1.02, 0.4, diff --git a/test/test_system_construction.jl b/test/test_system_construction.jl index a494fe1..bc4c1a0 100644 --- a/test/test_system_construction.jl +++ b/test/test_system_construction.jl @@ -1,28 +1,6 @@ -nodes_OMIB = [ - PSY.Bus( - 1, #number - "Bus 1", #Name - "REF", #BusType (REF, PV, PQ) - 0, #Angle in radians - 1.06, #Voltage in pu - (min = 0.94, max = 1.06), #Voltage limits in pu - 69, - ), #Base voltage in kV - PSY.Bus(2, "Bus 2", "PV", 0, 1.045, (min = 0.94, max = 1.06), 69), -] - -branch_OMIB = [PSY.Line( - "Line1", #name - true, #available - 0.0, #active power flow initial condition (from-to) - 0.0, #reactive power flow initial condition (from-to) - Arc(from = nodes_OMIB[1], to = nodes_OMIB[2]), #Connection between buses - 0.01, #resistance in pu - 0.05, #reactance in pu - (from = 0.0, to = 0.0), #susceptance in pu - 18.046, #rate in MW - 1.04, -)] #angle limits (-min and max) +OMIB_nodes = nodes_OMIB() + +branch_OMIB = branches_OMIB(OMIB_nodes) #### Generators ##### Basic = PSY.BaseMachine( @@ -48,7 +26,7 @@ no_pss = PSY.PSSFixed(0.0) Gen1AVR = PSY.DynamicGenerator( 1, #Number "TestGen", - nodes_OMIB[2],#bus + OMIB_nodes[2],#bus 1.0, # ω_ref, 1.05, 0.4, @@ -63,7 +41,7 @@ Gen1AVR = PSY.DynamicGenerator( Gen2AVR = PSY.DynamicGenerator( 1, #Number "TestGen2", - nodes_OMIB[2],#bus + OMIB_nodes[2],#bus 1.0, # ω_ref, 1.05, 0.4, @@ -125,7 +103,7 @@ vsc = CombinedVIwithVZ( test_inverter = PSY.DynamicInverter( 2, #number "DARCO", #name - nodes_OMIB[1], #bus location + OMIB_nodes[1], #bus location 1.0, #ω_ref 1.02, #V_ref 0.5, #P_ref @@ -142,7 +120,7 @@ test_inverter = PSY.DynamicInverter( @testset "Dynamic Generator in System" begin sys = PSY.System(100) - for bus in nodes_OMIB + for bus in OMIB_nodes PSY.add_component!(sys, bus) end for lines in branch_OMIB @@ -152,6 +130,6 @@ test_inverter = PSY.DynamicInverter( PSY.add_component!(sys, Gen2AVR) PSY.add_component!(sys, test_inverter) - @test collect(PSY.get_components(DynamicGenerator, sys))[1] == Gen1AVR + @test collect(PSY.get_components(PSY.DynamicGenerator, sys))[1] == Gen1AVR end From 3493fef146c58c0fe63e59b78028efebed96d9e6 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Fri, 31 Jan 2020 19:37:13 -0800 Subject: [PATCH 11/13] formatting issues --- test/data_tests/dynamic_test_data.jl | 14 +++----------- test/data_tests/network_test_data.jl | 9 --------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/test/data_tests/dynamic_test_data.jl b/test/data_tests/dynamic_test_data.jl index 4a7a0a6..ef55bd2 100644 --- a/test/data_tests/dynamic_test_data.jl +++ b/test/data_tests/dynamic_test_data.jl @@ -105,8 +105,6 @@ machine_full_kundur() = PSY.FullMachine( 555.0, ) #MVABase - - ######## Shaft Data ######### shaft_damping() = PSY.SingleMass( @@ -140,12 +138,10 @@ shaft_fivemass() = PSY.FiveMassShaft( 21.984, ) #K_ex - ######## PSS Data ######### pss_none() = PSY.PSSFixed(0.0) - ######## TG Data ######### tg_none() = PSY.TGFixed(1.0) #eff @@ -169,7 +165,6 @@ tg_type2() = PSY.TGTypeII( 0.1, ) #τ_min - ######## AVR Data ######### avr_none() = PSY.AVRFixed(0.0) @@ -192,7 +187,7 @@ avr_type1() = PSY.AVRTypeI( 1.555, ) #Be - 2nd ceiling coefficient -avr_type2() = PSY.AVRTypeII( +avr_type2() = PSY.AVRTypeII( 20.0, #K0 - Gain 0.2, #T1 - 1st pole 0.063, #T2 - 1st zero @@ -206,7 +201,6 @@ avr_type2() = PSY.AVRTypeII( 1.555, ) #Be - 2nd ceiling coefficient - ###### Dynamic Generators constructors ###### function dyn_gen_OMIB(nodes) @@ -383,7 +377,6 @@ end ############# Inverters ############## ###################################### - ###### Converter Data ###### converter_DAIB() = PSY.AvgCnvFixedDC( @@ -412,7 +405,6 @@ filter_test() = PSY.LCLFilter( 0.01, ) #Series resistance lg to grid connection (#Step up transformer or similar) - ###### PLL Data ###### pll_test() = PSY.PLL( @@ -435,7 +427,8 @@ reactive_droop_test() = PSY.ReactivePowerDroop( 1000.0, ) #ωf:: Reactive power cut-off low pass filter frequency -outer_control_test() = PSY.VirtualInertiaQdroop(virtual_inertia_test(), reactive_droop_test()) +outer_control_test() = + PSY.VirtualInertiaQdroop(virtual_inertia_test(), reactive_droop_test()) ######## Inner Control ###### @@ -452,7 +445,6 @@ vsc_test() = PSY.CombinedVIwithVZ( 0.2, ) #kad:: Active damping gain - ###### Inverters constructors ###### function inv_DAIB(nodes) diff --git a/test/data_tests/network_test_data.jl b/test/data_tests/network_test_data.jl index a61bf2e..28397d8 100644 --- a/test/data_tests/network_test_data.jl +++ b/test/data_tests/network_test_data.jl @@ -1,7 +1,6 @@ using PowerSystems const PSY = PowerSystems - ############### Buses Data ######################## nodes_OMIB() = [ @@ -17,7 +16,6 @@ nodes_OMIB() = [ PSY.Bus(2, "Bus 2", "PV", 0, 1.0, (min = 0.94, max = 1.06), 69), ] - nodes_3bus() = [ PSY.Bus(1, "Bus 1", "REF", 0, 1.02, (min = 0.94, max = 1.06), 138), PSY.Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138), @@ -43,10 +41,8 @@ nodes_DArco_IB() = [ PSY.Bus(2, "Bus 2", "PV", 0, 1.0, (min = 0.94, max = 1.06), 0.69), ] - ############### Branches Data ######################## - branches_OMIB(nodes_OMIB) = [PSY.Line( "Line1", #name true, #available @@ -230,7 +226,6 @@ branches_DArco_IB(nodes_DArco_IB) = [PSY.Line( 1.04, )] #angle limits (-min and max) - branches_3lines_case8(nodes_3bus) = [ PSY.Line( "Line1", @@ -309,7 +304,6 @@ branches_3lines_case8_fault(nodes_3bus) = [ ), ] - ############### Load Data ######################## loads_OMIB(nodes_OMIB) = [PSY.PowerLoad( @@ -323,7 +317,6 @@ loads_OMIB(nodes_OMIB) = [PSY.PowerLoad( 0.01, )] #Q_max - loads_3bus(nodes_3bus) = [ PSY.PowerLoad("Bus1", true, nodes_3bus[1], PSY.ConstantPower, 1.5, 0.8, 1.5, 0.8), PSY.PowerLoad("Bus2", true, nodes_3bus[2], PSY.ConstantPower, 1.5, 0.7, 1.5, 0.8), @@ -335,7 +328,6 @@ loads_3bus_case5(nodes_3bus) = [ PSY.PowerLoad("Bus3", true, nodes_3bus[3], PSY.ConstantPower, 0.3, 0.05, 0.3, 0.05), ] - loads_3bus_case7(nodes_3bus) = [ PSY.PowerLoad("Bus1", true, nodes_3bus[1], PSY.ConstantPower, 0.5, 0.1, 1.5, 0.8), PSY.PowerLoad("Bus2", true, nodes_3bus[2], PSY.ConstantPower, 1.0, 0.3, 1.5, 0.8), @@ -348,7 +340,6 @@ loads_3bus_case8(nodes_3bus) = [ PSY.PowerLoad("Bus3", true, nodes_3bus[3], PSY.ConstantPower, 0.3, 0.1, 0.5, 0.3), ] - ############### Infinite Sources Data ######################## inf_gen_1_pu(nodes) = PSY.Source( From 4691ba09f3e135b636e8986661005239aa45f83f Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Fri, 31 Jan 2020 20:00:30 -0800 Subject: [PATCH 12/13] add Ybus and system constructor for tests --- test/data_tests/dynamic_test_data.jl | 98 +++++++++++++++++++++++++++ test/data_tests/network_test_data.jl | 15 ++++ test/test_case1_OMIB.jl | 35 +--------- test/test_case2_4th_order.jl | 41 +++-------- test/test_case3_6th_order.jl | 41 +++-------- test/test_case4_8th_order.jl | 41 +++-------- test/test_case5_5shaft.jl | 34 +--------- test/test_case6_DAIB.jl | 14 +--- test/test_case7_4th_order_Inverter.jl | 33 +++------ test/test_case8_staticbranches.jl | 51 +++----------- 10 files changed, 161 insertions(+), 242 deletions(-) diff --git a/test/data_tests/dynamic_test_data.jl b/test/data_tests/dynamic_test_data.jl index ef55bd2..6f255b6 100644 --- a/test/data_tests/dynamic_test_data.jl +++ b/test/data_tests/dynamic_test_data.jl @@ -484,3 +484,101 @@ function inv_case78(nodes) filter_test(), ) #filter end + +###################################### +######## System Constructors ######### +###################################### + +function system_no_inv(nodes, branches, loads, sources, gens) + #Create system with BasePower = 100 MVA and nominal frequency 60 Hz. + sys = PSY.System(100.0, frequency = 60.0) + + #Add buses + for bus in nodes + PSY.add_component!(sys, bus) + end + + #Add lines + for lines in branches + PSY.add_component!(sys, lines) + end + + #Add loads + for load in loads + PSY.add_component!(sys, load) + end + + #Add infinite source + for source in sources + PSY.add_component!(sys, source) + end + + #Add generator + for gen in gens + PSY.add_component!(sys, gen) + end + return sys +end + +function system_DAIB(nodes, branches, sources, invs) + #Create system with BasePower = 100 MVA and nominal frequency 50 Hz. + sys = PSY.System(100.0, frequency = 50.0) + + #Add buses + for bus in nodes + PSY.add_component!(sys, bus) + end + + #Add lines + for lines in branches + PSY.add_component!(sys, lines) + end + + #Add infinite source + for source in sources + PSY.add_component!(sys, source) + end + + #Add inverters + for inv in invs + PSY.add_component!(sys, inv) + end + return sys +end + +function system_50Hz(nodes, branches, loads, sources, invs, gens) + #Create system with BasePower = 100 MVA and nominal frequency 50 Hz. + sys = PSY.System(100.0, frequency = 50.0) + + #Add buses + for bus in nodes + PSY.add_component!(sys, bus) + end + + #Add lines + for lines in branches + PSY.add_component!(sys, lines) + end + + #Add loads + for load in loads + PSY.add_component!(sys, load) + end + + #Add infinite source + for source in sources + PSY.add_component!(sys, source) + end + + #Add inverters + for inv in invs + PSY.add_component!(sys, inv) + end + + #Add generators + for gen in gens + PSY.add_component!(sys, gen) + end + + return sys +end diff --git a/test/data_tests/network_test_data.jl b/test/data_tests/network_test_data.jl index 28397d8..9b3acb3 100644 --- a/test/data_tests/network_test_data.jl +++ b/test/data_tests/network_test_data.jl @@ -368,3 +368,18 @@ inf_gen_105_pu(nodes) = PSY.Source( 0.0, #VI 0.000001, ) #Xth + +############# Obtain Ybus ########### + +function get_admittance_matrix(nodes, branches) + sys2 = PSY.System(100.0, frequency = 60.0) + for bus in nodes + PSY.add_component!(sys2, bus) + end + + #Add lines + for lines in branches + PSY.add_component!(sys2, lines) + end + return PSY.Ybus(sys2)[:, :] +end diff --git a/test/test_case1_OMIB.jl b/test/test_case1_OMIB.jl index 9a8383c..f9fa548 100644 --- a/test/test_case1_OMIB.jl +++ b/test/test_case1_OMIB.jl @@ -30,45 +30,14 @@ case1_gen = dyn_gen_OMIB(nodes_case1) ######################### Dynamical System ######################## #Create system with BasePower = 100 MVA and nominal frequency 60 Hz. -sys = PSY.System(100.0, frequency = 60.0); - -#Add buses -for bus in nodes_case1 - PSY.add_component!(sys, bus) -end - -#Add lines -for lines in branch_case1 - PSY.add_component!(sys, lines) -end - -#Add loads -for loads in loads_case1 - PSY.add_component!(sys, loads) -end - -#Add infinite source -PSY.add_component!(sys, inf_gen_case1) - -#Add generator -PSY.add_component!(sys, case1_gen) +sys = system_no_inv(nodes_case1, branch_case1, loads_case1, [inf_gen_case1], [case1_gen]) ################################################## ############### SOLVE PROBLEM #################### ################################################## #Compute Y_bus after fault -sys2 = PSY.System(100.0, frequency = 60.0); -#Add buses -for bus in nodes_case1 - PSY.add_component!(sys2, bus) -end - -#Add lines -for lines in branch_case1_fault - PSY.add_component!(sys2, lines) -end -Ybus_fault = PSY.Ybus(sys2)[:, :] +Ybus_fault = get_admittance_matrix(nodes_case1, branch_case1_fault) tspan = (0.0, 30.0); diff --git a/test/test_case2_4th_order.jl b/test/test_case2_4th_order.jl index c42d8ee..757dc3b 100644 --- a/test/test_case2_4th_order.jl +++ b/test/test_case2_4th_order.jl @@ -33,45 +33,20 @@ case2_gen3 = dyn_gen3_case2(nodes_case234) ######################### Dynamical System ######################## #Create system with BasePower = 100 MVA and nominal frequency 60 Hz. -sys = PSY.System(100.0, frequency = 60.0); - -#Add buses -for bus in nodes_case234 - PSY.add_component!(sys, bus) -end - -#Add lines -for lines in branch_case234 - PSY.add_component!(sys, lines) -end - -#Add loads -for loads in loads_case234 - PSY.add_component!(sys, loads) -end - -#Add infinite source -PSY.add_component!(sys, inf_gen_case234) - -#Add generators -PSY.add_component!(sys, case2_gen2) -PSY.add_component!(sys, case2_gen3) +sys = system_no_inv( + nodes_case234, + branch_case234, + loads_case234, + [inf_gen_case234], + [case2_gen2, case2_gen3], +) ################################################## ############### SOLVE PROBLEM #################### ################################################## #Compute Y_bus after fault -sys2 = PSY.System(100.0, frequency = 60.0); -#Add buses -for bus in nodes_case234 - PSY.add_component!(sys2, bus) -end -#Add lines -for lines in branch_case234_fault - PSY.add_component!(sys2, lines) -end -Ybus_fault = PSY.Ybus(sys2)[:, :] +Ybus_fault = get_admittance_matrix(nodes_case234, branch_case234_fault) #time span tspan = (0.0, 30.0); diff --git a/test/test_case3_6th_order.jl b/test/test_case3_6th_order.jl index ab0d4f7..839630b 100644 --- a/test/test_case3_6th_order.jl +++ b/test/test_case3_6th_order.jl @@ -33,45 +33,20 @@ case3_gen3 = dyn_gen3_case3(nodes_case234) ######################### Dynamical System ######################## #Create system with BasePower = 100 MVA and nominal frequency 60 Hz. -sys = PSY.System(100.0, frequency = 60.0); - -#Add buses -for bus in nodes_case234 - PSY.add_component!(sys, bus) -end - -#Add lines -for lines in branch_case234 - PSY.add_component!(sys, lines) -end - -#Add loads -for loads in loads_case234 - PSY.add_component!(sys, loads) -end - -#Add infinite source -PSY.add_component!(sys, inf_gen_case234) - -#Add generators -PSY.add_component!(sys, case3_gen2) -PSY.add_component!(sys, case3_gen3) +sys = system_no_inv( + nodes_case234, + branch_case234, + loads_case234, + [inf_gen_case234], + [case3_gen2, case3_gen3], +) ################################################## ############### SOLVE PROBLEM #################### ################################################## #Compute Y_bus after fault -sys2 = PSY.System(100.0, frequency = 60.0); -#Add buses -for bus in nodes_case234 - PSY.add_component!(sys2, bus) -end -#Add lines -for lines in branch_case234_fault - PSY.add_component!(sys2, lines) -end -Ybus_fault = PSY.Ybus(sys2)[:, :] +Ybus_fault = get_admittance_matrix(nodes_case234, branch_case234_fault) #time span tspan = (0.0, 20.0); diff --git a/test/test_case4_8th_order.jl b/test/test_case4_8th_order.jl index e654622..90b4c7d 100644 --- a/test/test_case4_8th_order.jl +++ b/test/test_case4_8th_order.jl @@ -33,45 +33,20 @@ case4_gen3 = dyn_gen3_case4(nodes_case234) ######################### Dynamical System ######################## #Create system with BasePower = 100 MVA and nominal frequency 60 Hz. -sys = PSY.System(100.0, frequency = 60.0); - -#Add buses -for bus in nodes_case234 - PSY.add_component!(sys, bus) -end - -#Add lines -for lines in branch_case234 - PSY.add_component!(sys, lines) -end - -#Add loads -for loads in loads_case234 - PSY.add_component!(sys, loads) -end - -#Add infinite source -PSY.add_component!(sys, inf_gen_case234) - -#Add generators -PSY.add_component!(sys, case4_gen2) -PSY.add_component!(sys, case4_gen3) +sys = system_no_inv( + nodes_case234, + branch_case234, + loads_case234, + [inf_gen_case234], + [case4_gen2, case4_gen3], +) ################################################## ############### SOLVE PROBLEM #################### ################################################## #Compute Y_bus after fault -sys2 = PSY.System(100.0, frequency = 60.0); -#Add buses -for bus in nodes_case234 - PSY.add_component!(sys2, bus) -end -#Add lines -for lines in branch_case234_fault - PSY.add_component!(sys2, lines) -end -Ybus_fault = PSY.Ybus(sys2)[:, :] +Ybus_fault = get_admittance_matrix(nodes_case234, branch_case234_fault) #time span tspan = (0.0, 20.0); diff --git a/test/test_case5_5shaft.jl b/test/test_case5_5shaft.jl index 96898fd..7dc9be3 100644 --- a/test/test_case5_5shaft.jl +++ b/test/test_case5_5shaft.jl @@ -31,44 +31,14 @@ case5_gen = dyn_gen_case5(nodes_case5) ######################### Dynamical System ######################## #Create system with BasePower = 100 MVA and nominal frequency 60 Hz. -sys = PSY.System(100.0, frequency = 60.0); - -#Add buses -for bus in nodes_case5 - PSY.add_component!(sys, bus) -end - -#Add lines -for lines in branch_case5 - PSY.add_component!(sys, lines) -end - -#Add loads -for loads in loads_case5 - PSY.add_component!(sys, loads) -end - -#Add infinite source -PSY.add_component!(sys, inf_gen_case5) - -#Add generators -PSY.add_component!(sys, case5_gen) +sys = system_no_inv(nodes_case5, branch_case5, loads_case5, [inf_gen_case5], [case5_gen]) ################################################## ############### SOLVE PROBLEM #################### ################################################## #Compute Y_bus after fault -sys2 = PSY.System(100.0, frequency = 60.0); -#Add buses -for bus in nodes_case5 - PSY.add_component!(sys2, bus) -end -#Add lines -for lines in branch_case5_fault - PSY.add_component!(sys2, lines) -end -Ybus_fault = PSY.Ybus(sys2)[:, :] +Ybus_fault = get_admittance_matrix(nodes_case5, branch_case5_fault) #time span tspan = (0.0, 20.0); diff --git a/test/test_case6_DAIB.jl b/test/test_case6_DAIB.jl index 22f4fc5..8b6f2d1 100644 --- a/test/test_case6_DAIB.jl +++ b/test/test_case6_DAIB.jl @@ -25,19 +25,7 @@ Darco_Inverter = inv_DAIB(nodes_DAIB) ######################### Dynamical System ######################## #Create system with BasePower = 100 MVA and nominal frequency 50 Hz. -sys = PSY.System(100, frequency = 50.0) -#Add buses -for bus in nodes_DAIB - PSY.add_component!(sys, bus) -end -#Add lines -for lines in branch_DAIB - PSY.add_component!(sys, lines) -end -#Add infinite source -PSY.add_component!(sys, inf_gen_DAIB) -#Add inverter -PSY.add_component!(sys, Darco_Inverter) +sys = system_DAIB(nodes_DAIB, branch_DAIB, [inf_gen_DAIB], [Darco_Inverter]) ################################################## ############### SOLVE PROBLEM #################### diff --git a/test/test_case7_4th_order_Inverter.jl b/test/test_case7_4th_order_Inverter.jl index 519ed4e..f78d8eb 100644 --- a/test/test_case7_4th_order_Inverter.jl +++ b/test/test_case7_4th_order_Inverter.jl @@ -34,31 +34,14 @@ case7_inv = inv_case78(nodes_case7) ######################### Dynamical System ######################## #Create system with BasePower = 100 MVA and nominal frequency 50 Hz. -sys = PSY.System(100, frequency = 50.0) - -#Add buses -for bus in nodes_case7 - PSY.add_component!(sys, bus) -end - -#Add lines -for lines in branch_case7 - PSY.add_component!(sys, lines) -end - -#Add loads -for loads in loads_case7 - PSY.add_component!(sys, loads) -end - -#Add infinite source -PSY.add_component!(sys, inf_gen_case7) - -#Add inverter -PSY.add_component!(sys, case7_inv) - -#Add generator -PSY.add_component!(sys, case7_gen) +sys = system_50Hz( + nodes_case7, + branch_case7, + loads_case7, + [inf_gen_case7], + [case7_inv], + [case7_gen], +) ################################################## ############### SOLVE PROBLEM #################### diff --git a/test/test_case8_staticbranches.jl b/test/test_case8_staticbranches.jl index ed4a509..d7873a0 100644 --- a/test/test_case8_staticbranches.jl +++ b/test/test_case8_staticbranches.jl @@ -34,36 +34,22 @@ case8_inv = inv_case78(nodes_case8) ######################### Dynamical System ######################## #Create system with BasePower = 100 MVA and nominal frequency 50 Hz. -sys = PSY.System(100.0, frequency = 50.0) - -#Add buses -for bus in nodes_case8 - PSY.add_component!(sys, bus) -end - -#Add lines -for lines in branch_case8 - PSY.add_component!(sys, lines) -end - -#Add loads -for loads in loads_case8 - PSY.add_component!(sys, loads) -end - -#Add infinite source -PSY.add_component!(sys, inf_gen_case8) - -#Add inverter -PSY.add_component!(sys, case8_inv) - -#Add generator -PSY.add_component!(sys, case8_gen) +sys = system_50Hz( + nodes_case8, + branch_case8, + loads_case8, + [inf_gen_case8], + [case8_inv], + [case8_gen], +) ################################################## ############### SOLVE PROBLEM #################### ################################################## +#Compute Y_bus after fault +Ybus_fault = get_admittance_matrix(nodes_case8, branch_case8_fault) + #time span tspan = (0.0, 20.0) @@ -104,21 +90,6 @@ x0_guess = [ 1.0, ] #Vm -#Compute Y_bus after fault -sys2 = PSY.System(100.0, frequency = 50.0); - -#Add buses -for bus in nodes_case8 - PSY.add_component!(sys2, bus) -end - -#Add lines -for lines in branch_case8_fault - PSY.add_component!(sys2, lines) -end - -Ybus_fault = PSY.Ybus(sys2)[:, :] - #Define Fault: Change of YBus Ybus_change = LITS.ThreePhaseFault( 1.0, #change at t = 1.0 From 77b623c42746704ca0b1090a73818b631bae5674 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Fri, 31 Jan 2020 21:02:23 -0800 Subject: [PATCH 13/13] add formatter option --- .github/workflows/formatter_code.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/formatter_code.jl b/.github/workflows/formatter_code.jl index c3d8a31..337412f 100644 --- a/.github/workflows/formatter_code.jl +++ b/.github/workflows/formatter_code.jl @@ -5,5 +5,6 @@ for main_path in main_paths whitespace_ops_in_indices = true, remove_extra_newlines = true, verbose = true, + always_for_in = true, ) end