在python中绘制具有多个参数的数学函数的最佳方法?

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

我是(理论上的)物理学专业的学生,​​我真的是这个程序设计的新手。我正在尝试在Python中绘制2D量子系统的径向Schrodinger波函数,但遇到很多麻烦

import numpy as np
import scipy.special as ss
import matplotlib.pyplot as plt


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

#radial wave function definition
beta = beta(0.067*9.1E-31, 0.5, 1.5)
R=5.0E-9
r=np.linspace(0, 0.6)
ro = r/R
def radial (n,gama,beta, ro, R,r):
    return (1/R)*np.sqrt((ss.gamma(n+1)/2**beta*ss.gamma(n+beta+1)))*(gama*ro)**beta*np.exp(-(gama*ro)**2/4)*ss.eval_genlaguerre(n,beta,((gama*ro)**2/2))

sol = radial(0, 1.5, beta, ro, R,r)
plt.plot(ro, sol, 'b-')
plt.xlabel('r/R')
plt.ylabel('R(r)')
plt.title('Solução radial em fução da coordenada radial')
plt.legend("gamma=1,5")
plt.grid()
plt.show()

我想问:将多个参数传递给数学函数的最佳方法是什么?即使有多个参数和特殊功能,我在绘图上也只能得到一条直线。感谢您提供任何提示或帮助。

python python-3.x scientific-computing
2个回答
0
投票

[ss.genlaguerre函数将布尔作为第三个参数,而不是数组。

https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.genlaguerre.html#scipy.special.genlaguerre


0
投票

您正在genlaguerre函数的布尔参数中输入非布尔值https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.genlaguerre.html

def genlaguerre(n: int,
                alpha: float,
                monic: Optional[bool] = False) -> orthopoly1d)

您正在输入:

ss.genlaguerre(n=n,
               alpha=beta,
               monic=((gama*ro)**2/2)  #  <--- this is your issue
               )
© www.soinside.com 2019 - 2024. All rights reserved.