case
Physical parameters and forcings.
This module contains the Case class which is the one used to describe the parameters and
the forcings of a model. It also contains the CaseTracable which is a variation of the
first classe which works better with JAX specificities. This classes can be obtained by the prefix
tunax.case. or directly by tunax..
- ForcingType
Type that represent the different possible types of the forcings in
Case.alias of
Tuple[float,float] |Callable[[float],float] |Callable[[float,float],float]
- ForcingArrayType
Type that represent the different possible types of the forcings in
CaseTracable.alias of
Tuple[float,float] |Float[Array, 'nz']|Float[Array, 'nz nt']
- class Case[source]
Physical parameters and forcings.
This class contains all the physical constants, and the constant forcings that definine an experience for the model. The forcings can be described as functions. The transformations from
CasetoCaseTracableis done when a model instance is created. The constructor takes all the attributes as parameters.- cp
Specific heat capacity of saltwater \([\text{J} \cdot \text{kg}^{-1} \cdot \text{K}^{-1}]\).
- Type:
float, default=3985.
- eos_tracers
Tracers used for the equation of state (the computation of the density). One of {
't','s','ts’,'b'}. - ‘t’: temperature - ‘s’: salinity - ‘ts’: temperature and salinity - ‘b’: buoyancy- Type:
str, default=’t’
- t_rho_ref
Reference temperature for the equation of state (the computation of the density) \([° \text C]\).
- Type:
float, default=0.
- s_rho_ref
Reference salinity for the equation of state (the computation of the density) \([\text{psu}]\).
- Type:
float, default=35.
- fcor
Coriolis frequency at the water column \([\text{rad} \cdot \text{s}^{-1}]\).
- Type:
float, default=0.
- ustr_btm
Zonal current stress at the bottom \([\text{m}^{2} \cdot \text{s}^{-2}]\).
- Type:
float, default=0.
- vstr_btm
Meridional current stress at the bottom \([\text{m}^{2} \cdot \text{s}^{-2}]\).
- Type:
float, default=0.
- t_forcing
Description of the forcing of temperature (potentially no forcing if the variable is not activated i.e. if
't'is not ineos_tracers). There are 3 cases :Border forcing : tuple of 2 floats, the first one is the forcing at the bottom and the second ont is the forcing at the top of the water column, the unit is in \([\text{K} \cdot \text{m} \cdot \text{s}^{-1}]\).
Deep constant forcing : function of signature float->float, the parameter is the depth and the ouput is the value of the forcing at this depth in \([\text{K} \cdot \text{s}^{-1}]\). The values of the functions represent the flux of the forcing (the derivative along the depth).)
Deep variable forcing : function of signature (float, float)->float, the parameters are the depth and the time and the ouput is the value of the forcing at this depth and this time in \([\text{K} \cdot \text{s}^{-1}]\). The values of the functions represent the flux of the forcing (the derivative along the depth).
- Type:
tuple of 2 floats or a function, optionnal, default=None
- s_forcing
Description of the forcing of salinity (potentially no forcing if the variable is not activated i.e. if
's'is not ineos_tracers). There are the 3 same cases as for thet_forcing, and the units are \([\text{psu} \cdot \text{m} \cdot \text{s}^{-1}]\) for the border forcing and \([\text{psu} \cdot \text{s}^{-1}]\) for the other ones.- Type:
tuple of 2 floats or a function, optionnal, default=None
- b_forcing
Description of the forcing of buoyancy (potentially no forcing if the variable is not activated i.e. if
'b'is not ineos_tracers). There are the 3 same cases as for thet_forcing, and the units are \([\text{m} \cdot \text{s}^{-1}]\) for the border forcing and \([\text{s}^{-1}]\) for the other ones.- Type:
tuple of 2 floats or a function, optionnal, default=None
- pt_forcing
Description of the forcing of passive tracer (potentially no forcing if the variable is not activated i.e. if
do_ptis not set). There are the 3 same cases as for thet_forcing, and the units are \([\text{m} \cdot \text{s}^{-1}]\) for the border forcing and \([\text{s}^{-1}]\) for the other ones.- Type:
tuple of 2 floats or a function, optionnal, default=None
- class CaseTracable[source]
Physical parameters and forcings tracable by JAX.
This class is similar to the
Caseone, but the function forcings are transformed in arrays so that the class is tracable by JAX which means that we can usejit()andgrad()more freely. The constructor takes all the attributes as parameters.- eos_tracers
cf.
Case.eos_tracers- Type:
str, default=’t’
- alpha
cf.
Case.alpha- Type:
float, default=2e-4
- t_rho_ref
cf.
Case.t_rho_ref- Type:
float, default=0.
- s_rho_ref
cf.
Case.s_rho_ref- Type:
float, default=35.
- do_pt
cf.
Case.do_pt- Type:
bool, default=False
- vkarmn
cf.
Case.vkarmn- Type:
float, default=0.384
- ustr_sfc
cf.
Case.ustr_sfc- Type:
float, default=0.
- ustr_btm
cf.
Case.ustr_btm- Type:
float, default=0.
- vstr_sfc
cf.
Case.vstr_sfc- Type:
float, default=0.
- vstr_btm
cf.
Case.vstr_btm- Type:
float, default=0.
- t_forcing
Description of the temperature forcing cf.
Case.t_forcing, the type depends on the forcing type :Border forcing : tuple of 2 floats, the first one is the forcing at the bottom and the second one is the forcing at the top of the water column, the unit is in \([\text{K} \cdot \text{m} \cdot \text{s}^{-1}]\).
Deep constant forcing : array of shape (nz) : the value of the forcing function on the geometrical
Gridof the model. The values represent the forcing flux, which is for each cell the difference between the forcing at the top of the cell and the forcing at bottom.Deep variable forcing : array of shape (nz, nt) : the value of the forcing function on the geometrical
Gridand the different iteration times of the model. As for deep constant forcing, the values represent the flux of the forcing at every time.
- Type:
tuple of 2 floats or
Array(nz) or (nz, nt), optionnal, default=None
- s_forcing
Same as
t_forcingfor Salinity.- Type:
tuple of 2 floats or
Array(nz) or (nz, nt), optionnal, default=None
- b_forcing
Same as
t_forcingfor buoyancy.- Type:
tuple of 2 floats or
Array(nz) or (nz, nt), optionnal, default=None
- pt_forcing
Same as
t_forcingfor passive tracer.- Type:
tuple of 2 floats or
Array(nz) or (nz, nt), optionnal, default=None
- t_forcing_type
Description of the type of temperature forcing :
'borders'for border forcing,'constant'for deep constant forcing and'variable'for deep variable forcing- Type:
str, optionnal, default=None
- s_forcing_type
Same as
t_forcing_typefor salinity.- Type:
str, optionnal, default=None
- b_forcing_type
Same as
t_forcing_typefor buoyancy.- Type:
str, optionnal, default=None
- pt_forcing_type
Same as
t_forcing_typefor passive tracer.- Type:
str, optionnal, default=None
- tra_promote_borders_constant(tra, grid)[source]
Promote the dimension of a forcing from borders to constant.
It can be use to apply
vmap()onSingleColumnModelfor batch computing. The inputCaseTracableinstance should have a borders forcing type and the ouput instance will have deep constant forcing type.- Parameters:
- Returns:
case_tracable – The
selfobject with the promoted forcing.- Return type:
- tra_promote_borders_variable(tra, grid, nt)[source]
Promote the dimension of a forcing from borders to variable.
It can be use to apply
vmap()onSingleColumnModelfor batch computing. The inputCaseTracableinstance should have a borders forcing type and the ouput instance will have deep variable forcing type.- Parameters:
- Returns:
case_tracable – The
selfobject with the promoted forcing.- Return type:
- tra_promote_constant_variable(tra, nt)[source]
Promote the dimension of a forcing from borders to constant.
It can be use to apply
vmap()onSingleColumnModelfor batch computing. The inputCaseTracableinstance should have a constant forcing type and the ouput instance will have deep variable forcing type.- Parameters:
- Returns:
case_tracable – The
selfobject with the promoted forcing.- Return type: