Evolving convection of a Darcy fluid in an inclined porous rectangle

Evolving convection of a Darcy fluid in an inclined porous rectangle#

\[\begin{split} \mathbb{S} \begin{cases} \Omega = [0, \mathcal{A}X] \times [0, X] & \text{aspect ratio } \mathcal{A}=\mathcal{O}(1)\\ c_0(x,y)=\lim_{\epsilon\to0}\left(1+\text{erf}\left(\frac{y-X}{\epsilon X}\right)\right)+\mathcal{N}(x,y) & \text{perturbed initial concentration} \\ c_{\text{D}}(x,y=X)=1 & \text{heavy upper boundary} \\ c_{\text{N}}(x,y=0)=0 & \text{no-flux on lower boundary}\\ c_{\text{N}}(x=0,y)=0 & \text{no-flux on left boundary}\\ c_{\text{N}}(x=\mathcal{A}X,y)=0 & \text{no-flux on right boundary}\\ \psi_{\text{D}}\vert_{\partial\Omega}=0 & \text{no-penetration on entire boundary} \\ \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}\\ \textbf{e}_g=-\sin\beta\textbf{e}_x-\cos\beta\textbf{e}_y & \text{gravity at an angle $\beta$ to the vertical coordinate} \\ \end{cases} \end{split}\]
import numpy as np
from matplotlib.patches import FancyArrowPatch
from lucifex.fdm import AB2, CN
from lucifex.sim import run
from lucifex.utils.npy_utils import as_index
from lucifex.plt import plot_colormap, save_figure, create_animation, display_animation
from py.C14_darcy_evolving import darcy_convection_evolving_rectangle

beta = 20.0
simulation = darcy_convection_evolving_rectangle(
    aspect=2.0,
    Nx=64,
    Ny=64,
    cell='quadrilateral', 
    scaling='advective',
    Ra=300.0, 
    beta=beta,
    c_ampl=1e-4, 
    c_freq=(14, 14), 
    c_seed=(456, 987), 
    D_adv=AB2,
    D_diff=CN,
)

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.name}(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)', return_path=True)(anim)

display_animation(anim_path)
Lx, Ly = 2.0, 1.0
arrow_len = 0.2
arrow_start = 0.5 * np.array((Lx, Ly))
arrow_end = arrow_start - arrow_len * np.array((np.sin(np.radians(beta)), np.cos(np.radians(beta))))

time_indices = as_index(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]:.2f})$')
    arrow = FancyArrowPatch(
        arrow_start,
        arrow_end,
        arrowstyle='-|>',
        mutation_scale=15,
        color='cyan',
        linewidth=2.0,
    )
    ax.add_patch(arrow)
    save_figure(f'{c.name}(t={c.time_series[i]:.2f})', thumbnail=(i == -1))(fig)
../../_images/dcb60e509b090af55b932670fc3a44cd0200e132e130294b76005f8080bedead.png ../../_images/31ff04a79fd6f443604e1de3a9bc7c0191bc79822f6bcee0f7737c2f8bb327e9.png ../../_images/42f3344bdb5243a4bd3243d81b779baaf9c69e27dfb4ba185e97245c1750a6b8.png