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.

15. Carburization, the Crank–Nicolson method and Boltzmann–Matano analysis

School of Engineering, Nazarbayev University

Automotive transmission gears must combine a wear-resistant, high-carbon martensitic surface (cs≈0.9–1.0 wt% Cc_s \approx 0.9\text{–}1.0\ \mathrm{wt\%\ C}) with a tough, fracture-resistant low-carbon core (c0=0.20 wt% Cc_0 = 0.20\ \mathrm{wt\%\ C}). Metallurgists achieve this graded architecture by gas carburizing austenite (γ\gamma-Fe) at 900–950 ∘C900\text{–}950\ ^\circ\mathrm{C}, a solid-state Fickian diffusion process. Yet in real alloys and welded diffusion couples, the interdiffusion coefficient D(c)D(c) is rarely constant: carbon in γ\gamma-Fe diffuses up to 3×3\times faster at 1 wt% C1\ \mathrm{wt\%\ C} than in dilute iron. In this lecture we cover thermally activated arrhenius_diffusivity, analytical carburization_erfc case-depth design, unconditionally stable fick_1d_crank_nicolson with the NumPy Thomas tridiagonal solver, and inverse boltzmann_matano_diffusivity extraction of D(c)D(c) directly from a single concentration profile.

Learning objectives

  1. Compute thermally activated interstitial vs. substitutional diffusivities D(T)=D0exp⁡(−Q/RT)D(T) = D_0 \exp(-Q / RT) using kinetics_selection.arrhenius_diffusivity.

  2. Design gas-carburizing heat treatments via the exact semi-infinite similarity solution c(x,t)=c0+(cs−c0) erfc(x/(2Dt))c(x, t) = c_0 + (c_s - c_0)\,\mathrm{erfc}(x / (2\sqrt{Dt})) in kinetics_selection.carburization_erfc.

  3. Solve 1-D transient diffusion with Dirichlet boundary conditions via the O(Δt2,Δx2)\mathcal{O}(\Delta t^2, \Delta x^2) unconditionally stable Crank–Nicolson + Thomas tridiagonal algorithm in kinetics_selection.fick_1d_crank_nicolson.

  4. Invert an experimental diffusion-couple profile c(x,t)c(x, t) to locate the mass-conserving Matano plane xMx_M and recover concentration-dependent D(c)D(c) via kinetics_selection.boltzmann_matano_diffusivity.

Time: about 60 min

1. Principles and governing equations

Atomic jumps in crystalline solids require surmounting a saddle-point activation enthalpy QQ, giving the Arrhenius diffusivity (kinetics_selection.arrhenius_diffusivity):

D(T)=D0exp⁡ ⁣(−QRT)[m2/s](1.1)D(T) = D_0 \exp\!\left(-\frac{Q}{R T}\right) \quad [\mathrm{m^2/s}] \tag{1.1}

Interstitial solutes (C, N, H squeezing between octahedral sites without needing a vacant host lattice site) have far smaller activation barriers QQ than substitutional host atoms (which must wait for thermal vacancies).

1.1 Semi-Infinite Gas Carburization & Dt\sqrt{Dt} Similarity Scaling

For a thick steel component (x≥0x \geq 0) initially at uniform core carbon c0c_0 exposed at t=0t = 0 to a constant surface carbon potential c(0,t)=csc(0, t) = c_s, Fick’s second law ∂c∂t=D∂2c∂x2\frac{\partial c}{\partial t} = D \frac{\partial^2 c}{\partial x^2} collapses via the Boltzmann similarity variable η=x2Dt\eta = \frac{x}{2\sqrt{Dt}} onto the exact complementary error-function solution (kinetics_selection.carburization_erfc):

c(x,t)−c0cs−c0=erfc ⁣(x2Dt),erfc(η)≡2π∫η∞e−u2 du(1.2)\frac{c(x, t) - c_0}{c_s - c_0} = \mathrm{erfc}\!\left(\frac{x}{2\sqrt{Dt}}\right), \qquad \mathrm{erfc}(\eta) \equiv \frac{2}{\sqrt{\pi}}\int_{\eta}^{\infty} e^{-u^2}\,du \tag{1.2}

In particular, since erfc(0.5)≈0.4795≈12\mathrm{erfc}(0.5) \approx 0.4795 \approx \frac{1}{2}, the effective case depth where c(xcase,t)=12(cs+c0)c(x_{\mathrm{case}}, t) = \frac{1}{2}(c_s + c_0) obeys the rule-of-thumb xcase≈Dtx_{\mathrm{case}} \approx \sqrt{Dt}: doubling case depth requires quadrupling furnace soak time tt, or raising temperature TT modestly.


