Technical memorandumSpecial edition
- File
- TM-26-1111
- From
- Charlie O'Donoghue
- Date
- Reading
- 7 min
- Subject
- Energy · Systems thinking · Maths
The maths under flexibility Part 1 of 3
The bath has an equation
The grid's bath, written as maths. The swing equation, why less spinning metal makes frequency fall faster, and what makes a grid settle rather than run away.
AI-forward: Claude drafted this from my notes and checked every source against its claim. The argument, the cuts and the edit are mine.
In Flexibility is the grid’s fastest loop I drew Britain’s grid as a bath. Generation is the tap, demand the plughole, the water is energy spinning in big machines, and frequency is the waterline. This series writes the same bath as maths. This part is the equation, and what makes it settle. The next is how millions of small devices can share one job. The last is what happens when a grid stops changing smoothly and jumps.
Every stock is an equation
A stock-and-flow diagram looks like plumbing. Underneath, it is calculus. Forrester called stocks levels and flows rates, and every system dynamics tool works out a level the same way: start with what was there, then add up inflow minus outflow over time.Note 1: Jim Hines, MIT Sloan School of Management (2004), Molecules of Structure, version 2.0, “Bathtub”: a level is the integral of its inflow minus its outflow, the form level equations take in every system dynamics language. For Forrester’s own terms, Jay W. Forrester (2009), Some Basic Concepts in System Dynamics, D-4894: “Many structures of levels and rates are found repeatedly.” Written as a rate of change, that is one line:
The left side asks how fast the stock is changing. The right side answers: by the gap between tap and plughole. A mathematician would call the stock a state variable and the line a differential equation. A simulation steps it forward in thin slices of time, which is all a model of a bath ever does. The bath figure in the flexibility essay ended on this line for the grid.
The grid’s version
The grid’s stock is the kinetic energy in the spinning rotors of every generator turning in step with the grid. NESO, the system operator, calls it inertia.Note 2: NESO, What is inertia? Engineers size it with two numbers per machine: its rating, S, and its inertia constant, H, the seconds its stored spin could run it at full output. Multiply them, add them up across Britain, and you have the grid’s stored spin, quoted in gigavolt-ampere seconds (GVA.s).
Rotor speed and frequency move together, so the bath equation for that stock becomes an equation for frequency. Power engineers call it the swing equation. Treat the whole grid as one big machine and it reads:Note 3: Callum MacIver, Keith Bell and Marcel Nedd (2021), An analysis of the August 9th 2019 GB transmission system frequency incident, Electric Power Systems Research 199, equation (1), adapted from Prabha Kundur, Power System Stability and Control (McGraw-Hill, 1994). The 1,000 MW at 200 GVA.s example is theirs, as is the point that demand varies with frequency.
It says three things. The imbalance sets the direction and size of the change: tap minus plughole. Nominal frequency, 50 Hz, scales it. And the stored spin divides it: the more energy is spinning, the more gently frequency moves for the same gap. Lose 1,000 MW with 200 GVA.s spinning and frequency starts to fall at 0.125 Hz every second. That slope has a name: RoCoF, the rate of change of frequency.
Less spin, steeper slopes
Wind and solar farms don’t synchronise with the grid in a way that adds inertia, and nor do the cables that import power from abroad.Note 4: National Grid (March 2014), Frequency changes during large disturbances and their impact on the total system, the GC0079 consultation: the 0.125 Hz/s setting, the cascade it risked, what it cost to avoid, and the recommended 1 Hz/s with a 500 ms delay. As they replace coal and gas, the HS under the fraction shrinks, and the same fault makes a steeper slope.
Steep slopes had a specific danger. Many small generators on local networks were set to disconnect if frequency changed faster than 0.125 Hz per second, their way of spotting that they had been cut off from the grid. In a big enough fault the whole grid changes that fast. They would trip together, the gap would grow, and frequency would fall further. National Grid paid to keep extra spinning plant running, or cut the size of the biggest possible loss, to stay under that line.
So the settings changed. In 2014 the industry recommended 1 Hz per second with a half-second delay, at first only for sites of 5 MW and above. Between October 2019 and August 2022 the Accelerated Loss of Mains Change Programme paid owners to reset their protection and remove a twitchier method called vector shift.Note 5: Electricity North West, Updating your loss of mains protection; National Grid ESO, ALoMCP window one report.
The floor on stored spin has been coming down since. Ofgem approved a cut from 140 to 120 GVA.s in 2023 and, in May 2026, a further cut in stages to 102 GVA.s.Note 6: Ofgem (28 May 2026), Frequency Risk and Control Report 2025: Authority decision. NESO plans to step down through 110 GVA.s first. At 102 GVA.s the same 1,000 MW loss starts frequency falling at about 0.25 Hz per second: twice the old setting, a quarter of the new one.
Bowls and hills
An equilibrium is a state in which nothing changes: tap equals plughole, so the slope is zero. Whether it is a useful one depends on what happens when something nudges it.
Read the swing equation again and it is the flat table. Nothing in it pulls frequency back to 50 Hz. Inertia makes the ball heavy, so it moves slowly, but a heavy ball on a flat table still doesn’t come home. The old relays were the hill: a fall that tripped generators that deepened the fall.
The bowl comes from whatever pushes back harder the further frequency moves. The first is built into big generators. Their governors have a droop of 3 to 5%: the further frequency falls, the more power they make, and Mandatory Frequency Response asks for the first of it within ten seconds.Note 7: NESO, Mandatory response services: a 3 to 5% governor droop; primary response within 10 seconds. It is a balancing loop inside every governor. The second is demand, some of which naturally eases off as frequency falls.
Put together, frequency after a fault does something recognisable. It falls at the slope inertia sets until the responses catch up. The lowest point is the nadir. Then it recovers part of the way and holds while the control room restores the rest. The usual statutory floor is 49.5 Hz. At 48.8 Hz, automatic load shedding starts disconnecting blocks of demand.Note 8: Keith Bell, University of Strathclyde (January 2026), Review of NESO’s frequency containment provisions and the Frequency Risk and Control Report 2025, for Ofgem: the 49.5 Hz and 48.8 Hz limits, inertial against battery response, and correlated risks.
Where flexibility comes in
Inertia only slows the fall. How deep it goes depends on how fast something pushes back, and that is the fast loop from the flexibility essay. Dynamic Containment pays batteries to answer frequency on their own, within a second.Note 9: NESO, Frequency response services: Dynamic Containment responds within 1 second. Keith Bell’s review of NESO’s frequency policy for Ofgem says it plainly: “any store of energy will do, provided it can be accessed quickly enough”.
It is not a like-for-like swap. A spinning machine gives up energy the instant it slows, with nothing to measure. A battery has to measure frequency first, then act, and once it is empty it has nothing left to give.
Try it. Less inertia makes the first slope steeper. More fast response makes the nadir shallower.
Try it Illustrative, not a grid model
First slope 0.21 Hz/sLowest point 49.56 Hz at 5.0 s where you started
Proving it settles
In 1892 Aleksandr Lyapunov defended a doctoral thesis, The general problem of the stability of motion.Note 10: MacTutor History of Mathematics, Aleksandr Mikhailovich Lyapunov: defended at Moscow University on 12 October 1892 (modern calendar). For the method, Wikipedia’s Lyapunov function is a fair start. Its best-known idea proves a system is stable without solving its equations. Find a quantity like the height of the ball in the bowl: zero at the bottom, positive everywhere else, and always falling while the ball moves. If one exists, the ball must end up at the bottom. It is the idea I borrowed for agent loops in Termites solved agent orchestration in 1959: a loop that settles needs something that only moves one way.
One equation, millions of devices
The swing equation treats Britain as one machine, with one H and one imbalance. That is why it is useful, and also what it hides. The fast response in it is no longer one big plant. It is thousands of batteries, and soon millions of EVs, heat pumps and home batteries, each with its own owner, rules and charge. Bell’s review lists a newer risk among the failures that arrive together: lots of smart demand switching at once on the same price signal.
For the equation, they have to add up to one smooth, well-behaved term. Getting millions of small devices to do that, without each knowing about the others, is a different kind of maths. Part 2 is about Petri nets, a way of drawing who may act, and when.
Notes
-
Jim Hines, MIT Sloan School of Management (2004), Molecules of Structure, version 2.0, “Bathtub”: a level is the integral of its inflow minus its outflow, the form level equations take in every system dynamics language. For Forrester’s own terms, Jay W. Forrester (2009), Some Basic Concepts in System Dynamics, D-4894: “Many structures of levels and rates are found repeatedly.”
-
NESO, What is inertia?
-
Callum MacIver, Keith Bell and Marcel Nedd (2021), An analysis of the August 9th 2019 GB transmission system frequency incident, Electric Power Systems Research 199, equation (1), adapted from Prabha Kundur, Power System Stability and Control (McGraw-Hill, 1994). The 1,000 MW at 200 GVA.s example is theirs, as is the point that demand varies with frequency.
-
National Grid (March 2014), Frequency changes during large disturbances and their impact on the total system, the GC0079 consultation: the 0.125 Hz/s setting, the cascade it risked, what it cost to avoid, and the recommended 1 Hz/s with a 500 ms delay.
-
Electricity North West, Updating your loss of mains protection; National Grid ESO, ALoMCP window one report.
-
Ofgem (28 May 2026), Frequency Risk and Control Report 2025: Authority decision. NESO plans to step down through 110 GVA.s first.
-
NESO, Mandatory response services: a 3 to 5% governor droop; primary response within 10 seconds.
-
Keith Bell, University of Strathclyde (January 2026), Review of NESO’s frequency containment provisions and the Frequency Risk and Control Report 2025, for Ofgem: the 49.5 Hz and 48.8 Hz limits, inertial against battery response, and correlated risks.
-
NESO, Frequency response services: Dynamic Containment responds within 1 second.
-
MacTutor History of Mathematics, Aleksandr Mikhailovich Lyapunov: defended at Moscow University on 12 October 1892 (modern calendar). For the method, Wikipedia’s Lyapunov function is a fair start.