How does the grid keep the lights on?
Be the grid operator for a day
- Foundations · L1
- Lesson 0 of 14
- 15 min
- No prerequisites
- Completed
Prairie Town's day, as the cheapest-first rule runs it
Text version: the day as a table, in MW
| Hour | Demand | Nuclear | Wind | Solar | Gas CC | Peaker | Spilled |
|---|---|---|---|---|---|---|---|
| 00:00 | 250 | 100 | 30 | 0 | 120 | 0 | 0 |
| 01:00 | 243 | 100 | 28 | 0 | 115 | 0 | 0 |
| 02:00 | 238 | 100 | 28 | 0 | 110 | 0 | 0 |
| 03:00 | 235 | 100 | 30 | 0 | 105 | 0 | 0 |
| 04:00 | 236 | 100 | 36 | 0 | 100 | 0 | 0 |
| 05:00 | 237 | 100 | 42 | 0 | 95 | 0 | 0 |
| 06:00 | 253 | 100 | 43 | 0 | 110 | 0 | 0 |
| 07:00 | 260 | 100 | 48 | 7 | 105 | 0 | 0 |
| 08:00 | 266 | 100 | 40 | 61 | 65 | 0 | 15 |
| 09:00 | 278 | 100 | 35 | 118 | 25 | 0 | 0 |
| 10:00 | 286 | 100 | 36 | 130 | 20 | 0 | 0 |
| 11:00 | 300 | 100 | 38 | 147 | 15 | 0 | 0 |
| 12:00 | 311 | 100 | 35 | 156 | 20 | 0 | 0 |
| 13:00 | 327 | 100 | 33 | 149 | 45 | 0 | 0 |
| 14:00 | 340 | 100 | 33 | 112 | 85 | 10 | 0 |
| 15:00 | 344 | 100 | 37 | 147 | 60 | 0 | 0 |
| 16:00 | 353 | 100 | 47 | 161 | 45 | 0 | 0 |
| 17:00 | 349 | 100 | 54 | 130 | 65 | 0 | 0 |
| 18:00 | 344 | 100 | 59 | 70 | 105 | 10 | 0 |
| 19:00 | 331 | 100 | 72 | 14 | 145 | 0 | 0 |
| 20:00 | 319 | 100 | 89 | 0 | 130 | 0 | 0 |
| 21:00 | 303 | 100 | 98 | 0 | 105 | 0 | 0 |
| 22:00 | 285 | 100 | 95 | 0 | 90 | 0 | 0 |
| 23:00 | 269 | 100 | 89 | 0 | 80 | 0 | 0 |
With JavaScript on, you run this day yourself: set two gas plants, hour by hour, so that supply equals demand.
Demand, wind and solar follow the real hourly shapes of 3 September 2025 on the Southwest Power Pool grid (EIA-930), scaled to the town. Prairie Town, its plants, prices and CO₂ rates are illustrative; CO₂ counts fuel burned at the plants only.
What you just did, as diagrams
- Balance
- Supply must equal demand at every moment. Prairie Town has no storage; real grids also use some, such as batteries (lesson 9).
- Frequency
- The alternating voltage completes 60 cycles each second, and generators turn in step with it; too little power slows them.
- Variable and dispatchable plants
- Wind and sun follow the weather; gas plants follow the operator's orders.
- Ramp limit
- The combined-cycle plant can change its output by only 40 MW from one hour to the next.
- Merit order
- Run the cheapest plant first and the most expensive last.
- Decisions, goal, rules
- What the operator chooses, what they keep low, and what they cannot break.
Go deeper · AnalystThe balance, energy and cost as equations
For every hour \(t\), with \(p_g(t)\) the output of plant \(g\) in MW, \(u(t)\) the unserved demand, \(s(t)\) the spilled power and \(d(t)\) the demand:
\[\sum_g p_g(t) + u(t) - s(t) = d(t).\]
Energy, cost and CO₂ are sums over the hours, with \(\Delta t = 1\) hour, a running cost \(c_g\) in $/MWh and an operating emission rate \(e_g\) in t/MWh (t = metric tonnes):
\[E_g = \sum_t p_g(t)\,\Delta t, \qquad C = \sum_t \sum_g c_g\,p_g(t)\,\Delta t, \qquad \mathrm{CO_2} = \sum_t \sum_g e_g\,p_g(t)\,\Delta t.\]
Check it on the cheapest-first rule’s day:
- Energy: 2,400 MWh of nuclear, 1,960 MWh from the combined-cycle plant, 20 MWh from the peaker.
- Cost: \(C = 2400 \times 10 + 1960 \times 40 + 20 \times 100 = \$104{,}400\).
- CO₂: \(1960 \times 0.37 + 20 \times 0.55 = 736.2\) t, from the gas plants’ fuel only.
Go deeper · ModelerPreview: the operator's day as an optimization problem
- Decisions
- Each gas plant's output, every hour: 48 numbers.
- Goal
- The lowest gas running cost for the day. The flat nuclear output costs the same in every plan, so the goal leaves it out.
- Rules
- Supply equals demand each hour; each plant stays within its size; the combined-cycle changes by at most 40 MW an hour, starting from 115 MW at midnight.
\[\min \; \sum_{t} \big( 40\,p_\mathrm{cc}(t) + 100\,p_\mathrm{pk}(t) \big)\]
| Cheapest-first rule | Plan all 24 hours together | |
|---|---|---|
| How it decides | one hour at a time | the whole day at once |
| Running cost | $104,400 | $104,000 |
| Peaker energy | 20 MWh | 0 MWh |
Planning saves $400, about 0.4%, by warming the combined-cycle plant up before the solar dip and the sunset.
Every rule and the goal add up outputs times fixed numbers, so this is a linear program. Lesson 10 writes it down step by step; lesson 11 hands it to a solver.
Go deeperWhat the game leaves out
- Prairie Town is an island: it cannot buy power from its neighbours.
- The forecast is perfect; real operators plan with forecasts that miss (lesson 4).
- The game moves in one-hour steps; real grids balance second by second (lesson 3).
- Nothing breaks: plants never fail, and power lines never fill up.
- The frequency dial is an illustrative indicator: 0.01 Hz per MW out of balance, capped at 0.5 Hz either way. Real frequency depends on spinning machines and controls (lesson 3).
- CO₂ counts only fuel burned at the plants. Building plants and supplying fuel, including methane leaks, are left out.
Check yourself
Myth or fact? “A gas plant can save the electricity it makes and send it out later.”
- Myth
- Fact
Answer
Myth. A gas plant makes electricity as it is used. Saving it for later takes storage, such as a battery or a pumped-storage hydro plant (lesson 9).
Myth or fact? “If supply is greater than demand, the grid's frequency rises.”
- Myth
- Fact
Answer
Fact. Extra power speeds up the spinning generators, so the frequency climbs above 60 Hz.
Myth or fact? “A wind farm can be told to make more power when demand rises.”
- Myth
- Fact
Answer
Myth. A wind farm can be turned down, but not up beyond what the wind allows: that is what variable means.
At 21:00 demand is 303 MW. Nuclear makes 100 MW, wind 98 MW, and the sun is down. How much must gas make?
- 303 MW
- 203 MW
- 105 MW
- 205 MW
Answer
105 MW: 303 − 100 − 98 = 105. Gas fills only the gap the other plants leave.
The peaker runs at 50 MW for 3 hours. How much energy does it make?
- 50 MWh
- 150 MWh
- 150 MW
- 53 MWh
Answer
150 MWh: energy = power × time = 50 MW × 3 h. MW is a rate; an amount of energy is in MWh.
Numbers, sources and what’s next
Numbers to remember
| Number | What it means | Source |
|---|---|---|
| 60 Hz | The frequency North American grids are designed to hold. | EIA, Today in Energy · design standard; checked 2 Nov 2026 |
| 63 | Balancing authorities in the contiguous U.S., each keeping supply equal to demand in its area. | EIA notice on Form EIA-930 (PDF) · as of March 2026 |
| 759 GW | Record peak demand of the Lower 48 states, set on 29 July 2025 (preliminary). | EIA, Today in Energy · as of August 2025 |
| 4.20 trillion kWh | U.S. electricity use in 2025, the highest on record. | EIA, Energy Explained · data for 2025 |
| 10,791 kWh | Electricity bought by an average U.S. home in a year, about 899 kWh a month. | EIA, Frequently Asked Questions · data for 2022 |
Next on the starter path
In the real world
CO₂ per MWh. Each hour's CO₂ per MWh depends on the mix. Under the cheapest-first rule, gas output peaks at 19:00, but CO₂ per MWh peaks at 00:00: gas is a bigger share of a smaller demand.
Real data. U.S. grids report hourly demand and generation by fuel in EIA's Hourly Electric Grid Monitor.
Open code. My open framework for carbon-aware electricity use builds on those data.
Case file CF6 (average and marginal emission factors, and when moving electricity use to cleaner hours lowers CO₂).
Sources and further reading
- EIA (2011). Electric systems respond quickly to the sudden loss of supply or demand. Today in Energy.
- NERC (2021). Balancing and Frequency Control Reference Document (PDF).
- U.S. DOE (July 2015). United States Electricity Industry Primer (PDF), p. 12: generation at 5–34.5 kV, transmission at 69–765 kV, distribution at 15–34.5 kV.
- U.S. DOE (January 2017). Quadrennial Energy Review, second installment, Appendix A: Electricity System Overview (PDF), p. A-6: homes receive two 120 V connections, combined to 240 V for large appliances.
- EIA. Hourly Electric Grid Monitor (Form EIA-930): the Southwest Power Pool data behind Prairie Town's day.
Spotted an error, or stuck? Write to hlli@ksu.edu. Corrections are made in place and dated here.
Text licensed CC BY 4.0, code MIT: teachers and students may reuse and adapt it, with credit to Honglin Li.