Estimating Fluid Velocity and Diffusion from Temperature Measurements (in Theory)
Background
My father, an sensor engineer, recently posed to me an intriguing question: How can we estimate the velocity and thermal diffusion coefficient of a running fluid using only temperature measurements?
While I have taken some computational physics classes, I am no an expert in fluid dynamics or sensor design. However, based on some fundamental physics principles, we can sketch out a theoretical approach that might just work.
Basic Setup
The temperature of a fluid in a long insulated pipe should basically become stationary after a while, assuming the fluid is flowing at a constant velocity. So, to be able to get a signal from the temperature, we need to introduce a heat source at a specific point, say $x = 0$ in the pipe.
A good idea is to drive the heat source with a periodic signal, say $f(t) = A(1 + \sin(\omega_d t))$, so that our temperature sensors can pick up the signal at the same frequency $\omega_d$ and analyze the temperature distribution at that frequency. Intuitively, this should reduce chances that the the teperature sensors picking up noise from the environment, as long as we pick a unique drive frequency.
The 1-D Heat Partial Differential Equation
To get started, ChatGPT told me to consider the classic one-dimensional heat equation, which describes how temperature evolves over time in a moving fluid in an infinitely long pipe.
\[\frac{\partial T}{\partial t} = \alpha \frac{\partial^2 T}{\partial x^2} - v \frac{\partial T}{\partial x} + \frac{f(t)}{\rho c} \delta(x)\]Where:
- $\alpha$ is the thermal diffusivity.
- $v$ is the velocity of the fluid (what we’re trying to estimate).
- $f(t)$ is the heat source, which we’ll assume is $f(t) = A(1 + \sin(\omega_d t))$.
- $\rho$ and $c$ are the fluid density and specific heat capacity.
- $\delta(x)$ is a Dirac delta function to model the fact that the heat source is located at a point $x = 0$.
I’ll admit, there are practical challenges to implementing this in the real world, especially when it comes to building a sensor. But for now, let’s stick with the math!
Solving the Equation in the Frequency Domain
To make things easier, we switch from the time domain to the frequency domain by applying the Fourier transform. This lets us look at the system’s response at the driving frequency $\omega_d$. The Fourier transform of the temperature $T(x, t)$ at this frequency is $\hat{T}(x)$:
\[\hat{T}(x, \omega) = \int_{-\infty}^{\infty} T(x, t) e^{-i \omega t} \, dt\]Since we’re interested in the response to the heat source’s drive frequency $\omega_d$, we consider the Fourier transform at this specific frequency, $\hat{T}(x) = \hat{T}(x, \omega_d)$.
By applying the Fourier transform to the heat equation, we get the following equation at frequency $\omega_d$:
\[i \omega_d \hat{T}(x) = \alpha \frac{d^2 \hat{T}}{dx^2} - v \frac{d \hat{T}}{dx} - \frac{A}{\rho c} i \pi \delta(0) \delta(x)\]For $x \neq 0$, the delta function vanishes, so we are left with the homogeneous part of the equation:
\[\alpha \frac{d^2 \hat{T}}{dx^2} - v \frac{d \hat{T}}{dx} - i \omega_d \hat{T}(x) = 0\]This is a second-order ordinary differential equation that we can solve. The general solution is:
\[\hat{T}(x) = C_1 e^{\lambda_1 x} + C_2 e^{\lambda_2 x}\]Where the constants $\lambda_1$ and $\lambda_2$ are:
\[\lambda_{1,2} = \frac{v \pm \sqrt{v^2 + 4 \alpha i \omega_d}}{2 \alpha}\]Applying Boundary Conditions
Now we apply the boundary conditions. Since we want the solution to remain bounded as $x \to \infty$, we must set $C_1 = 0$ for $x > 0$. Similarly, for $x < 0$, we set $C_2 = 0$ to avoid a diverging solution as $x \to -\infty$.
At $x = 0$, the temperature distribution must be continuous, so we require that $\hat{T}(0^-)$ equals $\hat{T}(0^+)$. This gives us the final form of the solution:
\begin{equation} \label{eq:solution} \hat{T}(x) = C \exp{\left(\frac{v - \text{sign}(x) \sqrt{v^2 + 4 \alpha i \omega_d}}{2 \alpha} x\right)} \end{equation}
Where $C$ is a constant that depends on the heat source amplitude $A$ and the fluid properties $\rho$ and $c$. The sign function $\text{sign}(x)$ is $1$ for $x > 0$ and $-1$ for $x < 0$.
Measuring Temperature and Solving for $v$ and $\alpha$
A good idea here is to place two sensors at different locations and measure $\hat{T}(x_0)$ and $\hat{T}(x_1)$. This way, we can cancel out the constant $C$! This effectively means we use two sensors to “denoise” the signal to remove effects due to the initial and conditions and the heat source’s waveform (in practice, the waveform cannot be perfectly sinusoidal).
So, let us place two temperature sensors at different positions along the flow, say at $x_0$ and $x_1$. Once we have temperature measurements at these two locations, we take their discrete Fourier transforms, giving us two complex values $M_0 = \hat{T}(x_0)$ and $M_1 = \hat{T}(x_1)$.
We take the log of the ratio between these measurements:
\[K = \log{\frac{M_1}{M_0}}\]This $K$ value is a complex number, which consists of two real quantities, and we can use it to solve for two parameters of interest $v$ and $\alpha$ by setting up the equations from the solution \eqref{eq:solution}:
\[K = \frac{v - \text{sign}(x_0) \sqrt{v^2 + 4 \alpha i \omega_d}}{2 \alpha} x_1 - \frac{v - \text{sign}(x_1) \sqrt{v^2 + 4 \alpha i \omega_d}}{2 \alpha} x_0\]Depending on whether $x_0$ and $x_1$ are both positive, or if one is negative, the solution process will vary slightly. For example, if both positions are positive, the equations reduces to a a system of linear equations, which can be solved for $v$ and $\alpha$:
\[\begin{aligned} v & = \frac{a^2 - b^2}{b^3 + a^2 b} (x_1 - x_0)^{-1} \omega_d \\ \alpha & = \frac{a}{b^3 + a^2 b} (x_1 - x_0)^{-2} \omega_d \end{aligned}\]where $a = \Re(K)$ and $b = \Im(K)$. If the sensors are on opposite sides of the source, the solution is a bit more complex and becomes a quadratic system, but it’s still solvable by Mathematica:
\[\begin{aligned} \label{eq:solution-np} v & = \frac{(x_0 + x_1)^2 \left( b^2 (x_1 - x_0) - \lvert a \rvert \sqrt{\left( -4b^2 x_0 x_1 + a^2 (x_0 + x_1)^2 \right)} \right)}{b \left( b^2 (x_0 - x_1)^2 + a^2 (x_0 + x_1)^2 \right) } \omega_d \\ \alpha & = \frac{(x_0 + x_1)^2 \left( a^2 (x_0 + x_1)^2 + \lvert a \rvert (-x_0 + x_1) \sqrt{\left( -4b^2 x_0 x_1 + a^2 (x_0 + x_1)^2 \right)} \right)}{2ab \left( b^2 (x_0 - x_1)^2 + a^2 (x_0 + x_1)^2 \right)} \omega_d \end{aligned}\]Practical Challenges (And Some Guesswork)
Sensor Placement
One obvious challenge is placing the sensors at the right positions. They need to be at known distances from the heat source, and they should be sensitive enough to pick up small temperature changes at the drive frequency $\omega_d$. Also, we need to make sure the sensors are sampling fast enough to avoid aliasing (more on that below).
Drive Frequency and Aliasing
From some simulations, I found a constraint on the drive frequency $\omega_d$ that needs to be satisfied. Specifically, the following condition must hold:
\[\frac{\omega_d}{\pi} = 2 f_d < \frac{v}{||x_1| - |x_0||}\]This essentially means that the drive frequency should be less than half the fluid velocity divided by the distance between the sensors. Though I haven’t fully worked out the details, I am speculating that this is due to Shannon’s sampling theorem. If the drive frequency is too high compared to the fluid velocity, we’ll run into aliasing issues, which could throw off the measurements.
Real-World Imperfections
The model I’ve used assumes everything is happening in one dimension, but in real life, the system could be more complex. There could be heat dissipating into the environment, non-uniform fluid flow, or other external factors affecting the results. These real-world complications would introduce some uncertainty into the measurements.
I’m not an expert in sensor design, but the theory behind it is sound, and with proper calibration, it seems possible to make this work. However, it’s worth noting that further work would be needed to handle the real-world deviations from the idealized model.
Conclusion
Using temperature measurements to estimate the velocity and thermal diffusivity of a flowing fluid is doable in theory, even though the practical aspects (like sensor design) might be trickier. By leveraging the 1-D heat equation with some Fourier analysis, we can get reasonable estimates for $v$ and $\alpha$. If nothing else, it’s a fun application of physics!
If you found this useful, please cite this as:
Yang, Cambridge (Aug 2024). Estimating Fluid Velocity and Diffusion from Temperature Measurements (in Theory). https://people.csail.mit.edu/camyang.
or as a BibTeX entry:
@article{yang2024estimating-fluid-velocity-and-diffusion-from-temperature-measurements-in-theory,
title = {Estimating Fluid Velocity and Diffusion from Temperature Measurements (in Theory)},
author = {Yang, Cambridge},
year = {2024},
month = {Aug},
url = {https://people.csail.mit.edu/camyang/blog/2024/fluid-sensor/}
}
Enjoy Reading This Article?
Here are some more articles you might like to read next: