5. Tensor computation module¶
The equation tensor for the coupled ocean-atmosphere model with temperature which allows for an extensible set of modes in the ocean and in the atmosphere.
Note
These are calculated using the analytical expressions from De Cruz, L., Demaeyer, J. and Vannitsem, S.: A modular arbitrary-order ocean-atmosphere model: MAOOAM v1.0, Geosci. Model Dev. Discuss. And the Fortran Code
Note
The python code is available here : aotensor.py .
Example: |
---|
>>> aotensor, Li, Lj, Lk, Lv =aotensor.init_aotensor()
5.1. Help Functions¶
There are ndim coordinates that correspond to 4 physical quantities. These functions help to have the i-th coordinates of a quantity.
- psi(i) -> i
- theta(i) -> i + natm
- A(i) -> i + 2*natm
- T(i) -> i + 2*natm + noc
- kdelta(i,j) -> (i==j)
5.2. Global variables¶
- real_eps = 2.2204460492503131e-16
- t=np.zeros( ((ndim+1),(ndim+1),(ndim+1)),dtype=float)
5.3. Dependencies¶
>>> from params_maooam import *
>>> from inprod_analytic import *
>>> from scipy.sparse import dok_matrix
>>> from scipy.sparse import csr_matrix
>>> import os
5.4. Functions¶
- compute_aotensor
- coeff(i, j, k, v)
- simplify
- init_aotensor
-
aotensor.
coeff
(i, j, k, v)[source] - Affects v for \(t_{i,j,k}\) making that tensor[i] upper triangular.
- Used in compute_aotensor.
Parameters: - i (int in [1,37]) – first coordinates
- j (int in [1,37]) – second coodinates
- k (int in [1,37]) – third coordinates
- v (float) – value
Returns: change the global tensor
Return type: void
Example: >>> coeff(i, j, k, v)
-
aotensor.
compute_aotensor
()[source] Computes the three-dimensional tensor t
Takes the inner products of inprod_analytic and computes the tensor
Parameters: t (array((37,37,37),float)) – tensor t is a global variable of aotensor Returns: change the global tensor Return type: void Example: >>> compute_aotensor()
Warning
Needs the global variable aotensor and the global inner products to be initialized.
-
aotensor.
init_aotensor
()[source] Initialize the tensor.
Returns: aotensor, Li, Lj, Lk, Lv Example: >>> aotensor, Li, Lj, Lk, Lv = init_aotensor()
-
aotensor.
simplify
()[source] Make sure that tensor[i] is upper triangular. To do after compute_aotensor().
Parameters: t (array((ndim+1,ndim+1,ndim+1),float)) – tensor t is a global variable of aotensor Returns: change the global tensor Return type: void Example: >>> simplify()