Constraints

Constraints

Constraint Templates

Constraint templates help simplify data wrangling across multiple Power Flow formulations by providing an abstraction layer between the network data and network constraint definitions. The constraint template's job is to extract the required parameters from a given network data structure and pass the data as named arguments to the Power Flow formulations.

These templates should be defined over GenericPowerModel and should not refer to model variables. For more details, see the files: core/constraint_template.jl and core/constraint.jl (core/constraint_template.jl provides higher level APIs, and pulls out index information from the data dictionaries, before calling out to methods defined in core/constraint.jl).

Voltage Constraints

source

do nothing, this model does not have complex voltage constraints

source

do nothing, this model does not have complex voltage constraints

source

do nothing, this model does not have complex voltage variables

source
source
source
source
source
source
source
source

do nothing, this model does not have complex voltage constraints

source

do nothing, this model does not have complex voltage variables

source
source
source
source

do nothing, this model does not have complex voltage constraints

source

do nothing, this model does not have complex voltage variables

source
source

Generator Constraints

source

pg[i] == pg

source
source

qq[i] == qq

source

do nothing, apo models do not have reactive variables

source

Bus Constraints

Setpoint Constraints

source

reference bus angle constraint

source

t[ref_bus] == 0

source

nothing to do, no voltage angle variables

source

t[ref_bus] == 0

source

t[ref_bus] == 0

source

Do nothing, no way to represent this in these variables

source
source

v[i] == vm

source

v[i] == vm

source

do nothing, this model does not have voltage variables

source
source

Power Balance Constraints

ensures that power generation and demand are balanced

source
source
source

KCL Constraints

source
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) - sum(pd[d] for d in bus_loads) - sum(gs[s] for s in bus_shunts)*v^2
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) - sum(qd[d] for d in bus_loads) + sum(bs[s] for s in bus_shunts)*v^2
source
source
source
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) - sum(pd[d] for d in bus_loads) - sum(gs[s] for d in bus_shunts)*w[i]
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) - sum(qd[d] for d in bus_loads) + sum(bs[s] for d in bus_shunts)*w[i]
source
source
source
source
source
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) - sum(pd[d] for d in bus_loads) - sum(gs[s] for s in bus_shunts)*vm^2
sum(q[a] for a in bus_arcs) + sum(p_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) - sum(qd[d] for d in bus_loads) + sum(bs[s] for s in bus_shunts)*vm^2
source
source
sum(p[a] for a in bus_arcs) + sum(p_ne[a] for a in bus_arcs_ne) + sum(p_dc[a_dc] for a_dc in bus_arcs_dc) == sum(pg[g] for g in bus_gens) - sum(pd[d] for d in bus_loads) - sum(gs[s] for s in bus_shunts)*w[i]
sum(q[a] for a in bus_arcs) + sum(q_ne[a] for a in bus_arcs_ne) + sum(q_dc[a_dc] for a_dc in bus_arcs_dc) == sum(qg[g] for g in bus_gens) - sum(qd[d] for d in bus_loads) + sum(bs[s] for s in bus_shunts)*w[i]
source

Branch Constraints

Ohm's Law Constraints

source

Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)

p[f_idx] ==  (g+g_fr)/tm*v[f_bus]^2 + (-g*tr+b*ti)/tm*(v[f_bus]*v[t_bus]*cos(t[f_bus]-t[t_bus])) + (-b*tr-g*ti)/tm*(v[f_bus]*v[t_bus]*sin(t[f_bus]-t[t_bus]))
q[f_idx] == -(b+b_fr)/tm*v[f_bus]^2 - (-b*tr-g*ti)/tm*(v[f_bus]*v[t_bus]*cos(t[f_bus]-t[t_bus])) + (-g*tr+b*ti)/tm*(v[f_bus]*v[t_bus]*sin(t[f_bus]-t[t_bus]))
source

Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)

source

Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)

p[f_idx] == -b*(t[f_bus] - t[t_bus])
source

nothing to do, no voltage angle variables

source
source

Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)

source
source

Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)

p[t_idx] ==  (g+g_to)*v[t_bus]^2 + (-g*tr-b*ti)/tm*(v[t_bus]*v[f_bus]*cos(t[t_bus]-t[f_bus])) + (-b*tr+g*ti)/tm*(v[t_bus]*v[f_bus]*sin(t[t_bus]-t[f_bus]))
q[t_idx] == -(b+b_to)*v[t_bus]^2 - (-b*tr+g*ti)/tm*(v[t_bus]*v[f_bus]*cos(t[f_bus]-t[t_bus])) + (-g*tr-b*ti)/tm*(v[t_bus]*v[f_bus]*sin(t[t_bus]-t[f_bus]))
source

Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)

