Inner Products

The inner products modules contain or produce the inner products needed for the projection of the model’s equations on basis of functions defined on its spatial domain.

Inner products module (base class)

Abstract base classes of the structure containing the inner products \((\cdot, \, \cdot)\) between the truncated set of basis functions \(\phi_i\) for the ocean and land fields, and \(F_i\) for the atmosphere fields (see Projecting the equations on a set of basis functions).

Description of the classes

The three classes computing and holding the inner products of the basis functions are:

Warning

These are abstract base class, they must be subclassed and the functions to compute the inner products must be defined!

class qgs.inner_products.base.AtmosphericInnerProducts[source]

Bases: ABC

Base class which contains all the atmospheric inner products coefficients needed for the tendencies tensor QgsTensor computation.

abstract a(i, j)[source]

Function to compute the matrix of the eigenvalues of the Laplacian (atmospheric): \(a_{i, j} = (F_i, {\nabla}^2 F_j)\).

abstract b(i, j, k)[source]

Function to compute the tensors holding the Jacobian inner products: \(b_{i, j, k} = (F_i, J(F_j, \nabla^2 F_k))\).

abstract c(i, j)[source]

Function to compute the matrix of beta terms for the atmosphere: \(c_{i,j} = (F_i, \partial_x F_j)\).

abstract d(i, j)[source]

Function to compute the forcing of the ocean on the atmosphere: \(d_{i,j} = (F_i, \nabla^2 \phi_j)\).

abstract g(i, j, k)[source]

Function to compute tensors holding the Jacobian inner products: \(g_{i,j,k} = (F_i, J(F_j, F_k))\).

load_from_file(filename, **kwargs)[source]

Function to load previously saved inner product object with the method save_to_file().

Parameters
  • filename (str) – The file name where the inner product object was saved.

  • kwargs (dict) – Keyword arguments to pass to the pickle module method.

abstract property natm

Number of atmospheric modes.

abstract s(i, j)[source]

Function to compute the forcing (thermal) of the ocean on the atmosphere: \(s_{i,j} = (F_i, \phi_j)\).

save_to_file(filename, **kwargs)[source]

Function to save the inner object to a file with the pickle module.

Parameters
  • filename (str) – The file name where to save the inner product object.

  • kwargs (dict) – Keyword arguments to pass to the pickle module method.

abstract u(i, j)[source]

Function to compute the matrix of inner product: \(u_{i, j} = (F_i, F_j)\).

abstract v(i, j, k, l, m)[source]

Function to compute the \(T^4\) temperature forcing of the ocean on the atmosphere: \(v_{i,j,k,l,m} = (F_i, \phi_j \phi_k \phi_l \phi_m)\).

abstract z(i, j, k, l, m)[source]

Function to compute the \(T^4\) temperature forcing for the radiation lost by atmosphere to space & ground/ocean: \(z_{i,j,k,l,m} = (F_i, F_j F_k F_l F_m)\).

class qgs.inner_products.base.GroundInnerProducts[source]

Bases: ABC

Base class which contains all the ground inner products coefficients needed for the tendencies tensor QgsTensor computation.

abstract C(i, j, k)[source]

Function to compute the tensors holding the Jacobian inner products: \(C_{i,j,k} = (\phi_i, J(\phi_j,\nabla^2 \phi_k))\).

abstract K(i, j)[source]

Function to compute the forcing of the ocean by the atmosphere: \(K_{i,j} = (\phi_i, \nabla^2 F_j)\).

abstract M(i, j)[source]

Function to compute the forcing of the ocean fields on the ocean: \(M_{i,j} = (\phi_i, \nabla^2 \phi_j)\).

abstract N(i, j)[source]

Function computing the beta term for the ocean: \(N_{i,j} = (\phi_i, \partial_x \phi_j)\).

abstract O(i, j, k)[source]

Function to compute the temperature advection term (passive scalar): \(O_{i,j,k} = (\phi_i, J(\phi_j, \phi_k))\)

abstract U(i, j)[source]

Function to compute the inner products: \(U_{i,j} = (\phi_i, \phi_j)\).

abstract W(i, j)[source]

Function to compute the short-wave radiative forcing of the ocean: \(W_{i,j} = (\phi_i, F_j)\).

load_from_file(filename, **kwargs)[source]

Function to load previously saved inner product object with the method save_to_file().

Parameters
  • filename (str) – The file name where the inner product object was saved.

  • kwargs (dict) – Keyword arguments to pass to the pickle module method.

abstract property ngr

Number of ground modes.

save_to_file(filename, **kwargs)[source]

Function to save the inner object to a file with the pickle module.

Parameters
  • filename (str) – The file name where to save the inner product object.

  • kwargs (dict) – Keyword arguments to pass to the pickle module method.

class qgs.inner_products.base.OceanicInnerProducts[source]

Bases: ABC

Base class which contains all the oceanic inner products coefficients needed for the tendencies tensor QgsTensor computation.

abstract C(i, j, k)[source]

Function to compute the tensors holding the Jacobian inner products: \(C_{i,j,k} = (\phi_i, J(\phi_j,\nabla^2 \phi_k))\).

abstract K(i, j)[source]

Function to compute the forcing of the ocean by the atmosphere: \(K_{i,j} = (\phi_i, \nabla^2 F_j)\).

abstract M(i, j)[source]

Function to compute the forcing of the ocean fields on the ocean: \(M_{i,j} = (\phi_i, \nabla^2 \phi_j)\).

abstract N(i, j)[source]

Function computing the beta term for the ocean: \(N_{i,j} = (\phi_i, \partial_x \phi_j)\).

abstract O(i, j, k)[source]

