diff --git a/.github/workflows/formatter_code.jl b/.github/workflows/formatter_code.jl index 76741ec..337412f 100644 --- a/.github/workflows/formatter_code.jl +++ b/.github/workflows/formatter_code.jl @@ -1,14 +1,10 @@ -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, + always_for_in = true, + ) end 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 # 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/src/base/simulation.jl b/src/base/simulation.jl index cac9eec..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, @@ -103,7 +100,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 @@ -196,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 @@ -274,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) = 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/data_tests/dynamic_test_data.jl b/test/data_tests/dynamic_test_data.jl new file mode 100644 index 0000000..6f255b6 --- /dev/null +++ b/test/data_tests/dynamic_test_data.jl @@ -0,0 +1,584 @@ +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 + +###################################### +######## 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 new file mode 100644 index 0000000..9b3acb3 --- /dev/null +++ b/test/data_tests/network_test_data.jl @@ -0,0 +1,385 @@ +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 + +############# 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/old_tests/test_case1_OMIB.jl b/test/old_tests/test_case1_OMIB.jl deleted file mode 100644 index e680388..0000000 --- a/test/old_tests/test_case1_OMIB.jl +++ /dev/null @@ -1,144 +0,0 @@ -""" -Case 1: -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 - 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 = [PowerLoad("Bus1", true, nodes_case1[2], PowerSystems.ConstantPower, 0.3, 0.01, 0.3, 0.01)] - - -############### Data devices ######################## - -inf_gen_case1 = StaticSource(1, #number - :InfBus, #name - nodes_case1[1], #bus - 1.05, #VR - 0.0, #VI - 0.000001) #Xth - -######## 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 - -######## Shaft Data ######### - -### Shaft for Case 1 ### -case1_shaft = SingleMass(3.148, #H - 2.0) #D - - - -######## 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 - -######## AVR Data ######### -case1_avr = 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 - case1_machine, #machine - case1_shaft, #shaft - case1_avr, #avr - case1234_no_tg, #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) - - -################################################## -############### SOLVE PROBLEM #################### -################################################## - -#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); - -#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 - -#Define Fault using Callbacks -cb = DiffEqBase.DiscreteCallback(LITS.change_t_one, LITS.Y_change!) - -#Define Simulation Problem -sim = Simulation(case1_DynSystem, tspan, Ybus_fault, cb, x0_init) - -#Solve problem in equilibrium -run_simulation!(sim, IDA(), dtmax=0.02); - -#Obtain data for angles -series = get_state_series(sim, (:Case1Gen, :δ)); - -@test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case2_4th_order.jl b/test/old_tests/test_case2_4th_order.jl deleted file mode 100644 index 4c19bc6..0000000 --- a/test/old_tests/test_case2_4th_order.jl +++ /dev/null @@ -1,185 +0,0 @@ -""" -Case 2: -This case study a three bus system with 2 machines (One d- One q-: 4th order model) and an infinite source. -The fault drop the connection between buses 1 and 3, eliminating the direct connection between the infinite source -and the generator located in bus 3. -""" - -################################################## -############### LOAD DATA ######################## -################################################## - -############### 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)] - -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)] - - -############### Data devices ######################## - -inf_gen_case234 = StaticSource(1, #number - :InfBus, #name - 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 = 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 - -######## 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) - 0.0) #D - - -case234_shaft3 = 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 ### -case1234_no_tg = TGFixed(1.0) #eff - - -######## AVR Data ######### -### 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 - -### 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 - -######################### Dynamical System ######################## - -case2_DynSystem = PSY.System(nodes_case234, - branch_case234, - [case2_gen2, case2_gen3], - vcat(inf_gen_case234,loads_case234), - 100.0, - 60.0) - - -################################################## -############### SOLVE PROBLEM #################### -################################################## - - -#Compute Y_bus after fault -Ybus_fault = PSY.Ybus(branch_case234_fault, nodes_case234)[:,:] - -#Initialize variables -dx0 = zeros(LITS.get_total_rows(case2_DynSystem)) -x0 = [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 -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) - -#Solve problem in equilibrium -run_simulation!(sim, IDA()); - -#Obtain data for angles -series = get_state_series(sim, (:Case2Gen2, :δ)); - -@test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case3_6th_order.jl b/test/old_tests/test_case3_6th_order.jl deleted file mode 100644 index cd33a0f..0000000 --- a/test/old_tests/test_case3_6th_order.jl +++ /dev/null @@ -1,204 +0,0 @@ -""" -Case 3: -This case study a three bus system with 2 machines (Simple Marconato: 6th order model) and an infinite source. -The fault drop the connection between buses 1 and 3, eliminating the direct connection between the infinite source -and the generator located in bus 3. -""" - -################################################## -############### LOAD DATA ######################## -################################################## - -############### 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)] - -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)] - - -############### Data devices ######################## - -inf_gen_case234 = StaticSource(1, #number - :InfBus, #name - 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 = 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 - -######## 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) - 0.0) #D - - -case234_shaft3 = 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 ### -case1234_no_tg = TGFixed(1.0) #eff - - -######## AVR Data ######### -### 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 - -### 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 - - -######################### Dynamical System ######################## - -case3_DynSystem = PSY.System(nodes_case234, - branch_case234, - [case3_gen2, case3_gen3], - vcat(inf_gen_case234,loads_case234), - 100.0, - 60.0) - - -################################################## -############### SOLVE PROBLEM #################### -################################################## - - - -#Compute Y_bus after fault -Ybus_fault = PSY.Ybus(branch_case234_fault, nodes_case234)[:,:] - -#Initialize variables -dx0 = zeros(LITS.get_total_rows(case3_DynSystem)) -x0 = [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 -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 Simulation Problem -sim = Simulation(case3_DynSystem, tspan, Ybus_fault, cb, x0_init) - -#Solve problem in equilibrium -run_simulation!(sim, IDA()); - -#Obtain data for angles -series = get_state_series(sim, (:Case3Gen2, :δ)); - -@test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case4_8th_order.jl b/test/old_tests/test_case4_8th_order.jl deleted file mode 100644 index d0d9f6e..0000000 --- a/test/old_tests/test_case4_8th_order.jl +++ /dev/null @@ -1,209 +0,0 @@ -""" -Case 4: -This case study a three bus system with 2 machines (Marconato: 8th order model) and an infinite source. -The fault drop the connection between buses 1 and 3, eliminating the direct connection between the infinite source -and the generator located in bus 3. -""" - - -################################################## -############### LOAD DATA ######################## -################################################## - -############### 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)] - -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)] - - -############### Data devices ######################## - -inf_gen_case234 = StaticSource(1, #number - :InfBus, #name - 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 = 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 - -######## 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) - 0.0) #D - - -case234_shaft3 = 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 ### -case1234_no_tg = TGFixed(1.0) #eff - - -######## AVR Data ######### -### 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 - -### 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 - - -######################### Dynamical System ######################## - -case4_DynSystem = PSY.System(nodes_case234, - branch_case234, - [case4_gen2, case4_gen3], - vcat(inf_gen_case234,loads_case234), - 100.0, - 60.0) - - -################################################## -############### SOLVE PROBLEM #################### -################################################## - - -#Compute Y_bus after fault -Ybus_fault = PSY.Ybus(branch_case234_fault, nodes_case234)[:,:]; - -#Initialize variables -dx0 = zeros(LITS.get_total_rows(case4_DynSystem)) -x0 = [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 -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 Simulation Problem -sim = Simulation(case4_DynSystem, tspan, Ybus_fault, cb, x0_init) - -#Solve problem in equilibrium -run_simulation!(sim, IDA()); - -#Obtain data for angles -series = get_state_series(sim, (:Case4Gen2, :δ)); - -@test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case5_5shaft.jl b/test/old_tests/test_case5_5shaft.jl deleted file mode 100644 index ba0a370..0000000 --- a/test/old_tests/test_case5_5shaft.jl +++ /dev/null @@ -1,174 +0,0 @@ -""" -Case 5: -This case study a three bus system with 1 machine located at bus 2. -The generator uses the model of a one d- one q- machine, and has a 5-mass shaft and a turbine governor. -The fault disconnects a circuit between buses 1 and 2, doubling its impedance. -""" - -################################################## -############### LOAD DATA ######################## -################################################## - -############### 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)] - -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)] - - -############### Data devices ######################## - -inf_gen_case5 = StaticSource(1, #number - :InfBus, #name - 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 = 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 = 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 ######### - -### TG for Case 5 ### -case5_tg = 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 = 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 - case5_machine, #machine - case5_shaft, #shaft - case5_avr, #avr - case5_tg, #tg - cases_no_pss) #pss - - -######################### Dynamical System ######################## - -case5_DynSystem = PSY.System(nodes_case5, - branch_case5, - [case5_gen], - vcat(inf_gen_case5,loads_case5), - 100.0, - 60.0) - - -################################################## -############### SOLVE PROBLEM #################### -################################################## - - -#Compute Y_bus after fault -Ybus_fault = PSY.Ybus(branch_case5_fault, nodes_case5)[:,:]; - -#Initialize variables -dx0 = zeros(LITS.get_total_rows(case5_DynSystem)) -x0 = [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 -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 Simulation Problem -sim = Simulation(case5_DynSystem, tspan, Ybus_fault, cb, x0_init) - -#Solve problem in equilibrium -run_simulation!(sim, IDA()); - -#Obtain data for angles -series = get_state_series(sim, (:Case5Gen, :δ)); - -@test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case6_DAIB.jl b/test/old_tests/test_case6_DAIB.jl deleted file mode 100644 index f8b85de..0000000 --- a/test/old_tests/test_case6_DAIB.jl +++ /dev/null @@ -1,153 +0,0 @@ -""" -Case 6: -This case study a 19-state virtual synchronous machine against an infinite bus located at bus 1, with VSM located at bus 2. -The perturbation increase the reference power (analogy for mechanical power) from 0.5 to 0.7. -""" - -################################################## -############### LOAD DATA ######################## -################################################## - -############### Data Network ######################## - -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) - -############### Data devices ######################## - -inf_gen_DAIB = StaticSource(1, #number - :InfBus, #name - nodes_DAIB[1],#bus - 1.00, #VR - 0.0, #VI - 0.000005) #Xth - -############### Inverter Data ######################## - -converter = AvgCnvFixedDC(690.0, #Rated Voltage - 2.75) #Rated MVA - -dc_source = FixedDCSource(600.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 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 - filt) #Output Filter - - -######################### Dynamical System ######################## - -DAIB = PSY.System(nodes_DAIB, branch_DAIB, [Darco_Inverter], [inf_gen_DAIB], 100.0, 50.0); - - -################################################## -############### SOLVE PROBLEM #################### -################################################## - -#Initialize variables -dx0 = zeros(LITS.get_total_rows(DAIB)) -x0 = [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 -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!) - -#Define Simulation Problem -sim = Simulation(DAIB, tspan, u0, cb, x0_init) - -#Solve problem in equilibrium -run_simulation!(sim, IDA()); - -#Obtain data for angles -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/old_tests/test_case7_4th_order_Inverter.jl deleted file mode 100644 index db86a66..0000000 --- a/test/old_tests/test_case7_4th_order_Inverter.jl +++ /dev/null @@ -1,218 +0,0 @@ -""" -Case 7: -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. -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 = [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_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)] - -#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)] - - -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)] - - -############### Data devices ######################## - -inf_gen_case7 = StaticSource(1, #number - :InfBus, #name - 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 = 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 = 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 ### -case7_no_tg = TGFixed(1.0) #eff - - -######## AVR Data ######### -### AVRs for Case 2, 3, 4 and 5 ### -case7_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 ### -case7_gen = PSY.DynamicGenerator(1, #Number - :Case7Gen, - nodes_case7[2], #bus - 1.0, # ω_ref, - 1.0142, #V_ref - 0.6, #P_ref - case7_machine, #machine - case7_shaft, #shaft - case7_avr, #avr - case7_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 - -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 ######################## - -case7_DynSystem = PSY.System(nodes_case7, branch_case7, [case7_inv, case7_gen], vcat(inf_gen_case7, loads_case7), 100.0, 50.0); - - -################################################## -############### SOLVE PROBLEM #################### -################################################## - -dx0 = zeros(LITS.get_total_rows(case7_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 - -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!) - -#Define Simulation Problem -sim = Simulation(case7_DynSystem, tspan, u0, cb, x0_init) - -#Solve problem in equilibrium -run_simulation!(sim, IDA()); - -#Obtain data for angles -series = get_state_series(sim, (:Case7Gen, :δ)); - -@test sim.solution.retcode == :Success diff --git a/test/old_tests/test_case8_staticbranches.jl b/test/old_tests/test_case8_staticbranches.jl deleted file mode 100644 index ff8013e..0000000 --- a/test/old_tests/test_case8_staticbranches.jl +++ /dev/null @@ -1,219 +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/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/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 new file mode 100644 index 0000000..f9fa548 --- /dev/null +++ b/test/test_case1_OMIB.jl @@ -0,0 +1,65 @@ +""" +Case 1: +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 = nodes_OMIB() + +branch_case1 = branches_OMIB(nodes_case1) + +#Trip of a single circuit of Line 1 -> Resistance and Reactance doubled. +branch_case1_fault = branches_OMIB_fault(nodes_case1) + +loads_case1 = loads_OMIB(nodes_case1) + +############### Data devices ######################## + +inf_gen_case1 = inf_gen_105_pu(nodes_case1) + +### Case 1 Generator ### + +case1_gen = dyn_gen_OMIB(nodes_case1) + +######################### Dynamical System ######################## + +#Create system with BasePower = 100 MVA and nominal frequency 60 Hz. +sys = system_no_inv(nodes_case1, branch_case1, loads_case1, [inf_gen_case1], [case1_gen]) + +################################################## +############### SOLVE PROBLEM #################### +################################################## + +#Compute Y_bus after fault +Ybus_fault = get_admittance_matrix(nodes_case1, branch_case1_fault) + +tspan = (0.0, 30.0); + +#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 + +#Solve problem in equilibrium +run_simulation!(sim, IDA(), dtmax = 0.02); + +#Obtain data for angles +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/test_case2_4th_order.jl b/test/test_case2_4th_order.jl new file mode 100644 index 0000000..757dc3b --- /dev/null +++ b/test/test_case2_4th_order.jl @@ -0,0 +1,100 @@ +""" +Case 2: +This case study a three bus system with 2 machines (One d- One q-: 4th order model) and an infinite source. +The fault drop the connection between buses 1 and 3, eliminating the direct connection between the infinite source +and the generator located in bus 3. +""" + +################################################## +############### LOAD DATA ######################## +################################################## + +############### Data Network ######################## + +nodes_case234 = nodes_3bus() + +branch_case234 = branches_3lines(nodes_case234) + +#Trip of Line 1. +branch_case234_fault = branches_3lines_fault(nodes_case234) + +loads_case234 = loads_3bus(nodes_case234) + +############### Data devices ######################## + +inf_gen_case234 = inf_gen_102_pu(nodes_case234) + +### Case 2 Generators ### + +case2_gen2 = dyn_gen2_case2(nodes_case234) + +case2_gen3 = dyn_gen3_case2(nodes_case234) + +######################### Dynamical System ######################## + +#Create system with BasePower = 100 MVA and nominal frequency 60 Hz. +sys = system_no_inv( + nodes_case234, + branch_case234, + loads_case234, + [inf_gen_case234], + [case2_gen2, case2_gen3], +) + +################################################## +############### SOLVE PROBLEM #################### +################################################## + +#Compute Y_bus after fault +Ybus_fault = get_admittance_matrix(nodes_case234, branch_case234_fault) + +#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 + +#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", :δ)); + +@test sim.solution.retcode == :Success diff --git a/test/test_case3_6th_order.jl b/test/test_case3_6th_order.jl new file mode 100644 index 0000000..839630b --- /dev/null +++ b/test/test_case3_6th_order.jl @@ -0,0 +1,104 @@ +""" +Case 3: +This case study a three bus system with 2 machines (Simple Marconato: 6th order model) and an infinite source. +The fault drop the connection between buses 1 and 3, eliminating the direct connection between the infinite source +and the generator located in bus 3. +""" + +################################################## +############### LOAD DATA ######################## +################################################## + +############### Data Network ######################## + +nodes_case234 = nodes_3bus() + +branch_case234 = branches_3lines(nodes_case234) + +#Trip of Line 1. +branch_case234_fault = branches_3lines_fault(nodes_case234) + +loads_case234 = loads_3bus(nodes_case234) + +############### Data devices ######################## + +inf_gen_case234 = inf_gen_102_pu(nodes_case234) + +### Case 3 Generators ### + +case3_gen2 = dyn_gen2_case3(nodes_case234) + +case3_gen3 = dyn_gen3_case3(nodes_case234) + +######################### Dynamical System ######################## + +#Create system with BasePower = 100 MVA and nominal frequency 60 Hz. +sys = system_no_inv( + nodes_case234, + branch_case234, + loads_case234, + [inf_gen_case234], + [case3_gen2, case3_gen3], +) + +################################################## +############### SOLVE PROBLEM #################### +################################################## + +#Compute Y_bus after fault +Ybus_fault = get_admittance_matrix(nodes_case234, branch_case234_fault) + +#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 + +#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, ("Case3Gen2", :δ)); + +@test sim.solution.retcode == :Success diff --git a/test/test_case4_8th_order.jl b/test/test_case4_8th_order.jl new file mode 100644 index 0000000..90b4c7d --- /dev/null +++ b/test/test_case4_8th_order.jl @@ -0,0 +1,108 @@ +""" +Case 4: +This case study a three bus system with 2 machines (Marconato: 8th order model) and an infinite source. +The fault drop the connection between buses 1 and 3, eliminating the direct connection between the infinite source +and the generator located in bus 3. +""" + +################################################## +############### LOAD DATA ######################## +################################################## + +############### Data Network ######################## + +nodes_case234 = nodes_3bus() + +branch_case234 = branches_3lines(nodes_case234) + +#Trip of Line 1. +branch_case234_fault = branches_3lines_fault(nodes_case234) + +loads_case234 = loads_3bus(nodes_case234) + +############### Data devices ######################## + +inf_gen_case234 = inf_gen_102_pu(nodes_case234) + +### Case 4 Generators ### + +case4_gen2 = dyn_gen2_case4(nodes_case234) + +case4_gen3 = dyn_gen3_case4(nodes_case234) + +######################### Dynamical System ######################## + +#Create system with BasePower = 100 MVA and nominal frequency 60 Hz. +sys = system_no_inv( + nodes_case234, + branch_case234, + loads_case234, + [inf_gen_case234], + [case4_gen2, case4_gen3], +) + +################################################## +############### SOLVE PROBLEM #################### +################################################## + +#Compute Y_bus after fault +Ybus_fault = get_admittance_matrix(nodes_case234, branch_case234_fault) + +#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 + +#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, ("Case4Gen2", :δ)); + +@test sim.solution.retcode == :Success diff --git a/test/test_case5_5shaft.jl b/test/test_case5_5shaft.jl new file mode 100644 index 0000000..7dc9be3 --- /dev/null +++ b/test/test_case5_5shaft.jl @@ -0,0 +1,93 @@ +""" +Case 5: +This case study a three bus system with 1 machine located at bus 2. +The generator uses the model of a one d- one q- machine, and has a 5-mass shaft and a turbine governor. +The fault disconnects a circuit between buses 1 and 2, doubling its impedance. +""" + +################################################## +############### LOAD DATA ######################## +################################################## + +############### Data Network ######################## + +nodes_case5 = nodes_3bus_case5() + +branch_case5 = branches_3lines_case5(nodes_case5) + +#Trip of a single circuit of Line 1 -> Resistance and Reactance doubled. +branch_case5_fault = branches_3lines_case5_fault(nodes_case5) + +loads_case5 = loads_3bus_case5(nodes_case5) + +############### Data devices ######################## + +inf_gen_case5 = inf_gen_1_pu(nodes_case5) + +### Case 5 Generator ### + +case5_gen = dyn_gen_case5(nodes_case5) + +######################### Dynamical System ######################## + +#Create system with BasePower = 100 MVA and nominal frequency 60 Hz. +sys = system_no_inv(nodes_case5, branch_case5, loads_case5, [inf_gen_case5], [case5_gen]) + +################################################## +############### SOLVE PROBLEM #################### +################################################## + +#Compute Y_bus after fault +Ybus_fault = get_admittance_matrix(nodes_case5, branch_case5_fault) + +#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 + +#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, ("Case5Gen", :δ)); + +@test sim.solution.retcode == :Success diff --git a/test/test_case6_DAIB.jl b/test/test_case6_DAIB.jl new file mode 100644 index 0000000..8b6f2d1 --- /dev/null +++ b/test/test_case6_DAIB.jl @@ -0,0 +1,76 @@ +""" +Case 6: +This case study a 19-state virtual synchronous machine against an infinite bus located at bus 1, with VSM located at bus 2. +The perturbation increase the reference power (analogy for mechanical power) from 0.5 to 0.7. +""" + +################################################## +############### LOAD DATA ######################## +################################################## + +############### Data Network ######################## + +nodes_DAIB = nodes_DArco_IB() + +branch_DAIB = branches_DArco_IB(nodes_DAIB) + +############### Data devices ######################## + +inf_gen_DAIB = inf_gen_1_pu(nodes_DAIB) + +############### Inverter Data ######################## + +Darco_Inverter = inv_DAIB(nodes_DAIB) + +######################### Dynamical System ######################## + +#Create system with BasePower = 100 MVA and nominal frequency 50 Hz. +sys = system_DAIB(nodes_DAIB, branch_DAIB, [inf_gen_DAIB], [Darco_Inverter]) + +################################################## +############### SOLVE PROBLEM #################### +################################################## + +#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 + 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) + +#Define Simulation Problem +sim = LITS.Simulation(sys, tspan, Pref_change, initial_guess = x0_guess) + +#Solve problem in equilibrium +run_simulation!(sim, Sundials.IDA()); + +#Obtain data for angles +series = get_state_series(sim, ("DARCO", :δω_vsm)) + +@test sim.solution.retcode == :Success diff --git a/test/test_case7_4th_order_Inverter.jl b/test/test_case7_4th_order_Inverter.jl new file mode 100644 index 0000000..f78d8eb --- /dev/null +++ b/test/test_case7_4th_order_Inverter.jl @@ -0,0 +1,101 @@ +""" +Case 7: +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. +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 = nodes_3bus() + +branch_case7 = branches_3lines(nodes_case7) + +#Trip of Line 1. +branch_case7_fault = branches_3lines_fault(nodes_case7) + +loads_case7 = loads_3bus_case7(nodes_case7) + +############### Data devices ######################## + +inf_gen_case7 = inf_gen_1_pu(nodes_case7) + +### Case 7 Generators ### + +case7_gen = dyn_gen_case7(nodes_case7) + +############### Inverter Data ######################## + +case7_inv = inv_case78(nodes_case7) + +######################### Dynamical System ######################## + +#Create system with BasePower = 100 MVA and nominal frequency 50 Hz. +sys = system_50Hz( + nodes_case7, + branch_case7, + loads_case7, + [inf_gen_case7], + [case7_inv], + [case7_gen], +) + +################################################## +############### SOLVE PROBLEM #################### +################################################## + +#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 + +#Define Fault using Callbacks +Pref_change = LITS.ControlReferenceChange(1.0, case7_gen, LITS.P_ref_index, 0.8) + +#Define Simulation Problem +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", :δ)); + +@test sim.solution.retcode == :Success diff --git a/test/test_case8_staticbranches.jl b/test/test_case8_staticbranches.jl new file mode 100644 index 0000000..d7873a0 --- /dev/null +++ b/test/test_case8_staticbranches.jl @@ -0,0 +1,118 @@ +""" +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 = 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) + +#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 + +#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 941fd59..e1183e8 100644 --- a/test/test_create_gen_component.jl +++ b/test/test_create_gen_component.jl @@ -1,242 +1,89 @@ -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, + 0.0, Basic, BaseShaft, proportional_avr, #avr @@ -248,10 +95,11 @@ end Gen1AVRnoAVR = PSY.DynamicGenerator( 1, #Number "TestGen", - nodes_OMIB[2],#bus + OMIB_nodes[2],#bus 1.0, # ω_ref, 1.05, 0.4, + 0.0, Basic, BaseShaft, fixed_avr, #avr @@ -263,10 +111,11 @@ end Gen2AVRnoAVR = PSY.DynamicGenerator( 1, #Number "TestGen", - nodes_OMIB[2],#bus + OMIB_nodes[2],#bus 1.0, # ω_ref, 1.02, 0.4, + 0.0, oneDoneQ, BaseShaft, fixed_avr, #avr @@ -278,10 +127,11 @@ end Gen2AVR = PSY.DynamicGenerator( 1, #Number "TestGen", - nodes_OMIB[2],#bus + OMIB_nodes[2],#bus 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..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,10 +26,11 @@ 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, + 0.0, Basic, BaseShaft, proportional_avr, #avr @@ -62,10 +41,11 @@ Gen1AVR = PSY.DynamicGenerator( Gen2AVR = PSY.DynamicGenerator( 1, #Number "TestGen2", - nodes_OMIB[2],#bus + OMIB_nodes[2],#bus 1.0, # ω_ref, 1.05, 0.4, + 0.0, Basic, BaseShaft, proportional_avr, #avr @@ -123,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 @@ -137,11 +117,10 @@ test_inverter = PSY.DynamicInverter( filt, ); #Output Filter - @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 @@ -151,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