lanl-ansi / PowerModels.jl

A Julia/JuMP Package for Power Network Optimization
https://lanl-ansi.github.io/PowerModels.jl/stable/
Other
395 stars 148 forks source link

PSSE parser to accept 'blanks' for transformer K parameter? #843

Open manuelma opened 2 years ago

manuelma commented 2 years ago

In transformer blocks, the K parameter indicates the bus to which the third winding is connected. If the transformer is only two-windings, the parameter should be zero but somehow I got myself a .raw file where the value is simple ommited as seen below:

1021, 10204, ,1, , , , , , , 'XXXX' , 1, 2   / load
0.007, 0.367, 9999
0.9777, ,0, 9999, 9999, 63, 1, 10204, 1.034, 0.72, 1.09, 1.04, 16, , , 
 , ,

So to be correct, the first line should be more like 1021, 10204, 0,1, ...

When I try to parse, I get the below

ERROR: ArgumentError: input string is empty or only contains whitespace
Stacktrace:
  [1] tryparse_internal(#unused#::Type{Int64}, s::SubString{String}, startpos::Int64, endpos::Int64, base_::Int64, raise::Bool)
    @ Base ./parse.jl:109
  [2] parse(::Type{Int64}, s::SubString{String}; base::Nothing)
    @ Base ./parse.jl:241
  [3] parse
    @ ./parse.jl:241 [inlined]
  [4] _parse_pti_data(data_io::FilteredIO)
    @ PowerModels ~/.julia/packages/PowerModels/kU7PK/src/io/pti.jl:708
  [5] parse_pti(io::FilteredIO)
    @ PowerModels ~/.julia/packages/PowerModels/kU7PK/src/io/pti.jl:890
  [6] #parse_psse#1230
    @ ~/.julia/packages/PowerModels/kU7PK/src/io/psse.jl:866 [inlined]
  [7] parse_psse
    @ ~/.julia/packages/PowerModels/kU7PK/src/io/psse.jl:865 [inlined]
  [8] #9
    @ ~/Codes/spine/Network_Prune/psse_to_spine.jl:40 [inlined]
  [9] open(f::var"#9#11", args::String; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./io.jl:330
 [10] open
    @ ./io.jl:328 [inlined]
 [11] psse_to_spine(psse_path::String, db_url::String)
    @ Main ~/Codes/spine/Network_Prune/psse_to_spine.jl:38
 [12] top-level scope
    @ REPL[13]:1

which makes sense because of this: https://github.com/lanl-ansi/PowerModels.jl/blob/cbce39778bfeaefdbde90e07220ee3bc36f8f33d/src/io/pti.jl#L707

The question is, should the parser handle empty values for the K parameter as if they were zero, so my file would pass?

ccoffrin commented 2 years ago

@manuelma, thanks for your bug reports. Can you check what the header of your .raw file says the format version is? So far we have only supported v33, so newer raw files may have features that are un-tested or break our parser.

In this case, it is probably likely that we can support it but I'll need to test the possible fix.

DillonJ commented 2 years ago

Hi folks… here is a link to a zip archive that contains the raw files in question : https://www.eirgridgroup.com/site-files/library/EirGrid/Study-files.zip

manuelma commented 2 years ago

Thank you @ccoffrin for the help and @DillonJ for the files. I can't see any information regarding the format version in the files, though... @ccoffrin I could submit a PR if that helps?