Simulation of Navier-Stokes Equations by Pseudo-Spectral Method
June 14, 2026 · View on GitHub
Introduction
This project implements a numerical simulation of the 2D Navier-Stokes equations in the formulation using the pseudo-spectral method. This approach enables efficient resolution of fluid flows in the spectral domain (Fourier space).
Fr En
Main Features
- 2D simulation of Navier-Stokes equations in the formulation
- Use of the pseudo-spectral method (Fourier Transforms with FFTW)
- GTK graphical interface for parameter control
- Parallelization with OpenMP for better performance
- Real-time visualization of results
- Export of results to video via ffmpeg
Mathematical Formulation and Pseudo-Spectral Method
A detailed demonstration of the formulation is available in docs/English/demonstration_NS.md. This formulation transforms the Navier-Stokes equations into a coupled system that is simpler to solve numerically.
The pseudo-spectral method combines the advantages of spectral methods and physical space methods:
- Fourier Transforms: Spatial derivatives are computed in spectral space, where they become simple multiplications.
- Non-linear terms: Computed in physical space to avoid costly convolutions.
For more details on the implementation, see docs/English/Pseudo_Spectral_method.md.
Project Structure
navier-stokes-spectral/
├── app/ # Main Fortran code
├── src/ # Fortran source code
├── docs/ # Documentation
│ ├── French/ # Documentation in French
│ └── English/ # Documentation in English
├── data/ # Folder for results
└── fpm.toml # Project configuration
Types of Simulated Flows
The program allows simulation of three classic flow types in fluid mechanics:
1. Co-rotating and Counter-rotating Vortex Simulation
This simulation shows the interaction of several vortices that can rotate in the same direction (co-rotating) or in opposite directions (counter-rotating). This phenomenon is particularly interesting in aerodynamics and meteorology.
2. Kelvin-Helmholtz Instability
This instability occurs at the interface between two fluids moving at different speeds. It manifests as the formation of characteristic vortices.
3. Taylor-Green Vortex
This classic test case in fluid mechanics allows the study of the transition to turbulence.
Prerequisites
The following dependencies are required:
- Fortran Compiler (gfortran recommended)
- GTK (version 4.x)
- fpm (version 0.9.0 or higher)
- FFTW (version 3.x)
- ffmpeg (for video export)
- OpenMP (for parallelization)
Installation
Linux (Debian/Ubuntu)
# Install system dependencies
sudo apt-get update
sudo apt-get install gfortran libgtk-3-dev libfftw3-dev ffmpeg libomp-dev
# Install fpm
curl -Lo fpm https://github.com/fortran-lang/fpm/releases/download/v0.11.0/fpm-0.11.0-linux-x86_64-gcc-12
chmod +x fpm
sudo mv fpm /usr/local/bin
Windows (MSYS2)
# Install dependencies
pacman -Syu
pacman -S mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-gtk3 mingw-w64-x86_64-fftw mingw-w64-x86_64-ffmpeg
# Install fpm
pacman -S git mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-fpm
macOS (with Homebrew)
# Install dependencies
brew install gcc gtk+3 fftw ffmpeg libomp
# Install fpm
brew tap fortran-lang/homebrew-fortran
brew install fpm
conda
conda create -n Navier_Stokes_Spectral_Method_env -c conda-forge gfortran=15.2.0 cmake=4.3.3 fpm=0.13.0 gtk4=4.22.4 cairo=1.18.4 pango=1.56.4 glib=2.88.1 pkg-config=0.29.2 lapack=3.11.0 blas=2.308 fftw=3.3.11
conda activate Navier_Stokes_Spectral_Method_env
Usage
Compilation and Execution
# Clone the repository
git clone https://github.com/Minard-Jules/navier-stokes-spectral
cd navier-stokes-spectral
# Compile and run
fpm run
Simulation Configuration
- Open the graphical interface
- Set the parameters :
- Spatial resolution (Nx, Ny)
- Reynolds number
- Time step
- Simulation duration
- Select the type of flow
- Start the simulation
Visualization
Available Visualization Types
- Velocity fields
- Vorticity
- Stream function
Colormap Options
Blue Orange Colormap (divergent)
https://github.com/user-attachments/assets/a47447f4-31ed-460e-a302-e4a0b335e0c5
'jet' Colormap
https://github.com/user-attachments/assets/4aed022a-e38d-4b91-830b-e7d64ec779b5
Exporting Results
Results are automatically saved in the data/ folder in the following formats :
- Data files (.vtk)
- Videos (.mp4)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Credits
- Minard Jules: Creator and main maintainer of the project