Rayleigh-Bénard convection of an isoviscous Stokes fluid#
from lucifex.sim import run
from lucifex.utils import as_indices
from lucifex.solver import maximum
from lucifex.viz import plot_colormap, plot_line, create_animation, save_figure, display_animation
from py.C02_stokes_convection import stokes_rayleigh_benard_rectangle
simulation = stokes_rayleigh_benard_rectangle(
aspect=2.0,
Nx=64,
Ny=64,
cell='quadrilateral',
scaling='diffusive',
Ra=5e4,
c_ampl=1e-3,
c_freq=(16, 8),
dt_max=0.1,
)
n_stop = 200
dt_init = 1e-6
n_init = 10
run(simulation, n_stop=n_stop, dt_init=dt_init, n_init=n_init)
c, u, p, up = simulation['c', 'u', 'p', 'up']
time_slice = slice(0, None, 2)
titles = [f'$c(t={t:.3f})$' for t in c.time_series[time_slice]]
anim = create_animation(
plot_colormap,
colorbar=False,
)(c.series[time_slice], title=titles)
anim_path = save_figure(f'{c.name}(x,y,t)', get_path=True)(anim)
display_animation(anim_path)
time_indices = as_indices(c.time_series, (0, 0.25, 0.5, 0.75, -1), fraction=True)
for i in time_indices:
t = c.time_series[i]
fig, ax = plot_colormap(c.series[i], title=f'$c(t={t:.2f})$')
save_figure(f'c(x,y,t={c.time_series[i]:.3f})', thumbnail=(i == -1))(fig)
u_max = [maximum(i) for i in u.series]
fig, ax = plot_line((u.time_series, u_max), x_label='$t$', y_label='$\max_{\mathbf{x}}|\mathbf{u}|$')
save_figure(f'uMax(t)')(fig)
The Kernel crashed while executing code in the current cell or a previous cell.
Please review the code in the cell(s) to identify a possible cause of the failure.
Click <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info.
View Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details.