diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a9c00b1f..bb0f6b7ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/docs/src/constraints.md b/docs/src/constraints.md index 605a527a5..f0d43e43c 100644 --- a/docs/src/constraints.md +++ b/docs/src/constraints.md @@ -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 diff --git a/docs/src/specifications.md b/docs/src/specifications.md index cbd5721e1..f83f78e65 100644 --- a/docs/src/specifications.md +++ b/docs/src/specifications.md @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/src/core/base.jl b/src/core/base.jl index f61d44005..fc076553c 100644 --- a/src/core/base.jl +++ b/src/core/base.jl @@ -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 diff --git a/src/core/constraint_template.jl b/src/core/constraint_template.jl index 312ef3dfa..fbaebe63f 100644 --- a/src/core/constraint_template.jl +++ b/src/core/constraint_template.jl @@ -364,7 +364,7 @@ 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"] @@ -372,12 +372,12 @@ function constraint_phase_angle_difference(pm::GenericPowerModel, branch) 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"] @@ -385,11 +385,11 @@ function constraint_phase_angle_difference_on_off(pm::GenericPowerModel, branch) 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"] @@ -397,7 +397,7 @@ function constraint_phase_angle_difference_ne(pm::GenericPowerModel, branch) 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 ### diff --git a/src/core/data.jl b/src/core/data.jl index 701373b2c..a29e0a098 100644 --- a/src/core/data.jl +++ b/src/core/data.jl @@ -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 @@ -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"] diff --git a/src/core/solution.jl b/src/core/solution.jl index 5dd4926d5..6f3253eb1 100644 --- a/src/core/solution.jl +++ b/src/core/solution.jl @@ -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 "" diff --git a/src/core/variable.jl b/src/core/variable.jl index 66cf29cef..bf4b53369 100644 --- a/src/core/variable.jl +++ b/src/core/variable.jl @@ -10,9 +10,9 @@ 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 @@ -20,15 +20,15 @@ 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 @@ -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 @@ -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 diff --git a/src/form/acp.jl b/src/form/acp.jl index 0c9eb800e..c49502f1b 100644 --- a/src/form/acp.jl +++ b/src/form/acp.jl @@ -19,7 +19,7 @@ ACPPowerModel(data::Dict{String,Any}; kwargs...) = "" function variable_voltage{T <: AbstractACPForm}(pm::GenericPowerModel{T}; kwargs...) - variable_phase_angle(pm; kwargs...) + variable_voltage_angle(pm; kwargs...) variable_voltage_magnitude(pm; kwargs...) end @@ -37,7 +37,7 @@ end "`vm - epsilon <= v[i] <= vm + epsilon`" function constraint_voltage_magnitude_setpoint{T <: AbstractACPForm}(pm::GenericPowerModel{T}, i, vm, epsilon) - v = pm.var[:v][i] + v = pm.var[:vm][i] if epsilon == 0.0 @constraint(pm.model, v == vm) @@ -49,22 +49,22 @@ end """ ''' -v_from - epsilon <= v[i] <= v_from + epsilon -v_to - epsilon <= v[i] <= v_to + epsilon +vm_from - epsilon <= v[i] <= vm_from + epsilon +vm_to - epsilon <= v[i] <= vm_to + epsilon ''' """ function constraint_voltage_dcline_setpoint{T <: AbstractACPForm}(pm::GenericPowerModel{T}, f_bus, t_bus, vf, vt, epsilon) - v_f = pm.var[:v][f_bus] - v_t = pm.var[:v][t_bus] + vm_fr = pm.var[:vm][f_bus] + vm_to = pm.var[:vm][t_bus] if epsilon == 0.0 - @constraint(pm.model, v_f == vf) - @constraint(pm.model, v_t == vt) + @constraint(pm.model, vm_fr == vf) + @constraint(pm.model, vm_to == vt) else - @constraint(pm.model, v_f <= vf + epsilon) - @constraint(pm.model, v_f >= vf - epsilon) - @constraint(pm.model, v_t <= vt + epsilon) - @constraint(pm.model, v_t >= vt - epsilon) + @constraint(pm.model, vm_fr <= vf + epsilon) + @constraint(pm.model, vm_fr >= vf - epsilon) + @constraint(pm.model, vm_to <= vt + epsilon) + @constraint(pm.model, vm_to >= vt - epsilon) end end @@ -75,7 +75,7 @@ sum(q[a] for a in bus_arcs) + sum(q_dc[a_dc] for a_dc in bus_arcs_dc) == sum(qg[ ``` """ function constraint_kcl_shunt{T <: AbstractACPForm}(pm::GenericPowerModel{T}, i, bus_arcs, bus_arcs_dc, bus_gens, pd, qd, gs, bs) - v = pm.var[:v][i] + vm = pm.var[:vm][i] p = pm.var[:p] q = pm.var[:q] pg = pm.var[:pg] @@ -83,8 +83,8 @@ function constraint_kcl_shunt{T <: AbstractACPForm}(pm::GenericPowerModel{T}, i, p_dc = pm.var[:p_dc] q_dc = pm.var[:q_dc] - @constraint(pm.model, sum(p[a] for a in bus_arcs) + sum(p_dc[a_dc] for a_dc in bus_arcs_dc) == sum(pg[g] for g in bus_gens) - pd - gs*v^2) - @constraint(pm.model, sum(q[a] for a in bus_arcs) + sum(q_dc[a_dc] for a_dc in bus_arcs_dc) == sum(qg[g] for g in bus_gens) - qd + bs*v^2) + @constraint(pm.model, sum(p[a] for a in bus_arcs) + sum(p_dc[a_dc] for a_dc in bus_arcs_dc) == sum(pg[g] for g in bus_gens) - pd - gs*vm^2) + @constraint(pm.model, sum(q[a] for a in bus_arcs) + sum(q_dc[a_dc] for a_dc in bus_arcs_dc) == sum(qg[g] for g in bus_gens) - qd + bs*vm^2) end """ @@ -94,7 +94,7 @@ sum(q[a] for a in bus_arcs) + sum(p_dc[a_dc] for a_dc in bus_arcs_dc) + sum(q_ne ``` """ function constraint_kcl_shunt_ne{T <: AbstractACPForm}(pm::GenericPowerModel{T}, i, bus_arcs, bus_arcs_dc, bus_arcs_ne, bus_gens, pd, qd, gs, bs) - v = pm.var[:v][i] + vm = pm.var[:vm][i] p = pm.var[:p] q = pm.var[:q] p_ne = pm.var[:p_ne] @@ -104,8 +104,8 @@ function constraint_kcl_shunt_ne{T <: AbstractACPForm}(pm::GenericPowerModel{T}, p_dc = pm.var[:p_dc] q_dc = pm.var[:q_dc] - @constraint(pm.model, sum(p[a] for a in bus_arcs) + sum(p_dc[a_dc] for a_dc in bus_arcs_dc) + sum(p_ne[a] for a in bus_arcs_ne) == sum(pg[g] for g in bus_gens) - pd - gs*v^2) - @constraint(pm.model, sum(q[a] for a in bus_arcs) + sum(q_dc[a_dc] for a_dc in bus_arcs_dc) + sum(q_ne[a] for a in bus_arcs_ne) == sum(qg[g] for g in bus_gens) - qd + bs*v^2) + @constraint(pm.model, sum(p[a] for a in bus_arcs) + sum(p_dc[a_dc] for a_dc in bus_arcs_dc) + sum(p_ne[a] for a in bus_arcs_ne) == sum(pg[g] for g in bus_gens) - pd - gs*vm^2) + @constraint(pm.model, sum(q[a] for a in bus_arcs) + sum(q_dc[a_dc] for a_dc in bus_arcs_dc) + sum(q_ne[a] for a in bus_arcs_ne) == sum(qg[g] for g in bus_gens) - qd + bs*vm^2) end """ @@ -119,13 +119,13 @@ q[f_idx] == -(b+c/2)/tm*v[f_bus]^2 - (-b*tr-g*ti)/tm*(v[f_bus]*v[t_bus]*cos(t[f_ function constraint_ohms_yt_from{T <: AbstractACPForm}(pm::GenericPowerModel{T}, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, ti, tm) p_fr = pm.var[:p][f_idx] q_fr = pm.var[:q][f_idx] - v_fr = pm.var[:v][f_bus] - v_to = pm.var[:v][t_bus] - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] + vm_fr = pm.var[:vm][f_bus] + vm_to = pm.var[:vm][t_bus] + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] - @NLconstraint(pm.model, p_fr == g/tm*v_fr^2 + (-g*tr+b*ti)/tm*(v_fr*v_to*cos(t_fr-t_to)) + (-b*tr-g*ti)/tm*(v_fr*v_to*sin(t_fr-t_to)) ) - @NLconstraint(pm.model, q_fr == -(b+c/2)/tm*v_fr^2 - (-b*tr-g*ti)/tm*(v_fr*v_to*cos(t_fr-t_to)) + (-g*tr+b*ti)/tm*(v_fr*v_to*sin(t_fr-t_to)) ) + @NLconstraint(pm.model, p_fr == g/tm*vm_fr^2 + (-g*tr+b*ti)/tm*(vm_fr*vm_to*cos(va_fr-va_to)) + (-b*tr-g*ti)/tm*(vm_fr*vm_to*sin(va_fr-va_to)) ) + @NLconstraint(pm.model, q_fr == -(b+c/2)/tm*vm_fr^2 - (-b*tr-g*ti)/tm*(vm_fr*vm_to*cos(va_fr-va_to)) + (-g*tr+b*ti)/tm*(vm_fr*vm_to*sin(va_fr-va_to)) ) end """ @@ -139,13 +139,13 @@ q[t_idx] == -(b+c/2)*v[t_bus]^2 - (-b*tr+g*ti)/tm*(v[t_bus]*v[f_bus]*cos(t[f_bus function constraint_ohms_yt_to{T <: AbstractACPForm}(pm::GenericPowerModel{T}, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, ti, tm) p_to = pm.var[:p][t_idx] q_to = pm.var[:q][t_idx] - v_fr = pm.var[:v][f_bus] - v_to = pm.var[:v][t_bus] - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] + vm_fr = pm.var[:vm][f_bus] + vm_to = pm.var[:vm][t_bus] + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] - @NLconstraint(pm.model, p_to == g*v_to^2 + (-g*tr-b*ti)/tm*(v_to*v_fr*cos(t_to-t_fr)) + (-b*tr+g*ti)/tm*(v_to*v_fr*sin(t_to-t_fr)) ) - @NLconstraint(pm.model, q_to == -(b+c/2)*v_to^2 - (-b*tr+g*ti)/tm*(v_to*v_fr*cos(t_to-t_fr)) + (-g*tr-b*ti)/tm*(v_to*v_fr*sin(t_to-t_fr)) ) + @NLconstraint(pm.model, p_to == g*vm_to^2 + (-g*tr-b*ti)/tm*(vm_to*vm_fr*cos(va_to-va_fr)) + (-b*tr+g*ti)/tm*(vm_to*vm_fr*sin(va_to-va_fr)) ) + @NLconstraint(pm.model, q_to == -(b+c/2)*vm_to^2 - (-b*tr+g*ti)/tm*(vm_to*vm_fr*cos(va_to-va_fr)) + (-g*tr-b*ti)/tm*(vm_to*vm_fr*sin(va_to-va_fr)) ) end """ @@ -159,13 +159,13 @@ q[f_idx] == -(b+c/2)*(v[f_bus]/tr)^2 + b*v[f_bus]/tr*v[t_bus]*cos(t[f_bus]-t[t_b function constraint_ohms_y_from{T <: AbstractACPForm}(pm::GenericPowerModel{T}, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, as) p_fr = pm.var[:p][f_idx] q_fr = pm.var[:q][f_idx] - v_fr = pm.var[:v][f_bus] - v_to = pm.var[:v][t_bus] - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] + vm_fr = pm.var[:vm][f_bus] + vm_to = pm.var[:vm][t_bus] + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] - @NLconstraint(pm.model, p_fr == g*(v_fr/tr)^2 + -g*v_fr/tr*v_to*cos(t_fr-t_to-as) + -b*v_fr/tr*v_to*sin(t_fr-t_to-as) ) - @NLconstraint(pm.model, q_fr == -(b+c/2)*(v_fr/tr)^2 + b*v_fr/tr*v_to*cos(t_fr-t_to-as) + -g*v_fr/tr*v_to*sin(t_fr-t_to-as) ) + @NLconstraint(pm.model, p_fr == g*(vm_fr/tr)^2 + -g*vm_fr/tr*vm_to*cos(va_fr-va_to-as) + -b*vm_fr/tr*vm_to*sin(va_fr-va_to-as) ) + @NLconstraint(pm.model, q_fr == -(b+c/2)*(vm_fr/tr)^2 + b*vm_fr/tr*vm_to*cos(va_fr-va_to-as) + -g*vm_fr/tr*vm_to*sin(va_fr-va_to-as) ) end """ @@ -179,19 +179,19 @@ q_to == -(b+c/2)*v[t_bus]^2 + b*v[t_bus]*v[f_bus]/tr*cos(t[f_bus]-t[t_bus]+as) + function constraint_ohms_y_to{T <: AbstractACPForm}(pm::GenericPowerModel{T}, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, as) p_to = pm.var[:p][t_idx] q_to = pm.var[:q][t_idx] - v_fr = pm.var[:v][f_bus] - v_to = pm.var[:v][t_bus] - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] + vm_fr = pm.var[:vm][f_bus] + vm_to = pm.var[:vm][t_bus] + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] - @NLconstraint(pm.model, p_to == g*v_to^2 + -g*v_to*v_fr/tr*cos(t_to-t_fr+as) + -b*v_to*v_fr/tr*sin(t_to-t_fr+as) ) - @NLconstraint(pm.model, q_to == -(b+c/2)*v_to^2 + b*v_to*v_fr/tr*cos(t_to-t_fr+as) + -g*v_to*v_fr/tr*sin(t_to-t_fr+as) ) + @NLconstraint(pm.model, p_to == g*vm_to^2 + -g*vm_to*vm_fr/tr*cos(va_to-va_fr+as) + -b*vm_to*vm_fr/tr*sin(va_to-va_fr+as) ) + @NLconstraint(pm.model, q_to == -(b+c/2)*vm_to^2 + b*vm_to*vm_fr/tr*cos(va_to-va_fr+as) + -g*vm_to*vm_fr/tr*sin(va_to-va_fr+as) ) end "" function variable_voltage_on_off{T <: AbstractACPForm}(pm::GenericPowerModel{T}; kwargs...) - variable_phase_angle(pm; kwargs...) + variable_voltage_angle(pm; kwargs...) variable_voltage_magnitude(pm; kwargs...) end @@ -207,14 +207,14 @@ q[f_idx] == z*(-(b+c/2)/tm*v[f_bus]^2 - (-b*tr-g*ti)/tm*(v[f_bus]*v[t_bus]*cos(t function constraint_ohms_yt_from_on_off{T <: AbstractACPForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, ti, tm, t_min, t_max) p_fr = pm.var[:p][f_idx] q_fr = pm.var[:q][f_idx] - v_fr = pm.var[:v][f_bus] - v_to = pm.var[:v][t_bus] - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] + vm_fr = pm.var[:vm][f_bus] + vm_to = pm.var[:vm][t_bus] + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] z = pm.var[:line_z][i] - @NLconstraint(pm.model, p_fr == z*(g/tm*v_fr^2 + (-g*tr+b*ti)/tm*(v_fr*v_to*cos(t_fr-t_to)) + (-b*tr-g*ti)/tm*(v_fr*v_to*sin(t_fr-t_to))) ) - @NLconstraint(pm.model, q_fr == z*(-(b+c/2)/tm*v_fr^2 - (-b*tr-g*ti)/tm*(v_fr*v_to*cos(t_fr-t_to)) + (-g*tr+b*ti)/tm*(v_fr*v_to*sin(t_fr-t_to))) ) + @NLconstraint(pm.model, p_fr == z*(g/tm*vm_fr^2 + (-g*tr+b*ti)/tm*(vm_fr*vm_to*cos(va_fr-va_to)) + (-b*tr-g*ti)/tm*(vm_fr*vm_to*sin(va_fr-va_to))) ) + @NLconstraint(pm.model, q_fr == z*(-(b+c/2)/tm*vm_fr^2 - (-b*tr-g*ti)/tm*(vm_fr*vm_to*cos(va_fr-va_to)) + (-g*tr+b*ti)/tm*(vm_fr*vm_to*sin(va_fr-va_to))) ) end """ @@ -226,14 +226,14 @@ q[t_idx] == z*(-(b+c/2)*v[t_bus]^2 - (-b*tr+g*ti)/tm*(v[t_bus]*v[f_bus]*cos(t[f_ function constraint_ohms_yt_to_on_off{T <: AbstractACPForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, ti, tm, t_min, t_max) p_to = pm.var[:p][t_idx] q_to = pm.var[:q][t_idx] - v_fr = pm.var[:v][f_bus] - v_to = pm.var[:v][t_bus] - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] + vm_fr = pm.var[:vm][f_bus] + vm_to = pm.var[:vm][t_bus] + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] z = pm.var[:line_z][i] - @NLconstraint(pm.model, p_to == z*(g*v_to^2 + (-g*tr-b*ti)/tm*(v_to*v_fr*cos(t_to-t_fr)) + (-b*tr+g*ti)/tm*(v_to*v_fr*sin(t_to-t_fr))) ) - @NLconstraint(pm.model, q_to == z*(-(b+c/2)*v_to^2 - (-b*tr+g*ti)/tm*(v_to*v_fr*cos(t_to-t_fr)) + (-g*tr-b*ti)/tm*(v_to*v_fr*sin(t_to-t_fr))) ) + @NLconstraint(pm.model, p_to == z*(g*vm_to^2 + (-g*tr-b*ti)/tm*(vm_to*vm_fr*cos(va_to-va_fr)) + (-b*tr+g*ti)/tm*(vm_to*vm_fr*sin(va_to-va_fr))) ) + @NLconstraint(pm.model, q_to == z*(-(b+c/2)*vm_to^2 - (-b*tr+g*ti)/tm*(vm_to*vm_fr*cos(va_to-va_fr)) + (-g*tr-b*ti)/tm*(vm_to*vm_fr*sin(va_to-va_fr))) ) end """ @@ -245,14 +245,14 @@ q_ne[f_idx] == z*(-(b+c/2)/tm*v[f_bus]^2 - (-b*tr-g*ti)/tm*(v[f_bus]*v[t_bus]*co function constraint_ohms_yt_from_ne{T <: AbstractACPForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, ti, tm, t_min, t_max) p_fr = pm.var[:p_ne][f_idx] q_fr = pm.var[:q_ne][f_idx] - v_fr = pm.var[:v][f_bus] - v_to = pm.var[:v][t_bus] - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] + vm_fr = pm.var[:vm][f_bus] + vm_to = pm.var[:vm][t_bus] + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] z = pm.var[:line_ne][i] - @NLconstraint(pm.model, p_fr == z*(g/tm*v_fr^2 + (-g*tr+b*ti)/tm*(v_fr*v_to*cos(t_fr-t_to)) + (-b*tr-g*ti)/tm*(v_fr*v_to*sin(t_fr-t_to))) ) - @NLconstraint(pm.model, q_fr == z*(-(b+c/2)/tm*v_fr^2 - (-b*tr-g*ti)/tm*(v_fr*v_to*cos(t_fr-t_to)) + (-g*tr+b*ti)/tm*(v_fr*v_to*sin(t_fr-t_to))) ) + @NLconstraint(pm.model, p_fr == z*(g/tm*vm_fr^2 + (-g*tr+b*ti)/tm*(vm_fr*vm_to*cos(va_fr-va_to)) + (-b*tr-g*ti)/tm*(vm_fr*vm_to*sin(va_fr-va_to))) ) + @NLconstraint(pm.model, q_fr == z*(-(b+c/2)/tm*vm_fr^2 - (-b*tr-g*ti)/tm*(vm_fr*vm_to*cos(va_fr-va_to)) + (-g*tr+b*ti)/tm*(vm_fr*vm_to*sin(va_fr-va_to))) ) end """ @@ -264,34 +264,34 @@ q_ne[t_idx] == z*(-(b+c/2)*v[t_bus]^2 - (-b*tr+g*ti)/tm*(v[t_bus]*v[f_bus]*cos(t function constraint_ohms_yt_to_ne{T <: AbstractACPForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, ti, tm, t_min, t_max) p_to = pm.var[:p_ne][t_idx] q_to = pm.var[:q_ne][t_idx] - v_fr = pm.var[:v][f_bus] - v_to = pm.var[:v][t_bus] - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] + vm_fr = pm.var[:vm][f_bus] + vm_to = pm.var[:vm][t_bus] + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] z = pm.var[:line_ne][i] - @NLconstraint(pm.model, p_to == z*(g*v_to^2 + (-g*tr-b*ti)/tm*(v_to*v_fr*cos(t_to-t_fr)) + (-b*tr+g*ti)/tm*(v_to*v_fr*sin(t_to-t_fr))) ) - @NLconstraint(pm.model, q_to == z*(-(b+c/2)*v_to^2 - (-b*tr+g*ti)/tm*(v_to*v_fr*cos(t_to-t_fr)) + (-g*tr-b*ti)/tm*(v_to*v_fr*sin(t_to-t_fr))) ) + @NLconstraint(pm.model, p_to == z*(g*vm_to^2 + (-g*tr-b*ti)/tm*(vm_to*vm_fr*cos(va_to-va_fr)) + (-b*tr+g*ti)/tm*(vm_to*vm_fr*sin(va_to-va_fr))) ) + @NLconstraint(pm.model, q_to == z*(-(b+c/2)*vm_to^2 - (-b*tr+g*ti)/tm*(vm_to*vm_fr*cos(va_to-va_fr)) + (-g*tr-b*ti)/tm*(vm_to*vm_fr*sin(va_to-va_fr))) ) end "`angmin <= line_z[i]*(t[f_bus] - t[t_bus]) <= angmax`" -function constraint_phase_angle_difference_on_off{T <: AbstractACPForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, angmin, angmax, t_min, t_max) - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] +function constraint_voltage_angle_difference_on_off{T <: AbstractACPForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, angmin, angmax, t_min, t_max) + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] z = pm.var[:line_z][i] - @constraint(pm.model, z*(t_fr - t_to) <= angmax) - @constraint(pm.model, z*(t_fr - t_to) >= angmin) + @constraint(pm.model, z*(va_fr - va_to) <= angmax) + @constraint(pm.model, z*(va_fr - va_to) >= angmin) end "`angmin <= line_ne[i]*(t[f_bus] - t[t_bus]) <= angmax`" -function constraint_phase_angle_difference_ne{T <: AbstractACPForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, angmin, angmax, t_min, t_max) - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] +function constraint_voltage_angle_difference_ne{T <: AbstractACPForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, angmin, angmax, t_min, t_max) + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] z = pm.var[:line_ne][i] - @constraint(pm.model, z*(t_fr - t_to) <= angmax) - @constraint(pm.model, z*(t_fr - t_to) >= angmin) + @constraint(pm.model, z*(va_fr - va_to) <= angmax) + @constraint(pm.model, z*(va_fr - va_to) >= angmin) end """ @@ -301,15 +301,15 @@ q[f_idx] + q[t_idx] >= -c/2*(v[f_bus]^2/tr^2 + v[t_bus]^2) ``` """ function constraint_loss_lb{T <: AbstractACPForm}(pm::GenericPowerModel{T}, f_bus, t_bus, f_idx, t_idx, c, tr) - v_fr = pm.var[:v][f_bus] - v_to = pm.var[:v][t_bus] + vm_fr = pm.var[:vm][f_bus] + vm_to = pm.var[:vm][t_bus] p_fr = pm.var[:p][f_idx] q_fr = pm.var[:q][f_idx] p_to = pm.var[:p][t_idx] q_to = pm.var[:q][t_idx] @constraint(m, p_fr + p_to >= 0) - @constraint(m, q_fr + q_to >= -c/2*(v_fr^2/tr^2 + v_to^2)) + @constraint(m, q_fr + q_to >= -c/2*(vm_fr^2/tr^2 + vm_to^2)) end @@ -344,7 +344,7 @@ function objective_max_loading_voltage_norm(pm::GenericPowerModel) load_factor = pm.var[:load_factor] scale = length(pm.ref[:bus]) - v = pm.var[:v] + v = pm.var[:vm] @objective(pm.model, Max, 10*scale*load_factor - sum(((bus["vmin"] + bus["vmax"])/2 - v[i])^2 for (i,bus) in pm.ref[:bus])) end @@ -364,7 +364,7 @@ end "" function bounds_tighten_voltage(pm::APIACPPowerModel; epsilon = 0.001) for (i,bus) in pm.ref[:bus] - v = pm.var[:v][i] + v = pm.var[:vm][i] setupperbound(v, bus["vmax"]*(1.0-epsilon)) setlowerbound(v, bus["vmin"]*(1.0+epsilon)) end @@ -387,7 +387,7 @@ function constraint_kcl_shunt_scaled(pm::APIACPPowerModel, bus) bus_gens = pm.ref[:bus_gens][i] load_factor = pm.var[:load_factor] - v = pm.var[:v] + v = pm.var[:vm] p = pm.var[:p] q = pm.var[:q] pg = pm.var[:pg] diff --git a/src/form/acr.jl b/src/form/acr.jl index e546fc4dd..37c18f993 100644 --- a/src/form/acr.jl +++ b/src/form/acr.jl @@ -102,7 +102,7 @@ end """ branch phase angle difference bounds """ -function constraint_phase_angle_difference{T <: AbstractACRForm}(pm::GenericPowerModel{T}, f_bus, t_bus, angmin, angmax) +function constraint_voltage_angle_difference{T <: AbstractACRForm}(pm::GenericPowerModel{T}, f_bus, t_bus, angmin, angmax) vr_fr = pm.var[:vr][f_bus] vr_to = pm.var[:vr][t_bus] vi_fr = pm.var[:vi][f_bus] diff --git a/src/form/act.jl b/src/form/act.jl index 9cb8ff73c..a4c61fd1e 100644 --- a/src/form/act.jl +++ b/src/form/act.jl @@ -18,13 +18,13 @@ ACTPowerModel(data::Dict{String,Any}; kwargs...) = "" function variable_voltage{T <: AbstractACTForm}(pm::GenericPowerModel{T}; kwargs...) - variable_phase_angle(pm; kwargs...) + variable_voltage_angle(pm; kwargs...) variable_voltage_magnitude_sqr(pm; kwargs...) variable_voltage_product(pm; kwargs...) end function constraint_voltage{T <: StandardACTForm}(pm::GenericPowerModel{T}) - t = pm.var[:t] + t = pm.var[:va] w = pm.var[:w] wr = pm.var[:wr] wi = pm.var[:wi] @@ -39,5 +39,5 @@ end "" function add_bus_voltage_setpoint{T <: AbstractACTForm}(sol, pm::GenericPowerModel{T}) add_setpoint(sol, pm, "bus", "bus_i", "vm", :w; scale = (x,item) -> sqrt(x)) - add_setpoint(sol, pm, "bus", "bus_i", "va", :t) + add_setpoint(sol, pm, "bus", "bus_i", "va", :va) end diff --git a/src/form/dcp.jl b/src/form/dcp.jl index 38eaa9107..2e977b69c 100644 --- a/src/form/dcp.jl +++ b/src/form/dcp.jl @@ -17,9 +17,10 @@ DCPPowerModel(data::Dict{String,Any}; kwargs...) = "" function variable_voltage{T <: AbstractDCPForm}(pm::GenericPowerModel{T}; kwargs...) - variable_phase_angle(pm; kwargs...) + variable_voltage_angle(pm; kwargs...) end + "nothing to add, there are no voltage variables on branches" function variable_voltage_ne{T <: AbstractDCPForm}(pm::GenericPowerModel{T}; kwargs...) end @@ -123,10 +124,10 @@ p[f_idx] == -b*(t[f_bus] - t[t_bus]) """ function constraint_ohms_yt_from{T <: AbstractDCPForm}(pm::GenericPowerModel{T}, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, ti, tm) p_fr = pm.var[:p][f_idx] - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] - @constraint(pm.model, p_fr == -b*(t_fr - t_to)) + @constraint(pm.model, p_fr == -b*(va_fr - va_to)) # omit reactive constraint end @@ -135,12 +136,12 @@ constraint_ohms_yt_to{T <: AbstractDCPForm}(pm::GenericPowerModel{T}, f_bus, t_b function constraint_ohms_yt_from_ne{T <: AbstractDCPForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, ti, tm, t_min, t_max) p_fr = pm.var[:p_ne][f_idx] - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] z = pm.var[:line_ne][i] - @constraint(pm.model, p_fr <= -b*(t_fr - t_to + t_max*(1-z)) ) - @constraint(pm.model, p_fr >= -b*(t_fr - t_to + t_min*(1-z)) ) + @constraint(pm.model, p_fr <= -b*(va_fr - va_to + t_max*(1-z)) ) + @constraint(pm.model, p_fr >= -b*(va_fr - va_to + t_min*(1-z)) ) end "Do nothing, this model is symmetric" @@ -165,12 +166,12 @@ constraint_thermal_limit_to{T <: AbstractDCPForm}(pm::GenericPowerModel{T}, t_id "" function add_bus_voltage_setpoint{T <: AbstractDCPForm}(sol, pm::GenericPowerModel{T}) - add_setpoint(sol, pm, "bus", "bus_i", "vm", :v; default_value = (item) -> 1) - add_setpoint(sol, pm, "bus", "bus_i", "va", :t) + add_setpoint(sol, pm, "bus", "bus_i", "vm", :vm; default_value = (item) -> 1) + add_setpoint(sol, pm, "bus", "bus_i", "va", :va) end "" -variable_voltage_on_off{T <: AbstractDCPForm}(pm::GenericPowerModel{T}; kwargs...) = variable_phase_angle(pm; kwargs...) +variable_voltage_on_off{T <: AbstractDCPForm}(pm::GenericPowerModel{T}; kwargs...) = variable_voltage_angle(pm; kwargs...) "do nothing, this model does not have complex voltage variables" constraint_voltage_on_off{T <: AbstractDCPForm}(pm::GenericPowerModel{T}) = nothing @@ -178,12 +179,12 @@ constraint_voltage_on_off{T <: AbstractDCPForm}(pm::GenericPowerModel{T}) = noth "`-b*(t[f_bus] - t[t_bus] + t_min*(1-line_z[i])) <= p[f_idx] <= -b*(t[f_bus] - t[t_bus] + t_max*(1-line_z[i]))`" function constraint_ohms_yt_from_on_off{T <: AbstractDCPForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, ti, tm, t_min, t_max) p_fr = pm.var[:p][f_idx] - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] z = pm.var[:line_z][i] - @constraint(pm.model, p_fr <= -b*(t_fr - t_to + t_max*(1-z)) ) - @constraint(pm.model, p_fr >= -b*(t_fr - t_to + t_min*(1-z)) ) + @constraint(pm.model, p_fr <= -b*(va_fr - va_to + t_max*(1-z)) ) + @constraint(pm.model, p_fr >= -b*(va_fr - va_to + t_min*(1-z)) ) end "Do nothing, this model is symmetric" @@ -226,23 +227,23 @@ constraint_thermal_limit_to_on_off{T <: AbstractDCPForm}(pm::GenericPowerModel{T constraint_thermal_limit_to_ne{T <: AbstractDCPForm}(pm::GenericPowerModel{T}, i, t_idx, rate_a) = Set() "`angmin*line_z[i] + t_min*(1-line_z[i]) <= t[f_bus] - t[t_bus] <= angmax*line_z[i] + t_max*(1-line_z[i])`" -function constraint_phase_angle_difference_on_off{T <: AbstractDCPForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, angmin, angmax, t_min, t_max) - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] +function constraint_voltage_angle_difference_on_off{T <: AbstractDCPForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, angmin, angmax, t_min, t_max) + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] z = pm.var[:line_z][i] - @constraint(pm.model, t_fr - t_to <= angmax*z + t_max*(1-z)) - @constraint(pm.model, t_fr - t_to >= angmin*z + t_min*(1-z)) + @constraint(pm.model, va_fr - va_to <= angmax*z + t_max*(1-z)) + @constraint(pm.model, va_fr - va_to >= angmin*z + t_min*(1-z)) end "`angmin*line_ne[i] + t_min*(1-line_ne[i]) <= t[f_bus] - t[t_bus] <= angmax*line_ne[i] + t_max*(1-line_ne[i])`" -function constraint_phase_angle_difference_ne{T <: AbstractDCPForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, angmin, angmax, t_min, t_max) - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] +function constraint_voltage_angle_difference_ne{T <: AbstractDCPForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, angmin, angmax, t_min, t_max) + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] z = pm.var[:line_ne][i] - @constraint(pm.model, t_fr - t_to <= angmax*z + t_max*(1-z)) - @constraint(pm.model, t_fr - t_to >= angmin*z + t_min*(1-z)) + @constraint(pm.model, va_fr - va_to <= angmax*z + t_max*(1-z)) + @constraint(pm.model, va_fr - va_to >= angmin*z + t_min*(1-z)) end "" @@ -286,12 +287,12 @@ Creates Ohms constraints (yt post fix indicates that Y and T values are in recta function constraint_ohms_yt_from_on_off{T <: AbstractDCPLLForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, ti, tm, t_min, t_max) p_fr = pm.var[:p][f_idx] p_to = pm.var[:p][t_idx] - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] z = pm.var[:line_z][i] - @constraint(pm.model, p_fr <= -b*(t_fr - t_to + t_max*(1-z)) ) - @constraint(pm.model, p_fr >= -b*(t_fr - t_to + t_min*(1-z)) ) + @constraint(pm.model, p_fr <= -b*(va_fr - va_to + t_max*(1-z)) ) + @constraint(pm.model, p_fr >= -b*(va_fr - va_to + t_min*(1-z)) ) end """ @@ -305,13 +306,13 @@ where `r = g/(g^2 + b^2)` and `t_m = max(|t_min|, |t_max|)` function constraint_ohms_yt_to_on_off{T <: AbstractDCPLLForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, ti, tm, t_min, t_max) p_fr = pm.var[:p][f_idx] p_to = pm.var[:p][t_idx] - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] z = pm.var[:line_z][i] r = g/(g^2 + b^2) t_m = max(abs(t_min),abs(t_max)) - @constraint(pm.model, p_fr + p_to >= r*( (-b*(t_fr - t_to))^2 - (-b*(t_m))^2*(1-z) ) ) + @constraint(pm.model, p_fr + p_to >= r*( (-b*(va_fr - va_to))^2 - (-b*(t_m))^2*(1-z) ) ) end """ @@ -324,12 +325,12 @@ Creates Ohms constraints (yt post fix indicates that Y and T values are in recta function constraint_ohms_yt_from_ne{T <: AbstractDCPLLForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, ti, tm, t_min, t_max) p_fr = pm.var[:p_ne][f_idx] p_to = pm.var[:p_ne][t_idx] - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] z = pm.var[:line_ne][i] - @constraint(pm.model, p_fr <= -b*(t_fr - t_to + t_max*(1-z)) ) - @constraint(pm.model, p_fr >= -b*(t_fr - t_to + t_min*(1-z)) ) + @constraint(pm.model, p_fr <= -b*(va_fr - va_to + t_max*(1-z)) ) + @constraint(pm.model, p_fr >= -b*(va_fr - va_to + t_min*(1-z)) ) end """ @@ -343,13 +344,13 @@ where `r = g/(g^2 + b^2)` and `t_m = max(|t_min|, |t_max|)` function constraint_ohms_yt_to_ne{T <: AbstractDCPLLForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, ti, tm, t_min, t_max) p_fr = pm.var[:p_ne][f_idx] p_to = pm.var[:p_ne][t_idx] - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] z = pm.var[:line_ne][i] r = g/(g^2 + b^2) t_m = max(abs(t_min),abs(t_max)) - @constraint(pm.model, p_fr + p_to >= r*( (-b*(t_fr - t_to))^2 - (-b*(t_m))^2*(1-z) ) ) + @constraint(pm.model, p_fr + p_to >= r*( (-b*(va_fr - va_to))^2 - (-b*(t_m))^2*(1-z) ) ) end "`-rate_a*line_z[i] <= p[t_idx] <= rate_a*line_z[i]`" diff --git a/src/form/shared.jl b/src/form/shared.jl index b467550bd..ba7e9e23c 100644 --- a/src/form/shared.jl +++ b/src/form/shared.jl @@ -23,7 +23,7 @@ AbstractPForms = Union{AbstractACPForm, AbstractACTForm, AbstractDCPForm} "`t[ref_bus] == 0`" function constraint_theta_ref{T <: AbstractPForms}(pm::GenericPowerModel{T}, ref_bus::Int) - @constraint(pm.model, pm.var[:t][ref_bus] == 0) + @constraint(pm.model, pm.var[:va][ref_bus] == 0) end """ @@ -32,12 +32,12 @@ t[f_bus] - t[t_bus] <= angmax t[f_bus] - t[t_bus] >= angmin ``` """ -function constraint_phase_angle_difference{T <: AbstractPForms}(pm::GenericPowerModel{T}, f_bus, t_bus, angmin, angmax) - t_fr = pm.var[:t][f_bus] - t_to = pm.var[:t][t_bus] +function constraint_voltage_angle_difference{T <: AbstractPForms}(pm::GenericPowerModel{T}, f_bus, t_bus, angmin, angmax) + va_fr = pm.var[:va][f_bus] + va_to = pm.var[:va][t_bus] - @constraint(pm.model, t_fr - t_to <= angmax) - @constraint(pm.model, t_fr - t_to >= angmin) + @constraint(pm.model, va_fr - va_to <= angmax) + @constraint(pm.model, va_fr - va_to >= angmin) end diff --git a/src/form/wr.jl b/src/form/wr.jl index 712abc2b4..98f351b40 100644 --- a/src/form/wr.jl +++ b/src/form/wr.jl @@ -60,14 +60,14 @@ end Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form) ``` -p[f_idx] == g/tm*w_from_ne[i] + (-g*tr+b*ti)/tm*(wr_ne[i]) + (-b*tr-g*ti)/tm*(wi_ne[i]) -q[f_idx] == -(b+c/2)/tm*w_from_ne[i] - (-b*tr-g*ti)/tm*(wr_ne[i]) + (-g*tr+b*ti)/tm*(wi_ne[i]) +p[f_idx] == g/tm*w_fr_ne[i] + (-g*tr+b*ti)/tm*(wr_ne[i]) + (-b*tr-g*ti)/tm*(wi_ne[i]) +q[f_idx] == -(b+c/2)/tm*w_fr_ne[i] - (-b*tr-g*ti)/tm*(wr_ne[i]) + (-g*tr+b*ti)/tm*(wi_ne[i]) ``` """ function constraint_ohms_yt_from_ne{T <: AbstractWRForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, ti, tm, t_min, t_max) p_fr = pm.var[:p_ne][f_idx] q_fr = pm.var[:q_ne][f_idx] - w_fr = pm.var[:w_from_ne][i] + w_fr = pm.var[:w_fr_ne][i] wr = pm.var[:wr_ne][i] wi = pm.var[:wi_ne][i] @@ -95,7 +95,7 @@ function constraint_ohms_yt_to_ne{T <: AbstractWRForm}(pm::GenericPowerModel{T}, end "" -function constraint_phase_angle_difference{T <: AbstractWRForm}(pm::GenericPowerModel{T}, f_bus, t_bus, angmin, angmax) +function constraint_voltage_angle_difference{T <: AbstractWRForm}(pm::GenericPowerModel{T}, f_bus, t_bus, angmin, angmax) w_fr = pm.var[:w][f_bus] w_to = pm.var[:w][t_bus] wr = pm.var[:wr][(f_bus, t_bus)] @@ -110,7 +110,7 @@ end function add_bus_voltage_setpoint{T <: AbstractWRForm}(sol, pm::GenericPowerModel{T}) add_setpoint(sol, pm, "bus", "bus_i", "vm", :w; scale = (x,item) -> sqrt(x)) # What should the default value be? - #add_setpoint(sol, pm, "bus", "bus_i", "va", :t; default_value = 0) + #add_setpoint(sol, pm, "bus", "bus_i", "va", :va; default_value = 0) end "" @@ -129,7 +129,7 @@ function constraint_voltage_on_off{T <: AbstractWRForm}(pm::GenericPowerModel{T} wi = pm.var[:wi] z = pm.var[:line_z] - w_from = pm.var[:w_from] + w_fr = pm.var[:w_fr] w_to = pm.var[:w_to] constraint_voltage_magnitude_sqr_from_on_off(pm) @@ -138,7 +138,7 @@ function constraint_voltage_on_off{T <: AbstractWRForm}(pm::GenericPowerModel{T} for (l,i,j) in pm.ref[:arcs_from] relaxation_complex_product_on_off(pm.model, w[i], w[j], wr[l], wi[l], z[l]) - relaxation_equality_on_off(pm.model, w[i], w_from[l], z[l]) + relaxation_equality_on_off(pm.model, w[i], w_fr[l], z[l]) relaxation_equality_on_off(pm.model, w[j], w_to[l], z[l]) end end @@ -156,12 +156,12 @@ function constraint_voltage_ne{T <: AbstractWRForm}(pm::GenericPowerModel{T}) wi = pm.var[:wi_ne] z = pm.var[:line_ne] - w_from = pm.var[:w_from_ne] + w_fr = pm.var[:w_fr_ne] w_to = pm.var[:w_to_ne] for (l,i,j) in pm.ref[:ne_arcs_from] - @constraint(pm.model, w_from[l] <= z[l]*buses[branches[l]["f_bus"]]["vmax"]^2) - @constraint(pm.model, w_from[l] >= z[l]*buses[branches[l]["f_bus"]]["vmin"]^2) + @constraint(pm.model, w_fr[l] <= z[l]*buses[branches[l]["f_bus"]]["vmax"]^2) + @constraint(pm.model, w_fr[l] >= z[l]*buses[branches[l]["f_bus"]]["vmin"]^2) @constraint(pm.model, wr[l] <= z[l]*wr_max[bi_bp[l]]) @constraint(pm.model, wr[l] >= z[l]*wr_min[bi_bp[l]]) @@ -172,7 +172,7 @@ function constraint_voltage_ne{T <: AbstractWRForm}(pm::GenericPowerModel{T}) @constraint(pm.model, w_to[l] >= z[l]*buses[branches[l]["t_bus"]]["vmin"]^2) relaxation_complex_product_on_off(pm.model, w[i], w[j], wr[l], wi[l], z[l]) - relaxation_equality_on_off(pm.model, w[i], w_from[l], z[l]) + relaxation_equality_on_off(pm.model, w[i], w_fr[l], z[l]) relaxation_equality_on_off(pm.model, w[j], w_to[l], z[l]) end end @@ -183,12 +183,12 @@ function constraint_voltage_magnitude_from_on_off{T <: AbstractWRForm}(pm::Gener buses = pm.ref[:bus] branches = pm.ref[:branch] - v_from = pm.var[:v_from] + vm_fr = pm.var[:vm_fr] z = pm.var[:line_z] for (i, branch) in pm.ref[:branch] - @constraint(pm.model, v_from[i] <= z[i]*buses[branch["f_bus"]]["vmax"]) - @constraint(pm.model, v_from[i] >= z[i]*buses[branch["f_bus"]]["vmin"]) + @constraint(pm.model, vm_fr[i] <= z[i]*buses[branch["f_bus"]]["vmax"]) + @constraint(pm.model, vm_fr[i] >= z[i]*buses[branch["f_bus"]]["vmin"]) end end @@ -197,12 +197,12 @@ function constraint_voltage_magnitude_to_on_off{T <: AbstractWRForm}(pm::Generic buses = pm.ref[:bus] branches = pm.ref[:branch] - v_to = pm.var[:v_to] + vm_to = pm.var[:vm_to] z = pm.var[:line_z] for (i, branch) in pm.ref[:branch] - @constraint(pm.model, v_to[i] <= z[i]*buses[branch["t_bus"]]["vmax"]) - @constraint(pm.model, v_to[i] >= z[i]*buses[branch["t_bus"]]["vmin"]) + @constraint(pm.model, vm_to[i] <= z[i]*buses[branch["t_bus"]]["vmax"]) + @constraint(pm.model, vm_to[i] >= z[i]*buses[branch["t_bus"]]["vmin"]) end end @@ -212,12 +212,12 @@ function constraint_voltage_magnitude_sqr_from_on_off{T <: AbstractWRForm}(pm::G buses = pm.ref[:bus] branches = pm.ref[:branch] - w_from = pm.var[:w_from] + w_fr = pm.var[:w_fr] z = pm.var[:line_z] for (i, branch) in pm.ref[:branch] - @constraint(pm.model, w_from[i] <= z[i]*buses[branch["f_bus"]]["vmax"]^2) - @constraint(pm.model, w_from[i] >= z[i]*buses[branch["f_bus"]]["vmin"]^2) + @constraint(pm.model, w_fr[i] <= z[i]*buses[branch["f_bus"]]["vmax"]^2) + @constraint(pm.model, w_fr[i] >= z[i]*buses[branch["f_bus"]]["vmin"]^2) end end @@ -257,14 +257,14 @@ end Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form) ``` -p[f_idx] == g/tm*w_from[i] + (-g*tr+b*ti)/tm*(wr[i]) + (-b*tr-g*ti)/tm*(wi[i]) -q[f_idx] == -(b+c/2)/tm*w_from[i] - (-b*tr-g*ti)/tm*(wr[i]) + (-g*tr+b*ti)/tm*(wi[i]) +p[f_idx] == g/tm*w_fr[i] + (-g*tr+b*ti)/tm*(wr[i]) + (-b*tr-g*ti)/tm*(wi[i]) +q[f_idx] == -(b+c/2)/tm*w_fr[i] - (-b*tr-g*ti)/tm*(wr[i]) + (-g*tr+b*ti)/tm*(wi[i]) ``` """ function constraint_ohms_yt_from_on_off{T <: AbstractWRForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, f_idx, t_idx, g, b, c, tr, ti, tm, t_min, t_max) p_fr = pm.var[:p][f_idx] q_fr = pm.var[:q][f_idx] - w_fr = pm.var[:w_from][i] + w_fr = pm.var[:w_fr][i] wr = pm.var[:wr][i] wi = pm.var[:wi][i] @@ -292,7 +292,7 @@ function constraint_ohms_yt_to_on_off{T <: AbstractWRForm}(pm::GenericPowerModel end "`angmin*wr[i] <= wi[i] <= angmax*wr[i]`" -function constraint_phase_angle_difference_on_off{T <: AbstractWRForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, angmin, angmax, t_min, t_max) +function constraint_voltage_angle_difference_on_off{T <: AbstractWRForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, angmin, angmax, t_min, t_max) wr = pm.var[:wr][i] wi = pm.var[:wi][i] @@ -301,7 +301,7 @@ function constraint_phase_angle_difference_on_off{T <: AbstractWRForm}(pm::Gener end "`angmin*wr_ne[i] <= wi_ne[i] <= angmax*wr_ne[i]`" -function constraint_phase_angle_difference_ne{T <: AbstractWRForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, angmin, angmax, t_min, t_max) +function constraint_voltage_angle_difference_ne{T <: AbstractWRForm}(pm::GenericPowerModel{T}, i, f_bus, t_bus, angmin, angmax, t_min, t_max) wr = pm.var[:wr_ne][i] wi = pm.var[:wi_ne][i] @@ -321,11 +321,11 @@ function variable_voltage_magnitude_sqr_from_ne{T <: AbstractWRForm}(pm::Generic buses = pm.ref[:bus] branches = pm.ref[:ne_branch] - pm.var[:w_from_ne] = @variable(pm.model, - [i in keys(pm.ref[:ne_branch])], basename="w_from_ne", + pm.var[:w_fr_ne] = @variable(pm.model, + [i in keys(pm.ref[:ne_branch])], basename="w_fr_ne", 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 @@ -377,7 +377,7 @@ end "Creates variables associated with differences in phase angles" -function variable_phase_angle_difference{T}(pm::GenericPowerModel{T}) +function variable_voltage_angle_difference{T}(pm::GenericPowerModel{T}) pm.var[:td] = @variable(pm.model, [bp in keys(pm.ref[:buspairs])], basename="td", lowerbound = pm.ref[:buspairs][bp]["angmin"], @@ -391,8 +391,8 @@ function variable_voltage_magnitude_product{T}(pm::GenericPowerModel{T}) buspairs = pm.ref[:buspairs] pm.var[:vv] = @variable(pm.model, [bp in keys(pm.ref[:buspairs])], basename="vv", - lowerbound = buspairs[bp]["v_from_min"]*buspairs[bp]["v_to_min"], - upperbound = buspairs[bp]["v_from_max"]*buspairs[bp]["v_to_max"], + lowerbound = buspairs[bp]["vm_fr_min"]*buspairs[bp]["vm_to_min"], + upperbound = buspairs[bp]["vm_fr_max"]*buspairs[bp]["vm_to_max"], start = getstart(pm.ref[:buspairs], bp, "vv_start", 1.0) ) end @@ -441,20 +441,20 @@ function variable_current_magnitude_sqr{T}(pm::GenericPowerModel{T}) pm.var[:cm] = @variable(pm.model, cm[bp in keys(pm.ref[:buspairs])], basename="cm", lowerbound = 0, - upperbound = (buspairs[bp]["rate_a"]*buspairs[bp]["tap"]/buspairs[bp]["v_from_min"])^2, + upperbound = (buspairs[bp]["rate_a"]*buspairs[bp]["tap"]/buspairs[bp]["vm_fr_min"])^2, start = getstart(pm.ref[:buspairs], bp, "cm_start") ) end "" function variable_voltage(pm::QCWRPowerModel; kwargs...) - variable_phase_angle(pm; kwargs...) + variable_voltage_angle(pm; kwargs...) variable_voltage_magnitude(pm; kwargs...) variable_voltage_magnitude_sqr(pm; kwargs...) variable_voltage_product(pm; kwargs...) - variable_phase_angle_difference(pm; kwargs...) + variable_voltage_angle_difference(pm; kwargs...) variable_voltage_magnitude_product(pm; kwargs...) variable_cosine(pm; kwargs...) variable_sine(pm; kwargs...) @@ -463,8 +463,8 @@ end "" function constraint_voltage(pm::QCWRPowerModel) - v = pm.var[:v] - t = pm.var[:t] + v = pm.var[:vm] + t = pm.var[:va] td = pm.var[:td] si = pm.var[:si] @@ -530,10 +530,10 @@ end "`t[ref_bus] == 0`" constraint_theta_ref(pm::QCWRPowerModel, ref_bus::Int) = - Set([@constraint(pm.model, pm.var[:t][ref_bus] == 0)]) + Set([@constraint(pm.model, pm.var[:va][ref_bus] == 0)]) "" -function constraint_phase_angle_difference(pm::QCWRPowerModel, f_bus, t_bus, angmin, angmax) +function constraint_voltage_angle_difference(pm::QCWRPowerModel, f_bus, t_bus, angmin, angmax) td = pm.var[:td][(f_bus, t_bus)] if getlowerbound(td) < angmin @@ -557,8 +557,8 @@ end "" function add_bus_voltage_setpoint(sol, pm::QCWRPowerModel) - 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 @@ -566,7 +566,7 @@ end "" function variable_voltage_on_off(pm::QCWRPowerModel; kwargs...) - variable_phase_angle(pm; kwargs...) + variable_voltage_angle(pm; kwargs...) variable_voltage_magnitude(pm; kwargs...) variable_voltage_magnitude_from_on_off(pm; kwargs...) variable_voltage_magnitude_to_on_off(pm; kwargs...) @@ -577,7 +577,7 @@ function variable_voltage_on_off(pm::QCWRPowerModel; kwargs...) variable_voltage_product_on_off(pm; kwargs...) - variable_phase_angle_difference_on_off(pm; kwargs...) + variable_voltage_angle_difference_on_off(pm; kwargs...) variable_voltage_magnitude_product_on_off(pm; kwargs...) variable_cosine_on_off(pm; kwargs...) variable_sine_on_off(pm; kwargs...) @@ -585,7 +585,7 @@ function variable_voltage_on_off(pm::QCWRPowerModel; kwargs...) end "" -function variable_phase_angle_difference_on_off{T}(pm::GenericPowerModel{T}) +function variable_voltage_angle_difference_on_off{T}(pm::GenericPowerModel{T}) pm.var[:td] = @variable(pm.model, td[l in keys(pm.ref[:branch])], basename="td", lowerbound = min(0, pm.ref[:branch][l]["angmin"]), @@ -663,10 +663,10 @@ end "" function constraint_voltage_on_off(pm::QCWRPowerModel) - v = pm.var[:v] - t = pm.var[:t] - v_from = pm.var[:v_from] - v_to = pm.var[:v_to] + v = pm.var[:vm] + t = pm.var[:va] + vm_fr = pm.var[:vm_fr] + vm_to = pm.var[:vm_to] td = pm.var[:td] si = pm.var[:si] @@ -674,7 +674,7 @@ function constraint_voltage_on_off(pm::QCWRPowerModel) vv = pm.var[:vv] w = pm.var[:w] - w_from = pm.var[:w_from] + w_fr = pm.var[:w_fr] w_to = pm.var[:w_to] wr = pm.var[:wr] @@ -690,9 +690,9 @@ function constraint_voltage_on_off(pm::QCWRPowerModel) relaxation_sqr(pm.model, v[i], w[i]) end - constraint_voltage_magnitude_from_on_off(pm) # bounds on v_from - constraint_voltage_magnitude_to_on_off(pm) # bounds on v_to - constraint_voltage_magnitude_sqr_from_on_off(pm) # bounds on w_from + constraint_voltage_magnitude_from_on_off(pm) # bounds on vm_fr + constraint_voltage_magnitude_to_on_off(pm) # bounds on vm_to + constraint_voltage_magnitude_sqr_from_on_off(pm) # bounds on w_fr constraint_voltage_magnitude_sqr_to_on_off(pm) # bounds on w_to constraint_voltage_product_on_off(pm) # bounds on wr, wi @@ -705,16 +705,17 @@ function constraint_voltage_on_off(pm::QCWRPowerModel) relaxation_sin_on_off(pm.model, td[l], si[l], z[l], td_max) relaxation_cos_on_off(pm.model, td[l], cs[l], z[l], td_max) - relaxation_product_on_off(pm.model, v_from[i], v_to[j], vv[l], z[l]) + relaxation_product_on_off(pm.model, vm_fr[i], vm_to[j], vv[l], z[l]) relaxation_product_on_off(pm.model, vv[l], cs[l], wr[l], z[l]) relaxation_product_on_off(pm.model, vv[l], si[l], wi[l], z[l]) # this constraint is redudant and useful for debugging #relaxation_complex_product(pm.model, w[i], w[j], wr[l], wi[l]) - relaxation_equality_on_off(pm.model, v[i], v_from[l], z[l]) - relaxation_equality_on_off(pm.model, v[j], v_to[l], z[l]) - relaxation_equality_on_off(pm.model, w[i], w_from[l], z[l]) + #cs4 = relaxation_complex_product_on_off(pm.model, w[i], w[j], wr[l], wi[l], z[l]) + relaxation_equality_on_off(pm.model, v[i], vm_fr[l], z[l]) + relaxation_equality_on_off(pm.model, v[j], vm_to[l], z[l]) + relaxation_equality_on_off(pm.model, w[i], w_fr[l], z[l]) relaxation_equality_on_off(pm.model, w[j], w_to[l], z[l]) # to prevent this constraint from being posted on multiple parallel lines @@ -745,7 +746,7 @@ end "`cm[f_bus,t_bus] == (g^2 + b^2)*(w[f_bus]/tm + w[t_bus] - 2*(tr*wr[f_bus,t_bus] + ti*wi[f_bus,t_bus])/tm) - c*q[f_idx] - ((c/2)/tm)^2*w[f_bus]`" function constraint_power_magnitude_link_on_off(pm::QCWRPowerModel, i, arc_from, g, b, c, tr, ti, tm) - w_fr = pm.var[:w_from][i] + w_fr = pm.var[:w_fr][i] w_to = pm.var[:w_to][i] q_fr = pm.var[:q][arc_from] wr = pm.var[:wr][i] diff --git a/src/form/wrm.jl b/src/form/wrm.jl index 0b04a972c..a871d05a5 100644 --- a/src/form/wrm.jl +++ b/src/form/wrm.jl @@ -126,7 +126,7 @@ function constraint_ohms_yt_to{T <: AbstractWRMForm}(pm::GenericPowerModel{T}, f end "" -function constraint_phase_angle_difference{T <: AbstractWRMForm}(pm::GenericPowerModel{T}, f_bus, t_bus, angmin, angmax) +function constraint_voltage_angle_difference{T <: AbstractWRMForm}(pm::GenericPowerModel{T}, f_bus, t_bus, angmin, angmax) w_fr_index = pm.ext[:lookup_w_index][f_bus] w_to_index = pm.ext[:lookup_w_index][t_bus] @@ -146,6 +146,6 @@ function add_bus_voltage_setpoint{T <: AbstractWRMForm}(sol, pm::GenericPowerMod add_setpoint(sol, pm, "bus", "bus_i", "vm", :WR; scale = (x,item) -> sqrt(x), extract_var = (var,idx,item) -> var[pm.ext[:lookup_w_index][idx], pm.ext[:lookup_w_index][idx]]) # What should the default value be? - #add_setpoint(sol, pm, "bus", "bus_i", "va", :t; default_value = 0) + #add_setpoint(sol, pm, "bus", "bus_i", "va", :va; default_value = 0) end diff --git a/src/io/common.jl b/src/io/common.jl index d7f265f16..b63dd581b 100644 --- a/src/io/common.jl +++ b/src/io/common.jl @@ -15,7 +15,7 @@ end function check_network_data(data::Dict{String,Any}) make_per_unit(data) check_transformer_parameters(data) - check_phase_angle_differences(data) + check_voltage_angle_differences(data) check_thermal_limits(data) check_bus_types(data) check_dcline_limits(data) diff --git a/src/prob/misc.jl b/src/prob/misc.jl index 674273cf1..7bb962b36 100644 --- a/src/prob/misc.jl +++ b/src/prob/misc.jl @@ -44,7 +44,7 @@ function post_api_opf(pm::GenericPowerModel) 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; scale = 0.999) constraint_thermal_limit_to(pm, branch; scale = 0.999) @@ -86,9 +86,9 @@ function post_sad_opf{T <: Union{AbstractACPForm, AbstractDCPForm}}(pm::GenericP constraint_ohms_yt_from(pm, branch) constraint_ohms_yt_to(pm, branch) - constraint_phase_angle_difference(pm, branch) - theta_fr = pm.var[:t][branch["f_bus"]] - theta_to = pm.var[:t][branch["t_bus"]] + constraint_voltage_angle_difference(pm, branch) + theta_fr = pm.var[:va][branch["f_bus"]] + theta_to = pm.var[:va][branch["t_bus"]] @constraint(pm.model, theta_fr - theta_to <= theta_delta_bound) @constraint(pm.model, theta_fr - theta_to >= -theta_delta_bound) diff --git a/src/prob/opf.jl b/src/prob/opf.jl index 18c308fc9..ced9ca9d1 100644 --- a/src/prob/opf.jl +++ b/src/prob/opf.jl @@ -38,7 +38,7 @@ function post_opf(pm::GenericPowerModel) 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) diff --git a/src/prob/ots.jl b/src/prob/ots.jl index 95ca82913..6a2e65c54 100644 --- a/src/prob/ots.jl +++ b/src/prob/ots.jl @@ -36,7 +36,7 @@ function post_ots(pm::GenericPowerModel) 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) diff --git a/src/prob/tnep.jl b/src/prob/tnep.jl index 7202179f2..2b2533428 100644 --- a/src/prob/tnep.jl +++ b/src/prob/tnep.jl @@ -36,7 +36,7 @@ function post_tnep(pm::GenericPowerModel) 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) @@ -46,7 +46,7 @@ function post_tnep(pm::GenericPowerModel) 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) diff --git a/test/opf.jl b/test/opf.jl index 305e62d33..ba238f3c8 100644 --- a/test/opf.jl +++ b/test/opf.jl @@ -244,7 +244,7 @@ end PMs.constraint_ohms_y_from(pm, branch) PMs.constraint_ohms_y_to(pm, branch) - PMs.constraint_phase_angle_difference(pm, branch) + PMs.constraint_voltage_angle_difference(pm, branch) PMs.constraint_thermal_limit_from(pm, branch) PMs.constraint_thermal_limit_to(pm, branch)