import numpy as np def khi(X): khi = np.zeros_like(X) khi[(X >= -1/4) & (X <= 1/4)] = 1 return khi def Uinit(X,J): Uinit = np.zeros(J) Uinit[:] = 256 * ((X[:]-1/4)**2) * ((X[:]+1/4)**2) * khi(X)[:] return Uinit """def Uinit(X,J): Uinit = np.zeros(J) Uinit[:] = khi(X)[:] return Uinit""" def schema1(U0,J,alpha): U0=np.append(U0[J-2],U0) U1=U0[1:J+1] - alpha*(U0[1:J+1]-U0[0:J]) return U1 def schema2(U0,J,alpha): U0=np.append(U0[J-2],U0) U0=np.append(U0,U0[1]) U1=U0[1:J+1]-(alpha/2)*(U0[2:J+2]-U0[0:J])+(0.5*alpha**2)*(U0[2:J+2]-2*U0[1:J+1]+U0[0:J]) return U1 def schema3(U0,J,alpha): U0=np.append(U0[J-2],U0) U0=np.append(U0[J-3],U0) U0=np.append(U0,U0[1]) U1=U0[2:J+2]-alpha*(U0[2:J+2]-U0[1:J+1])-((alpha/4)*(1-alpha)*(U0[3:J+3]-U0[2:J+2]-U0[1:J+1]+U0[0:J])) return U1