Phase-aware control API

The control guide shows how to specify and solve the local control laws. Their equations are derived in the phase-aware control chapter, and the validation guide describes the reference calculations and numerical tests. Network studies cover multiple inverters and comparisons of equipment ratings.

PowerOptLab.PiecewiseLinearLaw — Type
PiecewiseLinearLaw(breakpoints, values; smoothing_epsilon=nothing, formulation=nothing)

A continuous, flat-clamped piecewise-linear scalar law. smoothing_epsilon is an absolute width in the same units as breakpoints; it is used only by the smooth representation. Alternatively supply an AbstractPWLSmoothing instance via formulation, e.g. LocalC2Formulation(0.1). If both keywords are supplied their widths must agree. The default remains BMOPFTools softplus. Numeric smooth assessment and JuMP stamping use the same family and flat tails. Curve coordinates are copied and read-only; construct a new law to change them. Prepared canonical data are reused across numeric evaluation and model stamps. evaluate_exact retains exact corners.

source
PowerOptLab.WorstPhaseVoltVarWatt — Type
WorstPhaseVoltVarWatt(; volt_watt=nothing, volt_var=nothing,
                       conflict_policy=:dominant, extrema_epsilon=0.05,
                       conflict_epsilon=0.01,
                       volt_watt_basis=:available)

Direction-aware positive-sequence policy for three-phase local voltage control. Volt-watt observes the largest phase-voltage magnitude. Volt-var observes both the smallest and largest phase: low-voltage injection and high-voltage absorption are retained. When both occur, conflict_policy=:net adds the two opposing requests, :dominant continuously blends toward the branch with the larger normalized response, :low_voltage prioritizes injection, and :high_voltage prioritizes absorption.

Volt-watt ordinates are fractions in [0, 1]; Volt-var ordinates are fractions of InverterControlRequest.q_scale. Both curves must be non-increasing. extrema_epsilon is an SI voltage width for smooth phase extrema; conflict_epsilon is the dimensionless transition width in normalized branch severity and is part of both the firmware and JuMP laws. volt_watt_basis is :available or :rated.

Both curve inputs are phase magnitudes and therefore move with the local zero-sequence voltage — a component without an independent three-leg current actuator, and one whose measured value depends on the sensing reference documented in SequenceController.

source
PowerOptLab.AverageVoltageVoltVarWatt — Type
AverageVoltageVoltVarWatt(; volt_watt=nothing, volt_var=nothing,
                            extrema_epsilon=0.05,
                            volt_watt_basis=:available)

Legacy balanced-current comparator. Both PWL laws observe the arithmetic mean of the three local phase-voltage magnitudes. Like WorstPhaseVoltVarWatt, that input moves with the local zero-sequence voltage and with the sensing reference documented in SequenceController.

source
PowerOptLab.PositiveSequenceVoltVarWatt — Type
PositiveSequenceVoltVarWatt(; volt_watt=nothing, volt_var=nothing,
                              worst_phase_watt_guard=true,
                              guard_epsilon=0.05,
                              volt_watt_basis=:available)

Balanced-current sequence comparator. Volt-var observes |U1|. Volt-watt observes the largest phase magnitude when worst_phase_watt_guard=true, so an overvoltage phase cannot be hidden by the positive-sequence magnitude.

source
PowerOptLab.NegativeSequenceAdmittanceDroop — Type
NegativeSequenceAdmittanceDroop(gain; impedance_angle=0,
    ripple_blend=0, voltage_floor=1)

Request negative-sequence current from local voltage only. gain maps eta = |U2| / sqrt(|U1|^2 + voltage_floor^2) to an admittance magnitude in A/V. impedance_angle fixes the configured negative-sequence actuation angle, and ripple_blend blends the voltage-oriented request with the analytical double-frequency-ripple-cancelling target.

source
PowerOptLab.negative_sequence_virtual_impedance — Function
negative_sequence_virtual_impedance(r, x; ripple_blend=0, voltage_floor=1,
                                    smoothing_epsilon=1e-4)

