示例#1
0
文件: method.py 项目: mmdski/chulengo
    def _dh(h):

        lo, hi = h.limits()
        dh = Array(lo, hi - 1)

        for i in range(lo, hi):
            dh.set(i, h.get(i + 1) - h.get(i))

        return dh
示例#2
0
文件: method.py 项目: mmdski/chulengo
    def new_h(self, h_0):

        n_cells = h_0.shape[0]
        n_ghost = self._n_ghost
        h = Array(1 - n_ghost, n_cells + n_ghost)

        for i in range(n_cells):
            h.set(i + 1, h_0[i])

        return h
示例#3
0
文件: method.py 项目: mmdski/chulengo
    def _phi(self, theta):

        phi = Array.empty_like(theta)

        lo, hi = theta.limits()

        for i in range(lo, hi + 1):
            theta_mid = theta.get(i)
            r = (1 + theta_mid) / 2
            phi.set(i, max(0, min(r, 2, 2 * theta_mid)))

        return phi
示例#4
0
文件: method.py 项目: mmdski/chulengo
    def _flux_lim(self, s, dh, dt, dx):

        theta = self._theta(dh, s)
        phi = self._phi(theta)

        lo, hi = phi.limits()
        lim_flux = Array.empty_like(phi)

        for i in range(lo, hi + 1):
            lim_wave = dh.get(i) * phi.get(i)
            abs_s = abs(s.get(i))
            lim_flux.set(i, 0.5 * abs_s * (1 - dt / dx * abs_s) * lim_wave)

        return lim_flux
示例#5
0
文件: method.py 项目: mmdski/chulengo
    def _theta(self, dh, s):

        lo, hi = dh.limits()
        theta = Array(lo + 1, hi - 1)

        for i in range(lo + 1, hi):

            dh_mid = dh.get(i)

            if dh_mid == 0:
                theta.set(i, 0)
                continue

            dh_left = dh.get(i - 1)
            dh_right = dh.get(i + 1)

            s_mid = s.get(i)

            if s_mid > 0:
                theta.set(i, dh_left / dh_mid)
            elif s_mid < 0:
                theta.set(i, dh_right / dh_mid)

        return theta
示例#6
0
文件: method.py 项目: mmdski/chulengo
    def new_s(self, h):

        lo, hi = h.limits()
        s = Array(lo, hi - 1)

        return s
示例#7
0
文件: method.py 项目: mmdski/chulengo
    def new_f_x(self, h):

        lo, hi = h.limits()

        return Array(lo + self._n_ghost, hi - self._n_ghost)