Exemplo n.º 1
0
    def __call__(self, z, t):
        lnp = z[0]
        T = z[1]
        w = z[2]

        Dlnp_Dt = - (1 / (1 - const.R / const.C_p)) * derivative.diff_forward_n1_e1(w, self.delta_z) \

        dT_dt = (const.R / const.C_p) * T * Dlnp_Dt - average.avg_forward_e1(
            w) * derivative.diff_n1_e2(T, self.delta_z)

        dlnp_dt = Dlnp_Dt - average.avg_forward_e1(w) * derivative.diff_n1_e2(
            lnp, self.delta_z)

        dw_dt = - const.R * average.avg_backward_e1(T) * derivative.diff_backward_n1_e1(lnp, self.delta_z) + self.g_z \
                - w * derivative.diff_n1_e2(w, self.delta_z)

        dlnp_dt[-1] = dlnp_dt[-2]
        dT_dt[-1] = dT_dt[-2]
        dw_dt[0] = dw_dt[
            -1] = 0  # wind at top and bottom stays constant at zero

        # generate output
        dz = np.stack((dlnp_dt, dT_dt, dw_dt), axis=-1)
        dz = dz.transpose()
        return dz
Exemplo n.º 2
0
    def __call__(self, z, t):
        rho = z[0]
        rho_top = np.ones_like(rho) * rho[0]
        rho_bottom = np.ones_like(rho) * rho[-1]
        rho = np.concatenate((rho_top, rho, rho_bottom))

        w = z[1]
        w_flip = np.zeros_like(w)
        w = np.concatenate((w_flip, w, w_flip))

        drho_dt = - derivative.diff_n1_e4(rho * average.avg_forward_e1(w), self.delta_z)

        if self.non_linear:
            pass

        rho_on_u_grid = average.avg_backward_e1(rho)

        p = rho_on_u_grid * const.R * const.T

        dw_dt = - w * derivative.diff_n1_e4(w, self.delta_z) \
                - derivative.diff_n1_e4(p, self.delta_z) / rho_on_u_grid  # + 3.0

        if self.non_linear:
            pass  # dw_dt +=

        drho_dt = np.split(drho_dt, 3)[1]
        drho_dt[-1] = drho_dt[-2]

        dw_dt = np.split(dw_dt, 3)[1]
        dw_dt[0] = dw_dt[-1] = 0  # wind at top and bottom stays constant at zero

        # generate output
        dz = np.stack((drho_dt, dw_dt), axis=-1)
        dz = dz.transpose()
        return dz
Exemplo n.º 3
0
    def __call__(self, z, t):
        lnp = z[0]
        T = z[1]
        w = z[2]

        #alpha = (0.024 / C_p) * np.exp(-average.avg_backward_1(lnp))

        Dlnp_Dt = - (1 / (1 - const.R / const.C_p)) * derivative.diff_forward_n1_e1(w, self.delta_z) \
         #         + (alpha * R / C_p) * np.exp(- average.avg_backward_1(lnp)) * laplace.diff_n2_e2(

        #  average.avg_forward_1(T), self.delta_z)

        dT_dt = (const.R / const.C_p) * T * average.avg_backward_e1(Dlnp_Dt) \
                - w * derivative.diff_n1_e2(T, self.delta_z) \
           #     + (alpha * R / C_p) * laplace.diff_n2_e2(T, self.delta_z)


        dlnp_dt = Dlnp_Dt - average.avg_forward_e1(w) * derivative.diff_n1_e2(lnp, self.delta_z) \

        dw_dt = - const.R * T * derivative.diff_backward_n1_e1(lnp, self.delta_z) + self.g_z \
                - w * derivative.diff_n1_e2(w, self.delta_z) \
                + 1.5e-5 * const.R * T * np.exp(- average.avg_backward_e1(lnp)) * laplace.diff_n2_e2(w, self.delta_z)

        dlnp_dt[-1] = dlnp_dt[-2]
        dw_dt[0] = dw_dt[
            -1] = 0  # wind at top and bottom stays constant at zero

        # generate output
        dz = np.stack((dlnp_dt, dT_dt, dw_dt), axis=-1)
        dz = dz.transpose()
        return dz
Exemplo n.º 4
0
def s_to_z(axis, lnp, T, dpi_ds, num_grid_points):
    # converting lnp on offset grid to p on non-offset grid
    bottom_val = lnp[-1]
    top_val = lnp[1]
    lnp = average.avg_forward_e1(lnp)
    p = np.exp(lnp)
    p[0] = np.exp(top_val) / 2
    p[-1] = np.exp(bottom_val)

    # converting T on offset grid to T on non-offset grid
    top_val = T[1]
    bottom_val = T[-1]
    T = average.avg_forward_e1(T)
    T[1] = top_val
    T[-1] = bottom_val

    z = (const.R / const.g * np.cumsum(np.flip(
        (T * dpi_ds(axis) / p))) / num_grid_points)
    return np.flip(z)
Exemplo n.º 5
0
def s_to_z(axis, lnp, T, dpi_ds, num_grid_points):
    # converting lnp on offset grid to p on non-offset grid
    bottom_val = lnp[-1]
    top_val = lnp[1]
    lnp = average.avg_forward_e1(lnp)
    p = np.exp(lnp)
    p[0] = np.exp(top_val) / 2
    p[-1] = np.exp(bottom_val)

    z = (const.R / const.g * np.cumsum(np.flip(
        (T * dpi_ds(axis) / p))) / num_grid_points)
    # print("align: {}".format(np.max(z)))
    return np.flip(z)
Exemplo n.º 6
0
    def __call__(self, z, t):
        lnrho = z[0]
        w = z[1]

        dlnrho_dt = - derivative.diff_forward_n1_e1(w, self.delta_z)

        if self.non_linear:
            dlnrho_dt += - average.avg_forward_e1(w) * derivative.diff_n1_e2(lnrho, self.delta_z)

        dw_dt = - const.T * const.R * derivative.diff_backward_n1_e1(lnrho, self.delta_z) + const.g

        if self.non_linear:
            dw_dt += - w * derivative.diff_n1_e2(w, self.delta_z)
            if self.viscosity:
                dw_dt += 0.05 * np.exp(- average.avg_backward_e1(lnrho)) * laplace.diff_n2_e2(w, self.delta_z)

        dlnrho_dt[-1] = dlnrho_dt[-2]
        dw_dt[0] = dw_dt[-1] = 0  # wind at top and bottom stays constant at zero

        # generate output
        dz = np.stack((dlnrho_dt, dw_dt), axis=-1)
        dz = dz.transpose()
        return dz