@@ -85,7 +85,7 @@ const _dshl_dtypes = [("FROM BUS", Int64, 1:5), ("OPERATION", Int64, 7),
85
85
("SHUNT TO", Float64, 24:29), ("STATUS FROM", String, 31:32), ("STATUS TO", String, 34:35)]
86
86
87
87
const _dcba_dtypes = [("NUMBER", Int64, 1:4), ("OPERATION", Int64, 6), ("TYPE", Int64, 8),
88
- ("POLARITY", String , 9), ("NAME", String, 10:21), ("VOLTAGE LIMIT GROUP", String, 22:23),
88
+ ("POLARITY", Char , 9), ("NAME", String, 10:21), ("VOLTAGE LIMIT GROUP", String, 22:23),
89
89
("VOLTAGE", Float64, 24:28), ("GROUND ELECTRODE", Float64, 67:71), ("DC LINK", Int64, 72:75)]
90
90
91
91
const _dcli_dtypes = [("FROM BUS", Int64, 1:4), ("OPERATION", Int64, 6), ("TO BUS", Int64, 9:12),
@@ -169,7 +169,7 @@ const _dcai_dtypes = [("BUS", Int64, 1:5), ("OPERATION", Char, 7), ("GROUP", Int
169
169
("ACTIVE CHARGE", Float64, 23:27), ("REACTIVE CHARGE", Float64, 29:33),
170
170
("PARAMETER A", Float64, 35:37), ("PARAMETER B", Float64, 39:41),
171
171
("PARAMETER C", Float64, 43:45), ("PARAMETER D", Float64, 47:49), ("VOLTAGE", Float64, 51:55),
172
- ("VOLTAGE FOR CHARGE DEFINITION", Float64, 57:60)]
172
+ ("CHARGE DEFINITION VOLTAGE ", Float64, 57:60)]
173
173
174
174
const _dgei_dtypes = [("BUS", Int64, 1:5), ("OPERATION", Char, 7), ("AUTOMATIC MODE", Char, 8),
175
175
("GROUP", Int64, 10:11), ("STATUS", Char, 13), ("UNITIES", Int64, 14:16),
@@ -178,7 +178,7 @@ const _dgei_dtypes = [("BUS", Int64, 1:5), ("OPERATION", Char, 7), ("AUTOMATIC M
178
178
("MINIMUM REACTIVE GENERATION", Float64, 33:37), ("MAXIMUM REACTIVE GENERATION", Float64, 38:42),
179
179
("ELEVATOR TRANSFORMER REACTANCE", Float64, 43:48), ("XD", Float64, 50:54, 53),
180
180
("XQ", Float64, 55:59, 58), ("XL", Float64, 60:64, 63), ("POWER FACTOR", Float64, 66:69, 67),
181
- ("APARENT POWER", Float64, 70:74, 72), ("MECHANICAL LIMIT", Float64, 75:79, 77)]
181
+ ("APPARENT POWER", Float64, 70:74, 72), ("MECHANICAL LIMIT", Float64, 75:79, 77)]
182
182
183
183
const _dmot_dtypes = [("BUS", Int64, 1:5), ("OPERATION", Char, 7), ("STATUS", Char, 8),
184
184
("GROUP", Int64, 10:11), ("SIGN", Char, 12), ("LOADING FACTOR", Float64, 13:15),
@@ -191,7 +191,7 @@ const _dmot_dtypes = [("BUS", Int64, 1:5), ("OPERATION", Char, 7), ("STATUS", Ch
191
191
const _dcmt_dtypes = [("COMMENTS", String, 1:80)]
192
192
193
193
const _dinj_dtypes = [("NUMBER", Int64, 1:5), ("OPERATION", Char, 7),
194
- ("EQUIVALENT ACTIVE INJECITON ", Float64, 9:15), ("EQUIVALENT REACTIVE INJECTION", Float64, 16:22),
194
+ ("EQUIVALENT ACTIVE INJECTION ", Float64, 9:15), ("EQUIVALENT REACTIVE INJECTION", Float64, 16:22),
195
195
("EQUIVALENT SHUNT", Float64, 23:29), ("EQUIVALENT PARTICIPATION FACTOR", Float64, 30:36)]
196
196
197
197
const _pwf_dtypes = Dict("DBAR" => _dbar_dtypes, "DLIN" => _dlin_dtypes, "DGBT" => _dgbt_dtypes,
@@ -233,12 +233,12 @@ const _default_dbar = Dict("NUMBER" => nothing, "OPERATION" => 'A', "STATUS" =>
233
233
"AGGREGATOR 10" => nothing)
234
234
235
235
const _default_dlin = Dict("FROM BUS" => nothing, "OPENING FROM BUS" => 'L',
236
- "OPERATION" => 'A', "OPENING TO BUS" => 'L', "TO BUS" => nothing, "CIRCUIT" => nothing ,
236
+ "OPERATION" => 'A', "OPENING TO BUS" => 'L', "TO BUS" => nothing, "CIRCUIT" => 0 ,
237
237
"STATUS" => 'L', "OWNER" => 'F', "RESISTANCE" => 0.0, "REACTANCE" => nothing,
238
238
"SHUNT SUSCEPTANCE" => 0.0, "TAP" => 1.0, "MINIMUM TAP" => nothing,
239
239
"MAXIMUM TAP" => nothing, "LAG" => 0.0, "CONTROLLED BUS" => nothing,
240
- "NORMAL CAPACITY" => Inf, "EMERGENCY CAPACITY" => Inf , "NUMBER OF TAPS" => 33,
241
- "EQUIPAMENT CAPACITY" => Inf , "AGGREGATOR 1" => nothing, "AGGREGATOR 2" => nothing,
240
+ "NORMAL CAPACITY" => Inf, "EMERGENCY CAPACITY" => nothing , "NUMBER OF TAPS" => 33,
241
+ "EQUIPAMENT CAPACITY" => nothing , "AGGREGATOR 1" => nothing, "AGGREGATOR 2" => nothing,
242
242
"AGGREGATOR 3" => nothing, "AGGREGATOR 4" => nothing, "AGGREGATOR 5" => nothing,
243
243
"AGGREGATOR 6" => nothing, "AGGREGATOR 7" => nothing, "AGGREGATOR 8" => nothing,
244
244
"AGGREGATOR 9" => nothing, "AGGREGATOR 10" => nothing)
@@ -274,11 +274,11 @@ const _default_dshl = Dict("FROM BUS" => nothing, "OPERATION" => 'A', "TO BUS" =
274
274
"STATUS FROM" => " L", "STATUS TO" => " L")
275
275
276
276
const _default_dcba = Dict("NUMBER" => nothing, "OPERATION" => 'A', "TYPE" => 0,
277
- "POLARITY" => nothing, "NAME" => nothing, "VOLTAGE LIMIT GROUP" => nothing ,
277
+ "POLARITY" => nothing, "NAME" => nothing, "VOLTAGE LIMIT GROUP" => " 0" ,
278
278
"VOLTAGE" => 0, "GROUND ELECTRODE" => 0.0, "DC LINK" => 1)
279
279
280
280
const _default_dcli = Dict("FROM BUS" => nothing, "OPERATION" => 'A', "TO BUS" => nothing,
281
- "CIRCUIT" => nothing , "OWNER" => nothing, "RESISTANCE" => nothing, "INDUCTANCE" => 0.0,
281
+ "CIRCUIT" => 0 , "OWNER" => nothing, "RESISTANCE" => nothing, "INDUCTANCE" => 0.0,
282
282
"CAPACITY" => Inf)
283
283
284
284
const _default_dcnv = Dict("NUMBER" => nothing, "OPERATION" => 'A', "AC BUS" => nothing,
@@ -317,14 +317,15 @@ const _default_fagr_2 = Dict("NUMBER" => nothing, "OPERATION" => 'A', "DESCRIPTI
317
317
318
318
const _default_fagr_1 = Dict("NUMBER" => nothing, "DESCRIPTION" => nothing, "OCCURENCES" => _default_fagr_2)
319
319
320
- const _default_dcsc = Dict("FROM BUS" => nothing, "OPERATION" => nothing , "TO BUS" => nothing,
321
- "CIRCUIT" => nothing , "STATUS" => 'L', "OWNER" => 'F', "BYPASS" => 'D',
320
+ const _default_dcsc = Dict("FROM BUS" => nothing, "OPERATION" => 'A' , "TO BUS" => nothing,
321
+ "CIRCUIT" => 0 , "STATUS" => 'L', "OWNER" => 'F', "BYPASS" => 'D',
322
322
"MINIMUM VALUE" => -9999.0, "MAXIMUM VALUE" => 9999.0, "INITIAL VALUE" => nothing,
323
323
"CONTROL MODE" => 'X', "SPECIFIED VALUE" => nothing, "MEASUREMENT EXTREMITY" => nothing,
324
324
"NUMBER OF STAGES" => nothing, "NORMAL CAPACITY" => Inf, "EMERGENCY CAPACITY" => Inf,
325
325
"EQUIPAMENT CAPACITY" => Inf, "AGGREGATOR 1" => nothing, "AGGREGATOR 2" => nothing,
326
326
"AGGREGATOR 3" => nothing, "AGGREGATOR 4" => nothing, "AGGREGATOR 5" => nothing,
327
- "AGGREGATOR 6" => nothing)
327
+ "AGGREGATOR 6" => nothing, "AGGREGATOR 8" => nothing, "AGGREGATOR 7" => nothing,
328
+ "AGGREGATOR 9" => nothing, "AGGREGATOR 10" => nothing)
328
329
329
330
const _default_dcar = Dict("ELEMENT 1 TYPE" => nothing, "ELEMENT 1 IDENTIFICATION" => nothing,
330
331
"CONDITION 1" => nothing, "ELEMENT 2 TYPE" => nothing, "ELEMENT 2 IDENTIFICATION" => nothing,
@@ -342,23 +343,23 @@ const _default_dctr = Dict("FROM BUS" => nothing, "OPERATION" => 'A', "TO BUS" =
342
343
const _default_dare = Dict("NUMBER" => nothing, "NET INTERCHANGE" => 0.0, "NAME" => nothing,
343
344
"MINIMUM INTERCHANGE" => 0.0, "MAXIMUM INTERCHANGE" => 0.0)
344
345
345
- const _default_dtpf_circ = Dict("FROM BUS 1" => nothing, "TO BUS 1" => nothing, "CIRCUIT 1" => nothing ,
346
- "FROM BUS 2" => nothing, "TO BUS 2" => nothing, "CIRCUIT 2" => nothing ,
347
- "FROM BUS 3" => nothing, "TO BUS 3" => nothing, "CIRCUIT 3" => nothing ,
348
- "FROM BUS 4" => nothing, "TO BUS 4" => nothing, "CIRCUIT 4" => nothing ,
349
- "FROM BUS 5" => nothing, "TO BUS 5" => nothing, "CIRCUIT 5" => nothing , "OPERATION" => 'A')
346
+ const _default_dtpf_circ = Dict("FROM BUS 1" => nothing, "TO BUS 1" => nothing, "CIRCUIT 1" => 0 ,
347
+ "FROM BUS 2" => nothing, "TO BUS 2" => nothing, "CIRCUIT 2" => 0 ,
348
+ "FROM BUS 3" => nothing, "TO BUS 3" => nothing, "CIRCUIT 3" => 0 ,
349
+ "FROM BUS 4" => nothing, "TO BUS 4" => nothing, "CIRCUIT 4" => 0 ,
350
+ "FROM BUS 5" => nothing, "TO BUS 5" => nothing, "CIRCUIT 5" => 0 , "OPERATION" => 'A')
350
351
351
352
const _default_dmte = Dict("ELEMENT 1 TYPE" => nothing, "ELEMENT 1 IDENTIFICATION" => nothing,
352
353
"CONDITION 1" => nothing, "ELEMENT 2 TYPE" => nothing, "ELEMENT 2 IDENTIFICATION" => nothing,
353
354
"MAIN CONDITION" => nothing, "ELEMENT 3 TYPE" => nothing, "ELEMENT 3 IDENTIFICATION" => nothing,
354
355
"CONDITION 2" => nothing, "ELEMENT 4 TYPE" => nothing, "ELEMENT 4 IDENTIFICATION" => nothing,
355
356
"OPERATION" => 'A', "BOUNDARIES" => 'T')
356
357
357
- const _default_dmfl_circ = Dict("FROM BUS 1" => nothing, "TO BUS 1" => nothing, "CIRCUIT 1" => nothing ,
358
- "FROM BUS 2" => nothing, "TO BUS 2" => nothing, "CIRCUIT 2" => nothing ,
359
- "FROM BUS 3" => nothing, "TO BUS 3" => nothing, "CIRCUIT 3" => nothing ,
360
- "FROM BUS 4" => nothing, "TO BUS 4" => nothing, "CIRCUIT 4" => nothing ,
361
- "FROM BUS 5" => nothing, "TO BUS 5" => nothing, "CIRCUIT 5" => nothing , "OPERATION" => 'A')
358
+ const _default_dmfl_circ = Dict("FROM BUS 1" => nothing, "TO BUS 1" => nothing, "CIRCUIT 1" => 0 ,
359
+ "FROM BUS 2" => nothing, "TO BUS 2" => nothing, "CIRCUIT 2" => 0 ,
360
+ "FROM BUS 3" => nothing, "TO BUS 3" => nothing, "CIRCUIT 3" => 0 ,
361
+ "FROM BUS 4" => nothing, "TO BUS 4" => nothing, "CIRCUIT 4" => 0 ,
362
+ "FROM BUS 5" => nothing, "TO BUS 5" => nothing, "CIRCUIT 5" => 0 , "OPERATION" => 'A')
362
363
363
364
const _default_dbre = Dict()
364
365
@@ -371,8 +372,8 @@ const _default_dgei = Dict("BUS" => nothing, "OPERATION" => 'A', "AUTOMATIC MODE
371
372
"GROUP" => nothing, "STATUS" => 'L', "UNITIES" => 1, "OPERATING UNITIES" => 1,
372
373
"MINIMUM OPERATING UNITIES" => 1, "ACTIVE GENERATION" => 0.0, "REACTIVE GENERATION" => 0.0,
373
374
"MINIMUM REACTIVE GENERATION" => -9999.0, "MAXIMUM REACTIVE GENERATION" => 99999.0,
374
- "TRANSFORMER ELEVATOR REACTANCE" => nothing, "XD" => 0.0, "XQ" => 0.0, "XL" => 0.0,
375
- "POWER FACTOR" => 1.0, "APARENT POWER" => 99999.0, "MECHANICAL LIMIT" => 99999.0)
375
+ "ELEVATOR TRANSFORMER REACTANCE" => nothing, "XD" => 0.0, "XQ" => 0.0, "XL" => 0.0,
376
+ "POWER FACTOR" => 1.0, "APPARENT POWER" => 99999.0, "MECHANICAL LIMIT" => 99999.0)
376
377
377
378
const _default_dmot = Dict("BUS" => nothing, "OPERATION" => 'A', "STATUS" => 'L',
378
379
"GROUP" => nothing, "SIGN" => '+', "LOADING FACTOR" => 100.0, "UNITIES" => 1,
@@ -384,7 +385,7 @@ const _default_dmot = Dict("BUS" => nothing, "OPERATION" => 'A', "STATUS" => 'L'
384
385
const _default_dcmt = Dict("COMMENTS" => nothing)
385
386
386
387
const _default_dinj = Dict("NUMBER" => nothing, "OPERATION" => 'A',
387
- "EQUIVALENT ACTIVE INJECITON " => 0.0, "EQUIVALENT REACTIVE INJECITON " => 0.0,
388
+ "EQUIVALENT ACTIVE INJECTION " => 0.0, "EQUIVALENT REACTIVE INJECTION " => 0.0,
388
389
"EQUIVALENT SHUNT" => 0.0, "EQUIVALENT PARTICIPATION FACTOR" => 0.0)
389
390
390
391
const _default_titu = ""
@@ -704,17 +705,34 @@ function _handle_special_defaults!(pwf_data::Dict{String, Any}, section::String,
704
705
pwf_data[section][i][component] = pwf_data[section][i]["FROM BUS"] # Default: the bus itself
705
706
end
706
707
708
+ if section == "DLIN" && component in ["EMERGENCY CAPACITY", "EQUIPAMENT CAPACITY"]
709
+ normal_capacity = pwf_data[section][i]["NORMAL CAPACITY"]
710
+ normal_capacity = isa(normal_capacity, AbstractString) && _needs_default(normal_capacity) ? _pwf_defaults[section]["NORMAL CAPACITY"] : normal_capacity
711
+ pwf_data[section][i][component] = normal_capacity
712
+ end
713
+
707
714
if section == "DBSH" && component == "MINIMUM VOLTAGE"
708
715
ctrl_bus = pwf_data[section][i]["CONTROLLED BUS"]
716
+ ctrl_bus = !isa(ctrl_bus, Int64) ? pwf_data[section][i]["FROM BUS"] : ctrl_bus
709
717
group = pwf_data["DBAR"]["$ctrl_bus"]["VOLTAGE LIMIT GROUP"]
718
+ group = isa(group, AbstractString) && _needs_default(group) ? " 0" : group
710
719
group_idx = findfirst(x -> x["GROUP"] == group, pwf_data["DGLT"])
711
- pwf_data[section][i][component] = pwf_data["DGLT"][group_idx]["LOWER BOUND"]
720
+ lower_bound = pwf_data["DGLT"][group_idx]["LOWER BOUND"]
721
+ lower_bound = isa(lower_bound, AbstractString) && _needs_default(lower_bound) ? 0.8 : lower_bound
722
+ pwf_data[section][i][component] = lower_bound
712
723
end
713
724
if section == "DBSH" && component == "MAXIMUM VOLTAGE"
714
725
ctrl_bus = pwf_data[section][i]["CONTROLLED BUS"]
726
+ ctrl_bus = !isa(ctrl_bus, Int64) ? pwf_data[section][i]["FROM BUS"] : ctrl_bus
715
727
group = pwf_data["DBAR"]["$ctrl_bus"]["VOLTAGE LIMIT GROUP"]
728
+ group = isa(group, AbstractString) && _needs_default(group) ? " 0" : group
716
729
group_idx = findfirst(x -> x["GROUP"] == group, pwf_data["DGLT"])
717
- pwf_data[section][i][component] = pwf_data["DGLT"][group_idx]["UPPER BOUND"]
730
+ upper_bound = pwf_data["DGLT"][group_idx]["UPPER BOUND"]
731
+ upper_bound = isa(upper_bound, AbstractString) && _needs_default(upper_bound) ? 1.2 : upper_bound
732
+ pwf_data[section][i][component] = upper_bound
733
+ end
734
+ if section == "DBSH" && component == "CONTROLLED BUS"
735
+ pwf_data[section][i][component] = pwf_data[section][i]["FROM BUS"]
718
736
end
719
737
720
738
if section == "DCTR" && component in ["MINIMUM VOLTAGE", "MAXIMUM VOLTAGE"]
@@ -723,6 +741,66 @@ function _handle_special_defaults!(pwf_data::Dict{String, Any}, section::String,
723
741
if section == "DCTR" && component in ["MINIMUM PHASE", "MAXIMUM PHASE"]
724
742
pwf_data[section][i]["PHASE CONTROL"] = false
725
743
end
744
+
745
+ if section == "DCTR" && component == "MEASUREMENT EXTREMITY"
746
+ pwf_data[section][i][component] = pwf_data[section][i]["FROM BUS"]
747
+ end
748
+
749
+ if section == "DGLT" && component == "LOWER EMERGENCY BOUND"
750
+ pwf_data[section][i][component] = pwf_data[section][i]["LOWER BOUND"]
751
+ end
752
+ if section == "DGLT" && component == "UPPER EMERGENCY BOUND"
753
+ pwf_data[section][i][component] = pwf_data[section][i]["UPPER BOUND"]
754
+ end
755
+
756
+ if section == "DCBA" && component == "VOLTAGE"
757
+ if pwf_data[section][i]["POLARITY"] == '0'
758
+ pwf_data[section][i][component] = 0.0
759
+ else
760
+ pwf_data[section][i][component] = 1.0
761
+ end
762
+ end
763
+
764
+ if section == "DCCV" && component == "TAP HI MVAR MODE"
765
+ step = (pwf_data[section][i]["MAXIMUM TRANSFORMER TAP"] - pwf_data[section][i]["MINIMUM TRANSFORMER TAP"]) / pwf_data[section][i]["TRANSFORMER TAP NUMBER OF STEPS"]
766
+ pwf_data[section][i][component] = pwf_data[section][i]["MAXIMUM TRANSFORMER TAP"] - step
767
+ end
768
+
769
+ if section == "DELO" && component == "BASE" && haskey(pwf_data, "DCTE")
770
+ pwf_data[section][i][component] = pwf_data["DCTE"]["DASE"]
771
+ end
772
+
773
+ if section == "DCER" && component == "CONTROLLED BUS"
774
+ pwf_data[section][i][component] = pwf_data[section][i]["BUS"]
775
+ end
776
+
777
+ if section == "DCSC" && component == "INITIAL VALUE"
778
+ pwf_data[section][i][component] = pwf_data[section][i]["MAXIMUM VALUE"]
779
+ end
780
+ if section == "DCSC" && component == "MEASUREMENT EXTREMITY"
781
+ pwf_data[section][i][component] = pwf_data[section][i]["FROM BUS"]
782
+ end
783
+
784
+ if section == "DCAR" && component == "VOLTAGE" && haskey(pwf_data, "DCTE")
785
+ pwf_data[section][i][component] = pwf_data["DCTE"]["VFLD"]
786
+ end
787
+
788
+ if section == "DCAI" && component == "OPERATING UNITIES"
789
+ pwf_data[section][i][component] = pwf_data[section][i]["UNITIES"]
790
+ end
791
+ if section == "DCAI" && component == "VOLTAGE" && haskey(pwf_data, "DCTE")
792
+ vfld = pwf_data["DCTE"]["VFLD"]
793
+ vfld = isa(vfld, AbstractString) && _needs_default(vfld) ? 70 : vfld
794
+ pwf_data[section][i][component] = vfld
795
+ end
796
+ if section == "DGEI" && component == "OPERATING UNITIES"
797
+ pwf_data[section][i][component] = pwf_data[section][i]["UNITIES"]
798
+ end
799
+ if section == "REACTANCE GROUPS" && component == "OPERATING UNITIES"
800
+ unities = pwf_data[section][i]["UNITIES"]
801
+ unities = isa(unities, AbstractString) && _needs_default(unities) ? 1 : unities
802
+ pwf_data[section][i][component] = unities
803
+ end
726
804
end
727
805
728
806
function _handle_transformer_default!(pwf_data::Dict{String, Any}, section::String, i::String)
0 commit comments