Field3D.compute_tau_r
Last updated
Last updated
Computes the anisotropic part of the residual stress tensor, denoted as , for a given field in computational fluid dynamics simulations. The function can operate in two modes: 'Smag' and 'DNS'.
ValueError
: If the field is not a filtered field (i.e., self.filter_size == 1
).
AttributeError
: If required attributes (Cs
, S_LES
, DNS_folder_path
) are not defined.
mode
(str, optional): Mode of operation, either 'Smag' for the Smagorinsky model or 'DNS' for Direct Numerical Simulation data. Default is 'Smag'.
None
Initial Setup and Validation:
The function starts by updating the field and checking if the field is filtered.
If (self.filter_size == 1), it raises a (ValueError) because residual quantities computation only makes sense for filtered fields.
Mode: 'Smag' (Smagorinsky Model):
Turbulent Viscosity:
Checks if the Smagorinsky constant ((Cs)) is defined. If not, it initializes (Cs) to 0.1.
Computes the turbulent viscosity ((\mu_t)) using: where is the filter size, is the grid size, and is the strain rate at LES scale.
Anisotropic Residual Stress Tensor:
Initializes as a zero matrix.
For each component ((i, j)) of the tensor:
Computes .
Adjusts for compressibility by subtracting the isotropic part .
Computes the squared components and accumulates them.
Saves the computed to a file.
Mode: 'DNS' (Direct Numerical Simulation):
DNS Data Setup:
Checks if the path to DNS data is defined.
Initializes a (DNS_field) object to read DNS data.
Determines the type of filter used (box or Gaussian).
Residual Kinetic Energy:
Computes residual kinetic energy ( K_r^{DNS} ) as:
Saves ( K_r^{DNS} ) to a file.
Anisotropic Residual Stress Tensor:
Initializes (\tau_r) as a zero matrix.
For each component of the tensor:
Computes the filtered product
Calculates as:
Computes the squared components and accumulates them.
Saves the computed to a file.