I want to calculate the carrier concentration of my semiconductor using this equation:
$$ n(x) = \frac{m^*}{\pi\hbar^2}\int_{E_k}^{\infty}\frac{1}{1+\exp\left(\frac{E-E_f}{k_BT}\right)} \mathrm{d}E $$
I'm using this straightforward scipy approach:
import numpy as np
import scipy.constants as phys
import scipy.integrate as integrate
eigenvalue = [0.9 * phys.electron_volt, 1.3 * phys.electron_volt]
fermi = 1.0 * phys.electron_volt
T = 300
def fermi_integral(E, fermi, T):
return 1 / (1 + np.exp((E - fermi) / (phys.Boltzmann * T)))
for i in range(len(eigenvalue)):
result = integrate.quad(fermi_integral, eigenvalue[i], np.inf, args=(fermi, T))
print(result)
However, I'm running into
RuntimeWarning: overflow encountered in exp
return 1 / (1 + np.exp((E - fermi) / (phys.Boltzmann * T)))
and my result is always (0.0, 0.0)
I guess I have to use another approach, but I'm stuck and I hope you can give me some helpful input.
quad
tries at first. That's why rescaling can fix this as in nicoguaro's answer. $\endgroup$