# MeridionalDiffusion¶

General solver of the 1D meridional 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 &= -\frac{K}{a} ~ \frac{\partial \Psi}{\partial \phi}\end{split}$

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

The diffusivity $$K$$ can be a single scalar, or optionally a vector specified at grid cell boundaries (so its length must be exactly 1 greater than the length of $$\phi$$).

$$K$$ can be modified by the user at any time (e.g., after each timestep, if it depends 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 two diagnostics from the updated state:

• diffusive_flux given by $$F(\phi)$$ in units of $$[\Psi]$$ m/s
• diffusive_flux_convergence given by $$-\frac{1}{a \cos\phi} \frac{\partial}{\partial \phi} \left[ \cos\phi ~ F(\phi,t) \right]$$ in units of $$[\Psi]$$/s

The grid must be evenly spaced in latitude.

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

class climlab.dynamics.meridional_diffusion.MeridionalDiffusion(K=None, **kwargs)[source]

A parent class for Meridional diffusion processes.

Calculates the energy transport in a diffusion like process along the temperature gradient:

$H(\varphi) = \frac{D}{\cos \varphi}\frac{\partial}{\partial \varphi} \left( \cos\varphi \frac{\partial T(\varphi)}{\partial \varphi} \right)$

for an Energy Balance Model whose Energy Budget can be noted as:

$C(\varphi) \frac{dT(\varphi)}{dt} = R\downarrow (\varphi) - R\uparrow (\varphi) + H(\varphi)$

Initialization parameters

An instance of MeridionalDiffusion is initialized with the following arguments:

Parameters: K (float) – diffusion parameter in units of $$m^2/s$$

Object attributes

Additional to the parent class Diffusion which is initialized with diffusion_axis='lat', following object attributes are modified during initialization:

Variables: _K_dimensionless (array) – As _K_dimensionless has been computed like $$K_{\textrm{dimensionless}}= K \frac{\Delta t}{(\Delta \textrm{bounds})^2}$$ with $$K$$ in units $$1/s$$, the $$\Delta (\textrm{bounds})$$ have to be converted from deg to rad to make the array actually dimensionless. This is done during initialiation. _diffTriDiag (array) – the diffusion matrix is recomputed with appropriate weights for the meridional case by _make_meridional_diffusion_matrix() Meridional Diffusion of temperature as a stand-alone process: import numpy as np import climlab from climlab.dynamics.diffusion import MeridionalDiffusion from climlab.utils import legendre sfc = climlab.domain.zonal_mean_surface(num_lat=90, water_depth=10.) lat = sfc.lat.points initial = 12. - 40. * legendre.P2(np.sin(np.deg2rad(lat))) # make a copy of initial so that it remains unmodified Ts = climlab.Field(np.array(initial), domain=sfc) # thermal diffusivity in W/m**2/degC D = 0.55 # meridional diffusivity in 1/s K = D / sfc.heat_capacity d = MeridionalDiffusion(state=Ts, K=K) d.integrate_years(1.) import matplotlib.pyplot as plt fig = plt.figure( figsize=(6,4)) ax = fig.add_subplot(111) ax.set_title('Example for Meridional Diffusion') ax.set_xlabel('latitude') ax.set_xticks([-90,-60,-30,0,30,60,90]) ax.set_ylabel('temperature ($^{\circ}$C)') ax.plot(lat, initial, label='initial') ax.plot(lat, Ts, label='Ts (1yr)') ax.legend(loc='best') plt.show() K depth Depth at grid centers (m) depth_bounds Depth at grid interfaces (m) diagnostics Dictionary access to all diagnostic variables input Dictionary access to all input variables 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) timestep The amount of time over which step_forward() is integrating in unit seconds.

Methods

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