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

Update psse parser for 3winding transformers #917

Merged
merged 4 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ The primary developer is Carleton Coffrin (@ccoffrin) with support from the foll
- Kaarthik Sundar (@kaarthiksundar) LANL, OBBT utility
- Mathieu Tanneau (@mtanneau) Georgia Tech, PTDF matrix computation
- Byron Tasseff (@tasseff) LANL, multi-infrastructure updates
- Rahmat Heidari (@hei06j) CSIRO, PSS(R)E data parser support


## Citing PowerModels
Expand Down
66 changes: 50 additions & 16 deletions src/io/psse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,13 @@ function _psse2pm_transformer!(pm_data::Dict, pti_data::Dict, import_all::Bool)
else
br_r, br_x = transformer["R1-2"], transformer["X1-2"]
end
br_r *= (transformer["NOMV1"]^2 / _get_bus_value(transformer["I"], "base_kv", pm_data)^2) * (pm_data["baseMVA"] / transformer["SBASE1-2"])
br_x *= (transformer["NOMV1"]^2 / _get_bus_value(transformer["I"], "base_kv", pm_data)^2) * (pm_data["baseMVA"] / transformer["SBASE1-2"])
if transformer["NOMV1"] == 0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of x == 0.0 I am wondering if isapprox(x, 0.0) would be more robust.

@odow, can you comment the the best practice in Julia for float equality tests?

br_r *= (pm_data["baseMVA"] / transformer["SBASE1-2"])
br_x *= (pm_data["baseMVA"] / transformer["SBASE1-2"])
else
br_r *= (transformer["NOMV1"]^2 / _get_bus_value(transformer["I"], "base_kv", pm_data)^2) * (pm_data["baseMVA"] / transformer["SBASE1-2"])
br_x *= (transformer["NOMV1"]^2 / _get_bus_value(transformer["I"], "base_kv", pm_data)^2) * (pm_data["baseMVA"] / transformer["SBASE1-2"])
end
end

# Zeq scaling for tap2 (see eq (4.21b) in PROGRAM APPLICATION GUIDE 1 in PSSE installation folder)
Expand All @@ -448,8 +453,13 @@ function _psse2pm_transformer!(pm_data::Dict, pti_data::Dict, import_all::Bool)
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
if transformer["NOMV2"] == 0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same note as above.

br_r *= transformer["WINDV2"]^2
br_x *= transformer["WINDV2"]^2
else
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
end
end
end

Expand Down Expand Up @@ -482,17 +492,22 @@ function _psse2pm_transformer!(pm_data::Dict, pti_data::Dict, import_all::Bool)
sub_data["nomv2"] = transformer["NOMV2"]
end

# Assumes CW = 1, namely, for off-nominal turns ratio in pu of windning bus base voltage
sub_data["tap"] = pop!(transformer, "WINDV1") / pop!(transformer, "WINDV2")
sub_data["shift"] = pop!(transformer, "ANG1")

# Unit Transformations
if transformer["CW"] != 1 # NOT "for off-nominal turns ratio in pu of winding bus base voltage"
sub_data["tap"] *= _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 transformer["CW"] == 2 # i.e. for winding voltage in kv
sub_data["tap"] *= _get_bus_value(transformer["J"], "base_kv", pm_data) / _get_bus_value(transformer["I"], "base_kv", pm_data)
elseif transformer["CW"] == 3 # "for off-nominal turns ratio in pu of nominal winding voltage, NOMV1, NOMV2 and NOMV3."
if !iszero(transformer["NOMV1"]) && !iszero(transformer["NOMV2"])
sub_data["tap"] *= (transformer["NOMV1"] / transformer["NOMV2"]) * (_get_bus_value(transformer["J"], "base_kv", pm_data) / _get_bus_value(transformer["I"], "base_kv", pm_data))
end
end
end


if import_all
sub_data["cw"] = transformer["CW"]
end
Expand Down Expand Up @@ -544,13 +559,29 @@ function _psse2pm_transformer!(pm_data::Dict, pti_data::Dict, import_all::Bool)

