Inverter operating-constraint API
The operating-constraint guide compares this OPF formulation with the existing forward current controller.
PowerOptLab.VoltVarWattConstraints — Type
VoltVarWattConstraints(intent, encoding; sensing_reference=:device)
VoltVarWattConstraints(positive_policy; sensing_reference=:device)Volt-var equality and volt-watt upper bound on total POC power. Reuses the voltage sensing, flat-extended curves and smoothing of the positive-sequence policies, but does not allocate apparent power or scale a current command. sensing_reference has the same meaning as in SequenceController.
With volt_watt_basis=:rated, the watt ceiling is p_rated * fraction. With :available, it is fraction * (available_dc - (p_dc - p_poc)), where available_dc is the tighter of request availability and a DC source upper bound. An independent p_dc <= p_available bound accounts for all plant losses and preserves required loss imports at zero availability. No Q curve means Q = 0.
No watt curve means fraction = 1, and the ceiling is still imposed, matching the forward controller's min(p_rated*fraction, available) command: with :rated this caps P at p_rated; with :available it coincides with the DC availability bound. InverterOperatingConstraints instead imposes no ceiling without a watt curve.
The :available ceiling subtracts the solved plant losses p_dc - p_poc, so it depends on the operating point: more reactive current raises filter and conduction losses and lowers the ceiling. Firmware that scales a separately measured or estimated available power can differ by those losses. The product of fraction and the losses is an additional nonconvex term.
Curve encodings must currently be smooth. These relationships do not certify compliance with a regional standard.
PowerOptLab.InverterOperatingConstraints — Type
InverterOperatingConstraints(positive_policy=AverageVoltageVoltVarWatt();
reactive=FreeReactivePower(), p_min=nothing, p_max=nothing,
q_min=nothing, q_max=nothing, sensing_reference=:device)POC capability/dispatch relationships with an explicit reactive operating mode: FreeReactivePower, FixedReactivePower, or FixedPowerFactor. Optional finite P/Q bounds are in W/var and compose with every mode. The positive policy may supply a volt-watt ceiling. No watt curve means no watt ceiling at all, even with volt_watt_basis=:rated; add p_max=p_rated for a rated cap. This differs deliberately from VoltVarWattConstraints, which mirrors the forward controller. A policy containing a volt-var curve is rejected: use VoltVarWattConstraints for that Q equality.
An objective selects the remaining freedom. Neither a PF relation nor balanced current is an implication of the hardware. DC source bounds and current allocation are specified on ConstrainedInverter.
PowerOptLab.FreeReactivePower — Type
Leave total POC reactive power dispatchable within the physical and declared bounds.
PowerOptLab.FixedReactivePower — Type
FixedReactivePower(q) imposes total POC Q = q (var, injection positive).
PowerOptLab.FixedPowerFactor — Type
FixedPowerFactor(pf, direction)
FixedPowerFactor(pf)Fixed power-factor relation on total POC powers. Prefer the explicit form: direction is :absorbing (Q < 0 while exporting P, under-excited) or :injecting (Q > 0 while exporting P, over-excited), with 0 < pf <= 1. Standards and datasheets attach different signs and leading/lagging labels to the same operating point, so the direction is named rather than signed.
The single-argument form is the stored signed value: for positive P, positive pf absorbs Q and negative pf supplies Q. Requires 0 < abs(pf) <= 1. The relation uses bounded sine/cosine coefficients, including near zero PF, instead of an overflowing tangent. It also applies to negative P with the same algebraic ratio; it does not impose a generation or charging direction. At P = Q = 0 the equation is satisfied but a measured PF is undefined.
PowerOptLab.DCSourceBounds — Type
DCSourceBounds(; p_min=nothing, p_max=nothing)Additional signed bounds on physical DC-link power (W, positive from the source into the converter). Request availability always remains an upper bound. p_min=0 models a non-charging PV source while permitting AC loss imports. Signed bounds permit bidirectional sources. Omitted bounds retain the legacy availability-only source model; they do not assert that the source is PV. The boundary is the regulated DC-link input, including modeled converter and capacitor ESR loss. Upstream source/DC–DC mean-path and source-impedance harmonic losses are excluded; see dc_source_line_frequency_diagnostics.
PowerOptLab.ConstrainedInverter — Type
ConstrainedInverter(plant, policy;
current_allocation=:balanced_converter, dc_source=DCSourceBounds())Three-phase physical plant with explicit operating constraints. The default :balanced_converter imposes zero/negative sequence at the converter; :balanced_grid imposes balance on the grid arm; :free leaves sequence allocation to the optimisation within topology and capability constraints. The plant alone determines the three-leg zero-sum restriction. LCL grid and converter currents can differ. POC powers include the declared POC shunt. All declared hardware inequalities remain in the plant. Its power_limit_location selects converter or total POC apparent power; current/thermal ratings may be omitted independently. An impossible Q request makes the model infeasible rather than activating a limiter or a tracking slack.
Use stamp_device! with an InverterControlRequest to compose this device with an external OPF objective, or solve_constrained_inverter for a standalone dispatch solve. There is no implicit dispatch objective. Supports THREELEG, FOURLEG and SPLITDC with `gridforming=falseandpwmstrategy=:NONE`; fixed RMS current reserves remain supported. Monolithic THREELEG/FOURLEG also support :CENTERED with an open carrier-frequency DC source and an inductive filter with proportional passive R/L through embedded shared-carrier thermal allocation. Frozen-current variance and an all-duty AC-ripple-induced DC-current bound participate in every objective stage. `pwmthermalheadroom=0.10is an additional frozen-current validation allowance, not a bound on unmodeled dynamics. Independent carrier/event quadrature gates publication. Automatic AC reserve closure and split-link PWM allocation are not provided by this wrapper. Representative EMT is still required. The default DC source retains the request availability upper bound. Supplydcsource=DCSourceBounds(p_min=0)` for non-charging PV.
PowerOptLab.ConstrainedInverterResult — Type
Result of solve_constrained_inverter. plant contains physical SI quantities; operation contains curve targets, POC tracking residuals and signed capability margins (positive is feasible). q_constraint_residual_var checks the encoded equality, while q_tracking_residual_var compares with the exact PWL policy at the solved sensing voltage. Neither is a current-command replay. Unpublishable solves retain their status and configuration, with NaN for solved numerical quantities and nothing for absent optional targets.
PowerOptLab.solve_constrained_inverter — Function
solve_constrained_inverter(net, device, request;
objective=:max_export, p_set=nothing, per_unit=true,
s_base=1e6, optimizer=Ipopt.Optimizer, verbose=false, solver_options=())Solve a three-phase ConstrainedInverter with its declared operating policy. :max_export maximizes POC active injection. :feasibility requires a finite p_set (W, injection positive) and checks that fixed dispatch. Both retain the same reactive relationship and hard plant limits. Active power can import to supply losses when availability is zero. No controller-side current scaling is introduced.
This is a nonconvex OPF/dispatch formulation, not an autonomous inverter power flow or a proof of global optimality. Use stamp_device!(ctx, device; request) inside an external model hook to select another objective; stamping does not replace the objective. The standalone solver requires per_unit=true.
PowerOptLab.project_inverter_current — Function
project_inverter_current(inv, request; grid_voltage, requested_current,
target=:converter, dc_source=DCSourceBounds(p_min=0.), midpoint_charge=0.,
s_base=1e5, optimizer=Ipopt.Optimizer, verbose=false, solver_options=())Find a local least-squares current allocation within all declared inverter limits at fixed POC RMS voltage phasors. target selects converter-arm or grid-arm current; grid-arm current excludes the separate POC shunt. Phase order follows inv.phase_terminals. Voltage phasors refer to the inverter neutral (or earth when absent). The metric is the sum of squared complex-current errors, with a common numerical normalization that does not change its minimizer.
The reference includes filter/neutral coupling, losses, source bounds, sequence and thermal limits, and adaptive full-cycle rail cuts. Default DC bounds model a non-charging PV source; availability remains an upper bound. Split-link balancing charge is fixed to the explicit midpoint_charge in both the requested-point audit and the allocation. This is a conditional capability test, not optimization over that actuator. Non-split topologies require zero charge.
Supports the same three-phase, non-grid-forming plants and centered-PWM scope as ConstrainedInverter. The requested point is reconstructed and audited independently. A violated request together with a feasible allocation demonstrates a command/capability conflict under these conditions. Failure to find an allocation is inconclusive. This nonconvex offline reference does not certify a globally nearest point, implement reactive-priority VV+VW, or validate closed-loop dynamics.
PowerOptLab.InverterCurrentProjectionResult — Type
InverterCurrentProjectionResultOffline current allocation at fixed POC voltage and midpoint balancing charge. request_feasibility is :feasible, :violated or :unresolved, based on an independent reconstruction of the requested point. plant_feasibility is :feasible when either that point or the accepted allocation is a witness; otherwise it is :unresolved. A failed local solve never proves plant infeasibility. These statements apply only to the declared boundary/source model.
allocation retains the raw solve status and physical report. distance_A is the Euclidean distance across the three complex arm currents (NaN unless the allocation is publishable). requested_state and requested_physical are nothing if the filter transfer is singular or numerically indeterminate.
PowerOptLab.allocate_inverter_services — Function
allocate_inverter_services(inv, request; grid_voltage, reactive_request,
active_fraction=1., volt_watt_basis=:rated, negative_sequence_request=0im,
target=:converter, reactive_mode=:within_request,
dc_source=DCSourceBounds(p_min=0.), diagnose_plant=true,
s_base=1e5, optimizer=Ipopt.Optimizer, verbose=false, solver_options=())Allocate a three-leg command at measured, fixed POC RMS voltage phasors using the full averaged plant and continuous rail refinement. Stage 1 minimizes total POC Q tracking error; stage 2 holds its achieved Q and maximizes POC P; stage 3, when requested, holds both powers and maximizes the scale of the requested I₂. There is no finite objective weight that exchanges higher-priority service for lower-priority service. Every stage independently checks physical limits, fixed voltage, sequence-command and preserved-power residuals before continuing.
:within_request restricts Q between zero and reactive_request. Explicit :protective_override permits Q outside that interval, seeking the closest locally feasible Q when voltage protection requires it. This changes the policy; it is never activated as a silent fallback. I₂ follows the requested complex ray with scale in [0,1] on the selected converter/grid arm. Positive-sequence current delivers the chosen total POC powers, including filter/shunt effects.
The volt-watt ceiling uses p_rated*active_fraction for :rated and active_fraction*(available_dc - (p_dc-p_poc)) for :available; DC availability also remains a hard bound. Default source bounds prevent DC charging and allow AC loss imports at zero PV. grid_voltage refers to the plant neutral or earth when absent, in phase-terminal order. Supports THREELEG, non-grid-forming plants, including centered-PWM thermal allocation with an open carrier-frequency source. PWM/nonlinear-energy stages preserve service within a 0.0001 var/W SI budget to avoid a singular tangent lock, without relaxing hardware constraints. Four-leg phase service uses `allocatephaseinverterservices`.
This solver-based local reference can be re-evaluated at successive measurements. Its solve time, feeder equilibrium, stability and response time are not certified. It does not replace the fixed-structure SequenceController stamp. Local solver success does not establish globally best Q/P/I₂ allocation. On a failed first stage, an optional unrestricted physical projection supplies a plant-feasibility witness without issuing that alternative as the controller command.
PowerOptLab.evaluate_voltage_aware — Function
evaluate_voltage_aware(controlled, measurement, request; grid_voltage, kwargs...)Evaluate a solver-based Q→P→I₂ allocation from the exact mean/worst/sequence VV+VW voltage laws. measurement contains sensed phasors; grid_voltage must separately declare the physical POC phasors because sensing and power references can differ. Requires reactive priority and power-first sequence priority. Supports NoUnbalanceControl or voltage-admittance droop with ripple_blend=0; a current-dependent ripple-compensation request needs a separate feedback model. The result is a local fixed-measurement command, not a network equilibrium or dynamic-stability certificate. No existing controller stamp is changed.
PowerOptLab.AbstractInverterServiceAllocationResult — Type
Common result interface for solver-based local inverter service allocation.
PowerOptLab.InverterServiceAllocationResult — Type
InverterServiceAllocationResultResult of allocate_inverter_services. stages preserves every local solve in Q-tracking, P-export, then I₂-support order. allocation is the last stage, including a failed candidate. current_command is nothing unless all stages publish. plant_feasibility is :feasible only with an accepted stage or an independent diagnostic witness; otherwise it is :unresolved. policy_feasibility is :feasible only when the final stage publishes. An NLP failure is inconclusive, even if the unrestricted plant diagnostic succeeds. These are local nonconvex results, not global lexicographic optimality proofs.
PowerOptLab.allocate_phase_inverter_services — Function
allocate_phase_inverter_services(inv, request; grid_voltage,
reactive_request, active_fraction=(1.,1.,1.), volt_watt_basis=:rated,
target=:converter, dc_source=DCSourceBounds(p_min=0.), kwargs...)Four-leg local Q-vector-ray → equal-phase-P allocation at fixed physical POC phase-neutral phasors. Hardware/source/continuous rails and phase-policy checks gate every stage. A failed stage issues no command and proves no global plant or policy infeasibility. A separate unrestricted projection may supply a physical witness without replacing the failed policy. Current limits are RMS. The optional centered-PWM term includes an all-duty AC-ripple-induced DC thermal reserve; full switching dynamics still require representative EMT validation.
PowerOptLab.PerPhaseVoltVarWatt — Type
PerPhaseVoltVarWatt(; volt_var=nothing, volt_watt=nothing,
volt_watt_basis=:rated, current_target=:converter,
power_voltage_floor=1., sensing_reference=:device)Four-leg voltage-aware local policy. Each phase uses its own sensed RMS voltage; Q and rated P bases are one third of the total request bases. Reactive priority maximizes one common [0,1] service coordinate for the three Q requests, then holds it while maximizing total P (100 µvar preservation budget in PWM/nonlinear mode). POC active powers are equal across phases; that is not balanced current under unbalanced voltage. Available-basis VW uses one third of shared AC availability, including total solved losses. No separate phase PV sources or per-phase VA ratings are introduced. Zero/negative sequence and the neutral current follow from the phase powers and full physical filter.
Use evaluate_voltage_aware; fixed-graph implicit controller stamping is not provided. This is an exact-curve, solver-based quasi-static reference, not a firmware timing, global-optimality or dynamic-stability guarantee. Requires an explicit neutral, FOUR_LEG and non-GFM plant. Centered-PWM capacitor allocation is supported with an open carrier-frequency DC source. Omitted current limits remain omitted; in particular no neutral rating is inferred from a phase rating.
PowerOptLab.PhaseInverterServiceAllocationResult — Type
PhaseInverterServiceAllocationResultResult of allocate_phase_inverter_services. reactive_scale is the common fraction of phase_reactive_request_var; stages retains raw solver and physical evidence. current_command is present only when every policy stage passed. Plant/policy feasibility is :feasible when witnessed, otherwise :unresolved; a failed local solve does not prove infeasibility. A plant diagnostic, when requested, never replaces the failed controller command.
PowerOptLab.solve_voltage_aware_inverter_fleet — Function
solve_voltage_aware_inverter_fleet(net, spec; operating_modes=:energized,
initial_currents=nothing, relaxation=1., max_iterations=30,
atol_voltage=1e-7, atol_current=1e-6, reactive_mode=:within_request,
dc_source=DCSourceBounds(p_min=0.), s_base=1e5,
optimizer=Ipopt.Optimizer, verbose=false, solver_options=(), progress=nothing)Couple evaluate_voltage_aware to full native network power flows. Each local allocation uses separate physical and sensed voltages. The feeder map imposes allocated grid-arm currents plus the declared POC shunt. Intermediate network probes omit inverter hardware constraints and are explicitly virtual; otherwise a saturated rail could prevent evaluation of a perturbed iterate. Every returned candidate is reconstructed and audited at the actual feeder voltage. Acceptance requires voltage and current-map closure, local stage success, native SI equation checks and full inverter/source/policy checks. Solver failures, iteration limits and controller voltage-domain failures remain unpublishable.
operating_modes is a common symbol or a complete per-device dictionary. :energized retains active controls and loss imports at zero PV. :disconnected means an open grid-side contactor: the entire converter, filter and POC shunt are absent from the AC model. DC standby losses are outside this disconnected model. All-disconnected operation is a pure network power flow with zero iterations. Unselected native IBRs remain native. Inputs are not mutated; inverter sizing is unchanged. Supports three-leg sequence control and four-leg per-phase Q→P allocation; the latter has equal POC phase P and a shared DC source.
This is a quasi-static numerical fixed point, not an EMT/time-domain controller simulation, global uniqueness proof or latency/stability certificate. Registered native equation residuals are not an independent implementation of the circuit. progress, when supplied, receives each stored iteration diagnostics tuple.
PowerOptLab.VoltageAwareInverterFleetResult — Type
Result of solve_voltage_aware_inverter_fleet.
devices contains local Q→P→I₂ allocations at the final verification voltages. replayed and physical_feasibility(result) describe the imposed grid currents at the returned network voltages. network_equation_checks evaluates native zero-equality rows in SI; it is a model residual audit, not an independent circuit implementation. reason describes the iteration outcome; solve retains the last raw solver evidence and additionally gates publication on convergence, physical reports and policy/current closure. Disconnected devices have no local allocation or inverter report because their entire AC model is absent.
PowerOptLab.voltage_aware_inverter_rows — Function
Deterministic SI rows for a voltage-aware coupled fleet.
Only accepted=true rows belong in scientific equilibrium comparisons. Disconnected AC powers/currents are zero; DC power and inverter certificate fields are nothing because that device model is absent. Voltages remain customer-bus observables, not a claim that disconnected electronics are measuring them.