Skip to content

Commit

Permalink
Merge pull request #1034 from NREL-Sienna/jd/fix_tap_transformer_calc…
Browse files Browse the repository at this point in the history
…ulations

correct tap transformer calculation
  • Loading branch information
jd-lara authored Dec 20, 2023
2 parents 42be5d6 + f34e9aa commit 06080a9
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 33 deletions.
75 changes: 47 additions & 28 deletions src/parsers/pm_io/psse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -455,36 +455,40 @@ function _psse2pm_transformer!(pm_data::Dict, pti_data::Dict, import_all::Bool)
if transformer["CW"] == 1 # "for off-nominal turns ratio in pu of winding bus base voltage"
br_r *= transformer["WINDV2"]^2
br_x *= transformer["WINDV2"]^2
else # NOT "for off-nominal turns ratio in pu of winding bus base voltage"
if transformer["CW"] == 2 # "for winding voltage in kV"
br_r *=
(
transformer["WINDV2"] /
_get_bus_value(transformer["J"], "base_kv", pm_data)
)^2
br_x *=
(
transformer["WINDV2"] /
_get_bus_value(transformer["J"], "base_kv", pm_data)
)^2
else # "for off-nominal turns ratio in pu of nominal winding voltage, NOMV1, NOMV2 and NOMV3."
br_r *=
(
transformer["WINDV2"] * (
transformer["NOMV2"] /
_get_bus_value(transformer["J"], "base_kv", pm_data)
)
)^2
br_x *=
(
transformer["WINDV2"] * (
transformer["NOMV2"] /
_get_bus_value(transformer["J"], "base_kv", pm_data)
)
)^2
# NOT "for off-nominal turns ratio in pu of winding bus base voltage"
elseif transformer["CW"] == 2 # "for winding voltage in kV"
br_r *=
(
transformer["WINDV2"] /
_get_bus_value(transformer["J"], "base_kv", pm_data)
)^2
br_x *=
(
transformer["WINDV2"] /
_get_bus_value(transformer["J"], "base_kv", pm_data)
)^2
elseif transformer["CW"] == 3 # "for off-nominal turns ratio in pu of nominal winding voltage, NOMV1, NOMV2 and NOMV3."
#The nominal (rated) Winding 2 voltage base in kV, or zero to indicate
# that nominal Winding 2 voltage is assumed to be identical to the base
# voltage of bus J. NOMV2 is used in converting tap ratio data between values
# in per unit of nominal Winding 2 voltage and values in per unit of Winding 2
#bus base voltage when CW is 3. NOMV2 = 0.0 by default.
if iszero(transformer["NOMV2"])
nominal_voltage_ratio = 1.0
else
nominal_voltage_ratio =
transformer["NOMV2"] /
_get_bus_value(transformer["J"], "base_kv", pm_data)
end

br_r *= (transformer["WINDV2"] * (nominal_voltage_ratio))^2
br_x *= (transformer["WINDV2"] * (nominal_voltage_ratio))^2
else
error("invalid transformer $(transformer["CW"])")
end

@info br_x
@assert transformer["X1-2"] > 0.0 && br_x > 0.0
sub_data["br_r"] = br_r
sub_data["br_x"] = br_x

Expand Down Expand Up @@ -523,7 +527,22 @@ function _psse2pm_transformer!(pm_data::Dict, pti_data::Dict, import_all::Bool)
_get_bus_value(transformer["J"], "base_kv", pm_data) /
_get_bus_value(transformer["I"], "base_kv", pm_data)
if transformer["CW"] == 3 # "for off-nominal turns ratio in pu of nominal winding voltage, NOMV1, NOMV2 and NOMV3."
sub_data["tap"] *= transformer["NOMV1"] / transformer["NOMV2"]
if iszero(transformer["NOMV1"])
winding1_nominal_voltage =
_get_bus_value(transformer["I"], "base_kv", pm_data)
else
winding1_nominal_voltage = transformer["NOMV1"]
end

if iszero(transformer["NOMV2"])
winding2_nominal_voltage =
_get_bus_value(transformer["J"], "base_kv", pm_data)
else
winding2_nominal_voltage = transformer["NOMV2"]
end

sub_data["tap"] *=
winding1_nominal_voltage / winding2_nominal_voltage
end
end

Expand Down
29 changes: 24 additions & 5 deletions src/parsers/power_models_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,14 @@ end
function make_line(name, d, bus_f, bus_t)
pf = get(d, "pf", 0.0)
qf = get(d, "qf", 0.0)

available_value = d["br_status"] == 1
if get_bustype(bus_f) == ACBusTypes.ISOLATED ||
get_bustype(bus_t) == ACBusTypes.ISOLATED
available_value = false
end
return Line(;
name = name,
available = d["br_status"] == 1,
available = available_value,
active_power_flow = pf,
reactive_power_flow = qf,
arc = Arc(bus_f, bus_t),
Expand All @@ -609,9 +613,14 @@ end
function make_transformer_2w(name, d, bus_f, bus_t)
pf = get(d, "pf", 0.0)
qf = get(d, "qf", 0.0)
available_value = d["br_status"] == 1
if get_bustype(bus_f) == ACBusTypes.ISOLATED ||
get_bustype(bus_t) == ACBusTypes.ISOLATED
available_value = false
end
return Transformer2W(;
name = name,
available = d["br_status"] == 1,
available = available_value,
active_power_flow = pf,
reactive_power_flow = qf,
arc = Arc(bus_f, bus_t),
Expand All @@ -625,9 +634,14 @@ end
function make_tap_transformer(name, d, bus_f, bus_t)
pf = get(d, "pf", 0.0)
qf = get(d, "qf", 0.0)
available_value = d["br_status"] == 1
if get_bustype(bus_f) == ACBusTypes.ISOLATED ||
get_bustype(bus_t) == ACBusTypes.ISOLATED
available_value = false
end
return TapTransformer(;
name = name,
available = d["br_status"] == 1,
available = available_value,
active_power_flow = pf,
reactive_power_flow = qf,
arc = Arc(bus_f, bus_t),
Expand All @@ -642,9 +656,14 @@ end
function make_phase_shifting_transformer(name, d, bus_f, bus_t, alpha)
pf = get(d, "pf", 0.0)
qf = get(d, "qf", 0.0)
available_value = d["br_status"] == 1
if get_bustype(bus_f) == ACBusTypes.ISOLATED ||
get_bustype(bus_t) == ACBusTypes.ISOLATED
available_value = false
end
return PhaseShiftingTransformer(;
name = name,
available = d["br_status"] == 1,
available = available_value,
active_power_flow = pf,
reactive_power_flow = qf,
arc = Arc(bus_f, bus_t),
Expand Down

0 comments on commit 06080a9

Please sign in to comment.