Why is the law of the p-n junction valid under forward bias? I'm currently studying the physics of the PN junction. I went though the derivation of the built-in potential in the PN junction under equilibrium:

$$ {Diffusion\ current\ density} = {Drift\ current\ density} $$
$$ D_{p}p\frac{dp}{dx} = EU_ppq $$
where:
$ D_{p} $ = Diffusion coefficient for holes
$ p $ = holes density in semiconductor
$ E $ = electric field
$ U_p $ = hole mobility
$ q $ = electron charge
integrating on $ x $ we get :
$$ \int_{junction\ width}^{} D_{p} q \frac{dp}{dx} {d}x = \int_{junction\ width}^{} E U_p p q {d}x \implies $$
$$ \int_{p_{n0}}^{p_{p0}} D_{p} \frac {1}{p} {d}p = U_p \int_{junction\ width}^{} E {d}x $$
some mathematics and the resulting formula is:
$$ ln \frac{p_{p0}}{p_{n0}}  = \frac{V_{built\text{-}in}}{V_t} \implies $$
$$ p_{n0} e ^ \frac{V_{built\text{-}in}}{V_t} = p_{p0} $$
Which can be understood as $ {V_{built\text{-}in}} $ is the necessary voltage to counter the diffusion from concentrations $ p_{p0} $ to $ p_{n0} $
This is called the law of the junction.
Up to this point everything is fine. The problem is:
This law is also used in forward bias. The $ V_{built\text{-}in} $ is substituted by the net resultant voltage of the forward bias.
This is wrong, the resultant voltage is NOT countering the diffusion current along the gradient, there is forward current flowing. And the formula we based our derivation on should now be:
$$ D_{p}p\frac{dp}{dx} = EU_ppq + I_{f} \implies $$
$$ \int_{junction\ width}^{} D_{p} q \frac{dp}{dx} {d}x = \int_{junction\ width}^{} E U_p p q {d}x + \int_{junction\ width}^{} I_{f}{d}x $$
How is the first formula used as the law of the junction? Am I missing something? Is there some other derivation I'm not aware about?
 A: $V_\mathrm{bi}$ shrinks (grows) under forward (reverse) bias.
The same laws apply, but $V_\mathrm{bias}$ modulates the Fermi level in both $p$ and $n$ type regions, and these new Fermi levels must get matched again in the depletion region, so $V_\mathrm{bi}$ changes in order for equilibrium to be established.
There's some good info on this at the net. Try Google searching images for this. Hyperphysics talks about it too.
A: The currents that flow in the device are either diffusion currents (concentration gradients) or drift currents (potential gradients).  The sum of these (summed over the electrons and holes) make up any current flowing in the device.  Under the special condition of no net current you get the built-in voltage.  At some other voltage difference across the device you get whatever current will flow. 
Your conceptual flaw is that the forward current is somehow different - it is instead merely the sum of diffusion and drift yielding net current flow in the device. So, the same equation must describe the device, and solving for the built-in voltage just gives you what the junction looks like under no (externally applied) bias.
A: I actually haven't seen that derivation, it's interesting but clearly liable to lead you astray. The Law of the junction at equilibrium can be derived only with the fermi level being constant throughout the device.
$$E_F= const$$
If you then assume that the pn junction is long enough so that the "bulk" region is fairly unaffected (basically assuming the device is much larger than its depletion region, which is usually reasonable), then you know what the fermi levels are at the boundaries. These are just the fermi levels of an n-type and a p-type semiconductor (relative to the intrinsic fermi energy).
$$E_{F,n-type} = kT*ln(\frac{n_0}{ni}) $$
$$E_{F,p-type} = -kT *ln(\frac{p_0}{ni}) $$
Since the fermi level has to be constant throughout the entire device, and the valence/conduction/vacuum bands must be continuous (this is a much deeper rabbit hole, but true for a single type of semiconductor), the valence and conduction bands must bend by the difference between the fermi levels. Rearranging these equations, you get a value for Vbi, which is really a value for the difference between the conduction/valence band levels on either side of the device.
$$V_{bi}=\frac{1}{q}(E_{F,n-tpe}-E_{F,p-type})=\frac{kT}{q}*ln(\frac{n_{n0}*p_{p0}}{ni^2})$$
which we can rearrange into the Law of the Junction by dividing both sides by the thermal voltage and exponentiating. (I am going to replace $\frac{kT}{q}$ with $\phi_T$).
$$p_{p0}=\frac{n_{n0}}{ni^2}*e^{V_{bi}/\phi_T}=p_{n0}*e^{V_{bi}/\phi_T}$$
However, as you rightly pointed out, when we apply a bias voltage, our device isn't under equilibrium anymore. Does this mean this equation is not valid? Not quite. Remember, we said that $V_{bi}$ was just a stand-in for the difference in conduction/valence band levels between the far-away regions in the bulk of the device. When applying a voltage, the fermi level is not constant throughout the device. It will now be "offset" by exactly the voltage we applied. So for the equation to remain valid, we must replace $V_{bi}$ with $V_{bi}-V_A$, where $V_A$ is the forward bias of the device.
$$p_{p0}=p_{n0}*e^{(V_{bi}-V_A)/\phi_T}$$
This is the form of the law of the junction which is valid under non-equilibrium (at least until $V_A$ gets close to $V_{bi}$, but that's what device simulators are for).
A: You are absolutely right. The Law of the Junction is an approximation under non-equilibrium conditions. It results from the observation that the net current across the depletion layer is much smaller than the individual drift and diffusion currents. Therefore, the third term in your equation can be neglected without incurring in a large error.
That the net current is small, can be seen the following way: in the depletion layer the electric field and the minority carrier concentration are much higher than in the neutral regions, so the drift current is very high and compensated by an opposite diffusion current. The two are not in perfect balance as in equilibrium, but they "almost" cancel out.
Anyway, you can convince yourself that this argument is correct by doing a self-consistency test: assume the validity of the Law of the Junction and calculate the drift and diffusion currents across the depletion layer. Then you can show that under reasonable and common conditions, they almost cancel out.
