SU2 DataMiner Configuration#

SU2 DataMiner uses a configuration class in order to store important information regarding the data generation, data mining, and manifold generation processes. This page lists some of the important functions of the Config class which acts as the base class for configurations specific to the application such as NICFD and FGM FGM, for which additional settings can be specified.

Base Config Class#

SU2 DataMiner uses a configuration class in order to store important information regarding the data generation, data mining, and manifold generation processes. This page lists some of the important functions of the Config class which acts as the base class for configurations specific to the application such as NICFD and FGM FGM, for which additional settings can be specified.

Storage Location and Configuration Information#

During the various processes in SU2 DataMiner, data are generated, processed, and analyzed. All information regarding these processes is stored on the current hardware in a user-defined location. SU2 DataMiner configurations can be saved locally under different names in order to keep track of various data sets and manifolds at once. The following functions can be used to manipulate and access the storage location for fluid data and manifolds of the SU2 DataMiner configuration and save and load configurations.

SetConfigName(self, config_name: str)#

Set the name for the current SU2 DataMiner configuration. When saving the configuration, it will be saved under this name.

Parameters:

config_name (str) – SU2 DataMiner configuration name.

GetConfigName(self)#

Get the name of the current SU2 DataMiner configuration.

Returns:

SU2 DataMiner configuration name.

Return type:

str

SaveConfig(self)#

Save the current SU2 DataMiner configuration.

from su2dataminer.config import Config

c = Config()
c.SetConfigName("test")
c.SaveConfig()
SetOutputDir(self, output_dir: str)#

Define the output directory where all raw and processed fluid data and manifold data are saved.

Parameters:

output_dir (str) – output directory.

Raises:

Exception – if provided directory does not exist on the current hardware.

GetOutputDir(self)#

Get the output directory where raw and processed fluid data and manifold data are stored.

Raises:

Exception – if the output directory of the current SU2 DataMiner configuration is not present on the current hardware.

Returns:

output directory.

Return type:

str

PrintBanner(self)#

Print the main banner for the SU2 DataMiner configuration in the terminal.

SetConcatenationFileHeader(self, header: str = 'fluid_data')#

Define the file name header of the processed fluid manifold data.

Parameters:

header (str, optional) – manifold data file header, defaults to “fluid_data”

GetConcatenationFileHeader(self)#

Get the file name header of the processed fluid manifold data.

Returns:

fluid manifold data file header.

Return type:

str

Settings for Machine Learning Applications#

The data-driven fluid modeling applications of SU2 DataMiner involve the use of multi-layer perceptrons to calculate the thermodynamic state of the fluid during flow calculations in SU2. The values of the weights and biases, the hidden layer architecture(s) and other parameters needed to train the network can be stored in and retrieved from the SU2 DataMiner configuration.

SetControllingVariables(self, names_cv: list[str])#

Define the set of controlling variable names used as inputs for the networks of the data-driven fluid model.

Parameters:

names_cv (list[str]) – list with controlling variable names.

GetControllingVariables(self)#

Retrieve the set of controlling variable names used as inputs for the networks of the data-driven fluid model.

Returns:

list of controlling variable names.

Return type:

list[str]

SetTrainFraction(self, input: float = 0.8)#

Define the fraction of fluid data used for MLP training.

Parameters:

input (float, optional) – fluid data train fraction, defaults to 0.8

Raises:

Exception – if provided value lies outside 0-1.

GetTrainFraction(self)#

Get the fraction of fluid data used for MLP training.

Returns:

fluid data train fraction.

Return type:

float

SetTestFraction(self, input: float = 0.1)#

Define the fraction of fluid data used for MLP prediction accuracy evaluation.

Parameters:

input (float, optional) – fluid data test set fraction, defaults to 0.1

Raises:

Exception – if provided value lies outside 0-1.

GetTestFraction(self)#

Get the fraction of fluid data used for MLP accuracy evaluation.

Returns:

fluid data test fraction.

Return type:

float

The following functions are used to specify the parameters used for training the networks on the fluid data. Currently, SU2 DataMiner uses supervised, gradient-based methods for training where the learning rate follows the exponential decay method. The value of the initial learning rate and decay parameter can be accessed through

SetAlphaExpo(self, alpha_expo_in: float = -1.8269)#

