From 772044d278d9f388b44045c5109af382bf25dce2 Mon Sep 17 00:00:00 2001 From: David M Fobes Date: Wed, 20 Sep 2023 10:15:01 -0600 Subject: [PATCH] FIX: dss parsing of object names with '.' char (#444) * FIX: dss parsing of object names with '.' char This fixes a bug where dss allows for '.' characters in the name of the object, but we were previously splitting on all '.' chars, causing us to drop part of the name in some cases. Resolves #441 * FIX: scaling for pf_bf relaxation tests the sbase_scale_factor=1.0 was causing SCS solver problems, adjusted to 100.0 --- CHANGELOG.md | 1 + src/io/dss/parse.jl | 2 +- test/data/opendss/test2_master.dss | 3 +++ test/opendss.jl | 7 ++++++- test/pf_bf.jl | 2 +- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ec4fdbf1..7c964680c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## staged +- Fixed bug where `.` chars in dss object names would cause part of the name of the object to get dropped - Fixed bug where `var(pm, :p)` and `var(pm, :q)` in the `IVRUPowerModel` formulation were being overwritten by transformer and switch variable functions - Rewrite of dss parser for increased robustness and to avoid edge cases. Instead of parsing raw dss into Dicts, we use vectors of string pairs to preserve the order of commands. This more closely replicates proper dss parsing (**breaking**) - Rewrite of `dss2eng` transformation function to support new dss data model (**breaking**) diff --git a/src/io/dss/parse.jl b/src/io/dss/parse.jl index 41b52c819..ebdb1c683 100644 --- a/src/io/dss/parse.jl +++ b/src/io/dss/parse.jl @@ -56,7 +56,7 @@ end "" function _parse_dss_obj_type_name(dss_obj_type_name::AbstractString)::Vector{String} - obj_type_name = string.(split(replace(replace(dss_obj_type_name, "\""=>""), "\'"=>""), '.')) + obj_type_name = string.(split(replace(replace(dss_obj_type_name, "\""=>""), "\'"=>""), '.'; limit=2)) end diff --git a/test/data/opendss/test2_master.dss b/test/data/opendss/test2_master.dss index 2bf1fa630..f7204a3b0 100644 --- a/test/data/opendss/test2_master.dss +++ b/test/data/opendss/test2_master.dss @@ -104,3 +104,6 @@ setbusxy bus=testsource x=0.1 y=0.2 new regcontrol.t1 transformer=t1 winding=2 vreg=122 band=2 ptratio=20 ctprim=700 R=3 X=9 New CapControl.c1_Ctrl Capacitor=c1 element=Line.L2 terminal=1 type=kvar ptratio=1 ctratio=1 ONsetting=150 OFFsetting=-225 VoltOverride=Y Vmin=7110 Vmax=7740 Delay=100 Delayoff=100 + +new linecode.random_.001-test-name like=L2 +new line.test_.002 like=L2 bus1=_b2 bus2=b10 linecode=random_.001-test-name diff --git a/test/opendss.jl b/test/opendss.jl index 914e34b09..ec651c643 100644 --- a/test/opendss.jl +++ b/test/opendss.jl @@ -57,6 +57,11 @@ eng = parse_file("../test/data/opendss/test2_master.dss", import_all=true) math = parse_file("../test/data/opendss/test2_master.dss"; data_model=MATHEMATICAL, import_all=true) + @testset "dss . characters in name" begin + @test haskey(eng["linecode"], "random_.001-test-name") + @test eng["line"]["test_.002"]["linecode"] == "random_.001-test-name" + end + @testset "dss edit command" begin @test all(eng["transformer"]["t5"][k] == v for (k,v) in eng["transformer"]["t4"] if !(k in ["name", "bus", "source_id", "rw", "tm_set", "dss", "controls", "tm_nom"])) @test all(eng["transformer"]["t5"]["rw"] .== [0.0074, 0.0076]) @@ -92,7 +97,7 @@ @test length(math) == 18 @test length([p for p in propertynames(raw_dss) if !isempty(getproperty(raw_dss, p))]) == 23 - for (key, len) in zip(["bus", "load", "shunt", "branch", "gen", "transformer", "storage", "switch"], [34, 4, 5, 28, 5, 10, 1, 1]) + for (key, len) in zip(["bus", "load", "shunt", "branch", "gen", "transformer", "storage", "switch"], [34, 4, 5, 29, 5, 10, 1, 1]) @test haskey(math, key) @test length(math[key]) == len end diff --git a/test/pf_bf.jl b/test/pf_bf.jl index 90011f416..174f6f5a4 100644 --- a/test/pf_bf.jl +++ b/test/pf_bf.jl @@ -24,7 +24,7 @@ data = deepcopy(case3_unbalanced) apply_voltage_bounds!(data; vm_lb=0.9, vm_ub=1.1) - data["settings"]["sbase_default"] = 1.0 + data["settings"]["sbase_default"] = 100.0 merge!(data["voltage_source"]["source"], Dict{String,Any}( "cost_pg_parameters" => [0.0, 1000.0, 0.0],