About the Smart Grid Balancer

Written by MySimulator Team · Reviewed by MySimulator Editorial Review

Last updated: 20 July 2026

This simulation runs a small grid with configurable solar and wind capacity, a battery, sixteen shiftable loads, and an inflexible demand curve, and steps it forward through a simulated day. Solar output follows a daylight bell curve modulated by a mean-reverting cloudiness process; wind output is driven by a mean-reverting wind-speed process pushed through a realistic cut-in/rated/cut-out power curve. Both are genuinely noisy from second to second, not scripted.

Two things keep the grid balanced. First, once per simulated day the controller re-solves a greedy day-ahead schedule: each of the sixteen flexible loads is moved, within its allowed window, to whichever half-hour slot has the best forecast surplus of renewables over inflexible demand — deferring loads into a sunny or windy patch, or pulling them forward if the best slot is earlier. Second, in real time every tick the battery charges on any leftover surplus and discharges to cover any deficit, subject to its power rating, state of charge and round-trip efficiency losses. Whatever imbalance the battery still can't absorb becomes either curtailed renewable energy (wasted) or unmet demand (shortfall), and that residual also drives a simple grid-frequency model that drifts away from 50 Hz under sustained imbalance and relaxes back when the grid is balanced.

Frequently Asked Questions

What is demand response, and how is it different from just building more storage?

Demand response (DR) means changing when electricity is consumed rather than changing how much is generated or stored. Instead of always running a dishwasher, EV charger or industrial process at a fixed time, DR shifts some of that load to whenever the grid has spare capacity — usually when renewable output is high or overall demand is low — and away from periods when the grid is stressed. It's complementary to storage, not a substitute: storage moves energy in time by physically holding it (with round-trip losses), while DR moves the underlying activity in time and costs nothing in conversion losses, but only works for loads that can tolerate being early or late. Real utilities combine both, exactly as this simulation does with its flexible loads and its battery.

Why does adding solar and wind make grid balancing harder, not easier?

Coal, gas and nuclear plants are dispatchable — operators can ramp their output up or down to track demand. Solar and wind are variable and only partially predictable: solar output depends on cloud cover changing minute to minute and drops to zero every night, while wind depends on a stochastic wind-speed process that can swing between the cut-in and rated thresholds of a turbine's power curve within an hour. As the fraction of variable renewables on a grid rises, the residual demand that dispatchable plants and storage have to cover becomes lumpier and harder to forecast — the well-known "duck curve" problem, where net demand plunges in the middle of a sunny day and then ramps sharply upward in the evening as the sun sets and demand peaks. This simulation exposes that same dynamic: raise the weather-variability slider and you'll see the supply curves in the chart become noisier and force the battery and load-shifting logic to work harder.

How does the battery actually decide when to charge or discharge here?

Every simulated tick the controller computes the instantaneous mismatch between total renewable output and total demand. If there's a surplus, the battery charges at a rate capped by its power rating and by how much headroom is left before it hits full capacity, and only a fraction of that energy (round-trip efficiency, modelled here as roughly 0.93 × 0.93 ≈ 86%) actually ends up stored, with the rest lost as heat in the conversion. If there's a deficit, the battery discharges under the same power-rating and capacity constraints, again losing some energy to conversion inefficiency on the way out. Whatever mismatch remains after the battery has done what it can becomes curtailment (surplus) or shortfall (deficit) — this is a standard rule-based dispatch policy, simpler than the stochastic optimisation real grid operators run, but it captures the same physical constraints: power limits, energy limits, and efficiency losses.

What is grid frequency, and why does an imbalance move it away from 50 Hz?

Alternating-current grids operate at a fixed frequency (50 Hz in the UK and most of the world, 60 Hz in North America) because every generator, motor and transformer on the network is synchronised to it. That frequency is a direct readout of the balance between generation and load: when generation exceeds demand, spinning generators speed up slightly and frequency rises above 50 Hz; when demand exceeds generation, they slow down and frequency falls below 50 Hz. Grid operators maintain frequency within a very tight band (typically ±0.2 Hz) because large deviations can trip protective relays and cause cascading outages. This simulation's frequency gauge is a simplified first-order model — it drifts away from 50 Hz in proportion to the residual mismatch (after the battery has acted) and relaxes back toward 50 Hz over time, standing in for the much more detailed physical inertia and governor-response models used in real power-systems engineering.

What does "curtailment" mean, and why would a grid operator ever waste free renewable energy?

Curtailment is deliberately reducing solar or wind output below what the resource could physically generate, because the grid has nowhere to put the extra energy — transmission lines are full, storage is already at capacity, or there's simply no demand to absorb it at that moment. It sounds wasteful, and it is a real cost, but it's often still the cheapest available option: it's frequently less expensive to curtail a few percent of renewable output on the sunniest, windiest days than to build enough extra transmission capacity or storage to absorb every possible surplus. In this simulation, curtailment accumulates whenever the battery is full (or its power rating is maxed out) and there is still more renewable supply than demand plus battery charging can use.

How does the day-ahead load-shifting schedule relate to real demand-response programs?

Utilities run DR through mechanisms like time-of-use pricing (cheaper rates overnight or during solar peak encourage voluntary shifting), direct load control (a utility can remotely cycle air-conditioners or EV chargers under a signed agreement), and day-ahead or hour-ahead capacity markets where large flexible consumers bid their willingness to shift load. This simulation's greedy scheduler mimics the day-ahead style: once per simulated day it looks at the deterministic forecast of solar, wind and inflexible demand across the full day, and — processing loads one at a time — assigns each flexible load to whichever half-hour slot within its allowed window has the best remaining forecast surplus, then subtracts that load's power from the slot before scheduling the next one so loads don't all pile onto the single best slot. It's a simplified, single-pass greedy heuristic rather than the linear or mixed-integer programs real demand-response aggregators solve, but the underlying goal — align flexible consumption with periods of high renewable output — is identical.

Why do the flexible loads sometimes get shifted earlier ("advanced") instead of later ("deferred")?

The scheduler doesn't have a bias toward pushing loads later — it simply picks whichever slot inside the load's window (native hour minus the flexibility window to native hour plus the flexibility window) has the best forecast surplus, and that can fall before or after the load's native hour. For example, a load with a native hour in the early evening, just as solar is fading and the evening demand peak is building, is often better served by running earlier in the afternoon while solar is still strong — so it gets advanced. A load native to mid-morning, just before the strongest midday solar arrives, is more often deferred slightly to catch that peak. Watch the load-shifting timeline: loads plotted to the left of their native-hour marker were advanced, loads to the right were deferred.

What are the limits of this simulation compared to how real transmission-system operators balance a grid?

This is a deliberately simplified single-node model: it has no transmission network, no locational pricing, no other generation types (gas peakers, hydro, nuclear), no forecast error between the day-ahead schedule and what actually happens (the schedule is optimised against the noise-free deterministic forecast, then reality is noisy on top of it), and a single aggregate battery rather than a fleet of distributed storage assets. Real system operators run detailed unit-commitment and economic-dispatch optimisations across thousands of generators and flexible resources, using probabilistic weather forecasts, ancillary-services markets for frequency response, and regional transmission constraints. What this simulation preserves faithfully is the core mechanism — read the state of supply, demand, storage and flexible load, and continuously re-balance across time — that all of those systems ultimately depend on.