From e5f18cc8028750a5585cefb2247e5b4ac83968b7 Mon Sep 17 00:00:00 2001 From: David M Fobes Date: Wed, 18 Sep 2024 09:11:35 -0600 Subject: [PATCH] FIX: switches should not have length In ENGINEERING model, switches should be zero-length objects. Resolved this by applying length/linecode in the dss2eng parse stage. Resolves #462 --- CHANGELOG.md | 1 + src/data_model/transformations/dss2eng.jl | 24 +++++++++++++++++++++-- test/opendss.jl | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da2187590..9b6c0d8f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## staged +- Fixed creation of switch objects from dss, where ENGINEERING switches are expected to be zero-length objects (#462) - Fixed typo in single phase line parameters, should have been `line.c0 = line.c1` (#468) - Fixed missing `npts` property in loadshape in case3_balanced.dss (#466) - Fixed typo in unit tests 'blanced' to 'balanced' (#461) diff --git a/src/data_model/transformations/dss2eng.jl b/src/data_model/transformations/dss2eng.jl index d262c5699..ca68b4544 100644 --- a/src/data_model/transformations/dss2eng.jl +++ b/src/data_model/transformations/dss2eng.jl @@ -492,8 +492,28 @@ function _dss2eng_line!(data_eng::Dict{String,<:Any}, data_dss::OpenDssDataModel end if dss_obj["switch"] - eng_obj["state"] = CLOSED - eng_obj["dispatchable"] = YES + eng_obj["state"] = eng_obj["status"] == ENABLED ? CLOSED : OPEN + eng_obj["dispatchable"] = YES # default + eng_obj["status"] = ENABLED + + if haskey(eng_obj, "linecode") + _apply_linecode!(eng_obj, data_eng) + end + delete!(eng_obj, "linecode") + + # ENGINEERING model switches are zero-length objects + for k in ["b_fr", "b_to", "g_fr", "g_to"] + if haskey(eng_obj, k) + _admittance_conversion(data_eng, eng_obj, k) + end + end + + for k in ["rs", "xs"] + if haskey(eng_obj, k) + eng_obj[k] = _impedance_conversion(data_eng, eng_obj, k) + end + end + delete!(eng_obj, "length") _add_eng_obj!(data_eng, "switch", id, eng_obj) else diff --git a/test/opendss.jl b/test/opendss.jl index ec651c643..415d81e45 100644 --- a/test/opendss.jl +++ b/test/opendss.jl @@ -133,7 +133,7 @@ @testset "opendss parse switch length verify" begin @testset "branches with switches" begin - @test eng["switch"]["_l4"]["length"] == 0.001 + @test dss["line"]["_l4"]["length"] == 0.001 @test !all(get(br, "switch", false) for (_,br) in math["branch"] if !startswith(br["name"],"_virtual_branch.switch")) end end