Skip to content

Commit

Permalink
FIX: switches should not have length
Browse files Browse the repository at this point in the history
In ENGINEERING model, switches should be zero-length objects.
Resolved this by applying length/linecode in the dss2eng parse stage.

Resolves #462
  • Loading branch information
pseudocubic committed Sep 18, 2024
1 parent acc944e commit e5f18cc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 22 additions & 2 deletions src/data_model/transformations/dss2eng.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/opendss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e5f18cc

Please sign in to comment.