Physics 410/609---Computational Physics
Assignment #1---Due Thursday, September 21, 2006
1) We would like to test Newton's law of cooling for a cup of coffee.
In my home directory on Nations, you will two data files corresponding
to black coffee and coffee with cream:
-rw-r--r-- 1 sg user 187 Sep 14 2004 coffee_black.dat
-rw-r--r-- 1 sg user 187 Sep 14 2004 coffee_cream.dat
The first column is the time in minutes and the second is the temperature
in degrees Celsius. Room temperature (T_s) was 17 degrees Celsius.
Newton's law of cooling states
dT/dt = - r (T - T_s)
T is the temperature, and r is called the cooling constant.
a) Write a code to numerically integrate this equation using the Euler
algorithm. The time step, r, time between printing output and maximum
time to run should be input values. You may want to have additional
values input. A printout of your code is what is required.
b) Run your code with an initial temperature of 82.3 degrees Celsius and
T_s = 17 degrees Celsius. For this part you should use r = 0.1 / min and
pick a value of step size so that your accuracy after 40 minutes is at least
0.05 degrees Celsius. Show a printout of your results and be sure to say
what step size you used. Justify your selection of step size.
c) Adjust your value of r to try to fit the data in coffee_black.dat.
Explain your criteria for selecting the best value of r. (This may
require careful thought.)
d) Plot your results as a line and the data in coffee_black.dat as crosses.
Make sure that your graph axes are properly labeled (with units) and
indicate the value of r in the title.
e) Check to see of the value of r found in part c is appropriate for
coffee_cream.dat. If not, find the best value for this case.
2) Suppose the coffee is initially at 90 degrees Celsius, but that you can
only sip it when it reaches 75 degrees Celsius. Assuming that adding the
cream will reduce the temperature by 5 degrees Celsius, determine whether
you can drink the coffee sooner by adding the cream immediately, or by
waiting until the coffee cools to 80 degrees and then adding the cream.
Be sure to indicate what value(s) of r you are using. If you found two
different values for r in problem 1, use the appropriate one in each case.
Also comment on whether the answer would change if you use the same value of
r for both cases.
You may present you answer in tablular form, but it would be especially nice
if you prepare a graph in which it is clear which case allows you to
drink the coffee sooner.