Erro在python中使用genlaguerre吗?

问题描述 投票:0回答:1

我正在尝试在Python中绘制以下等式的图。

二维量子环的径向微分方程的解

“”

beta参数是

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9aaHBubS5wbmcifQ==” alt =“在此处输入图像描述”>“ >>

这是我的尝试

    import numpy as np
from scipy.special import gamma, genlaguerre
import matplotlib.pyplot as plt
from scipy import exp, sqrt

m = 0.067*9.1*10E-31
R = 5E-9
r = np.linspace(0, 20E-9)
#Definição do parâmetro beta

def beta(gama):
    flux = np.linspace(0,1.0)
    beta = sqrt((m-flux)**2+(gama**4)/4)
    return beta

def Rn(n,gama):

    raiz = sqrt((gamma(n+1)/((2**beta(gama)) * gamma(n+beta(gama)+1))))
    eval_g = genlaguerre((n,beta(gama)),((gama * r/R)**2/2))
    exp_g = exp(-((gama * r/R)**2)/4)


    return  (1/R) * raiz * (gama * r/R)**beta(gama) * exp_g * eval_g

sol1 = Rn(0,1.5)
sol2 = Rn(0,2.0)
sol3 = Rn(0,2.5)
sol4 = Rn(0,3.0)


fig, ax = plt.subplots()
ax.plot(r/R, sol1, color = 'red', label = '$\gamma$ = 1.5')
ax.plot(r/R, sol2, color = 'green', label = '$\gamma$ = 2.0')
ax.plot(r/R, sol3, color = 'blue', label = '$\gamma$ = 2.5')
ax.plot(r/R, sol4, color = 'black', label = '$\gamma$ = 3.0')
ax.legend()
ax.set_xlabel('R/r')
ax.set_ylabel('$R_0(r)$')

使用genlaguerre的错误

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

这里the link to the article

我正在尝试在Python中绘制以下方程式的图形。 2d量子环径向微分方程的解beta参数为。这是我的尝试。

我不是这个话题,但是狂热中至少存在以下错误(我故意设置为n = 0时是无声的):
与发布的beta函数图像相反,您在函数定义中添加了4除法。正确的版本:

def beta(gama): return np.sqrt((m-flux)**2+(gama**4))

    这不是分配峰值而不是固定峰值的原因,但我告诉我这里看到的内容。
  1. 乘积而不是除法,因为在幅度函数的定义中缺少括号:正确的版本:

def amplitude(gama): return np.sqrt(gamma(1)/((2**beta(gama)*gamma(beta(gama)+1))))

  1. 在Rn函数的定义中,缺少引入的1 / R。
    但是,不幸的是,所有这些都不会改变在相等的x位置处出现的峰...
python python-3.x scipy physics scientific-computing
1个回答
0
投票
与发布的beta函数图像相反,您在函数定义中添加了4除法。正确的版本:
© www.soinside.com 2019 - 2024. All rights reserved.