← Lesson diary · Process Identification and Control

Building Energy Lab

Process Identification and Control · Lessons 11–13

Building Energy Lab

A house with photovoltaic panels, a battery and a handful of appliances, on a time-of-use tariff. You decide which appliances have to run today and inside which hours they are allowed to run; the controller decides when to start each of them and what to do with the battery, so that the electricity bill of the day is as small as possible. This is the economic MPC problem of the lesson, written exactly as on the blackboard and solved in your browser.

The house today

 

Appliances to run (plannable loads)

LoadNot beforeDone by

Plant and contract

Tariff and day

Flexibility service

Day

Power at the meterkW · positive = bought, negative = sold
with economic MPC rule-based battery without control contract limit service window F1F2F3
Generation and consumptionkW
photovoltaic total load with MPC total load without control
Battery: energy stored and powerkWh · kW
energy stored xk battery power (+ charging)
When each appliance runshour of the day
allowed window chosen by MPC without control

The day, in numbers

StrategyBill of the dayBattery at midnightNet costBoughtSoldSelf-consumedPeak

 

What to notice

  • The controller buys time, not energy. The appliances consume the same kWh wherever they are placed: what changes is the price of the hour they land in, and whether the sun is paying for them. Widen the window of a load and watch it slide under the photovoltaic bell.
  • Self-consumption beats selling. As long as a kWh costs more to buy than it is paid when sold, the optimal plan prefers to use the generation on the spot or to store it. Push the selling price up towards the purchase price — the slider stops just below it, because being paid more than you pay would make buying and selling at once a way of printing money — and the reason to store melts away.
  • Efficiency and wear are what limit the battery. With a round-trip efficiency below one, every cycle loses energy, and the wear term charges every kWh that goes through. Put both at their best values and the battery cycles as much as the tariff allows; make wear expensive and it only does the trades that really pay.
  • Take away the terminal term and the battery empties. The energy left at midnight is worth nothing to a controller that only looks at today, so it sells it before the day ends. This is the terminal cost Vf of the theory, seen from the application side: it prices what happens after the horizon.
  • Flexibility is a product the house can sell. Ask it to stay under a cap for three evening hours, or to follow a curve at midday, and watch where the service is paid for: the battery and the appliances are moved to deliver it, and the bill of the day gets worse while the net cost gets better. The uncontrolled house collects the fee and then pays the penalty, which is the whole business case for a controller.
  • A penalty is a price, not a prohibition. The service is written in the cost and not in the constraints, so the controller compares delivering with paying: make the service hard (a deeper cap, a longer window, a smaller battery) and lower the penalty, and at some point it stops delivering. Push the cap to zero over six hours and it fails whatever the penalty, simply because the house cannot run on nothing — the fee was accepted for something it could not do.
  • The contract limit can make the problem infeasible. Lower it with several appliances forced into the same narrow window and the optimizer reports that no feasible plan exists: the constraints are contradictory, not the algorithm at fault.

The problem being solved

One optimization over the 24 hours of the day, with perfect forecasts of generation and of the non-plannable load. In closed loop it is re-solved at every step on the updated state and forecast; with nothing unexpected happening, the plan you see here is what the controller would follow.

min  Σt T/3600 · (cint Pint − coutt Poutt)  +  cwear Σt T/3600 · (Pcht + Pdist)  −  cterm xN

Pint − Poutt = Pnplt + Pplt + Pesst − Ppvt
Pplt = Σℓ Σj Pℓ(t−j+1) sj,ℓ    Σj=SℓFℓ−Nℓ sj,ℓ = 1    sj,ℓ ∈ {0,1}
xt+1 = xt + ηch T/3600 Pcht − (1/ηdis) T/3600 Pdist

When a flexibility service is asked for, one more term joins the objective over the hours of the event: λ Σ T/3600 · (Pint − Pcap)+ for the cap, or λ Σ T/3600 · |Ppoct − Preft| for the curve, each written with the two non-negative variables of the exact linearization of the absolute value. The fee paid for the service is a constant and does not change the optimal plan — it changes whether accepting the service was a good idea, which is your decision, not the controller's.

Each appliance has a fixed power profile and a duration; the binary sj,ℓ says that load ℓ starts at hour j, and the equality says it starts exactly once, inside the window you choose. That makes this a mixed-integer linear program, which the page solves with a simplex and a branch and bound written for the occasion. Both were checked against the Cbc solver on a few hundred random instances of this same model, optimum against optimum.

Simplifications with respect to the lecture: no electric vehicle, no thermal part, and the indicator variables that forbid buying and selling (or charging and discharging) at the same time are left out, because with a selling price below the buying one and a round-trip efficiency below one the optimal solution never does either. The page checks it on every solution.