Skip to content

Commit

Permalink
Add Test 59
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianManriqueM committed Sep 5, 2024
1 parent 05bd505 commit 3a3b6c7
Show file tree
Hide file tree
Showing 3 changed files with 194 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/results/results_eigenvalues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
25 changes: 25 additions & 0 deletions test/results/results_initial_conditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
)
157 changes: 157 additions & 0 deletions test/test_case59_st6b.jl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3a3b6c7

Please sign in to comment.