Continuous-flow microchannel chemical reactors and microfluidic chip heat sinks intensify heat and mass transfer by shrinking hydraulic channels to hundreds of micrometers (). This creates a design conflict: because Reynolds numbers are strictly laminar (), streamlines run parallel without turbulent mixing, while small molecular diffusivities () yield large Peclet numbers () so that little reactant reaches the catalytic walls. Inserting staggered micromixer baffles deflects streamlines transversely to boost wall/bulk conversion, at the expense of steeper hydraulic pressure drop ; simultaneously, exothermic reaction heat must conduct safely out through a low-conductivity catalyst washcoat bonded to a silicon chip wall. In this closing project we combine seven engcfd modules (constants, navier_stokes, lattice_boltzmann, convection_diffusion, tvd_advection, grids_fvm, and elliptic_multigrid) in a design study of such a reactor. The geometry, the operating conditions and the material properties are assumed values chosen for illustration, and the way in which stages 3 and 4 represent the effect of the baffles (an effective diffusivity and a cross-flow velocity that grow with the mixing index of stage 2) is an assumed closure, not a result of the lattice Boltzmann calculation. The project shows how the methods of the course fit together; it is not a validated reactor model.
Learning objectives¶
Evaluate fluid properties () and dimensionless operating regimes () from
constants.FLUIDS_DBand verify baseline planar microchannel hydraulics () vianavier_stokes.poiseuille_couette_exact.Quantify transverse mixing enhancement vs. hydraulic permeability penalty in baffled vs. unbaffled microchannels using
lattice_boltzmann.simulate_lbm_poiseuille_2dandsimulate_lbm_obstacle_flow_2d.Solve 2-D reactant conversion via
convection_diffusion.fvm_convection_diffusion_2d_steadyalongside bounded transient tracer mixing viatvd_advection.advect_2d_strang_periodic.Couple exothermic reaction heat release to composite washcoat/silicon wall conduction (
grids_fvm.harmonic_interface_conductivity,fvm_diffusion_1d_steady, andelliptic_multigrid.poisson_2d_fast_sine) and map the Conversion vs. Pumping-Power Penalty Pareto frontier.
Time: about 60 min
try: # use the installed package, or the copy in this repository
import engcfd
except ImportError:
import pathlib, subprocess, sys
for _root in [pathlib.Path.cwd(), *pathlib.Path.cwd().parents]:
if (_root / "engcfd" / "__init__.py").exists():
sys.path.insert(0, str(_root))
break
else: # on Google Colab: install from GitHub
subprocess.run([sys.executable, "-m", "pip", "install", "-q",
"git+https://github.com/ktwyw/engcfd.git"], check=True)
import engcfd
import inspect
import numpy as np
import matplotlib.pyplot as plt
from engcfd import (burgers_riemann, constants, convection_diffusion, elliptic_multigrid, grids_fvm,
lattice_boltzmann, navier_stokes, tvd_advection)
from engcfd.plotting import label_panels, panel_label, use_style
use_style()
def show_source(obj):
"""Return the source code of a library function or class."""
return inspect.getsource(obj)
def heading(text):
print(f"\n{text}\n" + "=" * len(text))1. Stage 1: Working-Fluid Selection, Dimensionless Groups & Baseline Hydraulics¶
Consider a planar catalytic microchannel of height (), length , mean inlet velocity , and reactant molecular diffusivity . Three dimensionless groups govern momentum, thermal, and species transport (constants.reynolds_number, constants.peclet_number):
We audit candidate working fluids from constants.FLUIDS_DB (water_298K, ethanol_298K, air_298K, liquid_sodium_673K) and cross-verify the aqueous microchannel pressure drop and wall shear stress with navier_stokes.poiseuille_couette_exact.
heading("Stage 1: Fluid Screening (FLUIDS_DB) & Planar Microchannel Hydraulic Baseline")
H_ch = 4.0e-4 # 400 um channel height [m]
L_ch = 8.0e-3 # 8 mm reactor length [m]
U_mean = 0.05 # 5 cm/s mean velocity [m/s]
D_mol = 2.0e-9 # Aqueous solute diffusivity [m^2/s]
print(f"{'Fluid':>20s} | {'Pr [-]':>8s} | {'Re_H [-]':>10s} | {'Pe_thermal':>11s} | {'dP/dx [kPa/m]':>14s}")
print("-" * 76)
for fname in ["water_298K", "ethanol_298K", "air_298K", "liquid_sodium_673K"]:
fp = constants.FLUIDS_DB[fname]
re_h = constants.reynolds_number(U_mean, H_ch, fp["nu_m2_s"])
pe_th = constants.peclet_number(U_mean, H_ch, fp["alpha_m2_s"])
dp_dx_mag = 12.0 * fp["mu_Pa_s"] * U_mean / (H_ch**2)
print(f"{fname:>20s} | {fp['Pr']:8.4f} | {re_h:10.3f} | {pe_th:11.3f} | {dp_dx_mag*1e-3:14.3f}")
assert np.isclose(pe_th, re_h * fp["Pr"], rtol=1e-12)
water = constants.FLUIDS_DB["water_298K"]
re_water = constants.reynolds_number(U_mean, H_ch, water["nu_m2_s"])
pe_mass = constants.peclet_number(U_mean, H_ch, D_mol)
dp_dx_water = -12.0 * water["mu_Pa_s"] * U_mean / (H_ch**2) # negative for +x flow
y_prof = np.linspace(0.0, H_ch, 101)
hyd_base = navier_stokes.poiseuille_couette_exact(y=y_prof, H=H_ch, mu=water["mu_Pa_s"], dP_dx=dp_dx_water)
print(f"\nAqueous microreactor: Re_H = {re_water:.2f} (strictly laminar), Mass Peclet Pe_m = {pe_mass:.1f} (diffusion-limited)")
print(f"Poiseuille u_mean = {hyd_base['u_mean']:.5f} m/s, u_max = {np.max(hyd_base['u']):.5f} m/s (exact 1.5*U_m = {1.5*U_mean:.5f})")
print(f"Baseline pressure drop Delta_P = {-dp_dx_water * L_ch:.3f} Pa, wall shear tau_w = {hyd_base['tau_bottom']:.4f} Pa")
assert np.isclose(hyd_base["u_mean"], U_mean, rtol=1e-14)
assert np.isclose(float(np.max(hyd_base["u"])), 1.5 * U_mean, rtol=1e-4)
assert re_water < 30.0 and pe_mass > 5000.0
Stage 1: Fluid Screening (FLUIDS_DB) & Planar Microchannel Hydraulic Baseline
=============================================================================
Fluid | Pr [-] | Re_H [-] | Pe_thermal | dP/dx [kPa/m]
----------------------------------------------------------------------------
water_298K | 6.1303 | 22.406 | 137.353 | 3.337
ethanol_298K | 15.6920 | 14.618 | 229.389 | 4.028
air_298K | 0.7302 | 1.281 | 0.935 | 0.069
liquid_sodium_673K | 0.0050 | 60.282 | 0.303 | 1.065
Aqueous microreactor: Re_H = 22.41 (strictly laminar), Mass Peclet Pe_m = 10000.0 (diffusion-limited)
Poiseuille u_mean = 0.05000 m/s, u_max = 0.07500 m/s (exact 1.5*U_m = 0.07500)
Baseline pressure drop Delta_P = 26.700 Pa, wall shear tau_w = 0.6675 Pa
What stage 1 shows. For water, , so the flow is laminar, and the pressure drop of the open channel is small ( over ). The mass Péclet number is : diffusion across half the channel takes , while the fluid leaves the reactor after . Without transverse flow, most of the reactant in the core of the channel leaves without reaching the wall.
2. Stage 2: D2Q9 LBM Micromixer Baffles & Bounded TVD Tracer Stirring¶
To break up parallel laminar streamlines, we insert alternating top/bottom staggered micro-baffles of height into the channel (lattice_boltzmann.simulate_lbm_obstacle_flow_2d). At constant target flow rate , hydraulic resistance scales inversely with Darcy permeability :
In parallel, we verify conservative, oscillation-free scalar tracer transport in a shear/cellular velocity field using tvd_advection.advect_2d_strang_periodic (limiter="van_leer").
heading("Stage 2: D2Q9 LBM Staggered-Baffle Micromixer & TVD Strang Scalar Transport")
nx_m, ny_m = 32, 16 # H_open = 14 lu
tau_m = 0.80
fx_m = 1.5e-5
# Compare open channel (hb=0) vs staggered alternating wall baffles of height hb in {2, 4, 6} lu:
baffle_heights = [0, 2, 4, 6]
k_baff, mix_idx, lbm_fields = [], [], {}
for hb in baffle_heights:
mk = np.zeros((nx_m, ny_m), dtype=bool)
mk[:, 0] = mk[:, -1] = True
if hb > 0:
mk[6:9, 1 : 1 + hb] = True # bottom baffle 1
mk[15:18, ny_m - 1 - hb : ny_m - 1] = True # top baffle 2
mk[24:27, 1 : 1 + hb] = True # bottom baffle 3
sim_b = lattice_boltzmann.simulate_lbm_obstacle_flow_2d(mk, tau=tau_m, body_force_x=fx_m, n_steps=180)
k_baff.append(sim_b["darcy_permeability_lu2"])
mix_idx.append(float(np.mean(np.abs(sim_b["uy"])) / sim_b["superficial_velocity"]))
lbm_fields[hb] = (mk, sim_b)
dp_penalties = [k_baff[0] / kv for kv in k_baff]
for hb, dp_pen, mi in zip(baffle_heights, dp_penalties, mix_idx):
print(f"Baffle height h_b = {hb:2d} lu | Pressure-drop penalty dP/dP_0 = {dp_pen:6.2f}x | Transverse mixing <|u_y|>/u_sup = {mi:.4f}")
assert np.isclose(mix_idx[0], 0.0, atol=1e-13)
assert mix_idx[1] < mix_idx[2] < mix_idx[3]
assert np.isclose(dp_penalties[0], 1.0) and dp_penalties[0] < dp_penalties[1] < dp_penalties[2] < dp_penalties[3]
# Verify bounded TVD Strang-split 2-D scalar patch stirring (0 <= C <= 1, exact mass conservation):
xg_t, yg_t = np.meshgrid((np.arange(24) + 0.5) / 24.0, (np.arange(24) + 0.5) / 24.0, indexing="ij")
c_patch0 = np.where((np.abs(xg_t - 0.35) <= 0.15) & (np.abs(yg_t - 0.50) <= 0.15), 1.0, 0.0)
u_row_tvd = 0.8 * np.sin(2.0 * np.pi * (np.arange(24) + 0.5) / 24.0)
v_col_tvd = -0.8 * np.sin(2.0 * np.pi * (np.arange(24) + 0.5) / 24.0)
tvd_out = tvd_advection.advect_2d_strang_periodic(c_patch0, u_row_tvd, v_col_tvd, dx=1.0/24, dy=1.0/24, dt=0.01, n_steps=25, limiter="van_leer")
print(f"TVD Strang stirring: mass_drift = {tvd_out['mass_drift']:.3e}, bounds = [{tvd_out['min_val']:.6f}, {tvd_out['max_val']:.6f}]")
assert tvd_out["mass_drift"] < 1e-14 and tvd_out["min_val"] >= -1e-12 and tvd_out["max_val"] <= 1.0 + 1e-12
mk4, sim4 = lbm_fields[4]
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11.2, 3.9))
uy_map = np.where(mk4, np.nan, sim4["uy"] / sim4["superficial_velocity"])
im1 = ax1.imshow(uy_map.T, origin="lower", cmap="coolwarm", aspect="auto", vmin=-0.8, vmax=0.8)
plt.colorbar(im1, ax=ax1, label=r"Normalized transverse velocity $u_y / u_{\mathrm{sup}}$ [-]")
ax1.set_xlabel("Axial lattice coordinate $x$ [lu]")
ax1.set_ylabel("Channel height $y$ [lu]")
ax1.set_title("Staggered Baffles ($h_b = 4$ lu) Induce $\\pm u_y$ Serpentine Mixing")
ax2.plot(baffle_heights, mix_idx, "bo-", lw=2.2, ms=6.5, label=r"Transverse mixing $\langle |u_y| \rangle / u_{\mathrm{sup}}$")
ax2_r = ax2.twinx()
ax2_r.plot(baffle_heights, dp_penalties, "rs--", lw=2.0, ms=6.5, label=r"Pressure-drop ratio $\Delta P / \Delta P_0$")
ax2.set_xlabel("Baffle height $h_b$ [lu]")
ax2.set_ylabel("Transverse mixing index [-]", color="b")
ax2_r.set_ylabel("Hydraulic pressure-drop penalty [-]", color="r")
ax2.set_title("Hydrodynamic Trade-Off: Mixing Gain vs. $\\Delta P$ Penalty")
label_panels(fig)
plt.show()
Stage 2: D2Q9 LBM Staggered-Baffle Micromixer & TVD Strang Scalar Transport
===========================================================================
Baffle height h_b = 0 lu | Pressure-drop penalty dP/dP_0 = 1.00x | Transverse mixing <|u_y|>/u_sup = 0.0000
Baffle height h_b = 2 lu | Pressure-drop penalty dP/dP_0 = 1.24x | Transverse mixing <|u_y|>/u_sup = 0.1005
Baffle height h_b = 4 lu | Pressure-drop penalty dP/dP_0 = 2.00x | Transverse mixing <|u_y|>/u_sup = 0.2400
Baffle height h_b = 6 lu | Pressure-drop penalty dP/dP_0 = 3.93x | Transverse mixing <|u_y|>/u_sup = 0.4048
TVD Strang stirring: mass_drift = 0.000e+00, bounds = [0.000000, 0.999991]

Figure 17.1. (a) Transverse velocity, relative to the superficial velocity, in the channel with baffles of height 4 lattice units; the solid nodes are white. (b) Mixing index (left axis) and pressure drop relative to the open channel (right axis) against the baffle height.
What stage 2 shows. Baffles of height give a mean transverse velocity of and double the pressure drop (). Baffles of height give at 3.93 times the pressure drop of the open channel. The tracer test conserves mass exactly and keeps the concentration between 0 and 1.
3. Stage 3: 2-D FVM Convection–Diffusion–Reaction & Damköhler Conversion¶
Inside the catalytic reactor domain , steady reactant concentration (normalized by , catalytic absorbing walls ) obeys:
Using the bounded "power_law" discretization in convection_diffusion.fvm_convection_diffusion_2d_steady, we map how bulk Damköhler number and baffle-enhanced effective dispersion/cross-flow govern reactor conversion .
heading("Stage 3: 2-D FVM Convection-Diffusion-Reaction — Damkohler & Mixing Conversion Map")
Lx_r, Ly_r = 1.0, 0.25
nx_r, ny_r = 36, 18
u_rxn = 1.0
bc_reactor = {"left": 1.0, "right": 0.0, "bottom": 0.0, "top": 0.0}
# Sweep bulk first-order rate k_rxn (Damkohler Da = k_rxn * Lx / u) for unmixed (Gamma=0.008, v=0) vs baffle-enhanced (Gamma_eff=0.030, v=0.12):
da_vals = [0.0, 0.6, 1.5, 3.0]
conv_unmixed, conv_baffled = [], []
print(f"{'Damkohler Da':>12s} | {'Unmixed Conversion X':>20s} | {'Baffle-Mixed Conversion X':>25s}")
print("-" * 64)
for da in da_vals:
sol_u = convection_diffusion.fvm_convection_diffusion_2d_steady(
nx=nx_r, ny=ny_r, Lx=Lx_r, Ly=Ly_r, u_vel=u_rxn, v_vel=0.0,
Gamma=0.008, k_react=da, bc_walls=bc_reactor, scheme="power_law", tol=1e-9,
)
sol_b = convection_diffusion.fvm_convection_diffusion_2d_steady(
nx=nx_r, ny=ny_r, Lx=Lx_r, Ly=Ly_r, u_vel=u_rxn, v_vel=0.12,
Gamma=0.030, k_react=da, bc_walls=bc_reactor, scheme="power_law", tol=1e-9,
)
# Sample interior pre-outlet cross-section (i = nx_r - 4) to avoid downstream Dirichlet outflow layer:
x_u = 1.0 - float(np.mean(sol_u["phi"][-4, :]))
x_b = 1.0 - float(np.mean(sol_b["phi"][-4, :]))
conv_unmixed.append(x_u)
conv_baffled.append(x_b)
print(f"{da:12.2f} | {x_u:20.4f} | {x_b:25.4f}")
assert np.all((sol_u["phi"] >= -1e-12) & (sol_u["phi"] <= 1.0 + 1e-12))
assert np.all((sol_b["phi"] >= -1e-12) & (sol_b["phi"] <= 1.0 + 1e-12))
assert all(cb > cu for cu, cb in zip(conv_unmixed, conv_baffled))
assert np.all(np.diff(conv_unmixed) > 0.0) and np.all(np.diff(conv_baffled) > 0.0)
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11.2, 4.0))
sol_vis = convection_diffusion.fvm_convection_diffusion_2d_steady(
nx=nx_r, ny=ny_r, Lx=Lx_r, Ly=Ly_r, u_vel=u_rxn, v_vel=0.0, Gamma=0.010, k_react=0.8, bc_walls=bc_reactor, scheme="power_law", tol=1e-9
)
Xr, Yr = np.meshgrid(sol_vis["xc"], sol_vis["yc"], indexing="ij")
cf = ax1.contourf(Xr, Yr, sol_vis["phi"], levels=18, cmap="YlGnBu")
plt.colorbar(cf, ax=ax1, label="Reactant concentration $C / C_{\\mathrm{in}}$ [-]")
ax1.set_xlabel("Axial position $x / L$ [-]")
ax1.set_ylabel("Transverse coordinate $y / L$ [-]")
ax1.set_title("2-D Concentration Boundary Layers ($\\mathrm{Da} = 0.8$)")
ax2.plot(da_vals, conv_unmixed, "ko--", lw=2.0, ms=6.5, label="Unbaffled laminar Graetz entry")
ax2.plot(da_vals, conv_baffled, "gs-", lw=2.2, ms=6.5, label="Baffle-enhanced cross-flow + dispersion")
ax2.set_xlabel("Damköhler number $\\mathrm{Da} = k_{\\mathrm{rxn}} L / u$ [-]")
ax2.set_ylabel("Reactant conversion $X = 1 - \\bar{C}_{\\mathrm{out}}/C_{\\mathrm{in}}$ [-]")
ax2.set_title("Conversion against Damköhler number")
ax2.legend(fontsize=8.5)
label_panels(fig)
plt.show()
Stage 3: 2-D FVM Convection-Diffusion-Reaction — Damkohler & Mixing Conversion Map
==================================================================================
Damkohler Da | Unmixed Conversion X | Baffle-Mixed Conversion X
----------------------------------------------------------------
0.00 | 0.7372 | 0.9828
0.60 | 0.8443 | 0.9887
1.50 | 0.9278 | 0.9938
3.00 | 0.9791 | 0.9977

Figure 17.2. (a) Reactant concentration in the model reactor for with absorbing walls. (b) Conversion against the Damköhler number for the two sets of assumed transport coefficients.
What stage 3 shows. With the assumed transport coefficients, the channel without cross-flow (, ) converts of the reactant at , where the reactant is consumed at the walls only, and the channel with the enhanced coefficients (, ) converts . A bulk reaction raises both values: at they are and , so the benefit of mixing is largest when the reaction at the wall controls the conversion.
4. Stage 4: Conjugate Composite-Wall Heat Removal & Multi-Objective Pareto Design¶
Exothermic reaction releases volumetric heat inside a porous catalyst washcoat (, low conductivity ) bonded to a silicon microreactor substrate (, high conductivity ) cooled externally at while the inner washcoat face is adiabatic ().
1-D Transverse Conjugate Conduction (
grids_fvm.fvm_diffusion_1d_steady+harmonic_interface_conductivity): exact series thermal resistance across the conductivity jump.2-D Silicon Chip Hot-Spot Spread (
elliptic_multigrid.poisson_2d_fast_sine): 2-D lateral heat spreading around a localized reaction hot spot.System Pareto Frontier: Sweeping baffle height maps Reactant Conversion against Hydraulic Pressure-Drop Penalty .
heading("Stage 4: Conjugate Washcoat/Silicon Cooling & Conversion vs Pressure-Drop Pareto Frontier")
# 1) 1-D Composite Wall Conjugate Conduction (150 um alumina washcoat + 350 um silicon chip, 20 cells):
L_wash, L_si = 1.5e-4, 3.5e-4
k_wash, k_si = 1.6, 148.0
q_vol_wash = 8.0e7 # 80 MW/m^3 exothermic heat generation inside 150-um catalyst washcoat [W/m^3]
T_cool = 300.0
grid_wall = grids_fvm.uniform_fvm_grid_1d(0.0, L_wash + L_si, n_cells=20) # interface falls cleanly on face 6 (x = 150 um)
xc_w = grid_wall["x_centers"]
k_cells_w = np.where(xc_w < L_wash, k_wash, k_si)
q_cells_w = np.where(xc_w < L_wash, q_vol_wash, 0.0)
conj_1d = grids_fvm.fvm_diffusion_1d_steady(
grid_wall["x_faces"], k_cells=k_cells_w, q_source=q_cells_w,
bc_left=("neumann", 0.0), bc_right=("dirichlet", T_cool),
)
# Exact analytical peak temperature at adiabatic inner washcoat surface x = 0:
# T(0) = T_cool + (q_vol * L_wash) * (L_wash / (2*k_wash) + L_si / k_si)
q_flux_int = q_vol_wash * L_wash # 12,000 W/m^2 conductive wall heat flux
dT_exact_peak = q_flux_int * (L_wash / (2.0 * k_wash) + L_si / k_si)
# Note cell 0 center is at dx/2: exact T(xc[0]) = T(0) - q_vol * xc[0]^2 / (2*k_wash)
T_xc0_exact = T_cool + dT_exact_peak - q_vol_wash * (xc_w[0] ** 2) / (2.0 * k_wash)
print(f"Composite wall heat flux q'' = {q_flux_int*1e-3:.2f} kW/m^2 | Balance residual = {conj_1d['max_cell_balance_residual']:.3e}")
print(f"Inner catalyst T(xc[0]) = {conj_1d['phi'][0]:.6f} K vs Exact continuum = {T_xc0_exact:.6f} K")
assert conj_1d["max_cell_balance_residual"] < 1e-5
assert np.isclose(conj_1d["phi"][0], T_xc0_exact, atol=0.01)
assert np.isclose(conj_1d["face_fluxes"][-1], q_flux_int, rtol=1e-10)
# 2) 2-D Chip Substrate Hot-Spot Spreading via Fast Sine Poisson (-k_si*h_si * lap_2d(dT) = q''(x, y)):
Xg_hs, Yg_hs = np.meshgrid(np.linspace(0.0, L_ch, 33)[1:-1], np.linspace(0.0, L_ch, 33)[1:-1], indexing="ij")
q2d_hotspot = q_flux_int * np.exp(-(((Xg_hs - 0.3 * L_ch) ** 2 + (Yg_hs - 0.5 * L_ch) ** 2) / ((0.18 * L_ch) ** 2)))
dT_chip_2d = elliptic_multigrid.poisson_2d_fast_sine(q2d_hotspot / (k_si * L_si), dx=L_ch / 32.0, dy=L_ch / 32.0)
print(f"2-D Silicon substrate lateral hot-spot peak rise dT_si,2D = {np.max(dT_chip_2d):.4f} K (< 1 K thanks to k_Si = 148 W/mK)")
assert 0.0 < float(np.max(dT_chip_2d)) < 2.0
# 3) Multi-Objective Pareto Trade-Off Across Baffle Heights hb = 0..6 lu on 32x16 channel:
hb_pareto = [0, 2, 4, 5, 6]
dp_ratio_p, conv_p = [], []
k_open_ref = None
for hb in hb_pareto:
mk_p = np.zeros((32, 16), dtype=bool)
mk_p[:, 0] = mk_p[:, -1] = True
if hb > 0:
mk_p[6:9, 1 : 1 + hb] = True
mk_p[15:18, 15 - hb : 15] = True
mk_p[24:27, 1 : 1 + hb] = True
lb_p = lattice_boltzmann.simulate_lbm_obstacle_flow_2d(mk_p, tau=0.80, body_force_x=1.5e-5, n_steps=160)
if k_open_ref is None:
k_open_ref = lb_p["darcy_permeability_lu2"]
dp_ratio_p.append(k_open_ref / lb_p["darcy_permeability_lu2"])
mix_r = float(np.mean(np.abs(lb_p["uy"])) / lb_p["superficial_velocity"])
cdr_p = convection_diffusion.fvm_convection_diffusion_2d_steady(
nx=32, ny=16, Lx=1.0, Ly=0.25, u_vel=1.0, v_vel=0.45 * mix_r,
Gamma=0.008 + 0.075 * mix_r, k_react=0.4,
bc_walls={"left": 1.0, "right": 0.0, "bottom": 0.0, "top": 0.0}, scheme="power_law", tol=1e-9,
)
conv_p.append(1.0 - float(np.mean(cdr_p["phi"][-4, :])))
for hb, x_dp, y_cv in zip(hb_pareto, dp_ratio_p, conv_p):
print(f"Baffle height h_b = {hb} lu | dP/dP_0 = {x_dp:5.2f} | conversion X = {y_cv:.3f}")
assert conv_p[-1] > conv_p[0] + 0.12 and dp_ratio_p[-1] > 3.5 * dp_ratio_p[0]
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11.2, 4.1))
ax1.plot(xc_w * 1e6, conj_1d["phi"] - T_cool, "ro-", lw=2.1, ms=5.5, label="FVM harmonic composite $T(y) - T_{\\mathrm{cool}}$")
ax1.axvline(L_wash * 1e6, color="k", ls="--", lw=1.3, label="Washcoat / Silicon interface ($150\\,\\mu\\mathrm{m}$)")
ax1.set_xlabel("Wall depth $y$ [$\\mu\\mathrm{m}$]")
ax1.set_ylabel("Temperature rise $\\Delta T$ [K]")
ax1.set_title("Conjugate Wall Profile ($92.5\\times$ Conductivity Jump)")
ax1.legend(fontsize=8)
ax2.plot(dp_ratio_p, conv_p, "bs-", lw=2.2, ms=7)
for hb, x_dp, y_cv in zip(hb_pareto, dp_ratio_p, conv_p):
ax2.annotate(f"$h_b={hb}$", (x_dp, y_cv), textcoords="offset points", xytext=(5, -10), fontsize=8)
ax2.set_xlabel("Hydraulic pressure-drop penalty $\\Delta P / \\Delta P_0$ [-]")
ax2.set_ylabel("Reactant conversion $X$ [-]")
ax2.set_title("Conversion against pressure drop")
ax2.set_xlim(0.8, 4.2)
label_panels(fig)
plt.show()
Stage 4: Conjugate Washcoat/Silicon Cooling & Conversion vs Pressure-Drop Pareto Frontier
=========================================================================================
Composite wall heat flux q'' = 12.00 kW/m^2 | Balance residual = 3.365e-07
Inner catalyst T(xc[0]) = 300.590878 K vs Exact continuum = 300.586972 K
2-D Silicon substrate lateral hot-spot peak rise dT_si,2D = 0.2983 K (< 1 K thanks to k_Si = 148 W/mK)
Baffle height h_b = 0 lu | dP/dP_0 = 1.00 | conversion X = 0.811
Baffle height h_b = 2 lu | dP/dP_0 = 1.23 | conversion X = 0.929
Baffle height h_b = 4 lu | dP/dP_0 = 1.94 | conversion X = 0.979
Baffle height h_b = 5 lu | dP/dP_0 = 2.63 | conversion X = 0.989
Baffle height h_b = 6 lu | dP/dP_0 = 3.73 | conversion X = 0.994

Figure 17.3. (a) Temperature rise across the washcoat and the silicon wall; the dashed line is the interface. (b) Conversion against the pressure drop relative to the open channel for five baffle heights.
Inside the algorithm¶
What stage 4 shows.
In panel (a), the temperature rise across the wall is , and about of it occurs inside the washcoat (); the silicon wall () is nearly isothermal. The finite-volume temperature at the first cell center differs from the analytical value by on the 20-cell mesh.
In panel (b), raising from 0 to raises the conversion from to at 1.94 times the pressure drop. Raising further to adds only 1.5 percentage points () and nearly doubles the pressure drop again (3.73 times that of the open channel). Within this model, is the reasonable choice; the conclusion depends on the assumed closure between the mixing index and the transport coefficients.
Below we inspect harmonic_interface_conductivity and fvm_convection_diffusion_2d_steady, and verify global flux conservation across the composite interface.
Check against the library¶
heading("Inside the Algorithm: Harmonic Interface Conductance & 2-D FVM Scalar Conservation")
print(show_source(grids_fvm.harmonic_interface_conductivity))
print(show_source(convection_diffusion.fvm_convection_diffusion_2d_steady))
# Verify exact harmonic vs erroneous arithmetic interface conductivity across washcoat (1.6) / silicon (148.0):
k_pair = np.array([1.6, 148.0])
v_pair = np.array([2.5e-5, 2.5e-5])
k_harm = float(grids_fvm.harmonic_interface_conductivity(k_pair, v_pair)[0])
k_arith = float(0.5 * (1.6 + 148.0))
print(f"Washcoat/Silicon interface k_face: Harmonic = {k_harm:.4f} W/(m*K) vs Arithmetic mean = {k_arith:.4f} W/(m*K) ({k_arith/k_harm:.1f}x overestimate)")
assert np.isclose(k_harm, 2.0 * 1.6 * 148.0 / (1.6 + 148.0), rtol=1e-15) and k_arith > 23.0 * k_harm
Inside the Algorithm: Harmonic Interface Conductance & 2-D FVM Scalar Conservation
==================================================================================
def harmonic_interface_conductivity(
k_cells: np.ndarray,
volumes: np.ndarray,
) -> np.ndarray:
"""Compute exact series-resistance harmonic face conductivities k_{i+1/2} across interior FVM faces."""
kc = np.asarray(k_cells, dtype=float).ravel()
vols = np.asarray(volumes, dtype=float).ravel()
if kc.size != vols.size or kc.size < 2 or np.any(kc <= 0.0):
raise ValueError("k_cells and volumes must match in size >= 2 with k_cells > 0.")
dl = 0.5 * vols[:-1]
dr = 0.5 * vols[1:]
return (dl + dr) / (dl / kc[:-1] + dr / kc[1:])
def fvm_convection_diffusion_2d_steady(
nx: int,
ny: int,
Lx: float,
Ly: float,
u_vel: float,
v_vel: float,
Gamma: float,
source: float | np.ndarray = 0.0,
k_react: float = 0.0,
bc_walls: dict | None = None,
scheme: str = "power_law",
tol: float = 1e-10,
max_iter: int = 5000,
) -> dict:
"""Solve 2-D steady FVM convection-diffusion-reaction u*phi_x + v*phi_y = Gamma*lap(phi) - k*phi + S."""
if nx < 3 or ny < 3 or Lx <= 0.0 or Ly <= 0.0 or Gamma <= 0.0 or k_react < 0.0:
raise ValueError("Require nx, ny >= 3, Lx, Ly, Gamma > 0, and k_react >= 0.")
dx = float(Lx) / int(nx)
dy = float(Ly) / int(ny)
xc = (np.arange(nx, dtype=float) + 0.5) * dx
yc = (np.arange(ny, dtype=float) + 0.5) * dy
bcs = {"left": 0.0, "right": 0.0, "bottom": 0.0, "top": 0.0}
if bc_walls is not None:
bcs.update(bc_walls)
fx = float(u_vel) * dy
fy = float(v_vel) * dx
dx_cond = float(Gamma) * dy / dx
dy_cond = float(Gamma) * dx / dy
ax_wt = _peclet_weighting_A(abs(fx / dx_cond), scheme)
ay_wt = _peclet_weighting_A(abs(fy / dy_cond), scheme)
aw = dx_cond * ax_wt + max(fx, 0.0)
ae = dx_cond * ax_wt + max(-fx, 0.0)
as_s = dy_cond * ay_wt + max(fy, 0.0)
an = dy_cond * ay_wt + max(-fy, 0.0)
# Boundary half-cell conductances:
ax_b = _peclet_weighting_A(0.5 * abs(fx / dx_cond), scheme)
ay_b = _peclet_weighting_A(0.5 * abs(fy / dy_cond), scheme)
aw_b = 2.0 * dx_cond * ax_b + max(fx, 0.0)
ae_b = 2.0 * dx_cond * ax_b + max(-fx, 0.0)
as_b = 2.0 * dy_cond * ay_b + max(fy, 0.0)
an_b = 2.0 * dy_cond * ay_b + max(-fy, 0.0)
src = np.full((nx, ny), float(source), dtype=float) if np.ndim(source) == 0 else np.asarray(source, dtype=float)
vol = dx * dy
aw_mat = np.full((nx, ny), aw, dtype=float)
ae_mat = np.full((nx, ny), ae, dtype=float)
as_mat = np.full((nx, ny), as_s, dtype=float)
an_mat = np.full((nx, ny), an, dtype=float)
aw_mat[0, :] = 0.0
ae_mat[-1, :] = 0.0
as_mat[:, 0] = 0.0
an_mat[:, -1] = 0.0
ap_mat = aw_mat + ae_mat + as_mat + an_mat + float(k_react) * vol
b_rhs = src * vol
ap_mat[0, :] += aw_b
b_rhs[0, :] += aw_b * float(bcs["left"])
ap_mat[-1, :] += ae_b
b_rhs[-1, :] += ae_b * float(bcs["right"])
ap_mat[:, 0] += as_b
b_rhs[:, 0] += as_b * float(bcs["bottom"])
ap_mat[:, -1] += an_b
b_rhs[:, -1] += an_b * float(bcs["top"])
phi = np.zeros((nx, ny), dtype=float)
ii, jj = np.meshgrid(np.arange(nx), np.arange(ny), indexing="ij")
red = (ii + jj) % 2 == 0
black = ~red
omega = 1.35
res_hist = []
for it in range(1, max_iter + 1):
for mask in (red, black):
nb_sum = np.zeros_like(phi)
nb_sum[1:, :] += aw_mat[1:, :] * phi[:-1, :]
nb_sum[:-1, :] += ae_mat[:-1, :] * phi[1:, :]
nb_sum[:, 1:] += as_mat[:, 1:] * phi[:, :-1]
nb_sum[:, :-1] += an_mat[:, :-1] * phi[:, 1:]
phi_gs = (nb_sum + b_rhs) / ap_mat
phi[mask] = (1.0 - omega) * phi[mask] + omega * phi_gs[mask]
if it % 20 == 0 or it == 1:
nb_all = np.zeros_like(phi)
nb_all[1:, :] += aw_mat[1:, :] * phi[:-1, :]
nb_all[:-1, :] += ae_mat[:-1, :] * phi[1:, :]
nb_all[:, 1:] += as_mat[:, 1:] * phi[:, :-1]
nb_all[:, :-1] += an_mat[:, :-1] * phi[:, 1:]
res = float(np.max(np.abs(ap_mat * phi - nb_all - b_rhs)))
res_hist.append(res)
if res < tol:
break
return {
"xc": xc,
"yc": yc,
"phi": phi,
"iterations": it,
"residual_history": np.array(res_hist, dtype=float),
}
Washcoat/Silicon interface k_face: Harmonic = 3.1658 W/(m*K) vs Arithmetic mean = 74.8000 W/(m*K) (23.6x overestimate)
Exercises¶
Worked solutions are in 17_solutions.ipynb. The cell below the list is a short self-check to start from.
Verify a result. Verify cross-module analytical consistency across three
engcfdsolvers: (a)fvm_convection_diffusion_1d(..., scheme='exponential')vs'power_law'at (n_cells=20), (b)simulate_lbm_poiseuille_2dat vspoiseuille_couette_exact, and (c)poisson_2d_multigrid_vcyclevspoisson_2d_fast_sineon a chip cooling Poisson problem.Find how it fails. Demonstrate numerically two high-consequence reactor modeling errors: (a) on a 2-cell composite wall (
x_faces = [0, 1e-4, 2e-4],k = [1.5, 150.0], left fluxJ_in = 15,000 W/m^2, rightT = 300 K), compare exact harmonic FVM (fvm_diffusion_1d_steady) against naive arithmetic face conductivity to show a error in predicted catalyst temperature rise ; and (b) show thatscheme='central'infvm_convection_diffusion_1d(n_cells=10, L=1.0, u=1.0, Gamma=0.02, ) produces negative concentrations (bounded_no_overshoot == False) whilescheme='power_law'preserves .Implement it yourself. Implement
design_conjugate_microreactor(baffle_heights, da_rxn=0.35, q_full_conv=1.2e8)combiningsimulate_lbm_obstacle_flow_2d,fvm_convection_diffusion_2d_steady, andfvm_diffusion_1d_steadyoverbaffle_heights = [0, 2, 4, 5, 7]on a32 x 16channel. Select the optimal baffle height maximizing conversion subject to and peak wall temperature rise , and verify all constraints programmatically.
heading("Self-check for the exercises")
exp_1d = convection_diffusion.fvm_convection_diffusion_1d(n_cells=20, L=1.0, u=1.0, Gamma=0.025, scheme="exponential")
pow_1d = convection_diffusion.fvm_convection_diffusion_1d(n_cells=20, L=1.0, u=1.0, Gamma=0.025, scheme="power_law")
cen_hi = convection_diffusion.fvm_convection_diffusion_1d(n_cells=10, L=1.0, u=1.0, Gamma=0.02, scheme="central")
print(f"Pe=40 exponential max_error = {exp_1d['max_error']:.3e} | power_law max_error = {pow_1d['max_error']:.3e}")
print(f"Pe_cell=5.0 central bounded = {cen_hi['bounded_no_overshoot']} (min phi = {np.min(cen_hi['phi']):+.4f} < 0)")
assert exp_1d["max_error"] < 1e-14 and pow_1d["max_error"] < 5e-3 and cen_hi["bounded_no_overshoot"] is False
print("All checks passed.")
Self-check for the exercises
============================
Pe=40 exponential max_error = 5.551e-17 | power_law max_error = 3.384e-03
Pe_cell=5.0 central bounded = False (min phi = -0.1111 < 0)
All checks passed.