Skip to content

Commit 70769ca

Browse files
ADD: center tap equivalence (#447)
* Add center tap equiv * FIX: Julia 1.6 compat * FIX: transformer test deepcopy * DOC: changelog --------- Co-authored-by: David M Fobes <dfobes@lanl.gov>
1 parent 9767b7d commit 70769ca

File tree

5 files changed

+195
-1
lines changed

5 files changed

+195
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## staged
44

5-
- none
5+
- Added transformation to remove center-tap (distribution) transformers and replace them with equivalenced lines
66

77
## v0.15.0
88

src/data_model/transformations/misc.jl

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,3 +784,102 @@ function join_lines!(data_eng::Dict{String,Any})
784784

785785
return data_eng
786786
end
787+
788+
789+
"""
790+
remove_distribution_transformers!(data_eng::Dict{String,<:Any})
791+
792+
Removes distribution transformers and replaces them with lines. The current version only
793+
supports distribution transformers supplying loads i.e. no lines between transformer and load.
794+
"""
795+
function remove_distribution_transformers!(data_eng::Dict{String,<:Any})
796+
if haskey(data_eng, "transformer")
797+
for (_, transformer) in data_eng["transformer"]
798+
buses = transformer["bus"]
799+
line_connections = [0 for i = 1:length(buses)]
800+
for (_, load) in data_eng["load"]
801+
if load["bus"] in buses
802+
indxs = findall(x->x==load["bus"], buses)
803+
for indx in indxs
804+
indx != 0 ? line_connections[indx] = 1 : nothing
805+
end
806+
end
807+
end
808+
for (_, line) in data_eng["line"]
809+
if line["f_bus"] in buses
810+
indxs = findall(x->x==line["f_bus"], buses)
811+
for indx in indxs
812+
indx != 0 ? line_connections[indx] = 0 : nothing
813+
end
814+
end
815+
if line["t_bus"] in buses
816+
indxs = findall(x->x==line["t_bus"], buses)
817+
for indx in indxs
818+
indx != 0 ? line_connections[indx] = 0 : nothing
819+
end
820+
end
821+
end
822+
if sum(line_connections) > 0
823+
if length(buses) == 3
824+
_equivalance_center_tap!(transformer, data_eng)
825+
elseif length(buses) == 2
826+
nothing
827+
end
828+
end
829+
end
830+
end
831+
end
832+
833+
834+
"""
835+
_equivalance_center_tap!(transformer::Dict{String,<:Any}, data_eng::Dict{String,<:Any})
836+
837+
Removes center tap transformers based on Eq. (1) from Kersting's paper
838+
'Center-Tapped Transformers and 120/240-V Secondary Models'
839+
Z0 = 0.5*r_t + j0.8*x_t
840+
"""
841+
function _equivalance_center_tap!(transformer, data_eng)
842+
name = string("_virtual.", transformer["name"])
843+
xs = transformer["xsc"][1] / 0.8
844+
rw = transformer["rw"][1] / 0.5
845+
data_eng["line"][name] = Dict{String,Any}(
846+
"status" => deepcopy(transformer["status"]),
847+
"length" => 1.0,
848+
"units" => "ft",
849+
"source_id" => transformer["source_id"],
850+
"t_connections" => transformer["connections"][1],
851+
"f_connections" => transformer["connections"][1],
852+
"f_bus" => transformer["bus"][1],
853+
"t_bus" => transformer["bus"][2],
854+
"name" => name,
855+
"rs" => fill(rw, 1, 1),
856+
"xs" => fill(xs, 1, 1),
857+
"g_fr" => fill(0.0, 1, 1),
858+
"g_to" => fill(0.0, 1, 1),
859+
"b_fr" => fill(0.0, 1, 1),
860+
"b_to" => fill(0.0, 1, 1),
861+
)
862+
buses = Dict()
863+
for bus in transformer["bus"]
864+
buses[bus] = Dict("name" => string("_virtual.", bus), "replace" => false)
865+
end
866+
for (id, load) in data_eng["load"]
867+
if load["bus"] in keys(buses)
868+
buses[load["bus"]]["replace"] = true
869+
_virtual_load = deepcopy(load)
870+
_virtual_load["connections"] = transformer["connections"][1]
871+
_virtual_load["vm_nom"] = transformer["vm_nom"][1]
872+
_virtual_load["configuration"] = WYE
873+
_virtual_load["pd_nom"] = [sum(_virtual_load["pd_nom"])]
874+
_virtual_load["qd_nom"] = [sum(_virtual_load["qd_nom"])]
875+
data_eng["load"][string("_virtual.", id)] = _virtual_load
876+
load["status"] = DISABLED
877+
end
878+
end
879+
for (id, bus) in buses
880+
if bus["replace"]
881+
data_eng["bus"][id]["terminals"] = transformer["connections"][1]
882+
end
883+
end
884+
data_eng["transformer"][transformer["name"]]["status"] = DISABLED
885+
end
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
clear
2+
3+
! Base Frequency
4+
Set DefaultBaseFrequency=60
5+
6+
! New Circuit
7+
New circuit.ut_trans
8+
~ BasekV=11 BaseMVA=0.1 pu=1.0 ISC3=9999999999 ISC1=9999999999
9+
10+
! Line Codes
11+
New LineCode.OH_3p nphases= 3 Units= mi
12+
~ Rmatrix= (1.191602 | 0.234849 1.191602 | 0.234849 0.234849 1.191602 )
13+
~ Xmatrix= (1.209452 | 0.489263 1.209452 | 0.489263 0.489263 1.209452 )
14+
New LineCode.OH_1p nphases= 1 Units= mi
15+
~ Rmatrix= (1.194260 )
16+
~ Xmatrix= (1.205420 )
17+
New LineCode.UG_3p nphases= 3 Units= mi
18+
~ Rmatrix= (1.009423 | 0.409732 1.009423 | 0.409732 0.409732 1.009423 )
19+
~ Xmatrix= (0.493164 | 0.100849 0.493164 | 0.100849 0.100849 0.493164 )
20+
~ Cmatrix= (286.101593 | 0.000000 286.101593 | 0.000000 0.000000 286.101593 )
21+
22+
! Lines
23+
New Line.LINE1 Bus1=SourceBus Bus2=1 phases=3
24+
~ length=10 units=Mi LineCode=OH_3p
25+
New Line.LINE2 Bus1=1 Bus2=2 phases=3
26+
~ length=5 units=Mi LineCode=UG_3p
27+
New Line.LINE3 Bus1=1 Bus2=3 phases=3
28+
~ length=6 units=Mi LineCode=OH_3p
29+
New Line.LINE4 Bus1=3.1.0 Bus2=4.1.0 phases=1
30+
~ length=4 units=Mi LineCode=OH_1p
31+
New Line.LINE5 Bus1=3.2.0 Bus2=5.2.0 phases=1
32+
~ length=6 units=Mi Rmatrix= (1.194260 ) Xmatrix= (1.205420 )
33+
New Line.LINE6 Bus1=1 Bus2=6 phases=3
34+
~ length=5 units=Mi LineCode=OH_3p
35+
36+
! Transformers
37+
New Transformer.T1 Phases=1 Windings=3 XHL=2.256 XHT=2.256 XLT=1.504
38+
~ wdg=1 bus=4.1.0 conn=wye kV=6.35085 kva=25 %R=0.665
39+
~ wdg=2 bus=4_L.1.0 conn=wye kV=0.120 kva=25 %R=1.33
40+
~ wdg=3 bus=4_L.0.2 conn=wye kV=0.120 kva=25 %R=1.33
41+
New Transformer.T2 Phases=1 Windings=3 XHL=2.256 XHT=2.256 XLT=1.504
42+
~ wdg=1 bus=5.2.0 conn=wye kV=6.35085 kva=25 %R=0.665
43+
~ wdg=2 bus=5_L.1.0 conn=wye kV=0.120 kva=25 %R=1.33
44+
~ wdg=3 bus=5_L.0.2 conn=wye kV=0.120 kva=25 %R=1.33
45+
New Transformer.T3 Phases=3 Windings=2 XHL=1.91
46+
~ wdg=1 bus=2.1.2.3.0 conn=wye kV=11 kva=75 %R=1.135
47+
~ wdg=2 bus=2_L.1.2.3.0 conn=wye kV=0.208 kva=75 %R=1.135
48+
New Transformer.T4 Phases=2 Windings=2 XHL=2.1
49+
~ wdg=1 bus=6.1.2 conn=delta kV=11 kva=75 %R=0.5
50+
~ wdg=2 bus=6_L.1.2 conn=delta kV=0.208 kva=75 %R=0.5
51+
52+
! Load
53+
New Load.L_6 phases=1 conn=delta bus1=6_L.1.2 kV=0.208 kW=5.040000000000000 Kvar=2.296291839688011
54+
New Load.L_2 phases=3 conn=wye bus1=2_L.1.2.3.0 kV=0.208 kW=14.096000000000000 Kvar=6.422327335762342
55+
New Load.L_4 phases=2 conn=wye bus1=4_L.1.2 kV=0.208 kW=3.125000000000000 Kvar=1.027137828683947
56+
New Load.L_5 phases=2 conn=wye bus1=5_L.1.2 kV=0.208 kW=4.458000000000000 Kvar=1.195107182990382
57+
58+
59+
60+
61+
! Set Voltage Bases
62+
Set voltagebases=[11 .208]
63+
Calcvoltagebases
64+
65+
! Solve network
66+
solve
67+

test/test_cases.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ test_gen_3ph_wye = parse_file("../test/data/en_validation_case_data/test_gen_3ph
6161
test_switch = parse_file("../test/data/en_validation_case_data/test_switch.dss", transformations=[remove_all_bounds!])
6262
test_gen_1ph_wye = parse_file("../test/data/en_validation_case_data/test_gen_1ph_wye.dss", transformations=[remove_all_bounds!])
6363
test_trans_dy = parse_file("../test/data/en_validation_case_data/test_trans_dy.dss", transformations=[remove_all_bounds!, transform_loops!])
64+
65+
# distribution transformer equivalent cases
66+
dist_transformer = parse_file("../test/data/opendss/dist_transformer.dss")

test/transformer.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,4 +383,29 @@
383383
@test all(isapprox.(result["solution"]["bus"]["tn_1"]["vm"], [1.045, 1.05]; atol=5E-3))
384384
end
385385
end
386+
387+
@testset "test center tap eq" begin
388+
@testset "trans_3w_center_tap" begin
389+
data = deepcopy(trans_3w_center_tap)
390+
remove_distribution_transformers!(data)
391+
392+
@test data["transformer"]["xfmr_1"]["status"] == ENABLED
393+
@test data["transformer"]["xfmr_2"]["status"] == ENABLED
394+
@test data["transformer"]["xfmr_3"]["status"] == ENABLED
395+
end
396+
397+
@testset "dist_transformer" begin
398+
data = deepcopy(dist_transformer)
399+
remove_distribution_transformers!(data)
400+
401+
result = solve_mc_pf(data, ACPUPowerModel, ipopt_solver; make_si=false)
402+
403+
@test data["transformer"]["t1"]["status"] == DISABLED
404+
@test data["transformer"]["t2"]["status"] == DISABLED
405+
@test norm(result["solution"]["bus"]["4"]["vm"]-[0.9990740842103211], Inf) <= 1.5E-5
406+
@test norm(result["solution"]["bus"]["4"]["va"]-[-0.39064739635881085], Inf) <= 0.1
407+
@test norm(result["solution"]["bus"]["4_l"]["vm"]-[0.9990723339621554], Inf) <= 1.5E-5
408+
@test norm(result["solution"]["bus"]["4_l"]["va"]-[-0.3907533731198626], Inf) <= 0.1
409+
end
410+
end
386411
end

0 commit comments

Comments
 (0)