how to solve newton's law of cooling using Numerical Solution

A metal bar is heated 100oc by a heat source. After 40 minutes the heat source is removed when the temperature of the metal bar reached to a plateau. Now the metal bar is placed in a room. The room temperature is 25oc. After 10 minutes the bar temperature reached to 80oc. a) What is the initial temperature of the metal bar. b) Find the metal bar temperature after 30 minutes.

How to solve this using Numerical Solution? I am trying to solve this using Euler method, but I only could finish upto this:

• Hi. Please explain what your experience level is with numerical methods, and what method have you chosen (or required) to use. – ja72 Dec 2 '18 at 3:55
• Is Δtk(T(t)-Ta ) to be interpreted as multiplication Δtk * (T(t)-Ta ) or a function Δtk(T) ? – ja72 Dec 2 '18 at 4:36
• I don't have much knowledge about the numerical method. Here I am trying to use Euler method as I mentioned in the question. Δtk(T(t)-Ta ) is a multiplication. – Cynthia Dec 2 '18 at 14:23

The equation you are trying to simulate is

$$\frac{{\rm d}T}{{\rm d}t} = -k \Bigl( T - T_a \Bigr)$$

This is a classic ordinary differential equation (ODE) of the form $$T'= f (T)$$ where $$T'$$ is the derivative and $$T$$ the quantity to be solved for.

Starting from any time step with a temperature $$T_i$$ at time $$t_i$$, you progress to the next time step $$t_{i+1}=t_i+h$$ using Euler's method which states $$T_{i+1} = T_{i} + h f(T_i)$$. So for each time step you do the following

$$T_{i+1} = T_i + h \left(- k \Bigl(T_i - T_a \Bigr) \right) = T_i - k\, h \left( T_i -T_a \right)$$

And that is all you need to before it becomes a programming question and not a math question. You already have this equation since $$h=\Delta t$$.

In pseudo-code the above would look like this:

start_time = 0
Ta = 250
end_time = 600
steps = 1000
h = (end_time-start_time)/steps
time = start_time
T = 800
for i=1 to steps
T = T - k*h*(T-Ta)
time = time + h
end
% Now T holds the temperature of the bar after 10 minutes of cooling
% at ambient temperature 250°F starting from 800°F using 1000 simulation steps.
• thank you for the details explanation – Cynthia Dec 3 '18 at 12:52