malta.transport =============== .. py:module:: malta.transport Functions --------- .. autoapisummary:: malta.transport.eulerian_diffusion_zz malta.transport.eulerian_diffusion_yy malta.transport.diff_matmul malta.transport.rk4 malta.transport.interpolate1D malta.transport.diff_Q0 malta.transport.u_diffusive malta.transport.cross_terms malta.transport.deltaQ malta.transport.Qmonotonic malta.transport.calc_As malta.transport.calc_flux malta.transport.linrood_advection malta.transport.cranknicholson_convection malta.transport.convection Module Contents --------------- .. py:function:: eulerian_diffusion_zz(Dzz, dx, mva) Creates matrix for one-dimensional Eulerian diffusion in z-direction using central differencing. :param Dzz: Diffusion (m2/s) in the z-direction (alitude) at all points. :type Dzz: array :param dx: Uniform grid spacing in the z-direction. :type dx: float :param mva: Molar density of air (mol/m3) for each vertical layer. :type mva: array :returns: A matrix containing diffusivity in z-direction. :rtype: array .. py:function:: eulerian_diffusion_yy(Dyy, dy, cosc_in, cose_in) Creates matrix for one-dimensional Eulerian diffusion in y-direction using central differencing. :param Dzz: Diffusion (m2/s) in the y-direction (alitude) at all points. :type Dzz: array :param dy: Uniform grid spacing in the y-direction. :type dy: float :param cosc_in: Cosine of latitude at grid centre :type cosc_in: array :param cose_in: Cosine of latitude at grid edge :type cose_in: array :returns: A matrix containing diffusivity in y-direction. :rtype: array .. py:function:: diff_matmul(cin, mva, A, dt) Simple matrix multiplication for Eulerian diffusion (not used) .. py:function:: rk4(cin, mva, Amat, dt) Runga-Kutta 4 solver for diffusion .. py:function:: interpolate1D(Fold, xnew, xold) Fast linear 1D interpolation for Dyz diffusion :param Fold: Field to interpolate. :type Fold: array :param xnew: Old cartesian coordinate locations. :type xnew: array :param xold: New cartesian coordinate locations. :type xold: array :returns: Interpolated field. :rtype: array .. py:function:: diff_Q0(Q0in, dx, epsilon=0.001) Calculate central difference of d/dx multiplied by 1/q 1/q*dq/dx -> inf when q -> 0. Therefore place threshold for mole fraction. :param Q0in: Mole fraction field :type Q0in: array :param dx: Uniform grid spacing. :type dx: array :param epsilon: Cut-off value for off-diagonal diffusion. Defaults to 1e-3. :type epsilon: float, optional :returns: Central differenced mole fraction field. :rtype: array .. py:function:: u_diffusive(Q0, Dzy, z, y, ze, ye, dz, dy) A velocity field, effectively Dyz*1/q*d/dx, which can be passed to an advection scheme for positivity preserving mixed derivative diffusion. This assumes w and v are constant following a Picard-linearisation from the previous time step else the advection becomes non-linear. :param Q0: Mole fraction field :type Q0: array :param Dzy: Diffusivitiy on Arakawa C-grid :type Dzy: array :param z: z at grid centres :type z: array :param y: y at grid centres :type y: array :param ze: z at grid edges :type ze: array :param ye: y at grid edges :type ye: array :param dz: Uniform spacing of z :type dz: array :param dy: Uniform spacing of y :type dy: array :returns: w, advective representation of diffusive field in z-direction array: v, advective representation of diffusive field in y-direction :rtype: array .. py:function:: cross_terms(Q0, Cz) Compute 'cross terms' following Eq. 3.11 Lin & Rood 96 .. py:function:: deltaQ(Qg) Compute delta_Q using Eq. 4.1 Lin & Rood 96 .. py:function:: Qmonotonic(Qg, dQg) Compute Qmono using Eq.5 Lin et al. 94 .. py:function:: calc_As(Qg, Qmono) Compute AL, AR and A6 .. py:function:: calc_flux(Qg, Qmono, Cz, dtdx, cosc, cose, mvae, mva, dz=np.array([0, 0]), u=None, horizontal=True) Calculates the flux between grid cells :param Qg: Cross-terms calculated by function cross_terms :type Qg: array :param Qmono: Monotonic concentrations calculated by function Qmonotonic :type Qmono: array :param Cz: Curant number :type Cz: array :param dtdx: Time step divided by grid spacing :type dtdx: float :param cosc: Cosine of latitude at grid centres :type cosc: array :param cose: Cosine of latitude at grid edges :type cose: array :param mvae: Molar density of air (mol/m3) for each vertical layer at cell edges. :type mvae: array :param mva: Molar density of air (mol/m3) for each vertical layer at cell centre. :type mva: array :param dz: Uniform grid spacing in z-direction. Only needed for z-direction flux. Defaults to np.array([0,0]). :type dz: array, optional :param u: Wind velocity. Defaults to None. :type u: array, optional :param horizontal: Whether flux transport is in horizontal (True) or vertical (False). Defaults to True. :type horizontal: bool, optional :returns: Flux between grid cells :rtype: array .. py:function:: linrood_advection(Q0, v, w, dy, dz, dt, mva, mvae, cosc, cose) Wrapper to compute advection in horizonal and vertical. :param Q0: Mole fraction field. :type Q0: array :param v: Horizontal velocity field. :type v: array :param w: Vertical velocity field. :type w: array :param dy: Uniform spacing of y. :type dy: array :param dz: Uniform spacing of z. :type dz: array :param dt: Time step. :type dt: float :param mva: Molar density of air (mol/m3) for each vertical layer at cell centre. :type mva: array :param mvae: Molar density of air (mol/m3) for each vertical layer at cell edges. :type mvae: array :param cosc: Cosine of latitude at grid centres. :type cosc: array :param cose: Cosine of latitude at grid edges. :type cose: array :returns: Advected mole fraction field. :rtype: array .. py:function:: cranknicholson_convection(c_in, C, eps, dt, dz, M) Crank Nicholson solver for convection/frontal systems More complicated matrix than diffusion so needs to be solved .. py:function:: convection(cin, convflux, dz, dt, M) Conmpute convection