Define the initial learning rate exponent (base 10).

Parameters:

alpha_expo_in (float, optional) – log10 of initial learning rate, defaults to -1.8269

Raises:

Exception – if provided value is positive.

GetAlphaExpo(self)#

Get the initial learning rate exponent (base 10).

Returns:

log10 of initial learning rate.

Return type:

float

SetLRDecay(self, lr_decay_in: float = 0.98959)#

Set the exponential learning rate decay parameter for MLP training.

Parameters:

lr_decay_in (float, optional) – Exponential learning rate decay parameter, defaults to DefaultProperties.learning_rate_decay

Raises:

Exception – if the learning rate decay parameter is not within zero and one.

GetLRDecay(self)#

Get the exponential learning rate decay parameter for MLP training.

Returns:

Exponential learning rate decay parameter.

Return type:

float

The networks are trained using batches of training data. The size of the training batches and the maximum number of epochs for which the networks are trained can be accessed through

SetBatchExpo(self, batch_expo_in: int = 6)#

Set the mini-batch size exponent (base 2) for MLP training.

Parameters:

batch_expo_in (int, optional) – Mini-batch size exponent (base 2) used for MLP training, defaults to DefaultProperties.batch_size_exponent

Raises:

Exception – if provided value is lower than or equal to zero.

GetBatchExpo(self)#

Get the MLP training mini-batch size exponent.

Returns:

mini-batch size exponent (base 2)

Return type:

int

SetNEpochs(self, n_epochs_in: int = 1000)#

Specify the maximum number of epochs for training of the networks.

Parameters:

n_epochs_in (int, optional) – maximum number of epochs, defaults to 1000

Raises:

Exception – if the number is lower than 1.

GetNEpochs(self)#

Retrieve the maximum number of epochs the networks are trained for.

Returns:

maximum number of training epochs.

Return type:

int

Additionally, the number of nodes in the hidden layers of the networks and activation function can be accessed. SU2 DataMiner currently supports the use of a single activation function to all hidden layers which can be selected from a list of options and the input and output layers use a linear function.

SetHiddenLayerArchitecture(self, hidden_layer_architecture: list[int] = [20, 20, 20])#

Define the hidden layer architecture of the multi-layer perceptron used for the MLP-based manifold.

Parameters:

hidden_layer_architecture (list[int], optional) – listed neuron count per hidden layer, defaults to [20,20,20]

Raises:

Exception – if an empty list is provided or if input contains non-integer data or the number of nodes is less than 1.

GetHiddenLayerArchitecture(self)#

Get the hidden layer architecture of the multi-layer perceptron used for the MLP-based manifold.

Returns:

list with number of neurons per hidden layer.

Return type:

list[str]

SetActivationFunction(self, activation_function_in: str = 'gelu')#

Define the hidden layer activation function for the MLP-based manifold. See Common.Properties.ActivationFunctionOptions for the supported options.

Parameters:

activation_function_in (str, optional) – hidden layer activation function name, defaults to “gelu”

Raises:

Exception – if the provided name does not appear in the list of available activation function options.

GetActivationFunction(self)#

Get the hidden layer activation function name.

Returns:

hidden layer activation function name.

Return type:

str

Finally, the weights and biases data can be accessed in the configuration using

SetWeights(self, weights: list[ndarray[float]])#

Store the weight values of the neural network.

Parameters:

weights (list[np.ndarray[float]]) – weight arrays for the network hidden layers.

Raises:

Exception: if an empty list is provided or the weights arrays are improperly formatted.

SetBiases(self, biases: list[ndarray[float]])#

Store the bias values of the neural network.

Parameters:

weights (list[np.ndarray[float]]) – bias arrays for the network hidden layers.

Raises:

Exception: if an empty list is provided or contains empty arrays.

GetWeightsBiases(self)#

Return values for weights and biases for the hidden layers in the MLP.

Returns:

weight arrays, biases arrays

Return type:

tuple(np.ndarray[float])

All the settings regarding the training parameters, architecture, weights, and biases of the trained network can be stored automatically after training a network from the Trainer class

UpdateMLPHyperParams(self, trainer)#

Retrieve the weights and biases from the MLP trainer class and store them in the configuration class.

Parameters:

trainer (TrainMLP) – reference to trainer class used to train the network.

