# Hydrostatic pressure & depth with a temperature gradient

## The Question

I am familiar with the standard hydrostatic equation connecting pressure, density, and height/depth - $P = \rho gh$. However, it is well known that density ($\rho$) varies with temperature. Therefore, how should this equation be altered to account for a liquid$^1$ with a temperature gradient?

That is to say, what is the pressure at the bottom of a liquid where the temperature at the top is different to that at the point of pressure measurement?

Or am I incorrect in thinking it makes any difference?
(Although this post seems to indicate that I am right.)

## The Context

I work for a company that provides control and monitoring systems for medium and large ships. A system recently provided for measuring the quantity of oil in the ship's tanks relies heavily on this equation, using pressure sensors installed in the tanks to calculate the depth of liquid. However, the client insists that our system is insufficiently accurate.
In the interests of customer satisfaction, and the potential for further system sales, I have been tasked with investigating ways of improving our mathematics, this being the main one. We already take account of the oil's Specific Gravity (as measured at 15ºC) and temperature at the pressure sensor (used to calculate the Volume Correction Factor, and therefore density), and are considering an extra temperature sensor at the top of the tank. My question is intended to find out if this will provide a notable benefit.

$^1$As you can see from the context, I am only interested in liquids. If your response takes gases into account too, that's fine by me.

There is a connection between these quantities provided by the Equation of State:

$$f(P,\rho,T) = 0$$

The specifics of the function $f$ depends on the system you're working with: gass, water, relativistic fluids, stellar intererios, ideal gasses, ...

This is a very old paper, but you can find there some approximations to $f$ for salt water, which I believe is exactly what you need

As a first approximation you can use the temperature coefficient of cubical expansion of a liquid $\beta$ and assume a relationship of the form $\rho_2 = \dfrac {\rho_1}{1+\beta (t_2-t_1)}$ where $\rho_1$ and $\rho_2$ ate densities of the liquid at temperatures $t_1$ and $t_2$.

Then you need to have information about the variation of temperature, $t$, with depth $y$.

Then do an integration of the form $\int _{y_1}^{y_2}\rho(y)\;g \;dy$

You will have to decide from the values of the coefficient of cubical expansion and the range of temperatures whether or not it is worth making the correction.

If the liquid you are interested in is water then there is a more precise equation for the density of water as given in Kaye and Laby.