Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Solutions · 17. Project: flow, mixing and reaction in a microchannel

School of Engineering, Nazarbayev University

Worked solutions to the three exercises of Lecture 17. Each solution is computed here and checked with assert statements against an exact identity or an independent calculation. The first code cell sets up the notebook and runs Demonstration 1 of the lecture without showing its output, because some of the solutions use its variables.

Exercise 1

Problem. Verify cross-module analytical consistency across three engcfd solvers: (a) fvm_convection_diffusion_1d(..., scheme='exponential') vs 'power_law' at Pe=40\mathrm{Pe} = 40 (n_cells=20), (b) simulate_lbm_poiseuille_2d at τmagic=12+34\tau_{\mathrm{magic}} = \frac{1}{2} + \frac{\sqrt{3}}{4} vs poiseuille_couette_exact, and (c) poisson_2d_multigrid_vcycle vs poisson_2d_fast_sine on a 33×3333 \times 33 chip cooling Poisson problem.


Exercise 1: Cross-Module Verification Across FVM, LBM, Navier-Stokes & Multigrid/DST Solvers
============================================================================================
1-D Exp FVM err = 5.55e-17 | LBM vs NS max rel err = 1.50e-08
Multigrid (9 V-cycles) vs Fast Sine max |u_MG - u_DST| = 5.438e-14

Explanation. Three independent numerical paradigms in engcfd, the exponential finite-volume flux, mesoscale D2Q9 kinetic theory at τmagic\tau_{\mathrm{magic}}, and O(N)O(N) Geometric Multigrid vs. O(Nlog⁡N)O(N \log N) Fast Sine transforms, each converge to their analytical or discrete-exact counterparts to 8–158\text{–}15 significant digits.


Exercise 2

Problem. 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 flux J_in = 15,000 W/m^2, right T = 300 K), compare exact harmonic FVM (fvm_diffusion_1d_steady) against naive arithmetic face conductivity (k1+k2)/2(k_1+k_2)/2 to show a >25%> 25\% error in predicted catalyst temperature rise ΔT\Delta T; and (b) show that scheme='central' in fvm_convection_diffusion_1d (n_cells=10, L=1.0, u=1.0, Gamma=0.02, PeΔx=5\mathrm{Pe}_{\Delta x} = 5) produces negative concentrations C<0C < 0 (bounded_no_overshoot == False) while scheme='power_law' preserves 0≤C≤10 \leq C \leq 1.


Exercise 2: Arithmetic Conductivity Error & Central-Difference Peclet Instability
=================================================================================
Catalyst center dT: Exact = 0.5100 K | Harmonic FVM = 0.5100 K | Arithmetic mean = 0.0248 K (err = 95.1%)
Pe_cell = 5.0: Central min(C) = -0.1111 (bounded=False) | Power-law min(C) = +1.0893e-21 (bounded=True)

Explanation. Arithmetic averaging treats the washcoat/silicon interface as if the two materials acted in parallel (karith=75.75 W/(m⋅K)k_{\mathrm{arith}} = 75.75\text{ W/(m}\cdot\text{K)}) rather than in series (kharm=2.97 W/(m⋅K)k_{\mathrm{harm}} = 2.97\text{ W/(m}\cdot\text{K)}), and underpredicts the temperature rise in the catalyst by 95%95\%. Similarly, central differencing at ∣PeΔx∣>2|\mathrm{Pe}_{\Delta x}| > 2 makes the downstream neighbor coefficient aE=D(1−0.5∣PeΔx∣)<0a_E = D(1 - 0.5|\mathrm{Pe}_{\Delta x}|) < 0, destroying diagonal dominance and creating sawtooth negative concentrations.


Exercise 3

Problem. Implement design_conjugate_microreactor(baffle_heights, da_rxn=0.35, q_full_conv=1.2e8) combining simulate_lbm_obstacle_flow_2d, fvm_convection_diffusion_2d_steady, and fvm_diffusion_1d_steady over baffle_heights = [0, 2, 4, 5, 7] on a 32 x 16 channel. Select the optimal baffle height maximizing conversion XX subject to ΔP/ΔP0≤4.0\Delta P / \Delta P_0 \leq 4.0 and peak wall temperature rise ΔTmax⁡≤1.5 K\Delta T_{\max} \leq 1.5\text{ K}, and verify all constraints programmatically.


Exercise 3: Implement It Yourself — Constrained Multi-Physics Microreactor Optimizer
====================================================================================
h_b = 0 lu | X = 0.8025 | dP/dP_0 =  1.00x | dT_max = 0.7113 K
h_b = 2 lu | X = 0.9260 | dP/dP_0 =  1.23x | dT_max = 0.8208 K
h_b = 4 lu | X = 0.9783 | dP/dP_0 =  1.94x | dT_max = 0.8671 K
h_b = 5 lu | X = 0.9883 | dP/dP_0 =  2.63x | dT_max = 0.8760 K
h_b = 7 lu | X = 0.9962 | dP/dP_0 =  5.38x | dT_max = 0.8830 K

Selected optimal design: h_b = 5 lu (X = 0.9883, dP/dP_0 = 2.63x <= 4.0x, dT_max = 0.876 K <= 1.5 K)

Summary of Exercise 3 and of the course. The 18 lectures have built the following methods in NumPy: finite-volume conservation & harmonic conductance, Peclet & Sweby TVD shock-capturing schemes, Fast Sine & Geometric Multigrid elliptic solvers, exact Riemann solvers for Burgers/Shallow-Water/Euler shocks, Chorin & staggered MAC Navier–Stokes projection, Ghia-verified vorticity–streamfunction cavities, and mesoscale D2Q9 Lattice Boltzmann porous-media and conjugate microreactor engineering.