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

Polar Voltage Names #157

Merged
merged 10 commits into from
Aug 23, 2017
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ PowerModels.jl Change Log
- Eliminated usage of pm.model.ext, for details see [#149](https://github.com/lanl-ansi/PowerModels.jl/pull/149)
- Made solution default units per-unit (breaking)
- Removed deprecated bus-less constraint_theta_ref function (breaking)
- Renamed polar voltage variables v,t to vm,va (breaking)
- Renamed functions with phase_angle to voltage_angle (breaking)
- Renamed v_from and w_from variables to v_fr w_fr (breaking)
- Removed variable and constraint function return values (breaking)
- Moved check_cost_models into the objective building function
- Fixed out of range bug in calc_theta_delta_bounds
Expand Down
6 changes: 3 additions & 3 deletions docs/src/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ constraint_thermal_limit_to_ne
### Phase Angle Difference Constraints

```@docs
constraint_phase_angle_difference
constraint_phase_angle_difference_on_off
constraint_phase_angle_difference_ne
constraint_voltage_angle_difference
constraint_voltage_angle_difference_on_off
constraint_voltage_angle_difference_ne
```

### Loss Constraints
Expand Down
8 changes: 4 additions & 4 deletions docs/src/specifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ for (i,branch) in pm.ref[:branch]
constraint_ohms_yt_from(pm, branch)
constraint_ohms_yt_to(pm, branch)

constraint_phase_angle_difference(pm, branch)
constraint_voltage_angle_difference(pm, branch)

constraint_thermal_limit_from(pm, branch)
constraint_thermal_limit_to(pm, branch)
Expand Down Expand Up @@ -73,7 +73,7 @@ for (i,branch) in pm.ref[:branch]
constraint_ohms_yt_from_on_off(pm, branch)
constraint_ohms_yt_to_on_off(pm, branch)

constraint_phase_angle_difference_on_off(pm, branch)
constraint_voltage_angle_difference_on_off(pm, branch)

constraint_thermal_limit_from_on_off(pm, branch)
constraint_thermal_limit_to_on_off(pm, branch)
Expand Down Expand Up @@ -162,7 +162,7 @@ for (i,branch) in pm.ref[:branch]
constraint_ohms_yt_from(pm, branch)
constraint_ohms_yt_to(pm, branch)

constraint_phase_angle_difference(pm, branch)
constraint_voltage_angle_difference(pm, branch)

constraint_thermal_limit_from(pm, branch)
constraint_thermal_limit_to(pm, branch)
Expand All @@ -172,7 +172,7 @@ for (i,branch) in pm.ref[:ne_branch]
constraint_ohms_yt_from_ne(pm, branch)
constraint_ohms_yt_to_ne(pm, branch)

constraint_phase_angle_difference_ne(pm, branch)
constraint_voltage_angle_difference_ne(pm, branch)

constraint_thermal_limit_from_ne(pm, branch)
constraint_thermal_limit_to_ne(pm, branch)
Expand Down
8 changes: 4 additions & 4 deletions src/core/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ function buspair_parameters(arcs_from, branches, buses)
"angmax"=>bp_angmax[(i,j)],
"rate_a"=>branches[bp_line[(i,j)]]["rate_a"],
"tap"=>branches[bp_line[(i,j)]]["tap"],
"v_from_min"=>buses[i]["vmin"],
"v_from_max"=>buses[i]["vmax"],
"v_to_min"=>buses[j]["vmin"],
"v_to_max"=>buses[j]["vmax"]
"vm_fr_min"=>buses[i]["vmin"],
"vm_fr_max"=>buses[i]["vmax"],
"vm_to_min"=>buses[j]["vmin"],
"vm_to_max"=>buses[j]["vmax"]
)) for (i,j) in buspair_indexes])

return buspairs
Expand Down
12 changes: 6 additions & 6 deletions src/core/constraint_template.jl
Original file line number Diff line number Diff line change
Expand Up @@ -364,40 +364,40 @@ end
### Branch - Phase Angle Difference Constraints ###

""
function constraint_phase_angle_difference(pm::GenericPowerModel, branch)
function constraint_voltage_angle_difference(pm::GenericPowerModel, branch)
i = branch["index"]
f_bus = branch["f_bus"]
t_bus = branch["t_bus"]
pair = (f_bus, t_bus)
buspair = pm.ref[:buspairs][pair]

if buspair["line"] == i
constraint_phase_angle_difference(pm, f_bus, t_bus, buspair["angmin"], buspair["angmax"])
constraint_voltage_angle_difference(pm, f_bus, t_bus, buspair["angmin"], buspair["angmax"])
end
end

""
function constraint_phase_angle_difference_on_off(pm::GenericPowerModel, branch)
function constraint_voltage_angle_difference_on_off(pm::GenericPowerModel, branch)
i = branch["index"]
f_bus = branch["f_bus"]
t_bus = branch["t_bus"]

t_min = pm.ref[:off_angmin]
t_max = pm.ref[:off_angmax]

constraint_phase_angle_difference_on_off(pm, i, f_bus, t_bus, branch["angmin"], branch["angmax"], t_min, t_max)
constraint_voltage_angle_difference_on_off(pm, i, f_bus, t_bus, branch["angmin"], branch["angmax"], t_min, t_max)
end

""
function constraint_phase_angle_difference_ne(pm::GenericPowerModel, branch)
function constraint_voltage_angle_difference_ne(pm::GenericPowerModel, branch)
i = branch["index"]
f_bus = branch["f_bus"]
t_bus = branch["t_bus"]

t_min = pm.ref[:off_angmin]
t_max = pm.ref[:off_angmax]

constraint_phase_angle_difference_ne(pm, i, f_bus, t_bus, branch["angmin"], branch["angmax"], t_min, t_max)
constraint_voltage_angle_difference_ne(pm, i, f_bus, t_bus, branch["angmin"], branch["angmax"], t_min, t_max)
end

### Branch - Loss Constraints ###
Expand Down
26 changes: 13 additions & 13 deletions src/core/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ function calc_voltage_product_bounds(buspairs)
i,j = bp

if buspair["angmin"] >= 0
wr_max[bp] = buspair["v_from_max"]*buspair["v_to_max"]*cos(buspair["angmin"])
wr_min[bp] = buspair["v_from_min"]*buspair["v_to_min"]*cos(buspair["angmax"])
wi_max[bp] = buspair["v_from_max"]*buspair["v_to_max"]*sin(buspair["angmax"])
wi_min[bp] = buspair["v_from_min"]*buspair["v_to_min"]*sin(buspair["angmin"])
wr_max[bp] = buspair["vm_fr_max"]*buspair["vm_to_max"]*cos(buspair["angmin"])
wr_min[bp] = buspair["vm_fr_min"]*buspair["vm_to_min"]*cos(buspair["angmax"])
wi_max[bp] = buspair["vm_fr_max"]*buspair["vm_to_max"]*sin(buspair["angmax"])
wi_min[bp] = buspair["vm_fr_min"]*buspair["vm_to_min"]*sin(buspair["angmin"])
end
if buspair["angmax"] <= 0
wr_max[bp] = buspair["v_from_max"]*buspair["v_to_max"]*cos(buspair["angmax"])
wr_min[bp] = buspair["v_from_min"]*buspair["v_to_min"]*cos(buspair["angmin"])
wi_max[bp] = buspair["v_from_min"]*buspair["v_to_min"]*sin(buspair["angmax"])
wi_min[bp] = buspair["v_from_max"]*buspair["v_to_max"]*sin(buspair["angmin"])
wr_max[bp] = buspair["vm_fr_max"]*buspair["vm_to_max"]*cos(buspair["angmax"])
wr_min[bp] = buspair["vm_fr_min"]*buspair["vm_to_min"]*cos(buspair["angmin"])
wi_max[bp] = buspair["vm_fr_min"]*buspair["vm_to_min"]*sin(buspair["angmax"])
wi_min[bp] = buspair["vm_fr_max"]*buspair["vm_to_max"]*sin(buspair["angmin"])
end
if buspair["angmin"] < 0 && buspair["angmax"] > 0
wr_max[bp] = buspair["v_from_max"]*buspair["v_to_max"]*1.0
wr_min[bp] = buspair["v_from_min"]*buspair["v_to_min"]*min(cos(buspair["angmin"]), cos(buspair["angmax"]))
wi_max[bp] = buspair["v_from_max"]*buspair["v_to_max"]*sin(buspair["angmax"])
wi_min[bp] = buspair["v_from_max"]*buspair["v_to_max"]*sin(buspair["angmin"])
wr_max[bp] = buspair["vm_fr_max"]*buspair["vm_to_max"]*1.0
wr_min[bp] = buspair["vm_fr_min"]*buspair["vm_to_min"]*min(cos(buspair["angmin"]), cos(buspair["angmax"]))
wi_max[bp] = buspair["vm_fr_max"]*buspair["vm_to_max"]*sin(buspair["angmax"])
wi_min[bp] = buspair["vm_fr_max"]*buspair["vm_to_max"]*sin(buspair["angmin"])
end
end

Expand Down Expand Up @@ -308,7 +308,7 @@ function make_mixed_units(data::Dict{String,Any})
end

"checks that phase angle differences are within 90 deg., if not tightens"
function check_phase_angle_differences(data, default_pad = 1.0472)
function check_voltage_angle_differences(data, default_pad = 1.0472)
assert("per_unit" in keys(data) && data["per_unit"])

for (i, branch) in data["branch"]
Expand Down
4 changes: 2 additions & 2 deletions src/core/solution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ end

