1

I am using mpmath library on python to compute this integral : enter image description here

enter image description here

The issue is that when I increase the range of integration, my integral value slowly decreases to 0.. while the integrand is positive!! I give you some values :

integration range : [-1.17,-1.11], integral value : 1.28479400889196e-8

integration range : [-1.2,0], integral value : 2.87226592130464e-29

integration range : [-10,10], integral value : 0.0

What's going on and how to solve issue besides selecting only the range where my integrand is not 0 ?

Here is my code (fermi dirac stat and conductivity have been adapted for pmos so it's not exactly the integral i've shown)

import numpy as np
from math import pi, sqrt, exp, log
from scipy.integrate import quad
import scipy.constants as phys
import matplotlib.pyplot as plt
from decimal import Decimal, getcontext
getcontext().prec = 1000

import mpmath as mp


k = (phys.Boltzmann)              # Boltzmann constant
                                  #Parenthesis left due to previous decimal conversion
m = (9.1094e-31)     #electron mass

h = (phys.Planck)     #Planck constant
h_b = h/(2 * pi)        #reduced

q = (1.602176634e-19)  
e =   (1)      
dE = 3e-3 * e

pi = (pi)


m_e = m * (1.06)   #electron effective mass
m_h = m * 0.59    #hole effective mass
A_2D = m_h / (pi*h_b**2) 


###### INPUTS
T = (4.2)
V_d = (0.02)
chi = (4.05)*e
E_g = (1.16)*e


g = 4                    #degeneracy
μ = (1e3)              #mobility, cm**2/Vs
A = A_2D

W = 1.00E-05
L = 1.00E-07

#########
E_c = 0
E_v = E_c - E_g

Phi_f = (0.55)
E_f = ( E_c - E_g/2 - e*Phi_f)
Ef_d = ( E_f - e * V_d)



#######

def fd(E,E_f):             #Fermi-Dirac distribution for holes
    res = 1/(1 + mp.exp(((E - E_f)*q/(k*T))))
    return 1-res

def sigma(E):
    if E_v-E < 2 :
        res = q * A * μ *1e-4 *  dE*q *  log( 1 + mp.exp((E_v-E)/ dE)) 
    else:
        res = - q * A * μ *1e-4 *q *(E-E_v)
    return res

def integrand(E):
    return sigma(E)*( fd(E,Ef_d) -fd(E,E_f))

X = np.linspace(E_v-5.05,5,1000)

FD = np.vectorize(fd)

Sigma = np.vectorize(sigma)



Integrand = np.vectorize(integrand)
#mp.quad
Int = mp.quad(integrand, [-10,10])
I_c = W/(q*L)*Int

fig, ax1 = plt.subplots()
ax1.plot(X,FD(X,Ef_d) - FD(X,E_f), color = 'g', label='fd stat');

ax2 = ax1.twinx()

ax2.semilogy() ;
ax2.plot(X,Sigma(X), label='sigma');
ax2.plot(X,Integrand(X), label='integrand');
ax1.legend()

ax2.legend(loc='lower right')
print('Int = ',Int)

Thanks

Sarah
  • 37
  • 4
  • 1
    Please provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). That includes all code that is necessary to reproduce the problem. Otherwise it's difficult to help. – a_guest Feb 24 '21 at 13:47
  • @a_guest I have edited and added the code – Sarah Feb 24 '21 at 14:20
  • do you have any tips ? :/ – Sarah Mar 09 '21 at 08:34
  • I suggest looking at `mp.quad` and how exactly it handles the integration. I suspect that there are not enough evaluation points when increasing the interval. So increasing this number might help. – a_guest Mar 09 '21 at 08:55

0 Answers0