Skip to content

Commit 7152b29

Browse files
authored
Merge pull request #37 from LAMPSPUC/handle_shunt_control_in_bus_section
Add shunt info in bus section
2 parents 373dc41 + 0b889d1 commit 7152b29

File tree

5 files changed

+32
-33
lines changed

5 files changed

+32
-33
lines changed

docs/src/index.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,6 @@ The package parses all available sections into a julia dictionary. Every key rep
6161
- DOPC
6262
- DCTE
6363

64-
**Incoming Sections:**
65-
66-
- DARE
67-
- DCAI
68-
- DCAR
69-
- DCSC
70-
- DGEI
71-
- DGLT
72-
- DINJ
73-
- DMFL
74-
- DMOT
75-
- DMTE
76-
- TITU
77-
7864
## PowerModels.jl converter
7965

8066
The package also allow converting .pwf file directly into PowerModels.jl network data structure:

docs/src/quickguide.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
11
# Quick Start Guide
22

3-
Parsing a .pwf file to Julia dictionary is as simple as:
3+
All functionalities of the PWF.jl package can be used by the following function
44

55
```julia
66
using PWF
77

88
file = "3bus.pwf"
9-
pwf_dict = parse_pwf(file)
9+
pwf_dict = parse_file(file; pm = true, add_control_data = false)
1010
```
1111

12-
Converting the .pwf file into PowerModels.jl network data dictionary:
13-
14-
```julia
15-
network_data = parse_pwf_to_powermodels(file)
16-
```
17-
18-
Then you are ready to use PowerModels!
19-
20-
```julia
21-
using PowerModels, Ipopt
22-
23-
run_ac_pf(network_data, Ipopt.Optimizer)
24-
```
12+
The parameter `pm` indicates if the data should be converted to the PowerModels.jl format. `add_control_data` is used to inform if additional information regarding control actions should be included in the PowerModels.jl data. For more information about Control Actions visit the ControlPowerFlow.jl [documentation](https://github.com/LAMPSPUC/ControlPowerFlow.jl)
2513

2614
For more information about PowerModels.jl visit the PowerModels [documentation](https://lanl-ansi.github.io/PowerModels.jl/stable/)
2715

src/pwf2pm/bus.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ function _pwf2pm_bus!(pm_data::Dict, pwf_data::Dict, bus::Dict, dict_dgbt, dict_
100100
sub_data["control_data"]["vmmin"] = sub_data["vmin"]
101101
sub_data["control_data"]["vmmax"] = sub_data["vmax"]
102102
sub_data["control_data"]["tap_control"] = nothing
103-
sub_data["control_data"]["constraint_type"] = nothing
103+
sub_data["control_data"]["tap_constraint_type"] = nothing
104+
sub_data["control_data"]["shunt_control"] = nothing
105+
sub_data["control_data"]["shunt_section"] = nothing
104106
end
105107

106108
idx = string(sub_data["index"])

src/pwf2pm/shunt.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ function _pwf2pm_DBSH_shunt!(pm_data::Dict, pwf_data::Dict, shunt::Dict; add_con
6262
sub_data["control_data"]["bsmax"] = bs_bounds[2]
6363
@assert sub_data["control_data"]["bsmin"] <= sub_data["control_data"]["bsmax"]
6464
sub_data["control_data"]["inclination"] = nothing
65+
66+
controlled_bus = sub_data["control_data"]["controlled_bus"]
67+
if sub_data["control_data"]["shunt_control_type"] in [2,3]
68+
pm_data["bus"]["$controlled_bus"]["control_data"]["shunt_control"] = true
69+
shunt_section = pm_data["bus"]["$controlled_bus"]["control_data"]["shunt_section"]
70+
if isnothing(shunt_section)
71+
pm_data["bus"]["$controlled_bus"]["control_data"]["shunt_section"] = "DBSH"
72+
else
73+
# don't overwrite
74+
end
75+
end
6576
end
6677

6778
sub_data["source_id"] = ["switched shunt", sub_data["shunt_bus"], "0$(n+1)"]
@@ -115,6 +126,17 @@ function _pwf2pm_DCER_shunt!(pm_data::Dict, pwf_data::Dict, shunt::Dict; add_con
115126
sub_data["control_data"]["vmmax"] = ctrl_bus["vm"]
116127
sub_data["control_data"]["controlled_bus"] = shunt["CONTROLLED BUS"]
117128
sub_data["control_data"]["inclination"] = shunt["INCLINATION"]
129+
130+
controlled_bus = sub_data["control_data"]["controlled_bus"]
131+
if sub_data["control_data"]["shunt_control_type"] in [2,3]
132+
pm_data["bus"]["$controlled_bus"]["control_data"]["shunt_control"] = true
133+
shunt_section = pm_data["bus"]["$controlled_bus"]["control_data"]["shunt_section"]
134+
if isnothing(shunt_section)
135+
pm_data["bus"]["$controlled_bus"]["control_data"]["shunt_section"] = "DCER"
136+
else
137+
pm_data["bus"]["$controlled_bus"]["control_data"]["shunt_section"] = "DCER" # DCER always overwrites
138+
end
139+
end
118140
end
119141

120142
sub_data["source_id"] = ["switched shunt", sub_data["shunt_bus"], "0$(n+1)"]

src/pwf2pm/transformer.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,18 @@ function _pwf2pm_transformer!(pm_data::Dict, pwf_data::Dict, branch::Dict; add_c
110110
sub_data["control_data"]["valsp"] = branch_dctr[circuit]["SPECIFIED VALUE"]
111111
sub_data["control_data"]["controlled_bus"] = branch_dctr[circuit]["MEASUREMENT EXTREMITY"]
112112

113+
# Add tap control information in controlled bus
113114
pm_data["bus"]["$(sub_data["control_data"]["controlled_bus"])"]["control_data"]["control_type"] = "tap_control"
114-
if isnothing(pm_data["bus"]["$(sub_data["control_data"]["controlled_bus"])"]["control_data"]["constraint_type"]) # setpoint is more restrict than bounds
115-
pm_data["bus"]["$(sub_data["control_data"]["controlled_bus"])"]["control_data"]["constraint_type"] = "bounds"
115+
if isnothing(pm_data["bus"]["$(sub_data["control_data"]["controlled_bus"])"]["control_data"]["tap_constraint_type"]) # setpoint is more restrict than bounds
116+
pm_data["bus"]["$(sub_data["control_data"]["controlled_bus"])"]["control_data"]["tap_constraint_type"] = "bounds"
116117
end
117118

118119
else
119120
pm_data["bus"]["$(sub_data["control_data"]["controlled_bus"])"]["control_data"]["control_type"] = "tap_control"
120121

121122
sub_data["control_data"]["constraint_type"] = "setpoint"
122123
sub_data["control_data"]["valsp"] = nothing
123-
pm_data["bus"]["$(sub_data["control_data"]["controlled_bus"])"]["control_data"]["constraint_type"] = "setpoint"
124+
pm_data["bus"]["$(sub_data["control_data"]["controlled_bus"])"]["control_data"]["tap_constraint_type"] = "setpoint"
124125
end
125126

126127
elseif constraint_type == "PHASE CONTROL" # phase control

0 commit comments

Comments
 (0)