@@ -145,7 +145,7 @@ model = NonhydrostaticModel(; grid,
145145 buoyancy = BuoyancyTracer (),
146146 tracers = :b )
147147
148- # We have included a "pinch" of viscosity and diffusivity in anticipation of what will follow furtherdown :
148+ # We have included a "pinch" of viscosity and diffusivity in anticipation of what will follow further down :
149149# viscosity and diffusivity will ensure numerical stability when we evolve the unstable mode to the point
150150# it becomes nonlinear.
151151
@@ -251,7 +251,7 @@ function estimate_growth_rate(simulation, energy, ω, b; convergence_criterion=1
251251 σ = []
252252 power_method_data = []
253253 compute! (ω)
254- push! (power_method_data, (ω= collect ( interior (ω, :, 1 , :)) , b= collect ( interior (b, :, 1 , :) ), σ= deepcopy (σ)))
254+ push! (power_method_data, (ω= deepcopy (ω) , b= deepcopy (b ), σ= deepcopy (σ)))
255255
256256 while convergence (σ) > convergence_criterion
257257 compute! (energy)
@@ -265,7 +265,7 @@ function estimate_growth_rate(simulation, energy, ω, b; convergence_criterion=1
265265
266266 compute! (ω)
267267 rescale! (simulation. model, energy)
268- push! (power_method_data, (ω= collect ( interior (ω, :, 1 , :)) , b= collect ( interior (b, :, 1 , :) ), σ= deepcopy (σ)))
268+ push! (power_method_data, (ω= deepcopy (ω) , b= deepcopy (b ), σ= deepcopy (σ)))
269269 end
270270
271271 return σ, power_method_data
@@ -281,9 +281,6 @@ b = model.tracers.b
281281
282282perturbation_vorticity = Field (∂z (u) - ∂x (w))
283283
284- xω, yω, zω = nodes (perturbation_vorticity)
285- xb, yb, zb = nodes (b)
286-
287284# # Rev your engines...
288285#
289286# We initialize the power iteration with random noise and rescale to have a `target_kinetic_energy`
@@ -307,7 +304,7 @@ n = Observable(1)
307304
308305fig = Figure (size= (800 , 600 ))
309306
310- kwargs = (xlabel= " x" , ylabel= " z" , limits = ((xω[ 1 ], xω[ end ] ), (zω[ 1 ], zω[ end ] )), aspect= 1 , )
307+ kwargs = (xlabel= " x" , ylabel= " z" , limits = ((- 5 , 5 ), (- 5 , 5 )), aspect= 1 )
311308
312309ω_title (t) = t === nothing ? @sprintf (" vorticity" ) : @sprintf (" vorticity at t = %.2f" , t)
313310b_title (t) = t === nothing ? @sprintf (" buoyancy" ) : @sprintf (" buoyancy at t = %.2f" , t)
@@ -321,13 +318,13 @@ bₙ = @lift power_method_data[$n].b
321318
322319σₙ = @lift [(i- 1 , i== 1 ? NaN : growth_rates[i- 1 ]) for i in 1 : $ n]
323320
324- ω_lims = @lift (- maximum (abs, power_method_data[$ n]. ω) - 1e-16 , maximum (abs, power_method_data[$ n]. ω) + 1e-16 )
325- b_lims = @lift (- maximum (abs, power_method_data[$ n]. b) - 1e-16 , maximum (abs, power_method_data[$ n]. b) + 1e-16 )
321+ ω_lims = @lift (- maximum (abs, power_method_data[$ n]. ω), maximum (abs, power_method_data[$ n]. ω))
322+ b_lims = @lift (- maximum (abs, power_method_data[$ n]. b), maximum (abs, power_method_data[$ n]. b))
326323
327- hm_ω = heatmap! (ax_ω, xω, zω, ωₙ; colorrange = ω_lims, colormap = :balance )
324+ hm_ω = heatmap! (ax_ω, ωₙ; colorrange = ω_lims, colormap = :balance )
328325Colorbar (fig[2 , 2 ], hm_ω)
329326
330- hm_b = heatmap! (ax_b, xb, zb, bₙ; colorrange = b_lims, colormap = :balance )
327+ hm_b = heatmap! (ax_b, bₙ; colorrange = b_lims, colormap = :balance )
331328Colorbar (fig[2 , 4 ], hm_b)
332329
333330eigentitle (σ, t) = length (σ) > 0 ? @sprintf (" Iteration #%i; growth rate %.2e" , length (σ), σ[end ]) : @sprintf (" Initial perturbation fields" )
@@ -345,7 +342,7 @@ scatter!(ax_σ, σₙ; color = :blue)
345342frames = 1 : length (power_method_data)
346343
347344record (fig, " powermethod.mp4" , frames, framerate= 1 ) do i
348- n[] = i
345+ n[] = i
349346end
350347
351348nothing # hide
@@ -410,12 +407,12 @@ t_final = times[end]
410407
411408n = Observable (1 )
412409
413- ωₙ = @lift interior ( ω_timeseries, :, 1 , :, $ n)
414- bₙ = @lift interior ( b_timeseries, :, 1 , :, $ n)
410+ ωₙ = @lift ω_timeseries[ $ n]
411+ bₙ = @lift b_timeseries[ $ n]
415412
416413fig = Figure (size= (800 , 600 ))
417414
418- kwargs = (xlabel= " x" , ylabel= " z" , limits = ((xω[ 1 ], xω[ end ] ), (zω[ 1 ], zω[ end ] )), aspect= 1 , )
415+ kwargs = (xlabel= " x" , ylabel= " z" , limits = ((- 5 , 5 ), (- 5 , 5 )), aspect= 1 )
419416
420417title = @lift @sprintf (" t = %.2f" , times[$ n])
421418
@@ -430,13 +427,13 @@ ax_KE = Axis(fig[3, :];
430427
431428fig[1 , :] = Label (fig, title, fontsize= 24 , tellwidth= false )
432429
433- ω_lims = @lift (- maximum (abs, interior ( ω_timeseries, :, 1 , :, $ n)) - 1e-16 , maximum (abs, interior ( ω_timeseries, :, 1 , :, $ n)) + 1e-16 )
434- b_lims = @lift (- maximum (abs, interior ( b_timeseries, :, 1 , :, $ n)) - 1e-16 , maximum (abs, interior ( b_timeseries, :, 1 , :, $ n)) + 1e-16 )
430+ ω_lims = @lift (- maximum (abs, ω_timeseries[ $ n]) , maximum (abs, ω_timeseries[ $ n]) )
431+ b_lims = @lift (- maximum (abs, b_timeseries[ $ n]) , maximum (abs, b_timeseries[ $ n]) )
435432
436- hm_ω = heatmap! (ax_ω, xω, zω, ωₙ; colorrange = ω_lims, colormap = :balance )
433+ hm_ω = heatmap! (ax_ω, ωₙ; colorrange = ω_lims, colormap = :balance )
437434Colorbar (fig[2 , 2 ], hm_ω)
438435
439- hm_b = heatmap! (ax_b, xb, zb, bₙ; colorrange = b_lims, colormap = :balance )
436+ hm_b = heatmap! (ax_b, bₙ; colorrange = b_lims, colormap = :balance )
440437Colorbar (fig[2 , 4 ], hm_b)
441438
442439tₙ = @lift times[1 : $ n]
@@ -469,12 +466,12 @@ nothing #hide
469466# And then the same for total vorticity & buoyancy of the fluid.
470467n = Observable (1 )
471468
472- Ωₙ = @lift interior ( Ω_timeseries, :, 1 , :, $ n)
473- Bₙ = @lift interior ( B_timeseries, :, 1 , :, $ n)
469+ Ωₙ = @lift Ω_timeseries[ $ n]
470+ Bₙ = @lift B_timeseries[ $ n]
474471
475472fig = Figure (size= (800 , 600 ))
476473
477- kwargs = (xlabel= " x" , ylabel= " z" , limits = ((xω[ 1 ], xω[ end ] ), (zω[ 1 ], zω[ end ] )), aspect= 1 , )
474+ kwargs = (xlabel= " x" , ylabel= " z" , limits = ((- 5 , 5 ), (- 5 , 5 )), aspect= 1 )
478475
479476title = @lift @sprintf (" t = %.2f" , times[$ n])
480477
@@ -489,10 +486,10 @@ ax_KE = Axis(fig[3, :];
489486
490487fig[1 , :] = Label (fig, title, fontsize= 24 , tellwidth= false )
491488
492- hm_Ω = heatmap! (ax_Ω, xω, zω, Ωₙ; colorrange = (- 1 , 1 ), colormap = :balance )
489+ hm_Ω = heatmap! (ax_Ω, Ωₙ; colorrange = (- 1 , 1 ), colormap = :balance )
493490Colorbar (fig[2 , 2 ], hm_Ω)
494491
495- hm_B = heatmap! (ax_B, xb, zb, Bₙ; colorrange = (- 0.05 , 0.05 ), colormap = :balance )
492+ hm_B = heatmap! (ax_B, Bₙ; colorrange = (- 0.05 , 0.05 ), colormap = :balance )
496493Colorbar (fig[2 , 4 ], hm_B)
497494
498495tₙ = @lift times[1 : $ n]
0 commit comments