Skip to content

nekStab/nekStab

Repository files navigation

nekStab banner

OS Arch Compiler MPI Status
Ubuntu 24.04 x86_64 gfortran 14 OpenMPI / MPICH CI
Ubuntu 24.04 x86_64 ifort 2024 / ifx 2025 Intel MPI CI
macOS 15 ARM64 gfortran 14 OpenMPI CI

nekStab is a toolbox for global stability and bifurcation analysis using the spectral element solver Nek5000. Released under BSD-3-Clause license.

Features

Steady-State & Periodic Orbit Computation

Method Description
SFD Selective Frequency Damping for unstable steady states
BoostConv Residual acceleration for slow convergence
TDF Time-Delayed Feedback for periodic orbits
Newton-Krylov Quadratic convergence for fixed points, UPOs (natural frequency), and forced periodic orbits

Global Stability Analysis

Analysis Steady Flows Time-Periodic (Floquet)
Direct eigenmodes
Adjoint eigenmodes
Transient growth

Sensitivity & Receptivity

  • Wavemaker — structural sensitivity to feedback
  • Energy budget — production, dissipation, transport decomposition (steady + Floquet)
  • Base flow sensitivity — response to mean flow modifications
  • Steady force sensitivity — optimal placement for passive control
  • Mode animation — reconstruct eigenmode dynamics over one period

Modal Decomposition

Method Description
POD Proper Orthogonal Decomposition (energy-ranked modes)
DMD Dynamic Mode Decomposition (frequency-ranked modes)
SPOD Spectral POD (frequency-resolved coherent structures)

Advanced Capabilities

  • OTD modes — real-time Lyapunov vectors for chaotic flows
  • Linearized DNS — perturbation evolution around base flows
  • Scalar transport — temperature and passive scalar stability
  • Sponge zones — non-reflecting boundaries for open flows
  • Vortex identification — λ₂, Q-criterion, Ω-criterion output
  • FFT module — FFTW3/MKL integration for spectral analysis with Nek5000

Why nekStab?

  • Matrix-free: No Jacobian storage — scales to millions of DoFs
  • Krylov-based: Time-stepper as linear operator — eigenvalues from snapshots
  • Spectral accuracy: Leverages Nek5000's high-order elements
  • MPI parallel: Efficient on laptops to supercomputers
  • Validated: Automated test suite covering 9 solver modes across 4 geometries (cylinder, backstep, flip-flop, jet)
  • FFT included: Smart linking to FFTW3 (GCC) or MKL (Intel) — no manual setup

Quick Reference

Mode String Aliases Description
0 'dns' Direct Numerical Simulation
0.1 'linear_dns' 'lindns' Linearized DNS (perturbation)
1.1 'sfd' Selective Frequency Damping
1.2 'boostconv' 'boost' BoostConv acceleration
1.4 'tdf' Time-Delayed Feedback
2 'newton_fp' 'newton' Newton for fixed points
2.1 'newton_po' 'upo' Newton for periodic orbits (unknown period)
2.2 'newton_po_t' 'forced_upo' Newton for periodic orbits (forced period)
3.1 'direct' Direct stability eigenmodes
3.11 'floquet_direct' Floquet direct analysis
3.2 'adjoint' Adjoint stability eigenmodes
3.21 'floquet_adjoint' Floquet adjoint analysis
3.3 'transient_growth' 'tg' Optimal perturbations
3.31 'floquet_tg' Floquet transient growth
4.1 'energy_budget' Kinetic energy budget
4.11 'energy_budget_floquet' Floquet energy budget
4.2 'wavemaker' Structural sensitivity
4.3 'bf_sensitivity' Base flow sensitivity
4.41 'force_sensitivity_real' Steady force sensitivity (real)
4.42 'force_sensitivity_imag' Steady force sensitivity (imag)
4.43 'delta_forcing' Delta forcing response
4.5 'animate_mode' 'animate' Mode animation
4.51 'animate_bf_deform' Base flow deformation animation
4.52 'animate_floquet' Floquet mode animation
5 'otd' Optimally Time-Dependent modes
6.1 'pod' Proper Orthogonal Decomposition
6.2 'dmd' Dynamic Mode Decomposition
6.3 'spod' Spectral POD

See DOC.md for full parameter reference.

Examples

Ready-to-run cases in example/:

Case Physics Demonstrated Features
cylinder/ 2D wake (Re=50–180) DNS, SFD, BoostConv, Newton, direct/adjoint stability, Floquet, wavemaker, sensitivity, OTD, POD/DMD/SPOD
back_fstep/ Separated flow (Re=500) Newton baseflow, transient growth
flip_flop/ Side-by-side cylinders (Re=62) Newton UPO (natural frequency), Floquet
tpjet/ Forced jet (Re=1900) Newton UPO (forced frequency), TDF, Floquet period-doubling
thermosyphon/ Buoyancy-driven (Ra=500) Newton baseflow, pitchfork + Hopf bifurcations
lid_driven/ Confined flow (Re=3600) Newton, steady bifurcations
cubic_cavity/ 3D cavity (Re=1950–2500) Newton, 3D steady bifurcations, UPO
naca0012/ Airfoil (Re=2000–2500) Newton, direct stability
blasius/ Flat-plate boundary layer Tollmien-Schlichting waves
torus/ Curved pipe Dean instability, 3D modes
poiseuille_OTD/ Channel flow (Re=5000) OTD modes
slot_FST/ Slot jet Free-stream turbulence synthesis

