How do you go about calculating electron densities, especially when impurities are involved?
I assume you are referring to carrier density, since even in doped semiconductor the overall electron density is essentially unchanged since the dopant density is so low compared to the number of lattice sites.
Given that assumption, dopant impurities are almost entirely ionized at room temperature. So, in N-type material the carrier density is equal to Nd which is the donor impurity density. In P-type material you would use the equation ni^2 = pn where ni is the intrinsic carrier density (due to thermal effects), p is the hole density and n is the electron density, so in that case, n = (ni^2)/p.
This is all well explained on the following web page:
Separate names with a comma.