---
title: Transport and heat flow lab
heading: Dopant diffusion, transient heating of a die, pulse trains through a thermal network and a Monte Carlo of Drude drift, in Python
eyebrow: B11 · Lesson 47 · Transport lab
xp: 50
---

::: hook
Lessons 41 to 46 described transport with a few equations: diffusion spreads as $\sqrt{Dt}$, heat obeys the same law with thermal diffusivity, thermal circuits have time constants, and carriers drift at $\frac{q\tau}{m}E$. Real process and package engineers solve those equations numerically, on grids and with sums over networks. In this lab you'll diffuse dopants with an explicit finite-difference scheme and check it against erfc and Gaussian profiles, heat a silicon die from its surface and watch it pass from the semi-infinite formula to steady state, push a pulse train through a Foster network, and find out by Monte Carlo why Drude's drift velocity has no factor of ½.
:::

::: play
- Two dopant profiles on a log scale. The solid one is a constant-source predeposition, $C_s\,\text{erfc}\frac{x}{2\sqrt{Dt}}$. The dashed one is what the same dose becomes after a drive-in with the same Dt, a Gaussian.
- The slider sets the diffusion length $\sqrt{Dt}$. The marker is a $10^{15}$ cm⁻³ background, and each profile's junction is where it crosses it.
- The readouts give the dose and the drive-in's junction depth. Steps 1 and 2 reproduce both profiles on a grid.
:::

```sim plot
view: graph
x: x = 0..3 µm
y: C = 1e14..1e21 log
slider: L = 0.02..0.6 step 0.01 = 0.1 µm
slider: s = 1e18..1e21 = 1e20 log
plot: s*erfc(x/(2*L)) | label: predeposition, erfc | samples: 600
plot: (2*s*L/sqrt(pi))/(sqrt(pi)*L)*exp(-x^2/(4*L^2)) | dashed | color: ch2 | label: after drive-in, Gaussian | samples: 600
marker: C = 1e15 | label: background
readout: dose, cm⁻² = 2*s*L*1e-4/sqrt(pi) | digits: 3
readout: drive-in junction depth, µm = 2*L*sqrt(ln((2*s/pi)/1e15)) | digits: 3
```

::: predict
## Carriers accelerate freely between collisions, which come on average every τ. A naive argument says the average velocity gained is $\frac12\frac{qE}{m}\tau$. What does a careful average give?

- [ ] $\frac12\frac{qE}{m}\tau$, as argued
- [x] $\frac{qE}{m}\tau$
- [ ] $2\frac{qE}{m}\tau$
- [ ] It depends on the temperature

::: reveal
$\frac{qE}{m}\tau$. Free flights have exponentially distributed lengths, and the drift comes from the distance covered in each, $\frac12as^2$, averaged over time. Long flights cover far more distance, and $\langle s^2\rangle = 2\tau^2$, so the drift is $\frac{a\langle s^2\rangle}{2\langle s\rangle} = a\tau$. Step 5 checks it by simulating a million flights.
:::
:::

::: nameit
## Explicit finite differences

On a grid of spacing Δx with time step Δt, the diffusion equation $\frac{\partial C}{\partial t} = D\frac{\partial^2C}{\partial x^2}$ becomes

$$C_i^{n+1} = C_i^n + r\left(C_{i+1}^n - 2C_i^n + C_{i-1}^n\right), \qquad r = \frac{D\Delta t}{\Delta x^2},$$

stable only for r ≤ ½ (the von Neumann analysis in A12). A fixed surface concentration is a fixed $C_0$; a sealed surface, where no dopant escapes, is zero slope, handled with a mirror point $C_{-1} = C_1$; and a heat flux q into a surface adds $\frac{2r\,\Delta x\,q}{\kappa}$ to the surface node each step.

## Predeposition and drive-in

A constant surface concentration gives $C_s\,\text{erfc}\frac{x}{2\sqrt{Dt}}$, with dose $Q = \frac{2C_s\sqrt{Dt}}{\sqrt\pi}$. A fixed dose diffused further, with the surface sealed, gives a Gaussian $\frac{Q}{\sqrt{\pi Dt}}e^{-x^2/4Dt}$, whose junction against a background $C_B$ is at $x_j = 2\sqrt{Dt\ln\frac{Q}{C_B\sqrt{\pi Dt}}}$.

## Heating a die

