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 computeHermiteFunctionDerivativeMatrix(DIMS):
       
       # Get data from DIMS
       L1 = DIMS[0]
       L2 = DIMS[1]
       NX = DIMS[3]
       
       alpha, whf = hefunclb(NX)
       HT = hefuncm(NX, alpha, True)
       HTD = hefuncm(NX+1, alpha, True)
       
       # Get the scale factor
       b = (np.amax(alpha) - np.min(alpha)) / abs(L2 - L1)
       
       # Make a diagonal matrix of weights
       W = np.diag(whf, k=0)
       
       # Compute the coefficients of spectral derivative in matrix form
       SDIFF = np.zeros((NX+2,NX+1));
       SDIFF[0,1] = mt.sqrt(0.5)
       SDIFF[NX,NX-1] = -mt.sqrt(NX * 0.5);
       SDIFF[NX+1,NX] = -mt.sqrt((NX + 1) * 0.5);
                     
       for rr in range(1,NX):
              SDIFF[rr,rr+1] = mt.sqrt((rr + 1) * 0.5);
              SDIFF[rr,rr-1] = -mt.sqrt(rr * 0.5);
              
       # Hermite function spectral transform in matrix form
       STR_H = (HT.T).dot(W)
       # Hermite function spatial derivative based on spectral differentiation
       temp = (HTD).dot(SDIFF)
       temp = temp.dot(STR_H)
       DDM = b * temp

       return DDM, STR_H
Ejemplo n.º 3
0
def computeHermiteFunctionDerivativeMatrix(DIMS):

    # Get data from DIMS
    L1 = DIMS[0]
    L2 = DIMS[1]
    NX = DIMS[3]

    # Make a truncation index
    tdex = np.array(range(NX - 1), dtype=int)

    alpha, whf = hefunclb(NX + 1)
    HT = hefuncm(NX, alpha, True)
    HTD = hefuncm(NX + 1, alpha, True)

    # Get the scale factor
    b = (np.amax(alpha) - np.min(alpha)) / abs(L2 - L1)

    # Make a diagonal matrix of weights
    W = np.diag(whf, k=0)

    # Compute the coefficients of spectral derivative in matrix form
    SDIFF = np.zeros((NX + 2, NX + 1))
    SDIFF[0, 1] = mt.sqrt(0.5)
    SDIFF[NX, NX - 1] = -mt.sqrt(NX * 0.5)
    SDIFF[NX + 1, NX] = -mt.sqrt((NX + 1) * 0.5)

    for rr in range(1, NX):
        SDIFF[rr, rr + 1] = mt.sqrt((rr + 1) * 0.5)
        SDIFF[rr, rr - 1] = -mt.sqrt(rr * 0.5)

    # Hermite function spectral transform in matrix form
    STR_H = (HT[:, tdex].T).dot(W)
    # Hermite function spatial derivative based on spectral differentiation
    temp = (HTD[:, tdex]).dot(SDIFF[np.ix_(tdex, tdex)])
    temp = temp.dot(STR_H)
    DDMT = b * temp

    # Output the full interpolation matrix
    STR_H = (HT.T).dot(W)
    # Hermite function spatial derivative based on spectral differentiation
    temp = HTD.dot(SDIFF)
    temp = temp.dot(STR_H)
    DDMF = b * temp

    return DDMF, DDMT, STR_H
Ejemplo n.º 4
0
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