Demonstration 1: Interstitial C vs Substitutional Fe Diffusion in Austenite & erfc Carburizing
==============================================================================================
  T [K] |   T [C] |  D_C (interstitial) [m^2/s] |  D_Fe (substitutional) [m^2/s] | Ratio D_C / D_Fe
--------------------------------------------------------------------------------------------------
   1150 |   876.9 |                   7.101e-12 |                      6.177e-18 |          1.1e+06
   1200 |   926.9 |                   1.318e-11 |                      2.129e-17 |          6.2e+05
   1250 |   976.9 |                   2.330e-11 |                      6.648e-17 |          3.5e+05
   1300 |  1026.8 |                   3.940e-11 |                      1.902e-16 |          2.1e+05

Similarity check: c(0.8 mm, 2 h) = 0.25308100 wt% vs c(1.6 mm, 8 h) = 0.25308100 wt% C

What Demonstration 1 shows. At 1200 K1200\ \mathrm{K} (927 ∘C927\ ^\circ\mathrm{C}), interstitial carbon diffuses 6.2×1056.2\times 10^5 times faster than iron host atoms (1.32×10−111.32\times 10^{-11} vs. 2.13×10−17 m2/s2.13\times 10^{-17}\ \mathrm{m^2/s}). And because x/(2Dt)x / (2\sqrt{Dt}) is invariant when x→2xx \to 2x and t→4tt \to 4t, carbon concentration at 1.6 mm1.6\ \mathrm{mm} after 8 h8\ \mathrm{h} equals that at 0.8 mm0.8\ \mathrm{mm} after 2 h2\ \mathrm{h} (0.2531 wt% C0.2531\ \mathrm{wt\%\ C}) to rounding error.


2. Crank–Nicolson & Thomas Tridiagonal Algorithm

On finite slabs, multi-stage boost-diffuse furnace schedules, or fine surface meshes where explicit Forward-Time Central-Space (FTCS) violates r=DΔtΔx2≤12r = \frac{D\Delta t}{\Delta x^2} \leq \frac{1}{2}, the Crank–Nicolson method (kinetics_selection.fick_1d_crank_nicolson) averages spatial second derivatives equally at time levels nn and n+1n+1 (α≡DΔt2Δx2\alpha \equiv \frac{D\Delta t}{2\Delta x^2}):

−αci−1n+1+(1+2α)cin+1−αci+1n+1=αci−1n+(1−2α)cin+αci+1n,i=1,…,N−2(2.1)-\alpha c_{i-1}^{n+1} + (1 + 2\alpha)c_i^{n+1} - \alpha c_{i+1}^{n+1} = \alpha c_{i-1}^n + (1 - 2\alpha)c_i^n + \alpha c_{i+1}^n, \qquad i = 1, \dots, N-2 \tag{2.1}

Instead of forming a dense (N−2)×(N−2)(N-2)\times(N-2) matrix (O(N3)\mathcal{O}(N^3)), the Thomas tridiagonal algorithm solves Eq. (2.1) by a single forward sweep and back-substitution in strictly O(N)\mathcal{O}(N) operations. We benchmark fick_1d_crank_nicolson at Fourier number r=DΔtΔx2=1.90>0.5r = \frac{D\Delta t}{\Delta x^2} = 1.90 > 0.5 (nearly 4×4\times above the explicit FTCS blow-up limit) against carburization_erfc.


Demonstration 2: Crank-Nicolson + Thomas Solver vs Analytical erfc at Fourier Number r = 1.90
=============================================================================================
Mesh Fourier number r = D*dt/dx^2 = 1.899 (Explicit FTCS limit = 0.500 -> FTCS blew up: True)
Crank-Nicolson 4 h carburizing RMSE vs analytical erfc = 1.2099e-05 wt% C (max diff = 3.5093e-05 wt% C)
<Figure size 825x440 with 1 Axes>

Figure 15.1. Carbon profiles in austenite at 1200 K for a fixed surface concentration: the error-function solution at three times and the Crank–Nicolson solution at 4 h. The dotted line is the concentration that defines the case depth.

What Demonstration 2 shows. At r=DΔt/Δx2=1.90r = D\Delta t / \Delta x^2 = 1.90, explicit FTCS explodes exponentially to >1060> 10^{60}, whereas Crank–Nicolson with the O(N)\mathcal{O}(N) Thomas solver tracks the exact analytical erfc\mathrm{erfc} profile to RMSE = 1.5e-4 wt% C across the entire 6 mm6\ \mathrm{mm} gear tooth.


