What is a linear system anyway?
‘Linear systems’ get their name because they exhibit a linear response to changes in input. “What’s a linear response?” I hear you ask, we can say that a system is linear if it obeys two rules:
- Scaling: Doubling the input doubles the response
- Additivity: The response to two inputs at once is just the sum of each individual one
Together those two are called superposition. It sounds simple but these properties are what allow us to tackle such systems with elegant control solutions. The goal of this post is to explain the intuition behind one, and I’ll be using a boiler to do so because it’s a classic example.
The boiler
Imagine we’re trying to control the water temperature inside a boiler. We have control over the strength of a flame that can be used to heat up the water. How can we use the flame to achieve a target water temperature?
Let’s see what can we state about the boiler:
- The water loses heat to the environment.
- The amount of heat it loses is proportional1 to how hot it is at that moment vs the ambient temperature.
- The water takes time to absorb heat from the flame.
The easy way
It follows that for any target temperature2, there’s a given flame strength that will be able to hold that target by balancing the heat loss. Why not set the flame to that strength, and wait for the water to reach temp? We can put together an equation to solve for the required strength:
Don’t be intimidated! The equation represents several simple concepts:
- mystery tau3, ignore it for now ♪
- is the flame strength at time
- is the water temperature at time
- is the ambient temperature4
- is the steady-state gain - basically this represents the ultimate amount of heat a given flame can add to the system. If , it means that for each ‘unit’ of flame we could raise the temp by .
Solving where (the steady state) gives exactly the flame strength we were after:
For example, let’s say our boiler’s cool water starts at , but we want , and for this particular boiler . Then:
So holding the flame at strength unit is what keeps the water sitting at 45°C once things settle down.
If we set the flame to and just wait, climbs towards and eventually settles there:
Mystery Tau, look at it we shall ♪
Eagle eyed readers might have noticed that I labelled time in multiples of , which I did because is the time constant. The time constant of a linear system is the fundamental time unit that dictates how quickly it responds. More specifically a time constant is the time it takes for the system to reach approximately of its climb to the steady-state value.
“Why 63.2%?” I hear you ask, it’s because a linear system’s approach to the target follows an exponential curve. As we heat up and approach the target, the heat loss also increases (because it’s proportional to how far above ambient the water is), while the amount of heat we’re adding remains fixed. All that means is our approach slows as we get closer and closer. The path it follows is exactly (with ):
In other words, the distance to the target closes at an exponentially decaying rate, so we call this an exponential approach.
Why is my shower still cold?!
Right so that’s a little slow… perhaps we could reach the target faster by starting with a stronger flame to heat the water up more quickly, and then smoothly transition to as we approach the target?
Let’s try it… below you can see that the stronger start moves more heat in early, so the resulting temperature (left axis) reaches sooner. The flame driving it (right axis) starts high and tapers back down to as we approach the target:
Here I’ve used twice the starting flame strength initially, reducing it to by the end. You can see that we’re reaching that mark in half the time.
Let’s crank this flame up to eleven!
This leads to two natural questions: “How strong should we set the initial flame?” and “Over what time period should we transition between the two?” It turns out these two questions are very intertwined.
We know that is a kind of measure of the response rate of the system, but imagine we want the boiler to respond more quickly on some shorter time constant . Assuming our boiler has , let’s push it 11 times faster: . If we bring back the first equation, we can solve for the initial state where . Remember that we’re closing a gap, and :
An eleven times shorter time constant and eleven times the flame! 5
And that’s no coincidence, remember that: . 6 It turns out we can do some rearranging to find that the starting flame strength is defined by a ratio of the two time constants:
This is super cool! It means our rule generalizes to: “Want to go times as fast? Then use times the flame, faded out with ”
So where does that leave us?
As we’ve learned, the time constant represents the exponential approach to the target temperature, and we want our strong initial flame to fade out matching that approach, so it needs an exponential decay.7 Plugging that in we can write down the entire continuous flame function that describes every flame strength from now until the water settles:
Think about what we just did. Split the flame function8 down the middle:
A steady part that holds the target forever, and an extra part that dies off once we’ve arrived (that’s scaling!). Then just… add them together (that’s superposition!).
That’s all there is to it. To solve a linear system9, we start by identifying the ideal steady state conditions, and then tune the aggressiveness () to accelerate the path there.