Compressible Flow Simulation: When and How to Model It

A compressible flow simulation is the right choice when density changes along the flow are large enough to alter the answer. In practice that means gases moving at roughly Mach 0.3 or faster, flows with shocks, and any case where temperature changes because the gas is being compressed or expanded. Below that range, an incompressible model gives the same result in less time. This guide shows how to decide, how to set the case up, and how to tell whether the result can be trusted. If you want a place to run thermal and fluid flow analyses, our CFD and fluid flow tools are built for engineers and students.
TL;DR
Treat a flow as compressible when the Mach number passes about 0.3, and always when it nears or exceeds Mach 1.
Liquids such as water are treated as incompressible in almost every practical case. Gases are the compressible problem.
A compressible solve needs the energy equation and a gas law, plus initial values for density, momentum and energy, and positive density and pressure throughout.
Shock-capturing scheme and mesh choice drive accuracy. Verify with mesh refinement, then validate against experiment or a known analytical result.
Using a compressible solver at very low Mach numbers can cost far more iterations without improving the answer.
Table of Contents
What compressible flow simulation actually means
Compressible flows are those in which density changes in time or in space. Miller’s 2024 introduction to compressible flow points out that most liquids show almost no density change with pressure and are treated as incompressible for practical prediction, while gases change density readily with pressure and need a gas law such as the ideal gas law, p = ρRT.
That last point is what separates the two simulation types. In an incompressible model, density is a fixed number and pressure acts mainly to keep the velocity field mass-conserving. In a compressible model, density becomes an unknown that is solved together with velocity, pressure and temperature. Pressure, density and temperature are tied together through the equation of state, so the energy equation can no longer be left out.
The practical result is a different class of problem: nozzles, supersonic inlets, turbine and compressor passages, valve and relief-device flow, high-speed external aerodynamics, and gas release from pressurized vessels all fall here.
When density changes matter: the Mach number test
The quick screen is the Mach number, Ma, the flow speed divided by the local speed of sound. The MIT OpenCourseWare notes on compressible flow state that significant density variations typically begin when the Mach number exceeds about 0.3, become especially large near and above Mach 1, and that once temperature changes appear, thermodynamics has to be addressed.
Use that as a decision table:
Condition | Typical treatment | Why |
Liquid, no cavitation or extreme pressure | Incompressible | Density barely responds to pressure |
Gas, Ma below about 0.3 | Incompressible, often with variable temperature handled separately | Density variation is small |
Gas, Ma about 0.3 to 1 | Compressible | Density changes affect pressure and drag |
Gas, Ma near or above 1 | Compressible, shock-capturing scheme | Shocks and expansion fans dominate the flow |
Large heating with low speed (for example, buoyancy) | Incompressible with a variable-density or Boussinesq approach | Density varies from temperature, not from speed |
Two cautions apply when you read the table. First, the Mach number must be the maximum local value, not the inlet value. A duct that enters at Ma 0.1 can accelerate to Ma 0.5 at a throat. Second, a small Mach number does not always remove the need for a variable-density model: strongly heated gas can change density a lot at low speed. Our guide to natural convection and when to drop the Boussinesq approximation covers that low-speed case.
Airflow in a data hall is a good example of the low end of the scale. Engineers who track the cooling load factor are working with air speeds that sit far below Mach 0.3, so an incompressible treatment is the natural choice there and a compressible solver would only add cost.
Compressible versus incompressible: how the solvers differ
The difference is not only physical. It changes the numerical machinery.
Incompressible solvers solve continuity and momentum with pressure as a constraint. Pressure-velocity coupling methods such as SIMPLE-type algorithms are standard. Temperature can be added as a passive or buoyancy-coupled scalar.
Compressible solvers solve conservation equations for mass, momentum and total energy, closed by an equation of state. The conservative formulation matters because it captures discontinuities such as shocks with the correct physical behavior, which is why practitioners tend to specialize in one family or the other, as CFD University’s overview explains.
A third family exists for the gap between them. All-speed or pressure-based compressible algorithms extend SIMPLE-type coupling to flows that span low and high Mach numbers. The textbook by Moukalled, Mangani and Darwish, The Finite Volume Method in Computational Fluid Dynamics, covers finite volume numerics for both incompressible and compressible flows, including these all-speed algorithms, with source code for both solver types.
If you are a student choosing a first tool, start with the incompressible case to learn meshing, boundary conditions and convergence. Move to compressible flow when your problem has a Mach number that demands it.

