我不知道为什么我使用附加的 python 代码得到 W 与 PT 的多个图表
I don't know why I get the multiple graphs of W versus PT using the attached python code
我想得到三张图(W vs. X, W vs. y, W vs PT)。但我可以获得两个正确的图表(W vs. X 和 W vs. y)。不幸的是,我终于得到了 W vs PT(绿线)的多张图表。我不知道该如何处理。如果您能为我做任何事,我们将不胜感激。
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
def PBR(X, W):
a = 9.8*10**(-5)
y = (1-a*W)**0.5
PH2 = PT0*(1.5-X)*y
PB = PT0 * X * y
PT = PT0 * (1 - X)*y
r = -k * PT * PH2 / (1 + KB*PB + KT *PT)
dXdW = -r/FT0
return dXdW
W = np.linspace(0, 10000)
KT = 1.038
KB = 1.39
FT0 = 50
k = 0.00087
PT0 = 12
X0 = 0
a = 9.8*10**(-5)
y = (1-a*W)**0.5
PT = PT0 * (1 - X)*y
X = odeint(PBR, X0, W)
plt.plot(W, PT, 'g', linewidth=0.5)
plt.plot(W, X,'r', linewidth=3.0)
plt.plot(W, y,'b', linewidth=5.0)
enter image description here
您是否正在寻找这样的输出。如果是 - 脚本中的小问题。查看标记为#** 的行。您想乘以 X 数组的第一维。
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
def PBR(X, W):
a = 9.8*10**(-5)
y = (1-a*W)**0.5
PH2 = PT0*(1.5-X)*y
PB = PT0 * X * y
PT = PT0 * (1 - X)*y
r = -k * PT * PH2 / (1 + KB*PB + KT *PT)
dXdW = -r/FT0
return dXdW
W = np.linspace(0, 10000)
KT = 1.038
KB = 1.39
FT0 = 50
k = 0.00087
PT0 = 12
X0 = 0
a = 9.8*10**(-5)
y = (1-a*W)**0.5
X = odeint(PBR, X0, W)
PT = PT0 * np.multiply(1 - X[:,0],y) #**
print(PT)
plt.plot(W, PT, 'g', linewidth=0.5)
plt.plot(W, X,'r', linewidth=3.0)
plt.plot(W, y,'b', linewidth=5.0)
我想得到三张图(W vs. X, W vs. y, W vs PT)。但我可以获得两个正确的图表(W vs. X 和 W vs. y)。不幸的是,我终于得到了 W vs PT(绿线)的多张图表。我不知道该如何处理。如果您能为我做任何事,我们将不胜感激。
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
def PBR(X, W):
a = 9.8*10**(-5)
y = (1-a*W)**0.5
PH2 = PT0*(1.5-X)*y
PB = PT0 * X * y
PT = PT0 * (1 - X)*y
r = -k * PT * PH2 / (1 + KB*PB + KT *PT)
dXdW = -r/FT0
return dXdW
W = np.linspace(0, 10000)
KT = 1.038
KB = 1.39
FT0 = 50
k = 0.00087
PT0 = 12
X0 = 0
a = 9.8*10**(-5)
y = (1-a*W)**0.5
PT = PT0 * (1 - X)*y
X = odeint(PBR, X0, W)
plt.plot(W, PT, 'g', linewidth=0.5)
plt.plot(W, X,'r', linewidth=3.0)
plt.plot(W, y,'b', linewidth=5.0)
enter image description here
您是否正在寻找这样的输出。如果是 - 脚本中的小问题。查看标记为#** 的行。您想乘以 X 数组的第一维。
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
def PBR(X, W):
a = 9.8*10**(-5)
y = (1-a*W)**0.5
PH2 = PT0*(1.5-X)*y
PB = PT0 * X * y
PT = PT0 * (1 - X)*y
r = -k * PT * PH2 / (1 + KB*PB + KT *PT)
dXdW = -r/FT0
return dXdW
W = np.linspace(0, 10000)
KT = 1.038
KB = 1.39
FT0 = 50
k = 0.00087
PT0 = 12
X0 = 0
a = 9.8*10**(-5)
y = (1-a*W)**0.5
X = odeint(PBR, X0, W)
PT = PT0 * np.multiply(1 - X[:,0],y) #**
print(PT)
plt.plot(W, PT, 'g', linewidth=0.5)
plt.plot(W, X,'r', linewidth=3.0)
plt.plot(W, y,'b', linewidth=5.0)