Rayleigh-Bénard convection of a Darcy fluid in a porous rectangle

Rayleigh-Bénard convection of a Darcy fluid in a porous rectangle#

\[\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}\\ \phi = 1 & \text{constant porosity} \\ \mathsf{D} = \mathsf{I} & \text{constant isotropic dispersion}\\ \mathsf{K} = \mathsf{I} & \text{constant isotropic permeability}\\ \mu = 1 & \text{constant viscosity} \\ \rho(c) = -c & \text{linear density}\\ 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 boundary}\\ c_{\text{N}}(x=L_x,y)=0 & \text{no-flux on right boundary}\\ \psi_{\text{D}}\vert_{\partial\Omega}=0 & \text{no-penetration on entire boundary} \end{cases} \end{split}\]
from lucifex.fdm import AB2, CN
from lucifex.sim import run
from lucifex.utils import grid, spacetime_grid, as_indices
from lucifex.viz import plot_colormap, plot_line, create_animation, save_figure, display_animation
from py.C01_darcy_rayleigh_benard import darcy_rayleigh_benard_rectangle

simulation = darcy_rayleigh_benard_rectangle(
    aspect=2.0,  
    Nx=64,
    Ny=64,
    cell='quadrilateral', 
    scaling='advective',
    Ra=500.0, 
    c_ampl=1e-3, 
    c_freq=(12, 8), 
    c_seed=(123, 456), 
    D_adv=AB2,
    D_diff=CN,
    diagnostic=True,
)

n_stop = 200
dt_init = 1e-6
n_init = 5
run(simulation, n_stop=n_stop, dt_init=dt_init, n_init=n_init)

c = simulation['c']
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)
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.
time_indices = as_indices(c.time_series, (0, 0.5, -1), fraction=True)
for i in time_indices:
    fig, ax = plot_colormap(c.series[i], title=f'$c(t={c.time_series[i]:.3f})$')
    save_figure(f'c(x,y,t={c.time_series[i]:.3f})', thumbnail=(i == -1))(fig)
../../_images/af34d476dae22f3af35c51bacffd172b839874f242328b9131cc3da098f30137.png ../../_images/31773b0cf1a93cd2443e1fd204bc2c037674c908efa7a83bc2a58419676f4b32.png ../../_images/dad9418e2b2c2354aa4e61cf009764432be2aefe51f2f90bdc932afd2ebb3ba7.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.
x, y = grid(c.mesh)

y_index = 8
y_value = y[y_index]
c_spacetime = spacetime_grid(c.series, 'y', y_value)

title = f'$c(y={y_value:.3f})$'
fig, ax = plot_colormap(
    (x, c.time_series, c_spacetime), 
    aspect='auto',
    x_label='$x$',
    y_label='$t$',
    title=title,
    colorbar=(0, 1),
)
save_figure(title.strip('$'))(fig)
../../_images/8321cc26bd5e9255efdceb779318008464ff47f750f67f6f468c237a0ab55825.png
uRMS, uMinMax = simulation['uRMS', 'uMinMax']
uMax = uMinMax.sub(1)

fig, ax = plot_line(
    (uRMS.time_series, uRMS.value_series),
    x_label='$t$',
    y_label='$\mathrm{rms}(\\textbf{u})$',
)
save_figure('uRMS(t)')(fig)

fig, ax = plot_line(
    (uMax.time_series, uMax.value_series),
    x_label='$t$',
    y_label='$\max_{\\textbf{x}}|\\textbf{u}|$',
)
save_figure('uMax(t)')(fig)
../../_images/e9d55d88e1891b70422cd4920b987e678587a93381c3cd29fdda607b40390625.png ../../_images/ea5123ab82a694729f58186e5432cd37bbc99dabece8e4d85a1385e15560cbd6.png
dt, dtCFL = simulation['dt', 'dtCFL']

fig, ax = plot_line(
    [(dt.time_series, dt.value_series), (dtCFL.time_series, dtCFL.value_series)],
    x_label='$t$',
    legend_labels=['$\Delta t$', '$\Delta t_{\mathbf{u}}$'],
)
ax.set_yscale('log')
save_figure('dt(t)')(fig)
../../_images/9fbb1eaf57abf2328c6c6f0576cf911bc03943e81424c118a25e705eaeae50b1.png
cMinMax = simulation['cMinMax']
cMin, cMax = cMinMax.split()

fig, ax = plot_line(
    (cMax.time_series, cMax.value_series),
    x_label='$t$',
    y_label='$\max_{\\textbf{x}}(c)$',
)
save_figure('cMax(t)')(fig)

fig, ax = plot_line(
    (cMin.time_series, cMin.value_series),
    x_label='$t$',
    y_label='$\min_{\\textbf{x}}(c)$',
)
save_figure('cMin(t)')(fig)
../../_images/1bdf62b3e8c87b2119b285bea9a5aebc9fc3bd3078a4c0a05a2dcd9b5d1395bb.png ../../_images/89f9883a69669bc16289d7623ccfb0ebff074b772e67c8770388ec145c883fd0.png