Reference no: EM132154794
Question :
Suppose that you are given an 8 ounce cup of coffee at 90°C and a 1 ounce container of cream at 20°C. You have learned from bitter experience that the hottest coffee you can drink comfortably is 60°C.
Assuming that you take cream in your coffee, and that you would like to start drinking as soon as possible, how long you should wait before adding the cream so that the coffee is 60°C?
To answer this question, you have to model the cooling process of a hot liquid in air and the mixing of liquids at different temperatures.
Hot coffee transfers heat to the environment by conduction, radiation, and evaporative cooling. Quantifying these effects individually would be challenging and unnecessary to answer the question as posed.
As a simplification, we can use Newton's Law of Cooling :
dy/dt = -r(y - T)
where y is the temperature of the coffee as a function of time and dy/dt is its time derivative; T is the temperature of the environment, which is a constant in this case (20°C), and r is a parameter (also constant) that characterizes the rate of heat transfer. Let's assume that r = 0.001 1/s.
In general, the final temperature of a mixture depends on the specific heat of the two liquids. But if we make the simplifying assumption that coffee and cream have the same density and specific heat, then the mixed temperature, ymix, is just a volume-weighed average
ymix = (v1*y1 + v2*y2)/(v1 + v2),
where v1 and v2 are the volumes of the liquids, and y1 and y2 are their temperatures.
To create a matlab program to solve this problem, use the following steps:
1) Create an M-file named coffee.m and write a function called coffee that takes no input variables and returns no output value.
2) Add a function called rate_func that takes inputs t and y and computes g(t,y) based on the above cooling rate formula, where y is the temperature of the coffee at a particular point in time. Notice that in this case g does not actually depend ont; nevertheless, your function has to take t as the first input argument in order to work with ode45.
Test your function by adding a line like rate func(0,90) to coffee, the call coffee from the Command Window.
3) Once you get rate _func(0,90) working, modify coffee to use ode45 to compute the temperature of the coffee (ignoring the cream) for 60 minutes. confirm that the coffee cools quickly at first, then more slowly, and reaches room temperature (approximately) after about an hour.
4) Write a function called mix_func that computes the final temperature of a mixture of two liquids. It should take the volumes and temperatures of the liquids as inputs and return the temperature of the mixture. Add code to coffee to testmix_func.