Like the one on this Wikipedia page, all of the diagrams I've seen so far seem to show a rectangular graph of charge density at a PN junction. I'd like to understand why.

I tried to simulate a process where I iteratively diffused the free charge carriers, and then recombined the overlapping charge densities of positive and negative carriers. While I do get a sharp transition in the middle, I don't get the sharp transitions at the edges of the depletion region. My idea is that I've incorrectly modeled diffusion, as I've just used a double moving average filter.

I'm attaching the generated graphs, where each row represents a step (either diffusion or recombination), while the columns represent (from left to right) static charge, the charge of free carriers and total charge.

Simulation graphs

What am I doing wrong?

  • $\begingroup$ What do you mean by "static charge" for your first column of plots? If you mean ionized dopants, those charges dont move, so all rows should be identical to the first. $\endgroup$
    – Matt
    Feb 7, 2023 at 3:05
  • $\begingroup$ By static charge I mean minority carriers. My understanding is that when carriers recombine the majority carriers are converting to minority carriers. $\endgroup$
    – Cosinux
    Feb 7, 2023 at 6:25

1 Answer 1


There are a few mistakes in this simulation

  1. When carriers recombine you lose one majority and one minority carrier. They recombine and are gone. The process is not converting majority carriers to minority carriers. (Although when majority carriers diffuse across the junction they do become excess minority carriers.)
  2. You should start with many more majority carriers than minority carriers on each side of the junction. You want at least 10000x more majority than minority. (That is what makes them majority carriers)
  3. You don't seem to be accounting for the ionized donors and acceptors. These are fixed charges that do not move. These are typically very close to equal to the number of majority carriers in equilibrium, but of the opposite charge.
  4. You need to track "holes" and "electrons" and not "majority" and "minority" carriers. As diffusion occurs across the junction you will at first have excess holes on the n side and excess electrons on the p side. It is the electrons and holes that diffuse. The majority/minority distinction is a label we apply based on where the carrier currently is. It is not an intrinsic property of the charge carrier.
  5. If you don't account for the electric field in the depletion region you will never get the rectangular charge profiles you seek.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.