To use the network stored in the configuration in SU2 simulations, the network information needs to be written to an ASCII file such that it can be loaded in SU2 through the MLPCpp module. All relevant information about the network is automatically written to a properly formatted ASCII file using

WriteSU2MLP(self, file_name_out: str)#

Write ASCII MLP file containing the network weights and biases from the data stored in the configuration.

Parameters:

file_name_out (str) – MLP file name

Configuration for real-gas applications#

The following section describes the most important functions of the Config_NICFD class.

__init__(self, load_file: str = None)#

SU2 DataMiner configuration class for real-gas applications.

Parameters:

load_file (str, optional) – configuration file name to load, defaults to None

Raises:

Exception – if loaded configuration is incompatible with the Config_NICFD class.

SetFluid(self, fluid_name='Air')#

Define the fluid name used for entropic data generation. By default, “Air” is used. Specify a list of fluids for mixtures.

Parameters:

fluid_name (str or list[str]) – CoolProp fluid name or list of names.

Raise:

Exception: If the fluid could not be defined in CoolProp.

SetEquationOfState(self, EOS_type_in: str = 'HEOS')#

Define the equation of state backend used by CoolProp to generate fluid data.

Parameters:

EOS_type_in (str, optional) – backend used by CoolProp, defaults to “HEOS”

Raises:

Exception – if the specified backend is not supported.

Example#

The code snippet below demonstrates the

from su2dataminer.config import Config_NICFD

config = Config_NICFD()
config.SetFluid("MM")
config.SetEquationOfState("HEOS")
config.SetName("siloxane_MM_heos")
config.UseAutoRange(True)
config.PrintBanner()

Configuration for combustion applications#

The following section describes the most important functions of the SU2 DataMiner configuration class for FGM applications.

SU2 DataMiner supports the generation of premixed flamelets using Cantera for FGM applications.

Reaction Mechanism and Species Transport Model#

The reaction mechanism used for flamelet calculations is specified through the following function:

SetReactionMechanism(self, mechanism_input: str = 'gri30.yaml')#

Define reaction mechanism used for flamelet data generation. The default setting is the gri30 mechanism for methane/hydrogen.

Parameters:

mechanism_input (str) – Reaction mechanism name.

Raise:

Exception: If the reaction mechanism could not be loaded from path.

GetReactionMechanism(self)#

Get the reaction mechanism used for flamelet generation.

Returns:

reaction mechanism name.

Return type:

str

SetTransportModel(self, transport_model: str = 'multicomponent')#

Define the transport model for the 1D flamelet computations: “unity-Lewis” or “multicomponent”.

Parameters:

transport_model (str, optional) – transport model name, defaults to DefaultSettings_FGM.transport_model

GetTransportModel(self)#

Get the transport model for 1D flamelet computations.

Returns:

flamelet transport model name.

Return type:

str

Reactants and Flamelet Types#

The fuel and oxidizer used for flamelet calculations can be defined through the following functions:

SetFuelDefinition(self, fuel_species: list[str], fuel_weights: list[float])#

Define fuel species and weights. By default the fuel is set to pure methane.

Parameters:
  • fuel_species (list[str]) – List containing fuel species names.

  • fuel_weights (list[float]) – List containing fuel molar fractions

Raise:

Exception: If no reactants are provided.

Raise:

Exception: If the number of species and weights are unequal.

SetOxidizerDefinition(self, oxidizer_species: list[str] = ['O2', 'N2'], oxidizer_weights: list[float] = [1.0, 3.76])#

Define oxidizer species and weights. Default arguments are for air.

Parameters:
  • oxidizer_species (list[str]) – List containing oxidizer species names.

  • oxidizer_weights (list[float]) – List containing oxidizer molar fractions.

Raise:

Exception: If no reactants are provided.

Raise:

Exception: If the number of species and weights are unequal.

The types of flamelet data that are currently supported by SU2 DataMiner are adiabatic flamelets, burner-stabilized flamelets, and chemical equilibrium data. Each of these flamelet types can be included or excluded from the manifold through the following functions:

RunFreeFlames(self, input: bool = True)#

Include adiabatic free flame data in the manifold.

Parameters:

input (bool) – enable generation of adabatic free flame data.

RunBurnerFlames(self, input: bool = True)#