What the compressible model needs
A compressible simulation needs more inputs than an incompressible one. The essentials are:
Conservation equations. Mass, momentum and energy for the gas, in conservative form for shock work.
An equation of state. For many gas problems, the ideal gas law is enough. Real-gas models enter when pressures are high or temperatures approach condensation.
Fluid properties. Specific heat ratio, gas constant, and viscosity and thermal conductivity, which often vary with temperature. Over a wide temperature range, constant properties introduce real error.
A turbulence model. Most engineering flows are turbulent. Pick the model for the flow type, and check its wall requirements.
A thermal model for walls. Adiabatic, fixed temperature or conjugate heat transfer, depending on the problem.
Property handling is where many first compressible runs go wrong. A gas moving through a nozzle may drop hundreds of kelvin, and a viscosity or conductivity fixed at inlet conditions can distort wall heat transfer. Our toolkit includes a built-in property database and supports variable material properties across a wide temperature range, so you do not have to hunt for property tables for each run.
Setting up the case, step by step

1. Define the domain and the physics you need
A finite flow domain needs physical boundary conditions on every edge, as the NASA Glenn CFD analysis process tutorial states. Extend the domain far enough that inlet and outlet conditions do not sit inside the region you care about. For external supersonic flow, make sure outflow boundaries are placed where the flow leaves supersonically, otherwise disturbances can travel back in.
2. Mesh for the physics
The same NASA tutorial gives wall-mesh guidance for turbulent flows: the first grid point off the wall should have y+ below 1.0, with grid stretching of no more than 15 to 20 percent between neighboring cells. Add refinement where gradients are steep, such as at shocks, expansion corners and shear layers. Our CFD mesh quality guide lists the metrics and limits to check and how to repair a poor mesh.
3. Set the boundary conditions
Compressible boundaries differ from incompressible ones because information travels at the speed of sound in some directions and not in others. Subsonic inlets usually take total pressure and total temperature. Supersonic inlets need all flow variables specified. Outlets can take a static pressure when subsonic and nothing when supersonic. Our practical guide to CFD boundary conditions walks through the common choices and where each goes wrong.
4. Set initial conditions explicitly
A compressible run starts from an initial solution and iterates toward the final flow field. The Nektar++ compressible Navier-Stokes tutorial shows why this matters: density, momentum and energy must each be set, for example ρ = ρ∞ and E = p∞/(γ−1) + ½ρ∞(u²+v²), because leaving fields at zero produces NaN errors. Density and pressure must stay positive at every time step.
A worked example: for air at 101,325 Pa and 300 K, the ideal gas law gives a density of about 1.18 kg/m³ using R = 287 J/(kg·K). Moving at 100 m/s, with a speed of sound near 347 m/s, the flow is at Ma of about 0.29, right at the edge of the incompressible range. Initialize the field with that density and velocity, not zeros, and the first iterations behave.
5. Pick the scheme and time stepping
Start with a robust first-order or limited second-order scheme to get a stable solution, then switch to higher-order for accuracy. For transient shock problems, use a time step tied to the fastest wave speed in the cell, the usual Courant condition.
6. Monitor the right things
Watch residuals, but also watch integrated quantities: mass-flow imbalance between inlet and outlet, total force on a body, wall heat flux. A solution is converged when those stop moving, not merely when residuals fall.
Numerical schemes and shock capturing
Shocks are the feature that distinguishes high-speed work. A numerical scheme has to resolve a jump that is much thinner than any practical cell without producing wiggles on either side.
A 2025 study of modern shock-capturing schemes for all-speed flows found that the default KNP scheme is diffusive on coarse grids and can produce spurious oscillations on refined grids. HLLC and its corrected versions, AUSM+up and LDFSS suppress oscillations and improve shock and contact-wave resolution, including on coarse grids.
The same study also reports trade-offs worth knowing before you choose:
AUSM+up has slightly elevated numerical dissipation and underperforms in the deep subsonic regime.
LDFSS matches HLLC-type accuracy but needs many iterations at very low Mach numbers and fails for strong unsteady propagating shock waves.
A TVD-based Runge-Kutta time integration makes the predictor-corrector approach robust and prevents numerical instabilities.
For a student project, an HLLC-type scheme is a reasonable starting point for a mixed-speed case. For deeper reading on discretization and solution methods, Computational Methods for Fluid Dynamics has a dedicated compressible flow chapter and a discussion of numerical accuracy and error estimation.
Cost and accuracy trade-offs
The cost difference comes from stiffness. At low Mach numbers, the speed of sound is much larger than the flow speed, so a compressible solver is forced to resolve acoustic waves that carry no useful information. CFD University notes that a compressible solver can converge painfully slowly for a nearly incompressible fluid such as water, while incompressible solvers converge much faster at low Mach numbers.
A practical rule of thumb follows:
If Ma stays below about 0.3 and temperature effects are modest, use incompressible.
If Ma is between 0.3 and about 0.8 with no shocks, a compressible or all-speed pressure-based solver is appropriate and usually converges well.
If shocks are present, use a density-based or shock-capturing method and expect a finer mesh locally.
If you need transient acoustics, you need a compressible solver and a time step small enough to carry the waves.
The benchmark paper from the Japan Society of Fluid Mechanics community offers a sense of the scale involved. A finite-element compressible solver benchmark ran large-eddy simulation of flow around a NACA0012 airfoil at Re 2×10^5 and a 9° angle of attack with about 13 million mesh points. It set the Mach number to 0.3, above the physical value, to avoid numerical stiffness, and the pressure coefficients agreed fairly well with experiment. The takeaway is that Mach number choice is itself a modeling lever, and that serious three-dimensional compressible work gets large quickly.
Checking convergence and validating the result
A run that finishes is not a run that is right. Separate two questions.
Verification asks whether you solved the equations correctly. A Chalmers University of Technology master’s thesis on OpenFOAM verification used manufactured solutions to calculate discretization error and the observed order of accuracy under mesh refinement, for both incompressible and compressible solvers. You can apply the same idea at a small scale: run three meshes, each refined by a constant ratio, and check that the error shrinks at the rate the scheme promises.
Validation asks whether you solved the right equations. The same thesis compared simulation results with experimental data at measurement points, using a metric based on the difference between simulation and experiment. For compressible flow, good benchmark choices are a converging-diverging nozzle with a known pressure ratio, a shock tube with an analytical solution, or a wedge or cone with a theoretical shock angle.
Our guide to simulation verification and validation in six steps lays out the workflow, and the article on CFD uncertainty quantification shows how to put error bars on a result without changing the solver.
A short convergence checklist:
Residuals have dropped several orders of magnitude and are flat.
Inlet and outlet mass flow match to within a small fraction of a percent.
Force, pressure or heat-flux monitors are stable over the last few hundred iterations.
Results change very little on the next finer mesh.
Density and pressure are positive everywhere, with no clipped cells reported.
Run your analysis with the Jewlz toolkit
When your work combines fluid flow with heat transfer, a single toolkit saves the effort of moving data between tools. The Jewlz Engineering Toolkit is a downloadable Excel-based tool that brings conduction, convection and radiation analysis together with a built-in property database, and it supports variable material properties across a wide temperature range. It includes CFD and fluid flow simulation alongside thermal analysis, pressure vessel simulation and heat exchanger design optimization.

