Exemple #1
0
Whvlam = phs1.getPeriodicDM( z=th, x=th, m=phsA-1 \
, phs=phsA, pol=polA, stc=stcA, period=2*np.pi )
Whvlam = alpA * dth0**(phsA - 2) * Whvlam  #scaled angular HV matrix
# dthPol = spdiags( dth**polA, np.array([0]), len(dth), len(dth) )
# Whvlam = alpA * dthPol.dot(Whvlam)

# #Complex angular HV:
# alpDthPol = alpA * dth0**polA
# # alpDthPol = alpA * ( np.tile(dth,(nlv-2,1)) ) ** polA

###########################################################################

#Weights for interpolation to boundary (I), extrapolation to
#ghost-nodes (E), d/ds at boundary (D), and extrapolation to boundary(H):

wIinner = phs1.getWeights(innerRadius, s[0:stcB], 0, phs, pol)
wEinner = phs1.getWeights(s[0], s[1:stcB + 1], 0, phs, pol)
wDinner = phs1.getWeights(innerRadius, s[0:stcB], 1, phs, pol)
wHinner = phs1.getWeights(innerRadius, s[1:stcB + 1], 0, phs, pol)

wIouter = phs1.getWeights(outerRadius, s[-1:-stcB - 1:-1], 0, phs, pol)
wEouter = phs1.getWeights(s[-1], s[-2:-stcB - 2:-1], 0, phs, pol)
wDouter = phs1.getWeights(outerRadius, s[-1:-stcB - 1:-1], 1, phs, pol)

###########################################################################

#Weights to interpolate from perturbed mesh to regular mesh for plotting:

Wradial = phs1.getDM(z=s0[1:-1], x=s, m=0, phs=phs, pol=pol, stc=stc)

