This library numerically solves the incompressible Navier-Stokes equations with a scalar field in two- and three-dimensional Cartesian domains using the spectral method. This is developed for a self-study purpose to experience by myself the difference between the finite-difference methods and the spectral methods.
- Fourier-Galerkin method.
- Orszag–Patterson algorithm.
- 2/3 de-aliasing.
- Pencil-based MPI parallelisation for more than 10^4 process.
- Fourth-order Runge-Kutta method (non-linear terms) combined with the integrating-factor technique (linear terms) for temporal integration.
Please refer to the documentation for details (under construction).
To initialise the flow field easily, I recommend
Prepare workplace
mkdir -p /path/to/your/directory cd /path/to/your/directory
Get source
git clone --recurse-submodules https://github.com/NaokiHori/SpectralNSSolver1 cd SpectralNSSolver1
Set initial condition
Although the scalar field can be arbitrary, the velocity field should be solenoidal.
main.py
offers several examples.cd initial_condition python3 main.py 0 cd ..
Build
make clean make output make all
Execute
Parameters are defined in
exec.sh
.bash exec.sh
This may take a few minutes, depending on your machine spec.
The flow fields are saved under output/save/
in NPY format.
Note that these velocities are in the spectral domain; you need to perform the inverse Fourier transform (and the normalisation) to recover the velocities in the physical domain.
If proper Python libraries are installed, you can visualise the flow fields by
python3 visualise/2d.py
Please checkout 3d
branch and re-compile the whole source files.
You also need to re-generate the initial flow field.
- Canuto et al., Spectral Methods - Fundamentals in Single Domains, Springer
- Canuto et al., Spectral Methods - Evolution to Complex Geometries and Applications to Fluid Dynamics, Springer
I would like to thank Dr. Chris Howland for fruitful discussions.