A flux q switched on at the surface of a thick slab raises the surface by $2q\sqrt{\frac{t}{\pi\kappa\rho c}}$ at first, while heat hasn't reached the bottom; after a few times $\frac{L^2}{\alpha}$, with $\alpha = \frac{\kappa}{\rho c}$, it settles at $\frac{qL}{\kappa}$. Compact models replace the slab with a **Foster network**, $Z(t) = \sum_iR_i(1 - e^{-t/\tau_i})$, fitted to measured heating curves. Because conduction is linear, a pulse train's response is a sum of shifted single responses: after n pulses of power P, length $t_p$ and period T,

$$\Delta T_{peak} = P\sum_{k=0}^{n-1}\left[Z(t_p + kT) - Z(kT)\right].$$

## Drude by Monte Carlo

Give each free flight a random length s from an exponential distribution with mean τ, a random starting velocity, and constant acceleration a = qE/m. The drift is the total displacement over the total time, $\frac{\sum(v_0s + \frac12as^2)}{\sum s}$, which tends to aτ.
:::

::: example
## A boron dose of $10^{14}$ cm⁻² is driven in at D = $10^{-13}$ cm²/s for one hour into $10^{15}$ cm⁻³ n-type silicon. What are the peak concentration and the junction depth?

::: solution
1. **Diffusion length squared.**
   $$Dt = 3.6 \times 10^{-10}\ \text{cm}^2$$
2. **Peak concentration.** The peak is at the surface:
   $$\begin{aligned} C_{peak} &= \frac{Q}{\sqrt{\pi Dt}} \\ &= \frac{10^{14}}{3.36 \times 10^{-5}} \\ &= 2.97 \times 10^{18}\ \text{cm}^{-3} \end{aligned}$$
3. **Junction depth.** The junction is where the Gaussian falls to $10^{15}$:
   $$\begin{aligned} x_j &= 2\sqrt{Dt\ln(2970)} \\ &= 2\sqrt{3.6 \times 10^{-10} \times 8.00} \\ &= 1.07 \times 10^{-4}\ \text{cm} \end{aligned}$$
   or 1.07 µm.
4. **Compare with the diffusion length.** The diffusion length $\sqrt{Dt}$ is only 0.19 µm; the logarithm of the large peak-to-background ratio pushes the junction more than five times deeper.

**Answer:** the peak is 2.97 × 10¹⁸ cm⁻³ at the surface, and the junction is 1.07 µm deep.
:::
:::

::: example
## A hot spot on a thick silicon die dissipates 100 W/cm². How much does its surface warm in the first millisecond? Take κ = 150 W/(m·K) and ρc = 1.64 × 10⁶ J/(m³·K).

::: solution
1. **Treat the die as semi-infinite.** While the heat hasn't spread far,
   $$\begin{aligned} \Delta T &= 2q\sqrt{\frac{t}{\pi\kappa\rho c}} \\ &= 2 \times 10^6\sqrt{\frac{10^{-3}}{\pi \times 150 \times 1.64 \times 10^6}} \\ &= 2.3\ \text{K} \end{aligned}$$
2. **How far the heat has spread.** With $\alpha = 9.1 \times 10^{-5}$ m²/s,
   $$\sqrt{\alpha t} = 0.30\ \text{mm}$$
3. **Pulses against steady power.** The rise grows only as $\sqrt t$ at first, which is why short pulses are so much easier on a die than steady power: the same 100 W/cm² held steady through a 0.5 mm die would add 3.3 K, and through the package far more.

**Answer:** the surface warms about 2.3 K in the first millisecond.
:::
:::

::: example
## A die with Foster network R = 0.2, 0.5, 1.0 K/W and τ = 1, 10, 100 ms takes 50 W pulses 5 ms long every 20 ms. How hot does it get on the first pulse, after 10, and in the long run?

::: solution
1. **The first pulse.**
   $$\begin{aligned} P\,Z(5\ \text{ms}) &= 50 \times 0.444 \\ &= 22.2\ \text{K} \end{aligned}$$
2. **After 10 pulses and in the long run.** Superposing shifted responses, the peak after 10 pulses is 32.9 K, and after 200 it has settled at 34.8 K.
3. **Compare with the average.** The average power is 12.5 W, which through the total 1.7 K/W gives 21.3 K; the peaks ride 13.5 K above that because the fast stages, 1 and 10 ms, follow each pulse.
4. **What each shortcut misses.** Rating a part by average power alone would miss that ripple, and reading only the single-pulse curve would miss the 12.6 K the slow stage accumulates.

**Answer:** the peak rise is 22.2 K on the first pulse, 32.9 K after 10, and 34.8 K in the long run.
:::
:::

