Pages

Tuesday, April 14, 2015

Matlab Day 2: 4/10/15

Thermal Systems 

Today, we went through simulations of a simple thermal system on Matlab. Using a guide created by Robert Bert and revised by Amy, we went through the packet to simulate the cooling and heating processes.

Temperature Change, Cooling Process

dT = dE/C = -((T-Tair)/Rth)/C*dt = (T-Tair)/(RthC)*dt

dT = temperature change during time dt
dE = energy change of the system during a short time dt
C = specific heat capacity (1000)
T = final temperature at end of dt
Tair =  ambient temperature (initial temperature at beginning of dt, 293K)
dt = time step/change in time
Rth = thermal resistance (.85)

For the modeling purposes, we have already established values for some of the variables.




1) How does the cooling behavior change if we vary the parameters Rth and C? 
As Rth, the thermal resistance, increases, the change in temperature would decrease in smaller increments at a time, dt, therefore causing the cooling behavior to take longer to cool down. As Rth decreases, the change in temperature would increase in larger increments at a time, dt, therefore causing the cooling behavior to cool down much faster. This is the same for C, the specific heat capacity, where the larger the C, the longer it takes for the cooling behavior to cool down, and the smaller the C, the faster it takes for the cooling behavior to cool down.

To check and confirm our results, we modified the above code to see how it would affect the graph. As we saw, the higher the C or Rth, the longer the system took to cool down. 


Temperature Change, Heating Process, Adding Thermal Energy to the System at a Constant Rate P






dT = dE/C = (P/C - (T-Tair)/(Rth*C))*dt

2) Calculate a good value for P if we want our coffee to heat up to the Starbucks ideal 84 degrees Celsius (357K).

Note: will to set dT = 0 because we do not any temperature change during a time dt...we want our Starbucks coffee to keep the same ideal temperature!

Following the formula from above:

0 = (P/C - (T-Tair)/(Rth*C))dt
0 = P/1000 - (357 - 293)/(.85*1000)
P/1000 = 64/850
P = 75.3

To check and confirm our results, Amy supplied us with a pre-made code.

Feedback & Control Portion

We have moved on to the feedback and control proportion! The program asked us to modify programs that uses

1) Bang-Bang Control to reach and maintain the desired temperature 
As the key feature to bang-bang control, the temperature controller is on when it hasn't reached its ideal temperature yet, and shuts off when it has reached the ideal temperature. On the graph, this behavior of bang-bang control is what produces the continuous wave-like feature on the graph.



Bang-bang control would be appropriate for many thermal systems because it hovers around the ideal temperature, being a little over or a little under but never reaching an extreme of either. It would be efficient in quickly turning off and on thermal systems, which is needed in most homes when trying to save energy or to heat a room quickly. This type of control would not be sufficient when used in greenhouses or places that require a more gradual rise in temperature and for the temperature to be precise and accurate so that, in the case of a greenhouse, plants will not die. 

2) Proportional Control to reach and maintain the desired temperature
As a key feature to proportional control, decreasing values of heat are added to the system as it nears the ideal temperature. P, the power, is set equal to gain*error, in order to achieve proportional control. We tweaked with the gain constant in order for the graph to be as close to 357 as possible. Each addition of heat acts as a part of a limit, shrinking in increments and nearing the ideal temperature, but never allowing the system to reach its ideal temperature.



For the purposes of comparing the proportional-control coffee simulation and the proportional-control coffee simulation with delay, I've set the values of the variables in the code and graph underneath to be the same as the ones I've set for the proportional-control coffee simulation with delay.



Proportional control would be appropriate in places like greenhouses that require a more graduate rise in temperature as well as precision and accuracy as the temperature remains constant. Although the exact ideal temperature may never be reached, the constant temperature is close enough to the ideal that frail ecosystems that require specific temperatures may not be disrupted. Compared to bang-bang control, proportional control is gradual and will not oscillate back and forth as it draws near to the ideal temperature.

Before we got started on the third task, Amy provided us with samples codes to understand how we will be implementing the delay.





3) Modify our bang-bang control heat simulation to include a delay 


In the case of this bang-bang controlled temperature controller, the sensor delay caused the temperature sensor recordings to believe the current temperature still has not approached the ideal temperature yet, which caused the overshoot upwards in the diagram. And even when the recordings finally notice that the temperature has gone down, the sensor delay, again, continues to put the recordings behind. Although the current temperature may have already been too low and needed the controller to be on again, the controller does not turn on until the recording, after a long delay, notices, which finishes one of the spikes. This trend continues forever, where the sensor delay causes the recordings to read the temperature a few moments back, and so it doesn't turn the controller off or on immediately when it is that given temperature to do so.

4) Modify our proportional control heat simulation to include a delay


In the case of this proportional controlled temperature controller with delay, the graph is very similar to the graph of the proportional controlled temperature controller without delay. The difference is the lower left corner where the delay is noticeable and P is set to 0 for its initial readings. We do not see much of a difference, besides the minimal shifts in the limit value, because proportional control, despite reading values from 5 units of dt before, will still go along a gradual curve and never reach 357 degrees Kelvin, our target temperature.

I might expect to see a delay in the response from the surroundings affecting the coffee temperature (if there is a change of surroundings) or a delay in the cooling down after the temperature is turned off in my thermodynamic system.

Edit: Realized a comment mistake in many of my screenshots. In the comment that covers the line
T = T+dT; % add dt to T to obtain new T for every increase in,
this is not the case because it is dT (change in temperature) that is being added to T to obtain a new T. 

2 comments:

  1. I'm impressed that you went back to check and confirm your code. And I like your combination of graphs and code in your post.

    ReplyDelete
  2. You did a great job of thoroughly explaining each task and I liked how you divided them into different sections, which made it easier to follow.

    ReplyDelete