Newton s Cooling Model in Matlab and the Cooling Project!

Similar documents
Project Two. Outline. James K. Peterson. March 27, Cooling Models. Estimating the Cooling Rate k. Typical Cooling Project Matlab Session

Project Two. James K. Peterson. March 26, Department of Biological Sciences and Department of Mathematical Sciences Clemson University

MatLab Code for Simple Convex Minimization

Riemann Sums. Outline. James K. Peterson. September 15, Riemann Sums. Riemann Sums In MatLab

The First Derivative and Second Derivative Test

The Derivative of a Function

Predator - Prey Model Trajectories and the nonlinear conservation law

The First Derivative and Second Derivative Test

Project One: C Bump functions

Ideal Gas and Latent Heat

More Protein Synthesis and a Model for Protein Transcription Error Rates

Class President: A Network Approach to Popularity. Due July 18, 2014

A population is modeled by the differential equation

Riemann Integration. Outline. James K. Peterson. February 2, Riemann Sums. Riemann Sums In MatLab. Graphing Riemann Sums

MATH 408N PRACTICE MIDTERM 1

Linear Motion with Constant Acceleration

Riemann Integration. James K. Peterson. February 2, Department of Biological Sciences and Department of Mathematical Sciences Clemson University

One common method of shaping

Sin, Cos and All That

Advanced Protein Models

Introduction to Special Relativity

Computer simulation of radioactive decay

Lecture 5b: Starting Matlab

LAB 2 - ONE DIMENSIONAL MOTION

Math Fundamentals for Statistics I (Math 52) Unit 7: Connections (Graphs, Equations and Inequalities)

Solving Linear Systems of ODEs with Matlab

Advanced Protein Models

An Introduction to Matlab

Physics E-1ax, Fall 2014 Experiment 3. Experiment 3: Force. 2. Find your center of mass by balancing yourself on two force plates.

Sin, Cos and All That

Using Recursion in Models and Decision Making: Recursion Using Rate of Change IV.C Student Activity Sheet 5: Newton s Law of Cooling

Solving systems of ODEs with Matlab

AP CHEMISTRY LAB RATES OF CHEMICAL REACTIONS (II)

Integration by Parts Logarithms and More Riemann Sums!

Mathematical Induction

Taylor Polynomials. James K. Peterson. Department of Biological Sciences and Department of Mathematical Sciences Clemson University

Exploring Graphs of Polynomial Functions

Who invented Calculus Newton or Leibniz? Join me in this discussion on Sept. 4, 2018.

1 Measurement Uncertainties

Algebra Exam. Solutions and Grading Guide

EXPERIMENT 2 Reaction Time Objectives Theory

Lab I. 2D Motion. 1 Introduction. 2 Theory. 2.1 scalars and vectors LAB I. 2D MOTION 15

Consequences of Continuity

CHM201 General Chemistry and Laboratory I Laboratory 7 Thermochemistry and Hess s Law May 2, 2018

Lab I. 2D Motion. 1 Introduction. 2 Theory. 2.1 scalars and vectors LAB I. 2D MOTION 15

More On Exponential Functions, Inverse Functions and Derivative Consequences

1 Implicit Differentiation

MAPLE Worksheet Number 7 Derivatives in Calculus

Math Lab 10: Differential Equations and Direction Fields Complete before class Wed. Feb. 28; Due noon Thu. Mar. 1 in class

Math 116 Second Midterm March 20, 2017

Slide 1. Slide 2. Slide 3. Integrated Rate Laws. What is a rate? A rate as a derivative. Finally a use for calculus! It s a delta/delta!

Geometric Series and the Ratio and Root Test

Lab 6 - Electron Charge-To-Mass Ratio

2. (12 points) Find an equation for the line tangent to the graph of f(x) =

Lab 2 Worksheet. Problems. Problem 1: Geometry and Linear Equations

Extreme Values and Positive/ Negative Definite Matrix Conditions

Defining Exponential Functions and Exponential Derivatives and Integrals

Coulomb s Law Mini-Lab

Physics 6A Lab Experiment 6

Implicit Differentiation Applying Implicit Differentiation Applying Implicit Differentiation Page [1 of 5]

GUIDED NOTES 2.2 LINEAR EQUATIONS IN ONE VARIABLE

Lesson 3A: How Fast Are You Moving?

Derivatives and the Product Rule

Coulomb s Law. 1 Equipment. 2 Introduction

Introduction to Determining Power Law Relationships

Designing Information Devices and Systems I Spring 2018 Lecture Notes Note Introduction to Linear Algebra the EECS Way

