Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct tap transformer calculation #1034

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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

Check warning on line 597 in src/parsers/power_models_data.jl

View check run for this annotation

Codecov / codecov/patch

src/parsers/power_models_data.jl#L597

Added line #L597 was not covered by tests
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 @@
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

Check warning on line 619 in src/parsers/power_models_data.jl

View check run for this annotation

Codecov / codecov/patch

src/parsers/power_models_data.jl#L619

Added line #L619 was not covered by tests
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 @@
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

Check warning on line 640 in src/parsers/power_models_data.jl

View check run for this annotation

Codecov / codecov/patch

src/parsers/power_models_data.jl#L640

Added line #L640 was not covered by tests
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 @@
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

Check warning on line 662 in src/parsers/power_models_data.jl

View check run for this annotation

Codecov / codecov/patch

src/parsers/power_models_data.jl#L662

Added line #L662 was not covered by tests
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
Loading