""
function add_bus_voltage_setpoint(sol, pm::GenericPowerModel)
add_setpoint(sol, pm, "bus", "bus_i", "vm", :v)
add_setpoint(sol, pm, "bus", "bus_i", "va", :t)
add_setpoint(sol, pm, "bus", "bus_i", "vm", :vm)
add_setpoint(sol, pm, "bus", "bus_i", "va", :va)
end

""
Expand Down
38 changes: 19 additions & 19 deletions src/core/variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ end


"variable: `t[i]` for `i` in `bus`es"
function variable_phase_angle(pm::GenericPowerModel; bounded::Bool = true)
pm.var[:t] = @variable(pm.model,
[i in keys(pm.ref[:bus])], basename="t",
function variable_voltage_angle(pm::GenericPowerModel; bounded::Bool = true)
pm.var[:va] = @variable(pm.model,
[i in keys(pm.ref[:bus])], basename="va",
start = getstart(pm.ref[:bus], i, "t_start")
)
end

"variable: `v[i]` for `i` in `bus`es"
function variable_voltage_magnitude(pm::GenericPowerModel; bounded = true)
if bounded
pm.var[:v] = @variable(pm.model,
[i in keys(pm.ref[:bus])], basename="v",
pm.var[:vm] = @variable(pm.model,
[i in keys(pm.ref[:bus])], basename="vm",
lowerbound = pm.ref[:bus][i]["vmin"],
upperbound = pm.ref[:bus][i]["vmax"],
start = getstart(pm.ref[:bus], i, "v_start", 1.0)
)
else
pm.var[:v] = @variable(pm.model,
[i in keys(pm.ref[:bus])], basename="v",
pm.var[:vm] = @variable(pm.model,
[i in keys(pm.ref[:bus])], basename="vm",
lowerbound = 0,
start = getstart(pm.ref[:bus], i, "v_start", 1.0))
end
Expand Down Expand Up @@ -57,29 +57,29 @@ end



"variable: `0 <= v_from[l] <= buses[branches[l][\"f_bus\"]][\"vmax\"]` for `l` in `branch`es"
"variable: `0 <= vm_fr[l] <= buses[branches[l][\"f_bus\"]][\"vmax\"]` for `l` in `branch`es"
function variable_voltage_magnitude_from_on_off(pm::GenericPowerModel)
buses = pm.ref[:bus]
branches = pm.ref[:branch]

pm.var[:v_from] = @variable(pm.model,
[i in keys(pm.ref[:branch])], basename="v_from",
pm.var[:vm_fr] = @variable(pm.model,
[i in keys(pm.ref[:branch])], basename="vm_fr",
lowerbound = 0,
upperbound = buses[branches[i]["f_bus"]]["vmax"],
start = getstart(pm.ref[:bus], i, "v_from_start", 1.0)
start = getstart(pm.ref[:bus], i, "vm_fr_start", 1.0)
)
end

"variable: `0 <= v_to[l] <= buses[branches[l][\"t_bus\"]][\"vmax\"]` for `l` in `branch`es"
"variable: `0 <= vm_to[l] <= buses[branches[l][\"t_bus\"]][\"vmax\"]` for `l` in `branch`es"
function variable_voltage_magnitude_to_on_off(pm::GenericPowerModel)
buses = pm.ref[:bus]
branches = pm.ref[:branch]

pm.var[:v_to] = @variable(pm.model,
[i in keys(pm.ref[:branch])], basename="v_to",
pm.var[:vm_to] = @variable(pm.model,
[i in keys(pm.ref[:branch])], basename="vm_to",
lowerbound = 0,
upperbound = buses[branches[i]["t_bus"]]["vmax"],
start = getstart(pm.ref[:bus], i, "v_to_start", 1.0)
start = getstart(pm.ref[:bus], i, "vm_to_start", 1.0)
)
end

Expand All @@ -102,16 +102,16 @@ function variable_voltage_magnitude_sqr(pm::GenericPowerModel; bounded = true)
end
end

"variable: `0 <= w_from[l] <= buses[branches[l][\"f_bus\"]][\"vmax\"]^2` for `l` in `branch`es"
"variable: `0 <= w_fr[l] <= buses[branches[l][\"f_bus\"]][\"vmax\"]^2` for `l` in `branch`es"
function variable_voltage_magnitude_sqr_from_on_off(pm::GenericPowerModel)
buses = pm.ref[:bus]
branches = pm.ref[:branch]

pm.var[:w_from] = @variable(pm.model,
[i in keys(pm.ref[:branch])], basename="w_from",
pm.var[:w_fr] = @variable(pm.model,
[i in keys(pm.ref[:branch])], basename="w_fr",
lowerbound = 0,
upperbound = buses[branches[i]["f_bus"]]["vmax"]^2,
start = getstart(pm.ref[:bus], i, "w_from_start", 1.001)
start = getstart(pm.ref[:bus], i, "w_fr_start", 1.001)
)
end

Expand Down
Loading