The SIR Disease Model Trajectories and MatLab

PRACTICE AP SECTION II, PART A. Time 1 hour and 15 minutes Part A: 30 minutes, 2 problems Part B: 45 minutes, 3 problems

Partner s Name: EXPERIMENT MOTION PLOTS & FREE FALL ACCELERATION

Modeling Data with Functions

3.4 Complex Zeros and the Fundamental Theorem of Algebra

Predator - Prey Model Trajectories are periodic

Lesson 3-2: Solving Linear Systems Algebraically

22: Applications of Differential Calculus

Lab 5 - ELECTRON CHARGE-TO-MASS RATIO

Math 5a Reading Assignments for Sections

7.1 Indefinite Integrals Calculus

Outline. Additional Nonlinear Systems. Abstract. Finding Equilibrium Points Numerically. Newton s Method

Consequences of Continuity

DON T PANIC! If you get stuck, take a deep breath and go on to the next question. Come back to the question you left if you have time at the end.

Physics 6A Lab Experiment 6

Calculus II. Calculus II tends to be a very difficult course for many students. There are many reasons for this.

Math 116 Practice for Exam 2

Chapter 14: Finding the Equilibrium Solution and Exploring the Nature of the Equilibration Process

Linear Regression. Linear Regression. Linear Regression. Did You Mean Association Or Correlation?

Graphs. 1. Graph paper 2. Ruler

Appendix. Using Your Calculator. Squares, Square Roots, Reciprocals, and Logs. Addition, Subtraction, Multiplication, and Division

Parametric Equations, Function Composition and the Chain Rule: A Worksheet

Derivatives and Continuity

A Simple Protein Synthesis Model

Differential Equations

Experiment 1: The Same or Not The Same?

Math Lab 8: Electric Fields Integrating Continuous Charge Distributions II Due noon Thu. Feb. 1 in class

3.1 Derivative Formulas for Powers and Polynomials

Regression I - the least squares line

CHAPTER 7: TECHNIQUES OF INTEGRATION

Designing Information Devices and Systems I Fall 2018 Lecture Notes Note Introduction to Linear Algebra the EECS Way

Business Statistics. Lecture 9: Simple Regression

Ideal Gas Law and Absolute Zero

Motion in Two Dimensions: Centripetal Acceleration

Transcription:

Newton s Cooling Model in Matlab and the Cooling Project! James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University March 10, 2014 Outline Your Newton Cooling Project Your Project Typical Cooling Project Matlab Session

Abstract Newton s Cooling Model in Matlab and the Cooling Project! Your assignment will be to take the liquid of your choice and place it in a cup of some sort like a coffee cup. Measure the ambient temperature A of the room you are in. Microwave the contents until the liquid is close to boiling. Then take it out of the microwave and measure the initial temperature, T 0. Then measure the temperature every 30 seconds for the first five minutes and then every minute for the next 10 minutes and then every five minutes thereafter until the temperature of the liquid in the cup reaches A + 5 or so. You will not reach room temperature in any reasonable length of time, so stopping at A + 5 is just fine. We will then model the decay of the temperature of your liquid using Newton s Law of Cooling. So it we let T (t) be the temperature of your liquid at time t in minutes, we will assume that the cooling of the liquid satisfies Newton s Law of Cooling.

Hence, we know This has solution T (t) = k(t (t) A), T (0) = T 0. T (t) = A + Be kt. Applying the initial condition, we get T 0 = A + B. or B = T 0 A. Hence, the solution is T (t) = A + (T 0 A)e kt. The one parameter we don t know is the constant of proportionality, k. However, we do have all the data we collected. So, rewrite our solution as T (t) A = e kt. T 0 A Now take the logarithm of both sides to get ( ) T (t) A ln = kt. (1) T 0 A This tell us how to estimate the value of k. Let the variable U(t) be defined to be ( ) T (t) A U(t) = ln T 0 A Then, Equation 1 can be written as U(t) = kt. Thus, the variable U is linear in t; i.e. if we graph U versus t we should see a straight line with slope k. Our collected data consists of pairs of the form (time, temperature). Suppose we collected N such pairs. Label them as (t i, T i) for 1 i N (you might have 80 points say so for you N = 80). Compute the corresponding U(t i) U i points ( ) Ti A U i = ln T 0 A and plot them as a scatter plot in MatLab.

