 # Lagniappe: Compressible Flow

Throughout the entirety of my commentary before, I dealt solely with fluids whose density was always constant. Although this is usually an excellent approximation, there are in fact situations where the change of a fluid’s density is not only important but useful—in these situations, we unsurprisingly label the flow as compressible.

In Part II, I had mentioned that for fluids in general, a fluid’s density was a function of pressure: $\rho = \rho(p)$. The reason we’re able to make the assumption that most fluids are incompressible is by guessing (and hoping) that this function is relatively “flat”; that is, that large changes in the pressure generate small changes in the density, small enough to ignore. If we wanted to fully understand compressible flow, we would need a full understanding of the function $\rho(p)$, which is more in the realm of thermodynamics than fluid mechanics. But for many purposes, we only need to understand how the density of a fluid changes when its pressure changes—and if the range of fluid densities in a given scenario we’re studying is sufficiently small, then that density/pressure change ratio $\frac{\partial\rho(p)}{\partial p}$ is essentially constant and only a property of the fluid in question.

It may seem like we need to overhaul the entire conceptual infrastructure I built up before to analyze compressible flow, but it’s actually surprisingly simple to handle! Consider the construction we were handling in Part V, where we used a control volume analysis inside of a pipe with a changing cross-section to study the key equations that governed steady flow within such a pipe; the fundamental equations of hydraulics. If I make the same assumptions I made in Part IV—the flow is steady, velocity always points directly into the pipe, etc.— but now consider that the densities at the inlet and outlet may be uniform, different values, control volume analysis dictates that the amount of mass flowing into the pipe needs to be the same as the amount of mass flowing out of the pipe. Mathematically, this translates into: $\displaystyle \int_{A_1}\rho_1 v_1\ dA\ = \int_{A_2}\rho_2 v_2\ dA$

If I integrate this and only focus on average quantities as I did in Part IV, we find something suspiciously similar to the first fundamental law of hydraulics: $\displaystyle \rho_1 \langle v_{1} \rangle A_{1} = \rho_2 \langle v_{2} \rangle A_{2}$

This naturally simplifies into the first fundamental law when the densities are the same. A steady compressible flow through a pipe section with non-constant cross-sectional area. For the mass of fluid within the pipe to remain the same, the amount of mass flowing in needs to equal the amount of mass flowing out. For equal densities, the equation becomes identical to its incompressible counterpart.

Similarly, a control volume analysis on the momentum within such a pipe returns what is essentially the second fundamental law of hydraulics we derived in Part V, except with the inlet and outlet densities made distinct: $\displaystyle |\vec{H}| = \frac{\rho_1 + \rho_2}{2}|\vec{g}|\frac{A_1 + A_2}{2} \left(z_{1} - z_{2}\right) + \langle p_{1} \rangle A_1 - \langle p_{2} \rangle A_2 + \rho_1 \langle v_{1} \rangle^2 A_1 - \rho_2 \langle v_{2} \rangle^2 A_2$

The density in the gravitational term is now the average of the densities at the inlet/outlet, and the momentum flux contributions into/out of the pipe now depend on their respective densities. So far, so good! But I’ll quickly mention that there’s another convenient but essentially equivalent formulation of these equations that will prove very useful—consider what happens if I take the compressible conservation of mass equation, move everything to one side, and divide both sides by the length $L$ of the pipe in question: $\displaystyle \frac{\rho_2 \langle v_{2} \rangle A_{2} - \rho_1 \langle v_{1} \rangle A_{1}}{L}$

In the limit where the pipe length becomes very, very small, the term in the above equation behaves like a derivative! And so by defining a “pipe direction” $x$, we can alternatively describe conservation of mass/the first fundamental equation through such a pipe using the following differential equation: $\displaystyle \frac{d\left(\rho \langle v \rangle A\right)}{dx} = 0$

The same process generates the following differential description of the second fundamental equation of hydraulics: $\displaystyle -\frac{dH}{dx} = \frac{d\left(pA + \rho \langle v \rangle^2 A + \rho g Az\right)}{dx}$

So now that we’ve gotten all that sorted out, what the heck can we actually do with these formulations of compressible hydraulics? Well, here’s a question we can tackle—what flow (if any) does a small change in fluid density generate?

