From a723c8bfd2e2993ca2fb7a4dc944cd0f8600563f Mon Sep 17 00:00:00 2001 From: Rahmat Heidari Date: Sun, 16 Jun 2024 14:30:51 +1000 Subject: [PATCH 1/4] fix psse parser 3winding tranformer --- src/io/psse.jl | 66 +++++++++++++++++++------- test/data/pti/case3_2wtf_vmon0.raw | 33 +++++++++++++ test/data/pti/case4_3wtf_vnom0_cw2.raw | 33 +++++++++++++ test/data/pti/case4_3wtf_vnom0_cw3.raw | 33 +++++++++++++ test/psse.jl | 26 ++++++++++ 5 files changed, 175 insertions(+), 16 deletions(-) create mode 100644 test/data/pti/case3_2wtf_vmon0.raw create mode 100644 test/data/pti/case4_3wtf_vnom0_cw2.raw create mode 100644 test/data/pti/case4_3wtf_vnom0_cw3.raw diff --git a/src/io/psse.jl b/src/io/psse.jl index f377a0b6..4f50d137 100644 --- a/src/io/psse.jl +++ b/src/io/psse.jl @@ -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 + 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) @@ -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 + 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 @@ -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 @@ -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 + 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 + 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 + 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 @@ -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 diff --git a/test/data/pti/case3_2wtf_vmon0.raw b/test/data/pti/case3_2wtf_vmon0.raw new file mode 100644 index 00000000..a8bc21ee --- /dev/null +++ b/test/data/pti/case3_2wtf_vmon0.raw @@ -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 diff --git a/test/data/pti/case4_3wtf_vnom0_cw2.raw b/test/data/pti/case4_3wtf_vnom0_cw2.raw new file mode 100644 index 00000000..d05b042e --- /dev/null +++ b/test/data/pti/case4_3wtf_vnom0_cw2.raw @@ -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 \ No newline at end of file diff --git a/test/data/pti/case4_3wtf_vnom0_cw3.raw b/test/data/pti/case4_3wtf_vnom0_cw3.raw new file mode 100644 index 00000000..f02e6889 --- /dev/null +++ b/test/data/pti/case4_3wtf_vnom0_cw3.raw @@ -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 \ No newline at end of file diff --git a/test/psse.jl b/test/psse.jl index 6c4ddbe0..5306512c 100644 --- a/test/psse.jl +++ b/test/psse.jl @@ -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 From 42bc06d110fd090044c7f53a7bf2d07777f0a3e1 Mon Sep 17 00:00:00 2001 From: Rahmat Heidari Date: Sun, 16 Jun 2024 21:57:13 +1000 Subject: [PATCH 2/4] update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b8b4106f..0d7c965f 100644 --- a/README.md +++ b/README.md @@ -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 From a31253e2ec4c432d4a0297efe9d84f5712b49e6f Mon Sep 17 00:00:00 2001 From: Rahmat Heidari Date: Tue, 25 Jun 2024 13:29:37 +1000 Subject: [PATCH 3/4] transformer parser updated --- src/io/psse.jl | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/io/psse.jl b/src/io/psse.jl index 4f50d137..47f1c7a7 100644 --- a/src/io/psse.jl +++ b/src/io/psse.jl @@ -497,17 +497,20 @@ function _psse2pm_transformer!(pm_data::Dict, pti_data::Dict, import_all::Bool) 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" - 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 + if transformer["CW"] == 1 # "for off-nominal turns ratio in pu of winding bus base voltage" + # do nothing + elseif transformer["CW"] == 2 # "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)) + else + # do nothing end + else + error(_LOGGER, "psse data parsing error, unsupported value for `CW` on transformer") end - if import_all sub_data["cw"] = transformer["CW"] end @@ -631,14 +634,18 @@ function _psse2pm_transformer!(pm_data::Dict, pti_data::Dict, import_all::Bool) sub_data["shift"] = pop!(transformer, "ANG$m") # Unit Transformations - if transformer["CW"] != 1 # NOT "for off-nominal turns ratio in pu of winding bus base voltage" - 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 + if transformer["CW"] == 1 # "for off-nominal turns ratio in pu of winding bus base voltage" + # do nothing + elseif transformer["CW"] == 2 # "for winding voltage in kv" + 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) + else + # do nothing end + else + error(_LOGGER, "psse data parsing error, unsupported value for `CW` on transformer") end if import_all From 893cfdea1c607129dfd7b9754a841e3625f759f1 Mon Sep 17 00:00:00 2001 From: Rahmat Heidari Date: Mon, 1 Jul 2024 11:09:04 +1000 Subject: [PATCH 4/4] update psse.jl --- src/io/psse.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/io/psse.jl b/src/io/psse.jl index 47f1c7a7..356de551 100644 --- a/src/io/psse.jl +++ b/src/io/psse.jl @@ -434,7 +434,7 @@ function _psse2pm_transformer!(pm_data::Dict, pti_data::Dict, import_all::Bool) else br_r, br_x = transformer["R1-2"], transformer["X1-2"] end - if transformer["NOMV1"] == 0.0 + if isapprox(transformer["NOMV1"], 0.0) br_r *= (pm_data["baseMVA"] / transformer["SBASE1-2"]) br_x *= (pm_data["baseMVA"] / transformer["SBASE1-2"]) else @@ -453,7 +453,7 @@ 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." - if transformer["NOMV2"] == 0.0 + if isapprox(transformer["NOMV2"], 0.0) br_r *= transformer["WINDV2"]^2 br_x *= transformer["WINDV2"]^2 else @@ -484,7 +484,7 @@ function _psse2pm_transformer!(pm_data::Dict, pti_data::Dict, import_all::Bool) if sub_data["rate_c"] == 0.0 delete!(sub_data, "rate_c") end - + if import_all sub_data["windv1"] = transformer["WINDV1"] sub_data["windv2"] = transformer["WINDV2"] @@ -562,7 +562,7 @@ 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" - if transformer["NOMV1"] == 0.0 + if isapprox(transformer["NOMV1"], 0.0) br_r12 *= (pm_data["baseMVA"] / transformer["SBASE1-2"]) br_x12 *= (pm_data["baseMVA"] / transformer["SBASE1-2"]) else @@ -570,7 +570,7 @@ function _psse2pm_transformer!(pm_data::Dict, pti_data::Dict, import_all::Bool) br_x12 *= (transformer["NOMV1"] / _get_bus_value(bus_id1, "base_kv", pm_data))^2 * (pm_data["baseMVA"] / transformer["SBASE1-2"]) end - if transformer["NOMV2"] == 0.0 + if isapprox(transformer["NOMV2"], 0.0) br_r23 *= (pm_data["baseMVA"] / transformer["SBASE2-3"]) br_x23 *= (pm_data["baseMVA"] / transformer["SBASE2-3"]) else @@ -578,7 +578,7 @@ function _psse2pm_transformer!(pm_data::Dict, pti_data::Dict, import_all::Bool) 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 + if isapprox(transformer["NOMV3"], 0.0) br_r31 *= (pm_data["baseMVA"] / transformer["SBASE3-1"]) br_x31 *= (pm_data["baseMVA"] / transformer["SBASE3-1"]) else