scipy 无法根据椭圆积分的数组错误创建mpf

mepcadol  于 2022-11-10  发布在  其他
关注(0)|答案(1)|浏览(105)

我正在编写一段代码,它需要使用椭圆积分来求解一个时间函数的方程。大部分代码都很简单,但是在包含椭圆积分的最后一个方程上遇到了一个错误,阅读“cannot create mpf from array”。不太确定是否有简单的修复方法,但是任何见解都将非常感谢。代码可以在下面找到:

import matplotlib.pyplot as plt
import numpy as np
from scipy import integrate
from mpmath import *

G = 6.6743*10**(-11) #Gravitational Constant
M = 10*(1.988*10**30) #Mass of the Black Hole (kg)
m = 1*(1.988*10**30) #Mass of the Companion Star (kg)
Mt = M + m #Total Mass(kg)
q = m/M #Mass Ratio
c = 2.99792458*10**8 #Speed of Light (m/s)
Period = 10 #Orbital Period (Days)
P = Period*86400 #Orbital Period (Seconds)
phi = 0.01*(np.pi/(180)) #Inclination from Line-of-Sight
t0 = Period/2 #Pulse Mid-Point
a = ((P**2*G*(Mt))/(4*np.pi**2))**(1/3) #Semi-Major Axis
omega = ((G*(m + M))/a**3)**0.5 #Angular Velocity
vtran = a*omega #Transverse Velocity
Rs = (2*G*M)/c**2 #Schwarzschild Radius
Rein = (2*Rs*a)**0.5 #Einstein Radius
te = (Rein/vtran)/86400 #Einstein Time
u0 = (a/Rein)*phi #Closest Angular Approach
pstar = ((1*(6.957*10**8))/Rein)
t = np.linspace(0,P,2500000) #Time Vector
u = ((u0**2)+((((t/86400)-t0)/te))**2)**0.5 #Angular Separation

n = ((4*u*pstar)/(u + pstar)**2)
k = ((4*n)/(4 + (u - pstar)**2))**0.5

Amp = (1/(2*(np.pi)))*(((((u+pstar)/(pstar**2))*np.sqrt(4+(u-pstar)**2)*ellipe(k**2))-(((u-pstar)/(pstar**2))*(((8+u**2-pstar**2)/(np.sqrt(4+(u-pstar)**2)))*ellipk(k**2)))+(((4*(u-pstar)**2)/(pstar**2*(u+pstar)))*(((1+pstar**2)/(np.sqrt(4+(u-pstar)**2)))*ellippi(n,k**2)))))
qco9c6ql

qco9c6ql1#

该问题特别针对mpmath.ellipe()mpmath.ellipk()mpath.ellippi()
文件在这里:https://mpmath.org/doc/current/functions/elliptic.html#ellipe(对于ellipkellippi也是如此)。
但总的来说,正如注解所指出的,mpmath.ellipe(*args)用一个自变量m调用,求第二类勒让德完全椭圆积分E(m)的值
您已传递了一个列表。

相关问题