Electric vehicle API
For equations, limitations and numerical semantics see the model guide.
The shared PE battery constructor is documented in the battery storage API. The multi-period scheduling API documents the solver that accepts EVDevice and ChargingSession objects.
PowerOptLab.EVDevice — Type
EVDevice(; id, bus, available, departure_energy, kwargs...)An electric-vehicle charger: a storage device that is only controllable while plugged in and must reach a target energy by departure. Set p_discharge_max > 0 for bidirectional (V2G) charging; the default 0.0 gives unidirectional (V1G).
Required
id,bus— asStorageDevice.p_charge_max— charge power limit (W).energy_max,energy_init— battery capacity and plug-in energy (Wh).available::Vector{Bool}— per period, whether the vehicle is plugged in. While unavailable the charger is idle and the state of charge is held.departure_energy— energy (Wh) required bydeparture_period.
Optional
p_discharge_max=0.0— V2G discharge limit (W);0.0⇒ charge-only.departure_period=nothing— period index by whose enddeparture_energymust be met;nothing⇒ the end of the horizon.phase_terminals,neutral,energy_min,q_min,q_max,eff_charge,eff_discharge,s_max,i_max,neutral_current_max,phase_policy,operation,complementarity_tolerance— asStorageDevice.energy_final=nothing— optional equality on the horizon-end stored energy.
For equipment capability intersections and assignment validation, use ChargingSession, EV, and EVSE. The legacy availability mask remains independent of its energy deadline; it does not represent trips.
PowerOptLab.EV — Type
EV(; id, energy_max, onboard_charge_max, kwargs...)Vehicle specification for fixed-assignment AC charging. Capacity/bounds are Wh; onboard_charge_max and onboard_discharge_max=0 are AC-referred W. One-way eff_charge=1, eff_discharge=1 include all losses between the AC port and the stored-energy account; do not add converter losses a second time. phase_count=1 is the number of simultaneously used phases, not a switchable phase choice. q_min=q_max=0 is the onboard charger's aggregate reactive capability (var). A specification is not a battery-state trajectory; the session supplies the initial energy. Optional charge_acceptance::PWLFunction is a nonnegative, nonincreasing AC power cap versus PE energy fraction (:unitless → :W), covering the usable energy domain. phase_policy=:equal_power constrains phase sharing unless both vehicle and EVSE explicitly select :independent. Heat and aging are not modeled.
PowerOptLab.EVSE — Type
EVSE(; id, bus, s_max, i_max, kwargs...)One AC charging outlet with a fixed conductor connection. s_max is aggregate VA; i_max is A per phase conductor. p_charge_max=s_max and p_discharge_max=0 are AC W. Default phase_terminals=["1"], neutral="n". Optional neutral_current_max bounds return current (A). phase_policy is :equal_power (equal phase P and Q) or explicitly :independent. q_min=q_max=0 are aggregate equipment var bounds. available=nothing means always operational; otherwise supply one Bool per interval. Equipment outages do not free an occupied outlet for another session.
This is a continuous-power scheduling envelope, not an AC/DC converter, a pilot response model, or a DC charging cabinet. It has no independent grid injection when empty. Shared cabinets and standby services require distinct models.
PowerOptLab.ChargingSession — Type
ChargingSession(; id, ev, evse, available, energy_init, departure_energy, kwargs...)A fixed assignment of an EV to one EVSE. available is a horizon-length occupancy mask. energy_init is stored energy (Wh) at the first horizon boundary; it is held before arrival and after departure. A single contiguous occupied interval is required. departure_period=nothing means the last occupied interval; the target is checked at its END. A supplied departure period must equal that interval. departure_energy is a stored-energy floor, not AC energy delivered. energy_final=nothing optionally fixes horizon-end energy. allow_v2g=false and allow_reactive_power=false are session permissions.
operation=:relaxed uses a normalized charge/discharge product bound with complementarity_tolerance=1e-8; :complementarity requires an MPCC backend. :independent is an explicit outer relaxation for research comparisons. acceptance_formulation=:auto lowers concave PWL acceptance bounds exactly; smooth formulations or ComplementarityGraph are explicit alternatives. acceptance_conservative=true corrects smooth upper bounds using their error contract. Endpoint bounds conservatively constrain each piecewise-constant interval. Conservative smoothing may make zero-cap states infeasible. Use the same EVSE object for successive sessions. One EV may have only one session per solve; repeated journeys need a persistent mobility-state model.