To start, let’s consider steady flow within a horizontal pipe with a constant cross-sectional area, where the pressure and densities of the fluid in the inlet/outlet are uniform, unchanging and only slightly different. We can also make the pipe section very short—short enough to make the momentum losses within it negligible. This rapidly simplifies a lot of the content of the second fundamental equation: $\displaystyle 0 = p_{1} - p_{2} + \rho_1 \langle v_{1} \rangle^2 - \rho_2 \langle v_{2} \rangle^2$

We can then ask ourselves what the flow speed through such a pipe must be in order for the small differences in density to be sustained steadily. To do so, we can hypothesize that the speed throughout the pipe section is a uniform constant value $a$—this is a good approximation, since compressible conservation of mass predicts small speed changes for small density changes—and see how such a speed would depend on the changes in pressure/density. A pipe of constant cross-section with slight differences in density & pressure at either end. Hypothetically, these density/pressure differences will cause a flow through the pipe of constant speed, which is related to the relationship between the change of pressure in the pipe and the change of density in the pipe.

Inserting this hypothesis into the second fundamental equation gets us: $\displaystyle 0 = p_{1} - p_{2} + \rho_1 a^2 - \rho_2 a^2$ $\displaystyle a^2 = -\frac{p_{2} - p_{1}}{\rho_2 - \rho_1}$

Because we had said that the differences in pressure and density were very small, we find a familiar term appear when we make those differences very small: $\displaystyle a^2 = \lim_{\Delta p, \Delta \rho \to\ 0} -\frac{p_{2} - p_{1}}{\rho_2 - \rho_1} = -\frac{\partial p}{\partial \rho} = -\left(\frac{\partial \rho}{\partial p}\right)^{-1}$

This is an interesting, nonintuitive result; if the density of a fluid changes somewhere a little bit, a flow towards the lower density direction will be generated with speed $a = \sqrt{\frac{\partial \rho}{\partial p}^{-1}}$ that only depends on the way a specific fluid generates pressure differences as a result of internal density differences. This particular type of flow is commonly called sound, and the flow speed $a$ is a property of a given fluid called its speed of sound. And because we had stated most fluids generate small density changes for large pressure differences $\left(\frac{\partial \rho}{\partial p} << 1\right)$, we should expect speeds of sound $a = \sqrt{\frac{\partial \rho}{\partial p}^{-1}}$ in general to be pretty big; 343 meters per second in air, and 1481 meters per second in water. That’s pretty fast!

There’s another question we can ask about compressible flow—how does it behave inside of horizontal pipes where the cross-sectional area is not constant? We can start by thinking about what happens for a fully incompressible flow inside such a pipe; as the first fundamental equation of hydraulics indicates, a decrease in cross-sectional area is directly connected to an increase in speed, and the second fundamental equation of hydraulics indicates that that speed increase must lead to a drop in pressure. One can imagine that if one takes this to the extreme, the drop in pressure becomes large enough that the density of the fluid begins to change. So what happens when that occurs? (Be warned: what follows will be an absolute mess of algebra.)

Let’s start by looking at the differential form of the first fundamental equation for compressible flow: $\displaystyle \frac{d\left(\rho \langle v \rangle A\right)}{dx} = 0$

Expanding it out, we can spot the term introduced by compressibility immediately—the density change term. $\displaystyle \frac{d\rho}{dx}\langle v \rangle A + \rho\frac{d\langle v \rangle}{dx} A + \rho\langle v \rangle \frac{dA}{dx} = 0$

Because we know that changes in the density are introduced by changes in pressure, we can introduce the speed of sound into the mix: $\displaystyle \frac{d\rho}{dx}= \frac{d\rho}{dp}\frac{dp}{dx} =\frac{1}{a^2}\frac{dp}{dx}$ $\displaystyle \frac{1}{a^2}\frac{dp}{dx}\langle v \rangle A + \rho\frac{d\langle v \rangle}{dx} A + \rho\langle v \rangle \frac{dA}{dx} = 0$

Now we need to handle the pressure change term. Luckily, we have the differential form of the second fundamental equation to help us out! Applying it to this system, getting rid of gravitational terms since the pipe is horizontal (reasonable), and neglecting momentum loss (somewhat unreasonable, but oh well), we obtain the following: $\displaystyle 0 = \frac{d\left(pA + \rho \langle v \rangle^2 A\right)}{dx}$

