SkillAgentSearch skills...

IncompressibleNavierStokes.jl

Incompressible Navier-Stokes solver

Install / Use

/learn @agdestein/IncompressibleNavierStokes.jl
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Logo Logo

IncompressibleNavierStokes

Stable Dev Build Status Coverage Aqua QA DOI Downloads Downloads

This package implements energy-conserving solvers for the incompressible Navier-Stokes equations on a staggered Cartesian grid. It is based on the Matlab package INS2D/INS3D. The simulations can be run on the single/multithreaded CPUs or Nvidia GPUs.

Installation

To install IncompressibleNavierStokes, open up a Julia-REPL, type ] to get into Pkg-mode, and type:

(v1.10) pkg> add IncompressibleNavierStokes

which will install the package and all dependencies to your local environment. Note that IncompressibleNavierStokes requires Julia version 1.9 or above.

See the Documentation for examples of some typical workflows. More examples can be found in the examples directory.

Source code for paper

See this repository for the source code used in the paper Discretize first, filter next: learning divergence-consistent closure models for large-eddy simulation.

Gallery

The velocity and pressure fields may be visualized in a live session using Makie. Alternatively, ParaView may be used, after exporting individual snapshot files using the save_vtk function, or the full time series using the VTKWriter processor.

<table> <tbody> <tr> <td style="width: 25%;"><img src="docs/src/public/Actuator2D.gif"></td> <td style="width: 25%;"><img src="docs/src/public/BackwardFacingStep2D.png"></td> <td style="width: 25%;"><img src="docs/src/public/DecayingTurbulence2D.gif"></td> <td style="width: 25%;"><img src="docs/src/public/TaylorGreenVortex2D.png"></td> </tr> <tr> <td align="center"><a href="examples/Actuator2D.jl">Actuator (2D)</a></td> <td align="center"><a href="examples/BackwardFacingStep2D.jl">Backward facing step (2D)</a></td> <td align="center"><a href="examples/DecayingTurbulence2D.jl">Decaying turbulence (2D)</a></td> <td align="center"><a href="examples/TaylorGreenVortex2D.jl">Taylor-Green vortex (2D)</a></td> </tr> <tr> <td style="width: 25%;"><img src="docs/src/public/Actuator3D.png"></td> <td style="width: 25%;"><img src="docs/src/public/BackwardFacingStep3D.png"></td> <td style="width: 25%;"><img src="docs/src/public/DecayingTurbulence3D.png"></td> <td style="width: 25%;"><img src="docs/src/public/TaylorGreenVortex3D.png"></td> </tr> <tr> <td align="center"><a href="examples/Actuator3D.jl">Actuator (3D)</a></td> <td align="center"><a href="examples/BackwardFacingStep3D.jl">Backward facing step (3D)</a></td> <td align="center"><a href="examples/DecayingTurbulence3D.jl">Decaying turbulence (3D)</a></td> <td align="center"><a href="examples/TaylorGreenVortex3D.jl"> Taylor-Green vortex (3D)</a></td> </tr> <tr> <td style="width: 25%;"><img src="docs/src/public/RayleighBenard2D.gif"></td> <td style="width: 25%;"><img src="docs/src/public/RayleighBenard3D.gif"></td> <td style="width: 25%;"><img src="docs/src/public/RayleighTaylor2D.gif"></td> <td style="width: 25%;">

ChannelFlow3D

</td> </tr> <tr> <td align="center"><a href="examples/RayleighBenard2D.jl">Rayleigh-Bénard (2D)</a></td> <td align="center"><a href="examples/RayleighBenard3D.jl">Rayleigh-Bénard (3D)</a></td> <td align="center"><a href="examples/RayleighTaylor2D.jl">Rayleigh-Taylor (2D)</a></td> <td align="center"><a href="examples/ChannelFlow3D.jl">Turbulent channel flow (3D)</a></td> </tr> </tbody> </table>

Demo

Make sure to have the GLMakie and IncompressibleNavierStokes installed:

using Pkg
Pkg.add(["GLMakie", "IncompressibleNavierStokes"])

Then run run the following code to make a short animation:

using GLMakie
using IncompressibleNavierStokes

# Setup
setup = Setup(
    x = (
        tanh_grid(0.0, 2.0, 200, 1.2),
        tanh_grid(0.0, 1.0, 100, 1.2),
    ),
    boundary_conditions = (
        u = (
            (DirichletBC(), DirichletBC()),
            (DirichletBC(), DirichletBC()),
        ),
        temp = (
            (SymmetricBC(), SymmetricBC()),
            (DirichletBC(1.0), DirichletBC(0.0)),
        ),
    ),
)

# Physical parameters
params = (
    viscosity = 3e-4,
    conductivity = 2e-4,
    gravity = 1.0,
    gdir = 2, # Gravity in the y-direction
    dodissipation = true,
)

# Solve equation
solve_unsteady(;
    force! = boussinesq!,
    setup,
    start = (
        u = velocityfield(setup, (dim, x, y) -> zero(x)),
        temp = temperaturefield(setup, (x, y) -> 1 / 2 + sinpi(30 * x) / 100),
    ),
    tlims = (0.0, 30.0),
    params,
    processors = (;
        anim = animator(;
            setup,
            path = "temperature.mp4",
            fieldname = :temperature,
            colorrange = (0.0, 1.0),
            size = (900, 500),
            colormap = :seaborn_icefire_gradient,
            nupdate = 5,
        ),
    ),
)

Similar projects

Related Skills

View on GitHub
GitHub Stars92
CategoryDevelopment
Updated7d ago
Forks18

Languages

Julia

Security Score

100/100

Audited on Mar 18, 2026

No findings