# The heat-transfer model of diffusion

So.. carriers flow through a diode's depletion zone the same way heat flows through a metal bar. Let's dig into that:

### The simple version:

Let's start with basic heat transfer: take two boxes that can hold and conduct heat, start them at different temperatures, then press them together. Energy will flow from the hotter one to the cooler one, and eventually they'll both end up at the same temperature.

If box1 starts at 100C and box2 starts at 0C, they'll both end up at 50C:

### The boilerplate (or "why geeks can never say anything simply"):

You can make things complicated by worrying about special cases.. what if it takes twice as much energy to raise box1's temperature than it takes to raise box2's temperature by the same amount? What if box1 can gain or lose energy faster than box2? If it takes time for energy to move through the boxes, won't the edges pressed together change temperature faster than the edges that aren't pressed together?

Those are all legitimate questions, but dealing with them makes the model more complicated. For now, I want to concentrate on a specific principle, so let's assume that the boxes have the same heat capacity, they both gain or lose energy at the same rate, and that the temperature in each box is the same everywhere. (if you really want to be picky about it, assume we're only measuring the temperature of each box at a single point in the center)

### The slightly more complicated version:

Now let's make a couple of changes to our model:

First, let's put a third box between the first two. Second, let's attach whatever machinery it takes to hold box1 at 100C and box2 at 0C:

For the box in the middle to reach equilibrium, it has to lose energy to box2 at the same rate it gains energy from box1. If it gains more than it loses, it will get hotter. If it loses more than it gains, it will get cooler.

For differences less than a few hundred degrees, the rate of transfer is proportional to the difference in temperature between the hot and cold sides. For the rates to be equal, the temperature differences have to be equal too.

That means the box in the center will reach equilibrium when its temperature is halfway between those of the boxes at either end: 50C.

### Not as pointless as it seems:

Now let's put two more boxes on either side of the one in the middle:

The box in the middle still finds its equilibrium at 50C.

The logic is still the same.. each of the boxes has to lose heat as fast as heat comes in to reach equilibrium. That means each box has to sit halfway between its neighbors.

You can keep adding boxes as long as you want:

and the reasoning will still work the same way. Eventually every box in the row will reach a specific temperature, and those temperatures will form a linear gradient from one end of the bar to the other:

### Enough of this easy stuff, let's break out the math:

That much is fairly straightforward, but there's an interesting relationship that isn't quite so easy to see: the ratio of 'heat in the system' to 'heat that moves through the system'.

To demonstrate the idea, let's assume the bar is a hundred boxes long, and that the temperature gradient is one degree per box:

The box furthest to the hot side will sit at 99C, will receive 1C worth of heat from the 100C source and lose 1C worth of heat to its 98C neighbor. 99C worth of heat in that box never goes anywhere though. It just sits there keeping that box hotter than its neighbor. In other words, only 1% of the heat in the box ever leaves. The other 99% is just overhead we have to pay to make the system work.

If we move toward the other end and look at the box that sits at 9C, it also receives 1C worth of heat from its warmer neighbor and passes 1C worth of heat to its cooler neighbor. That 1C is now 10% of the total heat in the box though.

When we get to the last box, all the heat that flows in flows out, so 100% of the heat in the box moves on through.

Since the amount of heat that moves stays constant while total heat per box gets smaller, the graph of 'heat that moves' divided by 'total heat' will be an inverse curve:

With a bit of mathematical hand-waving, we can convert that inverse
curve to one that shows the amount of heat that moves between any two
temperatures.
The actual technique is 'integration', which I will ** not ** try to
reduce to its simplest terms here.
The basic idea is that the area under the inverse curve tells us how
much of the heat in some chunk of the bar will eventually flow to the 0C
end.

For reasons I ** really ** don't intend to explain, the integral of
an inverse is the logarithm.
The general point of the game is that the integral * at * point X
is the area under the original curve * up to * point X, and when
you add up the area under a 1/x curve you get a ln(x) curve:

In the graph above, the purple cross mark on the ln(x) graph represents the area under the 1/x graph up to point A. The pink cross represents the area up to point B.

That's handy because we can find the area under the 1/x curve between A and B by taking the area up to B and subtracting the area up to A. Numerically it amounts to ln(B) - ln(A).

Now, if you remember your high school math, subtracting logarithms is the same as dividing. In other words, we could also say the area between A and B is ln(A/B).

Going back to our bar and doing some symbolic schmertzing, we can build an equation that tells us how much of the heat in the bar flows from one temperature to another:

- C = k*ln(A/B)

where 'C' is the symbol for 'amount of heat that flows' and 'k' is a constant that covers all the 'how much energy it takes to heat up a box and how fast energy moves from one box to another' stuff.

From that equation, we can unpack other useful relationships. We can (he said, feigning innocence) make an equation that lets us pick a temperature and the amount of energy we want to see move, and gives us the temperature we'd need at the other end:

- C = k*ln(A/B)
- C/k = ln(A/B)
- e^(C/k) = A/B
- B*e^(C/k) = A
- B = A*e^-(C/k)

In case you're wondering about that last step, it's a disguised example of 'subtracting logarithms is the same as division'. Dividing by e^x is the same as multiplying by e^-x.

This is also an example of a highly popular mathematical strategy called 'start from the answer you want, work back to what you have, then publish the steps in reverse order'. Once you get more than ankle-deep in physics, you'll find an amazing variety of things that boil down to:

- something times e^-(something else)

because equations of that general flavor make differential equations less painful.

### And the point of all this was?

So we have this completely non-intuitive exponential equation that might be convenient for math, but which measures some property no one would ever care about, right?

Well, not quite..

In a diode, it's the equation for the drift current that counterbalances the diffusion current, creating the depletion zone.

- Diffusion current works like heat moving through a bar.
- The temperature gradient represents the fixed charges uncovered by the diffusion current.
- The inverse function represents the electrical field created by those fixed charges.
- The integral represents the drift current that field imposes on carriers in the depletion zone.
- The definite integral (the difference between integrals at two points) represents the drift current necessary to balance the diffusion current.
- The values A and B are the distances from the PN junction to either edge of the depletion zone.

I really needed the model of the diffusion gradient and the exponential equation to explain how a diode behaves when you apply an external electrical field.

I'll do that next time.