Function to compute the temperature advection term (passive scalar): \(O_{i,j,k} = (\phi_i, J(\phi_j, \phi_k))\)

abstract U(i, j)[source]

Function to compute the inner products: \(U_{i,j} = (\phi_i, \phi_j)\).

abstract V(i, j, k, l, m)[source]

Function to compute the \(T^4\) temperature forcing from the ocean to the atmosphere: \(V_{i,j,k,l,m} = (\phi_i, \phi_j, \phi_k, \phi_l, \phi_m)\).

abstract W(i, j)[source]

Function to compute the short-wave radiative forcing of the ocean: \(W_{i,j} = (\phi_i, F_j)\).

abstract Z(i, j, k, l, m)[source]

Function to compute the \(T^4\) temperature forcing from the atmosphere to the ocean: \(Z_{i,j,k,l,m} = (\phi_i, F_j, F_k, F_l, F_m)\).

load_from_file(filename, **kwargs)[source]

Function to load previously saved inner product object with the method save_to_file().

Parameters
  • filename (str) – The file name where the inner product object was saved.

  • kwargs (dict) – Keyword arguments to pass to the pickle module method.

abstract property noc

Number of oceanic modes.

save_to_file(filename, **kwargs)[source]

Function to save the inner product object to a file with the pickle module.

Parameters
  • filename (str) – The file name where to save the inner product object.

  • kwargs (dict) – Keyword arguments to pass to the pickle module method.

Inner products definition module

Module containing classes to define the inner products used by the model.

class qgs.inner_products.definition.InnerProductDefinition(optimizer=None)[source]

Bases: ABC

Base class to define the model’s basis inner products.

Parameters

optimizer (None or callable, optional) – A function to optimize the computation of the integrals or the integrand. If None, does not optimize.

optimizer

A function to optimize the computation of the integrals or the integrand. If None, does not optimize the computation.

Type

None or callable

abstract ip_diff_x(S, G, symbolic_expr=False)[source]

Function to compute the inner product \((S, \partial_x G)\).

Parameters
  • S – Left-hand side function of the product.

  • G – Right-hand side function of the product.

  • symbolic_expr (bool, optional) – If True, return the integral as a symbolic expression object. Else, return the integral performed symbolically.

abstract ip_jac(S, G, H, symbolic_expr=False)[source]

Function to compute the inner product \((S, J(G, H))\), where \(J\) is the jacobian().

Parameters
  • S – Left-hand side function of the product.

  • G – 1st argument of the right-hand side function of the product.

  • H – 2nd argument of the right-hand side function of the product.

  • symbolic_expr (bool, optional) – If True, return the integral as a symbolic expression object. Else, return the integral performed symbolically.

abstract ip_jac_lap(S, G, H, symbolic_expr=False)[source]

Function to compute the inner product \((S, J(G, \nabla^2 H))\), where \(J\) is the jacobian().

Parameters
  • S – Left-hand side function of the product.

  • G – 1st argument of the right-hand side function of the product.

  • H – 2nd argument of the right-hand side function of the product.

  • symbolic_expr (bool, optional) – If True, return the integral as a symbolic expression object. Else, return the integral performed symbolically.

abstract ip_lap(S, G, symbolic_expr=False)[source]

Function to compute the inner product \((S, \nabla^2 G)\).

Parameters
  • S – Left-hand side function of the product.

  • G – Right-hand side function of the product.

  • symbolic_expr (bool, optional) – If True, return the integral as a symbolic expression object. Else, return the integral performed symbolically.

abstract static jacobian(S, G)[source]

Jacobian present in the advection terms:

Parameters
  • S – 1st argument the Jacobian.

  • G – 2nd argument the Jacobian.

abstract static laplacian(S)[source]

Laplacian \(\nabla^2 S\) of a function \(S\).

set_optimizer(optimizer)[source]

Function to set the optimizer.

Parameters

optimizer (callable) – A function to optimize the computation of the integrals or the integrand.

class qgs.inner_products.definition.StandardSymbolicInnerProductDefinition(optimizer=None)[source]

Bases: SymbolicInnerProductDefinition

Standard qgs class to define symbolic inner products using Sympy.

Parameters

optimizer (None or callable, optional) – A function to simplify the integrand to optimize the computation of the integrals. Should return a Sympy expression. If None, does not optimize the computation.

optimizer

A function to simplify the integrand to optimize the computation of the integrals. Should return a Sympy expression. If None, does not optimize the computation.

Type

None or callable

static integrate_over_domain(expr, symbolic_expr=False)[source]

Definition of the normalized integrals over the spatial domain used by the inner products: \(\frac{n}{2\pi^2}\int_0^\pi\int_0^{2\pi/n} \, \mathrm{expr}(x, y) \, \mathrm{d} x \, \mathrm{d} y\).

Parameters
  • expr (Sympy expression) – The expression to integrate.

  • symbolic_expr (bool, optional) – If True, return the integral as a symbolic expression object. Else, return the integral performed symbolically.

Returns

The result of the symbolic integration.

Return type

Sympy expression

static jacobian(S, G)[source]

Jacobian present in the advection terms:

Parameters
  • S (Sympy expression) – 1st argument the Jacobian.

  • G (Sympy expression) – 2nd argument the Jacobian.

Returns

The Jacobian.

Return type

Sympy expression

static laplacian(S)[source]

Laplacian \(\nabla^2 S\) of a given function \(S\) in 2D cartesian coordinates: \(\nabla^2 S = \partial^2_x S + \partial^2_y S\).

Parameters

S (Sympy expression) – Functions to take the Laplacian of.

Returns

The Laplacian.

Return type

Sympy expression

symbolic_inner_product(S, G, symbolic_expr=False, integrand=False)[source]

Function defining the inner product to be computed symbolically: \((S, G) = \frac{n}{2\pi^2}\int_0^\pi\int_0^{2\pi/n} S(x,y)\, G(x,y)\, \mathrm{d} x \, \mathrm{d} y\).

Parameters
  • S (Sympy expression) – Left-hand side function of the product.

  • G (Sympy expression) – Right-hand side function of the product.

  • symbolic_expr (bool, optional) – If True, return the integral as a symbolic expression object. Else, return the integral performed symbolically.

  • integrand (bool, optional) – If True, return the integrand of the integral and its integration limits as a list of symbolic expression object. Else, return the integral performed symbolically.

Returns

The result of the symbolic integration

Return type

Sympy expression

class qgs.inner_products.definition.SymbolicInnerProductDefinition(optimizer=None)[source]

Bases: InnerProductDefinition

Base class to define symbolic inner products using Sympy.

Parameters

optimizer (None or callable, optional) – A function to simplify the integrand to optimize the computation of the integrals. Should return a Sympy expression. If None, does not optimize the computation.

optimizer

A function to simplify the integrand to optimize the computation of the integrals. Should return a Sympy expression. If None, does not optimize the computation.

Type

None or callable

ip_diff_x(S, G, symbolic_expr=False, integrand=False)[source]

Function to compute the inner product \((S, \partial_x G)\).

Parameters
  • S (Sympy expression) – Left-hand side function of the product.

  • G (Sympy expression) – Right-hand side function of the product.

  • symbolic_expr (bool, optional) – If True, return the integral as a symbolic expression object. Else, return the integral performed symbolically.

  • integrand (bool, optional) – If True, return the integrand of the integral and its integration limits as a list of symbolic expression object. Else, return the integral performed symbolically.

Returns

The symbolic result of the inner product.

Return type

Sympy expression

ip_jac(S, G, H, symbolic_expr=False, integrand=False)[source]

Function to compute the inner product \((S, J(G, H))\), where \(J\) is the jacobian().

Parameters
  • S (Sympy expression) – Left-hand side function of the product.

  • G (Sympy expression) – 1st argument of the right-hand side function of the product.

  • H (Sympy expression) – 2nd argument of the right-hand side function of the product.

  • symbolic_expr (bool, optional) – If True, return the integral as a symbolic expression object. Else, return the integral performed symbolically.

  • integrand (bool, optional) – If True, return the integrand of the integral and its integration limits as a list of symbolic expression object. Else, return the integral performed symbolically.

Returns

The symbolic result of the inner product.

Return type

Sympy expression

ip_jac_lap(S, G, H, symbolic_expr=False, integrand=False)[source]

Function to compute the inner product \((S, J(G, \nabla^2 H))\), where \(J\) is the jacobian().

Parameters
  • S (Sympy expression) – Left-hand side function of the product.

  • G (Sympy expression) – 1st argument of the right-hand side function of the product.

  • H (Sympy expression) – 2nd argument of the right-hand side function of the product.

  • symbolic_expr (bool, optional) – If True, return the integral as a symbolic expression object. Else, return the integral performed symbolically.

  • integrand (bool, optional) – If True, return the integrand of the integral and its integration limits as a list of symbolic expression object. Else, return the integral performed symbolically.

Returns

The symbolic result of the inner product.

Return type

Sympy expression

ip_lap(S, G, symbolic_expr=False, integrand=False)[source]

Function to compute the inner product \((S, \nabla^2 G)\).

Parameters
  • S (Sympy expression) – Left-hand side function of the product.

  • G (Sympy expression) – Right-hand side function of the product.

  • symbolic_expr (bool, optional) – If True, return the integral as a symbolic expression object. Else, return the integral performed symbolically.

  • integrand (bool, optional) – If True, return the integrand of the integral and its integration limits as a list of symbolic expression object. Else, return the integral performed symbolically.

Returns

The symbolic result of the inner product.

Return type

Sympy expression

abstract symbolic_inner_product(S, G, symbolic_expr=False, integrand=False)[source]

Symbolic definition of the inner product \((S, G)\).

Parameters
  • S (Sympy expression) – Left-hand side function of the product.

  • G (Sympy expression) – Right-hand side function of the product.

  • symbolic_expr (bool, optional) – If True, return the integral as a symbolic expression object. Else, return the integral performed symbolically.

  • integrand (bool, optional) – If True, return the integrand of the integral and its integration limits as a list of symbolic expression object. Else, return the integral performed symbolically.

Returns

The symbolic result of the inner product.

Return type

Sympy expression

Analytic Inner products module

Inner products

\[(S, G) = \frac{n}{2\pi^2}\int_0^\pi\int_0^{2\pi/n} S(x,y)\, G(x,y)\, \mathrm{d} x \, \mathrm{d} y\]

between the truncated set of basis functions \(\phi_i\) for the ocean and land fields, and \(F_i\) for the atmosphere fields (see Projecting the equations on a set of basis functions).

Notes

These inner products are computed using the analytical expressions from:

  • De Cruz, L., Demaeyer, J. and Vannitsem, S.: The Modular Arbitrary-Order Ocean-Atmosphere Model: MAOOAM v1.0, Geosci. Model Dev., 9, 2793-2808, doi:10.5194/gmd-9-2793-2016, 2016.

  • Cehelsky, P., & Tung, K. K. (1987). Theories of multiple equilibria and weather regimes—A critical reexamination. Part II: Baroclinic two-layer models. Journal of the atmospheric sciences, 44 (21), 3282-3303. doi:10.1175/1520-0469(1987)044%3C3282%3ATOMEAW%3E2.0.CO%3B2

