Hi @mengx1. The electric field in the depletion region can be calculated by solving Poisson’s equation.

In text books we neglect the contribution from the charge carriers *n* and *p* and only consider the charge in the depletion region to be due to the constant charges from the donor and acceptor atoms. Due to the constant nature of the fixed charges the electric field will be a linear function of x.

However, when you consider the *n* and *p* values in this equation, the solution is not so simple anymore and the electric field does not vary linearly with x. Specially near the boundary between the n and p region you cannot neglect the contribution from the carriers (look at the plot from DEVICE for a simple pn junction).

When DEVICE solves for the electric field it solves the full Poisson’s equation and this is why the electric field profile is not a pure straight line.