On Friday April 1st, we used MATLAB to model the heating and cooling of a cup of coffee under different conditions. We took the following expression that gives the temperature of a system exposed to air as time passes.
where dT = a small change in temperature
C = heat capacity
T = Current temperature
Tair = Temperature of the surrounding air
Rth = Thermal resistance
dt = a small change in time
Question 1:
How does the cooling behavior change if we vary the parameters and C? Figure this out using intuition and the above equations, and then vary these parameters in your program to confirm your conclusions.
Rearranging the above equation, T = Tair - (dT/dt) *(RthC). T is proportional to Rth and C. Therefore, increasing Rth would increase T as would increasing C. But we can also see from this same equation that dT/dt is inversely proportional to Rth and C. So with larger Rth or larger C values the change gets steeper. And smaller Rth and C values give a curve with smaller slopes at different parts.
To test this, we modified the following code as noted in the comments and got the following results:
|
C = 100; Rth = 0.85 |
|
C = 10000; Rth= 0.85
Here, the temperature has shifted upwards (as expected, since C*Rth increased). But the slope over each small time interval has significantly decreased. |
|
C = 1000; Rth = 0.085
Here, you can see that the graph resembles the C = 100; Rth = 0.85 graph. This shows that it is really the product of C and Rth that affects the slope. |
We intentionally chose values of Rth and C dramatically different from the original values to see the change clearly.
Question 2: Calculate a good value for P if we want our coffee to heat up to the Starbucks ideal 84°C, using the Rth from the MATLAB script?
This time, we considered a system where the coffee is sitting on a heating plate that provides a power of P. We used the following expression to find the value of P that would heat up the coffee to 84°C.
P = (dT/dt)C + (T-Tair)/Rth; where Rth = 0.85
But at t = 0, dT/dt = 0. So P = (T-Tair)/Rth = (84 - 20)/0.85
P = 75 J/s
From the following graph deduce the thermal parameters C and Rth:
From the relation, P = (change in T) / Rth, we can rearrange to get Rth = (change in T) / P, which in this case is about (350 - 290) K / 75 Watt = 0.8 K/Watt.
From dT/dt = P/C at t = 0, we can rearrange to get C = P/(dT/dt)
If you focus on the first part of the curve near t = 0, it resembles a line with a slope of 20/250 = 1/12.5
Therefore C = 75 W * 12.5 s/K = 937 J/K ~ 1000 J/K, which is the given value. My values are a little off because we can only make estimates from the graph.
Question 3: Simulate a temperature controller that uses bang-bang control to reach and maintain the desired temperature. Bang-bang control is a very common approach for thermostats.
We used the following script:
And we got the following graph:
After T = 357 the curve starts oscillating very subtly. This is because the power turns off when the temperature exceeds 357 K and turns on when it drops below this desired value. Since it always overshoots the goal a little bit, some oscillation is expected but since the temperature stays very close to 357 K, the coffee will still be very close to the desired temperature, and certainly not much hotter or colder.
Why is bang-bang control appropriate for many thermal systems? When might it be insufficient?
Thermal systems like this one can be adjusted to a good enough precision to maintain a certain temperature. The small fluctuations in temperature as the system continuously adjusts its output keep systems like thermostats at reasonably close temperatures to the desired value. This might be insufficient if a very precise constant temperature is desired or if one needs a continuous and shift in temperature as a reaction to a drop or increase in the measured.
Question 4: Create a program that uses proportional control to reach and maintain the desired temperature. How does this approach compare to bang-bang control?
We used the following script:
And we obtained this graph:
This graph appears a lot smoother and the value of the final temperature constantly approaches 357 instead of oscillating between values slightly above and below this point (unlike bang-bang control). This is because the power supplied to the coffee decreases linearly as the temperature approaches the goal. So, we prevent overshooting the goal and having to come back for it.
This gives a more steady and precise temperature. It is also easier to reach the desired temperature in a short amount of time.
Question 5) Suppose there is a delay between the time the coffee reaches a given
temperature and when the temperature sensor records that temperature. Modify
both of your programs to include this effect, along the lines of the programs on the next few pages that I showed in class, which explore the effect of adding a “sensor delay” to a simulation of moving a SciBorg lego car a particular distance.
Here are the bang-bang and proportional control codes respectively that account for the delay (chosen to be 5 seconds here).
Bang-Bang Control with delay:
Proportional control with delay:
This yielded:
|
Proportional control with a delay of 5 |
This graph shows a brief oscillation before it flattens at around 355.
What other might you expect in your thermodynamic system, apart from sensor delays?
I would expect a delay in heat transfer. Since radiation goes at the speed of light and everything else at a lower speed, there is always a time lag between heat loss or gain by the coffee.
In addition, the actuator itself would have a lag between it receives the "order" to turn on the power supply and when it actually does.