0
にodeint用いた二次ODEを解く:私はこの方程式を解くために必要パイソン
Y '' + Y」 - B Y、A及びBは、の関数である Y = 0
それは意味がありませんプロットを返す
import numpy as np
import matplotlib.pyplot as pyplot
from scipy.integrate import odeint
x0 = 0.,0.1 # initial conditions
oe = 0.0 # cosmological constant density parameter
om = 1. # matter density parameter
h = 2.3E-18 # Hubble constant
w = -1.
a = np.linspace(0.1,1,10) # scale factor
def H(a): # Hubble rate equation
return h*np.sqrt((om/(a**3.))+(oe/(a**(3.*(1.+w)))))
def A(a): # differential equation term
return (-3./(2.*a))
def B(a): # differential equation term
return (3.*om*(h**2.))/((2.*(a**5.))*(H(a)**2.))
def system(X,a): # differential equation system
X0 = X[0]
X1 = X[1]
X2 = -A(a)*X1 + B(a)*X0
return X1,X2
x = odeint(system,x0,a)
pyplot.semilogx(a,x, linestyle='-', c="k", linewidth="2")
:同じ変数「」
は、私は、次のコードを試してみました。私はa = 1で "x"の最大値が1である1つのプロットを取得する必要があります。私が手
プロット:しかし、私は次のプロットを取得
を、期待される結果が次のグラフの連続線のようなものです:
任意の提案?
あなたはどうしますか?なぜ人物を追加しないのですか? [ask]をお読みください。また、H^2を持つと、数値精度が良くなりません。可能であれば、数量が1のオーダになるように方程式を書き直すことをお勧めします。 –
手順をステップバイステップでhttp://docs.scipy.org/doc/scipy/reference/generated/scipy.integrateに従ってください。 odeint.html – outoftime
コードは必要に応じて動作しますので、物理フォーラムに質問を転送して、モデルを期待通りのものにするために変更すべき点について話し合う必要があります。 – LutzL