Description of the classes

The three classes computing and holding the inner products of the basis functions are:

class qgs.inner_products.analytic.AtmosphericAnalyticInnerProducts(params=None, stored=True)[source]

Bases: AtmosphericInnerProducts

Class which contains all the atmospheric inner products coefficients needed for the tendencies tensor QgsTensor computation, computed with analytic formula.

Parameters
  • params (None or QgParams or list, optional) – An instance of model’s parameters object or a list in the form [aspect_ratio, ablocks, natm]. If a list is provided, aspect_ratio is the aspect ratio of the domain, ablocks is a spectral blocks detailing the model’s atmospheric modes \(x\)-and \(y\)-wavenumber as an array of shape (natm, 2), and natm is the number of modes in the atmosphere. If None, an empty object is initialized.

  • stored (bool, optional) – Indicate if the inner products must be computed and stored at the initialization. Default to True.

n

The aspect ratio of the domain.

Type

float

ocean_inner_products

The inner products of the ocean. None if no ocean.

Type

None or OceanicAnalyticInnerProducts

connected_to_ocean

Indicate if the atmosphere is connected to an ocean.

Type

bool

ground_inner_products

The inner products of the ground. None if no ground.

Type

None or GroundAnalyticInnerProducts

connected_to_ground

Indicate if the atmosphere is connected to the ground.

Type

bool

stored

Indicate if the inner products are stored in the object.

Type

bool

atmospheric_wavenumbers

An array of shape (nmod [0], ) of the wavenumber object of each mode.

Type

ndarray(WaveNumber)

a(i, j)[source]

Function to compute the matrix of the eigenvalues of the Laplacian (atmospheric): \(a_{i, j} = (F_i, {\nabla}^2 F_j)\).

b(i, j, k)[source]

Function to compute the tensors holding the Jacobian inner products: \(b_{i, j, k} = (F_i, J(F_j, \nabla^2 F_k))\).

c(i, j)[source]

Function to compute the matrix of beta terms for the atmosphere: \(c_{i,j} = (F_i, \partial_x F_j)\).

compute_inner_products()[source]

Function computing and storing all the inner products at once.

connect_to_ground(ground_inner_products)[source]

Connect the atmosphere to the ground.

Parameters

ground_inner_products (GroundAnalyticInnerProducts) – The inner products of the ground.

connect_to_ocean(ocean_inner_products)[source]

Connect the atmosphere to an ocean.

Parameters

ocean_inner_products (OceanicAnalyticInnerProducts) – The inner products of the ocean.

d(i, j)[source]

Function to compute the forcing of the ocean on the atmosphere: \(d_{i,j} = (F_i, \nabla^2 \phi_j)\).

g(i, j, k)[source]

Function to compute tensors holding the Jacobian inner products: \(g_{i,j,k} = (F_i, J(F_j, F_k))\).

property natm

Number of atmospheric modes.

s(i, j)[source]

Function to compute the forcing (thermal) of the ocean on the atmosphere: \(s_{i,j} = (F_i, \phi_j)\).

u(i, j)[source]

Function to compute the matrix of inner product: \(u_{i, j} = (F_i, F_j)\).

v(i, j, k, l, m)[source]

Function to compute the \(T^4\) temperature forcing of the ocean on the atmosphere: \(v_{i,j,k,l,m} = (F_i, \phi_j \phi_k \phi_l \phi_m)\).

z(i, j, k, l, m)[source]

Function to compute the \(T^4\) temperature forcing for the radiation lost by atmosphere to space & ground/ocean: \(z_{i,j,k,l,m} = (F_i, F_j F_k F_l F_m)\).

class qgs.inner_products.analytic.GroundAnalyticInnerProducts(params=None, stored=True)[source]

Bases: GroundInnerProducts

Class which contains all the ground inner products coefficients needed for the tendencies tensor QgsTensor computation, computed with analytic formula.

Parameters
  • params (None or QgParams or list, optional) – An instance of model’s parameters object or a list in the form [aspect_ratio, gblocks, ngr]. If a list is provided, aspect_ratio is the aspect ratio of the domain, gblocks is a spectral blocks detailing the model’s oceanic modes \(x\)-and \(y\)-wavenumber as an array of shape (ngr, 2), and ngr is the number of modes in the ocean. If None, an empty object is initialized.

  • stored (bool, optional) – Indicate if the inner products must be computed and stored at the initialization. Default to True.

n

The aspect ratio of the domain.

Type

float

atmosphere_inner_products

The inner products of the atmosphere. None if no atmosphere.

Type

None or AtmosphericInnerProducts

connected_to_atmosphere

Indicate if the ocean is connected to an atmosphere.

Type

bool

stored

Indicate if the inner products are stored in the object.

Type

bool

ground_wavenumbers

An array of shape (nmod [1], ) of the wavenumber object of each mode.

Type

ndarray(WaveNumber)

C(i, j, k)[source]

\(C_{i,j,k} = (\phi_i, J(\phi_j,\nabla^2 \phi_k))\)

Warning

Not defined and not used.

K(i, j)[source]

\(K_{i,j} = (\phi_i, \nabla^2 F_j)\)

Warning

Not defined and not used.

M(i, j)[source]

\(M_{i,j} = (\phi_i, \nabla^2 \phi_j)\)

Warning

Not defined and not used.

N(i, j)[source]

\(N_{i,j} = (\phi_i, \partial_x \phi_j)\)

Warning

Not defined and not used.

O(i, j, k)[source]

\(O_{i,j,k} = (\phi_i, J(\phi_j, \phi_k))\)

Warning

Not defined and not used.

U(i, j)[source]

Function to compute the inner products: \(U_{i,j} = (\phi_i, \phi_j)\).

