A compact Finite Volume Method solver for 2D Euler equations (internal channel flow). Demonstrates numerical methods, scientific programming and shock capturing.
This project implements a finite volume solver for the 2D Euler equations to simulate compressible internal channel flow over a symmetric bump. The complete workflow, from discretization, numerical flux computation, dissipation modeling, time integration, boundary conditions, to validation, follows the methodology described in Hirsch, Vol. 2.
- Central differencing scheme with numerical dissipation (after Hirsch, Numerical Computation of Internal & External Flows, Vol. 2)
- Low-storage Runge-Kutta (4th order) time integration
- Both subsonic and supersonic flow regimes are analyzed
This solver includes basic parallelization via Numba and is specifically tailored to internal channel flow. It is not intended as a general-purpose CFD package, rather, it serves as a compact academic-style example demonstrating the implementation of finite volume methods.
Simulation output for a freestream Mach number of
Clone and install:
git clone https://github.com/<your-username>/fvm-channel-flow.git
cd fvm-channel-flow
pip install -e .
Run sample cases:
python main.py --config examples/config.yaml
Results (plots) will be stored in the examples
directory.
The solver implements the 2D Euler equations in conservative form:
with U being the vector of conserved variables and f, g being the flux tensor in x- and y-direction:
Thermodynamics:
- Pressure:
$p = (\gamma-1)\left(\rho E - \tfrac{1}{2}\rho(u^2+v^2)\right)$ - Total energy:
$E = e + \tfrac{1}{2}(u^2+v^2)$ , with$e = p /((\gamma-1)\rho)$ - Total enthalpy:
$H = E + p/\rho$
Variables:
-
$\rho$ : density -
$u, v$ : velocity components -
$p$ : pressure -
$E$ : total specific energy -
$H$ : total enthalpy -
$c = \sqrt{\gamma R T}$ : speed of sound
The finite volume formulation without source terms in semi-discrete form is given by:
The discretization across faces is then given by:
The numerical fluxes across cell faces are computed using a central differencing scheme with artificial dissipation terms:
As proposed by Hirsch the following formulation of artifical dissipation was implemented:
with
Pressure sensor:
Hat indices
- East:
$(i+1/2,j)$ , West:$(i-1/2,j)$ - North:
$(i,j+1/2)$ , South:$(i,j-1/2)$
Low-storage Runge-Kutta (4th order):
Timestep (CFL condition):
Boundary conditions are enforced using ghost cells to impose the correct physical behavior at the domain boundaries.
At the inlet, stagnation conditions are prescribed from the freestream Mach number
The stagnation state is computed using isentropic relations:
From this, the static inlet values are obtained as:
Density follows from the ideal gas law
At the outlet, density and velocity are extrapolated from the interior, while a fixed static pressure condition is imposed:
The total energy
Along solid walls, a slip condition is enforced to prevent penetration. The velocity is projected onto the wall tangent using:
where
The total energy is then updated by combining the unchanged internal energy with the corrected kinetic energy.
To validate the solver, the results have been compared with those presented in Hirsch (Fig. 11.5.10). For this comparison, the bump height coefficient was set to
Overall, the solver reproduces the reference trends:
- For
$M_{\infty} = 0.01, 0.1, 0.7$ , the local Mach number distributions agree well with literature. - For
$M_{\infty} = 0.7$ , the shock induced by the bump is clearly captured at the expected location. - A discrepancy appears at
$M_{\infty} = 0.05$ , where the simulation predicts a slightly higher Mach range than the reference.
To investigate the discrepancy at
In summary, the solver reproduces the reference results with good accuracy, including correct shock formation in the supersonic case. Minor deviations may arise from differences in the dissipation model, but the overall agreement confirms the validity of the implementation.
- Hirsch, C. Numerical Computation of Internal and External Flows, Vol. 2 — numerical dissipation, discretization schemes, boundary conditions, and full solver workflow.