Tag Archives: simulate water temperature

The Way Water Warms


I am so happy with my Raspberry Pi now able to obtain real-time measurements from the La Selva biological station. As much as this station measures, it does not measure water temperature. Time for some geeking out!



What I DO have

So the measurements I do get from the biological station are basically all the ingredients I need to synthesize the water temperature. Especially these values will determine the temperature:

  • Light Intensity;
  • Air Temperature;
  • Rainfall;
  • Previous Water Temperature.

I want to use some kind of calculation to create a synthetic water temperature. I’m assuming sunlight will heat the water. The water temperature will somewhat follow the air temperature. Finally rain will seriously cool down water.


Making up a formula to synthesize water temperature

Forming a formula that synthesizes water temperature is kind of hard to do. There are so many variables. In the wild, water will come flowing in from somewhere else. Deep water will flow slowly, and hardly heat up under sunlight. A small pool of 10cm of water will heat up extensively, unless it streams fast.

It is almost impossible to work with all these variables. So I figured to just build a simulation formula, and see how the water temperature will develop as I run through the days. I started out with a formula like this:


WaterTemp = WaterTemp + (Light/settings.get(“synth.lightFactor”))
WaterTemp = WaterTemp + (AirTemp-WaterTemp) / settings.get(“synth.AirTempFactor”)
RainDiff = Rain * ( WaterTemp – settings.get(“synth.rainTemp”) )
if (RainDiff < 0): RainDiff = 0 WaterTemp = WaterTemp - ( RainDiff / settings.get("synth.rainFactor") )


The first line will increase the water temperature from the last sample with (Light/factor). This is the heating of the water by the influence of sunlight.

The second line first calculates the difference between air and water temperature. The further apart, the bigger the effect will be. After dividing by a factor, I add this difference to the water temperature (this cal either heat or cool down the water)

The third line first calculates the difference in temperature between the water and the rain. Then I multiply this number by the number of millimeters of rain (more rain = more cooling). In case the rain is warmer than the water (should never occur), I do nothing.

Finally I subtract the calculated value from the water temperature divided by another factor. I use these factors to tweak and tune the simulation.


The result

I still have to look at the effect in a longer run, maybe import a few weeks of simulated data into excel and graph it out. So far it seems to behave pretty well… Simulated temperatures normally run from 24 degrees centigrade (early morning) up to 27.5 degrees centigrade in the late afternoon (4PM). Rain cools it down 1-2 degrees. When looking at heavy rainfall (like September 11th 2013 where there was over 70mm of rainfall in 1,5 hours), the simulation delivered a water temperature of 21.4 degrees centigrade. Not bad at all!