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 · 0. Conservation laws, dimensionless groups and time-step limits

School of Engineering, Nazarbayev University

Worked solutions to the three exercises of Lecture 0. 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. Across all 10 fluids in constants.FLUIDS_DB at U=0.25 m/sU = 0.25\ \mathrm{m/s} and L=0.04 mL = 0.04\ \mathrm{m}, verify PeT/Re=μcp/k\mathrm{Pe}_T / \mathrm{Re} = \mu c_p / k to <10−13< 10^{-13} relative error, and programmatically identify all fluids satisfying (a) Re>104\mathrm{Re} > 10^4 with PeT<103\mathrm{Pe}_T < 10^3 and (b) Re<20\mathrm{Re} < 20 with PeT>5×104\mathrm{Pe}_T > 5\times 10^4.


Exercise 1: Prandtl-Peclet Closure & Regime Inversion Across 10 Fluids
======================================================================
liquid_sodium_673K   | Re =   30140.845 | Pe_T =     151.310 | rel_err = 0.00e+00
mercury_298K         | Re =   88689.384 | Pe_T =    2274.690 | rel_err = 1.35e-16
methane_298K         | Re =     592.960 | Pe_T =     428.880 | rel_err = 1.53e-16
air_298K             | Re =     640.346 | Pe_T =     467.564 | rel_err = 0.00e+00
steam_473K           | Re =     286.420 | Pe_T =     274.371 | rel_err = 1.16e-16
co2_supercritical    | Re =  131589.958 | Pe_T =  332405.839 | rel_err = 0.00e+00
water_298K           | Re =   11202.809 | Pe_T =   68676.541 | rel_err = 1.45e-16
ethanol_298K         | Re =    7309.125 | Pe_T =  114694.611 | rel_err = 1.13e-16
engine_oil_313K      | Re =      41.714 | Pe_T =  119476.667 | rel_err = 0.00e+00
glycerol_298K        | Re =      13.274 | Pe_T =  107384.105 | rel_err = 1.12e-16

Regime (a) [Re > 1e4 & Pe_T < 1e3]: ['liquid_sodium_673K']
Regime (b) [Re < 20  & Pe_T > 5e4]: ['glycerol_298K']

Explanation. Because ρ\rho cancels in PeT/Re=(UL/α)/(UL/ν)=ν/α=μcp/k\mathrm{Pe}_T / \mathrm{Re} = (UL/\alpha)/(UL/\nu) = \nu/\alpha = \mu c_p / k, the ratio of thermal-to-momentum Péclet numbers is a pure material property (Pr\mathrm{Pr}). Only liquid_sodium_673K (Pr=0.0050\mathrm{Pr} = 0.0050, Re=30 141,PeT=151.3\mathrm{Re} = 30\,141, \mathrm{Pe}_T = 151.3) combines high-Re\mathrm{Re} turbulence with PeT<103\mathrm{Pe}_T < 10^3, while the very viscous glycerol_298K (Pr=8090\mathrm{Pr} = 8090) has a very large thermal Péclet number (PeT=107 384\mathrm{Pe}_T = 107\,384) inside slow laminar flow (Re=13.27\mathrm{Re} = 13.27).


Exercise 2

Problem. Quantify the error factor when dynamic viscosity μ [Pa⋅s]\mu\ [\mathrm{Pa\cdot s}] is mistakenly passed instead of ν [m2/s]\nu\ [\mathrm{m^2/s}] into reynolds_number for water_298K and mercury_298K, evaluate the unphysical center-node stencil weight 1−6r1 - 6r when the 1-D limit r=0.5r = 0.5 is used in 3-D explicit FTCS diffusion, and verify ValueError guards.


Exercise 2: mu-vs-nu Unit Bug & 3-D Explicit Diffusion Blowup
=============================================================
water_298K     | True Re =    56014.0 | Buggy Re(mu) =   56.18 | Underpredicted by 997.05x (= rho)
mercury_298K   | True Re =   443446.9 | Buggy Re(mu) =   32.77 | Underpredicted by 13,534.00x (= rho)

Using 1-D limit r = 0.5 in 3-D: center weight = -2.0, checkerboard |G| = 5.0 (> 1 => explodes 5^n)

Explanation. Passing μ\mu in place of ν=μ/ρ\nu = \mu/\rho omits density ρ\rho, underpredicting Re\mathrm{Re} by 997×997\times in water and 13 534×13\,534\times in mercury (which classifies a Re=4.4×105\mathrm{Re} = 4.4\times 10^5 turbulent mercury pipe as laminar Re=32.8\mathrm{Re} = 32.8). In 3-D explicit FTCS diffusion, applying r=0.5r = 0.5 makes the center weight 1−6r=−21 - 6r = -2 and amplifies the (−1)i+j+k(-1)^{i+j+k} checkerboard mode by ∣1−12r∣=5×|1 - 12r| = 5\times every time step.


Exercise 3

Problem. Implement explicit_advection_diffusion_dt_max(u_m_s, diffusivity_m2_s, dx_m, ndim=1, safety=0.9) enforcing CFL+2dr=safety\mathrm{CFL} + 2 d r = \mathrm{safety}, and verify exact identity closure plus asymptotic log-slopes of 1.0 (advection regime) and 2.0 (diffusion regime).


Exercise 3: Implement It Yourself — Multi-D Positivity-Preserving Explicit Step Selector
========================================================================================
Coarse-grid log-slope (Pe_dx >> 1): 1.00431 (exact asymptotic = 1.0)
Fine-grid   log-slope (Pe_dx << 1): 1.99760 (exact asymptotic = 2.0)

Summary. Combining convective and dd-dimensional diffusive inverse time scales additively (Δt−1∝∣u∣/Δx+2dΓ/Δx2\Delta t^{-1} \propto |u|/\Delta x + 2 d \Gamma / \Delta x^2) guarantees discrete maximum-principle positivity across every grid resolution without ad-hoc min(dt_cfl, dt_diff) corner instabilities at Δx≈Δx∗\Delta x \approx \Delta x^*.