Negative-sequence policy of a voltage source with a balanced internal EMF behind the virtual impedance Z_v = r + jx (Ω). With no internal negative-sequence voltage, KVL across Z_v gives I2 = -U2/Z_v, a constant admittance 1/|Z_v| (A/V) at the angle arg Z_v. This is the steady-state negative-sequence behaviour of a grid-forming converter that regulates a balanced voltage, and the passive comparator for the negative-sequence admittance droop. It returns a NegativeSequenceAdmittanceDroop with a flat gain, so current limiting, priorities and DC availability apply unchanged. The plant's own grid_forming=true reproduces this law with Z_v equal to the series filter. Its synchronisation, droop and current-limit transients are not represented.

source
PowerOptLab.CommonScaleLimiter — Type
CommonScaleLimiter(; current_epsilon=nothing, power_epsilon=nothing,
                     current_epsilon_fraction=2.5e-5,
                     power_epsilon_fraction=5e-8,
                     pq_priority=:proportional,
                     priority_headroom_fraction=1e-3)

Apply a common scalar to positive- and negative-sequence current commands so the reconstructed currents at the configured current target respect its declared per-leg limit. The physical plant independently retains every converter- and grid-side current constraint. In converter mode the positive-sequence P,Q request is first allocated within the s_max command budget. The final plant-aware backoff enforces converter-terminal apparent power independently of the current target. The exact evaluator uses hard maxima. The smooth model represents capability magnitudes by smooth upper norms with excess at most one quarter of the stated SI width. Min/max selectors use that full width. Hard physical capability inequalities remain exact. pq_priority is :proportional, :watt, or :var for the positive-sequence apparent-power allocation. By default, smoothing widths are rating-relative fractions, so heterogeneous fleets receive the same dimensionless regularization. Supplying current_epsilon or power_epsilon explicitly opts into an absolute SI width for that quantity. In converter mode, priority_headroom_fraction reserves a small declared fraction of s_max before a watt- or var-priority component reaches the axis of the capability circle. It is a control/protection margin, not a square-root regularization. In PCC mode the composed controller instead allocates net terminal services with the chosen P/Q priority, actual complex capability intersections, and unscaled filter compensation; priority_headroom_fraction is unused there.

source
PowerOptLab.SequencePriorityLimiter — Type
SequencePriorityLimiter(; priority=:power, kwargs...)

Sequence-priority alternative to CommonScaleLimiter. The reserved sequence current is limited on its own to (1 - priority_headroom_fraction) times the target per-leg rating. The other sequence then receives the largest scale t ∈ [0, 1] for which every reconstructed phase satisfies |a_x + t b_x| <= i_max, where a_x is the reserved and b_x the requested phase contribution.

  • priority=:power reserves the positive-sequence (Volt-var/Volt-watt) current, so negative-sequence support uses only the remaining phase-current headroom and never curtails active power.
  • priority=:balance reserves the negative-sequence current and curtails the positive-sequence request when necessary.

The exact law uses the rationalised root of the per-phase quadratic, t = n/(c + sqrt(c^2 + |b|^2 n)) with n = i_max^2 - |a|^2 and c = Re(a conj(b)). The smooth model overestimates the square root and the selector denominators, so its scale never exceeds the exact one. All other keywords and their defaults are those of CommonScaleLimiter. The plant-aware protection (selected-location apparent power, both filter-side ratings, dv2_max and i_cap_max) honours the same priority. It first scales only the lower-priority sequence, holding the reserved one as an offset, and scales the reserved sequence only if that alone still violates a limit.

InverterControlResult.current_scale reports the scale applied to the positive-sequence request, as it does for the common-scale limiter. The negative-sequence scale is abs(i2)/abs(i2_request); study rows report it as negative_sequence_scale.

source
PowerOptLab.SequenceController — Type
SequenceController(positive, unbalance, limiter;
                   current_target=ConverterCurrentTarget(),
                   power_voltage_floor=1,
                   sensing_reference=:device)

Closed-form three-leg controller combining a positive-sequence Volt-var/Watt policy, a negative-sequence policy, and an algebraic feasibility limiter. current_target selects converter-leg or post-filter grid current. power_voltage_floor is the strictly positive SI voltage floor in the regularized standalone/converter P,Q-to-I1 conversion; it is not a magnitude-smoothing epsilon. Composed PCC mode instead requires |U1| to be at least this floor and uses the unattenuated inverse for terminal delivery and filter compensation.

sensing_reference declares the conductor the voltage sensors are referred to; it is part of the law, not of the power connection. The default :device uses the plant's declared neutral terminal. When the composed AdvancedInverter has neutral=nothing — the three-wire case, and the only one accepted for a native THREE_LEG fleet record — that reference is the network's ground, not a neutral conductor, so the measured phasors carry the local zero-sequence displacement. :ground always senses phase-to-ground. A terminal name such as "n" senses phase-to-neutral against that terminal of the inverter bus even when the power stage is three-wire, as in a three-wire product with a neutral sensing lead. |U_1| and |U_2| are invariant to that choice, so PositiveSequenceVoltVarWatt Volt-var and NegativeSequenceAdmittanceDroop are unaffected; the phase-magnitude policies are not. Neither is the default maximum-phase Volt-watt guard of PositiveSequenceVoltVarWatt (worst_phase_watt_guard=true). See the sensing-reference discussion in the phase-aware control design.

The controller equalities themselves use only these voltage phasors, but the composed allocation in stamp_smooth_control! additionally reads converter-terminal internal voltage and both filter-arm currents. It is a protection surrogate, not part of the voltage-curve law.

source
PowerOptLab.InverterControlRequest — Type

Per-point DC-link input availability, rated active power and reactive-power base, in SI.

p_available applies at the regulated DC-link input, including modeled converter and capacitor ESR loss. It is not lossless POC power or upstream PV/DC–DC input. Source-path mean and harmonic dissipation outside that boundary is excluded; see dc_source_line_frequency_diagnostics.

source
PowerOptLab.InverterControlRatings — Type
InverterControlRatings(; s_max, i_max=nothing, i_scale=something(i_max, 1.0))

Fundamental apparent-power command budget (VA) and optional per-phase current limit (A). With i_max=nothing the target-current limiter is bypassed. i_scale is a positive numerical current scale, not a capability bound; it sets rating-relative smoothing widths and starts. Plant-derived ratings use nominal power/voltage to choose it when no current rating is declared.

source
PowerOptLab.InverterControlResult — Type

Numeric controller record shared by exact evaluation and smooth-model extraction. sequence_power, total_power, and ripple_power are command-space diagnostics formed from the POC voltage measurement and commanded current at the configured current target. They are not converter-terminal powers when an output filter separates those locations. Complex powers use the injection sign convention. In composed PCC mode, p_request/q_request are net terminal requests before saturation. power_scale and the compatibility field current_scale both measure retained service-P/Q magnitude, excluding filter compensation and loss imports; they do not scale the full phase currents.

source
PowerOptLab.ConverterTerminalResult — Type

Converter-terminal phasors and powers derived from the physical plant solution. All phasors are RMS and powers follow the injection sign convention. The authoritative total converter power is sum(phase_power). Sequence powers use S_k = 3U_k*conj(I_k), and ripple_power is the complex twice-fundamental coefficient sum(U_phase*I_phase).

source
PowerOptLab.evaluate_exact — Function
evaluate_exact(controller, measurement, request, ratings;
               dc_power_offset=0)

Evaluate the exact standalone local controller without JuMP. This is an idealised reference law, not validated manufacturer firmware. Composed PCC control additionally requires plant measurements and uses terminal allocation; evaluate_exact alone does not include that allocation. It uses only local RMS phasors and fixed controller/rating data.

The positive-sequence active-power command never exceeds the AC-available power p_available - dc_power_offset (W). The offset is the DC power drawn beyond the commanded positive-sequence power, i.e. converter, filter and capacitor losses plus negative-sequence active power; see dc_power_offset. Its default of zero describes a lossless plant. When the offset exceeds the available power the command becomes an import that covers exactly the shortfall; the Volt-watt curve does not curtail that import. The loss import uses the physical voltage denominator without power_voltage_floor, which continues to regularize only the service command. A nonzero loss import requires nonzero positive-sequence voltage.

