21. (2) シミュレーションで遊ぼう
オイラー法で微分方程式のシミュレーション
𝑑𝑢
𝑑𝑡
= 𝑓 𝑢
時間方向の離散化
𝑡
𝑢
数値解
𝑢𝑘+1
= 𝑢𝑘 + 𝑓 𝑢𝑘 ∆𝑡
ある時間の𝑢の変化量は一定と近似する。
∆𝑡 ∆𝑡
∆𝑡
∆𝑡
区間内の変化速度は、
区間の開始時点のもの
を使うと楽々計算でき
る(オイラー法)
The change is constant within the timestep.
Euler method:
the velocity
depends on the
u at the start
point.
30. (2) シミュレーションで遊ぼう
シミュレーションで遊ぶ!
𝑑𝑋(𝑡)
𝑑𝑡
= 𝑘 − γ𝑋 𝑡 − τ
もし時間遅れがあったら……?
𝑋
分
解
# 時間遅れがある場合
# --略--
tdelay_step = 151 # 時間遅れの大きさ
# --略--
for i in range(n):
if t >= tdelay_step*dt:
f = k - γ * x_list[-tdelay_step] # 右辺を予め計算する。
else:
f = k # 右辺を予め計算する。
x = x + f * dt # Euler 法を用いた時間発展
t = t + dt # 時刻をdtだけ進める。
How about the case with delay?