Skip to content

Commit

Permalink
UPD: unit tests to use dss outputs as test values
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudocubic committed Jan 23, 2023
1 parent 2fc1f97 commit a2f9aee
Showing 1 changed file with 49 additions and 17 deletions.
66 changes: 49 additions & 17 deletions test/line_constants.jl
Original file line number Diff line number Diff line change
@@ -1,29 +1,61 @@
@testset "line constants" begin
eng = parse_file("../test/data/opendss/IEEE13_Assets.dss")

z = [0.000211485 9.80031e-5 9.61061e-5; 9.80031e-5 0.000217924 9.93019e-5; 9.61061e-5 9.93019e-5 0.000213946] + 1im * [0.000653882 0.000299058 0.000241464; 0.000299058 0.000632756 0.000273149; 0.000241464 0.000273149 0.000645754]
y = [0 0 0; 0 0 0; 0 0 0] + 1im * [0.00961103 -0.00291349 -0.00123061; -0.00291349 0.0103004 -0.00230101; -0.00123061 -0.00230101 0.0093989]
z = [
0.000211485 9.80031e-5 9.61061e-5;
9.80031e-5 0.000217924 9.93019e-5;
9.61061e-5 9.93019e-5 0.000213946
] + 1im * [
0.000653882 0.000299058 0.000241464;
0.000299058 0.000632756 0.000273149;
0.000241464 0.000273149 0.000645754
]
y = [
0 0 0;
0 0 0;
0 0 0
] + 1im * [
0.00961082 -0.00291343 -0.00123058;
-0.00291343 0.0103002 -0.00230096;
-0.00123058 -0.00230096 0.00939874
]

@test all(isapprox.(eng["line"]["650632"]["rs"] + 1im * eng["line"]["650632"]["xs"], z; atol=1e-4))
@test all(isapprox.(eng["line"]["650632"]["g_fr"].*2 + 1im * eng["line"]["650632"]["b_fr"].*2, y; atol=1e-4))

z = [0.000495446 0.000201749 0.000180103; 0.000201749 0.000489627 0.000201749; 0.000180103 0.000201749 0.000495446] + 1im * [-0.000280292 1.5444e-5 -1.4004e-5; 1.5444e-5 -0.000307078 1.5444e-5; -1.4004e-5 1.5444e-5 -0.000280292]
y = [0 0 0; 0 0 0; 0 0 0] + 1im * [0.0 0.0 0.0; 0.0 0.0 0.0; 0.0 0.0 0.0]

@test all(isapprox.(eng["line"]["692675"]["rs"] + 1im * eng["line"]["692675"]["xs"], z; atol=1e-4))
@test all(isapprox.(eng["line"]["692675"]["g_fr"].*2 + 1im * eng["line"]["692675"]["b_fr"].*2, y; atol=1e-4))

z = [0.000805623042762814;;] + 1im * [-0.00012323041308967396;;]
y = [0;;] + 1im * [0.0;;]

@test all(isapprox.(eng["line"]["684652"]["rs"] + 1im * eng["line"]["684652"]["xs"], z; atol=1e-4))
@test all(isapprox.(eng["line"]["684652"]["g_fr"].*2 + 1im * eng["line"]["684652"]["b_fr"].*2, y; atol=1e-4))
z = [
0.000491885 0.000198743 0.000177491;
0.000198743 0.000486187 0.000198743;
0.000177491 0.000198743 0.000491885
] + 1im * [
0.00027695 1.99955e-5 -9.24851e-6;
1.99955e-5 0.000250698 1.99955e-5;
-9.24851e-6 1.99955e-5 0.00027695
]
y = [
0 0 0;
0 0 0;
0 0 0
] + 1im * [
0.238581 0.0 0.0;
0.0 0.238581 0.0;
0.0 0.0 0.238581
]

@test all(isapprox.(eng["line"]["692675"]["rs"] + 1im * eng["line"]["692675"]["xs"], z; atol=1e-5))
@test all(isapprox.(eng["line"]["692675"]["g_fr"].*2 + 1im * eng["line"]["692675"]["b_fr"].*2, y; atol=1e-5))

z = [0.000802907;;] + 1im * [0.000429279;;]
y = [0;;] + 1im * [0.166359;;]

@test all(isapprox.(eng["line"]["684652"]["rs"] + 1im * eng["line"]["684652"]["xs"], z; atol=1e-5))
@test all(isapprox.(eng["line"]["684652"]["g_fr"].*2 + 1im * eng["line"]["684652"]["b_fr"].*2, y; atol=1e-5))

r = solve_mc_pf(eng, ACRUPowerModel, ipopt_solver; make_si=false, solution_processors=[sol_data_model!])

@test all(isapprox.(r["solution"]["bus"]["652"]["vm"], [0.977265]; atol=1e-4))
@test all(isapprox.(r["solution"]["bus"]["652"]["va"], [-5.5489]; atol=1e-2))
@test all(isapprox.(r["solution"]["bus"]["652"]["vm"], [0.974806]; atol=1e-4))
@test all(isapprox.(r["solution"]["bus"]["652"]["va"], [-5.35]; atol=1e-0))

@test all(isapprox.(r["solution"]["bus"]["675"]["vm"], [0.976462, 1.04466, 0.985318]; atol=1e-4))
@test all(isapprox.(r["solution"]["bus"]["675"]["va"], [-5.55622, -121.977, 116.092]; atol=1e-2))
@test all(isapprox.(r["solution"]["bus"]["675"]["vm"], [0.975987, 1.04705, 0.984996]; atol=1e-4))
@test all(isapprox.(r["solution"]["bus"]["675"]["va"], [-5.52, -121.71, 116.03]; atol=1e-0))
end

0 comments on commit a2f9aee

Please sign in to comment.