Fermi Energy and the Electric Potential In an extrinsic semiconductor the electric potential is:
$$\phi = \frac{1}{q}(E_{\mathrm{F}} - E_{\mathrm{Fi}})$$
where $E_{\mathrm{F}}$ is the Fermi energy, $E_{\mathrm{Fi}}$ is the intrinsic Fermi energy, $q$ is the electron charge and $\phi$ is the electric potential. I am not sure where this equation comes from. I understand why a potential will be created qualitatively, but where does this equation come from quantitatively?
From what I understand , the expected value of the electron energy is the Fermi energy. 
You take $E_{\mathrm{Fi}}$ as the reference for the electron potential. This is the equilibrium condition of an intrinsic semiconductor. If you dope the semiconductor, you introduce an imbalance and that causes the generation of an electric field, hence the new expected value $E_{\mathrm{F}} - E_{\mathrm{Fi}}$. Is that correct?
 A: this is probably years too late. However I needed help on this today, and asked my solid state lecturer  - I'm going to go ahead and paste their answer below for future students: 
You can think about the intrinsic fermi level as a reference energy level. So, Ei is the reference energy that will give you equal populations of electrons and holes in the CB and VB respectively, (at thermal equilibrium). Therefore, if the Fermi level energy is equal to Ei. [this is what happens in an intrinsic semiconductor] the populations of electrons and holes are equal, and when the Fermi energy (Ef) moves away from Ei, the reference level, the populations of electrons and holes have to change. So, when the energy difference between Ef and Ei is positive there are more electrons in the CB then holes in the VB, and when Ef-Ei is negative the population of holes is larger than the population of electrons.
Using a crude analogy: This is like looking at Ei as the reference level for zero gravitational potential energy. Then when you through a projectile in the air, the eight, h, represents the fermi level, and the potential energy represents the population of electrons in the CB. So when h=0, e.g. Ef=Ei, the population of electrons is zero (look at this “zero” as our ni value in a semiconductor), but when the projectile is at a heigh h>0, the potential energy is larger than zero, i.e. the population of electrons in the CB increases. However, even when the projectile is in the air, we know where the zero reference energy (Ei) is.
Now that we have a meaning for Ei as a reference energy level, so just a very useful abstract concept, you can ask how can we manipulate the Fermi energy in order to modify the populations of electrons and holes? Here is where the concept of doping comes into play.