source

nothing to do, this model is symetric

source

Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)

source
source

Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)

source
source

Creates Ohms constraints for AC models (y post fix indicates that Y values are in rectangular form)

p[f_idx] ==  (g+g_fr)*(v[f_bus]/tr)^2 + -g*v[f_bus]/tr*v[t_bus]*cos(t[f_bus]-t[t_bus]-as) + -b*v[f_bus]/tr*v[t_bus]*sin(t[f_bus]-t[t_bus]-as)
q[f_idx] == -(b+b_fr)*(v[f_bus]/tr)^2 + b*v[f_bus]/tr*v[t_bus]*cos(t[f_bus]-t[t_bus]-as) + -g*v[f_bus]/tr*v[t_bus]*sin(t[f_bus]-t[t_bus]-as)
source
source

Creates Ohms constraints for AC models (y post fix indicates that Y values are in rectangular form)

p[t_idx] == (g+g_to)*v[t_bus]^2 + -g*v[t_bus]*v[f_bus]/tr*cos(t[t_bus]-t[f_bus]+as) + -b*v[t_bus]*v[f_bus]/tr*sin(t[t_bus]-t[f_bus]+as)
q_to == -(b+b_to)*v[t_bus]^2 + b*v[t_bus]*v[f_bus]/tr*cos(t[f_bus]-t[t_bus]+as) + -g*v[t_bus]*v[f_bus]/tr*sin(t[t_bus]-t[f_bus]+as)
source

On/Off Ohm's Law Constraints

source
p[f_idx] == z*(g/tm*v[f_bus]^2 + (-g*tr+b*ti)/tm*(v[f_bus]*v[t_bus]*cos(t[f_bus]-t[t_bus])) + (-b*tr-g*ti)/tm*(v[f_bus]*v[t_bus]*sin(t[f_bus]-t[t_bus])))
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[f_bus]-t[t_bus])) + (-g*tr+b*ti)/tm*(v[f_bus]*v[t_bus]*sin(t[f_bus]-t[t_bus])))
source

-b*(t[f_bus] - t[t_bus] + vad_min*(1-branch_z[i])) <= p[f_idx] <= -b*(t[f_bus] - t[t_bus] + vad_max*(1-branch_z[i]))

source

Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)

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])
source
source
p[t_idx] == z*(g*v[t_bus]^2 + (-g*tr-b*ti)/tm*(v[t_bus]*v[f_bus]*cos(t[t_bus]-t[f_bus])) + (-b*tr+g*ti)/tm*(v[t_bus]*v[f_bus]*sin(t[t_bus]-t[f_bus])))
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_bus]-t[t_bus])) + (-g*tr-b*ti)/tm*(v[t_bus]*v[f_bus]*sin(t[t_bus]-t[f_bus])))
source

nothing to do, this model is symetric

source
source

Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)

p[t_idx] ==        g*w_to[i] + (-g*tr-b*ti)/tm*(wr[i]) + (-b*tr+g*ti)/tm*(-wi[i])
q[t_idx] == -(b+c/2)*w_to[i] - (-b*tr+g*ti)/tm*(wr[i]) + (-g*tr-b*ti)/tm*(-wi[i])
source
source
p_ne[f_idx] == z*(g/tm*v[f_bus]^2 + (-g*tr+b*ti)/tm*(v[f_bus]*v[t_bus]*cos(t[f_bus]-t[t_bus])) + (-b*tr-g*ti)/tm*(v[f_bus]*v[t_bus]*sin(t[f_bus]-t[t_bus])))
q_ne[f_idx] == z*(-(b+c/2)/tm*v[f_bus]^2 - (-b*tr-g*ti)/tm*(v[f_bus]*v[t_bus]*cos(t[f_bus]-t[t_bus])) + (-g*tr+b*ti)/tm*(v[f_bus]*v[t_bus]*sin(t[f_bus]-t[t_bus])))
source

Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)

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])
source
source
p_ne[t_idx] == z*(g*v[t_bus]^2 + (-g*tr-b*ti)/tm*(v[t_bus]*v[f_bus]*cos(t[t_bus]-t[f_bus])) + (-b*tr+g*ti)/tm*(v[t_bus]*v[f_bus]*sin(t[t_bus]-t[f_bus])))
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[f_bus]-t[t_bus])) + (-g*tr-b*ti)/tm*(v[t_bus]*v[f_bus]*sin(t[t_bus]-t[f_bus])))
source