Note the first value, U 1 = ln T0 A T0 A = ln(1) = 0. So our line has U intercept 0. Hence, our line is of the form y = mt and we have to find a good candidate for the slope m. This slope will then be used in our cooling model. From your data, you now have a collection of pairs (t i, U i) for 1 i N. We can find a line which comes close in an optimal way to all of this data (although the line does not have to include all the data!) by using a bit of calculus. At each time, the line has the value mt i. The discrepancy or error between the actual U value and the line value is then U i mt i. We want the cumulative error between our line and the data, so we don t want errors to cancel. Hence, we could choose an error term like U i mt i or (U i mt i) 2. Both of these are fine, but the squared one is differentiable which will allow us to use calculus methods. Define the energy function E(m) where m is the slope to be E(m) = N (U i mt i) 2. This is a nice function and so let s find where this function has a minimum by setting its derivative is zero. Setting the derivative to zero, we find de N dm = 2 (U i mt i) ( t i) = 0. Simplifying a bit, we have N ( U it i = m ti 2 ).

Solving for the critical point m, we find m = Uiti t2 i Finally, it is easy to see d 2 E dm 2 = 2 N ti 2 > 0. for all choices of m. Hence, the value m which is the critical point must be the global minimum Hence, the optimal slope is m = Uiti t2 i Then we can see how good our model is by plotting the model solution T (t) = T (t) = A + (T 0 A)e m t on the same plot as the actual data. First some notes of formatting of the report in your choice of word processor. 1. Use a one inch margin on all sides. 2. Use 11 pt font. Now let s talk about the structure of the document. It consists of the following pieces: Introduction: here you discuss the Newton s Law of Cooling. You should do some research on this at the library or online to find out more about this law. Your findings about this will then go in this section. This is 6 Points.

More on your document s structure: The Mathematical Model: Here you state the mathematical form of Newton s Law of Cooling. This means that you need to type the appropriate mathematical equations. Take care to do this nicely so that the report has a nice visual look. Discuss the meaning of each symbol in the mathematical equations, of course. Derive the solution to the Newton cooling problem showing all the mathematics. This is to make sure you learn how to use mathematics in a word processing document. Derive the optimal slope value as we have done in the text: again, this is to make sure you can type mathematics. Derive the appropriate log plot that you will use to find the Newton Cooling Constant. This is 10 Points. The Experiment: Here you discuss that your experiment is going to try find out if your liquid obeys Newton s Law of Cooling. You need to explicitly go over all of the information that is relevant to the experiment. This includes the choice of liquid, the cup it was placed in, an analysis of the kind of cup it was (ceramic, Styrofoam etc.), how the temperature of the liquid was measured and so forth. Be very explicit here. The idea is that the reader would have enough information to run the experiment themselves. Include a picture of the cup and your temperature measurement device in this section. Don t use water; that is an automatic project score of 0! Take pictures of your experimental setup and embed them in the document. This is 10 Points.

The MatLab Analysis: Here you include 1. the MatLab code fragments that plot your original data using circles for the data points. 2. the MatLab code to create the appropriate log plot annotated carefully. 3. the plot of your log data using circles for the data points. 4. the MatLab code to find the optimal slope from log plot and your value of the slope This is 10 Points. The Model: Here you discuss the model you found from your data and show how it compares to the data you collected. The MatLab code to plot the model and the data simultaneously needs to be here as well as the actual plot. Your original data is again plotted with circles for the data while the model is plotted as a smooth curve. This is 8 Points. Conclusions: Here you discuss whether or not you feel Newton s Law of Cooling provides a good theoretical model for your collected data. Discuss also flaws you might have found in the experiment. This is 6 points. References: Any references you used need to be placed here.

Let s see how we can manage our experimental data. Save your experimental data in a file with two columns. Column one is for time and column two is for the temperature of your liquid. Create a new file in Matlab and call it Newton.dat or some other name. Place it in your class folder. For a typical liquid (orange juice, water, tomato juice etc), we might collect the data here 0. 0 205 0. 5 201 2. 0 201 5. 0 190 8. 0 178 1 0. 0 175 1 3. 0 167 1 5. 0 161 2 5. 0 141 3 0. 0 135 4 0. 0 127 5 0. 0 117 6 5. 0 108 8 0. 0 100 9 5. 0 95 1 1 0. 0 89 1 3 0. 0 83 1 6 5. 0 80 We have the ambient or room temperature is 76 degrees for our experiment. load the data and generate the plot of the data % l o a d i n t h e e x p e r i m e n t a l d a t a from t h e % f i l e Newton. dat as two columns >> Data = l o a d ( Newton. dat ) ; % use t h e f i r s t column as time >> time = Data ( :, 1 ) ; % use t h e second column as t e m p e r a t u r e >> Temperature = Data ( :, 2 ) ; % g e n e r a t e a p l o t o f t h e e x p e r i m e n t a l d a t a >> p l o t ( time, Temperature, o ) ; % s e t x l a b e l >> x l a b e l ( Time i n Minutes ) ; % s e t y l a b e l >> y l a b e l ( Temperature in Fahrenheit ) ; % s e t t i t l e >> t i t l e ( Newton Law Of C o o l i n g E x p e r i m e n t a l Data ) ;

