Five sources feed a single grid core: solar (rises and falls with the day/night cycle), wind (gusty and semi-random), a dispatchable gas peaker that ramps to cover whatever renewables can't, a battery that soaks up surplus and discharges into shortfalls, and an interconnector that trades power with a neighbouring grid. Every tick the simulation totals supply against the city's fluctuating demand curve; any leftover mismatch pushes the grid's frequency away from its 50 Hz nominal, and a damping term (representing governor response) pulls it back — the further off nominal, the more strained the grid.
gas += clamp(demand − renewables − gas, −ramp·dt, ramp·dt)
d(freq)/dt = mismatch / inertia − damping·(freq − 50)
inertia ∝ (1 − renewable share) ← more renewables, less spinning mass, less inertia
- Solar / Wind capacity — the maximum output of each renewable source; actual output still swings with the simulated sun angle and wind gusts.
- City demand — the base load, itself modulated by a daily curve with a morning and evening peak.
- Battery reserve — bigger reserves buffer more of the mismatch between renewable output and demand before the gas peaker or interconnector has to respond.
- ☁ Cloud passes / 🌬 Calm spell — inject a temporary drop in solar or wind output, the exact kind of sudden variability that makes renewable integration hard.
- 🔌 Interconnector — toggle whether the grid can import or export power with a neighbouring system to help absorb the mismatch.
Real-world relevance: this is why grid operators keep spinning reserve, size battery storage, and forecast solar/wind output — as the renewable share climbs, the system has less natural inertia and needs faster, smarter balancing to keep frequency (and the lights) stable.