Tensors module

Module holding the model’s tendencies tensor encoding each of their additive terms.

qgs tensor module

This module computes and holds the tensors representing the tendencies of the model’s equations.

TODO: Add a list of the different tensor available

class qgs.tensors.qgtensor.QgsTensor(params=None, atmospheric_inner_products=None, oceanic_inner_products=None, ground_inner_products=None)[source]

Bases: object

qgs tendencies tensor class.

Parameters
  • params (None or QgParams, optional) – The models parameters to configure the tensor. None to initialize an empty tensor. Default to None.

  • atmospheric_inner_products (None or AtmosphericInnerProducts, optional) – The inner products of the atmospheric basis functions on which the model’s PDE atmospheric equations are projected. If None, disable the atmospheric tendencies. Default to None.

  • oceanic_inner_products (None or OceanicInnerProducts, optional) – The inner products of the oceanic basis functions on which the model’s PDE oceanic equations are projected. If None, disable the oceanic tendencies. Default to None.

  • ground_inner_products (None or GroundInnerProducts, optional) – The inner products of the ground basis functions on which the model’s PDE ground equations are projected. If None, disable the ground tendencies. Default to None.

params

The models parameters used to configure the tensor. None for an empty tensor.

Type

None or QgParams

atmospheric_inner_products

The inner products of the atmospheric basis functions on which the model’s PDE atmospheric equations are projected. If None, disable the atmospheric tendencies. Default to None.

Type

None or AtmosphericInnerProducts

oceanic_inner_products

The inner products of the oceanic basis functions on which the model’s PDE oceanic equations are projected. If None, disable the oceanic tendencies. Default to None.

Type

None or OceanicInnerProducts

ground_inner_products

The inner products of the ground basis functions on which the model’s PDE ground equations are projected. If None, disable the ground tendencies. Default to None.

Type

None or GroundInnerProducts

tensor

The tensor \(\mathcal{T}_{i,j,k}\) \(i\)-th components.

Type

sparse.COO(float)

jacobian_tensor

The jacobian tensor \(\mathcal{T}_{i,j,k} + \mathcal{T}_{i,k,j}\) \(i\)-th components.

Type

sparse.COO(float)

compute_tensor()[source]

Routine to compute the tensor.

static jacobian_from_tensor(tensor)[source]

Function to compute the Jacobian tensor.

Parameters

tensor (COO) – The qgs tensor.

Returns

The Jacobian tensor.

Return type

COO

load_from_file(filename, **kwargs)[source]

Function to load previously a saved tensor object with the method save_to_file().

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

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

print_jacobian_tensor(tensor_name='')[source]

Routine to print the Jacobian tensor.

Parameters

tensor_name (str, optional) – Specify the name to print beside the values of the tensor. Default to QgsTensorJacobian.

print_jacobian_tensor_to_file(filename, tensor_name='')[source]

Routine to print the Jacobian tensor to a file.

Parameters
  • filename (str) – The filename where to print the tensor.

  • tensor_name (str, optional) – Specify the name to print beside the values of the tensor. Default to QgsTensorJacobian.

print_tensor(tensor_name='')[source]

Routine to print the tensor.

Parameters

tensor_name (str, optional) – Specify the name to print beside the values of the tensor. Default to QgsTensor.

print_tensor_to_file(filename, tensor_name='')[source]

Routine to print the tensor to a file.

Parameters
  • filename (str) – The filename where to print the tensor.

  • tensor_name (str, optional) – Specify the name to print beside the values of the tensor. Default to QgsTensor.

save_to_file(filename, **kwargs)[source]

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

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

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

static simplify_tensor(tensor)[source]

Routine that simplifies the component of a tensor \(\mathcal{T}\). For each index \(i\), it upper-triangularizes the tensor \(\mathcal{T}_{i,\ldots}\) for all the subsequent indices.

Parameters

tensor (COO) – The tensor to simplify.

Returns

The upper-triangularized tensor.

Return type

COO

class qgs.tensors.qgtensor.QgsTensorDynamicT(params=None, atmospheric_inner_products=None, oceanic_inner_products=None, ground_inner_products=None)[source]

Bases: QgsTensor

qgs dynamical temperature first order (linear) tendencies tensor class.

Parameters
  • params (None or QgParams, optional) – The models parameters to configure the tensor. None to initialize an empty tensor. Default to None.

  • atmospheric_inner_products (None or AtmosphericInnerProducts, optional) – The inner products of the atmospheric basis functions on which the model’s PDE atmospheric equations are projected. If None, disable the atmospheric tendencies. Default to None.

  • oceanic_inner_products (None or OceanicInnerProducts, optional) – The inner products of the oceanic basis functions on which the model’s PDE oceanic equations are projected. If None, disable the oceanic tendencies. Default to None.

  • ground_inner_products (None or GroundInnerProducts, optional) – The inner products of the ground basis functions on which the model’s PDE ground equations are projected. If None, disable the ground tendencies. Default to None.