source
PowerOptLab.dc_power_offset — Function
dc_power_offset(p_dc, phase_voltage, target_current)

DC power drawn by the plant beyond the commanded positive-sequence power 3Re(U1 conj(I1)), in the units of p_dc. phase_voltage is the controller's sensed three-phase voltage and target_current the solved current at the controller's current target. The offset contains semiconductor, filter and capacitor losses and negative-sequence active power. Passing it to evaluate_exact reproduces the DC-availability limit stamped by stamp_smooth_control!.

source
PowerOptLab.sensing_terminal — Function
sensing_terminal(controller, inverter) -> Union{Nothing,String}

Terminal of the inverter bus that the controller's voltage sensors are referred to, or nothing for phase-to-ground sensing.

source
PowerOptLab.evaluate_smooth — Function
evaluate_smooth(controller, measurement, request, ratings;
                dc_power_offset=0)

Numerically evaluate the same differentiable computation graph stamped by stamp_smooth_control!. This is intended for inexpensive SI-valued extraction and comparison with evaluate_exact; it does not solve an optimization problem. dc_power_offset has the meaning documented for evaluate_exact.

source
PowerOptLab.stamp_smooth_control! — Function
stamp_smooth_control!(ctx, controller, request, inverter, handles)

Constrain an already-stamped AdvancedInverter to the smooth, fixed-structure counterpart of evaluate_exact. The voltage-curve law uses local POC phasors referred to the plant's declared neutral (see SequenceController) and commands the configured converter- or grid-side phase currents.

In PCC mode the composed law interprets curve outputs as net terminal P/Q, allocates watt/var/proportional priority against the actual complex power circle and optional arm-current/ripple limits, then compensates the filter when translating to converter current. It uses the PCC-terminal loss offset p_dc-p_poc; the standalone evaluator does not perform this plant-aware stage.

In converter mode the subsequent capability backoff is deliberately wider than evaluate_exact: it also reads converter-terminal internal voltage and physical POC voltage and both filter-arm currents so that a declared per-leg, selected-location apparent-power, dv2_max, or capacitor thermal-current limit saturates the command instead of making the controller equality infeasible. solve_controlled_inverter applies the same backoff to the exact law at the solved point, which is why the two commands are comparable. The three-leg capacitor budget includes the source-dependent 2ω current, frequency weights, fixed i_sw and current-dependent pwm_current_factor allowances. It does not infer a thermal rating from capacitance. An infeasible mandatory loss-import or fixed-ripple anchor still lies outside the controller domain.

source
PowerOptLab.solve_controlled_inverter — Function
solve_controlled_inverter(net, controlled, request; kwargs...)
    -> ControlledInverterResult

Solve one network snapshot with a local phase-aware controller composed around an AdvancedInverter. The voltage-curve law uses only the inverter's own POC voltage phasors (see SequenceController for the sensing reference); the subsequent capability backoff also uses converter-terminal voltage and both filter-arm currents. The nonlinear controller formulation requires per_unit=true; controller configuration and returned results remain SI. This is a controlled power flow: the controller equalities determine the command, while selection_objective only selects remaining plant allocation freedom (:loss, the default, or :zero for an objective-invariance check).

initialization=:automatic permits one cold rebuild after a numerical termination. :spread selects one start policy; :consistent selects the fallback directly. The fallback uses consistent graph starts and tries Ipopt gradient scaling unless the caller explicitly sets a scaling option. For a zero objective, it instead uses spread starts for a loss-objective seed and transfers only a raw-successful, physically accepted seed into the final zero objective. At most three objective stages are recorded, each with the supplied iteration budget. Zero-iteration and time-limit outcomes are not retried. Failed primals/duals never transfer between cold models. Stages, objectives, scaling and raw outcomes are retained in solve_diagnostics(result).numerical_attempts. Final raw and physical gates remain unchanged.

exact_smooth_current_residual compares the exact law with the stamped smooth law at the smooth model's own solved operating point, using the same solved plant phasors for both. It therefore bounds the smoothing error of the controller algebra, not the distance between the exact-law and smooth-law network equilibria; an independent fixed-point oracle is still outstanding research work.

source