Write a script to determine the change in temperature of the liquid over a 200 minute time period using the following equation: T(i+1)=T(i)+K*(Delta_t)*(F-T(i))
1 view (last 30 days)
The start Temperature of a liquid is 50 and is placed into a fridge of temperatue 5. (F=5)
Have to calculate each value of T(i+1) from the value of ܶT(i) from the previous time step over a space of 200 minutes where the time in dived into time steps each of duration delta_t. Must be computed using a 'For' loop. Also K = 0.045
I cant seem to get the time incrments correct as i always get negative values for my temperature which doesnt make any sense realistically.
William Rose on 26 Oct 2022
The change in temperature in each time step is proportional to the difference bwteeen the current temp and the fridge temp (Tf=5, constant):
deltaT = K*(T-Tf)*deltat
where deltaT is the change in temp (it changes with each time step) and deltat is the time step size (constant). I have assumed that K is a "rate of decay" constant, with units of 1/time.
You get negative values because you assume the temperature just declines at a constant rate, instead of assuming that it decays at a rate proportional to the difference between current tmp and fridge temp.
You can put that idea into a Matlab script.
By the way, this problem also has an analytical solution, involving an exponential function:
T(t)=(Tinit-Tf)*exp(-Kt) + Tf
If you plug in t=0 and t=infinity, you see that T(0)=Tinit=50 and T(infinity)=Tf=5, which makes sense.