0
我在做一些模擬,當我在scipy.integrate.odeint
中觀察到意外的行爲時。Scipy odeint停止
我可以重現我的問題與此代碼:
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint
tau = 0.01
a, b = 0.7, 0.8
def E_p(t):
E = -0.07
if t < b and t > a:
E = -0.05
return E
def dynamics(V, t):
return (E_p(t) - V)/tau
time = np.arange(0, 1, 0.001)
ps = odeint(dynamics, -0.07, time)
plt.plot(time, ps)
當我設置a和b左側(在我的情況下,零)odeint
行之有效附近的時間間隔,而不是間隔的權利它並不是什麼。
我希望看到這個
但更多的權利。我真正想要做的是在RC電路中模擬一個方形脈衝。
我認爲odeint
停止集成時感覺功能已經收斂,但我找不到任何文檔說這一點。
我不認爲'odeint'是能夠應付像你這樣的連續函數 – xnx
好了,我這樣做,圖像使用= 0.1和b = 0.2,因此它可以在來案例。很高興知道它何時有效,但我會認爲它不起作用並使用其他功能。將來我還需要使用一般的脈衝響應,所以我需要一個處理不連續函數的函數。 –