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 Last Commit

Thumbnail 1 Thumbnail 2 Thumbnail 3

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. It was developed as a self-study project to explore the differences between finite-difference methods and spectral methods.

Features

Refer to the documentation for details (currently under construction).

Dependencies

To easily initialize the flow field, it is recommended to use:

Quick Start

  1. Set up your workspace

    mkdir -p /path/to/your/directory
    cd /path/to/your/directory
  2. Clone the repository

    git clone --recurse-submodules https://github.com/NaokiHori/SpectralNSSolver1
    cd SpectralNSSolver1
  3. Set the initial condition

    The velocity field must be solenoidal, while the scalar field can be arbitrary. main.py provides several example initial conditions.

    cd initial_condition
    python3 main.py 0
    cd ..
  4. Build the solver

    make clean
    make output
    make all
  5. Run the simulation

    Execution parameters are defined in exec.sh.

    bash exec.sh

    The runtime depends on your system specifications.

  6. Output and Visualization

    The flow fields are stored in output/save/ as NPY files. These velocities are in the spectral domain, so an inverse Fourier transform (with normalization) is needed to obtain physical velocities.

    If the necessary Python libraries are installed, you can visualize the results with:

    python3 visualise/2d.py

3D Simulation

To run a 3D simulation, switch to the 3d branch and recompile all source files. You will also need to regenerate 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 valuable discussions.