params

The models parameters used to configure the tensor. None for an empty tensor.

Type

None or QgParams

atmospheric_inner_products

The inner products of the atmospheric basis functions on which the model’s PDE atmospheric equations are projected. If None, disable the atmospheric tendencies. Default to None.

Type

None or AtmosphericInnerProducts

oceanic_inner_products

The inner products of the oceanic basis functions on which the model’s PDE oceanic equations are projected. If None, disable the oceanic tendencies. Default to None.

Type

None or OceanicInnerProducts

ground_inner_products

The inner products of the ground basis functions on which the model’s PDE ground equations are projected. If None, disable the ground tendencies. Default to None.

Type

None or GroundInnerProducts

tensor

The tensor \(\mathcal{T}_{i,j,k}\) \(i\)-th components.

Type

sparse.COO(float)

jacobian_tensor

The jacobian tensor \(\mathcal{T}_{i,j,k} + \mathcal{T}_{i,k,j}\) \(i\)-th components.

Type

sparse.COO(float)

compute_tensor()[source]

Routine to compute the tensor.

class qgs.tensors.qgtensor.QgsTensorT4(params=None, atmospheric_inner_products=None, oceanic_inner_products=None, ground_inner_products=None)[source]

Bases: QgsTensorDynamicT

qgs \(T^4\) tendencies tensor class. Implies dynamical zeroth-order temperature.

Parameters
  • params (None or QgParams, optional) – The models parameters to configure the tensor. None to initialize an empty tensor. Default to None.

  • atmospheric_inner_products (None or AtmosphericInnerProducts, optional) – The inner products of the atmospheric basis functions on which the model’s PDE atmospheric equations are projected. If None, disable the atmospheric tendencies. Default to None.

  • oceanic_inner_products (None or OceanicInnerProducts, optional) – The inner products of the oceanic basis functions on which the model’s PDE oceanic equations are projected. If None, disable the oceanic tendencies. Default to None.

  • ground_inner_products (None or GroundInnerProducts, optional) – The inner products of the ground basis functions on which the model’s PDE ground equations are projected. If None, disable the ground tendencies. Default to None.

params

The models parameters used to configure the tensor. None for an empty tensor.

Type

None or QgParams

atmospheric_inner_products

The inner products of the atmospheric basis functions on which the model’s PDE atmospheric equations are projected. If None, disable the atmospheric tendencies. Default to None.

Type

None or AtmosphericInnerProducts

oceanic_inner_products

The inner products of the oceanic basis functions on which the model’s PDE oceanic equations are projected. If None, disable the oceanic tendencies. Default to None.

Type

None or OceanicInnerProducts

ground_inner_products

The inner products of the ground basis functions on which the model’s PDE ground equations are projected. If None, disable the ground tendencies. Default to None.

Type

None or GroundInnerProducts

tensor

The tensor \(\mathcal{T}_{i,j,k}\) \(i\)-th components.

Type

sparse.COO(float)

jacobian_tensor

The jacobian tensor \(\mathcal{T}_{i,j,k} + \mathcal{T}_{i,k,j}\) \(i\)-th components.

Type

sparse.COO(float)

qgs atmospheric thermodynamic tensor module

This module computes and holds the tensors representing the atmospheric thermodynamic tendencies of the model’s equations needed to compute the vertical wind velocity \(\omega\).

TODO: Add a list of the different tensor available

class qgs.tensors.atmo_thermo_tensor.AtmoThermoTensor(params=None, atmospheric_inner_products=None, oceanic_inner_products=None, ground_inner_products=None)[source]

Bases: QgsTensor

Atmospheric thermodynamic tendencies tensor class.

Parameters
  • params (None or QgParams, optional) – The models parameters to configure the tensor. None to initialize an empty tensor. Default to None.

  • atmospheric_inner_products (None or AtmosphericInnerProducts, optional) – The inner products of the atmospheric basis functions on which the model’s PDE atmospheric equations are projected. If None, disable the atmospheric tendencies. Default to None.

  • oceanic_inner_products (None or OceanicInnerProducts, optional) – The inner products of the oceanic basis functions on which the model’s PDE oceanic equations are projected. If None, disable the oceanic tendencies. Default to None.

  • ground_inner_products (None or GroundInnerProducts, optional) – The inner products of the ground basis functions on which the model’s PDE ground equations are projected. If None, disable the ground tendencies. Default to None.

params

The models parameters used to configure the tensor. None for an empty tensor.

Type

None or QgParams

atmospheric_inner_products

The inner products of the atmospheric basis functions on which the model’s PDE atmospheric equations are projected. If None, disable the atmospheric tendencies. Default to None.

Type

None or AtmosphericInnerProducts

oceanic_inner_products

