The clock runs a real 24-hour household energy balance, five simulated
minutes at a time. Solar output follows a daylight curve modulated by a
mean-reverting cloud-cover process; wind speed follows an Ornstein-Uhlenbeck
turbulence model fed through a real cubic turbine power curve with cut-in and
rated speeds. A dispatch rule decides where every kWh goes: surplus charges the
battery first (round-trip efficiency loss applied both ways) and only spills to
grid export once the battery is full; shortfalls draw from the battery before
falling back to a time-of-use grid price and its time-varying carbon intensity.
net = generation − demand
if net ≥ 0: charge battery (η≈0.95 each way) → export remainder
if net < 0: discharge battery (η≈0.95 each way) → import remainder
cost += import_kWh × price(hour); revenue += export_kWh × 0.05
CO2 += import_kWh × grid_intensity(hour)
- Solar / Wind capacity — installed peak power; actual output is always less, shaped by the stochastic weather processes above.
- Battery capacity — buffers the mismatch between generation and demand; bigger batteries catch more midday solar surplus for use at the evening peak.
- Evening demand shifted — the "wise decision" lever: moves this fraction of the 17:00–21:00 peak into the 00:00–05:00 off-peak window, cutting both grid price paid and reliance on imports without changing total energy used.
- Self-sufficiency — the share of total demand met without any grid import; a battery and demand-shifting both raise it even though installed capacity is unchanged.
Nothing here is fudged: cost, CO₂ and self-sufficiency are all running sums over the actual simulated supply/demand time series, exactly as a real home energy-management system would compute them.