First Steps

Prerequisites

Linux (GCC)

sudo apt -y install build-essential gfortran libmpich-dev libopenblas-dev libfftw3-dev cmake m4 htop

macOS

brew install mpich gfortran fftw wget git cmake htop

Installation

git clone --depth=1 https://github.com/nekStab/nekStab.git
cd nekStab
./Nek5000setup.sh
Command What it does
git clone --depth=1 ... Downloads only the latest version (fastest, minimal download)
cd nekStab Enter the nekStab directory
./Nek5000setup.sh Downloads and configures Nek5000 inside nekStab/Nek5000/

Already have Nek5000? Skip ./Nek5000setup.sh and point NEK_SOURCE_ROOT to your existing installation (see below).

Add to your shell config (~/.bashrc or ~/.zshrc):

# nekStab path
export NEKSTAB_SOURCE_ROOT=$HOME/nekStab
export PATH=$NEKSTAB_SOURCE_ROOT/bin:$PATH

# Nek5000 path (adjust if using existing installation)
export NEK_SOURCE_ROOT=$NEKSTAB_SOURCE_ROOT/Nek5000  # ← or your existing path
export PATH=$NEK_SOURCE_ROOT/bin:$PATH

# Stack/core limits for large simulations
ulimit -s unlimited
ulimit -c unlimited
Variable / Setting Purpose
NEKSTAB_SOURCE_ROOT Location of nekStab source (build scripts reference this)
NEK_SOURCE_ROOT Location of Nek5000 (required by Nek5000 build system)
PATH additions Makes mks, nekbmpi, genmap, etc. available anywhere
ulimit -s unlimited Removes stack size limit — prevents crashes in large runs
ulimit -c unlimited Enables core dumps for debugging crashes

Then reload: source ~/.bashrc (or restart terminal).

Shell completion

Enable tab completion for case names and common mks targets/options:

source "$NEKSTAB_SOURCE_ROOT/bin/mks-completion.bash"

For zsh, load Bash completion first:

autoload -Uz bashcompinit && bashcompinit
source "$NEKSTAB_SOURCE_ROOT/bin/mks-completion.bash"

Compilation

Go to a given example folder and compile the code:

cd ~/nekStab/example/cylinder/baseflow/newton
mks 1cyl

Compiler Selection

nekStab supports multiple Fortran compilers. The build script auto-detects available compilers in this order: ifxifortgfortran. To force a specific compiler:

NEKSTAB_FC=ifx mks 1cyl    # Intel LLVM (recommended for Intel/AMD CPUs)
NEKSTAB_FC=ifort mks 1cyl  # Intel Classic (available on many HPC systems)
NEKSTAB_FC=gcc mks 1cyl    # GCC/gfortran

Performance Considerations

Compiler Performance Notes
ifx (Intel LLVM) Fastest Requires Intel oneAPI 2024+, uses MKL
ifort (Intel Classic) Fast Available on HPC systems, discontinued in oneAPI 2025
gfortran (GCC) Good Universal, uses system BLAS/LAPACK

Note: Intel discontinued ifort in oneAPI 2025, but it remains available on many HPC systems. New installations should use ifx.

The Intel compilers use MKL (Math Kernel Library) which provides highly optimized BLAS/LAPACK routines with runtime CPU dispatching.

Debug Mode

For debugging crashes or numerical issues:

mks 1cyl --debug
What it enables Why it helps
Debug symbols (-g) Use gdb to inspect variables and step through code
Stack traces (-fbacktrace) See exact file:line when a crash occurs
Compiler warnings (-Wall) Catch uninitialized variables, type mismatches

Tip: When a crash happens in debug mode, the output shows which subroutine and line number failed — much easier than hunting through a release build.

Running

After successful compilation:

nekbmpi 1cyl 4       # Run case "1cyl" on 4 MPI processes
tail -f logfile      # Monitor output in real-time
killall nek5000      # Stop the simulation
Command What it does
nekbmpi 1cyl 4 Launches nek5000 via mpirun with 4 processes (adjust to your CPU cores)
tail -f logfile Streams solver output — watch convergence, time steps, diagnostics
killall nek5000 Gracefully stops all running Nek5000 processes

Tip: Use nekbmpi 1cyl 4 & to run in background, then tail -f logfile in the same terminal.

For more information, see the Documentation.

Mode Selection

Three equivalent ways to select operating mode:

Method Where Example
String .usr nekstab_mode = 'floquet_adjoint'
Flags .usr isAdjoint = .true. + ifFloquet = .true.
uparam .par userParam01 = 3.21

Development

nekStab is maintained by Ricardo Frantz.

See also: LightKrylov is a modern Fortran library providing abstract Krylov methods. neklab is the next-generation bifurcation and stability analysis toolbox for Nek5000, built on LightKrylov. Both are actively developed by Jean-Christophe Loiseau and Simon Kern.

Website: https://nekstab.github.io/

Citation

When using nekStab, please cite Frantz et al. (2023). See CITATIONS.md for BibTeX entries and additional references.