Electric Vehicles

makeEV creates fixed or flexible electric-vehicle demand. See Component Builders for shared naming, workbook, and port conventions, and Tags And Post-Processing for tagging and reporting. Each mode's diagram follows the conventions in Reading The Port Diagrams.

Unstable EV API

The EV API is not fixed yet. The modes, keyword arguments, component and port structure, and reporting semantics may change substantially in later Posy2 versions.

Exactly one of fixed_profile, smart_charging, and vehicle_to_grid must be true.

Fixed Profile

The fixed mode creates a conventional demand component. offhours1 and offhours2 give zero-based hours of day for the winter and summer patterns; minratio scales demand in those hours. days_threshold locates the boundary between the first winter segment and summer. The generated 365-day profile is normalised to annual_consumption, so its hourly values always sum to annual_consumption exactly. Off-hour indices must be unique, and a schedule leaving no charging hour at all (every hour an off-hour with minratio=0) is rejected.

This mode requires offhours1, offhours2, and minratio, but performs no workbook lookup. It can add the same proportional grid losses port as makedemand.

Ports of an EV component in fixed-profile mode

makeEV(
    "EV", electricity, snapshot;
    annual_consumption=50_000.0,
    fixed_profile=true,
    smart_charging=false,
    vehicle_to_grid=false,
    offhours1=0:5,
    offhours2=0:5,
    minratio=0.2,
)

Smart Charging And Vehicle To Grid

The flexible modes represent the connected fleet as storage. number_ev sets fleet size and scales per-vehicle power and battery limits. initial_connected_share is the share of the fleet connected immediately before the first model timestep.

Mobility is defined each hour by:

  • departures and arrivals: nonnegative vehicle counts;
  • departure_soc and arrival_soc: mean state of charge in [0, 1].

Departing and arriving battery energy use

\[\begin{aligned} D_t &= \mathrm{departures}_t \times \mathrm{departure\_soc}_t \times \mathrm{battery\_capacity\_per\_ev} \\ A_t &= \mathrm{arrivals}_t \times \mathrm{arrival\_soc}_t \times \mathrm{battery\_capacity\_per\_ev} \end{aligned}\]

The connected count at the start of hour t and charging availability follow

\[\begin{aligned} n_1 &= \mathrm{initial\_connected\_share} \times \mathrm{number\_ev} \\ n_{t+1} &= n_t - \mathrm{departures}_t + \mathrm{arrivals}_t \\ a_t &= n_t / \mathrm{number\_ev} \end{aligned}\]

On a circular mesh, annual departure and arrival counts must balance (sum(departures) = sum(arrivals)). Charging availability a_t applies as a capacity multiplier on input, level, and (in vehicle-to-grid mode) output.

Per-vehicle technology parameters come from the column named by tech_column in the storage sheet: charging_eff, self_discharge, max_charging_power, max_dispatch_power, and battery_capacity. Each has a corresponding keyword override. max_dispatch_power is resolved only in vehicle-to-grid mode; smart charging does not require it.

In tech_mode=:arguments, charging efficiency defaults to one and self-discharge to zero. Maximum charging power and battery capacity remain structural and must be supplied; vehicle-to-grid additionally requires maximum dispatch power. In timeseries_mode=:arguments, departures, arrivals, departure_soc, and arrival_soc must also be supplied explicitly. In timeseries_mode=:excel, omitted mobility series are read for zone from EV_departure, EV_arrival, EV_departure_soc, and EV_arrival_soc.

Smart charging exposes a flexible input, a level, fixed unconnected departure and arrival ports, and a reporting only driving output (departure - arrival). Vehicle-to-grid mode also exposes output, limited by available dispatch power, and applies compensation as a variable output cost.

Ports of an EV component in smart-charging and vehicle-to-grid modes

Tags for all EV modes: :tech => tech, :zone => elec.name, and the function tags electricity, demand, and ev. Vehicle-to-grid mode also receives the function tag generation, so its discharge appears in production reporting.

Note

EV profiles use a 365-day, 8,760-hour convention, which the full-year horizon required of every builder guarantees.

See the Electric Vehicles example for smart charging and vehicle-to-grid models using this builder.