W(i, j)[source]

Function to compute the short-wave radiative forcing of the ground: \(W_{i,j} = (\phi_i, F_j)\).

compute_inner_products()[source]

Function computing and storing all the inner products at once.

connect_to_atmosphere(atmosphere_inner_products)[source]

Connect the ground to an atmosphere.

Parameters

atmosphere_inner_products (AtmosphericAnalyticInnerProducts) – The inner products of the atmosphere.

property ngr

Number of ground modes.

class qgs.inner_products.analytic.OceanicAnalyticInnerProducts(params=None, stored=True)[source]

Bases: OceanicInnerProducts

Class which contains all the oceanic inner products coefficients needed for the tendencies tensor QgsTensor computation, computed with analytic formula.

Parameters
  • params (None or QgParams or list, optional) – An instance of model’s parameters object or a list in the form [aspect_ratio, oblocks, noc]. If a list is provided, aspect_ratio is the aspect ratio of the domain, ablocks is a spectral blocks detailing the model’s oceanic modes \(x\)-and \(y\)-wavenumber as an array of shape (noc, 2), and noc is the number of modes in the ocean. If None, an empty object is initialized.

  • stored (bool, optional) – Indicate if the inner products must be computed and stored at the initialization. Default to True.

n

The aspect ratio of the domain.

Type

float

atmosphere_inner_products

The inner products of the atmosphere. None if no atmosphere.

Type

None or AtmosphericInnerProducts

connected_to_atmosphere

Indicate if the ocean is connected to an atmosphere.

Type

bool

stored

Indicate if the inner products are stored in the object.

Type

bool

oceanic_wavenumbers

An array of shape (nmod [1], ) of the wavenumber object of each mode.

Type

ndarray(WaveNumber)

C(i, j, k)[source]

Function to compute the tensors holding the Jacobian inner products: \(C_{i,j,k} = (\phi_i, J(\phi_j,\nabla^2 \phi_k))\).

K(i, j)[source]

Forcing of the ocean by the atmosphere: \(K_{i,j} = (\phi_i, \nabla^2 F_j)\).

M(i, j)[source]

Forcing of the ocean fields on the ocean: \(M_{i,j} = (\phi_i, \nabla^2 \phi_j)\).

N(i, j)[source]

Function computing the beta term for the ocean: \(N_{i,j} = (\phi_i, \partial_x \phi_j)\).

O(i, j, k)[source]

Function to compute the temperature advection term (passive scalar): \(O_{i,j,k} = (\phi_i, J(\phi_j, \phi_k))\)

U(i, j)[source]

Function to compute the inner products: \(U_{i,j} = (\phi_i, \phi_j)\).

V(i, j, k, l, m)[source]

Function to compute the \(T^4\) temperature forcing from the ocean to the atmosphere: \(V_{i,j,k,l,m} = (\phi_i, \phi_j, \phi_k, \phi_l, \phi_m)\).

W(i, j)[source]

Function to compute the short-wave radiative forcing of the ocean: \(W_{i,j} = (\phi_i, F_j)\).

Z(i, j, k, l, m)[source]

Function to compute the \(T^4\) temperature forcing from the atmosphere to the ocean: \(Z_{i,j,k,l,m} = (\phi_i, F_j, F_k, F_l, F_m)\).

compute_inner_products()[source]

Function computing and storing all the inner products at once.

connect_to_atmosphere(atmosphere_inner_products)[source]

Connect the ocean to an atmosphere.

Parameters

atmosphere_inner_products (AtmosphericAnalyticInnerProducts) – The inner products of the atmosphere.

property noc

Number of oceanic modes.

Symbolic Inner products module

Inner products between the truncated set of basis functions \(\phi_i\) for the ocean and land fields, and \(F_i\) for the atmosphere fields (see Projecting the equations on a set of basis functions).

Notes

These inner products are computed symbolically using Sympy, and thus support arbitrary (but symbolic) basis functions.

Description of the classes

The three classes computing and holding the inner products of the basis functions are:

class qgs.inner_products.symbolic.AtmosphericSymbolicInnerProducts(params=None, stored=True, inner_product_definition=None, interaction_inner_product_definition=None, num_threads=None, quadrature=True, timeout=None, dynTinnerproducts=None, T4innerproducts=None)[source]

Bases: AtmosphericInnerProducts

Class which contains all the atmospheric inner products coefficients needed for the tendencies tensor QgsTensor computation, computed with analytic formula.

