Reactive Power Limits (Q-Limits) and PV→PQ Switching
A PV bus that violates its reactive limits becomes a PQ bus during the Newton-Raphson iteration (PV→PQ switching); events are logged, and hysteresis and a cooldown period allow switching back.
Data Structures in Net
The Q-limit state lives on the network:
| field | meaning |
|---|---|
qmin_pu, qmax_pu | per-bus limits in p.u. of the total generator Q, aggregated by buildQLimits! (or set with setQLimits!) before the power flow. On a bus with a regulating or reference unit: the qMin/qMax of its regulating and reference units summed (a missing limit makes that end unbounded), plus the fixed Q of every other unit at both ends, for a Q(U) unit its Q at the held voltage (such a unit does not widen the band, whatever its own limits). On a bus without one: the sum of all its units' limits. |
q_hyst_pu, cooldown_iters | hysteresis band in p.u. and minimum iterations between PV/PQ state changes |
reenable_v_hyst_pu, final_q_accept_pu | voltage margin of the PQ→PV release and size bound of the final check |
qLimitLog, qLimitEvents | chronological QLimitEvent records and the last side (:min or :max) per bus |
Pre-run Q-limit Preview in MVAr
verbose > 0 prints the PV limits in MVAr (via baseMVA) before the Newton loop, all rows with verbose > 1: a check that catches pu/MVAr mixups early.
Logging Q-Limit Hits and Releases
Base.@kwdef struct QLimitEvent
iter::Int
bus::Int
side::Symbol # :min | :max
kind::Symbol = :hit # :group_hit when a member of a jointly released group hits its
# limit again, :group_revert when another member returns with it,
# :release for a PQ->PV release (side = the limit the bus was clamped at)
endlogQLimitHit!(net, iter, bus, side): appends aQLimitEventtonet.qLimitLogand setsnet.qLimitEvents[bus] = side.- PQ->PV releases of the active set are logged with
kind = :release; a reader that wants the hits only filters onkind.:group_hitand:group_revertare PV->PQ switches but not hits: they do not count towardsguard.max_switches. lastQLimitIter(net, bus): last iteration in whichbushit a limit.resetQLimitLog!(net): clears both.pv_hit_q_limit(net, ["B3", "B10"]):trueif any listed bus appears innet.qLimitEvents(for tests).printQLimitLog(net; sort_by = :iter, io = stdout): the events as a table.
Conceptual Algorithm
In every Newton-Raphson iteration of the rectangular solver:
Solve one NR step; obtain the voltages
Vand bus powersS = P + jQ.Compute the generator Q per PV bus (net injection plus bus load).
Check the limits: bus
bhas hit a limit when its generator Q leaves[Qmin_b, Qmax_b](net.qmin_pu,net.qmax_pu) by more than the hysteresis marginq_hyst(power_flow.qlimits.hysteresis_pu, default0.01;0is the plain limit test),\[Q_b < Qmin_b - q_\mathrm{hyst} \quad \text{or} \quad Q_b > Qmax_b + q_\mathrm{hyst}\]
Under
power_flow.qlimits.guard.violation_mode: lock_pq(the default) the bus also switches once the overshoot exceedsguard.violation_threshold_pctpercent of its Q band $Qmax_b - Qmin_b$ (default1). With the defaults this threshold decides for a band narrower than 1 pu (100 MVAr on a 100 MVA base), the hysteresis margin for a wider one. A zero band switches on any overshoot; a band with one infinite limit switches on the hysteresis margin only.Clip Q and switch the bus type: set the generator's Q to the violated limit (
Q_b := Qmin_borQ_b := Qmax_b), thensetBusType!(net, b, "PQ") logQLimitHit!(net, iter, b, :min) # or :maxFrom the next iteration on the solver's
bus_typesvector carries:PQfor the bus and its residual switches from(ΔP, ΔV)to(ΔP, ΔQ)(Solver Guide).PV→PQ→PV re-enable, only with
net.q_hyst_pu > 0ornet.cooldown_iters > 0(both at zero disables switching back). In the active-set step a bus clamped at Qmax is released whenVm > Vset + reenable_v_hyst_pu, one clamped at Qmin whenVm < Vset - reenable_v_hyst_pu(power_flow.qlimits.reenable_v_hyst_pu, default1e-4pu): a machine at Qmax whose voltage sits above its setpoint needs less than Qmax to hold it (the back-off rule of Sundaresh and Rao, Sadhana 40(4), 2015). Callers that pass no voltages fall back to the Q band test\[Qmin_b + q_\mathrm{hyst} < Q_b < Qmax_b - q_\mathrm{hyst}\]
In both cases enough iterations must have passed since the last hit:
\[\text{iter} - \text{lastQLimitIter}(b) \ge \text{cooldown\_iters}\]
Cooldown and the one-retry guard apply: a machine flipping between the clamp and the voltage constraint is held after its first retry. At the converged point the machines held this way whose voltage is on the release side are released together. A machine of the group that hits its limit again stays clamped for the rest of the solve; the others go back to their limits with it and are released again, without it, at the next converged point. A solve allows at most five such failed rounds, in bus order; after that the remaining machines stay clamped. A machine with a narrow Q band (below
guard.min_q_range_puunderguard.narrow_range_mode: lock_pq) is released by the same voltage rule, but only at a converged point. Such a band is crossed by small voltage changes, so the voltage of an unsettled iterate would release and clamp it in turn; the converged voltage is the one the clamp must agree with. After that release the one-retry guard and the group release apply to it as to every other machine.examples/powerflow/example_qlimit_reenable_voltage_rule.jlshows the difference on the Zeng/Chiang 14-bus case.Repeat with the updated bus types and Q values.
Final check, the same for every enforcement mode. After the solve the overshoot
d = Q - Qmax(orQmin - Q, in pu) of every PV bus is judged by its size, not by the number of buses:class condition status run in order d <= hysteresis_puok(within_hysteresiswhend > tol)accepted bounded hysteresis_pu < d <= final_q_accept_pubounded_q_limit_violationaccepted, warning with bus, din pu and MVArviolation d > final_q_accept_puremaining_pv_q_limit_violationsnot accepted power_flow.qlimits.final_q_accept_pu(defaultauto, twicehysteresis_pu; an explicit value must be>= hysteresis_pu) bounds what is still accepted; both at zero make the check strict. The count-based guard keys (guard.accept_bounded_violations,guard.max_remaining_violations) are not part of this classification. The check writes one line per bus (side, Q, limit,din pu and MVAr, class) into the Q-limit block of the text report,run.log, the run metadata (final_q_check_status, withqlimits_disabledwhen Q-limit handling is off andnot_evaluatedwithout a converged solution,final_q_check_buses,final_q_check_max_dev_pu) and the Web UI result page, next to the voltage-side Q-V characteristic check.
Alternative to immediate PV→PQ switching: qlimit_mode = :adjust_vset
runpf!(net, 40, 1e-8, 1; qlimit_mode = :adjust_vset)When a PV bus reaches a limit, its voltage setpoint (vm_pu) is first moved in steps of vstep_pu before the bus becomes PQ, which avoids a switch where a small voltage correction keeps Q inside the limits. The regulating generator prosumer at the bus (one controller definition per bus) provides vstep_pu and optionally tap_steps_down / tap_steps_up (maximum number of adjustments). Without a valid controller, or once the step limits are exhausted, standard PV→PQ switching applies. Rectangular solver only; the default is :switch_to_pq.