Posy2.makeEV — Function
makeEV(name::String, elec::Node, s::Snapshot;
    tech::String=name,
    fixed_profile::Bool=true, smart_charging::Bool=false, vehicle_to_grid::Bool=false,
    annual_consumption=nothing, offhours1=nothing, offhours2=nothing, minratio=nothing, days_threshold::Integer=104,
    number_ev=nothing, initial_connected_share=nothing,
    zone::Union{Nothing,String}=nothing, tech_column::String="EV",
    compensation::Real=0., grid_losses=0.,
    departures=nothing, arrivals=nothing,
    departure_soc=nothing, arrival_soc=nothing,
    charging_eff::Union{Nothing,Real}=nothing, self_discharge::Union{Nothing,Real}=nothing,
    max_charging_power_per_ev::Union{Nothing,Real}=nothing, max_dispatch_power_per_ev::Union{Nothing,Real}=nothing,
    battery_capacity_per_ev::Union{Nothing,Real}=nothing,
)

Build, connect and return an EV component.

Arguments:

  • name: Component name prefix.

  • tech: technology label used for reporting and component queries; defaults to name.

  • elec: Electricity node to connect EV charging/discharging flows.

  • s: Target snapshot where the EV component and behaviors are registered.

  • fixed_profile: Enable fixed-profile EV demand mode (deterministic hourly charging profile).

  • smart_charging: Enable flexible charging mode (charging only, no discharge to grid).

  • vehicle_to_grid: Enable flexible charging + grid discharge (V2G) mode. Exactly one of fixed_profile, smart_charging, vehicle_to_grid must be true.

  • annual_consumption: Yearly EV electricity consumption in fixed-profile mode (MWh/year). Must be non-negative and is rejected in flexible modes.

  • offhours1: Winter off-hour indices (0-23, no duplicates). Required when fixed_profile=true; ignored otherwise.

  • offhours2: Summer off-hour indices (0-23, no duplicates). Required when fixed_profile=true; ignored otherwise.

  • minratio: Dimensionless charging level during off-hours (0 <= minratio <= 1). Required when fixed_profile=true; ignored otherwise. The hourly profile is normalized so that it sums to annual_consumption; a schedule that leaves no charging hour at all (every hour an off-hour with minratio=0) is rejected.

  • days_threshold: Number of first winter days before summer segment in fixed-profile assembly (0 <= days_threshold <= 183, used only when fixed_profile=true).

The fleet, mobility-profile, charging-efficiency, and battery-limit arguments below are used only in flexible/V2G modes unless stated otherwise.

  • number_ev: Number of vehicles in the fleet (> 0). Scales per-vehicle power and battery limits.
  • initial_connected_share: Share of the fleet connected immediately before the first model timestep (0 <= initial_connected_share <= 1).
  • zone: Zone key used to read omitted EV time series in :excel mode.
  • departures: Hourly number of vehicles departing the connected fleet, scalar or vector, nonnegative. If nothing, read it from the configured time-series workbook (EV_departure).
  • arrivals: Hourly number of vehicles arriving to the connected fleet, scalar or vector, nonnegative. If nothing, read it from the configured time-series workbook (EV_arrival).
  • departure_soc: Mean SOC of departing vehicles in [0, 1], scalar or vector. If nothing, read it from EV_departure_soc in :excel mode.
  • arrival_soc: Mean SOC of arriving vehicles in [0, 1], scalar or vector. If nothing, read it from EV_arrival_soc in :excel mode.
  • tech_column: Technology column name in the storage tech data sheet for EV parameters, used in flexible/V2G modes; defaults to "EV".
  • compensation: V2G compensation in currency/MWh of grid discharge (ignored in non-V2G modes).
  • grid_losses: Proportional grid-loss fraction on EV input in fixed-profile mode (0 <= grid_losses < 1).
  • charging_eff: Dimensionless charging efficiency in flexible/V2G modes (0 < charging_eff <= 1); defaults to one in :arguments mode.
  • self_discharge: Self-discharge fraction per hour in flexible/V2G modes (0 <= self_discharge < 1); defaults to zero in :arguments mode.
  • max_charging_power_per_ev: Maximum charging power in MW/vehicle (> 0), required explicitly in :arguments mode.
  • max_dispatch_power_per_ev: Maximum V2G power in MW/vehicle (>= 0), required explicitly for V2G in :arguments mode and ignored otherwise.
  • battery_capacity_per_ev: Battery capacity in MWh/vehicle (> 0), required explicitly in :arguments mode.
source