我正在努力解决标准模型的微分方程,但我遇到了问题。我想知道如何使用ODEINT函数,因为它可以解决我的问题,但有时我不知道如何解释图形。我首先尝试解决3个diff方程,我可以使用0到100的“t”向量,100个点。如果我试图用9个方程式解决系统,我必须使用从-20到0.1的向量“t”,因为python给了我这个错误:
ODEintWarning:在此调用上完成的工作量过多(可能是错误的Dfun类型)。使用full_output = 1运行以获取定量信息。 warnings.warn(warning_msg,ODEintWarning)
有人可以帮帮我吗?
以下是包含完整方程式的代码:
from scipy.integrate import odeint
import scipy.integrate as spi
from numpy import loadtxt
from pylab import figure, plot, xlabel, grid, hold, legend, title, savefig
from matplotlib.font_manager import FontProperties
import matplotlib.pyplot as plt
import numpy as np
#Units
#eV=10**(-9);
#MeV=10**(-3);
#GeV=1;
#TeV=1000
escala= 0.0001
def vectorfield(w, t, p):
"""
Defines the differential equations of the RGEs.
Arguments:
w : vector of the state variables:
the variables
t : time
p : vector of the parameters:
the constants
"""
g1, g2, g3, ye, ymu, yta, yu, yc, yt, yd, ys, yb = w
b1, b2, b3 = p
#T=ye**2 +ymu**2+yta**2+3*yc**2 + 3*yt**2 + 3*yd**2 +3*ys**2 + 3*yb**2
# Create f = (g1',g2',g3',...,m2'):
f = [b1*g1**3,
b2*g2**3,
b3*g3**3,
((3/2)*ye**3 + ye*(ye**2 + ymu**2 + yta**2 + 3*yc**2 + 3*yt**2 + 3*yd**2 + 3*ys**2 + 3*yb**2+ 3*yu**2) -ye*((9/4)*g1**2 - (9/4)*g2**2)),
((3/2)*ymu**3 + ymu*(ye**2 + ymu**2 + yta**2 + 3*yc**2 + 3*yt**2 + 3*yd**2 + 3*ys**2 + 3*yb**2+ 3*yu**2) -ymu*((9/4)*g1**2 - (9/4)*g2**2)),
((3/2)*yta**3 + yta*(ye**2 + ymu**2 + yta**2 + 3*yc**2 + 3*yt**2 + 3*yd**2 + 3*ys**2 + 3*yb**2+ 3*yu**2) -yta*((9/4)*g1**2 - (9/4)*g2**2)),
(3/2)*yu**3 - (3/2)*yu*yd**2 + yu*(ye**2 + ymu**2 + yta**2 + 3*yc**2 + 3*yt**2 + 3*yd**2 + 3*ys**2 + 3*yb**2+ 3*yu**2) - yu*(8*g3**2 + (17/20)*g1**2 +(9/4)*g2**2),
(3/2)*yc**3 - (3/2)*yc*ys**2 + yc*(ye**2 + ymu**2 + yta**2 + 3*yc**2 + 3*yt**2 + 3*yd**2 + 3*ys**2 + 3*yb**2+ 3*yu**2) - yc*(8*g3**2 + (17/20)*g1**2 +(9/4)*g2**2),
(3/2)*yt**3 - (3/2)*yt*yb**2 + yt*(ye**2 + ymu**2 + yta**2 + 3*yc**2 + 3*yt**2 + 3*yd**2 + 3*ys**2 + 3*yb**2+ 3*yu**2) - yt*(8*g3**2 + (17/20)*g1**2 +(9/4)*g2**2),
-(3/2)*yd*yu**2 + (3/2)*yd**3 + yd*(ye**2 + ymu**2 + yta**2 + 3*yc**2 + 3*yt**2 + 3*yd**2 + 3*ys**2 + 3*yb**2+ 3*yu**2) - yd*(8*g3**2 + (9/4)*g2**2 +(1/4)*g1**2),
-(3/2)*ys*yc**2 + (3/2)*ys**3 + ys*(ye**2 + ymu**2 + yta**2 + 3*yc**2 + 3*yt**2 + 3*yd**2 + 3*ys**2 + 3*yb**2+ 3*yu**2) - ys*(8*g3**2 + (9/4)*g2**2 +(1/4)*g1**2),
-(3/2)*yb*yt**2 + (3/2)*yb**3 + yb*(ye**2 + ymu**2 + yta**2 + 3*yc**2 + 3*yt**2 + 3*yd**2 + 3*ys**2 + 3*yb**2+ 3*yu**2) - yb*(8*g3**2 + (9/4)*g2**2 +(1/4)*g1**2)]
return f
b1 = 4.1
b2 = -3.1
b3= -7
g1=0.35
g2=0.65
g3=1.22
ye=(0.51*10**(-3))/174
ymu=(105.6*10**(-3))/174
yta=(1776*10**(-3))/174
yu=(2.3*10**(-3))/174
yc=1.29/174
yt=174/174
yd=(4.8*10**(-3))/174
ys=(95*10**(-3))/174
yb=4.18/174
abserr = 1.0e-8
relerr = 1.0e-6
stoptime = 0.1
numpoints = 250
scale=(16+stoptime)/249
t=np.linspace(0,100,100)
# Pack up the parameters and initial conditions:
p = [b1,b2,b3]
w0 = [g1, g2, g3, ye, ymu, yta, yu, yc, yt, yd, ys, yb]
wsol = odeint(vectorfield, w0, t, args=(p,),
atol=abserr, rtol=relerr)
with open('data.dat', 'w') as f:
# Print & save the solution.
for t1, w1 in zip(t, wsol):
print >> f, t1, w1[0], w1[1], w1[2], w1[3], w1[4], w1[5], w1[6], w1[7], w1[8], w1[9], w1[10], w1[11]
t, g1, g2, g3, ye, ymu, yta, yu, yc, yt, yd, ys, yb= loadtxt('data.dat', unpack=True)
figure(1, figsize=(6, 4.5))
xlabel('t')
grid(True)
lw = 1
plot(t, g1, 'b', linewidth=lw)
plot(t, g2, 'g', linewidth=lw)
plot(t, g3, 'm', linewidth=lw)
plot(t, yt, 'r', linewidth=lw)
plot(t, yb, 'y', linewidth=lw)
plt.show()