aPriori Documentation
  • 👋Welcome to aPriori
  • Getting started
    • What is aPriori?
    • Installation
    • Quickstart
  • Fundamentals and usage
    • aPriori Fundamentals
      • Data Formatting
      • Cut a 3D scalar
      • Filter a 3D scalar field
      • Initialize a DNS field
      • Data visualization
      • Cut a DNS field
      • Filter a DNS field
    • Machine Learning Tutorials
      • Data-Driven Closure for Turbulence-Chemistry interaction
      • Dynamic Data-Driven Smagorinky Closure for LES
  • API guide
    • Field3D
      • Field3D.build_attributes_list
      • Field3D.check_valid_attribute
      • Field3D.compute_chemical_timescale
      • Field3D.compute_kinetic_energy
      • Field3D.compute_mixing_timescale
      • Field3D.compute_residual_kinetic_energy
      • Field3D.compute_residual_dissipation_rate
      • Field3D.compute_reaction_rates
      • Field3D.compute_reaction_rates_batch
      • Field3D.compute_strain_rate
      • Field3D.compute_tau_r
      • Field3D.compute_velocity_module
      • Field3D.cut
      • Field3D.filter_favre
      • Field3D.filter
      • Field3D.find_path
      • Field3D.plot_x_midplane
      • Field3D.plot_y_midplane
      • Field3D.plot_z_midplane
      • Field3D.print_attributes
      • Field3D.update
    • Scalar3D
      • Scalar3D.is_light_mode
      • Scalar3D.reshape_3d
      • Scalar3D.reshape_column
      • Scalar3D.reshape_line
      • Scalar3D.cut
      • Scalar3D.filter_gauss
      • Scalar3D.plot_x_midplane
      • Scalar3D.plot_y_midplane
      • Scalar3D.plot_z_midplane
    • Mesh3D
  • BIBLIOGRAPHY
Powered by GitBook
On this page
  • Field3D.compute_tau_r(self, mode='Smag', save_tensor_components=True):
  • Description
  • Parameters
  • Raises
  • Returns
  • Workflow
  1. API guide
  2. Field3D

Field3D.compute_tau_r

PreviousField3D.compute_strain_rateNextField3D.compute_velocity_module

Last updated 1 year ago

Field3D.compute_tau_r(self, mode='Smag', save_tensor_components=True):


Description

Computes the anisotropic part of the residual stress tensor, denoted as τr\tau_rτr​, for a given field in computational fluid dynamics simulations. The function can operate in two modes: 'Smag' and 'DNS'.

Parameters

  • 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.

Raises

  • mode (str, optional): Mode of operation, either 'Smag' for the Smagorinsky model or 'DNS' for Direct Numerical Simulation data. Default is 'Smag'.

Returns

None

Workflow

  1. 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.

  2. 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: μt=(Cs⋅Δ⋅l)2â‹…SLES\mu_t = (Cs \cdot \Delta \cdot l)^2 \cdot S_{LES}μt​=(Cs⋅Δ⋅l)2â‹…SLES​ where Δ\DeltaΔ is the filter size, lll is the grid size, and SLESS_{LES}SLES​ is the strain rate at LES scale.

    • Anisotropic Residual Stress Tensor:

      • Initializes Ï„r\tau_rÏ„r​ as a zero matrix.

      • For each component ((i, j)) of the tensor:

        • Computes Ï„ijr=−2μtSijLES\tau^r_{ij} = -2\mu_t S_{ij}^{LES} Ï„ijr​=−2μt​SijLES​.

        • Adjusts for compressibility by subtracting the isotropic part (Siso)when(i=j)(S_{iso}) when (i = j)(Siso​)when(i=j).

        • Computes the squared components and accumulates them.

        • Saves the computed Ï„ijr\tau^r_{ij}Ï„ijr​ to a file.

  3. 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: KrDNS=0.5(Ux2+Uy2+Uz2)DNS−0.5(Ux2+Uy2+Uz2)K_r^{DNS} = 0.5 \left( U_x^2 + U_y^2 + U_z^2 \right)_{DNS} - 0.5 \left( U_x^2 + U_y^2 + U_z^2 \right)KrDNS​=0.5(Ux2​+Uy2​+Uz2​)DNS​−0.5(Ux2​+Uy2​+Uz2​)

      • Saves ( K_r^{DNS} ) to a file.

    • Anisotropic Residual Stress Tensor:

      • Initializes (\tau_r) as a zero matrix.

      • For each component (i,j)(i, j)(i,j) of the tensor:

        • Computes the filtered product (UiUj)~DNS)\widetilde{(U_i U_j)}_{DNS})(Ui​Uj​)​DNS​)

        • Calculates Ï„ijr\tau^r_{ij}Ï„ijr​ as: Ï„ijr=(UiUj)~DNS−U~iU~j−δij23KrDNS\tau^r_{ij} = \widetilde{(U_i U_j)}_{DNS} - \widetilde{U}_i \widetilde{U}_j - \delta_{ij} \frac{2}{3} K_r^{DNS}Ï„ijr​=(Ui​Uj​)​DNS​−Ui​Uj​−δij​32​KrDNS​

        • Computes the squared components and accumulates them.

        • Saves the computed Ï„ijr\tau^r_{ij}Ï„ijr​ to a file.