S10 · Lesson 34 · Dispatch lab
Lambda iteration with generator limits, dispatch with transmission losses and penalty factors, a congested two-bus market with its prices and congestion rent, and penalty factors from a full B matrix
Lessons 27 to 29 dispatched generators by equal incremental cost, charged remote plants for their losses, and priced electricity bus by bus. Market operators run these calculations every five minutes over thousands of units. In this lab you'll write the core of them: a lambda iteration that respects unit limits, the coordination equation with losses, a congested two-bus market, and penalty factors from a loss-coefficient matrix.
- The curve is total generation from three units against the system's incremental cost λ, each unit running at between its limits (lesson 27's units, with the first capped at 300 MW).
- Where a unit hits its limit the curve's slope drops: λ rises faster for the same added load.
- Lambda iteration searches this monotone curve for the λ that meets the demand.
Predict
Three units share 900 MW at λ = 11.35 dollars per MWh. If the first unit is limited to 300 MW instead of the 334.8 it would produce, what happens to λ?
With the first unit pinned at 300 MW, the other two share 600 MW: gives λ = 11.53 dollars per MWh. A limit takes a unit out of the balancing, so the remaining ones must climb their cost curves further.
Name it
What the lab computes
- Lambda iteration: for a trial λ, each unit runs at clamped to ; bisect on λ until the outputs sum to the demand.
- Losses: with a remote unit whose losses are , the coordination equation gives , and the balance is .
- Two-bus market: a cheap unit at A and a dear one at B serve load at B through a line of limited capacity. If the line binds, B's price is set by the dear unit, A's by the cheap one, and the congestion rent is the flow times the price difference.
- Penalty factors from : and .
Check
Write dispatch(units, D): units are (b, c, Pmin, Pmax) with incremental cost b + 2cP dollars per MWh; return (λ, list of outputs) meeting demand D, by bisecting λ between 0 and 1000.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write dispatch_losses(b1, c1, b2, c2, B, D): unit 1 local, unit 2 remote with losses ; return (λ, P1, P2, losses).
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write two_bus_market(cA, cB, D, limit): a constant-cost unit at A (cA dollars per MWh) and one at B (cB > cA) serve D MW at B through a line limited to limit MW; return (flow, price at A, price at B, congestion rent per hour).
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write penalty_factors(Bm, P): for a loss matrix Bm (list of lists, per MW) and outputs P, return the list of penalty factors .
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why does a congested line create two different prices at its ends, and who collects the difference?
When a line can't carry more, the next megawatt of load on the receiving side must come from a local generator that costs more, so the cost of serving one more megawatt there, the locational price, rises to that generator's cost. On the sending side, more load can still be met by the cheap generators, so the price stays low. Loads on the receiving side pay the high price for all their energy, while the cheap generators are paid the low price for what they send over the line, and the difference on that flow is the congestion rent, collected by the system operator and usually returned through financial transmission rights.