Parameters
  • params (QgParams or list) – An instance of model’s parameters object or a list in the form [aspect_ratio, atmospheric_basis, basis, oog, oro_basis]. If a list is provided, aspect_ratio is the aspect ratio of the domain, atmospheric_basis is a SymbolicBasis with the modes of the atmosphere, and ocean_basis is either None or a SymbolicBasis object with the modes of the ocean or the ground. Finally oog indicates if it is an ocean or a ground component that is connected, by setting it to ocean or to ‘ground’, and in this latter case, oro_basis indicates on which basis the orography is developed.

  • stored (bool, optional) – Indicate if the inner product must be stored or computed on the fly. Default to True

  • inner_product_definition (None or InnerProductDefinition, optional) – The definition of the inner product being used. If None, use the canonical StandardInnerProductDefinition object. Default to None.

  • interaction_inner_product_definition (None or InnerProductDefinition, optional) – The definition of the inner product being used for the interaction with the other components, i.e. to compute the inner products with the other component base of funcitons. If None, use the inner_product_definition provided. Default to None.

  • num_threads (int or None, optional) – Number of threads to use to compute the symbolic inner products. If None use all the cpus available. Default to None.

  • quadrature (bool, optional) – If True’, compute the inner products with a quadrature instead of the symbolic integration. If `True Disable the timeout parameter. Default to True.

  • timeout (int or float or bool or None, optional) – The timeout for the computation of each inner product. After the timeout, compute the inner product with a quadrature instead of symbolic integration. If None or False, no timeout occurs. Default to None.

  • dynTinnerproducts (bool, optional) – If the inner products are stored, allow to compute or not the inner products corresponding to the dynamic temperature tendencies. Supersedes the parameters in params if provided. Default to False.

  • T4innerproducts (bool, optional) – If the inner products are stored, allow to compute or not the inner products corresponding to the \(T^4\) tendencies. Compute the inner products corresponding to the dynamic temperature tendencies as well. Supersedes the parameters in params if provided. Default to False.

n

The aspect ratio of the domain.

Type

float

atmospheric_basis

Object holding the symbolic modes of the atmosphere.

Type

SymbolicBasis

oceanic_basis

Object holding the symbolic modes of the ocean (or None if there is no ocean).

Type

None or SymbolicBasis

connected_to_ocean

Indicate if the atmosphere is connected to an ocean.

Type

bool

stored

Indicate if the inner product must be stored or computed on the fly.

Type

bool

ip

Object defining the inner product.

Type

InnerProductDefinition

iip

Object defining the interaction inner product.

Type

InnerProductDefinition

subs

List of 2-tuples containing the substitutions to be made with the functions after the inner products symbolic computation.

Type

list(tuple)

a(i, j)[source]

Function to compute the matrix of the eigenvalues of the Laplacian (atmospheric): \(a_{i, j} = (F_i, {\nabla}^2 F_j)\).

b(i, j, k)[source]

Function to compute the tensors holding the Jacobian inner products: \(b_{i, j, k} = (F_i, J(F_j, \nabla^2 F_k))\).

c(i, j)[source]

Function to compute the matrix of beta terms for the atmosphere: \(c_{i,j} = (F_i, \partial_x F_j)\).

compute_inner_products(num_threads=None, timeout=None)[source]

Function computing and storing all the inner products at once.

Parameters
  • num_threads (int or None, optional) – Number of threads to use to compute the symbolic inner products. If None use all the cpus available. Default to None.

  • timeout (int or float or bool or None, optional) – The timeout for the computation of each inner product. After the timeout, compute the inner product with a quadrature instead of symbolic integration. If True, force the timeout and compute directly the inner product with a quadrature instead of trying to do the integration symbolically. If None or False, no timeout occurs. Default to None.

connect_to_ground(ground_basis, orographic_basis, num_threads=None, timeout=None)[source]

Connect the atmosphere to the ground.

Parameters
  • ground_basis (SymbolicBasis or GroundSymbolicInnerProducts) – Basis of function of the ground or a symbolic ground inner products object containing the basis.

  • orographic_basis (str) – String to select which component basis modes to use to develop the orography in series. Can be either ‘atmospheric’ or ‘ground’.

  • num_threads (int or None, optional) – Number of threads to use to compute the symbolic inner products. If None use all the cpus available. Default to None.

  • timeout (int or float or bool or None, optional) – The timeout for the computation of each inner product. After the timeout, compute the inner product with a quadrature instead of symbolic integration. If True, force the timeout and compute directly the inner product with a quadrature instead of trying to do the integration symbolically. If None or False, no timeout occurs. Default to None.

connect_to_ocean(ocean_basis, num_threads=None, timeout=None)[source]

Connect the atmosphere to an ocean.

Parameters
  • ocean_basis (SymbolicBasis or OceanicSymbolicInnerProducts) – Basis of function of the ocean or a symbolic oceanic inner products object containing the basis.

  • num_threads (int or None, optional) – Number of threads to use to compute the symbolic inner products. If None use all the cpus available. Default to None.

  • timeout (int or float or bool or None, optional) – The timeout for the computation of each inner product. After the timeout, compute the inner product with a quadrature instead of symbolic integration. If True, force the timeout and compute directly the inner product with a quadrature instead of trying to do the integration symbolically. If None or False, no timeout occurs. Default to None.

d(i, j)[source]

Function to compute the forcing of the ocean on the atmosphere: \(d_{i,j} = (F_i, \nabla^2 \phi_j)\).

g(i, j, k)[source]

Function to compute tensors holding the Jacobian inner products: \(g_{i,j,k} = (F_i, J(F_j, F_k))\).

gh(i, j, k)[source]

Function to compute tensors holding the Jacobian inner products: \(g_{i,j,k} = (F_i, J(F_j, \phi_k))\).

property natm

Number of atmospheric modes.

s(i, j)[source]

Function to compute the forcing (thermal) of the ocean on the atmosphere: \(s_{i,j} = (F_i, \phi_j)\).

u(i, j)[source]

Function to compute the matrix of inner product: \(u_{i, j} = (F_i, F_j)\).

v(i, j, k, l, m)[source]

Function to compute the \(T^4\) temperature forcing of the ocean on the atmosphere: \(v_{i,j,k,l,m} = (F_i, \phi_j \phi_k \phi_l \phi_m)\).

z(i, j, k, l, m)[source]

Function to compute the \(T^4\) temperature forcing for the radiation lost by atmosphere to space & ground/ocean: \(z_{i,j,k,l,m} = (F_i, F_j F_k F_l F_m)\).

class qgs.inner_products.symbolic.GroundSymbolicInnerProducts(params=None, stored=True, inner_product_definition=None, interaction_inner_product_definition=None, num_threads=None, quadrature=True, timeout=None, dynTinnerproducts=None, T4innerproducts=None)[source]

Bases: GroundInnerProducts

Class which contains all the ground inner products coefficients needed for the tendencies tensor QgsTensor computation.

Parameters
  • params (QgParams or list) – An instance of model’s parameters object or a list in the form [aspect_ratio, ground_basis, atmospheric_basis]. If a list is provided, aspect_ratio is the aspect ratio of the domain, ground_basis is a SymbolicBasis object with the modes of the ground, and atmospheric_basis is either a SymbolicBasis with the modes of the atmosphere or None if there is no atmosphere.

  • stored (bool, optional) – Indicate if the inner product must be stored or computed on the fly. Default to True

  • inner_product_definition (None or InnerProductDefinition, optional) – The definition of the inner product being used. If None, use the canonical StandardInnerProductDefinition object. Default to None.

  • interaction_inner_product_definition (None or InnerProductDefinition, optional) – The definition of the inner product being used for the interaction with the other components, i.e. to compute the inner products with the other component base of funcitons. If None, use the inner_product_definition provided. Default to None.

  • num_threads (int or None, optional) – Number of threads to use to compute the symbolic inner products. If None use all the cpus available. Default to None.

  • quadrature (bool, optional) – If True’, compute the inner products with a quadrature instead of the symbolic integration. If `True Disable the timeout parameter. Default to True.

  • timeout (int or float or bool or None, optional) – The timeout for the computation of each inner product. After the timeout, compute the inner product with a quadrature instead of symbolic integration. If None or False, no timeout occurs. Default to None.

  • dynTinnerproducts (bool, optional) – If the inner products are stored, allow to compute or not the inner products corresponding to the dynamic temperature tendencies. Supersedes the parameters in params if provided. Default to False.

  • T4innerproducts (bool, optional) – If the inner products are stored, allow to compute or not the inner products corresponding to the \(T^4\) tendencies. Compute the inner products corresponding to the dynamic temperature tendencies as well. Default to False.

