Skip to content

Decaying Homogeneous Isotropic Turbulence - 2D

In this example we consider decaying homogeneous isotropic turbulence, similar to the cases considered in [1] and [2]. 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

Setup

julia
n = 256
ax = LinRange(0.0, 1.0, n + 1)
setup = Setup(; x = (ax, ax), Re = 4e3);
ustart = random_field(setup, 0.0);

Solve unsteady problem

julia
state, outputs = solve_unsteady(;
    setup,
    ustart,
    tlims = (0.0, 1.0),
    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.0963263	Δt = 0.00091	umax = 3.8	itertime = 0.026
[ Info: t = 0.19863	Δt = 0.001	umax = 3.5	itertime = 0.015
[ Info: t = 0.302015	Δt = 0.0011	umax = 3.2	itertime = 0.015
[ Info: t = 0.42522	Δt = 0.0011	umax = 3.2	itertime = 0.015
[ Info: t = 0.53339	Δt = 0.0012	umax = 2.9	itertime = 0.015
[ Info: t = 0.65228	Δt = 0.0012	umax = 3	itertime = 0.015
[ Info: t = 0.767166	Δt = 0.0011	umax = 3.1	itertime = 0.015
[ Info: t = 0.876002	Δt = 0.001	umax = 3.4	itertime = 0.015
[ Info: t = 0.99724	Δt = 0.0013	umax = 2.7	itertime = 0.015

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 GLMakie
using IncompressibleNavierStokes

n = 256
ax = LinRange(0.0, 1.0, n + 1)
setup = Setup(; x = (ax, ax), Re = 4e3);
ustart = random_field(setup, 0.0);

state, outputs = solve_unsteady(;
    setup,
    ustart,
    tlims = (0.0, 1.0),
    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.