Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: dss parsing of object names with '.' char #444

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading