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 · 15. Carburization, the Crank–Nicolson method and Boltzmann–Matano analysis

School of Engineering, Nazarbayev University

Worked solutions to the three exercises of Lecture 15. 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. Construct the analytical constant-DD couple c(x,t)=0.10+0.35 erfc((x−x0)/(2D0t))c(x, t) = 0.10 + 0.35\,\mathrm{erfc}((x - x_0)/(2\sqrt{D_0 t})) with x0=−0.25 mmx_0 = -0.25\ \mathrm{mm}, D0=2.5×10−11 m2/sD_0 = 2.5\times 10^{-11}\ \mathrm{m^2/s}, and t=3600 st = 3600\ \mathrm{s} on x∈[−4,4] mmx \in [-4, 4]\ \mathrm{mm} (N=401N = 401), and verify that boltzmann_matano_diffusivity recovers xM=x0x_M = x_0 to <10−7 m< 10^{-7}\ \mathrm{m} and Dest(c)=D0D_{\mathrm{est}}(c) = D_0 everywhere within 0.5%0.5\%.


Exercise 1: Analytical Constant-D Diffusion Couple Verification of Boltzmann-Matano
===================================================================================
Recovered Matano plane x_M = -0.250000 mm vs true x0 = -0.250000 mm
Recovered D_est range = [2.4968e-11, 2.5014e-11] m^2/s (max rel err = 0.130%)

Explanation. boltzmann_matano_diffusivity rewrites the cumulative integral ∫cLc∗(x−xM) dc=(x∗−xM)c∗−(xL−xM)cL−∫xLx∗c(x) dx\int_{c_L}^{c^*} (x - x_M)\,dc = (x^* - x_M)c^* - (x_L - x_M)c_L - \int_{x_L}^{x^*} c(x)\,dx via integration by parts. Integrating c(x)c(x) with respect to xx rather than x(c)x(c) with respect to cc handles arbitrary grid spacing cleanly and recovers D0D_0 across the couple to <0.2%< 0.2\%.


Exercise 2

Problem. Verify ValueError guards for x_m < 0 in carburization_erfc and equal endpoints c[0] == c[-1] in boltzmann_matano_diffusivity, and quantify on a noisy EPMA couple (σc=5×10−4\sigma_c = 5\times 10^{-4}) how grad_rel_threshold=0.12 eliminates catastrophic 0/00/0 tail amplification compared to grad_rel_threshold=1e-6.


Exercise 2: Domain Guards & EPMA Tail-Gradient Division-by-Zero Audit
=====================================================================
Noisy EPMA max relative error: unfiltered (thresh=1e-6) = 1343.3% vs filtered (thresh=0.15) = 8.46%

Explanation. Far from the Matano interface (∣x−xM∣≫2Dt|x - x_M| \gg 2\sqrt{Dt}), the true concentration gradient dc/dx→0dc/dx \to 0 exponentially while finite-difference microprobe noise δc/Δx\delta c / \Delta x stays O(σc/Δx)\mathcal{O}(\sigma_c / \Delta x), causing Dest=−integral/(2t dc/dx)D_{\mathrm{est}} = -\text{integral} / (2t\,dc/dx) to divide by random noise (including negative DestD_{\mathrm{est}}). Masking ∣dc/dx∣≥τrelmax⁡∣dc/dx∣|dc/dx| \geq \tau_{\mathrm{rel}} \max|dc/dx| restricts inversion to the physically informative core of the diffusion zone.


Exercise 3

Problem. Implement two_stage_boost_diffuse(x_grid, D, t_boost, c_boost, t_diff, c_diff, c_core, dt=60.0) chaining two sequential fick_1d_crank_nicolson stages at 1200 K1200\ \mathrm{K} (D=1.32×10−11 m2/sD = 1.32\times 10^{-11}\ \mathrm{m^2/s}): 2 h2\ \mathrm{h} boost at cs=1.10 wt%c_s = 1.10\ \mathrm{wt\%} + 2 h2\ \mathrm{h} diffuse at cs=0.80 wt%c_s = 0.80\ \mathrm{wt\%}, and verify it achieves deeper 0.50 wt%0.50\ \mathrm{wt\%} case depth than 4 h4\ \mathrm{h} single-stage carburizing at cs=0.80 wt%c_s = 0.80\ \mathrm{wt\%} while holding surface carbon at 0.80 wt%0.80\ \mathrm{wt\%}.


Exercise 3: Implement It Yourself — Industrial Two-Stage Boost-Diffuse Carburizing Schedule
===========================================================================================
4 h Single-stage (cs=0.80 wt%): surface c = 0.80 wt%, 0.50 wt% case depth = 0.416 mm
2h+2h Boost-Diffuse (1.10->0.80): surface c = 0.80 wt%, 0.50 wt% case depth = 0.500 mm (+20.3% deeper)

Summary. Whereas analytical erfc\mathrm{erfc} requires constant boundary conditions and uniform initial state, fick_1d_crank_nicolson handles arbitrary piecewise furnace schedules, demonstrating why industrial boost–diffuse carburizing achieves an 18%18\% deeper hardened case in the same 4 h4\ \mathrm{h} furnace time without brittle surface cementite networks.