def computeGrid(DIMS, HermCheb, FourCheb, ChebCol): # Get the domain dimensions L1 = DIMS[0] L2 = DIMS[1] ZH = DIMS[2] NX = DIMS[3] NZ = DIMS[4] if ChebCol: # Compute the Chebyshev native grids xi, wcp = cheblb(NZ) #[-1 +1] z = 0.5 * ZH * (1.0 + xi) else: z = np.linspace(0.0, ZH, num=NZ, endpoint=True) # Map reference 1D domains to physical 1D domains if HermCheb and not FourCheb: alpha, whf = hefunclb(NX) #(-inf inf) x = 0.5 * abs(L2 - L1) / np.amax(alpha) * alpha elif FourCheb and not HermCheb: x = np.linspace(L1, L2, num=NX+1, endpoint=True) else: alpha, whf = hefunclb(NX) #(-inf inf) x = 0.5 * abs(L2 - L1) / np.amax(alpha) * alpha # Return the REFS structure REFS = [x, z] return REFS
def computeChebyshevDerivativeMatrix(DIMS): # Get data from DIMS ZH = DIMS[2] NZ = DIMS[4] # Make a truncation index tdex = np.array(range(NZ-1), dtype=int) # Initialize grid and make column vector xi, wcp = cheblb(NZ) # Get the Chebyshev transformation matrix CTD = chebpolym(NZ-1, -xi) # Make a diagonal matrix of weights W = np.diag(wcp) # Compute scaling for the forward transform S = np.eye(NZ) for ii in range(NZ - 1): temp = W.dot(CTD[:,ii]) temp = ((CTD[:,ii]).T).dot(temp) S[ii,ii] = temp ** (-1) S[NZ-1,NZ-1] = 1.0 / mt.pi # Compute the spectral derivative coefficients SDIFF = np.zeros((NZ,NZ)) SDIFF[NZ-2,NZ-1] = 2.0 * NZ for ii in reversed(range(NZ - 2)): A = 2.0 * (ii + 1) B = 1.0 if ii > 0: c = 1.0 else: c = 2.0 SDIFF[ii,:] = B / c * SDIFF[ii+2,:] SDIFF[ii,ii+1] = A / c # Chebyshev spectral transform in matrix form temp = (CTD[:,tdex].T).dot(W) STR_C = S[np.ix_(tdex,tdex)].dot(temp); # Chebyshev spatial derivative based on spectral differentiation # Domain scale factor included here temp = (CTD[:,tdex]).dot(SDIFF[np.ix_(tdex,tdex)]) DDMT = - (2.0 / ZH) * temp.dot(STR_C); # Output the complete matrices as well temp = CTD.dot(W) STR_C = S.dot(temp); # Chebyshev spatial derivative based on spectral differentiation # Domain scale factor included here temp = CTD.dot(SDIFF) DDMF = - (2.0 / ZH) * temp.dot(STR_C); return DDMF, DDMT, STR_C
def computeChebyshevDerivativeMatrix_X(DIMS): # Get data from DIMS #ZH = DIMS[2] #NZ = DIMS[4] # Get data from DIMS L1 = DIMS[0] L2 = DIMS[1] NX = DIMS[3] ZH = abs(L2 - L1) NZ = NX + 1 # Initialize grid and make column vector xi, wcp = cheblb(NZ) # Get the Chebyshev transformation matrix CTD = chebpolym(NZ-1, -xi) # Make a diagonal matrix of weights W = np.diag(wcp) # Compute scaling for the forward transform S = np.eye(NZ) for ii in range(NZ - 1): temp = W.dot(CTD[:,ii]) temp = ((CTD[:,ii]).T).dot(temp) S[ii,ii] = temp ** (-1) S[NZ-1,NZ-1] = 1.0 / mt.pi # Compute the spectral derivative coefficients SDIFF = np.zeros((NZ,NZ)) SDIFF[NZ-2,NZ-1] = 2.0 * NZ for ii in reversed(range(NZ - 2)): A = 2.0 * (ii + 1) B = 1.0 if ii > 0: c = 1.0 else: c = 2.0 SDIFF[ii,:] = B / c * SDIFF[ii+2,:] SDIFF[ii,ii+1] = A / c # Chebyshev spectral transform in matrix form temp = CTD.dot(W) STR_C = S.dot(temp); # Chebyshev spatial derivative based on spectral differentiation # Domain scale factor included here temp = (CTD).dot(SDIFF) DDM = - (2.0 / ZH) * temp.dot(STR_C); return DDM, STR_C
def computeGrid(DIMS): # Get the domain dimensions L1 = DIMS[0] L2 = DIMS[1] ZH = DIMS[2] NX = DIMS[3] NZ = DIMS[4] # Compute the Hermite function and Chebyshev native grids alpha, whf = hefunclb(NX + 1) #(-inf inf) xi, wcp = cheblb(NZ) #[-1 +1] # Map reference 1D domains to physical 1D domains x = 0.5 * abs(L2 - L1) / np.amax(alpha) * alpha z = 0.5 * ZH * (1.0 + xi) # Return the REFS structure REFS = [x, z] return REFS