Skip to content

Fourier-Galerkin-based massively-parallelised Navier-Stokes solver

License

Notifications You must be signed in to change notification settings

NaokiHori/SpectralNSSolver1

Repository files navigation

Spectral NS Solver 1

License_ CI_ DOCS_ LastCommit_

image

image

image

Overview

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.

Feature

Please refer to the documentation for details (under construction).

Dependency

To initialise the flow field easily, I recommend

Quick start

  1. Prepare workplace

    mkdir -p /path/to/your/directory
    cd       /path/to/your/directory
  2. Get source

    git clone --recurse-submodules https://github.com/NaokiHori/SpectralNSSolver1
    cd SpectralNSSolver1
  3. 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 ..
  4. Build

    make clean
    make output
    make all
  5. 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

3D simulation

Please checkout 3d branch and re-compile the whole source files. You also need to re-generate the initial flow field.

Reference

  • 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

Acknowledgement

I would like to thank Dr. Chris Howland for fruitful discussions.