亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法導入 X 問題。Oregonator 模型的剛性 ODE 求解器

無法導入 X 問題。Oregonator 模型的剛性 ODE 求解器

慕哥9229398 2022-06-28 16:52:47
該錯誤來自嘗試從 scipy.integrate 導入 Radau 方法(需要,因為 Oregonator 模型是一個剛性系統)。我試圖對俄勒岡州模型進行數值積分,以表明參數 f 在 0 和 3 之間必須存在某個過渡點,以便在該區間的特定子集中發生振蕩。原諒我的經驗不足,我是 Python 新手。錯誤:ImportError:無法從“scipy.integrate”導入名稱“radau”在我的無知中,我從頭開始構建了一個四階龍格-庫塔方法。在找到股票價格而不是化學波動后,我轉而使用 odeint。這仍然失敗。直到這之后我才發現了剛性系統的想法,所以我一直在研究 Radau 方法。import numpy as npimport matplotlib.pyplot as pltfrom scipy.integrate. import radau# Dimensionless parameterse = 0.04q = 0.0008f = 1.0# Oregonator modeldef Oregonator(Y, t):    return [((Y[0] * (1 - Y[0])  - ((Y[0] - q) * f * Y[1]) // (q + Y[0])))     // e, Y[0] - Y[1]]# Time span and inital conditionsts = np.linspace(0, 10, 100)Y0 = [1, 3]# Numerical algorithm/methodNumSol = radau(Oregonator, 0, Y0, t_bound=30)x = NumSol[:,0]z = NumSol[:,1]預期的結果應該是類似(第 12 頁)中的振蕩: https ://pdfs.semanticscholar.org/0959/9106a563e9d88ce6442e3bb5b242d5ccbdad.pdf 僅適用于 x 和 z。y 的缺失是由于我使用了穩態近似值。
查看完整描述

1 回答

?
慕村225694

TA貢獻1880條經驗 獲得超4個贊

用作求解器類(如或solve_ivp)的單行接口。使用類的正確大寫。在 ODE 函數中使用正確的參數順序(您可以使用in來使用相同的函數)。在您打算使用浮點除法的地方避免整數除法。RK45Radautfirst=Trueodeint


import numpy as np

import matplotlib.pyplot as plt

from scipy.integrate import solve_ivp


# Dimensionless parameters

eps = 4e-2

q = 8e-4

f = 2.0/3


# Oregonator model

def Oregonator(t,Y):

    x,z = Y;

    return [(x * (1 - x) + (f*(q-x)*z) / (q + x)) / eps, x - z]


# Time span and inital conditions

ts = np.linspace(0, 10, 100)

Y0 = [1, 0.5]


# Numerical algorithm/method

NumSol = solve_ivp(Oregonator, [0, 30], Y0, method="Radau")

x, z = NumSol.y

y = (f*z)/(q+x)

t = NumSol.t

plt.subplot(221);

plt.plot(t,x,'b'); plt.xlabel("t"); plt.ylabel("x");

plt.subplot(222);

plt.plot(t,y,'r'); plt.xlabel("t"); plt.ylabel("y");

plt.subplot(223);

plt.plot(t,z,'g'); plt.xlabel("t"); plt.ylabel("z");

plt.subplot(224);

plt.plot(x,z,'k'); plt.xlabel("x"); plt.ylabel("z");

plt.tight_layout(); plt.show()

然后這會產生情節

表現出周期性振蕩。

進一步的步驟可能是使用tspan選項或“密集輸出”在用戶定義的采樣點處獲取解決方案樣本。為獲得可靠的結果,請手動設置誤差容限。

f=0.51262接近從收斂到振蕩行為的過渡點。

查看完整回答
反對 回復 2022-06-28
  • 1 回答
  • 0 關注
  • 123 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號