NS2D is a simple pseudo-spectral solver for the two-dimensional Navier-Stokes equations in a doubly periodic domain written in Julia. Its aim is primarily to get myself familiar with the Julia ecosystem for scientific computing as well as illustrating how pseudo-spectral solvers work for my students. If you nonetheless think that such a simple solver written in Julia could be beneficial for your research, please do not hesitate to use it, fork it and/or send pull requests !
Method / Capabilities
NS2D solves the two-dimensional Navier-Stokes equations in a doubly-periodic domain using the vorticity-streamfunction formulation. Most of the computation is performed in spectral space while the non-linear advection term is computed in physical space using standard techniques for dealiasing. At its core, NS2D uses FFTW.jl with multi-threading and preallocated arrays for in-place fast Fourier transforms while time-integration is performed thanks to DifferentialEquations.jl.
Below is a list of canonical examples that can be simulate using NS2D.
In two dimensions, the Taylor-Green vortices are one of the few analytic solutions to the incompressible Navier-Stokes we know of. It is quite often used for testing and validation of the spatial and/or temporal accuracy of Navier-Stokes solvers. The figure below shows the initial vorticity field (top panel) and the maximum pointwise error over time between the analytic solution and the one simulated using NS2D (bottom panel).
These results have been obtained with :
- Number of grid points per direction
- Fifth order accurate time-stepping with variable time step using
- Absolute and relative tolerances set to
abstol = 1e-8and
Two-dimensional decaying isotropic turbulence
Two-dimensional Kolmogorov flow
As stated, NS2D is primary a sandbox for me to get familiar with the Julia ecosystem and test some ideas. Below is a non-exhaustive lists of such ideas. If you are interested in any of them, please do not hesitate to get in touch !
- Deterministic and stochastic forcing for forced turbulence,
- Parallel computing,
- GPU acceleration with
- Automatic differentiation with
JuliaDifffor optimization and machine-learning,