Skip to content

Decaying Homogeneous Isotropic Turbulence - 2D ​

In this example we consider decaying homogeneous isotropic turbulence, similar to the cases considered in [ DocumenterCitations.CitationSiteNode("Kochkov2021-cite-1")

] and [ DocumenterCitations.CitationSiteNode("Kurz2022-cite-1")

]. The initial velocity field is created randomly, but with a specific energy spectrum. Due to viscous dissipation, the turbulent features eventually group to form larger visible eddies.

Packages ​

We just need IncompressibleNavierStokes and a Makie plotting backend.

julia
using CairoMakie
using IncompressibleNavierStokes
# using CUDA

Setup

julia
n = 256
ax = LinRange(0.0, 1.0, n + 1)
setup = Setup(;
    x = (ax, ax),
    boundary_conditions = (;
        u = ((PeriodicBC(), PeriodicBC()), (PeriodicBC(), PeriodicBC())),
    ),
    # backend = CUDABackend(),
)
u = random_field(setup, 0.0);

Solve unsteady problem

julia
state, outputs = solve_unsteady(;
    setup,
    start = (; u),
    tlims = (0.0, 1.0),
    params = (; viscosity = 2.5e-4),
    processors = (
        rtp = realtimeplotter(; setup, nupdate = 10),
        ehist = realtimeplotter(;
            setup,
            plot = energy_history_plot,
            nupdate = 10,
            displayfig = false,
        ),
        espec = realtimeplotter(;
            setup,
            plot = energy_spectrum_plot,
            nupdate = 10,
            displayfig = false,
        ),
        log = timelogger(; nupdate = 100),
    ),
);
[ Info: t = 0.0861076	Δt = 0.00085	umax = 4.2	itertime = 0.032
[ Info: t = 0.172553	Δt = 0.0011	umax = 3.3	itertime = 0.0094
[ Info: t = 0.269483	Δt = 0.0014	umax = 2.6	itertime = 0.0091
[ Info: t = 0.396337	Δt = 0.0013	umax = 2.8	itertime = 0.0093
[ Info: t = 0.530083	Δt = 0.0014	umax = 2.6	itertime = 0.0091
[ Info: t = 0.661595	Δt = 0.0013	umax = 2.8	itertime = 0.0095
[ Info: t = 0.796814	Δt = 0.0013	umax = 2.7	itertime = 0.0091
[ Info: t = 0.933633	Δt = 0.0014	umax = 2.5	itertime = 0.0092
[ Info: Finished after 844 time steps and 10 seconds

Post-process ​

We may visualize or export the computed fields

Energy history

julia
outputs.ehist

Energy spectrum

julia
outputs.espec

Plot field

julia
fieldplot(state; setup)

Copy-pasteable code

Below is the full code for this example stripped of comments and output.

julia
using WGLMakie
using IncompressibleNavierStokes
# using CUDA

n = 256
ax = LinRange(0.0, 1.0, n + 1)
setup = Setup(;
    x = (ax, ax),
    boundary_conditions = (;
        u = ((PeriodicBC(), PeriodicBC()), (PeriodicBC(), PeriodicBC())),
    ),
    # backend = CUDABackend(),
)
u = random_field(setup, 0.0);

state, outputs = solve_unsteady(;
    setup,
    start = (; u),
    tlims = (0.0, 1.0),
    params = (; viscosity = 2.5e-4),
    processors = (
        rtp = realtimeplotter(; setup, nupdate = 10),
        ehist = realtimeplotter(;
            setup,
            plot = energy_history_plot,
            nupdate = 10,
            displayfig = false,
        ),
        espec = realtimeplotter(;
            setup,
            plot = energy_spectrum_plot,
            nupdate = 10,
            displayfig = false,
        ),
        log = timelogger(; nupdate = 100),
    ),
);

outputs.ehist

outputs.espec

fieldplot(state; setup)

This page was generated using Literate.jl.