See the Jewlz Engineering Toolkit for what each module covers, or open the CFD simulation software page to see the fluid flow tools.
Our perspective
Most compressible flow mistakes we see described by engineers and students are not exotic. They come from one of three places: a Mach number checked only at the inlet, properties fixed at one temperature, or a result accepted because the residuals looked small. That is why we build our toolkit around physics you can inspect. Conduction, convection and radiation sit in one place, with a property database behind them, so the temperature dependence that changes a compressible answer is part of the model and not an afterthought. We offer free engineering tools because we think the first calculation should never be blocked by a license. Our advice is simple: decide your regime with the Mach number, write down your boundary conditions before you touch a solver, and verify on at least three meshes. Then use the toolkit to carry the thermal side of the problem with the same discipline. Joel
FAQ
Can I use an incompressible simulation for air?
Yes, when the flow stays below about Mach 0.3 and density changes from temperature are small. In that range the density variation is small enough that an incompressible model gives practically the same velocity and pressure field at lower cost. If heating drives large density changes at low speed, use a variable-density approach.
Why does my compressible run produce NaN values?
The most common cause is incomplete initialization. Density, momentum and energy must all be set to physical values, because zero fields lead to NaN errors, and density and pressure must stay positive at every step. If the start is fine, reduce the time step or switch to a more robust scheme for the first iterations.
Is water a compressible flow?
In nearly all engineering cases, no. Liquids show almost no density change with pressure and are treated as incompressible. Compressibility of liquids only matters in special cases such as water hammer or very high pressures, where acoustic effects become the point of the study.
How fine should the mesh be at a shock?
As fine as you can afford in the direction normal to the shock, with refinement concentrated there rather than everywhere. Run at least three mesh levels and confirm the shock position and the downstream pressure change settle as you refine. A shock-capturing scheme such as HLLC helps limit oscillations on coarser grids.
Sources
CFD University, how to solve incompressible and compressible flows in CFD
Assessment of modern shock capturing schemes for all-speed flows (arXiv, 2025)
The Finite Volume Method in Computational Fluid Dynamics (Springer)
Chalmers thesis on verification and validation of OpenFOAM (2017)
Benchmark test of a finite element solver for compressible flow (CFD32)
Recommended


Comments