Sub-grid scales¶
sgs¶
Filtering¶
- weight_gauss_3d = <xarray.DataArray 'truediv-049dc5ac3a49cba1205f46208d5623e9' (w1: 3, w2: 3)> Size: 72B dask.array<truediv, shape=(3, 3), dtype=float64, chunksize=(3, 3), chunktype=numpy.ndarray> Dimensions without coordinates: w1, w2¶
3x3 2d Gaussian filter – binomial approximation
- weight_gauss_5d = <xarray.DataArray 'array-3ff26ea89580fcbc973ad0755922e2c1' (w1: 5, w2: 5)> Size: 200B dask.array<truediv, shape=(5, 5), dtype=float64, chunksize=(5, 5), chunktype=numpy.ndarray> Dimensions without coordinates: w1, w2¶
5x5 2d Gaussian filter – binomial approximation
- box_kernel(shape)[source]¶
returns a normalized box kernel with given shape
- Parameters:
shape (
list[int])- Return type:
DataArray- Returns:
the kernel array with dimesions
w1,w2
- class Filter(kernel, filter_dims)[source]¶
Basic filter class with kernel along dimensions the dimensions of kernel and filter_dims are matched one-to-one as given
- Variables:
kernel – filter kernel
filter_dims – dimensions along which to perform filtering; will be paired with dimensions of the kernel.
- kernel: DataArray¶
- filter_dims: Sequence[Hashable]¶
- property window: dict[Hashable, int]¶
- class IdentityFilter(kernel, filter_dims)[source]¶
identity filter
- Variables:
kernel – filter kernel will be ignored
- class CoarseGrain(window, bc='exact')[source]¶
Coarse-graining filter class with kernel along dimensions the dimensions of kernel and filter_dims are matched one-to-one as given
- Variables:
window – {dimension_name: number of grid points to average over}
bdry_cnd – boundary conditions: support the same as xr.coarsen, notably ‘trim’ and ‘exact’
SGS Model Core¶
- class SGSModel(*args, **kwargs)[source]¶
Base subgrid-scale (SGS) model class
sgs_tensor(): returns the SGS tensor for a given filter
- class LinCombSGSModel(model_components)[source]¶
Linear combination of subgrid-scale (SGS) models
- Parameters:
models – List of SGS model components
- class LeonardTensor(*args, **kwargs)[source]¶
compute the Leonard tensor for a large-scale equation
compute(): returns the Leonard tensor for a given filter
- class LeonardVelocityTensor(vel, tensor_dims)[source]¶
Leonard tensor for the velocity
- Variables:
vel – grid-scale/base velocity field
tensor_dims – tensor dimensions
- class LeonardThetaTensor(vel, theta, tensor_dims)[source]¶
Leonard tensor for the (potential) temperature \(\theta\)
- Variables:
vel – grid-scale/base velocity field
theta – grid-scale/base temperature field
- M_Germano_tensor(sgs_model, filter)[source]¶
compute the Mij Germano model tensor as \((<\tau(\matrhm{at grid})> - \alpha^2 \tau(\mathrm{at filter}))\), where \(\Delta * \alpha\) is the area/volume spanned by the filter kernel and \(\Delta\) is the filter scale.
- class DynamicModelProtcol(*args, **kwargs)[source]¶
compute the Leonard tensor for a large-scale equation
:meth compute_coeff : returns the SGS tensor for a given filter :meth sgs_tensor: returns the SGS tensor for a given test and regularisation filter
- class DynamicModel(static_model, leonard, minimisation)[source]¶
Dynamic model for SGS model
- Variables:
static_model – Static SGS model
leonard – Leonard tensor for the large-scale equation
minimisation – Minimisation method to compute coefficients
- Meth compute_coeff:
computes the amplitude coefficients for the SGS model
- Meth sgs_tensor:
computes the SGS tensor for a given test and regularisation filters
- class LinCombDynamicModel(static_model, leonard, minimisation)[source]¶
Dynamic model for linear combination SGS model
- Variables:
static_model – Static linear combination SGS model
leonard – Leonard tensor for the large-scale equation
minimisation – Minimisation method to compute coefficients
- Meth compute_coeff:
computes the coefficients for the SGS model
- Meth sgs_tensor:
computes the SGS tensor for a given test and regularisation filter
- class Minimisation(*args, **kwargs)[source]¶
Protocol for solving the over-determined tensor equation \(L = \sum_i c_i M_i\), where \(L\) and \(M_i\) are tensors and \(c_i\) are scalar coefficients to be computed.
- Variables:
contraction_dims – Names of the dimensions to contract when forming the tensor products \(L M_i\) and \(M_i M_j\).
coeff_dim – Dimension label along which the resulting coefficients \(c_i\) are concatenated.
- class LillyMinimisation1Model(contraction_dims, coeff_dim)[source]¶
- Lilly Minimisation (least square error) for a 1-global-coefficient model using
the Lilly identity as \(\overline{L \cdot M} / \overline{M \cdot M}\). where \(\cdot\) means tensor contraction, \(\overline{*}\) means regularisation filtering
- Parameters:
contraction_dims (
Sequence[str]) – labels of dimensions to be contracted to form \(L M_i\) and \(M_i M_j\) products.coeff_dim (
str) – label of dimension along which to concatenate the arrays \(c_i\)
- compute(L, Mi, reg_filter)[source]¶
Compute \(\overline{L\cdot M} / \overline{M \cdot M}\). where \(\overline{*}\) means regularisation filtering
- Parameters:
L (
DataArray) – LHS tensorM – a sequence of 1 RHS tensors
reg_filter (
Filter) – Filter used to regularize the contracted tensor products.
- Return type:
DataArray
- class LillyMinimisation2Model(contraction_dims, coeff_dim)[source]¶
Lilly Minimisation (least square error) for a 2-coefficient model using the Lilly identity as \(L = \sum_i^2 c_i M_i\).
- Parameters:
contraction_dims (
Sequence[str]) – labels of dimensions to be contracted to form \(L M_i\) and \(M_i M_j\) products.coeff_dim (
str) – label of dimension along which to concatenate the arrays \(c_i\)
- compute(L, Mi, reg_filter)[source]¶
Compute dynamic coefficients of a 2-component models using Germano identity as \(L = C_1 M_1 + C_2 M_2\) using regularized least-square minimisation. Inverting the \(\overline{M_i M_j}\) matrix analytically.
- Parameters:
L (
DataArray) – LHS tensorM – a sequence of 2 RHS tensors
reg_filter (
Filter) – Filter used to regularize the contracted tensor products.
- Return type:
DataArray
- class LillyMinimisation3Model(contraction_dims, coeff_dim)[source]¶
- Lilly Minimisation (least square error) for a 3-coefficient model using
the Lilly identity as \(L = \sum_i^3 c_i M_i\).
- Parameters:
contraction_dims (
Sequence[str]) – labels of dimensions to be contracted to form \(L M_i\) and \(M_i M_j\) products.coeff_dim (
str) – label of dimension along which to concatenate the arrays \(c_i\)
- compute(L, Mi, reg_filter)[source]¶
Compute dynamic coefficients of a 3-component models using Germano identity as \(L = C_1 M_1 + C_2 M_2 + C_3 M_3\) using regularized least-square minimisation (inverting the \(M_i M_j\) matrix explicitly).
- Parameters:
L (
DataArray) – LHS tensorM – a sequence of 3 RHS tensors
reg_filter (
Filter) – Filter used to regularize the contracted tensor products.
- Return type:
DataArray
- class LillyMinimisationNModel(contraction_dims, coeff_dim)[source]¶
- Lilly Minimisation (least square error) for an N-coefficient model using
the Lilly identity as \(L = \sum_i^N c_i M_i\).
- Parameters:
contraction_dims (
Sequence[str]) – labels of dimensions to be contracted to form \(L M_i\) and \(M_i M_j\) products.coeff_dim (
str) – label of dimension along which to concatenate the arrays \(c_i\)
- compute(L, Mi, reg_filter)[source]¶
Solve the system \(\overline{L \cdot M_i} = \sum_i^N c_j \overline{M_i \cdot M_j}\) using np.linalg.SVD, where \(L \cdot M_i\) and \(M_i \cdot M_j\) are scalar fields
- Parameters:
L (
DataArray) – LHS tensorM – a sequence of RHS tensors
reg_filter (
Filter) – Filter used to regularize the contracted tensor products.
- Return type:
DataArray
SGG models¶
- class SmagorinskyVelocityModel(vel, strain, cs, dx, tensor_dims)[source]¶
Smagorinsky model for the velocity equation
- Variables:
vel – grid-scale velocity
strain – grid-scale rate-of-strain
cs – Smagorinsky coefficient
dx – constant resolution with respect to dimension to-be-filtered
- class SmagorinskyHeatModel(vel, grad_theta, strain, ctheta, dx, tensor_dims)[source]¶
Smagorinsky model for the Heat equation
- Variables:
vel – grid-scale velocity
grad_theta – grid-scale (potential) temperature gradient
strain – grid-scale rate-of-strain
ctheta – Smagorinsky coefficient for the heat equation
dx – constant resolution with respect to dimension to-be-filtered
- class SSquaredVelocityModel(strain, cs, dx, tensor_dims)[source]¶
Kosovic JFM 1997, 336 and Speziale 1991 Ann Rev Fluid Mech 23 compoment \(\tau = (c_s \Delta)^2 \mathrm{Traceless}(\overline{S_{ik}} \overline{S_{kj}})\)
- Variables:
strain – grid-scale rate-of-strain
cs – Smagorinsky coefficient
dx – constant resolution with respect to dimension to-be-filtered
tensor_dims – labels of dimensions indexing tensor components
- class SOmegaVelocityModel(strain, rot, cs, dx, tensor_dims)[source]¶
Kosovic JFM 1997, 336 / Speziale 1991 Ann Rev Fluid Mech 23 component \(\tau = (c_s \Delta) ^2 \mathrm{Sym}[\overline{S_{ik}}\overline{\Omega_{kj}}]\)
- Variables:
strain – grid-scale rate-of-strain
rot – grid-scale rate-of-rotation
cs – Smagorinsky coefficient
dx – constant resolution with respect to dimension to-be-filtered
tensor_dims – labels of dimensions indexing tensor components
- sgs_tensor(filter)[source]¶
- compute model for SGS tensor
\(\tau = (c_s \Delta) ^2 \mathrm{Sym}[\overline{S_{ik}}\overline{\Omega_{kj}}]\) for a given filter (which can be trivial, i.e.
IdentityFilter)
- Parameters:
filter (
Filter) – Filter used to separate “large” and “small” scales- Return type:
DataArray
- DynamicKosovicModel(sij, omegaij, vel, res, compoment_coeff, tensor_dims=('c1', 'c2'), minimisation=LillyMinimisation2Model(contraction_dims=['c1', 'c2'], coeff_dim='cdim'))[source]¶
Dynamic version of the model by Carati & Cabot Proceedings of the 1996 Summer Program – Center for Turbulence Research
- Parameters:
sij (
DataArray) – grid-scale rate-of-strain tensoromegaij (
DataArray) – grid-scale rate-of-rotation tensorvel (
DataArray) – velocity field used for dynamic coefficient computationres (
float) – constant resolution with respect to dimension to-be-filteredcompoment_coeff (
Sequence[float]) – tuple of three Smagorinsky coefficients for parallel, perpendicular, and normal componentstensor_dims (
tuple[str,str]) – labels of dimensions indexing tensor components, defaults to (“c1”, “c2”)
- Return type:
- Returns:
Combined SGS model with dynamically computed coefficients
- s_parallel(s, n, tensor_dims)[source]¶
Projection of s in the n-direction: \(s^{\parallel}=(n_i (s.n)_j + (s.n)_i n_j - \frac{2}{3} \delta_{ij} (n.s.n) )\)
- Return type:
DataArray
- s_perpendicular(s, n, tensor_dims)[source]¶
Projection of s perpendicular to the n-direction: \(s - s^{\parallel}\)
- Return type:
DataArray
- class SparallelVelocityModel(strain, cs, dx, tensor_dims, n)[source]¶
Carati & Cabot Proceedings of the 1996 Summer Program – Center for Turbulence Research S_parallel component = \(|S| Traceless[Symmetric[(S.n)n]]\)
- Variables:
strain – grid-scale rate-of-strain
cs – Smagorinsky coefficient
dx – constant resolution with respect to dimension to-be-filtered
n – triple of floats to be coerce as a 3d constant vector along one of the tensor dimensions
tensor_dims – labels of dimensions indexing tensor components
- class SperpVelocityModel(strain, cs, dx, n, tensor_dims)[source]¶
Carati & Cabot Proceedings of the 1996 Summer Program – Center for Turbulence Research \(S_{\textrm{perp component}} = |S| Traceless(S - (S.n + n.S))\)
- Variables:
strain – grid-scale rate-of-strain
cs – Smagorinsky coefficient
dx – constant resolution with respect to dimension to-be-filtered
n – triple of floats to be coerce as a 3d constant vector along one of the tensor dimensions
tensor_dims – labels of dimensions indexing tensor components
- class NVelocityModel(strain, cs, dx, n, tensor_dims)[source]¶
Carati & Cabot Proceedings of the 1996 Summer Program – Center for Turbulence Research \(N component = |S|(n.s.n) Traceless(n * n)\)
- Variables:
strain – grid-scale rate-of-strain
cs – Smagorinsky coefficient
dx – constant resolution with respect to dimension to-be-filtered
n – triple of floats to be coerce as a 3d constant vector along one of the tensor dimensions
tensor_dims – labels of dimensions indexing tensor components
- DynamicCaratiCabotModel(sij, vel, res, compoment_coeff, n, tensor_dims=('c1', 'c2'), minimisation=LillyMinimisation3Model(contraction_dims=['c1', 'c2'], coeff_dim='cdim'))[source]¶
- Dynamic version of the model by
Carati & Cabot Proceedings of the 1996 Summer Program – Center for Turbulence Research
- Parameters:
sij (
DataArray) – grid-scale rate-of-strain tensorvel (
DataArray) – velocity field used for dynamic coefficient computationres (
float) – constant resolution with respect to dimension to-be-filteredcompoment_coeff (
Sequence[float]) – tuple of three Smagorinsky coefficients for parallel, perpendicular, and normal componentsn (
Sequence[float]) – triple of floats to be coerced as a 3d constant vector along one of the tensor dimensionstensor_dims (
tuple[str,str]) – labels of dimensions indexing tensor components, defaults to (“c1”, “c2”)
- Return type:
- Returns:
Combined SGS model with dynamically computed coefficients