Expanding out, and noting that $\displaystyle \frac{d\left(\rho \langle v \rangle A\right)}{dx} = 0$, we get: $\displaystyle 0 = \frac{dp}{dx}A + p\frac{dA}{dx} + \rho \langle v \rangle A \frac{d\langle v \rangle}{dx}$

Isolating the pressure derivative term: $\displaystyle \frac{dp}{dx} = - \frac{p}{A}\frac{dA}{dx} - \rho \langle v \rangle \frac{d\langle v \rangle}{dx}$

Inserting this big mess into that first equation with the speed of sound in it that we were dealing with earlier leads to: $\displaystyle -\frac{1}{a^2}\left(\frac{p}{A}\frac{dA}{dx} + \rho \langle v \rangle \frac{d\langle v \rangle}{dx}\right)\langle v \rangle A + \rho\frac{d\langle v \rangle}{dx} A + \rho\langle v \rangle \frac{dA}{dx} = 0$

Dividing everywhere by $\displaystyle \rho \langle v \rangle A$ and grouping everything that’s multiplied by either the speed derivative or area derivative results in: $\displaystyle \frac{1}{\langle v \rangle} \left(1 - \frac{\langle v \rangle^2}{a^2}\right)\frac{d\langle v \rangle}{dx} + A \left(1 - \frac{p}{\rho a^2}\right) = 0$

Look at that—we managed to group everything that involves the pressure and the density into one term! And luckily for us, that term is usually small enough to neglect—we had already claimed that the speed of sound is usually very large, so it stands to reason that pressures need to be very high in order for that term to matter. Neglecting that term, and solving for the area derivative, we find: $\displaystyle \frac{dA}{ds} = \frac{A}{U}\left(\frac{\langle v \rangle^2}{a^2} - 1\right)\frac{d\langle v \rangle}{dx} = 0$

Alright, that’s enough algebra for today—now let’s try to pull some useful facts out of all this baloney.

Consider what would happen if I was a rocketry engineer and was trying to design a rocket nozzle—because I know that ejecting fluid at high speeds gives me more thrust, I want to try and design a nozzle that speeds up the fluid as much as possible within it. For a completely incompressible fluid, the obvious answer is to make the nozzle decrease in cross-sectional area, as this leads to a proportional speed increase by conservation of mass. You can also see this in the above equation when the flow speed is sufficiently low; area and speed are both positive quantities, and $\left(\frac{\langle v \rangle^2}{a^2} - 1\right)$ is negative for speeds below the speed of sound, so the area derivative needs to be negative for the speed derivative to be positive. But as the flow keeps speeding up, something curious happens; once the flow gets faster than the speed of sound, the sign of the $\left(\frac{\langle v \rangle^2}{a^2} - 1\right)$ term flips and becomes positive! Consequently, the area derivative needs to be positive for the speed derivative to be positive, which is the exact opposite of what was going on below the speed of sound. For speeds faster than the speed of sound, the nozzle’s cross-sectional area needs to start getting bigger in order to accelerate the fluid more.

As a result of all of this, your rocket nozzle design would look like a pipe that gets smaller in radius until the point you predict the flow hits the speed of sound, and then the pipe would start getting bigger again up to some radius based on your operating design. This is precisely why basically all rocket nozzles have that quasi-hourglass shape! A schematic of a rocket nozzle. In the first section, the flow speed is below the speed of sound, and incompressible physics dominates—the cross-sectional area decreases to increase the speed. After the flow speed becomes larger than the speed of sound, compressible physics dominates—the cross-sectional area increases to further increase the flow speed. The total increase in flow speed is very large, causing a large imbalance in inlet/outlet momentum flux, which leads to a large thrust.

Physically, what’s happening is that two effects compete to speed up/slow down a compressible fluid—the effect you see in incompressible flow that causes flow to speed up/slow down when the cross-sectional area decreases/increases, and the slow down/speed up caused by the fluid density increasing/decreasing as a result of “squeezing”/”spreading out” when the cross-sectional area of the pipe decreases/increases. When the flow speed is below the speed of sound—commonly called subsonic flow—this first effect wins out. When the flow speed is above the speed of sound—commonly called supersonic flow—the second effect dominates. And the threshold between them can be quantified by the dimensionless number that is the ratio of the flow speed to the speed of sound of that fluid, commonly called the Mach number; when the Mach number is above 1, the flow is supersonic.