::: check
kind: python

## Step 1. Write `predep(D, t, L, nx)` simulating diffusion on [0, L] with nx points, C = 1 held at x = 0 and C = 0 at x = L, starting empty, with r = 0.4. Return `(x, C)` at time t.

```python starter
import numpy as np

def predep(D, t, L, nx):
    x = np.linspace(0, L, nx)
    return x, np.zeros(nx)

x, C = predep(1.0, 1.0, 10.0, 201)
print(C[20])
```

```python solution
import numpy as np

def predep(D, t, L, nx):
    x = np.linspace(0, L, nx)
    dx = x[1] - x[0]
    dt = 0.4 * dx * dx / D
    steps = int(round(t / dt))
    dt = t / steps
    r = D * dt / dx**2
    C = np.zeros(nx)
    C[0] = 1.0
    for _ in range(steps):
        C[1:-1] = C[1:-1] + r * (C[2:] - 2 * C[1:-1] + C[:-2])
        C[0], C[-1] = 1.0, 0.0
    return x, C

x, C = predep(1.0, 1.0, 10.0, 201)
print(C[20])
```

```python tests
import math
import numpy as np
x, C = predep(1.0, 1.0, 10.0, 201)
exact = np.array([math.erfc(xi / 2) for xi in x])
assert np.max(np.abs(C - exact)) < 0.005, f"The grid should match erfc(x/2√(Dt)) within 0.005; worst {np.max(np.abs(C - exact))}"
assert abs(C[20] - 0.4795) < 0.003, "At x = 1 the profile is erfc(0.5) = 0.4795."
```

::: right
Right. With r = 0.4 the explicit scheme is stable and its error shrinks as Δx².
:::
:::

::: check
kind: python

## Step 2. Write `drive_in(D, t, Q, L, nx)` putting a dose Q into the first grid cell at t = 0, diffusing with a sealed surface (mirror point) and C = 0 at x = L, with r = 0.4. Return `(x, C, dose)`, the dose being the trapezoid integral of C.

```python starter
import numpy as np

def drive_in(D, t, Q, L, nx):
    x = np.linspace(0, L, nx)
    return x, np.zeros(nx), 0.0

x, C, q = drive_in(1.0, 1.0, 1.0, 10.0, 401)
print(C[0], q)
```

```python solution
import numpy as np

def drive_in(D, t, Q, L, nx):
    x = np.linspace(0, L, nx)
    dx = x[1] - x[0]
    dt = 0.4 * dx * dx / D
    steps = int(round(t / dt))
    dt = t / steps
    r = D * dt / dx**2
    C = np.zeros(nx)
    C[0] = 2 * Q / dx
    for _ in range(steps):
        new = C.copy()
        new[1:-1] = C[1:-1] + r * (C[2:] - 2 * C[1:-1] + C[:-2])
        new[0] = C[0] + 2 * r * (C[1] - C[0])
        new[-1] = 0.0
        C = new
    trap = np.trapezoid if hasattr(np, "trapezoid") else np.trapz
    return x, C, float(trap(C, x))

x, C, q = drive_in(1.0, 1.0, 1.0, 10.0, 401)
print(C[0], q)
```

```python tests
import math
x, C, q = drive_in(1.0, 1.0, 1.0, 10.0, 401)
assert abs(q - 1) < 1e-6, f"A sealed surface keeps the dose; got {q}"
assert abs(C[0] / (1 / math.sqrt(math.pi)) - 1) < 0.01, f"The peak should be Q/√(πDt) = 0.5642; got {C[0]}"
assert abs(C[80] / (math.exp(-1) / math.sqrt(math.pi)) - 1) < 0.01, "At x = 2√(Dt) the Gaussian has fallen by e."
```

::: right
Right. The trapezoid rule counts the surface cell's half width, so starting with 2Q/Δx there puts exactly Q in the profile.
:::
:::

::: check
kind: python

## Step 3. Write `foster(P, R, tau, t)` returning $P\sum R_i(1 - e^{-t/\tau_i})$ (0 for t ≤ 0), and `train_peak(P, R, tau, tp, T, n)` returning the temperature rise at the end of the n-th pulse of a train with pulse length tp and period T.

```python starter
def foster(P, R, tau, t):
    return P * sum(R)

def train_peak(P, R, tau, tp, T, n):
    return foster(P, R, tau, tp)

print(train_peak(50, [0.2, 0.5, 1.0], [1e-3, 1e-2, 0.1], 5e-3, 20e-3, 10))
```

