Friday, April 1, 2016

MatLab part 2: modeling thermal systems

This time we are using MatLab to simulate thermal systems like a hot coffee being either heated or cooled.
Interestingly enough, heat transfer can be viewed as an energy transfer not unlike the transfer of electrons.  That helped me remember and understand the thermal dynamics functions better, although I'm still not at the level of comfort where I can just name exactly the units without some thinking

Exercise 1:
given the code to simulate the cooling of coffee. We were than told to determine how varying the parameters Rth and C would effect cooling. Rth is the rate of heat transfer and C is the heat capacity of the thing we're studying.  From Newton's Law of Cooling function, I expect Rth and C to be inversely proportional to the rise in temperature.

Here is the code for the...
% Simulation of cooling coffee
% coffee_coolsim.m
C = 1000; % heat capacity
Tair = 293; % ambient temperature in K (C + 273 = K)
Rth = .85; % thermal resistance
T = 357; % initial coffee temperature in K (84 C)
t = 0; % starting time
tmax = 1500; % duration of simulation
dt = 10; % time step
clf
clc
hold on
axis([0 tmax Tair T])
xlabel ('time (seconds)') % axes labels
ylabel ('temperature (K)')
while t < tmax
    dE = -((T - Tair) / Rth) * dt;
    dT = dE / C;
    T = T + dT;
    t = t + dt;
    plot(t,T,'ro')
    drawnow
end

When we tested, we found decreasing the values of thermal resistance, Rth and heat capacity, C, would increase the rate at which the "coffee" wood cool down.

Rth = 0.85 C = 1000












Rth = .85 C= 500

Rth = .5 C=500























exercise 2
this exercise simulated heating up coffee from room temperature.
below is the code for the simulation.  Note that the difference between this code and the previous code is that now there is an element of power that is providing heat to the coffee system to increase the temperature of the coffee.

Here is the code for the:
% Simulation of heating coffee
% heatsim.m
C = 800; % heat capacity
Tair = 293; % ambient temperature
Rth = 0.80; % thermal resistance
T = Tair; % initial coffee temperature
t = 0; % starting time
tmax = 2000; % duration of simulation
dt = 10; % time step
P = 64/0.85; % power added by heater
clf % clear old figure
clc % clear command center
hold on
axis([0 tmax Tair (T + 100)])
xlabel ('time (seconds)') % axes labels
ylabel ('temperature (K)')
while t < tmax
dE_in = P * dt;
dE_out = ((T - Tair) / Rth) * dt;
dE= dE_in - dE_out;
dT = dE / C;
T = T + dT;
t = t + dt;
plot(t,T,'ro')
drawnow
end

C = 1000 Rth = .64 P= 64
















Excercise 2 Part b:
part b of the problem was to guess the parameters of C and Rth from looking at a plot of the data.

In order to find Rth, we looked at the equation P = ΔT / Rth. By isolating Rth, we were left with ΔT / P on the other side. Plugging in the values for ΔT (357-293) and Rth (75), we calculated a Rth of .84.

In order to find C, we looked at the special circumstance of t = 0. When t = 0, for a short duration of dt, we have the equation dT/dt = P/C because we can assume the difference between the temperature of the cup and the temperature of the surroundings is negligible/really close to zero. Isolating C, we get P/(dt/dT). dt/dT is also known as the slope of the equation and can be determined by eyeballing the slope at t=0. The slope, therefore, will vary person by person. I personally think it looks like it is approximately, 20 / 250. This then gives me a value of approximately 950 for C.

exercise 3:


%%

exercise 4:



%%


exercise 5:


No comments:

Post a Comment