Skip to content

Commit ab492ce

Browse files
committed
FIX: bugs in transformer impedance and conductance calculations, kron reduction in lines, and delta connected loads vnom kv.
1 parent b6f5fe8 commit ab492ce

File tree

2 files changed

+74
-60
lines changed

2 files changed

+74
-60
lines changed

src/data_model/transformations/eng2math.jl

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -579,57 +579,57 @@ function _map_eng2math_switch!(data_math::Dict{String,<:Any}, data_eng::Dict{Str
579579
_apply_linecode!(eng_obj, data_eng)
580580
end
581581

582-
if !(all(isapprox.(get(eng_obj, "rs", zeros(1, 1)), 0)) && all(isapprox.(get(eng_obj, "xs", zeros(1, 1)), 0)))
583-
# build virtual bus
584-
585-
f_bus = deepcopy(data_math["bus"]["$(math_obj["f_bus"])"])
586-
t_bus = deepcopy(data_math["bus"]["$(math_obj["t_bus"])"])
587-
588-
N = length(eng_obj["t_connections"])
589-
bus_obj = Dict{String,Any}(
590-
"name" => "_virtual_bus.switch.$name",
591-
"bus_i" => length(data_math["bus"])+1,
592-
"bus_type" => eng_obj["status"] == DISABLED ? 4 : 1,
593-
"terminals" => eng_obj["t_connections"], # connected to the switch on the to-side
594-
"grounded" => fill(false, N), # connected to the switch on the to-side
595-
"vmin" => fill(0.0, N),
596-
"vmax" => fill(Inf, N),
597-
"vm_pair_lb" => Tuple{Any,Any,Real}[],
598-
"vm_pair_ub" => Tuple{Any,Any,Real}[],
599-
"source_id" => "switch.$name",
600-
"index" => length(data_math["bus"])+1,
601-
)
602-
603-
math_obj["t_bus"] = bus_obj["bus_i"]
604-
data_math["bus"]["$(bus_obj["index"])"] = bus_obj
605-
606-
branch_obj = _init_math_obj("line", name, eng_obj, length(data_math["branch"])+1)
607-
608-
_branch_obj = Dict{String,Any}(
609-
"name" => "_virtual_branch.switch.$name",
610-
"source_id" => "switch.$name",
611-
"f_bus" => bus_obj["bus_i"],
612-
"t_bus" => data_math["bus_lookup"][eng_obj["t_bus"]],
613-
"f_connections" => eng_obj["t_connections"], # the virtual branch connects to the switch on the to-side
614-
"t_connections" => eng_obj["t_connections"], # should be identical to the switch's to-side connections
615-
"br_r" => _impedance_conversion(data_eng, eng_obj, "rs"),
616-
"br_x" => _impedance_conversion(data_eng, eng_obj, "xs"),
617-
"g_fr" => _admittance_conversion(data_eng, eng_obj, "g_fr"),
618-
"g_to" => _admittance_conversion(data_eng, eng_obj, "g_to"),
619-
"b_fr" => _admittance_conversion(data_eng, eng_obj, "b_fr"),
620-
"b_to" => _admittance_conversion(data_eng, eng_obj, "b_to"),
621-
"angmin" => fill(-10.0, nphases),
622-
"angmax" => fill( 10.0, nphases),
623-
"c_rating_a" => fill(Inf, nphases),
624-
"br_status" => eng_obj["status"] == DISABLED ? 0 : 1,
625-
)
626-
627-
merge!(branch_obj, _branch_obj)
628-
629-
data_math["branch"]["$(branch_obj["index"])"] = branch_obj
630-
631-
map_to = [map_to, "bus.$(bus_obj["index"])", "branch.$(branch_obj["index"])"]
632-
end
582+
# if !(all(isapprox.(get(eng_obj, "rs", zeros(1, 1)), 0)) && all(isapprox.(get(eng_obj, "xs", zeros(1, 1)), 0)))
583+
# # build virtual bus
584+
585+
# f_bus = deepcopy(data_math["bus"]["$(math_obj["f_bus"])"])
586+
# t_bus = deepcopy(data_math["bus"]["$(math_obj["t_bus"])"])
587+
588+
# N = length(eng_obj["t_connections"])
589+
# bus_obj = Dict{String,Any}(
590+
# "name" => "_virtual_bus.switch.$name",
591+
# "bus_i" => length(data_math["bus"])+1,
592+
# "bus_type" => eng_obj["status"] == DISABLED ? 4 : 1,
593+
# "terminals" => eng_obj["t_connections"], # connected to the switch on the to-side
594+
# "grounded" => fill(false, N), # connected to the switch on the to-side
595+
# "vmin" => fill(0.0, N),
596+
# "vmax" => fill(Inf, N),
597+
# "vm_pair_lb" => Tuple{Any,Any,Real}[],
598+
# "vm_pair_ub" => Tuple{Any,Any,Real}[],
599+
# "source_id" => "switch.$name",
600+
# "index" => length(data_math["bus"])+1,
601+
# )
602+
603+
# math_obj["t_bus"] = bus_obj["bus_i"]
604+
# data_math["bus"]["$(bus_obj["index"])"] = bus_obj
605+
606+
# branch_obj = _init_math_obj("line", name, eng_obj, length(data_math["branch"])+1)
607+
608+
# _branch_obj = Dict{String,Any}(
609+
# "name" => "_virtual_branch.switch.$name",
610+
# "source_id" => "switch.$name",
611+
# "f_bus" => bus_obj["bus_i"],
612+
# "t_bus" => data_math["bus_lookup"][eng_obj["t_bus"]],
613+
# "f_connections" => eng_obj["t_connections"], # the virtual branch connects to the switch on the to-side
614+
# "t_connections" => eng_obj["t_connections"], # should be identical to the switch's to-side connections
615+
# "br_r" => _impedance_conversion(data_eng, eng_obj, "rs"),
616+
# "br_x" => _impedance_conversion(data_eng, eng_obj, "xs"),
617+
# "g_fr" => _admittance_conversion(data_eng, eng_obj, "g_fr"),
618+
# "g_to" => _admittance_conversion(data_eng, eng_obj, "g_to"),
619+
# "b_fr" => _admittance_conversion(data_eng, eng_obj, "b_fr"),
620+
# "b_to" => _admittance_conversion(data_eng, eng_obj, "b_to"),
621+
# "angmin" => fill(-10.0, nphases),
622+
# "angmax" => fill( 10.0, nphases),
623+
# "c_rating_a" => fill(Inf, nphases),
624+
# "br_status" => eng_obj["status"] == DISABLED ? 0 : 1,
625+
# )
626+
627+
# merge!(branch_obj, _branch_obj)
628+
629+
# data_math["branch"]["$(branch_obj["index"])"] = branch_obj
630+
631+
# map_to = [map_to, "bus.$(bus_obj["index"])", "branch.$(branch_obj["index"])"]
632+
# end
633633

634634
data_math["switch"]["$(math_obj["index"])"] = math_obj
635635

src/data_model/transformations/ravens2math.jl

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,19 @@ function _map_ravens2math_conductor!(data_math::Dict{String,<:Any}, data_ravens:
346346
wire_positions = spacinginfo_data["WireSpacingInfo.WirePositions"]
347347
num_of_wires = length(wire_positions)
348348

349+
# Kron reduce bus terminals by removing conn 4 based on number of wires
350+
if num_of_wires > nconds
351+
reduce = true
352+
end
353+
349354
# Coordinates
350355
x_coords = Vector{Float64}(undef, num_of_wires)
351356
y_coords = Vector{Float64}(undef, num_of_wires)
352357

353358
for i in 1:1:num_of_wires
354-
x_coords[i] = get(wire_positions[i], "WirePosition.xCoord", 0.0)
355-
y_coords[i] = get(wire_positions[i], "WirePosition.yCoord", 0.0)
359+
seq_num = wire_positions[i]["WirePosition.sequenceNumber"]
360+
x_coords[seq_num] = get(wire_positions[i], "WirePosition.xCoord", 0.0)
361+
y_coords[seq_num] = get(wire_positions[i], "WirePosition.yCoord", 0.0)
356362
end
357363

358364
# angular frequency
@@ -897,25 +903,29 @@ function _map_ravens2math_power_transformer!(data_math::Dict{String,<:Any}, data
897903
transf_star_impedance = get(transf_end_info[wdg_endNumber], "TransformerEndInfo.TransformerStarImpedance", Dict())
898904
r_s[wdg_endNumber][tank_id] = get(transf_end_info[wdg_endNumber], "TransformerEndInfo.r",
899905
get(transf_star_impedance, "TransformerStarImpedance.r", 0.0))
900-
r_s[wdg_endNumber][tank_id] = r_s[wdg_endNumber][tank_id]/ratios^2
901906

902907
# reactance computation
903908
x_sc[wdg_endNumber][tank_id] = get(transf_end_info[wdg_endNumber], "TransformerEndInfo.x",
904909
get(transf_star_impedance, "TransformerStarImpedance.x", 0.0))
905910
# -- alternative computation of xsc using sc tests
906911
if haskey(transf_end_info[wdg_endNumber], "TransformerEndInfo.EnergisedEndShortCircuitTests")
907912
leak_impedance_wdg = transf_end_info[wdg_endNumber]["TransformerEndInfo.EnergisedEndShortCircuitTests"][1]["ShortCircuitTest.leakageImpedance"]
908-
x_sc[wdg_endNumber][tank_id] = (sqrt((leak_impedance_wdg / zbase)^2 - ((r_s[wdg_endNumber][tank_id]*100.0 / zbase)*2)^2)/100.0)*zbase
913+
rs_pct = (r_s[wdg_endNumber][tank_id]/zbase)*100.0
914+
x_sc[wdg_endNumber][tank_id] = (sqrt((leak_impedance_wdg/zbase)^2 - (rs_pct+rs_pct)^2)/100)*zbase
909915
end
916+
917+
# RS and XSC computation based on ratios
918+
r_s[wdg_endNumber][tank_id] = r_s[wdg_endNumber][tank_id]/ratios^2
910919
x_sc[wdg_endNumber][tank_id] = (x_sc[wdg_endNumber][tank_id]/ratios^2)
911920

912921
# g_sh always with respect to wdg #1 always
913922
if wdg_endNumber == 1
914923
transf_end_noloadtest = get(transf_end_info[wdg_endNumber], "TransformerEndInfo.EnergisedEndNoLoadTests", [Dict()])
915924
loss = get(transf_end_noloadtest[1], "NoLoadTest.loss", 0.0)
916-
g_sh_tank = (loss*snom_wdg)/zbase
925+
g_sh_tank = (loss/(0.01*(snom_wdg/1000.0)))/zbase
917926
exct_current = get(transf_end_noloadtest[1], "NoLoadTest.excitingCurrent", 0.0)
918-
b_sh_tank = -((sqrt(abs((exct_current)^2 - (loss/(0.01*snom_wdg))^2)))/(100.0*zbase))
927+
cmag = sqrt(exct_current^2 - (loss*100.0/(0.01*(snom_wdg/1000.0)))^2)/100
928+
b_sh_tank = -(cmag*snom_wdg)/(vnom_wdg^2)
919929
# data is measured externally, but we now refer it to the internal side
920930
g_sh[tank_id] = g_sh_tank*ratios^2
921931
b_sh[tank_id] = b_sh_tank*ratios^2
@@ -1555,9 +1565,13 @@ function _map_ravens2math_energy_consumer!(data_math::Dict{String,<:Any}, data_r
15551565
end
15561566

15571567
# Correct (if needed) single-phase DELTA connections
1558-
if (math_obj["configuration"] == DELTA) && (nphases == 1)
1559-
math_obj["configuration"] = WYE
1560-
@warn "EnergyConsumer (load): $name has DELTA configuration but only 1 connection (phase). DELTA configurations must have at least 2 or 3 connections!. EnergyConsumer converted to WYE connection."
1568+
if (math_obj["configuration"] == DELTA)
1569+
math_obj["vnom_kv"] = math_obj["vnom_kv"]*sqrt(3)
1570+
if (nphases == 1)
1571+
math_obj["configuration"] = WYE
1572+
@warn "EnergyConsumer (load): $name has DELTA configuration but only 1 connection (phase). DELTA configurations must have at least 2 or 3 connections!. EnergyConsumer converted to WYE connection."
1573+
math_obj["vnom_kv"] = math_obj["vnom_kv"]/sqrt(3)
1574+
end
15611575
end
15621576

15631577
# Set status, dispatchable flag, and index

0 commit comments

Comments
 (0)