我想用物理計算的輸出來繪製輸出,但使用python的matplotlib,但是我的程序生成的繪圖對我來說沒有意義。我想繪製的是三個等式,1/a1,1/a2和1/a3,它們的梯度在點mn處變化,但是現在我的代碼會導致值以及梯度發生變化。Python/matplotlib繪圖值在漸變不連續處跳躍
似乎a1,a2,a3的方程式在函數從ms定義切換到ms> = mn定義時變得更大,但是使用像a1(10e11,mn)這樣的測試值嘗試它們並不會沒有顯示任何大的變化。
import matplotlib.pyplot as plt
import numpy as np
mn = 10312054216.046213
mz = 91.1876
a1z = 98.330 #NOTE: these values are for inverses of aplha at mz, ie 1/a1, etc
a2z = 29.571
a3z = 8.396
b1, b2, b3 = -13/(4*pi), 19/(12*pi), 7/(2*pi)
b1p, b2p, b3p = -157/(36*pi), 11/(12*pi), 17/(6*pi) #above new physics scale
c1, c2, c3 = 3/5, 1, 1
ms = np.linspace(10e8, 10e11, num = 1000000, endpoint = True)
def a1(ms, mn):
if (ms < mn):
return (c1*(a1z + b1*np.log(ms/mz)))**(-1)
elif (ms >= mn):
a1n = (c1*(a1z + b1*log(mn/mz)))**(-1)
return (c1*(a1n + b1p*log(ms/mn)))**(-1)
def a2(ms, mn):
if (ms < mn):
return (c2*(a2z + b2*np.log(ms/mz)))**(-1)
elif (ms >= mn):
a2n = (c2*(a2z + b2*log(mn/mz)))**(-1)
return (c2*(a2n + b2p*log(ms/mn)))**(-1)
def a3(ms, mn):
if (ms < mn):
return (c3*(a3z + b3*np.log(ms/mz)))**(-1)
elif (ms >= mn):
a3n = (c3*(a3z + b3*log(mn/mz)))**(-1)
return (c3*(a3n + b3p*log(ms/mn)))**(-1)
plt.xscale('log')
plt.plot(ms, [1/a1(x, mn) for x in ms])
plt.plot(ms, [1/a2(x, mn) for x in ms])
plt.plot(ms, [1/a3(x, mn) for x in ms])
plt.show()
在這裏的任何洞察將非常歡迎,謝謝。
我不明白你的問題是什麼。你想讓我們調試你的代碼嗎? – nicoguaro