Example #1
0
def smooth_rc_old(dx, dy, nu, dt, riv_i, riv_j, n):
    # elevation change along river course due to diffusional smoothing
    for c in xrange(1, len(riv_i) - 1):
        n_prev = n[riv_i[c - 1], riv_j[c - 1]]
        n_cur = n[riv_i[c], riv_j[c]]
        n_next = n[riv_i[c + 1], riv_j[c + 1]]

        dwnst_dx, upst_dx = dx, dx
        if is_diagonal_neighbor((riv_i[c], riv_j[c]), (riv_i[c + 1], riv_j[c + 1])):
            dwnst_dx *= np.sqrt(2.)

        if is_diagonal_neighbor((riv_i[c], riv_j[c]), (riv_i[c - 1], riv_j[c - 1])):
            upst_dx *= np.sqrt(2.)

        dwnst_dn = (n_next - n_cur) / dwnst_dx
        upst_dn = (n_cur - n_prev) / upst_dx
        mean_dx = (dwnst_dx + upst_dx) * .5

        # NOTE: This is the old way but, I think, is incorrect. For
        # non-uniform spacing of points you need to divide by the mean spacing.
        #dn_rc = (nu * dt) / (dx ** 2.) * (dwnst_dn - upst_dn)

        # This properly solves the second derivative with unequal spacing in x.
        dn_rc = (nu / dx * dt) * (dwnst_dn - upst_dn) / mean_dx

        n[riv_i[c], riv_j[c]] += dn_rc

    return n
Example #2
0
def calc_qs(nu, riv_i, riv_j, n, dx, dy, dt):

    sed_flux = 0
    dist = 0

    if is_diagonal_neighbor((riv_i[-1], riv_j[-1]), (riv_i[-2], riv_j[-2])):
        dist = np.sqrt(2.)
    else:
        dist = 1.

    sed_flux = - (nu * dt) * ((n[riv_i[-1], riv_j[-1]] -
                               n[riv_i[-2], riv_j[-2]]) / dist)

    return sed_flux