Skip to content

Commit

Permalink
FIX: dss parsing of object names with '.' char (#444)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
pseudocubic authored Sep 20, 2023
1 parent 3686697 commit 772044d
Show file tree
Hide file tree
Showing 5 changed files with 12 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 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**)
Expand Down
2 changes: 1 addition & 1 deletion src/io/dss/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
3 changes: 3 additions & 0 deletions test/data/opendss/test2_master.dss
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 6 additions & 1 deletion test/opendss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/pf_bf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit 772044d

Please sign in to comment.