# Unit Transformations
if transformer["CZ"] != 1 # NOT "for resistance and reactance in pu on system MVA base and winding voltage base"
br_r12 *= (transformer["NOMV1"] / _get_bus_value(bus_id1, "base_kv", pm_data))^2 * (pm_data["baseMVA"] / transformer["SBASE1-2"])
br_r23 *= (transformer["NOMV2"] / _get_bus_value(bus_id2, "base_kv", pm_data))^2 * (pm_data["baseMVA"] / transformer["SBASE2-3"])
br_r31 *= (transformer["NOMV3"] / _get_bus_value(bus_id3, "base_kv", pm_data))^2 * (pm_data["baseMVA"] / transformer["SBASE3-1"])
if transformer["NOMV1"] == 0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same note as above.

br_r12 *= (pm_data["baseMVA"] / transformer["SBASE1-2"])
br_x12 *= (pm_data["baseMVA"] / transformer["SBASE1-2"])
else
br_r12 *= (transformer["NOMV1"] / _get_bus_value(bus_id1, "base_kv", pm_data))^2 * (pm_data["baseMVA"] / transformer["SBASE1-2"])
br_x12 *= (transformer["NOMV1"] / _get_bus_value(bus_id1, "base_kv", pm_data))^2 * (pm_data["baseMVA"] / transformer["SBASE1-2"])
end

br_x12 *= (transformer["NOMV1"] / _get_bus_value(bus_id1, "base_kv", pm_data))^2 * (pm_data["baseMVA"] / transformer["SBASE1-2"])
br_x23 *= (transformer["NOMV2"] / _get_bus_value(bus_id2, "base_kv", pm_data))^2 * (pm_data["baseMVA"] / transformer["SBASE2-3"])
br_x31 *= (transformer["NOMV3"] / _get_bus_value(bus_id3, "base_kv", pm_data))^2 * (pm_data["baseMVA"] / transformer["SBASE3-1"])
if transformer["NOMV2"] == 0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same note as above.

br_r23 *= (pm_data["baseMVA"] / transformer["SBASE2-3"])
br_x23 *= (pm_data["baseMVA"] / transformer["SBASE2-3"])
else
br_r23 *= (transformer["NOMV2"] / _get_bus_value(bus_id2, "base_kv", pm_data))^2 * (pm_data["baseMVA"] / transformer["SBASE2-3"])
br_x23 *= (transformer["NOMV2"] / _get_bus_value(bus_id2, "base_kv", pm_data))^2 * (pm_data["baseMVA"] / transformer["SBASE2-3"])
end

if transformer["NOMV3"] == 0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same note as above

br_r31 *= (pm_data["baseMVA"] / transformer["SBASE3-1"])
br_x31 *= (pm_data["baseMVA"] / transformer["SBASE3-1"])
else
br_r31 *= (transformer["NOMV3"] / _get_bus_value(bus_id3, "base_kv", pm_data))^2 * (pm_data["baseMVA"] / transformer["SBASE3-1"])
br_x31 *= (transformer["NOMV3"] / _get_bus_value(bus_id3, "base_kv", pm_data))^2 * (pm_data["baseMVA"] / transformer["SBASE3-1"])
end
end

# See "Power System Stability and Control", ISBN: 0-07-035958-X, Eq. 6.72
Expand Down Expand Up @@ -601,9 +632,12 @@ function _psse2pm_transformer!(pm_data::Dict, pti_data::Dict, import_all::Bool)

# Unit Transformations
if transformer["CW"] != 1 # NOT "for off-nominal turns ratio in pu of winding bus base voltage"
sub_data["tap"] /= _get_bus_value(bus_id, "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["NOMV$m"]
if transformer["CW"] == 2
sub_data["tap"] /= _get_bus_value(bus_id, "base_kv", pm_data)
elseif transformer["CW"] == 3 # "for off-nominal turns ratio in pu of nominal winding voltage, NOMV1, NOMV2 and NOMV3."
if !iszero(transformer["NOMV$m"])
sub_data["tap"] *= transformer["NOMV$m"] / _get_bus_value(bus_id, "base_kv", pm_data)
end
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate about what the correct semantics of this should be?

The way the code is organized seems risky to me. For example, what happens if transformer["CW"] == 3 and iszero(transformer["NOMV$m"]) == true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iszero(transformer["NOMV$m"]) == true means that the transformer winding m nominal voltage is the same as the bus base voltage it is connected to, i.e. _get_bus_value(bus_id, "base_kv", pm_data). So in the case of transformer["CW"] == 3, the tap value won't change. For when transformer["CW"] == 2, the winding voltage is in kv and does not need to account for transformer["NOMV$m"].

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the complexity of this sepecific section I suggest we re-write the code int he form,

if transformer["CW"] == 1
  ...
elseif transformer["CW"] == 2
  ...
elseif transformer["CW"] == 3
  ...
else
  error - unsupported value for "CW" on transformer ....
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation implemented. :)


