涉及积分和值变化参数的函数图

计算科学 Python scipy 一体化 绘图 matplotlib
2021-11-30 04:31:01

我试图绘制相对于光子能量 的横截面,但对于在同一轴上hνγ=1.0,1.2,2.0

σ=[(ξeffξ0)2nrε]4π3αfshν|12R2βΓ(β+1)0(γρ)2βe12γ2ρ2γ2ρ2dρ|2Γf(λ01λ00hν)2+(Γf)2

在哪里

λ00=2γ2(β+1)γ44

e λ01=2γ2(β+3)γ44

是最终态和基态的能量,并且 β=(mΦ)2)γ44

这是我在 Python 中解决这个问题的尝试:

from scipy.integrate import quad
import numpy as np
from scipy.special import gamma
from scipy.constants import  pi, alpha
import matplotlib.pyplot as plt

#Constants
epsilon = 13.1 #dielectric constant of the material
gamma_C = 0.5 # donor impurity linewidth 
nr = 3.2 #refractive index of semiconductor
m = 0 # magnetic number
flux = 0  # Phi in eqn 8 magnetic flux
R = 5  #radius of the qunatum ring in nm
r = np.linspace(0, 6 * R)
rho = r / R
m_0 = 0.0067*0.511 # electron effective mass
h = 4.13e-15 # Planck constant in eV
hbar =  6.58e-16 # reduced Planck constant in eV
#Photon energy
h_ni = np.linspace(0, 100/h) #in eV


#Function that calculates the integrand
def func(rho, gama):
    beta = np.sqrt((m - flux)**2 + gama**4/4)
    return ((gama * rho)**2*beta * np.exp(-1/2*(gama * rho)**2) 
         * (gama * rho)**2/2   ) 

def cross_section(h_ni, gama):
    #function that calculates the photoionisation cross sectio
    beta = np.sqrt((m - flux)**2 + gama**4/4)
    Ei = gama**2*(1+beta)-gama**4/2
    Ef = gama**2*(3+beta)-gama**4/2

    return ((nr/epsilon) * 4*pi/3 * alpha * h_ni * 
          R ** 2 / (2**beta * gamma(beta + 1)) * 
          abs(quad(func, 0, np.infty))**2  *
            hbar*gamma_C/(((Ef-Ei-h_ni))**2 + ( hbar*gamma_C)**2))

#Plot

plt.figure();plt.clf()

for gama in [1.0, 1.5, 2.0]:
    plt.plot(h_ni, cross_section(h_ni, gama))

但我收到以下错误

   TypeError: func() missing 1 required positional argument: 'gama'

我该如何解决这个问题?欢迎任何帮助。

1个回答

您的函数func(rho, gamma)接受两个参数,而您只传递一个(我认为没有)。这就是你的错误告诉你的。

重新检查你使用的地方func(rho, gamma),并确保你传递了两个参数。