Monday, April 4, 2016

MATLAB: It's gettin' hot in here~ (thermal systems part 1)


Partner: Katrina Montales

Thermal Systems:
(link to the background on thermal systems above)

**NOTE: all temperatures are in Kelvin**


Question 1: The Cooling Behavior



Consider the equation for dT:


If we increase Rth or C, then we expect the change in temperature to decrease (less steep of a slope)
Red is the given Rth, Blue is the program run with lower Rth


If we decrease Rth or C, then we expect the change in temperature to increase (more steep of a slope)




Question 2: Add a Heater
Suppose the coffee starts out at room temperature and we turn on a heating element that adds thermal energy to the system at a constant rate P.
Consider the following altered equation for dT:


Calculate a good value for P if we want our coffee to heat up to the Starbucks idea 84C, using the Rth from the MATLAB script:
dT = 0 = P  _ T - Tair
dt           C      Rth*C

T - Tair = P
   Rth

P = 64/0.85 = 75





Can we find C and Rth by working backwards?

Rth: At equilibrium, the heat from the heater is equal the the heat leaving the coffee into the room
So, P = Teq-Tair
                 Rth
Rth = deltaT(final) =  63K  = 0.84 K/W
                 P               75W

C: When t = 0, for a very short dt, there is only energy going into the system:
So, dT = dE = Pdt
                C       C
               dT = P
               dt     C
C =        P          =    75W    = 1000J/K
       initial slope    0.075K/s


Question 3: Bang Bang Coffee Heater Temperature Control
Bang bang control is appropriate for many thermal systems because they require a lot of energy and so, in some cases, it may be better to have the heater on high for a short period of time and then turn it off. However, this can be inefficient, as we see in the graph, when trying to maintain the coffee's temperature. (Even though it was efficient when we were heating up the coffee)

Question 5a: note about the code - modified to include a delay of 2 seconds to reflect a real world sensor delay. (the delay was modeled by the expression mod(t, delay) == 0, meaning every 2 seconds enter the loop and check the temperature)









w/ sensor delay:


(they look pretty similar, eh? That is because bang-bang control isn't changed much with a delay, see a larger change in proportional control)

*the red is the temperature of the coffee when the heater is on, the blue is when the heater is off*

Question 4: Proportional Control Coffee Heating
How does the proportional control approach compare to bang-bang control? This was different because the coffee was heated in a much more precise way -- meaning we were not heating the coffee at full power if it was near the ideal temperature (that would be wasteful!). With the delay, we were able to model and visualize when the heat sensor was actually measuring the temperature and adjusting the power.

The delay was modeled by the expression mod(t, delay) == 0 meaning the sensor would sense the coffee's temperature after every delay amount of time.





Proportional Control w/o delay:


(temperature after 1500 seconds on the heater)

Proportional w/ delay of 35s:


(temperature after 1500 seconds on the heater)

Proportional w/ delay of 45s:


(temperature after 1500 seconds on the heater)
Interestingly enough, the delay separated the times the heater was able to readjust the power output, allowing it to get closer to the ideal temperature (rather than inching at an increment too little to make a difference (remember nudge?)).

In the real world, one might expect there to be a sensor delays, computational delays (computer doing calculations, though that is super fast!), heater delay (warming up/cooling down), etc. Delays all over the place! (psst: this is why we use MATLAB to model the ideal situation)

Skills:

  • MATLAB plotting
  • while/if/for loops
  • delays in matlab
  • bang bang control
  • proportional control





3 comments:

  1. I like how you put the different lines on the same graph when comparing different values of C and Rth! And love the GIFs :D

    ReplyDelete
  2. For the first part, I think plotting multiple equations with various Rth (or C) values on the same graph was a really smart way to display the difference in curves.

    ReplyDelete
  3. I also like the way you plot everything is the same graph, making it easy to compare and contrast. It is also interesting to see how different delay times effect the proportional control.

    ReplyDelete