```python solution
import math

def foster(P, R, tau, t):
    if t <= 0:
        return 0.0
    return P * sum(r * (1 - math.exp(-t / s)) for r, s in zip(R, tau))

def train_peak(P, R, tau, tp, T, n):
    return sum(foster(P, R, tau, tp + k * T) - foster(P, R, tau, k * T) for k in range(n))

print(train_peak(50, [0.2, 0.5, 1.0], [1e-3, 1e-2, 0.1], 5e-3, 20e-3, 10))
```

```python tests
R, tau = [0.2, 0.5, 1.0], [1e-3, 1e-2, 0.1]
assert abs(foster(50, R, tau, 5e-3) - 22.2079) < 1e-3, "One 5 ms pulse of 50 W gives 22.21 K."
assert abs(train_peak(50, R, tau, 5e-3, 20e-3, 10) - 32.9409) < 1e-3, f"After 10 pulses the peak is 32.94 K; got {train_peak(50, R, tau, 5e-3, 20e-3, 10)}"
assert abs(train_peak(50, R, tau, 5e-3, 20e-3, 200) - 34.7615) < 1e-3, "The train settles at 34.76 K."
```

::: right
Right. Superposition works because heat conduction is linear: each pulse is a step up followed by a step down.
:::
:::

::: check
kind: python

## Step 4. Write `die_surface(q, L, kappa, rhoc, t, nx)` simulating a slab of thickness L heated by flux q at x = 0, with x = L held at 0, starting at 0, using r = 0.4 and a flux boundary at the surface. Return the surface temperature rise at time t.

```python starter
def die_surface(q, L, kappa, rhoc, t, nx):
    return q * L / kappa

print(die_surface(1e6, 0.5e-3, 150, 1.64e6, 2e-4, 51))
```

```python solution
import numpy as np

def die_surface(q, L, kappa, rhoc, t, nx):
    a = kappa / rhoc
    dx = L / (nx - 1)
    dt = 0.4 * dx * dx / a
    steps = int(round(t / dt))
    dt = t / steps
    r = a * dt / dx**2
    T = np.zeros(nx)
    for _ in range(steps):
        new = T.copy()
        new[1:-1] = T[1:-1] + r * (T[2:] - 2 * T[1:-1] + T[:-2])
        new[0] = T[0] + 2 * r * (T[1] - T[0]) + 2 * r * dx * q / kappa
        new[-1] = 0.0
        T = new
    return float(T[0])

print(die_surface(1e6, 0.5e-3, 150, 1.64e6, 2e-4, 51))
```

```python tests
import math
early = die_surface(1e6, 0.5e-3, 150, 1.64e6, 2e-4, 51)
assert abs(early / (2e6 * math.sqrt(2e-4 / (math.pi * 150 * 1.64e6))) - 1) < 0.03, f"At 0.2 ms the surface should follow 2q√(t/πκρc) = 1.017 K; got {early}"
late = die_surface(1e6, 0.5e-3, 150, 1.64e6, 0.03, 51)
assert abs(late / 3.3333 - 1) < 0.01, f"After 30 ms it should be near qL/κ = 3.33 K; got {late}"
```

::: right
Right. The crossover comes near $L^2/\alpha$ = 2.7 ms: before it the die looks infinitely thick, after it the bottom's fixed temperature takes over.
:::
:::

::: check
kind: python

## Step 5. Write `drude_mc(n, seed)` simulating n free flights with lengths drawn from an exponential distribution of mean 1, starting velocities from a standard normal, and acceleration 1. Return the drift velocity, total displacement over total time.

```python starter
import numpy as np

def drude_mc(n, seed):
    return 0.5

print(drude_mc(1000000, 1))
```

```python solution
import numpy as np

def drude_mc(n, seed):
    rng = np.random.default_rng(seed)
    s = rng.exponential(1.0, n)
    v0 = rng.normal(0.0, 1.0, n)
    return float(np.sum(v0 * s + 0.5 * s * s) / np.sum(s))

print(drude_mc(1000000, 1))
```

```python tests
v = drude_mc(1000000, 1)
assert abs(v - 1) < 0.01, f"The drift should be aτ = 1; got {v}"
assert abs(drude_mc(1000000, 2) - 1) < 0.01, "The result shouldn't depend on the seed."
```

::: right
Right. Long flights dominate the displacement, which doubles the naive half.
:::
:::

::: check
kind: parts
given: Q = 10000000000000 | 100000000000000 | 1000000000000000; D = 1 | 3; t = 30 | 120

