A453 of 56
0 XP
  1. Hook
  2. Predict
  3. Name it
  4. Check
  5. Explain

A4 · Lesson 53 · Mini-project

What an hour of grid frequency says about the power system

The frequency of the power grid isn't exactly 50 or 60 Hz. It wanders by a few hundredths of a hertz all day, because generation and demand never match exactly, and when a large power station trips offline it drops sharply and then recovers. Grid operators watch this number second by second. In this project you'll analyze an hour of it, using everything from this course.

Predict

A large generator trips offline and the frequency drops. Why does it drop, rather than rise?

Name it

The data, and the plan

The log for this project is simulated, built to behave like a 50 Hz grid: a slow random wander with a spread of about 0.04 Hz, sampled once a second for an hour, and one event, a generator trip half an hour in. Real logs look much like it, and you'd load one with np.loadtxt exactly as in lesson 45. Each lab starts with the same few lines that build the log; don't change them.

import numpy as np
rng = np.random.default_rng(2024)
t = np.arange(3600)                     # seconds
dev = np.zeros(3600)
for k in range(1, 3600):                # a slow random wander
    dev[k] = 0.995 * dev[k - 1] + rng.normal(0, 0.004)
s = np.clip(t - 1800, 0, None)          # time since the trip
event = -0.25 * (1 - np.exp(-s / 3)) * np.exp(-s / 120)
f = 50 + dev + event                    # the frequency, in Hz

The tools you'll use:

  • Statistics: f.mean(), f.std(), f.min() and np.argmin(f) for when the minimum happened.
  • Thresholds: a comparison like f < 49.8 gives True or False at every second; np.mean of it is the fraction of time it's true, and np.argmax of it is the first second it's true.
  • Plots: two stacked panels, the full hour and a zoom on the event.

Grid operators work with bands. Here, take the normal operating band as 50 ± 0.2 Hz.

Check

Set f_mean to the hour's average frequency, f_std to its standard deviation, f_min to its lowest value and t_min to the time in seconds when that lowest value happened.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Set out_frac to the fraction of the hour that the frequency spends outside the band 50 ± 0.2 Hz, and t_first to the first second at which it drops below 49.8 Hz.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Plot the log in two stacked panels: the full hour on top, and the ten minutes from 1750 s to 2350 s below. Draw the band limits, 49.8 and 50.2 Hz, as dashed lines in both. Label the axes.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Explain why

Looking at your two panels, describe what happens to the grid frequency during the event, and what it tells you about how the grid responds.

Practice

Keep practicing

3 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.