无法真正弄清楚为什么RuntimeWarning: overflow encountered in exp
会出现此错误。我要实现的功能是:
Id = lambda t_u, yp: Is * (np.exp((Vin(t_u) - L*yp)/(n_Ut*Ut)) - 1.0)
具有值:
Vin = lambda t: Vo * np.sin(2*np.pi*w*t)
L = 50e-3 # 50 mH
Vo = 5 # 5 V
w = 50 # 50 Hz
Is = 1e-9 # 1 nA
Ut = 25e-3 # 25 mV
n_Ut = 1.0
该函数Id
是我试图用 Runge-Kutta-Method 解决的 ODE 的一部分。
编辑:
Methoden\Serien\6>python circuit.py
Traceback (most recent call last):
File "circuit.py", line 148, in <module>
perform_experiment(exrk_o5(), "exrk_o5")
File "circuit.py", line 48, in perform_experiment
t, y = run_method(method, label)
File "circuit.py", line 69, in run_method
t, y = method.__call__(circuit_rhs, y[0, :], t_end, n_steps)
File "C:\Users\-\numerical_methodes\6\rk.py", line 49, in __call__
t[k+1],y[k+1, :] = self.step(f, y[k, :], t[k], dt)
File "C:\Users\-\numerical_methodes\6\rk.py", line 102, in step
dydt[:, i] = rhs(t + c[i] * dt, y0 + dt * np.dot(A[i, :].T, dydt.T))
File "circuit.py", line 38, in circuit_rhs
dydt= np.array ([y[1] , Id(t, y [1]) /(C*L) - y [1]/( R*C) - y [0]/( C*L)])
File "circuit.py", line 27, in <lambda>
Id = lambda t_u, yp: Is * (np.exp((Vin(t_u) - L*yp)/(n_Ut*Ut)) - 1.0)
FloatingPointError: overflow encountered in exp
其中 y[1]=0 和 y[0]=0,作为第一个值。rk.py 文件只是 Runge-Kutta-Method 的实现。