Expand Down
33 changes: 33 additions & 0 deletions test/data/pti/case3_2wtf_vmon0.raw
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
0, 100.00, 33, 0, 1, 50.00 / PSS(R)E 33 RAW created by rawd33 MON, SEP 18 2023 13:45
Example
SOME ITEMS IS NOT SUPPORTED, PLEASE CHECK THE DOCS.
2,' ', 132.0000,1, 6, 6, 1,0.82852, -0.7009,1.10000,0.9000,1.1000,0.90000
3,' ', 132.0000,1, 6, 5, 1,0.93835, -2.1349,1.10000,0.9000,1.1000,0.90000
4,' ', 11.0000,3, 6, 6, 1,1.05000, 0.0000,1.1000,0.9000,1.10000,0.90000
0 / END OF BUS DATA, BEGIN LOAD DATA
2,'1 ',1, 6, 6, 15.000, 50.000, 0.000, 0.000, 0.000, 0.000, 1,1,0
0 / END OF LOAD DATA, BEGIN FIXED SHUNT DATA
0 / END OF FIXED SHUNT DATA, BEGIN GENERATOR DATA
4,'1 ', 18.352, 58.958, 400.000, 0.000,1.05000, 0, 100.000, 0.00000E+0, 2.00000E-1, 0.00000E+0, 0.00000E+0,1.00000,1, 100.0, 300.000, 0.000, 60,1.0000
0 / END OF GENERATOR DATA, BEGIN BRANCH DATA
2, 3,'1 ', 9.00000E-2, 1.60000E-1, 0.05000, 90.30, 99.30, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 60.00, 1,1.0000
0 / END OF BRANCH DATA, BEGIN TRANSFORMER DATA
3, 4, 0,'1 ',3,2,1, 0.00000E+0, 0.00000E+0,2,' ',1, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000,' '
0.00000E+0, 1.20000E-1, 100.00
1.00000, 0.000, 0.000, 100.00, 66.00, 0.00, 1, 0, 1.15003, 0.94999, 1.10000, 0.90000, 17, 0, 0.00000, 0.00000, 0.000
1.00000, 0.000
0 / END OF TRANSFORMER DATA, BEGIN AREA DATA
0 / END OF AREA DATA, BEGIN TWO-TERMINAL DC DATA
0 / END OF TWO-TERMINAL DC DATA, BEGIN VSC DC LINE DATA
0 / END OF VSC DC LINE DATA, BEGIN IMPEDANCE CORRECTION DATA
0 / END OF IMPEDANCE CORRECTION DATA, BEGIN MULTI-TERMINAL DC DATA
0 / END OF MULTI-TERMINAL DC DATA, BEGIN MULTI-SECTION LINE DATA
0 / END OF MULTI-SECTION LINE DATA, BEGIN ZONE DATA
0 / END OF ZONE DATA, BEGIN INTER-AREA TRANSFER DATA
0 / END OF INTER-AREA TRANSFER DATA, BEGIN OWNER DATA
0 / END OF OWNER DATA, BEGIN FACTS DEVICE DATA
0 / END OF FACTS DEVICE DATA, BEGIN SWITCHED SHUNT DATA
0 / END OF SWITCHED SHUNT DATA, BEGIN GNE DATA
0 / END OF GNE DATA, BEGIN INDUCTION MACHINE DATA
0 / END OF INDUCTION MACHINE DATA
Q
33 changes: 33 additions & 0 deletions test/data/pti/case4_3wtf_vnom0_cw2.raw
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
0, 100.0, 33, 0, 1, 50.0