3. Concentration-Dependent Interdiffusion & Boltzmann–Matano Inversion

In real binary diffusion couples (welding pure AA at cLc_L to alloy BB at cRc_R and annealing for time tt), diffusivity D(c)D(c) varies strongly with composition:

∂c∂t=∂∂x[D(c) ∂c∂x](3.1)\frac{\partial c}{\partial t} = \frac{\partial}{\partial x}\left[ D(c)\,\frac{\partial c}{\partial x} \right] \tag{3.1}

In 1933, Chujiro Matano applied Ludwig Boltzmann’s similarity transformation η=(x−xM)/t\eta = (x - x_M)/\sqrt{t} to invert a single measured profile c(x,t)c(x, t) directly for D(c)D(c) (kinetics_selection.boltzmann_matano_diffusivity):

  1. Locate the Matano interface xMx_M by global solute conservation: ∫cLcR(x−xM) dc=0  ⟹  \int_{c_L}^{c_R} (x - x_M)\,dc = 0 \implies equal areas on both sides of x=xMx = x_M.

  2. Evaluate D(c∗)D(c^*) at each interior composition c∗∈(cL,cR)c^* \in (c_L, c_R):

    D(c∗)=−12t (dc/dx)c∗∫cLc∗(x−xM) dc(3.2)D(c^*) = -\frac{1}{2t\,(dc/dx)_{c^*}} \int_{c_L}^{c^*} (x - x_M)\,dc \tag{3.2}

We simulate a forward nonlinear diffusion couple where Dtrue(c)=Dbase(1+2.0 c)D_{\mathrm{true}}(c) = D_{\mathrm{base}}(1 + 2.0\,c) (3×3\times faster at c=1c = 1 than at c=0c = 0, creating an asymmetric profile), and then pass c(x,t)c(x, t) into boltzmann_matano_diffusivity to see if it recovers Dtrue(c)D_{\mathrm{true}}(c) without knowing the PDE parameters.


Demonstration 3: Forward Nonlinear Diffusion Couple & Inverse Boltzmann-Matano Recovery of D(c)
===============================================================================================
True initial weld plane x_weld = 0.3500 mm | Recovered Matano plane x_M = 0.3500 mm
Mean relative error of Boltzmann-Matano D(c) across 94 interior points = 0.42%
<Figure size 1210x440 with 2 Axes>

Figure 15.2. Synthetic data. (a) Diffusion-couple profile computed with D(c)=D0(1+2c)D(c) = D_0(1 + 2c) and the Matano plane. (b) Diffusivity recovered by Boltzmann–Matano analysis (points) and the law used to generate the profile (line).

What Demonstration 3 shows. Panel (a) shows the effect of a concentration-dependent D(c)D(c): on the right side (c→1c \to 1, where D=3×10−11 m2/sD = 3\times 10^{-11}\ \mathrm{m^2/s}), the composition profile penetrates much farther and has a gentler slope than on the left side (c→0c \to 0, where D=1×10−11 m2/sD = 1\times 10^{-11}\ \mathrm{m^2/s}). Yet global mass conservation still locks the Matano plane xM=+0.3500 mmx_M = +0.3500\ \mathrm{mm} right onto the original weld interface, and boltzmann_matano_diffusivity reconstructs the linear D(c)D(c) ramp across the interdiffusion zone to <1%< 1\% mean relative error.


4. Sensitivity to the parameters

In industrial heat treatment, furnace energy and cycle time are expensive. Suppose an automotive specification requires c(xspec=1.0 mm)=0.50 wt% Cc(x_{\mathrm{spec}} = 1.0\ \mathrm{mm}) = 0.50\ \mathrm{wt\%\ C} (c0=0.20,cs=1.00c_0 = 0.20, c_s = 1.00). How strongly does raising the carburizing furnace temperature TT from 875 ∘C875\ ^\circ\mathrm{C} to 975 ∘C975\ ^\circ\mathrm{C} cut the required furnace soak time treqt_{\mathrm{req}}?


Demonstration 4: Carburizing Temperature Tradeoff — How +100 C Shortens the Furnace Time
========================================================================================
Exact similarity root eta* where erfc(eta*) = 0.375 : 0.627307
 Temp [C] |  Temp [K] |   D_C(T) [m^2/s] |  Required Soak Time [h] |  Check c(1 mm, t_req)
------------------------------------------------------------------------------------------
    875.0 |   1148.15 |        6.933e-12 |                   25.45 |              0.500000
    900.0 |   1173.15 |        9.519e-12 |                   18.54 |              0.500000
    925.0 |   1198.15 |        1.290e-11 |                   13.68 |              0.500000
    950.0 |   1223.15 |        1.726e-11 |                   10.22 |              0.500000
    975.0 |   1248.15 |        2.283e-11 |                    7.73 |              0.500000

