diff --git a/test/results/results_eigenvalues.jl b/test/results/results_eigenvalues.jl index b37b79b4c..c7cb82601 100644 --- a/test/results/results_eigenvalues.jl +++ b/test/results/results_eigenvalues.jl @@ -971,3 +971,15 @@ test58_eigvals_GateFlag = [ -0.19849913626541832 + 0.17939599481963514im -0.04238523317744444 + 0.0im ] + +test59_eigvals = [ + -99.69916689593907 + 0.0im + -84.05122388240402 + 0.0im + -39.79684261365684 + 0.0im + -38.3444969887499 + 0.0im + -8.550153616541023 + 0.0im + -0.6772738854081002 - 8.637736379730404im + -0.6772738854081002 + 8.637736379730404im + -0.36823401395037775 - 0.5649228138733879im + -0.36823401395037775 + 0.5649228138733879im +] diff --git a/test/results/results_initial_conditions.jl b/test/results/results_initial_conditions.jl index d54376ab5..cb38572b8 100644 --- a/test/results/results_initial_conditions.jl +++ b/test/results/results_initial_conditions.jl @@ -1781,3 +1781,28 @@ test58_x0_init_GateFlag = Dict( 2.099999999999999 ], ) + +test59_x0_init = Dict( + "V_R" => [ + 1.05 + 1.0198615749401696 + 0.9817964461177487 + ], + "V_I" => [ + 0.0 + -0.01680380791834505 + -0.15145839832533242 + ], + "generator-102-1" => [ + 0.8084146853601003 + 0.5302614530689579 + 0.7288775579091268 + 0.7311890654084042 + 0.9615873122791483 + 1.0 + 1.0199999999999998 + 0.047279162537359226 + 0.0 + 2.153115531256307 + ], +) diff --git a/test/test_case59_st6b.jl b/test/test_case59_st6b.jl new file mode 100644 index 000000000..5ccb57311 --- /dev/null +++ b/test/test_case59_st6b.jl @@ -0,0 +1,157 @@ +""" +Validation PSSE/ST6B: +This case study defines a three bus system with an infinite bus, GENROU and a load. +The GENROU machine has connected an ST6B Excitation System. +The fault drop the line connecting the infinite bus and GENROU. +""" +################################################## +############### LOAD DATA ######################## +################################################## + +raw_file = joinpath(TEST_FILES_DIR, "benchmarks/psse/ST6B/ThreeBusMulti.raw") +dyr_file = joinpath(TEST_FILES_DIR, "benchmarks/psse/ST6B/ThreeBus_ST6B.dyr") +#csv_file = joinpath(TEST_FILES_DIR, "benchmarks/psse/ST6B/results_PSSe.csv") + +@testset "Test 59 ST6B ResidualModel" begin + path = joinpath(pwd(), "test-psse-ST6B") + !isdir(path) && mkdir(path) + try + # Define system + sys = System(raw_file, dyr_file) + for l in get_components(PSY.StandardLoad, sys) + transform_load_to_constant_impedance(l) + end + + # Define Simulation Problem + sim = Simulation( + ResidualModel, + sys, #system + path, + (0.0, 20.0), #time span + BranchTrip(1.0, Line, "BUS 1-BUS 2-i_1"), #Type of Fault + ) + + # Test Initial Condition + diff_val = [0.0] + res = get_init_values_for_comparison(sim) + for (k, v) in test59_x0_init + diff_val[1] += LinearAlgebra.norm(res[k] - v) + end + + @test diff_val[1] < 1e-3 + + # Obtain small signal results for initial conditions + small_sig = small_signal_analysis(sim) + eigs = small_sig.eigenvalues + @test small_sig.stable + + # Test Eigenvalues + @test LinearAlgebra.norm(eigs - test59_eigvals) < 1e-3 + + # Solve problem + @test execute!(sim, IDA(); dtmax = 0.005, saveat = 0.005) == + PSID.SIMULATION_FINALIZED + results = read_results(sim) + + # Obtain results + + t_psid, v2_psid = get_voltage_magnitude_series(results, 102) + _, v3_psid = get_voltage_magnitude_series(results, 103) + _, ω_psid = get_state_series(results, ("generator-102-1", :ω)) + _, Vf = get_field_voltage_series(results, "generator-102-1") + + #= + # Obtain PSSE results + M = get_csv_data(csv_file) + t_psse = M[:, 1] + v1_psse = M[:, 2] + v2_psse = M[:, 3] + v3_psse = M[:, 4] + v4_psse = M[:, 5] + ω_psse = M[:, 6] .+ 1.0 + efd_psse = M[:, 7] + + # Test Transient Simulation Results + + @test LinearAlgebra.norm(t_psid - round.(t_psse, digits = 3)) == 0.0 + @test LinearAlgebra.norm(v2_psid - v2_psse, Inf) <= 1e-3 + @test LinearAlgebra.norm(v3_psid - v3_psse, Inf) <= 1e-3 + @test LinearAlgebra.norm(ω_psid - ω_psse, Inf) <= 1e-3 + =# + finally + @info("removing test files") + rm(path; force = true, recursive = true) + end +end + +@testset "Test 59 ST6B MassMatrixModel" begin + path = joinpath(pwd(), "test-psse-ST6B") + !isdir(path) && mkdir(path) + try + # Define system + sys = System(raw_file, dyr_file) + for l in get_components(PSY.StandardLoad, sys) + transform_load_to_constant_impedance(l) + end + + # Define Simulation Problem + sim = Simulation( + MassMatrixModel, + sys, #system + path, + (0.0, 20.0), #time span + BranchTrip(1.0, Line, "BUS 1-BUS 2-i_1"), #Type of Fault + ) + + # Test Initial Condition + diff_val = [0.0] + res = get_init_values_for_comparison(sim) + for (k, v) in test59_x0_init + diff_val[1] += LinearAlgebra.norm(res[k] - v) + end + + @test diff_val[1] < 1e-3 + + # Obtain small signal results for initial conditions + small_sig = small_signal_analysis(sim) + eigs = small_sig.eigenvalues + @test small_sig.stable + + # Test Eigenvalues + @test LinearAlgebra.norm(eigs - test59_eigvals) < 1e-3 + + # Solve problem + @test execute!(sim, Rodas4(); dtmax = 0.005, saveat = 0.005) == + PSID.SIMULATION_FINALIZED + results = read_results(sim) + + # Obtain results + + t_psid, v2_psid = get_voltage_magnitude_series(results, 102) + _, v3_psid = get_voltage_magnitude_series(results, 103) + _, ω_psid = get_state_series(results, ("generator-102-1", :ω)) + _, Vf = get_field_voltage_series(results, "generator-102-1") + + #= + # Obtain PSSE results + M = get_csv_data(csv_file) + t_psse = M[:, 1] + v1_psse = M[:, 2] + v2_psse = M[:, 3] + v3_psse = M[:, 4] + v4_psse = M[:, 5] + ω_psse = M[:, 6] .+ 1.0 + efd_psse = M[:, 7] + + # Test Transient Simulation Results + + @test LinearAlgebra.norm(t_psid - round.(t_psse, digits = 3)) == 0.0 + @test LinearAlgebra.norm(v2_psid - v2_psse, Inf) <= 1e-3 + @test LinearAlgebra.norm(v3_psid - v3_psse, Inf) <= 1e-3 + @test LinearAlgebra.norm(ω_psid - ω_psse, Inf) <= 1e-3 + =# + finally + @info("removing test files") + rm(path; force = true, recursive = true) + end +end