1, 'BUS1 ', 380.0, 3, 1, 1, 1, 1.0, 0.0, 1.1, 0.9, 1.1, 0.9
2, 'BUS2 ', 110.0, 2, 1, 1, 1, 1.03828, -0.0017, 1.1, 0.9, 1.1, 0.9
81, 'BUS81 ', 30.0, 1, 1, 1, 1, 0.95156, -150.4438, 1.1, 0.9, 1.1, 0.9
0 / END OF BUS DATA, BEGIN LOAD DATA
81, '1 ', 1, 1, 1, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 1, 0
0 / END OF LOAD DATA, BEGIN FIXED SHUNT DATA
0 / END OF FIXED SHUNT DATA, BEGIN GENERATOR DATA
1, 'Q1', 0.05, -2.757, 100.0, -100.0, 1.0, 1, 100.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1, 100.0, 100.0, 0.0, 1, 1.0, 0, 1.0, 0, 1.0, 0, 1.0, 0, 1.0
0 / END OF GENERATOR DATA, BEGIN BRANCH DATA
0 / END OF BRANCH DATA, BEGIN TRANSFORMER DATA
1, 2, 81, 'T4', 2, 2, 1, 0.0, 0.0, 2, 'T4 ', 1, 1, 1.0, 0, 1.0, 0, 1.0, 0, 1.0, ' '
0.0026, 0.209984, 350.0, 0.0016, 0.0699817, 50.0, 0.0016, 0.0999872, 50.0, 0.95174, -0.001
400.0, 0.0, 0.0, 350.0, 0.0, 0.0, 0, 0, 1.1, 0.9, 1.1, 0.9, 33, 0, 0.0, 0.0, 0.0
120.0, 0.0, 0.0, 50.0, 0.0, 0.0, 0, 0, 1.1, 0.9, 1.1, 0.9, 33, 0, 0.0, 0.0, 0.0
30.0, 0.0, -30.0, 50.0, 0.0, 0.0, 0, 0, 1.1, 0.9, 1.1, 0.9, 33, 0, 0.0, 0.0, 0.0
0 / END OF TRANSFORMER DATA, BEGIN AREA DATA
0 / END OF AREA DATA, BEGIN TWO-TERMINAL DC DATA
0 / END OF TWO-TERMINAL DC DATA, BEGIN VOLTAGE SOURCE CONVERTER DATA
0 / END OF VOLTAGE SOURCE CONVERTER DATA, BEGIN IMPEDANCE CORRECTION DATA
0 / END OF IMPEDANCE CORRECTION DATA, BEGIN MULTI-TERMINAL DC DATA
0 / END OF MULTI-TERMINAL DC DATA, BEGIN MULTI-SECTION LINE DATA
0 / END OF MULTI-SECTION LINE DATA, BEGIN ZONE DATA
0 / END OF ZONE DATA, BEGIN INTER-AREA TRANSFER DATA
0 / END OF INTER-AREA TRANSFER DATA, BEGIN OWNER DATA
0 / END OF OWNER DATA, BEGIN FACTS CONTROL DEVICE DATA
0 / END OF FACTS CONTROL DEVICE DATA, BEGIN SWITCHED SHUNT DATA
0 / END OF SWITCHED SHUNT DATA, BEGIN GNE DEVICE DATA
0 / END OF GNE DEVICE DATA, BEGIN INDUCTION MACHINE DATA
0 / END INDUCTION MACHINE DATA
Q
33 changes: 33 additions & 0 deletions test/data/pti/case4_3wtf_vnom0_cw3.raw
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
0, 100.0, 33, 0, 1, 50.0