n

The aspect ratio of the domain.

Type

float

ground_basis

Object holding the symbolic modes of the ground.

Type

SymbolicBasis

atmospheric_basis

Object holding the symbolic modes of the atmosphere (or None if there is no atmosphere).

Type

None or SymbolicBasis

connected_to_atmosphere

Indicate if the ground is connected to an atmosphere.

Type

bool

stored

Indicate if the inner product must be stored or computed on the fly.

Type

bool

ip

Object defining the inner product.

Type

InnerProductDefinition

iip

Object defining the interaction inner product.

Type

InnerProductDefinition

subs

List of 2-tuples containing the substitutions to be made with the functions after the inner products symbolic computation.

Type

list(tuple)

C(i, j, k)[source]

Function to compute the tensors holding the Jacobian inner products: \(C_{i,j,k} = (\phi_i, J(\phi_j,\nabla^2 \phi_k))\).

Warning

Not defined and not used.

K(i, j)[source]

Function to commpute the forcing: \(K_{i,j} = (\phi_i, \nabla^2 F_j)\).

Warning

Not defined and not used.

M(i, j)[source]

Function to compute the forcing: \(M_{i,j} = (\phi_i, \nabla^2 \phi_j)\).

Warning

Not defined and not used.

N(i, j)[source]

Function computing the beta term: \(N_{i,j} = (\phi_i, \partial_x \phi_j)\).

Warning

Not defined and not used.

O(i, j, k)[source]

Function to compute the temperature advection term (passive scalar): \(O_{i,j,k} = (\phi_i, J(\phi_j, \phi_k))\)

Warning

Not defined and not used.

U(i, j)[source]

Function to compute the inner products: \(U_{i,j} = (\phi_i, \phi_j)\).

V(i, j, k, l, m)[source]

Function to compute the \(T^4\) temperature forcing from the ground to the atmosphere: \(V_{i,j,k,l,m} = (\phi_i, \phi_j, \phi_k, \phi_l, \phi_m)\).

W(i, j)[source]

Function to compute the short-wave radiative forcing of the ground: \(W_{i,j} = (\phi_i, F_j)\).

Z(i, j, k, l, m)[source]

Function to compute the \(T^4\) temperature forcing from the atmosphere to the ground: \(Z_{i,j,k,l,m} = (\phi_i, F_j, F_k, F_l, F_m)\).

compute_inner_products(num_threads=None, timeout=None)[source]

Function computing and storing all the inner products at once.

Parameters
  • num_threads (int or None, optional) – Number of threads to use to compute the symbolic inner products. If None use all the cpus available. Default to None.

  • timeout (int or float or bool or None, optional) – The timeout for the computation of each inner product. After the timeout, compute the inner product with a quadrature instead of symbolic integration. If True, force the timeout and compute directly the inner product with a quadrature instead of trying to do the integration symbolically. If None or False, no timeout occurs. Default to None.

connect_to_atmosphere(atmosphere_basis, num_threads=None, timeout=None)[source]

Connect the ocean to an atmosphere.

Parameters
  • atmosphere_basis (SymbolicBasis or AtmosphericSymbolicInnerProducts) – Basis of function of the atmosphere or a symbolic atmospheric inner products object containing the basis.

  • num_threads (int or None, optional) – Number of threads to use to compute the symbolic inner products. If None use all the cpus available. Default to None.

  • timeout (int or float or bool or None, optional) – The timeout for the computation of each inner product. After the timeout, compute the inner product with a quadrature instead of symbolic integration. If True, force the timeout and compute directly the inner product with a quadrature instead of trying to do the integration symbolically. If None or False, no timeout occurs. Default to None.

property ngr

Number of ground modes.

class qgs.inner_products.symbolic.OceanicSymbolicInnerProducts(params=None, stored=True, inner_product_definition=None, interaction_inner_product_definition=None, num_threads=None, quadrature=True, timeout=None, dynTinnerproducts=None, T4innerproducts=None)[source]

