Python:curve_fit 不适用于具有三个拟合参数和不正确积分的函数

我正在尝试将数据集拟合到这个方程的怪物。我知道以前有人问过这个问题,但我不认为最初的猜测是我的问题,我也不能在我的拟合方程中添加更多项。

我的拟合方程。请注意积分中的“u”与上面定义的 u 不同。

http://img3.mukewang.com/6130b2b80001674209870706.jpg

顺便说一下,我的数据集以 mA/um 为单位。


我在函数F 中实现了这一点,它接受输入 Vd、T、r 和 Vt。T、r 和 Vt 是拟合参数。T 和 r 的范围从 0


我的前几个程序有可怕的拟合(如果它甚至可以完成积分),所以我决定看看算法是否有效。该函数的实现如下:


from scipy import integrate

from scipy.optimize import curve_fit

import numpy as np

import matplotlib.pyplot as plt


#Constants

eSiO2 = 3.9 #Relative dielectric constant of SiO2

tox = 2e-9  #Gate oxide thickness in m

evac = 8.854e-12    #Vacuum permittivity, F/m

em = 0.2*9.11e-31   #Effective electron mass in kg

KT = 4.11e-21 #Thermal energy in joules

Mv = 2.5 #Degeneracy factor

q = 1.6e-19 #Electron charge, coulombs

hbar = 1.054e-34    #Reduced plancks constant

Vg = 1


def F(Vd,T,r,Vt):

    #Derived constants required for computation

    Ci = (eSiO2*evac)/tox #Oxide capacitance per area

    ved = (q*r*Vd)/(KT) #little Vd

    I0 = (np.sqrt(2)*q*(KT**1.5)*Mv*np.sqrt(em))/(np.pi*hbar)**2 #Leakage Current


    #Rho

    rho1 = 2*np.pi*hbar**2*Ci

    rho2 = q*KT*em*Mv

    rhoV = Vg-Vt

    rho = (rho1*rhoV)/rho2


    #u

    UA = 1 + np.exp(ved)

    UB = np.exp(ved)*(np.exp(rho)-1)

    Usq = np.sqrt(UA**2+4*UB)

    u = np.log(Usq-UA)-np.log(2)


    #Integrand of F(u)

    def integrand1(A,x):

        return (np.sqrt(A))/(1+np.exp(A-x))


    #Integrand of F(u-v)

    def integrand2(A,x):

        return (np.sqrt(A))/(1+np.exp(A-x))

    sum1 = 0

    sum2 = 0

    tempy1=[]

    tempy2=[]

    tempx2=[]


    #Tempx2 = dummy variable domain

    tempx2 = np.linspace(0,100,num=10000)


    #Fitting parameters are determined

    if Ready is True:

        #Evaluate the integrands for all the Vd values

        tempy1 = integrand1(tempx2,u)

        tempy2 = integrand2(tempx2,u-ved)

海绵宝宝撒
浏览 302回答 1
1回答

喵喔喔

您丢弃所有结果tempy1和tempy2除了最后一个。我认为您想附加到列表中。改变for i in range (0,len(u)):        tempy1 = integrand1(tempx2,u[i])        tempy2 = integrand2(tempx2,u[i]-ved[i])到for i in range (0,len(u)):        tempy1.append(integrand1(tempx2,u[i]))        tempy2.append(integrand2(tempx2,u[i]-ved[i]))导致两个图重叠。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python