## Energy Balance Model of Can Experiment

### For Summer 1997 Envision-It Workshop

Our goal is to develop a Matlab model to describe the hot/cold can experiment. This type of a model is often called an energy balance model.

In an energy balance model, there can be heat flowing into or out of the system by a variety of physical processes. In the Steady State (or Equilibrium) case, these heat flows into and out of the system are equal and the temperature of the system is constant. If the heat flows are not equal (as is the case when the can is heating up or cooling down), the system will be gaining or losing energy and this will result in a temperature change.

We need to define a few terms before we can proceed with developing a mathematical model:

The Power (P) is the amount of energy flowing into/out of the system during some time period. We can write this as a mathematical equation:
(Eqn 1) P = ΔQ / Δt
where ΔQ (units of Joules or Calories) is the amount of energy flow and Δt is the time interval.

If the system absorbs a net amount of heat ΔQ the temperature of the system will change by an amount ΔT which is given by
(Eqn 2) ΔT = ΔQ / C
where C is called the heat capacity of the object. The heat capacity is the product of the m the mass of the object and c is its specific heat. For water, the specific heat is 1 cal/goC = 4186 J/kgoC

We will use the following algorithm to develop a computer simulation of a heat flow problem:

1. Set initial conditions (such as temperature) and parameters (mass, specific heat) for the system
2. Request user input for unknown parameters (such as the heat-loss coefficient)
3. Set the temperature to its first value
4. Use the current temperature to calculate the power gained (PGain) and lost (PLoss) by system
5. The net heat flow during a time interval Δt is (PGain-PLoss)*Δt, so the change in temperature is
(Eqn 3) ΔT = (PGain-PLoss)* Δt / C
6. The new temperature is the old temperature plus ΔT
7. The new temperature can be stored in an array, printed or put onto a graph of temperature vs. time.
8. If the experiment is not over (not at the last time interval), continue from step 4 above using the new temperature to calculate the power, etc.
9. If the experiment is over (at the last time interval), make plots of temperature vs. time and see how well they represent the data. If they do not, run the program again using a different estimate for the parameters in step 2.

For the can filled with hot water, it will lose heat by Convection, Conduction and Radiation. For an object near room temperature, we often group these together and approximate these in an equation called Newton's Law of Cooling:
(Eqn. 4) PLoss = k (T - TS)
where T is the temperature of the system, TS is the temperature of the surroundings, and k is the heat-loss coefficient. In other words, the larger the difference between the temperature of the object and its surroundings, the faster heat is lost from the object. The heat-loss coefficient, k, can sometimes be estimated from physical equations, but it is often found empirically by doing a measurement. This is what we are going to do.

If you have performed the experiment yourself, use an editor to make a file called `hotcans.out` which has three columns separated by spaces: Time, Temperature of Silver Can and Temperature of Black Can. If you do not have such a data set, you can use the data set (called `hotcans.out`) for the temperature vs. time for silver and black cans filled with water which start from a temperature of about 45oC. The situation for this data set is as follows:

• m = 0.1 kg of water
• TS = 21oC was the temperature of the room
• Δt = 60 seconds for the data (but we can choose a larger or smaller Δt in our computer model
The program `ploss.m` (which is listed below) will plot the data and calculate the model given by the equations above. To use this program you do the following
• Start up `matlab`
• Obtain the files `hotcans.out` and `ploss.m`. You may need to edit `hotcans.out` to remove any header lines. It should have three columns of numbers separated by spaces, the first being the time followed by the temperature of the silver and black cans respectively.
• Execute the command: `load hotcans.out;` This will create a matrix `hotcans` with 3 columns containing the experimental data.
• Execute the command: `timeActual=hotcans(:,1);` which will copy the first column of `hotcans` to the variable `timeActual`. Names in `Matlab` are case-sensitive, so make sure that you type this in exactly. Also, make sure that you put the semicolon at the end of the line, or else it will print out the entire column of several hundred times!
• If the times in your data set are in minutes, type in `timeActual=timeActual*60;` to get them into seconds - it will be easier to use seconds since the units on some of the physical constants are in seconds.
• We will start by fitting the data for the silver can. Execute the command: `TempActual=hotcans(:,2);` to copy the data for the silver can (later, to use the data for the black can, enter `TempActual=hotcans(:,3);`).
• To make sure that you have the data, execute the command `plot (timeActual,TempActual)`. It should plot a smooth curve going from the initial to final temperature (for my data set this is 45oC to 21oC over a period of about 36,000 seconds (10 hours)).
• Now use the `Open M-File` option to open the file `ploss.m` and look it over to understand how it works.
• Run the m-File either by selecting the `run M-File` menu option or by typing the file name `ploss`.
• Run the program several times until you can find a value for the heat-loss coefficient which fits the data for the silver can.
• Repeat the procedure for the black can.
As you are working on the problem, some questions you can be asking yourself: Can the model fit the data over the whole time range? (For example, the command `axis([0 3600 20 50]);` will allow you to display the first 3600 seconds of the data) Why or why doesn't it fit? In particular, what is the fit like in the first 15-20 minutes (make plots). What about the last few hours? When is there the largest deviation between the model and the data?
```%  PLOSS.M Energy Balance Model for Hot/Cold Cans
%  This program models the rate at which a hot object loses heat.
%  Tom Huber   10-JUL-97
%
%  Before running this, copy the actual Temperature vs. Time into
%    timeActual and TempActual
%
Ts = 20.7;      % Surrounding Temperature (in Centigrade)
m  = 0.1;       % Mass of Water in can (in kg)
c  = 4186;      % Specific Heat of Water (in J/(kg*DegreeC) )
C  = m*c;       % Heat Capacity (in J/DegreeC)

dt = timeActual(2) - timeActual(1);   % Use time step of actual data
tMax = max(timeActual);               % Use the last time
t = 0:dt:tMax;          % Make array of times

Temp = 0*t;                % Initialize Temperatures to 0
Temp(1) = TempActual(1);   % Use the actual 1st temperature

k = input ('Enter Heat Loss Coefficient ');

for i=2:length(Temp)
PLoss = k*(Temp(i-1) - Ts);   % Calculate the Power Loss
dTemp = -PLoss*dt/C;            % Calculate the Temperature Change
Temp(i) = Temp(i-1)+dTemp;     % Store the new temperature
end

hold off
plot(timeActual,TempActual,'b.')  % Plot the actual temperature
hold on                           % Allows graphs to be overlayed
plot(t,Temp,'y-');                % Plot the calculated Temperature
axis ([0 tMax min(TempActual)*.95 max(TempActual)*1.05]);
xlabel('Time (Seconds)');
ylabel('Temperature (Centigrade)');
title('Hot Can Cooling Down');
```

When the cold can absorbs energy from the light bulb, it will gain energy at a constant value. The terms that would physically come into play would be
PGain = Pbulb * f(SolidAngle) * (1-α)
where
• Pbulb = 100W is the amount of power emitted by the light bulb
• f(SolidAngle) is the fraction of solid angle for visible and infrared light to arrive at the can. This will be the same for both cans if they are at the same distance from the bulb.
• α is the fraction of the light which is reflected from the surface without being absorbed. This will depend on factors such as the "color" and "roughness" of the surface. In the global climate model we will study later, this factor is called the Albedo.
Modify your program to allow you to put in a constant value for PGain and try to use this to model the temperature vs. time data for cold cans heating up (either use your own data set, or you can use the file coldcans.out ). You can probably use the same heat-loss coefficient as you did from the cooling can experiment.
Electronic Copy: `http://physics.gac.edu/~huber/envision/canexpt/canexpt2.html`
Revised: 10-JUL-97 by Tom Huber, Physics Department, Gustavus Adolphus College.