Bases: OceanicInnerProducts

Class which contains all the oceanic inner products coefficients needed for the tendencies tensor QgsTensor computation.

Parameters
  • params (QgParams or list) – An instance of model’s parameters object or a list in the form [aspect_ratio, ocean_basis, atmospheric_basis]. If a list is provided, aspect_ratio is the aspect ratio of the domain, ocean_basis is a SymbolicBasis object with the modes of the ocean, and atmospheric_basis is either a SymbolicBasis with the modes of the atmosphere or None if there is no atmosphere.

  • stored (bool, optional) – Indicate if the inner product must be stored or computed on the fly. Default to True

  • inner_product_definition (None or InnerProductDefinition, optional) – The definition of the inner product being used. If None, use the canonical StandardInnerProductDefinition object. Default to None.

  • interaction_inner_product_definition (None or InnerProductDefinition, optional) – The definition of the inner product being used for the interaction with the other components, i.e. to compute the inner products with the other component base of funcitons. If None, use the inner_product_definition provided. Default to None.

  • num_threads (int or None, optional) – Number of threads to use to compute the symbolic inner products. If None use all the cpus available. Default to None.

  • quadrature (bool, optional) – If True’, compute the inner products with a quadrature instead of the symbolic integration. If `True Disable the timeout parameter. Default to True.

  • timeout (int or float or bool or None, optional) – The timeout for the computation of each inner product. After the timeout, compute the inner product with a quadrature instead of symbolic integration. If None or False, no timeout occurs. Default to None.

  • dynTinnerproducts (bool, optional) – If the inner products are stored, allow to compute or not the inner products corresponding to the dynamic temperature tendencies. Supersedes the parameters in params if provided. Default to False.

  • T4innerproducts (bool, optional) – If the inner products are stored, allow to compute or not the inner products corresponding to the \(T^4\) tendencies. Compute the inner products corresponding to the dynamic temperature tendencies as well. Supersedes the parameters in params if provided. Default to False.

n

The aspect ratio of the domain.

Type

float

oceanic_basis

Object holding the symbolic modes of the ocean.

Type

SymbolicBasis

atmospheric_basis

Object holding the symbolic modes of the atmosphere (or None if there is no atmosphere).

Type

None or SymbolicBasis

connected_to_atmosphere

Indicate if the ocean is connected to an atmosphere.

Type

bool

stored

Indicate if the inner product must be stored or computed on the fly.

Type

bool

ip

Object defining the inner product.

Type

InnerProductDefinition

iip

Object defining the interaction inner product.

Type

InnerProductDefinition

subs

List of 2-tuples containing the substitutions to be made with the functions after the inner products symbolic computation.

Type

list(tuple)

C(i, j, k)[source]

Function to compute the tensors holding the Jacobian inner products: \(C_{i,j,k} = (\phi_i, J(\phi_j,\nabla^2 \phi_k))\).

K(i, j)[source]

Function to commpute the forcing of the ocean by the atmosphere: \(K_{i,j} = (\phi_i, \nabla^2 F_j)\).

M(i, j)[source]

Function to compute the forcing of the ocean fields on the ocean: \(M_{i,j} = (\phi_i, \nabla^2 \phi_j)\).

N(i, j)[source]

Function computing the beta term for the ocean: \(N_{i,j} = (\phi_i, \partial_x \phi_j)\).

O(i, j, k)[source]

Function to compute the temperature advection term (passive scalar): \(O_{i,j,k} = (\phi_i, J(\phi_j, \phi_k))\)

U(i, j)[source]

Function to compute the inner products: \(U_{i,j} = (\phi_i, \phi_j)\).

V(i, j, k, l, m)[source]

Function to compute the \(T^4\) temperature forcing from the ocean to the atmosphere: \(V_{i,j,k,l,m} = (\phi_i, \phi_j, \phi_k, \phi_l, \phi_m)\).

W(i, j)[source]

Function to compute the short-wave radiative forcing of the ocean: \(W_{i,j} = (\phi_i, F_j)\).

Z(i, j, k, l, m)[source]

Function to compute the \(T^4\) temperature forcing from the atmosphere to the ocean: \(Z_{i,j,k,l,m} = (\phi_i, F_j, F_k, F_l, F_m)\).

compute_inner_products(num_threads=None, timeout=None)[source]

Function computing and storing all the inner products at once.

Parameters
  • num_threads (int or None, optional) – Number of threads to use to compute the symbolic inner products. If None use all the cpus available. Default to None.

  • timeout (int or float or bool or None, optional) – The timeout for the computation of each inner product. After the timeout, compute the inner product with a quadrature instead of symbolic integration. If True, force the timeout and compute directly the inner product with a quadrature instead of trying to do the integration symbolically. If None or False, no timeout occurs. Default to None.

connect_to_atmosphere(atmosphere_basis, num_threads=None, timeout=None)[source]

Connect the ocean to an atmosphere.

Parameters
  • atmosphere_basis (SymbolicBasis or AtmosphericSymbolicInnerProducts) – Basis of function of the atmosphere or a symbolic atmospheric inner products object containing the basis.

  • num_threads (int or None, optional) – Number of threads to use to compute the symbolic inner products. If None use all the cpus available. Default to None.

  • timeout (int or float or bool or None, optional) – The timeout for the computation of each inner product. After the timeout, compute the inner product with a quadrature instead of symbolic integration. If True, force the timeout and compute directly the inner product with a quadrature instead of trying to do the integration symbolically. If None or False, no timeout occurs. Default to None.

property noc

Number of oceanic modes.