A two-dimensional turbulence example

using Oceananigans
using TurbulentWords
using CairoMakie

We construct a simulation with a word and run it.

simulation = word_to_simulation("hello", pad_to_square=true)
simulation.stop_time = 15

model = simulation.model
u, v, w = model.velocities
outputs = (; ζ = ∂x(v) - ∂y(u))
filename = "hello_turbulence"
simulation.output_writers[:fields] = JLD2OutputWriter(model, outputs,
                                                      schedule = TimeInterval(0.2),
                                                      filename = filename * ".jld2",
                                                      overwrite_existing = true)

run!(simulation)
[ Info: Initializing simulation...
[ Info: Iteration: 0, time: 0.0, wall time: 13.771 seconds, Δt: 0.011000000000000001
[ Info:     ... simulation initialization complete (6.672 seconds)
[ Info: Executing initial time step...
[ Info:     ... initial time step complete (3.975 seconds).
[ Info: Iteration: 10, time: 0.11549999999999999, wall time: 20.633 seconds, Δt: 0.013310000000000002
[ Info: Iteration: 20, time: 0.24392300000000006, wall time: 14.777 seconds, Δt: 0.016105100000000004
[ Info: Iteration: 30, time: 0.4, wall time: 14.784 seconds, Δt: 0.019487171000000008
[ Info: Iteration: 40, time: 0.6000000000000001, wall time: 14.791 seconds, Δt: 0.023579476910000015
[ Info: Iteration: 50, time: 0.8259374246010001, wall time: 14.771 seconds, Δt: 0.02853116706110002
[ Info: Iteration: 60, time: 1.09415285130163, wall time: 14.740 seconds, Δt: 0.03452271214393103
[ Info: Iteration: 70, time: 1.4, wall time: 14.795 seconds, Δt: 0.04177248169415655
[ Info: Iteration: 80, time: 1.7999999999999998, wall time: 14.810 seconds, Δt: 0.04578645511522573
[ Info: Iteration: 90, time: 2.1999999999999997, wall time: 14.886 seconds, Δt: 0.04614620438982234
[ Info: Iteration: 100, time: 2.6, wall time: 14.722 seconds, Δt: 0.0461768398147992
[ Info: Iteration: 110, time: 3.0, wall time: 14.758 seconds, Δt: 0.04619209571899519
[ Info: Iteration: 120, time: 3.384846365755983, wall time: 14.770 seconds, Δt: 0.04625382621754567
[ Info: Iteration: 130, time: 3.7853689447219203, wall time: 14.794 seconds, Δt: 0.04647281064500211
[ Info: Iteration: 140, time: 4.186489284167951, wall time: 14.795 seconds, Δt: 0.046782548838778526
[ Info: Iteration: 150, time: 4.587900925013523, wall time: 14.807 seconds, Δt: 0.04722227572537058
[ Info: Iteration: 160, time: 4.9899693853252565, wall time: 14.751 seconds, Δt: 0.04777085601654993
[ Info: Iteration: 170, time: 5.392291991239807, wall time: 14.801 seconds, Δt: 0.048383302433095285
[ Info: Iteration: 180, time: 5.7457902496109785, wall time: 14.821 seconds, Δt: 0.04891921681599315
[ Info: Iteration: 190, time: 6.147845335531923, wall time: 14.754 seconds, Δt: 0.04965966939989189
[ Info: Iteration: 200, time: 6.550062125938046, wall time: 14.762 seconds, Δt: 0.050320594537049984
[ Info: Iteration: 210, time: 7.000000000000002, wall time: 14.751 seconds, Δt: 0.05057170466201736
[ Info: Iteration: 220, time: 7.450652863432308, wall time: 14.741 seconds, Δt: 0.05068934964879336
[ Info: Iteration: 230, time: 7.952602939149602, wall time: 14.749 seconds, Δt: 0.05089316369910018
[ Info: Iteration: 240, time: 8.450723674115485, wall time: 14.842 seconds, Δt: 0.0506984591009412
[ Info: Iteration: 250, time: 8.901521673570038, wall time: 14.754 seconds, Δt: 0.05068007452492321
[ Info: Iteration: 260, time: 9.399999999999999, wall time: 14.816 seconds, Δt: 0.050616742647250794
[ Info: Iteration: 270, time: 9.901306183839239, wall time: 14.790 seconds, Δt: 0.050401797946653
[ Info: Iteration: 280, time: 10.399999999999995, wall time: 14.808 seconds, Δt: 0.05003796428987859
[ Info: Iteration: 290, time: 10.84916999982335, wall time: 14.770 seconds, Δt: 0.04851539664001553
[ Info: Iteration: 300, time: 11.199999999999992, wall time: 14.736 seconds, Δt: 0.04764958110559436
[ Info: Iteration: 310, time: 11.59999999999999, wall time: 14.710 seconds, Δt: 0.046909594146251225
[ Info: Iteration: 320, time: 11.99999999999999, wall time: 14.763 seconds, Δt: 0.046472695696999494
[ Info: Iteration: 330, time: 12.399999999999988, wall time: 14.763 seconds, Δt: 0.04643406600884463
[ Info: Iteration: 340, time: 12.799999999999986, wall time: 14.724 seconds, Δt: 0.046492064214662086
[ Info: Iteration: 350, time: 13.199999999999985, wall time: 14.706 seconds, Δt: 0.046815091391884556
[ Info: Iteration: 360, time: 13.599999999999984, wall time: 14.727 seconds, Δt: 0.04722025857220661
[ Info: Iteration: 370, time: 13.999999999999984, wall time: 14.748 seconds, Δt: 0.047591075024664725
[ Info: Iteration: 380, time: 14.390625588159171, wall time: 14.752 seconds, Δt: 0.04759687226435427
[ Info: Iteration: 390, time: 14.790332624121223, wall time: 14.719 seconds, Δt: 0.047547682273745506
[ Info: Simulation is stopping after running for 9.902 minutes.
[ Info: Simulation time 15 seconds equals or exceeds stop time 15 seconds.

Now we load the saved output

ζt = FieldTimeSeries(filename * ".jld2", "ζ")
times = ζt.times
77-element Vector{Float64}:
  0.0
  0.20000000000000004
  0.4
  0.6000000000000001
  0.8
  1.0
  1.2
  1.4
  1.5999999999999999
  1.7999999999999998
  1.9999999999999998
  2.1999999999999997
  2.4
  2.6
  2.8000000000000003
  3.0000000000000004
  3.2000000000000006
  3.400000000000001
  3.6000000000000014
  3.8000000000000003
  4.0
  4.2
  4.4
  4.6000000000000005
  4.800000000000001
  5.000000000000001
  5.200000000000001
  5.400000000000001
  5.600000000000001
  5.800000000000002
  6.000000000000002
  6.200000000000002
  6.400000000000002
  6.600000000000002
  6.8000000000000025
  7.000000000000003
  7.200000000000003
  7.400000000000003
  7.600000000000003
  7.800000000000003
  8.000000000000004
  8.200000000000003
  8.400000000000002
  8.600000000000001
  8.8
  9.0
  9.2
  9.399999999999999
  9.599999999999998
  9.799999999999997
  9.999999999999996
 10.199999999999996
 10.399999999999995
 10.599999999999994
 10.799999999999994
 10.999999999999993
 11.199999999999992
 11.399999999999991
 11.59999999999999
 11.79999999999999
 11.99999999999999
 12.199999999999989
 12.399999999999988
 12.599999999999987
 12.799999999999986
 12.999999999999986
 13.199999999999985
 13.399999999999984
 13.599999999999984
 13.799999999999983
 13.999999999999984
 14.0
 14.2
 14.399999999999999
 14.599999999999998
 14.799999999999997
 14.999999999999996

and make a movie

fig = Figure(size = (600, 600))
ax = Axis(fig[1, 1])
hidedecorations!(ax)
hidespines!(ax)

n = Observable(1)

ζₙ = @lift interior(ζt[$n], :, :, 1)

ζmax = 0.8
heatmap!(ax, ζₙ; colormap = :balance, colorrange = (-ζmax, ζmax))

stillframes = 20
framerate = 32
movingframes = length(times)

record(fig, filename * ".mp4"; framerate) do io
    [recordframe!(io) for _ = 1:stillframes]

    for nn in 1:movingframes
        n[] = nn
        recordframe!(io)
    end

    for nn in movingframes:-1:1
        n[] = nn
        recordframe!(io)
    end

    [recordframe!(io) for _ = 1:stillframes]
end
"hello_turbulence.mp4"


This page was generated using Literate.jl.