nothing to do, this model is symetric

source
source

Creates Ohms constraints (yt post fix indicates that Y and T values are in rectangular form)

p[t_idx] == g*w_to_ne[i] + (-g*tr-b*ti)/tm*(wr_ne[i]) + (-b*tr+g*ti)/tm*(-wi_ne[i])
q[t_idx] == -(b+c/2)*w_to_ne[i] - (-b*tr+g*ti)/tm*(wr_ne[i]) + (-g*tr-b*ti)/tm*(-wi_ne[i])
source

Current

source

p[f_idx]^2 + q[f_idx]^2 <= w[f_bus]/tm*cm[f_bus,t_bus]

source
source

p[arc_from]^2 + q[arc_from]^2 <= w[f_bus]/tm*cm[i]

source
source

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]

source
source

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]

source

Thermal Limit Constraints

constraint_thermal_limit_from(pm::GenericPowerModel, n::Int, i::Int)

Adds the (upper and lower) thermal limit constraints for the desired branch to the PowerModel.

source

p[f_idx]^2 + q[f_idx]^2 <= rate_a^2

source

[rate_a, p[f_idx], q[f_idx]] in SecondOrderCone

source

-rate_a <= p[f_idx] <= rate_a

source
source

p[t_idx]^2 + q[t_idx]^2 <= rate_a^2

source

[rate_a, p[t_idx], q[t_idx]] in SecondOrderCone

source
source

nothing to do, this model is symetric

source
source

p[f_idx]^2 + q[f_idx]^2 <= (rate_a * branch_z[i])^2

source
source
source

p[t_idx]^2 + q[t_idx]^2 <= (rate_a * branch_z[i])^2

source
source

nothing to do, this model is symetric

source
source

p_ne[f_idx]^2 + q_ne[f_idx]^2 <= (rate_a * branch_ne[i])^2

source
source
source

p_ne[t_idx]^2 + q_ne[t_idx]^2 <= (rate_a * branch_ne[i])^2

source
source

nothing to do, this model is symetric

source

Current Limit Constraints

Adds a current magnitude limit constraint for the desired branch to the PowerModel.

source
source
source
source

Phase Angle Difference Constraints

source

branch voltage angle difference bounds

source
t[f_bus] - t[t_bus] <= angmax
t[f_bus] - t[t_bus] >= angmin
source

nothing to do, no voltage angle variables

source
source
t[f_bus] - t[t_bus] <= angmax
t[f_bus] - t[t_bus] >= angmin
source
source
source

angmin <= branch_z[i]*(t[f_bus] - t[t_bus]) <= angmax

source

angmin*branch_z[i] + vad_min*(1-branch_z[i]) <= t[f_bus] - t[t_bus] <= angmax*branch_z[i] + vad_max*(1-branch_z[i])

source

angmin*wr[i] <= wi[i] <= angmax*wr[i]

source
source

angmin <= branch_ne[i]*(t[f_bus] - t[t_bus]) <= angmax

source

angmin*branch_ne[i] + vad_min*(1-branch_ne[i]) <= t[f_bus] - t[t_bus] <= angmax*branch_ne[i] + vad_max*(1-branch_ne[i])

source

angmin*wr_ne[i] <= wi_ne[i] <= angmax*wr_ne[i]

source

Loss Constraints

source
p[f_idx] + p[t_idx] >= 0
q[f_idx] + q[t_idx] >= -c/2*(v[f_bus]^2/tr^2 + v[t_bus]^2)
source
source

Defines branch flow model power flow equations

source
source

Defines voltage drop over a branch, linking from and to side voltage magnitude

source
source

Defines relationship between branch (series) power flow, branch (series) current and node voltage magnitude

source

Defines relationship between branch (series) power flow, branch (series) current and node voltage magnitude

source

Storage Constraints

source
source
source
source
source
source
source
source
source
source
source
source
source
source
source

DC Line Constraints

source

Creates Line Flow constraint for DC Lines (Matpower Formulation)

p_fr + p_to == loss0 + p_fr * loss1
source
source

pf[i] == pf, pt[i] == pt

source