malta.transport

Functions

eulerian_diffusion_zz(Dzz, dx, mva)

Creates matrix for one-dimensional Eulerian diffusion in z-direction

eulerian_diffusion_yy(Dyy, dy, cosc_in, cose_in)

Creates matrix for one-dimensional Eulerian diffusion in y-direction

diff_matmul(cin, mva, A, dt)

Simple matrix multiplication for Eulerian diffusion (not used)

rk4(cin, mva, Amat, dt)

Runga-Kutta 4 solver for diffusion

interpolate1D(Fold, xnew, xold)

Fast linear 1D interpolation for Dyz diffusion

diff_Q0(Q0in, dx[, epsilon])

Calculate central difference of d/dx multiplied by 1/q

u_diffusive(Q0, Dzy, z, y, ze, ye, dz, dy)

A velocity field, effectively Dyz*1/q*d/dx, which can be

cross_terms(Q0, Cz)

Compute 'cross terms' following Eq. 3.11 Lin & Rood 96

deltaQ(Qg)

Compute delta_Q using Eq. 4.1 Lin & Rood 96

Qmonotonic(Qg, dQg)

Compute Qmono using Eq.5 Lin et al. 94

calc_As(Qg, Qmono)

Compute AL, AR and A6

calc_flux(Qg, Qmono, Cz, dtdx, cosc, cose, mvae, mva)

Calculates the flux between grid cells

linrood_advection(Q0, v, w, dy, dz, dt, mva, mvae, ...)

Wrapper to compute advection in horizonal and vertical.

cranknicholson_convection(c_in, C, eps, dt, dz, M)

Crank Nicholson solver for convection/frontal systems

convection(cin, convflux, dz, dt, M)

Conmpute convection

Module Contents

malta.transport.eulerian_diffusion_zz(Dzz, dx, mva)[source]

Creates matrix for one-dimensional Eulerian diffusion in z-direction using central differencing.

Parameters:
  • Dzz (array) – Diffusion (m2/s) in the z-direction (alitude) at all points.

  • dx (float) – Uniform grid spacing in the z-direction.

  • mva (array) – Molar density of air (mol/m3) for each vertical layer.

Returns:

A matrix containing diffusivity in z-direction.

Return type:

array

malta.transport.eulerian_diffusion_yy(Dyy, dy, cosc_in, cose_in)[source]

Creates matrix for one-dimensional Eulerian diffusion in y-direction using central differencing.

Parameters:
  • Dzz (array) – Diffusion (m2/s) in the y-direction (alitude) at all points.

  • dy (float) – Uniform grid spacing in the y-direction.

  • cosc_in (array) – Cosine of latitude at grid centre

  • cose_in (array) – Cosine of latitude at grid edge

Returns:

A matrix containing diffusivity in y-direction.

Return type:

array

malta.transport.diff_matmul(cin, mva, A, dt)[source]

Simple matrix multiplication for Eulerian diffusion (not used)

malta.transport.rk4(cin, mva, Amat, dt)[source]

Runga-Kutta 4 solver for diffusion

malta.transport.interpolate1D(Fold, xnew, xold)[source]

Fast linear 1D interpolation for Dyz diffusion

Parameters:
  • Fold (array) – Field to interpolate.

  • xnew (array) – Old cartesian coordinate locations.

  • xold (array) – New cartesian coordinate locations.

Returns:

Interpolated field.

Return type:

array

malta.transport.diff_Q0(Q0in, dx, epsilon=0.001)[source]

Calculate central difference of d/dx multiplied by 1/q 1/q*dq/dx -> inf when q -> 0. Therefore place threshold for mole fraction.

Parameters:
  • Q0in (array) – Mole fraction field

  • dx (array) – Uniform grid spacing.

  • epsilon (float, optional) – Cut-off value for off-diagonal diffusion. Defaults to 1e-3.

Returns:

Central differenced mole fraction field.

Return type:

array

malta.transport.u_diffusive(Q0, Dzy, z, y, ze, ye, dz, dy)[source]

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.

Parameters:
  • Q0 (array) – Mole fraction field

  • Dzy (array) – Diffusivitiy on Arakawa C-grid

  • z (array) – z at grid centres

  • y (array) – y at grid centres

  • ze (array) – z at grid edges

  • ye (array) – y at grid edges

  • dz (array) – Uniform spacing of z

  • dy (array) – Uniform spacing of y

Returns:

w, advective representation of diffusive field in z-direction array: v, advective representation of diffusive field in y-direction

Return type:

array

malta.transport.cross_terms(Q0, Cz)[source]

Compute ‘cross terms’ following Eq. 3.11 Lin & Rood 96

malta.transport.deltaQ(Qg)[source]

Compute delta_Q using Eq. 4.1 Lin & Rood 96

malta.transport.Qmonotonic(Qg, dQg)[source]

Compute Qmono using Eq.5 Lin et al. 94

malta.transport.calc_As(Qg, Qmono)[source]

Compute AL, AR and A6

malta.transport.calc_flux(Qg, Qmono, Cz, dtdx, cosc, cose, mvae, mva, dz=np.array([0, 0]), u=None, horizontal=True)[source]

Calculates the flux between grid cells

Parameters:
  • Qg (array) – Cross-terms calculated by function cross_terms

  • Qmono (array) – Monotonic concentrations calculated by function Qmonotonic

  • Cz (array) – Curant number

  • dtdx (float) – Time step divided by grid spacing

  • cosc (array) – Cosine of latitude at grid centres

  • cose (array) – Cosine of latitude at grid edges

  • mvae (array) – Molar density of air (mol/m3) for each vertical layer at cell edges.

  • mva (array) – Molar density of air (mol/m3) for each vertical layer at cell centre.

  • dz (array, optional) – Uniform grid spacing in z-direction. Only needed for z-direction flux. Defaults to np.array([0,0]).

  • u (array, optional) – Wind velocity. Defaults to None.

  • horizontal (bool, optional) – Whether flux transport is in horizontal (True) or vertical (False). Defaults to True.

Returns:

Flux between grid cells

Return type:

array

malta.transport.linrood_advection(Q0, v, w, dy, dz, dt, mva, mvae, cosc, cose)[source]

Wrapper to compute advection in horizonal and vertical.

Parameters:
  • Q0 (array) – Mole fraction field.

  • v (array) – Horizontal velocity field.

  • w (array) – Vertical velocity field.

  • dy (array) – Uniform spacing of y.

  • dz (array) – Uniform spacing of z.

  • dt (float) – Time step.

  • mva (array) – Molar density of air (mol/m3) for each vertical layer at cell centre.

  • mvae (array) – Molar density of air (mol/m3) for each vertical layer at cell edges.

  • cosc (array) – Cosine of latitude at grid centres.

  • cose (array) – Cosine of latitude at grid edges.

Returns:

Advected mole fraction field.

Return type:

array

malta.transport.cranknicholson_convection(c_in, C, eps, dt, dz, M)[source]

Crank Nicholson solver for convection/frontal systems More complicated matrix than diffusion so needs to be solved

malta.transport.convection(cin, convflux, dz, dt, M)[source]

Conmpute convection