General solver of the 1D meridional advection-diffusion equation on the sphere:

$\begin{split}\frac{\partial}{\partial t} \psi(\phi,t) &= -\frac{1}{a \cos\phi} \frac{\partial}{\partial \phi} \left[ \cos\phi ~ F(\phi,t) \right] \\ F &= U(\phi) \psi(\phi) -\frac{K(\phi)}{a} ~ \frac{\partial \psi}{\partial \phi}\end{split}$

for a state variable $$\psi(\phi,t)$$, arbitrary diffusivity $$K(\phi)$$ in units of $$x^2 ~ t^{-1}$$, and advecting velocity $$U(\phi)$$. $$\phi$$ is latitude and $$a$$ is the Earth’s radius (in meters).

$$K$$ and $$U$$ can be scalars, or optionally vector specified at grid cell boundaries (so their lengths must be exactly 1 greater than the length of $$\phi$$).

$$K$$ and $$U$$ can be modified by the user at any time (e.g., after each timestep, if they depend on other state variables).

A fully implicit timestep is used for computational efficiency. Thus the computed tendency $$\frac{\partial \psi}{\partial t}$$ will depend on the timestep.

In addition to the tendency over the implicit timestep, the solver also calculates several diagnostics from the updated state:

• diffusive_flux given by $$-\frac{K(\phi)}{a} ~ \frac{\partial \psi}{\partial \phi}$$ in units of $$[\psi]~[x]$$/s

• advective_flux given by $$U(\phi) \psi(\phi)$$ (same units)

• total_flux, the sum of advective, diffusive and prescribed fluxes

• flux_convergence (or instantanous scalar tendency) given by the right hand side of the first equation above, in units of $$[\psi]$$/s

Non-uniform grid spacing is supported.

The state variable $$\psi$$ may be multi-dimensional, but the diffusion will operate along the latitude dimension only.

class climlab.dynamics.meridional_advection_diffusion.MeridionalAdvectionDiffusion(K=0.0, U=0.0, use_banded_solver=False, prescribed_flux=0.0, **kwargs)[source]

A parent class for meridional advection-diffusion processes.

Attributes
K
U
depth

Depth at grid centers (m)

depth_bounds

Depth at grid interfaces (m)

diagnostics

input

lat

Latitude of grid centers (degrees North)

lat_bounds

Latitude of grid interfaces (degrees North)

lev

Pressure levels at grid centers (hPa or mb)

lev_bounds

Pressure levels at grid interfaces (hPa or mb)

lon

Longitude of grid centers (degrees)

lon_bounds

Longitude of grid interfaces (degrees)

prescribed_flux
timestep

The amount of time over which step_forward() is integrating in unit seconds.

Methods

 add_diagnostic(self, name[, value]) Create a new diagnostic variable called name for this process and initialize it with the given value. add_input(self, name[, value]) Create a new input variable called name for this process and initialize it with the given value. add_subprocess(self, name, proc) Adds a single subprocess to this process. add_subprocesses(self, procdict) Adds a dictionary of subproceses to this process. compute(self) Computes the tendencies for all state variables given current state and specified input. compute_diagnostics(self[, num_iter]) Compute all tendencies and diagnostics, but don’t update model state. declare_diagnostics(self, diaglist) Add the variable names in inputlist to the list of diagnostics. declare_input(self, inputlist) Add the variable names in inputlist to the list of necessary inputs. integrate_converge(self[, crit, verbose]) Integrates the model until model states are converging. integrate_days(self[, days, verbose]) Integrates the model forward for a specified number of days. integrate_years(self[, years, verbose]) Integrates the model by a given number of years. remove_diagnostic(self, name) Removes a diagnostic from the process.diagnostic dictionary and also delete the associated process attribute. remove_subprocess(self, name[, verbose]) Removes a single subprocess from this process. set_state(self, name, value) Sets the variable name to a new state value. set_timestep(self[, timestep, …]) Calculates the timestep in unit seconds and calls the setter function of timestep() step_forward(self) Updates state variables with computed tendencies. to_xarray(self[, diagnostics]) Convert process variables to xarray.Dataset format.
class climlab.dynamics.meridional_advection_diffusion.MeridionalDiffusion(K=0.0, use_banded_solver=False, prescribed_flux=0.0, **kwargs)[source]

A parent class for meridional diffusion-only processes, with advection set to zero.

Otherwise identical to the parent class.

Attributes
K
U
depth

Depth at grid centers (m)

depth_bounds

Depth at grid interfaces (m)

diagnostics

input

lat

Latitude of grid centers (degrees North)

lat_bounds

Latitude of grid interfaces (degrees North)

lev

Pressure levels at grid centers (hPa or mb)

lev_bounds

Pressure levels at grid interfaces (hPa or mb)

lon

Longitude of grid centers (degrees)

lon_bounds

Longitude of grid interfaces (degrees)

prescribed_flux
timestep

The amount of time over which step_forward() is integrating in unit seconds.

Methods

 add_diagnostic(self, name[, value]) Create a new diagnostic variable called name for this process and initialize it with the given value. add_input(self, name[, value]) Create a new input variable called name for this process and initialize it with the given value. add_subprocess(self, name, proc) Adds a single subprocess to this process. add_subprocesses(self, procdict) Adds a dictionary of subproceses to this process. compute(self) Computes the tendencies for all state variables given current state and specified input. compute_diagnostics(self[, num_iter]) Compute all tendencies and diagnostics, but don’t update model state. declare_diagnostics(self, diaglist) Add the variable names in inputlist to the list of diagnostics. declare_input(self, inputlist) Add the variable names in inputlist to the list of necessary inputs. integrate_converge(self[, crit, verbose]) Integrates the model until model states are converging. integrate_days(self[, days, verbose]) Integrates the model forward for a specified number of days. integrate_years(self[, years, verbose]) Integrates the model by a given number of years. remove_diagnostic(self, name) Removes a diagnostic from the process.diagnostic dictionary and also delete the associated process attribute. remove_subprocess(self, name[, verbose]) Removes a single subprocess from this process. set_state(self, name, value) Sets the variable name to a new state value. set_timestep(self[, timestep, …]) Calculates the timestep in unit seconds and calls the setter function of timestep() step_forward(self) Updates state variables with computed tendencies. to_xarray(self[, diagnostics]) Convert process variables to xarray.Dataset format.