Include burner-stabilized flame data in the manifold.

Parameters:

input (bool) – enable generation of burner-stabilized flame data.

RunEquilibrium(self, input: bool = True)#

Include chemical equilibrium (reactants and products) data in the manifold.

Parameters:

input (bool) – enable generation of chemical equilibrium data.

FGM Controlling Variables#

SetControllingVariables(self, controlling_variables: list[str] = ['ProgressVariable', 'EnthalpyTot', 'MixtureFraction'])#

Define the set of controlling variables for the current manifold.

Parameters:

controlling_variables (list[str], optional) – list with controlling variable names, defaults to DefaultSettings_FGM.controlling_variables

Raises:

Exception – if “ProgressVariable” is not included in the list of controlling variables.

GetControllingVariables(self)#

Retrieve the set of controlling variable names used as inputs for the networks of the data-driven fluid model.

Returns:

list of controlling variable names.

Return type:

list[str]

SetProgressVariableDefinition(self, pv_species: list[str] = ['CH4', 'H2', 'O2', 'H2O', 'CO2'], pv_weights: list[float] = [-0.062332, -0.49603, -0.031252, 0.055509, 0.022723])#

Set the progress variable species and mass-fraction weights.

Parameters:
  • pv_species (list[str]) – list of species names defining the progress variable.

  • pv_weights (list[float]) – list of progress variable weights for respective species mass fractions.

Raise:

Exception: if the provided species and weights have unequal length.

ResetProgressVariableDefinition(self)#

Reset progress variable definition to default (weighted reactants and major products).

GetUnburntScalars(self, equivalence_ratio: float, temperature: float)#

Compute the reactant progress variable, total enthalpy, and mixture fraction for a given equivalence ratio and temperature.

Parameters:
  • equivalence_ratio (float) – reactants equivalence ratio.

  • temperature (float) – reactants temperature in Kelvin.

Raise:

Warning: If temperature or equivalence ratio exceed flamelet data range.

Returns:

pv_unb: reactants progress variable value.

Return type:

pv_unb: float

Returns:

enth_unb: reactants total enthalpy value.

Return type:

enth_unb: float

Returns:

mixfrac_unb: reactants mixture fraction value.

Return type:

mixfrac_unb: float

Preferential Diffusion#

EnablePreferentialDiffusion(self, use_PD: bool = False)#

Include preferential diffusion scalars in flamelet data manifold.

Parameters:

use_PD (bool, optional) – include diffusion scalars, defaults to DefaultSettings_FGM.preferential_diffusion

SetAverageLewisNumbers(self, mixture_status: float = None, reactant_temperature: float = None)#

Define the constant specie Lewis numbers for a given mixture status and reactant temperature.

Parameters:
  • mixture_status (float, optional) – equivalence ratio or mixture fraction, defaults to the average of the manifold bounds.

  • reactant_temperature (float, optional) – reactant temperature, defaults to the average of the manifold bounds.

Raises:

Exception – if negative mixture status value or temperature is provided.

ComputeBetaTerms(self, variables: list[str], flamelet_data: ndarray)#

Compute the differential diffusion scalars for a flamelet.

Parameters:
  • variables (list[str]) – list of variable names in the flamelet data.

  • flamelet_data (np.ndarray) – flamelet data array.

Raise:

Exception: if number of variables does not match number of columns in flamelet data.

Returns:

Differential diffusion coefficients

Return type:

float

Thermochemical State Variables#

AddOutputGroup(self, variable_names_in: list[str])#

Add an MLP output group of flamelet variables.

Parameters:

variable_names_in (list[str]) – list of output variables to include in the outputs of a single MLP.

Raises:

Exception – if the number of variables is equal to zero.

RemoveOutputGroup(self, i_group: int)#

Remove one of the MLP output groups.

Parameters:

i_group (int) – MLP output group index to remove.

Raises:

Exception – if group index is outside the range of stored groups.

EditOutputGroup(self, i_group: int, variable_names_in: list[str])#

Re-define the variables in a specific MLP output group.

Parameters:
  • i_group (int) – MLP output group index to adapt.

  • variable_names_in (list[str]) – list of output variables to include in the outputs of a single MLP.

Raises:
  • Exception – if group index exceeds number of output groups.

  • Exception – if the number of variables is equal to zero.