Python+Scipyでルンゲクッタ8次のDOP853(Dormand Prince)を使う(その4) ローレンツ96モデル 36変数の方程式
ローレンツ方程式(ローレンツモデル)と言えば3変数のものが有名ですが多変数のローレンツ96というモデルもある。
https://en.wikipedia.org/wiki/Lorenz_96_model
F=8でカオスになるとか。
dx_i/dt=(x_i+1 - x_i-2)*x_i-1 -x_i +F
では計算。Wikipediaではodeintだがdop853で。やっぱりちょっと波形が違うな、、、
プログラムはこちら:
import numpy as np
from scipy.integrate import ode
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
N=36
F=8
def lorenz96(t, x): #odeintのときとt,xの並びが逆
"""Lorenz 96 model."""
# Compute state derivatives
d = np.zeros(N)
# First the 3 edge cases: i=1,2,N
d[0] = (x[1] - x[N-2]) * x[N-1] - x[0]
d[1] = (x[2] - x[N-1]) * x[0] - x[1]
d[N-1] = (x[0] - x[N-3]) * x[N-2] - x[N-1]
# Then the general case
for i in range(2, N-1):
d[i] = (x[i+1] - x[i-2]) * x[i-1] - x[i]
# Add the forcing term
d = d + F
# Return the state derivatives
return d
t0=0.
tmax=30.
dt=0.01
x0 = F * np.ones(N) # Initial state (equilibrium)
x0[19] += 0.01 # Add small perturbation to 20th variable
t = np.arange(t0, tmax, dt)
solver=ode(lorenz96)
solver.set_integrator('dop853')
solver.set_initial_value(x0,t0) #なぜか関数と並びが逆
sol= np.zeros((len(t),N))
sol[0] = x0
k=1
while solver.successful() and solver.t < tmax-dt:
solver.integrate(t[k])
sol[k] = solver.y
k+= 1
# Plot
fig = plt.figure(figsize=(12,12))
ax = fig.gca(projection='3d')
ax.plot(sol[:,0], sol[:,1], sol[:,2])
ax.set_xlabel("X Axis")
ax.set_ylabel("Y Axis")
ax.set_zlabel("Z Axis")
ax.set_title("Lorenz96 Attractor(DOP853)")
plt.show()
« Python+Scipyでルンゲクッタ8次のDOP853(Dormand Prince)を使う(その3) Aizawa Attractor | トップページ | Python+Scipyでルンゲクッタ8次のDOP853(Dormand Prince)を使う(その5) ピタゴラスの三体問題を計算する。rtolとatolを設定しないと無茶苦茶になる。 »
「学問・資格」カテゴリの記事
- 高周波・RFニュース 2026年4月15日 Microwave Journalはアンプと発振器特集、Signal Integrity Journalは100GHz越えのインターコネクトのAIを使うHFSSモデル化、ローデ・シュワルツが潜水艦通信をUDT2026で発表、Xiaomi Poco X8 Pro分解動画、atisの5Gポリシーレポート(2026.04.15)
- 高周波・RFニュース 2026年4月14日 IEEE Microwave Magazineは高周波エンジニア向け量子コンピュータ入門、Antenna and Propagation Magazineはニューラルネット電磁界シミュレーションなど、第106回ARFTG論文公開、QorvoのSバンドスイッチトフィルターバンクなど(2026.04.14)
- RF Weekly Digest (Gemini 3.1 Pro・Google AI Studio BuildによるAIで高周波・RF情報の週刊まとめアプリ)2026/4/5-4/12(2026.04.12)
- GLM-5.1(Ollamaから利用)でPythonのscikit-rfを使ってTouchstoneフォーマットのSパラメータファイルを読んでdB, 位相, スミスチャート, TDRを表示するGUIアプリを作ってもらった。5分など長く考えた後、Gemma 4:31bよりさらに出来が良く、思った通りのものができた。(2026.04.09)
« Python+Scipyでルンゲクッタ8次のDOP853(Dormand Prince)を使う(その3) Aizawa Attractor | トップページ | Python+Scipyでルンゲクッタ8次のDOP853(Dormand Prince)を使う(その5) ピタゴラスの三体問題を計算する。rtolとatolを設定しないと無茶苦茶になる。 »



コメント