Overview
The framework to account for the turbulence modeling uncertainties implemented in TRACE is based on the perturbation of the eigenspace of the Reynolds stress tensor. This methodology and the underlying fundamentals are described in Reynolds stress eigenspace perturbation framework.
As the limiting states of the Reynolds stress tensor with respect to its eigenvalues (see mapping of eigenvalues onto barycentric coordinates in Reynolds stress eigenspace perturbation framework) represent extraordinary states, the eigenvalue perturbation intends to shift the eigenvalues to these limiting states. This is done via the relative perturbation magnitude \( \Delta_B \in [0,1] \) (0 = do not modify the eigenvalues, 1 = modify the eigenvalues to the limiting states; see details in Reynolds stress eigenspace perturbation framework). The perturbation of the eigenvectors can be controlled via the rotation of the eigenvector matrix around the second eigenvector of the Reynolds stress tensor using a rotation angle \( 0 \leq \alpha \leq \frac \pi 4 \) (see details in Reynolds stress eigenspace perturbation framework). In general, the eigenspace perturbation framework tries to perturb the eigenvalues and eigenvectors in additional RANS simulations and sample from the possible solution space for quantities of interest. The resulting uncertainty is commonly assumed to be the union over the sampled solutions.
Unfortunately, the amount of perturbations is limited by the stability and convergence of the solver. Consequently, the idea of the framework without further information on the uncertainty of the eigenspace of the Reynolds stress tensor is to perturb eigenvalues and eigenvectors as much as possible (uniformly in the entire computational domain) to account for worst case scenarios while retaining steady-state converged results. However, as the uncertainties of the RANS turbulence model are not expected to be uniformly distributed across the computational domain, the perturbations of the eigenvalues can also be controlled on a cell-by-cell basis in the current implementation in TRACE.
Control and workflow
It is advisable (although not mandatory) to restart based on a converged RANS simulation in order to perturb the eigenspace of the Reynolds stress tensor. Due to the motivation of the framework, it requires six simulations in addition to the baseline RANS simulation (unperturbed turbulence model) to assess the uncertainty of the turbulence model. The set of additional simulations can be reduced to five if \( \Delta_B = 1 \) for the 3C perturbation (Reynolds stress tensor is a sphere, making a rotation of its eigenvectors obsolete). Three of the additional simulations come from targeting the eigenvalues at the limiting states of turbulence (1C, 2C, 3C). Moreover, each of them can be supplemented by perturbing the orientation of the eigenvectors of the Reynolds stress tensor ellipsoid, resulting in three additional simulations.
The UQ framework has to be activated using the control file command ActivateUncertaintyQuantificationTM. The user has the following configuration options via this command:
- method: Choose between uniform (data-free/not data-driven =
PerturbReynoldsStressUniformly) and local (data-driven = PerturbReynoldsStressMagnitudeLocally) approach.
- targetState: Choose between the target state for the eigenvalue perturbation (1C, 2C, 3C).
- deltaB: Amount of relative perturbation distance for the eigenvalue perturbation. The value has to be between 0 and 1 (0 = do not modify the eigenvalues, 1 = modify the eigenvalues to the specified target state).
- updateProductionK: If this flag is given, the turbulence production term of the baseline RANS model is replaced by the correct formulation using the perturbed Reynolds stresses.
- rotationAngle: Specify the amount of eigenvector rotation around the second eigenvector of the Reynolds stress tensor in rad. Values lower 0 and larger \( \frac \pi 4 \) are allowed but show warnings according to the described methodology in [37].
- rotationAngleFraction: Specify the amount of eigenvector rotation around the second eigenvector of the Reynolds stress tensor as a fraction of \( \frac \pi 4 \). The value has to be between 0 and 1 (0 = do not modify the eigenvectors, 1 = rotate the eigenvectors by \( \frac \pi 4 \)).
- rampDeltaB: Specify a ramp (initial value followed by the number of time steps for achieving the target value given by deltaB) for the continuous increase of the applied relative perturbation magnitude.
Setup eigenspace perturbation framework via control file
An exemplary control file command, which
- activates the uniform perturbation of the Reynolds stress tensor,
- aims for perturbing the eigenvalues to the 1C limiting state with a relative perturbation magnitude of 0.5,
- while the amount of perturbation is increased from 0 to 0.5 in 1000 time steps,
- replaces the original turbulence production term of the turbulence model with the explicit formulation,
- rotates the eigenvector matrix of the Reynolds stress tensor by \( 0.2 \frac \pi 4 \) around the second eigenvector,
looks like this:
all immediate ActivateUncertaintyQuantificationTM --method PerturbReynoldsStressUniformly --targetState C1 --deltaB 0.5 --updateProductionK --rotationAngleFraction 0.2 --rampDeltaB 0 1000
Setup eigenspace perturbation framework via pyTrace interface
Moreover, an example python code to control the eigenspace perturbation framework is given below: pytraceUQ_woControlFile.py
"""Example on how to control the eigenspace perturbation setup."""
from __future__ import annotations
import argparse
import pathlib
from tracesuite import AsciiOutputType, OutputType
from tracesuite.trace import TRACE, SimulationState
DEFAULT_OUTPUT_DIRECTORY = "output"
TURBULENCE_LIMIT_STATES_LIST = ["C1", "C2", "C3"]
DELTA_B_LIST = [0.2, 0.5, 1.0]
if __name__ == "__main__":
parser = argparse.ArgumentParser(prog=pathlib.Path(__file__).name, description="Setup UQ RANS calculation.")
parser.add_argument("-cgns", dest="input_CGNS", help="Choose input path+cgns-file.")
options = parser.parse_args()
command_line = "-cgns " + str(options.input_CGNS)
n_computations = 0
n_computations_successful = 0
output_folder = pathlib.Path(options.input_CGNS) / ".." / ".." / DEFAULT_OUTPUT_DIRECTORY
output_folder = output_folder.resolve()
for turbulence_limit_state in TURBULENCE_LIMIT_STATES_LIST:
for delta_B in DELTA_B_LIST:
trace = TRACE(command_line, stop_before_simulation_setup=True)
trace.message(f"Perturbation of the Reynolds stress tensor towards turbulent state {turbulence_limit_state} with delta_B {delta_B}.")
trace.set_reynolds_stress_uq(uq_method="PerturbReynoldsStressUniformly", limit_state_turbulence=turbulence_limit_state,
target_delta_b=delta_B, tke_production_update=True)
specific_output_path = output_folder / turbulence_limit_state / str(delta_B)
specific_file_3d = specific_output_path / "cgns" / "TRACE.cgns"
specific_file_residual = specific_output_path / "residual" / "residual.dat"
trace.set_cgns_output_data_file(OutputType.STANDARD_3D, specific_file_3d, interleave=1000)
trace.set_ascii_output(AsciiOutputType.RESIDUAL, specific_file_residual, is_active=True)
state = trace.run(999999)
if state not in (SimulationState.SIMULATION_CONVERGED,
SimulationState.SIMULATION_REACHED_MAXIMAL_NUMBER_OF_TIME_STEPS, SimulationState.SIMULATION_RUNNING):
trace.message(f"Simulation for {turbulence_limit_state} and delta_B = {delta_B} state failed: {state}")
else:
n_computations_successful += 1
n_computations += 1
trace.write_output_files()
trace.kill()
trace.message(f"\n {n_computations_successful} of {n_computations} computations of UQ terminated successfully.\n")
The linked python script manages the setup of multiple simulations by looping through predefined configurations. It demonstrates how to consecutively target the three different states of turbulence, while progressively increasing the perturbation magnitude \( \Delta_B \) in order to distinguish between converging and unstable simulations. This example can be extended arbitrarily, for instance to include and explore the effect of eigenvector rotation (perturbation) as part of the uncertainty quantification process. See the pyTrace documentation for more information on the respective method set_reynolds_stress_uq to control the eigenspace perturbation, which features essentially identical options as the control file command.
The command line to finally start the UQ computations reads as follows:
mpirun -np [#procs] pytraceUQ_woControlFile.py -cgns TRACE.cgns
Apply local perturbation via pyTrace interface
If the perturbation of the Reynolds stress tensor should be performed locally on a cell-by-cell basis, the respective control file command may like this
all immediate ActivateUncertaintyQuantificationTM --method PerturbReynoldsStressMagnitudeLocally --targetState C1 --updateProductionK --rotationAngleFraction 0.2
This requires an additional python code to setup/control the local perturbation magnitude via the pyTrace interface. An example python script is given below: pytraceUQ.py
"""Example on how to prescribe perturbation magnitude for eigenvalue perturbation."""
from __future__ import annotations
import argparse
import pathlib
from mojo.tecplot.tecplotFile import TecplotDataset
from tracesuite.trace import TRACE
if __name__ == "__main__":
parser = argparse.ArgumentParser(prog = pathlib.Path(__file__).name, description="Setup UQ RANS calculation.")
parser.add_argument("-cgns", dest="input_cgns", help="Choose input cgns-file.")
parser.add_argument("-cntl ", dest="input_cntl", help="Choose input cntl-file.")
options = parser.parse_args()
if options.input_cntl:
command_line = "-cgns " + str(options.input_cgns) + " -cntl " + str(options.input_cntl)
else:
command_line = "-cgns " + str(options.input_cgns)
trace = TRACE(command_line, stop_before_simulation_setup=False)
data = TecplotDataset("perturbationDistribution.dat")
data.readFile()
dataDict = {zone.title: {"p": zone.getVariable("p").getDataAsNumpyArray()} for zone in data.zones}
ghostlayers = 2
for block in trace.block_groups["Main"].local_blocks:
dim_I = block.dim[0]
dim_J = block.dim[1]
dim_K = block.dim[2]
dim_inner_I = dim_I - ghostlayers * 2
dim_inner_J = dim_J - ghostlayers * 2
dim_inner_K = dim_K - ghostlayers * 2
perturbation_magnitude = dataDict[block.name]["p"]
block.perturbationMagnitudeUQ[ghostlayers:-ghostlayers, ghostlayers:-ghostlayers, ghostlayers:-ghostlayers] \
= perturbation_magnitude.reshape((dim_inner_I, dim_inner_J, dim_inner_K))
state = trace.run(10)
Here the selection of a dedicated relative perturbation magnitude and its ramp is obsolete and omitted consequently. The required absolute perturbation magnitude has to be given using the python interface of TRACE. In this example, the respective quantity is loaded from an external file. In an actual scenario the local perturbation magnitude may result from a previously trained machine learning model. The access is granted via the variable perturbationMagnitudeUQ available on every block.
The command line to start the TRACE computation may read as follows:
mpirun -np [#procs] pytraceUQ.py -cgns TRACE.cgns -cntl TRACE_control.input
Examples provided in the TRACE suite
See the following test cases for exemplary application of the Reynolds stress tensor perturbation framework:
- Level 3:
ZPGflatPlate_UQ_Models
- Level 3:
pytrace_uncertaintyQuantificationControl
- Level 5:
EigenspacePerturbation_UQ_TUDa
Related research
For more details on related research during the implementation and application of the UQ framework in TRACE see the following publications:
- [37] : Motivation and derivation of the eigenvector rotation approach. Demonstration of the UQ-framework's capabilities for the converging-diverging channel.
- [39] : Turbulence model uncertainty quantification for the TUDa compressor.