# How to simulate temperature change of oven?

I am trying to write a software, which will model the oven temperature change when turning on/off. The data I can get is graph, by taking temperature reading each second from T0 time up to some temperature. Then I can take data for cooling graph. So I will have two non linear curves. Having this data, how can I simulate temperature change? Should I take current temperature at any given moment, see if oven is on/off, then follow respective curve to increase or decrease the temperature with calculated speed? Mostly I'm not clear on how to calculate the speed from curve.

What will be precision of such modelling?

took some readings from oven as sample data. I've turned off oven at 80 degree.

-

Once you have the data from the heating process, fit a curve through it. Do the same thing with the cool-down data. You then have an approximate expression for the evolution of the temperature with time when the heat source is on and when it is off. You should in general get a shape like $T(t) = T_0 + f(t)$ when the oven is on and $T(t) = T_0 - g(t)$ when it is off. Use these expressions in your code. Everytime the oven is switched between on or off, you switch equations in your code.

More in detail: if you start at $t=0$ with $T(0) = T_0$ and the heat source activated, you do nothing until an action is taken. Keep a logical variable active with value 1 if the heat source is active and 0 if not. If the action is to switch off the heat source, you simply change the value of your logical variable, overwrite $T_0$ and put $t=0$ again. If the action is to measure the temperature, read the logical variable and calculate the approximate temperature $T(t)$ using the expression corresponding to the value of active. You know $T_0$ and the time $t_1$ passed since $t=0$ so it's a straightforward calculation. (you know the time either from the actual time passed or from a simulated time that you could establish yourself)
If desired you could put all this in a loop and calculate the temperature nearly continuously while the heat source is being activated and deactivated. But my answer is already getting into the field of programming more than physics.

The precision of this particular approach depends partly on the accuracy of the plots (if the data is good). If the fit is no good, any extrapolations made with it will be completely unreliable. But if your heat source isn't too whimsical, you should be able to get a more than reasonable fit with a fairly basic mathematical model.
Another aspect of the problem which could have an important impact on the reliability of this approach is if the system exhibits a significant amount of hysteresis or if there is a time-memory. Both phenomena would be difficult to incorporate into a general model, at least without additional experimental data of different heat-up/cool-down cycles. So if their effects are not negligible within the desired level of precision, you will need more knowledge of their behaviour through experiments.

-
It's not just the fit of the data that is important. Whether the system exhibits hysteresis or whether there is a time-memory is also important. For example, if the air temperature hits 400F for 30 seconds vs 30 minutes the cool-down curve can change. Likewise, the heat-up curve to another temperature will change based on time history. –  tpg2114 Jan 13 '13 at 6:00
@tpg2114 Excellent point. I've edited my answer to include this as a restraint on the reliability of this approach. Any suggestions on how to tackle these in a general model of this oven? –  Wouter Jan 13 '13 at 11:17
so what kind of data I should collect in order to consider this aspects? –  Pablo Jan 13 '13 at 11:33
Well, I would start by attempting to measure exactly how strong the hysteresis in your system is. One way of doing this could be to heat the oven from the environmental temperature $T_0$ up to a certain high temperature $T_1$, then let it cool back down to $T_0$, heat it up to a lower temperature $T_2$, say $(T_1-T_0)/2$, and let it cool down again. You can then make your cool-down fit in both cases and compare. Do you get $T_0$ if you fill in the parameters (starting temperature and time passed) of the second curve into the fitting model of the first curve? –  Wouter Jan 13 '13 at 12:39
Or as tpg2114 suggested: you can take the temperature up to a certain value and hold it there (take the maximum temperature if it's not otherwise straightforward to keep the temperature constant). Do this for different times: first hold it there for a short time and cool down, then hold it there for a long time and cool down. Compare the cool-down curves to get an idea of the memory of the system. I'd like to add the following note as well. My proposition might be too crude a model, but it's worth giving a go, depending on how accurate you want your simulation to be. –  Wouter Jan 13 '13 at 12:51