1, 'BUS1 ', 380.0, 3, 1, 1, 1, 1.0, 0.0, 1.1, 0.9, 1.1, 0.9
2, 'BUS2 ', 110.0, 2, 1, 1, 1, 1.03828, -0.0017, 1.1, 0.9, 1.1, 0.9
81, 'BUS81 ', 30.0, 1, 1, 1, 1, 0.95156, -150.4438, 1.1, 0.9, 1.1, 0.9
0 / END OF BUS DATA, BEGIN LOAD DATA
81, '1 ', 1, 1, 1, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 1, 0
0 / END OF LOAD DATA, BEGIN FIXED SHUNT DATA
0 / END OF FIXED SHUNT DATA, BEGIN GENERATOR DATA
1, 'Q1', 0.05, -2.757, 100.0, -100.0, 1.0, 1, 100.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1, 100.0, 100.0, 0.0, 1, 1.0, 0, 1.0, 0, 1.0, 0, 1.0, 0, 1.0
0 / END OF GENERATOR DATA, BEGIN BRANCH DATA
0 / END OF BRANCH DATA, BEGIN TRANSFORMER DATA
1, 2, 81, 'T4', 3, 2, 1, 0.0, 0.0, 2, 'T4 ', 1, 1, 1.0, 0, 1.0, 0, 1.0, 0, 1.0, ' '
0.0026, 0.209984, 350.0, 0.0016, 0.0699817, 50.0, 0.0016, 0.0999872, 50.0, 0.95174, -0.001
1.0, 0.0, 0.0, 350.0, 0.0, 0.0, 0, 0, 1.1, 0.9, 1.1, 0.9, 33, 0, 0.0, 0.0, 0.0
1.0, 0.0, 0.0, 50.0, 0.0, 0.0, 0, 0, 1.1, 0.9, 1.1, 0.9, 33, 0, 0.0, 0.0, 0.0
1.0, 0.0, -30.0, 50.0, 0.0, 0.0, 0, 0, 1.1, 0.9, 1.1, 0.9, 33, 0, 0.0, 0.0, 0.0
0 / END OF TRANSFORMER DATA, BEGIN AREA DATA
0 / END OF AREA DATA, BEGIN TWO-TERMINAL DC DATA
0 / END OF TWO-TERMINAL DC DATA, BEGIN VOLTAGE SOURCE CONVERTER DATA
0 / END OF VOLTAGE SOURCE CONVERTER DATA, BEGIN IMPEDANCE CORRECTION DATA
0 / END OF IMPEDANCE CORRECTION DATA, BEGIN MULTI-TERMINAL DC DATA
0 / END OF MULTI-TERMINAL DC DATA, BEGIN MULTI-SECTION LINE DATA
0 / END OF MULTI-SECTION LINE DATA, BEGIN ZONE DATA
0 / END OF ZONE DATA, BEGIN INTER-AREA TRANSFER DATA
0 / END OF INTER-AREA TRANSFER DATA, BEGIN OWNER DATA
0 / END OF OWNER DATA, BEGIN FACTS CONTROL DEVICE DATA
0 / END OF FACTS CONTROL DEVICE DATA, BEGIN SWITCHED SHUNT DATA
0 / END OF SWITCHED SHUNT DATA, BEGIN GNE DEVICE DATA
0 / END OF GNE DEVICE DATA, BEGIN INDUCTION MACHINE DATA
0 / END INDUCTION MACHINE DATA
Q
26 changes: 26 additions & 0 deletions test/psse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,32 @@ end
end

end


@testset "with nomV=0 cw=2" begin
data = PowerModels.parse_file("../test/data/pti/case4_3wtf_vnom0_cw2.raw")

opf = PowerModels.solve_opf(data, PowerModels.ACPPowerModel, nlp_solver)
@test opf["termination_status"] == LOCALLY_SOLVED
@test isapprox(opf["objective"], 5.00079; atol=1e-3)
end

@testset "with nomV=0 cw=3" begin
data = PowerModels.parse_file("../test/data/pti/case4_3wtf_vnom0_cw3.raw")

opf = PowerModels.solve_opf(data, PowerModels.ACPPowerModel, nlp_solver)
@test opf["termination_status"] == LOCALLY_SOLVED
@test isapprox(opf["objective"], 5.00079; atol=1e-3)
end

@testset "2-windning transformer with nomV=0 cw=3" begin
data = PowerModels.parse_file("../test/data/pti/case3_2wtf_vmon0.raw")

opf = PowerModels.solve_opf(data, PowerModels.ACPPowerModel, nlp_solver)
@test opf["termination_status"] == LOCALLY_SOLVED
@test isapprox(opf["objective"], 17.5101; atol=1e-3)
end

end

@testset "transformer magnetizing admittance" begin
Expand Down
Loading