## A dose of {Q} cm⁻² is driven in at D = {D} × 10⁻¹³ cm²/s for {t} minutes, into a $10^{15}$ cm⁻³ background.

::: part
answer: Q/sqrt(pi*D*1e-13*t*60)
unit: cm⁻³
tolerance: 0.5%

### What's the surface concentration?

::: misses
- [Q/sqrt(D*1e-13*t*60)] The Gaussian's peak is $\frac{Q}{\sqrt{\pi Dt}}$.
- [any] Convert minutes to seconds.
:::
:::

::: part
answer: 2*sqrt(D*1e-13*t*60*ln(Q/sqrt(pi*D*1e-13*t*60)/1e15))*1e4
unit: µm
tolerance: 0.5%

### How deep is the junction?

::: misses
- [any] $x_j = 2\sqrt{Dt\ln\frac{C(0)}{C_B}}$.
:::
:::
:::

::: check
given: P = 10 | 50; t = 1 | 10
answer: P*(0.3*(1 - exp(-t/2)) + 1.2*(1 - exp(-t/50)))
unit: K
tolerance: 0.5%

## A die's Foster network has R = 0.3 and 1.2 K/W with τ = 2 and 50 ms. How much does a {P} W pulse lasting {t} ms heat it?

::: right
Right. $P\sum R_i(1 - e^{-t/\tau_i})$.
:::

::: misses
- [P*1.5] That's the steady rise; the pulse is too short to reach it.
- [any] Sum each stage's partial rise.
:::
:::

::: check
given: q = 10 | 100 | 1000; t = 0.01 | 1
answer: 2*q*1e4*sqrt(t*1e-3/(pi*150*1.64e6))
unit: K
tolerance: 0.5%

## A thick silicon die (κ = 150 W/(m·K), ρc = 1.64 × 10⁶ J/(m³·K)) takes {q} W/cm² on its surface. How much has the surface warmed after {t} ms?

::: right
Right. $2q\sqrt{\frac{t}{\pi\kappa\rho c}}$ while the die still looks semi-infinite.
:::

::: misses
- [q*1e4*sqrt(t*1e-3/(pi*150*1.64e6))] The semi-infinite solution has a factor of 2.
- [any] Convert W/cm² to W/m² and ms to s.
:::
:::

::: check
given: E = 100 | 1000; t = 0.1 | 0.3; m = 0.067 | 0.26
answer: 1.602176634e-19*E*100*t*1e-12/(m*9.1093837e-31)/1000
unit: km/s
tolerance: 0.5%

## A carrier with effective mass {m}$m_e$ and mean free time {t} ps sits in {E} V/cm. What's its drift velocity?

::: right
Right. $v_d = \frac{q\tau}{m^*}E$.
:::

::: misses
- [0.5*1.602176634e-19*E*100*t*1e-12/(m*9.1093837e-31)/1000] The careful average has no factor of ½.
- [any] $\frac{q\tau E}{m^*}$, with E in V/m.
:::
:::

::: explain
## Why can a pulse train's heating be found by adding up single-pulse responses?

::: model
Heat conduction is linear: the temperature rise from two heat sources together is the sum of the rises each would cause alone, because the conduction equation and its boundary conditions contain the temperature only to the first power (as long as κ and ρc don't change much with temperature). A rectangular pulse is a step of power switched on at the start and an equal negative step at the end, so its response is Z(t) minus Z shifted by the pulse length. A train is a sum of such pulses shifted by the period, so its response is the sum of the shifted responses. That's why datasheets give a single transient thermal impedance curve: everything else follows from it.
:::
:::

::: practice

::: check
given: Q = 100000000000000 | 500000000000000; D = 2 | 5; t = 60 | 240
answer: Q/sqrt(pi*D*1e-13*t*60)
unit: cm⁻³
tolerance: 0.5%

## Surface concentration after drive-in: Q = {Q} cm⁻², D = {D} × 10⁻¹³ cm²/s, {t} min?

::: misses
- [any] $\frac{Q}{\sqrt{\pi Dt}}$.
:::
:::

::: check
given: P = 20 | 80; t = 3 | 30
answer: P*(0.3*(1 - exp(-t/2)) + 1.2*(1 - exp(-t/50)))
unit: K
tolerance: 0.5%

## Pulse heating, {P} W for {t} ms, R = 0.3, 1.2 K/W, τ = 2, 50 ms?

::: misses
- [any] $P\sum R_i(1 - e^{-t/\tau_i})$.
:::
:::
:::
