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

1.6k Views Asked by At

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:

dT/dt (t)=(T(t+Δt)-T(t))/Δt T(t+Δt)=T(t)-Δtk(T(t)-Ta ) Then I stucked. please help.

1

There are 1 best solutions below

1
On BEST ANSWER

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.