The inner products of the oceanic basis functions on which the model’s PDE oceanic equations are projected. If None, disable the oceanic tendencies. Default to None.

Type

None or OceanicInnerProducts

ground_inner_products

The inner products of the ground basis functions on which the model’s PDE ground equations are projected. If None, disable the ground tendencies. Default to None.

Type

None or GroundInnerProducts

tensor

The tensor \(\mathcal{T}_{i,j,k}\) \(i\)-th components.

Type

sparse.COO(float)

jacobian_tensor

The jacobian tensor \(\mathcal{T}_{i,j,k} + \mathcal{T}_{i,k,j}\) \(i\)-th components.

Type

sparse.COO(float)

class qgs.tensors.atmo_thermo_tensor.AtmoThermoTensorDynamicT(params=None, atmospheric_inner_products=None, oceanic_inner_products=None, ground_inner_products=None)[source]

Bases: AtmoThermoTensor

Atmospheric thermodynamic dynamical temperature first order (linear) tendencies tensor class.

Parameters
  • params (None or QgParams, optional) – The models parameters to configure the tensor. None to initialize an empty tensor. Default to None.

  • atmospheric_inner_products (None or AtmosphericInnerProducts, optional) – The inner products of the atmospheric basis functions on which the model’s PDE atmospheric equations are projected. If None, disable the atmospheric tendencies. Default to None.

  • oceanic_inner_products (None or OceanicInnerProducts, optional) – The inner products of the oceanic basis functions on which the model’s PDE oceanic equations are projected. If None, disable the oceanic tendencies. Default to None.

  • ground_inner_products (None or GroundInnerProducts, optional) – The inner products of the ground basis functions on which the model’s PDE ground equations are projected. If None, disable the ground tendencies. Default to None.

params

The models parameters used to configure the tensor. None for an empty tensor.

Type

None or QgParams

atmospheric_inner_products

The inner products of the atmospheric basis functions on which the model’s PDE atmospheric equations are projected. If None, disable the atmospheric tendencies. Default to None.

Type

None or AtmosphericInnerProducts

oceanic_inner_products

The inner products of the oceanic basis functions on which the model’s PDE oceanic equations are projected. If None, disable the oceanic tendencies. Default to None.

Type

None or OceanicInnerProducts

ground_inner_products

The inner products of the ground basis functions on which the model’s PDE ground equations are projected. If None, disable the ground tendencies. Default to None.

Type

None or GroundInnerProducts

tensor

The tensor \(\mathcal{T}_{i,j,k}\) \(i\)-th components.

Type

sparse.COO(float)

jacobian_tensor

The jacobian tensor \(\mathcal{T}_{i,j,k} + \mathcal{T}_{i,k,j}\) \(i\)-th components.

Type

sparse.COO(float)

compute_tensor()[source]

Routine to compute the tensor.

class qgs.tensors.atmo_thermo_tensor.AtmoThermoTensorT4(params=None, atmospheric_inner_products=None, oceanic_inner_products=None, ground_inner_products=None)[source]

Bases: AtmoThermoTensorDynamicT

Atmospheric thermodynamic \(T^4\) tendencies tensor class. Implies dynamical zeroth-order temperature.

Parameters
  • params (None or QgParams, optional) – The models parameters to configure the tensor. None to initialize an empty tensor. Default to None.

  • atmospheric_inner_products (None or AtmosphericInnerProducts, optional) – The inner products of the atmospheric basis functions on which the model’s PDE atmospheric equations are projected. If None, disable the atmospheric tendencies. Default to None.

  • oceanic_inner_products (None or OceanicInnerProducts, optional) – The inner products of the oceanic basis functions on which the model’s PDE oceanic equations are projected. If None, disable the oceanic tendencies. Default to None.

  • ground_inner_products (None or GroundInnerProducts, optional) – The inner products of the ground basis functions on which the model’s PDE ground equations are projected. If None, disable the ground tendencies. Default to None.

params

The models parameters used to configure the tensor. None for an empty tensor.

Type

None or QgParams

atmospheric_inner_products

The inner products of the atmospheric basis functions on which the model’s PDE atmospheric equations are projected. If None, disable the atmospheric tendencies. Default to None.

Type

None or AtmosphericInnerProducts

oceanic_inner_products

The inner products of the oceanic basis functions on which the model’s PDE oceanic equations are projected. If None, disable the oceanic tendencies. Default to None.

Type

None or OceanicInnerProducts

ground_inner_products

The inner products of the ground basis functions on which the model’s PDE ground equations are projected. If None, disable the ground tendencies. Default to None.

Type

None or GroundInnerProducts

tensor

The tensor \(\mathcal{T}_{i,j,k}\) \(i\)-th components.

Type

sparse.COO(float)

jacobian_tensor

The jacobian tensor \(\mathcal{T}_{i,j,k} + \mathcal{T}_{i,k,j}\) \(i\)-th components.

Type

sparse.COO(float)