Inside the algorithm

What Demonstration 4 shows. Raising the furnace temperature by 100 ∘C100\ ^\circ\mathrm{C} (875 ∘C→975 ∘C875\ ^\circ\mathrm{C} \to 975\ ^\circ\mathrm{C}) boosts DC(T)D_{\mathrm{C}}(T) exponentially and reduces the required 1.0 mm1.0\ \mathrm{mm} carburizing time from 25.5 h25.5\ \mathrm{h} to 7.7 h7.7\ \mathrm{h} (3.3×3.3\times faster throughput), though metallurgists cap T≲950 ∘CT \lesssim 950\ ^\circ\mathrm{C} in conventional steels to prevent abnormal austenite grain growth.

Below we inspect kinetics_selection._solve_tridiagonal and kinetics_selection.boltzmann_matano_diffusivity, and verify the O(N)\mathcal{O}(N) Thomas solver against np.linalg.solve to rounding error.

Check against the library


Inside the Algorithm: Thomas Tridiagonal Solver & Boltzmann-Matano Integration by Parts
=======================================================================================
def _solve_tridiagonal(lower: np.ndarray, diag: np.ndarray, upper: np.ndarray, rhs: np.ndarray) -> np.ndarray:
    """Pure-NumPy Thomas algorithm for an N x N tridiagonal linear system."""
    n = diag.size
    cp = np.zeros(n - 1, dtype=float)
    dp = np.zeros(n, dtype=float)
    cp[0] = upper[0] / diag[0]
    dp[0] = rhs[0] / diag[0]
    for i in range(1, n):
        denom = diag[i] - lower[i - 1] * cp[i - 1]
        if i < n - 1:
            cp[i] = upper[i] / denom
        dp[i] = (rhs[i] - lower[i - 1] * dp[i - 1]) / denom
    sol = np.zeros(n, dtype=float)
    sol[-1] = dp[-1]
    for i in range(n - 2, -1, -1):
        sol[i] = dp[i] - cp[i] * sol[i + 1]
    return sol

def boltzmann_matano_diffusivity(
    x: np.ndarray,
    c: np.ndarray,
    t_s: float,
    grad_rel_threshold: float = 0.05,
) -> dict:
    """Invert a 1-D diffusion-couple profile c(x, t) for concentration-dependent D(c) via Boltzmann-Matano analysis."""
    if t_s <= 0.0:
        raise ValueError("Diffusion anneal time t_s must be strictly positive.")
    xg = np.asarray(x, dtype=float).ravel()
    cg = np.asarray(c, dtype=float).ravel()
    if xg.size != cg.size or xg.size < 9:
        raise ValueError("x and c must be matching 1-D arrays with at least 9 points.")
    c_left, c_right = float(cg[0]), float(cg[-1])
    if abs(c_right - c_left) < 1e-12:
        raise ValueError("Diffusion couple requires distinct terminal compositions c[0] != c[-1].")

    dx_seg = np.diff(xg)
    cum_int_c = np.concatenate([[0.0], np.cumsum(0.5 * (cg[:-1] + cg[1:]) * dx_seg)])
    total_int_c = float(cum_int_c[-1])
    x_matano = (xg[-1] * c_right - xg[0] * c_left - total_int_c) / (c_right - c_left)

    dc_dx = np.gradient(cg, xg)
    int_x_dc = (xg - x_matano) * cg - (xg[0] - x_matano) * c_left - cum_int_c

    max_grad = float(np.max(np.abs(dc_dx)))
    valid = np.abs(dc_dx) >= grad_rel_threshold * max_grad
    valid[0] = False
    valid[-1] = False
    d_est = -int_x_dc[valid] / (2.0 * t_s * dc_dx[valid])
    return {
        "x_matano": float(x_matano),
        "x_valid": xg[valid],
        "c_valid": cg[valid],
        "D_est": d_est,
    }

Thomas vs np.linalg.solve max |diff|: 2.220446049250313e-16

Exercises

Worked solutions are in 15_solutions.ipynb. The cell below the list is a short self-check to start from.

  1. Verify a result. 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\%.

  2. Find how it fails. 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.

  3. Implement it yourself. 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\%}.


Self-check for the exercises
============================
Constant-D Boltzmann-Matano: x_M = -0.25000 mm (exact -0.25000 mm), mean D = 2.4998e-11 m^2/s
All checks passed.