Skip to content

Commit 9192e63

Browse files
authored
Multi-conductor Renaming (#324)
* phase to conductor renaming * update MultiPhase datatypes to MultiConductor * add standard ids names to developer docs * updating file names * rename function args and tmp vars to reflect conductor short names
1 parent b2cbdd2 commit 9192e63

31 files changed

+1492
-1485
lines changed

CHANGELOG.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ PowerModels.jl Change Log
66
- Added Matpower data file export function
77
- Added mathematical model to documentation
88
- Added parsing string data from IO objects
9-
- Added support for network data with multiple phases
9+
- Added support for network data with multiple conductors
1010
- Removed explicit series variables from branch flow model
11-
- Improved helper functions ref, var, con to work with multiple networks and phases
11+
- Improved helper functions ref, var, con to work with multiple networks and conductors
1212
- Minor robustness improvements to parsing PTI files
1313
- Minor issues closed #316
1414

@@ -93,7 +93,7 @@ PowerModels.jl Change Log
9393
- Made index_name an optional parameter in add_setpoint (breaking)
9494
- Moved check_cost_models into the objective building function
9595
- Fixed out of range bug in calc_theta_delta_bounds
96-
- Fixed bug in phase angle differences in AbstractACPForms
96+
- Fixed bug in voltage angle differences in AbstractACPForms
9797
- Fixed bugs in AbstractDCPLLForm and added OPF test
9898

9999
### v0.3.4
@@ -104,7 +104,7 @@ PowerModels.jl Change Log
104104
- Added w-theta formulation of AC-OPF
105105
- Added data units checks to update_data
106106
- Made branch flow parameter names consistent with Matpower
107-
- Fixed bug in constants for w-space phase angle difference constraints
107+
- Fixed bug in constants for w-space voltage angle difference constraints
108108
- Fixed bug when no reference bus was specified
109109
- Fixed dcline parsing bug
110110

@@ -138,7 +138,7 @@ PowerModels.jl Change Log
138138
- Strengthened convex formulations with Lifted Nonlinear Cuts (LNCs)
139139
- Added ability to easily inspect the JuMP model produced by PowerModels
140140
- Added constraint templates to provide an abstraction layer between the network data and network constraint definitions
141-
- Moved system wide phase angle difference bounds to the "ref" dictionary
141+
- Moved system wide voltage angle difference bounds to the "ref" dictionary
142142
- Refactored model definitions to be based on complex numbers
143143

144144
### v0.2.3

docs/src/developer.md

+7
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ $y = g + j\cdot b$:
7373
- `b`: susceptance ($S$)
7474

7575

76+
### Standard Value Names
77+
78+
- network ids:`network`, `nw`, `n`
79+
- conductors ids: `conductor`, `cnd`, `c`
80+
- phase ids: `phase`, `ph`, `h`
81+
82+
7683
## DistFlow derivation
7784

7885
### For an asymmetric pi section

docs/src/quickguide.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ result["objective"]
3737
```
3838

3939
The `"solution"` field contains detailed information about the solution produced by the run method.
40-
For example, the following dictionary comprehension can be used to inspect the bus phase angles in the solution,
40+
For example, the following dictionary comprehension can be used to inspect the bus voltage angles in the solution,
4141

4242
```
4343
Dict(name => data["va"] for (name, data) in result["solution"]["bus"])

src/PowerModels.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ include("core/constraint.jl")
3535
include("core/relaxation_scheme.jl")
3636
include("core/objective.jl")
3737
include("core/solution.jl")
38-
include("core/multiphase.jl")
38+
include("core/multiconductor.jl")
3939

4040
include("form/acp.jl")
4141
include("form/acr.jl")

src/core/base.jl

+42-42
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export
55
setdata, setsolver, solve,
66
run_generic_model, build_generic_model, solve_generic_model,
77
ismultinetwork, nw_ids, nws,
8-
ismultiphase, phase_ids,
8+
ismulticonductor, conductor_ids,
99
ids, ref, var, ext
1010

1111

@@ -52,7 +52,7 @@ mutable struct GenericPowerModel{T<:AbstractPowerFormulation}
5252
var::Dict{Symbol,Any} # JuMP variables
5353
con::Dict{Symbol,Any} # JuMP constraint references
5454
cnw::Int # current network index value
55-
cph::Int # current phase index value
55+
ccnd::Int # current conductor index value
5656

5757
# Extension dictionary
5858
# Extensions should define a type to hold information particular to
@@ -75,17 +75,17 @@ function GenericPowerModel(data::Dict{String,Any}, T::DataType; ext = Dict{Strin
7575
nw_var = var[:nw][nw_id] = Dict{Symbol,Any}()
7676
nw_con = con[:nw][nw_id] = Dict{Symbol,Any}()
7777

78-
nw_var[:ph] = Dict{Int,Any}()
79-
nw_con[:ph] = Dict{Int,Any}()
78+
nw_var[:cnd] = Dict{Int,Any}()
79+
nw_con[:cnd] = Dict{Int,Any}()
8080

81-
for ph_id in nw[:phase_ids]
82-
nw_var[:ph][ph_id] = Dict{Symbol,Any}()
83-
nw_con[:ph][ph_id] = Dict{Symbol,Any}()
81+
for cnd_id in nw[:conductor_ids]
82+
nw_var[:cnd][cnd_id] = Dict{Symbol,Any}()
83+
nw_con[:cnd][cnd_id] = Dict{Symbol,Any}()
8484
end
8585
end
8686

8787
cnw = minimum([k for k in keys(var[:nw])])
88-
cph = minimum([k for k in keys(var[:nw][cnw][:ph])])
88+
ccnd = minimum([k for k in keys(var[:nw][cnw][:cnd])])
8989

9090
pm = GenericPowerModel{T}(
9191
Model(solver = solver), # model
@@ -96,22 +96,22 @@ function GenericPowerModel(data::Dict{String,Any}, T::DataType; ext = Dict{Strin
9696
var,
9797
con,
9898
cnw,
99-
cph,
99+
ccnd,
100100
ext
101101
)
102102

103103
return pm
104104
end
105105

106-
### Helper functions for working with multinetworks and multiphases
106+
### Helper functions for working with multinetworks and multiconductors
107107
ismultinetwork(pm::GenericPowerModel) = (length(pm.ref[:nw]) > 1)
108108
nw_ids(pm::GenericPowerModel) = keys(pm.ref[:nw])
109109
nws(pm::GenericPowerModel) = pm.ref[:nw]
110110

111-
ismultiphase(pm::GenericPowerModel, nw::Int) = haskey(pm.ref[:nw][nw], :phases)
112-
ismultiphase(pm::GenericPowerModel; nw::Int=pm.cnw) = haskey(pm.ref[:nw][nw], :phases)
113-
phase_ids(pm::GenericPowerModel, nw::Int) = pm.ref[:nw][nw][:phase_ids]
114-
phase_ids(pm::GenericPowerModel; nw::Int=pm.cnw) = pm.ref[:nw][nw][:phase_ids]
111+
ismulticonductor(pm::GenericPowerModel, nw::Int) = haskey(pm.ref[:nw][nw], :conductors)
112+
ismulticonductor(pm::GenericPowerModel; nw::Int=pm.cnw) = haskey(pm.ref[:nw][nw], :conductors)
113+
conductor_ids(pm::GenericPowerModel, nw::Int) = pm.ref[:nw][nw][:conductor_ids]
114+
conductor_ids(pm::GenericPowerModel; nw::Int=pm.cnw) = pm.ref[:nw][nw][:conductor_ids]
115115

116116

117117
ids(pm::GenericPowerModel, nw::Int, key::Symbol) = keys(pm.ref[:nw][nw][key])
@@ -122,35 +122,35 @@ ref(pm::GenericPowerModel, nw::Int) = pm.ref[:nw][nw]
122122
ref(pm::GenericPowerModel, nw::Int, key::Symbol) = pm.ref[:nw][nw][key]
123123
ref(pm::GenericPowerModel, nw::Int, key::Symbol, idx) = pm.ref[:nw][nw][key][idx]
124124
ref(pm::GenericPowerModel, nw::Int, key::Symbol, idx, param::String) = pm.ref[:nw][nw][key][idx][param]
125-
ref(pm::GenericPowerModel, nw::Int, key::Symbol, idx, param::String, ph::Int) = pm.ref[:nw][nw][key][idx][param][ph]
125+
ref(pm::GenericPowerModel, nw::Int, key::Symbol, idx, param::String, cnd::Int) = pm.ref[:nw][nw][key][idx][param][cnd]
126126

127127
ref(pm::GenericPowerModel; nw::Int=pm.cnw) = pm.ref[:nw][nw]
128128
ref(pm::GenericPowerModel, key::Symbol; nw::Int=pm.cnw) = pm.ref[:nw][nw][key]
129129
ref(pm::GenericPowerModel, key::Symbol, idx; nw::Int=pm.cnw) = pm.ref[:nw][nw][key][idx]
130-
ref(pm::GenericPowerModel, key::Symbol, idx, param::String; nw::Int=pm.cnw, ph::Int=pm.cph) = pm.ref[:nw][nw][key][idx][param][ph]
130+
ref(pm::GenericPowerModel, key::Symbol, idx, param::String; nw::Int=pm.cnw, cnd::Int=pm.ccnd) = pm.ref[:nw][nw][key][idx][param][cnd]
131131

132132

133133
Base.var(pm::GenericPowerModel, nw::Int) = pm.var[:nw][nw]
134134
Base.var(pm::GenericPowerModel, nw::Int, key::Symbol) = pm.var[:nw][nw][key]
135135
Base.var(pm::GenericPowerModel, nw::Int, key::Symbol, idx) = pm.var[:nw][nw][key][idx]
136-
Base.var(pm::GenericPowerModel, nw::Int, ph::Int) = pm.var[:nw][nw][:ph][ph]
137-
Base.var(pm::GenericPowerModel, nw::Int, ph::Int, key::Symbol) = pm.var[:nw][nw][:ph][ph][key]
138-
Base.var(pm::GenericPowerModel, nw::Int, ph::Int, key::Symbol, idx) = pm.var[:nw][nw][:ph][ph][key][idx]
136+
Base.var(pm::GenericPowerModel, nw::Int, cnd::Int) = pm.var[:nw][nw][:cnd][cnd]
137+
Base.var(pm::GenericPowerModel, nw::Int, cnd::Int, key::Symbol) = pm.var[:nw][nw][:cnd][cnd][key]
138+
Base.var(pm::GenericPowerModel, nw::Int, cnd::Int, key::Symbol, idx) = pm.var[:nw][nw][:cnd][cnd][key][idx]
139139

140-
Base.var(pm::GenericPowerModel; nw::Int=pm.cnw, ph::Int=pm.cph) = pm.var[:nw][nw][:ph][ph]
141-
Base.var(pm::GenericPowerModel, key::Symbol; nw::Int=pm.cnw, ph::Int=pm.cph) = pm.var[:nw][nw][:ph][ph][key]
142-
Base.var(pm::GenericPowerModel, key::Symbol, idx; nw::Int=pm.cnw, ph::Int=pm.cph) = pm.var[:nw][nw][:ph][ph][key][idx]
140+
Base.var(pm::GenericPowerModel; nw::Int=pm.cnw, cnd::Int=pm.ccnd) = pm.var[:nw][nw][:cnd][cnd]
141+
Base.var(pm::GenericPowerModel, key::Symbol; nw::Int=pm.cnw, cnd::Int=pm.ccnd) = pm.var[:nw][nw][:cnd][cnd][key]
142+
Base.var(pm::GenericPowerModel, key::Symbol, idx; nw::Int=pm.cnw, cnd::Int=pm.ccnd) = pm.var[:nw][nw][:cnd][cnd][key][idx]
143143

144144
con(pm::GenericPowerModel, nw::Int) = pm.con[:nw][nw]
145145
con(pm::GenericPowerModel, nw::Int, key::Symbol) = pm.con[:nw][nw][key]
146146
con(pm::GenericPowerModel, nw::Int, key::Symbol, idx) = pm.con[:nw][nw][key][idx]
147-
con(pm::GenericPowerModel, nw::Int, ph::Int) = pm.con[:nw][nw][:ph][ph]
148-
con(pm::GenericPowerModel, nw::Int, ph::Int, key::Symbol) = pm.con[:nw][nw][:ph][ph][key]
149-
con(pm::GenericPowerModel, nw::Int, ph::Int, key::Symbol, idx) = pm.con[:nw][nw][:ph][ph][key][idx]
147+
con(pm::GenericPowerModel, nw::Int, cnd::Int) = pm.con[:nw][nw][:cnd][cnd]
148+
con(pm::GenericPowerModel, nw::Int, cnd::Int, key::Symbol) = pm.con[:nw][nw][:cnd][cnd][key]
149+
con(pm::GenericPowerModel, nw::Int, cnd::Int, key::Symbol, idx) = pm.con[:nw][nw][:cnd][cnd][key][idx]
150150

151-
con(pm::GenericPowerModel; nw::Int=pm.cnw, ph::Int=pm.cph) = pm.con[:nw][nw][:ph][ph]
152-
con(pm::GenericPowerModel, key::Symbol; nw::Int=pm.cnw, ph::Int=pm.cph) = pm.con[:nw][nw][:ph][ph][key]
153-
con(pm::GenericPowerModel, key::Symbol, idx; nw::Int=pm.cnw, ph::Int=pm.cph) = pm.con[:nw][nw][:ph][ph][key][idx]
151+
con(pm::GenericPowerModel; nw::Int=pm.cnw, cnd::Int=pm.ccnd) = pm.con[:nw][nw][:cnd][cnd]
152+
con(pm::GenericPowerModel, key::Symbol; nw::Int=pm.cnw, cnd::Int=pm.ccnd) = pm.con[:nw][nw][:cnd][cnd][key]
153+
con(pm::GenericPowerModel, key::Symbol, idx; nw::Int=pm.cnw, cnd::Int=pm.ccnd) = pm.con[:nw][nw][:cnd][cnd][key][idx]
154154

155155

156156

@@ -193,16 +193,16 @@ function build_generic_model(file::String, model_constructor, post_method; kwar
193193
end
194194

195195
""
196-
function build_generic_model(data::Dict{String,Any}, model_constructor, post_method; multinetwork=false, multiphase=false, kwargs...)
196+
function build_generic_model(data::Dict{String,Any}, model_constructor, post_method; multinetwork=false, multiconductor=false, kwargs...)
197197
# NOTE, this model constructor will build the ref dict using the latest info from the data
198198
pm = model_constructor(data; kwargs...)
199199

200200
if !multinetwork && ismultinetwork(pm)
201201
error(LOGGER, "attempted to build a single-network model with multi-network data")
202202
end
203203

204-
if !multiphase && ismultiphase(pm)
205-
error(LOGGER, "attempted to build a single-phase model with multi-phase data")
204+
if !multiconductor && ismulticonductor(pm)
205+
error(LOGGER, "attempted to build a single-conductor model with multi-conductor data")
206206
end
207207

208208
post_method(pm)
@@ -272,10 +272,10 @@ function build_ref(data::Dict{String,Any})
272272
end
273273
end
274274

275-
if !haskey(ref, :phases)
276-
ref[:phase_ids] = 1:1
275+
if !haskey(ref, :conductors)
276+
ref[:conductor_ids] = 1:1
277277
else
278-
ref[:phase_ids] = 1:ref[:phases]
278+
ref[:conductor_ids] = 1:ref[:conductors]
279279
end
280280

281281
# filter turned off stuff
@@ -367,7 +367,7 @@ function build_ref(data::Dict{String,Any})
367367

368368
ref[:ref_buses] = ref_buses
369369

370-
ref[:buspairs] = buspair_parameters(ref[:arcs_from], ref[:branch], ref[:bus], ref[:phase_ids])
370+
ref[:buspairs] = buspair_parameters(ref[:arcs_from], ref[:branch], ref[:bus], ref[:conductor_ids])
371371

372372
off_angmin, off_angmax = calc_theta_delta_bounds(nw_data)
373373
ref[:off_angmin] = off_angmin
@@ -386,7 +386,7 @@ function build_ref(data::Dict{String,Any})
386386
end
387387
ref[:ne_bus_arcs] = ne_bus_arcs
388388

389-
ref[:ne_buspairs] = buspair_parameters(ref[:ne_arcs_from], ref[:ne_branch], ref[:bus], ref[:phase_ids])
389+
ref[:ne_buspairs] = buspair_parameters(ref[:ne_arcs_from], ref[:ne_branch], ref[:bus], ref[:conductor_ids])
390390
end
391391

392392
end
@@ -412,20 +412,20 @@ end
412412

413413

414414
"compute bus pair level structures"
415-
function buspair_parameters(arcs_from, branches, buses, phase_ids)
415+
function buspair_parameters(arcs_from, branches, buses, conductor_ids)
416416
buspair_indexes = collect(Set([(i,j) for (l,i,j) in arcs_from]))
417417

418-
bp_angmin = Dict([(bp, MultiPhaseVector([-Inf for h in phase_ids])) for bp in buspair_indexes])
419-
bp_angmax = Dict([(bp, MultiPhaseVector([ Inf for h in phase_ids])) for bp in buspair_indexes])
418+
bp_angmin = Dict([(bp, MultiConductorVector([-Inf for c in conductor_ids])) for bp in buspair_indexes])
419+
bp_angmax = Dict([(bp, MultiConductorVector([ Inf for c in conductor_ids])) for bp in buspair_indexes])
420420
bp_branch = Dict([(bp, Inf) for bp in buspair_indexes])
421421

422422
for (l,branch) in branches
423423
i = branch["f_bus"]
424424
j = branch["t_bus"]
425425

426-
for h in phase_ids
427-
bp_angmin[(i,j)][h] = max(bp_angmin[(i,j)][h], branch["angmin"][h])
428-
bp_angmax[(i,j)][h] = min(bp_angmax[(i,j)][h], branch["angmax"][h])
426+
for c in conductor_ids
427+
bp_angmin[(i,j)][c] = max(bp_angmin[(i,j)][c], branch["angmin"][c])
428+
bp_angmax[(i,j)][c] = min(bp_angmax[(i,j)][c], branch["angmax"][c])
429429
end
430430
bp_branch[(i,j)] = min(bp_branch[(i,j)], l)
431431
end

0 commit comments

Comments
 (0)