We see the plot of the measured data here: From the theory we have discussed, ( we ) know we should graph the T A transformed data given by log T0 A where A is the room temperature, T and T0 are the temperature and initial temperature of the liquid, respectively. Here A = 76 and T0 = 205. Thus, T0 A = 129. Here is how we do this in Matlab: % for t h i s data, T 0 A = 205 76 = 129 >> A = 7 6 ; >> LogTemperature = l o g ( ( Temperature A) / ( 129. 0 ) ) ; >> p l o t ( time, LogTemperature, o ) ; >> x l a b e l ( Time i n Minutes ) ; >> y l a b e l ( Transformed V a r i a b l e l n ( (T A) /( T 0 A) ) ) ; >> t i t l e ( Transformed Data V e r s u s Time ) ;

You can see this transformed data here: Then, look for the best straight line through the plot making sure you have the line go through the point (0, 0) at the top. The optimal slope is then m = Uiti N. t2 i In MatLab, we can add up all the entries in the variable U and time using the sum command. The optimal slope calculation in MatLab is then >> mstar = sum ( LogTemperature. time ) /sum ( time. time ) mstar = 0.0215 where the variable LogTemperature plays the role of U. Note time and LogTemperature are vectors so we use.* to do component wise multiplications!

The syntax LogTemperature.*time means to multiply each component of LogTemperature and time separately to create the new column of values LogTemperature(1) time (1) LogTemperature(N). time (N) The command sum applied to this column then creates the sum Uiti like we need. A similar thing is happening with the term sum(time.*time). The model is thus which we enter in MatLab as u(t) = 76.0 + 129 e 0.0215t % compute t h e model >> u2 = 76.0 + 129.0 exp ( mstar time ) ; Then we plot both the experimental data and the model on the same plot, % p l o t t h e model and the measure d a t a on t h e same p l o t >> p l o t ( time, u2, r, time, Temperature, o ) ; >> x l a b e l ( Time I n Minutes ) ; >> y l a b e l ( Temperature in Fahrenheit ) ; >> t i t l e ( F i t o f Newton Law o f C o o l i n g Model To Data : Data = o ) ; Looks pretty good! We could also have added a legend like legend( Model, Data, Location, BestOutside ); but we didn t show that. You should do that though in your report so it is really easy to see what is going on.

Our final plot! Here is all the code without comments! >> Data = l o a d ( Newton. dat ) ; >> time = Data ( :, 1 ) ; >> Temperature = Data ( :, 2 ) ; >> p l o t ( time, Temperature, o ) ; >> x l a b e l ( Time i n Minutes ) ; >> y l a b e l ( Temperature in Fahrenheit ) ; >> t i t l e ( Newton Law Of C o o l i n g E x p e r i m e n t a l Data ) ; % for t h i s data, T 0 A = 205 76 = 129 >> A = 7 6 ; >> LogTemperature = l o g ( ( Temperature A) / ( 129. 0 ) ) ; >> p l o t ( time, LogTemperature, o ) ; >> x l a b e l ( Time i n Minutes ) ; >> y l a b e l ( Transformed V a r i a b l e l n ( (T A) /( T 0 A) ) ) ; >> t i t l e ( Transformed Data V e r s u s Time ) ; >> mstar = sum ( LogTemperature. time ) /sum ( time. time ) ; >> u2 = 76.0 + 129.0 exp ( mstar time ) ; >> p l o t ( time, u2, r, time, Temperature, o ) ; >> x l a b e l ( Time I n Minutes ) ; >> y l a b e l ( Temperature in Fahrenheit ) ; >> t i t l e ( F i t o f Newton Law o f C o o l i n g Model To Data : Data = o ) ;

So there you have it. You are ready to go off and collect some data and see if your liquid obeys Newton s cooling law. Have some fun with this and treat it like a real lab in biology. Document everything! I want you to learn how to type mathematics into word so look around and find the tools to do that. You ll have three plots total! Make sure you get them all. I enjoy interesting liquid combinations in this lab, so be inventive!