嗨希望SO的更高功率可以帮助我解决这个问题。我有一个3个ODE系统,我试图用半隐式Euler方法解决。方程是:
我对数值分析的了解最好被描述为一个新手,我已经研究了如何最好地解决这样的方程组,并且我可以告诉我所描述的半隐式欧拉方法here似乎是最当然。
代码如下:
from numpy import *
from scipy.constants import elementary_charge as ec
from scipy.constants import Planck as h
# Constants
phi0 = h / (2*ec)
data_points = 10000
pp = 2*pi
f = (pp/phi0)
ff = phi0/pp
Ic = 340e-6
Rn = 1.1764705882352944
Cj = (0.1*phi0)/ (pp*Ic*Rn**2)
Ib = 600e-6
Lp = 1e-12
#Initial conditions
v0 = 0
Is0 = 0
x0 = 0
#Time derivation
dt = 1e-13
#element arrays
Is = zeros(data_points)
x = zeros(data_points)
v = zeros(data_points)
time = zeros(data_points)
#Allocating initial values
v[0] = v0
Is[0] = Is0
x[0] = x0
#Loop of iteration steps
for i in range(0, data_points-1):
time[i+1] = time[i] + dt
v[i+1] = v[i]+(1/cj)*dt*((1/Cj)*((Ib-Ic*sin((x[i]*time[i]))-(Is[i]*time[i]) )))
Is[i+1] = Is[i]+(1/Np)*dt*(((v[i+1]*time[i])-(Is[i]*time[i]*Rn)))
x[i+1] = x[i]+f*dt*(v[i+1]*time[i+1])
减去常量和初始条件的长列表,我的主要问题围绕着Euler for循环以及x
和Is
的实现。我知道代码没有产生明智结果的原因来自于数组x
在max(x)
大约1000-1500处应该max(time)
并且在图中有2pi过渡的假设。 / p>