Rayleigh-Bénard convection of a non-isoviscous Stokes fluid

Rayleigh-Bénard convection of a non-isoviscous Stokes fluid#

\[\begin{split} \mathbb{S} \begin{cases} \Omega = [0, \mathcal{A}X] \times [0, X] & \text{aspect ratio } \mathcal{A}=\mathcal{O}(1)\\ \textbf{e}_g=-\textbf{e}_y & \text{vertically downward gravity}\\ c_0(x,y)=1-y+\mathcal{N}(x,y) & \text{perturbed diffusive base state} \\ c_{\text{D}}(x,y=0)=1 & \text{hot lower boundary} \\ c_{\text{D}}(x,y=1)=0 & \text{cold upper boundary} \\ c_{\text{N}}(x=0,y)=0 & \text{no-flux on left and right boundaries}\\ c_{\text{N}}(x=L_x,y)=0 \\ \textbf{u}_{\text{E}}\vert_{\partial\Omega}=\textbf{0} & \text{no-flow on entire boundary}\\ \mathsf{D} = \mathsf{I} & \text{constant isotropic dispersion} \\ \mu = \exp(-\Lambda c) & \text{exponential viscosity} \\ \rho(c) = -c & \text{linear density} \\ \tau(\textbf{u})=\tfrac{1}{2}(\nabla\textbf{u} + (\nabla\textbf{u})^{\mathsf{T}}) & \text{Newtonian stress} \\ \end{cases} \end{split}\]
import numpy as np
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,
    Lmbda=5.0,
    c_ampl=1e-3,
    c_freq=(16, 8),
    c_limits=True,
    dt_max=1e-3, 
    dt_courant=0.1,
)

n_stop = 500
dt_init = 1e-6
n_init = 10
run(simulation, n_stop=n_stop, dt_init=dt_init, n_init=n_init)

c, cCorr = simulation['c', 'cCorr']
u, p, up = simulation['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:.6f})$')
    save_figure(f'c(x,y,t={c.time_series[i]:.6f})', thumbnail=(i == -1))(fig)
../../_images/e84d32f325981373aea914b7d7be4015bffba737e28ee77e3880a7bc6c2a8bb4.png ../../_images/3cd39b8bf53f29ef9074169a5de346a49c2632d8655072333d7d62a5196d79dc.png ../../_images/772f238a528b9f1f8545c6dede596825d3cf996cbe2b13040c6be67b1f7df59f.png ../../_images/a060b844d9139fd172790822f22576a8830cbbb0652845c215a852a1c0214ad8.png ../../_images/03ab26bd5e58a390aef0470ad88f07f30ae22a24030c1106aef2a7b865943dbe.png
cCorrMmax = [np.max(np.abs(i)) for i in c.series]
lines = [
    (cCorr.time_series, [np.min(i) for i in cCorr.dofs_series]),
    (cCorr.time_series, [np.max(i) for i in cCorr.dofs_series]),
]
legend_labels=['$\min_{\mathbf{x}}|\mathcal{C}(c)|$', '$\max_{\mathbf{x}}|\mathcal{C}(c)|$']
fig, ax = plot_line(
    lines,
    legend_labels=legend_labels,
    x_label='$t$',
)
save_figure(f'cCorr(t)')(fig)

cMmax = [maximum(i) for i in c.series]
fig, ax = plot_line((c.time_series, cMmax), x_label='$t$', y_label='$\max_{\mathbf{x}}|\mathbf{u}|$')
save_figure(f'cMax(t)')(fig)
../../_images/fa6d404c06a4d9db140d3ccfea42d6e842f362a3378a92fc42c7d22023aa78ed.png ../../_images/8d2a762d8c30627f775229e9e6671498d07c101f2fcffb2743e57b0bd1444915.png
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.
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)
../../_images/86b0d2b3cf7394ff3250c2b2be06414cd8442ea23e0e620b0d53f0d3dfaf19b1.png