当我尝试在mpmath函数中使用numpy数组时收到错误消息,此示例在到达该行时失败:
C = (f*L/D) + 2*mp.log(P1/P2)
其中P1是一个数组。与错误:
cannot create mpf from array([**P1_array**])
我知道这个和这个步骤是相关的。但是我无法使我的代码正常工作。有人可以帮我纠正这个错误吗?
import numpy as np
import mpmath as mp
mp.mp.dps = 20
# State equation --> pV = nZRT
P1 = np.linspace(101325,10*101325,100)
P2 = 101325
T = 300
D = 0.0095
A = mp.power(D,2)*mp.pi/4
L = 300
R = 8.31446
f = 0.05
Z1 = 0.9992
Z2 = 0.9999
Zm = 0.5*(Z1+Z2)
C = (f*L/D) + 2*mp.log(P1/P2)
w2 = (mp.power(P1,2)-mp.power(P2,2))*mp.power(A,2)/(Zm*R*T*C)
w = mp.power(w2,0.5)
相关分类