Sunday, 15 January 2012

numpy - Model I-V in Python -



numpy - Model I-V in Python -

model i-v.

method: perform integral, function of e, outputs current each voltage value used. repeated array of v_values. equation can found below.

although limits in equation range -inf inf, limits must restricted (e+ev)^2-\delta^2>0 , e^2-\delta^2>0, avoid poles. (\delta_1 = \delta_2). hence there 2 integrals, limits -inf -gap-e*v , gap inf.

however, maintain returning math range error although believe have excluded troublesome e values using limits stated above. pastie of errors: http://pastie.org/private/o3ugxtxai8zbktyxtxuvg

apologies vagueness of question. but, can see obvious mistakes or code misuse?

my attempt:

from scipy import integrate numpy import * import scipy sp import pylab pl import numpy np import math e = 1.60217646*10**(-19) r = 3000 gap = 400*10**(-6)*e g = (gap)**2 t = 0.02 k = 1.3806503*10**(-23) kt = k*t v_values = np.arange(0,0.001,0.0001) i=[] v in v_values: val, err = integrate.quad(lambda e:(1/(e*r))*(abs(e)/np.sqrt(abs(e**2-g)))*(abs(e+e*v)/(np.sqrt(abs((e+e*v)**2-g))))*((1/(1+math.exp((e+e*v)/kt)))-(1/(1+math.exp(e/k*t)))),-inf,(-gap-e*v)*0.9) i.append(val) = array(i) i2=[] v in v_values: val2, err = integrate.quad(lambda e:(1/(e*r))*(abs(e)/np.sqrt(abs(e**2-g)))*(abs(e+e*v)/(np.sqrt(abs((e+e*v)**2-g))))*((1/(1+math.exp((e+e*v)/kt)))-(1/(1+math.exp(e/k*t)))),gap*0.9,inf) i2.append(val2) i2 = array(i2) i[np.isnan(i)] = 0 i[np.isnan(i2)] = 0 pl.plot(v_values,i,'-b',v_values,i2,'-b') pl.show()

this question improve suited computational science site. still here points think about.

first, range of integration intersection of (-oo, -ev-gap) u (-ev+gap, +oo) , (-oo, -gap) u (gap, +oo). there 2 possible cases:

if ev < 2*gap allowed energy values in (-oo, -ev-gap) u (gap, +oo); if ev > 2*gap allowed energy values in (-oo, -ev-gap) u (-ev+gap, -gap) u (gap, +oo).

second, working in low temperature region. t equal 0.02 k, denominator in boltzmann factor 1.7 µev, while energy gap 400 µev. in case value of exponent huge positive energies , goes off limits of double precision floating point numbers, used python. minimum possible positive energy, things not improve @ higher energies. negative energies value close zero. note @ temperature, fermi-dirac distribution has sharp border , resembles reflected theta function. @ e = gap have exp(e/kt) of approximately 6.24e+100. run out of range when e/kt > 709.78 or e > 3.06*gap.

yet makes no sense go such energies since @ temperature difference between 2 fermi functions becomes 0 outside [-ev, 0] interval falls exclusively within gap given temperature when v < (2*gap)/e (0.8 mv). that's why 1 expect current close 0 when bias voltage less 0.8 mv. when more 0.8 mv, main value of integral come integrand in (-ev+gap, -gap), although non-zero value come part near singularity @ e = gap , part near singularity @ e = -ev-gap. you should not avoid singularities in dos, otherwise not expected discontinuities (vertical lines) in i(v) curve (image taken wikipedia):

rather, have derive equivalent approximate expressions in vicinity of each singularity , integrate them instead.

as can see, there many special cases value of integrand , have take them business relationship when computing numerically. if don't want that, should turn other mathematical bundle maple or mathematica. these have much more sophisticated numerical integration routines , might able straight handle formula.

note not effort reply question rather long comment not fit in comment field.

python numpy scipy integration physics

No comments:

Post a Comment