Wangular = phs1.getPeriodicDM( z=th0, x=th, m=0 \
Exemple #2
0
Whva = alp * dx**pol * Whva                    #lateral dissipation weights

phs = 5                                              #vertical PHS exponent
pol = 3                        #highest degree polynomial in vertical basis
stc = 5                                              #vertical stencil size
if verticalCoordinate == "pressure":
    alp = -2.**-22. * 300.                #vertical dissipation coefficient
else:
    alp = -2.**-22. * 300.          #much larger in height coordinate case?
Ws   = phs1.getDM(z=s,       x=s, m=1 \
, phs=phs, pol=pol, stc=stc)                   #vertical derivative weights
Whvs = phs1.getDM(z=s[1:-1], x=s, m=pol+1 \
, phs=phs, pol=pol, stc=stc)
Whvs = alp * ds**pol * Whvs                   #vertical dissipation weights

wItop = phs1.getWeights(z=(s[0]+s[1])/2.,   x=s[0:stc],        m=0 \
, phs=phs, pol=pol)                            #interpolate to top boundary
wEtop = phs1.getWeights(z=s[0],             x=s[1:stc+1],      m=0 \
, phs=phs, pol=pol)                         #extrapolate to top ghost nodes
wDtop = phs1.getWeights(z=(s[0]+s[1])/2.,   x=s[0:stc],        m=1 \
, phs=phs, pol=pol)                             #derivative on top boundary
wHtop = phs1.getWeights(z=(s[0]+s[1])/2.,   x=s[1:stc+1],      m=0 \
, phs=phs, pol=pol)                            #extrapolate to top boundary

wIbot = phs1.getWeights(z=(s[-2]+s[-1])/2., x=s[-1:-1-stc:-1], m=0 \
, phs=phs, pol=pol)                         #interpolate to bottom boundary
wEbot = phs1.getWeights(z=s[-1],            x=s[-2:-2-stc:-1], m=0 \
, phs=phs, pol=pol)                      #extrapolate to bottom ghost nodes
wDbot = phs1.getWeights(z=(s[-2]+s[-1])/2., x=s[-1:-1-stc:-1], m=1 \
, phs=phs, pol=pol)                          #derivative on bottom boundary
wHbot = phs1.getWeights(z=s[-1],            x=s[-2:-2-stc:-1], m=0 \
, phs=phs, pol=pol)                         #extrapolate to bottom boundary
Exemple #3
0
def derivativeApproximations(x, dx, left, right, s, ds):
    """
    This is where all of the weights for approximating spatial derivatives
    are calculated.  Also, at the end, the function outputs functions
    Da(), Ds(), and HV(), which are used to approximate the corresponding
    derivative of something.
    """
    phs = 11  #lateral PHS exponent (odd number)
    pol = 5  #highest degree polynomial in lateral basis
    stc = 11  #lateral stencil size
    alp = 2.**-9 * 300.  #lateral dissipation coefficient
    Wa   = phs1.getPeriodicDM(z=x, x=x, m=1 \
    , phs=phs, pol=pol, stc=stc, period=right-left)            #d/da matrix

    Whva = phs1.getPeriodicDM(z=x, x=x, m=6 \
    , phs=phs, pol=pol, stc=stc, period=right-left)
    Whva = alp * dx**5 * Whva  #lateral dissipation weights

    W2a = phs1.getPeriodicDM(z=x, x=x, m=2 \
    , phs=phs, pol=pol, stc=stc, period=right-left)
    W2a = 2.**-10. * dx * W2a

    phs = 5  #vertical PHS exponent
    pol = 2  #highest degree polynomial in vertical basis
    stc = 5  #vertical stencil size
    if phs == 7:
        alp = 2.**-24. * 300.
    elif phs == 5:
        alp = -2.**-22. * 300.  #vertical dissipation coefficient
    elif phs == 3:
        alp = 2.**-20 * 300.
    else:
        raise ValueError("Please use phs=3 or phs=5 or phs=7.")

    Ws = phs1.getDM(z=s, x=s, m=1 \
    , phs=phs, pol=pol, stc=stc)                               #d/ds matrix

    Whvs = phs1.getDM(z=s[1:-1], x=s, m=phs-1 \
    , phs=phs, pol=pol, stc=stc)
    Whvs = alp * ds**(phs - 2) * Whvs  #vertical dissipation weights

    numDampedLayers = np.int(np.round(len(s) / 2.))

    W2s = phs1.getDM(z=s[1:numDampedLayers], x=s, m=2 \
    , phs=phs, pol=pol, stc=stc)
    W2s = 2.**-10. * ds * W2s

    sTop = (s[0] + s[1]) / 2.

    wItop = phs1.getWeights(z=sTop,  x=s[0:stc],        m=0 \
    , phs=phs, pol=pol)                        #interpolate to top boundary

    wEtop = phs1.getWeights(z=s[0],  x=s[1:1+stc],      m=0 \
    , phs=phs, pol=pol)                     #extrapolate to top ghost nodes

    wDtop = phs1.getWeights(z=sTop,  x=s[0:stc],        m=1 \
    , phs=phs, pol=pol)                         #derivative on top boundary

    wHtop = phs1.getWeights(z=sTop,  x=s[1:1+stc],      m=0 \
    , phs=phs, pol=pol)                        #extrapolate to top boundary

    wIbot = phs1.getWeights(z=1.,    x=s[-1:-1-stc:-1], m=0 \
    , phs=phs, pol=pol)                     #interpolate to bottom boundary

    wEbot = phs1.getWeights(z=s[-1], x=s[-2:-2-stc:-1], m=0 \
    , phs=phs, pol=pol)                  #extrapolate to bottom ghost nodes

    wDbot = phs1.getWeights(z=1.,    x=s[-1:-1-stc:-1], m=1 \
    , phs=phs, pol=pol)                      #derivative on bottom boundary

    wHbot = phs1.getWeights(z=1.,    x=s[-2:-2-stc:-1], m=0 \
    , phs=phs, pol=pol)                     #extrapolate to bottom boundary

    #Lateral derivative on all levels:
    def Da(U):
        return Wa.dot(U.T).T

    #Vertical first derivative on all levels:
    def Ds(U):
        return Ws.dot(U)

    #Total dissipation on non-ghost levels:
    def HV(U):
        return Whva.dot(U[1:-1, :].T).T + Whvs.dot(U)

    #Rayleigh-damping function for top 30 layers (mountainWaves test case):
    def rayleighDamping(U):
        return W2a.dot(U[1:numDampedLayers, :].T).T + W2s.dot(U)

    return Wa, stc, wItop, wEtop, wDtop, wHtop, wIbot, wEbot, wDbot, wHbot \
    , Da, Ds, HV, rayleighDamping, numDampedLayers
Exemple #4
0
###########################################################################

#Setting ghost node values and getting the RHS of the ODE system:

if formulation == "exner":
    if highOrderZ == 1:
        ni = 2
        rbfOrder = 3
        polyOrder = 1
        bigTx = np.tile(Tx, (ni, 1))
        bigTz = np.tile(Tz, (ni, 1))
        bigNx = np.tile(Nx, (ni - 1, 1))
        bigNz = np.tile(Nz, (ni - 1, 1))
        #weights to extrapolate to ghost nodes:
        we = phs1.getWeights(s[0, 0], s[1:ni + 1, 0], 0, rbfOrder, polyOrder)
        we = np.transpose(np.tile(we, (nCol, 1)))
        #weights to extrapolate to boundary:
        we2 = phs1.getWeights((s[0, 0] + s[1, 0]) / 2., s[1:ni + 1, 0], 0,
                              rbfOrder, polyOrder)
        we2 = np.transpose(np.tile(we2, (nCol, 1)))
        #weights to interpolate to boundary:
        wi = phs1.getWeights(0., s[0:ni, 0], 0, rbfOrder, polyOrder)
        wi = -1 / wi[0] * wi[1:ni]
        wi = np.transpose(np.tile(wi, (nCol, 1)))
        #weights to approximate d/ds at boundary:
        wd = phs1.getWeights(0., s[0:ni, 0], 1, rbfOrder, polyOrder)
        wd = np.transpose(np.tile(wd, (nCol, 1)))

        def setGhostNodes(U):
            #extrapolate uT to bottom ghost nodes: