我目前使用Euler函数作为下面的函数,但是我想使用Runge-Kutta方法尝试相同的函数,因为我认为它更准确
def Euler(U,V,n,dt):
images = []
for i in range(n):
Uc = U[1:-1,1:-1]
Vc = V[1:-1,1:-1]
U[1:-1,1:-1]=Uc + dt * (Du * laplace(U,hx,ht) + F(Uc,Vc))
V[1:-1,1:-1]=Vc + dt * (Dv * laplace(V,ht) + G(Uc,Vc))
U=periodic(U)
V=periodic(V)
if i % 500 == 0:
images.append(V)
return images
我试图在下面执行此操作,但是我根本无法运行它
def RK4_2_d(U,t,c):
for k in range(len(t)-1):
uu=np.zeros((U.shape[0],V.shape[0]))
K1=ht*c*laplace(U[k,:,:],hy);uu[1:-1,1:-1]=K1
K2=ht*c*laplace(U[k,:]+uu/2,1:-1]=K2
K3=ht*c*laplace([U[k,1:-1]=K3
K4=ht*c*laplace(U[k,:]+uu,hy)
K1=ht*c*laplace(V[k,1:-1]=K1
K2=ht*c*laplace(V[k,1:-1]=K2
K3=ht*c*laplace(V[k,1:-1]=K3
K4=ht*c*laplace(V[k,hy)
U[1:-1,Vc))
U=periodic(U)
V=periodic(V)
if i % 500 == 0:
images.append(V)
return images
我在这方面走对了吗?