From da3ed1d0062979276e753fb54a28731a1d5db06c Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 28 Jun 2024 15:13:42 +0200 Subject: [PATCH 001/173] adding cantera enable options --- .github/workflows/regression.yml | 2 +- .gitmodules | 3 +++ meson.build | 46 ++++++++++++++++++++++++++++++-- meson_options.txt | 1 + meson_scripts/init.py | 9 +++++++ preconfigure.py | 6 +++++ 6 files changed, 64 insertions(+), 3 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index af6f6c60875d..7c247c3e304c 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -26,7 +26,7 @@ jobs: config_set: [BaseMPI, ReverseMPI, ForwardMPI, BaseNoMPI, ReverseNoMPI, ForwardNoMPI, BaseOMP, ReverseOMP, ForwardOMP] include: - config_set: BaseMPI - flags: '-Denable-pywrapper=true -Denable-coolprop=true -Denable-mpp=true -Dinstall-mpp=true -Denable-mlpcpp=true -Denable-tests=true --warnlevel=2' + flags: '-Denable-pywrapper=true -Denable-coolprop=true -Denable-mpp=true -Denable-cantera=true -Dinstall-cantera=true -Dinstall-mpp=true -Denable-mlpcpp=true -Denable-tests=true --warnlevel=2' - config_set: ReverseMPI flags: '-Denable-autodiff=true -Denable-normal=false -Denable-pywrapper=true -Denable-tests=true --warnlevel=3 --werror' - config_set: ForwardMPI diff --git a/.gitmodules b/.gitmodules index 2c655cb36da3..559b96867e41 100644 --- a/.gitmodules +++ b/.gitmodules @@ -18,6 +18,9 @@ [submodule "subprojects/CoolProp"] path = subprojects/CoolProp url = https://github.com/CoolProp/CoolProp.git +[submodule "subprojects/cantera"] + path = subprojects/cantera + url = https://github.com/Cantera/cantera.git [submodule "externals/opdi"] path = externals/opdi url = https://github.com/SciCompKL/OpDiLib diff --git a/meson.build b/meson.build index 66dde2dfc9d4..f89308a346e7 100644 --- a/meson.build +++ b/meson.build @@ -291,6 +291,29 @@ if get_option('enable-coolprop') endif endif +if get_option('enable-cantera') + cmake = import('cmake') + cmake_opts = cmake.subproject_options() + cmake_opts.set_override_option('warning_level', '0') + cmake_opts.add_cmake_defines({ + 'CMAKE_MAKE_PROGRAM': join_paths(meson.project_source_root(), 'ninja'), + 'CMAKE_POSITION_INDEPENDENT_CODE': 'ON' + }) + cmake_opts.set_install(get_option('install-cantera')) + cantera_subproj = cmake.subproject('cantera', options: cmake_opts) + cantera_dep = cantera_subproj.dependency('cantera') + su2_deps += cantera_dep + su2_cpp_args += '-DHAVE_CANTERA' + + if get_option('install-cantera') + py = find_program('python3', 'python') + p = run_command(py, 'SU2_PY/copy_directory.py', 'subprojects/cantera/data', join_paths(get_option('prefix'), 'cantera-data')) + if p.returncode() != 0 + error(p.stderr()) + endif + endif +endif + if get_option('enable-mlpcpp') su2_cpp_args += '-DHAVE_MLPCPP' endif @@ -346,6 +369,7 @@ message('''--------------------------------------------------------------------- libROM: @11@ CoolProp: @12@ MLPCpp: @13@ + cantera: @14@ Please be sure to add the $SU2_HOME and $SU2_RUN environment variables, and update your $PATH (and $PYTHONPATH if applicable) with $SU2_RUN @@ -357,10 +381,10 @@ message('''--------------------------------------------------------------------- export PATH=$PATH:$SU2_RUN export PYTHONPATH=$PYTHONPATH:$SU2_RUN - Use './ninja -C @14@ install' to compile and install SU2 + Use './ninja -C @15@ install' to compile and install SU2 '''.format(get_option('prefix')+'/bin', meson.project_source_root(), get_option('enable-tecio'), get_option('enable-cgns'), get_option('enable-autodiff'), get_option('enable-directdiff'), get_option('enable-pywrapper'), get_option('enable-mkl'), - get_option('enable-openblas'), get_option('enable-pastix'), get_option('enable-mixedprec'), get_option('enable-librom'), get_option('enable-coolprop'), + get_option('enable-openblas'), get_option('enable-pastix'), get_option('enable-mixedprec'), get_option('enable-librom'), get_option('enable-coolprop'), get_option('enable-cantera'), get_option('enable-mlpcpp'), meson.project_build_root().startswith(meson.project_source_root()) ? meson.project_build_root().split('/')[-1] : meson.project_build_root())) if get_option('enable-mpp') @@ -381,6 +405,24 @@ if get_option('enable-mpp') endif endif +if get_option('enable-cantera') + if get_option('install-cantera') + message(''' To run SU2 with Cantera library, add these lines to your .bashrc file: + + export CANTERA_DATA_DIRECTORY=$SU2_RUN/../mpp-data + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SU2_RUN/../lib + + ''') + else + message(''' To run SU2 with Cantera library, add these lines to your .bashrc file: + + export MPP_DATA_DIRECTORY=$SU2_HOME/subprojects/cantera/data + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SU2_HOME//subprojects/cantera + + ''') + endif +endif + if get_option('enable-librom') message(''' To run SU2 with libROM library, add this line to your .bashrc file: diff --git a/meson_options.txt b/meson_options.txt index 08fbac80669f..a95a9c942809 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -20,6 +20,7 @@ option('extra-deps', type : 'string', value : '', description: 'comma-separated option('enable-mpp', type : 'boolean', value : false, description: 'enable Mutation++ support') option('install-mpp', type : 'boolean', value : false, description: 'install Mutation++ in the directory defined with --prefix') option('enable-coolprop', type : 'boolean', value : false, description: 'enable CoolProp support') +option('enable-cantera', type : 'boolean', value : false, description: 'enable cantera support') option('enable-mlpcpp', type : 'boolean', value : false, description: 'enable profiling through gprof') option('enable-gprof', type : 'boolean', value : false, description: 'enable MLPCpp support') option('opdi-backend', type : 'combo', choices : ['auto', 'macro', 'ompt'], value : 'auto', description: 'OpDiLib backend choice') diff --git a/meson_scripts/init.py b/meson_scripts/init.py index bc58f9a95646..70882fd2333e 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -47,6 +47,7 @@ def init_submodules( own_opdi=True, own_mpp=True, own_cool=True, + own_cantera=True, own_mel=True, own_mlpcpp=True, ): @@ -69,6 +70,8 @@ def init_submodules( github_repo_mpp = "https://github.com/mutationpp/Mutationpp" sha_version_coolprop = "bafdea1f39ee873a6bb9833e3a21fe41f90b85e8" github_repo_coolprop = "https://github.com/CoolProp/CoolProp" + sha_version_cantera = "90b4481554dd2014e09398fecba713275cd890bc" + github_repo_cantera = "https://github.com/Cantera/cantera.git" sha_version_mel = "46205ab019e5224559091375a6d71aabae6bc5b9" github_repo_mel = "https://github.com/pcarruscag/MEL" sha_version_mlpcpp = "c19c53ea2b85ccfb185f1c6c87044dc0b5bc7ae0" @@ -81,6 +84,7 @@ def init_submodules( ninja_name = "ninja" mpp_name = "Mutationpp" coolprop_name = "CoolProp" + cantera_name = "cantera" mel_name = "MEL" mlpcpp_name = "MLPCpp" @@ -93,6 +97,7 @@ def init_submodules( alt_name_mel = base_path + "mel" alt_name_mpp = cur_dir + os.path.sep + "subprojects" + os.path.sep + "Mutationpp" alt_name_coolprop = cur_dir + os.path.sep + "subprojects" + os.path.sep + "CoolProp" + alt_name_cantera = cur_dir + os.path.sep + "subprojects" + os.path.sep + "cantera" alt_name_mlpcpp = cur_dir + os.path.sep + "subprojects" + os.path.sep + "MLPCpp" if method == "auto": @@ -121,6 +126,8 @@ def init_submodules( submodule_status(alt_name_mpp, sha_version_mpp) if own_cool: submodule_status(alt_name_coolprop, sha_version_coolprop) + if own_cantera: + submodule_status(alt_name_cantera,sha_version_cantera) if own_mel: submodule_status(alt_name_mel, sha_version_mel) if own_mlpcpp: @@ -155,6 +162,8 @@ def init_submodules( github_repo_coolprop, sha_version_coolprop, ) + if own_cantera: + download_module(cantera_name, alt_name_cantera, github_repo_cantera, sha_version_cantera) if own_mel: download_module(mel_name, alt_name_mel, github_repo_mel, sha_version_mel) if own_mlpcpp: diff --git a/preconfigure.py b/preconfigure.py index fa64e336e74d..373353714590 100755 --- a/preconfigure.py +++ b/preconfigure.py @@ -80,6 +80,7 @@ def run( own_opdi=True, own_mpp=True, own_cool=True, + own_cantera=True, own_mel=True, own_mlpcpp=True, ): @@ -93,6 +94,7 @@ def run( own_opdi=own_opdi, own_mpp=own_mpp, own_cool=own_cool, + own_cantera=own_cantera, own_mel=own_mel, own_mlpcpp=own_mlpcpp, ) @@ -134,6 +136,9 @@ def run( help="do not download own copy of CoolProp", action="store_false", ) + parser.add_argument( + "--no-cantera", help="do not download own copy of cantera", action="store_false" + ) parser.add_argument( "--no-mel", help="do not download own copy of MEL", action="store_false" ) @@ -151,6 +156,7 @@ def run( own_opdi=args.no_opdi, own_mpp=args.no_mpp, own_cool=args.no_coolprop, + own_cantera=args.no_cantera, own_mel=args.no_mel, own_mlpcpp=args.no_mlpcpp, ) From 2733e57bab7aa4565f0562de70a033bea0e90be8 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 28 Jun 2024 17:37:24 +0200 Subject: [PATCH 002/173] fix git location --- meson_scripts/init.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meson_scripts/init.py b/meson_scripts/init.py index 70882fd2333e..aa107195b5ce 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -71,7 +71,7 @@ def init_submodules( sha_version_coolprop = "bafdea1f39ee873a6bb9833e3a21fe41f90b85e8" github_repo_coolprop = "https://github.com/CoolProp/CoolProp" sha_version_cantera = "90b4481554dd2014e09398fecba713275cd890bc" - github_repo_cantera = "https://github.com/Cantera/cantera.git" + github_repo_cantera = "https://github.com/Cantera/cantera" sha_version_mel = "46205ab019e5224559091375a6d71aabae6bc5b9" github_repo_mel = "https://github.com/pcarruscag/MEL" sha_version_mlpcpp = "c19c53ea2b85ccfb185f1c6c87044dc0b5bc7ae0" @@ -127,7 +127,7 @@ def init_submodules( if own_cool: submodule_status(alt_name_coolprop, sha_version_coolprop) if own_cantera: - submodule_status(alt_name_cantera,sha_version_cantera) + submodule_status(alt_name_cantera, sha_version_cantera) if own_mel: submodule_status(alt_name_mel, sha_version_mel) if own_mlpcpp: From 52ba0a77414007fd93fecd1c66a6d94e0a4fbe44 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 29 Jul 2024 12:54:12 +0200 Subject: [PATCH 003/173] cantera class --- .github/workflows/regression.yml | 2 +- .gitmodules | 3 - Common/include/option_structure.hpp | 2 + SU2_CFD/include/fluid/CFluidCantera.hpp | 146 +++++++++++++++ SU2_CFD/src/fluid/CFluidCantera.cpp | 234 ++++++++++++++++++++++++ SU2_CFD/src/fluid/CFluidModel.cpp | 1 + SU2_CFD/src/meson.build | 3 +- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 1 + meson.build | 46 +---- meson_options.txt | 1 - meson_scripts/init.py | 9 - preconfigure.py | 6 - 12 files changed, 389 insertions(+), 65 deletions(-) create mode 100644 SU2_CFD/include/fluid/CFluidCantera.hpp create mode 100644 SU2_CFD/src/fluid/CFluidCantera.cpp diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 7c247c3e304c..af6f6c60875d 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -26,7 +26,7 @@ jobs: config_set: [BaseMPI, ReverseMPI, ForwardMPI, BaseNoMPI, ReverseNoMPI, ForwardNoMPI, BaseOMP, ReverseOMP, ForwardOMP] include: - config_set: BaseMPI - flags: '-Denable-pywrapper=true -Denable-coolprop=true -Denable-mpp=true -Denable-cantera=true -Dinstall-cantera=true -Dinstall-mpp=true -Denable-mlpcpp=true -Denable-tests=true --warnlevel=2' + flags: '-Denable-pywrapper=true -Denable-coolprop=true -Denable-mpp=true -Dinstall-mpp=true -Denable-mlpcpp=true -Denable-tests=true --warnlevel=2' - config_set: ReverseMPI flags: '-Denable-autodiff=true -Denable-normal=false -Denable-pywrapper=true -Denable-tests=true --warnlevel=3 --werror' - config_set: ForwardMPI diff --git a/.gitmodules b/.gitmodules index 559b96867e41..2c655cb36da3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -18,9 +18,6 @@ [submodule "subprojects/CoolProp"] path = subprojects/CoolProp url = https://github.com/CoolProp/CoolProp.git -[submodule "subprojects/cantera"] - path = subprojects/cantera - url = https://github.com/Cantera/cantera.git [submodule "externals/opdi"] path = externals/opdi url = https://github.com/SciCompKL/OpDiLib diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index e50653fcb7a9..54f90b39a56e 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -549,6 +549,7 @@ enum ENUM_FLUIDMODEL { COOLPROP = 10, /*!< \brief Thermodynamics library. */ FLUID_FLAMELET = 11, /*!< \brief lookup table (LUT) method for premixed flamelets. */ DATADRIVEN_FLUID = 12, /*!< \brief multi-layer perceptron driven fluid model. */ + CANTERA = 13, /*!< \brief Reacting flows model. */ }; static const MapType FluidModel_Map = { MakePair("STANDARD_AIR", STANDARD_AIR) @@ -564,6 +565,7 @@ static const MapType FluidModel_Map = { MakePair("COOLPROP", COOLPROP) MakePair("DATADRIVEN_FLUID", DATADRIVEN_FLUID) MakePair("FLUID_FLAMELET", FLUID_FLAMELET) + MakePair("CANTERA", CANTERA) }; /*! diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp new file mode 100644 index 000000000000..59be096359cf --- /dev/null +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -0,0 +1,146 @@ +/*! + * \file CFluidCantera.hpp + * \brief Defines the multicomponent incompressible Ideal Gas model for reacting flows. + * \author T. Economon, Cristopher Morales Ubal + * \version 8.0.1 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2024, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include +#include + +#include "CFluidModel.hpp" + +/*! + * \class CFluidCantera + * \brief Child class for defining reacting incompressible ideal gas mixture model. + * \author: T. Economon + */ +class CFluidCantera final : public CFluidModel { + private: + const int n_species_mixture; /*!< \brief Number of species in mixture. */ + su2double Gas_Constant; /*!< \brief Specific gas constant. */ + const su2double Gamma; /*!< \brief Ratio of specific heats of the gas. */ + const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */ + const su2double GasConstant_Ref; /*!< \brief Gas constant reference needed for Nondimensional problems. */ + const su2double Prandtl_Number; /*!< \brief Prandlt number.*/ + + const bool wilke; + const bool davidson; + + static constexpr int ARRAYSIZE = 16; + + std::array massFractions; /*!< \brief Mass fractions of all species. */ + std::array moleFractions; /*!< \brief Mole fractions of all species. */ + std::array molarMasses; /*!< \brief Molar masses of all species. */ + std::array specificHeat; /*!< \brief Specific Heat capacities of all species. */ + std::array laminarViscosity; /*!< \brief Laminar viscosity of all species. */ + std::array laminarThermalConductivity; /*!< \brief Laminar thermal conductivity of all species. */ + std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ + + std::unique_ptr LaminarViscosityPointers[ARRAYSIZE]; + std::unique_ptr ThermalConductivityPointers[ARRAYSIZE]; + std::unique_ptr MassDiffusivityPointers[ARRAYSIZE]; + + /*! + * \brief Convert mass fractions to mole fractions. + * \param[in] val_scalars - Scalar mass fraction. + */ + void MassToMoleFractions(const su2double* val_scalars); + + /*! + * \brief Wilke mixing law for mixture viscosity. + * \param[in] val_scalars - Scalar mass fraction. + */ + su2double WilkeViscosity(const su2double* val_scalars); + + /*! + * \brief Davidson mixing law for mixture viscosity. + * \param[in] val_scalars - Scalar mass fraction. + */ + su2double DavidsonViscosity(const su2double* val_scalars); + + /*! + * \brief Wilke mixing law for mixture thermal conductivity. + * \param[in] val_scalars - Scalar mass fraction. + */ + su2double WilkeConductivity(const su2double* val_scalars); + + /*! + * \brief Get fluid mean specific heat capacity at constant pressure. + */ + su2double ComputeMeanSpecificHeatCp(const su2double* val_scalars); + + /*! + * \brief Compute gas constant for mixture. + */ + su2double ComputeGasConstant(); + + /*! + * \brief Compute mass diffusivity for species. + */ + void ComputeMassDiffusivity(); + + public: + /*! + * \brief Constructor of the class. + */ + CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2double val_operating_pressure, const CConfig* config); + + /*! + * \brief Set viscosity model. + */ + void SetLaminarViscosityModel(const CConfig* config) override; + + /*! + * \brief Set thermal conductivity model. + */ + void SetThermalConductivityModel(const CConfig* config) override; + + /*! + * \brief Set mass diffusivity model. + */ + void SetMassDiffusivityModel(const CConfig* config) override; + + /*! + * \brief Get fluid laminar viscosity. + */ + inline su2double GetLaminarViscosity() override { return Mu; } + + /*! + * \brief Get fluid thermal conductivity. + */ + inline su2double GetThermalConductivity() override { return Kt + Mu_Turb * Cp / Prandtl_Number; } + + /*! + * \brief Get fluid mass diffusivity. + */ + inline su2double GetMassDiffusivity(int ivar) override { return massDiffusivity[ivar]; } + + /*! + * \brief Set the Dimensionless State using Temperature. + * \param[in] t - Temperature value at the point. + */ + void SetTDState_T(su2double val_temperature, const su2double* val_scalars) override; +}; \ No newline at end of file diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp new file mode 100644 index 000000000000..928b9f920ea9 --- /dev/null +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -0,0 +1,234 @@ +/*! + * \file CFluidCantera.cpp + * \brief Defines the multicomponent incompressible Ideal Gas model for reacting flows. + * \author T. Economon, Cristopher Morales Ubal + * \version 8.0.1 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2024, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../include/fluid/CFluidCantera.hpp" + +#include + +#include + +#include "../../include/fluid/CConstantConductivity.hpp" +#include "../../include/fluid/CConstantConductivityRANS.hpp" +#include "../../include/fluid/CConstantPrandtl.hpp" +#include "../../include/fluid/CConstantPrandtlRANS.hpp" +#include "../../include/fluid/CConstantViscosity.hpp" +#include "../../include/fluid/CPolynomialConductivity.hpp" +#include "../../include/fluid/CPolynomialConductivityRANS.hpp" +#include "../../include/fluid/CPolynomialViscosity.hpp" +#include "../../include/fluid/CSutherland.hpp" + +CFluidCantera::CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2double value_pressure_operating, + const CConfig* config) + : CFluidModel(), + n_species_mixture(config->GetnSpecies() + 1), + Gas_Constant(val_gas_constant), + Gamma(config->GetGamma()), + Pressure_Thermodynamic(value_pressure_operating), + GasConstant_Ref(config->GetGas_Constant_Ref()), + Prandtl_Number(config->GetPrandtl_Turb()), + wilke(config->GetKind_MixingViscosityModel() == MIXINGVISCOSITYMODEL::WILKE), + davidson(config->GetKind_MixingViscosityModel() == MIXINGVISCOSITYMODEL::DAVIDSON) { + if (n_species_mixture > ARRAYSIZE) { + SU2_MPI::Error("Too many species, increase ARRAYSIZE", CURRENT_FUNCTION); + } + + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + molarMasses[iVar] = config->GetMolecular_Weight(iVar); + specificHeat[iVar] = config->GetSpecific_Heat_CpND(iVar); + } + + SetLaminarViscosityModel(config); + SetThermalConductivityModel(config); + SetMassDiffusivityModel(config); +} + +void CFluidCantera::SetLaminarViscosityModel(const CConfig* config) { + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + LaminarViscosityPointers[iVar] = MakeLaminarViscosityModel(config, iVar); + } +} + +void CFluidCantera::SetThermalConductivityModel(const CConfig* config) { + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + ThermalConductivityPointers[iVar] = MakeThermalConductivityModel(config, iVar); + } +} + +void CFluidCantera::SetMassDiffusivityModel(const CConfig* config) { + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + MassDiffusivityPointers[iVar] = MakeMassDiffusivityModel(config, iVar); + } +} + +void CFluidCantera::ComputeMassDiffusivity() { + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + MassDiffusivityPointers[iVar]->SetDiffusivity(Density, Mu, Cp, Kt); + massDiffusivity[iVar] = MassDiffusivityPointers[iVar]->GetDiffusivity(); + } +} + +void CFluidCantera::MassToMoleFractions(const su2double* val_scalars) { + + su2double val_scalars_sum{0.0}; + for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { + massFractions[i_scalar] = val_scalars[i_scalar]; + val_scalars_sum += val_scalars[i_scalar]; + } + massFractions[n_species_mixture - 1] = 1 - val_scalars_sum; + + su2double mixtureMolarMass{0.0}; + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + mixtureMolarMass += massFractions[iVar] / molarMasses[iVar]; + } + + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + moleFractions[iVar] = (massFractions[iVar] / molarMasses[iVar]) / mixtureMolarMass; + } +} + +su2double CFluidCantera::WilkeViscosity(const su2double* val_scalars) { + + /* Fill laminarViscosity with n_species_mixture viscosity values. */ + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + LaminarViscosityPointers[iVar]->SetViscosity(Temperature, Density); + laminarViscosity[iVar] = LaminarViscosityPointers[iVar]->GetViscosity(); + } + + su2double viscosityMixture = 0.0; + + for (int i = 0; i < n_species_mixture; i++) { + su2double wilkeDenumerator = 0.0; + for (int j = 0; j < n_species_mixture; j++) { + if (j != i) { + const su2double phi = + pow(1 + sqrt(laminarViscosity[i] / laminarViscosity[j]) * pow(molarMasses[j] / molarMasses[i], 0.25), 2) / + sqrt(8 * (1 + molarMasses[i] / molarMasses[j])); + wilkeDenumerator += moleFractions[j] * phi; + } else { + wilkeDenumerator += moleFractions[j]; + } + } + const su2double wilkeNumerator = moleFractions[i] * laminarViscosity[i]; + viscosityMixture += wilkeNumerator / wilkeDenumerator; + } + return viscosityMixture; +} + +su2double CFluidCantera::DavidsonViscosity(const su2double* val_scalars) { + const su2double A = 0.375; + + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + LaminarViscosityPointers[iVar]->SetViscosity(Temperature, Density); + laminarViscosity[iVar] = LaminarViscosityPointers[iVar]->GetViscosity(); + } + + su2double mixtureFractionDenumerator = 0.0; + for (int i = 0; i < n_species_mixture; i++) { + mixtureFractionDenumerator += moleFractions[i] * sqrt(molarMasses[i]); + } + + std::array mixtureFractions; + for (int j = 0; j < n_species_mixture; j++) { + mixtureFractions[j] = (moleFractions[j] * sqrt(molarMasses[j])) / mixtureFractionDenumerator; + } + + su2double fluidity = 0.0; + for (int i = 0; i < n_species_mixture; i++) { + for (int j = 0; j < n_species_mixture; j++) { + const su2double E = (2 * sqrt(molarMasses[i]) * sqrt(molarMasses[j])) / (molarMasses[i] + molarMasses[j]); + fluidity += + ((mixtureFractions[i] * mixtureFractions[j]) / (sqrt(laminarViscosity[i]) * sqrt(laminarViscosity[j]))) * + pow(E, A); + } + } + return 1.0 / fluidity; +} + +su2double CFluidCantera::WilkeConductivity(const su2double* val_scalars) { + + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + ThermalConductivityPointers[iVar]->SetConductivity(Temperature, Density, Mu, 0.0, 0.0, 0.0, 0.0); + laminarThermalConductivity[iVar] = ThermalConductivityPointers[iVar]->GetConductivity(); + } + + su2double conductivityMixture = 0.0; + + for (int i = 0; i < n_species_mixture; i++) { + su2double wilkeDenumerator = 0.0; + for (int j = 0; j < n_species_mixture; j++) { + if (j != i) { + const su2double phi = + pow(1 + sqrt(laminarViscosity[i] / laminarViscosity[j]) * pow(molarMasses[j] / molarMasses[i], 0.25), 2) / + sqrt(8 * (1 + molarMasses[i] / molarMasses[j])); + wilkeDenumerator += moleFractions[j] * phi; + } else { + wilkeDenumerator += moleFractions[j]; + } + } + const su2double wilkeNumerator = moleFractions[i] * laminarThermalConductivity[i]; + conductivityMixture += wilkeNumerator / wilkeDenumerator; + } + return conductivityMixture; +} + +su2double CFluidCantera::ComputeGasConstant() { + su2double MeanMolecularWeight = 0.0; + + for (int i = 0; i < n_species_mixture; i++) { + MeanMolecularWeight += moleFractions[i] * molarMasses[i] / 1000; + } + Gas_Constant = UNIVERSAL_GAS_CONSTANT / (GasConstant_Ref * MeanMolecularWeight); + + return Gas_Constant; +} + +su2double CFluidCantera::ComputeMeanSpecificHeatCp(const su2double* val_scalars) { + su2double mean_cp = 0.0; + + for (int i_scalar = 0; i_scalar < n_species_mixture; i_scalar++) { + mean_cp += specificHeat[i_scalar] * massFractions[i_scalar]; + } + return mean_cp; +} + +void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { + MassToMoleFractions(val_scalars); + ComputeGasConstant(); + Temperature = val_temperature; + Density = Pressure_Thermodynamic / (Temperature * Gas_Constant); + Cp = ComputeMeanSpecificHeatCp(val_scalars); + Cv = Cp - Gas_Constant; + + if (wilke) { + Mu = WilkeViscosity(val_scalars); + } else if (davidson) { + Mu = DavidsonViscosity(val_scalars); + } + + Kt = WilkeConductivity(val_scalars); + ComputeMassDiffusivity(); +} \ No newline at end of file diff --git a/SU2_CFD/src/fluid/CFluidModel.cpp b/SU2_CFD/src/fluid/CFluidModel.cpp index 748010649456..ea9d7f33e1f7 100644 --- a/SU2_CFD/src/fluid/CFluidModel.cpp +++ b/SU2_CFD/src/fluid/CFluidModel.cpp @@ -37,6 +37,7 @@ #include "../../include/fluid/CConstantSchmidt.hpp" #include "../../include/fluid/CConstantViscosity.hpp" #include "../../include/fluid/CFluidScalar.hpp" +#include "../../include/fluid/CFluidCantera.hpp" #include "../../include/fluid/CPolynomialConductivity.hpp" #include "../../include/fluid/CPolynomialConductivityRANS.hpp" #include "../../include/fluid/CPolynomialViscosity.hpp" diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index 3b40822a34f4..ba918ab1ebc0 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -13,7 +13,8 @@ su2_cfd_src += files(['fluid/CFluidModel.cpp', 'fluid/CNEMOGas.cpp', 'fluid/CMutationTCLib.cpp', 'fluid/CSU2TCLib.cpp', - 'fluid/CDataDrivenFluid.cpp']) + 'fluid/CDataDrivenFluid.cpp', + 'fluid/CFluidCantera.cpp']) su2_cfd_src += files(['output/COutputFactory.cpp', 'output/CAdjElasticityOutput.cpp', diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 5b81394bd9a3..3b5f6448c217 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -34,6 +34,7 @@ #include "../../include/limiters/CLimiterDetails.hpp" #include "../../../Common/include/toolboxes/geometry_toolbox.hpp" #include "../../include/fluid/CFluidScalar.hpp" +#include "../../include/fluid/CFluidCantera.hpp" #include "../../include/fluid/CFluidFlamelet.hpp" #include "../../include/fluid/CFluidModel.hpp" diff --git a/meson.build b/meson.build index f89308a346e7..66dde2dfc9d4 100644 --- a/meson.build +++ b/meson.build @@ -291,29 +291,6 @@ if get_option('enable-coolprop') endif endif -if get_option('enable-cantera') - cmake = import('cmake') - cmake_opts = cmake.subproject_options() - cmake_opts.set_override_option('warning_level', '0') - cmake_opts.add_cmake_defines({ - 'CMAKE_MAKE_PROGRAM': join_paths(meson.project_source_root(), 'ninja'), - 'CMAKE_POSITION_INDEPENDENT_CODE': 'ON' - }) - cmake_opts.set_install(get_option('install-cantera')) - cantera_subproj = cmake.subproject('cantera', options: cmake_opts) - cantera_dep = cantera_subproj.dependency('cantera') - su2_deps += cantera_dep - su2_cpp_args += '-DHAVE_CANTERA' - - if get_option('install-cantera') - py = find_program('python3', 'python') - p = run_command(py, 'SU2_PY/copy_directory.py', 'subprojects/cantera/data', join_paths(get_option('prefix'), 'cantera-data')) - if p.returncode() != 0 - error(p.stderr()) - endif - endif -endif - if get_option('enable-mlpcpp') su2_cpp_args += '-DHAVE_MLPCPP' endif @@ -369,7 +346,6 @@ message('''--------------------------------------------------------------------- libROM: @11@ CoolProp: @12@ MLPCpp: @13@ - cantera: @14@ Please be sure to add the $SU2_HOME and $SU2_RUN environment variables, and update your $PATH (and $PYTHONPATH if applicable) with $SU2_RUN @@ -381,10 +357,10 @@ message('''--------------------------------------------------------------------- export PATH=$PATH:$SU2_RUN export PYTHONPATH=$PYTHONPATH:$SU2_RUN - Use './ninja -C @15@ install' to compile and install SU2 + Use './ninja -C @14@ install' to compile and install SU2 '''.format(get_option('prefix')+'/bin', meson.project_source_root(), get_option('enable-tecio'), get_option('enable-cgns'), get_option('enable-autodiff'), get_option('enable-directdiff'), get_option('enable-pywrapper'), get_option('enable-mkl'), - get_option('enable-openblas'), get_option('enable-pastix'), get_option('enable-mixedprec'), get_option('enable-librom'), get_option('enable-coolprop'), get_option('enable-cantera'), + get_option('enable-openblas'), get_option('enable-pastix'), get_option('enable-mixedprec'), get_option('enable-librom'), get_option('enable-coolprop'), get_option('enable-mlpcpp'), meson.project_build_root().startswith(meson.project_source_root()) ? meson.project_build_root().split('/')[-1] : meson.project_build_root())) if get_option('enable-mpp') @@ -405,24 +381,6 @@ if get_option('enable-mpp') endif endif -if get_option('enable-cantera') - if get_option('install-cantera') - message(''' To run SU2 with Cantera library, add these lines to your .bashrc file: - - export CANTERA_DATA_DIRECTORY=$SU2_RUN/../mpp-data - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SU2_RUN/../lib - - ''') - else - message(''' To run SU2 with Cantera library, add these lines to your .bashrc file: - - export MPP_DATA_DIRECTORY=$SU2_HOME/subprojects/cantera/data - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SU2_HOME//subprojects/cantera - - ''') - endif -endif - if get_option('enable-librom') message(''' To run SU2 with libROM library, add this line to your .bashrc file: diff --git a/meson_options.txt b/meson_options.txt index a95a9c942809..08fbac80669f 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -20,7 +20,6 @@ option('extra-deps', type : 'string', value : '', description: 'comma-separated option('enable-mpp', type : 'boolean', value : false, description: 'enable Mutation++ support') option('install-mpp', type : 'boolean', value : false, description: 'install Mutation++ in the directory defined with --prefix') option('enable-coolprop', type : 'boolean', value : false, description: 'enable CoolProp support') -option('enable-cantera', type : 'boolean', value : false, description: 'enable cantera support') option('enable-mlpcpp', type : 'boolean', value : false, description: 'enable profiling through gprof') option('enable-gprof', type : 'boolean', value : false, description: 'enable MLPCpp support') option('opdi-backend', type : 'combo', choices : ['auto', 'macro', 'ompt'], value : 'auto', description: 'OpDiLib backend choice') diff --git a/meson_scripts/init.py b/meson_scripts/init.py index aa107195b5ce..bc58f9a95646 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -47,7 +47,6 @@ def init_submodules( own_opdi=True, own_mpp=True, own_cool=True, - own_cantera=True, own_mel=True, own_mlpcpp=True, ): @@ -70,8 +69,6 @@ def init_submodules( github_repo_mpp = "https://github.com/mutationpp/Mutationpp" sha_version_coolprop = "bafdea1f39ee873a6bb9833e3a21fe41f90b85e8" github_repo_coolprop = "https://github.com/CoolProp/CoolProp" - sha_version_cantera = "90b4481554dd2014e09398fecba713275cd890bc" - github_repo_cantera = "https://github.com/Cantera/cantera" sha_version_mel = "46205ab019e5224559091375a6d71aabae6bc5b9" github_repo_mel = "https://github.com/pcarruscag/MEL" sha_version_mlpcpp = "c19c53ea2b85ccfb185f1c6c87044dc0b5bc7ae0" @@ -84,7 +81,6 @@ def init_submodules( ninja_name = "ninja" mpp_name = "Mutationpp" coolprop_name = "CoolProp" - cantera_name = "cantera" mel_name = "MEL" mlpcpp_name = "MLPCpp" @@ -97,7 +93,6 @@ def init_submodules( alt_name_mel = base_path + "mel" alt_name_mpp = cur_dir + os.path.sep + "subprojects" + os.path.sep + "Mutationpp" alt_name_coolprop = cur_dir + os.path.sep + "subprojects" + os.path.sep + "CoolProp" - alt_name_cantera = cur_dir + os.path.sep + "subprojects" + os.path.sep + "cantera" alt_name_mlpcpp = cur_dir + os.path.sep + "subprojects" + os.path.sep + "MLPCpp" if method == "auto": @@ -126,8 +121,6 @@ def init_submodules( submodule_status(alt_name_mpp, sha_version_mpp) if own_cool: submodule_status(alt_name_coolprop, sha_version_coolprop) - if own_cantera: - submodule_status(alt_name_cantera, sha_version_cantera) if own_mel: submodule_status(alt_name_mel, sha_version_mel) if own_mlpcpp: @@ -162,8 +155,6 @@ def init_submodules( github_repo_coolprop, sha_version_coolprop, ) - if own_cantera: - download_module(cantera_name, alt_name_cantera, github_repo_cantera, sha_version_cantera) if own_mel: download_module(mel_name, alt_name_mel, github_repo_mel, sha_version_mel) if own_mlpcpp: diff --git a/preconfigure.py b/preconfigure.py index 373353714590..fa64e336e74d 100755 --- a/preconfigure.py +++ b/preconfigure.py @@ -80,7 +80,6 @@ def run( own_opdi=True, own_mpp=True, own_cool=True, - own_cantera=True, own_mel=True, own_mlpcpp=True, ): @@ -94,7 +93,6 @@ def run( own_opdi=own_opdi, own_mpp=own_mpp, own_cool=own_cool, - own_cantera=own_cantera, own_mel=own_mel, own_mlpcpp=own_mlpcpp, ) @@ -136,9 +134,6 @@ def run( help="do not download own copy of CoolProp", action="store_false", ) - parser.add_argument( - "--no-cantera", help="do not download own copy of cantera", action="store_false" - ) parser.add_argument( "--no-mel", help="do not download own copy of MEL", action="store_false" ) @@ -156,7 +151,6 @@ def run( own_opdi=args.no_opdi, own_mpp=args.no_mpp, own_cool=args.no_coolprop, - own_cantera=args.no_cantera, own_mel=args.no_mel, own_mlpcpp=args.no_mlpcpp, ) From 1032e91aac23ea53f4bd4cf4a6043dea137c1eda Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 15 Aug 2024 16:48:19 +0200 Subject: [PATCH 004/173] initialization Cantera CIncEulerSolver --- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 3b5f6448c217..a26f7a5782e5 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -339,6 +339,15 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i auxFluidModel->SetTDState_T(Temperature_FreeStream, config->GetSpecies_Init()); break; + case CANTERA: + + config->SetGas_Constant(UNIVERSAL_GAS_CONSTANT / (config->GetMolecular_Weight() / 1000.0)); + Pressure_Thermodynamic = config->GetPressure_Thermodynamic(); + auxFluidModel = + new CFluidCantera(config->GetSpecific_Heat_Cp(), config->GetGas_Constant(), Pressure_Thermodynamic, config); + auxFluidModel->SetTDState_T(Temperature_FreeStream, config->GetSpecies_Init()); + break; + default: SU2_MPI::Error("Fluid model not implemented for incompressible solver.", CURRENT_FUNCTION); @@ -492,6 +501,11 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i fluidModel->SetTDState_T(Temperature_FreeStreamND, config->GetSpecies_Init()); break; + case CANTERA: + fluidModel = new CFluidCantera(Specific_Heat_CpND, Gas_ConstantND, Pressure_ThermodynamicND, config); + fluidModel->SetTDState_T(Temperature_FreeStreamND, config->GetSpecies_Init()); + break; + case INC_IDEAL_GAS_POLY: fluidModel = new CIncIdealGasPolynomial(Gas_ConstantND, Pressure_ThermodynamicND); if (viscous) { @@ -809,6 +823,23 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i NonDimTable.PrintFooter(); break; + case CANTERA: + ModelTable << "CANTERA"; + Unit << "N.m/kg.K"; + NonDimTable << "Spec. Heat (Cp)" << config->GetSpecific_Heat_Cp() << config->GetSpecific_Heat_Cp() / config->GetSpecific_Heat_CpND() << Unit.str() << config->GetSpecific_Heat_CpND(); + Unit.str(""); + Unit << "g/mol"; + NonDimTable << "Molecular weight" << config->GetMolecular_Weight() << 1.0 << Unit.str() << config->GetMolecular_Weight(); + Unit.str(""); + Unit << "N.m/kg.K"; + NonDimTable << "Gas Constant" << config->GetGas_Constant() << config->GetGas_Constant_Ref() << Unit.str() << config->GetGas_ConstantND(); + Unit.str(""); + Unit << "Pa"; + NonDimTable << "Therm. Pressure" << config->GetPressure_Thermodynamic() << config->GetPressure_Ref() << Unit.str() << config->GetPressure_ThermodynamicND(); + Unit.str(""); + NonDimTable.PrintFooter(); + break; + case INC_IDEAL_GAS_POLY: ModelTable << "INC_IDEAL_GAS_POLY"; Unit.str(""); From fb445d2c7cfb94a5a45b5a3a0311fa760e5267ed Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 27 Aug 2024 00:37:32 +0200 Subject: [PATCH 005/173] adding option for compiling --- .github/workflows/regression.yml | 2 +- .gitmodules | 3 +++ meson_options.txt | 2 ++ meson_scripts/init.py | 14 ++++++++++++++ preconfigure.py | 8 ++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 2502204b64c4..0f8676f34165 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -26,7 +26,7 @@ jobs: config_set: [BaseMPI, ReverseMPI, ForwardMPI, BaseNoMPI, ReverseNoMPI, ForwardNoMPI, BaseOMP, ReverseOMP, ForwardOMP] include: - config_set: BaseMPI - flags: '-Denable-pywrapper=true -Denable-coolprop=true -Denable-mpp=true -Dinstall-mpp=true -Denable-mlpcpp=true -Denable-tests=true --warnlevel=2' + flags: '-Denable-pywrapper=true -Denable-coolprop=true -Denable-cantera=true -Denable-mpp=true -Dinstall-mpp=true -Denable-mlpcpp=true -Denable-tests=true --warnlevel=2' - config_set: ReverseMPI flags: '-Denable-autodiff=true -Denable-normal=false -Denable-pywrapper=true -Denable-tests=true --warnlevel=3 --werror' - config_set: ForwardMPI diff --git a/.gitmodules b/.gitmodules index 2c655cb36da3..153397cf7628 100644 --- a/.gitmodules +++ b/.gitmodules @@ -18,6 +18,9 @@ [submodule "subprojects/CoolProp"] path = subprojects/CoolProp url = https://github.com/CoolProp/CoolProp.git +[submodule "subprojects/cantera"] + path = subprojects/cantera + url = https://github.com/cantera/cantera.git [submodule "externals/opdi"] path = externals/opdi url = https://github.com/SciCompKL/OpDiLib diff --git a/meson_options.txt b/meson_options.txt index 08fbac80669f..51377f37bb71 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -20,6 +20,8 @@ option('extra-deps', type : 'string', value : '', description: 'comma-separated option('enable-mpp', type : 'boolean', value : false, description: 'enable Mutation++ support') option('install-mpp', type : 'boolean', value : false, description: 'install Mutation++ in the directory defined with --prefix') option('enable-coolprop', type : 'boolean', value : false, description: 'enable CoolProp support') +option('enable-cantera', type : 'boolean', value : false, description: 'enable Cantera support') +option('install-cantera', type : 'boolean', value : false, description: 'install Cantera in the directory defined with --prefix') option('enable-mlpcpp', type : 'boolean', value : false, description: 'enable profiling through gprof') option('enable-gprof', type : 'boolean', value : false, description: 'enable MLPCpp support') option('opdi-backend', type : 'combo', choices : ['auto', 'macro', 'ompt'], value : 'auto', description: 'OpDiLib backend choice') diff --git a/meson_scripts/init.py b/meson_scripts/init.py index bc58f9a95646..5d3e2ebc62e4 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -47,6 +47,7 @@ def init_submodules( own_opdi=True, own_mpp=True, own_cool=True, + own_cantera=True, own_mel=True, own_mlpcpp=True, ): @@ -69,6 +70,8 @@ def init_submodules( github_repo_mpp = "https://github.com/mutationpp/Mutationpp" sha_version_coolprop = "bafdea1f39ee873a6bb9833e3a21fe41f90b85e8" github_repo_coolprop = "https://github.com/CoolProp/CoolProp" + sha_version_cantera = "feb64c2e028f4fa2ba9dc938022f5b2a693b5ddc" + github_repo_cantera = "https://github.com/Cantera/cantera" sha_version_mel = "46205ab019e5224559091375a6d71aabae6bc5b9" github_repo_mel = "https://github.com/pcarruscag/MEL" sha_version_mlpcpp = "c19c53ea2b85ccfb185f1c6c87044dc0b5bc7ae0" @@ -81,6 +84,7 @@ def init_submodules( ninja_name = "ninja" mpp_name = "Mutationpp" coolprop_name = "CoolProp" + cantera_name = "cantera" mel_name = "MEL" mlpcpp_name = "MLPCpp" @@ -93,6 +97,7 @@ def init_submodules( alt_name_mel = base_path + "mel" alt_name_mpp = cur_dir + os.path.sep + "subprojects" + os.path.sep + "Mutationpp" alt_name_coolprop = cur_dir + os.path.sep + "subprojects" + os.path.sep + "CoolProp" + alt_name_cantera = cur_dir + os.path.sep + "subprojects" + os.path.sep + "cantera" alt_name_mlpcpp = cur_dir + os.path.sep + "subprojects" + os.path.sep + "MLPCpp" if method == "auto": @@ -121,6 +126,8 @@ def init_submodules( submodule_status(alt_name_mpp, sha_version_mpp) if own_cool: submodule_status(alt_name_coolprop, sha_version_coolprop) + if own_cool: + submodule_status(alt_name_cantera, sha_version_cantera) if own_mel: submodule_status(alt_name_mel, sha_version_mel) if own_mlpcpp: @@ -155,6 +162,13 @@ def init_submodules( github_repo_coolprop, sha_version_coolprop, ) + if own_cantera: + download_module( + cantera_name, + alt_name_cantera, + github_repo_cantera, + sha_version_cantera, + ) if own_mel: download_module(mel_name, alt_name_mel, github_repo_mel, sha_version_mel) if own_mlpcpp: diff --git a/preconfigure.py b/preconfigure.py index fa64e336e74d..46bcafb3df7b 100755 --- a/preconfigure.py +++ b/preconfigure.py @@ -80,6 +80,7 @@ def run( own_opdi=True, own_mpp=True, own_cool=True, + own_cantera=True, own_mel=True, own_mlpcpp=True, ): @@ -93,6 +94,7 @@ def run( own_opdi=own_opdi, own_mpp=own_mpp, own_cool=own_cool, + own_cantera=own_cantera, own_mel=own_mel, own_mlpcpp=own_mlpcpp, ) @@ -134,6 +136,11 @@ def run( help="do not download own copy of CoolProp", action="store_false", ) + parser.add_argument( + "--no-cantera", + help="do not download own copy of Cantera", + action="store_false", + ) parser.add_argument( "--no-mel", help="do not download own copy of MEL", action="store_false" ) @@ -151,6 +158,7 @@ def run( own_opdi=args.no_opdi, own_mpp=args.no_mpp, own_cool=args.no_coolprop, + own_cantera=args.no_cantera, own_mel=args.no_mel, own_mlpcpp=args.no_mlpcpp, ) From e86ed41c23b8ffa7f5db47427a5b87434d15623d Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 27 Aug 2024 13:51:40 +0200 Subject: [PATCH 006/173] commented coupling lines and texting adding extra lines header --- .github/workflows/regression.yml | 3 ++- .gitmodules | 6 +++--- SU2_CFD/src/fluid/CFluidCantera.cpp | 5 +++++ meson_options.txt | 4 ++-- meson_scripts/init.py | 28 ++++++++++++++-------------- preconfigure.py | 16 ++++++++-------- 6 files changed, 34 insertions(+), 28 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 0f8676f34165..6b76ced5a7a6 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -26,7 +26,8 @@ jobs: config_set: [BaseMPI, ReverseMPI, ForwardMPI, BaseNoMPI, ReverseNoMPI, ForwardNoMPI, BaseOMP, ReverseOMP, ForwardOMP] include: - config_set: BaseMPI - flags: '-Denable-pywrapper=true -Denable-coolprop=true -Denable-cantera=true -Denable-mpp=true -Dinstall-mpp=true -Denable-mlpcpp=true -Denable-tests=true --warnlevel=2' + flags: '-Denable-pywrapper=true -Denable-coolprop=true -Denable-mpp=true -Dinstall-mpp=true -Denable-mlpcpp=true -Denable-tests=true --warnlevel=2' + # flags: '-Denable-pywrapper=true -Denable-coolprop=true -Denable-cantera=true -Denable-mpp=true -Dinstall-mpp=true -Denable-mlpcpp=true -Denable-tests=true --warnlevel=2' - config_set: ReverseMPI flags: '-Denable-autodiff=true -Denable-normal=false -Denable-pywrapper=true -Denable-tests=true --warnlevel=3 --werror' - config_set: ForwardMPI diff --git a/.gitmodules b/.gitmodules index 153397cf7628..c67744641396 100644 --- a/.gitmodules +++ b/.gitmodules @@ -18,9 +18,9 @@ [submodule "subprojects/CoolProp"] path = subprojects/CoolProp url = https://github.com/CoolProp/CoolProp.git -[submodule "subprojects/cantera"] - path = subprojects/cantera - url = https://github.com/cantera/cantera.git +# [submodule "subprojects/cantera"] +# path = subprojects/cantera +# url = https://github.com/cantera/cantera.git [submodule "externals/opdi"] path = externals/opdi url = https://github.com/SciCompKL/OpDiLib diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 928b9f920ea9..1d99c641646c 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -41,6 +41,11 @@ #include "../../include/fluid/CPolynomialViscosity.hpp" #include "../../include/fluid/CSutherland.hpp" +#include "../../subprojects/cantera/include/cantera/core.h" +#include + +using namespace Cantera; + CFluidCantera::CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2double value_pressure_operating, const CConfig* config) : CFluidModel(), diff --git a/meson_options.txt b/meson_options.txt index 51377f37bb71..9ed1a9e8c880 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -20,8 +20,8 @@ option('extra-deps', type : 'string', value : '', description: 'comma-separated option('enable-mpp', type : 'boolean', value : false, description: 'enable Mutation++ support') option('install-mpp', type : 'boolean', value : false, description: 'install Mutation++ in the directory defined with --prefix') option('enable-coolprop', type : 'boolean', value : false, description: 'enable CoolProp support') -option('enable-cantera', type : 'boolean', value : false, description: 'enable Cantera support') -option('install-cantera', type : 'boolean', value : false, description: 'install Cantera in the directory defined with --prefix') +#option('enable-cantera', type : 'boolean', value : false, description: 'enable Cantera support') +#option('install-cantera', type : 'boolean', value : false, description: 'install Cantera in the directory defined with --prefix') option('enable-mlpcpp', type : 'boolean', value : false, description: 'enable profiling through gprof') option('enable-gprof', type : 'boolean', value : false, description: 'enable MLPCpp support') option('opdi-backend', type : 'combo', choices : ['auto', 'macro', 'ompt'], value : 'auto', description: 'OpDiLib backend choice') diff --git a/meson_scripts/init.py b/meson_scripts/init.py index 5d3e2ebc62e4..ad1144e2d9fd 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -47,7 +47,7 @@ def init_submodules( own_opdi=True, own_mpp=True, own_cool=True, - own_cantera=True, + # own_cantera=True, own_mel=True, own_mlpcpp=True, ): @@ -70,8 +70,8 @@ def init_submodules( github_repo_mpp = "https://github.com/mutationpp/Mutationpp" sha_version_coolprop = "bafdea1f39ee873a6bb9833e3a21fe41f90b85e8" github_repo_coolprop = "https://github.com/CoolProp/CoolProp" - sha_version_cantera = "feb64c2e028f4fa2ba9dc938022f5b2a693b5ddc" - github_repo_cantera = "https://github.com/Cantera/cantera" + # sha_version_cantera = "feb64c2e028f4fa2ba9dc938022f5b2a693b5ddc" + # github_repo_cantera = "https://github.com/Cantera/cantera" sha_version_mel = "46205ab019e5224559091375a6d71aabae6bc5b9" github_repo_mel = "https://github.com/pcarruscag/MEL" sha_version_mlpcpp = "c19c53ea2b85ccfb185f1c6c87044dc0b5bc7ae0" @@ -84,7 +84,7 @@ def init_submodules( ninja_name = "ninja" mpp_name = "Mutationpp" coolprop_name = "CoolProp" - cantera_name = "cantera" + # cantera_name = "cantera" mel_name = "MEL" mlpcpp_name = "MLPCpp" @@ -97,7 +97,7 @@ def init_submodules( alt_name_mel = base_path + "mel" alt_name_mpp = cur_dir + os.path.sep + "subprojects" + os.path.sep + "Mutationpp" alt_name_coolprop = cur_dir + os.path.sep + "subprojects" + os.path.sep + "CoolProp" - alt_name_cantera = cur_dir + os.path.sep + "subprojects" + os.path.sep + "cantera" + # alt_name_cantera = cur_dir + os.path.sep + "subprojects" + os.path.sep + "cantera" alt_name_mlpcpp = cur_dir + os.path.sep + "subprojects" + os.path.sep + "MLPCpp" if method == "auto": @@ -126,8 +126,8 @@ def init_submodules( submodule_status(alt_name_mpp, sha_version_mpp) if own_cool: submodule_status(alt_name_coolprop, sha_version_coolprop) - if own_cool: - submodule_status(alt_name_cantera, sha_version_cantera) + # if own_cantera: + # submodule_status(alt_name_cantera, sha_version_cantera) if own_mel: submodule_status(alt_name_mel, sha_version_mel) if own_mlpcpp: @@ -162,13 +162,13 @@ def init_submodules( github_repo_coolprop, sha_version_coolprop, ) - if own_cantera: - download_module( - cantera_name, - alt_name_cantera, - github_repo_cantera, - sha_version_cantera, - ) + # if own_cantera: + # download_module( + # cantera_name, + # alt_name_cantera, + # github_repo_cantera, + # sha_version_cantera, + # ) if own_mel: download_module(mel_name, alt_name_mel, github_repo_mel, sha_version_mel) if own_mlpcpp: diff --git a/preconfigure.py b/preconfigure.py index 46bcafb3df7b..9525b55e1e50 100755 --- a/preconfigure.py +++ b/preconfigure.py @@ -80,7 +80,7 @@ def run( own_opdi=True, own_mpp=True, own_cool=True, - own_cantera=True, + #own_cantera=True, own_mel=True, own_mlpcpp=True, ): @@ -94,7 +94,7 @@ def run( own_opdi=own_opdi, own_mpp=own_mpp, own_cool=own_cool, - own_cantera=own_cantera, + # own_cantera=own_cantera, own_mel=own_mel, own_mlpcpp=own_mlpcpp, ) @@ -136,11 +136,11 @@ def run( help="do not download own copy of CoolProp", action="store_false", ) - parser.add_argument( - "--no-cantera", - help="do not download own copy of Cantera", - action="store_false", - ) + # parser.add_argument( + # "--no-cantera", + # help="do not download own copy of Cantera", + # action="store_false", + # ) parser.add_argument( "--no-mel", help="do not download own copy of MEL", action="store_false" ) @@ -158,7 +158,7 @@ def run( own_opdi=args.no_opdi, own_mpp=args.no_mpp, own_cool=args.no_coolprop, - own_cantera=args.no_cantera, + # own_cantera=args.no_cantera, own_mel=args.no_mel, own_mlpcpp=args.no_mlpcpp, ) From e3671644fa10ed49d166641a21aed1c4caf5a7d7 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 29 Aug 2024 16:40:26 +0200 Subject: [PATCH 007/173] adding meson options --- meson.build | 21 +++++++++++++++++++++ meson_options.txt | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 66dde2dfc9d4..2b92ec7c42ec 100644 --- a/meson.build +++ b/meson.build @@ -291,6 +291,27 @@ if get_option('enable-coolprop') endif endif +if get_option('enable-cantera') + if build_machine.cpu_family() == 'x86' or build_machine.cpu_family() == 'x86_64' + cmake = import('cmake') + cmake_opts = cmake.subproject_options() + # cmake_opts.set_override_option('warning_level', '0') + #cmake_opts.add_cmake_defines({ + # 'COOLPROP_STATIC_LIBRARY': true, + # 'CMAKE_MAKE_PROGRAM': join_paths(meson.project_source_root(), 'ninja'), + # 'CMAKE_POSITION_INDEPENDENT_CODE': 'ON' + #}) + include_directories('subproject/cantera/include') + link_directories('subproject/cantera/include') + cantera_subproj = cmake.subproject('cantera', options: cmake_opts) + cantera_dep = cantera_subproj.dependency('cantera/include/cantera') + su2_deps += cantera_dep + #su2_cpp_args += '-DHAVE_COOLPROP' + else + message('WARNING: CPU is not x86, skipping CoolProp dependency.') + endif +endif + if get_option('enable-mlpcpp') su2_cpp_args += '-DHAVE_MLPCPP' endif diff --git a/meson_options.txt b/meson_options.txt index 9ed1a9e8c880..fcacc93c9e60 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -20,7 +20,7 @@ option('extra-deps', type : 'string', value : '', description: 'comma-separated option('enable-mpp', type : 'boolean', value : false, description: 'enable Mutation++ support') option('install-mpp', type : 'boolean', value : false, description: 'install Mutation++ in the directory defined with --prefix') option('enable-coolprop', type : 'boolean', value : false, description: 'enable CoolProp support') -#option('enable-cantera', type : 'boolean', value : false, description: 'enable Cantera support') +option('enable-cantera', type : 'boolean', value : false, description: 'enable Cantera support') #option('install-cantera', type : 'boolean', value : false, description: 'install Cantera in the directory defined with --prefix') option('enable-mlpcpp', type : 'boolean', value : false, description: 'enable profiling through gprof') option('enable-gprof', type : 'boolean', value : false, description: 'enable MLPCpp support') From 7ee9d9a5ea7f475c406d6704c5b10f54a8feca3e Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 5 Sep 2024 10:11:45 +0200 Subject: [PATCH 008/173] - --- SU2_CFD/src/fluid/CFluidCantera.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 1d99c641646c..0b44f69460d3 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -41,10 +41,12 @@ #include "../../include/fluid/CPolynomialViscosity.hpp" #include "../../include/fluid/CSutherland.hpp" -#include "../../subprojects/cantera/include/cantera/core.h" +// #include +// //#include "../../subprojects/cantera/include/cantera/core.h" +#include #include -using namespace Cantera; +// using namespace Cantera; CFluidCantera::CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2double value_pressure_operating, const CConfig* config) From bebed1cd0d8ca31b87fcc490f6e357b20b06bfde Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 10 Sep 2024 19:12:00 +0200 Subject: [PATCH 009/173] meson additions --- SU2_CFD/src/fluid/CFluidCantera.cpp | 4 ++-- meson.build | 29 +++++++---------------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 0b44f69460d3..106aa00a7dca 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -42,11 +42,11 @@ #include "../../include/fluid/CSutherland.hpp" // #include -// //#include "../../subprojects/cantera/include/cantera/core.h" +#include "/home/cristopher/codes/cantera/include/cantera/core.h" #include #include -// using namespace Cantera; +using namespace Cantera; CFluidCantera::CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2double value_pressure_operating, const CConfig* config) diff --git a/meson.build b/meson.build index 2b92ec7c42ec..fc8fe16be780 100644 --- a/meson.build +++ b/meson.build @@ -5,7 +5,9 @@ project('SU2', 'c', 'cpp', default_options: ['buildtype=release', 'warning_level=0', 'c_std=c99', - 'cpp_std=c++11']) + 'cpp_std=c++17']) +add_global_arguments('-lcantera', language: 'cpp') +#add_global_arguments('-std=c++17', language: 'cpp') fsmod = import('fs') if not fsmod.exists('su2preconfig.timestamp') @@ -290,27 +292,10 @@ if get_option('enable-coolprop') message('WARNING: CPU is not x86, skipping CoolProp dependency.') endif endif - -if get_option('enable-cantera') - if build_machine.cpu_family() == 'x86' or build_machine.cpu_family() == 'x86_64' - cmake = import('cmake') - cmake_opts = cmake.subproject_options() - # cmake_opts.set_override_option('warning_level', '0') - #cmake_opts.add_cmake_defines({ - # 'COOLPROP_STATIC_LIBRARY': true, - # 'CMAKE_MAKE_PROGRAM': join_paths(meson.project_source_root(), 'ninja'), - # 'CMAKE_POSITION_INDEPENDENT_CODE': 'ON' - #}) - include_directories('subproject/cantera/include') - link_directories('subproject/cantera/include') - cantera_subproj = cmake.subproject('cantera', options: cmake_opts) - cantera_dep = cantera_subproj.dependency('cantera/include/cantera') - su2_deps += cantera_dep - #su2_cpp_args += '-DHAVE_COOLPROP' - else - message('WARNING: CPU is not x86, skipping CoolProp dependency.') - endif -endif +cantera_include = include_directories(['/home/cristopher/include']) +cantera_lib = static_library('cantera', include_directories : cantera_include) +cantera_dep = declare_dependency(link_with : cantera_lib,link_args: ['-L/home/cristopher/lib', '-lcantera'], include_directories : cantera_include) +su2_deps += cantera_dep if get_option('enable-mlpcpp') su2_cpp_args += '-DHAVE_MLPCPP' From befefc2a54950f97dc43ef9986393f9c24fdb9e5 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 11 Sep 2024 13:00:36 +0200 Subject: [PATCH 010/173] test --- SU2_CFD/src/fluid/CFluidCantera.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 106aa00a7dca..523d148ce9e8 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -40,6 +40,7 @@ #include "../../include/fluid/CPolynomialConductivityRANS.hpp" #include "../../include/fluid/CPolynomialViscosity.hpp" #include "../../include/fluid/CSutherland.hpp" +#include "../../Common/include/basic_types/ad_structure.hpp" // #include #include "/home/cristopher/codes/cantera/include/cantera/core.h" @@ -47,6 +48,7 @@ #include using namespace Cantera; +using namespace SU2_TYPE; CFluidCantera::CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2double value_pressure_operating, const CConfig* config) @@ -223,6 +225,16 @@ su2double CFluidCantera::ComputeMeanSpecificHeatCp(const su2double* val_scalars) } void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { + auto sol = newSolution("h2o2.yaml"); + auto gas = sol->thermo(); + + // Set the thermodynamic state by specifying T (500 K) P (2 atm) and the mole + // fractions. Note that the mole fractions do not need to sum to 1.0 - they will + // be normalized internally. Also, the values for any unspecified species will be + // set to zero. + gas->setState_TPX(GetValue(Temperature), GetValue(Pressure_Thermodynamic), "H2O:1.0, H2:8.0, AR:1.0"); + + // Print a summary report of the state of the gas. MassToMoleFractions(val_scalars); ComputeGasConstant(); Temperature = val_temperature; From b933eea7f4abdfb803ff17b2b8e3de5abceacfec Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 12 Sep 2024 16:21:49 +0200 Subject: [PATCH 011/173] cleaning .hpp and .cpp --- Common/include/CConfig.hpp | 3 + Common/src/CConfig.cpp | 4 + SU2_CFD/include/fluid/CFluidCantera.hpp | 41 -------- SU2_CFD/src/fluid/CFluidCantera.cpp | 130 ++---------------------- 4 files changed, 14 insertions(+), 164 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 352965419778..27429b2aa627 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -80,6 +80,9 @@ class CConfig { su2double AdjointLimit; /*!< \brief Adjoint variable limit */ string* ConvField; /*!< \brief Field used for convergence check.*/ string FluidName; /*!< \brief name of the applied fluid. */ + string TransportModel; /*!< \brief name transport model used in cantera*/ + string* GasComposition; /*!< \brief gas composition used in cantera*/ + unsigned short n_Gas_Composition; /*!<\brief number of gases in mixture composition for cantera */ string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */ unsigned short nConvField; /*!< \brief Number of fields used to monitor convergence.*/ diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 43f77fc9c527..26aa55189aff 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1184,6 +1184,10 @@ void CConfig::SetConfig_Options() { addEnumOption("FLUID_MODEL", Kind_FluidModel, FluidModel_Map, STANDARD_AIR); /*!\brief FLUID_NAME \n DESCRIPTION: Fluid name \n OPTIONS: see coolprop homepage \n DEFAULT: nitrogen \ingroup Config*/ addStringOption("FLUID_NAME", FluidName, string("nitrogen")); + /*!\brief TRANSPORT_MODEL \n DESCRIPTION: Transport model \n OPTIONS: see cantera homepage \n DEFAULT: mixture-averaged\ingroup Config*/ + addStringOption("TRANSPORT_MODEL", TransportModel, string("mixture_averaged")); + /*!\brief FLUID_NAME \n DESCRIPTION: Fluid name \n OPTIONS: see coolprop homepage \n DEFAULT: nitrogen \ingroup Config*/ + addStringListOption("GAS_COMPOSITION", n_Gas_Composition, GasComposition); /*!\par CONFIG_CATEGORY: Data-driven fluid model parameters \ingroup Config*/ /*!\brief INTERPOLATION_METHOD \n DESCRIPTION: Interpolation method used to determine the thermodynamic state of the fluid. \n OPTIONS: See \link DataDrivenMethod_Map \endlink DEFAULT: MLP \ingroup Config*/ diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 59be096359cf..dcb2b6edab82 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -46,21 +46,12 @@ class CFluidCantera final : public CFluidModel { const su2double GasConstant_Ref; /*!< \brief Gas constant reference needed for Nondimensional problems. */ const su2double Prandtl_Number; /*!< \brief Prandlt number.*/ - const bool wilke; - const bool davidson; - static constexpr int ARRAYSIZE = 16; std::array massFractions; /*!< \brief Mass fractions of all species. */ std::array moleFractions; /*!< \brief Mole fractions of all species. */ std::array molarMasses; /*!< \brief Molar masses of all species. */ - std::array specificHeat; /*!< \brief Specific Heat capacities of all species. */ - std::array laminarViscosity; /*!< \brief Laminar viscosity of all species. */ - std::array laminarThermalConductivity; /*!< \brief Laminar thermal conductivity of all species. */ std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ - - std::unique_ptr LaminarViscosityPointers[ARRAYSIZE]; - std::unique_ptr ThermalConductivityPointers[ARRAYSIZE]; std::unique_ptr MassDiffusivityPointers[ARRAYSIZE]; /*! @@ -69,29 +60,6 @@ class CFluidCantera final : public CFluidModel { */ void MassToMoleFractions(const su2double* val_scalars); - /*! - * \brief Wilke mixing law for mixture viscosity. - * \param[in] val_scalars - Scalar mass fraction. - */ - su2double WilkeViscosity(const su2double* val_scalars); - - /*! - * \brief Davidson mixing law for mixture viscosity. - * \param[in] val_scalars - Scalar mass fraction. - */ - su2double DavidsonViscosity(const su2double* val_scalars); - - /*! - * \brief Wilke mixing law for mixture thermal conductivity. - * \param[in] val_scalars - Scalar mass fraction. - */ - su2double WilkeConductivity(const su2double* val_scalars); - - /*! - * \brief Get fluid mean specific heat capacity at constant pressure. - */ - su2double ComputeMeanSpecificHeatCp(const su2double* val_scalars); - /*! * \brief Compute gas constant for mixture. */ @@ -108,15 +76,6 @@ class CFluidCantera final : public CFluidModel { */ CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2double val_operating_pressure, const CConfig* config); - /*! - * \brief Set viscosity model. - */ - void SetLaminarViscosityModel(const CConfig* config) override; - - /*! - * \brief Set thermal conductivity model. - */ - void SetThermalConductivityModel(const CConfig* config) override; /*! * \brief Set mass diffusivity model. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 523d148ce9e8..3c6093019d39 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -58,35 +58,18 @@ CFluidCantera::CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2do Gamma(config->GetGamma()), Pressure_Thermodynamic(value_pressure_operating), GasConstant_Ref(config->GetGas_Constant_Ref()), - Prandtl_Number(config->GetPrandtl_Turb()), - wilke(config->GetKind_MixingViscosityModel() == MIXINGVISCOSITYMODEL::WILKE), - davidson(config->GetKind_MixingViscosityModel() == MIXINGVISCOSITYMODEL::DAVIDSON) { + Prandtl_Number(config->GetPrandtl_Turb()) { if (n_species_mixture > ARRAYSIZE) { SU2_MPI::Error("Too many species, increase ARRAYSIZE", CURRENT_FUNCTION); } for (int iVar = 0; iVar < n_species_mixture; iVar++) { molarMasses[iVar] = config->GetMolecular_Weight(iVar); - specificHeat[iVar] = config->GetSpecific_Heat_CpND(iVar); } - SetLaminarViscosityModel(config); - SetThermalConductivityModel(config); SetMassDiffusivityModel(config); } -void CFluidCantera::SetLaminarViscosityModel(const CConfig* config) { - for (int iVar = 0; iVar < n_species_mixture; iVar++) { - LaminarViscosityPointers[iVar] = MakeLaminarViscosityModel(config, iVar); - } -} - -void CFluidCantera::SetThermalConductivityModel(const CConfig* config) { - for (int iVar = 0; iVar < n_species_mixture; iVar++) { - ThermalConductivityPointers[iVar] = MakeThermalConductivityModel(config, iVar); - } -} - void CFluidCantera::SetMassDiffusivityModel(const CConfig* config) { for (int iVar = 0; iVar < n_species_mixture; iVar++) { MassDiffusivityPointers[iVar] = MakeMassDiffusivityModel(config, iVar); @@ -119,91 +102,6 @@ void CFluidCantera::MassToMoleFractions(const su2double* val_scalars) { } } -su2double CFluidCantera::WilkeViscosity(const su2double* val_scalars) { - - /* Fill laminarViscosity with n_species_mixture viscosity values. */ - for (int iVar = 0; iVar < n_species_mixture; iVar++) { - LaminarViscosityPointers[iVar]->SetViscosity(Temperature, Density); - laminarViscosity[iVar] = LaminarViscosityPointers[iVar]->GetViscosity(); - } - - su2double viscosityMixture = 0.0; - - for (int i = 0; i < n_species_mixture; i++) { - su2double wilkeDenumerator = 0.0; - for (int j = 0; j < n_species_mixture; j++) { - if (j != i) { - const su2double phi = - pow(1 + sqrt(laminarViscosity[i] / laminarViscosity[j]) * pow(molarMasses[j] / molarMasses[i], 0.25), 2) / - sqrt(8 * (1 + molarMasses[i] / molarMasses[j])); - wilkeDenumerator += moleFractions[j] * phi; - } else { - wilkeDenumerator += moleFractions[j]; - } - } - const su2double wilkeNumerator = moleFractions[i] * laminarViscosity[i]; - viscosityMixture += wilkeNumerator / wilkeDenumerator; - } - return viscosityMixture; -} - -su2double CFluidCantera::DavidsonViscosity(const su2double* val_scalars) { - const su2double A = 0.375; - - for (int iVar = 0; iVar < n_species_mixture; iVar++) { - LaminarViscosityPointers[iVar]->SetViscosity(Temperature, Density); - laminarViscosity[iVar] = LaminarViscosityPointers[iVar]->GetViscosity(); - } - - su2double mixtureFractionDenumerator = 0.0; - for (int i = 0; i < n_species_mixture; i++) { - mixtureFractionDenumerator += moleFractions[i] * sqrt(molarMasses[i]); - } - - std::array mixtureFractions; - for (int j = 0; j < n_species_mixture; j++) { - mixtureFractions[j] = (moleFractions[j] * sqrt(molarMasses[j])) / mixtureFractionDenumerator; - } - - su2double fluidity = 0.0; - for (int i = 0; i < n_species_mixture; i++) { - for (int j = 0; j < n_species_mixture; j++) { - const su2double E = (2 * sqrt(molarMasses[i]) * sqrt(molarMasses[j])) / (molarMasses[i] + molarMasses[j]); - fluidity += - ((mixtureFractions[i] * mixtureFractions[j]) / (sqrt(laminarViscosity[i]) * sqrt(laminarViscosity[j]))) * - pow(E, A); - } - } - return 1.0 / fluidity; -} - -su2double CFluidCantera::WilkeConductivity(const su2double* val_scalars) { - - for (int iVar = 0; iVar < n_species_mixture; iVar++) { - ThermalConductivityPointers[iVar]->SetConductivity(Temperature, Density, Mu, 0.0, 0.0, 0.0, 0.0); - laminarThermalConductivity[iVar] = ThermalConductivityPointers[iVar]->GetConductivity(); - } - - su2double conductivityMixture = 0.0; - - for (int i = 0; i < n_species_mixture; i++) { - su2double wilkeDenumerator = 0.0; - for (int j = 0; j < n_species_mixture; j++) { - if (j != i) { - const su2double phi = - pow(1 + sqrt(laminarViscosity[i] / laminarViscosity[j]) * pow(molarMasses[j] / molarMasses[i], 0.25), 2) / - sqrt(8 * (1 + molarMasses[i] / molarMasses[j])); - wilkeDenumerator += moleFractions[j] * phi; - } else { - wilkeDenumerator += moleFractions[j]; - } - } - const su2double wilkeNumerator = moleFractions[i] * laminarThermalConductivity[i]; - conductivityMixture += wilkeNumerator / wilkeDenumerator; - } - return conductivityMixture; -} - su2double CFluidCantera::ComputeGasConstant() { su2double MeanMolecularWeight = 0.0; @@ -215,17 +113,8 @@ su2double CFluidCantera::ComputeGasConstant() { return Gas_Constant; } -su2double CFluidCantera::ComputeMeanSpecificHeatCp(const su2double* val_scalars) { - su2double mean_cp = 0.0; - - for (int i_scalar = 0; i_scalar < n_species_mixture; i_scalar++) { - mean_cp += specificHeat[i_scalar] * massFractions[i_scalar]; - } - return mean_cp; -} - void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { - auto sol = newSolution("h2o2.yaml"); + auto sol = newSolution("h2o2.yaml", "h2o2", "mixture-averaged"); auto gas = sol->thermo(); // Set the thermodynamic state by specifying T (500 K) P (2 atm) and the mole @@ -238,16 +127,11 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl MassToMoleFractions(val_scalars); ComputeGasConstant(); Temperature = val_temperature; - Density = Pressure_Thermodynamic / (Temperature * Gas_Constant); - Cp = ComputeMeanSpecificHeatCp(val_scalars); - Cv = Cp - Gas_Constant; - - if (wilke) { - Mu = WilkeViscosity(val_scalars); - } else if (davidson) { - Mu = DavidsonViscosity(val_scalars); - } + Density = gas->density(); + Cp = gas->cp_mass(); + Cv = gas->cv_mass(); + Mu = sol->transport()->viscosity(); + Kt = sol->transport()->thermalConductivity(); - Kt = WilkeConductivity(val_scalars); ComputeMassDiffusivity(); } \ No newline at end of file From b9d1af6bbf5df0b4e8171e766fe9fc27ba8c0c78 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 13 Sep 2024 16:44:35 +0200 Subject: [PATCH 012/173] cleaning and adding config options --- Common/include/CConfig.hpp | 11 +++++++++++ Common/src/CConfig.cpp | 4 +++- SU2_CFD/include/fluid/CFluidCantera.hpp | 3 ++- SU2_CFD/src/fluid/CFluidCantera.cpp | 17 ++++------------- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 27429b2aa627..9d698f1b7aa2 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -82,6 +82,7 @@ class CConfig { string FluidName; /*!< \brief name of the applied fluid. */ string TransportModel; /*!< \brief name transport model used in cantera*/ string* GasComposition; /*!< \brief gas composition used in cantera*/ + string ChemicalMechanism; /*!< \brief Chemical Reaction mechanism used in cantera*/ unsigned short n_Gas_Composition; /*!<\brief number of gases in mixture composition for cantera */ string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */ @@ -3968,6 +3969,16 @@ class CConfig { */ string GetFluid_Name(void) const { return FluidName; } + /*! + * \brief Returns the transport model used in Cantera. + */ + string GetTransport_Model(void) const { return TransportModel; } + + /*! + * \brief Returns the transport model used in Cantera. + */ + string GetChemical_Mechanism(void) const { return ChemicalMechanism; } + /*! * \brief Option to define the density model for incompressible flows. * \return Density model option diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 26aa55189aff..d53d049ad2b3 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1186,7 +1186,9 @@ void CConfig::SetConfig_Options() { addStringOption("FLUID_NAME", FluidName, string("nitrogen")); /*!\brief TRANSPORT_MODEL \n DESCRIPTION: Transport model \n OPTIONS: see cantera homepage \n DEFAULT: mixture-averaged\ingroup Config*/ addStringOption("TRANSPORT_MODEL", TransportModel, string("mixture_averaged")); - /*!\brief FLUID_NAME \n DESCRIPTION: Fluid name \n OPTIONS: see coolprop homepage \n DEFAULT: nitrogen \ingroup Config*/ + /*!\brief TRANSPORT_MODEL \n DESCRIPTION: Chemical reaction mechanism \n OPTIONS: see cantera homepage \n DEFAULT: gri30.yaml \ingroup Config*/ + addStringOption("CHEMICAL_MECHANISM", ChemicalMechanism, string("gri30.yaml")); + /*!\brief GAS_COMPOSITION \n DESCRIPTION: Gas composition \n OPTIONS: see cantera homepage \n DEFAULT: \ingroup Config*/ addStringListOption("GAS_COMPOSITION", n_Gas_Composition, GasComposition); /*!\par CONFIG_CATEGORY: Data-driven fluid model parameters \ingroup Config*/ diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index dcb2b6edab82..eee261490f57 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -41,10 +41,11 @@ class CFluidCantera final : public CFluidModel { private: const int n_species_mixture; /*!< \brief Number of species in mixture. */ su2double Gas_Constant; /*!< \brief Specific gas constant. */ - const su2double Gamma; /*!< \brief Ratio of specific heats of the gas. */ const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */ const su2double GasConstant_Ref; /*!< \brief Gas constant reference needed for Nondimensional problems. */ const su2double Prandtl_Number; /*!< \brief Prandlt number.*/ + const string Transport_Model; /*!< \brief Transport model used for computing mixture properties*/ + const string Chemical_Mechanism; /*!< \brief Chemical reaction mechanism used for in cantera*/ static constexpr int ARRAYSIZE = 16; diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 3c6093019d39..7dc9649518f8 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -31,18 +31,8 @@ #include -#include "../../include/fluid/CConstantConductivity.hpp" -#include "../../include/fluid/CConstantConductivityRANS.hpp" -#include "../../include/fluid/CConstantPrandtl.hpp" -#include "../../include/fluid/CConstantPrandtlRANS.hpp" -#include "../../include/fluid/CConstantViscosity.hpp" -#include "../../include/fluid/CPolynomialConductivity.hpp" -#include "../../include/fluid/CPolynomialConductivityRANS.hpp" -#include "../../include/fluid/CPolynomialViscosity.hpp" -#include "../../include/fluid/CSutherland.hpp" #include "../../Common/include/basic_types/ad_structure.hpp" -// #include #include "/home/cristopher/codes/cantera/include/cantera/core.h" #include #include @@ -55,10 +45,11 @@ CFluidCantera::CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2do : CFluidModel(), n_species_mixture(config->GetnSpecies() + 1), Gas_Constant(val_gas_constant), - Gamma(config->GetGamma()), Pressure_Thermodynamic(value_pressure_operating), GasConstant_Ref(config->GetGas_Constant_Ref()), - Prandtl_Number(config->GetPrandtl_Turb()) { + Prandtl_Number(config->GetPrandtl_Turb()), + Transport_Model(config->GetTransport_Model()), + Chemical_Mechanism(config->GetChemical_Mechanism()) { if (n_species_mixture > ARRAYSIZE) { SU2_MPI::Error("Too many species, increase ARRAYSIZE", CURRENT_FUNCTION); } @@ -114,7 +105,7 @@ su2double CFluidCantera::ComputeGasConstant() { } void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { - auto sol = newSolution("h2o2.yaml", "h2o2", "mixture-averaged"); + auto sol = newSolution(Chemical_Mechanism, "h2o2", Transport_Model); auto gas = sol->thermo(); // Set the thermodynamic state by specifying T (500 K) P (2 atm) and the mole From f66ec49343016a8c052c809a450e0adf8b36b459 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 13 Sep 2024 18:59:05 +0200 Subject: [PATCH 013/173] adding dictionary and comfig options --- Common/include/CConfig.hpp | 5 +++++ SU2_CFD/include/fluid/CFluidCantera.hpp | 8 ++++++++ SU2_CFD/src/fluid/CFluidCantera.cpp | 24 +++++++++++++++++------- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 9d698f1b7aa2..440cab4e8fa9 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -3979,6 +3979,11 @@ class CConfig { */ string GetChemical_Mechanism(void) const { return ChemicalMechanism; } + /*! + * \brief Returns the gas composition used in Cantera. + */ + string GetChemical_GasComposition(unsigned short val_index = 0) const { return GasComposition[val_index]; } + /*! * \brief Option to define the density model for incompressible flows. * \return Density model option diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index eee261490f57..5712a8fda4d0 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -41,6 +41,7 @@ class CFluidCantera final : public CFluidModel { private: const int n_species_mixture; /*!< \brief Number of species in mixture. */ su2double Gas_Constant; /*!< \brief Specific gas constant. */ + string chemical_composition; /*!< \brief Dictionary chemical composition. */ const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */ const su2double GasConstant_Ref; /*!< \brief Gas constant reference needed for Nondimensional problems. */ const su2double Prandtl_Number; /*!< \brief Prandlt number.*/ @@ -49,6 +50,7 @@ class CFluidCantera final : public CFluidModel { static constexpr int ARRAYSIZE = 16; + std::array gasComposition; /*!< \brief Gas composition. */ std::array massFractions; /*!< \brief Mass fractions of all species. */ std::array moleFractions; /*!< \brief Mole fractions of all species. */ std::array molarMasses; /*!< \brief Molar masses of all species. */ @@ -61,6 +63,12 @@ class CFluidCantera final : public CFluidModel { */ void MassToMoleFractions(const su2double* val_scalars); + /*! + * \brief Return a string(dictionary) with chemical species and its mass fraction value. + * \param[in] val_scalars - Scalar mass fraction. + */ + string DictionaryChemicalComposition(const su2double* val_scalars); + /*! * \brief Compute gas constant for mixture. */ diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 7dc9649518f8..662be65437ef 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -56,6 +56,7 @@ CFluidCantera::CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2do for (int iVar = 0; iVar < n_species_mixture; iVar++) { molarMasses[iVar] = config->GetMolecular_Weight(iVar); + gasComposition[iVar]=config->GetChemical_GasComposition(iVar); } SetMassDiffusivityModel(config); @@ -104,20 +105,29 @@ su2double CFluidCantera::ComputeGasConstant() { return Gas_Constant; } +string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars) { + su2double val_scalars_sum{0.0}; + for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { + chemical_composition.append(gasComposition[i_scalar] + ":" + to_string(val_scalars[i_scalar])); + val_scalars_sum += val_scalars[i_scalar]; + } + chemical_composition.append(gasComposition[n_species_mixture - 1] + ":" + to_string(1.0 - val_scalars_sum)); + + return chemical_composition; +} + void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { auto sol = newSolution(Chemical_Mechanism, "h2o2", Transport_Model); auto gas = sol->thermo(); - + MassToMoleFractions(val_scalars); + ComputeGasConstant(); + DictionaryChemicalComposition(val_scalars); + Temperature = val_temperature; // Set the thermodynamic state by specifying T (500 K) P (2 atm) and the mole // fractions. Note that the mole fractions do not need to sum to 1.0 - they will // be normalized internally. Also, the values for any unspecified species will be // set to zero. - gas->setState_TPX(GetValue(Temperature), GetValue(Pressure_Thermodynamic), "H2O:1.0, H2:8.0, AR:1.0"); - - // Print a summary report of the state of the gas. - MassToMoleFractions(val_scalars); - ComputeGasConstant(); - Temperature = val_temperature; + gas->setState_TPX(GetValue(Temperature), GetValue(Pressure_Thermodynamic), chemical_composition); Density = gas->density(); Cp = gas->cp_mass(); Cv = gas->cv_mass(); From 3c211faea4143af65eec2d320ee70a4ff0e6a1da Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 13 Sep 2024 19:38:29 +0200 Subject: [PATCH 014/173] fixing small error --- SU2_CFD/src/fluid/CFluidCantera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 662be65437ef..23eec8cbfabf 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -127,7 +127,7 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl // fractions. Note that the mole fractions do not need to sum to 1.0 - they will // be normalized internally. Also, the values for any unspecified species will be // set to zero. - gas->setState_TPX(GetValue(Temperature), GetValue(Pressure_Thermodynamic), chemical_composition); + gas->setState_TPY(GetValue(Temperature), GetValue(Pressure_Thermodynamic), chemical_composition); Density = gas->density(); Cp = gas->cp_mass(); Cv = gas->cv_mass(); From 8f62eb12a174819dc7b2932056524453fbbdb675 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 13 Sep 2024 20:01:01 +0200 Subject: [PATCH 015/173] string fix --- SU2_CFD/src/fluid/CFluidCantera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 23eec8cbfabf..4b83a8c0ce37 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -108,7 +108,7 @@ su2double CFluidCantera::ComputeGasConstant() { string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars) { su2double val_scalars_sum{0.0}; for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { - chemical_composition.append(gasComposition[i_scalar] + ":" + to_string(val_scalars[i_scalar])); + chemical_composition.append(gasComposition[i_scalar] + ":" + to_string(val_scalars[i_scalar])+", "); val_scalars_sum += val_scalars[i_scalar]; } chemical_composition.append(gasComposition[n_species_mixture - 1] + ":" + to_string(1.0 - val_scalars_sum)); From 58dce22735b682bca2e411905e32318f81ee90af Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 16 Sep 2024 17:41:30 +0200 Subject: [PATCH 016/173] enable meson options and adding viscosity-conductivity cantera models --- .github/workflows/regression.yml | 2 +- Common/include/option_structure.hpp | 8 +++++-- SU2_CFD/include/fluid/CFluidCantera.hpp | 15 ++++++++++--- SU2_CFD/src/fluid/CFluidCantera.cpp | 9 ++++++-- SU2_CFD/src/fluid/CFluidModel.cpp | 6 +++++ .../cht/CConjugateHeatInterface.cpp | 1 + SU2_CFD/src/output/CFlowOutput.cpp | 13 +++++++++++ SU2_CFD/src/solvers/CIncEulerSolver.cpp | 22 ++++++++++++++++--- UnitTests/meson.build | 1 + meson.build | 5 +++++ meson_scripts/init.py | 2 +- preconfigure.py | 16 +++++++------- 12 files changed, 80 insertions(+), 20 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 6b76ced5a7a6..5f1debbe6386 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -27,7 +27,7 @@ jobs: include: - config_set: BaseMPI flags: '-Denable-pywrapper=true -Denable-coolprop=true -Denable-mpp=true -Dinstall-mpp=true -Denable-mlpcpp=true -Denable-tests=true --warnlevel=2' - # flags: '-Denable-pywrapper=true -Denable-coolprop=true -Denable-cantera=true -Denable-mpp=true -Dinstall-mpp=true -Denable-mlpcpp=true -Denable-tests=true --warnlevel=2' + # flags: '-Denable-pywrapper=true -Denable-coolprop=true -Denable-cantera=true -Denable-mpp=true -Dinstall-mpp=true -Denable-mlpcpp=true -Denable-tests=true --warnlevel=2' - config_set: ReverseMPI flags: '-Denable-autodiff=true -Denable-normal=false -Denable-pywrapper=true -Denable-tests=true --warnlevel=3 --werror' - config_set: ForwardMPI diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index b8a927dc2ead..8467ce6e8a5e 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -550,7 +550,7 @@ enum ENUM_FLUIDMODEL { COOLPROP = 10, /*!< \brief Thermodynamics library. */ FLUID_FLAMELET = 11, /*!< \brief lookup table (LUT) method for premixed flamelets. */ DATADRIVEN_FLUID = 12, /*!< \brief multi-layer perceptron driven fluid model. */ - CANTERA = 13, /*!< \brief Reacting flows model. */ + FLUID_CANTERA = 13, /*!< \brief Reacting flows model. */ }; static const MapType FluidModel_Map = { MakePair("STANDARD_AIR", STANDARD_AIR) @@ -566,7 +566,7 @@ static const MapType FluidModel_Map = { MakePair("COOLPROP", COOLPROP) MakePair("DATADRIVEN_FLUID", DATADRIVEN_FLUID) MakePair("FLUID_FLAMELET", FLUID_FLAMELET) - MakePair("CANTERA", CANTERA) + MakePair("FLUID_CANTERA", FLUID_CANTERA) }; /*! @@ -673,6 +673,7 @@ enum class VISCOSITYMODEL { POLYNOMIAL, /*!< \brief Polynomial viscosity. */ FLAMELET, /*!< \brief LUT method for flamelets */ COOLPROP, /*!< \brief CoolProp viscosity. */ + CANTERA, /*!< \brief Cantera viscosity. */ }; static const MapType ViscosityModel_Map = { MakePair("CONSTANT_VISCOSITY", VISCOSITYMODEL::CONSTANT) @@ -680,6 +681,7 @@ static const MapType ViscosityModel_Map = { MakePair("POLYNOMIAL_VISCOSITY", VISCOSITYMODEL::POLYNOMIAL) MakePair("FLAMELET", VISCOSITYMODEL::FLAMELET) MakePair("COOLPROP", VISCOSITYMODEL::COOLPROP) + MakePair("CANTERA", VISCOSITYMODEL::CANTERA) }; /*! @@ -703,6 +705,7 @@ enum class CONDUCTIVITYMODEL { POLYNOMIAL, /*!< \brief Polynomial thermal conductivity. */ FLAMELET, /*!< \brief LUT method for flamelets */ COOLPROP, /*!< \brief COOLPROP thermal conductivity. */ + CANTERA, /*!< \brief COOLPROP thermal conductivity. */ }; static const MapType ConductivityModel_Map = { MakePair("CONSTANT_CONDUCTIVITY", CONDUCTIVITYMODEL::CONSTANT) @@ -710,6 +713,7 @@ static const MapType ConductivityModel_Map = { MakePair("POLYNOMIAL_CONDUCTIVITY", CONDUCTIVITYMODEL::POLYNOMIAL) MakePair("FLAMELET", CONDUCTIVITYMODEL::FLAMELET) MakePair("COOLPROP", CONDUCTIVITYMODEL::COOLPROP) + MakePair("CANTERA", CONDUCTIVITYMODEL::CANTERA) }; /*! diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 5712a8fda4d0..edc41f08b150 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -32,6 +32,11 @@ #include "CFluidModel.hpp" +#if defined(HAVE_CANTERA) +#define USE_CANTERA +#endif + + /*! * \class CFluidCantera * \brief Child class for defining reacting incompressible ideal gas mixture model. @@ -41,16 +46,17 @@ class CFluidCantera final : public CFluidModel { private: const int n_species_mixture; /*!< \brief Number of species in mixture. */ su2double Gas_Constant; /*!< \brief Specific gas constant. */ - string chemical_composition; /*!< \brief Dictionary chemical composition. */ const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */ const su2double GasConstant_Ref; /*!< \brief Gas constant reference needed for Nondimensional problems. */ const su2double Prandtl_Number; /*!< \brief Prandlt number.*/ + string chemical_composition; /*!< \brief Dictionary chemical composition. */ const string Transport_Model; /*!< \brief Transport model used for computing mixture properties*/ const string Chemical_Mechanism; /*!< \brief Chemical reaction mechanism used for in cantera*/ static constexpr int ARRAYSIZE = 16; - + #ifdef USE_CANTERA std::array gasComposition; /*!< \brief Gas composition. */ + #endif std::array massFractions; /*!< \brief Mass fractions of all species. */ std::array moleFractions; /*!< \brief Mole fractions of all species. */ std::array molarMasses; /*!< \brief Molar masses of all species. */ @@ -62,12 +68,13 @@ class CFluidCantera final : public CFluidModel { * \param[in] val_scalars - Scalar mass fraction. */ void MassToMoleFractions(const su2double* val_scalars); - + #ifdef USE_CANTERA /*! * \brief Return a string(dictionary) with chemical species and its mass fraction value. * \param[in] val_scalars - Scalar mass fraction. */ string DictionaryChemicalComposition(const su2double* val_scalars); + #endif /*! * \brief Compute gas constant for mixture. @@ -106,9 +113,11 @@ class CFluidCantera final : public CFluidModel { */ inline su2double GetMassDiffusivity(int ivar) override { return massDiffusivity[ivar]; } + #ifdef USE_CANTERA /*! * \brief Set the Dimensionless State using Temperature. * \param[in] t - Temperature value at the point. */ void SetTDState_T(su2double val_temperature, const su2double* val_scalars) override; + #endif }; \ No newline at end of file diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 4b83a8c0ce37..ce11fdf40052 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -30,7 +30,7 @@ #include #include - +#ifdef USE_CANTERA #include "../../Common/include/basic_types/ad_structure.hpp" #include "/home/cristopher/codes/cantera/include/cantera/core.h" @@ -39,6 +39,7 @@ using namespace Cantera; using namespace SU2_TYPE; +#endif CFluidCantera::CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2double value_pressure_operating, const CConfig* config) @@ -56,7 +57,9 @@ CFluidCantera::CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2do for (int iVar = 0; iVar < n_species_mixture; iVar++) { molarMasses[iVar] = config->GetMolecular_Weight(iVar); + #ifdef USE_CANTERA gasComposition[iVar]=config->GetChemical_GasComposition(iVar); + #endif } SetMassDiffusivityModel(config); @@ -105,6 +108,7 @@ su2double CFluidCantera::ComputeGasConstant() { return Gas_Constant; } +#ifdef USE_CANTERA string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars) { su2double val_scalars_sum{0.0}; for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { @@ -135,4 +139,5 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl Kt = sol->transport()->thermalConductivity(); ComputeMassDiffusivity(); -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/SU2_CFD/src/fluid/CFluidModel.cpp b/SU2_CFD/src/fluid/CFluidModel.cpp index ea9d7f33e1f7..c59fca8c9c57 100644 --- a/SU2_CFD/src/fluid/CFluidModel.cpp +++ b/SU2_CFD/src/fluid/CFluidModel.cpp @@ -63,6 +63,9 @@ unique_ptr CFluidModel::MakeLaminarViscosityModel(const CConfig case VISCOSITYMODEL::FLAMELET: /*--- Viscosity is obtained from the LUT ---*/ return nullptr; + case VISCOSITYMODEL::CANTERA: + /*--- Viscosity is obtained from the Cantera library---*/ + return nullptr; default: SU2_MPI::Error("Viscosity model not available.", CURRENT_FUNCTION); return nullptr; @@ -116,6 +119,9 @@ unique_ptr CFluidModel::MakeThermalConductivityModel(const C case CONDUCTIVITYMODEL::FLAMELET: /*--- Conductivity is obtained from the LUT ---*/ return nullptr; + case CONDUCTIVITYMODEL::CANTERA: + /*--- Conductivity is obtained from Cantera library---*/ + return nullptr; default: SU2_MPI::Error("Conductivity model not available.", CURRENT_FUNCTION); return nullptr; diff --git a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp index 908ea27ae7ff..e983113e3a40 100644 --- a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp +++ b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp @@ -106,6 +106,7 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet case CONDUCTIVITYMODEL::CONSTANT: case CONDUCTIVITYMODEL::FLAMELET: + case CONDUCTIVITYMODEL::CANTERA: case CONDUCTIVITYMODEL::COOLPROP: thermal_conductivity = thermal_conductivityND*donor_config->GetThermal_Conductivity_Ref(); break; diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 5ffee0d23f54..d23e139a0895 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -3157,6 +3157,13 @@ void CFlowOutput::WriteForcesBreakdown(const CConfig* config, const CSolver* flo case VISCOSITYMODEL::COOLPROP: file << "Viscosity Model: CoolProp \n"; break; + + case VISCOSITYMODEL::CANTERA: + file << "Viscosity Model: CANTERA \n"; + if (si_units) file << " N.s/m^2.\n"; + else file << " lbf.s/ft^2.\n"; + file << "Laminar Viscosity (non-dim): " << config->GetMu_ConstantND() << "\n"; + break; case VISCOSITYMODEL::SUTHERLAND: file << "Viscosity Model: SUTHERLAND \n"; @@ -3212,6 +3219,12 @@ void CFlowOutput::WriteForcesBreakdown(const CConfig* config, const CSolver* flo file << "Molecular Conductivity units: " << " W/m^2.K.\n"; file << "Molecular Conductivity (non-dim): " << config->GetThermal_Conductivity_ConstantND() << "\n"; break; + + case CONDUCTIVITYMODEL::CANTERA: + file << "Conductivity Model: CANTERA \n"; + file << "Molecular Conductivity units: " << " W/m^2.K.\n"; + file << "Molecular Conductivity (non-dim): " << config->GetThermal_Conductivity_ConstantND() << "\n"; + break; case CONDUCTIVITYMODEL::POLYNOMIAL: file << "Viscosity Model: POLYNOMIAL \n"; diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index a26f7a5782e5..4ce3094c9a3c 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -339,7 +339,7 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i auxFluidModel->SetTDState_T(Temperature_FreeStream, config->GetSpecies_Init()); break; - case CANTERA: + case FLUID_CANTERA: config->SetGas_Constant(UNIVERSAL_GAS_CONSTANT / (config->GetMolecular_Weight() / 1000.0)); Pressure_Thermodynamic = config->GetPressure_Thermodynamic(); @@ -501,7 +501,7 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i fluidModel->SetTDState_T(Temperature_FreeStreamND, config->GetSpecies_Init()); break; - case CANTERA: + case FLUID_CANTERA: fluidModel = new CFluidCantera(Specific_Heat_CpND, Gas_ConstantND, Pressure_ThermodynamicND, config); fluidModel->SetTDState_T(Temperature_FreeStreamND, config->GetSpecies_Init()); break; @@ -673,6 +673,15 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i Unit.str(""); NonDimTable.PrintFooter(); break; + + case VISCOSITYMODEL::CANTERA: + ModelTable << "CANTERA"; + if (config->GetSystemMeasurements() == SI) Unit << "N.s/m^2"; + else if (config->GetSystemMeasurements() == US) Unit << "lbf.s/ft^2"; + NonDimTable << "Viscosity" << "--" << "--" << Unit.str() << config->GetMu_ConstantND(); + Unit.str(""); + NonDimTable.PrintFooter(); + break; case VISCOSITYMODEL::SUTHERLAND: ModelTable << "SUTHERLAND"; @@ -736,6 +745,13 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i Unit.str(""); NonDimTable.PrintFooter(); break; + + case CONDUCTIVITYMODEL::CANTERA: + ModelTable << "CANTERA"; + Unit << "W/m^2.K"; + NonDimTable << "Molecular Cond." << "--" << "--" << Unit.str() << config->GetThermal_Conductivity_ConstantND(); + Unit.str(""); + break; case CONDUCTIVITYMODEL::POLYNOMIAL: ModelTable << "POLYNOMIAL"; @@ -823,7 +839,7 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i NonDimTable.PrintFooter(); break; - case CANTERA: + case FLUID_CANTERA: ModelTable << "CANTERA"; Unit << "N.m/kg.K"; NonDimTable << "Spec. Heat (Cp)" << config->GetSpecific_Heat_Cp() << config->GetSpecific_Heat_Cp() / config->GetSpecific_Heat_CpND() << Unit.str() << config->GetSpecific_Heat_CpND(); diff --git a/UnitTests/meson.build b/UnitTests/meson.build index 1c806b67ca43..add06584b9d2 100644 --- a/UnitTests/meson.build +++ b/UnitTests/meson.build @@ -12,6 +12,7 @@ su2_cfd_tests = files(['Common/geometry/primal_grid/CPrimalGrid_tests.cpp', 'Common/vectorization.cpp', 'Common/toolboxes/ndflattener_tests.cpp', 'Common/containers/CLookupTable_tests.cpp', + #'Common/CFluidCantera_Test.cpp', 'Common/toolboxes/multilayer_perceptron/CLookUp_ANN_tests.cpp', 'SU2_CFD/numerics/CNumerics_tests.cpp', 'SU2_CFD/gradients.cpp', diff --git a/meson.build b/meson.build index fc8fe16be780..a77cc9ad0554 100644 --- a/meson.build +++ b/meson.build @@ -292,6 +292,11 @@ if get_option('enable-coolprop') message('WARNING: CPU is not x86, skipping CoolProp dependency.') endif endif + +if get_option('enable-cantera') + su2_cpp_args +='-DHAVE_CANTERA' +endif + cantera_include = include_directories(['/home/cristopher/include']) cantera_lib = static_library('cantera', include_directories : cantera_include) cantera_dep = declare_dependency(link_with : cantera_lib,link_args: ['-L/home/cristopher/lib', '-lcantera'], include_directories : cantera_include) diff --git a/meson_scripts/init.py b/meson_scripts/init.py index ad1144e2d9fd..7c401f412456 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -47,7 +47,7 @@ def init_submodules( own_opdi=True, own_mpp=True, own_cool=True, - # own_cantera=True, + own_cantera=True, own_mel=True, own_mlpcpp=True, ): diff --git a/preconfigure.py b/preconfigure.py index 9525b55e1e50..46bcafb3df7b 100755 --- a/preconfigure.py +++ b/preconfigure.py @@ -80,7 +80,7 @@ def run( own_opdi=True, own_mpp=True, own_cool=True, - #own_cantera=True, + own_cantera=True, own_mel=True, own_mlpcpp=True, ): @@ -94,7 +94,7 @@ def run( own_opdi=own_opdi, own_mpp=own_mpp, own_cool=own_cool, - # own_cantera=own_cantera, + own_cantera=own_cantera, own_mel=own_mel, own_mlpcpp=own_mlpcpp, ) @@ -136,11 +136,11 @@ def run( help="do not download own copy of CoolProp", action="store_false", ) - # parser.add_argument( - # "--no-cantera", - # help="do not download own copy of Cantera", - # action="store_false", - # ) + parser.add_argument( + "--no-cantera", + help="do not download own copy of Cantera", + action="store_false", + ) parser.add_argument( "--no-mel", help="do not download own copy of MEL", action="store_false" ) @@ -158,7 +158,7 @@ def run( own_opdi=args.no_opdi, own_mpp=args.no_mpp, own_cool=args.no_coolprop, - # own_cantera=args.no_cantera, + own_cantera=args.no_cantera, own_mel=args.no_mel, own_mlpcpp=args.no_mlpcpp, ) From 0ac602112fb0b1ebc54e3a5f23cb9596afea5b7a Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 17 Sep 2024 16:45:22 +0200 Subject: [PATCH 017/173] adding phase name --- Common/include/CConfig.hpp | 12 +++++++++--- Common/src/CConfig.cpp | 6 ++++-- SU2_CFD/include/fluid/CFluidCantera.hpp | 3 ++- SU2_CFD/src/fluid/CFluidCantera.cpp | 5 +++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 440cab4e8fa9..48e574c7b219 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -82,7 +82,8 @@ class CConfig { string FluidName; /*!< \brief name of the applied fluid. */ string TransportModel; /*!< \brief name transport model used in cantera*/ string* GasComposition; /*!< \brief gas composition used in cantera*/ - string ChemicalMechanism; /*!< \brief Chemical Reaction mechanism used in cantera*/ + string ChemicalMechanismFile; /*!< \brief Chemical Reaction mechanism used in cantera*/ + string PhaseName; /*!< \brief Name of the phase in the chemical mechanism file used in cantera*/ unsigned short n_Gas_Composition; /*!<\brief number of gases in mixture composition for cantera */ string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */ @@ -3975,9 +3976,14 @@ class CConfig { string GetTransport_Model(void) const { return TransportModel; } /*! - * \brief Returns the transport model used in Cantera. + * \brief Returns the chemical reaction mechanism (mechanism.yaml) used in Cantera. + */ + string GetChemical_MechanismFile(void) const { return ChemicalMechanismFile; } + + /*! + * \brief Returns the name of the pase in the chemical reaction mechanism file used in Cantera. */ - string GetChemical_Mechanism(void) const { return ChemicalMechanism; } + string GetPhase_Name(void) const { return PhaseName; } /*! * \brief Returns the gas composition used in Cantera. diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index d53d049ad2b3..264d074de6c2 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1186,8 +1186,10 @@ void CConfig::SetConfig_Options() { addStringOption("FLUID_NAME", FluidName, string("nitrogen")); /*!\brief TRANSPORT_MODEL \n DESCRIPTION: Transport model \n OPTIONS: see cantera homepage \n DEFAULT: mixture-averaged\ingroup Config*/ addStringOption("TRANSPORT_MODEL", TransportModel, string("mixture_averaged")); - /*!\brief TRANSPORT_MODEL \n DESCRIPTION: Chemical reaction mechanism \n OPTIONS: see cantera homepage \n DEFAULT: gri30.yaml \ingroup Config*/ - addStringOption("CHEMICAL_MECHANISM", ChemicalMechanism, string("gri30.yaml")); + /*!\brief CHEMICAL_MECHANISM_FILE \n DESCRIPTION: Chemical reaction mechanism \n OPTIONS: see cantera homepage \n DEFAULT: gri30.yaml \ingroup Config*/ + addStringOption("CHEMICAL_MECHANISM_FILE", ChemicalMechanismFile, string("gri30.yaml")); + /*!\brief PHASE_NAME\n DESCRIPTION: name of the phase in the chemical mechanism file \n OPTIONS: see cantera homepage \n DEFAULT: gri30 \ingroup Config*/ + addStringOption("PHASE_NAME", PhaseName, string("gri30")); /*!\brief GAS_COMPOSITION \n DESCRIPTION: Gas composition \n OPTIONS: see cantera homepage \n DEFAULT: \ingroup Config*/ addStringListOption("GAS_COMPOSITION", n_Gas_Composition, GasComposition); diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index edc41f08b150..b4586834adeb 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -51,7 +51,8 @@ class CFluidCantera final : public CFluidModel { const su2double Prandtl_Number; /*!< \brief Prandlt number.*/ string chemical_composition; /*!< \brief Dictionary chemical composition. */ const string Transport_Model; /*!< \brief Transport model used for computing mixture properties*/ - const string Chemical_Mechanism; /*!< \brief Chemical reaction mechanism used for in cantera*/ + const string Chemical_MechanismFile; /*!< \brief Chemical reaction mechanism used for in cantera*/ + const string Phase_Name; /*!< \brief Name of the phase used for in cantera*/ static constexpr int ARRAYSIZE = 16; #ifdef USE_CANTERA diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index ce11fdf40052..b79c23271bec 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -50,7 +50,8 @@ CFluidCantera::CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2do GasConstant_Ref(config->GetGas_Constant_Ref()), Prandtl_Number(config->GetPrandtl_Turb()), Transport_Model(config->GetTransport_Model()), - Chemical_Mechanism(config->GetChemical_Mechanism()) { + Chemical_MechanismFile(config->GetChemical_MechanismFile()), + Phase_Name(config->GetPhase_Name()) { if (n_species_mixture > ARRAYSIZE) { SU2_MPI::Error("Too many species, increase ARRAYSIZE", CURRENT_FUNCTION); } @@ -121,7 +122,7 @@ string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars } void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { - auto sol = newSolution(Chemical_Mechanism, "h2o2", Transport_Model); + auto sol = newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model); auto gas = sol->thermo(); MassToMoleFractions(val_scalars); ComputeGasConstant(); From 8dc28f12ed049488e9f6c064ea94cd8eed9b0c0b Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 18 Sep 2024 00:01:15 +0200 Subject: [PATCH 018/173] adding Cantera test case --- Common/src/CConfig.cpp | 2 +- SU2_CFD/include/fluid/CFluidCantera.hpp | 24 +-- SU2_CFD/src/fluid/CFluidCantera.cpp | 52 +++---- .../species2_primitiveVenturi_CANTERA.cfg | 146 ++++++++++++++++++ 4 files changed, 185 insertions(+), 39 deletions(-) create mode 100644 TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 264d074de6c2..215b31509044 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1185,7 +1185,7 @@ void CConfig::SetConfig_Options() { /*!\brief FLUID_NAME \n DESCRIPTION: Fluid name \n OPTIONS: see coolprop homepage \n DEFAULT: nitrogen \ingroup Config*/ addStringOption("FLUID_NAME", FluidName, string("nitrogen")); /*!\brief TRANSPORT_MODEL \n DESCRIPTION: Transport model \n OPTIONS: see cantera homepage \n DEFAULT: mixture-averaged\ingroup Config*/ - addStringOption("TRANSPORT_MODEL", TransportModel, string("mixture_averaged")); + addStringOption("TRANSPORT_MODEL", TransportModel, string("mixture-averaged")); /*!\brief CHEMICAL_MECHANISM_FILE \n DESCRIPTION: Chemical reaction mechanism \n OPTIONS: see cantera homepage \n DEFAULT: gri30.yaml \ingroup Config*/ addStringOption("CHEMICAL_MECHANISM_FILE", ChemicalMechanismFile, string("gri30.yaml")); /*!\brief PHASE_NAME\n DESCRIPTION: name of the phase in the chemical mechanism file \n OPTIONS: see cantera homepage \n DEFAULT: gri30 \ingroup Config*/ diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index b4586834adeb..f7f3f9e51fdc 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -58,17 +58,17 @@ class CFluidCantera final : public CFluidModel { #ifdef USE_CANTERA std::array gasComposition; /*!< \brief Gas composition. */ #endif - std::array massFractions; /*!< \brief Mass fractions of all species. */ - std::array moleFractions; /*!< \brief Mole fractions of all species. */ - std::array molarMasses; /*!< \brief Molar masses of all species. */ + // std::array massFractions; /*!< \brief Mass fractions of all species. */ + // std::array moleFractions; /*!< \brief Mole fractions of all species. */ + // std::array molarMasses; /*!< \brief Molar masses of all species. */ std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ std::unique_ptr MassDiffusivityPointers[ARRAYSIZE]; - /*! - * \brief Convert mass fractions to mole fractions. - * \param[in] val_scalars - Scalar mass fraction. - */ - void MassToMoleFractions(const su2double* val_scalars); + // /*! + // * \brief Convert mass fractions to mole fractions. + // * \param[in] val_scalars - Scalar mass fraction. + // */ + // void MassToMoleFractions(const su2double* val_scalars); #ifdef USE_CANTERA /*! * \brief Return a string(dictionary) with chemical species and its mass fraction value. @@ -77,10 +77,10 @@ class CFluidCantera final : public CFluidModel { string DictionaryChemicalComposition(const su2double* val_scalars); #endif - /*! - * \brief Compute gas constant for mixture. - */ - su2double ComputeGasConstant(); + // /*! + // * \brief Compute gas constant for mixture. + // */ + // su2double ComputeGasConstant(); /*! * \brief Compute mass diffusivity for species. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index b79c23271bec..00f24b5c638e 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -57,7 +57,7 @@ CFluidCantera::CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2do } for (int iVar = 0; iVar < n_species_mixture; iVar++) { - molarMasses[iVar] = config->GetMolecular_Weight(iVar); + // molarMasses[iVar] = config->GetMolecular_Weight(iVar); #ifdef USE_CANTERA gasComposition[iVar]=config->GetChemical_GasComposition(iVar); #endif @@ -79,35 +79,35 @@ void CFluidCantera::ComputeMassDiffusivity() { } } -void CFluidCantera::MassToMoleFractions(const su2double* val_scalars) { +// void CFluidCantera::MassToMoleFractions(const su2double* val_scalars) { - su2double val_scalars_sum{0.0}; - for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { - massFractions[i_scalar] = val_scalars[i_scalar]; - val_scalars_sum += val_scalars[i_scalar]; - } - massFractions[n_species_mixture - 1] = 1 - val_scalars_sum; +// su2double val_scalars_sum{0.0}; +// for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { +// massFractions[i_scalar] = val_scalars[i_scalar]; +// val_scalars_sum += val_scalars[i_scalar]; +// } +// massFractions[n_species_mixture - 1] = 1 - val_scalars_sum; - su2double mixtureMolarMass{0.0}; - for (int iVar = 0; iVar < n_species_mixture; iVar++) { - mixtureMolarMass += massFractions[iVar] / molarMasses[iVar]; - } +// su2double mixtureMolarMass{0.0}; +// for (int iVar = 0; iVar < n_species_mixture; iVar++) { +// mixtureMolarMass += massFractions[iVar] / molarMasses[iVar]; +// } - for (int iVar = 0; iVar < n_species_mixture; iVar++) { - moleFractions[iVar] = (massFractions[iVar] / molarMasses[iVar]) / mixtureMolarMass; - } -} +// for (int iVar = 0; iVar < n_species_mixture; iVar++) { +// moleFractions[iVar] = (massFractions[iVar] / molarMasses[iVar]) / mixtureMolarMass; +// } +// } -su2double CFluidCantera::ComputeGasConstant() { - su2double MeanMolecularWeight = 0.0; +// su2double CFluidCantera::ComputeGasConstant() { +// su2double MeanMolecularWeight = 0.0; - for (int i = 0; i < n_species_mixture; i++) { - MeanMolecularWeight += moleFractions[i] * molarMasses[i] / 1000; - } - Gas_Constant = UNIVERSAL_GAS_CONSTANT / (GasConstant_Ref * MeanMolecularWeight); +// for (int i = 0; i < n_species_mixture; i++) { +// MeanMolecularWeight += moleFractions[i] * molarMasses[i] / 1000; +// } +// Gas_Constant = UNIVERSAL_GAS_CONSTANT / (GasConstant_Ref * MeanMolecularWeight); - return Gas_Constant; -} +// return Gas_Constant; +// } #ifdef USE_CANTERA string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars) { @@ -124,8 +124,8 @@ string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { auto sol = newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model); auto gas = sol->thermo(); - MassToMoleFractions(val_scalars); - ComputeGasConstant(); + // MassToMoleFractions(val_scalars); + // ComputeGasConstant(); DictionaryChemicalComposition(val_scalars); Temperature = val_temperature; // Set the thermodynamic state by specifying T (500 K) P (2 atm) and the mole diff --git a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg new file mode 100644 index 000000000000..9892bf05cea2 --- /dev/null +++ b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg @@ -0,0 +1,146 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Species mixing with 2 species, i.e. 1 transport equations % +% Including mixture dependent density, viscosity, thermal % +% conductivity % +% Author: Cristopher Morales Ubal % +% Institution: Eindhoven University of Technology % +% Date: 2022/06/15 % +% File Version 8.0.1 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= INC_RANS +KIND_TURB_MODEL= SST +% +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +INC_DENSITY_MODEL= VARIABLE +INC_DENSITY_INIT= 1.1766 +% +INC_VELOCITY_INIT= ( 1.00, 0.0, 0.0 ) +% +INC_ENERGY_EQUATION= YES +INC_TEMPERATURE_INIT= 300.0 +% +INC_NONDIM= DIMENSIONAL +% +% -------------------- FLUID PROPERTIES ------------------------------------- % +% +FLUID_MODEL= FLUID_CANTERA +% +THERMODYNAMIC_PRESSURE= 101325.0 +% +MOLECULAR_WEIGHT= 28.96 +% +SPECIFIC_HEAT_CP = 1009.39 +% +CONDUCTIVITY_MODEL= CANTERA +THERMAL_CONDUCTIVITY_CONSTANT= 0.0357 +% +PRANDTL_LAM= 0.72 +TURBULENT_CONDUCTIVITY_MODEL= NONE +PRANDTL_TURB= 0.90 +% +GAS_COMPOSITION= H2, CH4 +CHEMICAL_MECHANISM_FILE= grid30.yaml +PHASE_NAME= gri30 +TRANSPORT_MODEL= mixture-averaged +% +% +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +VISCOSITY_MODEL= CANTERA +% +MU_CONSTANT= 1.716E-5 +% +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_HEATFLUX= ( wall, 0.0 ) +MARKER_SYM= ( axis ) +% +SPECIFIED_INLET_PROFILE= NO +INLET_FILENAME= inlet_venturi.dat +INC_INLET_TYPE= VELOCITY_INLET VELOCITY_INLET +MARKER_INLET= ( gas_inlet, 300, 1.0, 1.0, 0.0, 0.0,\ + air_axial_inlet, 300, 1.0, 0.0, -1.0, 0.0 ) +MARKER_INLET_SPECIES= (gas_inlet, 0.5,\ + air_axial_inlet, 0.6) +% +INC_OUTLET_TYPE= PRESSURE_OUTLET +MARKER_OUTLET= ( outlet, 0.0) +% +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES +% +CFL_NUMBER= 60 +CFL_REDUCTION_SPECIES= 1.0 +CFL_REDUCTION_TURB= 1.0 +% +ITER= 1000 +% +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-8 +LINEAR_SOLVER_ITER= 5 +% +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= FDS +MUSCL_FLOW= YES +SLOPE_LIMITER_FLOW = NONE +TIME_DISCRE_FLOW= EULER_IMPLICIT +% +% -------------------- SCALAR TRANSPORT ---------------------------------------% +% +KIND_SCALAR_MODEL= SPECIES_TRANSPORT +DIFFUSIVITY_MODEL= CONSTANT_DIFFUSIVITY +DIFFUSIVITY_CONSTANT= 0.001 +% +CONV_NUM_METHOD_SPECIES= BOUNDED_SCALAR +MUSCL_SPECIES= NO +SLOPE_LIMITER_SPECIES = NONE +% +TIME_DISCRE_SPECIES= EULER_IMPLICIT +% +SPECIES_INIT= 1.0 +SPECIES_CLIPPING= NO +SPECIES_CLIPPING_MIN= 0.0 +SPECIES_CLIPPING_MAX= 1.0 +% +% -------------------- TURBULENT TRANSPORT ---------------------------------------% +% +CONV_NUM_METHOD_TURB= BOUNDED_SCALAR +MUSCL_TURB= NO +% +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_FIELD= RMS_PRESSURE, RMS_VELOCITY-X, RMS_VELOCITY-Y, RMS_TKE, RMS_SPECIES +CONV_RESIDUAL_MINVAL= -18 +CONV_STARTITER= 10 +% +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +MESH_FILENAME= primitiveVenturi.su2 +SCREEN_OUTPUT= INNER_ITER WALL_TIME \ + RMS_PRESSURE RMS_VELOCITY-X RMS_VELOCITY-Y RMS_TKE RMS_DISSIPATION RMS_SPECIES_0 \ + LINSOL_ITER LINSOL_RESIDUAL \ + LINSOL_ITER_TURB LINSOL_RESIDUAL_TURB \ + LINSOL_ITER_SPECIES LINSOL_RESIDUAL_SPECIES SURFACE_SPECIES_VARIANCE +SCREEN_WRT_FREQ_INNER= 10 +% +HISTORY_OUTPUT= RMS_RES FLOW_COEFF LINSOL SPECIES_COEFF SPECIES_COEFF_SURF +MARKER_ANALYZE= outlet gas_inlet air_axial_inlet +% +OUTPUT_FILES= RESTART_ASCII, PARAVIEW_MULTIBLOCK +VOLUME_OUTPUT= RESIDUAL, PRIMITIVE +OUTPUT_WRT_FREQ= 1000 +% +RESTART_SOL= NO +SOLUTION_FILENAME= solution From 17b694ba39d87186e370b38ffeb783647d43a7d5 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 19 Sep 2024 10:48:10 +0200 Subject: [PATCH 019/173] c++17 global in meson.build --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index a77cc9ad0554..bc1e2e866641 100644 --- a/meson.build +++ b/meson.build @@ -7,7 +7,7 @@ project('SU2', 'c', 'cpp', 'c_std=c99', 'cpp_std=c++17']) add_global_arguments('-lcantera', language: 'cpp') -#add_global_arguments('-std=c++17', language: 'cpp') +add_global_arguments('-std=c++17', language: 'cpp') fsmod = import('fs') if not fsmod.exists('su2preconfig.timestamp') From 79f260af3771ca87edaca28bf35d1ba984d5a9a7 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 21 Sep 2024 13:17:36 +0200 Subject: [PATCH 020/173] renaming --- Common/include/CConfig.hpp | 6 +++--- Common/src/CConfig.cpp | 4 ++-- .../species2_primitiveVenturi_CANTERA.cfg | 2 +- meson.build | 17 +++++++++-------- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 48e574c7b219..699bf63eec39 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -81,10 +81,10 @@ class CConfig { string* ConvField; /*!< \brief Field used for convergence check.*/ string FluidName; /*!< \brief name of the applied fluid. */ string TransportModel; /*!< \brief name transport model used in cantera*/ - string* GasComposition; /*!< \brief gas composition used in cantera*/ + string* GasCompositionNames; /*!< \brief gas composition used in cantera*/ string ChemicalMechanismFile; /*!< \brief Chemical Reaction mechanism used in cantera*/ string PhaseName; /*!< \brief Name of the phase in the chemical mechanism file used in cantera*/ - unsigned short n_Gas_Composition; /*!<\brief number of gases in mixture composition for cantera */ + unsigned short n_GasCompositionNames; /*!<\brief number of gases in mixture composition for cantera */ string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */ unsigned short nConvField; /*!< \brief Number of fields used to monitor convergence.*/ @@ -3988,7 +3988,7 @@ class CConfig { /*! * \brief Returns the gas composition used in Cantera. */ - string GetChemical_GasComposition(unsigned short val_index = 0) const { return GasComposition[val_index]; } + string GetChemical_GasComposition(unsigned short val_index = 0) const { return GasCompositionNames[val_index]; } /*! * \brief Option to define the density model for incompressible flows. diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 215b31509044..86dd86e4ae47 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1190,8 +1190,8 @@ void CConfig::SetConfig_Options() { addStringOption("CHEMICAL_MECHANISM_FILE", ChemicalMechanismFile, string("gri30.yaml")); /*!\brief PHASE_NAME\n DESCRIPTION: name of the phase in the chemical mechanism file \n OPTIONS: see cantera homepage \n DEFAULT: gri30 \ingroup Config*/ addStringOption("PHASE_NAME", PhaseName, string("gri30")); - /*!\brief GAS_COMPOSITION \n DESCRIPTION: Gas composition \n OPTIONS: see cantera homepage \n DEFAULT: \ingroup Config*/ - addStringListOption("GAS_COMPOSITION", n_Gas_Composition, GasComposition); + /*!\brief GAS_COMPOSITION \n DESCRIPTION: Gas composition names \n OPTIONS: see cantera homepage \n DEFAULT: \ingroup Config*/ + addStringListOption("GAS_COMPOSITION_NAMES", n_GasCompositionNames, GasCompositionNames); /*!\par CONFIG_CATEGORY: Data-driven fluid model parameters \ingroup Config*/ /*!\brief INTERPOLATION_METHOD \n DESCRIPTION: Interpolation method used to determine the thermodynamic state of the fluid. \n OPTIONS: See \link DataDrivenMethod_Map \endlink DEFAULT: MLP \ingroup Config*/ diff --git a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg index 9892bf05cea2..ed5f632a0d4f 100644 --- a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg +++ b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg @@ -45,7 +45,7 @@ PRANDTL_LAM= 0.72 TURBULENT_CONDUCTIVITY_MODEL= NONE PRANDTL_TURB= 0.90 % -GAS_COMPOSITION= H2, CH4 +GAS_COMPOSITION_NAMES= H2, CH4 CHEMICAL_MECHANISM_FILE= grid30.yaml PHASE_NAME= gri30 TRANSPORT_MODEL= mixture-averaged diff --git a/meson.build b/meson.build index bc1e2e866641..3597a1e98911 100644 --- a/meson.build +++ b/meson.build @@ -5,9 +5,11 @@ project('SU2', 'c', 'cpp', default_options: ['buildtype=release', 'warning_level=0', 'c_std=c99', - 'cpp_std=c++17']) -add_global_arguments('-lcantera', language: 'cpp') -add_global_arguments('-std=c++17', language: 'cpp') + 'cpp_std=c++11']) +if get_option('enable-cantera') + add_global_arguments('-lcantera', language: 'cpp') + add_global_arguments('-std=c++17', language: 'cpp') +endif fsmod = import('fs') if not fsmod.exists('su2preconfig.timestamp') @@ -295,13 +297,12 @@ endif if get_option('enable-cantera') su2_cpp_args +='-DHAVE_CANTERA' + cantera_include = include_directories(['/home/cristopher/codes/cantera/include']) + cantera_lib = static_library('cantera', include_directories : cantera_include) + cantera_dep = declare_dependency(link_with : cantera_lib,link_args: ['-L/home/cristopher/codes/cantera/build/lib', '-lcantera'], include_directories : cantera_include) + su2_deps += cantera_dep endif -cantera_include = include_directories(['/home/cristopher/include']) -cantera_lib = static_library('cantera', include_directories : cantera_include) -cantera_dep = declare_dependency(link_with : cantera_lib,link_args: ['-L/home/cristopher/lib', '-lcantera'], include_directories : cantera_include) -su2_deps += cantera_dep - if get_option('enable-mlpcpp') su2_cpp_args += '-DHAVE_MLPCPP' endif From bebae19d1876f82b59a6e55bfb9c3920565be764 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 21 Sep 2024 14:22:10 +0200 Subject: [PATCH 021/173] error messages, constructor cleaning, cleaning unneccesary functions --- Common/src/CConfig.cpp | 37 ++++++++++++++++++++++ SU2_CFD/include/fluid/CFluidCantera.hpp | 16 +--------- SU2_CFD/src/fluid/CFluidCantera.cpp | 41 +++---------------------- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 5 ++- 4 files changed, 44 insertions(+), 55 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 86dd86e4ae47..e8b23f6818c8 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -4027,6 +4027,43 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i } + if (Kind_FluidModel == FLUID_CANTERA) { + /*--- Check whether the number of entries of the GAS_COMPOSITION_NAMES equals the number of transported scalar + equations solved + 1.--- */ + if (n_GasCompositionNames != nSpecies_Init + 1) { + SU2_MPI::Error( + "The use of FLUID_CANTERA requires the number of entries for GAS_COMPOSITION_NAMES,\n" + "to be equal to the number of entries of SPECIES_INIT + 1", + CURRENT_FUNCTION); + } + /*--- Check whether the density model used is correct, in the case of FLUID_CANTERA the density model must be + VARIABLE. Otherwise, if the density model is CONSTANT, the scalars will not have influence the mixture density + and it will remain constant through the complete domain. --- */ + if (Kind_DensityModel != INC_DENSITYMODEL::VARIABLE) { + SU2_MPI::Error("The use of FLUID_CANTERA requires the INC_DENSITY_MODEL option to be VARIABLE", + CURRENT_FUNCTION); + } + /*--- Check whether the Kind scalar model used is correct, in the case of FLUID_CANTERA the kind scalar model must + be SPECIES_TRANSPORT. Otherwise, if the scalar model is NONE, the species transport equations will not be solved. + --- */ + if (Kind_Species_Model != SPECIES_MODEL::SPECIES_TRANSPORT) { + SU2_MPI::Error("The use of FLUID_CANTERA requires the KIND_SCALAR_MODEL option to be SPECIES_TRANSPORT", + CURRENT_FUNCTION); + } + + if (Kind_ConductivityModel != CONDUCTIVITYMODEL::CANTERA) { + SU2_MPI::Error("The use of FLUID_CANTERA requires the CONDUCTIVITY_MODEL option to be CANTERA", + CURRENT_FUNCTION); + } + + if (Kind_ViscosityModel != VISCOSITYMODEL::CANTERA) { + SU2_MPI::Error("The use of FLUID_CANTERA requires the VISCOSITY_MODEL option to be CANTERA", + CURRENT_FUNCTION); + } + + } + + if (Kind_Species_Model == SPECIES_MODEL::FLAMELET) { if (Kind_FluidModel != FLUID_FLAMELET) { diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index f7f3f9e51fdc..cdf512776312 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -45,7 +45,6 @@ class CFluidCantera final : public CFluidModel { private: const int n_species_mixture; /*!< \brief Number of species in mixture. */ - su2double Gas_Constant; /*!< \brief Specific gas constant. */ const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */ const su2double GasConstant_Ref; /*!< \brief Gas constant reference needed for Nondimensional problems. */ const su2double Prandtl_Number; /*!< \brief Prandlt number.*/ @@ -58,17 +57,9 @@ class CFluidCantera final : public CFluidModel { #ifdef USE_CANTERA std::array gasComposition; /*!< \brief Gas composition. */ #endif - // std::array massFractions; /*!< \brief Mass fractions of all species. */ - // std::array moleFractions; /*!< \brief Mole fractions of all species. */ - // std::array molarMasses; /*!< \brief Molar masses of all species. */ std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ std::unique_ptr MassDiffusivityPointers[ARRAYSIZE]; - // /*! - // * \brief Convert mass fractions to mole fractions. - // * \param[in] val_scalars - Scalar mass fraction. - // */ - // void MassToMoleFractions(const su2double* val_scalars); #ifdef USE_CANTERA /*! * \brief Return a string(dictionary) with chemical species and its mass fraction value. @@ -77,11 +68,6 @@ class CFluidCantera final : public CFluidModel { string DictionaryChemicalComposition(const su2double* val_scalars); #endif - // /*! - // * \brief Compute gas constant for mixture. - // */ - // su2double ComputeGasConstant(); - /*! * \brief Compute mass diffusivity for species. */ @@ -91,7 +77,7 @@ class CFluidCantera final : public CFluidModel { /*! * \brief Constructor of the class. */ - CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2double val_operating_pressure, const CConfig* config); + CFluidCantera(su2double val_operating_pressure, const CConfig* config); /*! diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 00f24b5c638e..1d643523f2b9 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -41,11 +41,9 @@ using namespace Cantera; using namespace SU2_TYPE; #endif -CFluidCantera::CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2double value_pressure_operating, - const CConfig* config) +CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* config) : CFluidModel(), n_species_mixture(config->GetnSpecies() + 1), - Gas_Constant(val_gas_constant), Pressure_Thermodynamic(value_pressure_operating), GasConstant_Ref(config->GetGas_Constant_Ref()), Prandtl_Number(config->GetPrandtl_Turb()), @@ -56,12 +54,11 @@ CFluidCantera::CFluidCantera(su2double val_Cp, su2double val_gas_constant, su2do SU2_MPI::Error("Too many species, increase ARRAYSIZE", CURRENT_FUNCTION); } - for (int iVar = 0; iVar < n_species_mixture; iVar++) { - // molarMasses[iVar] = config->GetMolecular_Weight(iVar); - #ifdef USE_CANTERA + #ifdef USE_CANTERA + for (int iVar = 0; iVar < n_species_mixture; iVar++) { gasComposition[iVar]=config->GetChemical_GasComposition(iVar); - #endif } + #endif SetMassDiffusivityModel(config); } @@ -79,36 +76,6 @@ void CFluidCantera::ComputeMassDiffusivity() { } } -// void CFluidCantera::MassToMoleFractions(const su2double* val_scalars) { - -// su2double val_scalars_sum{0.0}; -// for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { -// massFractions[i_scalar] = val_scalars[i_scalar]; -// val_scalars_sum += val_scalars[i_scalar]; -// } -// massFractions[n_species_mixture - 1] = 1 - val_scalars_sum; - -// su2double mixtureMolarMass{0.0}; -// for (int iVar = 0; iVar < n_species_mixture; iVar++) { -// mixtureMolarMass += massFractions[iVar] / molarMasses[iVar]; -// } - -// for (int iVar = 0; iVar < n_species_mixture; iVar++) { -// moleFractions[iVar] = (massFractions[iVar] / molarMasses[iVar]) / mixtureMolarMass; -// } -// } - -// su2double CFluidCantera::ComputeGasConstant() { -// su2double MeanMolecularWeight = 0.0; - -// for (int i = 0; i < n_species_mixture; i++) { -// MeanMolecularWeight += moleFractions[i] * molarMasses[i] / 1000; -// } -// Gas_Constant = UNIVERSAL_GAS_CONSTANT / (GasConstant_Ref * MeanMolecularWeight); - -// return Gas_Constant; -// } - #ifdef USE_CANTERA string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars) { su2double val_scalars_sum{0.0}; diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 4ce3094c9a3c..06437d940bd0 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -343,8 +343,7 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i config->SetGas_Constant(UNIVERSAL_GAS_CONSTANT / (config->GetMolecular_Weight() / 1000.0)); Pressure_Thermodynamic = config->GetPressure_Thermodynamic(); - auxFluidModel = - new CFluidCantera(config->GetSpecific_Heat_Cp(), config->GetGas_Constant(), Pressure_Thermodynamic, config); + auxFluidModel = new CFluidCantera(Pressure_Thermodynamic, config); auxFluidModel->SetTDState_T(Temperature_FreeStream, config->GetSpecies_Init()); break; @@ -502,7 +501,7 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i break; case FLUID_CANTERA: - fluidModel = new CFluidCantera(Specific_Heat_CpND, Gas_ConstantND, Pressure_ThermodynamicND, config); + fluidModel = new CFluidCantera(Pressure_ThermodynamicND, config); fluidModel->SetTDState_T(Temperature_FreeStreamND, config->GetSpecies_Init()); break; From cd8f1e33e9b169452794303c4335ab139adfa563 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 21 Sep 2024 14:29:20 +0200 Subject: [PATCH 022/173] additional cleaning --- SU2_CFD/src/fluid/CFluidCantera.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 1d643523f2b9..b99cd723cbbe 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -91,14 +91,8 @@ string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { auto sol = newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model); auto gas = sol->thermo(); - // MassToMoleFractions(val_scalars); - // ComputeGasConstant(); DictionaryChemicalComposition(val_scalars); Temperature = val_temperature; - // Set the thermodynamic state by specifying T (500 K) P (2 atm) and the mole - // fractions. Note that the mole fractions do not need to sum to 1.0 - they will - // be normalized internally. Also, the values for any unspecified species will be - // set to zero. gas->setState_TPY(GetValue(Temperature), GetValue(Pressure_Thermodynamic), chemical_composition); Density = gas->density(); Cp = gas->cp_mass(); From a815f58274b3e17e17418ab1c655d9e8a1a2b18b Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 23 Sep 2024 11:57:43 +0200 Subject: [PATCH 023/173] config error update --- Common/src/CConfig.cpp | 5 +++-- SU2_CFD/src/fluid/CFluidCantera.cpp | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index e8b23f6818c8..444f107cf180 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -3377,7 +3377,8 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i (Kind_FluidModel == FLUID_MIXTURE) || (Kind_FluidModel == FLUID_FLAMELET) || (Kind_FluidModel == INC_IDEAL_GAS_POLY) || - (Kind_FluidModel == CONSTANT_DENSITY)); + (Kind_FluidModel == CONSTANT_DENSITY)|| + (Kind_FluidModel == FLUID_CANTERA)); bool noneq_gas = ((Kind_FluidModel == MUTATIONPP) || (Kind_FluidModel == SU2_NONEQ)); bool standard_air = ((Kind_FluidModel == STANDARD_AIR)); @@ -5080,7 +5081,7 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i } if (Kind_DensityModel == INC_DENSITYMODEL::VARIABLE) { - if (Kind_FluidModel != INC_IDEAL_GAS && Kind_FluidModel != INC_IDEAL_GAS_POLY && Kind_FluidModel != FLUID_MIXTURE && Kind_FluidModel != FLUID_FLAMELET) { + if (Kind_FluidModel != INC_IDEAL_GAS && Kind_FluidModel != INC_IDEAL_GAS_POLY && Kind_FluidModel != FLUID_MIXTURE && Kind_FluidModel != FLUID_FLAMELET && Kind_FluidModel != FLUID_CANTERA) { SU2_MPI::Error("Variable density incompressible solver limited to ideal gases.\n Check the fluid model options (use INC_IDEAL_GAS, INC_IDEAL_GAS_POLY).", CURRENT_FUNCTION); } } diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index b99cd723cbbe..4d60723fcbe6 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -79,6 +79,7 @@ void CFluidCantera::ComputeMassDiffusivity() { #ifdef USE_CANTERA string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars) { su2double val_scalars_sum{0.0}; + chemical_composition=""; for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { chemical_composition.append(gasComposition[i_scalar] + ":" + to_string(val_scalars[i_scalar])+", "); val_scalars_sum += val_scalars[i_scalar]; From fc8751c34f59b97484c7ec416305e9786ea14501 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 23 Sep 2024 13:32:00 +0200 Subject: [PATCH 024/173] fixing constructor --- Common/include/option_structure.hpp | 2 +- SU2_CFD/include/fluid/CFluidCantera.hpp | 6 ++++++ SU2_CFD/src/fluid/CFluidCantera.cpp | 4 ++-- .../species2_primitiveVenturi_CANTERA.cfg | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 8467ce6e8a5e..02355339946a 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -705,7 +705,7 @@ enum class CONDUCTIVITYMODEL { POLYNOMIAL, /*!< \brief Polynomial thermal conductivity. */ FLAMELET, /*!< \brief LUT method for flamelets */ COOLPROP, /*!< \brief COOLPROP thermal conductivity. */ - CANTERA, /*!< \brief COOLPROP thermal conductivity. */ + CANTERA, /*!< \brief CANTERA thermal conductivity. */ }; static const MapType ConductivityModel_Map = { MakePair("CONSTANT_CONDUCTIVITY", CONDUCTIVITYMODEL::CONSTANT) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index cdf512776312..28e0702b5140 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -34,6 +34,10 @@ #if defined(HAVE_CANTERA) #define USE_CANTERA +namespace Cantera { +class Solution; +class ThermoPhase; +} #endif @@ -56,6 +60,8 @@ class CFluidCantera final : public CFluidModel { static constexpr int ARRAYSIZE = 16; #ifdef USE_CANTERA std::array gasComposition; /*!< \brief Gas composition. */ + std::shared_ptr sol; + std::shared_ptr gas; #endif std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ std::unique_ptr MassDiffusivityPointers[ARRAYSIZE]; diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 4d60723fcbe6..88cd90408b87 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -58,6 +58,8 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* for (int iVar = 0; iVar < n_species_mixture; iVar++) { gasComposition[iVar]=config->GetChemical_GasComposition(iVar); } + sol = std::shared_ptr(newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model)); + gas = sol->thermo(); #endif SetMassDiffusivityModel(config); @@ -90,8 +92,6 @@ string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars } void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { - auto sol = newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model); - auto gas = sol->thermo(); DictionaryChemicalComposition(val_scalars); Temperature = val_temperature; gas->setState_TPY(GetValue(Temperature), GetValue(Pressure_Thermodynamic), chemical_composition); diff --git a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg index ed5f632a0d4f..02c1394db880 100644 --- a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg +++ b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg @@ -23,7 +23,7 @@ INC_DENSITY_INIT= 1.1766 % INC_VELOCITY_INIT= ( 1.00, 0.0, 0.0 ) % -INC_ENERGY_EQUATION= YES +INC_ENERGY_EQUATION= NO INC_TEMPERATURE_INIT= 300.0 % INC_NONDIM= DIMENSIONAL @@ -46,7 +46,7 @@ TURBULENT_CONDUCTIVITY_MODEL= NONE PRANDTL_TURB= 0.90 % GAS_COMPOSITION_NAMES= H2, CH4 -CHEMICAL_MECHANISM_FILE= grid30.yaml +CHEMICAL_MECHANISM_FILE= gri30.yaml PHASE_NAME= gri30 TRANSPORT_MODEL= mixture-averaged % From 37936ed7717d26298366cb0dd00ec39abf17b07f Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 23 Sep 2024 14:56:34 +0200 Subject: [PATCH 025/173] adding descriptions --- SU2_CFD/include/fluid/CFluidCantera.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 28e0702b5140..6fdf63c3d10a 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -59,9 +59,9 @@ class CFluidCantera final : public CFluidModel { static constexpr int ARRAYSIZE = 16; #ifdef USE_CANTERA - std::array gasComposition; /*!< \brief Gas composition. */ - std::shared_ptr sol; - std::shared_ptr gas; + std::array gasComposition; /*!< \brief Gas composition. */ + std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ + std::shared_ptr gas; /*!< \brief Object needed to compute thermodynamic properties*/ #endif std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ std::unique_ptr MassDiffusivityPointers[ARRAYSIZE]; From b12d5614f987282e4caacbdcc60c7bfdd1ce7b55 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 24 Sep 2024 23:27:41 +0200 Subject: [PATCH 026/173] adding diffusivity models for CANTERA --- Common/include/option_structure.hpp | 2 ++ Common/src/CConfig.cpp | 4 +++ SU2_CFD/include/fluid/CFluidCantera.hpp | 2 ++ SU2_CFD/src/fluid/CFluidCantera.cpp | 28 +++++++++++++++---- SU2_CFD/src/fluid/CFluidModel.cpp | 4 +++ .../species2_primitiveVenturi_CANTERA.cfg | 2 +- 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 02355339946a..cea0d7060f5a 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -737,6 +737,7 @@ enum class DIFFUSIVITYMODEL { UNITY_LEWIS, /*!< \brief Unity Lewis model for mass diffusion in scalar transport. */ CONSTANT_LEWIS, /*!< \brief Different Lewis number model for mass diffusion in scalar transport. */ FLAMELET, /*!< \brief flamelet model for tabulated chemistry, diffusivity from lookup table */ + MIXTURE_AVERAGED, /*!< \brief Mixture average diffusivity from CANTERA */ }; static const MapType Diffusivity_Model_Map = { @@ -745,6 +746,7 @@ static const MapType Diffusivity_Model_Map = { MakePair("UNITY_LEWIS", DIFFUSIVITYMODEL::UNITY_LEWIS) MakePair("CONSTANT_LEWIS", DIFFUSIVITYMODEL::CONSTANT_LEWIS) MakePair("FLAMELET", DIFFUSIVITYMODEL::FLAMELET) + MakePair("MIXTURE_AVERAGED", DIFFUSIVITYMODEL::MIXTURE_AVERAGED) }; /*! diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 444f107cf180..0eff70bf5a4a 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -4062,6 +4062,10 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i CURRENT_FUNCTION); } + if (Kind_Diffusivity_Model != DIFFUSIVITYMODEL::UNITY_LEWIS && Kind_Diffusivity_Model != DIFFUSIVITYMODEL::MIXTURE_AVERAGED) { + SU2_MPI::Error("The use of FLUID_CANTERA requires the DIFFUSIVITY_MODEL option to be UNITY_LEWIS or MIXTURE_AVERAGED", + CURRENT_FUNCTION); + } } diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 6fdf63c3d10a..07b1fd8fff44 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -56,10 +56,12 @@ class CFluidCantera final : public CFluidModel { const string Transport_Model; /*!< \brief Transport model used for computing mixture properties*/ const string Chemical_MechanismFile; /*!< \brief Chemical reaction mechanism used for in cantera*/ const string Phase_Name; /*!< \brief Name of the phase used for in cantera*/ + const bool Unity_Lewis; /*!< \brief Bool for using UNITY_LEWIS as diffusivity model*/ static constexpr int ARRAYSIZE = 16; #ifdef USE_CANTERA std::array gasComposition; /*!< \brief Gas composition. */ + std::array speciesIndexes; /*!< \brief Array index species being solved*/ std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ std::shared_ptr gas; /*!< \brief Object needed to compute thermodynamic properties*/ #endif diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 88cd90408b87..7d0cb4d231bb 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -49,7 +49,8 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* Prandtl_Number(config->GetPrandtl_Turb()), Transport_Model(config->GetTransport_Model()), Chemical_MechanismFile(config->GetChemical_MechanismFile()), - Phase_Name(config->GetPhase_Name()) { + Phase_Name(config->GetPhase_Name()), + Unity_Lewis(config->GetKind_Diffusivity_Model()==DIFFUSIVITYMODEL::UNITY_LEWIS){ if (n_species_mixture > ARRAYSIZE) { SU2_MPI::Error("Too many species, increase ARRAYSIZE", CURRENT_FUNCTION); } @@ -60,6 +61,14 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* } sol = std::shared_ptr(newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model)); gas = sol->thermo(); + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + for (int i = 0; i < gas->nSpecies(); i++) { + if (gas->speciesName(i) == gasComposition[iVar]) { + speciesIndexes[iVar] = i; + break; + } + } + } #endif SetMassDiffusivityModel(config); @@ -71,14 +80,23 @@ void CFluidCantera::SetMassDiffusivityModel(const CConfig* config) { } } +#ifdef USE_CANTERA void CFluidCantera::ComputeMassDiffusivity() { - for (int iVar = 0; iVar < n_species_mixture; iVar++) { - MassDiffusivityPointers[iVar]->SetDiffusivity(Density, Mu, Cp, Kt); - massDiffusivity[iVar] = MassDiffusivityPointers[iVar]->GetDiffusivity(); + if (Unity_Lewis) { + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + MassDiffusivityPointers[iVar]->SetDiffusivity(Density, Mu, Cp, Kt); + massDiffusivity[iVar] = MassDiffusivityPointers[iVar]->GetDiffusivity(); + } + } else { + int nsp = gas->nSpecies(); + vector diff(nsp); + sol->transport()->getMixDiffCoeffsMass(&diff[0]); + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + massDiffusivity[iVar] = diff[speciesIndexes[iVar]]; + } } } -#ifdef USE_CANTERA string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars) { su2double val_scalars_sum{0.0}; chemical_composition=""; diff --git a/SU2_CFD/src/fluid/CFluidModel.cpp b/SU2_CFD/src/fluid/CFluidModel.cpp index c59fca8c9c57..8b28d45fe121 100644 --- a/SU2_CFD/src/fluid/CFluidModel.cpp +++ b/SU2_CFD/src/fluid/CFluidModel.cpp @@ -151,6 +151,10 @@ unique_ptr CFluidModel::MakeMassDiffusivityModel(const CConfi /*--- Diffusivity is obtained from the LUT ---*/ return nullptr; break; + case DIFFUSIVITYMODEL::MIXTURE_AVERAGED: + /*--- Diffusivity is obtained from CANTERA using mixture averaged model---*/ + return nullptr; + break; default: SU2_MPI::Error("Diffusivity model not available.", CURRENT_FUNCTION); return nullptr; diff --git a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg index 02c1394db880..0fa999ed87b4 100644 --- a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg +++ b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg @@ -100,7 +100,7 @@ TIME_DISCRE_FLOW= EULER_IMPLICIT % -------------------- SCALAR TRANSPORT ---------------------------------------% % KIND_SCALAR_MODEL= SPECIES_TRANSPORT -DIFFUSIVITY_MODEL= CONSTANT_DIFFUSIVITY +DIFFUSIVITY_MODEL= UNITY_LEWIS DIFFUSIVITY_CONSTANT= 0.001 % CONV_NUM_METHOD_SPECIES= BOUNDED_SCALAR From 51a854b068dc7648f4dcab2fd462b55fa3d1c6d1 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 27 Sep 2024 16:59:07 +0200 Subject: [PATCH 027/173] showing error when INC_NONDIM is INITIAL_VALUES or REFERENCE_VALUES --- Common/src/CConfig.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index e2e970341bce..172f48b5ad25 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -4053,6 +4053,13 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i CURRENT_FUNCTION); } + if (Ref_Inc_NonDim != DIMENSIONAL) { + SU2_MPI::Error( + "The use of FLUID_CANTERA requiere the option INC_NONDIM= DIMENSIONAL, the nondimensionalization is " + "currently unavailable.", + CURRENT_FUNCTION); + } + if (Kind_ConductivityModel != CONDUCTIVITYMODEL::CANTERA) { SU2_MPI::Error("The use of FLUID_CANTERA requires the CONDUCTIVITY_MODEL option to be CANTERA", CURRENT_FUNCTION); From e1623298f761d7a178ba44fd2c7205714c8ca08a Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 30 Sep 2024 16:34:13 +0200 Subject: [PATCH 028/173] reducing some pointers and arrays needed --- SU2_CFD/include/fluid/CFluidCantera.hpp | 2 -- SU2_CFD/src/fluid/CFluidCantera.cpp | 21 ++++++--------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 07b1fd8fff44..e51be205b47a 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -61,9 +61,7 @@ class CFluidCantera final : public CFluidModel { static constexpr int ARRAYSIZE = 16; #ifdef USE_CANTERA std::array gasComposition; /*!< \brief Gas composition. */ - std::array speciesIndexes; /*!< \brief Array index species being solved*/ std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ - std::shared_ptr gas; /*!< \brief Object needed to compute thermodynamic properties*/ #endif std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ std::unique_ptr MassDiffusivityPointers[ARRAYSIZE]; diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 7d0cb4d231bb..e13a22d9b3c0 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -60,15 +60,6 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* gasComposition[iVar]=config->GetChemical_GasComposition(iVar); } sol = std::shared_ptr(newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model)); - gas = sol->thermo(); - for (int iVar = 0; iVar < n_species_mixture; iVar++) { - for (int i = 0; i < gas->nSpecies(); i++) { - if (gas->speciesName(i) == gasComposition[iVar]) { - speciesIndexes[iVar] = i; - break; - } - } - } #endif SetMassDiffusivityModel(config); @@ -88,11 +79,11 @@ void CFluidCantera::ComputeMassDiffusivity() { massDiffusivity[iVar] = MassDiffusivityPointers[iVar]->GetDiffusivity(); } } else { - int nsp = gas->nSpecies(); + int nsp = sol->thermo()->nSpecies(); vector diff(nsp); sol->transport()->getMixDiffCoeffsMass(&diff[0]); for (int iVar = 0; iVar < n_species_mixture; iVar++) { - massDiffusivity[iVar] = diff[speciesIndexes[iVar]]; + massDiffusivity[iVar] = diff[sol->thermo()->speciesIndex(gasComposition[iVar])]; } } } @@ -112,10 +103,10 @@ string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { DictionaryChemicalComposition(val_scalars); Temperature = val_temperature; - gas->setState_TPY(GetValue(Temperature), GetValue(Pressure_Thermodynamic), chemical_composition); - Density = gas->density(); - Cp = gas->cp_mass(); - Cv = gas->cv_mass(); + sol->thermo()->setState_TPY(GetValue(Temperature), GetValue(Pressure_Thermodynamic), chemical_composition); + Density = sol->thermo()->density(); + Cp = sol->thermo()->cp_mass(); + Cv = sol->thermo()->cv_mass(); Mu = sol->transport()->viscosity(); Kt = sol->transport()->thermalConductivity(); From 6ad4e5d3ff0c5fcfa98b7c8ddd1de7bc719e528b Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 30 Sep 2024 16:46:04 +0200 Subject: [PATCH 029/173] version updated --- SU2_CFD/include/fluid/CFluidCantera.hpp | 2 +- SU2_CFD/src/fluid/CFluidCantera.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index e51be205b47a..1a268cffd9df 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -2,7 +2,7 @@ * \file CFluidCantera.hpp * \brief Defines the multicomponent incompressible Ideal Gas model for reacting flows. * \author T. Economon, Cristopher Morales Ubal - * \version 8.0.1 "Harrier" + * \version 8.1.0 "Harrier" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index e13a22d9b3c0..97565981c9d1 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -2,7 +2,7 @@ * \file CFluidCantera.cpp * \brief Defines the multicomponent incompressible Ideal Gas model for reacting flows. * \author T. Economon, Cristopher Morales Ubal - * \version 8.0.1 "Harrier" + * \version 8.1.0 "Harrier" * * SU2 Project Website: https://su2code.github.io * From a555012616af24fc470d85e666bb56e86a5b7ea4 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 1 Oct 2024 17:29:56 +0200 Subject: [PATCH 030/173] adding unit test case Cantera --- .../SU2_CFD/fluid/CFluidCantera_tests.cpp | 72 +++++++++++++++++++ .../SU2_CFD/fluid/multicomponent_cantera.cfg | 39 ++++++++++ UnitTests/meson.build | 2 +- 3 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp create mode 100644 UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg diff --git a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp new file mode 100644 index 000000000000..343de4d6befd --- /dev/null +++ b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp @@ -0,0 +1,72 @@ +/*! + * \file CFluidCantera_tests.cpp + * \brief Unit tests for the Cantera fluid model. + * \author C.Morales Ubal + * \version 8.1.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2024, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "catch.hpp" + +#include + +#include +#if defined(HAVE_CANTERA) +#define USE_CANTERA +#include "../../../Common/include/basic_types/ad_structure.hpp" +#include "../../../SU2_CFD/include/fluid/CFluidCantera.hpp" +#include "/home/cristopher/codes/cantera/include/cantera/core.h" +#include +#include + +using namespace Cantera; +using namespace SU2_TYPE; +#endif + +#ifdef USE_CANTERA +TEST_CASE("Fluid_Cantera", "[Multicomponent_flow]") { + /*--- Cantera fluid model unit test cases ---*/ + + SU2_COMPONENT val_software = SU2_COMPONENT::SU2_CFD; + CConfig* config = new CConfig("multicomponent_cantera.cfg", val_software, true); + CFluidCantera* auxFluidModel = nullptr; + + /*--- Create Cantera fluid model ---*/ + su2double value_pressure_operating = config->GetPressure_Thermodynamic(); + auxFluidModel= new CFluidCantera(value_pressure_operating, config); + + /*--- get scalar from config file and set temperature ---*/ + + const su2double* scalar = nullptr; + scalar=config->GetSpecies_Init(); + const su2double Temperature = 300.0; + /*--- Set state using temperature and scalar ---*/ + auxFluidModel->SetTDState_T(Temperature, scalar); + + /*--- check values for density and heat capacity ---*/ + + su2double density = auxFluidModel->GetDensity(); + su2double cp = auxFluidModel->GetCp(); + CHECK(density == Approx(0.92424)); + CHECK(cp == Approx(1277.9)); +} +#endif \ No newline at end of file diff --git a/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg b/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg new file mode 100644 index 000000000000..d9eb356c3082 --- /dev/null +++ b/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg @@ -0,0 +1,39 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Unit test Multicomponent Cantera 3 species H2, O2, N2 % +% Author: Cristopher Morales Ubal % +% Institution: Eindhoven University of Technology % +% Date: 2024/10/01 % +% File Version 8.1.0 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= INC_NAVIER_STOKES +% +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +INC_DENSITY_MODEL= VARIABLE +% +INC_NONDIM= DIMENSIONAL +% +% -------------------- FLUID PROPERTIES ------------------------------------- % +% +FLUID_MODEL= FLUID_CANTERA +% +CONDUCTIVITY_MODEL= CANTERA +VISCOSITY_MODEL= CANTERA +% +GAS_COMPOSITION_NAMES= H2, O2, N2 +CHEMICAL_MECHANISM_FILE= h2o2.yaml +PHASE_NAME= ohmech +TRANSPORT_MODEL= mixture-averaged +% +% -------------------- SCALAR TRANSPORT ---------------------------------------% +% +KIND_SCALAR_MODEL= SPECIES_TRANSPORT +DIFFUSIVITY_MODEL= UNITY_LEWIS +% +SPECIES_INIT= 0.020137986304114414,0.22830757006769173 diff --git a/UnitTests/meson.build b/UnitTests/meson.build index add06584b9d2..a64b9a33522f 100644 --- a/UnitTests/meson.build +++ b/UnitTests/meson.build @@ -12,7 +12,7 @@ su2_cfd_tests = files(['Common/geometry/primal_grid/CPrimalGrid_tests.cpp', 'Common/vectorization.cpp', 'Common/toolboxes/ndflattener_tests.cpp', 'Common/containers/CLookupTable_tests.cpp', - #'Common/CFluidCantera_Test.cpp', + 'SU2_CFD/fluid/CFluidCantera_tests.cpp', 'Common/toolboxes/multilayer_perceptron/CLookUp_ANN_tests.cpp', 'SU2_CFD/numerics/CNumerics_tests.cpp', 'SU2_CFD/gradients.cpp', From f76cbd8c01f26d34fe885b450fb718a6364f09a8 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 4 Oct 2024 12:08:09 +0200 Subject: [PATCH 031/173] adding chemical source term to species transport --- Common/include/CConfig.hpp | 7 +++ Common/src/CConfig.cpp | 8 ++++ SU2_CFD/include/numerics/CNumerics.hpp | 15 ++++++- .../numerics/species/species_sources.hpp | 30 +++++++++++++ .../include/variables/CSpeciesVariable.hpp | 25 +++++++++++ SU2_CFD/src/drivers/CDriver.cpp | 6 ++- .../src/numerics/species/species_sources.cpp | 44 +++++++++++++++++++ SU2_CFD/src/solvers/CSpeciesSolver.cpp | 33 ++++++++++++++ SU2_CFD/src/variables/CSpeciesVariable.cpp | 3 +- .../species2_primitiveVenturi_CANTERA.cfg | 1 + .../SU2_CFD/fluid/CFluidCantera_tests.cpp | 4 +- 11 files changed, 171 insertions(+), 5 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 984efe723281..230f0a390b6d 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -85,6 +85,7 @@ class CConfig { string ChemicalMechanismFile; /*!< \brief Chemical Reaction mechanism used in cantera*/ string PhaseName; /*!< \brief Name of the phase in the chemical mechanism file used in cantera*/ unsigned short n_GasCompositionNames; /*!<\brief number of gases in mixture composition for cantera */ + bool Combustion; /*!< \brief Flag for Combustion Detailed chemistry problems using Cantera */ string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */ unsigned short nConvField; /*!< \brief Number of fields used to monitor convergence.*/ @@ -4009,6 +4010,12 @@ class CConfig { */ string GetChemical_GasComposition(unsigned short val_index = 0) const { return GasCompositionNames[val_index]; } + /*! + * \brief Get information about the Combustion-Detailed chemistry usin Cantera problems. + * \return TRUE if combustion-detailed chemistry using Cantera is used; otherwise FALSE. + */ + bool GetCombustion(void) const { return Combustion; } + /*! * \brief Option to define the density model for incompressible flows. * \return Density model option diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 10c038fb4be3..41e995289fe8 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1193,6 +1193,8 @@ void CConfig::SetConfig_Options() { addStringOption("PHASE_NAME", PhaseName, string("gri30")); /*!\brief GAS_COMPOSITION \n DESCRIPTION: Gas composition names \n OPTIONS: see cantera homepage \n DEFAULT: \ingroup Config*/ addStringListOption("GAS_COMPOSITION_NAMES", n_GasCompositionNames, GasCompositionNames); + /*\brief COMBUSTION \n DESCRIPTION: Combustion- Detailed chemistry using Cantera \n DEFAULT: false \ingroup Config */ + addBoolOption("COMBUSTION", Combustion, false); /*!\par CONFIG_CATEGORY: Data-driven fluid model parameters \ingroup Config*/ /*!\brief INTERPOLATION_METHOD \n DESCRIPTION: Interpolation method used to determine the thermodynamic state of the fluid. \n OPTIONS: See \link DataDrivenMethod_Map \endlink DEFAULT: MLP \ingroup Config*/ @@ -4028,6 +4030,12 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i } } + if ((Kind_FluidModel != FLUID_CANTERA) && (Combustion == true)) { + SU2_MPI::Error( + "The use of COMBUSTION=YES requires the use of FLUID_MIXTURE=FLUID_CANTERA,\n" + "detailed chemistry cannot be performed with other fluid models", + CURRENT_FUNCTION); + } if (Kind_FluidModel == FLUID_CANTERA) { /*--- Check whether the number of entries of the GAS_COMPOSITION_NAMES equals the number of transported scalar diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 535335947caf..dffd1af6240f 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -62,7 +62,9 @@ class CNumerics { const su2double delta [3][3] = {{1.0, 0.0, 0.0},{0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}; /*!< \brief Identity matrix. */ const su2double *Diffusion_Coeff_i, /*!< \brief Species diffusion coefficients at point i. */ - *Diffusion_Coeff_j; /*!< \brief Species diffusion coefficients at point j. */ + *Diffusion_Coeff_j, /*!< \brief Species diffusion coefficients at point j. */ + *Chemical_Source_Term_i, /*!< \brief Species diffusion coefficients at point i. */ + *Chemical_Source_Term_j; /*!< \brief Species diffusion coefficients at point j. */ su2double Laminar_Viscosity_i, /*!< \brief Laminar viscosity at point i. */ Laminar_Viscosity_j; /*!< \brief Laminar viscosity at point j. */ @@ -751,6 +753,17 @@ class CNumerics { Diffusion_Coeff_j = val_diffusioncoeff_j; } + /*! + * \brief Set the Chemical source term + * \param[in] val_source_term_i - Value of the chemical source term at i. + * \param[in] val_source_term_j - Value of the chemical source term at j + */ + inline void SetChemicalSourceTerm(const su2double* val_source_term_i, + const su2double* val_source_term_j) { + Chemical_Source_Term_i = val_source_term_i; + Chemical_Source_Term_j = val_source_term_j; + } + /*! * \brief Set the laminar viscosity. * \param[in] val_laminar_viscosity_i - Value of the laminar viscosity at point i. diff --git a/SU2_CFD/include/numerics/species/species_sources.hpp b/SU2_CFD/include/numerics/species/species_sources.hpp index fb95e4146990..0a195eb857a4 100644 --- a/SU2_CFD/include/numerics/species/species_sources.hpp +++ b/SU2_CFD/include/numerics/species/species_sources.hpp @@ -91,3 +91,33 @@ class CSourceAxisymmetric_Species : public CSourceBase_Species { ResidualType<> ComputeResidual(const CConfig* config) override; }; + +/*! + * \class CSourceCombustion_Species + * \brief Class for source term for combustion problems. + * \ingroup SourceDiscr + * \author C.Morales Ubal + */ +template +class CSourceCombustion_Species : public CSourceBase_Species { + protected: + const FlowIndices idx; /*!< \brief Object to manage the access to the flow primitives. */ + const bool incompressible; + + public: + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimensions of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CSourceCombustion_Species(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); + + /*! + * \brief Residual of the axisymmetric source term. + * \param[in] config - Definition of the particular problem. + * \return Lightweight const-view of residual and Jacobian. + */ + ResidualType<> ComputeResidual(const CConfig* config) override; + +}; diff --git a/SU2_CFD/include/variables/CSpeciesVariable.hpp b/SU2_CFD/include/variables/CSpeciesVariable.hpp index faeca8fa7194..951e6392f04c 100644 --- a/SU2_CFD/include/variables/CSpeciesVariable.hpp +++ b/SU2_CFD/include/variables/CSpeciesVariable.hpp @@ -36,6 +36,7 @@ class CSpeciesVariable : public CScalarVariable { protected: MatrixType Diffusivity; /*!< \brief Matrix (nPoint,nVar) of mass diffusivities for scalar transport. */ + MatrixType SpeciesSourceTerm; /*!< \brief Matrix (nPoint, nVar) of chemical source terms for species transport*/ public: static constexpr size_t MAXNVAR = 20; /*!< \brief Max number of variables for static arrays. Increase, if necessary. */ @@ -74,4 +75,28 @@ class CSpeciesVariable : public CScalarVariable { * \return Pointer to the mass diffusivities */ inline const su2double* GetDiffusivity(unsigned long iPoint) const { return Diffusivity[iPoint]; } + + /*! + * \brief Set the value of the chemical source term for species transport + * \param[in] val_sourceTerm - the chemical source term. + * \param[in] val_ivar - eqn. index to the chemical source term. + */ + inline void SetChemicalSourceTerm(unsigned long iPoint, su2double val_sourceTerm, unsigned short val_ivar) { + SpeciesSourceTerm(iPoint, val_ivar) = val_sourceTerm; + } + + /*! + * \brief Get the value of the chemical source term for species transport + * \param[in] val_ivar - eqn. index to the chemical source term. + * \return Value of the chemical source term. + */ + inline su2double GetChemicalSourceTerm(unsigned long iPoint, unsigned short val_ivar) const { + return SpeciesSourceTerm(iPoint, val_ivar); + } + + /*! + * \brief Get the value of the chemical source term for species transport + * \return Pointer to the chemical source term + */ + inline const su2double* GetChemicalSourceTerm(unsigned long iPoint) const { return SpeciesSourceTerm[iPoint]; } }; diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 015e808b6269..c3d00cac72a6 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -1415,7 +1415,11 @@ void CDriver::InstantiateSpeciesNumerics(unsigned short nVar_Species, int offset else { numerics[iMGlevel][SPECIES_SOL][source_first_term] = new CSourceNothing(nDim, nVar_Species, config); } - numerics[iMGlevel][SPECIES_SOL][source_second_term] = new CSourceNothing(nDim, nVar_Species, config); + if (config->GetCombustion() == YES) { + numerics[iMGlevel][SPECIES_SOL][source_second_term] = new CSourceCombustion_Species(nDim, nVar_Species, config); + } else { + numerics[iMGlevel][SPECIES_SOL][source_second_term] = new CSourceNothing(nDim, nVar_Species, config); + } } } diff --git a/SU2_CFD/src/numerics/species/species_sources.cpp b/SU2_CFD/src/numerics/species/species_sources.cpp index 04018580eb1a..f1216c32b255 100644 --- a/SU2_CFD/src/numerics/species/species_sources.cpp +++ b/SU2_CFD/src/numerics/species/species_sources.cpp @@ -135,7 +135,51 @@ CNumerics::ResidualType<> CSourceAxisymmetric_Species::ComputeResidual(const return ResidualType<>(residual, jacobian, nullptr); } +template +CSourceCombustion_Species::CSourceCombustion_Species(unsigned short val_nDim, unsigned short val_nVar, + const CConfig* config) + : CSourceBase_Species(val_nDim, val_nVar, config), + idx(val_nDim, config->GetnSpecies()), + incompressible(config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE) {} + +template +CNumerics::ResidualType<> CSourceCombustion_Species::ComputeResidual(const CConfig* config) { + /*--- Preaccumulation ---*/ + AD::StartPreacc(); + AD::SetPreaccIn(ScalarVar_i, nVar); + AD::SetPreaccIn(Volume); + AD::SetPreaccIn(Chemical_Source_Term_i, nVar); + + if (incompressible) { + AD::SetPreaccIn(V_i, nDim+6); + } + else { + AD::SetPreaccIn(V_i, nDim+7); + } + + /*--- Initialization. ---*/ + for (auto iVar = 0u; iVar < nVar; iVar++) { + residual[iVar] = 0.0; + for (auto jVar = 0; jVar < nVar; jVar++) { + jacobian[iVar][jVar] = 0.0; + } + } + + for (auto iVar = 0u; iVar < nVar; iVar++) { + residual[iVar] += Volume * Chemical_Source_Term_i[iVar]; + } + + + AD::SetPreaccOut(residual, nVar); + AD::EndPreacc(); + + return ResidualType<>(residual, jacobian, nullptr); +} + /*--- Explicit instantiations until we don't move this to the hpp. ---*/ template class CSourceAxisymmetric_Species >; template class CSourceAxisymmetric_Species >; template class CSourceAxisymmetric_Species >; +template class CSourceCombustion_Species >; +template class CSourceCombustion_Species >; +template class CSourceCombustion_Species >; diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index 9d7c4494c516..dfb1adc71909 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -305,6 +305,11 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain for (auto iVar = 0u; iVar <= nVar; iVar++) { const su2double mass_diffusivity = solver_container[FLOW_SOL]->GetFluidModel()->GetMassDiffusivity(iVar); nodes->SetDiffusivity(iPoint, mass_diffusivity, iVar); + if (config->GetCombustion() == true) { + //const su2double chemical_source_term=solver_container[FLOW_SOL]->GetFluidModel()->GetMassDiffusivity(iVar); + const su2double chemical_source_term = 0.0; + nodes->SetChemicalSourceTerm(iPoint, chemical_source_term, iVar); + } } } // iPoint @@ -524,6 +529,7 @@ void CSpeciesSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool axisymmetric = config->GetAxisymmetric(); + const bool combustion =config->GetCombustion(); if (axisymmetric) { CNumerics *numerics = numerics_container[SOURCE_FIRST_TERM + omp_get_thread_num()*MAX_TERMS]; @@ -568,4 +574,31 @@ void CSpeciesSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta } END_SU2_OMP_FOR } + if (combustion) { + CNumerics* numerics = numerics_container[SOURCE_SECOND_TERM + omp_get_thread_num() * MAX_TERMS]; + + SU2_OMP_FOR_DYN(omp_chunk_size) + for (auto iPoint = 0u; iPoint < nPointDomain; iPoint++) { + /*--- Set Chemical Source Term ---*/ + + numerics->SetChemicalSourceTerm(nodes->GetChemicalSourceTerm(iPoint), nullptr); + + /*--- Set volume of the dual cell. ---*/ + + numerics->SetVolume(geometry->nodes->GetVolume(iPoint)); + + /*--- Update scalar sources in the fluidmodel ---*/ + + auto residual = numerics->ComputeResidual(config); + + /*--- Add Residual ---*/ + + LinSysRes.SubtractBlock(iPoint, residual); + + /*--- Implicit part ---*/ + + if (implicit) Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); + } + END_SU2_OMP_FOR + } } diff --git a/SU2_CFD/src/variables/CSpeciesVariable.cpp b/SU2_CFD/src/variables/CSpeciesVariable.cpp index 5715ae784cab..1dab91b91a44 100644 --- a/SU2_CFD/src/variables/CSpeciesVariable.cpp +++ b/SU2_CFD/src/variables/CSpeciesVariable.cpp @@ -30,8 +30,9 @@ CSpeciesVariable::CSpeciesVariable(const su2double* species_inf, unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig* config) : CScalarVariable(npoint, ndim, nvar, config) { - /*--- Allocate space for the mass diffusivity. ---*/ + /*--- Allocate space for the mass diffusivity and chemical source term. ---*/ Diffusivity.resize(nPoint, nVar + 1) = su2double(0.0); + SpeciesSourceTerm.resize(nPoint, nVar + 1) = su2double(0.0); for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) for (unsigned long iVar = 0; iVar < nVar; iVar++) diff --git a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg index 0fa999ed87b4..f607e4169b73 100644 --- a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg +++ b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg @@ -31,6 +31,7 @@ INC_NONDIM= DIMENSIONAL % -------------------- FLUID PROPERTIES ------------------------------------- % % FLUID_MODEL= FLUID_CANTERA +COMBUSTION = YES % THERMODYNAMIC_PRESSURE= 101325.0 % diff --git a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp index 343de4d6befd..a06223b037dd 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp @@ -66,7 +66,7 @@ TEST_CASE("Fluid_Cantera", "[Multicomponent_flow]") { su2double density = auxFluidModel->GetDensity(); su2double cp = auxFluidModel->GetCp(); - CHECK(density == Approx(0.92424)); - CHECK(cp == Approx(1277.9)); + CHECK(density == Approx(0.924236)); + CHECK(cp == Approx(1277.91)); } #endif \ No newline at end of file From dfed203d15d98cbf07826086a6b75d19313c8c80 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 4 Oct 2024 13:33:54 +0200 Subject: [PATCH 032/173] define DIFFUSIVITY_MODEL=CANTERA , transport model defines the diffusivity model --- Common/include/option_structure.hpp | 4 ++-- Common/src/CConfig.cpp | 4 ++-- SU2_CFD/include/fluid/CFluidCantera.hpp | 1 - SU2_CFD/src/fluid/CFluidCantera.cpp | 20 ++++++------------- SU2_CFD/src/fluid/CFluidModel.cpp | 4 ++-- .../SU2_CFD/fluid/multicomponent_cantera.cfg | 2 +- 6 files changed, 13 insertions(+), 22 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 71c68f6d6520..abe7185341df 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -737,7 +737,7 @@ enum class DIFFUSIVITYMODEL { UNITY_LEWIS, /*!< \brief Unity Lewis model for mass diffusion in scalar transport. */ CONSTANT_LEWIS, /*!< \brief Different Lewis number model for mass diffusion in scalar transport. */ FLAMELET, /*!< \brief flamelet model for tabulated chemistry, diffusivity from lookup table */ - MIXTURE_AVERAGED, /*!< \brief Mixture average diffusivity from CANTERA */ + CANTERA, /*!< \brief Mixture average diffusivity from CANTERA */ }; static const MapType Diffusivity_Model_Map = { @@ -746,7 +746,7 @@ static const MapType Diffusivity_Model_Map = { MakePair("UNITY_LEWIS", DIFFUSIVITYMODEL::UNITY_LEWIS) MakePair("CONSTANT_LEWIS", DIFFUSIVITYMODEL::CONSTANT_LEWIS) MakePair("FLAMELET", DIFFUSIVITYMODEL::FLAMELET) - MakePair("MIXTURE_AVERAGED", DIFFUSIVITYMODEL::MIXTURE_AVERAGED) + MakePair("CANTERA", DIFFUSIVITYMODEL::CANTERA) }; /*! diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 41e995289fe8..a981a7b275a1 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -4078,8 +4078,8 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i CURRENT_FUNCTION); } - if (Kind_Diffusivity_Model != DIFFUSIVITYMODEL::UNITY_LEWIS && Kind_Diffusivity_Model != DIFFUSIVITYMODEL::MIXTURE_AVERAGED) { - SU2_MPI::Error("The use of FLUID_CANTERA requires the DIFFUSIVITY_MODEL option to be UNITY_LEWIS or MIXTURE_AVERAGED", + if (Kind_Diffusivity_Model != DIFFUSIVITYMODEL::CANTERA) { + SU2_MPI::Error("The use of FLUID_CANTERA requires the DIFFUSIVITY_MODEL option to be CANTERA", CURRENT_FUNCTION); } } diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 1a268cffd9df..3bfb3609e631 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -56,7 +56,6 @@ class CFluidCantera final : public CFluidModel { const string Transport_Model; /*!< \brief Transport model used for computing mixture properties*/ const string Chemical_MechanismFile; /*!< \brief Chemical reaction mechanism used for in cantera*/ const string Phase_Name; /*!< \brief Name of the phase used for in cantera*/ - const bool Unity_Lewis; /*!< \brief Bool for using UNITY_LEWIS as diffusivity model*/ static constexpr int ARRAYSIZE = 16; #ifdef USE_CANTERA diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 97565981c9d1..8aee03522bea 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -49,8 +49,7 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* Prandtl_Number(config->GetPrandtl_Turb()), Transport_Model(config->GetTransport_Model()), Chemical_MechanismFile(config->GetChemical_MechanismFile()), - Phase_Name(config->GetPhase_Name()), - Unity_Lewis(config->GetKind_Diffusivity_Model()==DIFFUSIVITYMODEL::UNITY_LEWIS){ + Phase_Name(config->GetPhase_Name()){ if (n_species_mixture > ARRAYSIZE) { SU2_MPI::Error("Too many species, increase ARRAYSIZE", CURRENT_FUNCTION); } @@ -73,18 +72,11 @@ void CFluidCantera::SetMassDiffusivityModel(const CConfig* config) { #ifdef USE_CANTERA void CFluidCantera::ComputeMassDiffusivity() { - if (Unity_Lewis) { - for (int iVar = 0; iVar < n_species_mixture; iVar++) { - MassDiffusivityPointers[iVar]->SetDiffusivity(Density, Mu, Cp, Kt); - massDiffusivity[iVar] = MassDiffusivityPointers[iVar]->GetDiffusivity(); - } - } else { - int nsp = sol->thermo()->nSpecies(); - vector diff(nsp); - sol->transport()->getMixDiffCoeffsMass(&diff[0]); - for (int iVar = 0; iVar < n_species_mixture; iVar++) { - massDiffusivity[iVar] = diff[sol->thermo()->speciesIndex(gasComposition[iVar])]; - } + int nsp = sol->thermo()->nSpecies(); + vector diff(nsp); + sol->transport()->getMixDiffCoeffsMass(&diff[0]); + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + massDiffusivity[iVar] = diff[sol->thermo()->speciesIndex(gasComposition[iVar])]; } } diff --git a/SU2_CFD/src/fluid/CFluidModel.cpp b/SU2_CFD/src/fluid/CFluidModel.cpp index a384d7542f8e..6ebd36cca7a3 100644 --- a/SU2_CFD/src/fluid/CFluidModel.cpp +++ b/SU2_CFD/src/fluid/CFluidModel.cpp @@ -151,8 +151,8 @@ unique_ptr CFluidModel::MakeMassDiffusivityModel(const CConfi /*--- Diffusivity is obtained from the LUT ---*/ return nullptr; break; - case DIFFUSIVITYMODEL::MIXTURE_AVERAGED: - /*--- Diffusivity is obtained from CANTERA using mixture averaged model---*/ + case DIFFUSIVITYMODEL::CANTERA: + /*--- Diffusivity is obtained from CANTERA. Transport model option determines the diffusivity model---*/ return nullptr; break; default: diff --git a/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg b/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg index d9eb356c3082..c4b6226822f8 100644 --- a/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg +++ b/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg @@ -34,6 +34,6 @@ TRANSPORT_MODEL= mixture-averaged % -------------------- SCALAR TRANSPORT ---------------------------------------% % KIND_SCALAR_MODEL= SPECIES_TRANSPORT -DIFFUSIVITY_MODEL= UNITY_LEWIS +DIFFUSIVITY_MODEL= CANTERA % SPECIES_INIT= 0.020137986304114414,0.22830757006769173 From df2ea0c8dcaf655e46739200c97e4f0b2a83cf39 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 8 Oct 2024 15:42:50 +0200 Subject: [PATCH 033/173] adding chemical source term --- SU2_CFD/include/fluid/CFluidCantera.hpp | 14 +++++++++- SU2_CFD/include/fluid/CFluidModel.hpp | 6 +++++ SU2_CFD/src/fluid/CFluidCantera.cpp | 13 ++++++++++ SU2_CFD/src/solvers/CSpeciesSolver.cpp | 3 +-- .../SU2_CFD/fluid/CFluidCantera_tests.cpp | 26 +++++++++++++++++++ .../SU2_CFD/fluid/multicomponent_cantera.cfg | 5 ++-- 6 files changed, 62 insertions(+), 5 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 3bfb3609e631..03d206455483 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -36,7 +36,7 @@ #define USE_CANTERA namespace Cantera { class Solution; -class ThermoPhase; +//class ThermoPhase; } #endif @@ -61,6 +61,7 @@ class CFluidCantera final : public CFluidModel { #ifdef USE_CANTERA std::array gasComposition; /*!< \brief Gas composition. */ std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ + std::array chemicalSourceTerm; /*!< \brief chemical source term of all species*/ #endif std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ std::unique_ptr MassDiffusivityPointers[ARRAYSIZE]; @@ -78,6 +79,11 @@ class CFluidCantera final : public CFluidModel { */ void ComputeMassDiffusivity(); + /*! + * \brief Compute mass diffusivity for species. + */ + void ComputeChemicalSourceTerm(); + public: /*! * \brief Constructor of the class. @@ -106,6 +112,12 @@ class CFluidCantera final : public CFluidModel { inline su2double GetMassDiffusivity(int ivar) override { return massDiffusivity[ivar]; } #ifdef USE_CANTERA + /*! + * \brief Get Chemical source term species. + * \param[in] ivar - index of species. + */ + inline su2double GetChemicalSourceTerm(int ivar) override { return chemicalSourceTerm[ivar]; } + /*! * \brief Set the Dimensionless State using Temperature. * \param[in] t - Temperature value at the point. diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 30766e7b5431..05e095af0a5b 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -186,6 +186,12 @@ class CFluidModel { return mass_diffusivity; } + /*! + * \brief Get Chemical source term species. + * \param[in] iVar - index of species. + */ + inline virtual su2double GetChemicalSourceTerm(int iVar) { return 0.0; } + /*! * \brief Get fluid pressure partial derivative. */ diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 8aee03522bea..2979384ea44f 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -34,6 +34,7 @@ #include "../../Common/include/basic_types/ad_structure.hpp" #include "/home/cristopher/codes/cantera/include/cantera/core.h" +#include "/home/cristopher/codes/cantera/include/cantera/kinetics/Reaction.h" #include #include @@ -80,6 +81,17 @@ void CFluidCantera::ComputeMassDiffusivity() { } } +void CFluidCantera::ComputeChemicalSourceTerm(){ + vector netProductionRates(sol->kinetics()->nReactions()); + vector molecularWeights(sol->thermo()->nSpecies()); + sol->kinetics()->getNetProductionRates(&netProductionRates[0]); + sol->thermo()->getMolecularWeights(&molecularWeights[0]); + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); + chemicalSourceTerm[iVar] = molecularWeights[speciesIndex]*netProductionRates[speciesIndex]; + } +} + string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars) { su2double val_scalars_sum{0.0}; chemical_composition=""; @@ -103,5 +115,6 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl Kt = sol->transport()->thermalConductivity(); ComputeMassDiffusivity(); + ComputeChemicalSourceTerm(); } #endif \ No newline at end of file diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index dfb1adc71909..8d2590fe22ed 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -306,8 +306,7 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain const su2double mass_diffusivity = solver_container[FLOW_SOL]->GetFluidModel()->GetMassDiffusivity(iVar); nodes->SetDiffusivity(iPoint, mass_diffusivity, iVar); if (config->GetCombustion() == true) { - //const su2double chemical_source_term=solver_container[FLOW_SOL]->GetFluidModel()->GetMassDiffusivity(iVar); - const su2double chemical_source_term = 0.0; + const su2double chemical_source_term=solver_container[FLOW_SOL]->GetFluidModel()->GetChemicalSourceTerm(iVar); nodes->SetChemicalSourceTerm(iPoint, chemical_source_term, iVar); } } diff --git a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp index a06223b037dd..ee41faa0a228 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp @@ -69,4 +69,30 @@ TEST_CASE("Fluid_Cantera", "[Multicomponent_flow]") { CHECK(density == Approx(0.924236)); CHECK(cp == Approx(1277.91)); } +TEST_CASE("Fluid_Cantera_Combustion", "[Reacting_flow]") { + /*--- Cantera fluid model unit test cases ---*/ + + SU2_COMPONENT val_software = SU2_COMPONENT::SU2_CFD; + CConfig* config = new CConfig("multicomponent_cantera.cfg", val_software, true); + CFluidCantera* auxFluidModel = nullptr; + + /*--- Create Cantera fluid model ---*/ + su2double value_pressure_operating = config->GetPressure_Thermodynamic(); + auxFluidModel= new CFluidCantera(value_pressure_operating, config); + + /*--- get scalar from config file and set temperature ---*/ + + const su2double* scalar = nullptr; + scalar=config->GetSpecies_Init(); + const su2double Temperature = 1900.0; + /*--- Set state using temperature and scalar ---*/ + auxFluidModel->SetTDState_T(Temperature, scalar); + + /*--- check values for source terms ---*/ + + su2double sourceTerm_H2 = auxFluidModel->GetChemicalSourceTerm(0); + su2double sourceTerm_O2 = auxFluidModel->GetChemicalSourceTerm(1); + CHECK(sourceTerm_H2 == Approx(-0.136338463240109)); + CHECK(sourceTerm_O2 == Approx(-2.16320837966703)); +} #endif \ No newline at end of file diff --git a/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg b/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg index c4b6226822f8..7bf883b55686 100644 --- a/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg +++ b/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg @@ -22,13 +22,14 @@ INC_NONDIM= DIMENSIONAL % -------------------- FLUID PROPERTIES ------------------------------------- % % FLUID_MODEL= FLUID_CANTERA +COMBUSTION= YES % CONDUCTIVITY_MODEL= CANTERA VISCOSITY_MODEL= CANTERA % GAS_COMPOSITION_NAMES= H2, O2, N2 -CHEMICAL_MECHANISM_FILE= h2o2.yaml -PHASE_NAME= ohmech +CHEMICAL_MECHANISM_FILE= gri30.yaml +PHASE_NAME= gri30 TRANSPORT_MODEL= mixture-averaged % % -------------------- SCALAR TRANSPORT ---------------------------------------% From e68a17a05126dc9a80fad273c77b40a2ff1bc856 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 9 Oct 2024 11:19:35 +0200 Subject: [PATCH 034/173] adding source terms as outputs --- SU2_CFD/include/variables/CVariable.hpp | 7 +++++++ SU2_CFD/src/output/CFlowOutput.cpp | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index bc855bc5dca5..329042ce8dd8 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -1104,6 +1104,13 @@ class CVariable { */ inline virtual su2double GetDiffusivity(unsigned long iPoint, unsigned short val_ivar) const { return 0.0; } + /*! + * \brief A virtual member. + * \param[in] iPoint - Point index. + * \return Value of the chemical source term.. + */ + inline virtual su2double GetChemicalSourceTerm(unsigned long iPoint, unsigned short val_ivar) const { return 0.0; } + /*! * \brief A virtual member. * \param[in] iPoint - Point index. diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index e2af0d0dc3c8..27b6ba686fa0 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -1394,6 +1394,9 @@ void CFlowOutput::SetVolumeOutputFieldsScalarPrimitive(const CConfig* config) { case SPECIES_MODEL::SPECIES_TRANSPORT: for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++){ AddVolumeOutput("DIFFUSIVITY_" + std::to_string(iVar), "Diffusivity_" + std::to_string(iVar), "PRIMITIVE", "Diffusivity of the transported species " + std::to_string(iVar)); + if(config->GetCombustion()==true) { + AddVolumeOutput("CHEMICAL_SOURCE_TERM_" + std::to_string(iVar), "Chemical_Source_Term_" + std::to_string(iVar), "PRIMITIVE", "Chemical source term of the transported species " + std::to_string(iVar)); + } } break; default: @@ -1577,6 +1580,7 @@ void CFlowOutput::LoadVolumeDataScalar(const CConfig* config, const CSolver* con SetVolumeOutputValue("SPECIES_" + std::to_string(iVar), iPoint, Node_Species->GetSolution(iPoint, iVar)); SetVolumeOutputValue("RES_SPECIES_" + std::to_string(iVar), iPoint, solver[SPECIES_SOL]->LinSysRes(iPoint, iVar)); SetVolumeOutputValue("DIFFUSIVITY_"+ std::to_string(iVar), iPoint, Node_Species->GetDiffusivity(iPoint,iVar)); + if (config->GetCombustion()==true) SetVolumeOutputValue("CHEMICAL_SOURCE_TERM_"+ std::to_string(iVar), iPoint, Node_Species->GetChemicalSourceTerm(iPoint,iVar)); if (config->GetKind_SlopeLimit_Species() != LIMITER::NONE) SetVolumeOutputValue("LIMITER_SPECIES_" + std::to_string(iVar), iPoint, Node_Species->GetLimiter(iPoint, iVar)); } From 24ffda21db3dee4304b3e5c54b9d852e671a0f72 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 9 Oct 2024 18:15:43 +0200 Subject: [PATCH 035/173] adding ignition and saving marker inlet composition for future implementations --- Common/include/CConfig.hpp | 22 +++++++++++ Common/src/CConfig.cpp | 38 +++++++++++++++++++ SU2_CFD/src/solvers/CSpeciesSolver.cpp | 26 ++++++++++++- .../species2_primitiveVenturi_CANTERA.cfg | 2 +- .../SU2_CFD/fluid/multicomponent_cantera.cfg | 1 + 5 files changed, 87 insertions(+), 2 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 230f0a390b6d..71f1a0abb395 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -86,6 +86,7 @@ class CConfig { string PhaseName; /*!< \brief Name of the phase in the chemical mechanism file used in cantera*/ unsigned short n_GasCompositionNames; /*!<\brief number of gases in mixture composition for cantera */ bool Combustion; /*!< \brief Flag for Combustion Detailed chemistry problems using Cantera */ + su2double Spark_Temperature; /*!< \bried Spark temperature used for ignition in detailed chemistry using Cantera*/ string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */ unsigned short nConvField; /*!< \brief Number of fields used to monitor convergence.*/ @@ -202,7 +203,9 @@ class CConfig { nMarker_ContactResistance, /*!< \brief Number of CHT interfaces with contact resistance. */ nMarker_Inlet, /*!< \brief Number of inlet flow markers. */ nMarker_Inlet_Species, /*!< \brief Number of inlet species markers. */ + //nMarker_Inlet_Composition, /*!< \brief Number of inlet composition markers. */ nSpecies_per_Inlet, /*!< \brief Number of species defined per inlet markers. */ + //nComposition_per_Inlet, /*!< \brief Number of composition names defined per inlet markers. */ nMarker_Inlet_Turb, /*!< \brief Number of inlet turbulent markers. */ nTurb_Properties, /*!< \brief Number of turbulent properties per inlet markers. */ nMarker_Riemann, /*!< \brief Number of Riemann flow markers. */ @@ -258,6 +261,7 @@ class CConfig { *Marker_ActDiskBemOutlet_Axis, /*!< \brief Actuator disk BEM outlet markers passed to MARKER_ACTDISK_BEM_AXIS. */ *Marker_Inlet, /*!< \brief Inlet flow markers. */ *Marker_Inlet_Species, /*!< \brief Inlet species markers. */ + //*Marker_Inlet_Composition, /*!< \brief Inlet composition markers. */ *Marker_Inlet_Turb, /*!< \brief Inlet turbulent markers. */ *Marker_Riemann, /*!< \brief Riemann markers. */ *Marker_Giles, /*!< \brief Giles markers. */ @@ -296,6 +300,7 @@ class CConfig { su2double *Inlet_Pressure; /*!< \brief Specified static pressures for supersonic inlet boundaries. */ su2double **Inlet_Velocity; /*!< \brief Specified flow velocity vectors for supersonic inlet boundaries. */ su2double **Inlet_SpeciesVal; /*!< \brief Specified species vector for inlet boundaries. */ + //string **Inlet_CompositionVal; /*!< \brief Specified species vector for inlet boundaries. */ su2double **Inlet_TurbVal; /*!< \brief Specified turbulent intensity and viscosity ratio for inlet boundaries. */ su2double *EngineInflow_Target; /*!< \brief Specified fan face targets for nacelle boundaries. */ su2double *Inflow_Mach; /*!< \brief Specified fan face mach for nacelle boundaries. */ @@ -1366,6 +1371,9 @@ class CConfig { void addInletSpeciesOption(const string& name, unsigned short & nMarker_Inlet_Species, string * & Marker_Inlet_Species, su2double** & inlet_species_val, unsigned short & nSpecies_per_Inlet); + + // void addInletCompositionOption(const string& name, unsigned short & nMarker_Inlet_Composition, string * & Marker_Inlet_Composition, + // string** & inlet_composition_val, unsigned short & nComposition_per_Inlet); void addInletTurbOption(const string& name, unsigned short& nMarker_Inlet_Turb, string*& Marker_Inlet_Turb, su2double** & Turb_Properties, unsigned short & nTurb_Properties); @@ -4016,6 +4024,13 @@ class CConfig { */ bool GetCombustion(void) const { return Combustion; } + /*! + * \brief Get High temperature applied during spark ignition. + */ + const su2double GetSpark_Temperature(void) const { + return Spark_Temperature; + } + /*! * \brief Option to define the density model for incompressible flows. * \return Density model option @@ -6992,6 +7007,13 @@ class CConfig { */ const su2double* GetInlet_SpeciesVal(const string& val_index) const; + // /*! + // * \brief Get the composition names at an inlet boundary + // * \param[in] val_index - Index corresponding to the inlet boundary. + // * \return The inlet composition names. + // */ + // const string* GetInlet_CompositionVal(const string& val_index) const; + /*! * \brief Get the turbulent properties values at an inlet boundary * \param[in] val_index - Index corresponding to the inlet boundary. diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index a981a7b275a1..18e10745ddd2 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -494,6 +494,16 @@ void CConfig::addInletSpeciesOption(const string& name, unsigned short & nMarker option_map.insert(pair(name, val)); } +// void CConfig::addInletCompositionOption(const string& name, unsigned short & nMarker_Inlet_Composition, +// string * & Marker_Inlet_Composition, string** & inlet_composition_val, +// unsigned short & nComposition_per_Inlet) { +// assert(option_map.find(name) == option_map.end()); +// all_options.insert(pair(name, true)); +// COptionBase* val = new COptionStringValuesList(name, nMarker_Inlet_Composition, Marker_Inlet_Composition, +// inlet_composition_val, nComposition_per_Inlet); +// option_map.insert(pair(name, val)); +// } + void CConfig::addInletTurbOption(const string& name, unsigned short& nMarker_Inlet_Turb, string*& Marker_Inlet_Turb, su2double**& Turb_Properties_val, unsigned short& nTurb_Properties) { assert(option_map.find(name) == option_map.end()); @@ -1195,6 +1205,8 @@ void CConfig::SetConfig_Options() { addStringListOption("GAS_COMPOSITION_NAMES", n_GasCompositionNames, GasCompositionNames); /*\brief COMBUSTION \n DESCRIPTION: Combustion- Detailed chemistry using Cantera \n DEFAULT: false \ingroup Config */ addBoolOption("COMBUSTION", Combustion, false); + /*!\brief SCHMIDT_LAM \n DESCRIPTION: Laminar Schmidt number of mass diffusion \n DEFAULT 1.0 (~for Gases) \ingroup Config*/ + addDoubleOption("SPARK_TEMPERATURE", Spark_Temperature, 1000.0); /*!\par CONFIG_CATEGORY: Data-driven fluid model parameters \ingroup Config*/ /*!\brief INTERPOLATION_METHOD \n DESCRIPTION: Interpolation method used to determine the thermodynamic state of the fluid. \n OPTIONS: See \link DataDrivenMethod_Map \endlink DEFAULT: MLP \ingroup Config*/ @@ -1596,6 +1608,9 @@ void CConfig::SetConfig_Options() { /*!\brief MARKER_INLET_SPECIES \n DESCRIPTION: Inlet Species boundary marker(s) with the following format Inlet Species: (inlet_marker, Species1, Species2, ..., SpeciesN-1, inlet_marker2, Species1, Species2, ...) */ addInletSpeciesOption("MARKER_INLET_SPECIES",nMarker_Inlet_Species, Marker_Inlet_Species, Inlet_SpeciesVal, nSpecies_per_Inlet); + // /*!\brief MARKER_INLET_COMPOSITION \n DESCRIPTION: Inlet Species boundary marker(s) with the following format + // Inlet Species: (inlet_marker, NameSpecies1, NameSpecies2, ..., NameSpeciesN-1, inlet_marker2, NameSpecies1, NameSpecies2, ...) */ + // addInletCompositionOption("MARKER_INLET_COMPOSITION",nMarker_Inlet_Composition, Marker_Inlet_Composition, Inlet_CompositionVal, nComposition_per_Inlet); /*!\brief MARKER_INLET_TURBULENT \n DESCRIPTION: Inlet Turbulence boundary marker(s) with the following format Inlet Turbulent: (inlet_marker, TurbulentIntensity1, ViscosityRatio1, inlet_marker2, TurbulentIntensity2, ViscosityRatio2, ...) */ @@ -4037,6 +4052,13 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i CURRENT_FUNCTION); } + if ((flame_init_type != FLAMELET_INIT_TYPE::SPARK) && (Combustion == true)) { + SU2_MPI::Error( + "The use of COMBUSTION=YES requires the use of FLAME_INIT_METHOD=SPARK,\n" + "Other ignition methods are not currently available", + CURRENT_FUNCTION); + } + if (Kind_FluidModel == FLUID_CANTERA) { /*--- Check whether the number of entries of the GAS_COMPOSITION_NAMES equals the number of transported scalar equations solved + 1.--- */ @@ -7567,6 +7589,15 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) { BoundaryTable.PrintFooter(); } + // if (nMarker_Inlet_Composition != 0) { + // BoundaryTable << "Composition Inlet boundary"; + // for (iMarker_Inlet = 0; iMarker_Inlet < nMarker_Inlet_Composition; iMarker_Inlet++) { + // BoundaryTable << Marker_Inlet_Composition[iMarker_Inlet]; + // if (iMarker_Inlet < nMarker_Inlet_Composition-1) BoundaryTable << " "; + // } + // BoundaryTable.PrintFooter(); + // } + if (nMarker_Riemann != 0) { BoundaryTable << "Riemann boundary"; for (iMarker_Riemann = 0; iMarker_Riemann < nMarker_Riemann; iMarker_Riemann++) { @@ -9127,6 +9158,13 @@ const su2double* CConfig::GetInlet_SpeciesVal(const string& val_marker) const { return Inlet_SpeciesVal[iMarker_Inlet_Species]; } +// const string* CConfig::GetInlet_CompositionVal(const string& val_marker) const { +// unsigned short iMarker_Inlet_Composition; +// for (iMarker_Inlet_Composition = 0; iMarker_Inlet_Composition < nMarker_Inlet_Composition; iMarker_Inlet_Composition++) +// if (Marker_Inlet_Composition[iMarker_Inlet_Composition] == val_marker) break; +// return Inlet_CompositionVal[iMarker_Inlet_Composition]; +// } + const su2double* CConfig::GetInlet_TurbVal(const string& val_marker) const { /*--- If Turbulent Inlet is not provided for the marker, return free stream values. ---*/ for (auto iMarker = 0u; iMarker < nMarker_Inlet_Turb; iMarker++) { diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index 8d2590fe22ed..4ce4440e5a72 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -293,12 +293,36 @@ void CSpeciesSolver::LoadRestart(CGeometry** geometry, CSolver*** solver, CConfi void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_container, CConfig* config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { + unsigned long spark_iter_start, spark_duration; + bool ignition = false; + su2double temperature; + + /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ + if ((config->GetFlameletInitType() == FLAMELET_INIT_TYPE::SPARK) && !config->GetRestart()) { + auto spark_init = config->GetFlameInit(); + spark_iter_start = ceil(spark_init[4]); + spark_duration = ceil(spark_init[5]); + unsigned long iter = config->GetMultizone_Problem() ? config->GetOuterIter() : config->GetInnerIter(); + ignition = ((iter >= spark_iter_start) && (iter <= (spark_iter_start + spark_duration)) && !config->GetRestart()); + } SU2_OMP_SAFE_GLOBAL_ACCESS(config->SetGlobalParam(config->GetKind_Solver(), RunTime_EqSystem);) /*--- Set the laminar mass Diffusivity for the species solver. ---*/ SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0u; iPoint < nPoint; iPoint++) { - const su2double temperature = solver_container[FLOW_SOL]->GetNodes()->GetTemperature(iPoint); + if (ignition) { + /*--- Apply source terms within spark radius. ---*/ + su2double dist_from_center = 0, spark_radius = config->GetFlameInit()[3]; + dist_from_center = + GeometryToolbox::SquaredDistance(nDim, geometry->nodes->GetCoord(iPoint), config->GetFlameInit()); + if (dist_from_center < pow(spark_radius, 2)) { + temperature = config->GetSpark_Temperature(); + } else { + temperature = solver_container[FLOW_SOL]->GetNodes()->GetTemperature(iPoint); + } + } else { + temperature = solver_container[FLOW_SOL]->GetNodes()->GetTemperature(iPoint); + } const su2double* scalar = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint); solver_container[FLOW_SOL]->GetFluidModel()->SetMassDiffusivityModel(config); solver_container[FLOW_SOL]->GetFluidModel()->SetTDState_T(temperature, scalar); diff --git a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg index f607e4169b73..e08ccbb5e40c 100644 --- a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg +++ b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg @@ -31,7 +31,7 @@ INC_NONDIM= DIMENSIONAL % -------------------- FLUID PROPERTIES ------------------------------------- % % FLUID_MODEL= FLUID_CANTERA -COMBUSTION = YES +COMBUSTION = NO % THERMODYNAMIC_PRESSURE= 101325.0 % diff --git a/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg b/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg index 7bf883b55686..9aee44ca3feb 100644 --- a/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg +++ b/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg @@ -23,6 +23,7 @@ INC_NONDIM= DIMENSIONAL % FLUID_MODEL= FLUID_CANTERA COMBUSTION= YES +FLAME_INIT_METHOD= SPARK % CONDUCTIVITY_MODEL= CANTERA VISCOSITY_MODEL= CANTERA From 368d6021cf79c3f0806fe04661d2a93672d91ef8 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 10 Oct 2024 00:06:42 +0200 Subject: [PATCH 036/173] adding gas names to outputs for cantera, adding SetChemical_GasComposition --- Common/include/CConfig.hpp | 7 ++++ SU2_CFD/src/fluid/CFluidCantera.cpp | 1 + SU2_CFD/src/output/CFlowOutput.cpp | 56 ++++++++++++++++++++++------- 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 71f1a0abb395..0774713bd7f5 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -4018,6 +4018,13 @@ class CConfig { */ string GetChemical_GasComposition(unsigned short val_index = 0) const { return GasCompositionNames[val_index]; } + /*! + * \brief Set the gas composition used in Cantera. + */ + void SetChemical_GasComposition(unsigned short val_index, string gas_composition) const { + GasCompositionNames[val_index] = gas_composition; + } + /*! * \brief Get information about the Combustion-Detailed chemistry usin Cantera problems. * \return TRUE if combustion-detailed chemistry using Cantera is used; otherwise FALSE. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 2979384ea44f..7a5b3fa743d8 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -58,6 +58,7 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* #ifdef USE_CANTERA for (int iVar = 0; iVar < n_species_mixture; iVar++) { gasComposition[iVar]=config->GetChemical_GasComposition(iVar); + //config->SetChemical_GasComposition(iVar, gasComposition[iVar]); //this should be used for later } sol = std::shared_ptr(newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model)); #endif diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 27b6ba686fa0..568bd8e977e1 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -1270,8 +1270,14 @@ void CFlowOutput::SetVolumeOutputFieldsScalarSolution(const CConfig* config){ switch (config->GetKind_Species_Model()) { case SPECIES_MODEL::SPECIES_TRANSPORT: - for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++){ - AddVolumeOutput("SPECIES_" + std::to_string(iVar), "Species_" + std::to_string(iVar), "SOLUTION", "Species_" + std::to_string(iVar) + " mass fraction"); + for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { + if (config->GetKind_FluidModel() == FLUID_CANTERA) { + AddVolumeOutput("SPECIES_" + config->GetChemical_GasComposition(iVar), "Species_" + config->GetChemical_GasComposition(iVar), "SOLUTION", + "Species_" + config->GetChemical_GasComposition(iVar) + " mass fraction"); + } else { + AddVolumeOutput("SPECIES_" + std::to_string(iVar), "Species_" + std::to_string(iVar), "SOLUTION", + "Species_" + std::to_string(iVar) + " mass fraction"); + } } break; case SPECIES_MODEL::FLAMELET: @@ -1312,7 +1318,13 @@ void CFlowOutput::SetVolumeOutputFieldsScalarResidual(const CConfig* config) { switch (config->GetKind_Species_Model()) { case SPECIES_MODEL::SPECIES_TRANSPORT: for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++){ - AddVolumeOutput("RES_SPECIES_" + std::to_string(iVar), "Residual_Species_" + std::to_string(iVar), "RESIDUAL", "Residual of the transported species " + std::to_string(iVar)); + if (config->GetKind_FluidModel() == FLUID_CANTERA) { + AddVolumeOutput("RES_SPECIES_" + config->GetChemical_GasComposition(iVar), + "Residual_Species_" + config->GetChemical_GasComposition(iVar), "RESIDUAL", + "Residual of the transported species " + config->GetChemical_GasComposition(iVar)); + } else { + AddVolumeOutput("RES_SPECIES_" + std::to_string(iVar), "Residual_Species_" + std::to_string(iVar), "RESIDUAL", "Residual of the transported species " + std::to_string(iVar)); + } } break; case SPECIES_MODEL::FLAMELET: @@ -1393,9 +1405,16 @@ void CFlowOutput::SetVolumeOutputFieldsScalarPrimitive(const CConfig* config) { switch (config->GetKind_Species_Model()) { case SPECIES_MODEL::SPECIES_TRANSPORT: for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++){ - AddVolumeOutput("DIFFUSIVITY_" + std::to_string(iVar), "Diffusivity_" + std::to_string(iVar), "PRIMITIVE", "Diffusivity of the transported species " + std::to_string(iVar)); - if(config->GetCombustion()==true) { - AddVolumeOutput("CHEMICAL_SOURCE_TERM_" + std::to_string(iVar), "Chemical_Source_Term_" + std::to_string(iVar), "PRIMITIVE", "Chemical source term of the transported species " + std::to_string(iVar)); + if (config->GetKind_FluidModel() == FLUID_CANTERA) { + AddVolumeOutput("DIFFUSIVITY_" + config->GetChemical_GasComposition(iVar), "Diffusivity_" + config->GetChemical_GasComposition(iVar), "PRIMITIVE", + "Diffusivity of the transported species " + config->GetChemical_GasComposition(iVar)); + if (config->GetCombustion() == true) { + AddVolumeOutput("CHEMICAL_SOURCE_TERM_" + config->GetChemical_GasComposition(iVar), + "Chemical_Source_Term_" + config->GetChemical_GasComposition(iVar), "PRIMITIVE", + "Chemical source term of the transported species " + config->GetChemical_GasComposition(iVar)); + } + } else { + AddVolumeOutput("DIFFUSIVITY_" + std::to_string(iVar), "Diffusivity_" + std::to_string(iVar), "PRIMITIVE", "Diffusivity of the transported species " + std::to_string(iVar)); } } break; @@ -1577,12 +1596,25 @@ void CFlowOutput::LoadVolumeDataScalar(const CConfig* config, const CSolver* con case SPECIES_MODEL::SPECIES_TRANSPORT: { const auto Node_Species = solver[SPECIES_SOL]->GetNodes(); for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - SetVolumeOutputValue("SPECIES_" + std::to_string(iVar), iPoint, Node_Species->GetSolution(iPoint, iVar)); - SetVolumeOutputValue("RES_SPECIES_" + std::to_string(iVar), iPoint, solver[SPECIES_SOL]->LinSysRes(iPoint, iVar)); - SetVolumeOutputValue("DIFFUSIVITY_"+ std::to_string(iVar), iPoint, Node_Species->GetDiffusivity(iPoint,iVar)); - if (config->GetCombustion()==true) SetVolumeOutputValue("CHEMICAL_SOURCE_TERM_"+ std::to_string(iVar), iPoint, Node_Species->GetChemicalSourceTerm(iPoint,iVar)); - if (config->GetKind_SlopeLimit_Species() != LIMITER::NONE) - SetVolumeOutputValue("LIMITER_SPECIES_" + std::to_string(iVar), iPoint, Node_Species->GetLimiter(iPoint, iVar)); + if (config->GetKind_FluidModel() == FLUID_CANTERA) { + SetVolumeOutputValue("SPECIES_" + config->GetChemical_GasComposition(iVar), iPoint, Node_Species->GetSolution(iPoint, iVar)); + SetVolumeOutputValue("RES_SPECIES_" + config->GetChemical_GasComposition(iVar), iPoint, + solver[SPECIES_SOL]->LinSysRes(iPoint, iVar)); + SetVolumeOutputValue("DIFFUSIVITY_" + config->GetChemical_GasComposition(iVar), iPoint, + Node_Species->GetDiffusivity(iPoint, iVar)); + if (config->GetCombustion() == true) + SetVolumeOutputValue("CHEMICAL_SOURCE_TERM_" + config->GetChemical_GasComposition(iVar), iPoint, + Node_Species->GetChemicalSourceTerm(iPoint, iVar)); + if (config->GetKind_SlopeLimit_Species() != LIMITER::NONE) + SetVolumeOutputValue("LIMITER_SPECIES_" + config->GetChemical_GasComposition(iVar), iPoint, + Node_Species->GetLimiter(iPoint, iVar)); + } else { + SetVolumeOutputValue("SPECIES_" + std::to_string(iVar), iPoint, Node_Species->GetSolution(iPoint, iVar)); + SetVolumeOutputValue("RES_SPECIES_" + std::to_string(iVar), iPoint, solver[SPECIES_SOL]->LinSysRes(iPoint, iVar)); + SetVolumeOutputValue("DIFFUSIVITY_" + std::to_string(iVar), iPoint, Node_Species->GetDiffusivity(iPoint, iVar)); + if (config->GetKind_SlopeLimit_Species() != LIMITER::NONE) + SetVolumeOutputValue("LIMITER_SPECIES_" + std::to_string(iVar), iPoint, Node_Species->GetLimiter(iPoint, iVar)); + } } break; } From 66e67ac9ff3ee870bb80efd27d0f7521f51c39c1 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 16 Oct 2024 11:59:27 +0200 Subject: [PATCH 037/173] adding species name to flow and adjoint outputs --- SU2_CFD/src/output/CAdjFlowOutput.cpp | 28 +++++++++++++++++----- SU2_CFD/src/output/CFlowOutput.cpp | 34 +++++++++++++++++++++------ SU2_PY/SU2/io/historyMap.py | 34 +++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 13 deletions(-) diff --git a/SU2_CFD/src/output/CAdjFlowOutput.cpp b/SU2_CFD/src/output/CAdjFlowOutput.cpp index 481b63f6fb49..a9b5a129cadd 100644 --- a/SU2_CFD/src/output/CAdjFlowOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowOutput.cpp @@ -57,7 +57,11 @@ void CAdjFlowOutput::AddHistoryOutputFields_AdjScalarRMS_RES(const CConfig* conf if (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) { for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - AddHistoryOutput("RMS_ADJ_SPECIES_" + std::to_string(iVar), "rms[A_rho*Y_" + std::to_string(iVar) + "]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint transported species.", HistoryFieldType::RESIDUAL); + if(config->GetKind_FluidModel()==FLUID_CANTERA){ + AddHistoryOutput("RMS_ADJ_SPECIES_" + config->GetChemical_GasComposition(iVar), "rms[A_rho*Y_" + config->GetChemical_GasComposition(iVar) + "]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint transported species.", HistoryFieldType::RESIDUAL); + }else{ + AddHistoryOutput("RMS_ADJ_SPECIES_" + std::to_string(iVar), "rms[A_rho*Y_" + std::to_string(iVar) + "]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint transported species.", HistoryFieldType::RESIDUAL); + } } } @@ -93,7 +97,11 @@ void CAdjFlowOutput::AddHistoryOutputFields_AdjScalarMAX_RES(const CConfig* conf if (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) { for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - AddHistoryOutput("MAX_ADJ_SPECIES_" + std::to_string(iVar), "max[A_rho*Y_" + std::to_string(iVar) + "]",ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the adjoint transported species.", HistoryFieldType::RESIDUAL); + if(config->GetKind_FluidModel()==FLUID_CANTERA){ + AddHistoryOutput("MAX_ADJ_SPECIES_" + config->GetChemical_GasComposition(iVar), "max[A_rho*Y_" + config->GetChemical_GasComposition(iVar) + "]",ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the adjoint transported species.", HistoryFieldType::RESIDUAL); + }else{ + AddHistoryOutput("MAX_ADJ_SPECIES_" + std::to_string(iVar), "max[A_rho*Y_" + std::to_string(iVar) + "]",ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the adjoint transported species.", HistoryFieldType::RESIDUAL); + } } } @@ -201,10 +209,18 @@ void CAdjFlowOutput::LoadHistoryDataAdjScalar(const CConfig* config, const CSolv if (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) { for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - SetHistoryOutputValue("RMS_ADJ_SPECIES_" + std::to_string(iVar), log10(adjspecies_solver->GetRes_RMS(iVar))); - SetHistoryOutputValue("MAX_ADJ_SPECIES_" + std::to_string(iVar), log10(adjspecies_solver->GetRes_Max(iVar))); - if (multiZone) { - SetHistoryOutputValue("BGS_ADJ_SPECIES_" + std::to_string(iVar), log10(adjspecies_solver->GetRes_BGS(iVar))); + if (config->GetKind_FluidModel() == FLUID_CANTERA) { + SetHistoryOutputValue("RMS_ADJ_SPECIES_" + config->GetChemical_GasComposition(iVar), log10(adjspecies_solver->GetRes_RMS(iVar))); + SetHistoryOutputValue("MAX_ADJ_SPECIES_" + config->GetChemical_GasComposition(iVar), log10(adjspecies_solver->GetRes_Max(iVar))); + if (multiZone) { + SetHistoryOutputValue("BGS_ADJ_SPECIES_" + config->GetChemical_GasComposition(iVar), log10(adjspecies_solver->GetRes_BGS(iVar))); + } + } else { + SetHistoryOutputValue("RMS_ADJ_SPECIES_" + std::to_string(iVar), log10(adjspecies_solver->GetRes_RMS(iVar))); + SetHistoryOutputValue("MAX_ADJ_SPECIES_" + std::to_string(iVar), log10(adjspecies_solver->GetRes_Max(iVar))); + if (multiZone) { + SetHistoryOutputValue("BGS_ADJ_SPECIES_" + std::to_string(iVar), log10(adjspecies_solver->GetRes_BGS(iVar))); + } } } diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 568bd8e977e1..1ca3418a899f 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -990,7 +990,11 @@ void CFlowOutput::AddHistoryOutputFields_ScalarRMS_RES(const CConfig* config) { switch (config->GetKind_Species_Model()) { case SPECIES_MODEL::SPECIES_TRANSPORT: { for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - AddHistoryOutput("RMS_SPECIES_" + std::to_string(iVar), "rms[rho*Y_" + std::to_string(iVar)+"]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of transported species.", HistoryFieldType::RESIDUAL); + if (config->GetKind_FluidModel()==FLUID_CANTERA){ + AddHistoryOutput("RMS_SPECIES_" + config->GetChemical_GasComposition(iVar), "rms[rho*Y_" + config->GetChemical_GasComposition(iVar)+"]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of transported species.", HistoryFieldType::RESIDUAL); + }else{ + AddHistoryOutput("RMS_SPECIES_" + std::to_string(iVar), "rms[rho*Y_" + std::to_string(iVar)+"]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of transported species.", HistoryFieldType::RESIDUAL); + } } break; } @@ -1047,7 +1051,11 @@ void CFlowOutput::AddHistoryOutputFields_ScalarMAX_RES(const CConfig* config) { switch (config->GetKind_Species_Model()) { case SPECIES_MODEL::SPECIES_TRANSPORT: { for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - AddHistoryOutput("MAX_SPECIES_" + std::to_string(iVar), "max[rho*Y_" + std::to_string(iVar)+"]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of transported species.", HistoryFieldType::RESIDUAL); + if (config->GetKind_FluidModel()==FLUID_CANTERA){ + AddHistoryOutput("MAX_SPECIES_" + config->GetChemical_GasComposition(iVar), "max[rho*Y_" + config->GetChemical_GasComposition(iVar)+"]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of transported species.", HistoryFieldType::RESIDUAL); + }else{ + AddHistoryOutput("MAX_SPECIES_" + std::to_string(iVar), "max[rho*Y_" + std::to_string(iVar)+"]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of transported species.", HistoryFieldType::RESIDUAL); + } } break; } @@ -1102,7 +1110,11 @@ void CFlowOutput::AddHistoryOutputFields_ScalarBGS_RES(const CConfig* config) { switch (config->GetKind_Species_Model()) { case SPECIES_MODEL::SPECIES_TRANSPORT: { for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - AddHistoryOutput("BGS_SPECIES_" + std::to_string(iVar), "bgs[rho*Y_" + std::to_string(iVar)+"]", ScreenOutputFormat::FIXED, "BGS_RES", "Maximum residual of transported species.", HistoryFieldType::RESIDUAL); + if (config->GetKind_FluidModel()==FLUID_CANTERA){ + AddHistoryOutput("BGS_SPECIES_" + config->GetChemical_GasComposition(iVar), "bgs[rho*Y_" + config->GetChemical_GasComposition(iVar)+"]", ScreenOutputFormat::FIXED, "BGS_RES", "Maximum residual of transported species.", HistoryFieldType::RESIDUAL); + }else{ + AddHistoryOutput("BGS_SPECIES_" + std::to_string(iVar), "bgs[rho*Y_" + std::to_string(iVar)+"]", ScreenOutputFormat::FIXED, "BGS_RES", "Maximum residual of transported species.", HistoryFieldType::RESIDUAL); + } } break; } @@ -1201,10 +1213,18 @@ void CFlowOutput::LoadHistoryDataScalar(const CConfig* config, const CSolver* co switch(config->GetKind_Species_Model()) { case SPECIES_MODEL::SPECIES_TRANSPORT: { for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - SetHistoryOutputValue("RMS_SPECIES_" + std::to_string(iVar), log10(solver[SPECIES_SOL]->GetRes_RMS(iVar))); - SetHistoryOutputValue("MAX_SPECIES_" + std::to_string(iVar), log10(solver[SPECIES_SOL]->GetRes_Max(iVar))); - if (multiZone) { - SetHistoryOutputValue("BGS_SPECIES_" + std::to_string(iVar), log10(solver[SPECIES_SOL]->GetRes_BGS(iVar))); + if (config->GetKind_FluidModel()==FLUID_CANTERA){ + SetHistoryOutputValue("RMS_SPECIES_" + config->GetChemical_GasComposition(iVar), log10(solver[SPECIES_SOL]->GetRes_RMS(iVar))); + SetHistoryOutputValue("MAX_SPECIES_" + config->GetChemical_GasComposition(iVar), log10(solver[SPECIES_SOL]->GetRes_Max(iVar))); + if (multiZone) { + SetHistoryOutputValue("BGS_SPECIES_" + config->GetChemical_GasComposition(iVar), log10(solver[SPECIES_SOL]->GetRes_BGS(iVar))); + } + }else{ + SetHistoryOutputValue("RMS_SPECIES_" + std::to_string(iVar), log10(solver[SPECIES_SOL]->GetRes_RMS(iVar))); + SetHistoryOutputValue("MAX_SPECIES_" + std::to_string(iVar), log10(solver[SPECIES_SOL]->GetRes_Max(iVar))); + if (multiZone) { + SetHistoryOutputValue("BGS_SPECIES_" + std::to_string(iVar), log10(solver[SPECIES_SOL]->GetRes_BGS(iVar))); + } } } SetHistoryOutputValue("LINSOL_ITER_SPECIES", solver[SPECIES_SOL]->GetIterLinSolver()); diff --git a/SU2_PY/SU2/io/historyMap.py b/SU2_PY/SU2/io/historyMap.py index a477478359c0..57e3d3d549da 100644 --- a/SU2_PY/SU2/io/historyMap.py +++ b/SU2_PY/SU2/io/historyMap.py @@ -238,6 +238,12 @@ "HEADER": 'bgs[rho*Y_" + ' 'std::to_string(iVar)+"]', "TYPE": "RESIDUAL", }, + 'BGS_SPECIES_" + config->GetChemical_GasComposition(iVar': { + "DESCRIPTION": "BGS residual of " "transported species.", + "GROUP": "BGS_RES", + "HEADER": 'bgs[rho*Y_" + ' 'config->GetChemical_GasComposition(iVar)+"]', + "TYPE": "RESIDUAL", + }, "BGS_TEMPERATURE": { "DESCRIPTION": "Block-Gauss-Seidel residual of the " "temperature", "GROUP": "BGS_RES", @@ -798,6 +804,12 @@ "HEADER": 'max[A_rho*Y_" + ' "std::to_string(iVar) + " '"]', "TYPE": "RESIDUAL", }, + 'MAX_ADJ_SPECIES_" + config->GetChemical_GasComposition(iVar': { + "DESCRIPTION": "Maximum residual " "of the adjoint " "transported " "species.", + "GROUP": "MAX_RES", + "HEADER": 'max[A_rho*Y_" + ' "config->GetChemical_GasComposition(iVar) + " '"]', + "TYPE": "RESIDUAL", + }, "MAX_ADJ_TEMPERATURE": { "DESCRIPTION": "Maximum residual of the temperature.", "GROUP": "MAX_RES", @@ -882,6 +894,12 @@ "HEADER": "max[P]", "TYPE": "RESIDUAL", }, + 'MAX_SPECIES_" + config->GetChemical_GasComposition(iVar': { + "DESCRIPTION": "Maximum residual of " "transported species.", + "GROUP": "MAX_RES", + "HEADER": 'max[rho*Y_" + ' 'config->GetChemical_GasComposition(iVar)+"]', + "TYPE": "RESIDUAL", + }, 'MAX_SPECIES_" + std::to_string(iVar': { "DESCRIPTION": "Maximum residual of " "transported species.", "GROUP": "MAX_RES", @@ -1037,6 +1055,16 @@ "HEADER": 'rms[A_rho*Y_" + ' "std::to_string(iVar) + " '"]', "TYPE": "RESIDUAL", }, + 'RMS_ADJ_SPECIES_" + config->GetChemical_GasComposition(iVar': { + "DESCRIPTION": "Root-mean square " + "residual of the " + "adjoint " + "transported " + "species.", + "GROUP": "RMS_RES", + "HEADER": 'rms[A_rho*Y_" + ' "config->GetChemical_GasComposition(iVar) + " '"]', + "TYPE": "RESIDUAL", + }, "RMS_ADJ_TEMPERATURE": { "DESCRIPTION": "Root-mean square residual of the " "adjoint temperature.", "GROUP": "RMS_RES", @@ -1148,6 +1176,12 @@ "HEADER": 'rms[rho*Y_" + ' 'std::to_string(iVar)+"]', "TYPE": "RESIDUAL", }, + 'RMS_SPECIES_" + config->GetChemical_GasComposition(iVar': { + "DESCRIPTION": "Root-mean square " "residual of " "transported species.", + "GROUP": "RMS_RES", + "HEADER": 'rms[rho*Y_" + ' '+ config->GetChemical_GasComposition(iVar)+"]', + "TYPE": "RESIDUAL", + }, "RMS_TEMPERATURE": { "DESCRIPTION": "Root mean square residual of the " "temperature", "GROUP": "RMS_RES", From f1d661dca6da7f3c9bec9dd95fcc9b576f450171 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 16 Oct 2024 14:36:09 +0200 Subject: [PATCH 038/173] adding gas names to SURFACE_SPECIES outputs in history.csv --- SU2_CFD/src/output/CFlowOutput.cpp | 28 +++++++++++++++++++++++----- SU2_PY/SU2/io/historyMap.py | 11 +++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 1ca3418a899f..220046410433 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -83,7 +83,11 @@ void CFlowOutput::AddAnalyzeSurfaceOutput(const CConfig *config){ if (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) { /// DESCRIPTION: Average Species for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - AddHistoryOutput("SURFACE_SPECIES_" + std::to_string(iVar), "Avg_Species_" + std::to_string(iVar), ScreenOutputFormat::FIXED, "SPECIES_COEFF", "Total average species " + std::to_string(iVar) + " on all markers set in MARKER_ANALYZE", HistoryFieldType::COEFFICIENT); + if(config->GetKind_FluidModel()==FLUID_CANTERA){ + AddHistoryOutput("SURFACE_SPECIES_" + config->GetChemical_GasComposition(iVar), "Avg_Species_" + config->GetChemical_GasComposition(iVar), ScreenOutputFormat::FIXED, "SPECIES_COEFF", "Total average species " + config->GetChemical_GasComposition(iVar) + " on all markers set in MARKER_ANALYZE", HistoryFieldType::COEFFICIENT); + }else{ + AddHistoryOutput("SURFACE_SPECIES_" + std::to_string(iVar), "Avg_Species_" + std::to_string(iVar), ScreenOutputFormat::FIXED, "SPECIES_COEFF", "Total average species " + std::to_string(iVar) + " on all markers set in MARKER_ANALYZE", HistoryFieldType::COEFFICIENT); + } } /// DESCRIPTION: Species Variance AddHistoryOutput("SURFACE_SPECIES_VARIANCE", "Species_Variance", ScreenOutputFormat::SCIENTIFIC, "SPECIES_COEFF", "Total species variance, measure for mixing quality. On all markers set in MARKER_ANALYZE", HistoryFieldType::COEFFICIENT); @@ -125,7 +129,11 @@ void CFlowOutput::AddAnalyzeSurfaceOutput(const CConfig *config){ if (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) { /// DESCRIPTION: Average Species for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - AddHistoryOutputPerSurface("SURFACE_SPECIES_" + std::to_string(iVar), "Avg_Species_" + std::to_string(iVar), ScreenOutputFormat::FIXED, "SPECIES_COEFF_SURF", Marker_Analyze, HistoryFieldType::COEFFICIENT); + if(config->GetKind_FluidModel()==FLUID_CANTERA){ + AddHistoryOutputPerSurface("SURFACE_SPECIES_" + config->GetChemical_GasComposition(iVar), "Avg_Species_" + config->GetChemical_GasComposition(iVar), ScreenOutputFormat::FIXED, "SPECIES_COEFF_SURF", Marker_Analyze, HistoryFieldType::COEFFICIENT); + }else{ + AddHistoryOutputPerSurface("SURFACE_SPECIES_" + std::to_string(iVar), "Avg_Species_" + std::to_string(iVar), ScreenOutputFormat::FIXED, "SPECIES_COEFF_SURF", Marker_Analyze, HistoryFieldType::COEFFICIENT); + } } /// DESCRIPTION: Species Variance AddHistoryOutputPerSurface("SURFACE_SPECIES_VARIANCE", "Species_Variance", ScreenOutputFormat::SCIENTIFIC, "SPECIES_COEFF_SURF", Marker_Analyze, HistoryFieldType::COEFFICIENT); @@ -505,7 +513,12 @@ void CFlowOutput::SetAnalyzeSurface(const CSolver* const*solver, const CGeometry if (species) { for (unsigned short iVar = 0; iVar < nSpecies; iVar++) { su2double Species = Surface_Species_Total(iMarker_Analyze, iVar); - SetHistoryOutputPerSurfaceValue("SURFACE_SPECIES_" + std::to_string(iVar), Species, iMarker_Analyze); + if (config->GetKind_FluidModel() == FLUID_CANTERA) { + SetHistoryOutputPerSurfaceValue("SURFACE_SPECIES_" + config->GetChemical_GasComposition(iVar), Species, + iMarker_Analyze); + } else { + SetHistoryOutputPerSurfaceValue("SURFACE_SPECIES_" + std::to_string(iVar), Species, iMarker_Analyze); + } Tot_Surface_Species[iVar] += Species; if (iVar == 0) config->SetSurface_Species_0(iMarker_Analyze, Species); @@ -541,8 +554,13 @@ void CFlowOutput::SetAnalyzeSurface(const CSolver* const*solver, const CGeometry SetHistoryOutputValue("SURFACE_TOTAL_TEMPERATURE", Tot_Surface_TotalTemperature); SetHistoryOutputValue("SURFACE_TOTAL_PRESSURE", Tot_Surface_TotalPressure); if (species) { - for (unsigned short iVar = 0; iVar < nSpecies; iVar++) - SetHistoryOutputValue("SURFACE_SPECIES_" + std::to_string(iVar), Tot_Surface_Species[iVar]); + for (unsigned short iVar = 0; iVar < nSpecies; iVar++) { + if (config->GetKind_FluidModel() == FLUID_CANTERA) { + SetHistoryOutputValue("SURFACE_SPECIES_" + config->GetChemical_GasComposition(iVar), Tot_Surface_Species[iVar]); + } else { + SetHistoryOutputValue("SURFACE_SPECIES_" + std::to_string(iVar), Tot_Surface_Species[iVar]); + } + } SetAnalyzeSurfaceSpeciesVariance(solver, geometry, config, Surface_Species_Total, Surface_MassFlow_Abs_Total, Surface_Area_Total); diff --git a/SU2_PY/SU2/io/historyMap.py b/SU2_PY/SU2/io/historyMap.py index 57e3d3d549da..8985f6fb6029 100644 --- a/SU2_PY/SU2/io/historyMap.py +++ b/SU2_PY/SU2/io/historyMap.py @@ -1359,6 +1359,17 @@ "HEADER": 'Avg_Species_" + ' "std::to_string(iVar", "TYPE": "COEFFICIENT", }, + 'SURFACE_SPECIES_" + config->GetChemical_GasComposition(iVar': { + "DESCRIPTION": "Total average " + 'species " + ' + "std::to_string(iVar) " + '+ " on all ' + "markers set in " + "MARKER_ANALYZE", + "GROUP": "SPECIES_COEFF", + "HEADER": 'Avg_Species_" + ' "config->GetChemical_GasComposition(iVar", + "TYPE": "COEFFICIENT", + }, "SURFACE_SPECIES_VARIANCE": { "DESCRIPTION": "Total species variance", "GROUP": "SPECIES_COEFF", From 9a43e240094d32bc4abfae0fd98f89b93b74d08d Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 16 Oct 2024 15:25:57 +0200 Subject: [PATCH 039/173] small fix init.py --- meson_scripts/init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson_scripts/init.py b/meson_scripts/init.py index 47e783adf2b7..5d434302d15c 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -71,7 +71,7 @@ def init_submodules( sha_version_coolprop = "bafdea1f39ee873a6bb9833e3a21fe41f90b85e8" github_repo_coolprop = "https://github.com/CoolProp/CoolProp" # sha_version_cantera = "feb64c2e028f4fa2ba9dc938022f5b2a693b5ddc" - # github_repo_cantera = "https://github.com/Cantera/cantera" + # github_repo_cantera = "https://github.com/cantera/cantera" sha_version_mel = "46205ab019e5224559091375a6d71aabae6bc5b9" github_repo_mel = "https://github.com/pcarruscag/MEL" sha_version_mlpcpp = "c19c53ea2b85ccfb185f1c6c87044dc0b5bc7ae0" From bdb42ce878facfac1ed4f7a9dc102e6128162652 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 18 Oct 2024 15:38:07 +0200 Subject: [PATCH 040/173] adding heat release --- SU2_CFD/include/fluid/CFluidCantera.hpp | 11 +++++++++++ SU2_CFD/include/fluid/CFluidModel.hpp | 5 +++++ SU2_CFD/include/variables/CVariable.hpp | 2 +- SU2_CFD/src/fluid/CFluidCantera.cpp | 13 +++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 03d206455483..616889de6a9e 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -62,6 +62,7 @@ class CFluidCantera final : public CFluidModel { std::array gasComposition; /*!< \brief Gas composition. */ std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ std::array chemicalSourceTerm; /*!< \brief chemical source term of all species*/ + su2double Heat_Release; /*!< \brief heat release due to combustion */ #endif std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ std::unique_ptr MassDiffusivityPointers[ARRAYSIZE]; @@ -84,6 +85,11 @@ class CFluidCantera final : public CFluidModel { */ void ComputeChemicalSourceTerm(); + /*! + * \brief Compute heat release due to combustion. + */ + void ComputeHeatRelease(); + public: /*! * \brief Constructor of the class. @@ -118,6 +124,11 @@ class CFluidCantera final : public CFluidModel { */ inline su2double GetChemicalSourceTerm(int ivar) override { return chemicalSourceTerm[ivar]; } + /*! + * \brief Get Heat release due to combustion. + */ + inline su2double GetHeatRelease() override { return Heat_Release; } + /*! * \brief Set the Dimensionless State using Temperature. * \param[in] t - Temperature value at the point. diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 05e095af0a5b..4e01ab5b5ee4 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -192,6 +192,11 @@ class CFluidModel { */ inline virtual su2double GetChemicalSourceTerm(int iVar) { return 0.0; } + /*! + * \brief Get Heat release due to combustion. + */ + inline virtual su2double GetHeatRelease() { return 0.0; } + /*! * \brief Get fluid pressure partial derivative. */ diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 329042ce8dd8..9e93ae959a6f 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -1107,7 +1107,7 @@ class CVariable { /*! * \brief A virtual member. * \param[in] iPoint - Point index. - * \return Value of the chemical source term.. + * \return Value of the chemical source term. */ inline virtual su2double GetChemicalSourceTerm(unsigned long iPoint, unsigned short val_ivar) const { return 0.0; } diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 7a5b3fa743d8..c2c285166ec5 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -93,6 +93,18 @@ void CFluidCantera::ComputeChemicalSourceTerm(){ } } +void CFluidCantera::ComputeHeatRelease(){ + vector netProductionRates(sol->kinetics()->nReactions()); + vector partialMolarEnthalpies(sol->thermo()->nSpecies()); + sol->kinetics()->getNetProductionRates(&netProductionRates[0]); + sol->thermo()->getPartialMolarEnthalpies(&partialMolarEnthalpies[0]); + Heat_Release = 0.0; + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); + Heat_Release += partialMolarEnthalpies[speciesIndex]*netProductionRates[speciesIndex]; + } +} + string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars) { su2double val_scalars_sum{0.0}; chemical_composition=""; @@ -117,5 +129,6 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl ComputeMassDiffusivity(); ComputeChemicalSourceTerm(); + ComputeHeatRelease(); } #endif \ No newline at end of file From ca9083e80334f989577eb45d54e6e9de7d17ae5e Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 22 Oct 2024 13:43:16 +0200 Subject: [PATCH 041/173] solving for enthalpy --- SU2_CFD/include/fluid/CFluidModel.hpp | 14 ++ SU2_CFD/include/fluid/CFluidScalar.hpp | 10 ++ SU2_CFD/include/numerics/CNumerics.hpp | 2 + SU2_CFD/include/output/CFlowIncOutput.hpp | 1 + .../include/solvers/CFVMFlowSolverBase.hpp | 3 +- .../include/variables/CIncEulerVariable.hpp | 18 ++- SU2_CFD/include/variables/CIncNSVariable.hpp | 1 + SU2_CFD/src/fluid/CFluidScalar.cpp | 13 ++ SU2_CFD/src/numerics/CNumerics.cpp | 53 ++++++-- SU2_CFD/src/numerics/flow/convection/fds.cpp | 57 +++++++-- SU2_CFD/src/output/CFlowIncOutput.cpp | 61 +++++++-- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 120 ++++++++++++++---- SU2_CFD/src/variables/CIncEulerVariable.cpp | 2 +- SU2_CFD/src/variables/CIncNSVariable.cpp | 36 ++++-- SU2_PY/SU2/io/historyMap.py | 18 +++ 15 files changed, 332 insertions(+), 77 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 30766e7b5431..29cb44fcc033 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -47,6 +47,7 @@ class CLookUpTable; class CFluidModel { protected: su2double StaticEnergy{0.0}; /*!< \brief Internal Energy. */ + su2double Enthalpy{0.0}; /*!<*\brief Enthalpy. */ su2double Entropy{0.0}; /*!< \brief Entropy. */ su2double Density{0.0}; /*!< \brief Density. */ su2double Pressure{0.0}; /*!< \brief Pressure. */ @@ -113,6 +114,11 @@ class CFluidModel { */ su2double GetStaticEnergy() const { return StaticEnergy; } + /*! + * \brief Get fluid enthalpy. + */ + su2double GetEnthalpy() const { return Enthalpy; } + /*! * \brief Get fluid density. */ @@ -339,6 +345,14 @@ class CFluidModel { */ virtual void SetTDState_T(su2double val_Temperature, const su2double* val_scalars = nullptr) {} + /*! + * \brief Virtual member. + * \param[in] val_enthalpy - Enthalpy value at the point. + */ + inline virtual su2double ComputeTempFromEnthalpy(su2double val_enthalpy, const su2double* val_scalars = nullptr) { + 0.0; + } + /*! * \brief Set fluid eddy viscosity provided by a turbulence model needed for computing effective thermal conductivity. */ diff --git a/SU2_CFD/include/fluid/CFluidScalar.hpp b/SU2_CFD/include/fluid/CFluidScalar.hpp index 206de692ae08..527adbf6ffad 100644 --- a/SU2_CFD/include/fluid/CFluidScalar.hpp +++ b/SU2_CFD/include/fluid/CFluidScalar.hpp @@ -91,6 +91,11 @@ class CFluidScalar final : public CFluidModel { */ su2double ComputeMeanSpecificHeatCp(const su2double* val_scalars); + /*! + * \brief Compute Enthalpy given the temperature and scalars. + */ + su2double ComputeEnthalpyFromT(const su2double val_enthalpy, const su2double* val_scalars); + /*! * \brief Compute gas constant for mixture. */ @@ -137,6 +142,11 @@ class CFluidScalar final : public CFluidModel { */ inline su2double GetMassDiffusivity(int ivar) override { return massDiffusivity[ivar]; } + /*! + * \brief Compute Temperature from Enthalpy and scalars. + */ + inline su2double ComputeTempFromEnthalpy(const su2double val_temperature, const su2double* val_scalars) override; + /*! * \brief Set the Dimensionless State using Temperature. * \param[in] t - Temperature value at the point. diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 535335947caf..f5b0634030fc 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -188,6 +188,8 @@ class CNumerics { bool nemo; /*!< \brief Flag for NEMO problems */ + bool multicomponent_energy = false; /*!< \brief Flag for multicomponent and reacting flow */ + bool bounded_scalar = false; /*!< \brief Flag for bounded scalar problem */ public: diff --git a/SU2_CFD/include/output/CFlowIncOutput.hpp b/SU2_CFD/include/output/CFlowIncOutput.hpp index fe7d78744274..f9c18d3d776a 100644 --- a/SU2_CFD/include/output/CFlowIncOutput.hpp +++ b/SU2_CFD/include/output/CFlowIncOutput.hpp @@ -40,6 +40,7 @@ class CFlowIncOutput final: public CFlowOutput { private: TURB_MODEL turb_model; /*!< \brief The kind of turbulence model*/ bool heat; /*!< \brief Boolean indicating whether have a heat problem*/ + bool multicomponent; /*!< \brief Boolean indicating whether have a multicomponent problem*/ bool weakly_coupled_heat; /*!< \brief Boolean indicating whether have a weakly coupled heat equation*/ bool flamelet; /*!< \brief Boolean indicating whether we solve the flamelet equations */ unsigned short streamwisePeriodic; /*!< \brief Boolean indicating whether it is a streamwise periodic simulation. */ diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp index 2aa31880baea..6f548e3ad312 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp @@ -69,7 +69,8 @@ class CFVMFlowSolverBase : public CSolver { su2double Mach_Inf = 0.0; /*!< \brief Mach number at the infinity. */ su2double Density_Inf = 0.0; /*!< \brief Density at the infinity. */ su2double Energy_Inf = 0.0; /*!< \brief Energy at the infinity. */ - su2double Temperature_Inf = 0.0; /*!< \brief Energy at the infinity. */ + su2double Temperature_Inf = 0.0; /*!< \brief Temperature at the infinity. */ + su2double Enthalpy_Inf = 0.0; /*!< \brief Enthalpy at the infinity. */ su2double Pressure_Inf = 0.0; /*!< \brief Pressure at the infinity. */ su2double* Velocity_Inf = nullptr; /*!< \brief Flow Velocity vector at the infinity. */ diff --git a/SU2_CFD/include/variables/CIncEulerVariable.hpp b/SU2_CFD/include/variables/CIncEulerVariable.hpp index 7f398351f04f..628ac40b5773 100644 --- a/SU2_CFD/include/variables/CIncEulerVariable.hpp +++ b/SU2_CFD/include/variables/CIncEulerVariable.hpp @@ -40,7 +40,7 @@ */ class CIncEulerVariable : public CFlowVariable { public: - static constexpr size_t MAXNVAR = 12; + static constexpr size_t MAXNVAR = 13; template struct CIndices { @@ -59,11 +59,11 @@ class CIncEulerVariable : public CFlowVariable { inline IndexType ThermalConductivity() const { return nDim+6; } inline IndexType CpTotal() const { return nDim+7; } inline IndexType CvTotal() const { return nDim+8; } + inline IndexType Enthalpy() const { return nDim + 9; } /*--- For compatible interface with NEMO. ---*/ inline IndexType SpeciesDensities() const { return std::numeric_limits::max(); } inline IndexType Temperature_ve() const { return std::numeric_limits::max(); } - inline IndexType Enthalpy() const { return std::numeric_limits::max(); } }; protected: @@ -121,6 +121,14 @@ class CIncEulerVariable : public CFlowVariable { return val_temperature <= 0.0; } + /*! + * \brief Set the value of the enthalpy for multicomponent incompressible flows with energy equation. + * \param[in] iPoint - Point index. + */ + inline void SetEnthalpy(unsigned long iPoint, su2double val_enthalpy) { + Primitive(iPoint, indices.Enthalpy()) = val_enthalpy; + } + /*! * \brief Set the value of the beta coeffient for incompressible flows. * \param[in] iPoint - Point index. @@ -153,6 +161,12 @@ class CIncEulerVariable : public CFlowVariable { */ inline su2double GetTemperature(unsigned long iPoint) const final { return Primitive(iPoint, indices.Temperature()); } + /*! + * \brief Get the enthalpy of the flow. + * \return Value of the enthalpy of the flow. + */ + inline su2double GetEnthalpy(unsigned long iPoint) const final { return Primitive(iPoint, indices.Enthalpy()); } + /*! * \brief Get the velocity of the flow. * \param[in] iDim - Index of the dimension. diff --git a/SU2_CFD/include/variables/CIncNSVariable.hpp b/SU2_CFD/include/variables/CIncNSVariable.hpp index 138026140b5e..14d5e6bd7ace 100644 --- a/SU2_CFD/include/variables/CIncNSVariable.hpp +++ b/SU2_CFD/include/variables/CIncNSVariable.hpp @@ -40,6 +40,7 @@ class CIncNSVariable final : public CIncEulerVariable { private: VectorType Tau_Wall; /*!< \brief Magnitude of the wall shear stress from a wall function. */ VectorType DES_LengthScale; + bool Energy_Multicomponent = false; public: /*! diff --git a/SU2_CFD/src/fluid/CFluidScalar.cpp b/SU2_CFD/src/fluid/CFluidScalar.cpp index a57ddc7797ef..e8c50c1f38ea 100644 --- a/SU2_CFD/src/fluid/CFluidScalar.cpp +++ b/SU2_CFD/src/fluid/CFluidScalar.cpp @@ -212,6 +212,18 @@ su2double CFluidScalar::ComputeMeanSpecificHeatCp(const su2double* val_scalars) return mean_cp; } +su2double CFluidScalar::ComputeEnthalpyFromT(const su2double val_temperature, const su2double* val_scalars){ + su2double val_Enthalpy = Cp * (val_temperature - 298.15); + return val_Enthalpy; +} + +su2double CFluidScalar::ComputeTempFromEnthalpy(const su2double val_enthalpy, const su2double* val_scalars){ + MassToMoleFractions(val_scalars); + su2double val_cp = ComputeMeanSpecificHeatCp(val_scalars); + su2double val_Temperature = val_enthalpy / val_cp + 298.15; + return val_Temperature; +} + void CFluidScalar::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { MassToMoleFractions(val_scalars); ComputeGasConstant(); @@ -219,6 +231,7 @@ void CFluidScalar::SetTDState_T(const su2double val_temperature, const su2double Density = Pressure_Thermodynamic / (Temperature * Gas_Constant); Cp = ComputeMeanSpecificHeatCp(val_scalars); Cv = Cp - Gas_Constant; + Enthalpy = ComputeEnthalpyFromT(Temperature, val_scalars); if (wilke) { Mu = WilkeViscosity(val_scalars); diff --git a/SU2_CFD/src/numerics/CNumerics.cpp b/SU2_CFD/src/numerics/CNumerics.cpp index 2c36556f8089..379276fa83a1 100644 --- a/SU2_CFD/src/numerics/CNumerics.cpp +++ b/SU2_CFD/src/numerics/CNumerics.cpp @@ -54,6 +54,8 @@ CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar, Prandtl_Lam = config->GetPrandtl_Lam(); Prandtl_Turb = config->GetPrandtl_Turb(); Gas_Constant = config->GetGas_ConstantND(); + multicomponent_energy = + (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) && (config->GetEnergy_Equation()); tau = new su2double* [nDim]; for (iDim = 0; iDim < nDim; iDim++) @@ -278,10 +280,20 @@ void CNumerics::GetInviscidIncProjJac(const su2double *val_density, const su2dou val_Proj_Jac_Tensor[2][2] = val_scale*((*val_density)*(proj_vel + val_normal[1]*val_velocity[1])); val_Proj_Jac_Tensor[2][3] = val_scale*((*val_dRhodT)*val_velocity[1]*proj_vel); - val_Proj_Jac_Tensor[3][0] = val_scale*((*val_cp)*(*val_temperature)*proj_vel/(*val_betainc2)); - val_Proj_Jac_Tensor[3][1] = val_scale*((*val_cp)*(*val_temperature)*val_normal[0]*(*val_density)); - val_Proj_Jac_Tensor[3][2] = val_scale*((*val_cp)*(*val_temperature)*val_normal[1]*(*val_density)); - val_Proj_Jac_Tensor[3][3] = val_scale*((*val_cp)*((*val_temperature)*(*val_dRhodT) + (*val_density))*proj_vel); + if (multicomponent_energy) { + val_Proj_Jac_Tensor[3][0] = val_scale * ((*val_temperature) * proj_vel / (*val_betainc2)); + val_Proj_Jac_Tensor[3][1] = val_scale * ((*val_temperature) * val_normal[0] * (*val_density)); + val_Proj_Jac_Tensor[3][2] = val_scale * ((*val_temperature) * val_normal[1] * (*val_density)); + val_Proj_Jac_Tensor[3][3] = + val_scale * ((*val_temperature) * (*val_dRhodT) + (*val_density)) * proj_vel; + + } else { + val_Proj_Jac_Tensor[3][0] = val_scale * ((*val_cp) * (*val_temperature) * proj_vel / (*val_betainc2)); + val_Proj_Jac_Tensor[3][1] = val_scale * ((*val_cp) * (*val_temperature) * val_normal[0] * (*val_density)); + val_Proj_Jac_Tensor[3][2] = val_scale * ((*val_cp) * (*val_temperature) * val_normal[1] * (*val_density)); + val_Proj_Jac_Tensor[3][3] = + val_scale * ((*val_cp) * ((*val_temperature) * (*val_dRhodT) + (*val_density)) * proj_vel); + } } else { @@ -309,12 +321,21 @@ void CNumerics::GetInviscidIncProjJac(const su2double *val_density, const su2dou val_Proj_Jac_Tensor[3][3] = val_scale*((*val_density)*(proj_vel + val_normal[2]*val_velocity[2])); val_Proj_Jac_Tensor[3][4] = val_scale*((*val_dRhodT)*val_velocity[2]*proj_vel); - val_Proj_Jac_Tensor[4][0] = val_scale*((*val_cp)*(*val_temperature)*proj_vel/(*val_betainc2)); - val_Proj_Jac_Tensor[4][1] = val_scale*((*val_cp)*(*val_temperature)*val_normal[0]*(*val_density)); - val_Proj_Jac_Tensor[4][2] = val_scale*((*val_cp)*(*val_temperature)*val_normal[1]*(*val_density)); - val_Proj_Jac_Tensor[4][3] = val_scale*((*val_cp)*(*val_temperature)*val_normal[2]*(*val_density)); - val_Proj_Jac_Tensor[4][4] = val_scale*((*val_cp)*((*val_temperature)*(*val_dRhodT) + (*val_density))*proj_vel); - + if (multicomponent_energy) { + val_Proj_Jac_Tensor[4][0] = val_scale * ((*val_temperature) * proj_vel / (*val_betainc2)); + val_Proj_Jac_Tensor[4][1] = val_scale * ((*val_temperature) * val_normal[0] * (*val_density)); + val_Proj_Jac_Tensor[4][2] = val_scale * ((*val_temperature) * val_normal[1] * (*val_density)); + val_Proj_Jac_Tensor[4][3] = val_scale * ((*val_temperature) * val_normal[2] * (*val_density)); + val_Proj_Jac_Tensor[4][4] = + val_scale * ((*val_temperature) * (*val_dRhodT) + (*val_density)) * proj_vel; + } else { + val_Proj_Jac_Tensor[4][0] = val_scale * ((*val_cp) * (*val_temperature) * proj_vel / (*val_betainc2)); + val_Proj_Jac_Tensor[4][1] = val_scale * ((*val_cp) * (*val_temperature) * val_normal[0] * (*val_density)); + val_Proj_Jac_Tensor[4][2] = val_scale * ((*val_cp) * (*val_temperature) * val_normal[1] * (*val_density)); + val_Proj_Jac_Tensor[4][3] = val_scale * ((*val_cp) * (*val_temperature) * val_normal[2] * (*val_density)); + val_Proj_Jac_Tensor[4][4] = + val_scale * ((*val_cp) * ((*val_temperature) * (*val_dRhodT) + (*val_density)) * proj_vel); + } } AD::EndPassive(wasActive); } @@ -328,7 +349,11 @@ void CNumerics::GetPreconditioner(const su2double *val_density, const su2double val_Precon[0][0] = 1.0/(*val_betainc2); for (iDim = 0; iDim < nDim; iDim++) val_Precon[iDim+1][0] = val_velocity[iDim]/(*val_betainc2); - val_Precon[nDim+1][0] = (*val_cp)*(*val_temperature)/(*val_betainc2); + if (multicomponent_energy){ + val_Precon[nDim+1][0] = (*val_temperature)/(*val_betainc2); + }else{ + val_Precon[nDim+1][0] = (*val_cp)*(*val_temperature)/(*val_betainc2); + } for (jDim = 0; jDim < nDim; jDim++) { val_Precon[0][jDim+1] = 0.0; @@ -342,7 +367,11 @@ void CNumerics::GetPreconditioner(const su2double *val_density, const su2double val_Precon[0][nDim+1] = (*val_drhodt); for (iDim = 0; iDim < nDim; iDim++) val_Precon[iDim+1][nDim+1] = val_velocity[iDim]*(*val_drhodt); - val_Precon[nDim+1][nDim+1] = (*val_cp)*((*val_drhodt)*(*val_temperature) + (*val_density)); + if (multicomponent_energy){ + val_Precon[nDim+1][nDim+1] = (*val_drhodt)*(*val_temperature) + (*val_density); + }else{ + val_Precon[nDim+1][nDim+1] = (*val_cp)*((*val_drhodt)*(*val_temperature) + (*val_density)); + } } diff --git a/SU2_CFD/src/numerics/flow/convection/fds.cpp b/SU2_CFD/src/numerics/flow/convection/fds.cpp index ae48e59f3365..de1963e3fb30 100644 --- a/SU2_CFD/src/numerics/flow/convection/fds.cpp +++ b/SU2_CFD/src/numerics/flow/convection/fds.cpp @@ -94,7 +94,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config su2double ProjGridVel = 0.0; AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(V_i, nDim+10); AD::SetPreaccIn(V_j, nDim+10); AD::SetPreaccIn(Normal, nDim); if (dynamic_grid) { AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); @@ -118,7 +118,13 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; - Enthalpy_i = Cp_i*Temperature_i; Enthalpy_j = Cp_j*Temperature_j; + if (multicomponent_energy) { + Enthalpy_i = V_i[nDim + 9]; + Enthalpy_j = V_j[nDim + 9]; + } else { + Enthalpy_i = Cp_i * Temperature_i; + Enthalpy_j = Cp_j * Temperature_j; + } ProjVelocity = 0.0; for (iDim = 0; iDim < nDim; iDim++) { @@ -157,9 +163,15 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config MeandRhodT = 0.0; dRhodT_i = 0.0; dRhodT_j = 0.0; if (variable_density) { - MeandRhodT = -MeanDensity/MeanTemperature; - dRhodT_i = -DensityInc_i/Temperature_i; - dRhodT_j = -DensityInc_j/Temperature_j; + if (multicomponent_energy) { + MeandRhodT = -MeanDensity / (MeanCp * MeanTemperature); + dRhodT_i = -DensityInc_i / (Cp_i * Temperature_i); + dRhodT_j = -DensityInc_j / (Cp_j * Temperature_j); + } else { + MeandRhodT = -MeanDensity / MeanTemperature; + dRhodT_i = -DensityInc_i / Temperature_i; + dRhodT_j = -DensityInc_j / Temperature_j; + } } /*--- Compute ProjFlux_i ---*/ @@ -192,8 +204,11 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config Lambda[iVar] = fabs(Lambda[iVar]); /*--- Build the preconditioning matrix using mean values ---*/ - - GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); + if (multicomponent_energy) { + GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanEnthalpy, &MeandRhodT, Precon); + } else { + GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); + } /*--- Build the absolute value of the preconditioned Jacobian, i.e., |A_precon| = P x |Lambda| x inv(P), where P diagonalizes the matrix @@ -206,13 +221,26 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config Diff_V[0] = Pressure_j - Pressure_i; for (iDim = 0; iDim < nDim; iDim++) Diff_V[iDim+1] = Velocity_j[iDim] - Velocity_i[iDim]; - Diff_V[nDim+1] = Temperature_j - Temperature_i; + if (multicomponent_energy){ + Diff_V[nDim+1] = Enthalpy_j - Enthalpy_i; + }else{ + Diff_V[nDim+1] = Temperature_j - Temperature_i; + } /*--- Build the inviscid Jacobian w.r.t. the primitive variables ---*/ if (implicit) { - GetInviscidIncProjJac(&DensityInc_i, Velocity_i, &BetaInc2_i, &Cp_i, &Temperature_i, &dRhodT_i, Normal, 0.5, Jacobian_i); - GetInviscidIncProjJac(&DensityInc_j, Velocity_j, &BetaInc2_j, &Cp_j, &Temperature_j, &dRhodT_j, Normal, 0.5, Jacobian_j); + if (multicomponent_energy) { + GetInviscidIncProjJac(&DensityInc_i, Velocity_i, &BetaInc2_i, &Cp_i, &Enthalpy_i, &dRhodT_i, Normal, 0.5, + Jacobian_i); + GetInviscidIncProjJac(&DensityInc_j, Velocity_j, &BetaInc2_j, &Cp_j, &Enthalpy_j, &dRhodT_j, Normal, 0.5, + Jacobian_j); + } else { + GetInviscidIncProjJac(&DensityInc_i, Velocity_i, &BetaInc2_i, &Cp_i, &Temperature_i, &dRhodT_i, Normal, 0.5, + Jacobian_i); + GetInviscidIncProjJac(&DensityInc_j, Velocity_j, &BetaInc2_j, &Cp_j, &Temperature_j, &dRhodT_j, Normal, 0.5, + Jacobian_j); + } } /*--- Compute dissipation as Precon x |A_precon| x dV. If implicit, @@ -258,8 +286,13 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; } - Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; - Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; + if (multicomponent_energy){ + Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i; + Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j; + } else { + Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; + Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; + } } } } diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index eeffb6a3486c..ac61e806092d 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -37,6 +37,8 @@ CFlowIncOutput::CFlowIncOutput(CConfig *config, unsigned short nDim) : CFlowOutp heat = config->GetEnergy_Equation(); + multicomponent = config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT; + weakly_coupled_heat = config->GetWeakly_Coupled_Heat(); flamelet = (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET); @@ -108,7 +110,13 @@ void CFlowIncOutput::SetHistoryOutputFields(CConfig *config){ /// DESCRIPTION: Root-mean square residual of the velocity z-component. if (nDim == 3) AddHistoryOutput("RMS_VELOCITY-Z", "rms[W]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the velocity z-component.", HistoryFieldType::RESIDUAL); /// DESCRIPTION: Maximum residual of the temperature. - if (heat || weakly_coupled_heat) AddHistoryOutput("RMS_TEMPERATURE", "rms[T]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the temperature.", HistoryFieldType::RESIDUAL); + if (heat || weakly_coupled_heat){ + if (multicomponent){ + AddHistoryOutput("RMS_ENTHALPY", "rms[h]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the enthalpy.", HistoryFieldType::RESIDUAL); + } else { + AddHistoryOutput("RMS_TEMPERATURE", "rms[T]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the temperature.", HistoryFieldType::RESIDUAL); + } + } AddHistoryOutputFields_ScalarRMS_RES(config); @@ -128,7 +136,11 @@ void CFlowIncOutput::SetHistoryOutputFields(CConfig *config){ AddHistoryOutput("MAX_VELOCITY-Z", "max[W]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the velocity z-component.", HistoryFieldType::RESIDUAL); /// DESCRIPTION: Maximum residual of the temperature. if (heat || weakly_coupled_heat) - AddHistoryOutput("MAX_TEMPERATURE", "max[T]", ScreenOutputFormat::FIXED, "MAX_RES", "Root-mean square residual of the temperature.", HistoryFieldType::RESIDUAL); + if (multicomponent){ + AddHistoryOutput("MAX_ENTHALPY", "max[h]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the enthalpy.", HistoryFieldType::RESIDUAL); + } else { + AddHistoryOutput("MAX_TEMPERATURE", "max[T]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the temperature.", HistoryFieldType::RESIDUAL); + } AddHistoryOutputFields_ScalarMAX_RES(config); /// END_GROUP @@ -145,7 +157,11 @@ void CFlowIncOutput::SetHistoryOutputFields(CConfig *config){ AddHistoryOutput("BGS_VELOCITY-Z", "bgs[W]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the velocity z-component.", HistoryFieldType::RESIDUAL); /// DESCRIPTION: Maximum residual of the temperature. if (heat || weakly_coupled_heat) - AddHistoryOutput("BGS_TEMPERATURE", "bgs[T]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the temperature.", HistoryFieldType::RESIDUAL); + if (multicomponent){ + AddHistoryOutput("BGS_ENTHALPY", "bgs[h]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the enthalpy.", HistoryFieldType::RESIDUAL); + } else { + AddHistoryOutput("BGS_TEMPERATURE", "bgs[T]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the temperature.", HistoryFieldType::RESIDUAL); + } AddHistoryOutputFields_ScalarBGS_RES(config); @@ -232,10 +248,18 @@ void CFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolv if (heat) { SetHeatCoefficients(config, flow_solver); SetHistoryOutputValue("AVG_TEMPERATURE", flow_solver->GetTotal_AvgTemperature()); - SetHistoryOutputValue("RMS_TEMPERATURE", log10(flow_solver->GetRes_RMS(nDim + 1))); - SetHistoryOutputValue("MAX_TEMPERATURE", log10(flow_solver->GetRes_Max(nDim + 1))); - if (multiZone) { - SetHistoryOutputValue("BGS_TEMPERATURE", log10(flow_solver->GetRes_BGS(nDim + 1))); + if (multicomponent){ + SetHistoryOutputValue("RMS_ENTHALPY", log10(flow_solver->GetRes_RMS(nDim + 1))); + SetHistoryOutputValue("MAX_ENTHALPY", log10(flow_solver->GetRes_Max(nDim + 1))); + if (multiZone) { + SetHistoryOutputValue("BGS_ENTHALPY", log10(flow_solver->GetRes_BGS(nDim + 1))); + } + } else { + SetHistoryOutputValue("RMS_TEMPERATURE", log10(flow_solver->GetRes_RMS(nDim + 1))); + SetHistoryOutputValue("MAX_TEMPERATURE", log10(flow_solver->GetRes_Max(nDim + 1))); + if (multiZone) { + SetHistoryOutputValue("BGS_TEMPERATURE", log10(flow_solver->GetRes_BGS(nDim + 1))); + } } } @@ -295,8 +319,10 @@ void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("VELOCITY-Y", "Velocity_y", "SOLUTION", "y-component of the velocity vector"); if (nDim == 3) AddVolumeOutput("VELOCITY-Z", "Velocity_z", "SOLUTION", "z-component of the velocity vector"); - if (heat || weakly_coupled_heat || flamelet) - AddVolumeOutput("TEMPERATURE", "Temperature","SOLUTION", "Temperature"); + if (heat || weakly_coupled_heat || flamelet){ + if (multicomponent) AddVolumeOutput("ENTHALPY", "Enthalpy", "SOLUTION", "Enthalpy"); + else AddVolumeOutput("TEMPERATURE", "Temperature","SOLUTION", "Temperature"); + } SetVolumeOutputFieldsScalarSolution(config); @@ -320,6 +346,7 @@ void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("LAMINAR_VISCOSITY", "Laminar_Viscosity", "PRIMITIVE", "Laminar viscosity"); AddVolumeOutput("HEAT_CAPACITY", "Heat_Capacity", "PRIMITIVE", "Heat capacity"); AddVolumeOutput("THERMAL_CONDUCTIVITY", "Thermal_Conductivity", "PRIMITIVE", "Thermal conductivity"); + if (heat && multicomponent) AddVolumeOutput("TEMPERATURE", "Temperature", "PRIMITIVE", "Temperature"); AddVolumeOutput("SKIN_FRICTION-X", "Skin_Friction_Coefficient_x", "PRIMITIVE", "x-component of the skin friction vector"); AddVolumeOutput("SKIN_FRICTION-Y", "Skin_Friction_Coefficient_y", "PRIMITIVE", "y-component of the skin friction vector"); @@ -343,9 +370,10 @@ void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("RES_VELOCITY-Y", "Residual_Velocity_y", "RESIDUAL", "Residual of the y-velocity component"); if (nDim == 3) AddVolumeOutput("RES_VELOCITY-Z", "Residual_Velocity_z", "RESIDUAL", "Residual of the z-velocity component"); - if (config->GetEnergy_Equation()) - AddVolumeOutput("RES_TEMPERATURE", "Residual_Temperature", "RESIDUAL", "Residual of the temperature"); - + if (config->GetEnergy_Equation()){ + if (multicomponent) AddVolumeOutput("RES_ENTHALPY", "Residual_Enthalpy", "RESIDUAL", "Residual of the enthalpy"); + else AddVolumeOutput("RES_TEMPERATURE", "Residual_Temperature", "RESIDUAL", "Residual of the temperature"); + } SetVolumeOutputFieldsScalarResidual(config); if (config->GetKind_SlopeLimit_Flow() != LIMITER::NONE && config->GetKind_SlopeLimit_Flow() != LIMITER::VAN_ALBADA_EDGE) { @@ -399,7 +427,10 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve if (nDim == 3) SetVolumeOutputValue("VELOCITY-Z", iPoint, Node_Flow->GetSolution(iPoint, 3)); - if (heat || flamelet) SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Flow->GetSolution(iPoint, nDim+1)); + if (heat || flamelet) { + if (multicomponent) SetVolumeOutputValue("ENTHALPY", iPoint, Node_Flow->GetSolution(iPoint, nDim+1)); + else SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Flow->GetSolution(iPoint, nDim+1)); + } if (weakly_coupled_heat) SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Heat->GetSolution(iPoint, 0)); // Radiation solver @@ -423,6 +454,7 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve SetVolumeOutputValue("LAMINAR_VISCOSITY", iPoint, Node_Flow->GetLaminarViscosity(iPoint)); SetVolumeOutputValue("HEAT_CAPACITY", iPoint, Node_Flow->GetSpecificHeatCp(iPoint)); SetVolumeOutputValue("THERMAL_CONDUCTIVITY", iPoint, Node_Flow->GetThermalConductivity(iPoint)); + if (multicomponent) SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Flow->GetTemperature(iPoint)); } SetVolumeOutputValue("RES_PRESSURE", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 0)); @@ -431,7 +463,8 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve if (nDim == 3) SetVolumeOutputValue("RES_VELOCITY-Z", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 3)); if (config->GetEnergy_Equation()) - SetVolumeOutputValue("RES_TEMPERATURE", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, nDim+1)); + if (multicomponent) SetVolumeOutputValue("RES_ENTHALPY", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, nDim+1)); + else SetVolumeOutputValue("RES_TEMPERATURE", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, nDim+1)); if (config->GetKind_SlopeLimit_Flow() != LIMITER::NONE && config->GetKind_SlopeLimit_Flow() != LIMITER::VAN_ALBADA_EDGE) { SetVolumeOutputValue("LIMITER_PRESSURE", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 0)); diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 6aaf09a51835..64b0f2cc91ff 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -57,6 +57,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned bool time_stepping = config->GetTime_Marching() == TIME_MARCHING::TIME_STEPPING; bool adjoint = (config->GetContinuous_Adjoint()) || (config->GetDiscrete_Adjoint()); const bool centered = config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED; + bool Energy_Multicomponent = (config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation(); /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); @@ -119,7 +120,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned /*--- Make sure to align the sizes with the constructor of CIncEulerVariable. ---*/ nVar = nDim + 2; - nPrimVar = nDim + 9; + nPrimVar = nDim + 10; /*--- Centered schemes only need gradients for viscous fluxes (T and v, but we need also to include P). ---*/ nPrimVarGrad = nDim + (centered ? 2 : 4); @@ -178,6 +179,12 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned Pressure_Inf = config->GetPressure_FreeStreamND(); Velocity_Inf = config->GetVelocity_FreeStreamND(); Temperature_Inf = config->GetTemperature_FreeStreamND(); + if (Energy_Multicomponent){ + CFluidModel *auxFluidModel = new CFluidScalar(config->GetPressure_Thermodynamic(), config); + const su2double *scalar_init = config->GetSpecies_Init(); + auxFluidModel->SetTDState_T(Temperature_Inf,scalar_init); // compute total enthalpy from temperature + Enthalpy_Inf = auxFluidModel->GetEnthalpy(); + } /*--- Initialize the secondary values for direct derivative approxiations ---*/ @@ -208,7 +215,11 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned /*--- Initialize the solution to the far-field state everywhere. ---*/ if (navier_stokes) { - nodes = new CIncNSVariable(Pressure_Inf, Velocity_Inf, Temperature_Inf, nPoint, nDim, nVar, config); + if (Energy_Multicomponent){ + nodes = new CIncNSVariable(Pressure_Inf, Velocity_Inf, Enthalpy_Inf, nPoint, nDim, nVar, config); + }else{ + nodes = new CIncNSVariable(Pressure_Inf, Velocity_Inf, Temperature_Inf, nPoint, nDim, nVar, config); + } } else { nodes = new CIncEulerVariable(Pressure_Inf, Velocity_Inf, Temperature_Inf, nPoint, nDim, nVar, config); } @@ -1977,12 +1988,13 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo unsigned short iDim, jDim, iVar, jVar; - su2double BetaInc2, Density, dRhodT, Temperature, oneOverCp, Cp; + su2double BetaInc2, Density, dRhodT, Temperature, oneOverCp, Cp, Enthalpy; su2double Velocity[MAXNDIM] = {0.0}; bool variable_density = (config->GetVariable_Density_Model()); bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); bool energy = config->GetEnergy_Equation(); + bool multicomponent = config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT; /*--- Access the primitive variables at this node. ---*/ @@ -1991,6 +2003,7 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo Cp = nodes->GetSpecificHeatCp(iPoint); oneOverCp = 1.0/Cp; Temperature = nodes->GetTemperature(iPoint); + if (energy && multicomponent) Enthalpy = nodes->GetEnthalpy(iPoint); for (iDim = 0; iDim < nDim; iDim++) Velocity[iDim] = nodes->GetVelocity(iPoint,iDim); @@ -2000,7 +2013,11 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo law, but in the future, dRhodT should be in the fluid model. ---*/ if (variable_density) { - dRhodT = -Density/Temperature; + if (multicomponent && energy){ + dRhodT = -Density / (Cp * Temperature); + } else { + dRhodT = -Density/Temperature; + } } else { dRhodT = 0.0; } @@ -2017,8 +2034,15 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo for (iDim = 0; iDim < nDim; iDim++) Preconditioner[iDim+1][0] = Velocity[iDim]/BetaInc2; - if (energy) Preconditioner[nDim+1][0] = Cp*Temperature/BetaInc2; - else Preconditioner[nDim+1][0] = 0.0; + if (energy) { + if (multicomponent) { + Preconditioner[nDim + 1][0] = Enthalpy / BetaInc2; + } else { + Preconditioner[nDim + 1][0] = Cp * Temperature / BetaInc2; + } + } else { + Preconditioner[nDim + 1][0] = 0.0; + } for (jDim = 0; jDim < nDim; jDim++) { Preconditioner[0][jDim+1] = 0.0; @@ -2033,46 +2057,72 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo for (iDim = 0; iDim < nDim; iDim++) Preconditioner[iDim+1][nDim+1] = Velocity[iDim]*dRhodT; - if (energy) Preconditioner[nDim+1][nDim+1] = Cp*(dRhodT*Temperature + Density); - else Preconditioner[nDim+1][nDim+1] = 1.0; + if (energy) { + if (multicomponent) { + Preconditioner[nDim + 1][nDim + 1] = dRhodT * Enthalpy + Density; + } else { + Preconditioner[nDim + 1][nDim + 1] = Cp * (dRhodT * Temperature + Density); + } + } else { + Preconditioner[nDim + 1][nDim + 1] = 1.0; + } for (iVar = 0; iVar < nVar; iVar ++ ) for (jVar = 0; jVar < nVar; jVar ++ ) Preconditioner[iVar][jVar] = delta*Preconditioner[iVar][jVar]; } else { - /*--- For explicit calculations, we move the residual to the right-hand side and pre-multiply by the preconditioner inverse. Therefore, we build inv(Precon) here and multiply by the residual later in the R-K and Euler Explicit time integration schemes. ---*/ - Preconditioner[0][0] = Temperature*BetaInc2*dRhodT/Density + BetaInc2; - for (iDim = 0; iDim < nDim; iDim ++) - Preconditioner[iDim+1][0] = -1.0*Velocity[iDim]/Density; - - if (energy) Preconditioner[nDim+1][0] = -1.0*Temperature/Density; - else Preconditioner[nDim+1][0] = 0.0; + if (multicomponent && energy) { + Preconditioner[0][0] = Enthalpy * BetaInc2 * dRhodT / Density + BetaInc2; + } else { + Preconditioner[0][0] = Temperature * BetaInc2 * dRhodT / Density + BetaInc2; + } + for (iDim = 0; iDim < nDim; iDim++) Preconditioner[iDim + 1][0] = -1.0 * Velocity[iDim] / Density; + if (energy) { + if (multicomponent) { + Preconditioner[nDim + 1][0] = -1.0 * Enthalpy / Density; + } else { + Preconditioner[nDim + 1][0] = -1.0 * Temperature / Density; + } + } else { + Preconditioner[nDim + 1][0] = 0.0; + } for (jDim = 0; jDim < nDim; jDim++) { - Preconditioner[0][jDim+1] = 0.0; + Preconditioner[0][jDim + 1] = 0.0; for (iDim = 0; iDim < nDim; iDim++) { - if (iDim == jDim) Preconditioner[iDim+1][jDim+1] = 1.0/Density; - else Preconditioner[iDim+1][jDim+1] = 0.0; + if (iDim == jDim) + Preconditioner[iDim + 1][jDim + 1] = 1.0 / Density; + else + Preconditioner[iDim + 1][jDim + 1] = 0.0; } - Preconditioner[nDim+1][jDim+1] = 0.0; + Preconditioner[nDim + 1][jDim + 1] = 0.0; } - Preconditioner[0][nDim+1] = -1.0*BetaInc2*dRhodT*oneOverCp/Density; - for (iDim = 0; iDim < nDim; iDim ++) - Preconditioner[iDim+1][nDim+1] = 0.0; + if (multicomponent && energy) { + Preconditioner[0][nDim + 1] = -1.0 * BetaInc2 * dRhodT / Density; + } else { + Preconditioner[0][nDim + 1] = -1.0 * BetaInc2 * dRhodT * oneOverCp / Density; + } + for (iDim = 0; iDim < nDim; iDim++) Preconditioner[iDim + 1][nDim + 1] = 0.0; - if (energy) Preconditioner[nDim+1][nDim+1] = oneOverCp/Density; - else Preconditioner[nDim+1][nDim+1] = 0.0; + if (energy) { + if (multicomponent) { + Preconditioner[nDim + 1][nDim + 1] = 1.0 / Density; + } else { + Preconditioner[nDim + 1][nDim + 1] = oneOverCp / Density; + } + } else { + Preconditioner[nDim + 1][nDim + 1] = 0.0; + } } - } void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, @@ -2217,6 +2267,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool viscous = config->GetViscous(); + bool Energy_Multicomponent = (config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation(); string Marker_Tag = config->GetMarker_All_TagBound(val_marker); @@ -2380,6 +2431,15 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, V_inlet[prim_idx.Pressure()] = nodes->GetPressure(iPoint); } + /*-- Enthalpy is needed for energy equation in multicomponent and reacting flows. ---*/ + if (Energy_Multicomponent) { + CFluidModel* auxFluidModel = solver_container[FLOW_SOL]->GetFluidModel(); + const su2double* scalar_inlet = config->GetInlet_SpeciesVal(config->GetMarker_All_TagBound(val_marker)); + auxFluidModel->SetTDState_T(V_inlet[prim_idx.Temperature()], + scalar_inlet); // compute total enthalpy from temperature + V_inlet[prim_idx.Enthalpy()] = auxFluidModel->GetEnthalpy(); + } + /*--- Access density at the node. This is either constant by construction, or will be set fixed implicitly by the temperature and equation of state. ---*/ @@ -2469,6 +2529,7 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool viscous = config->GetViscous(); + bool Energy_Multicomponent = (config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation(); string Marker_Tag = config->GetMarker_All_TagBound(val_marker); su2double Normal[MAXNDIM] = {0.0}; @@ -2591,6 +2652,15 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, V_outlet[prim_idx.CpTotal()] = nodes->GetSpecificHeatCp(iPoint); + /*-- Enthalpy is needed for energy equation in multicomponent and reacting flows. ---*/ + if (Energy_Multicomponent) { + CFluidModel* auxFluidModel = solver_container[FLOW_SOL]->GetFluidModel();; + const su2double* scalar_outlet = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint); + auxFluidModel->SetTDState_T(nodes->GetTemperature(iPoint), + scalar_outlet); // compute total enthalpy from temperature + V_outlet[prim_idx.Enthalpy()] = auxFluidModel->GetEnthalpy(); + } + /*--- Set various quantities in the solver class ---*/ conv_numerics->SetPrimitive(V_domain, V_outlet); diff --git a/SU2_CFD/src/variables/CIncEulerVariable.cpp b/SU2_CFD/src/variables/CIncEulerVariable.cpp index 089845f6eb31..b2c6d8489717 100644 --- a/SU2_CFD/src/variables/CIncEulerVariable.cpp +++ b/SU2_CFD/src/variables/CIncEulerVariable.cpp @@ -30,7 +30,7 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *velocity, su2double temperature, unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig *config) - : CFlowVariable(npoint, ndim, nvar, ndim + 9, + : CFlowVariable(npoint, ndim, nvar, ndim + 10, ndim + (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED ? 2 : 4), config), indices(ndim, 0) { diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index cbcfa3b0aad6..7e2c80b9909d 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -46,19 +46,27 @@ CIncNSVariable::CIncNSVariable(su2double pressure, const su2double *velocity, su AuxVar.resize(nPoint,nAuxVar) = su2double(0.0); Grad_AuxVar.resize(nPoint,nAuxVar,nDim); } + if ((config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation()){ + Energy_Multicomponent = true; + } } bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2double turb_ke, CFluidModel *FluidModel, const su2double *scalar) { bool physical = true; + su2double Temperature; /*--- Set the value of the pressure ---*/ SetPressure(iPoint); - /*--- Set the value of the temperature directly ---*/ - - su2double Temperature = Solution(iPoint, indices.Temperature()); + if(Energy_Multicomponent){ + su2double Enthalpy = Solution(iPoint, nDim +1); + Temperature = FluidModel->ComputeTempFromEnthalpy(Enthalpy, scalar); + } else { + /*--- Set the value of the temperature directly ---*/ + Temperature = Solution(iPoint, indices.Temperature()); + } auto check_temp = SetTemperature(iPoint, Temperature); /*--- Use the fluid model to compute the new value of density. @@ -69,11 +77,13 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do FluidModel->SetTDState_T(Temperature, scalar); - /*--- for FLAMELET: copy the LUT temperature into the solution ---*/ - Solution(iPoint,nDim+1) = FluidModel->GetTemperature(); - /*--- for FLAMELET: update the local temperature using LUT variables ---*/ - Temperature = Solution(iPoint,indices.Temperature()); - check_temp = SetTemperature(iPoint, Temperature); + if (!Energy_Multicomponent) { + /*--- for FLAMELET: copy the LUT temperature into the solution ---*/ + Solution(iPoint, nDim + 1) = FluidModel->GetTemperature(); + /*--- for FLAMELET: update the local temperature using LUT variables ---*/ + Temperature = Solution(iPoint, indices.Temperature()); + check_temp = SetTemperature(iPoint, Temperature); + } /*--- Set the value of the density ---*/ @@ -90,9 +100,14 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do /*--- Recompute the primitive variables ---*/ - Temperature = Solution(iPoint, indices.Temperature()); + if (Energy_Multicomponent) { + su2double Enthalpy = Solution(iPoint, nDim + 1); + Temperature = FluidModel->ComputeTempFromEnthalpy(Enthalpy, scalar); + } else { + Temperature = Solution(iPoint, indices.Temperature()); + FluidModel->SetTDState_T(Temperature, scalar); + } SetTemperature(iPoint, Temperature); - FluidModel->SetTDState_T(Temperature, scalar); SetDensity(iPoint, FluidModel->GetDensity()); /*--- Flag this point as non-physical. ---*/ @@ -122,6 +137,7 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do SetSpecificHeatCp(iPoint, FluidModel->GetCp()); SetSpecificHeatCv(iPoint, FluidModel->GetCv()); + if (Energy_Multicomponent) SetEnthalpy(iPoint, FluidModel->GetEnthalpy()); return physical; diff --git a/SU2_PY/SU2/io/historyMap.py b/SU2_PY/SU2/io/historyMap.py index a477478359c0..be17da146431 100644 --- a/SU2_PY/SU2/io/historyMap.py +++ b/SU2_PY/SU2/io/historyMap.py @@ -244,6 +244,12 @@ "HEADER": "bgs[T]", "TYPE": "RESIDUAL", }, + "BGS_ENTHALPY": { + "DESCRIPTION": "Block-Gauss-Seidel residual of the " "enthalpy", + "GROUP": "BGS_RES", + "HEADER": "bgs[h]", + "TYPE": "RESIDUAL", + }, "BGS_TKE": { "DESCRIPTION": "BGS residual of kinetic energy (SST model).", "GROUP": "BGS_RES", @@ -894,6 +900,12 @@ "HEADER": "max[T]", "TYPE": "RESIDUAL", }, + "MAX_ENTHALPY": { + "DESCRIPTION": "Maximum residual of the enthalpy", + "GROUP": "MAX_RES", + "HEADER": "max[h]", + "TYPE": "RESIDUAL", + }, "MAX_TKE": { "DESCRIPTION": "Maximum residual of kinetic energy (SST model).", "GROUP": "MAX_RES", @@ -1154,6 +1166,12 @@ "HEADER": "rms[T]", "TYPE": "RESIDUAL", }, + "RMS_ENTHALPY": { + "DESCRIPTION": "Root mean square residual of the " "enthalpy", + "GROUP": "RMS_RES", + "HEADER": "rms[h]", + "TYPE": "RESIDUAL", + }, "RMS_TKE": { "DESCRIPTION": "Root-mean square residual of kinetic energy (SST " "model).", "GROUP": "RMS_RES", From 0487a68c028ac1f3ba4ceb77927222b0152144b8 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 25 Oct 2024 10:36:21 +0200 Subject: [PATCH 042/173] fixing flux jacobian --- SU2_CFD/include/numerics/flow/flow_diffusion.hpp | 1 + SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/include/numerics/flow/flow_diffusion.hpp b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp index 654bc91e6ac7..558d035eb1b1 100644 --- a/SU2_CFD/include/numerics/flow/flow_diffusion.hpp +++ b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp @@ -287,6 +287,7 @@ class CAvgGrad_Flow final : public CAvgGrad_Base { class CAvgGradInc_Flow final : public CAvgGrad_Base { private: su2double Mean_Thermal_Conductivity; /*!< \brief Mean value of the effective thermal conductivity. */ + su2double Mean_Heat_Capacity; /*!< \brief Mean value of the heat capacity. */ bool energy; /*!< \brief computation with the energy equation. */ /*! diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index a2cdb8935339..2e95a6ea0204 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -583,6 +583,10 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi Laminar_Viscosity_i = V_i[nDim+4]; Laminar_Viscosity_j = V_j[nDim+4]; Eddy_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_j = V_j[nDim+5]; Thermal_Conductivity_i = V_i[nDim+6]; Thermal_Conductivity_j = V_j[nDim+6]; + if (multicomponent_energy) { + Cp_i = V_i[nDim + 7]; + Cp_j = V_j[nDim + 7]; + } /*--- Mean transport properties ---*/ @@ -590,6 +594,7 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); + if (multicomponent_energy) Mean_Heat_Capacity = 0.5 * (Cp_i + Cp_j); /*--- Mean gradient approximation ---*/ @@ -649,8 +654,13 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi proj_vector_ij += (Coord_j[iDim]-Coord_i[iDim])*Normal[iDim]; } proj_vector_ij = proj_vector_ij/dist_ij_2; - Jacobian_i[nDim+1][nDim+1] = -Mean_Thermal_Conductivity*proj_vector_ij; - Jacobian_j[nDim+1][nDim+1] = Mean_Thermal_Conductivity*proj_vector_ij; + if (multicomponent_energy){ + Jacobian_i[nDim + 1][nDim + 1] = -Mean_Thermal_Conductivity * proj_vector_ij / Mean_Heat_Capacity; + Jacobian_j[nDim + 1][nDim + 1] = Mean_Thermal_Conductivity * proj_vector_ij / Mean_Heat_Capacity; + } else { + Jacobian_i[nDim + 1][nDim + 1] = -Mean_Thermal_Conductivity * proj_vector_ij; + Jacobian_j[nDim + 1][nDim + 1] = Mean_Thermal_Conductivity * proj_vector_ij; + } } } From 5076f9d3aea689a4de5104b8afd6095e39e44ce6 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 26 Oct 2024 18:00:46 +0200 Subject: [PATCH 043/173] fix output error --- SU2_CFD/src/output/CFlowIncOutput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index ac61e806092d..022af8869527 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -454,7 +454,7 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve SetVolumeOutputValue("LAMINAR_VISCOSITY", iPoint, Node_Flow->GetLaminarViscosity(iPoint)); SetVolumeOutputValue("HEAT_CAPACITY", iPoint, Node_Flow->GetSpecificHeatCp(iPoint)); SetVolumeOutputValue("THERMAL_CONDUCTIVITY", iPoint, Node_Flow->GetThermalConductivity(iPoint)); - if (multicomponent) SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Flow->GetTemperature(iPoint)); + if (multicomponent && heat) SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Flow->GetTemperature(iPoint)); } SetVolumeOutputValue("RES_PRESSURE", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 0)); From 09fe6f4e4e8bb8496e14344a7319206957cf2de4 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 31 Oct 2024 21:36:03 +0100 Subject: [PATCH 044/173] adding enthalpy diffusion --- SU2_CFD/include/fluid/CFluidModel.hpp | 10 +++++ SU2_CFD/include/fluid/CFluidScalar.hpp | 30 ++++++++++++- SU2_CFD/include/numerics/CNumerics.hpp | 28 ++++++++++++ .../include/numerics/flow/flow_diffusion.hpp | 9 ++-- .../include/solvers/CFVMFlowSolverBase.inl | 37 +++++++++++++++- SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 44 ++++++++++++++++--- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 4 +- 7 files changed, 150 insertions(+), 12 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 29cb44fcc033..2ed618eff339 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -192,6 +192,16 @@ class CFluidModel { return mass_diffusivity; } + /*! + * \brief Get heat diffusivity. + */ + inline virtual su2double GetEnthalpyDiffusivity(const su2double* val_scalars = nullptr) { return 0.0; } + + /*! + * \brief Get gradient heat diffusivity. + */ + inline virtual su2double GetGradEnthalpyDiffusivity(const su2double* val_scalars = nullptr) { return 0.0; } + /*! * \brief Get fluid pressure partial derivative. */ diff --git a/SU2_CFD/include/fluid/CFluidScalar.hpp b/SU2_CFD/include/fluid/CFluidScalar.hpp index 527adbf6ffad..70faa111b473 100644 --- a/SU2_CFD/include/fluid/CFluidScalar.hpp +++ b/SU2_CFD/include/fluid/CFluidScalar.hpp @@ -44,6 +44,8 @@ class CFluidScalar final : public CFluidModel { const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */ const su2double GasConstant_Ref; /*!< \brief Gas constant reference needed for Nondimensional problems. */ const su2double Prandtl_Number; /*!< \brief Prandlt number.*/ + su2double enthalpyDiffusivity; /*!< \brief enthalpy diffusion coefficient. */ + su2double gradEnthalpyDiffusivity; /*!< \brief gradient enthalpy diffusion coefficient. */ const bool wilke; const bool davidson; @@ -94,7 +96,7 @@ class CFluidScalar final : public CFluidModel { /*! * \brief Compute Enthalpy given the temperature and scalars. */ - su2double ComputeEnthalpyFromT(const su2double val_enthalpy, const su2double* val_scalars); + su2double ComputeEnthalpyFromT(const su2double val_temperature, const su2double* val_scalars); /*! * \brief Compute gas constant for mixture. @@ -142,6 +144,32 @@ class CFluidScalar final : public CFluidModel { */ inline su2double GetMassDiffusivity(int ivar) override { return massDiffusivity[ivar]; } + /*! + * \brief Get enthalpy diffusivity. + */ + inline su2double GetEnthalpyDiffusivity(const su2double* val_scalars) override { + enthalpyDiffusivity = 0.0; + for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { + enthalpyDiffusivity += (specificHeat[iVar] * massDiffusivity[iVar] - + specificHeat[n_species_mixture - 1] * massDiffusivity[n_species_mixture - 1]) * + (Temperature - 298.15) * val_scalars[iVar]; + } + return enthalpyDiffusivity; + } + + /*! + * \brief Get gradient enthalpy diffusivity. + */ + inline su2double GetGradEnthalpyDiffusivity(const su2double* val_scalars) override { + gradEnthalpyDiffusivity = 0.0; + for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { + gradEnthalpyDiffusivity += Density * (specificHeat[iVar] * massDiffusivity[iVar] - + specificHeat[n_species_mixture - 1] * massDiffusivity[n_species_mixture - 1]) * + val_scalars[iVar]; + } + return gradEnthalpyDiffusivity; + } + /*! * \brief Compute Temperature from Enthalpy and scalars. */ diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index f5b0634030fc..da6f64fa23bc 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -131,6 +131,12 @@ class CNumerics { *ScalarVar_i, /*!< \brief Vector of scalar variables at point i. */ *ScalarVar_j; /*!< \brief Vector of scalar variables at point j. */ const su2double + *HeatDiffusion_i, /*!< \brief Vector of heat diffusion for multicomponent at point i. */ + *HeatDiffusion_j; /*!< \brief Vector of heat diffusion for multicomponent at point j. */ + const su2double + *GradHeatDiffusion_i, /*!< \brief Vector of heat diffusion for multicomponent at point i. */ + *GradHeatDiffusion_j; /*!< \brief Vector of heat diffusion for multicomponent at point j. */ + const su2double *TransVar_i, /*!< \brief Vector of turbulent variables at point i. */ *TransVar_j; /*!< \brief Vector of turbulent variables at point j. */ const su2double @@ -753,6 +759,28 @@ class CNumerics { Diffusion_Coeff_j = val_diffusioncoeff_j; } + /*! + * \brief Set the heat diffusion + * \param[in] val_heatdiffusion_i - Value of the heat diffusion at i. + * \param[in] val_heatdiffusion_j - Value of the heat diffusion at j + */ + inline void SetHeatDiffusion(const su2double* val_heatdiffusion_i, + const su2double* val_heatdiffusion_j) { + HeatDiffusion_i = val_heatdiffusion_i; + HeatDiffusion_j = val_heatdiffusion_j; + } + + /*! + * \brief Set the heat diffusion + * \param[in] val_gradheatdiffusion_i - Value of the heat diffusion at i. + * \param[in] val_gradheatdiffusion_j - Value of the heat diffusion at j + */ + inline void SetGradHeatDiffusion(const su2double* val_gradheatdiffusion_i, + const su2double* val_gradheatdiffusion_j) { + GradHeatDiffusion_i = val_gradheatdiffusion_i; + GradHeatDiffusion_j = val_gradheatdiffusion_j; + } + /*! * \brief Set the laminar viscosity. * \param[in] val_laminar_viscosity_i - Value of the laminar viscosity at point i. diff --git a/SU2_CFD/include/numerics/flow/flow_diffusion.hpp b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp index 558d035eb1b1..be24cddb6e11 100644 --- a/SU2_CFD/include/numerics/flow/flow_diffusion.hpp +++ b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp @@ -51,6 +51,8 @@ class CAvgGrad_Base : public CNumerics { *heat_flux_jac_i = nullptr, /*!< \brief Jacobian of the molecular + turbulent heat flux vector, projected onto the normal vector. */ **tau_jacobian_i = nullptr; /*!< \brief Jacobian of the viscous + turbulent stress tensor, projected onto the normal vector. */ su2double *Mean_PrimVar = nullptr; /*!< \brief Mean primitive variables. */ + su2double *Mean_GradSecVar = nullptr; /*!< \brief Mean gradient secundary variable for multicomponent flows. */ + su2double *Mean_JacSecVar = nullptr; /*!< \brief Mean jacobian secundary variables for multicomponent flows. */ const su2double *PrimVar_i = nullptr, *PrimVar_j = nullptr; /*!< \brief Primitives variables at point i and j. */ @@ -288,6 +290,7 @@ class CAvgGradInc_Flow final : public CAvgGrad_Base { private: su2double Mean_Thermal_Conductivity; /*!< \brief Mean value of the effective thermal conductivity. */ su2double Mean_Heat_Capacity; /*!< \brief Mean value of the heat capacity. */ + su2double Mean_Density; /*!< \brief Mean value of the density. */ bool energy; /*!< \brief computation with the energy equation. */ /*! @@ -299,10 +302,10 @@ class CAvgGradInc_Flow final : public CAvgGrad_Base { * \param[in] val_gradprimvar - Gradient of the primitive variables. * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. * \param[in] val_thermal_conductivity - Thermal conductivity. + * \param[in] val_heatDiffusion - Heat diffusion */ - void GetViscousIncProjFlux(const su2double* const *val_gradprimvar, - const su2double *val_normal, - su2double val_thermal_conductivity); + void GetViscousIncProjFlux(const su2double* const* val_gradprimvar, const su2double* val_normal, + su2double val_thermal_conductivity, const su2double* val_heatDiffusion = nullptr); /*! * \brief Compute the projection of the viscous Jacobian matrices. diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 4797293529f6..499478c18285 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -31,6 +31,7 @@ #include "../limiters/computeLimiters.hpp" #include "../numerics_simd/CNumericsSIMD.hpp" #include "CFVMFlowSolverBase.hpp" +#include "../../include/variables/CSpeciesVariable.hpp" template void CFVMFlowSolverBase::AeroCoeffsArray::allocate(int size) { @@ -433,9 +434,14 @@ void CFVMFlowSolverBase::Viscous_Residual_impl(unsigned long iEdge, CGeome const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool tkeNeeded = (config->GetKind_Turb_Model() == TURB_MODEL::SST); + const bool speciesEnergy = (config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation(); - CVariable* turbNodes = nullptr; + CVariable* turbNodes = nullptr; + //CVariable* speciesNodes = nullptr; if (tkeNeeded) turbNodes = solver_container[TURB_SOL]->GetNodes(); + //if (speciesEnergy) speciesNodes = solver_container[SPECIES_SOL]->GetNodes(); + + auto* speciesNodes = su2staticcast_p(solver_container[SPECIES_SOL]->GetNodes()); /*--- Points, coordinates and normal vector in edge ---*/ @@ -465,6 +471,35 @@ void CFVMFlowSolverBase::Viscous_Residual_impl(unsigned long iEdge, CGeome if (tkeNeeded) numerics->SetTurbKineticEnergy(turbNodes->GetSolution(iPoint,0), turbNodes->GetSolution(jPoint,0)); + /*--- Conservative variables w/o reconstruction ---*/ + + if (speciesEnergy) { + CFluidModel* FluidModel = solver_container[FLOW_SOL]->GetFluidModel(); + FluidModel->SetTDState_T(nodes->GetPrimitive(iPoint)[prim_idx.Temperature()], speciesNodes->GetSolution(iPoint)); + const int n_species = config->GetnSpecies(); + su2double GradientScalar[n_species]; + su2double HeatDiffusion_i[nDim]; + su2double GradDiffusion_i[nDim]; + for (int i = 0; i < nDim; i++) { + for (int i_species = 0; i_species < n_species; i_species++) { + GradientScalar[i_species] = speciesNodes->GetGradient(iPoint)[i_species][i]; + } + HeatDiffusion_i[i] = FluidModel->GetEnthalpyDiffusivity(GradientScalar); + GradDiffusion_i[i] = FluidModel->GetGradEnthalpyDiffusivity(GradientScalar); + } + FluidModel->SetTDState_T(nodes->GetPrimitive(jPoint)[prim_idx.Temperature()], speciesNodes->GetSolution(jPoint)); + su2double HeatDiffusion_j[nDim]; + su2double GradDiffusion_j[nDim]; + for (int i = 0; i < nDim; i++) { + for (int i_species = 0; i_species < n_species; i_species++) { + GradientScalar[i_species] = speciesNodes->GetGradient(iPoint)[i_species][i]; + } + HeatDiffusion_j[i] = FluidModel->GetEnthalpyDiffusivity(GradientScalar); + GradDiffusion_j[i] = FluidModel->GetGradEnthalpyDiffusivity(GradientScalar); + } + numerics->SetHeatDiffusion(HeatDiffusion_i, HeatDiffusion_j); + numerics->SetGradHeatDiffusion(GradDiffusion_i, GradDiffusion_j); + } /*--- Wall shear stress values (wall functions) ---*/ diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index 2e95a6ea0204..5661e75d7016 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -50,6 +50,9 @@ CAvgGrad_Base::CAvgGrad_Base(unsigned short val_nDim, for (iVar = 0; iVar < nPrimVar; iVar++) Mean_GradPrimVar[iVar] = new su2double [nDim]; + Mean_GradSecVar = new su2double[nDim]; + Mean_JacSecVar = new su2double[nDim]; + Proj_Mean_GradPrimVar_Edge = new su2double[val_nPrimVar]; tau_jacobian_i = new su2double* [nDim]; @@ -71,6 +74,8 @@ CAvgGrad_Base::CAvgGrad_Base(unsigned short val_nDim, CAvgGrad_Base::~CAvgGrad_Base() { delete [] Mean_PrimVar; + delete [] Mean_GradSecVar; + delete [] Mean_JacSecVar; if (Mean_GradPrimVar != nullptr) { for (unsigned short iVar = 0; iVar < nPrimVar; iVar++) @@ -586,6 +591,8 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi if (multicomponent_energy) { Cp_i = V_i[nDim + 7]; Cp_j = V_j[nDim + 7]; + Density_i = V_i[nDim + 2]; + Density_j = V_i[nDim + 2]; } /*--- Mean transport properties ---*/ @@ -594,7 +601,10 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); - if (multicomponent_energy) Mean_Heat_Capacity = 0.5 * (Cp_i + Cp_j); + if (multicomponent_energy) { + Mean_Heat_Capacity = 0.5 * (Cp_i + Cp_j); + Mean_Density = 0.5 * (Density_i + Density_j); + } /*--- Mean gradient approximation ---*/ @@ -628,7 +638,14 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi if (config->GetSAParsedOptions().qcr2000) AddQCR(nDim, &Mean_GradPrimVar[1], tau); if (Mean_TauWall > 0) AddTauWall(UnitNormal, Mean_TauWall); - GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity); + if (multicomponent_energy) { + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradSecVar[iDim] = 0.5 * (HeatDiffusion_i[iDim] + HeatDiffusion_j[iDim]) * Mean_Density; + Mean_JacSecVar[iDim] = 0.5 * (GradHeatDiffusion_i[iDim] + GradHeatDiffusion_j[iDim]); + } + } + + GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity, Mean_GradSecVar); /*--- Implicit part ---*/ @@ -655,8 +672,14 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi } proj_vector_ij = proj_vector_ij/dist_ij_2; if (multicomponent_energy){ - Jacobian_i[nDim + 1][nDim + 1] = -Mean_Thermal_Conductivity * proj_vector_ij / Mean_Heat_Capacity; - Jacobian_j[nDim + 1][nDim + 1] = Mean_Thermal_Conductivity * proj_vector_ij / Mean_Heat_Capacity; + su2double projJacGradSecVar= 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + projJacGradSecVar += Mean_JacSecVar[iDim] * Normal[iDim]; + } + Jacobian_i[nDim + 1][nDim + 1] = + -(Mean_Thermal_Conductivity * proj_vector_ij + projJacGradSecVar) / Mean_Heat_Capacity; + Jacobian_j[nDim + 1][nDim + 1] = + (Mean_Thermal_Conductivity * proj_vector_ij + projJacGradSecVar) / Mean_Heat_Capacity; } else { Jacobian_i[nDim + 1][nDim + 1] = -Mean_Thermal_Conductivity * proj_vector_ij; Jacobian_j[nDim + 1][nDim + 1] = Mean_Thermal_Conductivity * proj_vector_ij; @@ -687,7 +710,8 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradprimvar, const su2double *val_normal, - su2double val_thermal_conductivity) { + su2double val_thermal_conductivity, + const su2double *val_heatDiffusion) { /*--- Gradient of primitive variables -> [Pressure vel_x vel_y vel_z Temperature] ---*/ @@ -703,6 +727,10 @@ void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradpri Flux_Tensor[1][1] = tau[1][0]; Flux_Tensor[2][1] = tau[1][1]; Flux_Tensor[3][1] = val_thermal_conductivity*val_gradprimvar[nDim+1][1]; + if (multicomponent_energy) { + Flux_Tensor[3][0] += val_heatDiffusion[0]; + Flux_Tensor[3][1] += val_heatDiffusion[1]; + } } else { @@ -724,6 +752,12 @@ void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradpri Flux_Tensor[3][2] = tau[2][2]; Flux_Tensor[4][2] = val_thermal_conductivity*val_gradprimvar[nDim+1][2]; + if (multicomponent_energy) { + Flux_Tensor[4][0] += val_heatDiffusion[0]; + Flux_Tensor[4][1] += val_heatDiffusion[1]; + Flux_Tensor[4][2] += val_heatDiffusion[2]; + } + } for (unsigned short iVar = 0; iVar < nVar; iVar++) { diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 64b0f2cc91ff..f3de80979363 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2477,7 +2477,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Viscous contribution, commented out because serious convergence problems ---*/ - if (!viscous) continue; + if (!viscous || Energy_Multicomponent) continue; /*--- Set transport properties at the inlet ---*/ @@ -2685,7 +2685,7 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Viscous contribution, commented out because serious convergence problems ---*/ - if (!viscous) continue; + if (!viscous || Energy_Multicomponent) continue; /*--- Set transport properties at the outlet. ---*/ From f258308fbf96a6dc39ab698ba9dbfc90354eeae8 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sun, 3 Nov 2024 10:52:03 +0100 Subject: [PATCH 045/173] moving enthalpy diffusion terms to CIncNSSolver.cpp --- .../include/solvers/CFVMFlowSolverBase.inl | 35 --------------- SU2_CFD/src/solvers/CIncNSSolver.cpp | 45 ++++++++++++++++++- 2 files changed, 44 insertions(+), 36 deletions(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 499478c18285..fe207611f7d5 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -31,7 +31,6 @@ #include "../limiters/computeLimiters.hpp" #include "../numerics_simd/CNumericsSIMD.hpp" #include "CFVMFlowSolverBase.hpp" -#include "../../include/variables/CSpeciesVariable.hpp" template void CFVMFlowSolverBase::AeroCoeffsArray::allocate(int size) { @@ -434,14 +433,9 @@ void CFVMFlowSolverBase::Viscous_Residual_impl(unsigned long iEdge, CGeome const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool tkeNeeded = (config->GetKind_Turb_Model() == TURB_MODEL::SST); - const bool speciesEnergy = (config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation(); CVariable* turbNodes = nullptr; - //CVariable* speciesNodes = nullptr; if (tkeNeeded) turbNodes = solver_container[TURB_SOL]->GetNodes(); - //if (speciesEnergy) speciesNodes = solver_container[SPECIES_SOL]->GetNodes(); - - auto* speciesNodes = su2staticcast_p(solver_container[SPECIES_SOL]->GetNodes()); /*--- Points, coordinates and normal vector in edge ---*/ @@ -471,35 +465,6 @@ void CFVMFlowSolverBase::Viscous_Residual_impl(unsigned long iEdge, CGeome if (tkeNeeded) numerics->SetTurbKineticEnergy(turbNodes->GetSolution(iPoint,0), turbNodes->GetSolution(jPoint,0)); - /*--- Conservative variables w/o reconstruction ---*/ - - if (speciesEnergy) { - CFluidModel* FluidModel = solver_container[FLOW_SOL]->GetFluidModel(); - FluidModel->SetTDState_T(nodes->GetPrimitive(iPoint)[prim_idx.Temperature()], speciesNodes->GetSolution(iPoint)); - const int n_species = config->GetnSpecies(); - su2double GradientScalar[n_species]; - su2double HeatDiffusion_i[nDim]; - su2double GradDiffusion_i[nDim]; - for (int i = 0; i < nDim; i++) { - for (int i_species = 0; i_species < n_species; i_species++) { - GradientScalar[i_species] = speciesNodes->GetGradient(iPoint)[i_species][i]; - } - HeatDiffusion_i[i] = FluidModel->GetEnthalpyDiffusivity(GradientScalar); - GradDiffusion_i[i] = FluidModel->GetGradEnthalpyDiffusivity(GradientScalar); - } - FluidModel->SetTDState_T(nodes->GetPrimitive(jPoint)[prim_idx.Temperature()], speciesNodes->GetSolution(jPoint)); - su2double HeatDiffusion_j[nDim]; - su2double GradDiffusion_j[nDim]; - for (int i = 0; i < nDim; i++) { - for (int i_species = 0; i_species < n_species; i_species++) { - GradientScalar[i_species] = speciesNodes->GetGradient(iPoint)[i_species][i]; - } - HeatDiffusion_j[i] = FluidModel->GetEnthalpyDiffusivity(GradientScalar); - GradDiffusion_j[i] = FluidModel->GetGradEnthalpyDiffusivity(GradientScalar); - } - numerics->SetHeatDiffusion(HeatDiffusion_i, HeatDiffusion_j); - numerics->SetGradHeatDiffusion(GradDiffusion_i, GradDiffusion_j); - } /*--- Wall shear stress values (wall functions) ---*/ diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 41cedcdb5f59..9971a2a2ddc9 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -275,7 +275,50 @@ void CIncNSSolver::Compute_Streamwise_Periodic_Recovered_Values(CConfig *config, void CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config) { - + const bool speciesEnergy = + (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation(); + const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); + + /*--- Contribution to heat flux due to enthalpy diffusion for multicomponent and reacting flows ---*/ + if (speciesEnergy) { + CVariable* speciesNodes = solver_container[SPECIES_SOL]->GetNodes(); + /*--- Points in edge ---*/ + + auto iPoint = geometry->edges->GetNode(iEdge, 0); + auto jPoint = geometry->edges->GetNode(iEdge, 1); + CFluidModel* FluidModel = solver_container[FLOW_SOL]->GetFluidModel(); + FluidModel->SetTDState_T(nodes->GetPrimitive(iPoint)[prim_idx.Temperature()], speciesNodes->GetSolution(iPoint)); + const int n_species = config->GetnSpecies(); + static constexpr size_t MAXNVAR_SPECIES = 20UL; + su2double GradientScalar[MAXNVAR_SPECIES]; + su2double HeatDiffusion_i[MAXNDIM]; + su2double GradDiffusion_i[MAXNDIM]; + /*--- Loop over spatial dimensions to fill in the enthalpy diffusion with the gradient of scalar species. ---*/ + /*--- The gradients of species with respect to the i-spatial dimension are stored in GradientScalars. ---*/ + for (int i = 0; i < nDim; i++) { + for (int i_species = 0; i_species < n_species; i_species++) { + GradientScalar[i_species] = speciesNodes->GetGradient(iPoint)[i_species][i]; + } + /*--- The gradients due to enthalpy diffusion depend on the fluid model, in particular if we are solving for total + * enthalpy or sensible enthalpy. ---*/ + HeatDiffusion_i[i] = FluidModel->GetEnthalpyDiffusivity(GradientScalar); + if (implicit) GradDiffusion_i[i] = FluidModel->GetGradEnthalpyDiffusivity(GradientScalar); + } + /*--- Repeat the above computations for jPoint. ---*/ + FluidModel->SetTDState_T(nodes->GetPrimitive(jPoint)[prim_idx.Temperature()], speciesNodes->GetSolution(jPoint)); + su2double HeatDiffusion_j[MAXNDIM]; + su2double GradDiffusion_j[MAXNDIM]; + for (int i = 0; i < nDim; i++) { + for (int i_species = 0; i_species < n_species; i_species++) { + GradientScalar[i_species] = speciesNodes->GetGradient(iPoint)[i_species][i]; + } + HeatDiffusion_j[i] = FluidModel->GetEnthalpyDiffusivity(GradientScalar); + if (implicit) GradDiffusion_j[i] = FluidModel->GetGradEnthalpyDiffusivity(GradientScalar); + } + /*--- Enthalpy diffusion and gradient (for implicit iterations) ---*/ + numerics->SetHeatDiffusion(HeatDiffusion_i, HeatDiffusion_j); + if (implicit) numerics->SetGradHeatDiffusion(GradDiffusion_i, GradDiffusion_j); + } Viscous_Residual_impl(iEdge, geometry, solver_container, numerics, config); } From 63a8f372d378aa7a7064f0be17dfe743f5b41e87 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sun, 3 Nov 2024 13:57:03 +0100 Subject: [PATCH 046/173] small fix --- SU2_CFD/include/fluid/CFluidModel.hpp | 5 ++--- SU2_CFD/include/fluid/CFluidScalar.hpp | 3 ++- SU2_CFD/src/fluid/CFluidScalar.cpp | 6 +++--- SU2_CFD/src/variables/CIncNSVariable.cpp | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 2ed618eff339..2d80d373b0ee 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -359,9 +359,8 @@ class CFluidModel { * \brief Virtual member. * \param[in] val_enthalpy - Enthalpy value at the point. */ - inline virtual su2double ComputeTempFromEnthalpy(su2double val_enthalpy, const su2double* val_scalars = nullptr) { - 0.0; - } + virtual void ComputeTempFromEnthalpy(su2double val_enthalpy, su2double* val_temperature, + const su2double* val_scalars = nullptr) {} /*! * \brief Set fluid eddy viscosity provided by a turbulence model needed for computing effective thermal conductivity. diff --git a/SU2_CFD/include/fluid/CFluidScalar.hpp b/SU2_CFD/include/fluid/CFluidScalar.hpp index 70faa111b473..516b44579060 100644 --- a/SU2_CFD/include/fluid/CFluidScalar.hpp +++ b/SU2_CFD/include/fluid/CFluidScalar.hpp @@ -173,7 +173,8 @@ class CFluidScalar final : public CFluidModel { /*! * \brief Compute Temperature from Enthalpy and scalars. */ - inline su2double ComputeTempFromEnthalpy(const su2double val_temperature, const su2double* val_scalars) override; + void ComputeTempFromEnthalpy(const su2double val_enthalpy, su2double* val_temperature, + const su2double* val_scalars) override; /*! * \brief Set the Dimensionless State using Temperature. diff --git a/SU2_CFD/src/fluid/CFluidScalar.cpp b/SU2_CFD/src/fluid/CFluidScalar.cpp index e8c50c1f38ea..60b57df5ea43 100644 --- a/SU2_CFD/src/fluid/CFluidScalar.cpp +++ b/SU2_CFD/src/fluid/CFluidScalar.cpp @@ -217,11 +217,11 @@ su2double CFluidScalar::ComputeEnthalpyFromT(const su2double val_temperature, co return val_Enthalpy; } -su2double CFluidScalar::ComputeTempFromEnthalpy(const su2double val_enthalpy, const su2double* val_scalars){ +void CFluidScalar::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2double* val_temperature, + const su2double* val_scalars) { MassToMoleFractions(val_scalars); su2double val_cp = ComputeMeanSpecificHeatCp(val_scalars); - su2double val_Temperature = val_enthalpy / val_cp + 298.15; - return val_Temperature; + *val_temperature = val_enthalpy / val_cp + 298.15; } void CFluidScalar::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index 7e2c80b9909d..c2aae3bc8c88 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -62,7 +62,7 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do if(Energy_Multicomponent){ su2double Enthalpy = Solution(iPoint, nDim +1); - Temperature = FluidModel->ComputeTempFromEnthalpy(Enthalpy, scalar); + FluidModel->ComputeTempFromEnthalpy(Enthalpy, &Temperature, scalar); } else { /*--- Set the value of the temperature directly ---*/ Temperature = Solution(iPoint, indices.Temperature()); @@ -102,12 +102,12 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do if (Energy_Multicomponent) { su2double Enthalpy = Solution(iPoint, nDim + 1); - Temperature = FluidModel->ComputeTempFromEnthalpy(Enthalpy, scalar); + FluidModel->ComputeTempFromEnthalpy(Enthalpy, &Temperature, scalar); } else { Temperature = Solution(iPoint, indices.Temperature()); - FluidModel->SetTDState_T(Temperature, scalar); } SetTemperature(iPoint, Temperature); + FluidModel->SetTDState_T(Temperature, scalar); SetDensity(iPoint, FluidModel->GetDensity()); /*--- Flag this point as non-physical. ---*/ From 481db68b2500ba3d968d74b854602b0c7277aa3a Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 7 Nov 2024 14:17:28 +0100 Subject: [PATCH 047/173] adding enthalpy and gradient diffusivities --- SU2_CFD/include/fluid/CFluidCantera.hpp | 19 ++++++ SU2_CFD/src/fluid/CFluidCantera.cpp | 86 +++++++++++++++++++++++-- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 29 +++++++-- 3 files changed, 125 insertions(+), 9 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 616889de6a9e..6ec8b34e492a 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -56,12 +56,15 @@ class CFluidCantera final : public CFluidModel { const string Transport_Model; /*!< \brief Transport model used for computing mixture properties*/ const string Chemical_MechanismFile; /*!< \brief Chemical reaction mechanism used for in cantera*/ const string Phase_Name; /*!< \brief Name of the phase used for in cantera*/ + su2double enthalpyDiffusivity; /*!< \brief enthalpy diffusion coefficient. */ + su2double gradEnthalpyDiffusivity; /*!< \brief gradient enthalpy diffusion coefficient. */ static constexpr int ARRAYSIZE = 16; #ifdef USE_CANTERA std::array gasComposition; /*!< \brief Gas composition. */ std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ std::array chemicalSourceTerm; /*!< \brief chemical source term of all species*/ + std::array molarMasses; /*!< \brief Molar masses of all species. */ su2double Heat_Release; /*!< \brief heat release due to combustion */ #endif std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ @@ -129,6 +132,22 @@ class CFluidCantera final : public CFluidModel { */ inline su2double GetHeatRelease() override { return Heat_Release; } + /*! + * \brief Compute Temperature from Enthalpy and scalars. + */ + void ComputeTempFromEnthalpy(const su2double val_enthalpy, su2double* val_temperature, + const su2double* val_scalars) override; + + /*! + * \brief Get enthalpy diffusivity. + */ + inline su2double GetEnthalpyDiffusivity(const su2double* val_scalars) override; + + /*! + * \brief Get gradient enthalpy diffusivity. + */ + inline su2double GetGradEnthalpyDiffusivity(const su2double* val_scalars) override; + /*! * \brief Set the Dimensionless State using Temperature. * \param[in] t - Temperature value at the point. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index c2c285166ec5..f0dd496972a5 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -56,11 +56,12 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* } #ifdef USE_CANTERA + sol = std::shared_ptr(newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model)); + sol->thermo()->getMolecularWeights(&molarMasses[0]); for (int iVar = 0; iVar < n_species_mixture; iVar++) { gasComposition[iVar]=config->GetChemical_GasComposition(iVar); //config->SetChemical_GasComposition(iVar, gasComposition[iVar]); //this should be used for later } - sol = std::shared_ptr(newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model)); #endif SetMassDiffusivityModel(config); @@ -84,12 +85,10 @@ void CFluidCantera::ComputeMassDiffusivity() { void CFluidCantera::ComputeChemicalSourceTerm(){ vector netProductionRates(sol->kinetics()->nReactions()); - vector molecularWeights(sol->thermo()->nSpecies()); sol->kinetics()->getNetProductionRates(&netProductionRates[0]); - sol->thermo()->getMolecularWeights(&molecularWeights[0]); for (int iVar = 0; iVar < n_species_mixture; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - chemicalSourceTerm[iVar] = molecularWeights[speciesIndex]*netProductionRates[speciesIndex]; + chemicalSourceTerm[iVar] = molarMasses[speciesIndex]*netProductionRates[speciesIndex]; } } @@ -105,6 +104,84 @@ void CFluidCantera::ComputeHeatRelease(){ } } +/*! + * \brief Get enthalpy diffusivity. + */ +su2double CFluidCantera::GetEnthalpyDiffusivity(const su2double* val_scalars) { + const int nsp = sol->thermo()->nSpecies(); + // The universal gas constant times temperature is retrieved from cantera. + const su2double uni_gas_constant_temp = sol->thermo()->RT(); + vector enthalpiesSpecies(nsp); + vector diff(nsp); + sol->thermo()->getEnthalpy_RT_ref(&enthalpiesSpecies[0]); + sol->transport()->getMixDiffCoeffsMass(&diff[0]); + enthalpyDiffusivity = 0.0; + const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); + for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { + int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); + enthalpyDiffusivity += uni_gas_constant_temp * + ((enthalpiesSpecies[speciesIndex] * diff[speciesIndex] / molarMasses[speciesIndex]) - + (enthalpiesSpecies[speciesN] * diff[speciesN] / molarMasses[speciesN])) * + val_scalars[iVar]; + } + return enthalpyDiffusivity; +} + +/*! + * \brief Get gradient enthalpy diffusivity. + */ +su2double CFluidCantera::GetGradEnthalpyDiffusivity(const su2double* val_scalars) { + const int nsp = sol->thermo()->nSpecies(); + // The universal gas constant is retrieved from cantera,in order to keep consistency with the values retrieve from it. + const su2double universal_gas_constant = (sol->thermo()->RT()) / Temperature; + vector specificHeatSpecies(nsp); + vector diff(nsp); + sol->thermo()->getCp_R_ref(&specificHeatSpecies[0]); + sol->transport()->getMixDiffCoeffsMass(&diff[0]); + gradEnthalpyDiffusivity = 0.0; + const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); + for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { + int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); + gradEnthalpyDiffusivity += + Density * universal_gas_constant * + ((specificHeatSpecies[speciesIndex] * diff[speciesIndex] / molarMasses[speciesIndex]) - + (specificHeatSpecies[speciesN] * diff[speciesN] / molarMasses[speciesN])) * + val_scalars[iVar]; + } + return gradEnthalpyDiffusivity; +} + +void CFluidCantera::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2double* val_temperature, + const su2double* val_scalars) { + DictionaryChemicalComposition(val_scalars); + /*--- convergence criterion for temperature in [K], high accuracy needed for restarts. ---*/ + su2double toll = 1e-5; + su2double temp_iter = 300.0; + su2double delta_temp_iter = 1e10; + su2double delta_enthalpy_iter; + const int counter_limit = 20; + + int counter = 0; + + while ((abs(delta_temp_iter) > toll) && (counter++ < counter_limit)) { + /*--- Set thermodynamic state based on the current value of temperature. ---*/ + sol->thermo()->setState_TPY(GetValue(temp_iter), GetValue(Pressure_Thermodynamic), chemical_composition); + + su2double Enthalpy = sol->thermo()->enthalpy_mass(); + su2double Cp = sol->thermo()->cp_mass(); + + delta_enthalpy_iter = val_enthalpy - Enthalpy; + + delta_temp_iter = delta_enthalpy_iter / Cp; + + temp_iter += delta_temp_iter; + } + *val_temperature = temp_iter; + if (counter == counter_limit) { + cout << "Warning Newton-Raphson exceed number of max iteration in temperature computation" << endl; + } +} + string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars) { su2double val_scalars_sum{0.0}; chemical_composition=""; @@ -122,6 +199,7 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl Temperature = val_temperature; sol->thermo()->setState_TPY(GetValue(Temperature), GetValue(Pressure_Thermodynamic), chemical_composition); Density = sol->thermo()->density(); + Enthalpy = sol->thermo()->enthalpy_mass(); Cp = sol->thermo()->cp_mass(); Cv = sol->thermo()->cv_mass(); Mu = sol->transport()->viscosity(); diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 5746a629b928..d3b5639dca53 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -180,11 +180,30 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned Pressure_Inf = config->GetPressure_FreeStreamND(); Velocity_Inf = config->GetVelocity_FreeStreamND(); Temperature_Inf = config->GetTemperature_FreeStreamND(); - if (Energy_Multicomponent){ - CFluidModel *auxFluidModel = new CFluidScalar(config->GetPressure_Thermodynamic(), config); - const su2double *scalar_init = config->GetSpecies_Init(); - auxFluidModel->SetTDState_T(Temperature_Inf,scalar_init); // compute total enthalpy from temperature - Enthalpy_Inf = auxFluidModel->GetEnthalpy(); + if (Energy_Multicomponent) { + const su2double* scalar_init = config->GetSpecies_Init(); + CFluidModel* auxFluidModel = nullptr; + + switch (config->GetKind_FluidModel()) { + case FLUID_MIXTURE: + + auxFluidModel = new CFluidScalar(config->GetPressure_Thermodynamic(), config); + auxFluidModel->SetTDState_T(Temperature_Inf, scalar_init); // compute total enthalpy from temperature + Enthalpy_Inf = auxFluidModel->GetEnthalpy(); + break; + + case FLUID_CANTERA: + + auxFluidModel = new CFluidCantera(config->GetPressure_Thermodynamic(), config); + auxFluidModel->SetTDState_T(Temperature_Inf, scalar_init); // compute total enthalpy from temperature + Enthalpy_Inf = auxFluidModel->GetEnthalpy(); + break; + + default: + + SU2_MPI::Error("Fluid model not compatible with multicomponent-reacting flows.", CURRENT_FUNCTION); + break; + } } /*--- Initialize the secondary values for direct derivative approxiations ---*/ From 573cefc3e2fdd90b8a6a285c2e8106466d088ab6 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 8 Nov 2024 09:20:54 +0100 Subject: [PATCH 048/173] increasing MAXNVAR in scalar convection and diffusion --- SU2_CFD/include/numerics/scalar/scalar_convection.hpp | 2 +- SU2_CFD/include/numerics/scalar/scalar_diffusion.hpp | 2 +- UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp | 4 ++-- UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp index 3e44479ac173..e7c0be6ad011 100644 --- a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp +++ b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp @@ -47,7 +47,7 @@ template class CUpwScalar : public CNumerics { protected: - enum : unsigned short {MAXNVAR = 8}; + enum : unsigned short {MAXNVAR = 20}; const FlowIndices idx; /*!< \brief Object to manage the access to the flow primitives. */ su2double a0 = 0.0; /*!< \brief The maximum of the face-normal velocity and 0. */ diff --git a/SU2_CFD/include/numerics/scalar/scalar_diffusion.hpp b/SU2_CFD/include/numerics/scalar/scalar_diffusion.hpp index 4e588c59d6c1..b6b3150b5f4a 100644 --- a/SU2_CFD/include/numerics/scalar/scalar_diffusion.hpp +++ b/SU2_CFD/include/numerics/scalar/scalar_diffusion.hpp @@ -59,7 +59,7 @@ struct CNoFlowIndices { template class CAvgGrad_Scalar : public CNumerics { protected: - enum : unsigned short {MAXNVAR = 8}; + enum : unsigned short {MAXNVAR = 20}; const FlowIndices idx; /*!< \brief Object to manage the access to the flow primitives. */ su2double Proj_Mean_GradScalarVar[MAXNVAR]; /*!< \brief Mean_gradScalarVar DOT normal, corrected if required. */ diff --git a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp index ee41faa0a228..7de5e9c4a875 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp @@ -92,7 +92,7 @@ TEST_CASE("Fluid_Cantera_Combustion", "[Reacting_flow]") { su2double sourceTerm_H2 = auxFluidModel->GetChemicalSourceTerm(0); su2double sourceTerm_O2 = auxFluidModel->GetChemicalSourceTerm(1); - CHECK(sourceTerm_H2 == Approx(-0.136338463240109)); - CHECK(sourceTerm_O2 == Approx(-2.16320837966703)); + CHECK(sourceTerm_H2 == Approx(-0.13633797171426)); + CHECK(sourceTerm_O2 == Approx(-2.16321066087493)); } #endif \ No newline at end of file diff --git a/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg b/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg index 9aee44ca3feb..dc4a9dc4c3bb 100644 --- a/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg +++ b/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg @@ -29,8 +29,8 @@ CONDUCTIVITY_MODEL= CANTERA VISCOSITY_MODEL= CANTERA % GAS_COMPOSITION_NAMES= H2, O2, N2 -CHEMICAL_MECHANISM_FILE= gri30.yaml -PHASE_NAME= gri30 +CHEMICAL_MECHANISM_FILE= h2o2.yaml +PHASE_NAME= ohmech TRANSPORT_MODEL= mixture-averaged % % -------------------- SCALAR TRANSPORT ---------------------------------------% From 30d0b88f8707c2697123f5b1880f2e0040425740 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 9 Nov 2024 16:12:22 +0100 Subject: [PATCH 049/173] cleaning and rewritting some functions --- SU2_CFD/include/fluid/CFluidModel.hpp | 8 +- SU2_CFD/include/fluid/CFluidScalar.hpp | 26 +----- SU2_CFD/include/numerics/CNumerics.hpp | 32 +++---- .../include/numerics/flow/flow_diffusion.hpp | 7 +- SU2_CFD/src/fluid/CFluidScalar.cpp | 17 ++++ SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 40 ++------- SU2_CFD/src/solvers/CIncNSSolver.cpp | 84 ++++++++++++------- subprojects/MLPCpp | 2 +- 8 files changed, 105 insertions(+), 111 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 2d80d373b0ee..15dc1a83cc7e 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -193,14 +193,14 @@ class CFluidModel { } /*! - * \brief Get heat diffusivity. + * \brief Get heat diffusivity terms. */ - inline virtual su2double GetEnthalpyDiffusivity(const su2double* val_scalars = nullptr) { return 0.0; } + virtual void GetEnthalpyDiffusivity(su2double* enthalpy_diffusions = nullptr) {} /*! - * \brief Get gradient heat diffusivity. + * \brief Get gradient heat diffusivity terms. */ - inline virtual su2double GetGradEnthalpyDiffusivity(const su2double* val_scalars = nullptr) { return 0.0; } + virtual void GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusions = nullptr) {} /*! * \brief Get fluid pressure partial derivative. diff --git a/SU2_CFD/include/fluid/CFluidScalar.hpp b/SU2_CFD/include/fluid/CFluidScalar.hpp index 516b44579060..1db6307cd46e 100644 --- a/SU2_CFD/include/fluid/CFluidScalar.hpp +++ b/SU2_CFD/include/fluid/CFluidScalar.hpp @@ -44,8 +44,6 @@ class CFluidScalar final : public CFluidModel { const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */ const su2double GasConstant_Ref; /*!< \brief Gas constant reference needed for Nondimensional problems. */ const su2double Prandtl_Number; /*!< \brief Prandlt number.*/ - su2double enthalpyDiffusivity; /*!< \brief enthalpy diffusion coefficient. */ - su2double gradEnthalpyDiffusivity; /*!< \brief gradient enthalpy diffusion coefficient. */ const bool wilke; const bool davidson; @@ -145,30 +143,14 @@ class CFluidScalar final : public CFluidModel { inline su2double GetMassDiffusivity(int ivar) override { return massDiffusivity[ivar]; } /*! - * \brief Get enthalpy diffusivity. + * \brief Get enthalpy diffusivity terms. */ - inline su2double GetEnthalpyDiffusivity(const su2double* val_scalars) override { - enthalpyDiffusivity = 0.0; - for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { - enthalpyDiffusivity += (specificHeat[iVar] * massDiffusivity[iVar] - - specificHeat[n_species_mixture - 1] * massDiffusivity[n_species_mixture - 1]) * - (Temperature - 298.15) * val_scalars[iVar]; - } - return enthalpyDiffusivity; - } + void GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) override; /*! - * \brief Get gradient enthalpy diffusivity. + * \brief Get gradient enthalpy diffusivity terms. */ - inline su2double GetGradEnthalpyDiffusivity(const su2double* val_scalars) override { - gradEnthalpyDiffusivity = 0.0; - for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { - gradEnthalpyDiffusivity += Density * (specificHeat[iVar] * massDiffusivity[iVar] - - specificHeat[n_species_mixture - 1] * massDiffusivity[n_species_mixture - 1]) * - val_scalars[iVar]; - } - return gradEnthalpyDiffusivity; - } + void GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusions) override; /*! * \brief Compute Temperature from Enthalpy and scalars. diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index da6f64fa23bc..b59bb99982f7 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -130,12 +130,10 @@ class CNumerics { const su2double *ScalarVar_i, /*!< \brief Vector of scalar variables at point i. */ *ScalarVar_j; /*!< \brief Vector of scalar variables at point j. */ - const su2double - *HeatDiffusion_i, /*!< \brief Vector of heat diffusion for multicomponent at point i. */ - *HeatDiffusion_j; /*!< \brief Vector of heat diffusion for multicomponent at point j. */ - const su2double - *GradHeatDiffusion_i, /*!< \brief Vector of heat diffusion for multicomponent at point i. */ - *GradHeatDiffusion_j; /*!< \brief Vector of heat diffusion for multicomponent at point j. */ + su2double + HeatFluxDiffusion; /*!< \brief Heat flux due to enthalpy diffusion for multicomponent. */ + su2double + Jac_HeatFluxDiffusion; /*!< \brief Heat flux jacobian due to enthalpy diffusion for multicomponent. */ const su2double *TransVar_i, /*!< \brief Vector of turbulent variables at point i. */ *TransVar_j; /*!< \brief Vector of turbulent variables at point j. */ @@ -760,25 +758,17 @@ class CNumerics { } /*! - * \brief Set the heat diffusion - * \param[in] val_heatdiffusion_i - Value of the heat diffusion at i. - * \param[in] val_heatdiffusion_j - Value of the heat diffusion at j + * \brief Set the heat flux due to enthalpy diffusion + * \param[in] val_heatfluxdiffusion - Value of the heat flux due to enthalpy diffusion. */ - inline void SetHeatDiffusion(const su2double* val_heatdiffusion_i, - const su2double* val_heatdiffusion_j) { - HeatDiffusion_i = val_heatdiffusion_i; - HeatDiffusion_j = val_heatdiffusion_j; - } + inline void SetHeatFluxDiffusion(su2double val_heatfluxdiffusion) { HeatFluxDiffusion = val_heatfluxdiffusion; } /*! - * \brief Set the heat diffusion - * \param[in] val_gradheatdiffusion_i - Value of the heat diffusion at i. - * \param[in] val_gradheatdiffusion_j - Value of the heat diffusion at j + * \brief Set Jacobian of the heat flux due to enthalpy diffusion + * \param[in] val_jacheatfluxdiffusion - Value of the heat flux jacobian due to enthalpy diffusion. */ - inline void SetGradHeatDiffusion(const su2double* val_gradheatdiffusion_i, - const su2double* val_gradheatdiffusion_j) { - GradHeatDiffusion_i = val_gradheatdiffusion_i; - GradHeatDiffusion_j = val_gradheatdiffusion_j; + inline void SetJacHeatFluxDiffusion(su2double val_jac_heatfluxdiffusion) { + Jac_HeatFluxDiffusion = val_jac_heatfluxdiffusion; } /*! diff --git a/SU2_CFD/include/numerics/flow/flow_diffusion.hpp b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp index be24cddb6e11..f3b997a97016 100644 --- a/SU2_CFD/include/numerics/flow/flow_diffusion.hpp +++ b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp @@ -51,8 +51,8 @@ class CAvgGrad_Base : public CNumerics { *heat_flux_jac_i = nullptr, /*!< \brief Jacobian of the molecular + turbulent heat flux vector, projected onto the normal vector. */ **tau_jacobian_i = nullptr; /*!< \brief Jacobian of the viscous + turbulent stress tensor, projected onto the normal vector. */ su2double *Mean_PrimVar = nullptr; /*!< \brief Mean primitive variables. */ - su2double *Mean_GradSecVar = nullptr; /*!< \brief Mean gradient secundary variable for multicomponent flows. */ - su2double *Mean_JacSecVar = nullptr; /*!< \brief Mean jacobian secundary variables for multicomponent flows. */ + su2double Mean_HeatFluxDiffusion; /*!< \brief Mean heat flux due to enthalpy diffusion for multicomponent flows. */ + su2double Mean_JacHeatFluxDiffusion; /*!< \brief Mean Jacobian heat flux due to enthalpy diffusion for multicomponent flows. */ const su2double *PrimVar_i = nullptr, *PrimVar_j = nullptr; /*!< \brief Primitives variables at point i and j. */ @@ -290,7 +290,6 @@ class CAvgGradInc_Flow final : public CAvgGrad_Base { private: su2double Mean_Thermal_Conductivity; /*!< \brief Mean value of the effective thermal conductivity. */ su2double Mean_Heat_Capacity; /*!< \brief Mean value of the heat capacity. */ - su2double Mean_Density; /*!< \brief Mean value of the density. */ bool energy; /*!< \brief computation with the energy equation. */ /*! @@ -305,7 +304,7 @@ class CAvgGradInc_Flow final : public CAvgGrad_Base { * \param[in] val_heatDiffusion - Heat diffusion */ void GetViscousIncProjFlux(const su2double* const* val_gradprimvar, const su2double* val_normal, - su2double val_thermal_conductivity, const su2double* val_heatDiffusion = nullptr); + su2double val_thermal_conductivity, su2double val_heatFluxDiffusion); /*! * \brief Compute the projection of the viscous Jacobian matrices. diff --git a/SU2_CFD/src/fluid/CFluidScalar.cpp b/SU2_CFD/src/fluid/CFluidScalar.cpp index 60b57df5ea43..b52c3b0b0b55 100644 --- a/SU2_CFD/src/fluid/CFluidScalar.cpp +++ b/SU2_CFD/src/fluid/CFluidScalar.cpp @@ -224,6 +224,23 @@ void CFluidScalar::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2doub *val_temperature = val_enthalpy / val_cp + 298.15; } +void CFluidScalar::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) { + for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { + enthalpy_diffusions[iVar] = Density * + (specificHeat[iVar] * massDiffusivity[iVar] - + specificHeat[n_species_mixture - 1] * massDiffusivity[n_species_mixture - 1]) * + (Temperature - 298.15); + } +} + +void CFluidScalar::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusions){ + for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { + grad_enthalpy_diffusions[iVar] = Density * + (specificHeat[iVar] * massDiffusivity[iVar] - + specificHeat[n_species_mixture - 1] * massDiffusivity[n_species_mixture - 1]); + } +} + void CFluidScalar::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { MassToMoleFractions(val_scalars); ComputeGasConstant(); diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index 5661e75d7016..8e3804a598b9 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -50,9 +50,6 @@ CAvgGrad_Base::CAvgGrad_Base(unsigned short val_nDim, for (iVar = 0; iVar < nPrimVar; iVar++) Mean_GradPrimVar[iVar] = new su2double [nDim]; - Mean_GradSecVar = new su2double[nDim]; - Mean_JacSecVar = new su2double[nDim]; - Proj_Mean_GradPrimVar_Edge = new su2double[val_nPrimVar]; tau_jacobian_i = new su2double* [nDim]; @@ -74,8 +71,6 @@ CAvgGrad_Base::CAvgGrad_Base(unsigned short val_nDim, CAvgGrad_Base::~CAvgGrad_Base() { delete [] Mean_PrimVar; - delete [] Mean_GradSecVar; - delete [] Mean_JacSecVar; if (Mean_GradPrimVar != nullptr) { for (unsigned short iVar = 0; iVar < nPrimVar; iVar++) @@ -591,8 +586,6 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi if (multicomponent_energy) { Cp_i = V_i[nDim + 7]; Cp_j = V_j[nDim + 7]; - Density_i = V_i[nDim + 2]; - Density_j = V_i[nDim + 2]; } /*--- Mean transport properties ---*/ @@ -603,7 +596,6 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); if (multicomponent_energy) { Mean_Heat_Capacity = 0.5 * (Cp_i + Cp_j); - Mean_Density = 0.5 * (Density_i + Density_j); } /*--- Mean gradient approximation ---*/ @@ -639,13 +631,11 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi if (Mean_TauWall > 0) AddTauWall(UnitNormal, Mean_TauWall); if (multicomponent_energy) { - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradSecVar[iDim] = 0.5 * (HeatDiffusion_i[iDim] + HeatDiffusion_j[iDim]) * Mean_Density; - Mean_JacSecVar[iDim] = 0.5 * (GradHeatDiffusion_i[iDim] + GradHeatDiffusion_j[iDim]); - } + Mean_HeatFluxDiffusion = HeatFluxDiffusion; + Mean_JacHeatFluxDiffusion = Jac_HeatFluxDiffusion; } - GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity, Mean_GradSecVar); + GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity, Mean_HeatFluxDiffusion); /*--- Implicit part ---*/ @@ -672,14 +662,10 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi } proj_vector_ij = proj_vector_ij/dist_ij_2; if (multicomponent_energy){ - su2double projJacGradSecVar= 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - projJacGradSecVar += Mean_JacSecVar[iDim] * Normal[iDim]; - } Jacobian_i[nDim + 1][nDim + 1] = - -(Mean_Thermal_Conductivity * proj_vector_ij + projJacGradSecVar) / Mean_Heat_Capacity; + -(Mean_Thermal_Conductivity * proj_vector_ij + Mean_JacHeatFluxDiffusion) / Mean_Heat_Capacity; Jacobian_j[nDim + 1][nDim + 1] = - (Mean_Thermal_Conductivity * proj_vector_ij + projJacGradSecVar) / Mean_Heat_Capacity; + (Mean_Thermal_Conductivity * proj_vector_ij + Mean_JacHeatFluxDiffusion) / Mean_Heat_Capacity; } else { Jacobian_i[nDim + 1][nDim + 1] = -Mean_Thermal_Conductivity * proj_vector_ij; Jacobian_j[nDim + 1][nDim + 1] = Mean_Thermal_Conductivity * proj_vector_ij; @@ -711,7 +697,7 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradprimvar, const su2double *val_normal, su2double val_thermal_conductivity, - const su2double *val_heatDiffusion) { + su2double val_heatDiffusion) { /*--- Gradient of primitive variables -> [Pressure vel_x vel_y vel_z Temperature] ---*/ @@ -727,10 +713,6 @@ void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradpri Flux_Tensor[1][1] = tau[1][0]; Flux_Tensor[2][1] = tau[1][1]; Flux_Tensor[3][1] = val_thermal_conductivity*val_gradprimvar[nDim+1][1]; - if (multicomponent_energy) { - Flux_Tensor[3][0] += val_heatDiffusion[0]; - Flux_Tensor[3][1] += val_heatDiffusion[1]; - } } else { @@ -752,12 +734,6 @@ void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradpri Flux_Tensor[3][2] = tau[2][2]; Flux_Tensor[4][2] = val_thermal_conductivity*val_gradprimvar[nDim+1][2]; - if (multicomponent_energy) { - Flux_Tensor[4][0] += val_heatDiffusion[0]; - Flux_Tensor[4][1] += val_heatDiffusion[1]; - Flux_Tensor[4][2] += val_heatDiffusion[2]; - } - } for (unsigned short iVar = 0; iVar < nVar; iVar++) { @@ -765,7 +741,9 @@ void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradpri for (unsigned short iDim = 0; iDim < nDim; iDim++) Proj_Flux_Tensor[iVar] += Flux_Tensor[iVar][iDim] * val_normal[iDim]; } - + if (multicomponent_energy) { + Proj_Flux_Tensor[nVar - 1] += val_heatDiffusion; + } } void CAvgGradInc_Flow::GetViscousIncProjJacs(su2double val_dS, diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 9971a2a2ddc9..01f7fce0ab0a 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -278,7 +278,7 @@ void CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CS const bool speciesEnergy = (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation(); const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - + /*--- Contribution to heat flux due to enthalpy diffusion for multicomponent and reacting flows ---*/ if (speciesEnergy) { CVariable* speciesNodes = solver_container[SPECIES_SOL]->GetNodes(); @@ -286,38 +286,66 @@ void CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CS auto iPoint = geometry->edges->GetNode(iEdge, 0); auto jPoint = geometry->edges->GetNode(iEdge, 1); + + /*--- Points coordinates, and normal vector ---*/ + + const su2double* Normal = geometry->edges->GetNormal(iEdge); + const su2double* Coord_i = geometry->nodes->GetCoord(iPoint); + const su2double* Coord_j = geometry->nodes->GetCoord(jPoint); + + /*--- Obtain fluid model for computing the enthalpy diffusion terms. ---*/ + CFluidModel* FluidModel = solver_container[FLOW_SOL]->GetFluidModel(); - FluidModel->SetTDState_T(nodes->GetPrimitive(iPoint)[prim_idx.Temperature()], speciesNodes->GetSolution(iPoint)); - const int n_species = config->GetnSpecies(); + + /*--- retrieve number of species that are solved and set maximum static array ---*/ + + int n_species = config->GetnSpecies(); static constexpr size_t MAXNVAR_SPECIES = 20UL; - su2double GradientScalar[MAXNVAR_SPECIES]; - su2double HeatDiffusion_i[MAXNDIM]; - su2double GradDiffusion_i[MAXNDIM]; - /*--- Loop over spatial dimensions to fill in the enthalpy diffusion with the gradient of scalar species. ---*/ - /*--- The gradients of species with respect to the i-spatial dimension are stored in GradientScalars. ---*/ - for (int i = 0; i < nDim; i++) { - for (int i_species = 0; i_species < n_species; i_species++) { - GradientScalar[i_species] = speciesNodes->GetGradient(iPoint)[i_species][i]; - } - /*--- The gradients due to enthalpy diffusion depend on the fluid model, in particular if we are solving for total - * enthalpy or sensible enthalpy. ---*/ - HeatDiffusion_i[i] = FluidModel->GetEnthalpyDiffusivity(GradientScalar); - if (implicit) GradDiffusion_i[i] = FluidModel->GetGradEnthalpyDiffusivity(GradientScalar); - } + + /*--- Species variables, and its gradients ---*/ + const su2double* Species_i = speciesNodes->GetSolution(iPoint); + const su2double* Species_j = speciesNodes->GetSolution(jPoint); + CMatrixView Species_Grad_i = speciesNodes->GetGradient(iPoint); + CMatrixView Species_Grad_j = speciesNodes->GetGradient(iPoint); + + /*--- Compute Projected gradient for species variables ---*/ + su2double ProjGradScalarVarNoCorr[MAXNVAR_SPECIES]{0.0}; + su2double Proj_Mean_GradScalarVar[MAXNVAR_SPECIES]{0.0}; + su2double proj_vector_ij = numerics->ComputeProjectedGradient( + nDim, n_species, Normal, Coord_i, Coord_j, Species_Grad_i, Species_Grad_j, true, Species_i, Species_j, + ProjGradScalarVarNoCorr, Proj_Mean_GradScalarVar); + + /*--- Get enthalpy diffusion terms and its gradient(for implicit) for each species at point i. ---*/ + + su2double EnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; + su2double GradEnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; + FluidModel->SetTDState_T(nodes->GetPrimitive(iPoint)[prim_idx.Temperature()], Species_i); + FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion_i); + if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion_i); + /*--- Repeat the above computations for jPoint. ---*/ + + su2double EnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; + su2double GradEnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; FluidModel->SetTDState_T(nodes->GetPrimitive(jPoint)[prim_idx.Temperature()], speciesNodes->GetSolution(jPoint)); - su2double HeatDiffusion_j[MAXNDIM]; - su2double GradDiffusion_j[MAXNDIM]; - for (int i = 0; i < nDim; i++) { - for (int i_species = 0; i_species < n_species; i_species++) { - GradientScalar[i_species] = speciesNodes->GetGradient(iPoint)[i_species][i]; - } - HeatDiffusion_j[i] = FluidModel->GetEnthalpyDiffusivity(GradientScalar); - if (implicit) GradDiffusion_j[i] = FluidModel->GetGradEnthalpyDiffusivity(GradientScalar); + FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion_j); + if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion_j); + + /*--- Compute Enthalpy diffusion flux and its jacobian (for implicit iterations) ---*/ + su2double flux_enthalpy_diffusion = 0.0; + su2double jac_flux_enthalpy_diffusion = 0.0; + for (int i_species = 0; i_species < n_species; i_species++) { + flux_enthalpy_diffusion += + 0.5 * (EnthalpyDiffusion_i[i_species] + EnthalpyDiffusion_j[i_species]) * Proj_Mean_GradScalarVar[i_species]; + if (implicit) + jac_flux_enthalpy_diffusion += 0.5 * (GradEnthalpyDiffusion_i[i_species] + GradEnthalpyDiffusion_j[i_species]) * + Proj_Mean_GradScalarVar[i_species]; } - /*--- Enthalpy diffusion and gradient (for implicit iterations) ---*/ - numerics->SetHeatDiffusion(HeatDiffusion_i, HeatDiffusion_j); - if (implicit) numerics->SetGradHeatDiffusion(GradDiffusion_i, GradDiffusion_j); + + /*--- Set heat flux and jacobian (for implicit) due to enthalpy diffusion ---*/ + + numerics->SetHeatFluxDiffusion(flux_enthalpy_diffusion); + if (implicit) numerics->SetJacHeatFluxDiffusion(jac_flux_enthalpy_diffusion); } Viscous_Residual_impl(iEdge, geometry, solver_container, numerics, config); } diff --git a/subprojects/MLPCpp b/subprojects/MLPCpp index 6865a58b22f2..c19c53ea2b85 160000 --- a/subprojects/MLPCpp +++ b/subprojects/MLPCpp @@ -1 +1 @@ -Subproject commit 6865a58b22f21a92977839d9c93eae9522402f55 +Subproject commit c19c53ea2b85ccfb185f1c6c87044dc0b5bc7ae0 From e002990d61f2fdc4e3b0317d6ea93a67427eaedc Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sun, 10 Nov 2024 15:40:51 +0100 Subject: [PATCH 050/173] adding heat release as an output --- SU2_CFD/include/variables/CSpeciesVariable.hpp | 14 ++++++++++++++ SU2_CFD/include/variables/CVariable.hpp | 7 +++++++ SU2_CFD/src/output/CFlowOutput.cpp | 4 ++++ SU2_CFD/src/solvers/CSpeciesSolver.cpp | 4 ++++ SU2_CFD/src/variables/CSpeciesVariable.cpp | 1 + 5 files changed, 30 insertions(+) diff --git a/SU2_CFD/include/variables/CSpeciesVariable.hpp b/SU2_CFD/include/variables/CSpeciesVariable.hpp index 951e6392f04c..69c3032af527 100644 --- a/SU2_CFD/include/variables/CSpeciesVariable.hpp +++ b/SU2_CFD/include/variables/CSpeciesVariable.hpp @@ -37,6 +37,7 @@ class CSpeciesVariable : public CScalarVariable { protected: MatrixType Diffusivity; /*!< \brief Matrix (nPoint,nVar) of mass diffusivities for scalar transport. */ MatrixType SpeciesSourceTerm; /*!< \brief Matrix (nPoint, nVar) of chemical source terms for species transport*/ + VectorType HeatRelease; /*!< \brief Vector of heat release due to combustion for species transport*/ public: static constexpr size_t MAXNVAR = 20; /*!< \brief Max number of variables for static arrays. Increase, if necessary. */ @@ -99,4 +100,17 @@ class CSpeciesVariable : public CScalarVariable { * \return Pointer to the chemical source term */ inline const su2double* GetChemicalSourceTerm(unsigned long iPoint) const { return SpeciesSourceTerm[iPoint]; } + + /*! + * \brief Get heat release due to combustion + * \param[in] iPoint - Point index. + * \return Value of the heat release due to combustion. + */ + inline su2double GetHeatRelease(unsigned long iPoint) const { return HeatRelease(iPoint); } + + /*! + * \brief Set heat release due to combustion. + * \param[in] iPoint - Point index. + */ + inline void SetHeatRelease(unsigned long iPoint, su2double val_heatRelease) { HeatRelease(iPoint) = val_heatRelease; } }; diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 9e93ae959a6f..57b88bdcb069 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -1111,6 +1111,13 @@ class CVariable { */ inline virtual su2double GetChemicalSourceTerm(unsigned long iPoint, unsigned short val_ivar) const { return 0.0; } + /*! + * \brief A virtual member. + * \param[in] iPoint - Point index. + * \return Value of the heat release due to combustion. + */ + inline virtual su2double GetHeatRelease(unsigned long iPoint) const { return 0.0; } + /*! * \brief A virtual member. * \param[in] iPoint - Point index. diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 220046410433..9077255165f4 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -1455,6 +1455,8 @@ void CFlowOutput::SetVolumeOutputFieldsScalarPrimitive(const CConfig* config) { AddVolumeOutput("DIFFUSIVITY_" + std::to_string(iVar), "Diffusivity_" + std::to_string(iVar), "PRIMITIVE", "Diffusivity of the transported species " + std::to_string(iVar)); } } + if (config->GetCombustion() == true) + AddVolumeOutput("HEAT_RELEASE", "Heat_Release", "PRIMITIVE", "Heat release due to combustion"); break; default: break; @@ -1654,6 +1656,8 @@ void CFlowOutput::LoadVolumeDataScalar(const CConfig* config, const CSolver* con SetVolumeOutputValue("LIMITER_SPECIES_" + std::to_string(iVar), iPoint, Node_Species->GetLimiter(iPoint, iVar)); } } + if (config->GetCombustion() == true) + SetVolumeOutputValue("HEAT_RELEASE", iPoint, Node_Species->GetHeatRelease(iPoint)); break; } diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index 4ce4440e5a72..c66eeff23159 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -326,6 +326,10 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain const su2double* scalar = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint); solver_container[FLOW_SOL]->GetFluidModel()->SetMassDiffusivityModel(config); solver_container[FLOW_SOL]->GetFluidModel()->SetTDState_T(temperature, scalar); + if (config->GetCombustion() == true) { + const su2double heat_release = solver_container[FLOW_SOL]->GetFluidModel()->GetHeatRelease(); + nodes->SetHeatRelease(iPoint, heat_release); + } for (auto iVar = 0u; iVar <= nVar; iVar++) { const su2double mass_diffusivity = solver_container[FLOW_SOL]->GetFluidModel()->GetMassDiffusivity(iVar); nodes->SetDiffusivity(iPoint, mass_diffusivity, iVar); diff --git a/SU2_CFD/src/variables/CSpeciesVariable.cpp b/SU2_CFD/src/variables/CSpeciesVariable.cpp index 1dab91b91a44..e904d4b1ee17 100644 --- a/SU2_CFD/src/variables/CSpeciesVariable.cpp +++ b/SU2_CFD/src/variables/CSpeciesVariable.cpp @@ -33,6 +33,7 @@ CSpeciesVariable::CSpeciesVariable(const su2double* species_inf, unsigned long n /*--- Allocate space for the mass diffusivity and chemical source term. ---*/ Diffusivity.resize(nPoint, nVar + 1) = su2double(0.0); SpeciesSourceTerm.resize(nPoint, nVar + 1) = su2double(0.0); + HeatRelease.resize(nPoint) = su2double(0.0); for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) for (unsigned long iVar = 0; iVar < nVar; iVar++) From b4d659d8625034cfc13541b2a4762d72d61284f4 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 18 Nov 2024 13:55:34 +0100 Subject: [PATCH 051/173] setting enthalpy, temperature and thermochemical properties for ignition process --- SU2_CFD/src/solvers/CIncNSSolver.cpp | 49 ++++++++++++++++++++++++++++ SU2_PY/SU2/io/historyMap.py | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 01f7fce0ab0a..4c9157315b25 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -69,6 +69,55 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container const bool limiter = (config->GetKind_SlopeLimit_Flow() != LIMITER::NONE) && (InnerIter <= config->GetLimiterIter()); const bool van_albada = (config->GetKind_SlopeLimit_Flow() == LIMITER::VAN_ALBADA_EDGE); const bool wall_functions = config->GetWall_Functions(); + const bool speciesEnergy = + (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation(); + const bool combustion = config->GetCombustion(); + + /*--- Setting temperature, enthalpy and themorchemical properties for ignition in reacting flows. ---*/ + if (speciesEnergy && combustion) { + unsigned long spark_iter_start, spark_duration; + bool ignition = false; + + /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ + if ((config->GetFlameletInitType() == FLAMELET_INIT_TYPE::SPARK) && !config->GetRestart()) { + auto spark_init = config->GetFlameInit(); + spark_iter_start = ceil(spark_init[4]); + spark_duration = ceil(spark_init[5]); + unsigned long iter = config->GetMultizone_Problem() ? config->GetOuterIter() : config->GetInnerIter(); + ignition = ((iter >= spark_iter_start) && (iter <= (spark_iter_start + spark_duration)) && !config->GetRestart()); + } + + SU2_OMP_SAFE_GLOBAL_ACCESS(config->SetGlobalParam(config->GetKind_Solver(), RunTime_EqSystem);) + + if (ignition) { + SU2_OMP_FOR_STAT(omp_chunk_size) + for (auto i_point = 0u; i_point < nPoint; i_point++) { + /*--- retrieve fluid model. ---*/ + CFluidModel* fluid_model_local = solver_container[FLOW_SOL]->GetFluidModel(); + /*--- Apply ignition temperature within spark radius. ---*/ + su2double dist_from_center = 0, spark_radius = config->GetFlameInit()[3]; + dist_from_center = + GeometryToolbox::SquaredDistance(nDim, geometry->nodes->GetCoord(i_point), config->GetFlameInit()); + if (dist_from_center < pow(spark_radius, 2)) { + /*--- retrieve scalars solution. ---*/ + su2double* scalars = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(i_point); + /*--- Set high temperature for ignition. ---*/ + nodes->SetTemperature(i_point, config->GetSpark_Temperature()); + /*--- Set thermodynamic state at high temeprature. ---*/ + fluid_model_local->SetTDState_T(config->GetSpark_Temperature(), scalars); + /*--- Set total enthalpy at high temperature. ---*/ + nodes->SetSolution(i_point, nDim + 1, fluid_model_local->GetEnthalpy()); + /*--- Set thermochemical properties at high temperature for consistency. ---*/ + nodes->SetDensity(i_point, fluid_model_local->GetDensity()); + nodes->SetSpecificHeatCp(i_point, fluid_model_local->GetCp()); + nodes->SetSpecificHeatCv(i_point, fluid_model_local->GetCv()); + nodes->SetThermalConductivity(i_point, fluid_model_local->GetThermalConductivity()); + nodes->SetLaminarViscosity(i_point, fluid_model_local->GetThermalConductivity()); + } + } + END_SU2_OMP_FOR + } + } /*--- Common preprocessing steps (implemented by CEulerSolver) ---*/ diff --git a/SU2_PY/SU2/io/historyMap.py b/SU2_PY/SU2/io/historyMap.py index 1a0d09cc3cb9..6adaec1ec519 100644 --- a/SU2_PY/SU2/io/historyMap.py +++ b/SU2_PY/SU2/io/historyMap.py @@ -1191,7 +1191,7 @@ 'RMS_SPECIES_" + config->GetChemical_GasComposition(iVar': { "DESCRIPTION": "Root-mean square " "residual of " "transported species.", "GROUP": "RMS_RES", - "HEADER": 'rms[rho*Y_" + ' '+ config->GetChemical_GasComposition(iVar)+"]', + "HEADER": 'rms[rho*Y_" + ' 'config->GetChemical_GasComposition(iVar)+"]', "TYPE": "RESIDUAL", }, "RMS_TEMPERATURE": { From 59d42d9f385269fcc80107019ca3c2d2afb1a6b1 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 22 Nov 2024 13:19:17 +0100 Subject: [PATCH 052/173] updating test case multicomponent cantera --- .../species2_primitiveVenturi_CANTERA.cfg | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg index e08ccbb5e40c..1fcd86c880d2 100644 --- a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg +++ b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg @@ -46,9 +46,9 @@ PRANDTL_LAM= 0.72 TURBULENT_CONDUCTIVITY_MODEL= NONE PRANDTL_TURB= 0.90 % -GAS_COMPOSITION_NAMES= H2, CH4 -CHEMICAL_MECHANISM_FILE= gri30.yaml -PHASE_NAME= gri30 +GAS_COMPOSITION_NAMES= H2, O2 +CHEMICAL_MECHANISM_FILE= h2o2.yaml +PHASE_NAME= ohmech TRANSPORT_MODEL= mixture-averaged % % @@ -94,14 +94,14 @@ LINEAR_SOLVER_ITER= 5 % -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% % CONV_NUM_METHOD_FLOW= FDS -MUSCL_FLOW= YES +MUSCL_FLOW= NO SLOPE_LIMITER_FLOW = NONE TIME_DISCRE_FLOW= EULER_IMPLICIT % % -------------------- SCALAR TRANSPORT ---------------------------------------% % KIND_SCALAR_MODEL= SPECIES_TRANSPORT -DIFFUSIVITY_MODEL= UNITY_LEWIS +DIFFUSIVITY_MODEL= CANTERA DIFFUSIVITY_CONSTANT= 0.001 % CONV_NUM_METHOD_SPECIES= BOUNDED_SCALAR From 7f9273009cc59b625d6bb580e62bc1d7f29f5015 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 22 Nov 2024 21:10:36 +0100 Subject: [PATCH 053/173] axisymetric source term and corrected flux jacobian at the wall --- .../include/numerics/flow/flow_sources.hpp | 3 +- SU2_CFD/src/numerics/flow/flow_sources.cpp | 21 +++++++++---- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 30 +++++++++++++++++++ SU2_CFD/src/solvers/CIncNSSolver.cpp | 15 ++++++---- 4 files changed, 58 insertions(+), 11 deletions(-) diff --git a/SU2_CFD/include/numerics/flow/flow_sources.hpp b/SU2_CFD/include/numerics/flow/flow_sources.hpp index e4cb64e4b54e..5fb9ef05be98 100644 --- a/SU2_CFD/include/numerics/flow/flow_sources.hpp +++ b/SU2_CFD/include/numerics/flow/flow_sources.hpp @@ -126,7 +126,8 @@ class CSourceGeneralAxisymmetric_Flow final : public CSourceAxisymmetric_Flow { class CSourceIncAxisymmetric_Flow final : public CSourceBase_Flow { bool implicit, /*!< \brief Implicit calculation. */ viscous, /*!< \brief Viscous incompressible flows. */ - energy; /*!< \brief computation with the energy equation. */ + energy, /*!< \brief computation with the energy equation. */ + multicomponent; /*!< \brief multicomponent incompressible flows. */ public: /*! diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index 6f8359a5f582..b07ad673be3e 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -245,7 +245,7 @@ CSourceIncAxisymmetric_Flow::CSourceIncAxisymmetric_Flow(unsigned short val_nDim implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); energy = config->GetEnergy_Equation(); viscous = config->GetViscous(); - + multicomponent = (config->GetKind_FluidModel() == FLUID_MIXTURE); } CNumerics::ResidualType<> CSourceIncAxisymmetric_Flow::ComputeResidual(const CConfig* config) { @@ -264,7 +264,11 @@ CNumerics::ResidualType<> CSourceIncAxisymmetric_Flow::ComputeResidual(const CCo DensityInc_i = V_i[nDim+2]; BetaInc2_i = V_i[nDim+3]; Cp_i = V_i[nDim+7]; - Enthalpy_i = Cp_i*Temp_i; + if (multicomponent && energy) { + Enthalpy_i = V_i[nDim + 9]; + } else { + Enthalpy_i = Cp_i * Temp_i; + } for (iDim = 0; iDim < nDim; iDim++) Velocity_i[iDim] = V_i[iDim+1]; @@ -296,7 +300,11 @@ CNumerics::ResidualType<> CSourceIncAxisymmetric_Flow::ComputeResidual(const CCo jacobian[3][0] = 0.0; jacobian[3][1] = 0.0; jacobian[3][2] = Enthalpy_i; - jacobian[3][3] = Cp_i*Velocity_i[1]; + if (multicomponent && energy) { + jacobian[3][3] = (1.0 - Enthalpy_i / (Cp_i * Temp_i)) * Velocity_i[1]; + } else { + jacobian[3][3] = Cp_i * Velocity_i[1]; + } for (iVar=0; iVar < nVar; iVar++) for (jVar=0; jVar < nVar; jVar++) @@ -326,8 +334,11 @@ CNumerics::ResidualType<> CSourceIncAxisymmetric_Flow::ComputeResidual(const CCo residual[2] -= Volume*(yinv*2.0*total_viscosity*PrimVar_Grad_i[2][1] - yinv* yinv*2.0*total_viscosity*Velocity_i[1] - TWO3*AuxVar_Grad_i[0][1]); - residual[3] -= Volume*yinv*Thermal_Conductivity_i*PrimVar_Grad_i[nDim+1][1]; - + residual[3] -= Volume * yinv * Thermal_Conductivity_i * PrimVar_Grad_i[nDim + 1][1]; + if (multicomponent && energy) { + residual[3] -= Volume * yinv * HeatFluxDiffusion; + if (implicit) jacobian[3][3] -= Volume * yinv * Jac_HeatFluxDiffusion; + } } } else { diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index f3de80979363..1e68499ddb2e 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1407,6 +1407,7 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont const bool energy = config->GetEnergy_Equation(); const bool streamwise_periodic = (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE); const bool streamwise_periodic_temperature = config->GetStreamwise_Periodic_Temperature(); + const bool multicomponent = (config->GetKind_FluidModel()==FLUID_MIXTURE); AD::StartNoSharedReading(); @@ -1589,6 +1590,35 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont numerics->SetAuxVarGrad(nodes->GetAuxVarGradient(iPoint), nullptr); + if(multicomponent && energy){ + /*--- retrieve number of species that are solved and set maximum static array ---*/ + int n_species = config->GetnSpecies(); + static constexpr size_t MAXNVAR_SPECIES = 20UL; + /*--- Obtain fluid model for computing the enthalpy diffusion terms. ---*/ + CFluidModel* FluidModel = solver_container[FLOW_SOL]->GetFluidModel(); + /*--- retrieve species gradient needed for multicomponent. ---*/ + CMatrixView Species_Grad_i = solver_container[SPECIES_SOL]->GetNodes()->GetGradient(iPoint); + /*--- Set thermodynamic state. ---*/ + FluidModel->SetTDState_T(nodes->GetTemperature(iPoint),solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint)); + /*--- Get enthalpy diffusion terms and its gradients(for implicit). ---*/ + su2double EnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; + su2double GradEnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; + FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion_i); + if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion_i); + /*--- Compute Enthalpy diffusion flux and its jacobian (for implicit iterations) ---*/ + su2double flux_enthalpy_diffusion = 0.0; + su2double jac_flux_enthalpy_diffusion = 0.0; + for (int i_species = 0; i_species < n_species; i_species++) { + flux_enthalpy_diffusion += EnthalpyDiffusion_i[i_species]* Species_Grad_i[i_species][1]; + if (implicit) + jac_flux_enthalpy_diffusion += GradEnthalpyDiffusion_i[i_species] * Species_Grad_i[i_species][1]; + } + + /*--- Set heat flux and jacobian (for implicit) due to enthalpy diffusion ---*/ + + numerics->SetHeatFluxDiffusion(flux_enthalpy_diffusion); + if (implicit) numerics->SetJacHeatFluxDiffusion(jac_flux_enthalpy_diffusion); + } } /*--- Compute Source term Residual ---*/ diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 01f7fce0ab0a..6b7ea0e56b94 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -306,7 +306,7 @@ void CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CS const su2double* Species_i = speciesNodes->GetSolution(iPoint); const su2double* Species_j = speciesNodes->GetSolution(jPoint); CMatrixView Species_Grad_i = speciesNodes->GetGradient(iPoint); - CMatrixView Species_Grad_j = speciesNodes->GetGradient(iPoint); + CMatrixView Species_Grad_j = speciesNodes->GetGradient(jPoint); /*--- Compute Projected gradient for species variables ---*/ su2double ProjGradScalarVarNoCorr[MAXNVAR_SPECIES]{0.0}; @@ -327,7 +327,7 @@ void CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CS su2double EnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; su2double GradEnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; - FluidModel->SetTDState_T(nodes->GetPrimitive(jPoint)[prim_idx.Temperature()], speciesNodes->GetSolution(jPoint)); + FluidModel->SetTDState_T(nodes->GetPrimitive(jPoint)[prim_idx.Temperature()], Species_j); FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion_j); if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion_j); @@ -408,6 +408,7 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool energy = config->GetEnergy_Equation(); const bool py_custom = config->GetMarker_All_PyCustom(val_marker); + const bool multicomponent = (config->GetKind_FluidModel() == FLUID_MIXTURE); /*--- Variables for streamwise periodicity ---*/ const bool streamwise_periodic = (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE); @@ -565,9 +566,13 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con if (implicit) { su2double proj_vector_ij = 0.0; - if (dist_ij_2 > 0.0) - proj_vector_ij = GeometryToolbox::DotProduct(nDim, Edge_Vector, Normal) / dist_ij_2; - Jacobian.AddVal2Diag(iPoint, nDim+1, thermal_conductivity*proj_vector_ij); + if (dist_ij_2 > 0.0) proj_vector_ij = GeometryToolbox::DotProduct(nDim, Edge_Vector, Normal) / dist_ij_2; + if (multicomponent) { + Cp = nodes->GetSpecificHeatCp(iPoint); + Jacobian.AddVal2Diag(iPoint, nDim + 1, thermal_conductivity * proj_vector_ij / Cp); + } else { + Jacobian.AddVal2Diag(iPoint, nDim + 1, thermal_conductivity * proj_vector_ij); + } } break; } // switch From e54bdeaa08988c591a52a710c700aec251f37d4a Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 26 Nov 2024 17:54:18 +0100 Subject: [PATCH 054/173] adding axisymmetric source term --- SU2_CFD/src/fluid/CFluidCantera.cpp | 4 ++++ SU2_CFD/src/numerics/flow/flow_sources.cpp | 4 ++-- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 3 ++- SU2_CFD/src/solvers/CIncNSSolver.cpp | 3 ++- SU2_CFD/src/variables/CIncNSVariable.cpp | 4 ++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 787edae33530..8c4d0f2db43a 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -162,6 +162,10 @@ void CFluidCantera::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2dou delta_temp_iter = delta_enthalpy_iter / Cp; temp_iter += delta_temp_iter; + if (temp_iter < 0.0) { + cout << "Warning: Negative temperature has been found during Newton-Raphson" << endl; + break; + } } *val_temperature = temp_iter; if (counter == counter_limit) { diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index b07ad673be3e..7d6d5e12c35a 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -245,7 +245,7 @@ CSourceIncAxisymmetric_Flow::CSourceIncAxisymmetric_Flow(unsigned short val_nDim implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); energy = config->GetEnergy_Equation(); viscous = config->GetViscous(); - multicomponent = (config->GetKind_FluidModel() == FLUID_MIXTURE); + multicomponent = (config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA); } CNumerics::ResidualType<> CSourceIncAxisymmetric_Flow::ComputeResidual(const CConfig* config) { @@ -337,7 +337,7 @@ CNumerics::ResidualType<> CSourceIncAxisymmetric_Flow::ComputeResidual(const CCo residual[3] -= Volume * yinv * Thermal_Conductivity_i * PrimVar_Grad_i[nDim + 1][1]; if (multicomponent && energy) { residual[3] -= Volume * yinv * HeatFluxDiffusion; - if (implicit) jacobian[3][3] -= Volume * yinv * Jac_HeatFluxDiffusion; + if (implicit) jacobian[3][3] -= Volume * yinv * Jac_HeatFluxDiffusion / Cp_i; } } diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index a98c65dd3b82..b9fb280ad27d 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1473,7 +1473,8 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont const bool energy = config->GetEnergy_Equation(); const bool streamwise_periodic = (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE); const bool streamwise_periodic_temperature = config->GetStreamwise_Periodic_Temperature(); - const bool multicomponent = (config->GetKind_FluidModel()==FLUID_MIXTURE); + const bool multicomponent = + (config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA); AD::StartNoSharedReading(); diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 22741baa1a98..d4a56e766e4f 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -457,7 +457,8 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool energy = config->GetEnergy_Equation(); const bool py_custom = config->GetMarker_All_PyCustom(val_marker); - const bool multicomponent = (config->GetKind_FluidModel() == FLUID_MIXTURE); + const bool multicomponent = + (config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA); /*--- Variables for streamwise periodicity ---*/ const bool streamwise_periodic = (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE); diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index c2aae3bc8c88..88274126d6a5 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -75,7 +75,7 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do /*--- Use the fluid model to compute the new value of density. ---*/ - FluidModel->SetTDState_T(Temperature, scalar); + if (!check_temp) FluidModel->SetTDState_T(Temperature, scalar); if (!Energy_Multicomponent) { /*--- for FLAMELET: copy the LUT temperature into the solution ---*/ @@ -87,7 +87,7 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do /*--- Set the value of the density ---*/ - const auto check_dens = SetDensity(iPoint, FluidModel->GetDensity()); + const auto check_dens = check_temp ? true: SetDensity(iPoint, FluidModel->GetDensity()); /*--- Non-physical solution found. Revert to old values. ---*/ From cec0868adcc767fbb0984fd4fe2ef692b60ac9c3 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 30 Nov 2024 16:14:46 +0100 Subject: [PATCH 055/173] update BC_ConjugateHeat_Interface for enthalpy equation --- SU2_CFD/src/solvers/CIncNSSolver.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index d4a56e766e4f..dbe3361adf19 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -653,6 +653,8 @@ void CIncNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **sol const su2double Temperature_Ref = config->GetTemperature_Ref(); const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool energy = config->GetEnergy_Equation(); + const bool multicomponent = + (config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA); /*--- Identify the boundary ---*/ @@ -738,7 +740,18 @@ void CIncNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **sol /*--- Strong imposition of the temperature on the fluid zone. ---*/ LinSysRes(iPoint, nDim+1) = 0.0; - nodes->SetSolution_Old(iPoint, nDim+1, Twall); + if (multicomponent) { + /*--- Retrieve scalars at wall node. ---*/ + su2double* scalars = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint); + /*--- Retrieve fluid model. ---*/ + CFluidModel* fluid_model_local = solver_container[FLOW_SOL]->GetFluidModel(); + /*--- Set thermodynamic state given wall temperature and species composition. ---*/ + fluid_model_local->SetTDState_T(Twall, scalars); + /*--- Set enthalpy obtained from fluid model. ---*/ + nodes->SetSolution_Old(iPoint, nDim + 1, fluid_model_local->GetEnthalpy()); + } else { + nodes->SetSolution_Old(iPoint, nDim + 1, Twall); + } nodes->SetEnergy_ResTruncError_Zero(iPoint); } END_SU2_OMP_FOR From fdbb9b9fb0c96fff456a9ddef8749ad63afde489 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 30 Nov 2024 16:23:40 +0100 Subject: [PATCH 056/173] updating BC_ConjugateHeat_Interface for fluid mixture --- SU2_CFD/src/solvers/CIncNSSolver.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 6b7ea0e56b94..7af9d4bb8d4f 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -603,6 +603,7 @@ void CIncNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **sol const su2double Temperature_Ref = config->GetTemperature_Ref(); const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool energy = config->GetEnergy_Equation(); + const bool multicomponent = (config->GetKind_FluidModel() == FLUID_MIXTURE); /*--- Identify the boundary ---*/ @@ -688,7 +689,18 @@ void CIncNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **sol /*--- Strong imposition of the temperature on the fluid zone. ---*/ LinSysRes(iPoint, nDim+1) = 0.0; - nodes->SetSolution_Old(iPoint, nDim+1, Twall); + if (multicomponent) { + /*--- Retrieve scalars at wall node. ---*/ + su2double* scalars = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint); + /*--- Retrieve fluid model. ---*/ + CFluidModel* fluid_model_local = solver_container[FLOW_SOL]->GetFluidModel(); + /*--- Set thermodynamic state given wall temperature and species composition. ---*/ + fluid_model_local->SetTDState_T(Twall, scalars); + /*--- Set enthalpy obtained from fluid model. ---*/ + nodes->SetSolution_Old(iPoint, nDim + 1, fluid_model_local->GetEnthalpy()); + } else { + nodes->SetSolution_Old(iPoint, nDim + 1, Twall); + } nodes->SetEnergy_ResTruncError_Zero(iPoint); } END_SU2_OMP_FOR From 70bb3d4b0a2baa500f290326f77640441fab6b87 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 16 Dec 2024 10:18:12 +0100 Subject: [PATCH 057/173] setting formation enthalpies and fixing heat release --- SU2_CFD/include/fluid/CFluidCantera.hpp | 6 ++++++ SU2_CFD/src/fluid/CFluidCantera.cpp | 23 +++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 7b1b4edf8c3d..010dabf20711 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -63,6 +63,7 @@ class CFluidCantera final : public CFluidModel { std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ std::array chemicalSourceTerm; /*!< \brief chemical source term of all species*/ std::array molarMasses; /*!< \brief Molar masses of all species. */ + std::array enthalpyFormation; /*!< \brief Enthalpy of Formation of all species. */ su2double Heat_Release; /*!< \brief heat release due to combustion */ #endif std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ @@ -91,6 +92,11 @@ class CFluidCantera final : public CFluidModel { */ void ComputeHeatRelease(); + /*! + * \brief Set enthalpies of formation. + */ + void SetEnthalpyFormation(const CConfig* config); + public: /*! * \brief Constructor of the class. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 8c4d0f2db43a..ed46b7f9dd09 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -62,6 +62,7 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* gasComposition[iVar]=config->GetChemical_GasComposition(iVar); //config->SetChemical_GasComposition(iVar, gasComposition[iVar]); //this should be used for later } + SetEnthalpyFormation(config); #endif SetMassDiffusivityModel(config); @@ -74,6 +75,21 @@ void CFluidCantera::SetMassDiffusivityModel(const CConfig* config) { } #ifdef USE_CANTERA +void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { + DictionaryChemicalComposition(config->GetSpecies_Init()); + su2double T_ref = 298.15; + sol->thermo()->setState_TPY(GetValue(T_ref), GetValue(Pressure_Thermodynamic), chemical_composition); + const int nsp = sol->thermo()->nSpecies(); + // The universal gas constant times temperature is retrieved from cantera. + const su2double uni_gas_constant_temp = sol->thermo()->RT(); + vector enthalpiesSpecies(nsp); + sol->thermo()->getEnthalpy_RT_ref(&enthalpiesSpecies[0]); + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); + enthalpyFormation[iVar] = uni_gas_constant_temp * enthalpiesSpecies[speciesIndex] / molarMasses[speciesIndex]; + } +} + void CFluidCantera::ComputeMassDiffusivity() { int nsp = sol->thermo()->nSpecies(); vector diff(nsp); @@ -92,15 +108,14 @@ void CFluidCantera::ComputeChemicalSourceTerm(){ } } -void CFluidCantera::ComputeHeatRelease(){ +void CFluidCantera::ComputeHeatRelease() { vector netProductionRates(sol->kinetics()->nReactions()); - vector partialMolarEnthalpies(sol->thermo()->nSpecies()); sol->kinetics()->getNetProductionRates(&netProductionRates[0]); - sol->thermo()->getPartialMolarEnthalpies(&partialMolarEnthalpies[0]); Heat_Release = 0.0; for (int iVar = 0; iVar < n_species_mixture; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - Heat_Release += partialMolarEnthalpies[speciesIndex]*netProductionRates[speciesIndex]; + Heat_Release += + -1.0 * enthalpyFormation[speciesIndex] * molarMasses[speciesIndex] * netProductionRates[speciesIndex]; } } From 2af10c3283b6ece0178b50c378dcbce3a3da0023 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 2 Jan 2025 15:43:31 +0100 Subject: [PATCH 058/173] activating muscl, consistent extrapolation for multicomponent --- SU2_CFD/include/solvers/CIncEulerSolver.hpp | 13 +++++++ SU2_CFD/src/solvers/CIncEulerSolver.cpp | 39 +++++++++++++++++++++ SU2_CFD/src/solvers/CIncNSSolver.cpp | 26 ++++++++++++++ SU2_CFD/src/variables/CIncNSVariable.cpp | 7 +++- 4 files changed, 84 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/include/solvers/CIncEulerSolver.hpp b/SU2_CFD/include/solvers/CIncEulerSolver.hpp index 990c9b7095d5..50c52d4654a0 100644 --- a/SU2_CFD/include/solvers/CIncEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CIncEulerSolver.hpp @@ -191,6 +191,19 @@ class CIncEulerSolver : public CFVMFlowSolverBaseGetKind_SlopeLimit_Flow() != LIMITER::NONE); const bool van_albada = (config->GetKind_SlopeLimit_Flow() == LIMITER::VAN_ALBADA_EDGE); const bool bounded_scalar = config->GetBounded_Scalar(); + const bool energy_multicomponent = (config->GetEnergy_Equation()) && (config->GetKind_FluidModel() == FLUID_MIXTURE); /*--- For hybrid parallel AD, pause preaccumulation if there is shared reading of * variables, otherwise switch to the faster adjoint evaluation mode. ---*/ @@ -1315,6 +1316,31 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont Primitive_i[iVar] = V_i[iVar]; Primitive_j[iVar] = V_j[iVar]; } + if (energy_multicomponent) { + su2double Project_Grad_Enthalpy_i = 0.0; + su2double Project_Grad_Enthalpy_j = 0.0; + + for (iDim = 0; iDim < nDim; iDim++) { + Project_Grad_Enthalpy_i += Vector_ij[iDim] * nodes->GetAuxVarGradient(iPoint, 1, iDim); + Project_Grad_Enthalpy_j -= Vector_ij[iDim] * nodes->GetAuxVarGradient(jPoint, 1, iDim); + } + su2double lim_i = 1.0; + su2double lim_j = 1.0; + if (van_albada) { + su2double V_ij = V_j[nDim + 9] - V_i[nDim + 9]; + lim_i = LimiterHelpers<>::vanAlbadaFunction(Project_Grad_Enthalpy_i, V_ij, EPS); + lim_j = LimiterHelpers<>::vanAlbadaFunction(-Project_Grad_Enthalpy_j, V_ij, EPS); + } else if (limiter) { + lim_i = 1.0; // nodes->GetLimiter_Primitive(iPoint, iVar); + lim_j = 1.0; // nodes->GetLimiter_Primitive(jPoint, iVar); + } + Primitive_i[nDim + 9] = V_i[nDim + 9] + lim_i * Project_Grad_Enthalpy_i; + Primitive_j[nDim + 9] = V_j[nDim + 9] + lim_j * Project_Grad_Enthalpy_j; + const su2double* scalar_i = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint); + const su2double* scalar_j = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(jPoint); + ComputeConsistentExtrapolation(GetFluidModel(), nDim, Primitive_i, scalar_i); + ComputeConsistentExtrapolation(GetFluidModel(), nDim, Primitive_j, scalar_j); + } /*--- Check for non-physical solutions after reconstruction. If found, use the cell-average value of the solution. This results in a locally @@ -1386,6 +1412,19 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont FinalizeResidualComputation(geometry, pausePreacc, counter_local, config); } +void CIncEulerSolver::ComputeConsistentExtrapolation(CFluidModel* fluidModel, unsigned short nDim, su2double* primitive, + const su2double* scalar) { + const CIncEulerVariable::CIndices prim_idx(nDim, 0); + const su2double enthalpy = primitive[prim_idx.Enthalpy()]; + su2double temperature = primitive[prim_idx.Temperature()]; + fluidModel->ComputeTempFromEnthalpy(enthalpy, &temperature, scalar); + + fluidModel->SetTDState_T(temperature, scalar); + + primitive[prim_idx.Temperature()] = temperature; + primitive[prim_idx.Density()] = fluidModel->GetDensity(); +} + void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 8ce8cb88ee17..ad73c560b0ea 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -69,10 +69,21 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container const bool limiter = (config->GetKind_SlopeLimit_Flow() != LIMITER::NONE) && (InnerIter <= config->GetLimiterIter()); const bool van_albada = (config->GetKind_SlopeLimit_Flow() == LIMITER::VAN_ALBADA_EDGE); const bool wall_functions = config->GetWall_Functions(); + const bool energy_multicomponent = (config->GetEnergy_Equation()) && (config->GetKind_FluidModel() == FLUID_MIXTURE); + const bool test = config->GetReconstructionGradientRequired(); /*--- Common preprocessing steps (implemented by CEulerSolver) ---*/ CommonPreprocessing(geometry, solver_container, config, iMesh, iRKStep, RunTime_EqSystem, Output); + if (energy_multicomponent && muscl) { + SU2_OMP_SAFE_GLOBAL_ACCESS(config->SetGlobalParam(config->GetKind_Solver(), RunTime_EqSystem);) + SU2_OMP_FOR_STAT(omp_chunk_size) + for (auto i_point = 0u; i_point < nPoint; i_point++) { + solver_container[FLOW_SOL]->GetNodes()->SetAuxVar(i_point, 1, + solver_container[FLOW_SOL]->GetNodes()->GetEnthalpy(i_point)); + } + END_SU2_OMP_FOR + } /*--- Compute gradient for MUSCL reconstruction ---*/ @@ -86,6 +97,21 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container default: break; } } + if (muscl && !center && energy_multicomponent) { + /*--- Gradient computation for MUSCL reconstruction of Enthalpy for multicomponent flows. ---*/ + + switch (config->GetKind_Gradient_Method_Recon()) { + case GREEN_GAUSS: + SetAuxVar_Gradient_GG(geometry, config); + break; + case LEAST_SQUARES: + case WEIGHTED_LEAST_SQUARES: + SetAuxVar_Gradient_LS(geometry, config); + break; + default: + break; + } + } /*--- Compute gradient of the primitive variables ---*/ diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index c2aae3bc8c88..81f9ecc0d86a 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -46,8 +46,13 @@ CIncNSVariable::CIncNSVariable(su2double pressure, const su2double *velocity, su AuxVar.resize(nPoint,nAuxVar) = su2double(0.0); Grad_AuxVar.resize(nPoint,nAuxVar,nDim); } - if ((config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation()){ + if ((config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation()) { Energy_Multicomponent = true; + if (config->GetMUSCL_Flow()) { + nAuxVar = 2; + AuxVar.resize(nPoint, nAuxVar) = su2double(0.0); + Grad_AuxVar.resize(nPoint, nAuxVar, nDim); + } } } From a1f526c4abd80693fc4f54782349cfa795218fb1 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 10 Jan 2025 09:47:01 +0100 Subject: [PATCH 059/173] correct average enthalpy for multicomponent flows output --- SU2_CFD/src/output/CFlowOutput.cpp | 7 ++++++- SU2_CFD/src/solvers/CIncNSSolver.cpp | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 3c651269b02e..979d911f3b26 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -150,6 +150,7 @@ void CFlowOutput::SetAnalyzeSurface(const CSolver* const*solver, const CGeometry const bool compressible = config->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE; const bool incompressible = config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE; const bool energy = config->GetEnergy_Equation(); + const bool multicomponent = config->GetKind_FluidModel() == FLUID_MIXTURE; const bool streamwisePeriodic = (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE); const bool species = config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT; const auto nSpecies = config->GetnSpecies(); @@ -241,7 +242,11 @@ void CFlowOutput::SetAnalyzeSurface(const CSolver* const*solver, const CGeometry sqrt(config->GetBulk_Modulus()/(flow_nodes->GetDensity(iPoint))); } Temperature = flow_nodes->GetTemperature(iPoint); - Enthalpy = flow_nodes->GetSpecificHeatCp(iPoint)*Temperature; + if (energy && multicomponent) { + Enthalpy = flow_nodes->GetEnthalpy(iPoint); + } else { + Enthalpy = flow_nodes->GetSpecificHeatCp(iPoint) * Temperature; + } TotalTemperature = Temperature + 0.5*Velocity2/flow_nodes->GetSpecificHeatCp(iPoint); TotalPressure = Pressure + 0.5*Density*Velocity2; } diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index ad73c560b0ea..bdeddb2447da 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -70,7 +70,6 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container const bool van_albada = (config->GetKind_SlopeLimit_Flow() == LIMITER::VAN_ALBADA_EDGE); const bool wall_functions = config->GetWall_Functions(); const bool energy_multicomponent = (config->GetEnergy_Equation()) && (config->GetKind_FluidModel() == FLUID_MIXTURE); - const bool test = config->GetReconstructionGradientRequired(); /*--- Common preprocessing steps (implemented by CEulerSolver) ---*/ From 15dd3a6ed7dbe34eb63672b901a12e916474b181 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 10 Jan 2025 11:08:22 +0100 Subject: [PATCH 060/173] small fix chemical source term --- SU2_CFD/include/fluid/CFluidCantera.hpp | 3 +-- SU2_CFD/src/fluid/CFluidCantera.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 010dabf20711..4dd0722fd32b 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -36,7 +36,6 @@ #define USE_CANTERA namespace Cantera { class Solution; -//class ThermoPhase; } #endif @@ -83,7 +82,7 @@ class CFluidCantera final : public CFluidModel { void ComputeMassDiffusivity(); /*! - * \brief Compute mass diffusivity for species. + * \brief Compute chemical source term for species. */ void ComputeChemicalSourceTerm(); diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index ed46b7f9dd09..98a61c7d0e3b 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -100,7 +100,8 @@ void CFluidCantera::ComputeMassDiffusivity() { } void CFluidCantera::ComputeChemicalSourceTerm(){ - vector netProductionRates(sol->kinetics()->nReactions()); + const int nsp = sol->thermo()->nSpecies(); + vector netProductionRates(nsp); sol->kinetics()->getNetProductionRates(&netProductionRates[0]); for (int iVar = 0; iVar < n_species_mixture; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); @@ -109,7 +110,8 @@ void CFluidCantera::ComputeChemicalSourceTerm(){ } void CFluidCantera::ComputeHeatRelease() { - vector netProductionRates(sol->kinetics()->nReactions()); + const int nsp = sol->thermo()->nSpecies(); + vector netProductionRates(nsp); sol->kinetics()->getNetProductionRates(&netProductionRates[0]); Heat_Release = 0.0; for (int iVar = 0; iVar < n_species_mixture; iVar++) { From ef2dc5fcd90ec93a38a70253a90cf9634e962626 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 11 Jan 2025 17:33:30 +0100 Subject: [PATCH 061/173] changing boolean names --- SU2_CFD/include/numerics/CNumerics.hpp | 2 +- SU2_CFD/src/numerics/CNumerics.cpp | 11 ++++----- SU2_CFD/src/numerics/flow/convection/fds.cpp | 12 +++++----- SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 10 ++++---- SU2_CFD/src/numerics/flow/flow_sources.cpp | 2 +- SU2_CFD/src/output/CFlowIncOutput.cpp | 2 +- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 25 ++++++++++---------- SU2_CFD/src/solvers/CIncNSSolver.cpp | 5 ++-- SU2_CFD/src/variables/CIncNSVariable.cpp | 2 +- 9 files changed, 35 insertions(+), 36 deletions(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 9942f79a4925..cec666bc72d5 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -192,7 +192,7 @@ class CNumerics { bool nemo; /*!< \brief Flag for NEMO problems */ - bool multicomponent_energy = false; /*!< \brief Flag for multicomponent and reacting flow */ + bool energy_multicomponent = false; /*!< \brief Flag for multicomponent and reacting flow */ bool bounded_scalar = false; /*!< \brief Flag for bounded scalar problem */ diff --git a/SU2_CFD/src/numerics/CNumerics.cpp b/SU2_CFD/src/numerics/CNumerics.cpp index 379276fa83a1..f78e4b602885 100644 --- a/SU2_CFD/src/numerics/CNumerics.cpp +++ b/SU2_CFD/src/numerics/CNumerics.cpp @@ -54,8 +54,7 @@ CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar, Prandtl_Lam = config->GetPrandtl_Lam(); Prandtl_Turb = config->GetPrandtl_Turb(); Gas_Constant = config->GetGas_ConstantND(); - multicomponent_energy = - (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) && (config->GetEnergy_Equation()); + energy_multicomponent = ((config->GetKind_FluidModel() == FLUID_MIXTURE) && (config->GetEnergy_Equation())); tau = new su2double* [nDim]; for (iDim = 0; iDim < nDim; iDim++) @@ -280,7 +279,7 @@ void CNumerics::GetInviscidIncProjJac(const su2double *val_density, const su2dou val_Proj_Jac_Tensor[2][2] = val_scale*((*val_density)*(proj_vel + val_normal[1]*val_velocity[1])); val_Proj_Jac_Tensor[2][3] = val_scale*((*val_dRhodT)*val_velocity[1]*proj_vel); - if (multicomponent_energy) { + if (energy_multicomponent) { val_Proj_Jac_Tensor[3][0] = val_scale * ((*val_temperature) * proj_vel / (*val_betainc2)); val_Proj_Jac_Tensor[3][1] = val_scale * ((*val_temperature) * val_normal[0] * (*val_density)); val_Proj_Jac_Tensor[3][2] = val_scale * ((*val_temperature) * val_normal[1] * (*val_density)); @@ -321,7 +320,7 @@ void CNumerics::GetInviscidIncProjJac(const su2double *val_density, const su2dou val_Proj_Jac_Tensor[3][3] = val_scale*((*val_density)*(proj_vel + val_normal[2]*val_velocity[2])); val_Proj_Jac_Tensor[3][4] = val_scale*((*val_dRhodT)*val_velocity[2]*proj_vel); - if (multicomponent_energy) { + if (energy_multicomponent) { val_Proj_Jac_Tensor[4][0] = val_scale * ((*val_temperature) * proj_vel / (*val_betainc2)); val_Proj_Jac_Tensor[4][1] = val_scale * ((*val_temperature) * val_normal[0] * (*val_density)); val_Proj_Jac_Tensor[4][2] = val_scale * ((*val_temperature) * val_normal[1] * (*val_density)); @@ -349,7 +348,7 @@ void CNumerics::GetPreconditioner(const su2double *val_density, const su2double val_Precon[0][0] = 1.0/(*val_betainc2); for (iDim = 0; iDim < nDim; iDim++) val_Precon[iDim+1][0] = val_velocity[iDim]/(*val_betainc2); - if (multicomponent_energy){ + if (energy_multicomponent){ val_Precon[nDim+1][0] = (*val_temperature)/(*val_betainc2); }else{ val_Precon[nDim+1][0] = (*val_cp)*(*val_temperature)/(*val_betainc2); @@ -367,7 +366,7 @@ void CNumerics::GetPreconditioner(const su2double *val_density, const su2double val_Precon[0][nDim+1] = (*val_drhodt); for (iDim = 0; iDim < nDim; iDim++) val_Precon[iDim+1][nDim+1] = val_velocity[iDim]*(*val_drhodt); - if (multicomponent_energy){ + if (energy_multicomponent){ val_Precon[nDim+1][nDim+1] = (*val_drhodt)*(*val_temperature) + (*val_density); }else{ val_Precon[nDim+1][nDim+1] = (*val_cp)*((*val_drhodt)*(*val_temperature) + (*val_density)); diff --git a/SU2_CFD/src/numerics/flow/convection/fds.cpp b/SU2_CFD/src/numerics/flow/convection/fds.cpp index de1963e3fb30..115a966896bd 100644 --- a/SU2_CFD/src/numerics/flow/convection/fds.cpp +++ b/SU2_CFD/src/numerics/flow/convection/fds.cpp @@ -118,7 +118,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; - if (multicomponent_energy) { + if (energy_multicomponent) { Enthalpy_i = V_i[nDim + 9]; Enthalpy_j = V_j[nDim + 9]; } else { @@ -163,7 +163,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config MeandRhodT = 0.0; dRhodT_i = 0.0; dRhodT_j = 0.0; if (variable_density) { - if (multicomponent_energy) { + if (energy_multicomponent) { MeandRhodT = -MeanDensity / (MeanCp * MeanTemperature); dRhodT_i = -DensityInc_i / (Cp_i * Temperature_i); dRhodT_j = -DensityInc_j / (Cp_j * Temperature_j); @@ -204,7 +204,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config Lambda[iVar] = fabs(Lambda[iVar]); /*--- Build the preconditioning matrix using mean values ---*/ - if (multicomponent_energy) { + if (energy_multicomponent) { GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanEnthalpy, &MeandRhodT, Precon); } else { GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); @@ -221,7 +221,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config Diff_V[0] = Pressure_j - Pressure_i; for (iDim = 0; iDim < nDim; iDim++) Diff_V[iDim+1] = Velocity_j[iDim] - Velocity_i[iDim]; - if (multicomponent_energy){ + if (energy_multicomponent){ Diff_V[nDim+1] = Enthalpy_j - Enthalpy_i; }else{ Diff_V[nDim+1] = Temperature_j - Temperature_i; @@ -230,7 +230,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config /*--- Build the inviscid Jacobian w.r.t. the primitive variables ---*/ if (implicit) { - if (multicomponent_energy) { + if (energy_multicomponent) { GetInviscidIncProjJac(&DensityInc_i, Velocity_i, &BetaInc2_i, &Cp_i, &Enthalpy_i, &dRhodT_i, Normal, 0.5, Jacobian_i); GetInviscidIncProjJac(&DensityInc_j, Velocity_j, &BetaInc2_j, &Cp_j, &Enthalpy_j, &dRhodT_j, Normal, 0.5, @@ -286,7 +286,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; } - if (multicomponent_energy){ + if (energy_multicomponent){ Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i; Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j; } else { diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index 8e3804a598b9..ddef652b8dbf 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -583,7 +583,7 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi Laminar_Viscosity_i = V_i[nDim+4]; Laminar_Viscosity_j = V_j[nDim+4]; Eddy_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_j = V_j[nDim+5]; Thermal_Conductivity_i = V_i[nDim+6]; Thermal_Conductivity_j = V_j[nDim+6]; - if (multicomponent_energy) { + if (energy_multicomponent) { Cp_i = V_i[nDim + 7]; Cp_j = V_j[nDim + 7]; } @@ -594,7 +594,7 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); - if (multicomponent_energy) { + if (energy_multicomponent) { Mean_Heat_Capacity = 0.5 * (Cp_i + Cp_j); } @@ -630,7 +630,7 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi if (config->GetSAParsedOptions().qcr2000) AddQCR(nDim, &Mean_GradPrimVar[1], tau); if (Mean_TauWall > 0) AddTauWall(UnitNormal, Mean_TauWall); - if (multicomponent_energy) { + if (energy_multicomponent) { Mean_HeatFluxDiffusion = HeatFluxDiffusion; Mean_JacHeatFluxDiffusion = Jac_HeatFluxDiffusion; } @@ -661,7 +661,7 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi proj_vector_ij += (Coord_j[iDim]-Coord_i[iDim])*Normal[iDim]; } proj_vector_ij = proj_vector_ij/dist_ij_2; - if (multicomponent_energy){ + if (energy_multicomponent){ Jacobian_i[nDim + 1][nDim + 1] = -(Mean_Thermal_Conductivity * proj_vector_ij + Mean_JacHeatFluxDiffusion) / Mean_Heat_Capacity; Jacobian_j[nDim + 1][nDim + 1] = @@ -741,7 +741,7 @@ void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradpri for (unsigned short iDim = 0; iDim < nDim; iDim++) Proj_Flux_Tensor[iVar] += Flux_Tensor[iVar][iDim] * val_normal[iDim]; } - if (multicomponent_energy) { + if (energy_multicomponent) { Proj_Flux_Tensor[nVar - 1] += val_heatDiffusion; } } diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index b07ad673be3e..4aa072be466c 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -337,7 +337,7 @@ CNumerics::ResidualType<> CSourceIncAxisymmetric_Flow::ComputeResidual(const CCo residual[3] -= Volume * yinv * Thermal_Conductivity_i * PrimVar_Grad_i[nDim + 1][1]; if (multicomponent && energy) { residual[3] -= Volume * yinv * HeatFluxDiffusion; - if (implicit) jacobian[3][3] -= Volume * yinv * Jac_HeatFluxDiffusion; + if (implicit) jacobian[3][3] -= Volume * yinv * Jac_HeatFluxDiffusion / Cp_i; } } diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index 60f7e6775c22..e616a9b63abc 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -37,7 +37,7 @@ CFlowIncOutput::CFlowIncOutput(CConfig *config, unsigned short nDim) : CFlowOutp heat = config->GetEnergy_Equation(); - multicomponent = config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT; + multicomponent = (config->GetKind_FluidModel() == FLUID_MIXTURE); weakly_coupled_heat = config->GetWeakly_Coupled_Heat(); flamelet = (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET); diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 9be9d63729cd..aa6bea96a0d1 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -57,7 +57,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned bool time_stepping = config->GetTime_Marching() == TIME_MARCHING::TIME_STEPPING; bool adjoint = (config->GetContinuous_Adjoint()) || (config->GetDiscrete_Adjoint()); const bool centered = config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED; - bool Energy_Multicomponent = (config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation(); + const bool energy_multicomponent = ((config->GetKind_FluidModel() == FLUID_MIXTURE) && config->GetEnergy_Equation()); /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); @@ -179,7 +179,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned Pressure_Inf = config->GetPressure_FreeStreamND(); Velocity_Inf = config->GetVelocity_FreeStreamND(); Temperature_Inf = config->GetTemperature_FreeStreamND(); - if (Energy_Multicomponent){ + if (energy_multicomponent){ CFluidModel *auxFluidModel = new CFluidScalar(config->GetPressure_Thermodynamic(), config); const su2double *scalar_init = config->GetSpecies_Init(); auxFluidModel->SetTDState_T(Temperature_Inf,scalar_init); // compute total enthalpy from temperature @@ -215,7 +215,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned /*--- Initialize the solution to the far-field state everywhere. ---*/ if (navier_stokes) { - if (Energy_Multicomponent){ + if (energy_multicomponent){ nodes = new CIncNSVariable(Pressure_Inf, Velocity_Inf, Enthalpy_Inf, nPoint, nDim, nVar, config); }else{ nodes = new CIncNSVariable(Pressure_Inf, Velocity_Inf, Temperature_Inf, nPoint, nDim, nVar, config); @@ -1238,7 +1238,8 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont const bool limiter = (config->GetKind_SlopeLimit_Flow() != LIMITER::NONE); const bool van_albada = (config->GetKind_SlopeLimit_Flow() == LIMITER::VAN_ALBADA_EDGE); const bool bounded_scalar = config->GetBounded_Scalar(); - const bool energy_multicomponent = (config->GetEnergy_Equation()) && (config->GetKind_FluidModel() == FLUID_MIXTURE); + const bool energy_multicomponent = + ((config->GetEnergy_Equation()) && (config->GetKind_FluidModel() == FLUID_MIXTURE)); /*--- For hybrid parallel AD, pause preaccumulation if there is shared reading of * variables, otherwise switch to the faster adjoint evaluation mode. ---*/ @@ -1446,7 +1447,7 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont const bool energy = config->GetEnergy_Equation(); const bool streamwise_periodic = (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE); const bool streamwise_periodic_temperature = config->GetStreamwise_Periodic_Temperature(); - const bool multicomponent = (config->GetKind_FluidModel()==FLUID_MIXTURE); + const bool multicomponent = (config->GetKind_FluidModel() == FLUID_MIXTURE); AD::StartNoSharedReading(); @@ -2063,7 +2064,7 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo bool variable_density = (config->GetVariable_Density_Model()); bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); bool energy = config->GetEnergy_Equation(); - bool multicomponent = config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT; + bool multicomponent = (config->GetKind_FluidModel() == FLUID_MIXTURE); /*--- Access the primitive variables at this node. ---*/ @@ -2336,7 +2337,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool viscous = config->GetViscous(); - bool Energy_Multicomponent = (config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation(); + const bool energy_multicomponent = ((config->GetKind_FluidModel() == FLUID_MIXTURE) && (config->GetEnergy_Equation())); string Marker_Tag = config->GetMarker_All_TagBound(val_marker); @@ -2501,7 +2502,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, } /*-- Enthalpy is needed for energy equation in multicomponent and reacting flows. ---*/ - if (Energy_Multicomponent) { + if (energy_multicomponent) { CFluidModel* auxFluidModel = solver_container[FLOW_SOL]->GetFluidModel(); const su2double* scalar_inlet = config->GetInlet_SpeciesVal(config->GetMarker_All_TagBound(val_marker)); auxFluidModel->SetTDState_T(V_inlet[prim_idx.Temperature()], @@ -2546,7 +2547,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Viscous contribution, commented out because serious convergence problems ---*/ - if (!viscous || Energy_Multicomponent) continue; + if (!viscous || energy_multicomponent) continue; /*--- Set transport properties at the inlet ---*/ @@ -2598,7 +2599,7 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool viscous = config->GetViscous(); - bool Energy_Multicomponent = (config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation(); + const bool energy_multicomponent = ((config->GetKind_FluidModel() == FLUID_MIXTURE) && (config->GetEnergy_Equation())); string Marker_Tag = config->GetMarker_All_TagBound(val_marker); su2double Normal[MAXNDIM] = {0.0}; @@ -2722,7 +2723,7 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, V_outlet[prim_idx.CpTotal()] = nodes->GetSpecificHeatCp(iPoint); /*-- Enthalpy is needed for energy equation in multicomponent and reacting flows. ---*/ - if (Energy_Multicomponent) { + if (energy_multicomponent) { CFluidModel* auxFluidModel = solver_container[FLOW_SOL]->GetFluidModel();; const su2double* scalar_outlet = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint); auxFluidModel->SetTDState_T(nodes->GetTemperature(iPoint), @@ -2754,7 +2755,7 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Viscous contribution, commented out because serious convergence problems ---*/ - if (!viscous || Energy_Multicomponent) continue; + if (!viscous || energy_multicomponent) continue; /*--- Set transport properties at the outlet. ---*/ diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index bdeddb2447da..08a8d7a1f1d4 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -300,12 +300,11 @@ void CIncNSSolver::Compute_Streamwise_Periodic_Recovered_Values(CConfig *config, void CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config) { - const bool speciesEnergy = - (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation(); + const bool energy_multicomponent = ((config->GetKind_FluidModel() == FLUID_MIXTURE) && config->GetEnergy_Equation()); const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); /*--- Contribution to heat flux due to enthalpy diffusion for multicomponent and reacting flows ---*/ - if (speciesEnergy) { + if (energy_multicomponent) { CVariable* speciesNodes = solver_container[SPECIES_SOL]->GetNodes(); /*--- Points in edge ---*/ diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index 81f9ecc0d86a..b8b7f7deb814 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -46,7 +46,7 @@ CIncNSVariable::CIncNSVariable(su2double pressure, const su2double *velocity, su AuxVar.resize(nPoint,nAuxVar) = su2double(0.0); Grad_AuxVar.resize(nPoint,nAuxVar,nDim); } - if ((config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation()) { + if ((config->GetKind_FluidModel() == FLUID_MIXTURE) && config->GetEnergy_Equation()) { Energy_Multicomponent = true; if (config->GetMUSCL_Flow()) { nAuxVar = 2; From 94bd0b0856e2d4548fd3d059434b8afeb1a4d4a7 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 11 Jan 2025 17:51:25 +0100 Subject: [PATCH 062/173] up to date to develop --- subprojects/MLPCpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/MLPCpp b/subprojects/MLPCpp index c19c53ea2b85..6865a58b22f2 160000 --- a/subprojects/MLPCpp +++ b/subprojects/MLPCpp @@ -1 +1 @@ -Subproject commit c19c53ea2b85ccfb185f1c6c87044dc0b5bc7ae0 +Subproject commit 6865a58b22f21a92977839d9c93eae9522402f55 From 912642b1ca6483752ab7979f96e53c423345bed4 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 18 Jan 2025 14:12:23 +0100 Subject: [PATCH 063/173] adding brackets --- SU2_CFD/src/output/CFlowIncOutput.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index e616a9b63abc..b7e05371bd07 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -135,12 +135,13 @@ void CFlowIncOutput::SetHistoryOutputFields(CConfig *config){ if (nDim == 3) AddHistoryOutput("MAX_VELOCITY-Z", "max[W]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the velocity z-component.", HistoryFieldType::RESIDUAL); /// DESCRIPTION: Maximum residual of the temperature. - if (heat || weakly_coupled_heat) + if (heat || weakly_coupled_heat) { if (multicomponent){ AddHistoryOutput("MAX_ENTHALPY", "max[h]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the enthalpy.", HistoryFieldType::RESIDUAL); } else { AddHistoryOutput("MAX_TEMPERATURE", "max[T]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the temperature.", HistoryFieldType::RESIDUAL); } + } AddHistoryOutputFields_ScalarMAX_RES(config); /// END_GROUP @@ -156,12 +157,13 @@ void CFlowIncOutput::SetHistoryOutputFields(CConfig *config){ if (nDim == 3) AddHistoryOutput("BGS_VELOCITY-Z", "bgs[W]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the velocity z-component.", HistoryFieldType::RESIDUAL); /// DESCRIPTION: Maximum residual of the temperature. - if (heat || weakly_coupled_heat) + if (heat || weakly_coupled_heat) { if (multicomponent){ AddHistoryOutput("BGS_ENTHALPY", "bgs[h]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the enthalpy.", HistoryFieldType::RESIDUAL); } else { AddHistoryOutput("BGS_TEMPERATURE", "bgs[T]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the temperature.", HistoryFieldType::RESIDUAL); } + } AddHistoryOutputFields_ScalarBGS_RES(config); @@ -462,9 +464,10 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve SetVolumeOutputValue("RES_VELOCITY-Y", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 2)); if (nDim == 3) SetVolumeOutputValue("RES_VELOCITY-Z", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 3)); - if (config->GetEnergy_Equation()) + if (config->GetEnergy_Equation()) { if (multicomponent) SetVolumeOutputValue("RES_ENTHALPY", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, nDim+1)); else SetVolumeOutputValue("RES_TEMPERATURE", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, nDim+1)); + } if (config->GetKind_SlopeLimit_Flow() != LIMITER::NONE && config->GetKind_SlopeLimit_Flow() != LIMITER::VAN_ALBADA_EDGE) { SetVolumeOutputValue("LIMITER_PRESSURE", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 0)); From a6ce2d42c427e480e9f844066caad9f5db7d7ea1 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 18 Jan 2025 14:32:55 +0100 Subject: [PATCH 064/173] fixing warning --- SU2_CFD/src/solvers/CIncNSSolver.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 08a8d7a1f1d4..2128f85a4505 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -338,6 +338,7 @@ void CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CS su2double proj_vector_ij = numerics->ComputeProjectedGradient( nDim, n_species, Normal, Coord_i, Coord_j, Species_Grad_i, Species_Grad_j, true, Species_i, Species_j, ProjGradScalarVarNoCorr, Proj_Mean_GradScalarVar); + (void)proj_vector_ij; /*--- Get enthalpy diffusion terms and its gradient(for implicit) for each species at point i. ---*/ From d568a9e5dab2903a2f5bae6e2bc8f31f91b97f0a Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 28 Jan 2025 10:55:47 +0100 Subject: [PATCH 065/173] updating to develop and preconditioning branch --- SU2_CFD/include/numerics/CNumerics.hpp | 2 +- SU2_CFD/src/numerics/CNumerics.cpp | 13 +++++---- SU2_CFD/src/numerics/flow/convection/fds.cpp | 12 ++++---- SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 10 +++---- SU2_CFD/src/output/CFlowIncOutput.cpp | 15 ++++++---- SU2_CFD/src/output/CFlowOutput.cpp | 2 +- SU2_CFD/src/output/COutput.cpp | 10 ++++--- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 29 ++++++++++++-------- SU2_CFD/src/solvers/CIncNSSolver.cpp | 9 +++--- SU2_CFD/src/solvers/CTurbSASolver.cpp | 2 +- SU2_CFD/src/variables/CIncNSVariable.cpp | 3 +- 11 files changed, 61 insertions(+), 46 deletions(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 56ef5e937f36..9b45910e776d 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -194,7 +194,7 @@ class CNumerics { bool nemo; /*!< \brief Flag for NEMO problems */ - bool multicomponent_energy = false; /*!< \brief Flag for multicomponent and reacting flow */ + bool energy_multicomponent = false; /*!< \brief Flag for multicomponent and reacting flow */ bool bounded_scalar = false; /*!< \brief Flag for bounded scalar problem */ diff --git a/SU2_CFD/src/numerics/CNumerics.cpp b/SU2_CFD/src/numerics/CNumerics.cpp index 379276fa83a1..3f91deb0dfed 100644 --- a/SU2_CFD/src/numerics/CNumerics.cpp +++ b/SU2_CFD/src/numerics/CNumerics.cpp @@ -54,8 +54,9 @@ CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar, Prandtl_Lam = config->GetPrandtl_Lam(); Prandtl_Turb = config->GetPrandtl_Turb(); Gas_Constant = config->GetGas_ConstantND(); - multicomponent_energy = - (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) && (config->GetEnergy_Equation()); + energy_multicomponent = + (((config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA)) && + (config->GetEnergy_Equation())); tau = new su2double* [nDim]; for (iDim = 0; iDim < nDim; iDim++) @@ -280,7 +281,7 @@ void CNumerics::GetInviscidIncProjJac(const su2double *val_density, const su2dou val_Proj_Jac_Tensor[2][2] = val_scale*((*val_density)*(proj_vel + val_normal[1]*val_velocity[1])); val_Proj_Jac_Tensor[2][3] = val_scale*((*val_dRhodT)*val_velocity[1]*proj_vel); - if (multicomponent_energy) { + if (energy_multicomponent) { val_Proj_Jac_Tensor[3][0] = val_scale * ((*val_temperature) * proj_vel / (*val_betainc2)); val_Proj_Jac_Tensor[3][1] = val_scale * ((*val_temperature) * val_normal[0] * (*val_density)); val_Proj_Jac_Tensor[3][2] = val_scale * ((*val_temperature) * val_normal[1] * (*val_density)); @@ -321,7 +322,7 @@ void CNumerics::GetInviscidIncProjJac(const su2double *val_density, const su2dou val_Proj_Jac_Tensor[3][3] = val_scale*((*val_density)*(proj_vel + val_normal[2]*val_velocity[2])); val_Proj_Jac_Tensor[3][4] = val_scale*((*val_dRhodT)*val_velocity[2]*proj_vel); - if (multicomponent_energy) { + if (energy_multicomponent) { val_Proj_Jac_Tensor[4][0] = val_scale * ((*val_temperature) * proj_vel / (*val_betainc2)); val_Proj_Jac_Tensor[4][1] = val_scale * ((*val_temperature) * val_normal[0] * (*val_density)); val_Proj_Jac_Tensor[4][2] = val_scale * ((*val_temperature) * val_normal[1] * (*val_density)); @@ -349,7 +350,7 @@ void CNumerics::GetPreconditioner(const su2double *val_density, const su2double val_Precon[0][0] = 1.0/(*val_betainc2); for (iDim = 0; iDim < nDim; iDim++) val_Precon[iDim+1][0] = val_velocity[iDim]/(*val_betainc2); - if (multicomponent_energy){ + if (energy_multicomponent){ val_Precon[nDim+1][0] = (*val_temperature)/(*val_betainc2); }else{ val_Precon[nDim+1][0] = (*val_cp)*(*val_temperature)/(*val_betainc2); @@ -367,7 +368,7 @@ void CNumerics::GetPreconditioner(const su2double *val_density, const su2double val_Precon[0][nDim+1] = (*val_drhodt); for (iDim = 0; iDim < nDim; iDim++) val_Precon[iDim+1][nDim+1] = val_velocity[iDim]*(*val_drhodt); - if (multicomponent_energy){ + if (energy_multicomponent){ val_Precon[nDim+1][nDim+1] = (*val_drhodt)*(*val_temperature) + (*val_density); }else{ val_Precon[nDim+1][nDim+1] = (*val_cp)*((*val_drhodt)*(*val_temperature) + (*val_density)); diff --git a/SU2_CFD/src/numerics/flow/convection/fds.cpp b/SU2_CFD/src/numerics/flow/convection/fds.cpp index de1963e3fb30..115a966896bd 100644 --- a/SU2_CFD/src/numerics/flow/convection/fds.cpp +++ b/SU2_CFD/src/numerics/flow/convection/fds.cpp @@ -118,7 +118,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; - if (multicomponent_energy) { + if (energy_multicomponent) { Enthalpy_i = V_i[nDim + 9]; Enthalpy_j = V_j[nDim + 9]; } else { @@ -163,7 +163,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config MeandRhodT = 0.0; dRhodT_i = 0.0; dRhodT_j = 0.0; if (variable_density) { - if (multicomponent_energy) { + if (energy_multicomponent) { MeandRhodT = -MeanDensity / (MeanCp * MeanTemperature); dRhodT_i = -DensityInc_i / (Cp_i * Temperature_i); dRhodT_j = -DensityInc_j / (Cp_j * Temperature_j); @@ -204,7 +204,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config Lambda[iVar] = fabs(Lambda[iVar]); /*--- Build the preconditioning matrix using mean values ---*/ - if (multicomponent_energy) { + if (energy_multicomponent) { GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanEnthalpy, &MeandRhodT, Precon); } else { GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); @@ -221,7 +221,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config Diff_V[0] = Pressure_j - Pressure_i; for (iDim = 0; iDim < nDim; iDim++) Diff_V[iDim+1] = Velocity_j[iDim] - Velocity_i[iDim]; - if (multicomponent_energy){ + if (energy_multicomponent){ Diff_V[nDim+1] = Enthalpy_j - Enthalpy_i; }else{ Diff_V[nDim+1] = Temperature_j - Temperature_i; @@ -230,7 +230,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config /*--- Build the inviscid Jacobian w.r.t. the primitive variables ---*/ if (implicit) { - if (multicomponent_energy) { + if (energy_multicomponent) { GetInviscidIncProjJac(&DensityInc_i, Velocity_i, &BetaInc2_i, &Cp_i, &Enthalpy_i, &dRhodT_i, Normal, 0.5, Jacobian_i); GetInviscidIncProjJac(&DensityInc_j, Velocity_j, &BetaInc2_j, &Cp_j, &Enthalpy_j, &dRhodT_j, Normal, 0.5, @@ -286,7 +286,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; } - if (multicomponent_energy){ + if (energy_multicomponent){ Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i; Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j; } else { diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index 8e3804a598b9..ddef652b8dbf 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -583,7 +583,7 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi Laminar_Viscosity_i = V_i[nDim+4]; Laminar_Viscosity_j = V_j[nDim+4]; Eddy_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_j = V_j[nDim+5]; Thermal_Conductivity_i = V_i[nDim+6]; Thermal_Conductivity_j = V_j[nDim+6]; - if (multicomponent_energy) { + if (energy_multicomponent) { Cp_i = V_i[nDim + 7]; Cp_j = V_j[nDim + 7]; } @@ -594,7 +594,7 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); - if (multicomponent_energy) { + if (energy_multicomponent) { Mean_Heat_Capacity = 0.5 * (Cp_i + Cp_j); } @@ -630,7 +630,7 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi if (config->GetSAParsedOptions().qcr2000) AddQCR(nDim, &Mean_GradPrimVar[1], tau); if (Mean_TauWall > 0) AddTauWall(UnitNormal, Mean_TauWall); - if (multicomponent_energy) { + if (energy_multicomponent) { Mean_HeatFluxDiffusion = HeatFluxDiffusion; Mean_JacHeatFluxDiffusion = Jac_HeatFluxDiffusion; } @@ -661,7 +661,7 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi proj_vector_ij += (Coord_j[iDim]-Coord_i[iDim])*Normal[iDim]; } proj_vector_ij = proj_vector_ij/dist_ij_2; - if (multicomponent_energy){ + if (energy_multicomponent){ Jacobian_i[nDim + 1][nDim + 1] = -(Mean_Thermal_Conductivity * proj_vector_ij + Mean_JacHeatFluxDiffusion) / Mean_Heat_Capacity; Jacobian_j[nDim + 1][nDim + 1] = @@ -741,7 +741,7 @@ void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradpri for (unsigned short iDim = 0; iDim < nDim; iDim++) Proj_Flux_Tensor[iVar] += Flux_Tensor[iVar][iDim] * val_normal[iDim]; } - if (multicomponent_energy) { + if (energy_multicomponent) { Proj_Flux_Tensor[nVar - 1] += val_heatDiffusion; } } diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index 60f7e6775c22..04da4ad0c20b 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -37,7 +37,7 @@ CFlowIncOutput::CFlowIncOutput(CConfig *config, unsigned short nDim) : CFlowOutp heat = config->GetEnergy_Equation(); - multicomponent = config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT; + multicomponent = ((config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA)); weakly_coupled_heat = config->GetWeakly_Coupled_Heat(); flamelet = (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET); @@ -135,12 +135,13 @@ void CFlowIncOutput::SetHistoryOutputFields(CConfig *config){ if (nDim == 3) AddHistoryOutput("MAX_VELOCITY-Z", "max[W]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the velocity z-component.", HistoryFieldType::RESIDUAL); /// DESCRIPTION: Maximum residual of the temperature. - if (heat || weakly_coupled_heat) + if (heat || weakly_coupled_heat) { if (multicomponent){ AddHistoryOutput("MAX_ENTHALPY", "max[h]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the enthalpy.", HistoryFieldType::RESIDUAL); } else { AddHistoryOutput("MAX_TEMPERATURE", "max[T]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the temperature.", HistoryFieldType::RESIDUAL); } + } AddHistoryOutputFields_ScalarMAX_RES(config); /// END_GROUP @@ -156,12 +157,13 @@ void CFlowIncOutput::SetHistoryOutputFields(CConfig *config){ if (nDim == 3) AddHistoryOutput("BGS_VELOCITY-Z", "bgs[W]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the velocity z-component.", HistoryFieldType::RESIDUAL); /// DESCRIPTION: Maximum residual of the temperature. - if (heat || weakly_coupled_heat) + if (heat || weakly_coupled_heat) { if (multicomponent){ AddHistoryOutput("BGS_ENTHALPY", "bgs[h]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the enthalpy.", HistoryFieldType::RESIDUAL); } else { AddHistoryOutput("BGS_TEMPERATURE", "bgs[T]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the temperature.", HistoryFieldType::RESIDUAL); } + } AddHistoryOutputFields_ScalarBGS_RES(config); @@ -462,9 +464,10 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve SetVolumeOutputValue("RES_VELOCITY-Y", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 2)); if (nDim == 3) SetVolumeOutputValue("RES_VELOCITY-Z", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 3)); - if (config->GetEnergy_Equation()) - if (multicomponent) SetVolumeOutputValue("RES_ENTHALPY", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, nDim+1)); - else SetVolumeOutputValue("RES_TEMPERATURE", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, nDim+1)); + if (config->GetEnergy_Equation()) { + if (multicomponent) SetVolumeOutputValue("RES_ENTHALPY", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, nDim + 1)); + else SetVolumeOutputValue("RES_TEMPERATURE", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, nDim + 1)); + } if (config->GetKind_SlopeLimit_Flow() != LIMITER::NONE && config->GetKind_SlopeLimit_Flow() != LIMITER::VAN_ALBADA_EDGE) { SetVolumeOutputValue("LIMITER_PRESSURE", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 0)); diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index c2bbe10566b8..e15d3502f6ec 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -159,7 +159,7 @@ void CFlowOutput::SetAnalyzeSurface(const CSolver* const*solver, const CGeometry const bool incompressible = config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE; const bool energy = config->GetEnergy_Equation(); const bool multicomponent = - (config->GetKind_FluidModel() == FLUID_MIXTURE || config->GetKind_FluidModel() == FLUID_CANTERA); + ((config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA)); const bool streamwisePeriodic = (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE); const bool species = config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT; const auto nSpecies = config->GetnSpecies(); diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 016b5d35ec0a..631a4ba6bdeb 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -206,8 +206,7 @@ void COutput::SetHistoryOutput(CGeometry *geometry, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) { - - curTimeIter = TimeIter; + curTimeIter = TimeIter; curAbsTimeIter = max(TimeIter, config->GetStartWindowIteration()) - config->GetStartWindowIteration(); curOuterIter = OuterIter; curInnerIter = InnerIter; @@ -273,7 +272,7 @@ void COutput::SetHistoryOutput(CGeometry ****geometry, CSolver *****solver, CCon void COutput::SetMultizoneHistoryOutput(COutput **output, CConfig **config, CConfig *driver_config, unsigned long TimeIter, unsigned long OuterIter){ - curTimeIter = TimeIter; + curTimeIter = TimeIter; curAbsTimeIter = max(TimeIter, driver_config->GetStartWindowIteration()) - driver_config->GetStartWindowIteration(); curOuterIter = OuterIter; @@ -389,6 +388,9 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, OUTPUT_TYPE form /*--- File writer that will later be used to write the file to disk. Created below in the "switch" ---*/ CFileWriter *fileWriter = nullptr; + /*--- Set current time iter even if history file is not written ---*/ + curTimeIter = config->GetTimeIter(); + /*--- If it is still present, strip the extension (suffix) from the filename ---*/ const auto lastindex = fileName.find_last_of('.'); fileName = fileName.substr(0, lastindex); @@ -476,7 +478,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, OUTPUT_TYPE form extension = CSU2MeshFileWriter::fileExt; if (fileName.empty()) - fileName = volumeFilename; + fileName = config->GetFilename(volumeFilename, "", curTimeIter); if (!config->GetWrt_Volume_Overwrite()) filename_iter = config->GetFilename_Iter(fileName, curInnerIter, curOuterIter); diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index bd24cb106db6..318b34250107 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -58,7 +58,9 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned bool time_stepping = config->GetTime_Marching() == TIME_MARCHING::TIME_STEPPING; bool adjoint = (config->GetContinuous_Adjoint()) || (config->GetDiscrete_Adjoint()); const bool centered = config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED; - bool Energy_Multicomponent = (config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation(); + const bool energy_multicomponent = + (((config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA)) && + config->GetEnergy_Equation()); /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); @@ -180,7 +182,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned Pressure_Inf = config->GetPressure_FreeStreamND(); Velocity_Inf = config->GetVelocity_FreeStreamND(); Temperature_Inf = config->GetTemperature_FreeStreamND(); - if (Energy_Multicomponent) { + if (energy_multicomponent) { const su2double* scalar_init = config->GetSpecies_Init(); CFluidModel* auxFluidModel = nullptr; @@ -235,7 +237,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned /*--- Initialize the solution to the far-field state everywhere. ---*/ if (navier_stokes) { - if (Energy_Multicomponent){ + if (energy_multicomponent){ nodes = new CIncNSVariable(Pressure_Inf, Velocity_Inf, Enthalpy_Inf, nPoint, nDim, nVar, config); }else{ nodes = new CIncNSVariable(Pressure_Inf, Velocity_Inf, Temperature_Inf, nPoint, nDim, nVar, config); @@ -1515,7 +1517,7 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont const bool streamwise_periodic = (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE); const bool streamwise_periodic_temperature = config->GetStreamwise_Periodic_Temperature(); const bool multicomponent = - (config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA); + ((config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA)); AD::StartNoSharedReading(); @@ -2132,7 +2134,8 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo bool variable_density = (config->GetVariable_Density_Model()); bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); bool energy = config->GetEnergy_Equation(); - bool multicomponent = config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT; + bool multicomponent = + ((config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA)); /*--- Access the primitive variables at this node. ---*/ @@ -2405,7 +2408,9 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool viscous = config->GetViscous(); - bool Energy_Multicomponent = (config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation(); + const bool energy_multicomponent = + (((config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA)) && + (config->GetEnergy_Equation())); string Marker_Tag = config->GetMarker_All_TagBound(val_marker); @@ -2570,7 +2575,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, } /*-- Enthalpy is needed for energy equation in multicomponent and reacting flows. ---*/ - if (Energy_Multicomponent) { + if (energy_multicomponent) { CFluidModel* auxFluidModel = solver_container[FLOW_SOL]->GetFluidModel(); const su2double* scalar_inlet = config->GetInlet_SpeciesVal(config->GetMarker_All_TagBound(val_marker)); auxFluidModel->SetTDState_T(V_inlet[prim_idx.Temperature()], @@ -2615,7 +2620,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Viscous contribution, commented out because serious convergence problems ---*/ - if (!viscous || Energy_Multicomponent) continue; + if (!viscous || energy_multicomponent) continue; /*--- Set transport properties at the inlet ---*/ @@ -2667,7 +2672,9 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool viscous = config->GetViscous(); - bool Energy_Multicomponent = (config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation(); + const bool energy_multicomponent = + (((config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA)) && + (config->GetEnergy_Equation())); string Marker_Tag = config->GetMarker_All_TagBound(val_marker); su2double Normal[MAXNDIM] = {0.0}; @@ -2791,7 +2798,7 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, V_outlet[prim_idx.CpTotal()] = nodes->GetSpecificHeatCp(iPoint); /*-- Enthalpy is needed for energy equation in multicomponent and reacting flows. ---*/ - if (Energy_Multicomponent) { + if (energy_multicomponent) { CFluidModel* auxFluidModel = solver_container[FLOW_SOL]->GetFluidModel();; const su2double* scalar_outlet = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint); auxFluidModel->SetTDState_T(nodes->GetTemperature(iPoint), @@ -2823,7 +2830,7 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Viscous contribution, commented out because serious convergence problems ---*/ - if (!viscous || Energy_Multicomponent) continue; + if (!viscous || energy_multicomponent) continue; /*--- Set transport properties at the outlet. ---*/ diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 5516f9d8821b..fc28905d55d8 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -348,12 +348,13 @@ void CIncNSSolver::Compute_Streamwise_Periodic_Recovered_Values(CConfig *config, void CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config) { - const bool speciesEnergy = - (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation(); + const bool energy_multicomponent = + (((config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA)) && + (config->GetEnergy_Equation())); const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); /*--- Contribution to heat flux due to enthalpy diffusion for multicomponent and reacting flows ---*/ - if (speciesEnergy) { + if (energy_multicomponent) { CVariable* speciesNodes = solver_container[SPECIES_SOL]->GetNodes(); /*--- Points in edge ---*/ @@ -387,6 +388,7 @@ void CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CS su2double proj_vector_ij = numerics->ComputeProjectedGradient( nDim, n_species, Normal, Coord_i, Coord_j, Species_Grad_i, Species_Grad_j, true, Species_i, Species_j, ProjGradScalarVarNoCorr, Proj_Mean_GradScalarVar); + (void)proj_vector_ij; /*--- Get enthalpy diffusion terms and its gradient(for implicit) for each species at point i. ---*/ @@ -628,7 +630,6 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con const su2double dTdn = -(nodes->GetTemperature(Point_Normal) - Twall)/dist_ij; /*--- Get thermal conductivity ---*/ - const su2double thermal_conductivity = nodes->GetThermalConductivity(iPoint); /*--- Apply a weak boundary condition for the energy equation. diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index 6b465e802fd8..7d9999d965f0 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -500,7 +500,7 @@ void CTurbSASolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_conta Res_Wall = coeff*RoughWallBC*Area; LinSysRes.SubtractBlock(iPoint, &Res_Wall); - su2double Jacobian_i = (laminar_viscosity*Area)/(0.03*Roughness_Height*sigma); + su2double Jacobian_i = (laminar_viscosity /density *Area)/(0.03*Roughness_Height*sigma); Jacobian_i += 2.0*RoughWallBC*Area/sigma; if (implicit) Jacobian.AddVal2Diag(iPoint, -Jacobian_i); } diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index 00c5ee81b51f..02ac1bb7644b 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -46,7 +46,8 @@ CIncNSVariable::CIncNSVariable(su2double pressure, const su2double *velocity, su AuxVar.resize(nPoint,nAuxVar) = su2double(0.0); Grad_AuxVar.resize(nPoint,nAuxVar,nDim); } - if ((config->GetKind_Species_Model()==SPECIES_MODEL::SPECIES_TRANSPORT) && config->GetEnergy_Equation()){ + if (((config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA)) && + (config->GetEnergy_Equation())) { Energy_Multicomponent = true; if (config->GetMUSCL_Flow()) { nAuxVar = 2; From 0655c994dbc3a131cb3ef9d9e60c747c196acb52 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 30 Jan 2025 17:37:56 +0100 Subject: [PATCH 066/173] adding standard reference temperature T0=298.15K as default value --- Common/include/CConfig.hpp | 7 +++++++ Common/src/CConfig.cpp | 3 +++ SU2_CFD/include/fluid/CFluidScalar.hpp | 1 + SU2_CFD/src/fluid/CFluidScalar.cpp | 13 +++++++------ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 58918bfdc2c4..361e4ded7eec 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -893,6 +893,7 @@ class CConfig { Initial_BCThrust, /*!< \brief Ratio of turbulent to laminar viscosity at the actuator disk. */ Pressure_FreeStream, /*!< \brief Total pressure of the fluid. */ Pressure_Thermodynamic, /*!< \brief Thermodynamic pressure of the fluid. */ + Standard_Ref_Temperature, /*!< \brief Standard reference temperature for multicomponent flows. */ Temperature_FreeStream, /*!< \brief Total temperature of the fluid. */ Temperature_ve_FreeStream; /*!< \brief Total vibrational-electronic temperature of the fluid. */ unsigned short wallModel_MaxIter; /*!< \brief maximum number of iterations for the Newton method for the wall model */ @@ -1924,6 +1925,12 @@ class CConfig { */ su2double GetPressure_Thermodynamic(void) const { return Pressure_Thermodynamic; } + /*! + * \brief Get the value of the standard reference temperature for multicomponent flows. + * \return Standard reference temperature. + */ + su2double GetStandard_RefTemperature(void) const { return Standard_Ref_Temperature; } + /*! * \brief Get the value of the non-dimensionalized thermodynamic pressure. * \return Non-dimensionalized thermodynamic pressure. diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index cc5bd3faca69..ccc4f4fdc314 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1211,6 +1211,9 @@ void CConfig::SetConfig_Options() { addDoubleOption("GAMMA_VALUE", Gamma, 1.4); /*!\brief THERMODYNAMIC_PRESSURE \n DESCRIPTION: Thermodynamics(operating) Pressure (101325 Pa), only for incompressible flows) \ingroup Config*/ addDoubleOption("THERMODYNAMIC_PRESSURE", Pressure_Thermodynamic, 101325.0); + /*!\brief STANDARD_REFERENCE_TEMPERATURE \n DESCRIPTION: Standard reference temperature (298.15K), only for + * multicomponent incompressible flows) \ingroup Config*/ + addDoubleOption("STANDARD_REFERENCE_TEMPERATURE", Standard_Ref_Temperature, 298.15); /*!\brief CP_VALUE \n DESCRIPTION: Specific heat at constant pressure, Cp (1004.703 J/kg*K (air), constant density incompressible fluids only) \ingroup Config*/ addDoubleListOption("SPECIFIC_HEAT_CP", nSpecific_Heat_Cp, Specific_Heat_Cp); /*!\brief THERMAL_EXPANSION_COEFF \n DESCRIPTION: Thermal expansion coefficient (0.00347 K^-1 (air), used for Boussinesq approximation for liquids/non-ideal gases) \ingroup Config*/ diff --git a/SU2_CFD/include/fluid/CFluidScalar.hpp b/SU2_CFD/include/fluid/CFluidScalar.hpp index 1db6307cd46e..5c0618de43cc 100644 --- a/SU2_CFD/include/fluid/CFluidScalar.hpp +++ b/SU2_CFD/include/fluid/CFluidScalar.hpp @@ -42,6 +42,7 @@ class CFluidScalar final : public CFluidModel { const int n_species_mixture; /*!< \brief Number of species in mixture. */ su2double Gas_Constant; /*!< \brief Specific gas constant. */ const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */ + const su2double Ref_Temperature; /*!< \brief Reference temperature. */ const su2double GasConstant_Ref; /*!< \brief Gas constant reference needed for Nondimensional problems. */ const su2double Prandtl_Number; /*!< \brief Prandlt number.*/ diff --git a/SU2_CFD/src/fluid/CFluidScalar.cpp b/SU2_CFD/src/fluid/CFluidScalar.cpp index b52c3b0b0b55..c305a74c7077 100644 --- a/SU2_CFD/src/fluid/CFluidScalar.cpp +++ b/SU2_CFD/src/fluid/CFluidScalar.cpp @@ -45,6 +45,7 @@ CFluidScalar::CFluidScalar(su2double value_pressure_operating, const CConfig* co : CFluidModel(), n_species_mixture(config->GetnSpecies() + 1), Pressure_Thermodynamic(value_pressure_operating), + Ref_Temperature(config->GetStandard_RefTemperature()), GasConstant_Ref(config->GetGas_Constant_Ref()), Prandtl_Number(config->GetPrandtl_Turb()), wilke(config->GetKind_MixingViscosityModel() == MIXINGVISCOSITYMODEL::WILKE), @@ -213,7 +214,7 @@ su2double CFluidScalar::ComputeMeanSpecificHeatCp(const su2double* val_scalars) } su2double CFluidScalar::ComputeEnthalpyFromT(const su2double val_temperature, const su2double* val_scalars){ - su2double val_Enthalpy = Cp * (val_temperature - 298.15); + su2double val_Enthalpy = Cp * (val_temperature - Ref_Temperature); return val_Enthalpy; } @@ -221,15 +222,15 @@ void CFluidScalar::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2doub const su2double* val_scalars) { MassToMoleFractions(val_scalars); su2double val_cp = ComputeMeanSpecificHeatCp(val_scalars); - *val_temperature = val_enthalpy / val_cp + 298.15; + *val_temperature = val_enthalpy / val_cp + Ref_Temperature; } void CFluidScalar::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) { + const su2double enthalpy_species_N = specificHeat[n_species_mixture - 1] * (Temperature - Ref_Temperature); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { - enthalpy_diffusions[iVar] = Density * - (specificHeat[iVar] * massDiffusivity[iVar] - - specificHeat[n_species_mixture - 1] * massDiffusivity[n_species_mixture - 1]) * - (Temperature - 298.15); + const su2double enthalpy_species_i = specificHeat[iVar] * (Temperature - Ref_Temperature); + enthalpy_diffusions[iVar] = Density * (enthalpy_species_i * massDiffusivity[iVar] - + enthalpy_species_N * massDiffusivity[n_species_mixture - 1]); } } From a14446c90e3efeebcd4dc15e52f74d2a451b0ca2 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 31 Jan 2025 10:01:51 +0100 Subject: [PATCH 067/173] adding jacobian chemical source term (testing) --- SU2_CFD/include/fluid/CFluidCantera.hpp | 13 ++++++ SU2_CFD/include/fluid/CFluidModel.hpp | 6 +++ SU2_CFD/include/numerics/CNumerics.hpp | 15 ++++++- .../numerics/species/species_sources.hpp | 1 + .../include/variables/CSpeciesVariable.hpp | 24 ++++++++++ SU2_CFD/src/fluid/CFluidCantera.cpp | 45 +++++++++++++++++++ .../src/numerics/species/species_sources.cpp | 7 +++ SU2_CFD/src/solvers/CSpeciesSolver.cpp | 11 +++++ SU2_CFD/src/variables/CSpeciesVariable.cpp | 3 ++ 9 files changed, 124 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 4dd0722fd32b..909682d5c4ad 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -61,6 +61,7 @@ class CFluidCantera final : public CFluidModel { std::array gasComposition; /*!< \brief Gas composition. */ std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ std::array chemicalSourceTerm; /*!< \brief chemical source term of all species*/ + std::array gradChemicalSourceTerm; /*!< \brief jacobian chemical source term of all species*/ std::array molarMasses; /*!< \brief Molar masses of all species. */ std::array enthalpyFormation; /*!< \brief Enthalpy of Formation of all species. */ su2double Heat_Release; /*!< \brief heat release due to combustion */ @@ -86,6 +87,12 @@ class CFluidCantera final : public CFluidModel { */ void ComputeChemicalSourceTerm(); + /*! + * \brief Compute Gradient chemical source terms. + * \param[in] val_scalars - Scalar mass fraction. + */ + void ComputeGradChemicalSourceTerm(const su2double* val_scalars); + /*! * \brief Compute heat release due to combustion. */ @@ -130,6 +137,12 @@ class CFluidCantera final : public CFluidModel { */ inline su2double GetChemicalSourceTerm(int ivar) override { return chemicalSourceTerm[ivar]; } + /*! + * \brief Get Gradient Chemical source term species i with respect to species i. + * \param[in] ivar - index of species. + */ + inline su2double GetGradChemicalSourceTerm(int ivar) override { return gradChemicalSourceTerm[ivar]; } + /*! * \brief Get Heat release due to combustion. */ diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 2e98ccd6e94a..1a832bb52412 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -198,6 +198,12 @@ class CFluidModel { */ inline virtual su2double GetChemicalSourceTerm(int iVar) { return 0.0; } + /*! + * \brief Get Gradient Chemical source term of species i with respect to species i. + * \param[in] iVar - index of species. + */ + inline virtual su2double GetGradChemicalSourceTerm(int iVar) { return 0.0; } + /*! * \brief Get Heat release due to combustion. */ diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 9b45910e776d..e3835704f731 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -64,7 +64,9 @@ class CNumerics { *Diffusion_Coeff_i, /*!< \brief Species diffusion coefficients at point i. */ *Diffusion_Coeff_j, /*!< \brief Species diffusion coefficients at point j. */ *Chemical_Source_Term_i, /*!< \brief Species diffusion coefficients at point i. */ - *Chemical_Source_Term_j; /*!< \brief Species diffusion coefficients at point j. */ + *Chemical_Source_Term_j, /*!< \brief Species diffusion coefficients at point j. */ + *Grad_Chemical_Source_Term_i, /*!< \brief Gradient Chemical source term Species at point i. */ + *Grad_Chemical_Source_Term_j; /*!< \brief Gradient Chemical source term Species at point j. */ su2double Laminar_Viscosity_i, /*!< \brief Laminar viscosity at point i. */ Laminar_Viscosity_j; /*!< \brief Laminar viscosity at point j. */ @@ -769,6 +771,17 @@ class CNumerics { Chemical_Source_Term_j = val_source_term_j; } + /*! + * \brief Set the gradient of the Chemical source term + * \param[in] val_grad_source_term_i - Value of the gradient of the chemical source term at i. + * \param[in] val_grad_source_term_j - Value of the gradient of the chemical source term at j. + */ + inline void SetGradChemicalSourceTerm(const su2double* val_grad_source_term_i, + const su2double* val_grad_source_term_j) { + Grad_Chemical_Source_Term_i = val_grad_source_term_i; + Grad_Chemical_Source_Term_j = val_grad_source_term_j; + } + /*! * \brief Set the heat flux due to enthalpy diffusion * \param[in] val_heatfluxdiffusion - Value of the heat flux due to enthalpy diffusion. diff --git a/SU2_CFD/include/numerics/species/species_sources.hpp b/SU2_CFD/include/numerics/species/species_sources.hpp index 0a195eb857a4..5f07af38c917 100644 --- a/SU2_CFD/include/numerics/species/species_sources.hpp +++ b/SU2_CFD/include/numerics/species/species_sources.hpp @@ -103,6 +103,7 @@ class CSourceCombustion_Species : public CSourceBase_Species { protected: const FlowIndices idx; /*!< \brief Object to manage the access to the flow primitives. */ const bool incompressible; + const bool implicit; public: /*! diff --git a/SU2_CFD/include/variables/CSpeciesVariable.hpp b/SU2_CFD/include/variables/CSpeciesVariable.hpp index 69c3032af527..a98baed8f075 100644 --- a/SU2_CFD/include/variables/CSpeciesVariable.hpp +++ b/SU2_CFD/include/variables/CSpeciesVariable.hpp @@ -37,6 +37,7 @@ class CSpeciesVariable : public CScalarVariable { protected: MatrixType Diffusivity; /*!< \brief Matrix (nPoint,nVar) of mass diffusivities for scalar transport. */ MatrixType SpeciesSourceTerm; /*!< \brief Matrix (nPoint, nVar) of chemical source terms for species transport*/ + MatrixType GradSpeciesSourceTerm; /*!< \brief Matrix (nPoint, nVar) of gradient of chemical source terms for species transport*/ VectorType HeatRelease; /*!< \brief Vector of heat release due to combustion for species transport*/ public: @@ -101,6 +102,29 @@ class CSpeciesVariable : public CScalarVariable { */ inline const su2double* GetChemicalSourceTerm(unsigned long iPoint) const { return SpeciesSourceTerm[iPoint]; } + /*! + * \brief Set the gradient of the chemical source term for species transport + * \param[in] val_gradSourceTerm - the gradient of the chemical source term. + * \param[in] val_ivar - eqn. index to the chemical source term. + */ + inline void SetGradChemicalSourceTerm(unsigned long iPoint, su2double val_gradSourceTerm, unsigned short val_ivar) { + GradSpeciesSourceTerm(iPoint, val_ivar) = val_gradSourceTerm; + } + + /*! + * \brief Get the value of the gradient of the chemical source term for species transport + * \param[in] val_ivar - eqn. index to the gradient of the chemical source term. + * \return Value of the gradient of the chemical source term. + */ + inline su2double GetGradChemicalSourceTerm(unsigned long iPoint, unsigned short val_ivar) const { + return GradSpeciesSourceTerm(iPoint, val_ivar); + } + + /*! + * \brief Get the value of the gradient of the chemical source term for species transport + * \return Pointer to the gradient of the chemical source term + */ + inline const su2double* GetGradChemicalSourceTerm(unsigned long iPoint) const { return GradSpeciesSourceTerm[iPoint]; } /*! * \brief Get heat release due to combustion * \param[in] iPoint - Point index. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 98a61c7d0e3b..ab26c2bdc73e 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -109,6 +109,50 @@ void CFluidCantera::ComputeChemicalSourceTerm(){ } } +void CFluidCantera::ComputeGradChemicalSourceTerm(const su2double* val_scalars) { + const int nsp = sol->thermo()->nSpecies(); + //const su2double meanMolecularWeight = sol->thermo()->meanMolecularWeight(); + vector netProductionRates_T(nsp); + // The universal gas constant times temperature is retrieved from cantera. + const su2double uni_gas_constant_temp = sol->thermo()->RT(); + vector enthalpiesSpecies(nsp); + sol->thermo()->getEnthalpy_RT_ref(&enthalpiesSpecies[0]); + //Eigen::SparseMatrix dW_dC = sol->kinetics()->netProductionRates_ddCi(); + sol->kinetics()->getNetProductionRates_ddT(&netProductionRates_T[0]); + const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); + for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { + int speciesIndex_i = sol->thermo()->speciesIndex(gasComposition[iVar]); + //su2double scalars_sum = 0.0; + const su2double dT_dYi = + uni_gas_constant_temp * (enthalpiesSpecies[speciesN] - enthalpiesSpecies[speciesIndex_i]) / Cp; + gradChemicalSourceTerm[iVar] = molarMasses[speciesIndex_i] * netProductionRates_T[speciesIndex_i] * dT_dYi; + // for (int jVar = 0; jVar < n_species_mixture - 1; jVar++) { + // int speciesIndex_j = sol->thermo()->speciesIndex(gasComposition[jVar]); + // su2double dW_dCi = dW_dC.coeff(iVar,jVar) * molarMasses[speciesIndex_i]; + // if (jVar != iVar) { + // const su2double factor = dW_dCi * Density * val_scalars[jVar] / (molarMasses[speciesIndex_j] / 1000); + // scalars_sum += val_scalars[jVar]; + // gradChemicalSourceTerm[iVar] += + // factor * (-dT_dYi / Temperature + + // meanMolecularWeight * (1 / molarMasses[speciesN] - 1 / molarMasses[speciesIndex_i])); + // } else { + // const su2double factor = dW_dCi * Density / (molarMasses[speciesIndex_j] / 1000); + // scalars_sum += val_scalars[jVar]; + // gradChemicalSourceTerm[iVar] += + // factor * (1.0 + val_scalars[jVar] * + // (-dT_dYi / Temperature + + // meanMolecularWeight * (1 / molarMasses[speciesN] - 1 / molarMasses[speciesIndex_i]))); + // } + // } + // su2double dW_dCN = dW_dC.coeff(iVar, speciesN)* molarMasses[speciesN]; + // const su2double factor = dW_dCN * Density / (molarMasses[speciesN] / 1000); + // gradChemicalSourceTerm[iVar] += + // factor * + // (-1.0 + (1.0 - scalars_sum) * (-dT_dYi / Temperature + meanMolecularWeight * (1 / molarMasses[speciesN] - + // 1 / molarMasses[speciesIndex_i]))); + } +} + void CFluidCantera::ComputeHeatRelease() { const int nsp = sol->thermo()->nSpecies(); vector netProductionRates(nsp); @@ -215,6 +259,7 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl ComputeMassDiffusivity(); ComputeChemicalSourceTerm(); + ComputeGradChemicalSourceTerm(val_scalars); ComputeHeatRelease(); } #endif \ No newline at end of file diff --git a/SU2_CFD/src/numerics/species/species_sources.cpp b/SU2_CFD/src/numerics/species/species_sources.cpp index f1216c32b255..18803fad686c 100644 --- a/SU2_CFD/src/numerics/species/species_sources.cpp +++ b/SU2_CFD/src/numerics/species/species_sources.cpp @@ -140,6 +140,7 @@ CSourceCombustion_Species::CSourceCombustion_Species(unsigned short val_nDim, const CConfig* config) : CSourceBase_Species(val_nDim, val_nVar, config), idx(val_nDim, config->GetnSpecies()), + implicit(config->GetKind_TimeIntScheme_Species() == EULER_IMPLICIT), incompressible(config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE) {} template @@ -169,6 +170,12 @@ CNumerics::ResidualType<> CSourceCombustion_Species::ComputeResidual(const CC residual[iVar] += Volume * Chemical_Source_Term_i[iVar]; } + if (implicit) { + for (auto iVar = 0u; iVar < nVar; iVar++) { + jacobian[iVar][iVar] += Volume * Grad_Chemical_Source_Term_i[iVar] / DensityInc_i; + } + } + AD::SetPreaccOut(residual, nVar); AD::EndPreacc(); diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index c66eeff23159..f4711c168d66 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -296,6 +296,7 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain unsigned long spark_iter_start, spark_duration; bool ignition = false; su2double temperature; + const bool implicit = (config->GetKind_TimeIntScheme_Species() == EULER_IMPLICIT); /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ if ((config->GetFlameletInitType() == FLAMELET_INIT_TYPE::SPARK) && !config->GetRestart()) { @@ -336,6 +337,11 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain if (config->GetCombustion() == true) { const su2double chemical_source_term=solver_container[FLOW_SOL]->GetFluidModel()->GetChemicalSourceTerm(iVar); nodes->SetChemicalSourceTerm(iPoint, chemical_source_term, iVar); + if (implicit) { + const su2double grad_chemical_source_term = + solver_container[FLOW_SOL]->GetFluidModel()->GetGradChemicalSourceTerm(iVar); + nodes->SetGradChemicalSourceTerm(iPoint, grad_chemical_source_term, iVar); + } } } @@ -609,6 +615,11 @@ void CSpeciesSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Set Chemical Source Term ---*/ numerics->SetChemicalSourceTerm(nodes->GetChemicalSourceTerm(iPoint), nullptr); + if (implicit) { + numerics->SetGradChemicalSourceTerm(nodes->GetGradChemicalSourceTerm(iPoint), nullptr); + numerics->SetDensity(solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint), + solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint)); + } /*--- Set volume of the dual cell. ---*/ diff --git a/SU2_CFD/src/variables/CSpeciesVariable.cpp b/SU2_CFD/src/variables/CSpeciesVariable.cpp index e904d4b1ee17..35767e47d7aa 100644 --- a/SU2_CFD/src/variables/CSpeciesVariable.cpp +++ b/SU2_CFD/src/variables/CSpeciesVariable.cpp @@ -33,6 +33,9 @@ CSpeciesVariable::CSpeciesVariable(const su2double* species_inf, unsigned long n /*--- Allocate space for the mass diffusivity and chemical source term. ---*/ Diffusivity.resize(nPoint, nVar + 1) = su2double(0.0); SpeciesSourceTerm.resize(nPoint, nVar + 1) = su2double(0.0); + if (config->GetKind_TimeIntScheme_Species() == EULER_IMPLICIT) { + GradSpeciesSourceTerm.resize(nPoint, nVar + 1) = su2double(0.0); + } HeatRelease.resize(nPoint) = su2double(0.0); for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) From 3f45e1c969f031c19f3558b005c85eb8125b3b7d Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 18 Feb 2025 12:30:20 +0100 Subject: [PATCH 068/173] reformulating and cleaning --- SU2_CFD/include/numerics/CNumerics.hpp | 3 + .../include/numerics/flow/convection/fds.hpp | 2 +- SU2_CFD/src/numerics/CNumerics.cpp | 53 ++++------------ SU2_CFD/src/numerics/flow/convection/fds.cpp | 62 +++++++------------ SU2_CFD/src/solvers/CIncEulerSolver.cpp | 62 +++++++------------ 5 files changed, 63 insertions(+), 119 deletions(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index cec666bc72d5..37ed3a036fce 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -103,6 +103,9 @@ class CNumerics { su2double Enthalpy_i, /*!< \brief Enthalpy at point i. */ Enthalpy_j; /*!< \brief Enthalpy at point j. */ + su2double + WorkingVariable_i, /*!< \brief Enthalpy at point i. */ + WorkingVariable_j; /*!< \brief Enthalpy at point j. */ su2double dist_i, /*!< \brief Distance of point i to the nearest wall. */ dist_j; /*!< \brief Distance of point j to the nearest wall. */ diff --git a/SU2_CFD/include/numerics/flow/convection/fds.hpp b/SU2_CFD/include/numerics/flow/convection/fds.hpp index e72db06db6a3..2e39d8fc10bd 100644 --- a/SU2_CFD/include/numerics/flow/convection/fds.hpp +++ b/SU2_CFD/include/numerics/flow/convection/fds.hpp @@ -51,7 +51,7 @@ class CUpwFDSInc_Flow final : public CNumerics { Pressure_j, ProjVelocity, MeandRhodT, dRhodT_i, dRhodT_j, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ - MeanDensity, MeanPressure, MeanSoundSpeed, MeanBetaInc2, MeanEnthalpy, MeanCp, MeanTemperature; /*!< \brief Mean values of primitive variables. */ + MeanDensity, MeanPressure, MeanSoundSpeed, MeanBetaInc2, MeanWorkingVar, MeanCp, MeanTemperature; /*!< \brief Mean values of primitive variables. */ unsigned short iDim, iVar, jVar, kVar; su2double* Flux = nullptr; /*!< \brief The flux / residual across the edge. */ diff --git a/SU2_CFD/src/numerics/CNumerics.cpp b/SU2_CFD/src/numerics/CNumerics.cpp index f78e4b602885..116ce359ee5d 100644 --- a/SU2_CFD/src/numerics/CNumerics.cpp +++ b/SU2_CFD/src/numerics/CNumerics.cpp @@ -279,20 +279,10 @@ void CNumerics::GetInviscidIncProjJac(const su2double *val_density, const su2dou val_Proj_Jac_Tensor[2][2] = val_scale*((*val_density)*(proj_vel + val_normal[1]*val_velocity[1])); val_Proj_Jac_Tensor[2][3] = val_scale*((*val_dRhodT)*val_velocity[1]*proj_vel); - if (energy_multicomponent) { - val_Proj_Jac_Tensor[3][0] = val_scale * ((*val_temperature) * proj_vel / (*val_betainc2)); - val_Proj_Jac_Tensor[3][1] = val_scale * ((*val_temperature) * val_normal[0] * (*val_density)); - val_Proj_Jac_Tensor[3][2] = val_scale * ((*val_temperature) * val_normal[1] * (*val_density)); - val_Proj_Jac_Tensor[3][3] = - val_scale * ((*val_temperature) * (*val_dRhodT) + (*val_density)) * proj_vel; - - } else { - val_Proj_Jac_Tensor[3][0] = val_scale * ((*val_cp) * (*val_temperature) * proj_vel / (*val_betainc2)); - val_Proj_Jac_Tensor[3][1] = val_scale * ((*val_cp) * (*val_temperature) * val_normal[0] * (*val_density)); - val_Proj_Jac_Tensor[3][2] = val_scale * ((*val_cp) * (*val_temperature) * val_normal[1] * (*val_density)); - val_Proj_Jac_Tensor[3][3] = - val_scale * ((*val_cp) * ((*val_temperature) * (*val_dRhodT) + (*val_density)) * proj_vel); - } + val_Proj_Jac_Tensor[3][0] = val_scale*((*val_cp)*(*val_temperature)*proj_vel/(*val_betainc2)); + val_Proj_Jac_Tensor[3][1] = val_scale*((*val_cp)*(*val_temperature)*val_normal[0]*(*val_density)); + val_Proj_Jac_Tensor[3][2] = val_scale*((*val_cp)*(*val_temperature)*val_normal[1]*(*val_density)); + val_Proj_Jac_Tensor[3][3] = val_scale*((*val_cp)*((*val_temperature)*(*val_dRhodT) + (*val_density))*proj_vel); } else { @@ -319,22 +309,13 @@ void CNumerics::GetInviscidIncProjJac(const su2double *val_density, const su2dou val_Proj_Jac_Tensor[3][2] = val_scale*(val_normal[1]*(*val_density)*val_velocity[2]); val_Proj_Jac_Tensor[3][3] = val_scale*((*val_density)*(proj_vel + val_normal[2]*val_velocity[2])); val_Proj_Jac_Tensor[3][4] = val_scale*((*val_dRhodT)*val_velocity[2]*proj_vel); - - if (energy_multicomponent) { - val_Proj_Jac_Tensor[4][0] = val_scale * ((*val_temperature) * proj_vel / (*val_betainc2)); - val_Proj_Jac_Tensor[4][1] = val_scale * ((*val_temperature) * val_normal[0] * (*val_density)); - val_Proj_Jac_Tensor[4][2] = val_scale * ((*val_temperature) * val_normal[1] * (*val_density)); - val_Proj_Jac_Tensor[4][3] = val_scale * ((*val_temperature) * val_normal[2] * (*val_density)); - val_Proj_Jac_Tensor[4][4] = - val_scale * ((*val_temperature) * (*val_dRhodT) + (*val_density)) * proj_vel; - } else { - val_Proj_Jac_Tensor[4][0] = val_scale * ((*val_cp) * (*val_temperature) * proj_vel / (*val_betainc2)); - val_Proj_Jac_Tensor[4][1] = val_scale * ((*val_cp) * (*val_temperature) * val_normal[0] * (*val_density)); - val_Proj_Jac_Tensor[4][2] = val_scale * ((*val_cp) * (*val_temperature) * val_normal[1] * (*val_density)); - val_Proj_Jac_Tensor[4][3] = val_scale * ((*val_cp) * (*val_temperature) * val_normal[2] * (*val_density)); - val_Proj_Jac_Tensor[4][4] = - val_scale * ((*val_cp) * ((*val_temperature) * (*val_dRhodT) + (*val_density)) * proj_vel); - } + + val_Proj_Jac_Tensor[4][0] = val_scale*((*val_cp)*(*val_temperature)*proj_vel/(*val_betainc2)); + val_Proj_Jac_Tensor[4][1] = val_scale*((*val_cp)*(*val_temperature)*val_normal[0]*(*val_density)); + val_Proj_Jac_Tensor[4][2] = val_scale*((*val_cp)*(*val_temperature)*val_normal[1]*(*val_density)); + val_Proj_Jac_Tensor[4][3] = val_scale*((*val_cp)*(*val_temperature)*val_normal[2]*(*val_density)); + val_Proj_Jac_Tensor[4][4] = val_scale*((*val_cp)*((*val_temperature)*(*val_dRhodT) + (*val_density))*proj_vel); + } AD::EndPassive(wasActive); } @@ -348,11 +329,7 @@ void CNumerics::GetPreconditioner(const su2double *val_density, const su2double val_Precon[0][0] = 1.0/(*val_betainc2); for (iDim = 0; iDim < nDim; iDim++) val_Precon[iDim+1][0] = val_velocity[iDim]/(*val_betainc2); - if (energy_multicomponent){ - val_Precon[nDim+1][0] = (*val_temperature)/(*val_betainc2); - }else{ - val_Precon[nDim+1][0] = (*val_cp)*(*val_temperature)/(*val_betainc2); - } + val_Precon[nDim+1][0] = (*val_cp)*(*val_temperature)/(*val_betainc2); for (jDim = 0; jDim < nDim; jDim++) { val_Precon[0][jDim+1] = 0.0; @@ -366,11 +343,7 @@ void CNumerics::GetPreconditioner(const su2double *val_density, const su2double val_Precon[0][nDim+1] = (*val_drhodt); for (iDim = 0; iDim < nDim; iDim++) val_Precon[iDim+1][nDim+1] = val_velocity[iDim]*(*val_drhodt); - if (energy_multicomponent){ - val_Precon[nDim+1][nDim+1] = (*val_drhodt)*(*val_temperature) + (*val_density); - }else{ - val_Precon[nDim+1][nDim+1] = (*val_cp)*((*val_drhodt)*(*val_temperature) + (*val_density)); - } + val_Precon[nDim+1][nDim+1] = (*val_cp)*((*val_drhodt)*(*val_temperature) + (*val_density)); } diff --git a/SU2_CFD/src/numerics/flow/convection/fds.cpp b/SU2_CFD/src/numerics/flow/convection/fds.cpp index 115a966896bd..a941a8008e63 100644 --- a/SU2_CFD/src/numerics/flow/convection/fds.cpp +++ b/SU2_CFD/src/numerics/flow/convection/fds.cpp @@ -121,9 +121,13 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config if (energy_multicomponent) { Enthalpy_i = V_i[nDim + 9]; Enthalpy_j = V_j[nDim + 9]; + WorkingVariable_i = Enthalpy_i; + WorkingVariable_j = Enthalpy_j; } else { Enthalpy_i = Cp_i * Temperature_i; Enthalpy_j = Cp_j * Temperature_j; + WorkingVariable_i = Temperature_i; + WorkingVariable_j = Temperature_j; } ProjVelocity = 0.0; @@ -149,7 +153,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config MeanDensity = 0.5*(DensityInc_i + DensityInc_j); MeanPressure = 0.5*(Pressure_i + Pressure_j); MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); - MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); + MeanWorkingVar = 0.5*(WorkingVariable_i + WorkingVariable_j); MeanCp = 0.5*(Cp_i + Cp_j); MeanTemperature = 0.5*(Temperature_i + Temperature_j); @@ -163,15 +167,17 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config MeandRhodT = 0.0; dRhodT_i = 0.0; dRhodT_j = 0.0; if (variable_density) { - if (energy_multicomponent) { - MeandRhodT = -MeanDensity / (MeanCp * MeanTemperature); - dRhodT_i = -DensityInc_i / (Cp_i * Temperature_i); - dRhodT_j = -DensityInc_j / (Cp_j * Temperature_j); - } else { - MeandRhodT = -MeanDensity / MeanTemperature; - dRhodT_i = -DensityInc_i / Temperature_i; - dRhodT_j = -DensityInc_j / Temperature_j; - } + MeandRhodT = -MeanDensity / MeanTemperature; + dRhodT_i = -DensityInc_i / Temperature_i; + dRhodT_j = -DensityInc_j / Temperature_j; + } + if (energy_multicomponent) { + MeandRhodT /= MeanCp ; + dRhodT_i /= Cp_i; + dRhodT_j /= Cp_j; + MeanCp = 1.0; + Cp_i = 1.0; + Cp_j = 1.0; } /*--- Compute ProjFlux_i ---*/ @@ -204,11 +210,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config Lambda[iVar] = fabs(Lambda[iVar]); /*--- Build the preconditioning matrix using mean values ---*/ - if (energy_multicomponent) { - GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanEnthalpy, &MeandRhodT, Precon); - } else { - GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); - } + GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanWorkingVar, &MeandRhodT, Precon); /*--- Build the absolute value of the preconditioned Jacobian, i.e., |A_precon| = P x |Lambda| x inv(P), where P diagonalizes the matrix @@ -221,26 +223,15 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config Diff_V[0] = Pressure_j - Pressure_i; for (iDim = 0; iDim < nDim; iDim++) Diff_V[iDim+1] = Velocity_j[iDim] - Velocity_i[iDim]; - if (energy_multicomponent){ - Diff_V[nDim+1] = Enthalpy_j - Enthalpy_i; - }else{ - Diff_V[nDim+1] = Temperature_j - Temperature_i; - } + Diff_V[nDim + 1] = WorkingVariable_j - WorkingVariable_i; /*--- Build the inviscid Jacobian w.r.t. the primitive variables ---*/ if (implicit) { - if (energy_multicomponent) { - GetInviscidIncProjJac(&DensityInc_i, Velocity_i, &BetaInc2_i, &Cp_i, &Enthalpy_i, &dRhodT_i, Normal, 0.5, - Jacobian_i); - GetInviscidIncProjJac(&DensityInc_j, Velocity_j, &BetaInc2_j, &Cp_j, &Enthalpy_j, &dRhodT_j, Normal, 0.5, - Jacobian_j); - } else { - GetInviscidIncProjJac(&DensityInc_i, Velocity_i, &BetaInc2_i, &Cp_i, &Temperature_i, &dRhodT_i, Normal, 0.5, - Jacobian_i); - GetInviscidIncProjJac(&DensityInc_j, Velocity_j, &BetaInc2_j, &Cp_j, &Temperature_j, &dRhodT_j, Normal, 0.5, - Jacobian_j); - } + GetInviscidIncProjJac(&DensityInc_i, Velocity_i, &BetaInc2_i, &Cp_i, &WorkingVariable_i, &dRhodT_i, Normal, 0.5, + Jacobian_i); + GetInviscidIncProjJac(&DensityInc_j, Velocity_j, &BetaInc2_j, &Cp_j, &WorkingVariable_j, &dRhodT_j, Normal, 0.5, + Jacobian_j); } /*--- Compute dissipation as Precon x |A_precon| x dV. If implicit, @@ -286,13 +277,8 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; } - if (energy_multicomponent){ - Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i; - Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j; - } else { - Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; - Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; - } + Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; + Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; } } } diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index aa6bea96a0d1..a939af159e12 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2073,7 +2073,10 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo Cp = nodes->GetSpecificHeatCp(iPoint); oneOverCp = 1.0/Cp; Temperature = nodes->GetTemperature(iPoint); - if (energy && multicomponent) Enthalpy = nodes->GetEnthalpy(iPoint); + Enthalpy = Cp * Temperature; + if (energy && multicomponent) { + Enthalpy = nodes->GetEnthalpy(iPoint); + } for (iDim = 0; iDim < nDim; iDim++) Velocity[iDim] = nodes->GetVelocity(iPoint,iDim); @@ -2085,6 +2088,7 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo if (variable_density) { if (multicomponent && energy){ dRhodT = -Density / (Cp * Temperature); + Cp = oneOverCp = 1.0; } else { dRhodT = -Density/Temperature; } @@ -2105,13 +2109,9 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo Preconditioner[iDim+1][0] = Velocity[iDim]/BetaInc2; if (energy) { - if (multicomponent) { - Preconditioner[nDim + 1][0] = Enthalpy / BetaInc2; - } else { - Preconditioner[nDim + 1][0] = Cp * Temperature / BetaInc2; - } + Preconditioner[nDim+1][0] = Enthalpy / BetaInc2; } else { - Preconditioner[nDim + 1][0] = 0.0; + Preconditioner[nDim+1][0] = 0.0; } for (jDim = 0; jDim < nDim; jDim++) { @@ -2128,13 +2128,9 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo Preconditioner[iDim+1][nDim+1] = Velocity[iDim]*dRhodT; if (energy) { - if (multicomponent) { - Preconditioner[nDim + 1][nDim + 1] = dRhodT * Enthalpy + Density; - } else { - Preconditioner[nDim + 1][nDim + 1] = Cp * (dRhodT * Temperature + Density); - } + Preconditioner[nDim+1][nDim+1] = dRhodT * Enthalpy + Cp * Density; } else { - Preconditioner[nDim + 1][nDim + 1] = 1.0; + Preconditioner[nDim+1][nDim+1] = 1.0; } for (iVar = 0; iVar < nVar; iVar ++ ) @@ -2147,50 +2143,36 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo Therefore, we build inv(Precon) here and multiply by the residual later in the R-K and Euler Explicit time integration schemes. ---*/ - if (multicomponent && energy) { - Preconditioner[0][0] = Enthalpy * BetaInc2 * dRhodT / Density + BetaInc2; - } else { - Preconditioner[0][0] = Temperature * BetaInc2 * dRhodT / Density + BetaInc2; - } + + Preconditioner[0][0] = Enthalpy * BetaInc2 * dRhodT * oneOverCp / Density + BetaInc2; + for (iDim = 0; iDim < nDim; iDim++) Preconditioner[iDim + 1][0] = -1.0 * Velocity[iDim] / Density; if (energy) { - if (multicomponent) { - Preconditioner[nDim + 1][0] = -1.0 * Enthalpy / Density; - } else { - Preconditioner[nDim + 1][0] = -1.0 * Temperature / Density; - } + Preconditioner[nDim+1][0] = -1.0 * Enthalpy * oneOverCp / Density; } else { - Preconditioner[nDim + 1][0] = 0.0; + Preconditioner[nDim+1][0] = 0.0; } for (jDim = 0; jDim < nDim; jDim++) { - Preconditioner[0][jDim + 1] = 0.0; + Preconditioner[0][jDim+1] = 0.0; for (iDim = 0; iDim < nDim; iDim++) { if (iDim == jDim) - Preconditioner[iDim + 1][jDim + 1] = 1.0 / Density; + Preconditioner[iDim+1][jDim+1] = 1.0 / Density; else - Preconditioner[iDim + 1][jDim + 1] = 0.0; + Preconditioner[iDim+1][jDim+1] = 0.0; } - Preconditioner[nDim + 1][jDim + 1] = 0.0; + Preconditioner[nDim+1][jDim+1] = 0.0; } - if (multicomponent && energy) { - Preconditioner[0][nDim + 1] = -1.0 * BetaInc2 * dRhodT / Density; - } else { - Preconditioner[0][nDim + 1] = -1.0 * BetaInc2 * dRhodT * oneOverCp / Density; - } - for (iDim = 0; iDim < nDim; iDim++) Preconditioner[iDim + 1][nDim + 1] = 0.0; + Preconditioner[0][nDim+1] = -1.0 * BetaInc2 * dRhodT * oneOverCp / Density; + for (iDim = 0; iDim < nDim; iDim++) Preconditioner[iDim+1][nDim+1] = 0.0; if (energy) { - if (multicomponent) { - Preconditioner[nDim + 1][nDim + 1] = 1.0 / Density; - } else { - Preconditioner[nDim + 1][nDim + 1] = oneOverCp / Density; - } + Preconditioner[nDim+1][nDim+1] = oneOverCp / Density; } else { - Preconditioner[nDim + 1][nDim + 1] = 0.0; + Preconditioner[nDim+1][nDim+1] = 0.0; } } } From b1fc9d43ed71fd704de3c0515bfed064acc46a5b Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 19 Feb 2025 14:01:52 +0100 Subject: [PATCH 069/173] cleaning flow_diffusion.hpp and .cpp --- .../include/numerics/flow/flow_diffusion.hpp | 8 +++--- SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 26 ++++++------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/SU2_CFD/include/numerics/flow/flow_diffusion.hpp b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp index f3b997a97016..558d035eb1b1 100644 --- a/SU2_CFD/include/numerics/flow/flow_diffusion.hpp +++ b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp @@ -51,8 +51,6 @@ class CAvgGrad_Base : public CNumerics { *heat_flux_jac_i = nullptr, /*!< \brief Jacobian of the molecular + turbulent heat flux vector, projected onto the normal vector. */ **tau_jacobian_i = nullptr; /*!< \brief Jacobian of the viscous + turbulent stress tensor, projected onto the normal vector. */ su2double *Mean_PrimVar = nullptr; /*!< \brief Mean primitive variables. */ - su2double Mean_HeatFluxDiffusion; /*!< \brief Mean heat flux due to enthalpy diffusion for multicomponent flows. */ - su2double Mean_JacHeatFluxDiffusion; /*!< \brief Mean Jacobian heat flux due to enthalpy diffusion for multicomponent flows. */ const su2double *PrimVar_i = nullptr, *PrimVar_j = nullptr; /*!< \brief Primitives variables at point i and j. */ @@ -301,10 +299,10 @@ class CAvgGradInc_Flow final : public CAvgGrad_Base { * \param[in] val_gradprimvar - Gradient of the primitive variables. * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. * \param[in] val_thermal_conductivity - Thermal conductivity. - * \param[in] val_heatDiffusion - Heat diffusion */ - void GetViscousIncProjFlux(const su2double* const* val_gradprimvar, const su2double* val_normal, - su2double val_thermal_conductivity, su2double val_heatFluxDiffusion); + void GetViscousIncProjFlux(const su2double* const *val_gradprimvar, + const su2double *val_normal, + su2double val_thermal_conductivity); /*! * \brief Compute the projection of the viscous Jacobian matrices. diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index ddef652b8dbf..0bfce624285c 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -583,10 +583,6 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi Laminar_Viscosity_i = V_i[nDim+4]; Laminar_Viscosity_j = V_j[nDim+4]; Eddy_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_j = V_j[nDim+5]; Thermal_Conductivity_i = V_i[nDim+6]; Thermal_Conductivity_j = V_j[nDim+6]; - if (energy_multicomponent) { - Cp_i = V_i[nDim + 7]; - Cp_j = V_j[nDim + 7]; - } /*--- Mean transport properties ---*/ @@ -594,9 +590,6 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); - if (energy_multicomponent) { - Mean_Heat_Capacity = 0.5 * (Cp_i + Cp_j); - } /*--- Mean gradient approximation ---*/ @@ -630,13 +623,12 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi if (config->GetSAParsedOptions().qcr2000) AddQCR(nDim, &Mean_GradPrimVar[1], tau); if (Mean_TauWall > 0) AddTauWall(UnitNormal, Mean_TauWall); + GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity); + if (energy_multicomponent) { - Mean_HeatFluxDiffusion = HeatFluxDiffusion; - Mean_JacHeatFluxDiffusion = Jac_HeatFluxDiffusion; + Proj_Flux_Tensor[nVar - 1] += HeatFluxDiffusion; } - GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity, Mean_HeatFluxDiffusion); - /*--- Implicit part ---*/ if (implicit) { @@ -662,10 +654,11 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi } proj_vector_ij = proj_vector_ij/dist_ij_2; if (energy_multicomponent){ + Mean_Heat_Capacity = 0.5 * (V_i[nDim + 7] + V_j[nDim + 7]); Jacobian_i[nDim + 1][nDim + 1] = - -(Mean_Thermal_Conductivity * proj_vector_ij + Mean_JacHeatFluxDiffusion) / Mean_Heat_Capacity; + -(Mean_Thermal_Conductivity * proj_vector_ij + Jac_HeatFluxDiffusion) / Mean_Heat_Capacity; Jacobian_j[nDim + 1][nDim + 1] = - (Mean_Thermal_Conductivity * proj_vector_ij + Mean_JacHeatFluxDiffusion) / Mean_Heat_Capacity; + (Mean_Thermal_Conductivity * proj_vector_ij + Jac_HeatFluxDiffusion) / Mean_Heat_Capacity; } else { Jacobian_i[nDim + 1][nDim + 1] = -Mean_Thermal_Conductivity * proj_vector_ij; Jacobian_j[nDim + 1][nDim + 1] = Mean_Thermal_Conductivity * proj_vector_ij; @@ -696,8 +689,7 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradprimvar, const su2double *val_normal, - su2double val_thermal_conductivity, - su2double val_heatDiffusion) { + su2double val_thermal_conductivity) { /*--- Gradient of primitive variables -> [Pressure vel_x vel_y vel_z Temperature] ---*/ @@ -741,9 +733,7 @@ void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradpri for (unsigned short iDim = 0; iDim < nDim; iDim++) Proj_Flux_Tensor[iVar] += Flux_Tensor[iVar][iDim] * val_normal[iDim]; } - if (energy_multicomponent) { - Proj_Flux_Tensor[nVar - 1] += val_heatDiffusion; - } + } void CAvgGradInc_Flow::GetViscousIncProjJacs(su2double val_dS, From b23913a797e1b504b4f9a1676cbce367b7fbb09c Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 21 Feb 2025 11:52:04 +0100 Subject: [PATCH 070/173] removing spaces --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 2 +- SU2_CFD/src/numerics/CNumerics.cpp | 4 ++-- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index a4e2f8849317..d7a634e82271 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -434,7 +434,7 @@ void CFVMFlowSolverBase::Viscous_Residual_impl(unsigned long iEdge, CGeome const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool tkeNeeded = (config->GetKind_Turb_Model() == TURB_MODEL::SST); - CVariable* turbNodes = nullptr; + CVariable* turbNodes = nullptr; if (tkeNeeded) turbNodes = solver_container[TURB_SOL]->GetNodes(); /*--- Points, coordinates and normal vector in edge ---*/ diff --git a/SU2_CFD/src/numerics/CNumerics.cpp b/SU2_CFD/src/numerics/CNumerics.cpp index 116ce359ee5d..5dcf37df568c 100644 --- a/SU2_CFD/src/numerics/CNumerics.cpp +++ b/SU2_CFD/src/numerics/CNumerics.cpp @@ -309,13 +309,13 @@ void CNumerics::GetInviscidIncProjJac(const su2double *val_density, const su2dou val_Proj_Jac_Tensor[3][2] = val_scale*(val_normal[1]*(*val_density)*val_velocity[2]); val_Proj_Jac_Tensor[3][3] = val_scale*((*val_density)*(proj_vel + val_normal[2]*val_velocity[2])); val_Proj_Jac_Tensor[3][4] = val_scale*((*val_dRhodT)*val_velocity[2]*proj_vel); - + val_Proj_Jac_Tensor[4][0] = val_scale*((*val_cp)*(*val_temperature)*proj_vel/(*val_betainc2)); val_Proj_Jac_Tensor[4][1] = val_scale*((*val_cp)*(*val_temperature)*val_normal[0]*(*val_density)); val_Proj_Jac_Tensor[4][2] = val_scale*((*val_cp)*(*val_temperature)*val_normal[1]*(*val_density)); val_Proj_Jac_Tensor[4][3] = val_scale*((*val_cp)*(*val_temperature)*val_normal[2]*(*val_density)); val_Proj_Jac_Tensor[4][4] = val_scale*((*val_cp)*((*val_temperature)*(*val_dRhodT) + (*val_density))*proj_vel); - + } AD::EndPassive(wasActive); } diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index a939af159e12..84773f2a75ac 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2170,7 +2170,6 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo if (energy) { Preconditioner[nDim+1][nDim+1] = oneOverCp / Density; - } else { Preconditioner[nDim+1][nDim+1] = 0.0; } From b50088da5ebe8a738285e62b736aa4ebee77fd85 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 21 Feb 2025 14:55:28 +0100 Subject: [PATCH 071/173] up-to-date with feature preconditioning --- SU2_CFD/include/numerics/CNumerics.hpp | 3 + .../include/numerics/flow/convection/fds.hpp | 2 +- .../include/numerics/flow/flow_diffusion.hpp | 8 +-- .../include/solvers/CFVMFlowSolverBase.inl | 2 +- SU2_CFD/src/numerics/CNumerics.cpp | 51 ++++----------- SU2_CFD/src/numerics/flow/convection/fds.cpp | 62 +++++++----------- SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 26 +++----- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 63 +++++++------------ 8 files changed, 74 insertions(+), 143 deletions(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index e3835704f731..fbea7c50f7f7 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -107,6 +107,9 @@ class CNumerics { su2double Enthalpy_i, /*!< \brief Enthalpy at point i. */ Enthalpy_j; /*!< \brief Enthalpy at point j. */ + su2double + WorkingVariable_i, /*!< \brief Enthalpy at point i. */ + WorkingVariable_j; /*!< \brief Enthalpy at point j. */ su2double dist_i, /*!< \brief Distance of point i to the nearest wall. */ dist_j; /*!< \brief Distance of point j to the nearest wall. */ diff --git a/SU2_CFD/include/numerics/flow/convection/fds.hpp b/SU2_CFD/include/numerics/flow/convection/fds.hpp index e72db06db6a3..2e39d8fc10bd 100644 --- a/SU2_CFD/include/numerics/flow/convection/fds.hpp +++ b/SU2_CFD/include/numerics/flow/convection/fds.hpp @@ -51,7 +51,7 @@ class CUpwFDSInc_Flow final : public CNumerics { Pressure_j, ProjVelocity, MeandRhodT, dRhodT_i, dRhodT_j, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ - MeanDensity, MeanPressure, MeanSoundSpeed, MeanBetaInc2, MeanEnthalpy, MeanCp, MeanTemperature; /*!< \brief Mean values of primitive variables. */ + MeanDensity, MeanPressure, MeanSoundSpeed, MeanBetaInc2, MeanWorkingVar, MeanCp, MeanTemperature; /*!< \brief Mean values of primitive variables. */ unsigned short iDim, iVar, jVar, kVar; su2double* Flux = nullptr; /*!< \brief The flux / residual across the edge. */ diff --git a/SU2_CFD/include/numerics/flow/flow_diffusion.hpp b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp index f3b997a97016..558d035eb1b1 100644 --- a/SU2_CFD/include/numerics/flow/flow_diffusion.hpp +++ b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp @@ -51,8 +51,6 @@ class CAvgGrad_Base : public CNumerics { *heat_flux_jac_i = nullptr, /*!< \brief Jacobian of the molecular + turbulent heat flux vector, projected onto the normal vector. */ **tau_jacobian_i = nullptr; /*!< \brief Jacobian of the viscous + turbulent stress tensor, projected onto the normal vector. */ su2double *Mean_PrimVar = nullptr; /*!< \brief Mean primitive variables. */ - su2double Mean_HeatFluxDiffusion; /*!< \brief Mean heat flux due to enthalpy diffusion for multicomponent flows. */ - su2double Mean_JacHeatFluxDiffusion; /*!< \brief Mean Jacobian heat flux due to enthalpy diffusion for multicomponent flows. */ const su2double *PrimVar_i = nullptr, *PrimVar_j = nullptr; /*!< \brief Primitives variables at point i and j. */ @@ -301,10 +299,10 @@ class CAvgGradInc_Flow final : public CAvgGrad_Base { * \param[in] val_gradprimvar - Gradient of the primitive variables. * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. * \param[in] val_thermal_conductivity - Thermal conductivity. - * \param[in] val_heatDiffusion - Heat diffusion */ - void GetViscousIncProjFlux(const su2double* const* val_gradprimvar, const su2double* val_normal, - su2double val_thermal_conductivity, su2double val_heatFluxDiffusion); + void GetViscousIncProjFlux(const su2double* const *val_gradprimvar, + const su2double *val_normal, + su2double val_thermal_conductivity); /*! * \brief Compute the projection of the viscous Jacobian matrices. diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index a4e2f8849317..d7a634e82271 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -434,7 +434,7 @@ void CFVMFlowSolverBase::Viscous_Residual_impl(unsigned long iEdge, CGeome const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool tkeNeeded = (config->GetKind_Turb_Model() == TURB_MODEL::SST); - CVariable* turbNodes = nullptr; + CVariable* turbNodes = nullptr; if (tkeNeeded) turbNodes = solver_container[TURB_SOL]->GetNodes(); /*--- Points, coordinates and normal vector in edge ---*/ diff --git a/SU2_CFD/src/numerics/CNumerics.cpp b/SU2_CFD/src/numerics/CNumerics.cpp index 3f91deb0dfed..1517bb51fff7 100644 --- a/SU2_CFD/src/numerics/CNumerics.cpp +++ b/SU2_CFD/src/numerics/CNumerics.cpp @@ -281,20 +281,10 @@ void CNumerics::GetInviscidIncProjJac(const su2double *val_density, const su2dou val_Proj_Jac_Tensor[2][2] = val_scale*((*val_density)*(proj_vel + val_normal[1]*val_velocity[1])); val_Proj_Jac_Tensor[2][3] = val_scale*((*val_dRhodT)*val_velocity[1]*proj_vel); - if (energy_multicomponent) { - val_Proj_Jac_Tensor[3][0] = val_scale * ((*val_temperature) * proj_vel / (*val_betainc2)); - val_Proj_Jac_Tensor[3][1] = val_scale * ((*val_temperature) * val_normal[0] * (*val_density)); - val_Proj_Jac_Tensor[3][2] = val_scale * ((*val_temperature) * val_normal[1] * (*val_density)); - val_Proj_Jac_Tensor[3][3] = - val_scale * ((*val_temperature) * (*val_dRhodT) + (*val_density)) * proj_vel; - - } else { - val_Proj_Jac_Tensor[3][0] = val_scale * ((*val_cp) * (*val_temperature) * proj_vel / (*val_betainc2)); - val_Proj_Jac_Tensor[3][1] = val_scale * ((*val_cp) * (*val_temperature) * val_normal[0] * (*val_density)); - val_Proj_Jac_Tensor[3][2] = val_scale * ((*val_cp) * (*val_temperature) * val_normal[1] * (*val_density)); - val_Proj_Jac_Tensor[3][3] = - val_scale * ((*val_cp) * ((*val_temperature) * (*val_dRhodT) + (*val_density)) * proj_vel); - } + val_Proj_Jac_Tensor[3][0] = val_scale*((*val_cp)*(*val_temperature)*proj_vel/(*val_betainc2)); + val_Proj_Jac_Tensor[3][1] = val_scale*((*val_cp)*(*val_temperature)*val_normal[0]*(*val_density)); + val_Proj_Jac_Tensor[3][2] = val_scale*((*val_cp)*(*val_temperature)*val_normal[1]*(*val_density)); + val_Proj_Jac_Tensor[3][3] = val_scale*((*val_cp)*((*val_temperature)*(*val_dRhodT) + (*val_density))*proj_vel); } else { @@ -322,21 +312,12 @@ void CNumerics::GetInviscidIncProjJac(const su2double *val_density, const su2dou val_Proj_Jac_Tensor[3][3] = val_scale*((*val_density)*(proj_vel + val_normal[2]*val_velocity[2])); val_Proj_Jac_Tensor[3][4] = val_scale*((*val_dRhodT)*val_velocity[2]*proj_vel); - if (energy_multicomponent) { - val_Proj_Jac_Tensor[4][0] = val_scale * ((*val_temperature) * proj_vel / (*val_betainc2)); - val_Proj_Jac_Tensor[4][1] = val_scale * ((*val_temperature) * val_normal[0] * (*val_density)); - val_Proj_Jac_Tensor[4][2] = val_scale * ((*val_temperature) * val_normal[1] * (*val_density)); - val_Proj_Jac_Tensor[4][3] = val_scale * ((*val_temperature) * val_normal[2] * (*val_density)); - val_Proj_Jac_Tensor[4][4] = - val_scale * ((*val_temperature) * (*val_dRhodT) + (*val_density)) * proj_vel; - } else { - val_Proj_Jac_Tensor[4][0] = val_scale * ((*val_cp) * (*val_temperature) * proj_vel / (*val_betainc2)); - val_Proj_Jac_Tensor[4][1] = val_scale * ((*val_cp) * (*val_temperature) * val_normal[0] * (*val_density)); - val_Proj_Jac_Tensor[4][2] = val_scale * ((*val_cp) * (*val_temperature) * val_normal[1] * (*val_density)); - val_Proj_Jac_Tensor[4][3] = val_scale * ((*val_cp) * (*val_temperature) * val_normal[2] * (*val_density)); - val_Proj_Jac_Tensor[4][4] = - val_scale * ((*val_cp) * ((*val_temperature) * (*val_dRhodT) + (*val_density)) * proj_vel); - } + val_Proj_Jac_Tensor[4][0] = val_scale*((*val_cp)*(*val_temperature)*proj_vel/(*val_betainc2)); + val_Proj_Jac_Tensor[4][1] = val_scale*((*val_cp)*(*val_temperature)*val_normal[0]*(*val_density)); + val_Proj_Jac_Tensor[4][2] = val_scale*((*val_cp)*(*val_temperature)*val_normal[1]*(*val_density)); + val_Proj_Jac_Tensor[4][3] = val_scale*((*val_cp)*(*val_temperature)*val_normal[2]*(*val_density)); + val_Proj_Jac_Tensor[4][4] = val_scale*((*val_cp)*((*val_temperature)*(*val_dRhodT) + (*val_density))*proj_vel); + } AD::EndPassive(wasActive); } @@ -350,11 +331,7 @@ void CNumerics::GetPreconditioner(const su2double *val_density, const su2double val_Precon[0][0] = 1.0/(*val_betainc2); for (iDim = 0; iDim < nDim; iDim++) val_Precon[iDim+1][0] = val_velocity[iDim]/(*val_betainc2); - if (energy_multicomponent){ - val_Precon[nDim+1][0] = (*val_temperature)/(*val_betainc2); - }else{ - val_Precon[nDim+1][0] = (*val_cp)*(*val_temperature)/(*val_betainc2); - } + val_Precon[nDim+1][0] = (*val_cp)*(*val_temperature)/(*val_betainc2); for (jDim = 0; jDim < nDim; jDim++) { val_Precon[0][jDim+1] = 0.0; @@ -368,11 +345,7 @@ void CNumerics::GetPreconditioner(const su2double *val_density, const su2double val_Precon[0][nDim+1] = (*val_drhodt); for (iDim = 0; iDim < nDim; iDim++) val_Precon[iDim+1][nDim+1] = val_velocity[iDim]*(*val_drhodt); - if (energy_multicomponent){ - val_Precon[nDim+1][nDim+1] = (*val_drhodt)*(*val_temperature) + (*val_density); - }else{ - val_Precon[nDim+1][nDim+1] = (*val_cp)*((*val_drhodt)*(*val_temperature) + (*val_density)); - } + val_Precon[nDim+1][nDim+1] = (*val_cp)*((*val_drhodt)*(*val_temperature) + (*val_density)); } diff --git a/SU2_CFD/src/numerics/flow/convection/fds.cpp b/SU2_CFD/src/numerics/flow/convection/fds.cpp index 115a966896bd..a941a8008e63 100644 --- a/SU2_CFD/src/numerics/flow/convection/fds.cpp +++ b/SU2_CFD/src/numerics/flow/convection/fds.cpp @@ -121,9 +121,13 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config if (energy_multicomponent) { Enthalpy_i = V_i[nDim + 9]; Enthalpy_j = V_j[nDim + 9]; + WorkingVariable_i = Enthalpy_i; + WorkingVariable_j = Enthalpy_j; } else { Enthalpy_i = Cp_i * Temperature_i; Enthalpy_j = Cp_j * Temperature_j; + WorkingVariable_i = Temperature_i; + WorkingVariable_j = Temperature_j; } ProjVelocity = 0.0; @@ -149,7 +153,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config MeanDensity = 0.5*(DensityInc_i + DensityInc_j); MeanPressure = 0.5*(Pressure_i + Pressure_j); MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); - MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); + MeanWorkingVar = 0.5*(WorkingVariable_i + WorkingVariable_j); MeanCp = 0.5*(Cp_i + Cp_j); MeanTemperature = 0.5*(Temperature_i + Temperature_j); @@ -163,15 +167,17 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config MeandRhodT = 0.0; dRhodT_i = 0.0; dRhodT_j = 0.0; if (variable_density) { - if (energy_multicomponent) { - MeandRhodT = -MeanDensity / (MeanCp * MeanTemperature); - dRhodT_i = -DensityInc_i / (Cp_i * Temperature_i); - dRhodT_j = -DensityInc_j / (Cp_j * Temperature_j); - } else { - MeandRhodT = -MeanDensity / MeanTemperature; - dRhodT_i = -DensityInc_i / Temperature_i; - dRhodT_j = -DensityInc_j / Temperature_j; - } + MeandRhodT = -MeanDensity / MeanTemperature; + dRhodT_i = -DensityInc_i / Temperature_i; + dRhodT_j = -DensityInc_j / Temperature_j; + } + if (energy_multicomponent) { + MeandRhodT /= MeanCp ; + dRhodT_i /= Cp_i; + dRhodT_j /= Cp_j; + MeanCp = 1.0; + Cp_i = 1.0; + Cp_j = 1.0; } /*--- Compute ProjFlux_i ---*/ @@ -204,11 +210,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config Lambda[iVar] = fabs(Lambda[iVar]); /*--- Build the preconditioning matrix using mean values ---*/ - if (energy_multicomponent) { - GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanEnthalpy, &MeandRhodT, Precon); - } else { - GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); - } + GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanWorkingVar, &MeandRhodT, Precon); /*--- Build the absolute value of the preconditioned Jacobian, i.e., |A_precon| = P x |Lambda| x inv(P), where P diagonalizes the matrix @@ -221,26 +223,15 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config Diff_V[0] = Pressure_j - Pressure_i; for (iDim = 0; iDim < nDim; iDim++) Diff_V[iDim+1] = Velocity_j[iDim] - Velocity_i[iDim]; - if (energy_multicomponent){ - Diff_V[nDim+1] = Enthalpy_j - Enthalpy_i; - }else{ - Diff_V[nDim+1] = Temperature_j - Temperature_i; - } + Diff_V[nDim + 1] = WorkingVariable_j - WorkingVariable_i; /*--- Build the inviscid Jacobian w.r.t. the primitive variables ---*/ if (implicit) { - if (energy_multicomponent) { - GetInviscidIncProjJac(&DensityInc_i, Velocity_i, &BetaInc2_i, &Cp_i, &Enthalpy_i, &dRhodT_i, Normal, 0.5, - Jacobian_i); - GetInviscidIncProjJac(&DensityInc_j, Velocity_j, &BetaInc2_j, &Cp_j, &Enthalpy_j, &dRhodT_j, Normal, 0.5, - Jacobian_j); - } else { - GetInviscidIncProjJac(&DensityInc_i, Velocity_i, &BetaInc2_i, &Cp_i, &Temperature_i, &dRhodT_i, Normal, 0.5, - Jacobian_i); - GetInviscidIncProjJac(&DensityInc_j, Velocity_j, &BetaInc2_j, &Cp_j, &Temperature_j, &dRhodT_j, Normal, 0.5, - Jacobian_j); - } + GetInviscidIncProjJac(&DensityInc_i, Velocity_i, &BetaInc2_i, &Cp_i, &WorkingVariable_i, &dRhodT_i, Normal, 0.5, + Jacobian_i); + GetInviscidIncProjJac(&DensityInc_j, Velocity_j, &BetaInc2_j, &Cp_j, &WorkingVariable_j, &dRhodT_j, Normal, 0.5, + Jacobian_j); } /*--- Compute dissipation as Precon x |A_precon| x dV. If implicit, @@ -286,13 +277,8 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; } - if (energy_multicomponent){ - Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i; - Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j; - } else { - Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; - Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; - } + Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; + Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; } } } diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index ddef652b8dbf..0bfce624285c 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -583,10 +583,6 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi Laminar_Viscosity_i = V_i[nDim+4]; Laminar_Viscosity_j = V_j[nDim+4]; Eddy_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_j = V_j[nDim+5]; Thermal_Conductivity_i = V_i[nDim+6]; Thermal_Conductivity_j = V_j[nDim+6]; - if (energy_multicomponent) { - Cp_i = V_i[nDim + 7]; - Cp_j = V_j[nDim + 7]; - } /*--- Mean transport properties ---*/ @@ -594,9 +590,6 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); - if (energy_multicomponent) { - Mean_Heat_Capacity = 0.5 * (Cp_i + Cp_j); - } /*--- Mean gradient approximation ---*/ @@ -630,13 +623,12 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi if (config->GetSAParsedOptions().qcr2000) AddQCR(nDim, &Mean_GradPrimVar[1], tau); if (Mean_TauWall > 0) AddTauWall(UnitNormal, Mean_TauWall); + GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity); + if (energy_multicomponent) { - Mean_HeatFluxDiffusion = HeatFluxDiffusion; - Mean_JacHeatFluxDiffusion = Jac_HeatFluxDiffusion; + Proj_Flux_Tensor[nVar - 1] += HeatFluxDiffusion; } - GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity, Mean_HeatFluxDiffusion); - /*--- Implicit part ---*/ if (implicit) { @@ -662,10 +654,11 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi } proj_vector_ij = proj_vector_ij/dist_ij_2; if (energy_multicomponent){ + Mean_Heat_Capacity = 0.5 * (V_i[nDim + 7] + V_j[nDim + 7]); Jacobian_i[nDim + 1][nDim + 1] = - -(Mean_Thermal_Conductivity * proj_vector_ij + Mean_JacHeatFluxDiffusion) / Mean_Heat_Capacity; + -(Mean_Thermal_Conductivity * proj_vector_ij + Jac_HeatFluxDiffusion) / Mean_Heat_Capacity; Jacobian_j[nDim + 1][nDim + 1] = - (Mean_Thermal_Conductivity * proj_vector_ij + Mean_JacHeatFluxDiffusion) / Mean_Heat_Capacity; + (Mean_Thermal_Conductivity * proj_vector_ij + Jac_HeatFluxDiffusion) / Mean_Heat_Capacity; } else { Jacobian_i[nDim + 1][nDim + 1] = -Mean_Thermal_Conductivity * proj_vector_ij; Jacobian_j[nDim + 1][nDim + 1] = Mean_Thermal_Conductivity * proj_vector_ij; @@ -696,8 +689,7 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradprimvar, const su2double *val_normal, - su2double val_thermal_conductivity, - su2double val_heatDiffusion) { + su2double val_thermal_conductivity) { /*--- Gradient of primitive variables -> [Pressure vel_x vel_y vel_z Temperature] ---*/ @@ -741,9 +733,7 @@ void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradpri for (unsigned short iDim = 0; iDim < nDim; iDim++) Proj_Flux_Tensor[iVar] += Flux_Tensor[iVar][iDim] * val_normal[iDim]; } - if (energy_multicomponent) { - Proj_Flux_Tensor[nVar - 1] += val_heatDiffusion; - } + } void CAvgGradInc_Flow::GetViscousIncProjJacs(su2double val_dS, diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 318b34250107..e29f08703bff 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2144,7 +2144,10 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo Cp = nodes->GetSpecificHeatCp(iPoint); oneOverCp = 1.0/Cp; Temperature = nodes->GetTemperature(iPoint); - if (energy && multicomponent) Enthalpy = nodes->GetEnthalpy(iPoint); + Enthalpy = Cp * Temperature; + if (energy && multicomponent) { + Enthalpy = nodes->GetEnthalpy(iPoint); + } for (iDim = 0; iDim < nDim; iDim++) Velocity[iDim] = nodes->GetVelocity(iPoint,iDim); @@ -2156,6 +2159,7 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo if (variable_density) { if (multicomponent && energy){ dRhodT = -Density / (Cp * Temperature); + Cp = oneOverCp = 1.0; } else { dRhodT = -Density/Temperature; } @@ -2176,13 +2180,9 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo Preconditioner[iDim+1][0] = Velocity[iDim]/BetaInc2; if (energy) { - if (multicomponent) { - Preconditioner[nDim + 1][0] = Enthalpy / BetaInc2; - } else { - Preconditioner[nDim + 1][0] = Cp * Temperature / BetaInc2; - } + Preconditioner[nDim+1][0] = Enthalpy / BetaInc2; } else { - Preconditioner[nDim + 1][0] = 0.0; + Preconditioner[nDim+1][0] = 0.0; } for (jDim = 0; jDim < nDim; jDim++) { @@ -2199,13 +2199,9 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo Preconditioner[iDim+1][nDim+1] = Velocity[iDim]*dRhodT; if (energy) { - if (multicomponent) { - Preconditioner[nDim + 1][nDim + 1] = dRhodT * Enthalpy + Density; - } else { - Preconditioner[nDim + 1][nDim + 1] = Cp * (dRhodT * Temperature + Density); - } + Preconditioner[nDim+1][nDim+1] = dRhodT * Enthalpy + Cp * Density; } else { - Preconditioner[nDim + 1][nDim + 1] = 1.0; + Preconditioner[nDim+1][nDim+1] = 1.0; } for (iVar = 0; iVar < nVar; iVar ++ ) @@ -2218,50 +2214,35 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo Therefore, we build inv(Precon) here and multiply by the residual later in the R-K and Euler Explicit time integration schemes. ---*/ - if (multicomponent && energy) { - Preconditioner[0][0] = Enthalpy * BetaInc2 * dRhodT / Density + BetaInc2; - } else { - Preconditioner[0][0] = Temperature * BetaInc2 * dRhodT / Density + BetaInc2; - } + + Preconditioner[0][0] = Enthalpy * BetaInc2 * dRhodT * oneOverCp / Density + BetaInc2; + for (iDim = 0; iDim < nDim; iDim++) Preconditioner[iDim + 1][0] = -1.0 * Velocity[iDim] / Density; if (energy) { - if (multicomponent) { - Preconditioner[nDim + 1][0] = -1.0 * Enthalpy / Density; - } else { - Preconditioner[nDim + 1][0] = -1.0 * Temperature / Density; - } + Preconditioner[nDim+1][0] = -1.0 * Enthalpy * oneOverCp / Density; } else { - Preconditioner[nDim + 1][0] = 0.0; + Preconditioner[nDim+1][0] = 0.0; } for (jDim = 0; jDim < nDim; jDim++) { - Preconditioner[0][jDim + 1] = 0.0; + Preconditioner[0][jDim+1] = 0.0; for (iDim = 0; iDim < nDim; iDim++) { if (iDim == jDim) - Preconditioner[iDim + 1][jDim + 1] = 1.0 / Density; + Preconditioner[iDim+1][jDim+1] = 1.0 / Density; else - Preconditioner[iDim + 1][jDim + 1] = 0.0; + Preconditioner[iDim+1][jDim+1] = 0.0; } - Preconditioner[nDim + 1][jDim + 1] = 0.0; + Preconditioner[nDim+1][jDim+1] = 0.0; } - if (multicomponent && energy) { - Preconditioner[0][nDim + 1] = -1.0 * BetaInc2 * dRhodT / Density; - } else { - Preconditioner[0][nDim + 1] = -1.0 * BetaInc2 * dRhodT * oneOverCp / Density; - } - for (iDim = 0; iDim < nDim; iDim++) Preconditioner[iDim + 1][nDim + 1] = 0.0; + Preconditioner[0][nDim+1] = -1.0 * BetaInc2 * dRhodT * oneOverCp / Density; + for (iDim = 0; iDim < nDim; iDim++) Preconditioner[iDim+1][nDim+1] = 0.0; if (energy) { - if (multicomponent) { - Preconditioner[nDim + 1][nDim + 1] = 1.0 / Density; - } else { - Preconditioner[nDim + 1][nDim + 1] = oneOverCp / Density; - } - + Preconditioner[nDim+1][nDim+1] = oneOverCp / Density; } else { - Preconditioner[nDim + 1][nDim + 1] = 0.0; + Preconditioner[nDim+1][nDim+1] = 0.0; } } } From 1961b08292d5ba64b29630749f6af1ffbecc94f4 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 21 Feb 2025 15:05:49 +0100 Subject: [PATCH 072/173] fix description working variable --- SU2_CFD/include/numerics/CNumerics.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 37ed3a036fce..afe18ee87a1b 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -104,8 +104,8 @@ class CNumerics { Enthalpy_i, /*!< \brief Enthalpy at point i. */ Enthalpy_j; /*!< \brief Enthalpy at point j. */ su2double - WorkingVariable_i, /*!< \brief Enthalpy at point i. */ - WorkingVariable_j; /*!< \brief Enthalpy at point j. */ + WorkingVariable_i, /*!< \brief Working Variable at point i for incompressible solver. */ + WorkingVariable_j; /*!< \brief Working Variable at point j for incompressible solver. */ su2double dist_i, /*!< \brief Distance of point i to the nearest wall. */ dist_j; /*!< \brief Distance of point j to the nearest wall. */ From 02e5eac957b037dcba30c5dd1b229a552cbedf83 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 22 Feb 2025 10:43:08 +0100 Subject: [PATCH 073/173] update parallel regresion test --- TestCases/parallel_regression.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 530328b52a64..5e8555798170 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1525,7 +1525,7 @@ def main(): species2_primitiveVenturi_mixingmodel.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel.cfg_file = "species2_primitiveVenturi_mixingmodel.cfg" species2_primitiveVenturi_mixingmodel.test_iter = 50 - species2_primitiveVenturi_mixingmodel.test_vals = [ -5.407755, -4.557255, -4.635502, -5.642910, -0.059627, -5.546376, 5.000000, -1.879995, 5.000000, -4.898985, 5.000000, -1.169389, 0.000551, 0.000483, 0.000068, 0.000000] + species2_primitiveVenturi_mixingmodel.test_vals = [ -5.406062, -4.556225, -4.633753, -5.644242, -0.058437, -5.545635, 5.000000, -1.881888, 5.000000, -4.900700, 5.000000, -1.169412, 0.000559, 0.000492, 0.000067, 0.000000] test_list.append(species2_primitiveVenturi_mixingmodel) # 2 species (1 eq) primitive venturi mixing using mixing model and bounded scalar transport @@ -1533,7 +1533,7 @@ def main(): species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_file = "species2_primitiveVenturi_mixingmodel_boundedscalar.cfg" species2_primitiveVenturi_mixingmodel_boundedscalar.test_iter = 50 - species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.392378, -4.492373, -4.576491, -5.759780, -0.137797, -5.677531, 5.000000, -1.895013, 5.000000, -4.806816, 5.000000, -1.697769, 0.000275, 0.000275, 0.000000, 0.000000] + species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.390872, -4.491249, -4.575176, -5.760619, -0.137842, -5.677153, 5.000000, -1.896522, 5.000000, -4.806007, 5.000000, -1.697287, 0.000275, 0.000275, 0.000000, 0.000000] test_list.append(species2_primitiveVenturi_mixingmodel_boundedscalar) # 2 species (1 eq) primitive venturi mixing using mixing model including viscosity, thermal conductivity and inlet markers for SA turbulence model @@ -1549,7 +1549,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_iter = 50 - species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_vals = [-5.688779, -4.556193, -4.513326, -6.563666, 2.298459, -5.423525, 30.000000, -6.903871, 13.000000, -8.224587, 8.000000, -9.119625, 2.078869, 1.000000, 0.600000, 0.478869] + species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_vals = [-5.705589, -4.493347, -4.464137, -6.399752, 2.021703, -5.466399, 30.000000, -7.430567, 13.000000, -8.018769, 8.000000, -8.506180, 2.092565, 1.000000, 0.600000, 0.492565] test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2) # 2 species (1 eq) primitive venturi mixing using mixing model including heat capacity and mass diffusivity NonDimensional case From 810d2df97d1f5da9b43c2f64868706767d18709a Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 22 Feb 2025 11:32:09 +0100 Subject: [PATCH 074/173] fix non-dimensionalization issue --- Common/include/CConfig.hpp | 4 ++-- SU2_CFD/src/fluid/CFluidScalar.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index a53eaef1218b..de1eafb8eac2 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -1928,9 +1928,9 @@ class CConfig { /*! * \brief Get the value of the standard reference temperature for multicomponent flows. - * \return Standard reference temperature. + * \return Standard reference temperature, Non-dimensionalized if it is needed for Non-Dimensional problems. */ - su2double GetStandard_RefTemperature(void) const { return Standard_Ref_Temperature; } + su2double GetStandard_RefTemperatureND(void) const { return Standard_Ref_Temperature / Temperature_Ref; } /*! * \brief Get the value of the non-dimensionalized thermodynamic pressure. diff --git a/SU2_CFD/src/fluid/CFluidScalar.cpp b/SU2_CFD/src/fluid/CFluidScalar.cpp index c305a74c7077..ac22fb7d5f3d 100644 --- a/SU2_CFD/src/fluid/CFluidScalar.cpp +++ b/SU2_CFD/src/fluid/CFluidScalar.cpp @@ -45,7 +45,7 @@ CFluidScalar::CFluidScalar(su2double value_pressure_operating, const CConfig* co : CFluidModel(), n_species_mixture(config->GetnSpecies() + 1), Pressure_Thermodynamic(value_pressure_operating), - Ref_Temperature(config->GetStandard_RefTemperature()), + Ref_Temperature(config->GetStandard_RefTemperatureND()), GasConstant_Ref(config->GetGas_Constant_Ref()), Prandtl_Number(config->GetPrandtl_Turb()), wilke(config->GetKind_MixingViscosityModel() == MIXINGVISCOSITYMODEL::WILKE), From 70ae6eebe293c1aad167d858d10a5a8b5b981afb Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 22 Feb 2025 14:03:32 +0100 Subject: [PATCH 075/173] updating species Non-Dimensional test case --- TestCases/parallel_regression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 5e8555798170..183341de5163 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1557,7 +1557,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_iter = 50 - species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.287504, -4.852957, -4.798004, -7.501815, 1.991002, -5.023713, 10.000000, -2.696121, 3.000000, -5.182457, 5.000000, -5.561055, 2.078843, 1.000000, 0.600000, 0.478843] + species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.291034, -4.770419, -4.743257, -7.365441, 1.709269, -5.067282, 10.000000, -2.860653, 4.000000, -5.134413, 5.000000, -5.474359, 2.093031, 1.000000, 0.600000, 0.493031] test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND) # 2 species (1 eq) primitive venturi mixing From 89c3e1272a93760a0143bbe48e56ceb57ad4b8d1 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 24 Feb 2025 10:19:43 +0100 Subject: [PATCH 076/173] cleaning and updating to feature_preconditioning --- Common/include/CConfig.hpp | 14 -------------- Common/src/CConfig.cpp | 29 ----------------------------- TestCases/parallel_regression.py | 2 +- 3 files changed, 1 insertion(+), 44 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index c73f38fe0238..2fb53e98d094 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -202,9 +202,7 @@ class CConfig { nMarker_ContactResistance, /*!< \brief Number of CHT interfaces with contact resistance. */ nMarker_Inlet, /*!< \brief Number of inlet flow markers. */ nMarker_Inlet_Species, /*!< \brief Number of inlet species markers. */ - //nMarker_Inlet_Composition, /*!< \brief Number of inlet composition markers. */ nSpecies_per_Inlet, /*!< \brief Number of species defined per inlet markers. */ - //nComposition_per_Inlet, /*!< \brief Number of composition names defined per inlet markers. */ nMarker_Inlet_Turb, /*!< \brief Number of inlet turbulent markers. */ nTurb_Properties, /*!< \brief Number of turbulent properties per inlet markers. */ nMarker_Riemann, /*!< \brief Number of Riemann flow markers. */ @@ -260,7 +258,6 @@ class CConfig { *Marker_ActDiskBemOutlet_Axis, /*!< \brief Actuator disk BEM outlet markers passed to MARKER_ACTDISK_BEM_AXIS. */ *Marker_Inlet, /*!< \brief Inlet flow markers. */ *Marker_Inlet_Species, /*!< \brief Inlet species markers. */ - //*Marker_Inlet_Composition, /*!< \brief Inlet composition markers. */ *Marker_Inlet_Turb, /*!< \brief Inlet turbulent markers. */ *Marker_Riemann, /*!< \brief Riemann markers. */ *Marker_Giles, /*!< \brief Giles markers. */ @@ -299,7 +296,6 @@ class CConfig { su2double *Inlet_Pressure; /*!< \brief Specified static pressures for supersonic inlet boundaries. */ su2double **Inlet_Velocity; /*!< \brief Specified flow velocity vectors for supersonic inlet boundaries. */ su2double **Inlet_SpeciesVal; /*!< \brief Specified species vector for inlet boundaries. */ - //string **Inlet_CompositionVal; /*!< \brief Specified species vector for inlet boundaries. */ su2double **Inlet_TurbVal; /*!< \brief Specified turbulent intensity and viscosity ratio for inlet boundaries. */ su2double *EngineInflow_Target; /*!< \brief Specified fan face targets for nacelle boundaries. */ su2double *Inflow_Mach; /*!< \brief Specified fan face mach for nacelle boundaries. */ @@ -1376,9 +1372,6 @@ class CConfig { void addInletSpeciesOption(const string& name, unsigned short & nMarker_Inlet_Species, string * & Marker_Inlet_Species, su2double** & inlet_species_val, unsigned short & nSpecies_per_Inlet); - - // void addInletCompositionOption(const string& name, unsigned short & nMarker_Inlet_Composition, string * & Marker_Inlet_Composition, - // string** & inlet_composition_val, unsigned short & nComposition_per_Inlet); void addInletTurbOption(const string& name, unsigned short& nMarker_Inlet_Turb, string*& Marker_Inlet_Turb, su2double** & Turb_Properties, unsigned short & nTurb_Properties); @@ -7035,13 +7028,6 @@ class CConfig { */ const su2double* GetInlet_SpeciesVal(const string& val_index) const; - // /*! - // * \brief Get the composition names at an inlet boundary - // * \param[in] val_index - Index corresponding to the inlet boundary. - // * \return The inlet composition names. - // */ - // const string* GetInlet_CompositionVal(const string& val_index) const; - /*! * \brief Get the turbulent properties values at an inlet boundary * \param[in] val_index - Index corresponding to the inlet boundary. diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index c19808a523c0..05ba6e235206 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -495,16 +495,6 @@ void CConfig::addInletSpeciesOption(const string& name, unsigned short & nMarker option_map.insert(pair(name, val)); } -// void CConfig::addInletCompositionOption(const string& name, unsigned short & nMarker_Inlet_Composition, -// string * & Marker_Inlet_Composition, string** & inlet_composition_val, -// unsigned short & nComposition_per_Inlet) { -// assert(option_map.find(name) == option_map.end()); -// all_options.insert(pair(name, true)); -// COptionBase* val = new COptionStringValuesList(name, nMarker_Inlet_Composition, Marker_Inlet_Composition, -// inlet_composition_val, nComposition_per_Inlet); -// option_map.insert(pair(name, val)); -// } - void CConfig::addInletTurbOption(const string& name, unsigned short& nMarker_Inlet_Turb, string*& Marker_Inlet_Turb, su2double**& Turb_Properties_val, unsigned short& nTurb_Properties) { assert(option_map.find(name) == option_map.end()); @@ -1617,9 +1607,6 @@ void CConfig::SetConfig_Options() { /*!\brief MARKER_INLET_SPECIES \n DESCRIPTION: Inlet Species boundary marker(s) with the following format Inlet Species: (inlet_marker, Species1, Species2, ..., SpeciesN-1, inlet_marker2, Species1, Species2, ...) */ addInletSpeciesOption("MARKER_INLET_SPECIES",nMarker_Inlet_Species, Marker_Inlet_Species, Inlet_SpeciesVal, nSpecies_per_Inlet); - // /*!\brief MARKER_INLET_COMPOSITION \n DESCRIPTION: Inlet Species boundary marker(s) with the following format - // Inlet Species: (inlet_marker, NameSpecies1, NameSpecies2, ..., NameSpeciesN-1, inlet_marker2, NameSpecies1, NameSpecies2, ...) */ - // addInletCompositionOption("MARKER_INLET_COMPOSITION",nMarker_Inlet_Composition, Marker_Inlet_Composition, Inlet_CompositionVal, nComposition_per_Inlet); /*!\brief MARKER_INLET_TURBULENT \n DESCRIPTION: Inlet Turbulence boundary marker(s) with the following format Inlet Turbulent: (inlet_marker, TurbulentIntensity1, ViscosityRatio1, inlet_marker2, TurbulentIntensity2, ViscosityRatio2, ...) */ @@ -7630,15 +7617,6 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) { BoundaryTable.PrintFooter(); } - // if (nMarker_Inlet_Composition != 0) { - // BoundaryTable << "Composition Inlet boundary"; - // for (iMarker_Inlet = 0; iMarker_Inlet < nMarker_Inlet_Composition; iMarker_Inlet++) { - // BoundaryTable << Marker_Inlet_Composition[iMarker_Inlet]; - // if (iMarker_Inlet < nMarker_Inlet_Composition-1) BoundaryTable << " "; - // } - // BoundaryTable.PrintFooter(); - // } - if (nMarker_Riemann != 0) { BoundaryTable << "Riemann boundary"; for (iMarker_Riemann = 0; iMarker_Riemann < nMarker_Riemann; iMarker_Riemann++) { @@ -9199,13 +9177,6 @@ const su2double* CConfig::GetInlet_SpeciesVal(const string& val_marker) const { return Inlet_SpeciesVal[iMarker_Inlet_Species]; } -// const string* CConfig::GetInlet_CompositionVal(const string& val_marker) const { -// unsigned short iMarker_Inlet_Composition; -// for (iMarker_Inlet_Composition = 0; iMarker_Inlet_Composition < nMarker_Inlet_Composition; iMarker_Inlet_Composition++) -// if (Marker_Inlet_Composition[iMarker_Inlet_Composition] == val_marker) break; -// return Inlet_CompositionVal[iMarker_Inlet_Composition]; -// } - const su2double* CConfig::GetInlet_TurbVal(const string& val_marker) const { /*--- If Turbulent Inlet is not provided for the marker, return free stream values. ---*/ for (auto iMarker = 0u; iMarker < nMarker_Inlet_Turb; iMarker++) { diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 5e8555798170..183341de5163 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1557,7 +1557,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_iter = 50 - species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.287504, -4.852957, -4.798004, -7.501815, 1.991002, -5.023713, 10.000000, -2.696121, 3.000000, -5.182457, 5.000000, -5.561055, 2.078843, 1.000000, 0.600000, 0.478843] + species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.291034, -4.770419, -4.743257, -7.365441, 1.709269, -5.067282, 10.000000, -2.860653, 4.000000, -5.134413, 5.000000, -5.474359, 2.093031, 1.000000, 0.600000, 0.493031] test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND) # 2 species (1 eq) primitive venturi mixing From 165a9ad43f0bda44d0ee725b8b7429bb9275e6d9 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 4 Mar 2025 13:31:26 +0100 Subject: [PATCH 077/173] fix parallel_regression.py --- TestCases/parallel_regression.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 45c6752016a0..353eeef35fe7 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1525,11 +1525,7 @@ def main(): species2_primitiveVenturi_mixingmodel.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel.cfg_file = "species2_primitiveVenturi_mixingmodel.cfg" species2_primitiveVenturi_mixingmodel.test_iter = 50 -<<<<<<< HEAD species2_primitiveVenturi_mixingmodel.test_vals = [ -5.406062, -4.556225, -4.633753, -5.644242, -0.058437, -5.545635, 5.000000, -1.881888, 5.000000, -4.900700, 5.000000, -1.169412, 0.000559, 0.000492, 0.000067, 0.000000] -======= - species2_primitiveVenturi_mixingmodel.test_vals = [-5.433571, -4.507202, -4.599966, -5.856697, -0.076061, -5.608935, 5.000000, -1.897907, 5.000000, -4.894972, 5.000000, -1.202673, 0.000538, 0.000476, 0.000062, 0.000000] ->>>>>>> develop test_list.append(species2_primitiveVenturi_mixingmodel) # 2 species (1 eq) primitive venturi mixing using mixing model and bounded scalar transport @@ -1537,11 +1533,7 @@ def main(): species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_file = "species2_primitiveVenturi_mixingmodel_boundedscalar.cfg" species2_primitiveVenturi_mixingmodel_boundedscalar.test_iter = 50 -<<<<<<< HEAD species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.390872, -4.491249, -4.575176, -5.760619, -0.137842, -5.677153, 5.000000, -1.896522, 5.000000, -4.806007, 5.000000, -1.697287, 0.000275, 0.000275, 0.000000, 0.000000] -======= - species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.397959, -4.441556, -4.532005, -6.118886, -0.129272, -5.681345, 5.000000, -1.986039, 5.000000, -4.961054, 5.000000, -1.880403, 0.000297, 0.000297, 0.000000, 0.000000] ->>>>>>> develop test_list.append(species2_primitiveVenturi_mixingmodel_boundedscalar) # 2 species (1 eq) primitive venturi mixing using mixing model including viscosity, thermal conductivity and inlet markers for SA turbulence model @@ -1557,11 +1549,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_iter = 50 -<<<<<<< HEAD species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_vals = [-5.705589, -4.493347, -4.464137, -6.399752, 2.021703, -5.466399, 30.000000, -7.430567, 13.000000, -8.018769, 8.000000, -8.506180, 2.092565, 1.000000, 0.600000, 0.492565] -======= - species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_vals = [-5.704159, -4.581981, -4.519914, -6.960130, 2.304741, -5.429054, 30.000000, -6.864204, 12.000000, -8.228958, 8.000000, -9.215808, 2.079379, 1.000000, 0.600000, 0.479379] ->>>>>>> develop test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2) # 2 species (1 eq) primitive venturi mixing using mixing model including heat capacity and mass diffusivity NonDimensional case @@ -1569,11 +1557,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_iter = 50 -<<<<<<< HEAD species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.291034, -4.770419, -4.743257, -7.365441, 1.709269, -5.067282, 10.000000, -2.860653, 4.000000, -5.134413, 5.000000, -5.474359, 2.093031, 1.000000, 0.600000, 0.493031] -======= - species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.304586, -4.884409, -4.811332, -7.928962, 1.999898, -5.034484, 10.000000, -2.603534, 3.000000, -5.374631, 5.000000, -5.612314, 2.079522, 1.000000, 0.600000, 0.479522] ->>>>>>> develop test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND) # 2 species (1 eq) primitive venturi mixing From eabaabf6d29abed5bed156ad464436ab9d7fbf0f Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 4 Mar 2025 15:25:00 +0100 Subject: [PATCH 078/173] updating regression test cases --- TestCases/parallel_regression.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 353eeef35fe7..f94a64d9f8cb 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1525,7 +1525,7 @@ def main(): species2_primitiveVenturi_mixingmodel.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel.cfg_file = "species2_primitiveVenturi_mixingmodel.cfg" species2_primitiveVenturi_mixingmodel.test_iter = 50 - species2_primitiveVenturi_mixingmodel.test_vals = [ -5.406062, -4.556225, -4.633753, -5.644242, -0.058437, -5.545635, 5.000000, -1.881888, 5.000000, -4.900700, 5.000000, -1.169412, 0.000559, 0.000492, 0.000067, 0.000000] + species2_primitiveVenturi_mixingmodel.test_vals = [ -5.432322, -4.506693, -4.598961, -5.858079, -0.074848, -5.608093, 5.000000, -1.900665, 5.000000, -4.895929, 5.000000, -1.202887, 0.000544, 0.000484, 0.000060, 0.000000] test_list.append(species2_primitiveVenturi_mixingmodel) # 2 species (1 eq) primitive venturi mixing using mixing model and bounded scalar transport @@ -1533,7 +1533,7 @@ def main(): species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_file = "species2_primitiveVenturi_mixingmodel_boundedscalar.cfg" species2_primitiveVenturi_mixingmodel_boundedscalar.test_iter = 50 - species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.390872, -4.491249, -4.575176, -5.760619, -0.137842, -5.677153, 5.000000, -1.896522, 5.000000, -4.806007, 5.000000, -1.697287, 0.000275, 0.000275, 0.000000, 0.000000] + species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.396930, -4.441229, -4.531561, -6.119468, -0.129257, -5.681246, 5.000000, -1.986168, 5.000000, -4.959587, 5.000000, -1.880063, 0.000297, 0.000297, 0.000000, 0.000000] test_list.append(species2_primitiveVenturi_mixingmodel_boundedscalar) # 2 species (1 eq) primitive venturi mixing using mixing model including viscosity, thermal conductivity and inlet markers for SA turbulence model @@ -1549,7 +1549,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_iter = 50 - species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_vals = [-5.705589, -4.493347, -4.464137, -6.399752, 2.021703, -5.466399, 30.000000, -7.430567, 13.000000, -8.018769, 8.000000, -8.506180, 2.092565, 1.000000, 0.600000, 0.492565] + species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_vals = [-5.683102, -4.564193, -4.448313, -6.737904, 2.044729, -5.467878, 30.000000, -7.621295, 12.000000, -8.052264, 8.000000, -8.963883, 2.092215, 1.000000, 0.600000, 0.492215] test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2) # 2 species (1 eq) primitive venturi mixing using mixing model including heat capacity and mass diffusivity NonDimensional case @@ -1557,7 +1557,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_iter = 50 - species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.291034, -4.770419, -4.743257, -7.365441, 1.709269, -5.067282, 10.000000, -2.860653, 4.000000, -5.134413, 5.000000, -5.474359, 2.093031, 1.000000, 0.600000, 0.493031] + species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.273052, -4.863236, -4.734578, -7.722857, 1.740741, -5.073467, 10.000000, -2.926106, 3.000000, -5.186545, 5.000000, -5.929953, 2.092322, 1.000000, 0.600000, 0.492322] test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND) # 2 species (1 eq) primitive venturi mixing From ea01b352a10126c68f14f925edf7a817bfa5b84e Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 4 Mar 2025 16:59:04 +0100 Subject: [PATCH 079/173] updating to preconditioning --- .../include/geometry/CMultiGridGeometry.hpp | 2 +- Common/include/geometry/CPhysicalGeometry.hpp | 2 +- Common/include/geometry/dual_grid/CVertex.hpp | 43 +++++---- Common/src/geometry/CGeometry.cpp | 92 ++++++++++++++---- .../include/solvers/CFVMFlowSolverBase.inl | 10 +- SU2_CFD/include/solvers/CTurbSSTSolver.hpp | 2 - SU2_CFD/include/variables/CFlowVariable.hpp | 2 +- SU2_CFD/src/drivers/CDriver.cpp | 4 +- SU2_CFD/src/solvers/CIncNSSolver.cpp | 6 +- SU2_CFD/src/solvers/CNSSolver.cpp | 6 +- SU2_CFD/src/solvers/CTurbSASolver.cpp | 4 +- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 61 ++++++------ .../optim.csv.ref | 2 +- TestCases/hybrid_regression.py | 42 ++++----- TestCases/hybrid_regression_AD.py | 4 +- .../chtPinArray_2d/of_grad_findiff.csv.ref | 2 +- TestCases/parallel_regression.py | 94 +++++++++---------- TestCases/parallel_regression_AD.py | 14 +-- TestCases/serial_regression.py | 60 ++++++------ TestCases/serial_regression_AD.py | 2 +- TestCases/tutorials.py | 16 ++-- TestCases/vandv.py | 12 +-- TestCases/vandv/rans/swbli/config_sst.cfg | 16 ++-- 23 files changed, 274 insertions(+), 224 deletions(-) diff --git a/Common/include/geometry/CMultiGridGeometry.hpp b/Common/include/geometry/CMultiGridGeometry.hpp index c3e897f7f311..09a3ca06d905 100644 --- a/Common/include/geometry/CMultiGridGeometry.hpp +++ b/Common/include/geometry/CMultiGridGeometry.hpp @@ -123,7 +123,7 @@ class CMultiGridGeometry final : public CGeometry { void SetRestricted_GridVelocity(const CGeometry* fine_grid) override; /*! - * \brief Find and store the closest neighbor to a vertex. + * \brief Find and store the closest, most normal, neighbor to a vertex. * \param[in] config - Definition of the particular problem. */ void FindNormal_Neighbor(const CConfig* config) override; diff --git a/Common/include/geometry/CPhysicalGeometry.hpp b/Common/include/geometry/CPhysicalGeometry.hpp index 7257f546d40b..406b4c49c2c9 100644 --- a/Common/include/geometry/CPhysicalGeometry.hpp +++ b/Common/include/geometry/CPhysicalGeometry.hpp @@ -607,7 +607,7 @@ class CPhysicalGeometry final : public CGeometry { void ComputeMeshQualityStatistics(const CConfig* config) override; /*! - * \brief Find and store the closest neighbor to a vertex. + * \brief Find and store the closest, most normal, neighbor to a vertex. * \param[in] config - Definition of the particular problem. */ void FindNormal_Neighbor(const CConfig* config) override; diff --git a/Common/include/geometry/dual_grid/CVertex.hpp b/Common/include/geometry/dual_grid/CVertex.hpp index 56c195c6e3fe..518a85b6ff65 100644 --- a/Common/include/geometry/dual_grid/CVertex.hpp +++ b/Common/include/geometry/dual_grid/CVertex.hpp @@ -45,7 +45,8 @@ class CVertex : public CDualGrid { long PeriodicPoint[5] = {-1}; /*!< \brief Store the periodic point of a boundary (iProcessor, iPoint) */ bool ActDisk_Perimeter = false; /*!< \brief Identify nodes at the perimeter of the actuator disk */ short Rotation_Type; /*!< \brief Type of rotation associated with the vertex (MPI and periodic) */ - unsigned long Normal_Neighbor; /*!< \brief Index of the closest neighbor. */ + unsigned long Normal_Neighbor; /*!< \brief Index of the closest, most normal, neighbor. */ + su2double NearestNeighborDist = 0.0; /*!< \brief Distance to nearest internal neighbor that is not a wall. */ su2double Basis_Function[3] = {0.0}; /*!< \brief Basis function values for interpolation across zones. */ public: @@ -98,7 +99,7 @@ class CVertex : public CDualGrid { * \brief Get the normal to a face of the control volume asociated with a vertex. * \return Dimensional normal vector, the modulus is the area of the face. */ - inline su2double* GetNormal(void) override { return Normal; } + inline su2double* GetNormal() override { return Normal; } /*! * \brief Get the ith component of the normal. @@ -108,7 +109,7 @@ class CVertex : public CDualGrid { /*! * \brief Initialize normal vector. */ - inline void SetZeroValues(void) override { + inline void SetZeroValues() override { for (unsigned short iDim = 0; iDim < nDim; iDim++) Normal[iDim] = 0.0; } @@ -122,7 +123,7 @@ class CVertex : public CDualGrid { * \brief Get the value of an auxiliary variable for gradient computation. * \return Value of the auxiliar variable. */ - inline su2double GetAuxVar(void) const { return Aux_Var; } + inline su2double GetAuxVar() const { return Aux_Var; } /*! * \brief Add the value of an auxiliary variable for gradient computation. @@ -167,7 +168,7 @@ class CVertex : public CDualGrid { * \brief Get the value of the coordinate variation due to a surface modification. * \return Variation of the coordinate. */ - inline su2double* GetVarCoord(void) { return VarCoord; } + inline su2double* GetVarCoord() { return VarCoord; } /*! * \brief Set the value of the cartesian coordinate for the vertex. @@ -181,7 +182,7 @@ class CVertex : public CDualGrid { * \brief Get the value of the cartesian coordinate for the vertex. * \return Value of the cartesian coordinate of the vertex. */ - inline su2double* GetCoord(void) override { return CartCoord; } + inline su2double* GetCoord() override { return CartCoord; } /*! * \brief Get the value of the cartesian coordinate for the vertex. @@ -200,7 +201,7 @@ class CVertex : public CDualGrid { * \brief Get the type of rotation associated to the vertex. * \return Value of the rotation that must be applied to the solution of the vertex */ - inline short GetRotation_Type(void) const { return Rotation_Type; } + inline short GetRotation_Type() const { return Rotation_Type; } /*! * \overload @@ -250,49 +251,49 @@ class CVertex : public CDualGrid { * \brief Get the value of the periodic point of a vertex. * \return Value of the periodic point of a vertex. */ - inline long GetDonorPoint(void) const { return PeriodicPoint[0]; } + inline long GetDonorPoint() const { return PeriodicPoint[0]; } /*! * \brief Get the value of the periodic point of a vertex. * \return Value of the periodic point of a vertex. */ - inline long GetDonorMarker(void) const { return PeriodicPoint[4]; } + inline long GetDonorMarker() const { return PeriodicPoint[4]; } /*! * \brief Get the value of the periodic point of a vertex. * \return Value of the periodic point of a vertex. */ - inline long GetDonorVertex(void) const { return PeriodicPoint[3]; } + inline long GetDonorVertex() const { return PeriodicPoint[3]; } /*! * \brief Get the value of the periodic point of a vertex. * \return Value of the periodic point of a vertex. */ - inline long GetDonorGlobalIndex(void) const { return PeriodicPoint[2]; } + inline long GetDonorGlobalIndex() const { return PeriodicPoint[2]; } /*! * \brief Get the value of the periodic point of a vertex. * \return Value of the periodic point of a vertex. */ - inline long GetGlobalDonorPoint(void) const { return PeriodicPoint[2]; } + inline long GetGlobalDonorPoint() const { return PeriodicPoint[2]; } /*! * \brief Get the value of the periodic point of a vertex. * \return Value of the periodic point of a vertex. */ - inline long GetDonorProcessor(void) const { return PeriodicPoint[1]; } + inline long GetDonorProcessor() const { return PeriodicPoint[1]; } /*! * \brief Get the value of the periodic point of a vertex, and its somain * \return Value of the periodic point of a vertex, and the domain. */ - inline long* GetPeriodicPointDomain(void) { return PeriodicPoint; } + inline long* GetPeriodicPointDomain() { return PeriodicPoint; } /*! * \brief Get the value of the periodic point of a vertex, and its somain * \return Value of the periodic point of a vertex, and the domain. */ - inline bool GetActDisk_Perimeter(void) const { return ActDisk_Perimeter; } + inline bool GetActDisk_Perimeter() const { return ActDisk_Perimeter; } /*! * \brief Set the finite element basis functions needed for interpolation. @@ -318,5 +319,15 @@ class CVertex : public CDualGrid { * \brief Get the value of the closest neighbor. * \return Index of the closest neighbor. */ - inline unsigned long GetNormal_Neighbor(void) const { return Normal_Neighbor; } + inline unsigned long GetNormal_Neighbor() const { return Normal_Neighbor; } + + /*! + * \brief Set the distance of the nearest internal neighbor that is not a wall. + */ + inline void SetNearestNeighborDistance(const su2double& val) { NearestNeighborDist = val; } + + /*! + * \brief Get the distance to the nearest internal neighbor that is not a wall. + */ + inline const su2double& GetNearestNeighborDistance() const { return NearestNeighborDist; } }; diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index e771960b6386..1301ee6b5a39 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3902,6 +3902,36 @@ const CGeometry::CLineletInfo& CGeometry::GetLineletInfo(const CConfig* config) return li; } +namespace { +su2double NearestNeighborDistance(CGeometry* geometry, const CConfig* config, const unsigned long iPoint) { + const su2double max = std::numeric_limits::max(); + su2double distance = max; + for (const auto jPoint : geometry->nodes->GetPoints(iPoint)) { + const su2double dist = geometry->nodes->GetWall_Distance(jPoint); + if (dist > EPS) distance = fmin(distance, dist); + } + if (distance > 0 && distance < max) return distance; + + /*--- The point only has wall neighbors, which all have 0 wall distance. + * Compute an alternative distance based on volume and wall area. ---*/ + + const auto nDim = geometry->GetnDim(); + su2double Normal[3] = {}; + for (auto iMarker = 0u; iMarker < config->GetnMarker_All(); iMarker++) { + if (!config->GetViscous_Wall(iMarker)) continue; + + const auto iVertex = geometry->nodes->GetVertex(iPoint, iMarker); + if (iVertex < 0) continue; + + for (auto iDim = 0u; iDim < nDim; iDim++) { + Normal[iDim] += geometry->vertex[iMarker][iVertex]->GetNormal(iDim); + } + } + const su2double Vol = geometry->nodes->GetVolume(iPoint) + geometry->nodes->GetPeriodicVolume(iPoint); + return 2 * Vol / GeometryToolbox::Norm(nDim, Normal); +} +} // namespace + void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeometry**** geometry_container) { int nZone = config_container[ZONE_0]->GetnZone(); bool allEmpty = true; @@ -3946,27 +3976,53 @@ void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeo CGeometry* geometry = geometry_container[iZone][iInst][MESH_0]; geometry->SetWallDistance(0.0); } + continue; } - /*--- Otherwise, set wall roughnesses. ---*/ - if (!allEmpty) { - /*--- Store all wall roughnesses in a common data structure. ---*/ - // [iZone][iMarker] -> roughness, for this rank - auto roughness_f = make_pair(nZone, [config_container, geometry_container, iInst](unsigned long iZone) { - const CConfig* config = config_container[iZone]; - const auto nMarker = geometry_container[iZone][iInst][MESH_0]->GetnMarker(); - - return make_pair(nMarker, [config](unsigned long iMarker) { - return config->GetWallRoughnessProperties(config->GetMarker_All_TagBound(iMarker)).second; - }); + + /*--- Otherwise, set wall roughnesses, storing them in a common data structure. ---*/ + // [iZone][iMarker] -> roughness, for this rank + auto roughness_f = make_pair(nZone, [config_container, geometry_container, iInst](unsigned long iZone) { + const CConfig* config = config_container[iZone]; + const auto nMarker = geometry_container[iZone][iInst][MESH_0]->GetnMarker(); + + return make_pair(nMarker, [config](unsigned long iMarker) { + return config->GetWallRoughnessProperties(config->GetMarker_All_TagBound(iMarker)).second; }); - NdFlattener<2> roughness_local(roughness_f); - // [rank][iZone][iMarker] -> roughness - NdFlattener<3> roughness_global(Nd_MPI_Environment(), roughness_local); - // use it to update roughnesses - for (int jZone = 0; jZone < nZone; jZone++) { - if (wallDistanceNeeded[jZone] && config_container[jZone]->GetnRoughWall() > 0) { - geometry_container[jZone][iInst][MESH_0]->nodes->SetWallRoughness(roughness_global); + }); + NdFlattener<2> roughness_local(roughness_f); + // [rank][iZone][iMarker] -> roughness + NdFlattener<3> roughness_global(Nd_MPI_Environment(), roughness_local); + // use it to update roughnesses + for (int jZone = 0; jZone < nZone; jZone++) { + if (wallDistanceNeeded[jZone] && config_container[jZone]->GetnRoughWall() > 0) { + geometry_container[jZone][iInst][MESH_0]->nodes->SetWallRoughness(roughness_global); + } + } + + for (int iZone = 0; iZone < nZone; iZone++) { + /*--- For the FEM solver, we use a different mesh structure ---*/ + MAIN_SOLVER kindSolver = config_container[iZone]->GetKind_Solver(); + if (!wallDistanceNeeded[iZone] || kindSolver == MAIN_SOLVER::FEM_LES || kindSolver == MAIN_SOLVER::FEM_RANS) { + continue; + } + const auto* config = config_container[iZone]; + auto* geometry = geometry_container[iZone][iInst][MESH_0]; + + for (unsigned short iMarker = 0; iMarker < config->GetnMarker_All(); ++iMarker) { + const auto viscous = config->GetViscous_Wall(iMarker); + + SU2_OMP_FOR_STAT(OMP_MIN_SIZE) + for (auto iVertex = 0u; iVertex < geometry->nVertex[iMarker]; iVertex++) { + const auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); + su2double dist = 0; + if (viscous && geometry->nodes->GetDomain(iPoint)) { + dist = NearestNeighborDistance(geometry, config, iPoint); + } else { + dist = geometry->nodes->GetWall_Distance(iPoint); + } + geometry->vertex[iMarker][iVertex]->SetNearestNeighborDistance(dist); } + END_SU2_OMP_FOR } } } diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index d7a634e82271..8a99712dc8e0 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -2350,7 +2350,7 @@ void CFVMFlowSolverBase::Friction_Forces(const CGeometry* geometr unsigned long iVertex, iPoint, iPointNormal; unsigned short iMarker, iMarker_Monitoring, iDim, jDim; - su2double Viscosity = 0.0, Area, Density = 0.0, WallDistMod, FrictionVel, + su2double Viscosity = 0.0, Area, Density = 0.0, FrictionVel, UnitNormal[3] = {0.0}, TauElem[3] = {0.0}, Tau[3][3] = {{0.0}}, Cp, thermal_conductivity, MaxNorm = 8.0, Grad_Vel[3][3] = {{0.0}}, Grad_Temp[3] = {0.0}, Grad_Temp_ve[3] = {0.0}, AxiFactor; @@ -2497,11 +2497,9 @@ void CFVMFlowSolverBase::Friction_Forces(const CGeometry* geometr FrictionVel = sqrt(fabs(WallShearStress[iMarker][iVertex]) / Density); - if (!wallfunctions && (MGLevel == MESH_0 || geometry->nodes->GetDomain(iPoint))) { - // for CMultiGridGeometry, the normal neighbor of halo nodes in not set - iPointNormal = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor(); - Coord_Normal = geometry->nodes->GetCoord(iPointNormal); - WallDistMod = GeometryToolbox::Distance(nDim, Coord, Coord_Normal); + if (!wallfunctions && MGLevel == MESH_0 && geometry->nodes->GetDomain(iPoint)) { + // for CMultiGridGeometry and halos, the nearest neighbor distance is not set + const su2double WallDistMod = geometry->vertex[iMarker][iVertex]->GetNearestNeighborDistance(); YPlus[iMarker][iVertex] = WallDistMod * FrictionVel / (Viscosity / Density); } diff --git a/SU2_CFD/include/solvers/CTurbSSTSolver.hpp b/SU2_CFD/include/solvers/CTurbSSTSolver.hpp index 78aa77200950..0db8bf164b63 100644 --- a/SU2_CFD/include/solvers/CTurbSSTSolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSSTSolver.hpp @@ -53,7 +53,6 @@ class CTurbSSTSolver final : public CTurbSolver { CSolver **solver_container, const CConfig *config, unsigned short val_marker); - public: /*! * \brief Constructor. @@ -302,5 +301,4 @@ class CTurbSSTSolver final : public CTurbSolver { */ inline su2double GetOmega_Inf(void) const override { return Solution_Inf[1]; } - }; diff --git a/SU2_CFD/include/variables/CFlowVariable.hpp b/SU2_CFD/include/variables/CFlowVariable.hpp index 95d59c083ad3..d4d770f0ba8d 100644 --- a/SU2_CFD/include/variables/CFlowVariable.hpp +++ b/SU2_CFD/include/variables/CFlowVariable.hpp @@ -260,7 +260,7 @@ class CFlowVariable : public CVariable { * \param[in] iPoint - Point index. * \return Value of magnitude. */ - inline su2double GetStrainMag(unsigned long iPoint) const final { return StrainMag(iPoint); } + inline su2double GetStrainMag(unsigned long iPoint) const { return StrainMag(iPoint); } /*! * \brief Get the entire vector of the rate of strain magnitude. diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index c3d00cac72a6..259494731119 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -833,7 +833,7 @@ void CDriver::InitializeGeometryFVM(CConfig *config, CGeometry **&geometry) { geometry[iMGlevel]->SetBoundControlVolume(geometry[iMGlevel-1], config, ALLOCATE); geometry[iMGlevel]->SetCoord(geometry[iMGlevel-1]); - /*--- Find closest neighbor to a surface point ---*/ + /*--- Find closest, most normal, neighbor to a surface point ---*/ geometry[iMGlevel]->FindNormal_Neighbor(config); @@ -2521,7 +2521,7 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet else interface_type = NO_TRANSFER; } - + if (interface_type != NO_TRANSFER) { auto nVar = 4; interface[donor][target] = new CConjugateHeatInterface(nVar, 0); diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index fc28905d55d8..e3c3943f2977 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -850,11 +850,7 @@ void CIncNSSolver::SetTau_Wall_WF(CGeometry *geometry, CSolver **solver_containe const su2double VelTangMod = GeometryToolbox::Norm(int(MAXNDIM), VelTang); /*--- Compute normal distance of the interior point from the wall ---*/ - - su2double WallDist[MAXNDIM] = {0.0}; - GeometryToolbox::Distance(nDim, Coord, Coord_Normal, WallDist); - - su2double WallDistMod = GeometryToolbox::Norm(int(MAXNDIM), WallDist); + const su2double WallDistMod = GeometryToolbox::Distance(nDim, Coord, Coord_Normal); su2double Density_Wall = nodes->GetDensity(iPoint); diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index 50f243c7f0cf..fef4a352b2a7 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -864,11 +864,7 @@ void CNSSolver::SetTau_Wall_WF(CGeometry *geometry, CSolver **solver_container, const su2double VelTangMod = GeometryToolbox::Norm(int(MAXNDIM), VelTang); /*--- Compute normal distance of the interior point from the wall ---*/ - - su2double WallDist[MAXNDIM] = {0.0}; - GeometryToolbox::Distance(nDim, Coord, Coord_Normal, WallDist); - - const su2double WallDistMod = GeometryToolbox::Norm(int(MAXNDIM), WallDist); + const su2double WallDistMod = GeometryToolbox::Distance(nDim, Coord, Coord_Normal); su2double T_Wall = nodes->GetTemperature(iPoint); const su2double Conductivity_Wall = nodes->GetThermalConductivity(iPoint); diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index 7d9999d965f0..b66eedd4d99a 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -309,7 +309,7 @@ void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_contai CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { bool axisymmetric = config->GetAxisymmetric(); - + const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool harmonic_balance = (config->GetTime_Marching() == TIME_MARCHING::HARMONIC_BALANCE); const bool transition_BC = config->GetSAParsedOptions().bc; @@ -389,7 +389,7 @@ void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_contai /*--- Set y coordinate ---*/ numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(iPoint)); } - + /*--- Compute the source term ---*/ auto residual = numerics->ComputeResidual(config); diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 02b91c8ab2cf..0e3d1bf5ecfd 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -230,7 +230,7 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai const su2double dist = geometry->nodes->GetWall_Distance(iPoint); const su2double VorticityMag = max(GeometryToolbox::Norm(3, flowNodes->GetVorticity(iPoint)), 1e-12); - const su2double StrainMag = max(nodes->GetStrainMag(iPoint), 1e-12); + const su2double StrainMag = max(flowNodes->GetStrainMag(iPoint), 1e-12); nodes->SetBlendingFunc(iPoint, mu, dist, rho, config->GetKind_Trans_Model()); const su2double F2 = nodes->GetF2blending(iPoint); @@ -251,37 +251,37 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai /*--- Compute turbulence index ---*/ if (config->GetKind_Trans_Model() != TURB_TRANS_MODEL::NONE) { - for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) - if (config->GetViscous_Wall(iMarker)) { - SU2_OMP_FOR_STAT(OMP_MIN_SIZE) - for (auto iVertex = 0u; iVertex < geometry->nVertex[iMarker]; iVertex++) { - const auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); + for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { + if (!config->GetViscous_Wall(iMarker)) continue; - /*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/ + SU2_OMP_FOR_STAT(OMP_MIN_SIZE) + for (auto iVertex = 0u; iVertex < geometry->nVertex[iMarker]; iVertex++) { + const auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - if (geometry->nodes->GetDomain(iPoint)) { - const auto jPoint = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor(); + /*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/ - su2double shearStress = 0.0; - for(auto iDim = 0u; iDim < nDim; iDim++) { - shearStress += pow(solver_container[FLOW_SOL]->GetCSkinFriction(iMarker, iVertex, iDim), 2.0); - } - shearStress = sqrt(shearStress); + if (!geometry->nodes->GetDomain(iPoint)) continue; - const su2double FrictionVelocity = sqrt(shearStress/flowNodes->GetDensity(iPoint)); - const su2double wall_dist = geometry->nodes->GetWall_Distance(jPoint); - const su2double Derivative = flowNodes->GetLaminarViscosity(jPoint) * pow(nodes->GetSolution(jPoint, 0), 0.673) / wall_dist; - const su2double turbulence_index = 6.1 * Derivative / pow(FrictionVelocity, 2.346); + const auto jPoint = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor(); - nodes->SetTurbIndex(iPoint, turbulence_index); - - } + su2double shearStress = 0.0; + for(auto iDim = 0u; iDim < nDim; iDim++) { + shearStress += pow(solver_container[FLOW_SOL]->GetCSkinFriction(iMarker, iVertex, iDim), 2.0); } - END_SU2_OMP_FOR + shearStress = sqrt(shearStress); + + const su2double FrictionVelocity = sqrt(shearStress/flowNodes->GetDensity(iPoint)); + const su2double wall_dist = geometry->vertex[iMarker][iVertex]->GetNearestNeighborDistance(); + + const su2double Derivative = flowNodes->GetLaminarViscosity(jPoint) * pow(nodes->GetSolution(jPoint, 0), 0.673) / wall_dist; + const su2double turbulence_index = 6.1 * Derivative / pow(FrictionVelocity, 2.346); + + nodes->SetTurbIndex(iPoint, turbulence_index); } + END_SU2_OMP_FOR + } } - AD::EndNoSharedReading(); } @@ -459,20 +459,16 @@ void CTurbSSTSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont } else { // smooth wall /*--- distance to closest neighbor ---*/ - const auto jPoint = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); + su2double wall_dist = geometry->vertex[val_marker][iVertex]->GetNearestNeighborDistance(); - su2double distance2 = GeometryToolbox::SquaredDistance(nDim, - geometry->nodes->GetCoord(iPoint), - geometry->nodes->GetCoord(jPoint)); /*--- Set wall values ---*/ - - su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(jPoint); - su2double laminar_viscosity = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(jPoint); + su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + su2double laminar_viscosity = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); su2double beta_1 = constants[4]; su2double solution[MAXNVAR]; solution[0] = 0.0; - solution[1] = 60.0*laminar_viscosity/(density*beta_1*distance2); + solution[1] = 60.0*laminar_viscosity/(density*beta_1*pow(wall_dist,2)); /*--- Set the solution values and zero the residual ---*/ nodes->SetSolution_Old(iPoint,solution); @@ -1012,8 +1008,7 @@ su2double CTurbSSTSolver::GetInletAtVertex(unsigned short iMarker, unsigned long su2double Normal[MAXNDIM] = {0.0}; geometry->vertex[iMarker][iVertex]->GetNormal(Normal); - return GeometryToolbox::Norm(nDim, Normal); -} + return GeometryToolbox::Norm(nDim, Normal);} void CTurbSSTSolver::SetUniformInlet(const CConfig* config, unsigned short iMarker) { if (config->GetMarker_All_KindBC(iMarker) == INLET_FLOW) { diff --git a/TestCases/Tutorials/design/Inc_Turbulent_Bend_Wallfunctions/optim.csv.ref b/TestCases/Tutorials/design/Inc_Turbulent_Bend_Wallfunctions/optim.csv.ref index 2f0fb6fc2974..fb3d04a9bb49 100644 --- a/TestCases/Tutorials/design/Inc_Turbulent_Bend_Wallfunctions/optim.csv.ref +++ b/TestCases/Tutorials/design/Inc_Turbulent_Bend_Wallfunctions/optim.csv.ref @@ -1,2 +1,2 @@ ITER, avg_dp -1, 89.03358290403737 +1, 63.82289754521027 diff --git a/TestCases/hybrid_regression.py b/TestCases/hybrid_regression.py index da3af4f5c9dc..318ba0bdf2f2 100644 --- a/TestCases/hybrid_regression.py +++ b/TestCases/hybrid_regression.py @@ -165,7 +165,7 @@ def main(): rae2822_sst.cfg_dir = "rans/rae2822" rae2822_sst.cfg_file = "turb_SST_RAE2822.cfg" rae2822_sst.test_iter = 20 - rae2822_sst.test_vals = [-0.510363, 4.872736, 0.815617, 0.060920, 0] + rae2822_sst.test_vals = [-0.510371, 4.905635, 0.811981, 0.061600, 0.000000] test_list.append(rae2822_sst) # RAE2822 SST_SUST @@ -173,7 +173,7 @@ def main(): rae2822_sst_sust.cfg_dir = "rans/rae2822" rae2822_sst_sust.cfg_file = "turb_SST_SUST_RAE2822.cfg" rae2822_sst_sust.test_iter = 20 - rae2822_sst_sust.test_vals = [-2.535141, 4.872736, 0.815617, 0.060920] + rae2822_sst_sust.test_vals = [-2.569447, 4.905635, 0.811980, 0.061600] test_list.append(rae2822_sst_sust) # Flat plate @@ -206,7 +206,7 @@ def main(): turb_naca0012_sst.cfg_dir = "rans/naca0012" turb_naca0012_sst.cfg_file = "turb_NACA0012_sst.cfg" turb_naca0012_sst.test_iter = 10 - turb_naca0012_sst.test_vals = [-12.105781, -15.277738, -6.210248, 1.049757, 0.019249, -2.807857, 0] + turb_naca0012_sst.test_vals = [-12.232701, -14.434762, -6.411172, 1.047444, 0.019214, -1.652128, 0] test_list.append(turb_naca0012_sst) # NACA0012 (SST_SUST, FUN3D finest grid results: CL=1.0840, CD=0.01253) @@ -214,7 +214,7 @@ def main(): turb_naca0012_sst_sust.cfg_dir = "rans/naca0012" turb_naca0012_sst_sust.cfg_file = "turb_NACA0012_sst_sust.cfg" turb_naca0012_sst_sust.test_iter = 10 - turb_naca0012_sst_sust.test_vals = [-12.082157, -14.827303, -6.061342, 1.000276, 0.019495, -1.762311] + turb_naca0012_sst_sust.test_vals = [-12.152274, -14.781420, -6.725224, 1.000270, 0.019123, -1.417716] test_list.append(turb_naca0012_sst_sust) # NACA0012 (SST, fixed values for turbulence quantities) @@ -222,7 +222,7 @@ def main(): turb_naca0012_sst_fixedvalues.cfg_dir = "rans/naca0012" turb_naca0012_sst_fixedvalues.cfg_file = "turb_NACA0012_sst_fixedvalues.cfg" turb_naca0012_sst_fixedvalues.test_iter = 10 - turb_naca0012_sst_fixedvalues.test_vals = [-5.192504, -10.035367, -1.617698, 1.022029, 0.040310, -2.381926] + turb_naca0012_sst_fixedvalues.test_vals = [-5.192403, -10.256922, -1.568131, 1.022561, 0.040530, -2.382766] test_list.append(turb_naca0012_sst_fixedvalues) # NACA0012 (SST, explicit Euler for flow and turbulence equations) @@ -230,7 +230,7 @@ def main(): turb_naca0012_sst_expliciteuler.cfg_dir = "rans/naca0012" turb_naca0012_sst_expliciteuler.cfg_file = "turb_NACA0012_sst_expliciteuler.cfg" turb_naca0012_sst_expliciteuler.test_iter = 10 - turb_naca0012_sst_expliciteuler.test_vals = [-3.533827, -3.157766, 3.364024, 1.122856, 0.500771, -float("inf")] + turb_naca0012_sst_expliciteuler.test_vals = [-3.533765, -3.157766, 3.364026, 1.124760, 0.501702, -float("inf")] test_list.append(turb_naca0012_sst_expliciteuler) # PROPELLER @@ -250,7 +250,7 @@ def main(): axi_rans_air_nozzle_restart.cfg_dir = "axisymmetric_rans/air_nozzle" axi_rans_air_nozzle_restart.cfg_file = "air_nozzle_restart.cfg" axi_rans_air_nozzle_restart.test_iter = 10 - axi_rans_air_nozzle_restart.test_vals = [-12.070954, -7.407644, -8.698118, -4.008751, 0] + axi_rans_air_nozzle_restart.test_vals = [-12.065478, -6.838586, -8.839400, -4.103176, 0] test_list.append(axi_rans_air_nozzle_restart) ################################# @@ -263,7 +263,7 @@ def main(): turb_naca0012_sst_restart_mg.cfg_file = "turb_NACA0012_sst_multigrid_restart.cfg" turb_naca0012_sst_restart_mg.test_iter = 20 turb_naca0012_sst_restart_mg.ntest_vals = 5 - turb_naca0012_sst_restart_mg.test_vals = [-7.644702, -7.433663, -1.918163, -0.000003, 0.079111] + turb_naca0012_sst_restart_mg.test_vals = [-7.633090, -7.182014, -0.627166, -0.000020, 0.078737] test_list.append(turb_naca0012_sst_restart_mg) ############################# @@ -275,7 +275,7 @@ def main(): turb_naca0012_1c.cfg_dir = "rans_uq/naca0012" turb_naca0012_1c.cfg_file = "turb_NACA0012_uq_1c.cfg" turb_naca0012_1c.test_iter = 10 - turb_naca0012_1c.test_vals = [-4.976788, 1.141064, 0.246262, -0.116795] + turb_naca0012_1c.test_vals = [-4.976353, 1.141375, 0.243102, -0.112154] turb_naca0012_1c.test_vals_aarch64 = [-4.981105, 1.138873, 0.248013, -0.117248] test_list.append(turb_naca0012_1c) @@ -284,7 +284,7 @@ def main(): turb_naca0012_2c.cfg_dir = "rans_uq/naca0012" turb_naca0012_2c.cfg_file = "turb_NACA0012_uq_2c.cfg" turb_naca0012_2c.test_iter = 10 - turb_naca0012_2c.test_vals = [-5.485942, 0.967831, 0.236638, -0.119183] + turb_naca0012_2c.test_vals = [-5.485942, 0.968057, 0.233600, -0.114502] turb_naca0012_2c.test_vals_aarch64 = [-5.483345, 0.968720, 0.214914, -0.124932] test_list.append(turb_naca0012_2c) @@ -293,7 +293,7 @@ def main(): turb_naca0012_3c.cfg_dir = "rans_uq/naca0012" turb_naca0012_3c.cfg_file = "turb_NACA0012_uq_3c.cfg" turb_naca0012_3c.test_iter = 10 - turb_naca0012_3c.test_vals = [-5.584306, 0.931276, 0.226035, -0.120956] + turb_naca0012_3c.test_vals = [-5.584306, 0.931465, 0.223394, -0.116130] turb_naca0012_3c.test_vals_aarch64 = [-5.584300, 0.931293, 0.207447, -0.125691] test_list.append(turb_naca0012_3c) @@ -302,7 +302,7 @@ def main(): turb_naca0012_p1c1.cfg_dir = "rans_uq/naca0012" turb_naca0012_p1c1.cfg_file = "turb_NACA0012_uq_p1c1.cfg" turb_naca0012_p1c1.test_iter = 10 - turb_naca0012_p1c1.test_vals = [-5.114413, 1.076465, 0.227286, -0.123574] + turb_naca0012_p1c1.test_vals = [-5.114258, 1.076587, 0.224375, -0.118856] turb_naca0012_p1c1.test_vals_aarch64 = [-5.132358, 1.075658, 0.337268, -0.082827] test_list.append(turb_naca0012_p1c1) @@ -311,8 +311,8 @@ def main(): turb_naca0012_p1c2.cfg_dir = "rans_uq/naca0012" turb_naca0012_p1c2.cfg_file = "turb_NACA0012_uq_p1c2.cfg" turb_naca0012_p1c2.test_iter = 10 - turb_naca0012_p1c2.test_vals = [-5.548780, 0.945778, 0.213968, -0.126040] - turb_naca0012_p1c2.test_vals_aarch64 = [-5.554425, 0.943683, 0.229293, -0.121125] + turb_naca0012_p1c2.test_vals = [-5.548775, 0.945962, 0.211150, -0.121291] + turb_naca0012_p1c2.test_vals_aarch64 = [-5.548775, 0.945962, 0.211150, -0.121291] test_list.append(turb_naca0012_p1c2) ###################################### @@ -411,7 +411,7 @@ def main(): inc_turb_naca0012_sst_sust.cfg_dir = "incomp_rans/naca0012" inc_turb_naca0012_sst_sust.cfg_file = "naca0012_SST_SUST.cfg" inc_turb_naca0012_sst_sust.test_iter = 20 - inc_turb_naca0012_sst_sust.test_vals = [-7.270637, 0.018416, 0.000004, 0.307678] + inc_turb_naca0012_sst_sust.test_vals = [-7.291693, 0.132607, 0.000002, 0.312092] test_list.append(inc_turb_naca0012_sst_sust) # Weakly coupled heat equation @@ -452,7 +452,7 @@ def main(): square_cylinder.cfg_dir = "unsteady/square_cylinder" square_cylinder.cfg_file = "turb_square.cfg" square_cylinder.test_iter = 3 - square_cylinder.test_vals = [-2.560839, -1.173497, 0.061188, 1.399403, 2.220575, 1.399351, 2.218781, 0] + square_cylinder.test_vals = [-2.560839, -1.176729, 0.061954, 1.399401, 2.220361, 1.399349, 2.218600, 0.000000] square_cylinder.test_vals_aarch64 = [-2.557902, -1.173574, 0.058050, 1.399794, 2.220402, 1.399748, 2.218604, 0] square_cylinder.unsteady = True test_list.append(square_cylinder) @@ -556,7 +556,7 @@ def main(): Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" Jones_tc_restart.test_iter = 5 - Jones_tc_restart.test_vals = [-10.467026, -2.871699, -19.214627, -13.508254, -11.582396, -6.306163, 73273, 73273, 0.019884, 82.491] + Jones_tc_restart.test_vals = [-7.286677, -5.327018, -14.895652, -9.330534, -12.071733, -6.548623, 73291.000000, 73291.000000, 0.020111, 82.896000] test_list.append(Jones_tc_restart) # 2D axial stage @@ -564,7 +564,7 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [0.987667, 1.531950, -2.888460, 2.606789, -2.418222, 3.087180, 106380.000000, 106380.000000, 5.733000, 64.728000] + axial_stage2D.test_vals = [1.108159, 1.561741, -2.895046, 2.607615, -2.479708, 3.063739, 106380.000000, 106380.000000, 5.733600, 64.747000] axial_stage2D.test_vals_aarch64 = [0.983739, 1.534333, -2.888521, 2.606770, -2.418339, 3.087275, 106380, 106380, 5.7325, 64.711] test_list.append(axial_stage2D) @@ -573,8 +573,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-5.007735, -3.099310, -2.751696, 1.091966, -3.542819, 2.163237, -471630.000000, 94.866000, -0.035738] - transonic_stator_restart.test_vals_aarch64 = [-5.007735, -3.099310, -2.751696, 1.091966, -3.542819, 2.163237, -471630, 94.866, -0.035738] + transonic_stator_restart.test_vals = [-4.357748, -2.480402, -2.075152, 1.737469, -1.440919, 2.727299, -471620.000000, 94.840000, -0.054603] + transonic_stator_restart.test_vals_aarch64 = [-4.357748, -2.480402, -2.075152, 1.737469, -1.440919, 2.727299, -471620.000000, 94.840000, -0.054603] test_list.append(transonic_stator_restart) # Multiple turbomachinery interface restart @@ -657,7 +657,7 @@ def main(): bars_SST_2D.cfg_dir = "sliding_interface/bars_SST_2D" bars_SST_2D.cfg_file = "bars.cfg" bars_SST_2D.test_iter = 13 - bars_SST_2D.test_vals = [13.000000, -0.773513, -1.700012] + bars_SST_2D.test_vals = [13.000000, 0.268825, -1.700012] bars_SST_2D.multizone = True test_list.append(bars_SST_2D) diff --git a/TestCases/hybrid_regression_AD.py b/TestCases/hybrid_regression_AD.py index 3cc8adf1a686..f0eebcb6b96d 100644 --- a/TestCases/hybrid_regression_AD.py +++ b/TestCases/hybrid_regression_AD.py @@ -86,7 +86,7 @@ def main(): discadj_rans_naca0012_sst.cfg_dir = "disc_adj_rans/naca0012" discadj_rans_naca0012_sst.cfg_file = "turb_NACA0012_sst.cfg" discadj_rans_naca0012_sst.test_iter = 10 - discadj_rans_naca0012_sst.test_vals = [-2.234104, -0.198500, 2.763900, -0.039720] + discadj_rans_naca0012_sst.test_vals = [-2.237494, -0.200182, 2.762600, -0.039607] test_list.append(discadj_rans_naca0012_sst) ####################################### @@ -131,7 +131,7 @@ def main(): discadj_incomp_turb_NACA0012_sst.cfg_dir = "disc_adj_incomp_rans/naca0012" discadj_incomp_turb_NACA0012_sst.cfg_file = "turb_naca0012_sst.cfg" discadj_incomp_turb_NACA0012_sst.test_iter = 10 - discadj_incomp_turb_NACA0012_sst.test_vals = [-4.029282, -2.181911, -7.734686, 0.000000, -0.939944] + discadj_incomp_turb_NACA0012_sst.test_vals = [-3.597708, -2.983823, -8.354806, 0.000000, -0.916525] test_list.append(discadj_incomp_turb_NACA0012_sst) ####################################################### diff --git a/TestCases/incomp_navierstokes/streamwise_periodic/chtPinArray_2d/of_grad_findiff.csv.ref b/TestCases/incomp_navierstokes/streamwise_periodic/chtPinArray_2d/of_grad_findiff.csv.ref index 2634fca1ff54..dece285b96fc 100644 --- a/TestCases/incomp_navierstokes/streamwise_periodic/chtPinArray_2d/of_grad_findiff.csv.ref +++ b/TestCases/incomp_navierstokes/streamwise_periodic/chtPinArray_2d/of_grad_findiff.csv.ref @@ -1,2 +1,2 @@ "VARIABLE" , "AVG_DENSITY[0]", "AVG_ENTHALPY[0]", "AVG_NORMALVEL[0]", "DRAG[0]" , "EFFICIENCY[0]" , "FORCE_X[0]" , "FORCE_Y[0]" , "FORCE_Z[0]" , "LIFT[0]" , "MOMENT_X[0]" , "MOMENT_Y[0]" , "MOMENT_Z[0]" , "SIDEFORCE[0]" , "SURFACE_MACH[0]", "SURFACE_MASSFLOW[0]", "SURFACE_MOM_DISTORTION[0]", "SURFACE_PRESSURE_DROP[0]", "SURFACE_SECONDARY[0]", "SURFACE_SECOND_OVER_UNIFORM[0]", "SURFACE_STATIC_PRESSURE[0]", "SURFACE_STATIC_TEMPERATURE[0]", "SURFACE_TOTAL_PRESSURE[0]", "SURFACE_TOTAL_TEMPERATURE[0]", "SURFACE_UNIFORMITY[0]", "AVG_TEMPERATURE[1]", "MAXIMUM_HEATFLUX[1]", "TOTAL_HEATFLUX[1]", "FINDIFF_STEP" -0 , 0.0 , -300000.0026077032, -3.3306691000000184e-08, 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , -0.01999999887924986, 0.0 , -0.9000000009140585 , 0.0 , 0.9379999998948563 , 1.649999997743734 , 419.99999780273356 , -69.99999868639861 , 358.9999998609983 , -69.99999868639861 , -0.6000000052353016 , -380.0000001774606, 0.0 , -430.00000005122274, 1e-08 +0 , 0.0 , -3800000.0175088644, -3.330699999961374e-08, 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , -1.4500000006245628, -5.5510000002640306e-08, -42.070000000338226 , 0.0 , 43.11999999839777 , 79.95999999899084 , 5740.000000287182 , -1079.9999927257886 , 79.99999951380232 , -1080.0000040944724 , -37.40000000806987 , -729.9999992937956, 0.0 , 790.0000014160469, 1e-08 diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 183341de5163..f94a64d9f8cb 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -365,7 +365,7 @@ def main(): rae2822_sst.cfg_dir = "rans/rae2822" rae2822_sst.cfg_file = "turb_SST_RAE2822.cfg" rae2822_sst.test_iter = 20 - rae2822_sst.test_vals = [-0.510369, 4.870643, 0.816647, 0.061833, 0.000000] + rae2822_sst.test_vals = [-0.510367, 4.902122, 0.813791, 0.062425, 0.000000] test_list.append(rae2822_sst) # RAE2822 SST_SUST @@ -373,7 +373,7 @@ def main(): rae2822_sst_sust.cfg_dir = "rans/rae2822" rae2822_sst_sust.cfg_file = "turb_SST_SUST_RAE2822.cfg" rae2822_sst_sust.test_iter = 20 - rae2822_sst_sust.test_vals = [-2.537339, 4.870643, 0.816647, 0.061833] + rae2822_sst_sust.test_vals = [-2.569628, 4.902122, 0.813791, 0.062425] test_list.append(rae2822_sst_sust) # Flat plate @@ -397,7 +397,7 @@ def main(): turb_flatplate_CC_Wilcox.cfg_dir = "rans/flatplate" turb_flatplate_CC_Wilcox.cfg_file = "turb_SST_flatplate_compressibility_Wilcox.cfg" turb_flatplate_CC_Wilcox.test_iter = 20 - turb_flatplate_CC_Wilcox.test_vals = [-1.280875, 1.974212, 1.440458, 5.038402, -4.051125, 8.521136] + turb_flatplate_CC_Wilcox.test_vals = [-1.280875, 1.974210, 1.440441, 5.038396, -4.052127, 11.904843] test_list.append(turb_flatplate_CC_Wilcox) # Flat plate SST compressibility correction Sarkar @@ -405,7 +405,7 @@ def main(): turb_flatplate_CC_Sarkar.cfg_dir = "rans/flatplate" turb_flatplate_CC_Sarkar.cfg_file = "turb_SST_flatplate_compressibility_Sarkar.cfg" turb_flatplate_CC_Sarkar.test_iter = 20 - turb_flatplate_CC_Sarkar.test_vals = [-1.280875, 1.974212, 1.440458, 5.038402, -4.051128, 8.521136] + turb_flatplate_CC_Sarkar.test_vals = [-1.280875, 1.974210, 1.440441, 5.038396, -4.052131, 11.904843] test_list.append(turb_flatplate_CC_Sarkar) # ONERA M6 Wing @@ -450,8 +450,8 @@ def main(): turb_naca0012_sst.cfg_dir = "rans/naca0012" turb_naca0012_sst.cfg_file = "turb_NACA0012_sst.cfg" turb_naca0012_sst.test_iter = 10 - turb_naca0012_sst.test_vals = [-12.107692, -15.277743, -6.210238, 1.049757, 0.019249, -2.357984, 0] - turb_naca0012_sst.test_vals_aarch64 = [-12.107692, -15.277743, -6.210238, 1.049757, 0.019249, -2.357984, 0] + turb_naca0012_sst.test_vals = [-12.232533, -14.435252, -6.410718, 1.047444, 0.019214, -1.704292, 0.000000] + turb_naca0012_sst.test_vals_aarch64 = [-12.232533, -14.435252, -6.410718, 1.047444, 0.019214, -1.704292, 0.000000] turb_naca0012_sst.timeout = 3200 test_list.append(turb_naca0012_sst) @@ -460,8 +460,8 @@ def main(): turb_naca0012_sst_sust.cfg_dir = "rans/naca0012" turb_naca0012_sst_sust.cfg_file = "turb_NACA0012_sst_sust.cfg" turb_naca0012_sst_sust.test_iter = 10 - turb_naca0012_sst_sust.test_vals = [-12.087234, -14.827336, -6.062338, 1.000276, 0.019495, -1.779654] - turb_naca0012_sst_sust.test_vals_aarch64 = [-12.087234, -14.827336, -6.062338, 1.000276, 0.019495, -1.779654] + turb_naca0012_sst_sust.test_vals = [-12.146206, -14.781894, -6.726031, 1.000270, 0.019123, -1.593340] + turb_naca0012_sst_sust.test_vals_aarch64 = [-12.146206, -14.781894, -6.726031, 1.000270, 0.019123, -1.593340] turb_naca0012_sst_sust.timeout = 3200 test_list.append(turb_naca0012_sst_sust) @@ -470,7 +470,7 @@ def main(): turb_naca0012_sst_2003_Vm.cfg_dir = "rans/naca0012" turb_naca0012_sst_2003_Vm.cfg_file = "turb_NACA0012_sst_2003-Vm.cfg" turb_naca0012_sst_2003_Vm.test_iter = 10 - turb_naca0012_sst_2003_Vm.test_vals = [-7.662107, -10.010518, -3.354064, 1.048299, 0.019832, -2.071125] + turb_naca0012_sst_2003_Vm.test_vals = [-8.263497, -10.306865, -3.563758, 1.045289, 0.019325, -1.551944] turb_naca0012_sst_2003_Vm.timeout = 3200 test_list.append(turb_naca0012_sst_2003_Vm) @@ -479,7 +479,7 @@ def main(): turb_naca0012_sst_1994_KLm.cfg_dir = "rans/naca0012" turb_naca0012_sst_1994_KLm.cfg_file = "turb_NACA0012_sst_1994-KLm.cfg" turb_naca0012_sst_1994_KLm.test_iter = 10 - turb_naca0012_sst_1994_KLm.test_vals = [-8.560764, -10.801276, -3.996309, 1.049043, 0.019285, -1.809924] + turb_naca0012_sst_1994_KLm.test_vals = [-8.563644, -10.803387, -3.994584, 1.046738, 0.019251, -1.806540] turb_naca0012_sst_1994_KLm.timeout = 3200 test_list.append(turb_naca0012_sst_1994_KLm) @@ -489,7 +489,7 @@ def main(): turb_naca0012_sst_fixedvalues.cfg_dir = "rans/naca0012" turb_naca0012_sst_fixedvalues.cfg_file = "turb_NACA0012_sst_fixedvalues.cfg" turb_naca0012_sst_fixedvalues.test_iter = 10 - turb_naca0012_sst_fixedvalues.test_vals = [-5.216625, -10.018477, -1.615201, 1.021842, 0.040325, -3.728658] + turb_naca0012_sst_fixedvalues.test_vals = [-5.216567, -10.242833, -1.565507, 1.022391, 0.040547, -3.738426] turb_naca0012_sst_fixedvalues.timeout = 3200 test_list.append(turb_naca0012_sst_fixedvalues) @@ -498,7 +498,7 @@ def main(): turb_naca0012_sst_expliciteuler.cfg_dir = "rans/naca0012" turb_naca0012_sst_expliciteuler.cfg_file = "turb_NACA0012_sst_expliciteuler.cfg" turb_naca0012_sst_expliciteuler.test_iter = 10 - turb_naca0012_sst_expliciteuler.test_vals = [-3.533827, -3.157766, 3.364024, 1.122856, 0.500771, -float("inf")] + turb_naca0012_sst_expliciteuler.test_vals = [-3.533765, -3.157766, 3.364026, 1.124760, 0.501702, -float("inf")] turb_naca0012_sst_expliciteuler.timeout = 3200 test_list.append(turb_naca0012_sst_expliciteuler) @@ -530,7 +530,7 @@ def main(): axi_rans_air_nozzle_restart.cfg_dir = "axisymmetric_rans/air_nozzle" axi_rans_air_nozzle_restart.cfg_file = "air_nozzle_restart.cfg" axi_rans_air_nozzle_restart.test_iter = 10 - axi_rans_air_nozzle_restart.test_vals = [-12.071395, -7.467871, -8.649076, -3.995810, 0] + axi_rans_air_nozzle_restart.test_vals = [-12.067082, -6.839065, -8.740217, -4.045574, 0.000000] axi_rans_air_nozzle_restart.tol = 0.0001 test_list.append(axi_rans_air_nozzle_restart) @@ -544,7 +544,7 @@ def main(): turb_naca0012_sst_restart_mg.cfg_file = "turb_NACA0012_sst_multigrid_restart.cfg" turb_naca0012_sst_restart_mg.test_iter = 20 turb_naca0012_sst_restart_mg.ntest_vals = 5 - turb_naca0012_sst_restart_mg.test_vals = [-7.612353, -7.432347, -1.918249, -0.000013, 0.079110] + turb_naca0012_sst_restart_mg.test_vals = [-7.600526, -7.181993, -0.627166, -0.000016, 0.078729] turb_naca0012_sst_restart_mg.timeout = 3200 turb_naca0012_sst_restart_mg.tol = 0.000001 test_list.append(turb_naca0012_sst_restart_mg) @@ -646,7 +646,7 @@ def main(): inc_turb_naca0012_sst_sust.cfg_dir = "incomp_rans/naca0012" inc_turb_naca0012_sst_sust.cfg_file = "naca0012_SST_SUST.cfg" inc_turb_naca0012_sst_sust.test_iter = 20 - inc_turb_naca0012_sst_sust.test_vals = [-7.270578, 0.018403, -0.000001, 0.307688] + inc_turb_naca0012_sst_sust.test_vals = [-7.291511, 0.132644, -0.000001, 0.312109] test_list.append(inc_turb_naca0012_sst_sust) #################### @@ -881,7 +881,7 @@ def main(): turb_naca0012_1c.cfg_dir = "rans_uq/naca0012" turb_naca0012_1c.cfg_file = "turb_NACA0012_uq_1c.cfg" turb_naca0012_1c.test_iter = 10 - turb_naca0012_1c.test_vals = [-4.980989, 1.139850, 0.469677, -0.081426] + turb_naca0012_1c.test_vals = [-4.981013, 1.139991, 0.466303, -0.076862] test_list.append(turb_naca0012_1c) # NACA0012 2c @@ -889,7 +889,7 @@ def main(): turb_naca0012_2c.cfg_dir = "rans_uq/naca0012" turb_naca0012_2c.cfg_file = "turb_NACA0012_uq_2c.cfg" turb_naca0012_2c.test_iter = 10 - turb_naca0012_2c.test_vals = [-5.484979, 0.968118, 0.320621, -0.114603] + turb_naca0012_2c.test_vals = [-5.484979, 0.968345, 0.317774, -0.109857] test_list.append(turb_naca0012_2c) # NACA0012 3c @@ -897,7 +897,7 @@ def main(): turb_naca0012_3c.cfg_dir = "rans_uq/naca0012" turb_naca0012_3c.cfg_file = "turb_NACA0012_uq_3c.cfg" turb_naca0012_3c.test_iter = 10 - turb_naca0012_3c.test_vals = [-5.584315, 0.931258, 0.277047, -0.118255] + turb_naca0012_3c.test_vals = [-5.584315, 0.931447, 0.274234, -0.113498] test_list.append(turb_naca0012_3c) # NACA0012 p1c1 @@ -905,7 +905,7 @@ def main(): turb_naca0012_p1c1.cfg_dir = "rans_uq/naca0012" turb_naca0012_p1c1.cfg_file = "turb_NACA0012_uq_p1c1.cfg" turb_naca0012_p1c1.test_iter = 10 - turb_naca0012_p1c1.test_vals = [-5.122398, 1.074022, 0.415368, -0.096185] + turb_naca0012_p1c1.test_vals = [-5.122291, 1.074243, 0.412316, -0.091523] test_list.append(turb_naca0012_p1c1) # NACA0012 p1c2 @@ -913,7 +913,7 @@ def main(): turb_naca0012_p1c2.cfg_dir = "rans_uq/naca0012" turb_naca0012_p1c2.cfg_file = "turb_NACA0012_uq_p1c2.cfg" turb_naca0012_p1c2.test_iter = 10 - turb_naca0012_p1c2.test_vals = [-5.549595, 0.945508, 0.287359, -0.117019] + turb_naca0012_p1c2.test_vals = [-5.549595, 0.945688, 0.284500, -0.112282] test_list.append(turb_naca0012_p1c2) ###################################### @@ -974,7 +974,7 @@ def main(): square_cylinder.cfg_dir = "unsteady/square_cylinder" square_cylinder.cfg_file = "turb_square.cfg" square_cylinder.test_iter = 3 - square_cylinder.test_vals = [-1.173495, 0.061186, 1.399404, 2.220578, 1.399352, 2.218783, 0] + square_cylinder.test_vals = [-1.176727, 0.061953, 1.399402, 2.220364, 1.399350, 2.218602, 0.000000] square_cylinder.unsteady = True test_list.append(square_cylinder) @@ -1048,7 +1048,7 @@ def main(): coolprop_fluidModel.cfg_dir = "nicf/coolprop" coolprop_fluidModel.cfg_file = "fluidModel.cfg" coolprop_fluidModel.test_iter = 5 - coolprop_fluidModel.test_vals = [-4.424953, -1.582877, 3.442422, 0.000000, 0.000000] + coolprop_fluidModel.test_vals = [-4.424952, -1.583033, 3.720621, 0.000000, 0.000000] coolprop_fluidModel.enabled_on_cpu_arch = ["x86_64"] test_list.append(coolprop_fluidModel) @@ -1057,7 +1057,7 @@ def main(): coolprop_transportModel.cfg_dir = "nicf/coolprop" coolprop_transportModel.cfg_file = "transportModel.cfg" coolprop_transportModel.test_iter = 5 - coolprop_transportModel.test_vals = [-4.428098, -1.314332, 4.630872, 0.000000, 0.000000] + coolprop_transportModel.test_vals = [-4.428096, -1.314555, 4.666156, 0.000000, 0.000000] coolprop_transportModel.enabled_on_cpu_arch = ["x86_64"] test_list.append(coolprop_transportModel) @@ -1066,7 +1066,7 @@ def main(): datadriven_fluidModel.cfg_dir = "nicf/datadriven" datadriven_fluidModel.cfg_file = "datadriven_nozzle.cfg" datadriven_fluidModel.test_iter = 50 - datadriven_fluidModel.test_vals = [-2.632817, 0.155922, 4.690917, 0.000000, 0.000000] + datadriven_fluidModel.test_vals = [-2.632720, 0.156604, 4.691528, 0.000000, 0.000000] test_list.append(datadriven_fluidModel) ###################################### @@ -1086,7 +1086,7 @@ def main(): Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" Jones_tc_restart.test_iter = 5 - Jones_tc_restart.test_vals = [-10.467612, -2.871708, -19.345651, -13.625871, -11.582397, -6.306168, 73273, 73273, 0.019884, 82.491] + Jones_tc_restart.test_vals = [-7.286677, -5.327030, -14.895645, -9.330524, -12.071730, -6.548621, 73291.000000, 73291.000000, 0.020111, 82.896000] test_list.append(Jones_tc_restart) # 2D axial stage @@ -1094,7 +1094,7 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [0.987681, 1.532093, -2.888460, 2.606791, -2.418287, 3.087104, 106380, 106380, 5.7329, 64.728] + axial_stage2D.test_vals = [1.108171, 1.561780, -2.895045, 2.607616, -2.479708, 3.063740, 106380.000000, 106380.000000, 5.733600, 64.747000] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -1102,7 +1102,7 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630, 94.868, -0.035888] + transonic_stator_restart.test_vals = [-4.354904, -2.473465, -2.076229, 1.740407, -1.440833, 2.730785, -471620.000000, 94.839000, -0.050270] transonic_stator_restart.test_vals_aarch64 = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630, 94.868, -0.035888] test_list.append(transonic_stator_restart) @@ -1185,7 +1185,7 @@ def main(): bars_SST_2D.cfg_dir = "sliding_interface/bars_SST_2D" bars_SST_2D.cfg_file = "bars.cfg" bars_SST_2D.test_iter = 13 - bars_SST_2D.test_vals = [13.000000, -0.773513, -1.700012] + bars_SST_2D.test_vals = [13.000000, 0.268760, -1.700012] bars_SST_2D.multizone = True test_list.append(bars_SST_2D) @@ -1233,7 +1233,7 @@ def main(): # For a thin disk with the inner and outer radius of this geometry, from # "Formulas for Stress, Strain, and Structural Matrices", 2nd Edition, figure 19-4, # the maximum stress is 165.6MPa, we get a Von Misses stress very close to that. - rotating_cylinder_fea.test_vals = [-6.861940, -6.835545, -6.895500, 22, -8.313847, 1.6502e+08] + rotating_cylinder_fea.test_vals = [-6.861940, -6.835550, -6.895497, 22, -8.313847, 1.6502e+08] test_list.append(rotating_cylinder_fea) # Dynamic beam, 2d @@ -1337,7 +1337,7 @@ def main(): sp_pinArray_cht_2d_dp_hf.cfg_dir = "incomp_navierstokes/streamwise_periodic/chtPinArray_2d" sp_pinArray_cht_2d_dp_hf.cfg_file = "configMaster.cfg" sp_pinArray_cht_2d_dp_hf.test_iter = 100 - sp_pinArray_cht_2d_dp_hf.test_vals = [0.088580, -0.764276, -1.086940, -0.747450, 208.023676, 344.680000, -0.000000, -0.747450, 0.747450] + sp_pinArray_cht_2d_dp_hf.test_vals = [0.548558, -0.379295, -1.007163, -0.732245, 208.023676, 334.010000, -0.000000, -0.732240, 0.732240] sp_pinArray_cht_2d_dp_hf.multizone = True test_list.append(sp_pinArray_cht_2d_dp_hf) @@ -1346,8 +1346,8 @@ def main(): sp_pinArray_3d_cht_mf_hf_tp.cfg_dir = "incomp_navierstokes/streamwise_periodic/chtPinArray_3d" sp_pinArray_3d_cht_mf_hf_tp.cfg_file = "configMaster.cfg" sp_pinArray_3d_cht_mf_hf_tp.test_iter = 30 - sp_pinArray_3d_cht_mf_hf_tp.test_vals = [-1.627413, -3.083567, -4.577909, -0.009725, 104.632413, 418.370000, 0.000000] - sp_pinArray_3d_cht_mf_hf_tp.test_vals_aarch64 = [-1.622914, -3.081114, -4.576282, -0.009725, 104.632412, 418.370000, 0.000000] + sp_pinArray_3d_cht_mf_hf_tp.test_vals = [-1.117102, -1.880628, -2.561816, -0.009804, 104.600540, 418.360000, 0.000000] + sp_pinArray_3d_cht_mf_hf_tp.test_vals_aarch64 = [-1.117102, -1.880628, -2.561816, -0.009804, 104.600540, 418.360000, 0.000000] sp_pinArray_3d_cht_mf_hf_tp.multizone = True test_list.append(sp_pinArray_3d_cht_mf_hf_tp) @@ -1370,8 +1370,8 @@ def main(): pywrapper_turb_naca0012_sst.cfg_dir = "rans/naca0012" pywrapper_turb_naca0012_sst.cfg_file = "turb_NACA0012_sst.cfg" pywrapper_turb_naca0012_sst.test_iter = 10 - pywrapper_turb_naca0012_sst.test_vals = [-12.107692, -15.277743, -6.210238, 1.049757, 0.019249, -2.357984, 0] - pywrapper_turb_naca0012_sst.test_vals_aarch64 = [-12.107692, -15.277743, -6.210238, 1.049757, 0.019249, -2.357984, 0] + pywrapper_turb_naca0012_sst.test_vals = [-12.232533, -14.435252, -6.410718, 1.047444, 0.019214, -1.704292, 0] + pywrapper_turb_naca0012_sst.test_vals_aarch64 = [-12.232533, -14.435252, -6.410718, 1.047444, 0.019214, -1.704292, 0] pywrapper_turb_naca0012_sst.command = TestCase.Command("mpirun -np 2", "SU2_CFD.py", "--parallel -f") pywrapper_turb_naca0012_sst.timeout = 3200 test_list.append(pywrapper_turb_naca0012_sst) @@ -1381,7 +1381,7 @@ def main(): pywrapper_square_cylinder.cfg_dir = "unsteady/square_cylinder" pywrapper_square_cylinder.cfg_file = "turb_square.cfg" pywrapper_square_cylinder.test_iter = 10 - pywrapper_square_cylinder.test_vals = [-1.176405, -0.354027, 1.407859, 2.360784, 1.404715, 2.302615, 0] + pywrapper_square_cylinder.test_vals = [-1.181633, -0.354608, 1.401055, 2.358088, 1.401417, 2.301179, 0] pywrapper_square_cylinder.command = TestCase.Command("mpirun -np 2", "SU2_CFD.py", "--parallel -f") pywrapper_square_cylinder.unsteady = True test_list.append(pywrapper_square_cylinder) @@ -1433,7 +1433,7 @@ def main(): pywrapper_unsteadyCHT.cfg_dir = "py_wrapper/flatPlate_unsteady_CHT" pywrapper_unsteadyCHT.cfg_file = "unsteady_CHT_FlatPlate_Conf.cfg" pywrapper_unsteadyCHT.test_iter = 5 - pywrapper_unsteadyCHT.test_vals = [-1.614167, 2.240663, -0.001392, 0.177499] + pywrapper_unsteadyCHT.test_vals = [-1.614167, 2.246133, -0.001388, 0.172996] pywrapper_unsteadyCHT.command = TestCase.Command("mpirun -np 2", "python", "launch_unsteady_CHT_FlatPlate.py --parallel -f") pywrapper_unsteadyCHT.unsteady = True test_list.append(pywrapper_unsteadyCHT) @@ -1443,7 +1443,7 @@ def main(): pywrapper_rigidMotion.cfg_dir = "py_wrapper/flatPlate_rigidMotion" pywrapper_rigidMotion.cfg_file = "flatPlate_rigidMotion_Conf.cfg" pywrapper_rigidMotion.test_iter = 5 - pywrapper_rigidMotion.test_vals = [-1.614165, 2.238591, 0.349970, 0.095593] + pywrapper_rigidMotion.test_vals = [-1.614165, 2.243155, 0.350196, 0.089497] pywrapper_rigidMotion.command = TestCase.Command("mpirun -np 2", "python", "launch_flatPlate_rigidMotion.py --parallel -f") pywrapper_rigidMotion.unsteady = True test_list.append(pywrapper_rigidMotion) @@ -1525,7 +1525,7 @@ def main(): species2_primitiveVenturi_mixingmodel.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel.cfg_file = "species2_primitiveVenturi_mixingmodel.cfg" species2_primitiveVenturi_mixingmodel.test_iter = 50 - species2_primitiveVenturi_mixingmodel.test_vals = [ -5.406062, -4.556225, -4.633753, -5.644242, -0.058437, -5.545635, 5.000000, -1.881888, 5.000000, -4.900700, 5.000000, -1.169412, 0.000559, 0.000492, 0.000067, 0.000000] + species2_primitiveVenturi_mixingmodel.test_vals = [ -5.432322, -4.506693, -4.598961, -5.858079, -0.074848, -5.608093, 5.000000, -1.900665, 5.000000, -4.895929, 5.000000, -1.202887, 0.000544, 0.000484, 0.000060, 0.000000] test_list.append(species2_primitiveVenturi_mixingmodel) # 2 species (1 eq) primitive venturi mixing using mixing model and bounded scalar transport @@ -1533,7 +1533,7 @@ def main(): species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_file = "species2_primitiveVenturi_mixingmodel_boundedscalar.cfg" species2_primitiveVenturi_mixingmodel_boundedscalar.test_iter = 50 - species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.390872, -4.491249, -4.575176, -5.760619, -0.137842, -5.677153, 5.000000, -1.896522, 5.000000, -4.806007, 5.000000, -1.697287, 0.000275, 0.000275, 0.000000, 0.000000] + species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.396930, -4.441229, -4.531561, -6.119468, -0.129257, -5.681246, 5.000000, -1.986168, 5.000000, -4.959587, 5.000000, -1.880063, 0.000297, 0.000297, 0.000000, 0.000000] test_list.append(species2_primitiveVenturi_mixingmodel_boundedscalar) # 2 species (1 eq) primitive venturi mixing using mixing model including viscosity, thermal conductivity and inlet markers for SA turbulence model @@ -1549,7 +1549,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_iter = 50 - species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_vals = [-5.705589, -4.493347, -4.464137, -6.399752, 2.021703, -5.466399, 30.000000, -7.430567, 13.000000, -8.018769, 8.000000, -8.506180, 2.092565, 1.000000, 0.600000, 0.492565] + species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_vals = [-5.683102, -4.564193, -4.448313, -6.737904, 2.044729, -5.467878, 30.000000, -7.621295, 12.000000, -8.052264, 8.000000, -8.963883, 2.092215, 1.000000, 0.600000, 0.492215] test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2) # 2 species (1 eq) primitive venturi mixing using mixing model including heat capacity and mass diffusivity NonDimensional case @@ -1557,7 +1557,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_iter = 50 - species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.291034, -4.770419, -4.743257, -7.365441, 1.709269, -5.067282, 10.000000, -2.860653, 4.000000, -5.134413, 5.000000, -5.474359, 2.093031, 1.000000, 0.600000, 0.493031] + species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.273052, -4.863236, -4.734578, -7.722857, 1.740741, -5.073467, 10.000000, -2.926106, 3.000000, -5.186545, 5.000000, -5.929953, 2.092322, 1.000000, 0.600000, 0.492322] test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND) # 2 species (1 eq) primitive venturi mixing @@ -1565,7 +1565,7 @@ def main(): species2_primitiveVenturi.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi.cfg_file = "species2_primitiveVenturi.cfg" species2_primitiveVenturi.test_iter = 50 - species2_primitiveVenturi.test_vals = [-5.643794, -4.798953, -4.858719, -5.648947, -1.195985, -5.564607, 5.000000, -0.958960, 5.000000, -2.515334, 5.000000, -0.796944, 0.000210, 0.000206, 0.000004, 0.000000] + species2_primitiveVenturi.test_vals = [-5.383507, -4.591042, -4.618659, -5.371315, -1.048003, -5.321849, 5.000000, -1.011668, 5.000000, -2.540380, 5.000000, -1.220744, 0.000035, 0.000035, 0.000000, 0.000000] test_list.append(species2_primitiveVenturi) # 2 species (1 eq) primitive venturi mixing with bounded scalar transport @@ -1573,7 +1573,7 @@ def main(): species_primitiveVenturi_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species_primitiveVenturi_boundedscalar.cfg_file = "species2_primitiveVenturi_boundedscalar.cfg" species_primitiveVenturi_boundedscalar.test_iter = 50 - species_primitiveVenturi_boundedscalar.test_vals = [-5.283533, -4.417193, -4.478360, -5.669526, -0.952767, -5.618596, 5.000000, -1.996975, 5.000000, -4.017868, 5.000000, -1.747496, 0.000423, 0.000423, 0.000000, 0.000000] + species_primitiveVenturi_boundedscalar.test_vals = [-5.273416, -4.372370, -4.440933, -5.944335, -0.961736, -5.609422, 5.000000, -2.024352, 5.000000, -4.092737, 5.000000, -1.811021, 0.000423, 0.000423, 0.000000, 0.000000] test_list.append(species_primitiveVenturi_boundedscalar) # 2 species (1 eq) primitive venturi mixing using mixing model including inlet markers for turbulent intensity and viscosity ratios @@ -1581,7 +1581,7 @@ def main(): species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.cfg_file = "species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.cfg" species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.test_iter = 50 - species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.test_vals = [-4.105910, -1.680056, -1.599493, -0.672401, 1.441091, -3.759601, 23.000000, -5.201473, 11.000000, -5.312651, 4.000000, -6.525448, 2.000000, 1.000000, 0.000000, 1.000000] + species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.test_vals = [-4.047742, -1.641280, -1.562848, -0.984640, 1.499898, -3.745901, 23.000000, -5.208811, 12.000000, -5.399205, 3.000000, -5.230072, 2.000000, 1.000000, 0.000000, 1.000000] test_list.append(species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS) # 3 species (2 eq) primitive venturi mixing with inlet files. @@ -1590,7 +1590,7 @@ def main(): species3_primitiveVenturi_inletFile.cfg_dir = "species_transport/venturi_primitive_3species" species3_primitiveVenturi_inletFile.cfg_file = "species3_primitiveVenturi_inletFile.cfg" species3_primitiveVenturi_inletFile.test_iter = 50 - species3_primitiveVenturi_inletFile.test_vals = [-5.714428, -4.869589, -4.929349, -5.719577, -1.266622, -5.824037, -5.944720, 5.000000, -0.958918, 5.000000, -2.515337, 5.000000, -0.523677] + species3_primitiveVenturi_inletFile.test_vals = [-5.454137, -4.661671, -4.689288, -5.441944, -1.118632, -5.592455, -5.735073, 5.000000, -1.011667, 5.000000, -2.540380, 5.000000, -1.040187] test_list.append(species3_primitiveVenturi_inletFile) # rectangle passive transport validation @@ -1607,7 +1607,7 @@ def main(): species3_multizone_restart.cfg_dir = "species_transport/multizone" species3_multizone_restart.cfg_file = "configMaster.cfg" species3_multizone_restart.test_iter = 5 - species3_multizone_restart.test_vals = [-6.111017, -5.720050] + species3_multizone_restart.test_vals = [-2.081789, -1.936012] species3_multizone_restart.multizone = True test_list.append(species3_multizone_restart) @@ -1620,7 +1620,7 @@ def main(): cgns_writer.cfg_dir = "cgns_writer" cgns_writer.cfg_file = "config.cfg" cgns_writer.test_iter = 1 - cgns_writer.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873] + cgns_writer.test_vals = [-2.974473, 0.640256, 5.371029, -6.732060] cgns_writer.command = TestCase.Command("mpirun -n 2", "SU2_CFD") cgns_writer.new_output = True test_list.append(cgns_writer) diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index f54849610f4a..c7eb4ee04b7c 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -91,8 +91,8 @@ def main(): discadj_rans_naca0012_sst.cfg_dir = "disc_adj_rans/naca0012" discadj_rans_naca0012_sst.cfg_file = "turb_NACA0012_sst.cfg" discadj_rans_naca0012_sst.test_iter = 10 - discadj_rans_naca0012_sst.test_vals = [-2.274779, -0.278440, -2.255500, -0.003160] - discadj_rans_naca0012_sst.test_vals_aarch64 = [-2.274779, -0.278440, -2.255500, -0.003160] + discadj_rans_naca0012_sst.test_vals = [-2.265084, -0.280000, -2.268000, -0.002968] + discadj_rans_naca0012_sst.test_vals_aarch64 = [-2.265084, -0.280000, -2.268000, -0.002968] test_list.append(discadj_rans_naca0012_sst) ####################################### @@ -137,8 +137,8 @@ def main(): discadj_incomp_turb_NACA0012_sst.cfg_dir = "disc_adj_incomp_rans/naca0012" discadj_incomp_turb_NACA0012_sst.cfg_file = "turb_naca0012_sst.cfg" discadj_incomp_turb_NACA0012_sst.test_iter = 10 - discadj_incomp_turb_NACA0012_sst.test_vals = [-4.183391, -2.287284, -7.892044, 0, -1.230919] - discadj_incomp_turb_NACA0012_sst.test_vals_aarch64 = [-4.183391, -2.287284, -7.892044, 0, -1.230919] + discadj_incomp_turb_NACA0012_sst.test_vals = [-3.944706, -2.788179, -7.913889, 0.000000, -0.956513] + discadj_incomp_turb_NACA0012_sst.test_vals_aarch64 = [-3.944706, -2.788179, -7.913889, 0.000000, -0.956513] test_list.append(discadj_incomp_turb_NACA0012_sst) #################################################################### @@ -150,7 +150,7 @@ def main(): discadj_axisymmetric_rans_nozzle.cfg_dir = "axisymmetric_rans/air_nozzle" discadj_axisymmetric_rans_nozzle.cfg_file = "air_nozzle_restart.cfg" discadj_axisymmetric_rans_nozzle.test_iter = 10 - discadj_axisymmetric_rans_nozzle.test_vals = [9.550294, 4.938499, 7.387346, 2.733061] + discadj_axisymmetric_rans_nozzle.test_vals = [9.554393, 4.939337, 7.053413, 2.476067] discadj_axisymmetric_rans_nozzle.no_restart = True test_list.append(discadj_axisymmetric_rans_nozzle) @@ -299,7 +299,7 @@ def main(): da_sp_pinArray_cht_2d_dp_hf.cfg_dir = "incomp_navierstokes/streamwise_periodic/chtPinArray_2d" da_sp_pinArray_cht_2d_dp_hf.cfg_file = "DA_configMaster.cfg" da_sp_pinArray_cht_2d_dp_hf.test_iter = 100 - da_sp_pinArray_cht_2d_dp_hf.test_vals = [-4.706292, -4.062398, -4.137374] + da_sp_pinArray_cht_2d_dp_hf.test_vals = [-4.703416, -4.061963, -4.136826] da_sp_pinArray_cht_2d_dp_hf.multizone = True test_list.append(da_sp_pinArray_cht_2d_dp_hf) @@ -308,7 +308,7 @@ def main(): da_sp_pinArray_cht_2d_mf.cfg_dir = "incomp_navierstokes/streamwise_periodic/dp-adjoint_chtPinArray_2d" da_sp_pinArray_cht_2d_mf.cfg_file = "configMaster.cfg" da_sp_pinArray_cht_2d_mf.test_iter = 100 - da_sp_pinArray_cht_2d_mf.test_vals = [-4.600710, -1.298285, -1.430286, -18.503417, -0.870017, -5.768271, -19.069555, -47.953298] + da_sp_pinArray_cht_2d_mf.test_vals = [-4.508582, -1.198591, -1.394041, -18.498530, -0.810948, -6.006116, -19.074586, -49.841067] da_sp_pinArray_cht_2d_mf.multizone = True test_list.append(da_sp_pinArray_cht_2d_mf) diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index b4b9cd473a9a..67325c873f99 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -226,7 +226,7 @@ def main(): rae2822_sst.cfg_dir = "rans/rae2822" rae2822_sst.cfg_file = "turb_SST_RAE2822.cfg" rae2822_sst.test_iter = 20 - rae2822_sst.test_vals = [-0.510376, 4.873617, 0.816197, 0.060504, 0] + rae2822_sst.test_vals = [-0.510374, 4.906793, 0.812735, 0.061081, 0.000000] test_list.append(rae2822_sst) # RAE2822 SST_SUST @@ -234,7 +234,7 @@ def main(): rae2822_sst_sust.cfg_dir = "rans/rae2822" rae2822_sst_sust.cfg_file = "turb_SST_SUST_RAE2822.cfg" rae2822_sst_sust.test_iter = 20 - rae2822_sst_sust.test_vals = [-2.536121, 4.873617, 0.816197, 0.060504] + rae2822_sst_sust.test_vals = [-2.571683, 4.906792, 0.812735, 0.061081] test_list.append(rae2822_sst_sust) # Flat plate @@ -250,7 +250,7 @@ def main(): turb_wallfunction_flatplate_sst.cfg_dir = "wallfunctions/flatplate/compressible_SST" turb_wallfunction_flatplate_sst.cfg_file = "turb_SST_flatplate.cfg" turb_wallfunction_flatplate_sst.test_iter = 10 - turb_wallfunction_flatplate_sst.test_vals = [-4.394471, -1.877558, -1.960378, 0.983694, -1.255671, 1.566842, 10.000000, -1.763190, 0.034806, 0.002921] + turb_wallfunction_flatplate_sst.test_vals = [-4.541780, -1.933200, -1.940897, 0.941215, -1.609670, 1.488457, 10.000000, -1.747275, 0.034238, 0.002427] test_list.append(turb_wallfunction_flatplate_sst) # FLAT PLATE, WALL FUNCTIONS, COMPRESSIBLE SA @@ -284,8 +284,8 @@ def main(): turb_naca0012_sst.cfg_dir = "rans/naca0012" turb_naca0012_sst.cfg_file = "turb_NACA0012_sst.cfg" turb_naca0012_sst.test_iter = 10 - turb_naca0012_sst.test_vals = [-12.107132, -15.277740, -6.210248, 1.049757, 0.019249, -3.173936, 0] - turb_naca0012_sst.test_vals_aarch64 = [-12.107132, -15.277740, -6.210248, 1.049757, 0.019249, -3.173936, 0] + turb_naca0012_sst.test_vals = [-12.229890, -14.434837, -6.410709, 1.047444, 0.019214, -2.107944, 0.000000] + turb_naca0012_sst.test_vals_aarch64 = [-12.229890, -14.434837, -6.410709, 1.047444, 0.019214, -2.107944, 0.000000] turb_naca0012_sst.timeout = 3200 test_list.append(turb_naca0012_sst) @@ -294,7 +294,7 @@ def main(): turb_naca0012_sst_2003m.cfg_dir = "rans/naca0012" turb_naca0012_sst_2003m.cfg_file = "turb_NACA0012_sst_2003m.cfg" turb_naca0012_sst_2003m.test_iter = 10 - turb_naca0012_sst_2003m.test_vals = [-7.688139, -10.046053, -3.410061, 1.048970, 0.019798, -2.208236, 0] + turb_naca0012_sst_2003m.test_vals = [-8.617054, -10.719389, -3.976617, 1.046417, 0.019227, -1.708430, 0.000000] turb_naca0012_sst_2003m.timeout = 3200 test_list.append(turb_naca0012_sst_2003m) @@ -303,8 +303,8 @@ def main(): turb_naca0012_sst_sust_restart.cfg_dir = "rans/naca0012" turb_naca0012_sst_sust_restart.cfg_file = "turb_NACA0012_sst_sust.cfg" turb_naca0012_sst_sust_restart.test_iter = 10 - turb_naca0012_sst_sust_restart.test_vals = [-12.084326, -14.827365, -6.062398, 1.000276, 0.019495, -2.201517] - turb_naca0012_sst_sust_restart.test_vals_aarch64 = [-12.084326, -14.827365, -6.062398, 1.000276, 0.019495, -2.201517] + turb_naca0012_sst_sust_restart.test_vals = [-12.157374, -14.782027, -6.726462, 1.000270, 0.019123, -1.780624] + turb_naca0012_sst_sust_restart.test_vals_aarch64 = [-12.157374, -14.782027, -6.726462, 1.000270, 0.019123, -1.780624] turb_naca0012_sst_sust_restart.timeout = 3200 test_list.append(turb_naca0012_sst_sust_restart) @@ -313,7 +313,7 @@ def main(): turb_naca0012_sst_fixedvalues.cfg_dir = "rans/naca0012" turb_naca0012_sst_fixedvalues.cfg_file = "turb_NACA0012_sst_fixedvalues.cfg" turb_naca0012_sst_fixedvalues.test_iter = 10 - turb_naca0012_sst_fixedvalues.test_vals = [-5.206694, -10.016428, -1.616043, 1.021479, 0.040333, -3.478142] + turb_naca0012_sst_fixedvalues.test_vals = [-5.206634, -10.239842, -1.566346, 1.022023, 0.040554, -3.477742] turb_naca0012_sst_fixedvalues.timeout = 3200 test_list.append(turb_naca0012_sst_fixedvalues) @@ -335,8 +335,8 @@ def main(): axi_rans_air_nozzle_restart.cfg_dir = "axisymmetric_rans/air_nozzle" axi_rans_air_nozzle_restart.cfg_file = "air_nozzle_restart.cfg" axi_rans_air_nozzle_restart.test_iter = 10 - axi_rans_air_nozzle_restart.test_vals = [-12.071702, -7.474599, -8.646498, -3.988633, 0] - axi_rans_air_nozzle_restart.test_vals_aarch64 = [-12.071702, -7.474599, -8.646498, -3.988633, 0] + axi_rans_air_nozzle_restart.test_vals = [-12.066971, -6.841755, -8.747510, -4.048582, 0.000000] + axi_rans_air_nozzle_restart.test_vals_aarch64 = [-12.066971, -6.841755, -8.747510, -4.048582, 0.000000] axi_rans_air_nozzle_restart.tol = 0.0001 test_list.append(axi_rans_air_nozzle_restart) @@ -350,7 +350,7 @@ def main(): turb_naca0012_sst_restart_mg.cfg_file = "turb_NACA0012_sst_multigrid_restart.cfg" turb_naca0012_sst_restart_mg.test_iter = 50 turb_naca0012_sst_restart_mg.ntest_vals = 5 - turb_naca0012_sst_restart_mg.test_vals = [-7.639702, -7.441853, -1.895004, 0.000001, 0.079178] + turb_naca0012_sst_restart_mg.test_vals = [-7.645511, -7.268262, -1.665682, -0.000027, 0.078643] turb_naca0012_sst_restart_mg.timeout = 3200 turb_naca0012_sst_restart_mg.tol = 0.000001 test_list.append(turb_naca0012_sst_restart_mg) @@ -449,7 +449,7 @@ def main(): inc_turb_naca0012_sst_sust.cfg_dir = "incomp_rans/naca0012" inc_turb_naca0012_sst_sust.cfg_file = "naca0012_SST_SUST.cfg" inc_turb_naca0012_sst_sust.test_iter = 20 - inc_turb_naca0012_sst_sust.test_vals = [-7.270375, 0.018431, 0.000021, 0.307673] + inc_turb_naca0012_sst_sust.test_vals = [-7.291334, 0.132662, 0.000021, 0.312093] test_list.append(inc_turb_naca0012_sst_sust) # FLAT PLATE, WALL FUNCTIONS, INCOMPRESSIBLE SST @@ -457,7 +457,7 @@ def main(): inc_turb_wallfunction_flatplate_sst.cfg_dir = "wallfunctions/flatplate/incompressible_SST" inc_turb_wallfunction_flatplate_sst.cfg_file = "turb_SST_flatplate.cfg" inc_turb_wallfunction_flatplate_sst.test_iter = 10 - inc_turb_wallfunction_flatplate_sst.test_vals = [-6.507362, -5.693894, -6.434063, -4.223774, -7.008049, -1.954102, 10.000000, -3.047554, 0.001081, 0.003644, 0] + inc_turb_wallfunction_flatplate_sst.test_vals = [-6.512787, -5.722412, -6.414362, -4.223877, -7.162308, -2.044027, 10.000000, -3.059125, 0.001126, 0.003161, 0.000000] test_list.append(inc_turb_wallfunction_flatplate_sst) # FLAT PLATE, WALL FUNCTIONS, INCOMPRESSIBLE SA @@ -677,7 +677,7 @@ def main(): turb_naca0012_1c.cfg_dir = "rans_uq/naca0012" turb_naca0012_1c.cfg_file = "turb_NACA0012_uq_1c.cfg" turb_naca0012_1c.test_iter = 10 - turb_naca0012_1c.test_vals = [-4.992120, 1.134926, 0.356004, -0.089085] + turb_naca0012_1c.test_vals = [-4.992596, 1.134903, 0.352867, -0.084425] test_list.append(turb_naca0012_1c) # NACA0012 2c @@ -685,7 +685,7 @@ def main(): turb_naca0012_2c.cfg_dir = "rans_uq/naca0012" turb_naca0012_2c.cfg_file = "turb_NACA0012_uq_2c.cfg" turb_naca0012_2c.test_iter = 10 - turb_naca0012_2c.test_vals = [-5.485136, 0.968075, 0.273236, -0.110320] + turb_naca0012_2c.test_vals = [-5.485136, 0.968303, 0.270450, -0.105529] test_list.append(turb_naca0012_2c) # NACA0012 3c @@ -693,7 +693,7 @@ def main(): turb_naca0012_3c.cfg_dir = "rans_uq/naca0012" turb_naca0012_3c.cfg_file = "turb_NACA0012_uq_3c.cfg" turb_naca0012_3c.test_iter = 10 - turb_naca0012_3c.test_vals = [-5.584305, 0.931248, 0.250749, -0.113574] + turb_naca0012_3c.test_vals = [-5.584305, 0.931441, 0.248013, -0.108776] test_list.append(turb_naca0012_3c) # NACA0012 p1c1 @@ -701,7 +701,7 @@ def main(): turb_naca0012_p1c1.cfg_dir = "rans_uq/naca0012" turb_naca0012_p1c1.cfg_file = "turb_NACA0012_uq_p1c1.cfg" turb_naca0012_p1c1.test_iter = 10 - turb_naca0012_p1c1.test_vals = [-5.120263, 1.074826, 0.294764, -0.109420] + turb_naca0012_p1c1.test_vals = [-5.120005, 1.075062, 0.291687, -0.104749] test_list.append(turb_naca0012_p1c1) # NACA0012 p1c2 @@ -709,7 +709,7 @@ def main(): turb_naca0012_p1c2.cfg_dir = "rans_uq/naca0012" turb_naca0012_p1c2.cfg_file = "turb_NACA0012_uq_p1c2.cfg" turb_naca0012_p1c2.test_iter = 10 - turb_naca0012_p1c2.test_vals = [-5.549132, 0.945637, 0.252403, -0.117491] + turb_naca0012_p1c2.test_vals = [-5.549133, 0.945821, 0.249565, -0.112728] test_list.append(turb_naca0012_p1c2) ###################################### @@ -769,7 +769,7 @@ def main(): square_cylinder.cfg_dir = "unsteady/square_cylinder" square_cylinder.cfg_file = "turb_square.cfg" square_cylinder.test_iter = 3 - square_cylinder.test_vals = [-2.560840, -1.173495, 0.061186, 1.399403, 2.220585, 1.399351, 2.218790, 0] + square_cylinder.test_vals = [-2.560840, -1.176728, 0.061952, 1.399401, 2.220371, 1.399349, 2.218609, 0.000000] square_cylinder.unsteady = True test_list.append(square_cylinder) @@ -864,7 +864,7 @@ def main(): Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" Jones_tc_restart.test_iter = 5 - Jones_tc_restart.test_vals = [-10.466644, -2.871703, -19.193464, -13.487820, -11.582397, -6.306167, 73273, 73273, 0.019884, 82.491] + Jones_tc_restart.test_vals = [-7.286680, -5.327029, -14.895646, -9.330526, -12.071730, -6.548621, 73291.000000, 73291.000000, 0.020111, 82.896000] test_list.append(Jones_tc_restart) # 2D axial stage @@ -872,7 +872,7 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [0.987679, 1.532118, -2.888457, 2.606793, -2.418303, 3.087091, 106380.000000, 106380.000000, 5.732900, 64.728000] + axial_stage2D.test_vals = [1.108169, 1.561824, -2.895047, 2.607614, -2.479708, 3.063739, 106380.000000, 106380.000000, 5.733600, 64.747000] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -880,8 +880,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-5.008547, -3.102420, -2.752033, 1.091152, -3.543849, 2.169844, -471630.000000, 94.866000, -0.035806] - transonic_stator_restart.test_vals_aarch64 = [-5.008547, -3.102420, -2.752033, 1.091152, -3.543849, 2.169844, -471630, 94.866, -0.035806] + transonic_stator_restart.test_vals = [-4.359318, -2.486927, -2.079507, 1.735899, -1.442225, 2.732961, -471620, 94.840000, -0.055455] + transonic_stator_restart.test_vals_aarch64 = [-4.359318, -2.486927, -2.079507, 1.735899, -1.442225, 2.732961, -471620, 94.840000, -0.055455] test_list.append(transonic_stator_restart) # Multiple turbomachinery interface restart @@ -972,7 +972,7 @@ def main(): bars_SST_2D.cfg_dir = "sliding_interface/bars_SST_2D" bars_SST_2D.cfg_file = "bars.cfg" bars_SST_2D.test_iter = 13 - bars_SST_2D.test_vals = [13.000000, -0.773513, -1.700012] + bars_SST_2D.test_vals = [13.000000, 0.268825, -1.700012] bars_SST_2D.multizone = True test_list.append(bars_SST_2D) @@ -1520,8 +1520,8 @@ def main(): pywrapper_turb_naca0012_sst.cfg_dir = "rans/naca0012" pywrapper_turb_naca0012_sst.cfg_file = "turb_NACA0012_sst.cfg" pywrapper_turb_naca0012_sst.test_iter = 10 - pywrapper_turb_naca0012_sst.test_vals = [-12.107132, -15.277740, -6.210248, 1.049757, 0.019249, -3.173936, 0] - pywrapper_turb_naca0012_sst.test_vals_aarch64 = [-12.107132, -15.277740, -6.210248, 1.049757, 0.019249, -3.173936, 0] + pywrapper_turb_naca0012_sst.test_vals = [-12.229890, -14.434837, -6.410709, 1.047444, 0.019214, -2.107944, 0] + pywrapper_turb_naca0012_sst.test_vals_aarch64 = [-12.229890, -14.434837, -6.410709, 1.047444, 0.019214, -2.107944, 0] pywrapper_turb_naca0012_sst.command = TestCase.Command(exec = "SU2_CFD.py", param = "-f") pywrapper_turb_naca0012_sst.timeout = 3200 pywrapper_turb_naca0012_sst.tol = 0.00001 @@ -1534,7 +1534,7 @@ def main(): pywrapper_square_cylinder.cfg_dir = "unsteady/square_cylinder" pywrapper_square_cylinder.cfg_file = "turb_square.cfg" pywrapper_square_cylinder.test_iter = 3 - pywrapper_square_cylinder.test_vals = [-2.560840, -1.173495, 0.061186, 1.399403, 2.220585, 1.399351, 2.218790, 0] + pywrapper_square_cylinder.test_vals = [-2.560840, -1.176728, 0.061952, 1.399401, 2.220371, 1.399349, 2.218609, 0.000000] pywrapper_square_cylinder.command = TestCase.Command(exec = "SU2_CFD.py", param = "-f") pywrapper_square_cylinder.timeout = 1600 pywrapper_square_cylinder.tol = 0.00001 @@ -1577,7 +1577,7 @@ def main(): pywrapper_unsteadyCHT.cfg_dir = "py_wrapper/flatPlate_unsteady_CHT" pywrapper_unsteadyCHT.cfg_file = "unsteady_CHT_FlatPlate_Conf.cfg" pywrapper_unsteadyCHT.test_iter = 5 - pywrapper_unsteadyCHT.test_vals = [-1.614167, 2.240658, 0.000772, 0.177467] + pywrapper_unsteadyCHT.test_vals = [-1.614167, 2.246123, 0.000771, 0.172998] pywrapper_unsteadyCHT.command = TestCase.Command(exec = "python", param = "launch_unsteady_CHT_FlatPlate.py -f") pywrapper_unsteadyCHT.timeout = 1600 pywrapper_unsteadyCHT.tol = 0.00001 @@ -1591,7 +1591,7 @@ def main(): pywrapper_rigidMotion.cfg_dir = "py_wrapper/flatPlate_rigidMotion" pywrapper_rigidMotion.cfg_file = "flatPlate_rigidMotion_Conf.cfg" pywrapper_rigidMotion.test_iter = 5 - pywrapper_rigidMotion.test_vals = [-1.614165, 2.238592, 0.349984, 0.095593] + pywrapper_rigidMotion.test_vals = [-1.614165, 2.243155, 0.350210, 0.089497] pywrapper_rigidMotion.command = TestCase.Command(exec = "python", param = "launch_flatPlate_rigidMotion.py -f") pywrapper_rigidMotion.timeout = 1600 pywrapper_rigidMotion.tol = 0.00001 diff --git a/TestCases/serial_regression_AD.py b/TestCases/serial_regression_AD.py index 620a3b20e8f9..9ec8ee3b716b 100644 --- a/TestCases/serial_regression_AD.py +++ b/TestCases/serial_regression_AD.py @@ -86,7 +86,7 @@ def main(): discadj_rans_naca0012_sst.cfg_dir = "disc_adj_rans/naca0012" discadj_rans_naca0012_sst.cfg_file = "turb_NACA0012_sst.cfg" discadj_rans_naca0012_sst.test_iter = 10 - discadj_rans_naca0012_sst.test_vals = [-2.127041, -0.204660, 0.335320, -0.022055] + discadj_rans_naca0012_sst.test_vals = [-2.130129, -0.206396, 0.339910, -0.022046] test_list.append(discadj_rans_naca0012_sst) ####################################### diff --git a/TestCases/tutorials.py b/TestCases/tutorials.py index f4a151bdaad7..a6b23824d35e 100644 --- a/TestCases/tutorials.py +++ b/TestCases/tutorials.py @@ -96,7 +96,7 @@ def main(): sudo_tutorial.cfg_dir = "../Tutorials/incompressible_flow/Inc_Turbulent_Bend_Wallfunctions" sudo_tutorial.cfg_file = "sudo.cfg" sudo_tutorial.test_iter = 10 - sudo_tutorial.test_vals = [-14.579462, -13.203791, -13.601782, -12.616876, -14.005299, -10.817605, 15.000000, -2.296083] + sudo_tutorial.test_vals = [-14.286992, -12.868418, -13.150195, -11.400439, -13.027783, -9.510980, 15.000000, -2.288151] sudo_tutorial.command = TestCase.Command("mpirun -n 2", "SU2_CFD") test_list.append(sudo_tutorial) @@ -105,7 +105,7 @@ def main(): sudo_design_primal.cfg_dir = "../Tutorials/design/Inc_Turbulent_Bend_Wallfunctions" sudo_design_primal.cfg_file = "sudo_primal.cfg" sudo_design_primal.test_iter = 10 - sudo_design_primal.test_vals = [-13.474698, -12.487574, -12.441102, -11.418111, -12.552674, -9.712569, 89.034000] + sudo_design_primal.test_vals = [-12.064068, -11.348930, -11.059284, -10.029629, -11.437307, -8.258444, 64.545000] sudo_design_primal.command = TestCase.Command("mpirun -n 2", "SU2_CFD") test_list.append(sudo_design_primal) @@ -114,7 +114,7 @@ def main(): sudo_design_adjoint.cfg_dir = "../Tutorials/design/Inc_Turbulent_Bend_Wallfunctions" sudo_design_adjoint.cfg_file = "sudo_adjoint.cfg" sudo_design_adjoint.test_iter = 10 - sudo_design_adjoint.test_vals = [-4.133194, -3.691046, -2.581693, -3.476472, -3.837900, -6.900137] + sudo_design_adjoint.test_vals = [-4.118073, -3.680088, -2.567859, -3.440055, -3.710829, -7.211066] sudo_design_adjoint.command = TestCase.Command("mpirun -n 2", "SU2_CFD_AD") test_list.append(sudo_design_adjoint) @@ -144,7 +144,7 @@ def main(): kenics_mixer_tutorial.cfg_dir = "../Tutorials/incompressible_flow/Inc_Species_Transport_Composition_Dependent_Model" kenics_mixer_tutorial.cfg_file = "kenics_mixer_tutorial.cfg" kenics_mixer_tutorial.test_iter = 10 - kenics_mixer_tutorial.test_vals = [-7.489796, -6.823473, -6.838032, -5.157793, -7.911512, -3.166212, -7.447901, 5.000000, -1.862212, 4.000000, -5.131048, 3.000000, -6.380193, 0.025472, 0.000000, 0.025472, 0.000000, 64.105000, 8.479200, 48.099000, 7.526700] + kenics_mixer_tutorial.test_vals = [-7.490002, -6.823162, -6.837602, -5.156401, -7.928782, -3.089710, -7.447882, 5.000000, -1.863053, 4.000000, -5.174845, 3.000000, -6.382936, 0.025471, 0.000000, 0.025471, 0.000000, 64.126000, 8.479400, 48.120000, 7.526800] kenics_mixer_tutorial.command = TestCase.Command("mpirun -n 2", "SU2_CFD") test_list.append(kenics_mixer_tutorial) @@ -228,7 +228,7 @@ def main(): tutorial_trans_flatplate_T3A.cfg_dir = "../Tutorials/compressible_flow/Transitional_Flat_Plate/Langtry_and_Menter/T3A" tutorial_trans_flatplate_T3A.cfg_file = "transitional_LM_model_ConfigFile.cfg" tutorial_trans_flatplate_T3A.test_iter = 20 - tutorial_trans_flatplate_T3A.test_vals = [-5.837399, -2.092246, -3.983493, -0.302381, -1.920868, 1.667180, -3.496278, 0.391608] + tutorial_trans_flatplate_T3A.test_vals = [-5.841281, -2.094610, -3.948081, -0.305564, -1.588781, 8.304710, -3.507210, 0.395186] tutorial_trans_flatplate_T3A.test_vals_aarch64 = [-5.837368, -2.092246, -3.984172, -0.302357, -1.928108, 1.667157, -3.496279, 0.391610] tutorial_trans_flatplate_T3A.no_restart = True test_list.append(tutorial_trans_flatplate_T3A) @@ -238,7 +238,7 @@ def main(): tutorial_trans_flatplate_T3Am.cfg_dir = "../Tutorials/compressible_flow/Transitional_Flat_Plate/Langtry_and_Menter/T3A-" tutorial_trans_flatplate_T3Am.cfg_file = "transitional_LM_model_ConfigFile.cfg" tutorial_trans_flatplate_T3Am.test_iter = 20 - tutorial_trans_flatplate_T3Am.test_vals = [-6.063700, -1.945073, -3.946836, -0.549147, -3.863792, 2.664440, -2.517610, 1.112977] + tutorial_trans_flatplate_T3Am.test_vals = [-6.206420, -2.029271, -4.028226, -0.685276, -3.893698, 6.726680, -2.520959, 0.948647] tutorial_trans_flatplate_T3Am.test_vals_aarch64 = [-6.063726, -1.945088, -3.946923, -0.549166, -3.863794, 2.664439, -2.517601, 1.112978] tutorial_trans_flatplate_T3Am.no_restart = True test_list.append(tutorial_trans_flatplate_T3Am) @@ -274,7 +274,7 @@ def main(): tutorial_nicfd_nozzle.cfg_dir = "../Tutorials/compressible_flow/NICFD_nozzle" tutorial_nicfd_nozzle.cfg_file = "NICFD_nozzle.cfg" tutorial_nicfd_nozzle.test_iter = 20 - tutorial_nicfd_nozzle.test_vals = [-2.056675, -2.124123, 3.687027, 0.000000, 0.000000] + tutorial_nicfd_nozzle.test_vals = [-2.056675, -2.124123, 3.687776, 0.000000, 0.000000] tutorial_nicfd_nozzle.no_restart = True test_list.append(tutorial_nicfd_nozzle) @@ -345,7 +345,7 @@ def main(): pass_list = [ test.run_test() for test in test_list ] - # design-FADO: 90 degree pipe bend optimization + # design-FADO: 90 degree pipe bend optimization sudo_design_fado = TestCase('sudo_bend_design_fado') sudo_design_fado.command = TestCase.Command(exec = "python", param = "optimization.py") sudo_design_fado.cfg_dir = "../Tutorials/design/Inc_Turbulent_Bend_Wallfunctions" diff --git a/TestCases/vandv.py b/TestCases/vandv.py index f9da69699942..4be2db6e5aad 100644 --- a/TestCases/vandv.py +++ b/TestCases/vandv.py @@ -54,8 +54,8 @@ def main(): flatplate_sst1994m.cfg_dir = "vandv/rans/flatplate" flatplate_sst1994m.cfg_file = "turb_flatplate_sst.cfg" flatplate_sst1994m.test_iter = 5 - flatplate_sst1994m.test_vals = [-13.045864, -10.962894, -11.543805, -8.355270, -11.200467, -5.084711, 0.002786] - flatplate_sst1994m.test_vals_aarch64 = [-13.045864, -10.962894, -11.543805, -8.355270, -11.200467, -5.084711, 0.002786] + flatplate_sst1994m.test_vals = [-13.026348, -9.634516, -10.706546, -7.560399, -9.926923, -5.237330, 0.002786] + flatplate_sst1994m.test_vals_aarch64 = [-13.026348, -9.634516, -10.706546, -7.560399, -9.926923, -5.237330, 0.002786] test_list.append(flatplate_sst1994m) # bump in channel - sst-v1994m @@ -63,8 +63,8 @@ def main(): bump_sst1994m.cfg_dir = "vandv/rans/bump_in_channel" bump_sst1994m.cfg_file = "turb_bump_sst.cfg" bump_sst1994m.test_iter = 5 - bump_sst1994m.test_vals = [-13.000658, -10.449108, -10.585058, -7.531737, -10.468414, -5.695067, 0.004904] - bump_sst1994m.test_vals_aarch64 = [-13.000658, -10.449108, -10.585058, -7.531737, -10.468414, -5.695067, 0.004904] + bump_sst1994m.test_vals = [-12.986997, -10.675928, -10.587885, -7.593707, -10.992547, -1.011790, 0.004900] + bump_sst1994m.test_vals_aarch64 = [-12.986997, -10.675928, -10.587885, -7.593707, -10.992547, -1.011790, 0.004900] test_list.append(bump_sst1994m) # SWBLI SA @@ -82,7 +82,7 @@ def main(): swbli_sst.cfg_dir = "vandv/rans/swbli" swbli_sst.cfg_file = "config_sst.cfg" swbli_sst.test_iter = 5 - swbli_sst.test_vals = [-11.505404, -10.756847, -11.931456, -10.349754, -11.606988, -4.851901, 0.002280, -1.521436, -3.777949, 1.340100] + swbli_sst.test_vals = [-11.502406, -10.850464, -11.572206, -10.370605, -11.405558, -4.349068, 0.001794, -1.450380, -3.681252, 10.000000] test_list.append(swbli_sst) ########################## @@ -94,7 +94,7 @@ def main(): sandiajet_sst.cfg_dir = "vandv/species_transport/sandia_jet" sandiajet_sst.cfg_file = "validation.cfg" sandiajet_sst.test_iter = 5 - sandiajet_sst.test_vals = [-17.169907, -13.518707, -15.442566, -12.021165, -9.660040, -15.289842, 5.000000, -2.746249, 5.000000, -4.836800, 5.000000, -3.966350, 0.000259, 0.000000, 0.000000, 0.000259, 4047.400000, 3946.800000, 49.161000, 51.433000] + sandiajet_sst.test_vals = [-17.198747, -14.117051, -15.599971, -14.054169, -10.364040, -15.739739, 5.000000, -3.100725, 5.000000, -5.353629, 5.000000, -4.200029, 0.000258, 0.000000, 0.000000, 0.000258, 4019.500000, 3918.900000, 49.151000, 51.436000] sandiajet_sst.test_vals_aarch64 = [-17.069026, -13.156800, -15.290567, -11.689831, -9.349978, -14.907311, 5.000000, -2.738947, 5.000000, -4.813747, 5.000000, -3.981740, 0.000259, 0.000000, 0.000000, 0.000259, 4047.400000, 3946.800000, 49.161000, 51.433000] test_list.append(sandiajet_sst) diff --git a/TestCases/vandv/rans/swbli/config_sst.cfg b/TestCases/vandv/rans/swbli/config_sst.cfg index efd2de113508..42d3684879fc 100644 --- a/TestCases/vandv/rans/swbli/config_sst.cfg +++ b/TestCases/vandv/rans/swbli/config_sst.cfg @@ -4,7 +4,7 @@ % SOLVER= RANS KIND_TURB_MODEL= SST -SST_OPTIONS= V2003m +SST_OPTIONS= V2003m, COMPRESSIBILITY-WILCOX REF_DIMENSIONALIZATION= FREESTREAM_VEL_EQ_MACH % % ----------------------------- FREESTREAM ------------------------------ % @@ -68,23 +68,23 @@ MUSCL_TURB= NO TIME_DISCRE_FLOW= EULER_IMPLICIT TIME_DISCRE_TURB= EULER_IMPLICIT % -CFL_NUMBER= 1 +CFL_NUMBER= 10 CFL_REDUCTION_TURB= 1 -CFL_ADAPT= YES +CFL_ADAPT= NO CFL_ADAPT_PARAM= ( 1.0, 1.05, 1, 50, 0.8 ) % LINEAR_SOLVER= FGMRES LINEAR_SOLVER_PREC= ILU -LINEAR_SOLVER_ERROR= 0.1 -LINEAR_SOLVER_ITER= 10 +LINEAR_SOLVER_ERROR= 0.01 +LINEAR_SOLVER_ITER= 3 % -NEWTON_KRYLOV= YES -NEWTON_KRYLOV_IPARAM= ( 0, 3, 1 ) % n0, np, ft +NEWTON_KRYLOV= NO +NEWTON_KRYLOV_IPARAM= ( 0, 0, 1 ) % n0, np, ft NEWTON_KRYLOV_DPARAM= ( 0.0, 1e-20, -3, 1e-5 ) % r0, tp, rf, e % % ------------------------ CONVERGENCE CRITERIA ------------------------- % % -ITER= 2000 +ITER= 20000 CONV_RESIDUAL_MINVAL= -11.5 % % --------------------------- INPUT / OUTPUT ---------------------------- % From 053eabd990e542e9d7d62b6002d2110bdd3e8d6d Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 7 Mar 2025 09:25:27 +0100 Subject: [PATCH 080/173] adding underelaxation factor option --- Common/include/CConfig.hpp | 8 +++++ Common/src/CConfig.cpp | 2 ++ .../include/solvers/CFVMFlowSolverBase.hpp | 6 ++-- SU2_CFD/include/solvers/CIncEulerSolver.hpp | 7 ++++ SU2_CFD/src/solvers/CIncEulerSolver.cpp | 35 +++++++++++++++++++ 5 files changed, 56 insertions(+), 2 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 2fb53e98d094..aa64b64108e5 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -579,6 +579,7 @@ class CConfig { bool ReconstructionGradientRequired; /*!< \brief Enable or disable a second gradient calculation for upwind reconstruction only. */ bool LeastSquaresRequired; /*!< \brief Enable or disable memory allocation for least-squares gradient methods. */ bool Energy_Equation; /*!< \brief Solve the energy equation for incompressible flows. */ + bool Relaxation_Inc; /*!< \brief Enable relaxation factor in the energy equation for incompressible flows. */ UPWIND Kind_Upwind, /*!< \brief Upwind scheme. */ @@ -4070,6 +4071,13 @@ class CConfig { */ bool GetEnergy_Equation(void) const { return Energy_Equation; } + /*! + * \brief Flag for enabling relaxation factor in energy equation for incompressible flows. + * \return Flag for relaxation factor in energy equation for incom + */ + + bool GetRelaxationIncEnergy_Equation(void) const { return Relaxation_Inc; } + /*! * \brief free stream option to initialize the solution * \return free stream option diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 05ba6e235206..e10cb3ca0b20 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1366,6 +1366,8 @@ void CConfig::SetConfig_Options() { addEnumOption("INC_DENSITY_MODEL", Kind_DensityModel, DensityModel_Map, INC_DENSITYMODEL::CONSTANT); /*!\brief ENERGY_EQUATION \n DESCRIPTION: Solve the energy equation in the incompressible flow solver. \ingroup Config*/ addBoolOption("INC_ENERGY_EQUATION", Energy_Equation, false); + /* DESCRIPTION: Option to enable the use of Relaxation factor for energy equation in incompressible flows */ + addBoolOption("RELAXATION_ENERGY_INC", Relaxation_Inc, false); /*!\brief INC_DENSITY_REF \n DESCRIPTION: Reference density for incompressible flows \ingroup Config*/ addDoubleOption("INC_DENSITY_REF", Inc_Density_Ref, 1.0); /*!\brief INC_VELOCITY_REF \n DESCRIPTION: Reference velocity for incompressible flows (1.0 by default) \ingroup Config*/ diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp index 6f548e3ad312..c291e4082e1f 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp @@ -981,8 +981,10 @@ class CFVMFlowSolverBase : public CSolver { */ template void CompleteImplicitIteration_impl(CGeometry *geometry, CConfig *config) { - - if (compute_ur) ComputeUnderRelaxationFactor(config); + + bool enable_compute_ur = compute_ur; + if (config->GetRelaxationIncEnergy_Equation()) enable_compute_ur = true; + if (enable_compute_ur) ComputeUnderRelaxationFactor(config); /*--- Update solution with under-relaxation and communicate it. ---*/ diff --git a/SU2_CFD/include/solvers/CIncEulerSolver.hpp b/SU2_CFD/include/solvers/CIncEulerSolver.hpp index 50c52d4654a0..ab9638dd1417 100644 --- a/SU2_CFD/include/solvers/CIncEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CIncEulerSolver.hpp @@ -434,4 +434,11 @@ class CIncEulerSolver : public CFVMFlowSolverBase(geometry, config); } +void CIncEulerSolver::ComputeUnderRelaxationFactor(const CConfig* config) { + + /* Loop over the solution update given by relaxing the linear + system for this nonlinear iteration. */ + + const su2double allowableRatio = 0.2; + + SU2_OMP_FOR_STAT(omp_chunk_size) + + for (auto iPoint = 0ul; iPoint < nPointDomain; iPoint++) { + su2double localUnderRelaxation = 1.0; + + /*--- Energy ---*/ + + const unsigned long index = iPoint * nVar + nVar - 1; + + su2double ratio = fabs(LinSysSol[index]) / (fabs(nodes->GetSolution(iPoint, nVar - 1)) + EPS); + + if (ratio > allowableRatio) { + localUnderRelaxation = min(allowableRatio / ratio, localUnderRelaxation); + } + + /* Threshold the relaxation factor in the event that there is + a very small value. This helps avoid catastrophic crashes due + to non-realizable states by canceling the update. */ + + if (localUnderRelaxation < 1e-10) localUnderRelaxation = 0.0; + + /* Store the under-relaxation factor for this point. */ + + nodes->SetUnderRelaxation(iPoint, localUnderRelaxation); + } + + END_SU2_OMP_FOR +} void CIncEulerSolver::SetBeta_Parameter(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { From 36566b7db0adc6670710a720820105c70dd5482f Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 7 Mar 2025 11:39:03 +0100 Subject: [PATCH 081/173] adding lowerlimit for underrelaxation factor --- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index c7e29e8ca5fe..7fd5cf25fe2b 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2080,7 +2080,7 @@ void CIncEulerSolver::CompleteImplicitIteration(CGeometry *geometry, CSolver**, CompleteImplicitIteration_impl(geometry, config); } void CIncEulerSolver::ComputeUnderRelaxationFactor(const CConfig* config) { - + /* Loop over the solution update given by relaxing the linear system for this nonlinear iteration. */ @@ -2105,7 +2105,7 @@ void CIncEulerSolver::ComputeUnderRelaxationFactor(const CConfig* config) { a very small value. This helps avoid catastrophic crashes due to non-realizable states by canceling the update. */ - if (localUnderRelaxation < 1e-10) localUnderRelaxation = 0.0; + if (localUnderRelaxation < 1e-3) localUnderRelaxation = 0.001; /* Store the under-relaxation factor for this point. */ From 75e3c71072114def7a862561ee42e1b29519af1c Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 14 Mar 2025 08:16:54 +0100 Subject: [PATCH 082/173] add EPS species transport --- SU2_CFD/include/variables/CVariable.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index fe5191f89610..fd3c759f0ccd 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -455,6 +455,8 @@ class CVariable { su2double val_new = (Solution_Old(iPoint,iVar)*Sol2Conservative_old + solution)/Sol2Conservative; Solution(iPoint,iVar) = min(max(val_new, lowerlimit), upperlimit); + const su2double EPS = 1e-12; + if (Solution(iPoint, iVar) <= EPS) Solution(iPoint, iVar) = 0.0; } /*! From 282396afcee8d6023afee7d5319ad957be4d15c6 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 14 Mar 2025 11:06:01 +0100 Subject: [PATCH 083/173] unable gradient chemical source term --- SU2_CFD/src/fluid/CFluidCantera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index ab26c2bdc73e..790c9875fa3d 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -125,7 +125,7 @@ void CFluidCantera::ComputeGradChemicalSourceTerm(const su2double* val_scalars) //su2double scalars_sum = 0.0; const su2double dT_dYi = uni_gas_constant_temp * (enthalpiesSpecies[speciesN] - enthalpiesSpecies[speciesIndex_i]) / Cp; - gradChemicalSourceTerm[iVar] = molarMasses[speciesIndex_i] * netProductionRates_T[speciesIndex_i] * dT_dYi; + gradChemicalSourceTerm[iVar] = 0.0; //molarMasses[speciesIndex_i] * netProductionRates_T[speciesIndex_i] * dT_dYi; // for (int jVar = 0; jVar < n_species_mixture - 1; jVar++) { // int speciesIndex_j = sol->thermo()->speciesIndex(gasComposition[jVar]); // su2double dW_dCi = dW_dC.coeff(iVar,jVar) * molarMasses[speciesIndex_i]; From 56f0d86dac3b6ce2431dc730f41e5f677b1ac60b Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 14 Mar 2025 14:27:04 +0100 Subject: [PATCH 084/173] undo EPS change --- SU2_CFD/include/variables/CVariable.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index fd3c759f0ccd..fe5191f89610 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -455,8 +455,6 @@ class CVariable { su2double val_new = (Solution_Old(iPoint,iVar)*Sol2Conservative_old + solution)/Sol2Conservative; Solution(iPoint,iVar) = min(max(val_new, lowerlimit), upperlimit); - const su2double EPS = 1e-12; - if (Solution(iPoint, iVar) <= EPS) Solution(iPoint, iVar) = 0.0; } /*! From 5eec6ad280eca432ec14bcff4bfa95aacf89c50e Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 14 Mar 2025 16:02:56 +0100 Subject: [PATCH 085/173] enable chemical gradient --- SU2_CFD/src/fluid/CFluidCantera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 790c9875fa3d..ab26c2bdc73e 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -125,7 +125,7 @@ void CFluidCantera::ComputeGradChemicalSourceTerm(const su2double* val_scalars) //su2double scalars_sum = 0.0; const su2double dT_dYi = uni_gas_constant_temp * (enthalpiesSpecies[speciesN] - enthalpiesSpecies[speciesIndex_i]) / Cp; - gradChemicalSourceTerm[iVar] = 0.0; //molarMasses[speciesIndex_i] * netProductionRates_T[speciesIndex_i] * dT_dYi; + gradChemicalSourceTerm[iVar] = molarMasses[speciesIndex_i] * netProductionRates_T[speciesIndex_i] * dT_dYi; // for (int jVar = 0; jVar < n_species_mixture - 1; jVar++) { // int speciesIndex_j = sol->thermo()->speciesIndex(gasComposition[jVar]); // su2double dW_dCi = dW_dC.coeff(iVar,jVar) * molarMasses[speciesIndex_i]; From 1b7bba059b3ae849a9327c82fc99a19003c560f4 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 24 Mar 2025 16:44:12 +0100 Subject: [PATCH 086/173] adding mass flux correction continuity equation --- SU2_CFD/include/fluid/CFluidCantera.hpp | 5 +++++ SU2_CFD/include/fluid/CFluidModel.hpp | 5 +++++ SU2_CFD/include/fluid/CFluidScalar.hpp | 5 +++++ SU2_CFD/include/numerics/CNumerics.hpp | 8 ++++++++ SU2_CFD/src/fluid/CFluidCantera.cpp | 11 +++++++++++ SU2_CFD/src/fluid/CFluidScalar.cpp | 6 ++++++ SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 1 + SU2_CFD/src/solvers/CIncNSSolver.cpp | 9 +++++++++ 8 files changed, 50 insertions(+) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 909682d5c4ad..b50dc9e7f100 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -159,6 +159,11 @@ class CFluidCantera final : public CFluidModel { */ void GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) override; + /*! + * \brief Get enthalpy diffusivity terms. + */ + void GetMassCorrectionDiffusivity(su2double* MassCorrection_diffusions) override; + /*! * \brief Get gradient enthalpy diffusivity terms. */ diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 1a832bb52412..666c8435dbff 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -214,6 +214,11 @@ class CFluidModel { */ virtual void GetEnthalpyDiffusivity(su2double* enthalpy_diffusions = nullptr) {} + /*! + * \brief Get heat diffusivity terms. + */ + virtual void GetMassCorrectionDiffusivity(su2double* massCorrection_diffusions = nullptr) {} + /*! * \brief Get gradient heat diffusivity terms. */ diff --git a/SU2_CFD/include/fluid/CFluidScalar.hpp b/SU2_CFD/include/fluid/CFluidScalar.hpp index 5c0618de43cc..b5c4b74acae3 100644 --- a/SU2_CFD/include/fluid/CFluidScalar.hpp +++ b/SU2_CFD/include/fluid/CFluidScalar.hpp @@ -148,6 +148,11 @@ class CFluidScalar final : public CFluidModel { */ void GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) override; + /*! + * \brief Get enthalpy diffusivity terms. + */ + void GetMassCorrectionDiffusivity(su2double* massCorrection_diffusions) override; + /*! * \brief Get gradient enthalpy diffusivity terms. */ diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 7ca954215295..18b744a2c313 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -140,6 +140,8 @@ class CNumerics { su2double HeatFluxDiffusion; /*!< \brief Heat flux due to enthalpy diffusion for multicomponent. */ su2double + MassCorrFluxDiffusion; /*!< \brief Mass flux correction due to species diffusion for multicomponent. */ + su2double Jac_HeatFluxDiffusion; /*!< \brief Heat flux jacobian due to enthalpy diffusion for multicomponent. */ const su2double *TransVar_i, /*!< \brief Vector of turbulent variables at point i. */ @@ -791,6 +793,12 @@ class CNumerics { */ inline void SetHeatFluxDiffusion(su2double val_heatfluxdiffusion) { HeatFluxDiffusion = val_heatfluxdiffusion; } + /*! + * \brief Set the mass flux correction due to species diffusion + * \param[in] val_masscorrfluxdiffusion - Value of the mass flux correction due to species diffusion. + */ + inline void SetMassCorrFluxDiffusion(su2double val_masscorrfluxdiffusion) { MassCorrFluxDiffusion = val_masscorrfluxdiffusion; } + /*! * \brief Set Jacobian of the heat flux due to enthalpy diffusion * \param[in] val_jacheatfluxdiffusion - Value of the heat flux jacobian due to enthalpy diffusion. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index ab26c2bdc73e..30bf6d6fdf41 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -182,6 +182,17 @@ void CFluidCantera::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) { } } +void CFluidCantera::GetMassCorrectionDiffusivity(su2double* massCorrection_diffusions) { + const int nsp = sol->thermo()->nSpecies(); + vector diff(nsp); + sol->transport()->getMixDiffCoeffsMass(&diff[0]); + const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); + for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { + int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); + massCorrection_diffusions[iVar] = Density * (diff[speciesIndex] - diff[speciesN]); + } +} + void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusions) { const int nsp = sol->thermo()->nSpecies(); // The universal gas constant is retrieved from cantera,in order to keep consistency with the values retrieve from it. diff --git a/SU2_CFD/src/fluid/CFluidScalar.cpp b/SU2_CFD/src/fluid/CFluidScalar.cpp index ac22fb7d5f3d..618f353c925f 100644 --- a/SU2_CFD/src/fluid/CFluidScalar.cpp +++ b/SU2_CFD/src/fluid/CFluidScalar.cpp @@ -234,6 +234,12 @@ void CFluidScalar::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) { } } +void CFluidScalar::GetMassCorrectionDiffusivity(su2double* massCorrection_diffusions) { + for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { + massCorrection_diffusions[iVar] = Density * (massDiffusivity[iVar] - massDiffusivity[n_species_mixture - 1]); + } +} + void CFluidScalar::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusions){ for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { grad_enthalpy_diffusions[iVar] = Density * diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index 0bfce624285c..31b370c3fb71 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -626,6 +626,7 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity); if (energy_multicomponent) { + Proj_Flux_Tensor[0] += MassCorrFluxDiffusion; Proj_Flux_Tensor[nVar - 1] += HeatFluxDiffusion; } diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index e3c3943f2977..55c73c0ef472 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -393,25 +393,33 @@ void CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CS /*--- Get enthalpy diffusion terms and its gradient(for implicit) for each species at point i. ---*/ su2double EnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; + su2double MassCorrectionDiffusion_i[MAXNVAR_SPECIES]{0.0}; su2double GradEnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; FluidModel->SetTDState_T(nodes->GetPrimitive(iPoint)[prim_idx.Temperature()], Species_i); FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion_i); + FluidModel->GetMassCorrectionDiffusivity(MassCorrectionDiffusion_i); if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion_i); /*--- Repeat the above computations for jPoint. ---*/ su2double EnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; + su2double MassCorrectionDiffusion_j[MAXNVAR_SPECIES]{0.0}; su2double GradEnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; FluidModel->SetTDState_T(nodes->GetPrimitive(jPoint)[prim_idx.Temperature()], Species_j); FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion_j); + FluidModel->GetMassCorrectionDiffusivity(MassCorrectionDiffusion_j); if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion_j); /*--- Compute Enthalpy diffusion flux and its jacobian (for implicit iterations) ---*/ su2double flux_enthalpy_diffusion = 0.0; + su2double flux_massCorrection_diffusion = 0.0; su2double jac_flux_enthalpy_diffusion = 0.0; for (int i_species = 0; i_species < n_species; i_species++) { flux_enthalpy_diffusion += 0.5 * (EnthalpyDiffusion_i[i_species] + EnthalpyDiffusion_j[i_species]) * Proj_Mean_GradScalarVar[i_species]; + flux_massCorrection_diffusion += 0.5 * + (MassCorrectionDiffusion_i[i_species] + MassCorrectionDiffusion_j[i_species]) * + Proj_Mean_GradScalarVar[i_species]; if (implicit) jac_flux_enthalpy_diffusion += 0.5 * (GradEnthalpyDiffusion_i[i_species] + GradEnthalpyDiffusion_j[i_species]) * Proj_Mean_GradScalarVar[i_species]; @@ -420,6 +428,7 @@ void CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CS /*--- Set heat flux and jacobian (for implicit) due to enthalpy diffusion ---*/ numerics->SetHeatFluxDiffusion(flux_enthalpy_diffusion); + numerics->SetMassCorrFluxDiffusion(flux_massCorrection_diffusion); if (implicit) numerics->SetJacHeatFluxDiffusion(jac_flux_enthalpy_diffusion); } Viscous_Residual_impl(iEdge, geometry, solver_container, numerics, config); From 72046b0d5f6439d75fba21e3bc2a8847c2165365 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 31 Mar 2025 11:36:55 +0200 Subject: [PATCH 087/173] test source average --- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index f4711c168d66..6bca1a206651 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -612,9 +612,22 @@ void CSpeciesSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta SU2_OMP_FOR_DYN(omp_chunk_size) for (auto iPoint = 0u; iPoint < nPointDomain; iPoint++) { + auto nodes_geometry = geometry->nodes; + int count = 0; + su2double source_average[MAXNVAR] = {0.0}; + for (size_t iNeigh = 0; iNeigh < nodes_geometry->GetnPoint(iPoint); ++iNeigh) { + size_t jPoint = nodes_geometry->GetPoint(iPoint, iNeigh); + for (int iVar=0.0; iVar GetChemicalSourceTerm(jPoint)[iVar]; + } + count +=1; + } + for (int iVar = 0.0; iVar < nVar; iVar++){ + source_average[iVar] /= count; + } /*--- Set Chemical Source Term ---*/ - numerics->SetChemicalSourceTerm(nodes->GetChemicalSourceTerm(iPoint), nullptr); + numerics->SetChemicalSourceTerm(source_average, nullptr); if (implicit) { numerics->SetGradChemicalSourceTerm(nodes->GetGradChemicalSourceTerm(iPoint), nullptr); numerics->SetDensity(solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint), From 1304b05bfa41640c0d038355cc7bbc3285ff932c Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 1 Apr 2025 18:14:14 +0200 Subject: [PATCH 088/173] undo average source term and retrieving delta time --- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index 6bca1a206651..cc33a8a62348 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -335,6 +335,9 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain const su2double mass_diffusivity = solver_container[FLOW_SOL]->GetFluidModel()->GetMassDiffusivity(iVar); nodes->SetDiffusivity(iPoint, mass_diffusivity, iVar); if (config->GetCombustion() == true) { + /*--- Retrieve delta time step ---*/ + su2double delta_time = solver_container[FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint); + /*--- call function integrate chemical source term ---*/ const su2double chemical_source_term=solver_container[FLOW_SOL]->GetFluidModel()->GetChemicalSourceTerm(iVar); nodes->SetChemicalSourceTerm(iPoint, chemical_source_term, iVar); if (implicit) { @@ -612,22 +615,9 @@ void CSpeciesSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta SU2_OMP_FOR_DYN(omp_chunk_size) for (auto iPoint = 0u; iPoint < nPointDomain; iPoint++) { - auto nodes_geometry = geometry->nodes; - int count = 0; - su2double source_average[MAXNVAR] = {0.0}; - for (size_t iNeigh = 0; iNeigh < nodes_geometry->GetnPoint(iPoint); ++iNeigh) { - size_t jPoint = nodes_geometry->GetPoint(iPoint, iNeigh); - for (int iVar=0.0; iVar GetChemicalSourceTerm(jPoint)[iVar]; - } - count +=1; - } - for (int iVar = 0.0; iVar < nVar; iVar++){ - source_average[iVar] /= count; - } /*--- Set Chemical Source Term ---*/ - numerics->SetChemicalSourceTerm(source_average, nullptr); + numerics->SetChemicalSourceTerm(nodes->GetChemicalSourceTerm(iPoint), nullptr); if (implicit) { numerics->SetGradChemicalSourceTerm(nodes->GetGradChemicalSourceTerm(iPoint), nullptr); numerics->SetDensity(solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint), From 1e624d2bb653b3f15fa14e251e00ad3fe072dc6a Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 7 Apr 2025 09:28:29 +0200 Subject: [PATCH 089/173] test bash reactor --- SU2_CFD/include/fluid/CFluidCantera.hpp | 15 ++++++++----- SU2_CFD/include/fluid/CFluidModel.hpp | 6 +++++ SU2_CFD/src/fluid/CFluidCantera.cpp | 29 +++++++++++++++++++------ SU2_CFD/src/solvers/CSpeciesSolver.cpp | 1 + 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index b50dc9e7f100..3b1486301687 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -36,6 +36,8 @@ #define USE_CANTERA namespace Cantera { class Solution; +class IdealGasConstPressureReactor; +class ReactorNet; } #endif @@ -58,6 +60,8 @@ class CFluidCantera final : public CFluidModel { static constexpr int ARRAYSIZE = 16; #ifdef USE_CANTERA + Cantera::IdealGasConstPressureReactor* combustor; + Cantera::ReactorNet* sim; std::array gasComposition; /*!< \brief Gas composition. */ std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ std::array chemicalSourceTerm; /*!< \brief chemical source term of all species*/ @@ -82,11 +86,6 @@ class CFluidCantera final : public CFluidModel { */ void ComputeMassDiffusivity(); - /*! - * \brief Compute chemical source term for species. - */ - void ComputeChemicalSourceTerm(); - /*! * \brief Compute Gradient chemical source terms. * \param[in] val_scalars - Scalar mass fraction. @@ -131,6 +130,12 @@ class CFluidCantera final : public CFluidModel { inline su2double GetMassDiffusivity(int ivar) override { return massDiffusivity[ivar]; } #ifdef USE_CANTERA + /*! + * \brief Compute chemical source term for species. + * \param[in] delta_time - time integration flow solver. + */ + void ComputeChemicalSourceTerm(su2double delta_time, const su2double* val_scalars) override; + /*! * \brief Get Chemical source term species. * \param[in] ivar - index of species. diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 666c8435dbff..1e7810085ff8 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -192,6 +192,12 @@ class CFluidModel { return mass_diffusivity; } + /*! + * \brief Compute chemical source term for species. + * \param[in] delta_time - time integration flow solver. + */ + virtual void ComputeChemicalSourceTerm(su2double delta_time, const su2double* val_scalars = nullptr) {}; + /*! * \brief Get Chemical source term species. * \param[in] iVar - index of species. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 30bf6d6fdf41..74c45c0688ed 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -35,6 +35,7 @@ #include "/home/cristopher/codes/cantera/include/cantera/core.h" #include "/home/cristopher/codes/cantera/include/cantera/kinetics/Reaction.h" +#include "/home/cristopher/codes/cantera/include/cantera/zerodim.h" #include #include @@ -58,6 +59,14 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* #ifdef USE_CANTERA sol = std::shared_ptr(newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model)); sol->thermo()->getMolecularWeights(&molarMasses[0]); + combustor = nullptr; + sim = nullptr; + if (config->GetCombustion()) { + combustor = new IdealGasConstPressureReactor(); + //combustor->insert(sol); + sim = new ReactorNet(); + sim->addReactor(*combustor); + } for (int iVar = 0; iVar < n_species_mixture; iVar++) { gasComposition[iVar]=config->GetChemical_GasComposition(iVar); //config->SetChemical_GasComposition(iVar, gasComposition[iVar]); //this should be used for later @@ -99,13 +108,19 @@ void CFluidCantera::ComputeMassDiffusivity() { } } -void CFluidCantera::ComputeChemicalSourceTerm(){ - const int nsp = sol->thermo()->nSpecies(); - vector netProductionRates(nsp); - sol->kinetics()->getNetProductionRates(&netProductionRates[0]); - for (int iVar = 0; iVar < n_species_mixture; iVar++) { +void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2double* val_scalars){ + // const int nsp = sol->thermo()->nSpecies(); + // vector netProductionRates(nsp); + // sol->kinetics()->getNetProductionRates(&netProductionRates[0]); + combustor->insert(sol); + sim->setInitialTime(0.0); + sim->advance(delta_time); + for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - chemicalSourceTerm[iVar] = molarMasses[speciesIndex]*netProductionRates[speciesIndex]; + const su2double scalar_new = combustor->massFraction(speciesIndex); + const su2double density_new = combustor->density(); + const su2double source_term_corr = (density_new * scalar_new - Density * val_scalars[iVar]) / abs(delta_time); + chemicalSourceTerm[iVar] = source_term_corr; //molarMasses[speciesIndex]*netProductionRates[speciesIndex]; } } @@ -269,7 +284,7 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl Kt = sol->transport()->thermalConductivity(); ComputeMassDiffusivity(); - ComputeChemicalSourceTerm(); + //ComputeChemicalSourceTerm(); ComputeGradChemicalSourceTerm(val_scalars); ComputeHeatRelease(); } diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index cc33a8a62348..458ba9b403fe 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -338,6 +338,7 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain /*--- Retrieve delta time step ---*/ su2double delta_time = solver_container[FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint); /*--- call function integrate chemical source term ---*/ + solver_container[FLOW_SOL]->GetFluidModel()->ComputeChemicalSourceTerm(delta_time, scalar); const su2double chemical_source_term=solver_container[FLOW_SOL]->GetFluidModel()->GetChemicalSourceTerm(iVar); nodes->SetChemicalSourceTerm(iPoint, chemical_source_term, iVar); if (implicit) { From 0da0297512a0f0d0472e940a7e7ffd0048f41115 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 8 Apr 2025 10:46:23 +0200 Subject: [PATCH 090/173] set temperature limit --- SU2_CFD/src/fluid/CFluidCantera.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 74c45c0688ed..d5b1b0590d95 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -113,6 +113,8 @@ void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2dou // vector netProductionRates(nsp); // sol->kinetics()->getNetProductionRates(&netProductionRates[0]); combustor->insert(sol); + su2double Delta_t_max = 20; + combustor->setAdvanceLimit("temperature", Delta_t_max); sim->setInitialTime(0.0); sim->advance(delta_time); for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { From fc0419f3c56075d5f6481ceceba1962e05387e01 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 9 Apr 2025 13:05:16 +0200 Subject: [PATCH 091/173] recomputation source terms batch reactor --- SU2_CFD/src/fluid/CFluidCantera.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index d5b1b0590d95..44e9bd633452 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -63,9 +63,11 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* sim = nullptr; if (config->GetCombustion()) { combustor = new IdealGasConstPressureReactor(); - //combustor->insert(sol); + combustor->insert(sol); sim = new ReactorNet(); sim->addReactor(*combustor); + su2double Delta_t_max = 20; + combustor->setAdvanceLimit("temperature", Delta_t_max); } for (int iVar = 0; iVar < n_species_mixture; iVar++) { gasComposition[iVar]=config->GetChemical_GasComposition(iVar); @@ -109,20 +111,25 @@ void CFluidCantera::ComputeMassDiffusivity() { } void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2double* val_scalars){ - // const int nsp = sol->thermo()->nSpecies(); - // vector netProductionRates(nsp); - // sol->kinetics()->getNetProductionRates(&netProductionRates[0]); combustor->insert(sol); - su2double Delta_t_max = 20; - combustor->setAdvanceLimit("temperature", Delta_t_max); sim->setInitialTime(0.0); + //delta_time = 1.0;//E-12; sim->advance(delta_time); + su2double scalar_new[n_species_mixture]{0.0}; for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - const su2double scalar_new = combustor->massFraction(speciesIndex); - const su2double density_new = combustor->density(); - const su2double source_term_corr = (density_new * scalar_new - Density * val_scalars[iVar]) / abs(delta_time); - chemicalSourceTerm[iVar] = source_term_corr; //molarMasses[speciesIndex]*netProductionRates[speciesIndex]; + scalar_new[iVar] = combustor->massFraction(speciesIndex); + const su2double temp_comb = combustor->temperature(); + } + DictionaryChemicalComposition(scalar_new); + su2double temperature_comb = combustor->temperature(); + sol->thermo()->setState_TPY(GetValue(temperature_comb), GetValue(Pressure_Thermodynamic), chemical_composition); + const int nsp = sol->thermo()->nSpecies(); + vector netProductionRates(nsp); + sol->kinetics()->getNetProductionRates(&netProductionRates[0]); + for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { + int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); + chemicalSourceTerm[iVar] = molarMasses[speciesIndex]*netProductionRates[speciesIndex]; } } From b429804804ccd42b9c79609dd844fdface90daae Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 9 Apr 2025 14:07:22 +0200 Subject: [PATCH 092/173] small fix --- SU2_CFD/src/fluid/CFluidCantera.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 44e9bd633452..15ccc04ba886 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -122,8 +122,8 @@ void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2dou const su2double temp_comb = combustor->temperature(); } DictionaryChemicalComposition(scalar_new); - su2double temperature_comb = combustor->temperature(); - sol->thermo()->setState_TPY(GetValue(temperature_comb), GetValue(Pressure_Thermodynamic), chemical_composition); + //su2double temperature_comb = combustor->temperature(); + sol->thermo()->setState_TPY(GetValue(Temperature), GetValue(Pressure_Thermodynamic), chemical_composition); const int nsp = sol->thermo()->nSpecies(); vector netProductionRates(nsp); sol->kinetics()->getNetProductionRates(&netProductionRates[0]); From de7879a05531f524bbd81ab944a0a5776c944b7c Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 10 Apr 2025 16:44:29 +0200 Subject: [PATCH 093/173] test computing mean integral --- SU2_CFD/src/fluid/CFluidCantera.cpp | 46 +++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 15ccc04ba886..f5371ddfdb46 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -111,26 +111,48 @@ void CFluidCantera::ComputeMassDiffusivity() { } void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2double* val_scalars){ + const int n_step = 100; combustor->insert(sol); sim->setInitialTime(0.0); - //delta_time = 1.0;//E-12; - sim->advance(delta_time); - su2double scalar_new[n_species_mixture]{0.0}; - for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { - int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - scalar_new[iVar] = combustor->massFraction(speciesIndex); - const su2double temp_comb = combustor->temperature(); - } - DictionaryChemicalComposition(scalar_new); - //su2double temperature_comb = combustor->temperature(); - sol->thermo()->setState_TPY(GetValue(Temperature), GetValue(Pressure_Thermodynamic), chemical_composition); const int nsp = sol->thermo()->nSpecies(); vector netProductionRates(nsp); sol->kinetics()->getNetProductionRates(&netProductionRates[0]); for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - chemicalSourceTerm[iVar] = molarMasses[speciesIndex]*netProductionRates[speciesIndex]; + chemicalSourceTerm[iVar] = molarMasses[speciesIndex]*netProductionRates[speciesIndex]/ n_step; + } + //delta_time = 1.0;//E-12; + su2double delta_time_check = max(0.1*delta_time, 1E-12); + su2double scalar_new[n_species_mixture]{0.0}; + for (int i_step = 1; i_step < n_step; i_step++){ + sim->advance(delta_time_check * i_step / n_step); + for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { + int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); + scalar_new[iVar] = combustor->massFraction(speciesIndex); + const su2double temp_comb = combustor->temperature(); + } + DictionaryChemicalComposition(scalar_new); + sol->thermo()->setState_TPY(GetValue(Temperature), GetValue(Pressure_Thermodynamic), chemical_composition); + sol->kinetics()->getNetProductionRates(&netProductionRates[0]); + for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { + int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); + chemicalSourceTerm[iVar]+= molarMasses[speciesIndex] * netProductionRates[speciesIndex]/n_step; + } } + // for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { + // int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); + // scalar_new[iVar] = combustor->massFraction(speciesIndex); + // const su2double temp_comb = combustor->temperature(); + // } + // DictionaryChemicalComposition(scalar_new); + // sol->thermo()->setState_TPY(GetValue(Temperature), GetValue(Pressure_Thermodynamic), chemical_composition); + // // const int nsp = sol->thermo()->nSpecies(); + // // vector netProductionRates(nsp); + // sol->kinetics()->getNetProductionRates(&netProductionRates[0]); + // for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { + // int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); + // chemicalSourceTerm[iVar] = molarMasses[speciesIndex]*netProductionRates[speciesIndex]; + // } } void CFluidCantera::ComputeGradChemicalSourceTerm(const su2double* val_scalars) { From 91757d01b93fa69f94a096f379f00ca993b4ab9d Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 14 Apr 2025 12:45:23 +0200 Subject: [PATCH 094/173] chemical source --- SU2_CFD/src/fluid/CFluidCantera.cpp | 45 +++++------------------------ 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index f5371ddfdb46..de6ad573dd51 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -111,48 +111,19 @@ void CFluidCantera::ComputeMassDiffusivity() { } void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2double* val_scalars){ - const int n_step = 100; combustor->insert(sol); sim->setInitialTime(0.0); - const int nsp = sol->thermo()->nSpecies(); - vector netProductionRates(nsp); - sol->kinetics()->getNetProductionRates(&netProductionRates[0]); + //const int nsp = sol->thermo()->nSpecies(); + // vector netProductionRates(nsp); + // sol->kinetics()->getNetProductionRates(&netProductionRates[0]); + sim->advance(delta_time); + const su2double density_new = combustor->density(); for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - chemicalSourceTerm[iVar] = molarMasses[speciesIndex]*netProductionRates[speciesIndex]/ n_step; + const su2double scalar_new = combustor->massFraction(speciesIndex); + const su2double source_term_corr = (density_new * scalar_new - Density * val_scalars[iVar]) / abs(delta_time); + chemicalSourceTerm[iVar] = source_term_corr; // molarMasses[speciesIndex]*netProductionRates[speciesIndex]/ n_step; } - //delta_time = 1.0;//E-12; - su2double delta_time_check = max(0.1*delta_time, 1E-12); - su2double scalar_new[n_species_mixture]{0.0}; - for (int i_step = 1; i_step < n_step; i_step++){ - sim->advance(delta_time_check * i_step / n_step); - for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { - int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - scalar_new[iVar] = combustor->massFraction(speciesIndex); - const su2double temp_comb = combustor->temperature(); - } - DictionaryChemicalComposition(scalar_new); - sol->thermo()->setState_TPY(GetValue(Temperature), GetValue(Pressure_Thermodynamic), chemical_composition); - sol->kinetics()->getNetProductionRates(&netProductionRates[0]); - for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { - int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - chemicalSourceTerm[iVar]+= molarMasses[speciesIndex] * netProductionRates[speciesIndex]/n_step; - } - } - // for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { - // int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - // scalar_new[iVar] = combustor->massFraction(speciesIndex); - // const su2double temp_comb = combustor->temperature(); - // } - // DictionaryChemicalComposition(scalar_new); - // sol->thermo()->setState_TPY(GetValue(Temperature), GetValue(Pressure_Thermodynamic), chemical_composition); - // // const int nsp = sol->thermo()->nSpecies(); - // // vector netProductionRates(nsp); - // sol->kinetics()->getNetProductionRates(&netProductionRates[0]); - // for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { - // int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - // chemicalSourceTerm[iVar] = molarMasses[speciesIndex]*netProductionRates[speciesIndex]; - // } } void CFluidCantera::ComputeGradChemicalSourceTerm(const su2double* val_scalars) { From c7ff2bf8163a56568c462b325451f09140b0ba38 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 28 Apr 2025 15:48:01 +0200 Subject: [PATCH 095/173] updating with develop --- Common/include/CConfig.hpp | 165 ++--------- Common/include/option_structure.hpp | 57 ++++ Common/src/CConfig.cpp | 46 ++- Common/src/geometry/CGeometry.cpp | 3 +- SU2_CFD/include/fluid/CDataDrivenFluid.hpp | 28 +- SU2_CFD/include/fluid/CFluidFlamelet.hpp | 3 + SU2_CFD/include/solvers/CIncNSSolver.hpp | 1 + .../solvers/CSpeciesFlameletSolver.hpp | 7 +- SU2_CFD/include/solvers/CSpeciesSolver.hpp | 1 + SU2_CFD/src/fluid/CDataDrivenFluid.cpp | 263 ++++++++++++------ SU2_CFD/src/fluid/CFluidFlamelet.cpp | 39 +-- SU2_CFD/src/output/CAdjFlowOutput.cpp | 78 +++--- SU2_CFD/src/output/CFlowOutput.cpp | 158 ++++++----- SU2_CFD/src/solvers/CIncNSSolver.cpp | 11 +- SU2_CFD/src/solvers/CSolver.cpp | 10 +- .../src/solvers/CSpeciesFlameletSolver.cpp | 73 ++--- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 12 +- .../variables/CSpeciesFlameletVariable.cpp | 8 +- 18 files changed, 512 insertions(+), 451 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index aa64b64108e5..b23c5a9b72a7 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -542,9 +542,8 @@ class CConfig { Kind_TimeIntScheme_Heat, /*!< \brief Time integration for the wave equations. */ Kind_TimeStep_Heat, /*!< \brief Time stepping method for the (fvm) heat equation. */ n_Datadriven_files; - ENUM_DATADRIVEN_METHOD Kind_DataDriven_Method; /*!< \brief Method used for datset regression in data-driven fluid models. */ - su2double DataDriven_Relaxation_Factor; /*!< \brief Relaxation factor for Newton solvers in data-driven fluid models. */ + DataDrivenFluid_ParsedOptions datadriven_ParsedOptions; /*!< \brief Options for data-driven fluid analysis. */ STRUCT_TIME_INT Kind_TimeIntScheme_FEA; /*!< \brief Time integration for the FEA equations. */ STRUCT_SPACE_ITE Kind_SpaceIteScheme_FEA; /*!< \brief Iterative scheme for nonlinear structural analysis. */ @@ -829,8 +828,7 @@ class CConfig { SurfAdjCoeff_FileName, /*!< \brief Output file with the adjoint variables on the surface. */ SurfSens_FileName, /*!< \brief Output file for the sensitivity on the surface (discrete adjoint). */ VolSens_FileName, /*!< \brief Output file for the sensitivity in the volume (discrete adjoint). */ - ObjFunc_Hess_FileName, /*!< \brief Hessian approximation obtained by the Sobolev smoothing solver. */ - *DataDriven_Method_FileNames; /*!< \brief Dataset information for data-driven fluid models. */ + ObjFunc_Hess_FileName; /*!< \brief Hessian approximation obtained by the Sobolev smoothing solver. */ bool Wrt_Performance, /*!< \brief Write the performance summary at the end of a calculation. */ @@ -1248,28 +1246,7 @@ class CConfig { unsigned short nSpecies_Init; /*!< \brief Number of entries of SPECIES_INIT */ /*--- Additional flamelet solver options ---*/ - ///TODO: Add python wrapper initialization option - FLAMELET_INIT_TYPE flame_init_type = FLAMELET_INIT_TYPE::NONE; /*!< \brief Method for solution ignition for flamelet problems. */ - std::array flame_init; /*!< \brief Flame front initialization parameters. */ - std::array spark_init; /*!< \brief Spark ignition initialization parameters. */ - su2double* spark_reaction_rates; /*!< \brief Source terms for flamelet spark ignition option. */ - unsigned short nspark; /*!< \brief Number of source terms for spark initialization. */ - bool preferential_diffusion = false; /*!< \brief Preferential diffusion physics for flamelet solver.*/ - - /*--- lookup table ---*/ - unsigned short n_scalars = 0; /*!< \brief Number of transported scalars for flamelet LUT approach. */ - unsigned short n_lookups = 0; /*!< \brief Number of lookup variables, for visualization only. */ - unsigned short n_table_sources = 0; /*!< \brief Number of transported scalar source terms for LUT. */ - unsigned short n_user_scalars = 0; /*!< \brief Number of user defined (auxiliary) scalar transport equations. */ - unsigned short n_user_sources = 0; /*!< \brief Number of source terms for user defined (auxiliary) scalar transport equations. */ - unsigned short n_control_vars = 0; /*!< \brief Number of controlling variables (independent variables) for the LUT. */ - - string* controlling_variable_names; - string* cv_source_names; - vector table_scalar_names; /*!< \brief Names of transported scalar variables. */ - string* lookup_names; /*!< \brief Names of passive look-up variables. */ - string* user_scalar_names; /*!< \brief Names of the user defined (auxiliary) transported scalars .*/ - string* user_source_names; /*!< \brief Names of the source terms for the user defined transported scalars. */ + FluidFlamelet_ParsedOptions flamelet_ParsedOptions; /*!< \brief Additional flamelet solver options */ /*! * \brief Set the default values of config options not set in the config file using another config object. @@ -2184,106 +2161,6 @@ class CConfig { */ bool GetSpecies_StrongBC() const { return Species_StrongBC; } - /*! - * \brief Get the flame initialization. - * (x1,x2,x3) = flame offset/spark center location. - * (x4,x5,x6) = flame normal, separating unburnt from burnt or - * spark radius, spark start iteration, spark duration. - * (x7) = flame thickness, the length from unburnt to burnt conditions. - * (x8) = flame burnt thickness, the length to stay at burnt conditions. - * \return Ignition initialization parameters for the flamelet model. - */ - const su2double* GetFlameInit() const { - switch (flame_init_type) - { - case FLAMELET_INIT_TYPE::FLAME_FRONT: - return flame_init.data(); - break; - case FLAMELET_INIT_TYPE::SPARK: - return spark_init.data(); - break; - default: - return nullptr; - break; - } - } - - /*! - * \brief Get species net reaction rates applied during spark ignition. - */ - const su2double* GetSpark() const { - return spark_reaction_rates; - } - - /*! - * \brief Preferential diffusion combustion problem. - */ - bool GetPreferentialDiffusion() const { return preferential_diffusion; } - - /*! - * \brief Define preferential diffusion combustion problem. - */ - inline void SetPreferentialDiffusion(bool input) { preferential_diffusion = input; } - - /*! - * \brief Get the number of control variables for flamelet model. - */ - unsigned short GetNControlVars() const { return n_control_vars; } - - /*! - * \brief Get the number of total transported scalars for flamelet model. - */ - unsigned short GetNScalars() const { return n_scalars; } - - /*! - * \brief Get the number of user scalars for flamelet model. - */ - unsigned short GetNUserScalars() const { return n_user_scalars; } - - /*! - * \brief Get the name of a specific controlling variable. - */ - const string& GetControllingVariableName(unsigned short i_cv) const { - return controlling_variable_names[i_cv]; - } - - /*! - * \brief Get the name of the source term variable for a specific controlling variable. - */ - const string& GetControllingVariableSourceName(unsigned short i_cv) const { - return cv_source_names[i_cv]; - } - /*! - * \brief Get the name of the user scalar. - */ - const string& GetUserScalarName(unsigned short i_user_scalar) const { - static const std::string none = "NONE"; - if (n_user_scalars > 0) return user_scalar_names[i_user_scalar]; else return none; - } - - /*! - * \brief Get the name of the user scalar source term. - */ - const string& GetUserSourceName(unsigned short i_user_source) const { - static const std::string none = "NONE"; - if (n_user_sources > 0) return user_source_names[i_user_source]; else return none; - } - - /*! - * \brief Get the ignition method used for combustion problems. - */ - FLAMELET_INIT_TYPE GetFlameletInitType() const { return flame_init_type; } - - /*! - * \brief Get the number of transported scalars for combustion. - */ - unsigned short GetNLookups() const { return n_lookups; } - - /*! - * \brief Get the name of the variable that we want to retrieve from the lookup table. - */ - const string& GetLookupName(unsigned short i_lookup) const { return lookup_names[i_lookup]; } - /*! * \brief Get the Young's modulus of elasticity. * \return Value of the Young's modulus of elasticity. @@ -3985,29 +3862,6 @@ class CConfig { */ unsigned short GetKind_FluidModel(void) const { return Kind_FluidModel; } - /*! - * \brief Datadriven method for EoS evaluation. - */ - ENUM_DATADRIVEN_METHOD GetKind_DataDriven_Method(void) const { return Kind_DataDriven_Method; } - - /*! - * \brief Get name of the input file for the data-driven fluid model interpolation method. - * \return Name of the input file for the interpolation method. - */ - const string* GetDataDriven_FileNames(void) const { return DataDriven_Method_FileNames; } - - /*! - * \brief Get number of listed look-up table or multi-layer perceptron input files. - * \return Number of listed data-driven method input files. - */ - unsigned short GetNDataDriven_Files(void) const { return n_Datadriven_files; } - - /*! - * \brief Get Newton solver relaxation factor for data-driven fluid models. - * \return Newton solver relaxation factor. - */ - su2double GetRelaxation_DataDriven(void) const { return DataDriven_Relaxation_Factor; } - /*! * \brief Returns the name of the fluid we are using in CoolProp. */ @@ -10001,4 +9855,17 @@ class CConfig { */ LM_ParsedOptions GetLMParsedOptions() const { return lmParsedOptions; } + + /*! + * \brief Get parsed option data structure for data-driven fluid model. + * \return option data structure for data-driven fluid model. + */ + const DataDrivenFluid_ParsedOptions& GetDataDrivenParsedOptions() const { return datadriven_ParsedOptions; } + + /*! + * \brief Get parsed option data structure for the flamelet fluid model. + * \return option data structure for the flamelet fluid model. + */ + const FluidFlamelet_ParsedOptions& GetFlameletParsedOptions() const { return flamelet_ParsedOptions; } + }; diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index abe7185341df..290f80f339ca 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -1332,6 +1333,20 @@ inline LM_ParsedOptions ParseLMOptions(const LM_OPTIONS *LM_Options, unsigned sh return LMParsedOptions; } +/*! + * \brief Structure containing parsed options for data-driven fluid model. + */ +struct DataDrivenFluid_ParsedOptions { + su2double rho_init_custom = -1; /*!< \brief Optional initial guess for density in inverse look-up operations. */ + su2double e_init_custom = -1; /*!< \brief Optional initial guess for static energy in inverse look-up operations.*/ + su2double Newton_relaxation = 1.0; /*!< \brief Relaxation factor for Newton solvers in data-driven fluid models. */ + bool use_PINN = false; /*!< \brief Use physics-informed method for data-driven fluid modeling. */ + ENUM_DATADRIVEN_METHOD interp_algorithm_type = ENUM_DATADRIVEN_METHOD::MLP; /*!< \brief Interpolation algorithm used for data-driven fluid model. */ + unsigned short n_filenames = 1; /*!< \brief Number of datasets. */ + std::string *datadriven_filenames; /*!< \brief Dataset information for data-driven fluid models. */ +}; + + /*! * \brief types of species transport models */ @@ -1399,6 +1414,34 @@ static const MapType Flamelet_Init_Map = { MakePair("SPARK", FLAMELET_INIT_TYPE::SPARK) }; +/*! + * \brief Structure containing parsed options for flamelet fluid model. + */ +struct FluidFlamelet_ParsedOptions { + ///TODO: Add python wrapper initialization option + FLAMELET_INIT_TYPE ignition_method = FLAMELET_INIT_TYPE::NONE; /*!< \brief Method for solution ignition for flamelet problems. */ + unsigned short n_scalars = 0; /*!< \brief Number of transported scalars for flamelet LUT approach. */ + unsigned short n_lookups = 0; /*!< \brief Number of lookup variables, for visualization only. */ + unsigned short n_table_sources = 0; /*!< \brief Number of transported scalar source terms for LUT. */ + unsigned short n_user_scalars = 0; /*!< \brief Number of user defined (auxiliary) scalar transport equations. */ + unsigned short n_user_sources = 0; /*!< \brief Number of source terms for user defined (auxiliary) scalar transport equations. */ + unsigned short n_control_vars = 0; /*!< \brief Number of controlling variables (independent variables) for the LUT. */ + + std::string *controlling_variable_names; /*!< \brief Names of the independent, transported scalars. */ + std::string* cv_source_names; /*!< \brief Names of the source terms of the independent, transported scalars. */ + std::string* lookup_names; /*!< \brief Names of the passive look-up terms. */ + std::string* user_scalar_names; /*!< \brief Names of the passive transported scalars. */ + std::string* user_source_names; /*!< \brief Names of the source terms of the passive transported scalars. */ + + std::array flame_init{{0,0,0, /* flame offset (x,y,z) */ + 1,0,0, /* flame normal (nx, ny, nz) */ + 5e-3,1}}; /*!< \brief Flame front initialization parameters. */ + std::array spark_init{{0,0,0,0,0,0}}; /*!< \brief Spark ignition initialization parameters. */ + su2double* spark_reaction_rates; /*!< \brief Source terms for flamelet spark ignition option. */ + unsigned short nspark; /*!< \brief Number of source terms for spark initialization. */ + bool preferential_diffusion = false; /*!< \brief Preferential diffusion physics for flamelet solver.*/ +}; + /*! * \brief Types of subgrid scale models */ @@ -1894,6 +1937,20 @@ enum TURBO_MARKER_TYPE{ OUTFLOW = 2 /*!< \brief flag for outflow marker for compute turboperformance. */ }; +enum class RAMP_TYPE{ + GRID, /*!< \brief flag for rotational/translational ramps */ + BOUNDARY /*!< \brief flag for pressure/mass flow ramps*/ +}; + +/*! + * \brief Coefficients of the ramp specified in the config, ordered by index in the config + */ +enum RAMP_COEFF{ + INITIAL_VALUE = 0, /*!< \brief intial value of the ramp */ + UPDATE_FREQ = 1, /*::max(); su2double distance = max; for (const auto jPoint : geometry->nodes->GetPoints(iPoint)) { - const su2double dist = geometry->nodes->GetWall_Distance(jPoint); + const su2double dist = + geometry->nodes->GetViscousBoundary(jPoint) ? 0.0 : geometry->nodes->GetWall_Distance(jPoint); if (dist > EPS) distance = fmin(distance, dist); } if (distance > 0 && distance < max) return distance; diff --git a/SU2_CFD/include/fluid/CDataDrivenFluid.hpp b/SU2_CFD/include/fluid/CDataDrivenFluid.hpp index 57a68ea8d71f..a7fda2c6dd36 100644 --- a/SU2_CFD/include/fluid/CDataDrivenFluid.hpp +++ b/SU2_CFD/include/fluid/CDataDrivenFluid.hpp @@ -62,6 +62,13 @@ class CDataDrivenFluid final : public CFluidModel { rho_min, rho_max, /*!< \brief Minimum and maximum density values in data set. */ e_min, e_max; /*!< \brief Minimum and maximum energy values in data set. */ + bool custom_init_rho{false}, + custom_init_e{false}; + su2double val_custom_init_rho, + val_custom_init_e, + rho_median, + e_median; + unsigned long MaxIter_Newton; /*!< \brief Maximum number of iterations for Newton solvers. */ su2double dsde_rho, /*!< \brief Entropy derivative w.r.t. density. */ @@ -87,6 +94,11 @@ class CDataDrivenFluid final : public CFluidModel { vector outputs_rhoe; /*!< \brief Pointers to output variables. */ + vector> dsdrhoe; /*!< \brief Entropy Jacobian terms. */ + vector>> d2sdrhoe2; /*!< \brief Entropy Hessian terms. */ + + bool use_MLP_derivatives; /*!< \brief Use physics-informed model. */ + /*--- Class variables for the multi-layer perceptron method ---*/ #ifdef USE_MLPCPP MLPToolbox::CLookUp_ANN* lookup_mlp; /*!< \brief Multi-layer perceptron collection. */ @@ -145,8 +157,8 @@ class CDataDrivenFluid final : public CFluidModel { * \param[in] dY2drho - Pointer to the partial derivative of quantity 2 w.r.t. density at constant energy. * \param[in] dY2de - Pointer to the partial derivative of quantity 2 w.r.t. energy at constant density. */ - void Run_Newton_Solver(su2double Y1_target, su2double Y2_target, su2double* Y1, su2double* Y2, su2double* dY1drho, - su2double* dY1de, su2double* dY2drho, su2double* dY2de); + void Run_Newton_Solver(const su2double Y1_target, const su2double Y2_target, const su2double & Y1, const su2double & Y2, const su2double & dY1drho, + const su2double & dY1de, const su2double & dY2drho, const su2double & dY2de); /*! * \brief 1D Newton solver for computing the density or energy corresponding to Y_target. @@ -155,9 +167,10 @@ class CDataDrivenFluid final : public CFluidModel { * \param[in] X - Pointer to controlling variable (density or energy). * \param[in] dYdX - Pointer to the partial derivative of target quantity w.r.t. controlling variable. */ - void Run_Newton_Solver(su2double Y_target, su2double* Y, su2double* X, su2double* dYdX); + void Run_Newton_Solver(const su2double Y_target, const su2double & Y, su2double & X, const su2double & dYdX); void ComputeIdealGasQuantities(); + public: /*! * \brief Constructor of the class. @@ -213,6 +226,15 @@ class CDataDrivenFluid final : public CFluidModel { */ void SetTDState_Ps(su2double P, su2double s) override; + /*! + * \brief compute some derivatives of enthalpy and entropy needed for subsonic inflow BC + * \param[in] InputSpec - Input pair for FLP calls ("Pv"). + * \param[in] th1 - first thermodynamic variable (P). + * \param[in] th2 - second thermodynamic variable (v). + * + */ + void ComputeDerivativeNRBC_Prho(su2double P, su2double rho) override; + /*! * \brief Get fluid model extrapolation instance. * \return Query point lies outside fluid model data range. diff --git a/SU2_CFD/include/fluid/CFluidFlamelet.hpp b/SU2_CFD/include/fluid/CFluidFlamelet.hpp index f95072f30ce1..c933c8650cb6 100644 --- a/SU2_CFD/include/fluid/CFluidFlamelet.hpp +++ b/SU2_CFD/include/fluid/CFluidFlamelet.hpp @@ -37,6 +37,9 @@ class CFluidFlamelet final : public CFluidModel { private: + DataDrivenFluid_ParsedOptions datadriven_fluid_options; + FluidFlamelet_ParsedOptions flamelet_options; + ENUM_DATADRIVEN_METHOD Kind_DataDriven_Method = ENUM_DATADRIVEN_METHOD::LUT; /*!< \brief Interpolation method for data set evaluation. */ diff --git a/SU2_CFD/include/solvers/CIncNSSolver.hpp b/SU2_CFD/include/solvers/CIncNSSolver.hpp index b41ae738a7fb..e9cc628b35c5 100644 --- a/SU2_CFD/include/solvers/CIncNSSolver.hpp +++ b/SU2_CFD/include/solvers/CIncNSSolver.hpp @@ -36,6 +36,7 @@ * \author F. Palacios, T. Economon, T. Albring */ class CIncNSSolver final : public CIncEulerSolver { + FluidFlamelet_ParsedOptions flamelet_config_options; /*! * \brief Generic implementation of the isothermal, heatflux and heat-transfer/convection walls. diff --git a/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp b/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp index cf336b7f4584..1d3b137e59c8 100644 --- a/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp +++ b/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp @@ -37,6 +37,7 @@ */ class CSpeciesFlameletSolver final : public CSpeciesSolver { private: + FluidFlamelet_ParsedOptions flamelet_config_options; bool include_mixture_fraction = false; /*!< \brief include mixture fraction as a controlling variable. */ /*! * \brief Compute the preconditioner for low-Mach flows. @@ -87,24 +88,22 @@ class CSpeciesFlameletSolver final : public CSpeciesSolver { /*! * \brief Retrieve passive look-up data from manifold. - * \param[in] config - definition of particular problem. * \param[in] fluid_model_local - pointer to flamelet fluid model. * \param[in] iPoint - node ID. * \param[in] scalars - local scalar solution. * \return - within manifold bounds (0) or outside manifold bounds (1). */ - unsigned long SetScalarLookUps(const CConfig* config, CFluidModel* fluid_model_local, unsigned long iPoint, + unsigned long SetScalarLookUps(CFluidModel* fluid_model_local, unsigned long iPoint, const vector& scalars); /*! * \brief Retrieve the preferential diffusion scalar values from manifold. - * \param[in] config - definition of particular problem. * \param[in] fluid_model_local - pointer to flamelet fluid model. * \param[in] iPoint - node ID. * \param[in] scalars - local scalar solution. * \return - within manifold bounds (0) or outside manifold bounds (1). */ - unsigned long SetPreferentialDiffusionScalars(const CConfig* config, CFluidModel* fluid_model_local, + unsigned long SetPreferentialDiffusionScalars(CFluidModel* fluid_model_local, unsigned long iPoint, const vector& scalars); public: diff --git a/SU2_CFD/include/solvers/CSpeciesSolver.hpp b/SU2_CFD/include/solvers/CSpeciesSolver.hpp index 7236989afd46..1fa4d78d0c6e 100644 --- a/SU2_CFD/include/solvers/CSpeciesSolver.hpp +++ b/SU2_CFD/include/solvers/CSpeciesSolver.hpp @@ -40,6 +40,7 @@ class CSpeciesSolver : public CScalarSolver { protected: unsigned short Inlet_Position; /*!< \brief Column index for scalar variables in inlet files. */ vector Inlet_SpeciesVars; /*!< \brief Species variables at inlet profiles. */ + FluidFlamelet_ParsedOptions flamelet_config_options; public: /*! diff --git a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp index f4c81091df0c..fc9a1876e199 100644 --- a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp +++ b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp @@ -33,30 +33,45 @@ CDataDrivenFluid::CDataDrivenFluid(const CConfig* config, bool display) : CFluidModel() { rank = SU2_MPI::GetRank(); - Kind_DataDriven_Method = config->GetKind_DataDriven_Method(); + DataDrivenFluid_ParsedOptions datadriven_fluid_options = config->GetDataDrivenParsedOptions(); + + Kind_DataDriven_Method = datadriven_fluid_options.interp_algorithm_type; varname_rho = "Density"; varname_e = "Energy"; + /*--- Use physics-informed approach ---*/ + use_MLP_derivatives = datadriven_fluid_options.use_PINN; + + /*--- Retrieve initial density and static energy values from config ---*/ + val_custom_init_e = datadriven_fluid_options.rho_init_custom; + val_custom_init_rho = datadriven_fluid_options.e_init_custom; + custom_init_e = (val_custom_init_e != -1.0); + custom_init_rho = (val_custom_init_rho != -1.0); + + /*--- Set up interpolation algorithm according to data-driven method. Currently only MLP's are supported. ---*/ switch (Kind_DataDriven_Method) { case ENUM_DATADRIVEN_METHOD::MLP: #ifdef USE_MLPCPP - lookup_mlp = new MLPToolbox::CLookUp_ANN(config->GetNDataDriven_Files(), config->GetDataDriven_FileNames()); + lookup_mlp = new MLPToolbox::CLookUp_ANN(datadriven_fluid_options.n_filenames, datadriven_fluid_options.datadriven_filenames); if ((rank == MASTER_NODE) && display) lookup_mlp->DisplayNetworkInfo(); #else SU2_MPI::Error("SU2 was not compiled with MLPCpp enabled (-Denable-mlpcpp=true).", CURRENT_FUNCTION); #endif break; case ENUM_DATADRIVEN_METHOD::LUT: - lookup_table = new CLookUpTable(config->GetDataDriven_FileNames()[0], varname_rho, varname_e); + if (use_MLP_derivatives && (rank == MASTER_NODE) && display) + cout << "Physics-informed approach currently only works with MLP-based tabulation." << endl; + + lookup_table = new CLookUpTable(datadriven_fluid_options.datadriven_filenames[0], varname_rho, varname_e); break; default: break; } /*--- Relaxation factor and tolerance for Newton solvers. ---*/ - Newton_Relaxation = config->GetRelaxation_DataDriven(); + Newton_Relaxation = datadriven_fluid_options.Newton_relaxation; Newton_Tolerance = 1e-10; MaxIter_Newton = 50; @@ -92,23 +107,50 @@ void CDataDrivenFluid::MapInputs_to_Outputs() { /*--- Required outputs for the interpolation method are entropy and its partial derivatives with respect to energy and * density. ---*/ - size_t n_outputs = 6; - size_t idx_s = 0, idx_dsde_rho = 1, idx_dsdrho_e = 2, idx_d2sde2 = 3, idx_d2sdedrho = 4, idx_d2sdrho2 = 5; - - outputs_rhoe.resize(n_outputs); - output_names_rhoe.resize(n_outputs); - output_names_rhoe[idx_s] = "s"; - outputs_rhoe[idx_s] = &Entropy; - output_names_rhoe[idx_dsde_rho] = "dsde_rho"; - outputs_rhoe[idx_dsde_rho] = &dsde_rho; - output_names_rhoe[idx_dsdrho_e] = "dsdrho_e"; - outputs_rhoe[idx_dsdrho_e] = &dsdrho_e; - output_names_rhoe[idx_d2sde2] = "d2sde2"; - outputs_rhoe[idx_d2sde2] = &d2sde2; - output_names_rhoe[idx_d2sdedrho] = "d2sdedrho"; - outputs_rhoe[idx_d2sdedrho] = &d2sdedrho; - output_names_rhoe[idx_d2sdrho2] = "d2sdrho2"; - outputs_rhoe[idx_d2sdrho2] = &d2sdrho2; + size_t n_outputs, idx_s,idx_dsde_rho = 1, idx_dsdrho_e = 2, idx_d2sde2 = 3, idx_d2sdedrho = 4, idx_d2sdrho2 = 5; + if (use_MLP_derivatives) { + n_outputs = 1; + idx_s = 0; + + outputs_rhoe.resize(n_outputs); + output_names_rhoe.resize(n_outputs); + output_names_rhoe[idx_s] = "s"; + outputs_rhoe[idx_s] = &Entropy; + + dsdrhoe.resize(n_outputs); + d2sdrhoe2.resize(n_outputs); + dsdrhoe[0].resize(2); + dsdrhoe[0][idx_rho] = &dsdrho_e; + dsdrhoe[0][idx_e] = &dsde_rho; + + d2sdrhoe2[0].resize(2); + d2sdrhoe2[0][idx_rho].resize(2); + d2sdrhoe2[0][idx_e].resize(2); + d2sdrhoe2[0][idx_rho][idx_rho] = &d2sdrho2; + d2sdrhoe2[0][idx_rho][idx_e] = &d2sdedrho; + d2sdrhoe2[0][idx_e][idx_rho] = &d2sdedrho; + d2sdrhoe2[0][idx_e][idx_e] = &d2sde2; + } else { + n_outputs = 6; + idx_s = 0; + idx_dsde_rho = 1, idx_dsdrho_e = 2, idx_d2sde2 = 3, idx_d2sdedrho = 4, idx_d2sdrho2 = 5; + + outputs_rhoe.resize(n_outputs); + output_names_rhoe.resize(n_outputs); + output_names_rhoe[idx_s] = "s"; + outputs_rhoe[idx_s] = &Entropy; + output_names_rhoe[idx_dsde_rho] = "dsde_rho"; + outputs_rhoe[idx_dsde_rho] = &dsde_rho; + output_names_rhoe[idx_dsdrho_e] = "dsdrho_e"; + outputs_rhoe[idx_dsdrho_e] = &dsdrho_e; + output_names_rhoe[idx_d2sde2] = "d2sde2"; + outputs_rhoe[idx_d2sde2] = &d2sde2; + output_names_rhoe[idx_d2sdedrho] = "d2sdedrho"; + outputs_rhoe[idx_d2sdedrho] = &d2sdedrho; + output_names_rhoe[idx_d2sdrho2] = "d2sdrho2"; + outputs_rhoe[idx_d2sdrho2] = &d2sdrho2; + } + /*--- Further preprocessing of input and output variables. ---*/ if (Kind_DataDriven_Method == ENUM_DATADRIVEN_METHOD::MLP) { @@ -137,44 +179,67 @@ void CDataDrivenFluid::MapInputs_to_Outputs() { } void CDataDrivenFluid::SetTDState_rhoe(su2double rho, su2double e) { - /*--- Compute thermodynamic state based on density and energy. ---*/ - Density = rho; - StaticEnergy = e; - /*--- Clip density and energy values to prevent extrapolation. ---*/ - Density = min(rho_max, max(rho_min, Density)); - StaticEnergy = min(e_max, max(e_min, StaticEnergy)); + Density = max(min(rho, rho_max), rho_min); + StaticEnergy = max(min(e, e_max), e_min); - Evaluate_Dataset(Density, StaticEnergy); + AD::StartPreacc(); + AD::SetPreaccIn(Density); + AD::SetPreaccIn(StaticEnergy); - /*--- Compute speed of sound. ---*/ - auto blue_term = (dsdrho_e * (2 - rho * pow(dsde_rho, -1) * d2sdedrho) + rho * d2sdrho2); - auto green_term = (-pow(dsde_rho, -1) * d2sde2 * dsdrho_e + d2sdedrho); + /*--- Compute thermodynamic state based on density and energy. ---*/ + + Density = max(min(rho, rho_max), rho_min); + StaticEnergy = max(min(e, e_max), e_min); - SoundSpeed2 = -rho * pow(dsde_rho, -1) * (blue_term - rho * green_term * (dsdrho_e / dsde_rho)); + Evaluate_Dataset(Density, StaticEnergy); + const su2double rho_2 = Density * Density; /*--- Compute primary flow variables. ---*/ - Temperature = 1.0 / dsde_rho; - Pressure = -pow(rho, 2) * Temperature * dsdrho_e; - Density = rho; - StaticEnergy = e; - Enthalpy = e + Pressure / rho; + Temperature = pow(dsde_rho, -1); + Pressure = -rho_2 * Temperature * dsdrho_e; + Enthalpy = StaticEnergy + Pressure / Density; /*--- Compute secondary flow variables ---*/ - dTde_rho = -pow(dsde_rho, -2) * d2sde2; - dTdrho_e = -pow(dsde_rho, -2) * d2sdedrho; + dTde_rho = -Temperature * Temperature * d2sde2; + dTdrho_e = -Temperature * Temperature * d2sdedrho; - dPde_rho = -pow(rho, 2) * (dTde_rho * dsdrho_e + Temperature * d2sdedrho); - dPdrho_e = -2 * rho * Temperature * dsdrho_e - pow(rho, 2) * (dTdrho_e * dsdrho_e + Temperature * d2sdrho2); + /*--- Compute speed of sound. ---*/ + const su2double blue_term = (dsdrho_e * (2 - Density * Temperature * d2sdedrho) + Density * d2sdrho2); + const su2double green_term = (-Temperature * d2sde2 * dsdrho_e + d2sdedrho); + + SoundSpeed2 = -Density * Temperature * (blue_term - Density * green_term * (dsdrho_e / dsde_rho)); + + dPde_rho = -rho_2 * Temperature * (-Temperature * (d2sde2 * dsdrho_e) + d2sdedrho); + dPdrho_e = - Density * Temperature * (dsdrho_e * (2 - Density * Temperature * d2sdedrho) + Density * d2sdrho2); /*--- Compute enthalpy and entropy derivatives required for Giles boundary conditions. ---*/ - dhdrho_e = -Pressure * pow(rho, -2) + dPdrho_e / rho; - dhde_rho = 1 + dPde_rho / rho; + dhdrho_e = -Pressure * (1 / rho_2) + dPdrho_e / Density; + dhde_rho = 1 + dPde_rho / Density; + /*--- Compute specific heat at constant volume and specific heat at constant pressure. ---*/ + Cv = 1 / dTde_rho; dhdrho_P = dhdrho_e - dhde_rho * (1 / dPde_rho) * dPdrho_e; dhdP_rho = dhde_rho * (1 / dPde_rho); dsdrho_P = dsdrho_e - dPdrho_e * (1 / dPde_rho) * dsde_rho; dsdP_rho = dsde_rho / dPde_rho; + + const su2double drhode_p = -dPde_rho/dPdrho_e; + const su2double dTde_p = dTde_rho + dTdrho_e*drhode_p; + const su2double dhde_p = dhde_rho + drhode_p*dhdrho_e; + Cp = dhde_p / dTde_p; + + AD::SetPreaccOut(Temperature); + AD::SetPreaccOut(SoundSpeed2); + AD::SetPreaccOut(dPde_rho); + AD::SetPreaccOut(dPdrho_e); + AD::SetPreaccOut(dTde_rho); + AD::SetPreaccOut(dTdrho_e); + AD::SetPreaccOut(Pressure); + AD::SetPreaccOut(Entropy); + AD::SetPreaccOut(Cp); + AD::SetPreaccOut(Cv); + AD::EndPreacc(); } void CDataDrivenFluid::SetTDState_PT(su2double P, su2double T) { @@ -184,7 +249,7 @@ void CDataDrivenFluid::SetTDState_PT(su2double P, su2double T) { e_start = Cv_idealgas * T; /*--- Run 2D Newton solver for pressure and temperature ---*/ - Run_Newton_Solver(P, T, &Pressure, &Temperature, &dPdrho_e, &dPde_rho, &dTdrho_e, &dTde_rho); + Run_Newton_Solver(P, T, Pressure, Temperature, dPdrho_e, dPde_rho, dTdrho_e, dTde_rho); } void CDataDrivenFluid::SetTDState_Prho(su2double P, su2double rho) { @@ -197,10 +262,9 @@ void CDataDrivenFluid::SetEnergy_Prho(su2double P, su2double rho) { Density = rho; /*--- Approximate static energy through ideal gas law. ---*/ - su2double e_idealgas = Cv_idealgas * (P / (R_idealgas * rho)); - StaticEnergy = min(e_max, max(e_idealgas, e_min)); + StaticEnergy = Cv_idealgas * (P / (R_idealgas * rho)); - Run_Newton_Solver(P, &Pressure, &StaticEnergy, &dPde_rho); + Run_Newton_Solver(P, Pressure, StaticEnergy, dPde_rho); } void CDataDrivenFluid::SetTDState_rhoT(su2double rho, su2double T) { @@ -210,40 +274,49 @@ void CDataDrivenFluid::SetTDState_rhoT(su2double rho, su2double T) { /*--- Approximate static energy through ideal gas law. ---*/ StaticEnergy = Cv_idealgas * T; - Run_Newton_Solver(T, &Temperature, &StaticEnergy, &dTde_rho); + Run_Newton_Solver(T, Temperature, StaticEnergy, dTde_rho); } void CDataDrivenFluid::SetTDState_hs(su2double h, su2double s) { /*--- Run 2D Newton solver for enthalpy and entropy. ---*/ - /*--- Approximate density and static energy through ideal gas law under isentropic assumption. ---*/ - su2double T_init = h / Cp_idealgas; - su2double P_init = P_middle * pow(T_init / T_middle, gamma_idealgas/(gamma_idealgas - 1)); - - e_start = h * Cv_idealgas / Cp_idealgas; - rho_start = P_init / (R_idealgas * T_init); - Run_Newton_Solver(h, s, &Enthalpy, &Entropy, &dhdrho_e, &dhde_rho, &dsdrho_e, &dsde_rho); + e_start = StaticEnergy; + rho_start = Density; + Run_Newton_Solver(h, s, Enthalpy, Entropy, dhdrho_e, dhde_rho, dsdrho_e, dsde_rho); } void CDataDrivenFluid::SetTDState_Ps(su2double P, su2double s) { /*--- Run 2D Newton solver for pressure and entropy ---*/ - /*--- Approximate initial state through isentropic assumption and ideal gas law. ---*/ - su2double T_init = T_middle * pow(P / P_middle, (gamma_idealgas - 1)/gamma_idealgas); - e_start = Cv_idealgas * T_init; - rho_start = P / (R_idealgas * T_init); + e_start = StaticEnergy; + rho_start = Density; + Run_Newton_Solver(P, s, Pressure, Entropy, dPdrho_e, dPde_rho, dsdrho_e, dsde_rho); +} + + +void CDataDrivenFluid::ComputeDerivativeNRBC_Prho(su2double P, su2double rho) { + SetTDState_Prho(P, rho); - Run_Newton_Solver(P, s, &Pressure, &Entropy, &dPdrho_e, &dPde_rho, &dsdrho_e, &dsde_rho); + dhdrho_P = dhdrho_e - dhde_rho * (1 / dPde_rho) * dPdrho_e; + dhdP_rho = dhde_rho * (1 / dPde_rho); + dsdrho_P = dsdrho_e - dPdrho_e * (1 / dPde_rho) * dsde_rho; + dsdP_rho = dsde_rho / dPde_rho; } + unsigned long CDataDrivenFluid::Predict_MLP(su2double rho, su2double e) { unsigned long exit_code = 0; /*--- Evaluate MLP collection for the given values for density and energy. ---*/ #ifdef USE_MLPCPP MLP_inputs[idx_rho] = rho; MLP_inputs[idx_e] = e; - exit_code = lookup_mlp->PredictANN(iomap_rhoe, MLP_inputs, outputs_rhoe); + if (use_MLP_derivatives){ + exit_code = lookup_mlp->PredictANN(iomap_rhoe, MLP_inputs, outputs_rhoe, &dsdrhoe, &d2sdrhoe2); + } else { + exit_code = lookup_mlp->PredictANN(iomap_rhoe, MLP_inputs, outputs_rhoe); + } #endif + return exit_code; } @@ -268,37 +341,37 @@ void CDataDrivenFluid::Evaluate_Dataset(su2double rho, su2double e) { } } -void CDataDrivenFluid::Run_Newton_Solver(su2double Y1_target, su2double Y2_target, su2double* Y1, su2double* Y2, - su2double* dY1drho, su2double* dY1de, su2double* dY2drho, su2double* dY2de) { +void CDataDrivenFluid::Run_Newton_Solver(const su2double Y1_target, const su2double Y2_target, const su2double & Y1, const su2double & Y2, const su2double & dY1drho, + const su2double & dY1de, const su2double & dY2drho, const su2double & dY2de) { /*--- 2D Newton solver, computing the density and internal energy values corresponding to Y1_target and Y2_target. * ---*/ + AD::StartPreacc(); + AD::SetPreaccIn(Y1_target); + AD::SetPreaccIn(Y2_target); /*--- Setting initial values for density and energy. ---*/ su2double rho = rho_start, e = e_start; bool converged = false; unsigned long Iter = 0; - su2double delta_Y1, delta_Y2, delta_rho, delta_e, determinant; - /*--- Initiating Newton solver ---*/ while (!converged && (Iter < MaxIter_Newton)) { /*--- Determine thermodynamic state based on current density and energy. ---*/ SetTDState_rhoe(rho, e); /*--- Determine residuals. ---*/ - delta_Y1 = *Y1 - Y1_target; - delta_Y2 = *Y2 - Y2_target; + const su2double delta_Y1 = Y1 - Y1_target; + const su2double delta_Y2 = Y2 - Y2_target; /*--- Continue iterative process if residuals are outside tolerances. ---*/ - if ((abs(delta_Y1 / *Y1) < Newton_Tolerance) && (abs(delta_Y2 / *Y2) < Newton_Tolerance)) { + if ((abs(delta_Y1 / Y1) < Newton_Tolerance) && (abs(delta_Y2 / Y2) < Newton_Tolerance)) { converged = true; } else { /*--- Compute step size for density and energy. ---*/ - determinant = (*dY1drho) * (*dY2de) - (*dY1de) * (*dY2drho); - - delta_rho = (*dY2de * delta_Y1 - *dY1de * delta_Y2) / determinant; - delta_e = (-*dY2drho * delta_Y1 + *dY1drho * delta_Y2) / determinant; + const su2double determinant = (dY1drho) * (dY2de) - (dY1de) * (dY2drho); + const su2double delta_rho = (dY2de * delta_Y1 - dY1de * delta_Y2) / determinant; + const su2double delta_e = (-dY2drho * delta_Y1 + dY1drho * delta_Y2) / determinant; /*--- Update density and energy values. ---*/ rho -= Newton_Relaxation * delta_rho; @@ -307,38 +380,44 @@ void CDataDrivenFluid::Run_Newton_Solver(su2double Y1_target, su2double Y2_targe Iter++; } nIter_Newton = Iter; - + AD::SetPreaccOut(Density); + AD::SetPreaccOut(StaticEnergy); + AD::EndPreacc(); /*--- Evaluation of final state. ---*/ - SetTDState_rhoe(rho, e); + SetTDState_rhoe(Density, StaticEnergy); } -void CDataDrivenFluid::Run_Newton_Solver(su2double Y_target, su2double* Y, su2double* X, su2double* dYdX) { +void CDataDrivenFluid::Run_Newton_Solver(const su2double Y_target, const su2double & Y, su2double & X, const su2double & dYdX) { /*--- 1D Newton solver, computing the density or internal energy value corresponding to Y_target. ---*/ bool converged = false; unsigned long Iter = 0; - su2double delta_Y, delta_X; - + AD::StartPreacc(); + AD::SetPreaccIn(Y_target); + AD::SetPreaccIn(X); /*--- Initiating Newton solver. ---*/ while (!converged && (Iter < MaxIter_Newton)) { /*--- Determine thermodynamic state based on current density and energy. ---*/ SetTDState_rhoe(Density, StaticEnergy); /*--- Determine residual ---*/ - delta_Y = Y_target - *Y; + const su2double delta_Y = Y_target - Y; /*--- Continue iterative process if residuals are outside tolerances. ---*/ - if (abs(delta_Y / *Y) < Newton_Tolerance) { + if (abs(delta_Y / Y) < Newton_Tolerance) { converged = true; } else { - delta_X = delta_Y / *dYdX; + const su2double delta_X = delta_Y / dYdX; /*--- Update energy value ---*/ - *X += Newton_Relaxation * delta_X; + X += Newton_Relaxation * delta_X; } Iter++; } + AD::SetPreaccOut(Density); + AD::SetPreaccOut(StaticEnergy); + AD::EndPreacc(); /*--- Calculate thermodynamic state based on converged values for density and energy. ---*/ SetTDState_rhoe(Density, StaticEnergy); @@ -367,21 +446,27 @@ void CDataDrivenFluid::ComputeIdealGasQuantities() { e_min = lookup_mlp->GetInputNorm(iomap_rhoe, idx_e).first; rho_max = lookup_mlp->GetInputNorm(iomap_rhoe, idx_rho).second; e_max = lookup_mlp->GetInputNorm(iomap_rhoe, idx_e).second; - rho_average = 0.5*(lookup_mlp->GetInputNorm(iomap_rhoe, idx_rho).first + lookup_mlp->GetInputNorm(iomap_rhoe, idx_rho).second); - e_average = 0.5*(lookup_mlp->GetInputNorm(iomap_rhoe, idx_e).first + lookup_mlp->GetInputNorm(iomap_rhoe, idx_e).second); + rho_average = lookup_mlp->GetInputOffset(iomap_rhoe, idx_rho); + e_average = lookup_mlp->GetInputOffset(iomap_rhoe, idx_e); #endif break; default: break; } - /*--- Compute thermodynamic state from middle of data set. ---*/ - SetTDState_rhoe(rho_average, e_average); + + su2double rho_init = custom_init_rho ? val_custom_init_rho : rho_average; + su2double e_init = custom_init_e ? val_custom_init_e : e_average; + + SetTDState_rhoe(rho_init, e_init); + rho_median = rho_init; + e_median = e_init; P_middle = Pressure; T_middle = Temperature; - R_idealgas = P_middle / (rho_average * T_middle); - Cv_idealgas = e_average / T_middle; - Cp_idealgas = Enthalpy / T_middle; + R_idealgas = P_middle / (rho_init * T_middle); + Cv_idealgas = Cv; + Cp_idealgas = Cp; + gamma_idealgas = (R_idealgas / Cv_idealgas) + 1; -} \ No newline at end of file +} diff --git a/SU2_CFD/src/fluid/CFluidFlamelet.cpp b/SU2_CFD/src/fluid/CFluidFlamelet.cpp index a458a3fd97c1..ad70a85011d7 100644 --- a/SU2_CFD/src/fluid/CFluidFlamelet.cpp +++ b/SU2_CFD/src/fluid/CFluidFlamelet.cpp @@ -36,13 +36,16 @@ CFluidFlamelet::CFluidFlamelet(CConfig* config, su2double value_pressure_operating) : CFluidModel() { rank = SU2_MPI::GetRank(); - Kind_DataDriven_Method = config->GetKind_DataDriven_Method(); + datadriven_fluid_options = config->GetDataDrivenParsedOptions(); + flamelet_options = config->GetFlameletParsedOptions(); + + Kind_DataDriven_Method = datadriven_fluid_options.interp_algorithm_type; /* -- number of auxiliary species transport equations, e.g. 1=CO, 2=NOx --- */ - n_user_scalars = config->GetNUserScalars(); - n_control_vars = config->GetNControlVars(); + n_user_scalars = flamelet_options.n_user_scalars; + n_control_vars = flamelet_options.n_control_vars; include_mixture_fraction = (n_control_vars == 3); - n_scalars = config->GetNScalars(); + n_scalars = flamelet_options.n_scalars; if (rank == MASTER_NODE) { cout << "Number of scalars: " << n_scalars << endl; @@ -52,19 +55,19 @@ CFluidFlamelet::CFluidFlamelet(CConfig* config, su2double value_pressure_operati scalars_vector.resize(n_scalars); table_scalar_names.resize(n_scalars); - for (auto iCV = 0u; iCV < n_control_vars; iCV++) table_scalar_names[iCV] = config->GetControllingVariableName(iCV); + for (auto iCV = 0u; iCV < n_control_vars; iCV++) table_scalar_names[iCV] = flamelet_options.controlling_variable_names[iCV]; /*--- auxiliary species transport equations---*/ for (auto i_aux = 0u; i_aux < n_user_scalars; i_aux++) { - table_scalar_names[n_control_vars + i_aux] = config->GetUserScalarName(i_aux); + table_scalar_names[n_control_vars + i_aux] = flamelet_options.user_scalar_names[i_aux]; } controlling_variable_names.resize(n_control_vars); for (auto iCV = 0u; iCV < n_control_vars; iCV++) - controlling_variable_names[iCV] = config->GetControllingVariableName(iCV); + controlling_variable_names[iCV] =flamelet_options.controlling_variable_names[iCV]; passive_specie_names.resize(n_user_scalars); - for (auto i_aux = 0u; i_aux < n_user_scalars; i_aux++) passive_specie_names[i_aux] = config->GetUserScalarName(i_aux); + for (auto i_aux = 0u; i_aux < n_user_scalars; i_aux++) passive_specie_names[i_aux] = flamelet_options.user_scalar_names[i_aux]; switch (Kind_DataDriven_Method) { case ENUM_DATADRIVEN_METHOD::LUT: @@ -73,7 +76,7 @@ CFluidFlamelet::CFluidFlamelet(CConfig* config, su2double value_pressure_operati cout << "*** initializing the lookup table ***" << endl; cout << "*****************************************" << endl; } - look_up_table = new CLookUpTable(config->GetDataDriven_FileNames()[0], table_scalar_names[I_PROGVAR], + look_up_table = new CLookUpTable(datadriven_fluid_options.datadriven_filenames[0], table_scalar_names[I_PROGVAR], table_scalar_names[I_ENTH]); break; default: @@ -83,7 +86,7 @@ CFluidFlamelet::CFluidFlamelet(CConfig* config, su2double value_pressure_operati cout << "***********************************************" << endl; } #ifdef USE_MLPCPP - lookup_mlp = new MLPToolbox::CLookUp_ANN(config->GetNDataDriven_Files(), config->GetDataDriven_FileNames()); + lookup_mlp = new MLPToolbox::CLookUp_ANN(datadriven_fluid_options.n_filenames, datadriven_fluid_options.datadriven_filenames); if ((rank == MASTER_NODE)) lookup_mlp->DisplayNetworkInfo(); #else SU2_MPI::Error("SU2 was not compiled with MLPCpp enabled (-Denable-mlpcpp=true).", CURRENT_FUNCTION); @@ -170,7 +173,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { varnames_Sources.resize(n_sources); val_vars_Sources.resize(n_sources); for (auto iCV = 0u; iCV < n_control_vars; iCV++) - varnames_Sources[iCV] = config->GetControllingVariableSourceName(iCV); + varnames_Sources[iCV] = flamelet_options.cv_source_names[iCV]; /*--- No source term for enthalpy ---*/ /*--- For the auxiliary equations, we use a positive (production) and a negative (consumption) term: @@ -178,12 +181,12 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { for (size_t i_aux = 0; i_aux < n_user_scalars; i_aux++) { /*--- Order of the source terms: S_prod_1, S_cons_1, S_prod_2, S_cons_2, ...---*/ - varnames_Sources[n_control_vars + 2 * i_aux] = config->GetUserSourceName(2 * i_aux); - varnames_Sources[n_control_vars + 2 * i_aux + 1] = config->GetUserSourceName(2 * i_aux + 1); + varnames_Sources[n_control_vars + 2 * i_aux] = flamelet_options.user_source_names[2 * i_aux]; + varnames_Sources[n_control_vars + 2 * i_aux + 1] = flamelet_options.user_source_names[2 * i_aux + 1]; } /*--- Passive look-up terms ---*/ - size_t n_lookups = config->GetNLookups(); + size_t n_lookups = flamelet_options.n_lookups; if (n_lookups == 0) { varnames_LookUp.resize(1); val_vars_LookUp.resize(1); @@ -191,7 +194,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { } else { varnames_LookUp.resize(n_lookups); val_vars_LookUp.resize(n_lookups); - for (auto iLookup = 0u; iLookup < n_lookups; iLookup++) varnames_LookUp[iLookup] = config->GetLookupName(iLookup); + for (auto iLookup = 0u; iLookup < n_lookups; iLookup++) varnames_LookUp[iLookup] = flamelet_options.lookup_names[iLookup]; } /*--- Preferential diffusion scalars ---*/ @@ -208,7 +211,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { val_vars_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH] = beta_enth; val_vars_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_MIXFRAC] = beta_mixfrac; - preferential_diffusion = config->GetPreferentialDiffusion(); + preferential_diffusion = flamelet_options.preferential_diffusion; switch (Kind_DataDriven_Method) { case ENUM_DATADRIVEN_METHOD::LUT: preferential_diffusion = look_up_table->CheckForVariables(varnames_PD); @@ -216,7 +219,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { case ENUM_DATADRIVEN_METHOD::MLP: #ifdef USE_MLPCPP n_betas = 0; - for (auto iMLP = 0u; iMLP < config->GetNDataDriven_Files(); iMLP++) { + for (auto iMLP = 0u; iMLP < datadriven_fluid_options.n_filenames; iMLP++) { auto outputMap = lookup_mlp->FindVariableIndices(iMLP, varnames_PD, false); n_betas += outputMap.size(); } @@ -227,7 +230,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { break; } - if (!preferential_diffusion && config->GetPreferentialDiffusion()) + if (!preferential_diffusion && flamelet_options.preferential_diffusion) SU2_MPI::Error("Preferential diffusion scalars not included in flamelet manifold.", CURRENT_FUNCTION); if (Kind_DataDriven_Method == ENUM_DATADRIVEN_METHOD::MLP) { diff --git a/SU2_CFD/src/output/CAdjFlowOutput.cpp b/SU2_CFD/src/output/CAdjFlowOutput.cpp index a9b5a129cadd..3a711703d1b7 100644 --- a/SU2_CFD/src/output/CAdjFlowOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowOutput.cpp @@ -66,12 +66,13 @@ void CAdjFlowOutput::AddHistoryOutputFields_AdjScalarRMS_RES(const CConfig* conf } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddHistoryOutput("RMS_ADJ_"+cv_name, "rms[" + cv_name + "]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint " + cv_name, HistoryFieldType::RESIDUAL); } - for (unsigned short i_scalar = 0; i_scalar < config->GetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (unsigned short i_scalar = 0; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++) { + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; AddHistoryOutput("RMS_ADJ_" + scalar_name, "rms[" + scalar_name + "]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint of " + scalar_name + " .", HistoryFieldType::RESIDUAL); } } @@ -106,12 +107,13 @@ void CAdjFlowOutput::AddHistoryOutputFields_AdjScalarMAX_RES(const CConfig* conf } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddHistoryOutput("MAX_ADJ_" + cv_name, "max["+cv_name +"]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the adjoint " + cv_name, HistoryFieldType::RESIDUAL); } - for (unsigned short i_scalar = 0; i_scalar < config->GetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (unsigned short i_scalar = 0; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++) { + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; AddHistoryOutput("MAX_ADJ_" + scalar_name, "max[scalar_" + scalar_name + "]",ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the adjoint of " + scalar_name + " .", HistoryFieldType::RESIDUAL); } } @@ -144,13 +146,14 @@ void CAdjFlowOutput::AddHistoryOutputFields_AdjScalarBGS_RES(const CConfig* conf } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddHistoryOutput("BGS_ADJ_" + cv_name, "bgs[" + cv_name + "]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the adjoint " + cv_name, HistoryFieldType::RESIDUAL); } - for (unsigned short i_scalar = 0; i_scalar < config->GetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (unsigned short i_scalar = 0; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++) { + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; AddHistoryOutput("BGS_ADJ_" + scalar_name, "bgs[" + scalar_name + "]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the adjoint of " + scalar_name + " .", HistoryFieldType::RESIDUAL); } } @@ -229,16 +232,17 @@ void CAdjFlowOutput::LoadHistoryDataAdjScalar(const CConfig* config, const CSolv } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); - SetHistoryOutputValue("RMS_ADJ_"+cv_name, log10(adjspecies_solver->GetRes_RMS(iCV))); - SetHistoryOutputValue("MAX_ADJ_"+cv_name, log10(adjspecies_solver->GetRes_Max(iCV))); - if (multiZone) - SetHistoryOutputValue("BGS_ADJ_" + cv_name, log10(adjspecies_solver->GetRes_BGS(iCV))); - } + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; + SetHistoryOutputValue("RMS_ADJ_"+cv_name, log10(adjspecies_solver->GetRes_RMS(iCV))); + SetHistoryOutputValue("MAX_ADJ_"+cv_name, log10(adjspecies_solver->GetRes_Max(iCV))); + if (multiZone) + SetHistoryOutputValue("BGS_ADJ_" + cv_name, log10(adjspecies_solver->GetRes_BGS(iCV))); + } - for (unsigned short i_scalar = 0; i_scalar < config->GetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (unsigned short i_scalar = 0; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++) { + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; SetHistoryOutputValue("RMS_ADJ_" + scalar_name, log10(adjspecies_solver->GetRes_RMS(2 + i_scalar))); SetHistoryOutputValue("MAX_ADJ_" + scalar_name, log10(adjspecies_solver->GetRes_Max(2 + i_scalar))); if (multiZone) { @@ -279,13 +283,14 @@ void CAdjFlowOutput::SetVolumeOutputFieldsAdjScalarSolution(const CConfig* confi } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddVolumeOutput("ADJ_" + cv_name, "Adjoint_" + cv_name, "SOLUTION", "Adjoint of the " + cv_name + " controlling variable."); } - for (unsigned short i_scalar = 0; i_scalar < config->GetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (unsigned short i_scalar = 0; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++) { + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; AddVolumeOutput("ADJ_" + scalar_name, "Adjoint_" + scalar_name, "SOLUTION", "Adjoint of " + scalar_name); } } @@ -320,12 +325,13 @@ void CAdjFlowOutput::SetVolumeOutputFieldsAdjScalarResidual(const CConfig* confi } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - for(auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); + for(auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddVolumeOutput("RES_ADJ_" + cv_name, "Residual_Adjoint_" + cv_name, "RESIDUAL", "Residual of the adjoint of " + cv_name); } - for (unsigned short i_scalar = 0; i_scalar < config->GetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (unsigned short i_scalar = 0; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++) { + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; AddVolumeOutput("RES_ADJ_" + scalar_name, "Residual_Adjoint_" + scalar_name, "RESIDUAL", "Residual of the adjoint of " + scalar_name); } } @@ -367,16 +373,16 @@ void CAdjFlowOutput::LoadVolumeDataAdjScalar(const CConfig* config, const CSolve } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; SetVolumeOutputValue("ADJ_" + cv_name, iPoint, Node_AdjSpecies->GetSolution(iPoint, iCV)); SetVolumeOutputValue("RES_ADJ_" + cv_name, iPoint, Node_AdjSpecies->GetSolution(iPoint, iCV) - Node_AdjSpecies->GetSolution_Old(iPoint, iCV)); } - for (unsigned short i_scalar = 0; i_scalar < config->GetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); - SetVolumeOutputValue("ADJ_" + scalar_name, iPoint, Node_AdjSpecies->GetSolution(iPoint, config->GetNControlVars() + i_scalar)); - SetVolumeOutputValue("RES_ADJ_" + scalar_name, iPoint, Node_AdjSpecies->GetSolution(iPoint, config->GetNControlVars() + i_scalar) - Node_AdjSpecies->GetSolution_Old(iPoint, config->GetNControlVars() + i_scalar)); + for (unsigned short i_scalar = 0; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++) { + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; + SetVolumeOutputValue("ADJ_" + scalar_name, iPoint, Node_AdjSpecies->GetSolution(iPoint, flamelet_config_options.n_control_vars + i_scalar)); + SetVolumeOutputValue("RES_ADJ_" + scalar_name, iPoint, Node_AdjSpecies->GetSolution(iPoint, flamelet_config_options.n_control_vars + i_scalar) - Node_AdjSpecies->GetSolution_Old(iPoint, flamelet_config_options.n_control_vars + i_scalar)); } } diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index e15d3502f6ec..011ac2d2ad34 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -1023,15 +1023,16 @@ void CFlowOutput::AddHistoryOutputFields_ScalarRMS_RES(const CConfig* config) { break; } case SPECIES_MODEL::FLAMELET: { + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Controlling variable transport. ---*/ - for (auto iCV = 0u; iCV < config->GetNControlVars(); iCV++){ - const auto& CV_name = config->GetControllingVariableName(iCV); + for (auto iCV = 0u; iCV < flamelet_config_options.n_control_vars; iCV++){ + const auto& CV_name = flamelet_config_options.controlling_variable_names[iCV]; AddHistoryOutput("RMS_"+CV_name, "rms["+CV_name+"]",ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean squared residual of " + CV_name + " controlling variable equation.", HistoryFieldType::RESIDUAL); } /*--- auxiliary species transport ---*/ - for (auto i_scalar = 0u; i_scalar < config->GetNUserScalars(); i_scalar++){ - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (auto i_scalar = 0u; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++){ + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; AddHistoryOutput("RMS_"+scalar_name, "rms["+scalar_name+"]", ScreenOutputFormat::FIXED , "RMS_RES", "Root-mean squared residual of the "+scalar_name+" mass fraction equation." , HistoryFieldType::RESIDUAL); } break; @@ -1084,15 +1085,16 @@ void CFlowOutput::AddHistoryOutputFields_ScalarMAX_RES(const CConfig* config) { break; } case SPECIES_MODEL::FLAMELET: { + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Controlling variable transport. ---*/ - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++){ - const auto& cv_name = config->GetControllingVariableName(iCV); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++){ + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddHistoryOutput("MAX_" + cv_name, "max[" + cv_name + "]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the " + cv_name + " equation.", HistoryFieldType::RESIDUAL); } /*--- auxiliary species transport ---*/ - for (auto i_scalar = 0u; i_scalar < config->GetNUserScalars(); i_scalar++){ - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (auto i_scalar = 0u; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++){ + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; AddHistoryOutput("MAX_" + scalar_name, "max[" + scalar_name + "]", ScreenOutputFormat::FIXED , "MAX_RES", "Maximum residual of the " + scalar_name + " mass fraction equation." , HistoryFieldType::RESIDUAL); } break; @@ -1143,15 +1145,16 @@ void CFlowOutput::AddHistoryOutputFields_ScalarBGS_RES(const CConfig* config) { break; } case SPECIES_MODEL::FLAMELET: { + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Controlling variable transport. ---*/ - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++){ - const auto& cv_name = config->GetControllingVariableName(iCV); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++){ + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddHistoryOutput("BGS_" + cv_name, "bgs[" + cv_name + "]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the " + cv_name + " controlling variable equation.", HistoryFieldType::RESIDUAL); } /*--- auxiliary species transport ---*/ - for (auto i_scalar = 0u; i_scalar < config->GetNUserScalars(); i_scalar++){ - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (auto i_scalar = 0u; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++){ + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; AddHistoryOutput("BGS_"+scalar_name, "bgs["+scalar_name+"]", ScreenOutputFormat::FIXED , "BGS_RES", "BGS residual of the "+scalar_name+" mass fraction equation." , HistoryFieldType::RESIDUAL); } break; @@ -1257,9 +1260,10 @@ void CFlowOutput::LoadHistoryDataScalar(const CConfig* config, const CSolver* co } case SPECIES_MODEL::FLAMELET: { + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Controlling variable transport. ---*/ - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++){ - const auto& cv_name = config->GetControllingVariableName(iCV); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++){ + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; SetHistoryOutputValue("RMS_" + cv_name, log10(solver[SPECIES_SOL]->GetRes_RMS(iCV))); SetHistoryOutputValue("MAX_" + cv_name, log10(solver[SPECIES_SOL]->GetRes_Max(iCV))); if (multiZone) { @@ -1267,19 +1271,19 @@ void CFlowOutput::LoadHistoryDataScalar(const CConfig* config, const CSolver* co } } /*--- auxiliary species transport ---*/ - for (unsigned short iReactant=0; iReactantGetNUserScalars(); iReactant++){ - const auto& species_name = config->GetUserScalarName(iReactant); - SetHistoryOutputValue("RMS_" + species_name, log10(solver[SPECIES_SOL]->GetRes_RMS(config->GetNControlVars() + iReactant))); - SetHistoryOutputValue("MAX_" + species_name, log10(solver[SPECIES_SOL]->GetRes_Max(config->GetNControlVars() + iReactant))); + for (unsigned short iReactant=0; iReactantGetRes_RMS(flamelet_config_options.n_control_vars + iReactant))); + SetHistoryOutputValue("MAX_" + species_name, log10(solver[SPECIES_SOL]->GetRes_Max(flamelet_config_options.n_control_vars + iReactant))); if (multiZone) { - SetHistoryOutputValue("BGS_" + species_name, log10(solver[SPECIES_SOL]->GetRes_BGS(config->GetNControlVars() + iReactant))); + SetHistoryOutputValue("BGS_" + species_name, log10(solver[SPECIES_SOL]->GetRes_BGS(flamelet_config_options.n_control_vars + iReactant))); } } SetHistoryOutputValue("LINSOL_ITER_FLAMELET", solver[SPECIES_SOL]->GetIterLinSolver()); SetHistoryOutputValue("LINSOL_RESIDUAL_FLAMELET", log10(solver[SPECIES_SOL]->GetResLinSolver())); - break; } + break; case SPECIES_MODEL::NONE: break; } @@ -1324,18 +1328,19 @@ void CFlowOutput::SetVolumeOutputFieldsScalarSolution(const CConfig* config){ } } break; - case SPECIES_MODEL::FLAMELET: - /*--- Controlling variables. ---*/ - for (auto iCV=0u; iCVGetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); - AddVolumeOutput(cv_name, cv_name, "SOLUTION", cv_name + " solution."); - } - /*--- auxiliary species ---*/ - for (auto iReactant=0u; iReactantGetNUserScalars(); iReactant++) { - const auto& species_name = config->GetUserScalarName(iReactant); - AddVolumeOutput(species_name, species_name, "SOLUTION", species_name + "Mass fraction solution"); + case SPECIES_MODEL::FLAMELET: { + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); + /*--- Controlling variables. ---*/ + for (auto iCV=0u; iCVGetFlameletParsedOptions(); /*--- Residuals for controlling variable transport equations. ---*/ - for (auto iCV=0u; iCVGetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + for (auto iCV=0u; iCVGetNUserScalars(); iReactant++){ - const auto& species_name = config->GetUserScalarName(iReactant); + for (unsigned short iReactant=0; iReactantGetnSpecies(); iVar++) AddVolumeOutput("LIMITER_SPECIES_" + std::to_string(iVar), "Limiter_Species_" + std::to_string(iVar), "LIMITER", "Limiter value of the transported species " + std::to_string(iVar)); break; - case SPECIES_MODEL::FLAMELET: + case SPECIES_MODEL::FLAMELET: { + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Limiter for controlling variables transport. ---*/ - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddVolumeOutput("LIMITER_" + cv_name, "Limiter_" + cv_name, "LIMITER", "Limiter of " + cv_name + " controlling variable."); } /*--- limiter for auxiliary species transport ---*/ - for (unsigned short iReactant=0; iReactant < config->GetNUserScalars(); iReactant++) { - const auto& species_name = config->GetUserScalarName(iReactant); + for (unsigned short iReactant=0; iReactant < flamelet_config_options.n_user_scalars; iReactant++) { + const auto& species_name = flamelet_config_options.user_scalar_names[iReactant]; AddVolumeOutput("LIMITER_" + species_name, "LIMITER_" + species_name, "LIMITER", "Limiter value for the " + species_name + " equation"); } + } break; default: break; @@ -1489,19 +1498,21 @@ void CFlowOutput::SetVolumeOutputFieldsScalarSource(const CConfig* config) { /*--- Only place outputs of the "SOURCE" group for scalar transport here. ---*/ switch (config->GetKind_Species_Model()) { - case SPECIES_MODEL::FLAMELET: - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_source_name = config->GetControllingVariableSourceName(iCV); - const auto& cv_name = config->GetControllingVariableName(iCV); + case SPECIES_MODEL::FLAMELET: { + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_source_name = flamelet_config_options.cv_source_names[iCV]; + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; if (cv_source_name.compare("NULL") != 0) AddVolumeOutput("SOURCE_"+cv_name, "Source_" + cv_name, "SOURCE", "Source " + cv_name); } /*--- no source term for enthalpy ---*/ /*--- auxiliary species source terms ---*/ - for (auto iReactant=0u; iReactantGetNUserScalars(); iReactant++) { - const auto& species_name = config->GetUserScalarName(iReactant); + for (auto iReactant=0u; iReactantGetKind_Species_Model()) { - case SPECIES_MODEL::FLAMELET: - for (auto i_lookup = 0u; i_lookup < config->GetNLookups(); ++i_lookup) { - string strname1 = "lookup_" + config->GetLookupName(i_lookup); - AddVolumeOutput(config->GetLookupName(i_lookup), strname1,"LOOKUP", config->GetLookupName(i_lookup)); - } - AddVolumeOutput("TABLE_MISSES" , "Table_misses" , "LOOKUP", "Lookup table misses"); - break; - default: - break; + if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); + for (auto i_lookup = 0u; i_lookup < flamelet_config_options.n_lookups; ++i_lookup) { + string strname1 = "lookup_" + flamelet_config_options.lookup_names[i_lookup]; + AddVolumeOutput(flamelet_config_options.lookup_names[i_lookup], strname1,"LOOKUP", flamelet_config_options.lookup_names[i_lookup]); + } + AddVolumeOutput("TABLE_MISSES" , "Table_misses" , "LOOKUP", "Lookup table misses"); } } @@ -1669,47 +1677,47 @@ void CFlowOutput::LoadVolumeDataScalar(const CConfig* config, const CSolver* con case SPECIES_MODEL::FLAMELET: { const auto Node_Species = solver[SPECIES_SOL]->GetNodes(); - + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Controlling variables transport equations. ---*/ - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; SetVolumeOutputValue(cv_name, iPoint, Node_Species->GetSolution(iPoint, iCV)); SetVolumeOutputValue("RES_" + cv_name, iPoint, solver[SPECIES_SOL]->LinSysRes(iPoint, iCV)); - const auto& source_name = config->GetControllingVariableSourceName(iCV); + const auto& source_name = flamelet_config_options.cv_source_names[iCV]; if (source_name.compare("NULL") != 0) SetVolumeOutputValue("SOURCE_" + cv_name, iPoint, Node_Species->GetScalarSources(iPoint)[iCV]); } /*--- auxiliary species transport equations ---*/ - for (unsigned short i_scalar=0; i_scalarGetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); - SetVolumeOutputValue(scalar_name, iPoint, Node_Species->GetSolution(iPoint, config->GetNControlVars() + i_scalar)); - SetVolumeOutputValue("SOURCE_" + scalar_name, iPoint, Node_Species->GetScalarSources(iPoint)[config->GetNControlVars() + i_scalar]); - SetVolumeOutputValue("RES_" + scalar_name, iPoint, solver[SPECIES_SOL]->LinSysRes(iPoint, config->GetNControlVars() + i_scalar)); + for (unsigned short i_scalar=0; i_scalarGetSolution(iPoint, flamelet_config_options.n_control_vars + i_scalar)); + SetVolumeOutputValue("SOURCE_" + scalar_name, iPoint, Node_Species->GetScalarSources(iPoint)[flamelet_config_options.n_control_vars + i_scalar]); + SetVolumeOutputValue("RES_" + scalar_name, iPoint, solver[SPECIES_SOL]->LinSysRes(iPoint, flamelet_config_options.n_control_vars + i_scalar)); } if (config->GetKind_SlopeLimit_Species() != LIMITER::NONE) { /*--- Limiter for controlling variable transport equations. ---*/ - for (auto iCV=0u; iCVGetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + for (auto iCV=0u; iCVGetLimiter(iPoint, iCV)); } /*--- limiter for auxiliary species transport equations ---*/ - for (unsigned short i_scalar=0; i_scalarGetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); - SetVolumeOutputValue("LIMITER_" + scalar_name, iPoint, Node_Species->GetLimiter(iPoint, config->GetNControlVars() + i_scalar)); + for (unsigned short i_scalar=0; i_scalarGetLimiter(iPoint, flamelet_config_options.n_control_vars + i_scalar)); } } /*--- variables that we look up from the LUT ---*/ - for (int i_lookup = 0; i_lookup < config->GetNLookups(); ++i_lookup) { - if (config->GetLookupName(i_lookup)!="NULL") - SetVolumeOutputValue(config->GetLookupName(i_lookup), iPoint, Node_Species->GetScalarLookups(iPoint)[i_lookup]); + for (int i_lookup = 0; i_lookup < flamelet_config_options.n_lookups; ++i_lookup) { + if (flamelet_config_options.lookup_names[i_lookup] !="NULL") + SetVolumeOutputValue(flamelet_config_options.lookup_names[i_lookup], iPoint, Node_Species->GetScalarLookups(iPoint)[i_lookup]); } SetVolumeOutputValue("TABLE_MISSES", iPoint, Node_Species->GetTableMisses(iPoint)); - break; } + break; case SPECIES_MODEL::NONE: break; } } diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 55c73c0ef472..c73dd988729a 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -52,6 +52,7 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short default: break; } + if (config->GetCombustion()) flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Set the initial Streamwise periodic pressure drop value. ---*/ @@ -79,12 +80,12 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container bool ignition = false; /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ - if ((config->GetFlameletInitType() == FLAMELET_INIT_TYPE::SPARK) && !config->GetRestart()) { - auto spark_init = config->GetFlameInit(); + if (flamelet_config_options.ignition_method == FLAMELET_INIT_TYPE::SPARK) { + auto spark_init = flamelet_config_options.spark_init; spark_iter_start = ceil(spark_init[4]); spark_duration = ceil(spark_init[5]); unsigned long iter = config->GetMultizone_Problem() ? config->GetOuterIter() : config->GetInnerIter(); - ignition = ((iter >= spark_iter_start) && (iter <= (spark_iter_start + spark_duration)) && !config->GetRestart()); + ignition = ((iter >= spark_iter_start) && (iter <= (spark_iter_start + spark_duration))); } SU2_OMP_SAFE_GLOBAL_ACCESS(config->SetGlobalParam(config->GetKind_Solver(), RunTime_EqSystem);) @@ -95,9 +96,9 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container /*--- retrieve fluid model. ---*/ CFluidModel* fluid_model_local = solver_container[FLOW_SOL]->GetFluidModel(); /*--- Apply ignition temperature within spark radius. ---*/ - su2double dist_from_center = 0, spark_radius = config->GetFlameInit()[3]; + su2double dist_from_center = 0, spark_radius = flamelet_config_options.spark_init[3]; dist_from_center = - GeometryToolbox::SquaredDistance(nDim, geometry->nodes->GetCoord(i_point), config->GetFlameInit()); + GeometryToolbox::SquaredDistance(nDim, geometry->nodes->GetCoord(i_point), flamelet_config_options.spark_init.data()); if (dist_from_center < pow(spark_radius, 2)) { /*--- retrieve scalars solution. ---*/ su2double* scalars = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(i_point); diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index 2c6322392c72..009910e91a2a 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -3696,14 +3696,16 @@ void CSolver::LoadInletProfile(CGeometry **geometry, columnValue << config->GetInlet_SpeciesVal(Marker_Tag)[iVar] << "\t"; } break; - case SPECIES_MODEL::FLAMELET: + case SPECIES_MODEL::FLAMELET: { + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); /*--- 2-equation flamelet model ---*/ columnName << "PROGRESSVAR" << setw(24) << "ENTHALPYTOT" << setw(24); columnValue << config->GetInlet_SpeciesVal(Marker_Tag)[0] << "\t" << config->GetInlet_SpeciesVal(Marker_Tag)[1]<<"\t"; /*--- auxiliary species transport equations ---*/ - for (unsigned short iReactant = 0; iReactant < config->GetNUserScalars(); iReactant++) { - columnName << config->GetUserScalarName(iReactant) << setw(24); - columnValue << config->GetInlet_SpeciesVal(Marker_Tag)[config->GetNControlVars() + iReactant] << "\t"; + for (unsigned short iReactant = 0; iReactant < flamelet_config_options.n_user_scalars; iReactant++) { + columnName << flamelet_config_options.user_scalar_names[iReactant] << setw(24); + columnValue << config->GetInlet_SpeciesVal(Marker_Tag)[flamelet_config_options.n_control_vars + iReactant] << "\t"; + } } break; } diff --git a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp index 33ad74b3f38a..843ce6b0d7b7 100644 --- a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp @@ -36,9 +36,13 @@ CSpeciesFlameletSolver::CSpeciesFlameletSolver(CGeometry* geometry, CConfig* config, unsigned short iMesh) : CSpeciesSolver(geometry, config, true) { + + /*--- Retrieve options from config. ---*/ + flamelet_config_options = config->GetFlameletParsedOptions(); + /*--- Dimension of the problem. ---*/ - nVar = config->GetNScalars(); - include_mixture_fraction = (config->GetNControlVars() == 3); + nVar = flamelet_config_options.n_scalars; + include_mixture_fraction = (flamelet_config_options.n_control_vars == 3); Initialize(geometry, config, iMesh, nVar); @@ -73,8 +77,8 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver auto* flowNodes = su2staticcast_p(solver_container[FLOW_SOL]->GetNodes()); /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ - if ((config->GetFlameletInitType() == FLAMELET_INIT_TYPE::SPARK) && !config->GetRestart()) { - auto spark_init = config->GetFlameInit(); + if ((flamelet_config_options.ignition_method == FLAMELET_INIT_TYPE::SPARK) && !config->GetRestart()) { + auto spark_init = flamelet_config_options.spark_init; spark_iter_start = ceil(spark_init[4]); spark_duration = ceil(spark_init[5]); unsigned long iter = config->GetMultizone_Problem() ? config->GetOuterIter() : config->GetInnerIter(); @@ -95,18 +99,18 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver if (ignition) { /*--- Apply source terms within spark radius. ---*/ su2double dist_from_center = 0, - spark_radius = config->GetFlameInit()[3]; - dist_from_center = GeometryToolbox::SquaredDistance(nDim, geometry->nodes->GetCoord(i_point), config->GetFlameInit()); + spark_radius = flamelet_config_options.spark_init[3]; + dist_from_center = GeometryToolbox::SquaredDistance(nDim, geometry->nodes->GetCoord(i_point), flamelet_config_options.spark_init.data()); if (dist_from_center < pow(spark_radius,2)) { for (auto iVar = 0u; iVar < nVar; iVar++) - nodes->SetScalarSource(i_point, iVar, nodes->GetScalarSources(i_point)[iVar] + config->GetSpark()[iVar]); + nodes->SetScalarSource(i_point, iVar, nodes->GetScalarSources(i_point)[iVar] + flamelet_config_options.spark_reaction_rates[iVar]); } } nodes->SetTableMisses(i_point, misses); n_not_in_domain_local += misses; /*--- Obtain passive look-up scalars. ---*/ - SetScalarLookUps(config, fluid_model_local, i_point, scalars_vector); + SetScalarLookUps(fluid_model_local, i_point, scalars_vector); /*--- Set mass diffusivity based on thermodynamic state. ---*/ auto T = flowNodes->GetTemperature(i_point); @@ -117,8 +121,8 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver } /*--- Obtain preferential diffusion scalar values. ---*/ - if (config->GetPreferentialDiffusion()) - SetPreferentialDiffusionScalars(config, fluid_model_local, i_point, scalars_vector); + if (flamelet_config_options.preferential_diffusion) + SetPreferentialDiffusionScalars(fluid_model_local, i_point, scalars_vector); if (!Output) LinSysRes.SetBlock_Zero(i_point); } @@ -130,7 +134,7 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver cout << "Number of points outside manifold domain: " << n_not_in_domain_global << endl; /*--- Compute preferential diffusion scalar gradients. ---*/ - if (config->GetPreferentialDiffusion()) { + if (flamelet_config_options.preferential_diffusion) { switch (config->GetKind_Gradient_Method()) { case GREEN_GAUSS: SetAuxVar_Gradient_GG(geometry, config); @@ -157,11 +161,11 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver** su2double flame_offset[3] = {0, 0, 0}, flame_normal[3] = {0, 0, 0}, flame_thickness = 0, flame_burnt_thickness = 0, flamenorm = 0; - bool flame_front_ignition = (config->GetFlameletInitType() == FLAMELET_INIT_TYPE::FLAME_FRONT); + bool flame_front_ignition = (flamelet_config_options.ignition_method == FLAMELET_INIT_TYPE::FLAME_FRONT); if (flame_front_ignition) { /*--- Collect flame front ignition parameters. ---*/ - auto flame_init = config->GetFlameInit(); + auto flame_init = flamelet_config_options.flame_init; for (auto iDim = 0u; iDim < 3; ++iDim) { flame_offset[iDim] = flame_init[iDim]; flame_normal[iDim] = flame_init[3 + iDim]; @@ -179,11 +183,11 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver** if (rank == MASTER_NODE) { cout << "initial condition: T = " << temp_inlet << endl; - for (auto iCV = 0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + for (auto iCV = 0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; cout << "initial condition: " << cv_name << " = " << config->GetSpecies_Init()[iCV] << endl; } - switch (config->GetFlameletInitType()) { + switch (flamelet_config_options.ignition_method) { case FLAMELET_INIT_TYPE::FLAME_FRONT: cout << "Ignition with a straight flame front" << endl; break; @@ -214,12 +218,14 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver** scalar_init[I_ENTH] = enth_inlet; prog_unburnt = config->GetSpecies_Init()[I_PROGVAR]; - prog_burnt = GetBurntProgressVariable(fluid_model_local, scalar_init); SU2_OMP_FOR_STAT(omp_chunk_size) for (unsigned long i_point = 0; i_point < nPoint; i_point++) { auto coords = geometry[i_mesh]->nodes->GetCoord(i_point); if (flame_front_ignition) { + + prog_burnt = GetBurntProgressVariable(fluid_model_local, scalar_init); + /*--- Determine if point is above or below the plane, assuming the normal is pointing towards the burned region. ---*/ point_loc = 0.0; @@ -258,7 +264,7 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver** n_not_in_domain_local += fluid_model_local->GetExtrapolation(); /* --- Initialize the auxiliary transported scalars (not controlling variables). --- */ - for (int i_scalar = config->GetNControlVars(); i_scalar < config->GetNScalars(); ++i_scalar) { + for (int i_scalar = flamelet_config_options.n_control_vars; i_scalar < flamelet_config_options.n_scalars; ++i_scalar) { scalar_init[i_scalar] = config->GetSpecies_Init()[i_scalar]; } @@ -506,40 +512,40 @@ unsigned long CSpeciesFlameletSolver::SetScalarSources(const CConfig* config, CF unsigned long iPoint, const vector& scalars) { /*--- Compute total source terms from the production and consumption. ---*/ - vector table_sources(config->GetNControlVars() + 2 * config->GetNUserScalars()); + vector table_sources(flamelet_config_options.n_control_vars + 2 * flamelet_config_options.n_user_scalars); unsigned long misses = fluid_model_local->EvaluateDataSet(scalars, FLAMELET_LOOKUP_OPS::SOURCES, table_sources); table_sources[I_PROGVAR] = fmax(0, table_sources[I_PROGVAR]); nodes->SetTableMisses(iPoint, misses); /*--- The source term for progress variable is always positive, we clip from below to makes sure. --- */ - vector source_scalar(config->GetNScalars()); - for (auto iCV = 0u; iCV < config->GetNControlVars(); iCV++) source_scalar[iCV] = table_sources[iCV]; + vector source_scalar(flamelet_config_options.n_scalars); + for (auto iCV = 0u; iCV < flamelet_config_options.n_control_vars; iCV++) source_scalar[iCV] = table_sources[iCV]; /*--- Source term for the auxiliary species transport equations. ---*/ - for (size_t i_aux = 0; i_aux < config->GetNUserScalars(); i_aux++) { + for (size_t i_aux = 0; i_aux < flamelet_config_options.n_user_scalars; i_aux++) { /*--- The source term for the auxiliary equations consists of a production term and a consumption term: S_TOT = S_PROD + S_CONS * Y ---*/ - su2double y_aux = scalars[config->GetNControlVars() + i_aux]; - su2double source_prod = table_sources[config->GetNControlVars() + 2 * i_aux]; - su2double source_cons = table_sources[config->GetNControlVars() + 2 * i_aux + 1]; - source_scalar[config->GetNControlVars() + i_aux] = source_prod + source_cons * y_aux; + su2double y_aux = scalars[flamelet_config_options.n_control_vars + i_aux]; + su2double source_prod = table_sources[flamelet_config_options.n_control_vars + 2 * i_aux]; + su2double source_cons = table_sources[flamelet_config_options.n_control_vars + 2 * i_aux + 1]; + source_scalar[flamelet_config_options.n_control_vars + i_aux] = source_prod + source_cons * y_aux; } for (auto i_scalar = 0u; i_scalar < nVar; i_scalar++) nodes->SetScalarSource(iPoint, i_scalar, source_scalar[i_scalar]); return misses; } -unsigned long CSpeciesFlameletSolver::SetScalarLookUps(const CConfig* config, CFluidModel* fluid_model_local, +unsigned long CSpeciesFlameletSolver::SetScalarLookUps(CFluidModel* fluid_model_local, unsigned long iPoint, const vector& scalars) { /*--- Retrieve the passive look-up variables from the manifold. ---*/ unsigned long misses{0}; /*--- Skip if no passive look-ups are listed ---*/ - if (config->GetNLookups() > 0) { - vector lookup_scalar(config->GetNLookups()); + if (flamelet_config_options.n_lookups > 0) { + vector lookup_scalar(flamelet_config_options.n_lookups); misses = fluid_model_local->EvaluateDataSet(scalars, FLAMELET_LOOKUP_OPS::LOOKUP, lookup_scalar); - for (auto i_lookup = 0u; i_lookup < config->GetNLookups(); i_lookup++) { + for (auto i_lookup = 0u; i_lookup < flamelet_config_options.n_lookups; i_lookup++) { nodes->SetLookupScalar(iPoint, lookup_scalar[i_lookup], i_lookup); } } @@ -547,8 +553,7 @@ unsigned long CSpeciesFlameletSolver::SetScalarLookUps(const CConfig* config, CF return misses; } -unsigned long CSpeciesFlameletSolver::SetPreferentialDiffusionScalars(const CConfig* config, - CFluidModel* fluid_model_local, +unsigned long CSpeciesFlameletSolver::SetPreferentialDiffusionScalars(CFluidModel* fluid_model_local, unsigned long iPoint, const vector& scalars) { /*--- Retrieve the preferential diffusion scalar values from the manifold. ---*/ @@ -566,7 +571,7 @@ void CSpeciesFlameletSolver::Viscous_Residual(const unsigned long iEdge, const C CNumerics* numerics, const CConfig* config) { /*--- Overloaded viscous residual method which accounts for preferential diffusion. ---*/ const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT), - PreferentialDiffusion = config->GetPreferentialDiffusion(); + PreferentialDiffusion = flamelet_config_options.preferential_diffusion; /*--- Points in edge ---*/ auto iPoint = geometry->edges->GetNode(iEdge, 0); @@ -592,7 +597,7 @@ void CSpeciesFlameletSolver::Viscous_Residual(const unsigned long iEdge, const C diff_coeff_beta_j[MAXNVAR] = {0}; // Number of active transport scalars - const auto n_CV = config->GetNControlVars(); + const auto n_CV = flamelet_config_options.n_control_vars; su2activematrix scalar_grad_i(MAXNVAR, MAXNDIM), scalar_grad_j(MAXNVAR, MAXNDIM); /*--- Looping over spatial dimensions to fill in the diffusion scalar gradients. ---*/ diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index 458ba9b403fe..d4e5bfe9c1e8 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -41,6 +41,8 @@ CSpeciesSolver::CSpeciesSolver(CGeometry* geometry, CConfig* config, unsigned sh nVar = config->GetnSpecies(); + if (config->GetCombustion()) flamelet_config_options = config->GetFlameletParsedOptions(); + Initialize(geometry, config, iMesh, nVar); /*--- Initialize the solution to the far-field state everywhere. ---*/ @@ -299,12 +301,12 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain const bool implicit = (config->GetKind_TimeIntScheme_Species() == EULER_IMPLICIT); /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ - if ((config->GetFlameletInitType() == FLAMELET_INIT_TYPE::SPARK) && !config->GetRestart()) { - auto spark_init = config->GetFlameInit(); + if (flamelet_config_options.ignition_method == FLAMELET_INIT_TYPE::SPARK) { + auto spark_init = flamelet_config_options.spark_init; spark_iter_start = ceil(spark_init[4]); spark_duration = ceil(spark_init[5]); unsigned long iter = config->GetMultizone_Problem() ? config->GetOuterIter() : config->GetInnerIter(); - ignition = ((iter >= spark_iter_start) && (iter <= (spark_iter_start + spark_duration)) && !config->GetRestart()); + ignition = ((iter >= spark_iter_start) && (iter <= (spark_iter_start + spark_duration))); } SU2_OMP_SAFE_GLOBAL_ACCESS(config->SetGlobalParam(config->GetKind_Solver(), RunTime_EqSystem);) @@ -313,9 +315,9 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain for (auto iPoint = 0u; iPoint < nPoint; iPoint++) { if (ignition) { /*--- Apply source terms within spark radius. ---*/ - su2double dist_from_center = 0, spark_radius = config->GetFlameInit()[3]; + su2double dist_from_center = 0, spark_radius = flamelet_config_options.spark_init[3]; dist_from_center = - GeometryToolbox::SquaredDistance(nDim, geometry->nodes->GetCoord(iPoint), config->GetFlameInit()); + GeometryToolbox::SquaredDistance(nDim, geometry->nodes->GetCoord(iPoint), flamelet_config_options.spark_init.data()); if (dist_from_center < pow(spark_radius, 2)) { temperature = config->GetSpark_Temperature(); } else { diff --git a/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp b/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp index 9b8d9b562126..f9e38b971773 100644 --- a/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp +++ b/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp @@ -49,12 +49,12 @@ CSpeciesFlameletVariable::CSpeciesFlameletVariable(const su2double* species_inf, Res_TruncError.resize(nPoint, nVar) = su2double(0.0); /* Allocate space for the source and scalars for visualization */ - - source_scalar.resize(nPoint, config->GetNScalars()) = su2double(0.0); - lookup_scalar.resize(nPoint, config->GetNLookups()) = su2double(0.0); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); + source_scalar.resize(nPoint, flamelet_config_options.n_scalars) = su2double(0.0); + lookup_scalar.resize(nPoint, flamelet_config_options.n_lookups) = su2double(0.0); table_misses.resize(nPoint) = 0; - if (config->GetPreferentialDiffusion()) { + if (flamelet_config_options.preferential_diffusion) { AuxVar.resize(nPoint, FLAMELET_PREF_DIFF_SCALARS::N_BETA_TERMS) = su2double(0.0); Grad_AuxVar.resize(nPoint, FLAMELET_PREF_DIFF_SCALARS::N_BETA_TERMS, nDim, 0.0); } From 52982a4fb9b47e71abc4f3a8fff0c7a194cee09e Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 28 Apr 2025 16:40:20 +0200 Subject: [PATCH 096/173] updating to develop --- .github/workflows/regression.yml | 2 +- .../include/solvers/CFVMFlowSolverBase.inl | 90 ++-- SU2_CFD/include/solvers/CTurbSolver.hpp | 7 + SU2_CFD/include/variables/CTurbVariable.hpp | 6 +- SU2_CFD/include/variables/CVariable.hpp | 14 + SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 1 + .../src/solvers/CSpeciesFlameletSolver.cpp | 4 +- SU2_CFD/src/solvers/CTurbSolver.cpp | 9 + SU2_CFD/src/variables/CNSVariable.cpp | 2 + SU2_CFD/src/variables/CTurbVariable.cpp | 4 + .../optim.csv.ref | 2 +- .../naca0012/of_grad_cd_disc.dat.ref | 76 ++-- .../naca0012/of_grad_directdiff.dat.ref | 6 +- .../wedge/of_grad_combo.dat.ref | 8 +- .../disc_adj_fsi/Airfoil_2d/configFlow.cfg | 9 +- TestCases/disc_adj_fsi/dyn_fsi/config.cfg | 5 +- TestCases/disc_adj_fsi/dyn_fsi/configFEA.cfg | 3 +- TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg | 9 +- .../disc_adj_fsi/dyn_fsi/grad_dv.opt.ref | 16 +- .../lam_prem_ch4_cht_cfd_master.cfg | 4 +- .../lam_prem_ch4_cht_ad_master.cfg | 3 +- TestCases/hybrid_regression.py | 70 +-- TestCases/hybrid_regression_AD.py | 12 +- .../chtPinArray_2d/of_grad_findiff.csv.ref | 2 +- .../multiple_ffd/naca0012/of_grad_cd.dat.ref | 4 +- .../naca0012/of_grad_directdiff.dat.ref | 4 +- .../nicf/datadriven/datadriven_nozzle.cfg | 39 +- TestCases/parallel_regression.py | 188 ++++---- TestCases/parallel_regression_AD.py | 82 ++-- .../translating_NACA0012/config.cfg | 14 +- .../translating_NACA0012/forces_0.csv.ref | 400 +++++++++--------- .../updated_moving_frame_NACA12/config.cfg | 7 +- TestCases/rotating/naca0012/rot_NACA0012.cfg | 2 +- TestCases/serial_regression.py | 94 ++-- TestCases/serial_regression_AD.py | 16 +- TestCases/tutorials.py | 50 ++- TestCases/vandv.py | 26 +- .../vandv/rans/dsma661/dsma661_sa_config.cfg | 140 ++++++ .../vandv/rans/dsma661/dsma661_sst_config.cfg | 140 ++++++ UnitTests/SU2_CFD/fluid/CFluidModel_tests.cpp | 122 ++++++ .../SU2_CFD/fluid/CFluidModel_tests_AD.cpp | 156 +++++++ UnitTests/SU2_CFD/fluid/MLP_PINN.mlp | 78 ++++ UnitTests/meson.build | 4 + config_template.cfg | 9 +- meson_scripts/init.py | 2 +- 45 files changed, 1341 insertions(+), 600 deletions(-) create mode 100644 TestCases/vandv/rans/dsma661/dsma661_sa_config.cfg create mode 100644 TestCases/vandv/rans/dsma661/dsma661_sst_config.cfg create mode 100644 UnitTests/SU2_CFD/fluid/CFluidModel_tests.cpp create mode 100644 UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp create mode 100644 UnitTests/SU2_CFD/fluid/MLP_PINN.mlp diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 5f1debbe6386..16e66fe5020b 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -31,7 +31,7 @@ jobs: - config_set: ReverseMPI flags: '-Denable-autodiff=true -Denable-normal=false -Denable-pywrapper=true -Denable-tests=true --warnlevel=3 --werror' - config_set: ForwardMPI - flags: '-Denable-directdiff=true -Denable-normal=false -Denable-tests=true --warnlevel=3 --werror' + flags: '-Denable-directdiff=true -Denable-normal=false -Denable-tests=true -Denable-mlpcpp=true --warnlevel=3 --werror' - config_set: BaseNoMPI flags: '-Denable-pywrapper=true -Denable-openblas=true -Dwith-mpi=disabled -Denable-mlpcpp=true -Denable-tests=true --warnlevel=3 --werror' - config_set: ReverseNoMPI diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 8a99712dc8e0..a29a47f2c617 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -1141,41 +1141,54 @@ void CFVMFlowSolverBase::BC_Sym_Plane(CGeometry* geometry, CSolve for (auto iDim = 0u; iDim < nDim; iDim++) UnitNormal[iDim] = Normal[iDim] / Area; } - su2double* V_reflected = GetCharacPrimVar(val_marker, iVertex); + /*--- Energy terms due to grid movement (aka work of pressure forces). ---*/ + if (dynamic_grid) { + su2double* V_reflected = GetCharacPrimVar(val_marker, iVertex); - /*--- Grid movement ---*/ - if (dynamic_grid) - conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); + conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), + geometry->nodes->GetGridVel(iPoint)); - /*--- Normal vector for this vertex (negate for outward convention). ---*/ - for (auto iDim = 0u; iDim < nDim; iDim++) Normal[iDim] = -Normal[iDim]; - conv_numerics->SetNormal(Normal); + /*--- Normal vector for this vertex (negate for outward convention). ---*/ + for (auto iDim = 0u; iDim < nDim; iDim++) Normal[iDim] = -Normal[iDim]; + conv_numerics->SetNormal(Normal); - for (auto iVar = 0u; iVar < nPrimVar; iVar++) - V_reflected[iVar] = nodes->GetPrimitive(iPoint, iVar); + for (auto iVar = 0u; iVar < nPrimVar; iVar++) + V_reflected[iVar] = nodes->GetPrimitive(iPoint, iVar); - su2double ProjVelocity_i = nodes->GetProjVel(iPoint, UnitNormal); - /*--- Adjustment to v.n due to grid movement. ---*/ - if (dynamic_grid) + su2double ProjVelocity_i = nodes->GetProjVel(iPoint, UnitNormal); + /*--- Adjustment to v.n due to grid movement. ---*/ ProjVelocity_i -= GeometryToolbox::DotProduct(nDim, geometry->nodes->GetGridVel(iPoint), UnitNormal); - for (auto iDim = 0u; iDim < nDim; iDim++) - V_reflected[iDim + iVel] = nodes->GetVelocity(iPoint, iDim) - ProjVelocity_i * UnitNormal[iDim]; + for (auto iDim = 0u; iDim < nDim; iDim++) + V_reflected[iDim + iVel] = nodes->GetVelocity(iPoint, iDim) - ProjVelocity_i * UnitNormal[iDim]; - /*--- Get current solution at this boundary node ---*/ - const su2double* V_domain = nodes->GetPrimitive(iPoint); + /*--- Get current solution at this boundary node. ---*/ + const su2double* V_domain = nodes->GetPrimitive(iPoint); - /*--- Set Primitive and Secondary for numerics class. ---*/ - conv_numerics->SetPrimitive(V_domain, V_reflected); - conv_numerics->SetSecondary(nodes->GetSecondary(iPoint), nodes->GetSecondary(iPoint)); + /*--- Set Primitive and Secondary for numerics class. ---*/ + conv_numerics->SetPrimitive(V_domain, V_reflected); + conv_numerics->SetSecondary(nodes->GetSecondary(iPoint), nodes->GetSecondary(iPoint)); - /*--- Compute the residual using an upwind scheme. ---*/ - auto residual = conv_numerics->ComputeResidual(config); + /*--- Compute the residual using an upwind scheme. ---*/ + auto residual = conv_numerics->ComputeResidual(config); - /*--- We include an update of the continuity and energy here, this is important for stability since - * these fluxes include numerical diffusion. ---*/ - for (auto iVar = 0u; iVar < nVar; iVar++) { - if (iVar < iVel || iVar >= iVel + nDim) LinSysRes(iPoint, iVar) += residual.residual[iVar]; + /*--- Use just the energy fluxes to update the residual, adding the others would + * increase numerical diffusion which we wish to avoid if possible. ---*/ + for (auto iVar = iVel + nDim; iVar < nVar; iVar++) { + LinSysRes(iPoint, iVar) += residual.residual[iVar]; + } + if (implicit) { + auto* block = Jacobian.GetBlock(iPoint, iPoint); + /*--- But in the Jacobian we also include the mass flux, this allows some cases with + * motion to use larger CFL, for example pywrapper_translating_naca0012. ---*/ + for (auto iVar = 0u; iVar < nVar; iVar++) { + if (iVar < iVel || iVar >= iVel + nDim) { + for (auto jVar = 0u; jVar < nVar; jVar++) { + block[iVar * nVar + jVar] += SU2_TYPE::GetValue(residual.jacobian_i[iVar][jVar]); + } + } + } + } } /*--- Explicitly set the velocity components normal to the symmetry plane to zero. @@ -1184,7 +1197,7 @@ void CFVMFlowSolverBase::BC_Sym_Plane(CGeometry* geometry, CSolve su2double* solutionOld = nodes->GetSolution_Old(iPoint); - su2double gridVel[MAXNVAR] = {}; + su2double gridVel[MAXNDIM] = {}; if (dynamic_grid) { for (auto iDim = 0u; iDim < nDim; iDim++) { gridVel[iDim] = geometry->nodes->GetGridVel(iPoint)[iDim]; @@ -1215,7 +1228,30 @@ void CFVMFlowSolverBase::BC_Sym_Plane(CGeometry* geometry, CSolve /*--- Jacobian contribution for implicit integration. ---*/ if (implicit) { - Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); + /*--- Modify the Jacobians according to the modification of the residual + * J_new = (I - n * n^T) * J where n = {0, nx, ny, nz, 0, ...} ---*/ + su2double mat[MAXNVAR * MAXNVAR] = {}; + + for (auto iVar = 0u; iVar < nVar; iVar++) + mat[iVar * nVar + iVar] = 1; + for (auto iDim = 0u; iDim < nDim; iDim++) + for (auto jDim = 0u; jDim < nDim; jDim++) + mat[(iDim + iVel) * nVar + jDim + iVel] -= UnitNormal[iDim] * UnitNormal[jDim]; + + auto ModifyJacobian = [&](const unsigned long jPoint) { + su2double jac[MAXNVAR * MAXNVAR], newJac[MAXNVAR * MAXNVAR]; + auto* block = Jacobian.GetBlock(iPoint, jPoint); + for (auto iVar = 0u; iVar < nVar * nVar; iVar++) jac[iVar] = block[iVar]; + + CBlasStructure().gemm(nVar, nVar, nVar, mat, jac, newJac, config); + + for (auto iVar = 0u; iVar < nVar * nVar; iVar++) + block[iVar] = SU2_TYPE::GetValue(newJac[iVar]); + }; + ModifyJacobian(iPoint); + for (size_t iNeigh = 0; iNeigh < geometry->nodes->GetnPoint(iPoint); ++iNeigh) { + ModifyJacobian(geometry->nodes->GetPoint(iPoint, iNeigh)); + } } /*--- Correction for multigrid. ---*/ diff --git a/SU2_CFD/include/solvers/CTurbSolver.hpp b/SU2_CFD/include/solvers/CTurbSolver.hpp index 8040e53ad17f..c61fd4d91dc3 100644 --- a/SU2_CFD/include/solvers/CTurbSolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSolver.hpp @@ -140,4 +140,11 @@ class CTurbSolver : public CScalarSolver { Inlet_TurbVars[val_marker][val_vertex][val_dim] = val_turb_var; } + /*! + * \brief Register additional In- or Outputs for RANS. + * \param[in] input - Boolean whether In- or Output should be registered. + * \param[in] config - The particular config. + * \returns The number of extra variables. + */ + unsigned long RegisterSolutionExtra(bool input, const CConfig* config) final; }; diff --git a/SU2_CFD/include/variables/CTurbVariable.hpp b/SU2_CFD/include/variables/CTurbVariable.hpp index 48f2087b2bf4..466815682864 100644 --- a/SU2_CFD/include/variables/CTurbVariable.hpp +++ b/SU2_CFD/include/variables/CTurbVariable.hpp @@ -100,5 +100,9 @@ class CTurbVariable : public CScalarVariable { */ inline void SetIntermittency(unsigned long iPoint, su2double val_intermittency) final { intermittency(iPoint) = val_intermittency; } + /*! + * \brief Register eddy viscosity (muT) as Input or Output of an AD recording. + * \param[in] input - Boolean whether In- or Output should be registered. + */ + void RegisterEddyViscosity(bool input); }; - diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index fe5191f89610..05c1b8028f7a 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -137,6 +137,20 @@ class CVariable { RegisterContainer(input, variable, &ad_index); } + void RegisterContainer(bool input, su2activevector& variable, su2vector* ad_index = nullptr) { + const auto nPoint = variable.rows(); + SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads())) + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + + if (input) AD::RegisterInput(variable(iPoint)); + else AD::RegisterOutput(variable(iPoint)); + + if (ad_index) AD::SetIndex((*ad_index)(iPoint), variable(iPoint)); + + } + END_SU2_OMP_FOR + } + public: /*--- Disable copy and assignment. ---*/ CVariable(const CVariable&) = delete; diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index eada9828e352..9f26966b91b1 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -162,6 +162,7 @@ void CDiscAdjSolver::RegisterSolution(CGeometry *geometry, CConfig *config) { /*--- Boolean true indicates that an input is registered ---*/ direct_solver->GetNodes()->RegisterSolution(true); + /*--- Register quantities that are no solver variables but further inputs/outputs of the (outer) iteration. ---*/ direct_solver->RegisterSolutionExtra(true, config); if (time_n_needed) diff --git a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp index 843ce6b0d7b7..56ae8f674dcd 100644 --- a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp @@ -77,12 +77,12 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver auto* flowNodes = su2staticcast_p(solver_container[FLOW_SOL]->GetNodes()); /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ - if ((flamelet_config_options.ignition_method == FLAMELET_INIT_TYPE::SPARK) && !config->GetRestart()) { + if ((flamelet_config_options.ignition_method == FLAMELET_INIT_TYPE::SPARK)) { auto spark_init = flamelet_config_options.spark_init; spark_iter_start = ceil(spark_init[4]); spark_duration = ceil(spark_init[5]); unsigned long iter = config->GetMultizone_Problem() ? config->GetOuterIter() : config->GetInnerIter(); - ignition = ((iter >= spark_iter_start) && (iter <= (spark_iter_start + spark_duration)) && !config->GetRestart()); + ignition = ((iter >= spark_iter_start) && (iter <= (spark_iter_start + spark_duration))); } SU2_OMP_SAFE_GLOBAL_ACCESS(config->SetGlobalParam(config->GetKind_Solver(), RunTime_EqSystem);) diff --git a/SU2_CFD/src/solvers/CTurbSolver.cpp b/SU2_CFD/src/solvers/CTurbSolver.cpp index 2340369c0c77..9d47a99f547b 100644 --- a/SU2_CFD/src/solvers/CTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSolver.cpp @@ -236,3 +236,12 @@ void CTurbSolver::Impose_Fixed_Values(const CGeometry *geometry, const CConfig * } } + +unsigned long CTurbSolver::RegisterSolutionExtra(bool input, const CConfig* config) { + + /*--- Register muT as input/output of a RANS iteration. ---*/ + nodes->RegisterEddyViscosity(input); + + /*--- We don't need to save adjoint values for muT. ---*/ + return 0; +} diff --git a/SU2_CFD/src/variables/CNSVariable.cpp b/SU2_CFD/src/variables/CNSVariable.cpp index 5b67a0bdbb8e..a7dda66b982d 100644 --- a/SU2_CFD/src/variables/CNSVariable.cpp +++ b/SU2_CFD/src/variables/CNSVariable.cpp @@ -114,6 +114,8 @@ void CNSVariable::SetRoe_Dissipation_FD(unsigned long iPoint, su2double val_wall AD::SetPreaccIn(Primitive(iPoint, indices.EddyViscosity())); /*--- Laminar viscosity --- */ AD::SetPreaccIn(Primitive(iPoint, indices.LaminarViscosity())); + /*--- Density; GetDensity reads from Solution (not Primitive) at index 0 ---*/ + AD::SetPreaccIn(Solution(iPoint, 0)); su2double uijuij = 0.0; diff --git a/SU2_CFD/src/variables/CTurbVariable.cpp b/SU2_CFD/src/variables/CTurbVariable.cpp index 46b686766a78..5703e3eadc52 100644 --- a/SU2_CFD/src/variables/CTurbVariable.cpp +++ b/SU2_CFD/src/variables/CTurbVariable.cpp @@ -36,3 +36,7 @@ CTurbVariable::CTurbVariable(unsigned long npoint, unsigned long ndim, unsigned intermittency.resize(nPoint) = su2double(1.0); } + +void CTurbVariable::RegisterEddyViscosity(bool input) { + RegisterContainer(input, muT); +} diff --git a/TestCases/Tutorials/design/Inc_Turbulent_Bend_Wallfunctions/optim.csv.ref b/TestCases/Tutorials/design/Inc_Turbulent_Bend_Wallfunctions/optim.csv.ref index fb3d04a9bb49..2423dbf65989 100644 --- a/TestCases/Tutorials/design/Inc_Turbulent_Bend_Wallfunctions/optim.csv.ref +++ b/TestCases/Tutorials/design/Inc_Turbulent_Bend_Wallfunctions/optim.csv.ref @@ -1,2 +1,2 @@ ITER, avg_dp -1, 63.82289754521027 +1, 64.90301114659223 diff --git a/TestCases/cont_adj_euler/naca0012/of_grad_cd_disc.dat.ref b/TestCases/cont_adj_euler/naca0012/of_grad_cd_disc.dat.ref index 6da6f45e3ee1..43f74e02a639 100644 --- a/TestCases/cont_adj_euler/naca0012/of_grad_cd_disc.dat.ref +++ b/TestCases/cont_adj_euler/naca0012/of_grad_cd_disc.dat.ref @@ -1,39 +1,39 @@ VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" - 0 , -2656.0 , 0.001 - 1 , -7290.69 , 0.001 - 2 , -11252.7 , 0.001 - 3 , -12531.4 , 0.001 - 4 , -10923.7 , 0.001 - 5 , -6826.86 , 0.001 - 6 , -843.71 , 0.001 - 7 , 6462.74 , 0.001 - 8 , 14656.3 , 0.001 - 9 , 23308.0 , 0.001 - 10 , 31688.2 , 0.001 - 11 , 38407.2 , 0.001 - 12 , 41274.9 , 0.001 - 13 , 37812.2 , 0.001 - 14 , 27093.1 , 0.001 - 15 , 14049.9 , 0.001 - 16 , 17583.8 , 0.001 - 17 , 78620.8 , 0.001 - 18 , 140614.0 , 0.001 - 19 , -18263.2 , 0.001 - 20 , -20877.9 , 0.001 - 21 , -22859.6 , 0.001 - 22 , -24751.5 , 0.001 - 23 , -28392.5 , 0.001 - 24 , -35514.1 , 0.001 - 25 , -46855.4 , 0.001 - 26 , -61697.7 , 0.001 - 27 , -77631.1 , 0.001 - 28 , -90537.8 , 0.001 - 29 , -95036.8 , 0.001 - 30 , -85899.0 , 0.001 - 31 , -60885.3 , 0.001 - 32 , -24333.4 , 0.001 - 33 , 12334.3 , 0.001 - 34 , 39948.1 , 0.001 - 35 , 65452.2 , 0.001 - 36 , 82215.8 , 0.001 - 37 , -44066.2 , 0.001 + 0 , 292.459 , 0.001 + 1 , -8318.5 , 0.001 + 2 , -16158.4 , 0.001 + 3 , -21277.2 , 0.001 + 4 , -23366.9 , 0.001 + 5 , -22727.6 , 0.001 + 6 , -19872.3 , 0.001 + 7 , -15278.1 , 0.001 + 8 , -9283.99 , 0.001 + 9 , -2179.87 , 0.001 + 10 , 5520.63 , 0.001 + 11 , 12726.0 , 0.001 + 12 , 17538.0 , 0.001 + 13 , 17441.1 , 0.001 + 14 , 10335.6 , 0.001 + 15 , -2686.37 , 0.001 + 16 , -10522.5 , 0.001 + 17 , 24712.2 , 0.001 + 18 , 166438.0 , 0.001 + 19 , -15618.6 , 0.001 + 20 , -14178.7 , 0.001 + 21 , -12765.5 , 0.001 + 22 , -12007.2 , 0.001 + 23 , -13597.5 , 0.001 + 24 , -19002.9 , 0.001 + 25 , -28729.6 , 0.001 + 26 , -41946.6 , 0.001 + 27 , -56289.3 , 0.001 + 28 , -67832.1 , 0.001 + 29 , -71484.0 , 0.001 + 30 , -62334.5 , 0.001 + 31 , -38478.2 , 0.001 + 32 , -4757.34 , 0.001 + 33 , 26448.5 , 0.001 + 34 , 45049.5 , 0.001 + 35 , 60960.9 , 0.001 + 36 , 83515.9 , 0.001 + 37 , 8837.4 , 0.001 diff --git a/TestCases/cont_adj_euler/naca0012/of_grad_directdiff.dat.ref b/TestCases/cont_adj_euler/naca0012/of_grad_directdiff.dat.ref index 1b4c963eeacc..2d6e15119833 100644 --- a/TestCases/cont_adj_euler/naca0012/of_grad_directdiff.dat.ref +++ b/TestCases/cont_adj_euler/naca0012/of_grad_directdiff.dat.ref @@ -1,4 +1,4 @@ VARIABLES="VARIABLE" , "DRAG" , "EFFICIENCY" , "FORCE_X" , "FORCE_Y" , "FORCE_Z" , "LIFT" , "MOMENT_X" , "MOMENT_Y" , "MOMENT_Z" , "SIDEFORCE" - 0 , 0.2405003164 , -108.3397202 , 0.2752804375 , -1.591326829 , 0.0 , -1.596953347 , 0.0 , 0.0 , 1.18511582 , 0.0 - 1 , 0.4163088272 , -176.5661566 , 0.4692829784 , -2.423229574 , 0.0 , -2.432890265 , 0.0 , 0.0 , 1.020271816 , 0.0 - 2 , 0.5558397416 , -231.7769399 , 0.6239540061 , -3.115569035 , 0.0 , -3.128439099 , 0.0 , 0.0 , 0.6093229584 , 0.0 + 0 , 0.24008251 , -117.3444057 , 0.2742430499 , -1.56293638 , 0.0 , -1.568547024 , 0.0 , 0.0 , 1.189018284 , 0.0 + 1 , 0.4064005433 , -189.77779 , 0.4586830911 , -2.391641926 , 0.0 , -2.401078899 , 0.0 , 0.0 , 1.030793484 , 0.0 + 2 , 0.5421052294 , -249.5397676 , 0.6095878335 , -3.086770277 , 0.0 , -3.099333798 , 0.0 , 0.0 , 0.6218682473 , 0.0 diff --git a/TestCases/cont_adj_euler/wedge/of_grad_combo.dat.ref b/TestCases/cont_adj_euler/wedge/of_grad_combo.dat.ref index 8ef5d9598b78..eca2a7ba1835 100644 --- a/TestCases/cont_adj_euler/wedge/of_grad_combo.dat.ref +++ b/TestCases/cont_adj_euler/wedge/of_grad_combo.dat.ref @@ -1,5 +1,5 @@ VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" - 0 , 0.00770904 , 0.0001 - 1 , 0.00500468 , 0.0001 - 2 , 0.00247269 , 0.0001 - 3 , 0.000899035 , 0.0001 + 0 , 0.00765473 , 0.0001 + 1 , 0.00497838 , 0.0001 + 2 , 0.0024697 , 0.0001 + 3 , 0.00090216 , 0.0001 diff --git a/TestCases/disc_adj_fsi/Airfoil_2d/configFlow.cfg b/TestCases/disc_adj_fsi/Airfoil_2d/configFlow.cfg index 845c47996540..23143f1ea39f 100755 --- a/TestCases/disc_adj_fsi/Airfoil_2d/configFlow.cfg +++ b/TestCases/disc_adj_fsi/Airfoil_2d/configFlow.cfg @@ -51,10 +51,9 @@ TIME_DISCRE_FLOW= EULER_IMPLICIT % Linear solvers ------------------------------------------------------- % LINEAR_SOLVER= FGMRES LINEAR_SOLVER_PREC= ILU -LINEAR_SOLVER_ERROR= 1E-3 -LINEAR_SOLVER_ITER= 20 -LINEAR_SOLVER_SMOOTHER_RELAXATION= 0.7 -DISCADJ_LIN_SOLVER= SMOOTHER +LINEAR_SOLVER_ERROR= 1E-4 +LINEAR_SOLVER_ITER= 50 +DISCADJ_LIN_SOLVER= FGMRES DISCADJ_LIN_PREC= ILU NEWTON_KRYLOV= YES QUASI_NEWTON_NUM_SAMPLES= 999 @@ -91,4 +90,4 @@ VOLUME_ADJ_FILENAME= adjoint_fluid SURFACE_FILENAME= surface_fluid SURFACE_ADJ_FILENAME= adjoint_surface_fluid SCREEN_WRT_FREQ_INNER= 10 -CONV_FILENAME= history \ No newline at end of file +CONV_FILENAME= history diff --git a/TestCases/disc_adj_fsi/dyn_fsi/config.cfg b/TestCases/disc_adj_fsi/dyn_fsi/config.cfg index 2f8810526ad8..0aa9e2ebd7bd 100644 --- a/TestCases/disc_adj_fsi/dyn_fsi/config.cfg +++ b/TestCases/disc_adj_fsi/dyn_fsi/config.cfg @@ -11,16 +11,15 @@ MESH_FILENAME= mesh.su2 TIME_DOMAIN = YES TIME_ITER = 3 -TIME_STEP = 0.01 +TIME_STEP = 0.002 UNST_ADJOINT_ITER= 10 ITER_AVERAGE_OBJ= 3 OBJECTIVE_FUNCTION= REFERENCE_NODE -SCREEN_OUTPUT= OUTER_ITER, AVG_BGS_RES[0] +SCREEN_OUTPUT= TIME_ITER, OUTER_ITER, AVG_BGS_RES[0], AVG_BGS_RES[1], SENSITIVITY[1] WRT_ZONE_HIST=YES %WRT_ZONE_CONV=YES -% Debug: Force Zero Grid Velocity = NO WRT_PERFORMANCE= NO diff --git a/TestCases/disc_adj_fsi/dyn_fsi/configFEA.cfg b/TestCases/disc_adj_fsi/dyn_fsi/configFEA.cfg index 7070a14d4a54..0879e03fe446 100644 --- a/TestCases/disc_adj_fsi/dyn_fsi/configFEA.cfg +++ b/TestCases/disc_adj_fsi/dyn_fsi/configFEA.cfg @@ -17,7 +17,7 @@ DESIGN_VARIABLE_FEA= YOUNG_MODULUS % Solid properties ----------------------------------------------------- % MATERIAL_MODEL= NEO_HOOKEAN -ELASTICITY_MODULUS= 7E8 +ELASTICITY_MODULUS= 2E9 POISSON_RATIO= 0.35 MATERIAL_DENSITY= 2700.0 @@ -48,7 +48,6 @@ INCREMENTAL_LOAD= NO MESH_FILENAME= mesh.su2 MESH_FORMAT= SU2 -RESTART_SOL= NO SOLUTION_FILENAME= solution_solid.dat SOLUTION_ADJ_FILENAME= adjoint_solid.dat OUTPUT_WRT_FREQ= 1 diff --git a/TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg b/TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg index fbb5552efc8e..755b4f515cc9 100644 --- a/TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg +++ b/TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg @@ -46,12 +46,15 @@ NUM_METHOD_GRAD= GREEN_GAUSS CFL_NUMBER= 1000.0 % Flow numerics -------------------------------------------------------- % -CONV_NUM_METHOD_FLOW= JST +CONV_NUM_METHOD_FLOW= ROE +MUSCL_FLOW= YES +SLOPE_LIMITER_FLOW= NONE JST_SENSOR_COEFF= ( 0.5, 0.02 ) +ENTROPY_FIX_COEFF= 0.01 TIME_DISCRE_FLOW= EULER_IMPLICIT % Linear solvers ------------------------------------------------------- % -LINEAR_SOLVER= BCGSTAB +LINEAR_SOLVER= FGMRES LINEAR_SOLVER_PREC= ILU LINEAR_SOLVER_ERROR= 1E-6 LINEAR_SOLVER_ITER= 25 @@ -82,7 +85,6 @@ CONV_RESIDUAL_MINVAL= -7 MESH_FILENAME= mesh.su2 MESH_FORMAT= SU2 % -RESTART_SOL= NO SOLUTION_FILENAME= solution_fluid.dat SOLUTION_ADJ_FILENAME= adjoint_fluid.dat OUTPUT_WRT_FREQ= 1 @@ -95,5 +97,6 @@ SURFACE_FILENAME= surface_fluid SURFACE_ADJ_FILENAME= adjoint_surface_fluid SCREEN_WRT_FREQ_INNER= 10 CONV_FILENAME= history +SCREEN_OUTPUT= ITER, RMS_RES, LINSOL HISTORY_OUTPUT= ITER, RMS_RES, AERO_COEFF, TAVG_AERO_COEFF OUTPUT_FILES= NONE diff --git a/TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref b/TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref index 73b7753eb65e..3a0cbdefcf4e 100644 --- a/TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref +++ b/TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref @@ -1,9 +1,9 @@ INDEX GRAD -0 -3.533163525398154e-03 -1 -1.879941699367452e-03 -2 -8.078436962531523e-04 -3 -2.794845540524826e-04 -4 -2.790760674146328e-04 -5 -8.045490756184532e-04 -6 -1.867166054373919e-03 -7 -3.498473613679959e-03 +0 -4.570869215186209e-04 +1 -2.401466750293265e-04 +2 -9.134698389661222e-05 +3 -1.628087055796442e-05 +4 -1.741052457131011e-05 +5 -9.462489787924037e-05 +6 -2.452466259888652e-04 +7 -4.635483632874935e-04 diff --git a/TestCases/flamelet/03_laminar_premixed_ch4_flame_cht_cfd/lam_prem_ch4_cht_cfd_master.cfg b/TestCases/flamelet/03_laminar_premixed_ch4_flame_cht_cfd/lam_prem_ch4_cht_cfd_master.cfg index 9a674d7a8e5c..cb9dafa62bae 100644 --- a/TestCases/flamelet/03_laminar_premixed_ch4_flame_cht_cfd/lam_prem_ch4_cht_cfd_master.cfg +++ b/TestCases/flamelet/03_laminar_premixed_ch4_flame_cht_cfd/lam_prem_ch4_cht_cfd_master.cfg @@ -43,13 +43,15 @@ SCREEN_WRT_FREQ_OUTER= 1 WRT_VOLUME_OVERWRITE= YES -WRT_ZONE_CONV= YES +%WRT_ZONE_CONV= YES CONV_RESIDUAL_MINVAL= -20 VOLUME_FILENAME= fluid CONV_FILENAME= history +SCREEN_OUTPUT= OUTER_ITER, RMS_RES[0], RMS_RES[1] + % --------------------------- Optimization Parameters --------------------------% MESH_FILENAME= mesh_unstructured_cht.su2 diff --git a/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_ad_master.cfg b/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_ad_master.cfg index e3e9a0597c13..91524aea8eaf 100644 --- a/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_ad_master.cfg +++ b/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_ad_master.cfg @@ -44,10 +44,11 @@ OUTER_ITER = 1100 OUTPUT_WRT_FREQ= 50 SCREEN_WRT_FREQ_INNER= 1 SCREEN_WRT_FREQ_OUTER= 1 +SCREEN_OUTPUT= OUTER_ITER, BGS_RES[0], BGS_RES[1] WRT_VOLUME_OVERWRITE= YES -WRT_ZONE_CONV= YES +%WRT_ZONE_CONV= YES CONV_RESIDUAL_MINVAL= -20 VOLUME_FILENAME= fluid diff --git a/TestCases/hybrid_regression.py b/TestCases/hybrid_regression.py index fa67b04a4269..ae34d1748f1a 100644 --- a/TestCases/hybrid_regression.py +++ b/TestCases/hybrid_regression.py @@ -51,7 +51,7 @@ def main(): channel.cfg_dir = "euler/channel" channel.cfg_file = "inv_channel_RK.cfg" channel.test_iter = 20 - channel.test_vals = [-2.965605, 2.459083, 0.016007, 0.042277] + channel.test_vals = [-2.965642, 2.459171, 0.016012, 0.042270] test_list.append(channel) # NACA0012 @@ -59,7 +59,7 @@ def main(): naca0012.cfg_dir = "euler/naca0012" naca0012.cfg_file = "inv_NACA0012_Roe.cfg" naca0012.test_iter = 20 - naca0012.test_vals = [-4.431337, -3.970066, 0.319205, 0.022299] + naca0012.test_vals = [-4.766168, -4.287699, 0.326688, 0.022661] test_list.append(naca0012) # Supersonic wedge @@ -67,7 +67,7 @@ def main(): wedge.cfg_dir = "euler/wedge" wedge.cfg_file = "inv_wedge_HLLC.cfg" wedge.test_iter = 20 - wedge.test_vals = [-1.368091, 4.302736, -0.243433, 0.042906] + wedge.test_vals = [-1.379426, 4.288828, -0.245341, 0.043244] test_list.append(wedge) # ONERA M6 Wing @@ -83,7 +83,7 @@ def main(): fixedCL_naca0012.cfg_dir = "fixed_cl/naca0012" fixedCL_naca0012.cfg_file = "inv_NACA0012.cfg" fixedCL_naca0012.test_iter = 10 - fixedCL_naca0012.test_vals = [-3.905038, 1.628019, 0.301067, 0.019483] + fixedCL_naca0012.test_vals = [-3.896832, 1.637749, 0.301084, 0.019485] test_list.append(fixedCL_naca0012) # HYPERSONIC FLOW PAST BLUNT BODY @@ -91,7 +91,7 @@ def main(): bluntbody.cfg_dir = "euler/bluntbody" bluntbody.cfg_file = "blunt.cfg" bluntbody.test_iter = 20 - bluntbody.test_vals = [0.491773, 6.855541, 0.000298, 1.791791] + bluntbody.test_vals = [0.475463, 6.835018, 0.000226, 1.784354] test_list.append(bluntbody) ########################## @@ -103,7 +103,7 @@ def main(): flatplate.cfg_dir = "navierstokes/flatplate" flatplate.cfg_file = "lam_flatplate.cfg" flatplate.test_iter = 100 - flatplate.test_vals = [-7.679131, -2.206953, 0.001084, 0.036233, 2.361500, -2.325300, 0, 0] + flatplate.test_vals = [-7.680034, -2.207912, 0.001084, 0.036233, 2.361500, -2.325300, 0.000000, 0.000000] test_list.append(flatplate) # Laminar cylinder (steady) @@ -136,7 +136,7 @@ def main(): poiseuille_profile.cfg_dir = "navierstokes/poiseuille" poiseuille_profile.cfg_file = "profile_poiseuille.cfg" poiseuille_profile.test_iter = 10 - poiseuille_profile.test_vals = [-12.008990, -7.262477, -0.000000, 2.089953] + poiseuille_profile.test_vals = [-12.009016, -7.262446, -0.000000, 2.089953] poiseuille_profile.test_vals_aarch64 = [-12.494717, -7.711274, -0.000000, 2.085796] test_list.append(poiseuille_profile) @@ -181,7 +181,7 @@ def main(): turb_flatplate.cfg_dir = "rans/flatplate" turb_flatplate.cfg_file = "turb_SA_flatplate.cfg" turb_flatplate.test_iter = 20 - turb_flatplate.test_vals = [-4.312725, -6.737976, -0.187467, 0.057468] + turb_flatplate.test_vals = [-4.316134, -6.737979, -0.187461, 0.057468] test_list.append(turb_flatplate) # ONERA M6 Wing @@ -189,7 +189,7 @@ def main(): turb_oneram6.cfg_dir = "rans/oneram6" turb_oneram6.cfg_file = "turb_ONERAM6.cfg" turb_oneram6.test_iter = 10 - turb_oneram6.test_vals = [-2.408523, -6.662833, 0.238333, 0.158910, 0] + turb_oneram6.test_vals = [-2.408675, -6.662904, 0.238578, 0.158968, 0.000000] test_list.append(turb_oneram6) # NACA0012 (SA, FUN3D finest grid results: CL=1.0983, CD=0.01242) @@ -230,7 +230,7 @@ def main(): turb_naca0012_sst_expliciteuler.cfg_dir = "rans/naca0012" turb_naca0012_sst_expliciteuler.cfg_file = "turb_NACA0012_sst_expliciteuler.cfg" turb_naca0012_sst_expliciteuler.test_iter = 10 - turb_naca0012_sst_expliciteuler.test_vals = [-3.533765, -3.157766, 3.364026, 1.124760, 0.501702, -float("inf")] + turb_naca0012_sst_expliciteuler.test_vals = [-3.533765, -3.157766, 3.364026, 1.124757, 0.501700, -float("inf")] test_list.append(turb_naca0012_sst_expliciteuler) # PROPELLER @@ -250,7 +250,7 @@ def main(): axi_rans_air_nozzle_restart.cfg_dir = "axisymmetric_rans/air_nozzle" axi_rans_air_nozzle_restart.cfg_file = "air_nozzle_restart.cfg" axi_rans_air_nozzle_restart.test_iter = 10 - axi_rans_air_nozzle_restart.test_vals = [-12.065572, -6.837646, -8.883745, -3.822957, 0.000000] + axi_rans_air_nozzle_restart.test_vals = [-12.065954, -6.836372, -8.889803, -3.832665, 0.000000] test_list.append(axi_rans_air_nozzle_restart) ################################# @@ -263,7 +263,7 @@ def main(): turb_naca0012_sst_restart_mg.cfg_file = "turb_NACA0012_sst_multigrid_restart.cfg" turb_naca0012_sst_restart_mg.test_iter = 20 turb_naca0012_sst_restart_mg.ntest_vals = 5 - turb_naca0012_sst_restart_mg.test_vals = [-7.633090, -7.182014, -0.627166, -0.000020, 0.078737] + turb_naca0012_sst_restart_mg.test_vals = [-7.633091, -7.181942, -0.627082, -0.000020, 0.078737] test_list.append(turb_naca0012_sst_restart_mg) ############################# @@ -324,7 +324,7 @@ def main(): harmonic_balance.cfg_dir = "harmonic_balance" harmonic_balance.cfg_file = "HB.cfg" harmonic_balance.test_iter = 25 - harmonic_balance.test_vals = [-1.554985, 0.831796, 0.935728, 3.960209] + harmonic_balance.test_vals = [-1.559187, 0.829574, 0.931511, 3.954440] test_list.append(harmonic_balance) # Turbulent pitching NACA 64a010 airfoil @@ -332,7 +332,7 @@ def main(): hb_rans_preconditioning.cfg_dir = "harmonic_balance/hb_rans_preconditioning" hb_rans_preconditioning.cfg_file = "davis.cfg" hb_rans_preconditioning.test_iter = 25 - hb_rans_preconditioning.test_vals = [-1.902111, 0.484080, 0.601469, 3.608991, -5.949373] + hb_rans_preconditioning.test_vals = [-1.902111, 0.484080, 0.601469, 3.608991, -5.949369] test_list.append(hb_rans_preconditioning) ############################# @@ -344,7 +344,7 @@ def main(): inc_euler_naca0012.cfg_dir = "incomp_euler/naca0012" inc_euler_naca0012.cfg_file = "incomp_NACA0012.cfg" inc_euler_naca0012.test_iter = 20 - inc_euler_naca0012.test_vals = [-7.104363, -6.354829, 0.531976, 0.008467] + inc_euler_naca0012.test_vals = [-7.127256, -6.466554, 0.531991, 0.008466] test_list.append(inc_euler_naca0012) # C-D nozzle with pressure inlet and mass flow outlet @@ -352,7 +352,7 @@ def main(): inc_nozzle.cfg_dir = "incomp_euler/nozzle" inc_nozzle.cfg_file = "inv_nozzle.cfg" inc_nozzle.test_iter = 20 - inc_nozzle.test_vals = [-6.363748, -5.564772, -0.003840, 0.126592] + inc_nozzle.test_vals = [-6.595923, -5.820518, -0.018365, 0.126411] inc_nozzle.test_vals_aarch64 = [-5.624385, -4.988472, -0.000096, 0.137032] test_list.append(inc_nozzle) @@ -390,7 +390,7 @@ def main(): inc_lam_bend.cfg_dir = "incomp_navierstokes/bend" inc_lam_bend.cfg_file = "lam_bend.cfg" inc_lam_bend.test_iter = 10 - inc_lam_bend.test_vals = [-3.547250, -3.225803, -0.015148, 1.006543] + inc_lam_bend.test_vals = [-3.560185, -3.051988, -0.013972, 1.102842] inc_lam_bend.test_vals_aarch64 = [-3.437996, -3.086188, -0.015600, 1.142213] test_list.append(inc_lam_bend) @@ -462,7 +462,7 @@ def main(): sine_gust.cfg_dir = "gust" sine_gust.cfg_file = "inv_gust_NACA0012.cfg" sine_gust.test_iter = 5 - sine_gust.test_vals = [-1.977514, 3.481817, -0.010400, -0.008115] + sine_gust.test_vals = [-1.977498, 3.481818, -0.010484, -0.008178] sine_gust.unsteady = True test_list.append(sine_gust) @@ -471,7 +471,7 @@ def main(): cosine_gust.cfg_dir = "gust" cosine_gust.cfg_file = "cosine_gust_zdir.cfg" cosine_gust.test_iter = 79 - cosine_gust.test_vals = [-2.418806, 0.001963, -0.001264, 0.000415, -0.000592] + cosine_gust.test_vals = [-2.418805, 0.001949, -0.001254, 0.000425, -0.000593] cosine_gust.unsteady = True cosine_gust.enabled_with_tsan = False test_list.append(cosine_gust) @@ -481,7 +481,7 @@ def main(): gust_mesh_defo.cfg_dir = "gust" gust_mesh_defo.cfg_file = "gust_with_mesh_deformation.cfg" gust_mesh_defo.test_iter = 6 - gust_mesh_defo.test_vals = [-1.844761, 0.001116, -0.000265] + gust_mesh_defo.test_vals = [-1.844761, 0.001095, -0.000273] gust_mesh_defo.unsteady = True gust_mesh_defo.enabled_with_tsan = False test_list.append(gust_mesh_defo) @@ -491,7 +491,7 @@ def main(): aeroelastic.cfg_dir = "aeroelastic" aeroelastic.cfg_file = "aeroelastic_NACA64A010.cfg" aeroelastic.test_iter = 2 - aeroelastic.test_vals = [0.074058, 0.027628, -0.001641, -0.000128] + aeroelastic.test_vals = [0.074052, 0.027623, -0.001641, -0.000128] aeroelastic.test_vals_aarch64 = [0.074170, 0.027590, -0.001579, -0.000160] aeroelastic.unsteady = True aeroelastic.enabled_on_cpu_arch = ["x86_64"] # Requires AVX-capable architecture @@ -503,7 +503,7 @@ def main(): ddes_flatplate.cfg_dir = "ddes/flatplate" ddes_flatplate.cfg_file = "ddes_flatplate.cfg" ddes_flatplate.test_iter = 10 - ddes_flatplate.test_vals = [-2.714786, -5.882652, -0.215041, 0.023758, 0] + ddes_flatplate.test_vals = [-2.714713, -5.788302, -0.214960, 0.023758, 0.000000] ddes_flatplate.unsteady = True test_list.append(ddes_flatplate) @@ -512,7 +512,7 @@ def main(): unst_inc_turb_naca0015_sa.cfg_dir = "unsteady/pitching_naca0015_rans_inc" unst_inc_turb_naca0015_sa.cfg_file = "config_incomp_turb_sa.cfg" unst_inc_turb_naca0015_sa.test_iter = 1 - unst_inc_turb_naca0015_sa.test_vals = [-3.008629, -6.888963, 1.435186, 0.433529] + unst_inc_turb_naca0015_sa.test_vals = [-3.008629, -6.888996, 1.435193, 0.433537] unst_inc_turb_naca0015_sa.unsteady = True test_list.append(unst_inc_turb_naca0015_sa) @@ -521,7 +521,7 @@ def main(): unst_deforming_naca0012.cfg_dir = "disc_adj_euler/naca0012_pitching_def" unst_deforming_naca0012.cfg_file = "inv_NACA0012_pitching_deform.cfg" unst_deforming_naca0012.test_iter = 5 - unst_deforming_naca0012.test_vals = [-3.665202, -3.793253, -3.716498, -3.148334] + unst_deforming_naca0012.test_vals = [-3.665168, -3.793307, -3.716526, -3.148348] unst_deforming_naca0012.unsteady = True unst_deforming_naca0012.enabled_with_tsan = False test_list.append(unst_deforming_naca0012) @@ -535,7 +535,7 @@ def main(): edge_VW.cfg_dir = "nicf/edge" edge_VW.cfg_file = "edge_VW.cfg" edge_VW.test_iter = 40 - edge_VW.test_vals = [-5.759815, 0.398128, -0.000009, 0.000000] + edge_VW.test_vals = [-5.681149, 0.463233, -0.000009, 0.000000] test_list.append(edge_VW) # Rarefaction shock wave edge_PPR @@ -543,7 +543,7 @@ def main(): edge_PPR.cfg_dir = "nicf/edge" edge_PPR.cfg_file = "edge_PPR.cfg" edge_PPR.test_iter = 40 - edge_PPR.test_vals = [-6.923001, -0.757902, -0.000034, 0.000000] + edge_PPR.test_vals = [-7.139177, -0.980792, -0.000034, 0.000000] edge_PPR.test_vals_aarch64 = [-8.573595, -2.391849, -0.000034, 0.000000] test_list.append(edge_PPR) @@ -595,7 +595,7 @@ def main(): uniform_flow.cfg_dir = "sliding_interface/uniform_flow" uniform_flow.cfg_file = "uniform_NN.cfg" uniform_flow.test_iter = 5 - uniform_flow.test_vals = [5.000000, 0.000000, -0.186037, -10.624438] + uniform_flow.test_vals = [5.000000, 0.000000, -0.195002, -10.624444] uniform_flow.unsteady = True uniform_flow.multizone = True test_list.append(uniform_flow) @@ -605,7 +605,7 @@ def main(): channel_2D.cfg_dir = "sliding_interface/channel_2D" channel_2D.cfg_file = "channel_2D_WA.cfg" channel_2D.test_iter = 2 - channel_2D.test_vals = [2.000000, 0.000000, 0.417392, 0.350483, 0.401514] + channel_2D.test_vals = [2.000000, 0.000000, 0.464907, 0.348052, 0.397452] channel_2D.unsteady = True channel_2D.multizone = True test_list.append(channel_2D) @@ -615,7 +615,7 @@ def main(): channel_3D.cfg_dir = "sliding_interface/channel_3D" channel_3D.cfg_file = "channel_3D_WA.cfg" channel_3D.test_iter = 2 - channel_3D.test_vals = [2.000000, 0.000000, 0.622653, 0.506145, 0.410984] + channel_3D.test_vals = [2.000000, 0.000000, 0.629106, 0.524901, 0.422380] channel_3D.test_vals_aarch64 = [2.000000, 0.000000, 0.620558, 0.504323, 0.412729] channel_3D.unsteady = True channel_3D.multizone = True @@ -627,7 +627,7 @@ def main(): pipe.cfg_dir = "sliding_interface/pipe" pipe.cfg_file = "pipe_NN.cfg" pipe.test_iter = 2 - pipe.test_vals = [0.121511, 0.477625, 0.641343, 0.983342, 1.018866] + pipe.test_vals = [0.080826, 0.547321, 0.655098, 0.968229, 1.049129] pipe.unsteady = True pipe.multizone = True test_list.append(pipe) @@ -637,7 +637,7 @@ def main(): rotating_cylinders.cfg_dir = "sliding_interface/rotating_cylinders" rotating_cylinders.cfg_file = "rot_cylinders_WA.cfg" rotating_cylinders.test_iter = 3 - rotating_cylinders.test_vals = [3.000000, 0.000000, 0.719776, 1.111045, 1.154066] + rotating_cylinders.test_vals = [3.000000, 0.000000, 0.717065, 1.119817, 1.160326] rotating_cylinders.unsteady = True rotating_cylinders.multizone = True test_list.append(rotating_cylinders) @@ -647,7 +647,7 @@ def main(): supersonic_vortex_shedding.cfg_dir = "sliding_interface/supersonic_vortex_shedding" supersonic_vortex_shedding.cfg_file = "sup_vor_shed_WA.cfg" supersonic_vortex_shedding.test_iter = 5 - supersonic_vortex_shedding.test_vals = [5.000000, 0.000000, 1.206774, 1.053443] + supersonic_vortex_shedding.test_vals = [5.000000, 0.000000, 1.207118, 1.065254] supersonic_vortex_shedding.unsteady = True supersonic_vortex_shedding.multizone = True test_list.append(supersonic_vortex_shedding) @@ -698,7 +698,7 @@ def main(): fsi2d.cfg_dir = "fea_fsi/WallChannel_2d" fsi2d.cfg_file = "configFSI.cfg" fsi2d.test_iter = 4 - fsi2d.test_vals = [4.000000, 0.000000, -3.726064, -4.277803] + fsi2d.test_vals = [4.000000, 0.000000, -3.726029, -4.277769] fsi2d.multizone= True fsi2d.unsteady = True fsi2d.enabled_with_tsan = False @@ -709,7 +709,7 @@ def main(): dyn_fsi.cfg_dir = "fea_fsi/dyn_fsi" dyn_fsi.cfg_file = "config.cfg" dyn_fsi.test_iter = 4 - dyn_fsi.test_vals = [-4.330905, -4.153024, 0.000000, 103.000000] + dyn_fsi.test_vals = [-4.330725, -4.152983, 0.000000, 103.000000] dyn_fsi.test_vals_aarch64 = [-4.332167, -4.057742, 0.000000, 102.000000] dyn_fsi.multizone = True dyn_fsi.unsteady = True @@ -720,7 +720,7 @@ def main(): stat_fsi_restart.cfg_dir = "fea_fsi/stat_fsi" stat_fsi_restart.cfg_file = "config_restart.cfg" stat_fsi_restart.test_iter = 1 - stat_fsi_restart.test_vals = [-3.468782, -4.271197, 0.000000, 36.000000] + stat_fsi_restart.test_vals = [-3.549586, -4.460650, 0.000000, 35.000000] stat_fsi_restart.test_vals_aarch64 = [-3.442878, -4.228058, 0.000000, 37.000000] stat_fsi_restart.multizone = True test_list.append(stat_fsi_restart) diff --git a/TestCases/hybrid_regression_AD.py b/TestCases/hybrid_regression_AD.py index 7350e0afdd2d..8663d271f227 100644 --- a/TestCases/hybrid_regression_AD.py +++ b/TestCases/hybrid_regression_AD.py @@ -50,7 +50,7 @@ def main(): discadj_naca0012.cfg_dir = "cont_adj_euler/naca0012" discadj_naca0012.cfg_file = "inv_NACA0012_discadj.cfg" discadj_naca0012.test_iter = 100 - discadj_naca0012.test_vals = [-3.560691, -8.925239, -0.000000, 0.005559] + discadj_naca0012.test_vals = [-3.562611, -8.932638, -0.000000, 0.005608] test_list.append(discadj_naca0012) # Inviscid Cylinder 3D (multiple markers) @@ -58,7 +58,7 @@ def main(): discadj_cylinder3D.cfg_dir = "disc_adj_euler/cylinder3D" discadj_cylinder3D.cfg_file = "inv_cylinder3D.cfg" discadj_cylinder3D.test_iter = 5 - discadj_cylinder3D.test_vals = [-3.773755, -3.737672, -0.000000, 0.000000] + discadj_cylinder3D.test_vals = [-3.689810, -3.883743, -0.000000, 0.000000] test_list.append(discadj_cylinder3D) # Arina nozzle 2D @@ -66,7 +66,7 @@ def main(): discadj_arina2k.cfg_dir = "disc_adj_euler/arina2k" discadj_arina2k.cfg_file = "Arina2KRS.cfg" discadj_arina2k.test_iter = 20 - discadj_arina2k.test_vals = [-3.534954, -3.773310, 0.027244, 0.000000] + discadj_arina2k.test_vals = [-3.254503, -3.495599, 0.052373, 0.000000] test_list.append(discadj_arina2k) #################################### @@ -98,7 +98,7 @@ def main(): discadj_incomp_NACA0012.cfg_dir = "disc_adj_incomp_euler/naca0012" discadj_incomp_NACA0012.cfg_file = "incomp_NACA0012_disc.cfg" discadj_incomp_NACA0012.test_iter = 20 - discadj_incomp_NACA0012.test_vals = [20.000000, -4.087948, -2.655204, 0.000000] + discadj_incomp_NACA0012.test_vals = [20.000000, -4.091640, -2.655563, 0.000000] test_list.append(discadj_incomp_NACA0012) ##################################### @@ -185,7 +185,7 @@ def main(): discadj_pitchingNACA0012.cfg_dir = "disc_adj_euler/naca0012_pitching" discadj_pitchingNACA0012.cfg_file = "inv_NACA0012_pitching.cfg" discadj_pitchingNACA0012.test_iter = 4 - discadj_pitchingNACA0012.test_vals = [-1.221198, -1.647772, -0.007510, 0.000013] + discadj_pitchingNACA0012.test_vals = [-1.220333, -1.646832, -0.007539, 0.000013] discadj_pitchingNACA0012.unsteady = True discadj_pitchingNACA0012.enabled_with_tsan = False test_list.append(discadj_pitchingNACA0012) @@ -253,7 +253,7 @@ def main(): pywrapper_CFD_AD_MeshDisp.cfg_dir = "py_wrapper/disc_adj_flow/mesh_disp_sens" pywrapper_CFD_AD_MeshDisp.cfg_file = "configAD_flow.cfg" pywrapper_CFD_AD_MeshDisp.test_iter = 1000 - pywrapper_CFD_AD_MeshDisp.test_vals = [30.000000, -2.505480, 1.403813, 0.000000] + pywrapper_CFD_AD_MeshDisp.test_vals = [30.000000, -2.496218, 1.441643, 0.000000] pywrapper_CFD_AD_MeshDisp.test_vals_aarch64 = [30.000000, -2.499079, 1.440068, 0.000000] pywrapper_CFD_AD_MeshDisp.command = TestCase.Command(exec = "python", param = "run_adjoint.py --parallel -f") pywrapper_CFD_AD_MeshDisp.timeout = 1600 diff --git a/TestCases/incomp_navierstokes/streamwise_periodic/chtPinArray_2d/of_grad_findiff.csv.ref b/TestCases/incomp_navierstokes/streamwise_periodic/chtPinArray_2d/of_grad_findiff.csv.ref index dece285b96fc..f633bb537397 100644 --- a/TestCases/incomp_navierstokes/streamwise_periodic/chtPinArray_2d/of_grad_findiff.csv.ref +++ b/TestCases/incomp_navierstokes/streamwise_periodic/chtPinArray_2d/of_grad_findiff.csv.ref @@ -1,2 +1,2 @@ "VARIABLE" , "AVG_DENSITY[0]", "AVG_ENTHALPY[0]", "AVG_NORMALVEL[0]", "DRAG[0]" , "EFFICIENCY[0]" , "FORCE_X[0]" , "FORCE_Y[0]" , "FORCE_Z[0]" , "LIFT[0]" , "MOMENT_X[0]" , "MOMENT_Y[0]" , "MOMENT_Z[0]" , "SIDEFORCE[0]" , "SURFACE_MACH[0]", "SURFACE_MASSFLOW[0]", "SURFACE_MOM_DISTORTION[0]", "SURFACE_PRESSURE_DROP[0]", "SURFACE_SECONDARY[0]", "SURFACE_SECOND_OVER_UNIFORM[0]", "SURFACE_STATIC_PRESSURE[0]", "SURFACE_STATIC_TEMPERATURE[0]", "SURFACE_TOTAL_PRESSURE[0]", "SURFACE_TOTAL_TEMPERATURE[0]", "SURFACE_UNIFORMITY[0]", "AVG_TEMPERATURE[1]", "MAXIMUM_HEATFLUX[1]", "TOTAL_HEATFLUX[1]", "FINDIFF_STEP" -0 , 0.0 , -3800000.0175088644, -3.330699999961374e-08, 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , -1.4500000006245628, -5.5510000002640306e-08, -42.070000000338226 , 0.0 , 43.11999999839777 , 79.95999999899084 , 5740.000000287182 , -1079.9999927257886 , 79.99999951380232 , -1080.0000040944724 , -37.40000000806987 , -729.9999992937956, 0.0 , 790.0000014160469, 1e-08 +0 , 0.0 , -1000000.0242143869, -9.992000000081167e-08, 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , -1.4199999995301305, 0.0 , -36.519999999096164 , 0.0 , 39.07999999996914 , 73.22000000198337 , 6360.000003269306 , -279.99999474559445 , 109.99999915384251 , -290.0000026784255 , -34.39999998189336 , -110.00000199601345, 0.0 , 260.00000161729986, 1e-08 diff --git a/TestCases/multiple_ffd/naca0012/of_grad_cd.dat.ref b/TestCases/multiple_ffd/naca0012/of_grad_cd.dat.ref index 8ece51e1c663..3c7f554fd5d0 100644 --- a/TestCases/multiple_ffd/naca0012/of_grad_cd.dat.ref +++ b/TestCases/multiple_ffd/naca0012/of_grad_cd.dat.ref @@ -1,3 +1,3 @@ VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" - 0 , 0.0779077 , 0.001 - 1 , -0.115995 , 0.001 + 0 , 0.0790825 , 0.001 + 1 , -0.112974 , 0.001 diff --git a/TestCases/multiple_ffd/naca0012/of_grad_directdiff.dat.ref b/TestCases/multiple_ffd/naca0012/of_grad_directdiff.dat.ref index d5db7c2a840c..6ec22d9664a3 100644 --- a/TestCases/multiple_ffd/naca0012/of_grad_directdiff.dat.ref +++ b/TestCases/multiple_ffd/naca0012/of_grad_directdiff.dat.ref @@ -1,3 +1,3 @@ VARIABLES="VARIABLE" , "DRAG" , "EFFICIENCY" , "FORCE_X" , "FORCE_Y" , "FORCE_Z" , "LIFT" , "MOMENT_X" , "MOMENT_Y" , "MOMENT_Z" , "SIDEFORCE" - 0 , 0.06156331034 , -0.6082822997 , 0.05895593271 , 0.1201660031 , 0.0 , 0.11885129 , 0.0 , 0.0 , 0.009672466384 , 0.0 - 1 , -0.08521017525 , 8.292100787 , -0.09081780606 , 0.2560645458 , 0.0 , 0.2579847894 , 0.0 , 0.0 , 0.004373844484 , 0.0 + 0 , 0.05922508178 , -0.6082054907 , 0.05650610011 , 0.1252552372 , 0.0 , 0.1239927558 , 0.0 , 0.0 , 0.00502894879 , 0.0 + 1 , -0.07750209216 , 8.684127966 , -0.08326907905 , 0.2634518171 , 0.0 , 0.2652056281 , 0.0 , 0.0 , -0.006643227386 , 0.0 diff --git a/TestCases/nicf/datadriven/datadriven_nozzle.cfg b/TestCases/nicf/datadriven/datadriven_nozzle.cfg index 0e5326609f48..38dfd82a5197 100644 --- a/TestCases/nicf/datadriven/datadriven_nozzle.cfg +++ b/TestCases/nicf/datadriven/datadriven_nozzle.cfg @@ -15,7 +15,7 @@ SOLVER= RANS KIND_TURB_MODEL= SST MATH_PROBLEM= DIRECT -RESTART_SOL= NO +RESTART_SOL= YES SYSTEM_MEASUREMENTS= SI % % -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------% @@ -26,31 +26,34 @@ AOA= 0.0 SIDESLIP_ANGLE= 0.0 INIT_OPTION= TD_CONDITIONS FREESTREAM_OPTION= TEMPERATURE_FS -FREESTREAM_PRESSURE= 250000.0 +FREESTREAM_PRESSURE= 3361842.0 % -% Free-stream temperature (288.15 K, 518.67 R by default) -FREESTREAM_TEMPERATURE= 400.0 +FREESTREAM_TEMPERATURE= 189.288 FREESTREAM_DENSITY= 2.0 REF_DIMENSIONALIZATION= DIMENSIONAL % ---- DATADRIVEN FLUID MODEL DEFINITION -------% -% +% Use physics-informed neural network method. FLUID_MODEL = DATADRIVEN_FLUID INTERPOLATION_METHOD = MLP -FILENAMES_INTERPOLATOR = (MLP_air.mlp) -DATADRIVEN_NEWTON_RELAXATION = 0.8 +FILENAMES_INTERPOLATOR = (MLP_nitrogen.mlp) +USE_PINN= YES + +CONDUCTIVITY_MODEL=CONSTANT_PRANDTL +PRANDTL_LAM=0.8426621478074403 +PRANDTL_TURB=0.8426621478074403 % --------------------------- VISCOSITY MODEL ---------------------------------% VISCOSITY_MODEL= CONSTANT_VISCOSITY -MU_CONSTANT= 1.21409E-05 +MU_CONSTANT= 1.0998841148727364e-05 -% --------------------------- THERMAL CONDUCTIVITY MODEL ----------------------% -CONDUCTIVITY_MODEL= CONSTANT_CONDUCTIVITY -THERMAL_CONDUCTIVITY_CONSTANT= 0.030542828 % -------------------- BOUNDARY CONDITION DEFINITION --------------------------% -MARKER_SYM= ( SYMMETRY, WALL ) -MARKER_RIEMANN= ( INFLOW, TOTAL_CONDITIONS_PT, 904388, 542.13, 1.0, 0.0, 0.0, OUTFLOW, STATIC_PRESSURE, 200000.0, 0.0, 0.0, 0.0, 0.0 ) +MARKER_SYM= ( SYMMETRY ) +MARKER_HEATFLUX= (WALL, 0.0) +MARKER_RIEMANN= ( INFLOW, TOTAL_CONDITIONS_PT, 3361842.0, 189.288, 1.0, 0.0, 0.0, \ + OUTFLOW, STATIC_PRESSURE, 747076.0, 0.0, 0.0, 0.0, 0.0 ) + % ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% NUM_METHOD_GRAD= GREEN_GAUSS @@ -73,8 +76,6 @@ LINEAR_SOLVER_ITER= 10 % -------------------------- MULTIGRID PARAMETERS -----------------------------% % -% Multi-grid levels (0 = no multi-grid) -MGLEVEL= 0 % -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% CONV_NUM_METHOD_FLOW= ROE @@ -89,7 +90,7 @@ CFL_REDUCTION_TURB= 1.0 % --------------------------- CONVERGENCE PARAMETERS --------------------------% % % Number of total iterations -ITER= 10 +ITER= 500 CONV_RESIDUAL_MINVAL= -24 CONV_STARTITER= 10 @@ -109,19 +110,19 @@ SOLUTION_FILENAME= solution_flow.dat TABULAR_FORMAT= CSV % % Output file convergence history (w/o extension) -CONV_FILENAME= history % % Output file restart flow RESTART_FILENAME= restart_flow.dat % % Output file flow (w/o extension) variables -VOLUME_FILENAME= flow +VOLUME_OUTPUT=(SOLUTION) % % Output file surface flow coefficient (w/o extension) SURFACE_FILENAME= surface_flow % % Writing solution file frequency OUTPUT_WRT_FREQ= 500 +OUTPUT_FILES=RESTART % % Screen output -SCREEN_OUTPUT= (INNER_ITER, RMS_DENSITY, RMS_TKE, RMS_DISSIPATION, LIFT, DRAG) +SCREEN_OUTPUT= (INNER_ITER, RMS_RES) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 766cbee60869..7d98728b09f6 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -47,7 +47,7 @@ def main(): cfd_flamelet_ch4.cfg_dir = "flamelet/01_laminar_premixed_ch4_flame_cfd" cfd_flamelet_ch4.cfg_file = "lam_prem_ch4_cfd.cfg" cfd_flamelet_ch4.test_iter = 10 - cfd_flamelet_ch4.test_vals = [-13.665072, -12.593885, -14.249600, -6.069756, -14.816937, -17.057821] + cfd_flamelet_ch4.test_vals = [-14.297190, -12.593356, -14.249342, -6.069757, -14.816955, -17.057821] cfd_flamelet_ch4.new_output = True test_list.append(cfd_flamelet_ch4) @@ -56,7 +56,7 @@ def main(): cfd_flamelet_ch4_axi.cfg_dir = "flamelet/05_laminar_premixed_ch4_flame_cfd_axi" cfd_flamelet_ch4_axi.cfg_file = "lam_prem_ch4_cfd_axi.cfg" cfd_flamelet_ch4_axi.test_iter = 10 - cfd_flamelet_ch4_axi.test_vals = [-10.935396, -11.476692, -11.302574, -12.734435, -6.110559] + cfd_flamelet_ch4_axi.test_vals = [-10.935482, -11.477701, -11.302709, -12.734435, -6.110542] cfd_flamelet_ch4_axi.new_output = True test_list.append(cfd_flamelet_ch4_axi) @@ -65,7 +65,7 @@ def main(): cfd_flamelet_ch4_partial_premix.cfg_dir = "flamelet/06_laminar_partial_premixed_ch4_flame_cfd" cfd_flamelet_ch4_partial_premix.cfg_file = "lam_partial_prem_ch4_cfd.cfg" cfd_flamelet_ch4_partial_premix.test_iter = 10 - cfd_flamelet_ch4_partial_premix.test_vals = [-9.641526, -11.303947, -3.675920, -13.158386, -11.087893] + cfd_flamelet_ch4_partial_premix.test_vals = [-9.645814, -11.304194, -3.675580, -13.158500, -11.087904] cfd_flamelet_ch4_partial_premix.new_output = True test_list.append(cfd_flamelet_ch4_partial_premix) @@ -74,7 +74,7 @@ def main(): cfd_flamelet_h2.cfg_dir = "flamelet/07_laminar_premixed_h2_flame_cfd" cfd_flamelet_h2.cfg_file = "laminar_premixed_h2_flame_cfd.cfg" cfd_flamelet_h2.test_iter = 5 - cfd_flamelet_h2.test_vals = [-9.999540, -9.843936, -3.290033, -11.338454] + cfd_flamelet_h2.test_vals = [-10.006096, -9.844001, -3.290043, -11.338465] cfd_flamelet_h2.new_output = True test_list.append(cfd_flamelet_h2) @@ -175,7 +175,7 @@ def main(): visc_cone.cfg_dir = "nonequilibrium/visc_wedge" visc_cone.cfg_file = "axi_visccone.cfg" visc_cone.test_iter = 10 - visc_cone.test_vals = [-5.222270, -5.746525, -20.560273, -20.510152, -20.409102, 1.255757, -3.208382, -0.016014, 0.093462, 32619.000000] + visc_cone.test_vals = [-5.222270, -5.746525, -20.560278, -20.510152, -20.409102, 1.255758, -3.208382, -0.016014, 0.093462, 32619.000000] visc_cone.test_vals_aarch64 = [-5.222267, -5.746523, -20.560279, -20.510152, -20.409102, 1.255758, -3.208380, -0.016014, 0.093462, 32633.000000] test_list.append(visc_cone) @@ -220,7 +220,7 @@ def main(): channel.cfg_dir = "euler/channel" channel.cfg_file = "inv_channel_RK.cfg" channel.test_iter = 20 - channel.test_vals = [-2.904385, 2.536048, 0.020906, 0.042348] + channel.test_vals = [-2.904401, 2.536139, 0.020924, 0.042340] test_list.append(channel) # NACA0012 @@ -228,7 +228,7 @@ def main(): naca0012.cfg_dir = "euler/naca0012" naca0012.cfg_file = "inv_NACA0012_Roe.cfg" naca0012.test_iter = 20 - naca0012.test_vals = [-4.319811, -3.867353, 0.321947, 0.022489] + naca0012.test_vals = [-4.607257, -4.138750, 0.327682, 0.022685] test_list.append(naca0012) # Supersonic wedge @@ -236,7 +236,7 @@ def main(): wedge.cfg_dir = "euler/wedge" wedge.cfg_file = "inv_wedge_HLLC.cfg" wedge.test_iter = 20 - wedge.test_vals = [-1.377543, 4.293870, -0.243566, 0.042930] + wedge.test_vals = [-1.387215, 4.281574, -0.245443, 0.043264] test_list.append(wedge) # ONERA M6 Wing @@ -244,7 +244,7 @@ def main(): oneram6.cfg_dir = "euler/oneram6" oneram6.cfg_file = "inv_ONERAM6.cfg" oneram6.test_iter = 10 - oneram6.test_vals = [-11.512364, -10.982009, 0.280800, 0.008623] + oneram6.test_vals = [-11.500303, -10.971884, 0.280800, 0.008623] oneram6.timeout = 3200 test_list.append(oneram6) @@ -253,7 +253,7 @@ def main(): fixedCL_naca0012.cfg_dir = "fixed_cl/naca0012" fixedCL_naca0012.cfg_file = "inv_NACA0012.cfg" fixedCL_naca0012.test_iter = 10 - fixedCL_naca0012.test_vals = [-3.856871, 1.676974, 0.301113, 0.019487] + fixedCL_naca0012.test_vals = [-3.840915, 1.693979, 0.301144, 0.019489] test_list.append(fixedCL_naca0012) # Polar sweep of the inviscid NACA0012 @@ -262,7 +262,7 @@ def main(): polar_naca0012.cfg_file = "inv_NACA0012.cfg" polar_naca0012.polar = True polar_naca0012.test_iter = 10 - polar_naca0012.test_vals = [-1.086730, 4.382703, 0.001762, 0.033013] + polar_naca0012.test_vals = [-1.096894, 4.372054, 0.002074, 0.031515] polar_naca0012.test_vals_aarch64 = [-1.083394, 4.386134, 0.001588, 0.033513] polar_naca0012.command = TestCase.Command(exec = "compute_polar.py", param = "-i 11") # flaky test on arm64 @@ -274,7 +274,7 @@ def main(): bluntbody.cfg_dir = "euler/bluntbody" bluntbody.cfg_file = "blunt.cfg" bluntbody.test_iter = 20 - bluntbody.test_vals = [0.493672, 6.857839, -0.000002, 1.791404] + bluntbody.test_vals = [0.475144, 6.834602, -0.000007, 1.783980] test_list.append(bluntbody) # Equivalent area NACA64-206 @@ -282,7 +282,7 @@ def main(): ea_naca64206.cfg_dir = "optimization_euler/equivalentarea_naca64206" ea_naca64206.cfg_file = "NACA64206.cfg" ea_naca64206.test_iter = 10 - ea_naca64206.test_vals = [-1.188459, -0.522783, -0.003147, 67775.000000] + ea_naca64206.test_vals = [-1.125893, -0.474056, -0.002414, 67775.000000] test_list.append(ea_naca64206) # SUPERSONIC FLOW PAST A RAMP IN A CHANNEL @@ -290,7 +290,7 @@ def main(): ramp.cfg_dir = "euler/ramp" ramp.cfg_file = "inv_ramp.cfg" ramp.test_iter = 10 - ramp.test_vals = [-13.648694, -8.010920, -0.076277, 0.054839] + ramp.test_vals = [-13.650727, -8.014514, -0.076277, 0.054839] ramp.test_vals_aarch64 = [-13.398422, -7.786461, -0.081064, 0.056474] test_list.append(ramp) @@ -303,7 +303,7 @@ def main(): flatplate.cfg_dir = "navierstokes/flatplate" flatplate.cfg_file = "lam_flatplate.cfg" flatplate.test_iter = 100 - flatplate.test_vals = [-7.613122, -2.140941, 0.001084, 0.036230, 2.361500, -2.325300, 0.000000, 0.000000] + flatplate.test_vals = [-7.613292, -2.141207, 0.001084, 0.036230, 2.361500, -2.325300, 0.000000, 0.000000] test_list.append(flatplate) # Custom objective function @@ -311,7 +311,7 @@ def main(): flatplate_udobj.cfg_dir = "user_defined_functions" flatplate_udobj.cfg_file = "lam_flatplate.cfg" flatplate_udobj.test_iter = 20 - flatplate_udobj.test_vals = [-6.660355, -1.186227, -0.956763, 0.000642, -0.000643, 0.000540, -0.001184, 596.990000, 300.060000, 296.920000, 22.235000, 0.524150, 37.285000, 2.350100] + flatplate_udobj.test_vals = [-6.760101, -1.283906, -0.745653, 0.000587, -0.000038, 0.000977, -0.001015, 596.450000, 299.550000, 296.900000, 21.318000, 0.586640, 36.553000, 2.188800] test_list.append(flatplate_udobj) # Laminar cylinder (steady) @@ -344,7 +344,7 @@ def main(): poiseuille_profile.cfg_dir = "navierstokes/poiseuille" poiseuille_profile.cfg_file = "profile_poiseuille.cfg" poiseuille_profile.test_iter = 10 - poiseuille_profile.test_vals = [-12.007512, -7.227061, -0.000000, 2.089953] + poiseuille_profile.test_vals = [-12.007512, -7.227061, -0.000000, 2.089953] poiseuille_profile.test_vals_aarch64 = [-12.492864, -7.671632, -0.000000, 2.085796] test_list.append(poiseuille_profile) @@ -381,7 +381,7 @@ def main(): turb_flatplate.cfg_dir = "rans/flatplate" turb_flatplate.cfg_file = "turb_SA_flatplate.cfg" turb_flatplate.test_iter = 20 - turb_flatplate.test_vals = [-4.293470, -6.730438, -0.187644, 0.057700] + turb_flatplate.test_vals = [-4.297198, -6.730442, -0.187632, 0.057700] test_list.append(turb_flatplate) # Flat plate (compressible) with species inlet @@ -389,7 +389,7 @@ def main(): turb_flatplate_species.cfg_dir = "rans/flatplate" turb_flatplate_species.cfg_file = "turb_SA_flatplate_species.cfg" turb_flatplate_species.test_iter = 20 - turb_flatplate_species.test_vals = [-4.243064, -0.634797, -1.706652, 1.231264, -3.308212, 9.000000, -6.632972, 5.000000, -6.985977, 10.000000, -6.248436, 0.999902, 0.999902] + turb_flatplate_species.test_vals = [-4.249479, -0.634915, -1.716291, 1.223196, -3.307930, 9.000000, -6.634088, 5.000000, -6.985954, 10.000000, -6.255640, 0.999903, 0.999903] test_list.append(turb_flatplate_species) # Flat plate SST compressibility correction Wilcox @@ -397,7 +397,7 @@ def main(): turb_flatplate_CC_Wilcox.cfg_dir = "rans/flatplate" turb_flatplate_CC_Wilcox.cfg_file = "turb_SST_flatplate_compressibility_Wilcox.cfg" turb_flatplate_CC_Wilcox.test_iter = 20 - turb_flatplate_CC_Wilcox.test_vals = [-1.280875, 1.974210, 1.440441, 5.038396, -3.791318, 11.809748] + turb_flatplate_CC_Wilcox.test_vals = [-1.280934, 1.974155, 1.440363, 5.038339, -3.791118, 8.297543] test_list.append(turb_flatplate_CC_Wilcox) # Flat plate SST compressibility correction Sarkar @@ -405,7 +405,7 @@ def main(): turb_flatplate_CC_Sarkar.cfg_dir = "rans/flatplate" turb_flatplate_CC_Sarkar.cfg_file = "turb_SST_flatplate_compressibility_Sarkar.cfg" turb_flatplate_CC_Sarkar.test_iter = 20 - turb_flatplate_CC_Sarkar.test_vals = [-1.280875, 1.974210, 1.440441, 5.038396, -3.791321, 11.809748] + turb_flatplate_CC_Sarkar.test_vals = [-1.280934, 1.974155, 1.440363, 5.038339, -3.791121, 8.297543] test_list.append(turb_flatplate_CC_Sarkar) # ONERA M6 Wing @@ -413,7 +413,7 @@ def main(): turb_oneram6.cfg_dir = "rans/oneram6" turb_oneram6.cfg_file = "turb_ONERAM6.cfg" turb_oneram6.test_iter = 10 - turb_oneram6.test_vals = [-2.408532, -6.662836, 0.238334, 0.158910, 0] + turb_oneram6.test_vals = [-2.408685, -6.662907, 0.238579, 0.158968, 0.000000] turb_oneram6.timeout = 3200 test_list.append(turb_oneram6) @@ -422,7 +422,7 @@ def main(): turb_oneram6_vc.cfg_dir = "rans/oneram6" turb_oneram6_vc.cfg_file = "turb_ONERAM6_vc.cfg" turb_oneram6_vc.test_iter = 15 - turb_oneram6_vc.test_vals = [-2.281896, -6.614616, 0.233785, 0.142861, 0] + turb_oneram6_vc.test_vals = [-2.282318, -6.614780, 0.234330, 0.143024, 0.000000] turb_oneram6_vc.timeout = 3200 test_list.append(turb_oneram6_vc) @@ -431,7 +431,7 @@ def main(): turb_oneram6_nk.cfg_dir = "rans/oneram6" turb_oneram6_nk.cfg_file = "turb_ONERAM6_nk.cfg" turb_oneram6_nk.test_iter = 20 - turb_oneram6_nk.test_vals = [-4.851388, -4.457414, -11.468726, 0.217228, 0.049043, 5.000000, -0.533763, 23.567000] + turb_oneram6_nk.test_vals = [-4.828066, -4.426250, -11.417591, 0.224679, 0.044309, 1.000000, -0.642977, 31.384000] turb_oneram6_nk.timeout = 600 turb_oneram6_nk.tol = 0.0001 test_list.append(turb_oneram6_nk) @@ -498,7 +498,7 @@ def main(): turb_naca0012_sst_expliciteuler.cfg_dir = "rans/naca0012" turb_naca0012_sst_expliciteuler.cfg_file = "turb_NACA0012_sst_expliciteuler.cfg" turb_naca0012_sst_expliciteuler.test_iter = 10 - turb_naca0012_sst_expliciteuler.test_vals = [-3.533765, -3.157766, 3.364026, 1.124760, 0.501702, -float("inf")] + turb_naca0012_sst_expliciteuler.test_vals = [-3.533765, -3.157766, 3.364026, 1.124757, 0.501700, -float("inf")] turb_naca0012_sst_expliciteuler.timeout = 3200 test_list.append(turb_naca0012_sst_expliciteuler) @@ -530,7 +530,7 @@ def main(): axi_rans_air_nozzle_restart.cfg_dir = "axisymmetric_rans/air_nozzle" axi_rans_air_nozzle_restart.cfg_file = "air_nozzle_restart.cfg" axi_rans_air_nozzle_restart.test_iter = 10 - axi_rans_air_nozzle_restart.test_vals = [-12.067146, -6.838120, -8.845013, -3.786289, 0.000000] + axi_rans_air_nozzle_restart.test_vals = [-12.067375, -6.838713, -8.845034, -3.786225, 0.000000] axi_rans_air_nozzle_restart.tol = 0.0001 test_list.append(axi_rans_air_nozzle_restart) @@ -558,7 +558,7 @@ def main(): inc_euler_naca0012.cfg_dir = "incomp_euler/naca0012" inc_euler_naca0012.cfg_file = "incomp_NACA0012.cfg" inc_euler_naca0012.test_iter = 20 - inc_euler_naca0012.test_vals = [-7.141428, -6.403478, 0.531992, 0.008466] + inc_euler_naca0012.test_vals = [-7.154146, -6.507095, 0.532001, 0.008466] test_list.append(inc_euler_naca0012) # C-D nozzle with pressure inlet and mass flow outlet @@ -566,15 +566,15 @@ def main(): inc_nozzle.cfg_dir = "incomp_euler/nozzle" inc_nozzle.cfg_file = "inv_nozzle.cfg" inc_nozzle.test_iter = 20 - inc_nozzle.test_vals = [-6.308730, -5.512525, -0.004405, 0.126629] + inc_nozzle.test_vals = [-6.576818, -5.796867, -0.003141, 0.126481] test_list.append(inc_nozzle) # Laminar wall mounted cylinder, Euler walls, cylinder wall diagonally split - inc_cylinder_split = TestCase('inc_cylinder_split') - inc_cylinder_split.cfg_dir = "incomp_navierstokes/cylinder_split" - inc_cylinder_split.cfg_file = "cylinder_split.cfg" + inc_cylinder_split = TestCase('inc_cylinder_split') + inc_cylinder_split.cfg_dir = "incomp_navierstokes/cylinder_split" + inc_cylinder_split.cfg_file = "cylinder_split.cfg" inc_cylinder_split.test_iter = 10 - inc_cylinder_split.test_vals = [-10.172747, -11.108149, -10.908852, 10.000000] + inc_cylinder_split.test_vals = [-10.207060, -11.197502, -11.296847, 10.000000] test_list.append(inc_cylinder_split) ############################# @@ -594,7 +594,7 @@ def main(): inc_lam_sphere.cfg_dir = "incomp_navierstokes/sphere" inc_lam_sphere.cfg_file = "sphere.cfg" inc_lam_sphere.test_iter = 5 - inc_lam_sphere.test_vals = [-8.342926, -9.322789, 0.121003, 25.782687] + inc_lam_sphere.test_vals = [-8.342048, -9.328063, 0.121003, 25.782687] test_list.append(inc_lam_sphere) # Buoyancy-driven cavity @@ -614,11 +614,11 @@ def main(): test_list.append(inc_poly_cylinder) # X-coarse laminar bend as a mixed element CGNS test - inc_lam_bend = TestCase('inc_lam_bend') - inc_lam_bend.cfg_dir = "incomp_navierstokes/bend" - inc_lam_bend.cfg_file = "lam_bend.cfg" + inc_lam_bend = TestCase('inc_lam_bend') + inc_lam_bend.cfg_dir = "incomp_navierstokes/bend" + inc_lam_bend.cfg_file = "lam_bend.cfg" inc_lam_bend.test_iter = 10 - inc_lam_bend.test_vals = [-3.550744, -3.220213, -0.017606, 1.015086] + inc_lam_bend.test_vals = [-3.588863, -3.101606, -0.022302, 1.062971] test_list.append(inc_lam_bend) # 3D laminar channnel with 1 cell in flow direction, streamwise periodic @@ -634,7 +634,7 @@ def main(): inc_heatTransfer_BC.cfg_dir = "incomp_navierstokes/streamwise_periodic/chtPinArray_2d" inc_heatTransfer_BC.cfg_file = "BC_HeatTransfer.cfg" inc_heatTransfer_BC.test_iter = 50 - inc_heatTransfer_BC.test_vals = [-8.201114, -7.405807, -7.555676, -0.113666, -1671.700000] + inc_heatTransfer_BC.test_vals = [-8.747445, -7.653823, -8.079512, -0.654920, -1670.100000] test_list.append(inc_heatTransfer_BC) ############################ @@ -785,7 +785,7 @@ def main(): schubauer_klebanoff_transition.cfg_dir = "transition/Schubauer_Klebanoff" schubauer_klebanoff_transition.cfg_file = "transitional_BC_model_ConfigFile.cfg" schubauer_klebanoff_transition.test_iter = 10 - schubauer_klebanoff_transition.test_vals = [-8.058933, -13.242001, 0.000048, 0.007993] + schubauer_klebanoff_transition.test_vals = [-8.215651, -13.240283, 0.000048, 0.007983] test_list.append(schubauer_klebanoff_transition) ##################################### @@ -821,7 +821,7 @@ def main(): contadj_fixed_CL_naca0012.cfg_dir = "fixed_cl/naca0012" contadj_fixed_CL_naca0012.cfg_file = "inv_NACA0012_ContAdj.cfg" contadj_fixed_CL_naca0012.test_iter = 100 - contadj_fixed_CL_naca0012.test_vals = [0.748438, -4.810920, -0.520110, -0.000292] + contadj_fixed_CL_naca0012.test_vals = [0.748407, -4.810872, -0.520110, -0.000291] test_list.append(contadj_fixed_CL_naca0012) ################################### @@ -933,7 +933,7 @@ def main(): harmonic_balance.cfg_dir = "harmonic_balance" harmonic_balance.cfg_file = "HB.cfg" harmonic_balance.test_iter = 25 - harmonic_balance.test_vals = [-1.554985, 0.831796, 0.935729, 3.960210] + harmonic_balance.test_vals = [-1.559187, 0.829575, 0.931512, 3.954440] test_list.append(harmonic_balance) # Turbulent pitching NACA 64a010 airfoil @@ -942,7 +942,7 @@ def main(): hb_rans_preconditioning.cfg_file = "davis.cfg" hb_rans_preconditioning.test_iter = 25 hb_rans_preconditioning.tol = 0.00001 - hb_rans_preconditioning.test_vals = [-1.902098, 0.484070, 0.601481, 3.609002, -5.949360] + hb_rans_preconditioning.test_vals = [-1.902098, 0.484070, 0.601481, 3.609002, -5.949356] test_list.append(hb_rans_preconditioning) ###################################### @@ -954,7 +954,7 @@ def main(): rot_naca0012.cfg_dir = "rotating/naca0012" rot_naca0012.cfg_file = "rot_NACA0012.cfg" rot_naca0012.test_iter = 25 - rot_naca0012.test_vals = [-2.709459, 2.836670, -0.081188, 0.002156] + rot_naca0012.test_vals = [-2.603551, 2.924633, -0.081272, 0.002162] test_list.append(rot_naca0012) # Lid-driven cavity @@ -991,7 +991,7 @@ def main(): sine_gust.cfg_dir = "gust" sine_gust.cfg_file = "inv_gust_NACA0012.cfg" sine_gust.test_iter = 5 - sine_gust.test_vals = [-1.977514, 3.481817, -0.010609, -0.007956] + sine_gust.test_vals = [-1.977498, 3.481817, -0.010773, -0.008068] sine_gust.unsteady = True test_list.append(sine_gust) @@ -1000,7 +1000,7 @@ def main(): aeroelastic.cfg_dir = "aeroelastic" aeroelastic.cfg_file = "aeroelastic_NACA64A010.cfg" aeroelastic.test_iter = 2 - aeroelastic.test_vals = [0.075176, 0.027496, -0.001643, -0.000126] + aeroelastic.test_vals = [0.075023, 0.027483, -0.001643, -0.000126] aeroelastic.unsteady = True test_list.append(aeroelastic) @@ -1009,7 +1009,7 @@ def main(): ddes_flatplate.cfg_dir = "ddes/flatplate" ddes_flatplate.cfg_file = "ddes_flatplate.cfg" ddes_flatplate.test_iter = 10 - ddes_flatplate.test_vals = [-2.714786, -5.882637, -0.215041, 0.023758, 0] + ddes_flatplate.test_vals = [-2.714713, -5.788290, -0.214960, 0.023758, 0.000000] ddes_flatplate.unsteady = True test_list.append(ddes_flatplate) @@ -1027,7 +1027,7 @@ def main(): flatplate_unsteady.cfg_dir = "navierstokes/flatplate" flatplate_unsteady.cfg_file = "lam_flatplate_unst.cfg" flatplate_unsteady.test_iter = 3 - flatplate_unsteady.test_vals = [-8.875126, -8.250188, -6.305789, -5.469452, -3.398228, 0.002075, -0.326018] + flatplate_unsteady.test_vals = [-8.875128, -8.250204, -6.305788, -5.469452, -3.398230, 0.002075, -0.325535] flatplate_unsteady.unsteady = True test_list.append(flatplate_unsteady) @@ -1040,7 +1040,7 @@ def main(): edge_VW.cfg_dir = "nicf/edge" edge_VW.cfg_file = "edge_VW.cfg" edge_VW.test_iter = 50 - edge_VW.test_vals = [-8.107432, -1.914195, -0.000009, 0.000000] + edge_VW.test_vals = [-9.057409, -2.833203, -0.000009, 0.000000] test_list.append(edge_VW) # Rarefaction shock wave edge_PPR @@ -1048,7 +1048,7 @@ def main(): edge_PPR.cfg_dir = "nicf/edge" edge_PPR.cfg_file = "edge_PPR.cfg" edge_PPR.test_iter = 50 - edge_PPR.test_vals = [-8.611983, -2.441992, -0.000034, 0.000000] + edge_PPR.test_vals = [-9.781896, -3.630892, -0.000034, 0.000000] test_list.append(edge_PPR) # Rarefaction Q1D nozzle, include CoolProp fluid model @@ -1056,7 +1056,7 @@ def main(): coolprop_fluidModel.cfg_dir = "nicf/coolprop" coolprop_fluidModel.cfg_file = "fluidModel.cfg" coolprop_fluidModel.test_iter = 5 - coolprop_fluidModel.test_vals = [-4.424952, -1.583022, 3.724040, 0.000000, 0.000000] + coolprop_fluidModel.test_vals = [-4.684483, -1.583073, 3.724768, 0.000000, 0.000000] coolprop_fluidModel.enabled_on_cpu_arch = ["x86_64"] test_list.append(coolprop_fluidModel) @@ -1065,7 +1065,7 @@ def main(): coolprop_transportModel.cfg_dir = "nicf/coolprop" coolprop_transportModel.cfg_file = "transportModel.cfg" coolprop_transportModel.test_iter = 5 - coolprop_transportModel.test_vals = [-4.428096, -1.314553, 4.667817, 0.000000, 0.000000] + coolprop_transportModel.test_vals = [-4.684988, -1.314608, 4.668105, 0.000000, 0.000000] coolprop_transportModel.enabled_on_cpu_arch = ["x86_64"] test_list.append(coolprop_transportModel) @@ -1074,7 +1074,7 @@ def main(): datadriven_fluidModel.cfg_dir = "nicf/datadriven" datadriven_fluidModel.cfg_file = "datadriven_nozzle.cfg" datadriven_fluidModel.test_iter = 50 - datadriven_fluidModel.test_vals = [-2.713249, 0.183616, 4.717485, 0.000000, 0.000000] + datadriven_fluidModel.test_vals = [-6.338898, -3.837472, -4.351292, -1.860262, -2.700991, 0.691801] test_list.append(datadriven_fluidModel) ###################################### @@ -1132,7 +1132,7 @@ def main(): uniform_flow.cfg_dir = "sliding_interface/uniform_flow" uniform_flow.cfg_file = "uniform_NN.cfg" uniform_flow.test_iter = 5 - uniform_flow.test_vals = [5.000000, 0.000000, -0.186036, -10.624450] + uniform_flow.test_vals = [5.000000, 0.000000, -0.195002, -10.624448] uniform_flow.unsteady = True uniform_flow.multizone = True test_list.append(uniform_flow) @@ -1142,7 +1142,7 @@ def main(): channel_2D.cfg_dir = "sliding_interface/channel_2D" channel_2D.cfg_file = "channel_2D_WA.cfg" channel_2D.test_iter = 2 - channel_2D.test_vals = [2.000000, 0.000000, 0.417418, 0.350499, 0.401527] + channel_2D.test_vals = [2.000000, 0.000000, 0.464931, 0.348057, 0.397535] channel_2D.timeout = 100 channel_2D.unsteady = True channel_2D.multizone = True @@ -1153,7 +1153,7 @@ def main(): channel_3D.cfg_dir = "sliding_interface/channel_3D" channel_3D.cfg_file = "channel_3D_WA.cfg" channel_3D.test_iter = 2 - channel_3D.test_vals = [2.000000, 0.000000, 0.622666, 0.506173, 0.410911] + channel_3D.test_vals = [2.000000, 0.000000, 0.629113, 0.524906, 0.422425] channel_3D.unsteady = True channel_3D.multizone = True test_list.append(channel_3D) @@ -1163,7 +1163,7 @@ def main(): pipe.cfg_dir = "sliding_interface/pipe" pipe.cfg_file = "pipe_NN.cfg" pipe.test_iter = 2 - pipe.test_vals = [0.121512, 0.477629, 0.641341, 0.983336, 1.018856] + pipe.test_vals = [0.080827, 0.547324, 0.655095, 0.968235, 1.049121] pipe.unsteady = True pipe.multizone = True test_list.append(pipe) @@ -1173,7 +1173,7 @@ def main(): rotating_cylinders.cfg_dir = "sliding_interface/rotating_cylinders" rotating_cylinders.cfg_file = "rot_cylinders_WA.cfg" rotating_cylinders.test_iter = 3 - rotating_cylinders.test_vals = [3.000000, 0.000000, 0.719777, 1.111044, 1.154071] + rotating_cylinders.test_vals = [3.000000, 0.000000, 0.717065, 1.119815, 1.160330] rotating_cylinders.unsteady = True rotating_cylinders.multizone = True test_list.append(rotating_cylinders) @@ -1183,7 +1183,7 @@ def main(): supersonic_vortex_shedding.cfg_dir = "sliding_interface/supersonic_vortex_shedding" supersonic_vortex_shedding.cfg_file = "sup_vor_shed_WA.cfg" supersonic_vortex_shedding.test_iter = 5 - supersonic_vortex_shedding.test_vals = [5.000000, 0.000000, 1.206774, 1.053450] + supersonic_vortex_shedding.test_vals = [5.000000, 0.000000, 1.207118, 1.065260] supersonic_vortex_shedding.unsteady = True supersonic_vortex_shedding.multizone = True test_list.append(supersonic_vortex_shedding) @@ -1258,7 +1258,7 @@ def main(): fsi2d.cfg_dir = "fea_fsi/WallChannel_2d" fsi2d.cfg_file = "configFSI.cfg" fsi2d.test_iter = 4 - fsi2d.test_vals = [4.000000, 0.000000, -3.726049, -4.277801] + fsi2d.test_vals = [4.000000, 0.000000, -3.726013, -4.277768] fsi2d.command = TestCase.Command(exec = "parallel_computation_fsi.py", param = "-f") fsi2d.multizone= True fsi2d.unsteady = True @@ -1269,7 +1269,7 @@ def main(): stat_fsi.cfg_dir = "fea_fsi/stat_fsi" stat_fsi.cfg_file = "config.cfg" stat_fsi.test_iter = 7 - stat_fsi.test_vals = [-3.309522, -4.948620, 0.000000, 8] + stat_fsi.test_vals = [-3.301938, -4.971986, 0.000000, 11.000000] stat_fsi.multizone = True test_list.append(stat_fsi) @@ -1278,7 +1278,7 @@ def main(): dyn_fsi.cfg_dir = "fea_fsi/dyn_fsi" dyn_fsi.cfg_file = "config.cfg" dyn_fsi.test_iter = 4 - dyn_fsi.test_vals = [-4.330921, -4.153040, 0.000000, 96] + dyn_fsi.test_vals = [-4.330741, -4.153001, 0.000000, 97.000000] dyn_fsi.multizone = True dyn_fsi.unsteady = True test_list.append(dyn_fsi) @@ -1288,7 +1288,7 @@ def main(): stat_fsi_restart.cfg_dir = "fea_fsi/stat_fsi" stat_fsi_restart.cfg_file = "config_restart.cfg" stat_fsi_restart.test_iter = 1 - stat_fsi_restart.test_vals = [-3.450744, -4.279403, 0.000000, 27] + stat_fsi_restart.test_vals = [-3.486655, -4.425104, 0.000000, 27.000000] stat_fsi_restart.multizone = True test_list.append(stat_fsi_restart) @@ -1345,7 +1345,7 @@ def main(): sp_pinArray_cht_2d_dp_hf.cfg_dir = "incomp_navierstokes/streamwise_periodic/chtPinArray_2d" sp_pinArray_cht_2d_dp_hf.cfg_file = "configMaster.cfg" sp_pinArray_cht_2d_dp_hf.test_iter = 100 - sp_pinArray_cht_2d_dp_hf.test_vals = [0.548558, -0.379295, -1.007163, -0.732245, 208.023676, 334.010000, -0.000000, -0.732240, 0.732240] + sp_pinArray_cht_2d_dp_hf.test_vals = [0.500399, -0.667466, -0.984103, -0.726712, 208.023676, 350.140000, -0.000000, -0.726710, 0.726710] sp_pinArray_cht_2d_dp_hf.multizone = True test_list.append(sp_pinArray_cht_2d_dp_hf) @@ -1354,7 +1354,7 @@ def main(): sp_pinArray_3d_cht_mf_hf_tp.cfg_dir = "incomp_navierstokes/streamwise_periodic/chtPinArray_3d" sp_pinArray_3d_cht_mf_hf_tp.cfg_file = "configMaster.cfg" sp_pinArray_3d_cht_mf_hf_tp.test_iter = 30 - sp_pinArray_3d_cht_mf_hf_tp.test_vals = [-1.117102, -1.880628, -2.561816, -0.009804, 104.600540, 418.360000, 0.000000] + sp_pinArray_3d_cht_mf_hf_tp.test_vals = [-1.116189, -1.881686, -2.561500, -0.009805, 104.600449, 418.360000, 0.000000] sp_pinArray_3d_cht_mf_hf_tp.test_vals_aarch64 = [-1.117102, -1.880628, -2.561816, -0.009804, 104.600540, 418.360000, 0.000000] sp_pinArray_3d_cht_mf_hf_tp.multizone = True test_list.append(sp_pinArray_3d_cht_mf_hf_tp) @@ -1369,7 +1369,7 @@ def main(): pywrapper_naca0012.cfg_dir = "euler/naca0012" pywrapper_naca0012.cfg_file = "inv_NACA0012_Roe.cfg" pywrapper_naca0012.test_iter = 100 - pywrapper_naca0012.test_vals = [-8.461085, -7.758356, 0.335769, 0.023275] + pywrapper_naca0012.test_vals = [-9.249009, -8.546597, 0.335769, 0.023275] pywrapper_naca0012.command = TestCase.Command("mpirun -np 2", "SU2_CFD.py", "--parallel -f") test_list.append(pywrapper_naca0012) @@ -1399,7 +1399,7 @@ def main(): pywrapper_aeroelastic.cfg_dir = "aeroelastic" pywrapper_aeroelastic.cfg_file = "aeroelastic_NACA64A010.cfg" pywrapper_aeroelastic.test_iter = 2 - pywrapper_aeroelastic.test_vals = [0.075176, 0.027496, -0.001643, -0.000126] + pywrapper_aeroelastic.test_vals = [0.075023, 0.027483, -0.001643, -0.000126] pywrapper_aeroelastic.command = TestCase.Command("mpirun -np 2", "SU2_CFD.py", "--parallel -f") pywrapper_aeroelastic.unsteady = True test_list.append(pywrapper_aeroelastic) @@ -1419,7 +1419,7 @@ def main(): pywrapper_fsi2d.cfg_dir = "fea_fsi/WallChannel_2d" pywrapper_fsi2d.cfg_file = "configFSI.cfg" pywrapper_fsi2d.test_iter = 4 - pywrapper_fsi2d.test_vals = [4.000000, 0.000000, -3.726049, -4.277801] + pywrapper_fsi2d.test_vals = [4.000000, 0.000000, -3.726013, -4.277768] pywrapper_fsi2d.command = TestCase.Command("mpirun -np 2", "SU2_CFD.py", "--nZone 2 --fsi True --parallel -f") pywrapper_fsi2d.unsteady = True pywrapper_fsi2d.multizone = True @@ -1430,7 +1430,7 @@ def main(): pywrapper_unsteadyFSI.cfg_dir = "py_wrapper/dyn_fsi" pywrapper_unsteadyFSI.cfg_file = "config.cfg" pywrapper_unsteadyFSI.test_iter = 4 - pywrapper_unsteadyFSI.test_vals = [0.000000, 49.000000, 5.000000, 55.000000, -0.709822, -3.429271, -2.524625, -7.938341, 0.001514] + pywrapper_unsteadyFSI.test_vals = [0.000000, 31.000000, 5.000000, 58.000000, -1.756677, -2.828286, -7.638545, -6.863959, 0.000156] pywrapper_unsteadyFSI.command = TestCase.Command("mpirun -np 2", "python", "run.py") pywrapper_unsteadyFSI.unsteady = True pywrapper_unsteadyFSI.multizone = True @@ -1461,7 +1461,7 @@ def main(): pywrapper_deformingBump.cfg_dir = "py_wrapper/deforming_bump_in_channel" pywrapper_deformingBump.cfg_file = "config.cfg" pywrapper_deformingBump.test_iter = 1 - pywrapper_deformingBump.test_vals = [0.500000, 0.000000, -3.037859, -1.603563, -2.074259, 2.424288, 7.762848, -0.220436] + pywrapper_deformingBump.test_vals = [0.500000, 0.000000, -2.811520, -1.603562, -2.074259, 2.424289, 7.616891, -0.205655] pywrapper_deformingBump.command = TestCase.Command("mpirun -np 2", "python", "run.py") pywrapper_deformingBump.unsteady = True test_list.append(pywrapper_deformingBump) @@ -1549,7 +1549,7 @@ def main(): species2_primitiveVenturi_mixingmodel_viscosity.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_viscosity.cfg_file = "species2_primitiveVenturi_mixingmodel_viscosity.cfg" species2_primitiveVenturi_mixingmodel_viscosity.test_iter = 50 - species2_primitiveVenturi_mixingmodel_viscosity.test_vals = [-4.857405, -3.646534, -3.737422, -7.602756, -5.008835, 5.000000, -1.756256, 5.000000, -3.163548, 5.000000, -2.189690, 2.476807, 0.977000, 0.609279, 0.890528] + species2_primitiveVenturi_mixingmodel_viscosity.test_vals = [-5.232339, -3.617118, -3.857221, -7.533847, -5.126646, 5.000000, -1.682962, 5.000000, -3.474078, 5.000000, -2.086859, 2.495548, 0.985490, 0.600234, 0.909824] test_list.append(species2_primitiveVenturi_mixingmodel_viscosity) # 2 species (1 eq) primitive venturi mixing using mixing model including heat capacity and mass diffusivity @@ -1573,7 +1573,7 @@ def main(): species2_primitiveVenturi.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi.cfg_file = "species2_primitiveVenturi.cfg" species2_primitiveVenturi.test_iter = 50 - species2_primitiveVenturi.test_vals = [-5.383507, -4.591042, -4.618659, -5.371315, -1.048003, -5.321849, 5.000000, -1.011668, 5.000000, -2.540380, 5.000000, -1.220744, 0.000035, 0.000035, 0.000000, 0.000000] + species2_primitiveVenturi.test_vals = [-5.919132, -4.941085, -4.919763, -5.717215, -1.405791, -6.087254, 5.000000, -0.524653, 5.000000, -2.608809, 5.000000, -0.351723, 0.000113, 0.000112, 0.000000, 0.000000] test_list.append(species2_primitiveVenturi) # 2 species (1 eq) primitive venturi mixing with bounded scalar transport @@ -1581,7 +1581,7 @@ def main(): species_primitiveVenturi_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species_primitiveVenturi_boundedscalar.cfg_file = "species2_primitiveVenturi_boundedscalar.cfg" species_primitiveVenturi_boundedscalar.test_iter = 50 - species_primitiveVenturi_boundedscalar.test_vals = [-5.273416, -4.372370, -4.440933, -5.944335, -0.961736, -5.609422, 5.000000, -2.024352, 5.000000, -4.092737, 5.000000, -1.811021, 0.000423, 0.000423, 0.000000, 0.000000] + species_primitiveVenturi_boundedscalar.test_vals = [-5.534441, -4.368794, -4.465911, -5.935827, -0.867763, -5.633723, 5.000000, -1.470749, 5.000000, -4.161492, 5.000000, -1.724769, 0.000434, 0.000434, 0.000000, 0.000000] test_list.append(species_primitiveVenturi_boundedscalar) # 2 species (1 eq) primitive venturi mixing using mixing model including inlet markers for turbulent intensity and viscosity ratios @@ -1589,7 +1589,7 @@ def main(): species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.cfg_file = "species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.cfg" species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.test_iter = 50 - species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.test_vals = [-4.047742, -1.641280, -1.562848, -0.984640, 1.499898, -3.745901, 23.000000, -5.208811, 12.000000, -5.399205, 3.000000, -5.230072, 2.000000, 1.000000, 0.000000, 1.000000] + species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS.test_vals = [-4.565556, -1.773987, -1.569972, -0.978893, 1.693213, -3.843844, 23.000000, -5.040721, 10.000000, -5.559387, 3.000000, -5.370252, 2.000000, 1.000000, 0.000000, 1.000000] test_list.append(species2_primitiveVenturi_mixingmodel_TURBULENT_MARKERS) # 3 species (2 eq) primitive venturi mixing with inlet files. @@ -1598,7 +1598,7 @@ def main(): species3_primitiveVenturi_inletFile.cfg_dir = "species_transport/venturi_primitive_3species" species3_primitiveVenturi_inletFile.cfg_file = "species3_primitiveVenturi_inletFile.cfg" species3_primitiveVenturi_inletFile.test_iter = 50 - species3_primitiveVenturi_inletFile.test_vals = [-5.454137, -4.661671, -4.689288, -5.441944, -1.118632, -5.592455, -5.735073, 5.000000, -1.011667, 5.000000, -2.540380, 5.000000, -1.040187] + species3_primitiveVenturi_inletFile.test_vals = [-5.989944, -5.011655, -4.990373, -5.787315, -1.475219, -6.316068, -6.446277, 5.000000, -0.525858, 5.000000, -2.609037, 5.000000, -0.362429] test_list.append(species3_primitiveVenturi_inletFile) # rectangle passive transport validation @@ -1606,7 +1606,7 @@ def main(): species_passive_val.cfg_dir = "species_transport/passive_transport_validation" species_passive_val.cfg_file = "passive_transport.cfg" species_passive_val.test_iter = 50 - species_passive_val.test_vals = [-16.604279, -16.303255, -16.970059, -4.257599, 10.000000, -4.731945, 8.000000, -5.193350, 0.186610, 0.000000] + species_passive_val.test_vals = [-16.561013, -16.280437, -16.910003, -4.257599, 10.000000, -4.457215, 8.000000, -5.193350, 0.186610, 0.000000] species_passive_val.test_vals_aarch64 = [-16.538551, -16.312552, -16.882823, -4.257599, 10, -4.585464, 8, -5.19335, 0.18661, 0] test_list.append(species_passive_val) @@ -1615,7 +1615,7 @@ def main(): species3_multizone_restart.cfg_dir = "species_transport/multizone" species3_multizone_restart.cfg_file = "configMaster.cfg" species3_multizone_restart.test_iter = 5 - species3_multizone_restart.test_vals = [-2.081789, -1.936012] + species3_multizone_restart.test_vals = [-3.715625, -3.070578] species3_multizone_restart.multizone = True test_list.append(species3_multizone_restart) @@ -1628,11 +1628,24 @@ def main(): cgns_writer.cfg_dir = "cgns_writer" cgns_writer.cfg_file = "config.cfg" cgns_writer.test_iter = 1 - cgns_writer.test_vals = [-2.974473, 0.640256, 5.371029, -6.732060] - cgns_writer.command = TestCase.Command("mpirun -n 2", "SU2_CFD") + cgns_writer.test_vals = [-2.974473, 0.640256, 5.371028, -6.732060] cgns_writer.new_output = True test_list.append(cgns_writer) + ###################################### + ### RUN CHT TEST WITH FILEDIFF ### + ###################################### + + # 2D planar laminar premixed methane flame on isothermal burner with conjugate heat transfer in cooling fin (restart) + cfd_flamelet_ch4_cht = TestCase('cfd_flamelet_ch4_cht') + cfd_flamelet_ch4_cht.cfg_dir = "flamelet/03_laminar_premixed_ch4_flame_cht_cfd" + cfd_flamelet_ch4_cht.cfg_file = "lam_prem_ch4_cht_cfd_master.cfg" + cfd_flamelet_ch4_cht.test_iter = 5 + cfd_flamelet_ch4_cht.test_vals = [-10.166224, -9.299576, -10.022482, -11.907558, -3.447626, -12.290421, -13.719415, -6.864920] + cfd_flamelet_ch4_cht.timeout = 1600 + cfd_flamelet_ch4_cht.multizone = True + test_list.append(cfd_flamelet_ch4_cht) + ###################################### ### RUN TESTS ### ###################################### @@ -1651,25 +1664,6 @@ def main(): pass_list = [ test.run_test() for test in test_list ] - ###################################### - ### RUN CHT TEST WITH FILEDIFF ### - ###################################### - - # 2D planar laminar premixed methane flame on isothermal burner with conjugate heat transfer in cooling fin (restart) - cfd_flamelet_ch4_cht = TestCase('cfd_flamelet_ch4_cht') - cfd_flamelet_ch4_cht.cfg_dir = "flamelet/03_laminar_premixed_ch4_flame_cht_cfd" - cfd_flamelet_ch4_cht.cfg_file = "lam_prem_ch4_cht_cfd_master.cfg" - cfd_flamelet_ch4_cht.test_iter = 5 - cfd_flamelet_ch4_cht.command = TestCase.Command("mpirun -n 2", "SU2_CFD") - cfd_flamelet_ch4_cht.timeout = 1600 - cfd_flamelet_ch4_cht.reference_file = "restart_0.csv.ref" - cfd_flamelet_ch4_cht.test_file = "restart_0.csv" - cfd_flamelet_ch4_cht.multizone = True - cfd_flamelet_ch4_cht.comp_threshold = 1e-6 - cfd_flamelet_ch4_cht.tol_file_percent = 1.0 - pass_list.append(cfd_flamelet_ch4_cht.run_filediff()) - test_list.append(cfd_flamelet_ch4_cht) - ###################################### ### RUN SU2_SOL TESTS ### ###################################### diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index 89bd7e8037d6..0e9330304476 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -47,7 +47,7 @@ def main(): discadj_naca0012.cfg_dir = "cont_adj_euler/naca0012" discadj_naca0012.cfg_file = "inv_NACA0012_discadj.cfg" discadj_naca0012.test_iter = 100 - discadj_naca0012.test_vals = [-3.560692, -8.925239, -0.000000, 0.005559] + discadj_naca0012.test_vals = [-3.562562, -8.932563, -0.000000, 0.005608] test_list.append(discadj_naca0012) # Inviscid Cylinder 3D (multiple markers) @@ -55,7 +55,7 @@ def main(): discadj_cylinder3D.cfg_dir = "disc_adj_euler/cylinder3D" discadj_cylinder3D.cfg_file = "inv_cylinder3D.cfg" discadj_cylinder3D.test_iter = 5 - discadj_cylinder3D.test_vals = [-3.778153, -3.743482, 0.000000, 0.000000] + discadj_cylinder3D.test_vals = [-3.693714, -3.889422, 0.000000, 0.000000] test_list.append(discadj_cylinder3D) # Arina nozzle 2D @@ -63,7 +63,7 @@ def main(): discadj_arina2k.cfg_dir = "disc_adj_euler/arina2k" discadj_arina2k.cfg_file = "Arina2KRS.cfg" discadj_arina2k.test_iter = 20 - discadj_arina2k.test_vals = [-3.540396, -3.828299, 0.027959, 0.000000] + discadj_arina2k.test_vals = [-3.254894, -3.550776, 0.053099, 0.000000] test_list.append(discadj_arina2k) # Equivalent area NACA64-206 @@ -71,7 +71,7 @@ def main(): ea_naca64206.cfg_dir = "optimization_euler/equivalentarea_naca64206" ea_naca64206.cfg_file = "NACA64206.cfg" ea_naca64206.test_iter = 10 - ea_naca64206.test_vals = [3.127605, 2.411805, -5505700.000000, 10.591000] + ea_naca64206.test_vals = [3.117653, 2.396440, -5467200.000000, 11.585000] test_list.append(ea_naca64206) #################################### @@ -104,7 +104,7 @@ def main(): discadj_incomp_NACA0012.cfg_dir = "disc_adj_incomp_euler/naca0012" discadj_incomp_NACA0012.cfg_file = "incomp_NACA0012_disc.cfg" discadj_incomp_NACA0012.test_iter = 20 - discadj_incomp_NACA0012.test_vals = [20.000000, -4.093433, -2.686134, 0.000000] + discadj_incomp_NACA0012.test_vals = [20.000000, -4.096681, -2.686537, 0.000000] test_list.append(discadj_incomp_NACA0012) ##################################### @@ -128,7 +128,7 @@ def main(): discadj_incomp_turb_NACA0012_sa.cfg_dir = "disc_adj_incomp_rans/naca0012" discadj_incomp_turb_NACA0012_sa.cfg_file = "turb_naca0012_sa.cfg" discadj_incomp_turb_NACA0012_sa.test_iter = 10 - discadj_incomp_turb_NACA0012_sa.test_vals = [10.000000, -3.846018, -1.031079, 0.000000] + discadj_incomp_turb_NACA0012_sa.test_vals = [10.000000, -3.846020, -1.031079, 0.000000] discadj_incomp_turb_NACA0012_sa.test_vals_aarch64 = [10.000000, -3.846020, -1.031078, 0.000000] test_list.append(discadj_incomp_turb_NACA0012_sa) @@ -150,7 +150,7 @@ def main(): discadj_axisymmetric_rans_nozzle.cfg_dir = "axisymmetric_rans/air_nozzle" discadj_axisymmetric_rans_nozzle.cfg_file = "air_nozzle_restart.cfg" discadj_axisymmetric_rans_nozzle.test_iter = 10 - discadj_axisymmetric_rans_nozzle.test_vals = [9.553798, 4.939170, 7.053482, 2.476177] + discadj_axisymmetric_rans_nozzle.test_vals = [9.738507, 5.143637, 7.119665, 2.505997] discadj_axisymmetric_rans_nozzle.no_restart = True test_list.append(discadj_axisymmetric_rans_nozzle) @@ -217,7 +217,7 @@ def main(): discadj_pitchingNACA0012.cfg_dir = "disc_adj_euler/naca0012_pitching" discadj_pitchingNACA0012.cfg_file = "inv_NACA0012_pitching.cfg" discadj_pitchingNACA0012.test_iter = 4 - discadj_pitchingNACA0012.test_vals = [-1.227073, -1.648410, -0.007541, 0.000012] + discadj_pitchingNACA0012.test_vals = [-1.226212, -1.647429, -0.007557, 0.000012] discadj_pitchingNACA0012.unsteady = True test_list.append(discadj_pitchingNACA0012) @@ -256,7 +256,7 @@ def main(): discadj_heat.cfg_dir = "disc_adj_heat" discadj_heat.cfg_file = "disc_adj_heat.cfg" discadj_heat.test_iter = 10 - discadj_heat.test_vals = [-1.840134, 0.750337, 0.000000, 0.006760] + discadj_heat.test_vals = [-1.999668, 0.670563, 0.000000, 0.006210] discadj_heat.test_vals_aarch64 = [-2.226539, 0.605868, 0.000000, -6.256400] test_list.append(discadj_heat) @@ -277,7 +277,7 @@ def main(): discadj_fsi2.cfg_dir = "disc_adj_fsi/Airfoil_2d" discadj_fsi2.cfg_file = "config.cfg" discadj_fsi2.test_iter = 8 - discadj_fsi2.test_vals = [-2.402385, 2.873651, -1.278981, -1.284800, 3.530900] + discadj_fsi2.test_vals = [-4.772585, 0.918091, -3.863369, 0.295450, 3.841200] discadj_fsi2.test_vals_aarch64 = [-4.349372, 0.190601, -1.303589, 0.754070, 2.324400] discadj_fsi2.tol = 0.00001 test_list.append(discadj_fsi2) @@ -299,7 +299,7 @@ def main(): da_sp_pinArray_cht_2d_dp_hf.cfg_dir = "incomp_navierstokes/streamwise_periodic/chtPinArray_2d" da_sp_pinArray_cht_2d_dp_hf.cfg_file = "DA_configMaster.cfg" da_sp_pinArray_cht_2d_dp_hf.test_iter = 100 - da_sp_pinArray_cht_2d_dp_hf.test_vals = [-4.703416, -4.061963, -4.136826] + da_sp_pinArray_cht_2d_dp_hf.test_vals = [-4.754828, -4.058323, -4.137408] da_sp_pinArray_cht_2d_dp_hf.multizone = True test_list.append(da_sp_pinArray_cht_2d_dp_hf) @@ -308,7 +308,7 @@ def main(): da_sp_pinArray_cht_2d_mf.cfg_dir = "incomp_navierstokes/streamwise_periodic/dp-adjoint_chtPinArray_2d" da_sp_pinArray_cht_2d_mf.cfg_file = "configMaster.cfg" da_sp_pinArray_cht_2d_mf.test_iter = 100 - da_sp_pinArray_cht_2d_mf.test_vals = [-4.508582, -1.198591, -1.394041, -18.498530, -0.810948, -6.006116, -19.074586, -49.841067] + da_sp_pinArray_cht_2d_mf.test_vals = [-4.543396, -1.198883, -1.451287, -18.497517, -0.811918, -6.001418, -19.076086, -49.855384] da_sp_pinArray_cht_2d_mf.multizone = True test_list.append(da_sp_pinArray_cht_2d_mf) @@ -317,64 +317,52 @@ def main(): da_unsteadyCHT_cylinder.cfg_dir = "coupled_cht/disc_adj_unsteadyCHT_cylinder" da_unsteadyCHT_cylinder.cfg_file = "chtMaster.cfg" da_unsteadyCHT_cylinder.test_iter = 2 - da_unsteadyCHT_cylinder.test_vals = [-3.508906, -4.317739, -4.241558, -11.836892, -12.862650, 0.000000, 3.688000, 0.295190] + da_unsteadyCHT_cylinder.test_vals = [-3.508906, -4.317739, -4.241558, -11.836892, -12.862640, 0.000000, 3.688000, 0.295190] da_unsteadyCHT_cylinder.test_vals_aarch64 = [-3.508906, -4.317739, -4.241558, -11.836892, -12.862650, 0.000000, 3.688000, 0.295190] da_unsteadyCHT_cylinder.unsteady = True da_unsteadyCHT_cylinder.multizone = True test_list.append(da_unsteadyCHT_cylinder) - ###################################### - ### RUN TESTS ### - ###################################### - - # set suitable defaults unless something else has been specified - # command: "mpirun -n 2 SU2_CFD_AD" - # timeout: 1600 - # tol: 0.00001 - for test in test_list: - if test.command.empty(): - test.command = TestCase.Command("mpirun -n 2", "SU2_CFD_AD") - if test.timeout == 0: - test.timeout = 1600 - if test.tol == 0.0: - test.tol = 0.00001 - - pass_list = [ test.run_test() for test in test_list ] - ################################## ### Disc. adj. flamelet solver ### ################################## # 2D planar laminar premixed flame on isothermal burner (restart) discadj_flamelet_ch4_hx = TestCase('discadj_flamelet_ch4_hx') - discadj_flamelet_ch4_hx.command = TestCase.Command("mpirun -n 2", "SU2_CFD_AD") discadj_flamelet_ch4_hx.cfg_dir = "flamelet/02_laminar_premixed_ch4_flame_hx_ad" discadj_flamelet_ch4_hx.cfg_file = "lam_prem_ch4_hx_ad.cfg" discadj_flamelet_ch4_hx.multizone = False discadj_flamelet_ch4_hx.test_iter = 10 - discadj_flamelet_ch4_hx.timeout = 20000 - discadj_flamelet_ch4_hx.reference_file = "restart_adj_custom.csv.ref" - discadj_flamelet_ch4_hx.test_file = "restart_adj_custom.csv" - discadj_flamelet_ch4_hx.comp_threshold = 1e-6 - discadj_flamelet_ch4_hx.tol_file_percent = 0.1 - pass_list.append(discadj_flamelet_ch4_hx.run_filediff()) + discadj_flamelet_ch4_hx.test_vals = [-8.699008, -8.604699, -8.816298, -6.626855, -14.620943, -3.249062, -18.930953] test_list.append(discadj_flamelet_ch4_hx) # 2D planar laminar premixed flame on isothermal burner with conjugate heat transfer (restart) discadj_flamelet_ch4_cht = TestCase('discadj_flamelet_ch4_cht') - discadj_flamelet_ch4_cht.command = TestCase.Command("mpirun -n 2", "SU2_CFD_AD") discadj_flamelet_ch4_cht.cfg_dir = "flamelet/04_laminar_premixed_ch4_flame_cht_ad" discadj_flamelet_ch4_cht.cfg_file = "lam_prem_ch4_cht_ad_master.cfg" discadj_flamelet_ch4_cht.multizone = True - discadj_flamelet_ch4_cht.test_iter = 5 - discadj_flamelet_ch4_cht.reference_file = "restart_adj_T_0.csv.ref" - discadj_flamelet_ch4_cht.test_file = "restart_adj_T_0.csv" - discadj_flamelet_ch4_cht.comp_threshold = 1e-6 - discadj_flamelet_ch4_cht.tol_file_percent = 0.1 - discadj_flamelet_ch4_cht.timeout = 20000 - pass_list.append(discadj_flamelet_ch4_cht.run_filediff()) + discadj_flamelet_ch4_cht.test_iter = 10 + discadj_flamelet_ch4_cht.test_vals = [-2.760027, -1.999839, -2.096537, -0.153424, -7.289370, -18.655063, -18.622003, -4.847179] test_list.append(discadj_flamelet_ch4_cht) + ###################################### + ### RUN TESTS ### + ###################################### + + # set suitable defaults unless something else has been specified + # command: "mpirun -n 2 SU2_CFD_AD" + # timeout: 1600 + # tol: 0.00001 + for test in test_list: + if test.command.empty(): + test.command = TestCase.Command("mpirun -n 2", "SU2_CFD_AD") + if test.timeout == 0: + test.timeout = 1600 + if test.tol == 0.0: + test.tol = 0.00001 + + pass_list = [ test.run_test() for test in test_list ] + ################################################ ### Gradient check (dot) for flamelet solver ### ################################################ @@ -511,7 +499,7 @@ def main(): pywrapper_CFD_AD_MeshDisp.cfg_dir = "py_wrapper/disc_adj_flow/mesh_disp_sens" pywrapper_CFD_AD_MeshDisp.cfg_file = "configAD_flow.cfg" pywrapper_CFD_AD_MeshDisp.test_iter = 1000 - pywrapper_CFD_AD_MeshDisp.test_vals = [30.000000, -2.506016, 1.407249, 0.000000] + pywrapper_CFD_AD_MeshDisp.test_vals = [30.000000, -2.496560, 1.440884, 0.000000] pywrapper_CFD_AD_MeshDisp.command = TestCase.Command("mpirun -n 2", "python", "run_adjoint.py --parallel -f") pywrapper_CFD_AD_MeshDisp.timeout = 1600 pywrapper_CFD_AD_MeshDisp.tol = 0.000001 diff --git a/TestCases/py_wrapper/translating_NACA0012/config.cfg b/TestCases/py_wrapper/translating_NACA0012/config.cfg index a78809272390..3deaf8fc1b62 100644 --- a/TestCases/py_wrapper/translating_NACA0012/config.cfg +++ b/TestCases/py_wrapper/translating_NACA0012/config.cfg @@ -43,7 +43,7 @@ MARKER_DEFORM_MESH= ( airfoil ) % DISCRETIZATION METHODS % CONV_NUM_METHOD_FLOW= ROE -MUSCL_FLOW= NO +MUSCL_FLOW= YES NUM_METHOD_GRAD= GREEN_GAUSS SLOPE_LIMITER_FLOW= VENKATAKRISHNAN_WANG VENKAT_LIMITER_COEFF= 0.1 @@ -54,7 +54,7 @@ CFL_NUMBER= 1000 CFL_ADAPT= NO % MGLEVEL= 3 -MGCYCLE= W_CYCLE +MGCYCLE= V_CYCLE MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) MG_POST_SMOOTH= ( 0, 0, 0, 0 ) MG_CORRECTION_SMOOTH= ( 0, 0, 0, 0 ) @@ -63,13 +63,13 @@ MG_DAMP_PROLONGATION= 0.7 % LINEAR_SOLVER= FGMRES -LINEAR_SOLVER_PREC= ILU -LINEAR_SOLVER_ERROR= 1.0e-6 -LINEAR_SOLVER_ITER= 25 +LINEAR_SOLVER_PREC= LU_SGS +LINEAR_SOLVER_ERROR= 0.1 +LINEAR_SOLVER_ITER= 5 % CONVERGENCE PARAMETERS % -ITER= 2500 +ITER= 100 CONV_FIELD= RMS_DENSITY CONV_RESIDUAL_MINVAL= -9 @@ -77,5 +77,5 @@ CONV_RESIDUAL_MINVAL= -9 % MESH_FILENAME= ../../euler/naca0012/mesh_NACA0012_inv.su2 MESH_FORMAT= SU2 -SCREEN_OUTPUT= (INNER_ITER, RMS_RES, LIFT, DRAG, MOMENT_X, MOMENT_Y, MOMENT_Z, LINSOL_RES, LINSOL_ITER) +SCREEN_OUTPUT= (INNER_ITER, RMS_RES, LIFT, DRAG, MOMENT_X, MOMENT_Y, MOMENT_Z, LINSOL) HISTORY_OUTPUT= (INNER_ITER, RMS_RES, AERO_COEFF) diff --git a/TestCases/py_wrapper/translating_NACA0012/forces_0.csv.ref b/TestCases/py_wrapper/translating_NACA0012/forces_0.csv.ref index 56ad73bb9aa8..d9998aced7cb 100644 --- a/TestCases/py_wrapper/translating_NACA0012/forces_0.csv.ref +++ b/TestCases/py_wrapper/translating_NACA0012/forces_0.csv.ref @@ -1,200 +1,200 @@ -199, -0.85, -0.00, 0.00 -0, -2.66, 18.33, 0.00 -1, -3.73, 25.70, 0.00 -2, -4.53, 31.27, 0.00 -3, -5.24, 36.23, 0.00 -4, -5.81, 40.33, 0.00 -5, -6.25, 43.55, 0.00 -6, -6.60, 46.13, 0.00 -7, -6.83, 47.96, 0.00 -8, -6.95, 49.09, 0.00 -9, -6.97, 49.54, 0.00 -10, -6.90, 49.35, 0.00 -11, -6.74, 48.57, 0.00 -12, -6.50, 47.14, 0.00 -13, -6.17, 45.13, 0.00 -14, -5.76, 42.53, 0.00 -15, -5.29, 39.38, 0.00 -16, -4.75, 35.75, 0.00 -17, -4.16, 31.65, 0.00 -18, -3.53, 27.09, 0.00 -19, -2.85, 22.14, 0.00 -20, -2.14, 16.79, 0.00 -21, -1.39, 11.10, 0.00 -22, -0.63, 5.06, 0.00 -23, 0.16, -1.33, 0.00 -24, 0.98, -8.10, 0.00 -25, 1.82, -15.27, 0.00 -26, 2.68, -22.82, 0.00 -27, 3.56, -30.76, 0.00 -28, 4.45, -39.00, 0.00 -29, 5.32, -47.44, 0.00 -30, 6.19, -56.07, 0.00 -31, 7.05, -64.97, 0.00 -32, 7.91, -74.28, 0.00 -33, 8.78, -83.97, 0.00 -34, 9.63, -93.91, 0.00 -35, 10.46, -104.09, 0.00 -36, 11.25, -114.37, 0.00 -37, 12.00, -124.73, 0.00 -38, 12.71, -135.28, 0.00 -39, 13.38, -145.98, 0.00 -40, 13.99, -156.79, 0.00 -41, 14.55, -167.72, 0.00 -42, 15.06, -178.80, 0.00 -43, 15.48, -189.92, 0.00 -44, 15.83, -201.03, 0.00 -45, 16.07, -211.97, 0.00 -46, 16.22, -222.82, 0.00 -47, 16.27, -233.68, 0.00 -48, 16.23, -244.83, 0.00 -49, 16.13, -256.65, 0.00 -50, 15.93, -269.12, 0.00 -51, 15.62, -282.01, 0.00 -52, 15.14, -294.70, 0.00 -53, 14.49, -307.24, 0.00 -54, 13.68, -319.91, 0.00 -55, 12.67, -332.16, 0.00 -56, 11.42, -342.95, 0.00 -57, 9.91, -351.31, 0.00 -58, 8.15, -356.48, 0.00 -59, 6.19, -358.24, 0.00 -60, 4.07, -357.17, 0.00 -61, 1.85, -353.80, 0.00 -62, -0.43, -348.10, 0.00 -63, -2.73, -340.32, 0.00 -64, -5.01, -331.03, 0.00 -65, -7.24, -320.26, 0.00 -66, -9.38, -308.18, 0.00 -67, -11.42, -295.32, 0.00 -68, -13.34, -281.72, 0.00 -69, -15.11, -267.62, 0.00 -70, -16.72, -253.15, 0.00 -71, -18.14, -238.20, 0.00 -72, -19.34, -222.69, 0.00 -73, -20.27, -206.50, 0.00 -74, -20.91, -189.85, 0.00 -75, -21.24, -172.83, 0.00 -76, -21.19, -155.22, 0.00 -77, -20.73, -137.21, 0.00 -78, -19.84, -118.97, 0.00 -79, -18.47, -100.51, 0.00 -80, -16.59, -82.08, 0.00 -81, -14.17, -63.76, 0.00 -82, -11.16, -45.67, 0.00 -83, -7.51, -27.92, 0.00 -84, -3.16, -10.66, 0.00 -85, 1.96, 5.99, 0.00 -86, 7.98, 21.97, 0.00 -87, 15.01, 37.12, 0.00 -88, 23.22, 51.25, 0.00 -89, 32.70, 63.95, 0.00 -90, 43.60, 74.81, 0.00 -91, 56.10, 83.39, 0.00 -92, 70.04, 88.70, 0.00 -93, 85.41, 90.05, 0.00 -94, 101.82, 86.49, 0.00 -95, 118.17, 76.97, 0.00 -96, 133.74, 61.30, 0.00 -97, 147.39, 39.89, 0.00 -98, 111.90, 15.02, 0.00 -99, 71.22, -0.00, 0.00 -100, 109.26, -14.66, 0.00 -101, 137.60, -37.24, 0.00 -102, 115.95, -53.15, 0.00 -103, 93.75, -61.06, 0.00 -104, 72.27, -61.39, 0.00 -105, 52.36, -55.20, 0.00 -106, 34.79, -44.05, 0.00 -107, 19.66, -29.23, 0.00 -108, 6.81, -11.68, 0.00 -109, -3.93, 7.68, 0.00 -110, -12.86, 28.37, 0.00 -111, -20.21, 49.96, 0.00 -112, -26.23, 72.22, 0.00 -113, -31.05, 94.79, 0.00 -114, -34.88, 117.65, 0.00 -115, -37.90, 140.89, 0.00 -116, -40.20, 164.49, 0.00 -117, -41.88, 188.42, 0.00 -118, -43.00, 212.71, 0.00 -119, -43.62, 237.42, 0.00 -120, -43.64, 261.69, 0.00 -121, -43.10, 285.24, 0.00 -122, -42.11, 308.46, 0.00 -123, -40.72, 331.35, 0.00 -124, -38.94, 353.54, 0.00 -125, -36.84, 375.42, 0.00 -126, -34.48, 397.10, 0.00 -127, -31.85, 418.29, 0.00 -128, -28.97, 438.71, 0.00 -129, -25.85, 458.00, 0.00 -130, -22.55, 476.33, 0.00 -131, -19.10, 493.80, 0.00 -132, -15.54, 510.37, 0.00 -133, -11.90, 526.39, 0.00 -134, -8.20, 541.54, 0.00 -135, -4.46, 556.04, 0.00 -136, -0.70, 570.26, 0.00 -137, 3.05, 583.60, 0.00 -138, 6.79, 596.04, 0.00 -139, 10.50, 608.18, 0.00 -140, 14.17, 619.60, 0.00 -141, 17.77, 629.84, 0.00 -142, 21.29, 639.37, 0.00 -143, 24.72, 648.06, 0.00 -144, 28.03, 655.33, 0.00 -145, 31.19, 661.08, 0.00 -146, 34.20, 665.74, 0.00 -147, 37.05, 669.08, 0.00 -148, 39.71, 670.85, 0.00 -149, 42.17, 671.22, 0.00 -150, 44.38, 669.34, 0.00 -151, 46.26, 664.42, 0.00 -152, 47.51, 652.70, 0.00 -153, 46.78, 616.94, 0.00 -154, 39.70, 504.23, 0.00 -155, 24.94, 305.93, 0.00 -156, 16.44, 195.28, 0.00 -157, 13.94, 160.59, 0.00 -158, 13.18, 147.63, 0.00 -159, 12.74, 138.97, 0.00 -160, 12.29, 130.81, 0.00 -161, 11.80, 122.63, 0.00 -162, 11.26, 114.42, 0.00 -163, 10.66, 106.07, 0.00 -164, 10.01, 97.60, 0.00 -165, 9.32, 89.11, 0.00 -166, 8.57, 80.48, 0.00 -167, 7.78, 71.77, 0.00 -168, 6.96, 63.07, 0.00 -169, 6.10, 54.40, 0.00 -170, 5.22, 45.80, 0.00 -171, 4.33, 37.37, 0.00 -172, 3.44, 29.24, 0.00 -173, 2.56, 21.44, 0.00 -174, 1.69, 13.95, 0.00 -175, 0.83, 6.81, 0.00 -176, 0.01, 0.05, 0.00 -177, -0.80, -6.35, 0.00 -178, -1.58, -12.38, 0.00 -179, -2.32, -18.05, 0.00 -180, -3.04, -23.33, 0.00 -181, -3.71, -28.22, 0.00 -182, -4.34, -32.66, 0.00 -183, -4.92, -36.62, 0.00 -184, -5.43, -40.09, 0.00 -185, -5.87, -42.98, 0.00 -186, -6.24, -45.27, 0.00 -187, -6.52, -46.94, 0.00 -188, -6.70, -47.94, 0.00 -189, -6.80, -48.33, 0.00 -190, -6.80, -48.04, 0.00 -191, -6.70, -47.05, 0.00 -192, -6.48, -45.33, 0.00 -193, -6.15, -42.84, 0.00 -194, -5.72, -39.70, 0.00 -195, -5.15, -35.65, 0.00 -196, -4.45, -30.72, 0.00 -197, -3.65, -25.15, 0.00 -198, -2.59, -17.80, 0.00 +199, -0.95, -0.00, 0.00 +0, -2.89, 19.93, 0.00 +1, -4.16, 28.63, 0.00 +2, -5.19, 35.84, 0.00 +3, -6.11, 42.27, 0.00 +4, -6.89, 47.83, 0.00 +5, -7.53, 52.42, 0.00 +6, -8.06, 56.37, 0.00 +7, -8.47, 59.49, 0.00 +8, -8.76, 61.87, 0.00 +9, -8.94, 63.52, 0.00 +10, -9.02, 64.50, 0.00 +11, -9.01, 64.87, 0.00 +12, -8.90, 64.57, 0.00 +13, -8.70, 63.67, 0.00 +14, -8.42, 62.15, 0.00 +15, -8.06, 60.06, 0.00 +16, -7.64, 57.51, 0.00 +17, -7.16, 54.41, 0.00 +18, -6.62, 50.82, 0.00 +19, -6.02, 46.77, 0.00 +20, -5.38, 42.25, 0.00 +21, -4.69, 37.33, 0.00 +22, -3.97, 31.98, 0.00 +23, -3.21, 26.23, 0.00 +24, -2.43, 20.13, 0.00 +25, -1.63, 13.66, 0.00 +26, -0.80, 6.84, 0.00 +27, 0.03, -0.29, 0.00 +28, 0.88, -7.75, 0.00 +29, 1.74, -15.50, 0.00 +30, 2.60, -23.53, 0.00 +31, 3.45, -31.83, 0.00 +32, 4.31, -40.43, 0.00 +33, 5.15, -49.28, 0.00 +34, 5.98, -58.35, 0.00 +35, 6.80, -67.68, 0.00 +36, 7.60, -77.26, 0.00 +37, 8.37, -87.01, 0.00 +38, 9.12, -97.01, 0.00 +39, 9.83, -107.21, 0.00 +40, 10.49, -117.56, 0.00 +41, 11.11, -128.08, 0.00 +42, 11.69, -138.80, 0.00 +43, 12.20, -149.69, 0.00 +44, 12.65, -160.70, 0.00 +45, 13.03, -171.78, 0.00 +46, 13.32, -182.92, 0.00 +47, 13.52, -194.12, 0.00 +48, 13.61, -205.31, 0.00 +49, 13.60, -216.52, 0.00 +50, 13.47, -227.51, 0.00 +51, 13.18, -238.10, 0.00 +52, 12.75, -248.28, 0.00 +53, 12.23, -259.17, 0.00 +54, 11.51, -269.17, 0.00 +55, 10.25, -268.73, 0.00 +56, 8.38, -251.80, 0.00 +57, 7.08, -251.06, 0.00 +58, 7.58, -331.40, 0.00 +59, 7.34, -425.09, 0.00 +60, 5.05, -443.58, 0.00 +61, 2.27, -434.14, 0.00 +62, -0.52, -424.59, 0.00 +63, -3.33, -414.88, 0.00 +64, -6.11, -403.87, 0.00 +65, -8.85, -391.44, 0.00 +66, -11.50, -377.71, 0.00 +67, -14.04, -363.05, 0.00 +68, -16.44, -347.37, 0.00 +69, -18.68, -330.91, 0.00 +70, -20.72, -313.80, 0.00 +71, -22.54, -296.04, 0.00 +72, -24.12, -277.82, 0.00 +73, -25.43, -259.16, 0.00 +74, -26.46, -240.22, 0.00 +75, -27.16, -221.02, 0.00 +76, -27.48, -201.33, 0.00 +77, -27.42, -181.48, 0.00 +78, -26.96, -161.64, 0.00 +79, -26.03, -141.69, 0.00 +80, -24.63, -121.84, 0.00 +81, -22.68, -102.06, 0.00 +82, -20.15, -82.45, 0.00 +83, -16.97, -63.10, 0.00 +84, -13.07, -44.09, 0.00 +85, -8.36, -25.53, 0.00 +86, -2.73, -7.52, 0.00 +87, 3.97, 9.81, 0.00 +88, 11.89, 26.25, 0.00 +89, 21.22, 41.51, 0.00 +90, 32.12, 55.12, 0.00 +91, 44.88, 66.72, 0.00 +92, 59.51, 75.37, 0.00 +93, 76.12, 80.27, 0.00 +94, 94.45, 80.24, 0.00 +95, 113.03, 73.62, 0.00 +96, 129.92, 59.55, 0.00 +97, 142.64, 38.61, 0.00 +98, 108.56, 14.57, 0.00 +99, 69.98, -0.00, 0.00 +100, 103.93, -13.95, 0.00 +101, 125.25, -33.90, 0.00 +102, 102.02, -46.76, 0.00 +103, 77.51, -50.49, 0.00 +104, 53.83, -45.73, 0.00 +105, 32.59, -34.37, 0.00 +106, 14.60, -18.48, 0.00 +107, -0.30, 0.44, 0.00 +108, -12.53, 21.51, 0.00 +109, -22.47, 43.94, 0.00 +110, -30.49, 67.29, 0.00 +111, -36.85, 91.11, 0.00 +112, -41.91, 115.39, 0.00 +113, -45.81, 139.82, 0.00 +114, -48.77, 164.48, 0.00 +115, -50.93, 189.36, 0.00 +116, -52.38, 214.32, 0.00 +117, -53.20, 239.37, 0.00 +118, -53.43, 264.32, 0.00 +119, -53.12, 289.11, 0.00 +120, -52.35, 313.88, 0.00 +121, -51.12, 338.31, 0.00 +122, -49.52, 362.75, 0.00 +123, -47.56, 387.00, 0.00 +124, -45.22, 410.58, 0.00 +125, -42.59, 434.00, 0.00 +126, -39.71, 457.30, 0.00 +127, -36.56, 480.08, 0.00 +128, -33.16, 502.25, 0.00 +129, -29.56, 523.72, 0.00 +130, -25.78, 544.66, 0.00 +131, -21.86, 565.07, 0.00 +132, -17.80, 584.72, 0.00 +133, -13.65, 603.83, 0.00 +134, -9.41, 621.93, 0.00 +135, -5.12, 639.20, 0.00 +136, -0.81, 656.06, 0.00 +137, 3.51, 671.80, 0.00 +138, 7.82, 686.38, 0.00 +139, 12.10, 700.45, 0.00 +140, 16.32, 713.56, 0.00 +141, 20.46, 725.19, 0.00 +142, 24.51, 736.06, 0.00 +143, 28.46, 746.15, 0.00 +144, 32.29, 754.94, 0.00 +145, 35.97, 762.42, 0.00 +146, 39.51, 769.08, 0.00 +147, 42.90, 774.72, 0.00 +148, 46.11, 779.11, 0.00 +149, 49.18, 782.75, 0.00 +150, 52.06, 785.17, 0.00 +151, 54.77, 786.61, 0.00 +152, 57.30, 787.12, 0.00 +153, 59.67, 786.85, 0.00 +154, 61.83, 785.26, 0.00 +155, 63.48, 778.68, 0.00 +156, 67.01, 795.78, 0.00 +157, 59.18, 681.93, 0.00 +158, 2.62, 29.33, 0.00 +159, -2.31, -25.18, 0.00 +160, 0.55, 5.86, 0.00 +161, 0.34, 3.53, 0.00 +162, 0.33, 3.30, 0.00 +163, 0.29, 2.87, 0.00 +164, 0.12, 1.20, 0.00 +165, -0.13, -1.27, 0.00 +166, -0.46, -4.36, 0.00 +167, -0.86, -7.92, 0.00 +168, -1.30, -11.82, 0.00 +169, -1.79, -15.99, 0.00 +170, -2.32, -20.31, 0.00 +171, -2.86, -24.72, 0.00 +172, -3.42, -29.14, 0.00 +173, -4.00, -33.56, 0.00 +174, -4.58, -37.85, 0.00 +175, -5.15, -41.99, 0.00 +176, -5.71, -46.00, 0.00 +177, -6.25, -49.75, 0.00 +178, -6.77, -53.23, 0.00 +179, -7.26, -56.43, 0.00 +180, -7.72, -59.27, 0.00 +181, -8.13, -61.77, 0.00 +182, -8.49, -63.87, 0.00 +183, -8.79, -65.51, 0.00 +184, -9.04, -66.76, 0.00 +185, -9.23, -67.51, 0.00 +186, -9.33, -67.71, 0.00 +187, -9.36, -67.37, 0.00 +188, -9.29, -66.42, 0.00 +189, -9.14, -64.91, 0.00 +190, -8.89, -62.78, 0.00 +191, -8.54, -59.98, 0.00 +192, -8.08, -56.48, 0.00 +193, -7.50, -52.21, 0.00 +194, -6.82, -47.34, 0.00 +195, -6.01, -41.55, 0.00 +196, -5.06, -34.95, 0.00 +197, -4.01, -27.61, 0.00 +198, -2.73, -18.81, 0.00 diff --git a/TestCases/py_wrapper/updated_moving_frame_NACA12/config.cfg b/TestCases/py_wrapper/updated_moving_frame_NACA12/config.cfg index 449248bf1695..7417a173e403 100644 --- a/TestCases/py_wrapper/updated_moving_frame_NACA12/config.cfg +++ b/TestCases/py_wrapper/updated_moving_frame_NACA12/config.cfg @@ -54,7 +54,12 @@ CFL_NUMBER= 1e3 CFL_ADAPT= NO % MGLEVEL= 3 -MGCYCLE= W_CYCLE +MGCYCLE= V_CYCLE +MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) +MG_POST_SMOOTH= ( 0, 0, 0, 0 ) +MG_CORRECTION_SMOOTH= ( 0, 0, 0, 0 ) +MG_DAMP_RESTRICTION= 0.7 +MG_DAMP_PROLONGATION= 0.7 % LINEAR_SOLVER= FGMRES LINEAR_SOLVER_PREC= ILU diff --git a/TestCases/rotating/naca0012/rot_NACA0012.cfg b/TestCases/rotating/naca0012/rot_NACA0012.cfg index 54fbc87e5aea..6584205176b5 100644 --- a/TestCases/rotating/naca0012/rot_NACA0012.cfg +++ b/TestCases/rotating/naca0012/rot_NACA0012.cfg @@ -52,7 +52,7 @@ MARKER_DESIGNING = ( airfoil ) % ------------- COMMON PARAMETERS TO DEFINE THE NUMERICAL METHOD --------------% % NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES -CFL_NUMBER= 1e4 +CFL_NUMBER= 100 CFL_ADAPT= NO CFL_ADAPT_PARAM= ( 1.5, 0.5, 1.0, 100.0 ) RK_ALPHA_COEFF= ( 0.66667, 0.66667, 1.000000 ) diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index a50b91aa9ea1..ebedcc2e2356 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -93,7 +93,7 @@ def main(): channel.cfg_dir = "euler/channel" channel.cfg_file = "inv_channel_RK.cfg" channel.test_iter = 10 - channel.test_vals = [-2.691364, 2.781660, -0.009405, 0.011874] + channel.test_vals = [-2.691660, 2.781413, -0.009401, 0.011862] test_list.append(channel) # NACA0012 @@ -101,7 +101,7 @@ def main(): naca0012.cfg_dir = "euler/naca0012" naca0012.cfg_file = "inv_NACA0012_Roe.cfg" naca0012.test_iter = 20 - naca0012.test_vals = [-4.431325, -3.970055, 0.319205, 0.022299] + naca0012.test_vals = [-4.766184, -4.287722, 0.326688, 0.022661] test_list.append(naca0012) # Supersonic wedge @@ -109,7 +109,7 @@ def main(): wedge.cfg_dir = "euler/wedge" wedge.cfg_file = "inv_wedge_HLLC.cfg" wedge.test_iter = 20 - wedge.test_vals = [-1.368091, 4.302736, -0.243433, 0.042906] + wedge.test_vals = [-1.379426, 4.288828, -0.245341, 0.043244] test_list.append(wedge) # ONERA M6 Wing @@ -117,7 +117,7 @@ def main(): oneram6.cfg_dir = "euler/oneram6" oneram6.cfg_file = "inv_ONERAM6.cfg" oneram6.test_iter = 10 - oneram6.test_vals = [-11.510606, -10.980023, 0.280800, 0.008623] + oneram6.test_vals = [-11.498143, -10.969216, 0.280800, 0.008623] oneram6.timeout = 9600 test_list.append(oneram6) @@ -126,7 +126,7 @@ def main(): fixedCL_naca0012.cfg_dir = "fixed_cl/naca0012" fixedCL_naca0012.cfg_file = "inv_NACA0012.cfg" fixedCL_naca0012.test_iter = 10 - fixedCL_naca0012.test_vals = [-3.848561, 1.688373, 0.301145, 0.019489] + fixedCL_naca0012.test_vals = [-3.837516, 1.700577, 0.301169, 0.019490] test_list.append(fixedCL_naca0012) # Polar sweep of the inviscid NACA0012 @@ -135,7 +135,7 @@ def main(): polar_naca0012.cfg_file = "inv_NACA0012.cfg" polar_naca0012.polar = True polar_naca0012.test_iter = 10 - polar_naca0012.test_vals = [-1.067859, 4.397227, 0.000060, 0.031134] + polar_naca0012.test_vals = [-1.077848, 4.386916, -0.000333, 0.029678] polar_naca0012.test_vals_aarch64 = [-1.063447, 4.401847, 0.000291, 0.031696] polar_naca0012.command = TestCase.Command(exec = "compute_polar.py", param = "-n 1 -i 11") # flaky test on arm64 @@ -147,7 +147,7 @@ def main(): bluntbody.cfg_dir = "euler/bluntbody" bluntbody.cfg_file = "blunt.cfg" bluntbody.test_iter = 20 - bluntbody.test_vals = [0.493297, 6.857373, -0.000026, 1.791394] + bluntbody.test_vals = [0.475378, 6.834898, 0.000000, 1.783956] test_list.append(bluntbody) ########################## @@ -166,7 +166,7 @@ def main(): flatplate.cfg_dir = "navierstokes/flatplate" flatplate.cfg_file = "lam_flatplate.cfg" flatplate.test_iter = 20 - flatplate.test_vals = [-5.097707, 0.381809, 0.001324, 0.027932, 2.361600, -2.333600, 0, 0] + flatplate.test_vals = [-5.097199, 0.382306, 0.001326, 0.027904, 2.361500, -2.333600, 0.000000, 0.000000] test_list.append(flatplate) # Laminar cylinder (steady) @@ -242,7 +242,7 @@ def main(): turb_flatplate.cfg_dir = "rans/flatplate" turb_flatplate.cfg_file = "turb_SA_flatplate.cfg" turb_flatplate.test_iter = 20 - turb_flatplate.test_vals = [-4.312724, -6.737976, -0.187467, 0.057468] + turb_flatplate.test_vals = [-4.316135, -6.737979, -0.187461, 0.057468] test_list.append(turb_flatplate) # FLAT PLATE, WALL FUNCTIONS, COMPRESSIBLE SST @@ -250,7 +250,7 @@ def main(): turb_wallfunction_flatplate_sst.cfg_dir = "wallfunctions/flatplate/compressible_SST" turb_wallfunction_flatplate_sst.cfg_file = "turb_SST_flatplate.cfg" turb_wallfunction_flatplate_sst.test_iter = 10 - turb_wallfunction_flatplate_sst.test_vals = [-4.541884, -1.933249, -1.940974, 0.941214, -1.608738, 1.485909, 10.000000, -1.747280, 0.034237, 0.002426] + turb_wallfunction_flatplate_sst.test_vals = [-4.587729, -1.908761, -1.968077, 0.903297, -1.608475, 1.497162, 10.000000, -1.733571, 0.033374, 0.002430] test_list.append(turb_wallfunction_flatplate_sst) # FLAT PLATE, WALL FUNCTIONS, COMPRESSIBLE SA @@ -258,7 +258,7 @@ def main(): turb_wallfunction_flatplate_sa.cfg_dir = "wallfunctions/flatplate/compressible_SA" turb_wallfunction_flatplate_sa.cfg_file = "turb_SA_flatplate.cfg" turb_wallfunction_flatplate_sa.test_iter = 10 - turb_wallfunction_flatplate_sa.test_vals = [-4.460657, -2.033641, -2.118149, 0.889562, -5.382249, 10.000000, -1.517453, 0.034213, 0.002636] + turb_wallfunction_flatplate_sa.test_vals = [-4.487562, -2.016144, -2.169439, 0.834724, -5.382532, 10.000000, -1.508186, 0.034484, 0.002639] test_list.append(turb_wallfunction_flatplate_sa) # ONERA M6 Wing @@ -266,7 +266,7 @@ def main(): turb_oneram6.cfg_dir = "rans/oneram6" turb_oneram6.cfg_file = "turb_ONERAM6.cfg" turb_oneram6.test_iter = 10 - turb_oneram6.test_vals = [-2.408533, -6.662837, 0.238334, 0.158910, 0] + turb_oneram6.test_vals = [-2.408685, -6.662908, 0.238580, 0.158968, 0.000000] turb_oneram6.timeout = 3200 test_list.append(turb_oneram6) @@ -335,7 +335,7 @@ def main(): axi_rans_air_nozzle_restart.cfg_dir = "axisymmetric_rans/air_nozzle" axi_rans_air_nozzle_restart.cfg_file = "air_nozzle_restart.cfg" axi_rans_air_nozzle_restart.test_iter = 10 - axi_rans_air_nozzle_restart.test_vals = [-12.067037, -6.840810, -8.843191, -3.783401, 0.000000] + axi_rans_air_nozzle_restart.test_vals = [-12.067274, -6.841605, -8.843340, -3.783551, 0.000000] axi_rans_air_nozzle_restart.test_vals_aarch64 = [-12.067037, -6.840810, -8.843191, -3.783401, 0.000000] axi_rans_air_nozzle_restart.tol = 0.0001 test_list.append(axi_rans_air_nozzle_restart) @@ -371,7 +371,7 @@ def main(): inc_euler_naca0012.cfg_dir = "incomp_euler/naca0012" inc_euler_naca0012.cfg_file = "incomp_NACA0012.cfg" inc_euler_naca0012.test_iter = 20 - inc_euler_naca0012.test_vals = [-7.128795, -6.375403, 0.531980, 0.008467] + inc_euler_naca0012.test_vals = [-7.140809, -6.485990, 0.531993, 0.008466] test_list.append(inc_euler_naca0012) # C-D nozzle with pressure inlet and mass flow outlet @@ -379,7 +379,7 @@ def main(): inc_nozzle.cfg_dir = "incomp_euler/nozzle" inc_nozzle.cfg_file = "inv_nozzle.cfg" inc_nozzle.test_iter = 20 - inc_nozzle.test_vals = [-6.363763, -5.566528, -0.005348, 0.126610] + inc_nozzle.test_vals = [-6.623301, -5.844127, -0.023181, 0.126370] test_list.append(inc_nozzle) ############################# @@ -422,7 +422,7 @@ def main(): inc_lam_bend.cfg_dir = "incomp_navierstokes/bend" inc_lam_bend.cfg_file = "lam_bend.cfg" inc_lam_bend.test_iter = 10 - inc_lam_bend.test_vals = [-3.558881, -3.234611, -0.016265, 1.024052] + inc_lam_bend.test_vals = [-3.647474, -3.230291, -0.016108, 1.085750] test_list.append(inc_lam_bend) ############################ @@ -457,7 +457,7 @@ def main(): inc_turb_wallfunction_flatplate_sst.cfg_dir = "wallfunctions/flatplate/incompressible_SST" inc_turb_wallfunction_flatplate_sst.cfg_file = "turb_SST_flatplate.cfg" inc_turb_wallfunction_flatplate_sst.test_iter = 10 - inc_turb_wallfunction_flatplate_sst.test_vals = [-6.512787, -5.722412, -6.414362, -4.223877, -7.162308, -2.044027, 10.000000, -3.059125, 0.001126, 0.003161, 0.000000] + inc_turb_wallfunction_flatplate_sst.test_vals = [-6.881306, -5.729111, -6.724803, -4.242636, -7.162846, -2.044959, 10.000000, -2.877924, 0.001151, 0.003161, 0.000000] test_list.append(inc_turb_wallfunction_flatplate_sst) # FLAT PLATE, WALL FUNCTIONS, INCOMPRESSIBLE SA @@ -465,7 +465,7 @@ def main(): inc_turb_wallfunction_flatplate_sa.cfg_dir = "wallfunctions/flatplate/incompressible_SA" inc_turb_wallfunction_flatplate_sa.cfg_file = "turb_SA_flatplate.cfg" inc_turb_wallfunction_flatplate_sa.test_iter = 10 - inc_turb_wallfunction_flatplate_sa.test_vals = [-6.521493, -5.710967, -6.424313, -4.224459, -9.586823, 10.000000, -3.054800, 0.000999, 0.003759] + inc_turb_wallfunction_flatplate_sa.test_vals = [-6.894429, -5.717193, -6.743475, -4.242550, -9.587276, 10.000000, -2.879802, 0.001021, 0.003759] test_list.append(inc_turb_wallfunction_flatplate_sa) #################### @@ -558,7 +558,7 @@ def main(): schubauer_klebanoff_transition.cfg_dir = "transition/Schubauer_Klebanoff" schubauer_klebanoff_transition.cfg_file = "transitional_BC_model_ConfigFile.cfg" schubauer_klebanoff_transition.test_iter = 10 - schubauer_klebanoff_transition.test_vals = [-8.087369, -13.241874, 0.000055, 0.007992] + schubauer_klebanoff_transition.test_vals = [-8.284308, -13.240273, 0.000057, 0.007982] test_list.append(schubauer_klebanoff_transition) ##################################### @@ -602,7 +602,7 @@ def main(): contadj_fixedCL_naca0012.cfg_dir = "fixed_cl/naca0012" contadj_fixedCL_naca0012.cfg_file = "inv_NACA0012_ContAdj.cfg" contadj_fixedCL_naca0012.test_iter = 100 - contadj_fixedCL_naca0012.test_vals = [0.755070, -4.794630, -0.525290, -0.000238] + contadj_fixedCL_naca0012.test_vals = [0.754936, -4.793625, -0.524550, -0.000227] test_list.append(contadj_fixedCL_naca0012) ################################### @@ -721,7 +721,7 @@ def main(): harmonic_balance.cfg_dir = "harmonic_balance" harmonic_balance.cfg_file = "HB.cfg" harmonic_balance.test_iter = 25 - harmonic_balance.test_vals = [-1.554985, 0.831796, 0.935729, 3.960210] + harmonic_balance.test_vals = [-1.559187, 0.829575, 0.931512, 3.954440] test_list.append(harmonic_balance) # Turbulent pitching NACA 64a010 airfoil @@ -729,7 +729,7 @@ def main(): hb_rans_preconditioning.cfg_dir = "harmonic_balance/hb_rans_preconditioning" hb_rans_preconditioning.cfg_file = "davis.cfg" hb_rans_preconditioning.test_iter = 25 - hb_rans_preconditioning.test_vals = [-1.902097, 0.484069, 0.601483, 3.609005, -5.949359] + hb_rans_preconditioning.test_vals = [-1.902097, 0.484069, 0.601483, 3.609005, -5.949355] test_list.append(hb_rans_preconditioning) ###################################### @@ -741,7 +741,7 @@ def main(): rot_naca0012.cfg_dir = "rotating/naca0012" rot_naca0012.cfg_file = "rot_NACA0012.cfg" rot_naca0012.test_iter = 25 - rot_naca0012.test_vals = [-2.738864, 2.811401, -0.080279, 0.002160] + rot_naca0012.test_vals = [-2.610126, 2.922809, -0.080488, 0.002170] test_list.append(rot_naca0012) # Lid-driven cavity @@ -778,7 +778,7 @@ def main(): sine_gust.cfg_dir = "gust" sine_gust.cfg_file = "inv_gust_NACA0012.cfg" sine_gust.test_iter = 5 - sine_gust.test_vals = [-1.977514, 3.481817, -0.010465, -0.007859] + sine_gust.test_vals = [-1.977498, 3.481817, -0.010657, -0.007976] sine_gust.unsteady = True test_list.append(sine_gust) @@ -787,7 +787,7 @@ def main(): aeroelastic.cfg_dir = "aeroelastic" aeroelastic.cfg_file = "aeroelastic_NACA64A010.cfg" aeroelastic.test_iter = 2 - aeroelastic.test_vals = [0.074291, 0.027620, -0.001641, -0.000128] + aeroelastic.test_vals = [0.074208, 0.027599, -0.001641, -0.000128] aeroelastic.unsteady = True test_list.append(aeroelastic) @@ -796,7 +796,7 @@ def main(): ddes_flatplate.cfg_dir = "ddes/flatplate" ddes_flatplate.cfg_file = "ddes_flatplate.cfg" ddes_flatplate.test_iter = 10 - ddes_flatplate.test_vals = [-2.714786, -5.882646, -0.215041, 0.023758, 0] + ddes_flatplate.test_vals = [-2.714713, -5.788301, -0.214960, 0.023758, 0.000000] ddes_flatplate.unsteady = True test_list.append(ddes_flatplate) @@ -814,7 +814,7 @@ def main(): unst_deforming_naca0012.cfg_dir = "disc_adj_euler/naca0012_pitching_def" unst_deforming_naca0012.cfg_file = "inv_NACA0012_pitching_deform.cfg" unst_deforming_naca0012.test_iter = 5 - unst_deforming_naca0012.test_vals = [-3.665187, -3.793258, -3.716457, -3.148323] + unst_deforming_naca0012.test_vals = [-3.665152, -3.793306, -3.716483, -3.148336] unst_deforming_naca0012.unsteady = True test_list.append(unst_deforming_naca0012) @@ -827,7 +827,7 @@ def main(): ls89_sa.cfg_dir = "nicf/LS89" ls89_sa.cfg_file = "turb_SA_PR.cfg" ls89_sa.test_iter = 20 - ls89_sa.test_vals = [-5.050483, -13.371791, 0.174939, 0.430757] + ls89_sa.test_vals = [-5.050483, -13.371790, 0.174939, 0.430757] test_list.append(ls89_sa) # Rarefaction shock wave edge_VW @@ -835,7 +835,7 @@ def main(): edge_VW.cfg_dir = "nicf/edge" edge_VW.cfg_file = "edge_VW.cfg" edge_VW.test_iter = 20 - edge_VW.test_vals = [-0.768929, 5.433202, -0.000628, 0.000000] + edge_VW.test_vals = [-0.772250, 5.429879, -0.000470, 0.000000] test_list.append(edge_VW) # Rarefaction shock wave edge_PPR @@ -843,7 +843,7 @@ def main(): edge_PPR.cfg_dir = "nicf/edge" edge_PPR.cfg_file = "edge_PPR.cfg" edge_PPR.test_iter = 20 - edge_PPR.test_vals = [-2.017812, 4.174560, 0.000019, 0.000000] + edge_PPR.test_vals = [-2.126694, 4.066051, -0.000013, 0.000000] test_list.append(edge_PPR) @@ -910,7 +910,7 @@ def main(): uniform_flow.cfg_dir = "sliding_interface/uniform_flow" uniform_flow.cfg_file = "uniform_NN.cfg" uniform_flow.test_iter = 2 - uniform_flow.test_vals = [2.000000, 0.000000, -0.202598, -13.248144] + uniform_flow.test_vals = [2.000000, 0.000000, -0.230641, -13.250022] uniform_flow.tol = 0.000001 uniform_flow.unsteady = True uniform_flow.multizone = True @@ -921,7 +921,7 @@ def main(): channel_2D.cfg_dir = "sliding_interface/channel_2D" channel_2D.cfg_file = "channel_2D_WA.cfg" channel_2D.test_iter = 2 - channel_2D.test_vals = [2.000000, 0.000000, 0.417404, 0.350501, 0.401519] + channel_2D.test_vals = [2.000000, 0.000000, 0.464920, 0.348054, 0.397553] channel_2D.timeout = 100 channel_2D.unsteady = True channel_2D.multizone = True @@ -932,7 +932,7 @@ def main(): channel_3D.cfg_dir = "sliding_interface/channel_3D" channel_3D.cfg_file = "channel_3D_WA.cfg" channel_3D.test_iter = 1 - channel_3D.test_vals = [1.000000, 0.000000, 0.656358, 0.766909, 0.690972] + channel_3D.test_vals = [1.000000, 0.000000, 0.611989, 0.798999, 0.702438] channel_3D.unsteady = True channel_3D.multizone = True test_list.append(channel_3D) @@ -942,7 +942,7 @@ def main(): pipe.cfg_dir = "sliding_interface/pipe" pipe.cfg_file = "pipe_NN.cfg" pipe.test_iter = 2 - pipe.test_vals = [0.477630, 0.641341, 0.983336, 1.018856] + pipe.test_vals = [0.547322, 0.655095, 0.968232, 1.049121] pipe.unsteady = True pipe.multizone = True test_list.append(pipe) @@ -952,7 +952,7 @@ def main(): rotating_cylinders.cfg_dir = "sliding_interface/rotating_cylinders" rotating_cylinders.cfg_file = "rot_cylinders_WA.cfg" rotating_cylinders.test_iter = 3 - rotating_cylinders.test_vals = [3.000000, 0.000000, 0.719778, 1.111044, 1.154068] + rotating_cylinders.test_vals = [3.000000, 0.000000, 0.717067, 1.119816, 1.160327] rotating_cylinders.unsteady = True rotating_cylinders.multizone = True test_list.append(rotating_cylinders) @@ -962,7 +962,7 @@ def main(): supersonic_vortex_shedding.cfg_dir = "sliding_interface/supersonic_vortex_shedding" supersonic_vortex_shedding.cfg_file = "sup_vor_shed_WA.cfg" supersonic_vortex_shedding.test_iter = 5 - supersonic_vortex_shedding.test_vals = [5.000000, 0.000000, 1.206774, 1.053444] + supersonic_vortex_shedding.test_vals = [5.000000, 0.000000, 1.207119, 1.065262] supersonic_vortex_shedding.unsteady = True supersonic_vortex_shedding.multizone = True test_list.append(supersonic_vortex_shedding) @@ -1040,7 +1040,7 @@ def main(): fsi2d.cfg_dir = "fea_fsi/WallChannel_2d" fsi2d.cfg_file = "configFSI.cfg" fsi2d.test_iter = 4 - fsi2d.test_vals = [4.000000, 0.000000, -3.726050, -4.277800] + fsi2d.test_vals = [4.000000, 0.000000, -3.726014, -4.277767] fsi2d.multizone = True fsi2d.unsteady = True test_list.append(fsi2d) @@ -1050,7 +1050,7 @@ def main(): stat_fsi.cfg_dir = "fea_fsi/stat_fsi" stat_fsi.cfg_file = "config.cfg" stat_fsi.test_iter = 7 - stat_fsi.test_vals = [-3.343487, -4.993604, 0.000000, 7.000000] + stat_fsi.test_vals = [-3.336320, -4.991964, 0.000000, 7.000000] stat_fsi.multizone = True test_list.append(stat_fsi) @@ -1059,7 +1059,7 @@ def main(): stat_fsi_restart.cfg_dir = "fea_fsi/stat_fsi" stat_fsi_restart.cfg_file = "config_restart.cfg" stat_fsi_restart.test_iter = 1 - stat_fsi_restart.test_vals = [-3.405333, -4.327317, 0.000000, 26.000000] + stat_fsi_restart.test_vals = [-3.401553, -4.672932, 0.000000, 26.000000] stat_fsi_restart.multizone = True test_list.append(stat_fsi_restart) @@ -1068,7 +1068,7 @@ def main(): dyn_fsi.cfg_dir = "fea_fsi/dyn_fsi" dyn_fsi.cfg_file = "config.cfg" dyn_fsi.test_iter = 4 - dyn_fsi.test_vals = [-4.330908, -4.153034, 0.000000, 86.000000] + dyn_fsi.test_vals = [-4.330728, -4.152995, 0.000000, 85.000000] dyn_fsi.multizone = True dyn_fsi.unsteady = True test_list.append(dyn_fsi) @@ -1079,7 +1079,7 @@ def main(): airfoilRBF.cfg_file = "config.cfg" airfoilRBF.test_iter = 1 - airfoilRBF.test_vals = [1.000000, 0.087829, -3.377221] + airfoilRBF.test_vals = [1.000000, 0.086004, -3.365759] airfoilRBF.tol = 0.0001 airfoilRBF.multizone = True test_list.append(airfoilRBF) @@ -1477,7 +1477,7 @@ def main(): opt_multiobj1surf_py.cfg_dir = "optimization_euler/multiobjective_wedge" opt_multiobj1surf_py.cfg_file = "inv_wedge_ROE_multiobj_1surf.cfg" opt_multiobj1surf_py.test_iter = 1 - opt_multiobj1surf_py.test_vals = [1.000000, 1.000000, 36.139240, 4.307073] + opt_multiobj1surf_py.test_vals = [1.000000, 1.000000, 36.122920, 4.611743] opt_multiobj1surf_py.command = TestCase.Command(exec = "shape_optimization.py", param = "-g CONTINUOUS_ADJOINT -f") opt_multiobj1surf_py.timeout = 1600 opt_multiobj1surf_py.tol = 0.00001 @@ -1490,7 +1490,7 @@ def main(): opt_2surf1obj_py.cfg_dir = "optimization_euler/multiobjective_wedge" opt_2surf1obj_py.cfg_file = "inv_wedge_ROE_2surf_1obj.cfg" opt_2surf1obj_py.test_iter = 1 - opt_2surf1obj_py.test_vals = [1.000000, 1.000000, 2.005099, 0.000358] + opt_2surf1obj_py.test_vals = [1.000000, 1.000000, 2.005099, 0.000383] opt_2surf1obj_py.command = TestCase.Command(exec = "shape_optimization.py", param = "-g CONTINUOUS_ADJOINT -f") opt_2surf1obj_py.timeout = 1600 opt_2surf1obj_py.tol = 0.00001 @@ -1507,7 +1507,7 @@ def main(): pywrapper_naca0012.cfg_dir = "euler/naca0012" pywrapper_naca0012.cfg_file = "inv_NACA0012_Roe.cfg" pywrapper_naca0012.test_iter = 20 - pywrapper_naca0012.test_vals = [-4.431325, -3.970055, 0.319205, 0.022299] + pywrapper_naca0012.test_vals = [-4.766184, -4.287722, 0.326688, 0.022661] pywrapper_naca0012.command = TestCase.Command(exec = "SU2_CFD.py", param = "-f") pywrapper_naca0012.timeout = 1600 pywrapper_naca0012.tol = 0.00001 @@ -1548,7 +1548,7 @@ def main(): pywrapper_aeroelastic.cfg_dir = "aeroelastic" pywrapper_aeroelastic.cfg_file = "aeroelastic_NACA64A010.cfg" pywrapper_aeroelastic.test_iter = 2 - pywrapper_aeroelastic.test_vals = [0.074291, 0.027620, -0.001641, -0.000128] + pywrapper_aeroelastic.test_vals = [0.074208, 0.027599, -0.001641, -0.000128] pywrapper_aeroelastic.command = TestCase.Command(exec = "SU2_CFD.py", param = "-f") pywrapper_aeroelastic.timeout = 1600 pywrapper_aeroelastic.tol = 0.00001 @@ -1562,7 +1562,7 @@ def main(): pywrapper_fsi2d.cfg_dir = "fea_fsi/WallChannel_2d" pywrapper_fsi2d.cfg_file = "configFSI.cfg" pywrapper_fsi2d.test_iter = 4 - pywrapper_fsi2d.test_vals = [4.000000, 0.000000, -3.726050, -4.277800] + pywrapper_fsi2d.test_vals = [4.000000, 0.000000, -3.726014, -4.277767] pywrapper_fsi2d.command = TestCase.Command(exec = "SU2_CFD.py", param = "--nZone 2 --fsi True -f") pywrapper_fsi2d.unsteady = True pywrapper_fsi2d.multizone = True @@ -1605,7 +1605,7 @@ def main(): pywrapper_custom_inlet.cfg_dir = "py_wrapper/custom_inlet" pywrapper_custom_inlet.cfg_file = "lam_flatplate.cfg" pywrapper_custom_inlet.test_iter = 20 - pywrapper_custom_inlet.test_vals = [-4.120910, -1.540677, -3.567156, 1.342054, -0.748463, 0.161782, -0.012949, 0.516060, -0.529000] + pywrapper_custom_inlet.test_vals = [-4.123206, -1.543215, -3.735006, 1.339481, -0.793478, 0.161210, -0.007009, 0.513560, -0.520570] pywrapper_custom_inlet.command = TestCase.Command(exec = "python", param = "run.py") pywrapper_custom_inlet.timeout = 1600 pywrapper_custom_inlet.tol = 0.0001 diff --git a/TestCases/serial_regression_AD.py b/TestCases/serial_regression_AD.py index e684ea5953e6..007d63f3a2b0 100644 --- a/TestCases/serial_regression_AD.py +++ b/TestCases/serial_regression_AD.py @@ -50,7 +50,7 @@ def main(): discadj_naca0012.cfg_dir = "cont_adj_euler/naca0012" discadj_naca0012.cfg_file = "inv_NACA0012_discadj.cfg" discadj_naca0012.test_iter = 100 - discadj_naca0012.test_vals = [-3.560691, -8.925239, -0.000000, 0.005559] + discadj_naca0012.test_vals = [-3.562611, -8.932639, -0.000000, 0.005608] test_list.append(discadj_naca0012) # Inviscid Cylinder 3D (multiple markers) @@ -58,7 +58,7 @@ def main(): discadj_cylinder3D.cfg_dir = "disc_adj_euler/cylinder3D" discadj_cylinder3D.cfg_file = "inv_cylinder3D.cfg" discadj_cylinder3D.test_iter = 5 - discadj_cylinder3D.test_vals = [-3.780430, -3.745463, -0.000000, 0.000000] + discadj_cylinder3D.test_vals = [-3.702105, -3.895140, -0.000000, 0.000000] test_list.append(discadj_cylinder3D) # Arina nozzle 2D @@ -66,7 +66,7 @@ def main(): discadj_arina2k.cfg_dir = "disc_adj_euler/arina2k" discadj_arina2k.cfg_file = "Arina2KRS.cfg" discadj_arina2k.test_iter = 20 - discadj_arina2k.test_vals = [-3.534947, -3.773294, 0.027242, 0.000000] + discadj_arina2k.test_vals = [-3.254490, -3.495569, 0.052370, 0.000000] test_list.append(discadj_arina2k) ####################################################### @@ -98,7 +98,7 @@ def main(): discadj_incomp_NACA0012.cfg_dir = "disc_adj_incomp_euler/naca0012" discadj_incomp_NACA0012.cfg_file = "incomp_NACA0012_disc.cfg" discadj_incomp_NACA0012.test_iter = 20 - discadj_incomp_NACA0012.test_vals = [20.000000, -4.087948, -2.655204, 0.000000] + discadj_incomp_NACA0012.test_vals = [20.000000, -4.091644, -2.655563, 0.000000] test_list.append(discadj_incomp_NACA0012) ##################################### @@ -148,7 +148,7 @@ def main(): discadj_pitchingNACA0012.cfg_dir = "disc_adj_euler/naca0012_pitching" discadj_pitchingNACA0012.cfg_file = "inv_NACA0012_pitching.cfg" discadj_pitchingNACA0012.test_iter = 4 - discadj_pitchingNACA0012.test_vals = [-1.220016, -1.646770, -0.007597, 0.000013] + discadj_pitchingNACA0012.test_vals = [-1.219518, -1.646199, -0.007607, 0.000013] discadj_pitchingNACA0012.unsteady = True test_list.append(discadj_pitchingNACA0012) @@ -157,7 +157,7 @@ def main(): unst_deforming_naca0012.cfg_dir = "disc_adj_euler/naca0012_pitching_def" unst_deforming_naca0012.cfg_file = "inv_NACA0012_pitching_deform_ad.cfg" unst_deforming_naca0012.test_iter = 4 - unst_deforming_naca0012.test_vals = [-1.959357, -1.843601, 2729.700000, 0.000004] + unst_deforming_naca0012.test_vals = [-1.960419, -1.844186, 2970.700000, 0.000004] unst_deforming_naca0012.unsteady = True test_list.append(unst_deforming_naca0012) @@ -183,7 +183,7 @@ def main(): discadj_heat.cfg_dir = "disc_adj_heat" discadj_heat.cfg_file = "disc_adj_heat.cfg" discadj_heat.test_iter = 10 - discadj_heat.test_vals = [-1.956346, 0.721746, 0.000000, 0.007024] + discadj_heat.test_vals = [-2.174678, 0.591525, 0.000000, 0.008748] test_list.append(discadj_heat) ################################### @@ -337,7 +337,7 @@ def main(): pywrapper_CFD_AD_MeshDisp.cfg_dir = "py_wrapper/disc_adj_flow/mesh_disp_sens" pywrapper_CFD_AD_MeshDisp.cfg_file = "configAD_flow.cfg" pywrapper_CFD_AD_MeshDisp.test_iter = 1000 - pywrapper_CFD_AD_MeshDisp.test_vals = [30.000000, -2.505330, 1.409290, 0.000000] + pywrapper_CFD_AD_MeshDisp.test_vals = [30.000000, -2.496380, 1.441373, 0.000000] pywrapper_CFD_AD_MeshDisp.command = TestCase.Command(exec = "python", param = "run_adjoint.py -f") pywrapper_CFD_AD_MeshDisp.timeout = 1600 pywrapper_CFD_AD_MeshDisp.tol = 0.000001 diff --git a/TestCases/tutorials.py b/TestCases/tutorials.py index ef4398b6f751..17a9596e53e5 100644 --- a/TestCases/tutorials.py +++ b/TestCases/tutorials.py @@ -69,7 +69,7 @@ def main(): cht_CR.cfg_dir = "../Tutorials/multiphysics/contact_resistance_cht" cht_CR.cfg_file = "master.cfg" cht_CR.test_iter = 80 - cht_CR.test_vals = [ -8.857438, -9.377593, -10.097769, -2.122358] + cht_CR.test_vals = [-8.606916, -9.227614, -10.411673, -2.114949] cht_CR.multizone = True test_list.append(cht_CR) @@ -80,7 +80,7 @@ def main(): sp_pinArray_2d_mf_hf.cfg_dir = "../Tutorials/incompressible_flow/Inc_Streamwise_Periodic" sp_pinArray_2d_mf_hf.cfg_file = "sp_pinArray_2d_mf_hf.cfg" sp_pinArray_2d_mf_hf.test_iter = 25 - sp_pinArray_2d_mf_hf.test_vals = [-4.613682, 1.471278, -0.748987, 241.667177] + sp_pinArray_2d_mf_hf.test_vals = [-4.666594, 1.403293, -0.758331, 241.626886] test_list.append(sp_pinArray_2d_mf_hf) # 2D pin case pressure drop periodic with heatflux BC and temperature periodicity @@ -88,7 +88,7 @@ def main(): sp_pinArray_2d_dp_hf_tp.cfg_dir = "../Tutorials/incompressible_flow/Inc_Streamwise_Periodic" sp_pinArray_2d_dp_hf_tp.cfg_file = "sp_pinArray_2d_dp_hf_tp.cfg" sp_pinArray_2d_dp_hf_tp.test_iter = 25 - sp_pinArray_2d_dp_hf_tp.test_vals = [-4.640621, 1.436697, -0.707302, 208.023676] + sp_pinArray_2d_dp_hf_tp.test_vals = [-4.718616, 1.341279, -0.716655, 208.023676] test_list.append(sp_pinArray_2d_dp_hf_tp) # 90 degree pipe bend with wall functions from the experiments of Sudo et al. @@ -96,7 +96,7 @@ def main(): sudo_tutorial.cfg_dir = "../Tutorials/incompressible_flow/Inc_Turbulent_Bend_Wallfunctions" sudo_tutorial.cfg_file = "sudo.cfg" sudo_tutorial.test_iter = 10 - sudo_tutorial.test_vals = [-14.286992, -12.868418, -13.150195, -13.036596, -13.027783, -9.510980, 15.000000, -2.288151] + sudo_tutorial.test_vals = [-14.664419, -12.789769, -13.280336, -13.016392, -13.018817, -9.510066, 15.000000, -1.994192] sudo_tutorial.command = TestCase.Command("mpirun -n 2", "SU2_CFD") test_list.append(sudo_tutorial) @@ -105,7 +105,7 @@ def main(): sudo_design_primal.cfg_dir = "../Tutorials/design/Inc_Turbulent_Bend_Wallfunctions" sudo_design_primal.cfg_file = "sudo_primal.cfg" sudo_design_primal.test_iter = 10 - sudo_design_primal.test_vals = [-12.064068, -11.348930, -11.059284, -11.066144, -11.437307, -8.258444, 64.545000] + sudo_design_primal.test_vals = [-12.282828, -11.284608, -11.508705, -10.879281, -11.317890, -8.080709, 64.545000] sudo_design_primal.command = TestCase.Command("mpirun -n 2", "SU2_CFD") test_list.append(sudo_design_primal) @@ -114,7 +114,7 @@ def main(): sudo_design_adjoint.cfg_dir = "../Tutorials/design/Inc_Turbulent_Bend_Wallfunctions" sudo_design_adjoint.cfg_file = "sudo_adjoint.cfg" sudo_design_adjoint.test_iter = 10 - sudo_design_adjoint.test_vals = [-4.118073, -3.680088, -2.567859, -3.440055, -3.710829, -7.211066] + sudo_design_adjoint.test_vals = [-4.380696, -3.296474, -3.098815, -3.195595, -3.737980, -7.327552] sudo_design_adjoint.command = TestCase.Command("mpirun -n 2", "SU2_CFD_AD") test_list.append(sudo_design_adjoint) @@ -134,7 +134,7 @@ def main(): species3_primitiveVenturi.cfg_dir = "../Tutorials/incompressible_flow/Inc_Species_Transport" species3_primitiveVenturi.cfg_file = "species3_primitiveVenturi.cfg" species3_primitiveVenturi.test_iter = 50 - species3_primitiveVenturi.test_vals = [-5.869509, -5.252493, -5.127926, -5.912790, -1.767067, -6.152558, -6.304196, 5.000000, -0.933280, 5.000000, -2.314730, 5.000000, -0.680255, 1.649865, 0.500678, 0.596475, 0.552712] + species3_primitiveVenturi.test_vals = [-6.325258, -5.481481, -5.487951, -6.041510, -1.982216, -6.686450, -6.770227, 5.000000, -0.578086, 5.000000, -2.435371, 5.000000, -0.176851, 1.655677, 0.501807, 0.602254, 0.551616] test_list.append(species3_primitiveVenturi) # 3 species (2 eq) primitive venturi mixing @@ -142,7 +142,7 @@ def main(): DAspecies3_primitiveVenturi.cfg_dir = "../Tutorials/incompressible_flow/Inc_Species_Transport" DAspecies3_primitiveVenturi.cfg_file = "DAspecies3_primitiveVenturi.cfg" DAspecies3_primitiveVenturi.test_iter = 50 - DAspecies3_primitiveVenturi.test_vals = [-7.584508, -7.211527, -6.740742, -6.896386, -11.472089, -10.865347, -10.096770] + DAspecies3_primitiveVenturi.test_vals = [-9.822258, -8.691684, -8.724082, -8.421745, -12.992943, -11.017067, -10.232083] DAspecies3_primitiveVenturi.test_vals_aarch64 = [-7.865411, -7.548131, -7.347978, -7.217536, -11.822422, -10.968444, -10.193225] DAspecies3_primitiveVenturi.command = TestCase.Command("mpirun -n 2", "SU2_CFD_AD") test_list.append(DAspecies3_primitiveVenturi) @@ -164,7 +164,7 @@ def main(): premixed_hydrogen.cfg_dir = "../Tutorials/incompressible_flow/Inc_Combustion/1__premixed_hydrogen" premixed_hydrogen.cfg_file = "H2_burner.cfg" premixed_hydrogen.test_iter = 10 - premixed_hydrogen.test_vals = [-9.809794, -10.369804, -11.044267, -4.332945, -11.883789] + premixed_hydrogen.test_vals = [-9.880667, -10.491791, -11.028989, -4.325192, -11.885386] test_list.append(premixed_hydrogen) ### Compressible Flow @@ -174,7 +174,7 @@ def main(): tutorial_inv_bump.cfg_dir = "../Tutorials/compressible_flow/Inviscid_Bump" tutorial_inv_bump.cfg_file = "inv_channel.cfg" tutorial_inv_bump.test_iter = 0 - tutorial_inv_bump.test_vals = [-1.548003, 3.983585, 0.020973, 0.071064] + tutorial_inv_bump.test_vals = [-1.437425, 4.075857, 0.035200, 0.019230] test_list.append(tutorial_inv_bump) # Inviscid Wedge @@ -182,7 +182,7 @@ def main(): tutorial_inv_wedge.cfg_dir = "../Tutorials/compressible_flow/Inviscid_Wedge" tutorial_inv_wedge.cfg_file = "inv_wedge_HLLC.cfg" tutorial_inv_wedge.test_iter = 0 - tutorial_inv_wedge.test_vals = [-0.864206, 4.850246, -0.245674, 0.043209] + tutorial_inv_wedge.test_vals = [-0.481460, 5.253008, -0.281099, 0.049535] tutorial_inv_wedge.no_restart = True test_list.append(tutorial_inv_wedge) @@ -191,7 +191,7 @@ def main(): tutorial_inv_onera.cfg_dir = "../Tutorials/compressible_flow/Inviscid_ONERAM6" tutorial_inv_onera.cfg_file = "inv_ONERAM6.cfg" tutorial_inv_onera.test_iter = 0 - tutorial_inv_onera.test_vals = [-5.504569, -4.895596, 0.248943, 0.118355] + tutorial_inv_onera.test_vals = [-5.204928, -4.597762, 0.294332, 0.115223] tutorial_inv_onera.no_restart = True test_list.append(tutorial_inv_onera) @@ -218,7 +218,7 @@ def main(): tutorial_turb_flatplate.cfg_dir = "../Tutorials/compressible_flow/Turbulent_Flat_Plate" tutorial_turb_flatplate.cfg_file = "turb_SA_flatplate.cfg" tutorial_turb_flatplate.test_iter = 0 - tutorial_turb_flatplate.test_vals = [-2.258584, -4.901015, -0.429373, 0.201034] + tutorial_turb_flatplate.test_vals = [-2.258584, -4.901015, -0.429401, 0.201034] tutorial_turb_flatplate.no_restart = True test_list.append(tutorial_turb_flatplate) @@ -227,7 +227,7 @@ def main(): tutorial_trans_flatplate.cfg_dir = "../Tutorials/compressible_flow/Transitional_Flat_Plate" tutorial_trans_flatplate.cfg_file = "transitional_BC_model_ConfigFile.cfg" tutorial_trans_flatplate.test_iter = 0 - tutorial_trans_flatplate.test_vals = [-22.021786, -15.330766, 0.000000, 0.023952] #last 4 columns + tutorial_trans_flatplate.test_vals = [-22.021786, -15.330766, 0.000000, 0.023944] tutorial_trans_flatplate.no_restart = True test_list.append(tutorial_trans_flatplate) @@ -236,7 +236,7 @@ def main(): tutorial_trans_flatplate_T3A.cfg_dir = "../Tutorials/compressible_flow/Transitional_Flat_Plate/Langtry_and_Menter/T3A" tutorial_trans_flatplate_T3A.cfg_file = "transitional_LM_model_ConfigFile.cfg" tutorial_trans_flatplate_T3A.test_iter = 20 - tutorial_trans_flatplate_T3A.test_vals = [-5.841218, -2.094611, -3.947011, -0.305590, -1.586230, 8.296809, -3.507308, 0.394898] + tutorial_trans_flatplate_T3A.test_vals = [-5.837372, -2.092248, -3.985588, -0.302343, -1.938059, 1.767906, -3.496887, 0.391359] tutorial_trans_flatplate_T3A.test_vals_aarch64 = [-5.837368, -2.092246, -3.984172, -0.302357, -1.928108, 1.667157, -3.496279, 0.391610] tutorial_trans_flatplate_T3A.no_restart = True test_list.append(tutorial_trans_flatplate_T3A) @@ -246,7 +246,7 @@ def main(): tutorial_trans_flatplate_T3Am.cfg_dir = "../Tutorials/compressible_flow/Transitional_Flat_Plate/Langtry_and_Menter/T3A-" tutorial_trans_flatplate_T3Am.cfg_file = "transitional_LM_model_ConfigFile.cfg" tutorial_trans_flatplate_T3Am.test_iter = 20 - tutorial_trans_flatplate_T3Am.test_vals = [-6.206421, -2.029271, -4.028227, -0.685277, -3.893712, 6.692342, -2.521007, 0.948646] + tutorial_trans_flatplate_T3Am.test_vals = [-5.887367, -1.965182, -3.915982, -0.391858, -3.893196, 2.628116, -2.486582, 1.346060] tutorial_trans_flatplate_T3Am.test_vals_aarch64 = [-6.063726, -1.945088, -3.946923, -0.549166, -3.863794, 2.664439, -2.517601, 1.112978] tutorial_trans_flatplate_T3Am.no_restart = True test_list.append(tutorial_trans_flatplate_T3Am) @@ -274,18 +274,28 @@ def main(): tutorial_turb_oneram6.cfg_dir = "../Tutorials/compressible_flow/Turbulent_ONERAM6" tutorial_turb_oneram6.cfg_file = "turb_ONERAM6.cfg" tutorial_turb_oneram6.test_iter = 0 - tutorial_turb_oneram6.test_vals = [-4.564441, -11.524295, 0.327905, 0.097340] + tutorial_turb_oneram6.test_vals = [-4.564441, -11.533952, 0.330625, 0.097701] test_list.append(tutorial_turb_oneram6) - # NICD Nozzle + # NICFD Nozzle tutorial_nicfd_nozzle = TestCase('nicfd_nozzle') tutorial_nicfd_nozzle.cfg_dir = "../Tutorials/compressible_flow/NICFD_nozzle" tutorial_nicfd_nozzle.cfg_file = "NICFD_nozzle.cfg" tutorial_nicfd_nozzle.test_iter = 20 - tutorial_nicfd_nozzle.test_vals = [-2.056675, -2.120178, 3.756865, 0.000000, 0.000000] + tutorial_nicfd_nozzle.test_vals = [-2.258703, -2.317269, 3.711051, 0.000000, 0.000000] tutorial_nicfd_nozzle.no_restart = True test_list.append(tutorial_nicfd_nozzle) + # NICFD Nozzle using PINN + tutorial_nicfd_nozzle_pinn = TestCase('nicfd_nozzle_pinn') + tutorial_nicfd_nozzle_pinn.cfg_dir = "../Tutorials/compressible_flow/NICFD_nozzle/PhysicsInformed" + tutorial_nicfd_nozzle_pinn.cfg_file = "config_NICFD_PINN.cfg" + tutorial_nicfd_nozzle_pinn.test_iter = 20 + tutorial_nicfd_nozzle_pinn.test_vals = [-3.181747, -1.638856, -1.277037, 2.445964, -11.769570] + tutorial_nicfd_nozzle_pinn.no_restart = True + test_list.append(tutorial_nicfd_nozzle_pinn) + + # Unsteady NACA0012 tutorial_unst_naca0012 = TestCase('unsteady_naca0012') tutorial_unst_naca0012.cfg_dir = "../Tutorials/compressible_flow/Unsteady_NACA0012" @@ -312,7 +322,7 @@ def main(): tutorial_design_inv_naca0012.cfg_dir = "../Tutorials/design/Inviscid_2D_Unconstrained_NACA0012" tutorial_design_inv_naca0012.cfg_file = "inv_NACA0012_basic.cfg" tutorial_design_inv_naca0012.test_iter = 0 - tutorial_design_inv_naca0012.test_vals = [-3.918503, -3.332494, 0.134359, 0.218097] + tutorial_design_inv_naca0012.test_vals = [-3.585391, -2.989014, 0.169337, 0.235131] tutorial_design_inv_naca0012.no_restart = True test_list.append(tutorial_design_inv_naca0012) diff --git a/TestCases/vandv.py b/TestCases/vandv.py index 1978292f7481..aaf7562298fa 100644 --- a/TestCases/vandv.py +++ b/TestCases/vandv.py @@ -54,7 +54,7 @@ def main(): flatplate_sst1994m.cfg_dir = "vandv/rans/flatplate" flatplate_sst1994m.cfg_file = "turb_flatplate_sst.cfg" flatplate_sst1994m.test_iter = 5 - flatplate_sst1994m.test_vals = [-13.024930, -9.634457, -10.707600, -7.558080, -9.926634, -4.910704, 0.002786] + flatplate_sst1994m.test_vals = [-13.034112, -9.631829, -10.705034, -7.564954, -9.926380, -4.911151, 0.002786] flatplate_sst1994m.test_vals_aarch64 = [-13.024930, -9.634457, -10.707600, -7.558080, -9.926634, -4.910704, 0.002786] test_list.append(flatplate_sst1994m) @@ -63,8 +63,8 @@ def main(): bump_sst1994m.cfg_dir = "vandv/rans/bump_in_channel" bump_sst1994m.cfg_file = "turb_bump_sst.cfg" bump_sst1994m.test_iter = 5 - bump_sst1994m.test_vals = [-13.006002, -10.671005, -10.602936, -7.625336, -10.992230, -0.224690, 0.004900] - bump_sst1994m.test_vals_aarch64 = [-13.006002, -10.671005, -10.602936, -7.625336, -10.992230, -0.224690, 0.004900] + bump_sst1994m.test_vals = [-13.058028, -10.648326, -10.605014, -7.606233, -10.707705, -5.453705, 0.004903] + bump_sst1994m.test_vals_aarch64 = [-13.025265, -10.669816, -10.615338, -7.577125, -10.709448, -5.453868, 0.004903] test_list.append(bump_sst1994m) # SWBLI SA @@ -72,7 +72,7 @@ def main(): swbli_sa.cfg_dir = "vandv/rans/swbli" swbli_sa.cfg_file = "config_sa.cfg" swbli_sa.test_iter = 5 - swbli_sa.test_vals = [-11.511278, -10.750583, -11.854073, -10.320108, -14.316261, 0.002238, -1.585354, 1.276300] + swbli_sa.test_vals = [-11.511182, -10.750503, -11.853919, -10.320019, -14.316261, 0.002238, -1.585259, 1.276300] swbli_sa.test_vals_aarch64 = [-11.511278, -10.750583, -11.854073, -10.320108, -14.316261, 0.002238, -1.585354, 1.276300] test_list.append(swbli_sa) @@ -85,6 +85,22 @@ def main(): swbli_sst.test_vals = [-11.502801, -10.850953, -11.573565, -10.370903, -11.405169, -3.864744, 0.001794, -1.451606, -3.606886, 10.000000] test_list.append(swbli_sst) + # DSMA661 - SA + dsma661_sa = TestCase('dsma661_sa') + dsma661_sa.cfg_dir = "vandv/rans/dsma661" + dsma661_sa.cfg_file = "dsma661_sa_config.cfg" + dsma661_sa.test_iter = 5 + dsma661_sa.test_vals = [-11.013046, -8.140606, -8.989695, -5.978550, -10.593381, 0.155689, 0.024173] + test_list.append(dsma661_sa) + + # DSMA661 - SST-V2003m + dsma661_sst = TestCase('dsma661_sst') + dsma661_sst.cfg_dir = "vandv/rans/dsma661" + dsma661_sst.cfg_file = "dsma661_sst_config.cfg" + dsma661_sst.test_iter = 5 + dsma661_sst.test_vals = [-11.010713, -8.424971, -9.045546, -5.969005, -10.556865, -8.053764, 0.155948, 0.023353] + test_list.append(dsma661_sst) + ########################## ### Incompressible RANS ### ########################## @@ -94,7 +110,7 @@ def main(): sandiajet_sst.cfg_dir = "vandv/species_transport/sandia_jet" sandiajet_sst.cfg_file = "validation.cfg" sandiajet_sst.test_iter = 5 - sandiajet_sst.test_vals = [-17.198747, -14.117051, -15.599971, -14.054169, -10.364040, -15.739739, 5.000000, -3.100725, 5.000000, -5.353629, 5.000000, -4.200029, 0.000258, 0.000000, 0.000000, 0.000258, 4019.500000, 3918.900000, 49.151000, 51.436000] + sandiajet_sst.test_vals = [-17.167460, -14.133874, -15.538854, -14.038830, -10.311748, -15.739547, 5.000000, -2.916316, 5.000000, -5.380194, 5.000000, -4.153689, 0.000258, 0.000000, 0.000000, 0.000258, 4019.500000, 3918.900000, 49.151000, 51.436000] sandiajet_sst.test_vals_aarch64 = [-17.069026, -13.156800, -15.290567, -11.689831, -9.349978, -14.907311, 5.000000, -2.738947, 5.000000, -4.813747, 5.000000, -3.981740, 0.000259, 0.000000, 0.000000, 0.000259, 4047.400000, 3946.800000, 49.161000, 51.433000] test_list.append(sandiajet_sst) diff --git a/TestCases/vandv/rans/dsma661/dsma661_sa_config.cfg b/TestCases/vandv/rans/dsma661/dsma661_sa_config.cfg new file mode 100644 index 000000000000..41c902232a42 --- /dev/null +++ b/TestCases/vandv/rans/dsma661/dsma661_sa_config.cfg @@ -0,0 +1,140 @@ +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +% Solver type (EULER, NAVIER_STOKES, RANS, +% INC_EULER, INC_NAVIER_STOKES, INC_RANS, +% NEMO_EULER, NEMO_NAVIER_STOKES, +% FEM_EULER, FEM_NAVIER_STOKES, FEM_RANS, FEM_LES, +% HEAT_EQUATION_FVM, ELASTICITY) +SOLVER= RANS +MATH_PROBLEM= DIRECT +RESTART_SOL= YES +DISCARD_INFILES= NO +SYSTEM_MEASUREMENTS= SI +KIND_TURB_MODEL= SA % (NONE, SA, SST) +SA_OPTIONS= NONE +% +% ------------------------------- SOLVER CONTROL ------------------------------% +% +ITER= 1000000 +CONV_FIELD= RMS_DENSITY +CONV_RESIDUAL_MINVAL= -11 +CONV_STARTITER= 10 +CONV_CAUCHY_ELEMS= 100 +CONV_CAUCHY_EPS= 1E-11 +% +% ---------------------- REFERENCE VALUE DEFINITION ---------------------------% +% +REF_ORIGIN_MOMENT_X = 0.00 +REF_ORIGIN_MOMENT_Y = 0.00 +REF_ORIGIN_MOMENT_Z = 0.00 +REF_LENGTH= 1.0 +REF_VELOCITY= 1.0 +REF_VISCOSITY= 1.0 +REF_AREA= 1.0 +% +% -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------% +% +MACH_NUMBER= 0.088 +AOA= 0 +INIT_OPTION= REYNOLDS +FREESTREAM_OPTION= TEMPERATURE_FS +FREESTREAM_TEMPERATURE= 300 +FREESTREAM_DENSITY= 1.2886 +FREESTREAM_VELOCITY= ( 30.5552677, 0.00, 0.00 ) +FREESTREAM_VISCOSITY= 1.853E-5 +FREESTREAM_NU_FACTOR= 3 +REYNOLDS_NUMBER= 1.2e6 +REYNOLDS_LENGTH= 1.0 +REF_DIMENSIONALIZATION= DIMENSIONAL +% +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +% Viscosity model (SUTHERLAND, CONSTANT_VISCOSITY, POLYNOMIAL_VISCOSITY, FLAMELET). +VISCOSITY_MODEL= SUTHERLAND +MU_CONSTANT= 1.716E-5 +MU_REF= 1.716E-5 +MU_T_REF= 273.15 +SUTHERLAND_CONSTANT= 110.4 +% +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +% Navier-Stokes (no-slip), constant heat flux wall marker(s) (NONE = no marker) +% Format: ( marker name, constant heat flux (J/m^2), ... ) +MARKER_HEATFLUX= (airfoil, 0.0) +MARKER_FAR= (farfield) +MARKER_PLOTTING = ( airfoil ) +MARKER_MONITORING = ( airfoil ) +MARKER_ANALYZE_AVERAGE = AREA +% +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +% Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) +NUM_METHOD_GRAD= GREEN_GAUSS +CFL_NUMBER= 1000.0 %For coarser meshes 1000 converges fast; for finer meshes 10-100 works well +CFL_ADAPT= NO +CFL_ADAPT_PARAM= ( 0.95, 1.05, 0.001, 10000, 0.00001 ) +% +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= ROE +MUSCL_FLOW= YES +SLOPE_LIMITER_FLOW= VAN_ALBADA_EDGE +TIME_DISCRE_FLOW= EULER_IMPLICIT +% +% -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% +% +CONV_NUM_METHOD_TURB= SCALAR_UPWIND +MUSCL_TURB= NO +SLOPE_LIMITER_TURB= VENKATAKRISHNAN +TIME_DISCRE_TURB= EULER_IMPLICIT +% +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +% Linear solver for implicit formulations (BCGSTAB, FGMRES) +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ILU_FILL_IN= 0 +LINEAR_SOLVER_ERROR= 1E-3 +LINEAR_SOLVER_ITER= 20 +% +% ------------------------- SCREEN/HISTORY VOLUME OUTPUT --------------------------% +% +SCREEN_OUTPUT= (INNER_ITER, WALL_TIME, RMS_RES, LIFT, DRAG) +HISTORY_OUTPUT= (INNER_ITER, WALL_TIME, RMS_RES, AERO_COEFF, FLOW_COEFF) +VOLUME_OUTPUT = (COORDINATES, SOLUTION, PRIMITIVE, VORTEX_IDENTIFICATION, CFL_NUMBER, MESH_QUALITY, RESIDUALS) +SCREEN_WRT_FREQ_INNER= 1 +HISTORY_WRT_FREQ_INNER= 1 +OUTPUT_WRT_FREQ= 200 +WRT_PERFORMANCE= YES +WRT_AD_STATISTICS= YES +WRT_RESTART_OVERWRITE= YES +WRT_SURFACE_OVERWRITE= YES +WRT_VOLUME_OVERWRITE= YES +WRT_FORCES_BREAKDOWN= YES +% +% ------------------------- INPUT/OUTPUT FILE INFORMATION --------------------------% +% +MESH_FILENAME= mesh_turb_dsma661_65.su2 % mesh_turb_dsma661_65.su2, mesh_turb_dsma661_129.su2, + %mesh_turb_dsma661_257.su2, mesh_turb_dsma661_513.su2, mesh_turb_dsma661_1025.su2 +MESH_FORMAT= SU2 +% 149_29, 297_57, 593_113, 1185_225, 2369_449, +RESTART_FILENAME= restart_flow-149_29.dat +VOLUME_FILENAME= flow-149_29 +BREAKDOWN_FILENAME= forces_breakdown-149_29.dat +CONV_FILENAME= history-149_29 +SURFACE_FILENAME= suface-149_29 + +MESH_OUT_FILENAME= mesh_out.su2 +SOLUTION_FILENAME= sa_restart_flow-149_29.dat +TABULAR_FORMAT= CSV +OUTPUT_PRECISION= 15 +% Files to output +% Possible formats : (TECPLOT_ASCII, TECPLOT, SURFACE_TECPLOT_ASCII, +% SURFACE_TECPLOT, CSV, SURFACE_CSV, PARAVIEW_ASCII, PARAVIEW_LEGACY, SURFACE_PARAVIEW_ASCII, +% SURFACE_PARAVIEW_LEGACY, PARAVIEW, SURFACE_PARAVIEW, RESTART_ASCII, RESTART, CGNS, SURFACE_CGNS, STL_ASCII, STL_BINARY) +% default : (RESTART, PARAVIEW, SURFACE_PARAVIEW) +OUTPUT_FILES= (RESTART, PARAVIEW, SURFACE_PARAVIEW) +VALUE_OBJFUNC_FILENAME= of_eval.dat +READ_BINARY_RESTART= YES +REORIENT_ELEMENTS= YES +% diff --git a/TestCases/vandv/rans/dsma661/dsma661_sst_config.cfg b/TestCases/vandv/rans/dsma661/dsma661_sst_config.cfg new file mode 100644 index 000000000000..e3bcc532d696 --- /dev/null +++ b/TestCases/vandv/rans/dsma661/dsma661_sst_config.cfg @@ -0,0 +1,140 @@ +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +% Solver type (EULER, NAVIER_STOKES, RANS, +% INC_EULER, INC_NAVIER_STOKES, INC_RANS, +% NEMO_EULER, NEMO_NAVIER_STOKES, +% FEM_EULER, FEM_NAVIER_STOKES, FEM_RANS, FEM_LES, +% HEAT_EQUATION_FVM, ELASTICITY) +SOLVER= RANS +MATH_PROBLEM= DIRECT +RESTART_SOL= YES +DISCARD_INFILES= NO +SYSTEM_MEASUREMENTS= SI +KIND_TURB_MODEL= SST % (NONE, SA, SST) +SST_OPTIONS= V2003m +% +% ------------------------------- SOLVER CONTROL ------------------------------% +% +ITER= 1000000 +CONV_FIELD= RMS_DENSITY +CONV_RESIDUAL_MINVAL= -11 +CONV_STARTITER= 10 +CONV_CAUCHY_ELEMS= 100 +CONV_CAUCHY_EPS= 1E-11 +% +% ---------------------- REFERENCE VALUE DEFINITION ---------------------------% +% +REF_ORIGIN_MOMENT_X = 0.00 +REF_ORIGIN_MOMENT_Y = 0.00 +REF_ORIGIN_MOMENT_Z = 0.00 +REF_LENGTH= 1.0 +REF_VELOCITY= 1.0 +REF_VISCOSITY= 1.0 +REF_AREA= 1.0 +% +% -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------% +% +MACH_NUMBER= 0.088 +AOA= 0 +INIT_OPTION= REYNOLDS +FREESTREAM_OPTION= TEMPERATURE_FS +FREESTREAM_TEMPERATURE= 300 +FREESTREAM_DENSITY= 1.2886 +FREESTREAM_VELOCITY= ( 30.5552677, 0.00, 0.00 ) +FREESTREAM_VISCOSITY= 1.853E-5 +FREESTREAM_NU_FACTOR= 3 +REYNOLDS_NUMBER= 1.2e6 +REYNOLDS_LENGTH= 1.0 +REF_DIMENSIONALIZATION= DIMENSIONAL +% +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +% Viscosity model (SUTHERLAND, CONSTANT_VISCOSITY, POLYNOMIAL_VISCOSITY, FLAMELET). +VISCOSITY_MODEL= SUTHERLAND +MU_CONSTANT= 1.716E-5 +MU_REF= 1.716E-5 +MU_T_REF= 273.15 +SUTHERLAND_CONSTANT= 110.4 +% +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +% Navier-Stokes (no-slip), constant heat flux wall marker(s) (NONE = no marker) +% Format: ( marker name, constant heat flux (J/m^2), ... ) +MARKER_HEATFLUX= (airfoil, 0.0) +MARKER_FAR= (farfield) +MARKER_PLOTTING = ( airfoil ) +MARKER_MONITORING = ( airfoil ) +MARKER_ANALYZE_AVERAGE = AREA +% +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +% Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) +NUM_METHOD_GRAD= GREEN_GAUSS +CFL_NUMBER= 1000.0 %For coarser meshes 1000 converges fast; for finer meshes 10-100 works well +CFL_ADAPT= NO +CFL_ADAPT_PARAM= ( 0.95, 1.05, 0.001, 10000, 0.00001 ) +% +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= ROE +MUSCL_FLOW= YES +SLOPE_LIMITER_FLOW= VAN_ALBADA_EDGE +TIME_DISCRE_FLOW= EULER_IMPLICIT +% +% -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% +% +CONV_NUM_METHOD_TURB= SCALAR_UPWIND +MUSCL_TURB= NO +SLOPE_LIMITER_TURB= VENKATAKRISHNAN +TIME_DISCRE_TURB= EULER_IMPLICIT +% +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +% Linear solver for implicit formulations (BCGSTAB, FGMRES) +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= LU_SGS +LINEAR_SOLVER_ILU_FILL_IN= 0 +LINEAR_SOLVER_ERROR= 1E-3 +LINEAR_SOLVER_ITER= 20 +% +% ------------------------- SCREEN/HISTORY VOLUME OUTPUT --------------------------% +% +SCREEN_OUTPUT= (INNER_ITER, WALL_TIME, RMS_RES, LIFT, DRAG) +HISTORY_OUTPUT= (INNER_ITER, WALL_TIME, RMS_RES, RMS_NU_TILDE, AERO_COEFF, FLOW_COEFF) +VOLUME_OUTPUT = (COORDINATES, SOLUTION, PRIMITIVE, VORTEX_IDENTIFICATION, CFL_NUMBER, MESH_QUALITY, RESIDUALS) +SCREEN_WRT_FREQ_INNER= 1 +HISTORY_WRT_FREQ_INNER= 1 +OUTPUT_WRT_FREQ= 500 +WRT_PERFORMANCE= YES +WRT_AD_STATISTICS= YES +WRT_RESTART_OVERWRITE= YES +WRT_SURFACE_OVERWRITE= YES +WRT_VOLUME_OVERWRITE= YES +WRT_FORCES_BREAKDOWN= YES +% +% ------------------------- INPUT/OUTPUT FILE INFORMATION --------------------------% +% +MESH_FILENAME= mesh_turb_dsma661_65.su2 % mesh_turb_dsma661_65.su2, mesh_turb_dsma661_129.su2, + %mesh_turb_dsma661_257.su2, mesh_turb_dsma661_513.su2, mesh_turb_dsma661_1025.su2 +MESH_FORMAT= SU2 +% 149_29, 297_57, 593_113, 1185_225, 2369_449, +RESTART_FILENAME= restart_flow-149_29.dat +VOLUME_FILENAME= flow-149_29 +BREAKDOWN_FILENAME= forces_breakdown-149_29.dat +CONV_FILENAME= history-149_29 +SURFACE_FILENAME= suface-149_29 + +MESH_OUT_FILENAME= mesh_out.su2 +SOLUTION_FILENAME= sst_restart_flow-149_29.dat +TABULAR_FORMAT= CSV +OUTPUT_PRECISION= 15 +% Files to output +% Possible formats : (TECPLOT_ASCII, TECPLOT, SURFACE_TECPLOT_ASCII, +% SURFACE_TECPLOT, CSV, SURFACE_CSV, PARAVIEW_ASCII, PARAVIEW_LEGACY, SURFACE_PARAVIEW_ASCII, +% SURFACE_PARAVIEW_LEGACY, PARAVIEW, SURFACE_PARAVIEW, RESTART_ASCII, RESTART, CGNS, SURFACE_CGNS, STL_ASCII, STL_BINARY) +% default : (RESTART, PARAVIEW, SURFACE_PARAVIEW) +OUTPUT_FILES= (RESTART, PARAVIEW, SURFACE_PARAVIEW) +VALUE_OBJFUNC_FILENAME= of_eval.dat +READ_BINARY_RESTART= YES +REORIENT_ELEMENTS= YES +% diff --git a/UnitTests/SU2_CFD/fluid/CFluidModel_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidModel_tests.cpp new file mode 100644 index 000000000000..639d15a7b739 --- /dev/null +++ b/UnitTests/SU2_CFD/fluid/CFluidModel_tests.cpp @@ -0,0 +1,122 @@ +/*! + * \file CFluidModel_tests.cpp + * \brief Unit tests for the fluid model classes. + * \author E.Bunschoten + * \version 8.1.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2024, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "catch.hpp" +#include +#include "../../../SU2_CFD/include/fluid/CFluidModel.hpp" +#include "../../../SU2_CFD/include/fluid/CIdealGas.hpp" +#include "../../../SU2_CFD/include/fluid/CDataDrivenFluid.hpp" + +void FluidModelChecks(CFluidModel* fluid_model, const su2double val_p, const su2double val_T) { + /*--- Check consistency of reverse look-up ---*/ + { + fluid_model->SetTDState_PT(val_p, val_T); + + const su2double val_rho_fluidmodel = fluid_model->GetDensity(); + const su2double val_e_fluidmodel = fluid_model->GetStaticEnergy(); + + fluid_model->SetTDState_rhoe(val_rho_fluidmodel, val_e_fluidmodel); + CHECK(Approx(fluid_model->GetPressure()) == val_p); + CHECK(Approx(fluid_model->GetTemperature()) == val_T); + } + /*--- Check internal consistency between primary and derived fluid properties ---*/ + fluid_model->SetTDState_PT(val_p, val_T); + const su2double val_rho = fluid_model->GetDensity(); + const su2double val_e = fluid_model->GetStaticEnergy(); + + const su2double dTdrho_e = fluid_model->GetdTdrho_e(); + const su2double dPdrho_e = fluid_model->GetdPdrho_e(); + const su2double dTde_rho = fluid_model->GetdTde_rho(); + const su2double dPde_rho = fluid_model->GetdPde_rho(); + + su2double delta_rho = 1e-2, delta_e = 100.0; + { + fluid_model->SetTDState_rhoe(val_rho + delta_rho, val_e); + const su2double T_plus = fluid_model->GetTemperature(); + const su2double p_plus = fluid_model->GetPressure(); + + fluid_model->SetTDState_rhoe(val_rho - delta_rho, val_e); + const su2double T_minus = fluid_model->GetTemperature(); + const su2double p_minus = fluid_model->GetPressure(); + const su2double dTdrho_e_FD = (T_plus - T_minus) / (2 * delta_rho); + const su2double dPdrho_e_FD = (p_plus - p_minus) / (2 * delta_rho); + + CHECK(dTdrho_e == Approx(dTdrho_e_FD)); + CHECK(dPdrho_e == Approx(dPdrho_e_FD)); + } + { + fluid_model->SetTDState_rhoe(val_rho, val_e + delta_e); + const su2double T_plus = fluid_model->GetTemperature(); + const su2double p_plus = fluid_model->GetPressure(); + + fluid_model->SetTDState_rhoe(val_rho, val_e - delta_e); + const su2double T_minus = fluid_model->GetTemperature(); + const su2double p_minus = fluid_model->GetPressure(); + const su2double dTde_rho_FD = (T_plus - T_minus) / (2 * delta_e); + const su2double dPde_rho_FD = (p_plus - p_minus) / (2 * delta_e); + + CHECK(dTde_rho == Approx(dTde_rho_FD)); + CHECK(dPde_rho == Approx(dPde_rho_FD)); + } +} + +TEST_CASE("Test case for ideal gas fluid model") { + CIdealGas* fluid_model = new CIdealGas(1.4, 287.0); + + FluidModelChecks(fluid_model, 101325, 300.0); + FluidModelChecks(fluid_model, 1e6, 600.0); + + delete fluid_model; +} + +TEST_CASE("Test case for data-driven fluid model") { + std::stringstream config_options; + + config_options << "SOLVER=RANS" << std::endl; + config_options << "KIND_TURB_MODEL=SA" << std::endl; + config_options << "SA_OPTIONS= NONE" << std::endl; + config_options << "REYNOLDS_NUMBER=1e6" << std::endl; + config_options << "FLUID_MODEL=DATADRIVEN_FLUID" << std::endl; + config_options << "USE_PINN=YES" << std::endl; + config_options << "INTERPOLATION_METHOD=MLP" << std::endl; + config_options << "FILENAMES_INTERPOLATOR=(src/SU2/UnitTests/SU2_CFD/fluid/MLP_PINN.mlp)" << std::endl; + config_options << "CONV_NUM_METHOD_FLOW=JST" << std::endl; + + /*--- Setup ---*/ + + CConfig* config = new CConfig(config_options, SU2_COMPONENT::SU2_CFD, false); + + /*--- Define fluid model ---*/ + CDataDrivenFluid* fluid_model = new CDataDrivenFluid(config, false); + + /*--- Check fluid model consistency for several combinations of pressure-temperature. ---*/ + FluidModelChecks(fluid_model, 1.83e6, 523.0); + FluidModelChecks(fluid_model, 2e5, 520.0); + + delete config; + delete fluid_model; +} diff --git a/UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp b/UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp new file mode 100644 index 000000000000..dbc80e47287a --- /dev/null +++ b/UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp @@ -0,0 +1,156 @@ +/*! + * \file CFluidModel_tests.cpp + * \brief AD unit tests for the fluid model classes. + * \author E.Bunschoten + * \version 8.1.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2024, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "catch.hpp" +#include +#include "../../../SU2_CFD/include/fluid/CFluidModel.hpp" +#include "../../../SU2_CFD/include/fluid/CIdealGas.hpp" +#include "../../../SU2_CFD/include/fluid/CDataDrivenFluid.hpp" +#include "../../../SU2_CFD/include/fluid/CPengRobinson.hpp" + +void FluidModelADChecks(CFluidModel* fluid_model, su2double val_p, su2double val_T) { + /*--- Consistency tests for the fluid model secondary variables and AD integration. ---*/ + + /*--- Extract fluid density and static energy. ---*/ + fluid_model->SetTDState_PT(val_p, val_T); + su2double val_rho = fluid_model->GetDensity(); + su2double val_e = fluid_model->GetStaticEnergy(); + + /*--- Test 1: check consistency of pressure derivatives. ---*/ + AD::Reset(); + AD::StartRecording(); + AD::RegisterInput(val_rho); + AD::RegisterInput(val_e); + + fluid_model->SetTDState_rhoe(val_rho, val_e); + su2double val_p_pred = fluid_model->GetPressure(); + AD::RegisterOutput(val_p_pred); + AD::StopRecording(); + + SU2_TYPE::SetDerivative(val_p_pred, 1.0); + AD::ComputeAdjoint(); + + /*--- Extract pressure derivatives from fluid model and AD. ---*/ + const su2double dpdrho_e_AD = SU2_TYPE::GetDerivative(val_rho); + const su2double dpde_rho_AD = SU2_TYPE::GetDerivative(val_e); + const su2double dpdrho_e_pred = fluid_model->GetdPdrho_e(); + const su2double dpde_rho_pred = fluid_model->GetdPde_rho(); + + CHECK(SU2_TYPE::GetValue(dpdrho_e_AD) == Approx(SU2_TYPE::GetValue(dpdrho_e_pred))); + CHECK(SU2_TYPE::GetValue(dpde_rho_AD) == Approx(SU2_TYPE::GetValue(dpde_rho_pred))); + + /*--- Test 2: check consistency of temperature derivatives. ---*/ + AD::Reset(); + AD::StartRecording(); + AD::RegisterInput(val_rho); + AD::RegisterInput(val_e); + + fluid_model->SetTDState_rhoe(val_rho, val_e); + su2double val_T_pred = fluid_model->GetTemperature(); + + AD::RegisterOutput(val_T_pred); + AD::StopRecording(); + + SU2_TYPE::SetDerivative(val_T_pred, 1.0); + AD::ComputeAdjoint(); + + /*--- Extract temperature derivatives from fluid model and AD. ---*/ + const su2double dTdrho_e_AD = SU2_TYPE::GetDerivative(val_rho); + const su2double dTde_rho_AD = SU2_TYPE::GetDerivative(val_e); + const su2double dTdrho_e_pred = fluid_model->GetdTdrho_e(); + const su2double dTde_rho_pred = fluid_model->GetdTde_rho(); + + CHECK(SU2_TYPE::GetValue(dTdrho_e_AD) == Approx(SU2_TYPE::GetValue(dTdrho_e_pred))); + CHECK(SU2_TYPE::GetValue(dTde_rho_AD) == Approx(SU2_TYPE::GetValue(dTde_rho_pred))); + + /*--- Test 3: check consistency of specific heat at constant pressure. ---*/ + const su2double drhode_p = -dpde_rho_AD / dpdrho_e_AD; + const su2double dTde_p = dTde_rho_AD + dTdrho_e_AD * drhode_p; + const su2double dhde_rho = 1 + dpde_rho_AD / val_rho; + const su2double dhdrho_e = -val_p * (1 / pow(val_rho, 2)) + dpdrho_e_AD / val_rho; + const su2double dhde_p = dhde_rho + drhode_p * dhdrho_e; + const su2double Cp_AD = dhde_p / dTde_p; + const su2double Cp_pred = fluid_model->GetCp(); + + CHECK(SU2_TYPE::GetValue(Cp_AD) == Approx(SU2_TYPE::GetValue(Cp_pred))); + + /*--- Test 4: check consistency of secondary variables for non-reflecting boundary conditions.---*/ + AD::Reset(); + AD::StartRecording(); + AD::RegisterInput(val_p); + AD::RegisterInput(val_rho); + + fluid_model->ComputeDerivativeNRBC_Prho(val_p, val_rho); + su2double val_s_pred = fluid_model->GetEntropy(); + + AD::RegisterOutput(val_s_pred); + AD::StopRecording(); + + SU2_TYPE::SetDerivative(val_s_pred, 1.0); + AD::ComputeAdjoint(); + const su2double dsdp_rho_AD = SU2_TYPE::GetDerivative(val_p); + const su2double dsdrho_p_AD = SU2_TYPE::GetDerivative(val_rho); + const su2double dsdp_rho_pred = fluid_model->GetdsdP_rho(); + const su2double dsdrho_p_pred = fluid_model->Getdsdrho_P(); + + CHECK(SU2_TYPE::GetValue(dsdp_rho_pred) == Approx(SU2_TYPE::GetValue(dsdp_rho_AD))); + CHECK(SU2_TYPE::GetValue(dsdrho_p_pred) == Approx(SU2_TYPE::GetValue(dsdrho_p_AD))); +} + +TEST_CASE("AD test case for ideal gas fluid model", "[AD tests]") { + CIdealGas* fluid_model = new CIdealGas(1.4, 287.0, true); + FluidModelADChecks(fluid_model, 101325, 300.0); + + delete fluid_model; +} + +TEST_CASE("AD test case for data-driven fluid model", "[AD tests]") { + std::stringstream config_options; + + config_options << "SOLVER=RANS" << std::endl; + config_options << "KIND_TURB_MODEL=SA" << std::endl; + config_options << "SA_OPTIONS= NONE" << std::endl; + config_options << "REYNOLDS_NUMBER=1e6" << std::endl; + config_options << "FLUID_MODEL=DATADRIVEN_FLUID" << std::endl; + config_options << "USE_PINN=YES" << std::endl; + config_options << "INTERPOLATION_METHOD=MLP" << std::endl; + config_options << "FILENAMES_INTERPOLATOR=(src/SU2/UnitTests/SU2_CFD/fluid/MLP_PINN.mlp)" << std::endl; + config_options << "CONV_NUM_METHOD_FLOW=JST" << std::endl; + + /*--- Setup ---*/ + + CConfig* config = new CConfig(config_options, SU2_COMPONENT::SU2_CFD, false); + + /*--- Define fluid model ---*/ + CDataDrivenFluid* fluid_model = new CDataDrivenFluid(config, false); + + FluidModelADChecks(fluid_model, 3e5, 520.0); + FluidModelADChecks(fluid_model, 1.83e6, 523.0); + + delete config; + delete fluid_model; +} diff --git a/UnitTests/SU2_CFD/fluid/MLP_PINN.mlp b/UnitTests/SU2_CFD/fluid/MLP_PINN.mlp new file mode 100644 index 000000000000..36084ee790fa --- /dev/null +++ b/UnitTests/SU2_CFD/fluid/MLP_PINN.mlp @@ -0,0 +1,78 @@ +
+ +[number of layers] +4 + +[neurons per layer] +2 +12 +12 +1 + +[activation function] +linear +exponential +exponential +linear + +[input names] +Density +Energy + +[input regularization method] +minmax + +[input normalization] ++1.0000000000002272e-01 +3.6000000000001620e+02 ++2.4999999999999913e+05 +5.5000000000000407e+05 + +[output names] +s + +[output regularization method] +minmax + +[output normalization] ++6.5239076364026619e+02 +1.5203988895015702e+03 + +
+ +[weights per layer] + +-2.2636230520308294e+00 -1.4376163759051570e+02 -1.8210265085365642e+00 -1.9392431999968291e+01 +7.7998972848161929e-01 -4.4451402056377132e-01 +1.1480586943782076e+00 +7.3911541657373481e-01 +6.6848364842168884e-01 -1.8271554443848029e+01 +1.2261285194926941e+00 -1.4498105832610020e+00 +-3.5792276167311754e-01 -4.6660012868153460e-02 +8.6960980388545261e-01 -3.3067252427727123e-01 +7.2901181049513930e-01 -4.5132436983111057e-01 -1.6721101091715045e+00 +1.6381708561036443e-01 -9.9953810361650641e-01 -1.6660397867362475e+00 -3.6845287976534608e-01 +3.2679042214120246e-01 + + ++5.9993107069789275e-01 -3.7968611358916876e-01 -9.1784196873856094e-01 +3.7697075096981791e-01 -2.4514594732936050e+00 -2.9404244326707329e-01 -9.4877021231483852e-02 -3.3980372028224931e-02 +4.2421189400580528e-01 +7.7781137867976824e-01 +7.8391084779202980e-02 -1.8389416804610961e+00 +-2.5408281524798354e-01 +9.0756663051344069e-03 +1.1584753496996323e+00 +2.3534308868577432e-03 +2.4490086543179976e+00 +5.5043198360778117e-02 +7.1243387886788068e-01 -1.3472356985325758e-02 -1.6022336815491792e-01 +7.9384957177751261e-03 -8.3913484678289282e-02 -5.0208325332694126e-01 +-1.3231543644220687e+00 +2.3890465005266312e-01 -2.7829788154280122e+00 -4.1684736117099767e-02 -1.7289853140913009e-01 -2.7452124285237439e-01 +1.9057689172006617e-01 -4.8499148958861135e-02 -1.5998171284591250e-01 -3.8444057771255657e-01 -1.7591798029573689e+00 -3.1998700856829099e-01 +-3.4460543761346853e+00 +2.8269088892223054e-01 -1.8007009126606924e-01 -1.8194428084477665e-01 -9.8097976562849054e-01 +2.2343131530917884e+00 -9.3480765212571959e-01 -2.1820922470878051e-01 +2.4998489167470859e+00 -9.2764413588769656e-01 +4.2116280346986166e+00 +5.7430289000882420e+00 +-1.3779943339666223e-01 +5.1527341679864391e-01 -2.0684081713014844e+00 -4.6713867186704139e-01 -1.6656574393452730e+00 +8.2916484143979841e-02 -6.2985392912561127e-03 -8.0554067455084744e-01 +1.5050572815527488e-01 -3.0403633272013114e-01 +9.3661086475363739e-02 -1.7366620874413785e-01 ++1.2102271004943301e+00 -1.4795362440831727e-01 -7.7934495467562570e-01 -5.9581359297919689e-01 -2.5799123516309956e+00 -4.2086823260415152e-01 -6.1754592301131395e-01 +5.3496586769756471e-01 -1.1988742301845021e+00 -1.1825507727456516e-01 -1.2989806049860451e+00 -1.5082167140110778e+00 +-1.5832999264655581e+00 -5.0541334265413407e-01 -1.2224436375090135e+00 +9.4464382557138807e-02 -7.7094226591729909e-01 -1.3308898524504738e+00 -5.6071570095690060e-01 -1.1808627032633583e-01 -6.8406003004295413e-01 -1.0851498125792971e+00 -1.6619882623877327e+00 +3.3905033683843949e-01 +-1.6613583604241693e+00 -4.7389354240091253e-01 -1.6404302611149377e+00 +5.6328884449292083e-01 -2.3886973163682126e+00 +6.3182847097032660e-02 -1.1988633757241718e+00 -1.0449760622285645e-01 -5.0007576677205112e-01 -5.7953124309145942e-01 +1.3744226228525147e-01 -5.2406676771136440e-01 +-5.2321502793378249e-01 -5.3150359391312596e-01 -8.2608918128172837e-01 -1.5179873908573804e+00 -1.3741534704444816e+00 -1.1396125599060034e+00 -2.4669798409655488e-01 +3.5463486969786873e-01 -1.4557579529418466e-01 +3.9772638519145487e-01 -7.3761409583500159e-01 +4.3638838398439539e-01 ++1.1339107378860229e+00 +1.7594521224843396e-01 -2.3113519941138065e+00 -1.6298684024567350e-01 +2.1654392231781072e+00 +1.1946181086317720e+00 +6.1504990167411666e-01 +3.5812470374750952e-02 +4.7359603213749768e-01 -1.3926908147980210e-01 +1.5092490082960155e+00 +6.2527693075989743e-01 +-1.8730091080176507e+00 +6.0253144933079306e-01 -8.4799895628536026e-01 -4.9738323769072662e-01 -2.7954591059886620e+00 -6.0772894919752340e-01 -1.6669559186193763e+00 +3.2575755465661199e-01 -6.3810153137096781e-01 -1.5742470796026808e+00 +4.0723523279497037e-01 -2.6629855030791610e-01 ++9.5260226581936475e-02 +1.3178352071446142e-01 -8.2706051782881629e-01 +4.3476689449955158e-01 -1.9510329069314138e+00 -6.1816074212742961e-02 -8.8250388388085288e-01 -3.9491669828062620e-01 -1.5457029407527009e-01 -8.1118953547083511e-02 -9.3695252718016830e-01 -7.2928015955932368e-01 + + +-1.1729556416685407e+00 ++6.5203789113121413e-01 +-1.8734538612518090e-01 ++2.1621137726863668e-01 ++5.6641315509463920e-03 ++2.0302117964378608e-01 ++8.4775779057667755e-02 +-3.0580176253474467e-01 ++3.0269028189313296e-01 ++5.6045172511572938e-01 +-1.2871102614766081e-01 +-1.2950131608167472e+00 + + +[biases per layer] ++0.0000000000000000e+00 +0.0000000000000000e+00 ++1.1016481462000773e+00 +2.3664012769409184e+00 -9.4722828005676618e-01 +2.9514075029104910e-02 -7.7331761508748165e-01 +7.3249514271738470e-01 +2.5926140499409794e-01 +8.9008692454169913e-01 +5.0307216362067246e-02 +5.9255316881972364e-01 -2.0202744615666726e-01 -4.3866869529767016e-01 ++3.7843782710203738e-01 +1.6775822623352205e-01 -6.9759335447123827e-01 -4.0155126735738134e-01 -2.5582386039767488e+00 -4.7188519950683777e-01 -7.9682095244914830e-01 -7.9066710997409528e-02 -6.3882846975992846e-01 -4.3560525651855958e-01 -1.3131160733413525e+00 -8.0222167363936081e-01 ++3.4454053855686528e-01 diff --git a/UnitTests/meson.build b/UnitTests/meson.build index a64b9a33522f..cfa80e4ee302 100644 --- a/UnitTests/meson.build +++ b/UnitTests/meson.build @@ -15,11 +15,15 @@ su2_cfd_tests = files(['Common/geometry/primal_grid/CPrimalGrid_tests.cpp', 'SU2_CFD/fluid/CFluidCantera_tests.cpp', 'Common/toolboxes/multilayer_perceptron/CLookUp_ANN_tests.cpp', 'SU2_CFD/numerics/CNumerics_tests.cpp', + 'SU2_CFD/fluid/CFluidModel_tests.cpp', 'SU2_CFD/gradients.cpp', 'SU2_CFD/windowing.cpp']) # Reverse-mode (algorithmic differentiation) tests: su2_cfd_tests_ad = files(['Common/simple_ad_test.cpp']) +if get_option('enable-mlpcpp') + su2_cfd_tests_ad = su2_cfd_tests_ad + files(['SU2_CFD/fluid/CFluidModel_tests_AD.cpp']) +endif # Forward-mode (direct differentiation) tests: su2_cfd_tests_dd = files(['Common/simple_directdiff_test.cpp']) diff --git a/config_template.cfg b/config_template.cfg index 0acf538f8562..06d8238c590a 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -441,7 +441,14 @@ FILENAMES_INTERPOLATOR= (MLP_1.mlp, MLP_2.mlp, MLP_3.mlp) % Relaxation factor for the Newton solvers in the data-driven fluid model DATADRIVEN_NEWTON_RELAXATION= 0.8 -% +% Use physics-informed neural network for calculation of the fluid caloric properties. +USE_PINN= YES + +% Optional initial guess for fluid density and static energy in data-driven fluid analysis. +DATADRIVEN_INITIAL_DENSITY= -1 +DATADRIVEN_INITIAL_ENERGY= -1 + + % Specify if there is ionization IONIZATION= NO % diff --git a/meson_scripts/init.py b/meson_scripts/init.py index e31d7229a783..0c7bf57fc854 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -77,7 +77,7 @@ def init_submodules( github_repo_mel = "https://github.com/pcarruscag/MEL" sha_version_fado = "ce7ee018e4e699af5028d69baa1939fea290e18a" github_repo_fado = "https://github.com/pcarruscag/FADO" - sha_version_mlpcpp = "6865a58b22f21a92977839d9c93eae9522402f55" + sha_version_mlpcpp = "e19ca0cafb28c4b7ba5b8cffef42883259b00dc0" github_repo_mlpcpp = "https://github.com/EvertBunschoten/MLPCpp" medi_name = "MeDiPack" From 7b27fe783b30d4b6d95bc5337e77d9cf5277efad Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 29 Apr 2025 17:21:58 +0200 Subject: [PATCH 097/173] deleting chemical dictionary --- SU2_CFD/include/fluid/CFluidCantera.hpp | 2 +- SU2_CFD/src/fluid/CFluidCantera.cpp | 70 +++++++++++++++++++------ 2 files changed, 54 insertions(+), 18 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 3b1486301687..37a59a3be45c 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -78,7 +78,7 @@ class CFluidCantera final : public CFluidModel { * \brief Return a string(dictionary) with chemical species and its mass fraction value. * \param[in] val_scalars - Scalar mass fraction. */ - string DictionaryChemicalComposition(const su2double* val_scalars); + //string DictionaryChemicalComposition(const su2double* val_scalars); #endif /*! diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index de6ad573dd51..f45b7d3deec2 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -87,10 +87,22 @@ void CFluidCantera::SetMassDiffusivityModel(const CConfig* config) { #ifdef USE_CANTERA void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { - DictionaryChemicalComposition(config->GetSpecies_Init()); - su2double T_ref = 298.15; - sol->thermo()->setState_TPY(GetValue(T_ref), GetValue(Pressure_Thermodynamic), chemical_composition); + //DictionaryChemicalComposition(config->GetSpecies_Init()); + /*--- Set mass fractions. ---*/ const int nsp = sol->thermo()->nSpecies(); + su2double val_scalars_sum{0.0}; + su2double massFractions[nsp]{0.0}; + for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { + int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); + massFractions[speciesIndex] = config->GetSpecies_Init()[i_scalar]; + val_scalars_sum += config->GetSpecies_Init()[i_scalar]; + } + sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); + massFractions[n_species_mixture - 1] = 1 - val_scalars_sum; + sol->thermo()->setMassFractions(massFractions); + su2double T_ref = 298.15; + sol->thermo()->setState_TP(GetValue(T_ref), GetValue(Pressure_Thermodynamic)); + //const int nsp = sol->thermo()->nSpecies(); // The universal gas constant times temperature is retrieved from cantera. const su2double uni_gas_constant_temp = sol->thermo()->RT(); vector enthalpiesSpecies(nsp); @@ -116,6 +128,7 @@ void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2dou //const int nsp = sol->thermo()->nSpecies(); // vector netProductionRates(nsp); // sol->kinetics()->getNetProductionRates(&netProductionRates[0]); + //su2double delta_time_test = 1E-15; sim->advance(delta_time); const su2double density_new = combustor->density(); for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { @@ -229,7 +242,7 @@ void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusio void CFluidCantera::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2double* val_temperature, const su2double* val_scalars) { - DictionaryChemicalComposition(val_scalars); + //DictionaryChemicalComposition(val_scalars); /*--- convergence criterion for temperature in [K], high accuracy needed for restarts. ---*/ su2double toll = 1e-5; su2double temp_iter = 300.0; @@ -239,9 +252,21 @@ void CFluidCantera::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2dou int counter = 0; + /*--- Set mass fractions. ---*/ + const int nsp = sol->thermo()->nSpecies(); + su2double val_scalars_sum{0.0}; + su2double massFractions[nsp]{0.0}; + for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { + int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); + massFractions[speciesIndex] = val_scalars[i_scalar]; + val_scalars_sum += val_scalars[speciesIndex]; + } + massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1 - val_scalars_sum; + sol->thermo()->setMassFractions(massFractions); + while ((abs(delta_temp_iter) > toll) && (counter++ < counter_limit)) { /*--- Set thermodynamic state based on the current value of temperature. ---*/ - sol->thermo()->setState_TPY(GetValue(temp_iter), GetValue(Pressure_Thermodynamic), chemical_composition); + sol->thermo()->setState_TP(GetValue(temp_iter), GetValue(Pressure_Thermodynamic)); su2double Enthalpy = sol->thermo()->enthalpy_mass(); su2double Cp = sol->thermo()->cp_mass(); @@ -262,22 +287,33 @@ void CFluidCantera::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2dou } } -string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars) { - su2double val_scalars_sum{0.0}; - chemical_composition=""; - for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { - chemical_composition.append(gasComposition[i_scalar] + ":" + to_string(val_scalars[i_scalar])+", "); - val_scalars_sum += val_scalars[i_scalar]; - } - chemical_composition.append(gasComposition[n_species_mixture - 1] + ":" + to_string(1.0 - val_scalars_sum)); +// string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars) { +// su2double val_scalars_sum{0.0}; +// chemical_composition=""; +// for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { +// chemical_composition.append(gasComposition[i_scalar] + ":" + to_string(val_scalars[i_scalar])+", "); +// val_scalars_sum += val_scalars[i_scalar]; +// } +// chemical_composition.append(gasComposition[n_species_mixture - 1] + ":" + to_string(1.0 - val_scalars_sum)); - return chemical_composition; -} +// return chemical_composition; +// } void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { - DictionaryChemicalComposition(val_scalars); + //DictionaryChemicalComposition(val_scalars); Temperature = val_temperature; - sol->thermo()->setState_TPY(GetValue(Temperature), GetValue(Pressure_Thermodynamic), chemical_composition); + /*--- Set mass fractions. ---*/ + const int nsp = sol->thermo()->nSpecies(); + su2double val_scalars_sum{0.0}; + su2double massFractions[nsp]{0.0}; + for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { + int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); + massFractions[speciesIndex] = val_scalars[i_scalar]; + val_scalars_sum += val_scalars[i_scalar]; + } + massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1 - val_scalars_sum; + sol->thermo()->setMassFractions(massFractions); + sol->thermo()->setState_TP(GetValue(Temperature), GetValue(Pressure_Thermodynamic)); Density = sol->thermo()->density(); Enthalpy = sol->thermo()->enthalpy_mass(); Cp = sol->thermo()->cp_mass(); From c12f5f693fba9ce50cac968cf71f651cdef40c75 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 30 Apr 2025 09:43:19 +0200 Subject: [PATCH 098/173] test source term --- SU2_CFD/src/fluid/CFluidCantera.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index f45b7d3deec2..df8dc46e63be 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -123,19 +123,21 @@ void CFluidCantera::ComputeMassDiffusivity() { } void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2double* val_scalars){ - combustor->insert(sol); - sim->setInitialTime(0.0); - //const int nsp = sol->thermo()->nSpecies(); - // vector netProductionRates(nsp); - // sol->kinetics()->getNetProductionRates(&netProductionRates[0]); + // combustor->insert(sol); + // su2double Delta_t_max = 20; + // combustor->setAdvanceLimit("temperature", Delta_t_max); + // sim->setInitialTime(0.0); + const int nsp = sol->thermo()->nSpecies(); + vector netProductionRates(nsp); + sol->kinetics()->getNetProductionRates(&netProductionRates[0]); //su2double delta_time_test = 1E-15; - sim->advance(delta_time); - const su2double density_new = combustor->density(); + //sim->advance(delta_time); + //const su2double density_new = combustor->density(); for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - const su2double scalar_new = combustor->massFraction(speciesIndex); - const su2double source_term_corr = (density_new * scalar_new - Density * val_scalars[iVar]) / abs(delta_time); - chemicalSourceTerm[iVar] = source_term_corr; // molarMasses[speciesIndex]*netProductionRates[speciesIndex]/ n_step; + // const su2double scalar_new = combustor->massFraction(speciesIndex); + // const su2double source_term_corr = (density_new * scalar_new - Density * val_scalars[iVar]) / abs(delta_time); + chemicalSourceTerm[iVar] = molarMasses[speciesIndex]*netProductionRates[speciesIndex]; // source_term_corr; } } From e537bb2f0796ce437cb2be5d864600775d423fce Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 1 May 2025 15:41:44 +0200 Subject: [PATCH 099/173] cleaning --- SU2_CFD/include/fluid/CFluidCantera.hpp | 8 -------- SU2_CFD/src/fluid/CFluidCantera.cpp | 16 ---------------- 2 files changed, 24 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 37a59a3be45c..1b3b6e193fb6 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -73,14 +73,6 @@ class CFluidCantera final : public CFluidModel { std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ std::unique_ptr MassDiffusivityPointers[ARRAYSIZE]; - #ifdef USE_CANTERA - /*! - * \brief Return a string(dictionary) with chemical species and its mass fraction value. - * \param[in] val_scalars - Scalar mass fraction. - */ - //string DictionaryChemicalComposition(const su2double* val_scalars); - #endif - /*! * \brief Compute mass diffusivity for species. */ diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index df8dc46e63be..c0b201efdb0d 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -87,7 +87,6 @@ void CFluidCantera::SetMassDiffusivityModel(const CConfig* config) { #ifdef USE_CANTERA void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { - //DictionaryChemicalComposition(config->GetSpecies_Init()); /*--- Set mass fractions. ---*/ const int nsp = sol->thermo()->nSpecies(); su2double val_scalars_sum{0.0}; @@ -102,7 +101,6 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { sol->thermo()->setMassFractions(massFractions); su2double T_ref = 298.15; sol->thermo()->setState_TP(GetValue(T_ref), GetValue(Pressure_Thermodynamic)); - //const int nsp = sol->thermo()->nSpecies(); // The universal gas constant times temperature is retrieved from cantera. const su2double uni_gas_constant_temp = sol->thermo()->RT(); vector enthalpiesSpecies(nsp); @@ -244,7 +242,6 @@ void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusio void CFluidCantera::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2double* val_temperature, const su2double* val_scalars) { - //DictionaryChemicalComposition(val_scalars); /*--- convergence criterion for temperature in [K], high accuracy needed for restarts. ---*/ su2double toll = 1e-5; su2double temp_iter = 300.0; @@ -289,20 +286,7 @@ void CFluidCantera::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2dou } } -// string CFluidCantera::DictionaryChemicalComposition(const su2double* val_scalars) { -// su2double val_scalars_sum{0.0}; -// chemical_composition=""; -// for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { -// chemical_composition.append(gasComposition[i_scalar] + ":" + to_string(val_scalars[i_scalar])+", "); -// val_scalars_sum += val_scalars[i_scalar]; -// } -// chemical_composition.append(gasComposition[n_species_mixture - 1] + ":" + to_string(1.0 - val_scalars_sum)); - -// return chemical_composition; -// } - void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { - //DictionaryChemicalComposition(val_scalars); Temperature = val_temperature; /*--- Set mass fractions. ---*/ const int nsp = sol->thermo()->nSpecies(); From f821c84825916820c244319dd2c9c66ae8126922 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 2 Jun 2025 10:12:13 +0200 Subject: [PATCH 100/173] adding option time integration --- Common/include/CConfig.hpp | 11 ++++- Common/src/CConfig.cpp | 4 +- SU2_CFD/include/fluid/CFluidCantera.hpp | 1 + SU2_CFD/src/fluid/CFluidCantera.cpp | 53 ++++++++++++++++--------- 4 files changed, 48 insertions(+), 21 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index b23c5a9b72a7..751b243d4a4f 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -85,7 +85,8 @@ class CConfig { string ChemicalMechanismFile; /*!< \brief Chemical Reaction mechanism used in cantera*/ string PhaseName; /*!< \brief Name of the phase in the chemical mechanism file used in cantera*/ unsigned short n_GasCompositionNames; /*!<\brief number of gases in mixture composition for cantera */ - bool Combustion; /*!< \brief Flag for Combustion Detailed chemistry problems using Cantera */ + bool Combustion, /*!< \brief Flag for Combustion Detailed chemistry problems using Cantera */ + Chemistry_Time_Integration; /*!< \brief Flag for Source term tiem-integration for Detailed chemistry using Cantera */ su2double Spark_Temperature; /*!< \bried Spark temperature used for ignition in detailed chemistry using Cantera*/ string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */ @@ -3895,11 +3896,17 @@ class CConfig { } /*! - * \brief Get information about the Combustion-Detailed chemistry usin Cantera problems. + * \brief Get information about the Combustion-Detailed chemistry using Cantera. * \return TRUE if combustion-detailed chemistry using Cantera is used; otherwise FALSE. */ bool GetCombustion(void) const { return Combustion; } + /*! + * \brief Get information about the source term time-integration using Cantera. + * \return TRUE if chemistry time-integration using Cantera is used; otherwise FALSE. + */ + bool GetChemistryTimeIntegration(void) const { return Chemistry_Time_Integration; } + /*! * \brief Get High temperature applied during spark ignition. */ diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 64165d634ed3..392aa7d023c4 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1198,8 +1198,10 @@ void CConfig::SetConfig_Options() { addStringOption("PHASE_NAME", PhaseName, string("gri30")); /*!\brief GAS_COMPOSITION \n DESCRIPTION: Gas composition names \n OPTIONS: see cantera homepage \n DEFAULT: \ingroup Config*/ addStringListOption("GAS_COMPOSITION_NAMES", n_GasCompositionNames, GasCompositionNames); - /*\brief COMBUSTION \n DESCRIPTION: Combustion- Detailed chemistry using Cantera \n DEFAULT: false \ingroup Config */ + /*\brief COMBUSTION \n DESCRIPTION: Combustion Detailed chemistry using Cantera \n DEFAULT: false \ingroup Config */ addBoolOption("COMBUSTION", Combustion, false); + /*\brief CHEMISTRY_TIME_INTEGRATION \n DESCRIPTION: Source term time-integration for Detailed chemistry using Cantera \n DEFAULT: false \ingroup Config */ + addBoolOption("CHEMISTRY_TIME_INTEGRATION", Chemistry_Time_Integration, false); /*!\brief SCHMIDT_LAM \n DESCRIPTION: Laminar Schmidt number of mass diffusion \n DEFAULT 1.0 (~for Gases) \ingroup Config*/ addDoubleOption("SPARK_TEMPERATURE", Spark_Temperature, 1000.0); diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 1b3b6e193fb6..d7bcf8027c7c 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -57,6 +57,7 @@ class CFluidCantera final : public CFluidModel { const string Transport_Model; /*!< \brief Transport model used for computing mixture properties*/ const string Chemical_MechanismFile; /*!< \brief Chemical reaction mechanism used for in cantera*/ const string Phase_Name; /*!< \brief Name of the phase used for in cantera*/ + const bool Chemistry_Time_Integration; /*!< \brief bool if time-integration is used for chemical source terms*/ static constexpr int ARRAYSIZE = 16; #ifdef USE_CANTERA diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index c0b201efdb0d..8b58d8b53e75 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -51,7 +51,8 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* Prandtl_Number(config->GetPrandtl_Turb()), Transport_Model(config->GetTransport_Model()), Chemical_MechanismFile(config->GetChemical_MechanismFile()), - Phase_Name(config->GetPhase_Name()){ + Phase_Name(config->GetPhase_Name()), + Chemistry_Time_Integration(config->GetChemistryTimeIntegration()){ if (n_species_mixture > ARRAYSIZE) { SU2_MPI::Error("Too many species, increase ARRAYSIZE", CURRENT_FUNCTION); } @@ -61,12 +62,12 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* sol->thermo()->getMolecularWeights(&molarMasses[0]); combustor = nullptr; sim = nullptr; - if (config->GetCombustion()) { + if (Chemistry_Time_Integration) { combustor = new IdealGasConstPressureReactor(); combustor->insert(sol); sim = new ReactorNet(); sim->addReactor(*combustor); - su2double Delta_t_max = 20; + su2double Delta_t_max = 0.1; combustor->setAdvanceLimit("temperature", Delta_t_max); } for (int iVar = 0; iVar < n_species_mixture; iVar++) { @@ -121,21 +122,37 @@ void CFluidCantera::ComputeMassDiffusivity() { } void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2double* val_scalars){ - // combustor->insert(sol); - // su2double Delta_t_max = 20; - // combustor->setAdvanceLimit("temperature", Delta_t_max); - // sim->setInitialTime(0.0); - const int nsp = sol->thermo()->nSpecies(); - vector netProductionRates(nsp); - sol->kinetics()->getNetProductionRates(&netProductionRates[0]); - //su2double delta_time_test = 1E-15; - //sim->advance(delta_time); - //const su2double density_new = combustor->density(); - for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { - int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - // const su2double scalar_new = combustor->massFraction(speciesIndex); - // const su2double source_term_corr = (density_new * scalar_new - Density * val_scalars[iVar]) / abs(delta_time); - chemicalSourceTerm[iVar] = molarMasses[speciesIndex]*netProductionRates[speciesIndex]; // source_term_corr; + if (Chemistry_Time_Integration) { + combustor->insert(sol); + su2double Delta_t_max = 0.1; + combustor->setAdvanceLimit("temperature", Delta_t_max); + sim->setInitialTime(0.0); + sim->advance(max(1E-15,0.0001*delta_time)); + sim->setTolerances(1E-12, 1E-12); + //const su2double density_new = combustor->density(); + // cout << "time simulated " << setprecision(12) << sim->time() << endl; + // cout << "Temperature before integration: " << setprecision(12) << Temperature << endl; + // cout << "Temperature after integration: " << setprecision(12) << combustor->temperature() << endl; + // cout << "Pressure combustor after integration: " << setprecision(12) << combustor->pressure() << endl; + for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { + int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); + const su2double scalar_new = combustor->massFraction(speciesIndex); + //const su2double scalat_old = val_scalars[iVar]; + // cout << "Species before integration: " << setprecision(12) << val_scalars[iVar] << endl; + // cout << "Species after integration: " << setprecision(12) << scalar_new << endl; + cout << "Time simulated: " << setprecision(12) << sim->time() << endl; + const su2double source_term_corr = Density * (scalar_new - val_scalars[iVar]) / abs(sim->time()); + // cout<<"source_term "<thermo()->nSpecies(); + vector netProductionRates(nsp); + sol->kinetics()->getNetProductionRates(&netProductionRates[0]); + for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { + int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); + chemicalSourceTerm[iVar] = molarMasses[speciesIndex] * netProductionRates[speciesIndex]; + } } } From 4428a03fc1e81fdb5dcf7d074d908595c22d19bd Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 3 Jun 2025 08:34:12 +0200 Subject: [PATCH 101/173] update parallel regression test --- TestCases/parallel_regression.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 0b5d8d80f233..24b4cfc6fd13 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1542,7 +1542,7 @@ def main(): species2_primitiveVenturi_mixingmodel.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel.cfg_file = "species2_primitiveVenturi_mixingmodel.cfg" species2_primitiveVenturi_mixingmodel.test_iter = 50 - species2_primitiveVenturi_mixingmodel.test_vals = [ -5.432322, -4.506693, -4.598961, -5.858079, -0.074848, -5.608093, 5.000000, -1.900665, 5.000000, -4.895929, 5.000000, -1.202887, 0.000544, 0.000484, 0.000060, 0.000000] + species2_primitiveVenturi_mixingmodel.test_vals = [ -5.732153, -4.561603, -4.665933, -5.864167, -0.069493, -5.583639, 5.000000, -1.381549, 5.000000, -4.869625, 5.000000, -1.453019, 0.000378, 0.000362, 0.000016, 0.000000] test_list.append(species2_primitiveVenturi_mixingmodel) # 2 species (1 eq) primitive venturi mixing using mixing model and bounded scalar transport @@ -1550,7 +1550,7 @@ def main(): species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_file = "species2_primitiveVenturi_mixingmodel_boundedscalar.cfg" species2_primitiveVenturi_mixingmodel_boundedscalar.test_iter = 50 - species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.396930, -4.441229, -4.531561, -6.119468, -0.129257, -5.681246, 5.000000, -1.986168, 5.000000, -4.959587, 5.000000, -1.880063, 0.000297, 0.000297, 0.000000, 0.000000] + species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.688210, -4.507478, -4.611654, -6.120321, -0.118407, -5.705981, 5.000000, -1.439850, 5.000000, -4.922431, 5.000000, -1.768043, 0.000313, 0.000313, 0.000000, 0.000000] test_list.append(species2_primitiveVenturi_mixingmodel_boundedscalar) # 2 species (1 eq) primitive venturi mixing using mixing model including viscosity, thermal conductivity and inlet markers for SA turbulence model @@ -1566,7 +1566,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_iter = 50 - species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_vals = [-5.683102, -4.564193, -4.448313, -6.737904, 2.044729, -5.467878, 30.000000, -7.621295, 12.000000, -8.052264, 8.000000, -8.963883, 2.092215, 1.000000, 0.600000, 0.492215] + species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_vals = [-5.820188, -4.627870, -4.556574, -6.834134, 2.077283, -5.481298, 30.000000, -7.317611, 12.000000, -8.064489, 8.000000, -8.902923, 2.092310, 1.000000, 0.600000, 0.492310] test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2) # 2 species (1 eq) primitive venturi mixing using mixing model including heat capacity and mass diffusivity NonDimensional case @@ -1574,7 +1574,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_iter = 50 - species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.273052, -4.863236, -4.734578, -7.722857, 1.740741, -5.073467, 10.000000, -2.926106, 3.000000, -5.186545, 5.000000, -5.929953, 2.092322, 1.000000, 0.600000, 0.492322] + species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.407825, -4.920839, -4.842095, -7.820571, 1.773871, -5.086936, 10.000000, -2.736335, 3.000000, -5.216316, 5.000000, -5.855262, 2.092350, 1.000000, 0.600000, 0.492350] test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND) # 2 species (1 eq) primitive venturi mixing From faa4cdbc5af580fd83b5701e2c2717fe55cd4698 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 3 Jun 2025 14:02:45 +0200 Subject: [PATCH 102/173] adding temperature limits incompressible solver --- Common/include/CConfig.hpp | 8 ++++++++ Common/src/CConfig.cpp | 18 ++++++++++++++++++ .../include/variables/CIncEulerVariable.hpp | 3 ++- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 4 ++-- SU2_CFD/src/variables/CIncEulerVariable.cpp | 5 +++++ 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index ce401873a14c..7f22bb9ddf09 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -876,6 +876,8 @@ class CConfig { nPrandtl_Lam, /*!< \brief Number of species laminar Prandtl number. */ nPrandtl_Turb, /*!< \brief Number of species turbulent Prandtl number. */ nConstant_Lewis_Number; /*!< \brief Number of species Lewis Number. */ + su2double* Inc_Temperature_Limits; /*!< \brief Temperature limits for incompressible energy equation. */ + unsigned short nInc_Temperature_Limits; /*!< \brief Number of entries of INC_TEMPERATURE_LIMITS */ su2double Diffusivity_Constant; /*!< \brief Constant mass diffusivity for scalar transport. */ su2double Diffusivity_ConstantND; /*!< \brief Non-dim. constant mass diffusivity for scalar transport. */ su2double Schmidt_Number_Laminar; /*!< \brief Laminar Schmidt number for mass diffusion. */ @@ -2132,6 +2134,12 @@ class CConfig { */ su2double GetInc_Temperature_Init(void) const { return Inc_Temperature_Init; } + /*! + * \brief Get the temperature limits for incompressible flows when energy equation is enabled. + * \return minimum and maximum temperature limits. + */ + su2double GetInc_Temperature_Limits(unsigned short iVar) const { return Inc_Temperature_Limits[iVar]; } + /*! * \brief Get the flag for activating species transport clipping. * \return Flag for species clipping. diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index a1f4df53da90..ce8f2fc6229d 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1396,6 +1396,8 @@ void CConfig::SetConfig_Options() { addDoubleOption("INC_INLET_DAMPING", Inc_Inlet_Damping, 0.1); /*!\brief INC_OUTLET_DAMPING \n DESCRIPTION: Damping factor applied to the iterative updates to the pressure at a mass flow outlet in incompressible flow (0.1 by default). \ingroup Config*/ addDoubleOption("INC_OUTLET_DAMPING", Inc_Outlet_Damping, 0.1); + /*!\brief INC_TEMPERATURE_LIMITS \n DESCRIPTION: Temperature limits (minimum and maximum values) for energy equation in the incompressible solver \ingroup Config*/ + addDoubleListOption("INC_TEMPERATURE_LIMITS", nInc_Temperature_Limits, Inc_Temperature_Limits); /*--- Options related to the species solver. ---*/ @@ -3939,6 +3941,22 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i } } + if (Energy_Equation && (Inc_Temperature_Limits == nullptr)) { + Inc_Temperature_Limits = new su2double[2]; + Inc_Temperature_Limits[0] = 0.0; + Inc_Temperature_Limits[1] = 5000.0; + nInc_Temperature_Limits = 2; + } + + /*--- Check whether the number of entries of INC_TEMPERATURE_LIMITS are equal to 2.--- */ + + if ((nInc_Temperature_Limits != 2) && (Inc_Temperature_Limits != nullptr)) { + SU2_MPI::Error( + "The use of INC_TEMPERATURE_LIMITS requires the number of entries to be equal to 2: Minimum " + "Temperature, Maximum Temperature", + CURRENT_FUNCTION); + } + /*--- Set default values for various fluid properties. ---*/ const su2double Molecular_Weight_Default = 28.96; diff --git a/SU2_CFD/include/variables/CIncEulerVariable.hpp b/SU2_CFD/include/variables/CIncEulerVariable.hpp index 1daf3e010de9..1439bfde37aa 100644 --- a/SU2_CFD/include/variables/CIncEulerVariable.hpp +++ b/SU2_CFD/include/variables/CIncEulerVariable.hpp @@ -71,6 +71,7 @@ class CIncEulerVariable : public CFlowVariable { VectorType Streamwise_Periodic_RecoveredPressure, /*!< \brief Recovered/Physical pressure [Pa] for streamwise periodic flow. */ Streamwise_Periodic_RecoveredTemperature; /*!< \brief Recovered/Physical temperature [K] for streamwise periodic flow. */ + su2double Inc_Temperature_Limits[2]; /*!< \brief contains temperature limits for energy equation. */ public: /*! * \brief Constructor of the class. @@ -118,7 +119,7 @@ class CIncEulerVariable : public CFlowVariable { */ inline bool SetTemperature(unsigned long iPoint, su2double val_temperature) final { Primitive(iPoint, indices.Temperature()) = val_temperature; - return val_temperature <= 0.0; + return (val_temperature <= Inc_Temperature_Limits[0]) || (val_temperature >= Inc_Temperature_Limits[1]); } /*! diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index ae477c0aae03..11abdf1cce4b 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -237,9 +237,9 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned /*--- Initialize the solution to the far-field state everywhere. ---*/ if (navier_stokes) { - if (energy_multicomponent){ + if (energy_multicomponent) { nodes = new CIncNSVariable(Pressure_Inf, Velocity_Inf, Enthalpy_Inf, nPoint, nDim, nVar, config); - }else{ + } else { nodes = new CIncNSVariable(Pressure_Inf, Velocity_Inf, Temperature_Inf, nPoint, nDim, nVar, config); } } else { diff --git a/SU2_CFD/src/variables/CIncEulerVariable.cpp b/SU2_CFD/src/variables/CIncEulerVariable.cpp index 215f351ab55a..8936f351d80d 100644 --- a/SU2_CFD/src/variables/CIncEulerVariable.cpp +++ b/SU2_CFD/src/variables/CIncEulerVariable.cpp @@ -63,6 +63,11 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *veloci if (config->GetStreamwise_Periodic_Temperature()) Streamwise_Periodic_RecoveredTemperature.resize(nPoint) = su2double(0.0); } + + if (config->GetEnergy_Equation()) { + Inc_Temperature_Limits[0] = config->GetInc_Temperature_Limits(0); + Inc_Temperature_Limits[1] = config->GetInc_Temperature_Limits(1); + } } bool CIncEulerVariable::SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel) { From 395430d04d33df6c489e597ac7064fc65f115a96 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 4 Jun 2025 15:52:09 +0200 Subject: [PATCH 103/173] adding adj enthalpy fields for incompressible solver --- SU2_CFD/include/output/CAdjFlowIncOutput.hpp | 1 + SU2_CFD/src/output/CAdjFlowIncOutput.cpp | 90 +++++++++++++++++--- SU2_PY/SU2/io/historyMap.py | 12 +++ 3 files changed, 89 insertions(+), 14 deletions(-) diff --git a/SU2_CFD/include/output/CAdjFlowIncOutput.hpp b/SU2_CFD/include/output/CAdjFlowIncOutput.hpp index 2aee3d236ee9..725aefba332d 100644 --- a/SU2_CFD/include/output/CAdjFlowIncOutput.hpp +++ b/SU2_CFD/include/output/CAdjFlowIncOutput.hpp @@ -40,6 +40,7 @@ class CAdjFlowIncOutput final: public CAdjFlowOutput { RADIATION_MODEL rad_model; /*!< \brief The kind of radiation model */ bool heat; /*!< \brief Boolean indicating whether have a heat problem*/ bool weakly_coupled_heat; /*!< \brief Boolean indicating whether have a weakly coupled heat equation*/ + bool multicomponent; /*!< \brief Boolean indicating whether have a multicomponent problem*/ public: diff --git a/SU2_CFD/src/output/CAdjFlowIncOutput.cpp b/SU2_CFD/src/output/CAdjFlowIncOutput.cpp index 140ab6d7bdd7..257ff3fea312 100644 --- a/SU2_CFD/src/output/CAdjFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowIncOutput.cpp @@ -37,6 +37,8 @@ CAdjFlowIncOutput::CAdjFlowIncOutput(CConfig *config, unsigned short nDim) : CAd weakly_coupled_heat = config->GetWeakly_Coupled_Heat(); + multicomponent = (config->GetKind_FluidModel() == FLUID_MIXTURE); + rad_model = config->GetKind_RadiationModel(); /*--- Set the default history fields if nothing is set in the config file ---*/ @@ -113,7 +115,11 @@ void CAdjFlowIncOutput::SetHistoryOutputFields(CConfig *config) { } /// DESCRIPTION: Maximum residual of the temperature. if (heat || weakly_coupled_heat) { - AddHistoryOutput("RMS_ADJ_TEMPERATURE", "rms[A_T]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint temperature.", HistoryFieldType::RESIDUAL); + if (multicomponent){ + AddHistoryOutput("RMS_ADJ_ENTHALPY", "rms[A_h]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the enthalpy.", HistoryFieldType::RESIDUAL); + } else { + AddHistoryOutput("RMS_ADJ_TEMPERATURE", "rms[A_T]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint temperature.", HistoryFieldType::RESIDUAL); + } } if (config->GetKind_Streamwise_Periodic() == ENUM_STREAMWISE_PERIODIC::MASSFLOW) { @@ -141,7 +147,11 @@ void CAdjFlowIncOutput::SetHistoryOutputFields(CConfig *config) { } /// DESCRIPTION: Maximum residual of the temperature. if (heat || weakly_coupled_heat) { - AddHistoryOutput("MAX_ADJ_TEMPERATURE", "max[A_T]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the temperature.", HistoryFieldType::RESIDUAL); + if (multicomponent) { + AddHistoryOutput("MAX_ADJ_ENTHALPY", "max[A_h]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the enthalpy.", HistoryFieldType::RESIDUAL); + } else { + AddHistoryOutput("MAX_ADJ_TEMPERATURE", "max[A_T]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the temperature.", HistoryFieldType::RESIDUAL); + } } AddHistoryOutputFields_AdjScalarMAX_RES(config); @@ -213,8 +223,17 @@ void CAdjFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS SetHistoryOutputValue("RMS_ADJ_TEMPERATURE", log10(adjheat_solver->GetRes_RMS(0))); } if (heat) { - if (nDim == 3) SetHistoryOutputValue("RMS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_RMS(4))); - else SetHistoryOutputValue("RMS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_RMS(3))); + if (multicomponent) { + if (nDim == 3) + SetHistoryOutputValue("RMS_ADJ_ENTHALPY", log10(adjflow_solver->GetRes_RMS(4))); + else + SetHistoryOutputValue("RMS_ADJ_ENTHALPY", log10(adjflow_solver->GetRes_RMS(3))); + } else { + if (nDim == 3) + SetHistoryOutputValue("RMS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_RMS(4))); + else + SetHistoryOutputValue("RMS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_RMS(3))); + } } if (config->AddRadiation()) { @@ -235,8 +254,17 @@ void CAdjFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjheat_solver->GetRes_Max(0))); } if (heat) { - if (nDim == 3) SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_Max(4))); - else SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_Max(3))); + if (multicomponent) { + if (nDim == 3) + SetHistoryOutputValue("MAX_ADJ_ENTHALPY", log10(adjflow_solver->GetRes_Max(4))); + else + SetHistoryOutputValue("MAX_ADJ_ENTHALPY", log10(adjflow_solver->GetRes_Max(3))); + } else { + if (nDim == 3) + SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_Max(4))); + else + SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_Max(3))); + } } if (multiZone) { @@ -250,8 +278,17 @@ void CAdjFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS SetHistoryOutputValue("BGS_ADJ_TEMPERATURE", log10(adjheat_solver->GetRes_BGS(0))); } if (heat) { - if (nDim == 3) SetHistoryOutputValue("BGS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_BGS(4))); - else SetHistoryOutputValue("BGS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_BGS(3))); + if (multicomponent) { + if (nDim == 3) + SetHistoryOutputValue("BGS_ADJ_ENTHALPY", log10(adjflow_solver->GetRes_BGS(4))); + else + SetHistoryOutputValue("BGS_ADJ_ENTHALPY", log10(adjflow_solver->GetRes_BGS(3))); + } else { + if (nDim == 3) + SetHistoryOutputValue("BGS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_BGS(4))); + else + SetHistoryOutputValue("BGS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_BGS(3))); + } } if (config->AddRadiation()) { @@ -298,7 +335,11 @@ void CAdjFlowIncOutput::SetVolumeOutputFields(CConfig *config) { /// DESCRIPTION: Adjoint Velocity z-component. AddVolumeOutput("ADJ_VELOCITY-Z", "Adjoint_Velocity_z", "SOLUTION", "z-component of the adjoint velocity vector"); } - AddVolumeOutput("ADJ_TEMPERATURE", "Adjoint_Temperature", "SOLUTION", "Adjoint temperature"); + if (multicomponent && heat) { + AddVolumeOutput("ADJ_ENTHALPY", "Adjoint_Enthalpy", "SOLUTION", "Adjoint_Enthalpy"); + } else { + AddVolumeOutput("ADJ_TEMPERATURE", "Adjoint_Temperature", "SOLUTION", "Adjoint temperature"); + } SetVolumeOutputFieldsAdjScalarSolution(config); @@ -328,7 +369,11 @@ void CAdjFlowIncOutput::SetVolumeOutputFields(CConfig *config) { AddVolumeOutput("RES_ADJ_VELOCITY-Z", "Residual_Adjoint_Velocity_z", "RESIDUAL", "Residual of the adjoint z-velocity"); } /// DESCRIPTION: Residual of the adjoint energy. - AddVolumeOutput("RES_ADJ_TEMPERATURE", "Residual_Adjoint_Heat", "RESIDUAL", "Residual of the adjoint temperature"); + if (multicomponent && heat) { + AddVolumeOutput("RES_ADJ_ENTHALPY", "Residual_Adjoint_Heat", "RESIDUAL", "Residual of the adjoint enthalpy"); + } else { + AddVolumeOutput("RES_ADJ_TEMPERATURE", "Residual_Adjoint_Heat", "RESIDUAL", "Residual of the adjoint temperature"); + } SetVolumeOutputFieldsAdjScalarResidual(config); @@ -383,8 +428,17 @@ void CAdjFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSo SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjHeat->GetSolution(iPoint, 0)); } else { - if (nDim == 3) SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 4)); - else SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 3)); + if (multicomponent) { + if (nDim == 3) + SetVolumeOutputValue("ADJ_ENTHALPY", iPoint, Node_AdjFlow->GetSolution(iPoint, 4)); + else + SetVolumeOutputValue("ADJ_ENTHALPY", iPoint, Node_AdjFlow->GetSolution(iPoint, 3)); + } else { + if (nDim == 3) + SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 4)); + else + SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 3)); + } } // Radiation @@ -398,9 +452,17 @@ void CAdjFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSo SetVolumeOutputValue("RES_ADJ_VELOCITY-Y", iPoint, Node_AdjFlow->GetSolution(iPoint, 2) - Node_AdjFlow->GetSolution_Old(iPoint, 2)); if (nDim == 3) { SetVolumeOutputValue("RES_ADJ_VELOCITY-Z", iPoint, Node_AdjFlow->GetSolution(iPoint, 3) - Node_AdjFlow->GetSolution_Old(iPoint, 3)); - SetVolumeOutputValue("RES_ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 4) - Node_AdjFlow->GetSolution_Old(iPoint, 4)); + if (multicomponent) { + SetVolumeOutputValue("RES_ADJ_ENTHALPY", iPoint, Node_AdjFlow->GetSolution(iPoint, 4) - Node_AdjFlow->GetSolution_Old(iPoint, 4)); + } else { + SetVolumeOutputValue("RES_ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 4) - Node_AdjFlow->GetSolution_Old(iPoint, 4)); + } } else { - SetVolumeOutputValue("RES_ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 3) - Node_AdjFlow->GetSolution_Old(iPoint, 3)); + if (multicomponent) { + SetVolumeOutputValue("RES_ADJ_ENTHALPY", iPoint, Node_AdjFlow->GetSolution(iPoint, 3) - Node_AdjFlow->GetSolution_Old(iPoint, 3)); + } else { + SetVolumeOutputValue("RES_ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 3) - Node_AdjFlow->GetSolution_Old(iPoint, 3)); + } } if (config->AddRadiation()) { diff --git a/SU2_PY/SU2/io/historyMap.py b/SU2_PY/SU2/io/historyMap.py index be17da146431..e98684e50655 100644 --- a/SU2_PY/SU2/io/historyMap.py +++ b/SU2_PY/SU2/io/historyMap.py @@ -810,6 +810,12 @@ "HEADER": "max[A_T]", "TYPE": "RESIDUAL", }, + "MAX_ADJ_ENTHALPY": { + "DESCRIPTION": "Maximum residual of the enthalpy.", + "GROUP": "MAX_RES", + "HEADER": "max[A_h]", + "TYPE": "RESIDUAL", + }, "MAX_ADJ_TKE": { "DESCRIPTION": "Maximum residual of the adjoint kinetic " "energy.", "GROUP": "MAX_RES", @@ -1055,6 +1061,12 @@ "HEADER": "rms[A_T]", "TYPE": "RESIDUAL", }, + "RMS_ADJ_ENTHALPY": { + "DESCRIPTION": "Root mean square residual of the " "adjoint enthalpy.", + "GROUP": "RMS_RES", + "HEADER": "rms[A_h]", + "TYPE": "RESIDUAL", + }, "RMS_ADJ_TKE": { "DESCRIPTION": "Root-mean square residual of the adjoint " "kinetic energy.", "GROUP": "RMS_RES", From 247e64be29a1b9f58a96cc317211724ebae641d2 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 4 Jun 2025 16:38:13 +0200 Subject: [PATCH 104/173] adding HeatFluxDiffusion in Preaccumulation --- SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index 53af20096d63..882191d0224d 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -553,6 +553,9 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); AD::SetPreaccIn(TauWall_i); AD::SetPreaccIn(TauWall_j); AD::SetPreaccIn(Normal, nDim); + if (energy_multicomponent) { + AD::SetPreaccIn(HeatFluxDiffusion); + } unsigned short iVar, jVar, iDim; From f232ff5e96cf6bba3f8cb8a4e8396a44df5ad6ff Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 5 Jun 2025 11:08:14 +0200 Subject: [PATCH 105/173] updating to preconditioning branch --- SU2_CFD/include/output/CAdjFlowIncOutput.hpp | 1 + SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 4 + SU2_CFD/src/output/CAdjFlowIncOutput.cpp | 90 +++++++++++++++++--- SU2_PY/SU2/io/historyMap.py | 12 +++ TestCases/parallel_regression.py | 8 +- 5 files changed, 97 insertions(+), 18 deletions(-) diff --git a/SU2_CFD/include/output/CAdjFlowIncOutput.hpp b/SU2_CFD/include/output/CAdjFlowIncOutput.hpp index 2aee3d236ee9..725aefba332d 100644 --- a/SU2_CFD/include/output/CAdjFlowIncOutput.hpp +++ b/SU2_CFD/include/output/CAdjFlowIncOutput.hpp @@ -40,6 +40,7 @@ class CAdjFlowIncOutput final: public CAdjFlowOutput { RADIATION_MODEL rad_model; /*!< \brief The kind of radiation model */ bool heat; /*!< \brief Boolean indicating whether have a heat problem*/ bool weakly_coupled_heat; /*!< \brief Boolean indicating whether have a weakly coupled heat equation*/ + bool multicomponent; /*!< \brief Boolean indicating whether have a multicomponent problem*/ public: diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index 5869ba9de225..0cb752473d13 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -553,6 +553,10 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); AD::SetPreaccIn(TauWall_i); AD::SetPreaccIn(TauWall_j); AD::SetPreaccIn(Normal, nDim); + if (energy_multicomponent) { + AD::SetPreaccIn(HeatFluxDiffusion); + AD::SetPreaccIn(MassCorrFluxDiffusion); + } unsigned short iVar, jVar, iDim; diff --git a/SU2_CFD/src/output/CAdjFlowIncOutput.cpp b/SU2_CFD/src/output/CAdjFlowIncOutput.cpp index 140ab6d7bdd7..bc3970909cf2 100644 --- a/SU2_CFD/src/output/CAdjFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowIncOutput.cpp @@ -37,6 +37,8 @@ CAdjFlowIncOutput::CAdjFlowIncOutput(CConfig *config, unsigned short nDim) : CAd weakly_coupled_heat = config->GetWeakly_Coupled_Heat(); + multicomponent = (config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA); + rad_model = config->GetKind_RadiationModel(); /*--- Set the default history fields if nothing is set in the config file ---*/ @@ -113,7 +115,11 @@ void CAdjFlowIncOutput::SetHistoryOutputFields(CConfig *config) { } /// DESCRIPTION: Maximum residual of the temperature. if (heat || weakly_coupled_heat) { - AddHistoryOutput("RMS_ADJ_TEMPERATURE", "rms[A_T]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint temperature.", HistoryFieldType::RESIDUAL); + if (multicomponent){ + AddHistoryOutput("RMS_ADJ_ENTHALPY", "rms[A_h]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the enthalpy.", HistoryFieldType::RESIDUAL); + } else { + AddHistoryOutput("RMS_ADJ_TEMPERATURE", "rms[A_T]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint temperature.", HistoryFieldType::RESIDUAL); + } } if (config->GetKind_Streamwise_Periodic() == ENUM_STREAMWISE_PERIODIC::MASSFLOW) { @@ -141,7 +147,11 @@ void CAdjFlowIncOutput::SetHistoryOutputFields(CConfig *config) { } /// DESCRIPTION: Maximum residual of the temperature. if (heat || weakly_coupled_heat) { - AddHistoryOutput("MAX_ADJ_TEMPERATURE", "max[A_T]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the temperature.", HistoryFieldType::RESIDUAL); + if (multicomponent) { + AddHistoryOutput("MAX_ADJ_ENTHALPY", "max[A_h]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the enthalpy.", HistoryFieldType::RESIDUAL); + } else { + AddHistoryOutput("MAX_ADJ_TEMPERATURE", "max[A_T]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the temperature.", HistoryFieldType::RESIDUAL); + } } AddHistoryOutputFields_AdjScalarMAX_RES(config); @@ -213,8 +223,17 @@ void CAdjFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS SetHistoryOutputValue("RMS_ADJ_TEMPERATURE", log10(adjheat_solver->GetRes_RMS(0))); } if (heat) { - if (nDim == 3) SetHistoryOutputValue("RMS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_RMS(4))); - else SetHistoryOutputValue("RMS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_RMS(3))); + if (multicomponent) { + if (nDim == 3) + SetHistoryOutputValue("RMS_ADJ_ENTHALPY", log10(adjflow_solver->GetRes_RMS(4))); + else + SetHistoryOutputValue("RMS_ADJ_ENTHALPY", log10(adjflow_solver->GetRes_RMS(3))); + } else { + if (nDim == 3) + SetHistoryOutputValue("RMS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_RMS(4))); + else + SetHistoryOutputValue("RMS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_RMS(3))); + } } if (config->AddRadiation()) { @@ -235,8 +254,17 @@ void CAdjFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjheat_solver->GetRes_Max(0))); } if (heat) { - if (nDim == 3) SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_Max(4))); - else SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_Max(3))); + if (multicomponent) { + if (nDim == 3) + SetHistoryOutputValue("MAX_ADJ_ENTHALPY", log10(adjflow_solver->GetRes_Max(4))); + else + SetHistoryOutputValue("MAX_ADJ_ENTHALPY", log10(adjflow_solver->GetRes_Max(3))); + } else { + if (nDim == 3) + SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_Max(4))); + else + SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_Max(3))); + } } if (multiZone) { @@ -250,8 +278,17 @@ void CAdjFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS SetHistoryOutputValue("BGS_ADJ_TEMPERATURE", log10(adjheat_solver->GetRes_BGS(0))); } if (heat) { - if (nDim == 3) SetHistoryOutputValue("BGS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_BGS(4))); - else SetHistoryOutputValue("BGS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_BGS(3))); + if (multicomponent) { + if (nDim == 3) + SetHistoryOutputValue("BGS_ADJ_ENTHALPY", log10(adjflow_solver->GetRes_BGS(4))); + else + SetHistoryOutputValue("BGS_ADJ_ENTHALPY", log10(adjflow_solver->GetRes_BGS(3))); + } else { + if (nDim == 3) + SetHistoryOutputValue("BGS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_BGS(4))); + else + SetHistoryOutputValue("BGS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_BGS(3))); + } } if (config->AddRadiation()) { @@ -298,7 +335,11 @@ void CAdjFlowIncOutput::SetVolumeOutputFields(CConfig *config) { /// DESCRIPTION: Adjoint Velocity z-component. AddVolumeOutput("ADJ_VELOCITY-Z", "Adjoint_Velocity_z", "SOLUTION", "z-component of the adjoint velocity vector"); } - AddVolumeOutput("ADJ_TEMPERATURE", "Adjoint_Temperature", "SOLUTION", "Adjoint temperature"); + if (multicomponent && heat) { + AddVolumeOutput("ADJ_ENTHALPY", "Adjoint_Enthalpy", "SOLUTION", "Adjoint_Enthalpy"); + } else { + AddVolumeOutput("ADJ_TEMPERATURE", "Adjoint_Temperature", "SOLUTION", "Adjoint temperature"); + } SetVolumeOutputFieldsAdjScalarSolution(config); @@ -328,7 +369,11 @@ void CAdjFlowIncOutput::SetVolumeOutputFields(CConfig *config) { AddVolumeOutput("RES_ADJ_VELOCITY-Z", "Residual_Adjoint_Velocity_z", "RESIDUAL", "Residual of the adjoint z-velocity"); } /// DESCRIPTION: Residual of the adjoint energy. - AddVolumeOutput("RES_ADJ_TEMPERATURE", "Residual_Adjoint_Heat", "RESIDUAL", "Residual of the adjoint temperature"); + if (multicomponent && heat) { + AddVolumeOutput("RES_ADJ_ENTHALPY", "Residual_Adjoint_Heat", "RESIDUAL", "Residual of the adjoint enthalpy"); + } else { + AddVolumeOutput("RES_ADJ_TEMPERATURE", "Residual_Adjoint_Heat", "RESIDUAL", "Residual of the adjoint temperature"); + } SetVolumeOutputFieldsAdjScalarResidual(config); @@ -383,8 +428,17 @@ void CAdjFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSo SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjHeat->GetSolution(iPoint, 0)); } else { - if (nDim == 3) SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 4)); - else SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 3)); + if (multicomponent) { + if (nDim == 3) + SetVolumeOutputValue("ADJ_ENTHALPY", iPoint, Node_AdjFlow->GetSolution(iPoint, 4)); + else + SetVolumeOutputValue("ADJ_ENTHALPY", iPoint, Node_AdjFlow->GetSolution(iPoint, 3)); + } else { + if (nDim == 3) + SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 4)); + else + SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 3)); + } } // Radiation @@ -398,9 +452,17 @@ void CAdjFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSo SetVolumeOutputValue("RES_ADJ_VELOCITY-Y", iPoint, Node_AdjFlow->GetSolution(iPoint, 2) - Node_AdjFlow->GetSolution_Old(iPoint, 2)); if (nDim == 3) { SetVolumeOutputValue("RES_ADJ_VELOCITY-Z", iPoint, Node_AdjFlow->GetSolution(iPoint, 3) - Node_AdjFlow->GetSolution_Old(iPoint, 3)); - SetVolumeOutputValue("RES_ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 4) - Node_AdjFlow->GetSolution_Old(iPoint, 4)); + if (multicomponent) { + SetVolumeOutputValue("RES_ADJ_ENTHALPY", iPoint, Node_AdjFlow->GetSolution(iPoint, 4) - Node_AdjFlow->GetSolution_Old(iPoint, 4)); + } else { + SetVolumeOutputValue("RES_ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 4) - Node_AdjFlow->GetSolution_Old(iPoint, 4)); + } } else { - SetVolumeOutputValue("RES_ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 3) - Node_AdjFlow->GetSolution_Old(iPoint, 3)); + if (multicomponent) { + SetVolumeOutputValue("RES_ADJ_ENTHALPY", iPoint, Node_AdjFlow->GetSolution(iPoint, 3) - Node_AdjFlow->GetSolution_Old(iPoint, 3)); + } else { + SetVolumeOutputValue("RES_ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 3) - Node_AdjFlow->GetSolution_Old(iPoint, 3)); + } } if (config->AddRadiation()) { diff --git a/SU2_PY/SU2/io/historyMap.py b/SU2_PY/SU2/io/historyMap.py index 6adaec1ec519..8fb73d6b756c 100644 --- a/SU2_PY/SU2/io/historyMap.py +++ b/SU2_PY/SU2/io/historyMap.py @@ -822,6 +822,12 @@ "HEADER": "max[A_T]", "TYPE": "RESIDUAL", }, + "MAX_ADJ_ENTHALPY": { + "DESCRIPTION": "Maximum residual of the enthalpy.", + "GROUP": "MAX_RES", + "HEADER": "max[A_h]", + "TYPE": "RESIDUAL", + }, "MAX_ADJ_TKE": { "DESCRIPTION": "Maximum residual of the adjoint kinetic " "energy.", "GROUP": "MAX_RES", @@ -1083,6 +1089,12 @@ "HEADER": "rms[A_T]", "TYPE": "RESIDUAL", }, + "RMS_ADJ_ENTHALPY": { + "DESCRIPTION": "Root mean square residual of the " "adjoint enthalpy.", + "GROUP": "RMS_RES", + "HEADER": "rms[A_h]", + "TYPE": "RESIDUAL", + }, "RMS_ADJ_TKE": { "DESCRIPTION": "Root-mean square residual of the adjoint " "kinetic energy.", "GROUP": "RMS_RES", diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index a6c8cf296637..24b4cfc6fd13 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1542,7 +1542,7 @@ def main(): species2_primitiveVenturi_mixingmodel.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel.cfg_file = "species2_primitiveVenturi_mixingmodel.cfg" species2_primitiveVenturi_mixingmodel.test_iter = 50 - species2_primitiveVenturi_mixingmodel.test_vals = [-5.736233, -4.561289, -4.666830, -5.863760, -0.071055, -5.584743, 5.000000, -1.376449, 5.000000, -4.869012, 5.000000, -1.452251, 0.000372, 0.000356, 0.000016, 0.000000] + species2_primitiveVenturi_mixingmodel.test_vals = [ -5.732153, -4.561603, -4.665933, -5.864167, -0.069493, -5.583639, 5.000000, -1.381549, 5.000000, -4.869625, 5.000000, -1.453019, 0.000378, 0.000362, 0.000016, 0.000000] test_list.append(species2_primitiveVenturi_mixingmodel) # 2 species (1 eq) primitive venturi mixing using mixing model and bounded scalar transport @@ -1550,7 +1550,7 @@ def main(): species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_file = "species2_primitiveVenturi_mixingmodel_boundedscalar.cfg" species2_primitiveVenturi_mixingmodel_boundedscalar.test_iter = 50 - species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.689876, -4.507214, -4.611632, -6.120372, -0.118388, -5.705973, 5.000000, -1.437234, 5.000000, -4.924953, 5.000000, -1.768691, 0.000313, 0.000313, 0.000000, 0.000000] + species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.688210, -4.507478, -4.611654, -6.120321, -0.118407, -5.705981, 5.000000, -1.439850, 5.000000, -4.922431, 5.000000, -1.768043, 0.000313, 0.000313, 0.000000, 0.000000] test_list.append(species2_primitiveVenturi_mixingmodel_boundedscalar) # 2 species (1 eq) primitive venturi mixing using mixing model including viscosity, thermal conductivity and inlet markers for SA turbulence model @@ -1566,7 +1566,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_iter = 50 - species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_vals = [-5.830112, -4.504576, -4.654774, -7.014975, 2.317603, -5.509555, 30.000000, -6.906408, 11.000000, -8.227485, 8.000000, -9.294144, 2.077533, 1.000000, 0.600000, 0.477533] + species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_vals = [-5.820188, -4.627870, -4.556574, -6.834134, 2.077283, -5.481298, 30.000000, -7.317611, 12.000000, -8.064489, 8.000000, -8.902923, 2.092310, 1.000000, 0.600000, 0.492310] test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2) # 2 species (1 eq) primitive venturi mixing using mixing model including heat capacity and mass diffusivity NonDimensional case @@ -1574,7 +1574,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_iter = 50 - species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.429311, -4.805894, -4.943400, -7.978127, 2.012275, -5.115722, 10.000000, -2.264471, 2.000000, -5.061843, 4.000000, -5.055035, 2.077660, 1.000000, 0.600000, 0.477660] + species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.407825, -4.920839, -4.842095, -7.820571, 1.773871, -5.086936, 10.000000, -2.736335, 3.000000, -5.216316, 5.000000, -5.855262, 2.092350, 1.000000, 0.600000, 0.492350] test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND) # 2 species (1 eq) primitive venturi mixing From fcacd1815c977a215c031f255508571765f1929b Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 6 Jun 2025 11:46:43 +0200 Subject: [PATCH 106/173] updating JST and Lax-Friedrich --- .../numerics/flow/convection/centered.hpp | 6 +- .../src/numerics/flow/convection/centered.cpp | 56 ++++++++++++++++--- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/SU2_CFD/include/numerics/flow/convection/centered.hpp b/SU2_CFD/include/numerics/flow/convection/centered.hpp index 6e7d3190733a..c66359557334 100644 --- a/SU2_CFD/include/numerics/flow/convection/centered.hpp +++ b/SU2_CFD/include/numerics/flow/convection/centered.hpp @@ -48,7 +48,8 @@ class CCentLaxInc_Flow final : public CNumerics { Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ MeanDensity, MeanPressure, MeanBetaInc2, MeanEnthalpy, - MeanCp, MeanTemperature, /*!< \brief Mean values of primitive variables. */ + MeanCp, MeanTemperature, + MeanWorkingVar, /*!< \brief Mean values of primitive variables. */ MeandRhodT, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ Param_p, Param_Kappa_0, /*!< \brief Artificial dissipation parameters. */ Local_Lambda_i, Local_Lambda_j, @@ -108,7 +109,8 @@ class CCentJSTInc_Flow final : public CNumerics { Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ MeanDensity, MeanPressure, MeanBetaInc2, MeanEnthalpy, - MeanCp, MeanTemperature, /*!< \brief Mean values of primitive variables. */ + MeanCp, MeanTemperature, + MeanWorkingVar, /*!< \brief Mean values of primitive variables. */ MeandRhodT, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ Param_p, Param_Kappa_2, Param_Kappa_4, /*!< \brief Artificial dissipation parameters. */ diff --git a/SU2_CFD/src/numerics/flow/convection/centered.cpp b/SU2_CFD/src/numerics/flow/convection/centered.cpp index 5e15f35983fb..f80f1769ef88 100644 --- a/SU2_CFD/src/numerics/flow/convection/centered.cpp +++ b/SU2_CFD/src/numerics/flow/convection/centered.cpp @@ -97,7 +97,17 @@ CNumerics::ResidualType<> CCentLaxInc_Flow::ComputeResidual(const CConfig* confi DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; - Enthalpy_i = Cp_i*Temperature_i; Enthalpy_j = Cp_j*Temperature_j; + if (energy_multicomponent) { + Enthalpy_i = V_i[nDim + 9]; + Enthalpy_j = V_j[nDim + 9]; + WorkingVariable_i = Enthalpy_i; + WorkingVariable_j = Enthalpy_j; + } else { + Enthalpy_i = Cp_i * Temperature_i; + Enthalpy_j = Cp_j * Temperature_j; + WorkingVariable_i = Temperature_i; + WorkingVariable_j = Temperature_j; + } Area = 0.0; sq_vel_i = 0.0; sq_vel_j = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; @@ -121,6 +131,7 @@ CNumerics::ResidualType<> CCentLaxInc_Flow::ComputeResidual(const CConfig* confi MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); MeanCp = 0.5*(Cp_i + Cp_j); MeanTemperature = 0.5*(Temperature_i + Temperature_j); + MeanWorkingVar = 0.5*(WorkingVariable_i + WorkingVariable_j); /*--- We need the derivative of the equation of state to build the preconditioning matrix. For now, the only option is the ideal gas @@ -130,6 +141,12 @@ CNumerics::ResidualType<> CCentLaxInc_Flow::ComputeResidual(const CConfig* confi if (variable_density) { MeandRhodT = -MeanDensity/MeanTemperature; } + if (energy_multicomponent) { + MeandRhodT /= MeanCp ; + MeanCp = 1.0; + Cp_i = 1.0; + Cp_j = 1.0; + } /*--- Get projected flux tensor ---*/ @@ -138,7 +155,7 @@ CNumerics::ResidualType<> CCentLaxInc_Flow::ComputeResidual(const CConfig* confi /*--- Jacobians of the inviscid flux ---*/ if (implicit) { - GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, Jacobian_i); + GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanWorkingVar, &MeandRhodT, Normal, 0.5, Jacobian_i); for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { Jacobian_j[iVar][jVar] = Jacobian_i[iVar][jVar]; @@ -179,12 +196,13 @@ CNumerics::ResidualType<> CCentLaxInc_Flow::ComputeResidual(const CConfig* confi /*--- Computes differences btw. conservative variables ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar - 1; iVar++) Diff_V[iVar] = V_i[iVar]-V_j[iVar]; + Diff_V[nVar - 1] = WorkingVariable_i - WorkingVariable_j; /*--- Build the preconditioning matrix using mean values ---*/ - GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); + GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanWorkingVar, &MeandRhodT, Precon); /*--- Compute the local espectral radius of the preconditioned system and the stretching factor. ---*/ @@ -320,7 +338,17 @@ CNumerics::ResidualType<> CCentJSTInc_Flow::ComputeResidual(const CConfig* confi DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; - Enthalpy_i = Cp_i*Temperature_i; Enthalpy_j = Cp_j*Temperature_j; + if (energy_multicomponent) { + Enthalpy_i = V_i[nDim + 9]; + Enthalpy_j = V_j[nDim + 9]; + WorkingVariable_i = Enthalpy_i; + WorkingVariable_j = Enthalpy_j; + } else { + Enthalpy_i = Cp_i * Temperature_i; + Enthalpy_j = Cp_j * Temperature_j; + WorkingVariable_i = Temperature_i; + WorkingVariable_j = Temperature_j; + } Area = 0.0; sq_vel_i = 0.0; sq_vel_j = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; @@ -342,6 +370,7 @@ CNumerics::ResidualType<> CCentJSTInc_Flow::ComputeResidual(const CConfig* confi MeanPressure = 0.5*(Pressure_i + Pressure_j); MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); + MeanWorkingVar = 0.5*(WorkingVariable_i + WorkingVariable_j); MeanCp = 0.5*(Cp_i + Cp_j); MeanTemperature = 0.5*(Temperature_i + Temperature_j); @@ -353,6 +382,12 @@ CNumerics::ResidualType<> CCentJSTInc_Flow::ComputeResidual(const CConfig* confi if (variable_density) { MeandRhodT = -MeanDensity/MeanTemperature; } + if (energy_multicomponent) { + MeandRhodT /= MeanCp ; + MeanCp = 1.0; + Cp_i = 1.0; + Cp_j = 1.0; + } /*--- Get projected flux tensor ---*/ @@ -361,7 +396,7 @@ CNumerics::ResidualType<> CCentJSTInc_Flow::ComputeResidual(const CConfig* confi /*--- Jacobians of the inviscid flux ---*/ if (implicit) { - GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, Jacobian_i); + GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanWorkingVar, &MeandRhodT, Normal, 0.5, Jacobian_i); for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { Jacobian_j[iVar][jVar] = Jacobian_i[iVar][jVar]; @@ -405,12 +440,17 @@ CNumerics::ResidualType<> CCentJSTInc_Flow::ComputeResidual(const CConfig* confi for (iVar = 0; iVar < nVar; iVar++) { Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; - Diff_V[iVar] = V_i[iVar]-V_j[iVar]; + if (iVar == nVar - 1) { + Diff_V[iVar] = WorkingVariable_i - WorkingVariable_j; + } else { + Diff_V[iVar] = V_i[iVar] - V_j[iVar]; + } } + /*--- Build the preconditioning matrix using mean values ---*/ - GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); + GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanWorkingVar, &MeandRhodT, Precon); /*--- Compute the local spectral radius of the preconditioned system and the stretching factor. ---*/ From 5e1dacf33b1609f27963e9c91062037aa0aee461 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 18 Jun 2025 12:15:01 +0200 Subject: [PATCH 107/173] updating BC far-field for multicomponent flows --- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 51c0321039e6..6157511d50b5 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2184,6 +2184,7 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain const bool implicit = config->GetKind_TimeIntScheme() == EULER_IMPLICIT; const bool viscous = config->GetViscous(); + const bool energy_multicomponent = ((config->GetKind_FluidModel() == FLUID_MIXTURE) && (config->GetEnergy_Equation())); su2double Normal[MAXNDIM] = {0.0}; @@ -2228,6 +2229,15 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain V_infty[prim_idx.Temperature()] = GetTemperature_Inf(); + /*-- Enthalpy at far-field is needed for energy equation in multicomponent and reacting flows. ---*/ + if (energy_multicomponent) { + CFluidModel* auxFluidModel = solver_container[FLOW_SOL]->GetFluidModel(); + const su2double* scalar_infty = config->GetSpecies_Init(); + auxFluidModel->SetTDState_T(V_infty[prim_idx.Temperature()], + scalar_infty); // obtain enthalpy from temperature and species mass fractions + V_infty[prim_idx.Enthalpy()] = auxFluidModel->GetEnthalpy(); + } + /*--- Store the density. ---*/ V_infty[prim_idx.Density()] = GetDensity_Inf(); @@ -2263,7 +2273,7 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain /*--- Viscous residual contribution ---*/ - if (!viscous) continue; + if (!viscous || energy_multicomponent) continue; /*--- Set transport properties at infinity. ---*/ From 93f70ab661b1c74be2c8e9d7114e58e5a40532a6 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 20 Jun 2025 10:32:38 +0200 Subject: [PATCH 108/173] fix small bug conductivity prandtl --- SU2_CFD/src/fluid/CFluidScalar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/fluid/CFluidScalar.cpp b/SU2_CFD/src/fluid/CFluidScalar.cpp index a8775ea90df3..ef28a2c81983 100644 --- a/SU2_CFD/src/fluid/CFluidScalar.cpp +++ b/SU2_CFD/src/fluid/CFluidScalar.cpp @@ -169,7 +169,7 @@ su2double CFluidScalar::DavidsonViscosity(const su2double* val_scalars) { su2double CFluidScalar::WilkeConductivity(const su2double* val_scalars) { for (int iVar = 0; iVar < n_species_mixture; iVar++) { - ThermalConductivityPointers[iVar]->SetConductivity(Temperature, Density, Mu, 0.0, 0.0, 0.0, 0.0); + ThermalConductivityPointers[iVar]->SetConductivity(Temperature, Density, Mu, 0.0, Cp, 0.0, 0.0); laminarThermalConductivity[iVar] = ThermalConductivityPointers[iVar]->GetConductivity(); } From 8640efd366841f8642677b71b57b905a02f71974 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 27 Jun 2025 15:17:45 +0200 Subject: [PATCH 109/173] adding regression cases --- TestCases/parallel_regression.py | 16 ++ .../species2_primitiveVenturi_JST.cfg | 153 +++++++++++++++++ ...pecies2_primitiveVenturi_Lax_Friedrich.cfg | 155 ++++++++++++++++++ 3 files changed, 324 insertions(+) create mode 100644 TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_JST.cfg create mode 100644 TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_Lax_Friedrich.cfg diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 490112e0c601..bd9a21923026 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1586,6 +1586,22 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.407825, -4.920839, -4.842095, -7.820571, 1.773871, -5.086936, 10.000000, -2.736335, 3.000000, -5.216316, 5.000000, -5.855262, 2.092350, 1.000000, 0.600000, 0.492350] test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND) + # 2 species (1 eq) primitive venturi mixing using mixing model solving enthalpy equation using preconditioning + JST convective scheme + species2_primitiveVenturi_JST = TestCase('species2_primitiveVenturi_JST.cfg') + species2_primitiveVenturi_JST.cfg_dir = "species_transport/venturi_primitive_3species" + species2_primitiveVenturi_JST.cfg_file = "species2_primitiveVenturi_JST.cfg" + species2_primitiveVenturi_JST.test_iter = 50 + species2_primitiveVenturi_JST.test_vals = [-4.667804, -6.715941, -6.135929, 0.122592, -7.541682, 10.00000, -3.607574, 5.000000, -6.111865, 0.046831, 0.014468, 0.017896, 0.014468, 50.000000] + test_list.append(species2_primitiveVenturi_JST) + + # 2 species (1 eq) primitive venturi mixing using mixing model solving enthalpy equation using preconditioning + Lax-Friedrich convective scheme + species2_primitiveVenturi_Lax_Friedrich = TestCase('species2_primitiveVenturi_Lax_Friedrich.cfg') + species2_primitiveVenturi_Lax_Friedrich.cfg_dir = "species_transport/venturi_primitive_3species" + species2_primitiveVenturi_Lax_Friedrich.cfg_file = "species2_primitiveVenturi_Lax_Friedrich.cfg" + species2_primitiveVenturi_Lax_Friedrich.test_iter = 50 + species2_primitiveVenturi_Lax_Friedrich.test_vals = [-4.667804, -6.715941, -6.135929, 0.122592, -7.541682, 10.00000, -3.607574, 5.000000, -6.111865, 0.046831, 0.014468, 0.017896, 0.014468, 50.000000] + test_list.append(species2_primitiveVenturi_Lax_Friedrich) + # 2 species (1 eq) primitive venturi mixing species2_primitiveVenturi = TestCase('species2_primitiveVenturi') species2_primitiveVenturi.cfg_dir = "species_transport/venturi_primitive_3species" diff --git a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_JST.cfg b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_JST.cfg new file mode 100644 index 000000000000..2bd04a386be3 --- /dev/null +++ b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_JST.cfg @@ -0,0 +1,153 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Species mixing with 2 species: Hydrogen and air. % +% 1 transport equation is being solved(For H2 in this case). % +% Including JST scheme with preconditioning for enthalpy. % +% Author: Cristopher Morales Ubal % +% Institution: Eindhoven University of Technology % +% Date: 2025/06/27 % +% File Version 8.0.1 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= INC_NAVIER_STOKES +KIND_TURB_MODEL= NONE +% +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +INC_DENSITY_MODEL= VARIABLE +INC_DENSITY_INIT= 0.0807 +% +INC_VELOCITY_INIT= ( 0.1, 0.0, 0.0 ) +% +INC_ENERGY_EQUATION= YES +INC_TEMPERATURE_INIT= 350.0 +% +INC_NONDIM= DIMENSIONAL +% +% -------------------- FLUID PROPERTIES ------------------------------------- % +% +FLUID_MODEL= FLUID_MIXTURE +% +THERMODYNAMIC_PRESSURE= 101325.0 +% +MOLECULAR_WEIGHT= 2.01588, 28.960 +% +SPECIFIC_HEAT_CP = 14310, 1009.39 +% +CONDUCTIVITY_MODEL= CONSTANT_CONDUCTIVITY +THERMAL_CONDUCTIVITY_CONSTANT= 0.187, 0.0258 +% +PRANDTL_LAM= 0.72, 0.72 +TURBULENT_CONDUCTIVITY_MODEL= NONE +PRANDTL_TURB= 0.90, 0.90 +% +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +VISCOSITY_MODEL= CONSTANT_VISCOSITY +% +MU_CONSTANT= 8.9E-06, 1.8551E-05 +% +MU_REF= 8.411E-05, 1.716E-05 +% +MU_T_REF= 273, 273 +% +SUTHERLAND_CONSTANT= 97, 111 +% +MIXING_VISCOSITY_MODEL = WILKE +% +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_HEATFLUX= ( wall, 0.0) +MARKER_SYM= ( axis ) +% +SPECIFIED_INLET_PROFILE= NO +INLET_FILENAME= inlet_venturi.dat +INC_INLET_TYPE= VELOCITY_INLET VELOCITY_INLET +MARKER_INLET= ( gas_inlet, 350, 0.1, 1.0, 0.0, 0.0,\ + air_axial_inlet, 300, 0.1, 0.0, -1.0, 0.0 ) +MARKER_INLET_SPECIES= (gas_inlet, 0.014467517838966, \ + air_axial_inlet, 0.020137986304114414) +% +INC_OUTLET_TYPE= PRESSURE_OUTLET +MARKER_OUTLET= ( outlet, 0.0 ) +% +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES +% +CFL_NUMBER= 100 +CFL_REDUCTION_SPECIES= 1.0 +CFL_REDUCTION_TURB= 1.0 +CFL_ADAPT= YES +CFL_ADAPT_PARAM= ( 0.5, 2.0, 10, 1000, 1E-4) +% +% Run commented Iter for good results +ITER= 2000 +% +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-5 +LINEAR_SOLVER_ITER= 10 +% +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= JST +MUSCL_FLOW= NO +SLOPE_LIMITER_FLOW = NONE +TIME_DISCRE_FLOW= EULER_IMPLICIT +% +% -------------------- SCALAR TRANSPORT ---------------------------------------% +% +KIND_SCALAR_MODEL= SPECIES_TRANSPORT +% +DIFFUSIVITY_MODEL = UNITY_LEWIS +% +CONV_NUM_METHOD_SPECIES= BOUNDED_SCALAR +MUSCL_SPECIES= NO +SLOPE_LIMITER_SPECIES = NONE +% +TIME_DISCRE_SPECIES= EULER_IMPLICIT +% +SPECIES_INIT= 0.014467517838966 +SPECIES_CLIPPING= NO +SPECIES_CLIPPING_MIN= 0.0 +SPECIES_CLIPPING_MAX= 1.0 +% +% -------------------- TURBULENT TRANSPORT ---------------------------------------% +% +CONV_NUM_METHOD_TURB= BOUNDED_SCALAR +MUSCL_TURB= NO +% +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_FIELD= RMS_PRESSURE, RMS_VELOCITY-X, RMS_VELOCITY-Y, RMS_SPECIES +CONV_RESIDUAL_MINVAL= -18 +CONV_STARTITER= 10 +% +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +MESH_FILENAME= primitiveVenturi.su2 +SCREEN_OUTPUT= INNER_ITER WALL_TIME \ + RMS_PRESSURE RMS_VELOCITY-X RMS_VELOCITY-Y RMS_ENTHALPY RMS_SPECIES_0 \ + LINSOL_ITER LINSOL_RESIDUAL \ + LINSOL_ITER_SPECIES LINSOL_RESIDUAL_SPECIES \ + SURFACE_SPECIES_0 AVG_CFL +SCREEN_WRT_FREQ_INNER= 10 +% +HISTORY_OUTPUT= ITER RMS_RES LINSOL SPECIES_COEFF SPECIES_COEFF_SURF +CONV_FILENAME= history +MARKER_ANALYZE= gas_inlet, air_axial_inlet, outlet +MARKER_ANALYZE_AVERAGE= AREA +% +OUTPUT_FILES= RESTART_ASCII, PARAVIEW_MULTIBLOCK +VOLUME_OUTPUT= RESIDUAL, PRIMITIVE, TIMESTEP +OUTPUT_WRT_FREQ= 1000 +% +RESTART_SOL= NO +READ_BINARY_RESTART= NO diff --git a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_Lax_Friedrich.cfg b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_Lax_Friedrich.cfg new file mode 100644 index 000000000000..dbe7fde8ebfc --- /dev/null +++ b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_Lax_Friedrich.cfg @@ -0,0 +1,155 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Species mixing with 2 species: Hydrogen and air. % +% 1 transport equation is being solved(For H2 in this case). % +% Including Lax-Friedrich scheme with preconditioning % +% solving for enthalpy. % +% Author: Cristopher Morales Ubal % +% Institution: Eindhoven University of Technology % +% Date: 2022/06/27 % +% File Version 8.0.1 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= INC_NAVIER_STOKES +KIND_TURB_MODEL= NONE +% +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +INC_DENSITY_MODEL= VARIABLE +INC_DENSITY_INIT= 0.0807 +% +INC_VELOCITY_INIT= ( 0.1, 0.0, 0.0 ) +% +INC_ENERGY_EQUATION= YES +INC_TEMPERATURE_INIT= 350.0 +% +INC_NONDIM= DIMENSIONAL +% +% -------------------- FLUID PROPERTIES ------------------------------------- % +% +FLUID_MODEL= FLUID_MIXTURE +% +THERMODYNAMIC_PRESSURE= 101325.0 +% +MOLECULAR_WEIGHT= 2.01588, 28.960 +% +SPECIFIC_HEAT_CP = 14310, 1009.39 +% +CONDUCTIVITY_MODEL= CONSTANT_CONDUCTIVITY +THERMAL_CONDUCTIVITY_CONSTANT= 0.187, 0.0258 +% +PRANDTL_LAM= 0.72, 0.72 +TURBULENT_CONDUCTIVITY_MODEL= NONE +PRANDTL_TURB= 0.90, 0.90 +% +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +VISCOSITY_MODEL= CONSTANT_VISCOSITY +% +MU_CONSTANT= 8.9E-06, 1.8551E-05 +% +MU_REF= 8.411E-05, 1.716E-05 +% +MU_T_REF= 273, 273 +% +SUTHERLAND_CONSTANT= 97, 111 +% +MIXING_VISCOSITY_MODEL = WILKE +% +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_HEATFLUX= ( wall, 0.0) +MARKER_SYM= ( axis ) +% +SPECIFIED_INLET_PROFILE= NO +INLET_FILENAME= inlet_venturi.dat +INC_INLET_TYPE= VELOCITY_INLET VELOCITY_INLET +MARKER_INLET= ( gas_inlet, 350, 0.1, 1.0, 0.0, 0.0,\ + air_axial_inlet, 300, 0.1, 0.0, -1.0, 0.0 ) +MARKER_INLET_SPECIES= (gas_inlet, 0.014467517838966, \ + air_axial_inlet, 0.020137986304114414) +% +INC_OUTLET_TYPE= PRESSURE_OUTLET +MARKER_OUTLET= ( outlet, 0.0 ) +% +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES +% +CFL_NUMBER= 100 +CFL_REDUCTION_SPECIES= 1.0 +CFL_REDUCTION_TURB= 1.0 +CFL_ADAPT= YES +CFL_ADAPT_PARAM= ( 0.5, 2.0, 10, 1000, 1E-4) +% +% Run commented Iter for good results +ITER= 2000 +% +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-5 +LINEAR_SOLVER_ITER= 10 +% +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= LAX-FRIEDRICH +LAX_SENSOR_COEFF = 0.01 +MUSCL_FLOW= NO +SLOPE_LIMITER_FLOW = NONE +TIME_DISCRE_FLOW= EULER_IMPLICIT +% +% -------------------- SCALAR TRANSPORT ---------------------------------------% +% +KIND_SCALAR_MODEL= SPECIES_TRANSPORT +% +DIFFUSIVITY_MODEL = UNITY_LEWIS +% +CONV_NUM_METHOD_SPECIES= BOUNDED_SCALAR +MUSCL_SPECIES= NO +SLOPE_LIMITER_SPECIES = NONE +% +TIME_DISCRE_SPECIES= EULER_IMPLICIT +% +SPECIES_INIT= 0.014467517838966 +SPECIES_CLIPPING= NO +SPECIES_CLIPPING_MIN= 0.0 +SPECIES_CLIPPING_MAX= 1.0 +% +% -------------------- TURBULENT TRANSPORT ---------------------------------------% +% +CONV_NUM_METHOD_TURB= BOUNDED_SCALAR +MUSCL_TURB= NO +% +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_FIELD= RMS_PRESSURE, RMS_VELOCITY-X, RMS_VELOCITY-Y, RMS_SPECIES +CONV_RESIDUAL_MINVAL= -18 +CONV_STARTITER= 10 +% +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +MESH_FILENAME= primitiveVenturi.su2 +SCREEN_OUTPUT= INNER_ITER WALL_TIME \ + RMS_PRESSURE RMS_VELOCITY-X RMS_VELOCITY-Y RMS_ENTHALPY RMS_SPECIES_0 \ + LINSOL_ITER LINSOL_RESIDUAL \ + LINSOL_ITER_SPECIES LINSOL_RESIDUAL_SPECIES \ + SURFACE_SPECIES_0 AVG_CFL +SCREEN_WRT_FREQ_INNER= 10 +% +HISTORY_OUTPUT= ITER RMS_RES LINSOL SPECIES_COEFF SPECIES_COEFF_SURF +CONV_FILENAME= history +MARKER_ANALYZE= gas_inlet, air_axial_inlet, outlet +MARKER_ANALYZE_AVERAGE= AREA +% +OUTPUT_FILES= RESTART_ASCII, PARAVIEW_MULTIBLOCK +VOLUME_OUTPUT= RESIDUAL, PRIMITIVE, TIMESTEP +OUTPUT_WRT_FREQ= 1000 +% +RESTART_SOL= NO +READ_BINARY_RESTART= NO From c0b0bed96779a3383f7e554fab0b51497e9fc5b7 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 30 Jun 2025 16:40:17 +0200 Subject: [PATCH 110/173] update residual JST-Lax_Friedrich --- TestCases/parallel_regression.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index bd9a21923026..1d1cc8c04f34 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1591,7 +1591,7 @@ def main(): species2_primitiveVenturi_JST.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_JST.cfg_file = "species2_primitiveVenturi_JST.cfg" species2_primitiveVenturi_JST.test_iter = 50 - species2_primitiveVenturi_JST.test_vals = [-4.667804, -6.715941, -6.135929, 0.122592, -7.541682, 10.00000, -3.607574, 5.000000, -6.111865, 0.046831, 0.014468, 0.017896, 0.014468, 50.000000] + species2_primitiveVenturi_JST.test_vals = [-6.035464, -7.071918, -7.201080, -1.142940, -8.348316, 10.000000, -3.223791, 10.000000, -4.435519, 0.049048, 0.014468, 0.020068, 0.014512, 25.000000] test_list.append(species2_primitiveVenturi_JST) # 2 species (1 eq) primitive venturi mixing using mixing model solving enthalpy equation using preconditioning + Lax-Friedrich convective scheme @@ -1599,7 +1599,7 @@ def main(): species2_primitiveVenturi_Lax_Friedrich.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_Lax_Friedrich.cfg_file = "species2_primitiveVenturi_Lax_Friedrich.cfg" species2_primitiveVenturi_Lax_Friedrich.test_iter = 50 - species2_primitiveVenturi_Lax_Friedrich.test_vals = [-4.667804, -6.715941, -6.135929, 0.122592, -7.541682, 10.00000, -3.607574, 5.000000, -6.111865, 0.046831, 0.014468, 0.017896, 0.014468, 50.000000] + species2_primitiveVenturi_Lax_Friedrich.test_vals = [-6.092441, -6.981653, -6.982959, -1.195023, -8.245626, 10.000000, -3.472515, 8.000000, -5.356121, 0.048943, 0.014468, 0.020007, 0.014468, 12.500000] test_list.append(species2_primitiveVenturi_Lax_Friedrich) # 2 species (1 eq) primitive venturi mixing From c2a572b7b81afc105664f99d86a5223fc9213fbe Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 7 Jul 2025 15:55:34 +0200 Subject: [PATCH 111/173] adding GetValue for DA in FluidCantera --- SU2_CFD/include/fluid/CFluidCantera.hpp | 2 +- SU2_CFD/src/fluid/CFluidCantera.cpp | 46 ++++++++++++------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index d7bcf8027c7c..d53e38b22f2e 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -67,7 +67,7 @@ class CFluidCantera final : public CFluidModel { std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ std::array chemicalSourceTerm; /*!< \brief chemical source term of all species*/ std::array gradChemicalSourceTerm; /*!< \brief jacobian chemical source term of all species*/ - std::array molarMasses; /*!< \brief Molar masses of all species. */ + std::array molarMasses; /*!< \brief Molar masses of all species. */ std::array enthalpyFormation; /*!< \brief Enthalpy of Formation of all species. */ su2double Heat_Release; /*!< \brief heat release due to combustion */ #endif diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 8b58d8b53e75..0873c560f787 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -68,7 +68,7 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* sim = new ReactorNet(); sim->addReactor(*combustor); su2double Delta_t_max = 0.1; - combustor->setAdvanceLimit("temperature", Delta_t_max); + combustor->setAdvanceLimit("temperature", GetValue(Delta_t_max)); } for (int iVar = 0; iVar < n_species_mixture; iVar++) { gasComposition[iVar]=config->GetChemical_GasComposition(iVar); @@ -91,20 +91,20 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { /*--- Set mass fractions. ---*/ const int nsp = sol->thermo()->nSpecies(); su2double val_scalars_sum{0.0}; - su2double massFractions[nsp]{0.0}; + double massFractions[nsp]{0.0}; for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); - massFractions[speciesIndex] = config->GetSpecies_Init()[i_scalar]; + massFractions[speciesIndex] = GetValue(config->GetSpecies_Init()[i_scalar]); val_scalars_sum += config->GetSpecies_Init()[i_scalar]; } sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); - massFractions[n_species_mixture - 1] = 1 - val_scalars_sum; + massFractions[n_species_mixture - 1] = GetValue(1 - val_scalars_sum); sol->thermo()->setMassFractions(massFractions); su2double T_ref = 298.15; sol->thermo()->setState_TP(GetValue(T_ref), GetValue(Pressure_Thermodynamic)); // The universal gas constant times temperature is retrieved from cantera. const su2double uni_gas_constant_temp = sol->thermo()->RT(); - vector enthalpiesSpecies(nsp); + vector enthalpiesSpecies(nsp); sol->thermo()->getEnthalpy_RT_ref(&enthalpiesSpecies[0]); for (int iVar = 0; iVar < n_species_mixture; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); @@ -114,7 +114,7 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { void CFluidCantera::ComputeMassDiffusivity() { int nsp = sol->thermo()->nSpecies(); - vector diff(nsp); + vector diff(nsp); sol->transport()->getMixDiffCoeffsMass(&diff[0]); for (int iVar = 0; iVar < n_species_mixture; iVar++) { massDiffusivity[iVar] = diff[sol->thermo()->speciesIndex(gasComposition[iVar])]; @@ -125,9 +125,9 @@ void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2dou if (Chemistry_Time_Integration) { combustor->insert(sol); su2double Delta_t_max = 0.1; - combustor->setAdvanceLimit("temperature", Delta_t_max); + combustor->setAdvanceLimit("temperature", GetValue(Delta_t_max)); sim->setInitialTime(0.0); - sim->advance(max(1E-15,0.0001*delta_time)); + sim->advance(max(1E-15, GetValue(0.0001 * delta_time))); sim->setTolerances(1E-12, 1E-12); //const su2double density_new = combustor->density(); // cout << "time simulated " << setprecision(12) << sim->time() << endl; @@ -147,7 +147,7 @@ void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2dou } } else { const int nsp = sol->thermo()->nSpecies(); - vector netProductionRates(nsp); + vector netProductionRates(nsp); sol->kinetics()->getNetProductionRates(&netProductionRates[0]); for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); @@ -159,10 +159,10 @@ void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2dou void CFluidCantera::ComputeGradChemicalSourceTerm(const su2double* val_scalars) { const int nsp = sol->thermo()->nSpecies(); //const su2double meanMolecularWeight = sol->thermo()->meanMolecularWeight(); - vector netProductionRates_T(nsp); + vector netProductionRates_T(nsp); // The universal gas constant times temperature is retrieved from cantera. const su2double uni_gas_constant_temp = sol->thermo()->RT(); - vector enthalpiesSpecies(nsp); + vector enthalpiesSpecies(nsp); sol->thermo()->getEnthalpy_RT_ref(&enthalpiesSpecies[0]); //Eigen::SparseMatrix dW_dC = sol->kinetics()->netProductionRates_ddCi(); sol->kinetics()->getNetProductionRates_ddT(&netProductionRates_T[0]); @@ -202,7 +202,7 @@ void CFluidCantera::ComputeGradChemicalSourceTerm(const su2double* val_scalars) void CFluidCantera::ComputeHeatRelease() { const int nsp = sol->thermo()->nSpecies(); - vector netProductionRates(nsp); + vector netProductionRates(nsp); sol->kinetics()->getNetProductionRates(&netProductionRates[0]); Heat_Release = 0.0; for (int iVar = 0; iVar < n_species_mixture; iVar++) { @@ -216,8 +216,8 @@ void CFluidCantera::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) { const int nsp = sol->thermo()->nSpecies(); // The universal gas constant times temperature is retrieved from cantera. const su2double uni_gas_constant_temp = sol->thermo()->RT(); - vector enthalpiesSpecies(nsp); - vector diff(nsp); + vector enthalpiesSpecies(nsp); + vector diff(nsp); sol->thermo()->getEnthalpy_RT_ref(&enthalpiesSpecies[0]); sol->transport()->getMixDiffCoeffsMass(&diff[0]); const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); @@ -231,7 +231,7 @@ void CFluidCantera::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) { void CFluidCantera::GetMassCorrectionDiffusivity(su2double* massCorrection_diffusions) { const int nsp = sol->thermo()->nSpecies(); - vector diff(nsp); + vector diff(nsp); sol->transport()->getMixDiffCoeffsMass(&diff[0]); const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { @@ -244,8 +244,8 @@ void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusio const int nsp = sol->thermo()->nSpecies(); // The universal gas constant is retrieved from cantera,in order to keep consistency with the values retrieve from it. const su2double universal_gas_constant = (sol->thermo()->RT()) / Temperature; - vector specificHeatSpecies(nsp); - vector diff(nsp); + vector specificHeatSpecies(nsp); + vector diff(nsp); sol->thermo()->getCp_R_ref(&specificHeatSpecies[0]); sol->transport()->getMixDiffCoeffsMass(&diff[0]); const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); @@ -271,13 +271,13 @@ void CFluidCantera::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2dou /*--- Set mass fractions. ---*/ const int nsp = sol->thermo()->nSpecies(); su2double val_scalars_sum{0.0}; - su2double massFractions[nsp]{0.0}; + double massFractions[nsp]{0.0}; for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); - massFractions[speciesIndex] = val_scalars[i_scalar]; + massFractions[speciesIndex] = GetValue(val_scalars[i_scalar]); val_scalars_sum += val_scalars[speciesIndex]; } - massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1 - val_scalars_sum; + massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = GetValue(1 - val_scalars_sum); sol->thermo()->setMassFractions(massFractions); while ((abs(delta_temp_iter) > toll) && (counter++ < counter_limit)) { @@ -308,13 +308,13 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl /*--- Set mass fractions. ---*/ const int nsp = sol->thermo()->nSpecies(); su2double val_scalars_sum{0.0}; - su2double massFractions[nsp]{0.0}; + double massFractions[nsp]{0.0}; for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); - massFractions[speciesIndex] = val_scalars[i_scalar]; + massFractions[speciesIndex] = GetValue(val_scalars[i_scalar]); val_scalars_sum += val_scalars[i_scalar]; } - massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1 - val_scalars_sum; + massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = GetValue(1 - val_scalars_sum); sol->thermo()->setMassFractions(massFractions); sol->thermo()->setState_TP(GetValue(Temperature), GetValue(Pressure_Thermodynamic)); Density = sol->thermo()->density(); From 827f640da271cd7cd9527ec3a97db086e9ab44a4 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 11 Jul 2025 11:54:22 +0200 Subject: [PATCH 112/173] adding constructor when SU2 is not compile with Cantera --- SU2_CFD/include/fluid/CFluidCantera.hpp | 10 ++--- SU2_CFD/src/fluid/CFluidCantera.cpp | 55 ++++++++++++------------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index d53e38b22f2e..487bc5ef0051 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -49,6 +49,7 @@ class ReactorNet; */ class CFluidCantera final : public CFluidModel { private: + #ifdef USE_CANTERA const int n_species_mixture; /*!< \brief Number of species in mixture. */ const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */ const su2double GasConstant_Ref; /*!< \brief Gas constant reference needed for Nondimensional problems. */ @@ -60,17 +61,16 @@ class CFluidCantera final : public CFluidModel { const bool Chemistry_Time_Integration; /*!< \brief bool if time-integration is used for chemical source terms*/ static constexpr int ARRAYSIZE = 16; - #ifdef USE_CANTERA + Cantera::IdealGasConstPressureReactor* combustor; Cantera::ReactorNet* sim; std::array gasComposition; /*!< \brief Gas composition. */ std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ std::array chemicalSourceTerm; /*!< \brief chemical source term of all species*/ std::array gradChemicalSourceTerm; /*!< \brief jacobian chemical source term of all species*/ - std::array molarMasses; /*!< \brief Molar masses of all species. */ + std::array molarMasses; /*!< \brief Molar masses of all species. */ std::array enthalpyFormation; /*!< \brief Enthalpy of Formation of all species. */ su2double Heat_Release; /*!< \brief heat release due to combustion */ - #endif std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ std::unique_ptr MassDiffusivityPointers[ARRAYSIZE]; @@ -94,6 +94,7 @@ class CFluidCantera final : public CFluidModel { * \brief Set enthalpies of formation. */ void SetEnthalpyFormation(const CConfig* config); + #endif public: /*! @@ -101,7 +102,7 @@ class CFluidCantera final : public CFluidModel { */ CFluidCantera(su2double val_operating_pressure, const CConfig* config); - + #ifdef USE_CANTERA /*! * \brief Set mass diffusivity model. */ @@ -122,7 +123,6 @@ class CFluidCantera final : public CFluidModel { */ inline su2double GetMassDiffusivity(int ivar) override { return massDiffusivity[ivar]; } - #ifdef USE_CANTERA /*! * \brief Compute chemical source term for species. * \param[in] delta_time - time integration flow solver. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 0873c560f787..5a521740dd4a 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -41,7 +41,6 @@ using namespace Cantera; using namespace SU2_TYPE; -#endif CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* config) : CFluidModel(), @@ -56,8 +55,6 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* if (n_species_mixture > ARRAYSIZE) { SU2_MPI::Error("Too many species, increase ARRAYSIZE", CURRENT_FUNCTION); } - - #ifdef USE_CANTERA sol = std::shared_ptr(newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model)); sol->thermo()->getMolecularWeights(&molarMasses[0]); combustor = nullptr; @@ -70,12 +67,11 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* su2double Delta_t_max = 0.1; combustor->setAdvanceLimit("temperature", GetValue(Delta_t_max)); } - for (int iVar = 0; iVar < n_species_mixture; iVar++) { - gasComposition[iVar]=config->GetChemical_GasComposition(iVar); - //config->SetChemical_GasComposition(iVar, gasComposition[iVar]); //this should be used for later + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + gasComposition[iVar] = config->GetChemical_GasComposition(iVar); + // config->SetChemical_GasComposition(iVar, gasComposition[iVar]); //this should be used for later } SetEnthalpyFormation(config); - #endif SetMassDiffusivityModel(config); } @@ -86,7 +82,6 @@ void CFluidCantera::SetMassDiffusivityModel(const CConfig* config) { } } -#ifdef USE_CANTERA void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { /*--- Set mass fractions. ---*/ const int nsp = sol->thermo()->nSpecies(); @@ -101,10 +96,10 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { massFractions[n_species_mixture - 1] = GetValue(1 - val_scalars_sum); sol->thermo()->setMassFractions(massFractions); su2double T_ref = 298.15; - sol->thermo()->setState_TP(GetValue(T_ref), GetValue(Pressure_Thermodynamic)); + sol->thermo()->setState_TP(T_ref, Pressure_Thermodynamic); // The universal gas constant times temperature is retrieved from cantera. const su2double uni_gas_constant_temp = sol->thermo()->RT(); - vector enthalpiesSpecies(nsp); + vector enthalpiesSpecies(nsp); sol->thermo()->getEnthalpy_RT_ref(&enthalpiesSpecies[0]); for (int iVar = 0; iVar < n_species_mixture; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); @@ -114,7 +109,7 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { void CFluidCantera::ComputeMassDiffusivity() { int nsp = sol->thermo()->nSpecies(); - vector diff(nsp); + vector diff(nsp); sol->transport()->getMixDiffCoeffsMass(&diff[0]); for (int iVar = 0; iVar < n_species_mixture; iVar++) { massDiffusivity[iVar] = diff[sol->thermo()->speciesIndex(gasComposition[iVar])]; @@ -147,7 +142,7 @@ void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2dou } } else { const int nsp = sol->thermo()->nSpecies(); - vector netProductionRates(nsp); + vector netProductionRates(nsp); sol->kinetics()->getNetProductionRates(&netProductionRates[0]); for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); @@ -159,10 +154,10 @@ void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2dou void CFluidCantera::ComputeGradChemicalSourceTerm(const su2double* val_scalars) { const int nsp = sol->thermo()->nSpecies(); //const su2double meanMolecularWeight = sol->thermo()->meanMolecularWeight(); - vector netProductionRates_T(nsp); + vector netProductionRates_T(nsp); // The universal gas constant times temperature is retrieved from cantera. const su2double uni_gas_constant_temp = sol->thermo()->RT(); - vector enthalpiesSpecies(nsp); + vector enthalpiesSpecies(nsp); sol->thermo()->getEnthalpy_RT_ref(&enthalpiesSpecies[0]); //Eigen::SparseMatrix dW_dC = sol->kinetics()->netProductionRates_ddCi(); sol->kinetics()->getNetProductionRates_ddT(&netProductionRates_T[0]); @@ -202,7 +197,7 @@ void CFluidCantera::ComputeGradChemicalSourceTerm(const su2double* val_scalars) void CFluidCantera::ComputeHeatRelease() { const int nsp = sol->thermo()->nSpecies(); - vector netProductionRates(nsp); + vector netProductionRates(nsp); sol->kinetics()->getNetProductionRates(&netProductionRates[0]); Heat_Release = 0.0; for (int iVar = 0; iVar < n_species_mixture; iVar++) { @@ -216,8 +211,8 @@ void CFluidCantera::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) { const int nsp = sol->thermo()->nSpecies(); // The universal gas constant times temperature is retrieved from cantera. const su2double uni_gas_constant_temp = sol->thermo()->RT(); - vector enthalpiesSpecies(nsp); - vector diff(nsp); + vector enthalpiesSpecies(nsp); + vector diff(nsp); sol->thermo()->getEnthalpy_RT_ref(&enthalpiesSpecies[0]); sol->transport()->getMixDiffCoeffsMass(&diff[0]); const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); @@ -231,7 +226,7 @@ void CFluidCantera::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) { void CFluidCantera::GetMassCorrectionDiffusivity(su2double* massCorrection_diffusions) { const int nsp = sol->thermo()->nSpecies(); - vector diff(nsp); + vector diff(nsp); sol->transport()->getMixDiffCoeffsMass(&diff[0]); const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { @@ -244,8 +239,8 @@ void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusio const int nsp = sol->thermo()->nSpecies(); // The universal gas constant is retrieved from cantera,in order to keep consistency with the values retrieve from it. const su2double universal_gas_constant = (sol->thermo()->RT()) / Temperature; - vector specificHeatSpecies(nsp); - vector diff(nsp); + vector specificHeatSpecies(nsp); + vector diff(nsp); sol->thermo()->getCp_R_ref(&specificHeatSpecies[0]); sol->transport()->getMixDiffCoeffsMass(&diff[0]); const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); @@ -271,18 +266,18 @@ void CFluidCantera::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2dou /*--- Set mass fractions. ---*/ const int nsp = sol->thermo()->nSpecies(); su2double val_scalars_sum{0.0}; - double massFractions[nsp]{0.0}; + su2double massFractions[nsp]{0.0}; for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); - massFractions[speciesIndex] = GetValue(val_scalars[i_scalar]); + massFractions[speciesIndex] = val_scalars[i_scalar]; val_scalars_sum += val_scalars[speciesIndex]; } - massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = GetValue(1 - val_scalars_sum); + massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1 - val_scalars_sum; sol->thermo()->setMassFractions(massFractions); while ((abs(delta_temp_iter) > toll) && (counter++ < counter_limit)) { /*--- Set thermodynamic state based on the current value of temperature. ---*/ - sol->thermo()->setState_TP(GetValue(temp_iter), GetValue(Pressure_Thermodynamic)); + sol->thermo()->setState_TP(temp_iter, Pressure_Thermodynamic); su2double Enthalpy = sol->thermo()->enthalpy_mass(); su2double Cp = sol->thermo()->cp_mass(); @@ -308,15 +303,15 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl /*--- Set mass fractions. ---*/ const int nsp = sol->thermo()->nSpecies(); su2double val_scalars_sum{0.0}; - double massFractions[nsp]{0.0}; + su2double massFractions[nsp]{0.0}; for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); - massFractions[speciesIndex] = GetValue(val_scalars[i_scalar]); + massFractions[speciesIndex] = val_scalars[i_scalar]; val_scalars_sum += val_scalars[i_scalar]; } - massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = GetValue(1 - val_scalars_sum); + massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1 - val_scalars_sum; sol->thermo()->setMassFractions(massFractions); - sol->thermo()->setState_TP(GetValue(Temperature), GetValue(Pressure_Thermodynamic)); + sol->thermo()->setState_TP(Temperature, Pressure_Thermodynamic); Density = sol->thermo()->density(); Enthalpy = sol->thermo()->enthalpy_mass(); Cp = sol->thermo()->cp_mass(); @@ -329,4 +324,8 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl ComputeGradChemicalSourceTerm(val_scalars); ComputeHeatRelease(); } +#else +CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* config) { + SU2_MPI::Error("SU2 was not compiled with Cantera(-Denable-cantera=true)", CURRENT_FUNCTION); +} #endif \ No newline at end of file From 3148c3a0f90237cf1a56ea479fea2f4c17517a2f Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 12 Jul 2025 13:43:51 +0200 Subject: [PATCH 113/173] adding function for computing enthalpy due to species diffusion --- SU2_CFD/include/solvers/CIncNSSolver.hpp | 13 ++- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 6 +- SU2_CFD/src/solvers/CIncNSSolver.cpp | 139 ++++++++++++----------- 3 files changed, 89 insertions(+), 69 deletions(-) diff --git a/SU2_CFD/include/solvers/CIncNSSolver.hpp b/SU2_CFD/include/solvers/CIncNSSolver.hpp index 684ea4625466..6d0f25a9d102 100644 --- a/SU2_CFD/include/solvers/CIncNSSolver.hpp +++ b/SU2_CFD/include/solvers/CIncNSSolver.hpp @@ -94,8 +94,19 @@ class CIncNSSolver final : public CIncEulerSolver { */ void Compute_Streamwise_Periodic_Recovered_Values(CConfig *config, const CGeometry *geometry, const unsigned short iMesh); + /*! + * \brief Compute the enthalpy due to species diffusion contribution for multicomponent and reacting flows. + * \param[in] iEdge - Edge for which the flux and Jacobians are to be computed. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] numerics - Description of the numerical method. + * \param[in] n_species - Number of species in the mixture that a transport equation is solved. + * \param[in] implicit - Boolean for implicit iterations. + */ + void ComputeEnthalpyDiffusion(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, CNumerics* numerics, + const int n_species, const bool implicit) ; -public: + public: /*! * \brief Constructor of the class. * \param[in] geometry - Geometrical definition of the problem. diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 6157511d50b5..e7f7a4ea0233 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1332,8 +1332,10 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont lim_i = LimiterHelpers<>::vanAlbadaFunction(Project_Grad_Enthalpy_i, V_ij, EPS); lim_j = LimiterHelpers<>::vanAlbadaFunction(-Project_Grad_Enthalpy_j, V_ij, EPS); } else if (limiter) { - lim_i = 1.0; // nodes->GetLimiter_Primitive(iPoint, iVar); - lim_j = 1.0; // nodes->GetLimiter_Primitive(jPoint, iVar); + /*--- For solving enthalpy instead of temperature, computation of limiters must be added + in future implementation, for now it is limited to van Albada limiter or default value 1.0. ---*/ + lim_i = 1.0; + lim_j = 1.0; } Primitive_i[nDim + 9] = V_i[nDim + 9] + lim_i * Project_Grad_Enthalpy_i; Primitive_j[nDim + 9] = V_j[nDim + 9] + lim_j * Project_Grad_Enthalpy_j; diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 1ca5080ee588..be55f202d69b 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -301,78 +301,85 @@ void CIncNSSolver::Compute_Streamwise_Periodic_Recovered_Values(CConfig *config, void CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config) { const bool energy_multicomponent = ((config->GetKind_FluidModel() == FLUID_MIXTURE) && config->GetEnergy_Equation()); - const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); /*--- Contribution to heat flux due to enthalpy diffusion for multicomponent and reacting flows ---*/ if (energy_multicomponent) { - CVariable* speciesNodes = solver_container[SPECIES_SOL]->GetNodes(); - /*--- Points in edge ---*/ - - auto iPoint = geometry->edges->GetNode(iEdge, 0); - auto jPoint = geometry->edges->GetNode(iEdge, 1); - - /*--- Points coordinates, and normal vector ---*/ - - const su2double* Normal = geometry->edges->GetNormal(iEdge); - const su2double* Coord_i = geometry->nodes->GetCoord(iPoint); - const su2double* Coord_j = geometry->nodes->GetCoord(jPoint); - - /*--- Obtain fluid model for computing the enthalpy diffusion terms. ---*/ - - CFluidModel* FluidModel = solver_container[FLOW_SOL]->GetFluidModel(); - - /*--- retrieve number of species that are solved and set maximum static array ---*/ - - int n_species = config->GetnSpecies(); - static constexpr size_t MAXNVAR_SPECIES = 20UL; - - /*--- Species variables, and its gradients ---*/ - const su2double* Species_i = speciesNodes->GetSolution(iPoint); - const su2double* Species_j = speciesNodes->GetSolution(jPoint); - CMatrixView Species_Grad_i = speciesNodes->GetGradient(iPoint); - CMatrixView Species_Grad_j = speciesNodes->GetGradient(jPoint); - - /*--- Compute Projected gradient for species variables ---*/ - su2double ProjGradScalarVarNoCorr[MAXNVAR_SPECIES]{0.0}; - su2double Proj_Mean_GradScalarVar[MAXNVAR_SPECIES]{0.0}; - su2double proj_vector_ij = numerics->ComputeProjectedGradient( - nDim, n_species, Normal, Coord_i, Coord_j, Species_Grad_i, Species_Grad_j, true, Species_i, Species_j, - ProjGradScalarVarNoCorr, Proj_Mean_GradScalarVar); - (void)proj_vector_ij; - - /*--- Get enthalpy diffusion terms and its gradient(for implicit) for each species at point i. ---*/ - - su2double EnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; - su2double GradEnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; - FluidModel->SetTDState_T(nodes->GetPrimitive(iPoint)[prim_idx.Temperature()], Species_i); - FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion_i); - if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion_i); - - /*--- Repeat the above computations for jPoint. ---*/ - - su2double EnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; - su2double GradEnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; - FluidModel->SetTDState_T(nodes->GetPrimitive(jPoint)[prim_idx.Temperature()], Species_j); - FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion_j); - if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion_j); - - /*--- Compute Enthalpy diffusion flux and its jacobian (for implicit iterations) ---*/ - su2double flux_enthalpy_diffusion = 0.0; - su2double jac_flux_enthalpy_diffusion = 0.0; - for (int i_species = 0; i_species < n_species; i_species++) { - flux_enthalpy_diffusion += - 0.5 * (EnthalpyDiffusion_i[i_species] + EnthalpyDiffusion_j[i_species]) * Proj_Mean_GradScalarVar[i_species]; - if (implicit) - jac_flux_enthalpy_diffusion += 0.5 * (GradEnthalpyDiffusion_i[i_species] + GradEnthalpyDiffusion_j[i_species]) * - Proj_Mean_GradScalarVar[i_species]; - } + const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); + const int n_species = config->GetnSpecies(); + ComputeEnthalpyDiffusion(iEdge, geometry, solver_container, numerics, n_species, implicit); + } + + Viscous_Residual_impl(iEdge, geometry, solver_container, numerics, config); +} + +void CIncNSSolver::ComputeEnthalpyDiffusion(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, + CNumerics* numerics, const int n_species, const bool implicit) { + + CVariable* speciesNodes = solver_container[SPECIES_SOL]->GetNodes(); + /*--- Points in edge ---*/ + + auto iPoint = geometry->edges->GetNode(iEdge, 0); + auto jPoint = geometry->edges->GetNode(iEdge, 1); + + /*--- Points coordinates, and normal vector ---*/ + + const su2double* Normal = geometry->edges->GetNormal(iEdge); + const su2double* Coord_i = geometry->nodes->GetCoord(iPoint); + const su2double* Coord_j = geometry->nodes->GetCoord(jPoint); + + /*--- Obtain fluid model for computing the enthalpy diffusion terms. ---*/ - /*--- Set heat flux and jacobian (for implicit) due to enthalpy diffusion ---*/ + CFluidModel* FluidModel = solver_container[FLOW_SOL]->GetFluidModel(); - numerics->SetHeatFluxDiffusion(flux_enthalpy_diffusion); - if (implicit) numerics->SetJacHeatFluxDiffusion(jac_flux_enthalpy_diffusion); + /*--- set maximum static array ---*/ + + static constexpr size_t MAXNVAR_SPECIES = 20UL; + + /*--- Species variables, and its gradients ---*/ + const su2double* Species_i = speciesNodes->GetSolution(iPoint); + const su2double* Species_j = speciesNodes->GetSolution(jPoint); + CMatrixView Species_Grad_i = speciesNodes->GetGradient(iPoint); + CMatrixView Species_Grad_j = speciesNodes->GetGradient(jPoint); + + /*--- Compute Projected gradient for species variables ---*/ + su2double ProjGradScalarVarNoCorr[MAXNVAR_SPECIES]{0.0}; + su2double Proj_Mean_GradScalarVar[MAXNVAR_SPECIES]{0.0}; + su2double proj_vector_ij = + numerics->ComputeProjectedGradient(nDim, n_species, Normal, Coord_i, Coord_j, Species_Grad_i, Species_Grad_j, + true, Species_i, Species_j, ProjGradScalarVarNoCorr, Proj_Mean_GradScalarVar); + (void)proj_vector_ij; + + /*--- Get enthalpy diffusion terms and its gradient(for implicit) for each species at point i. ---*/ + + su2double EnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; + su2double GradEnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; + FluidModel->SetTDState_T(nodes->GetPrimitive(iPoint)[prim_idx.Temperature()], Species_i); + FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion_i); + if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion_i); + + /*--- Repeat the above computations for jPoint. ---*/ + + su2double EnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; + su2double GradEnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; + FluidModel->SetTDState_T(nodes->GetPrimitive(jPoint)[prim_idx.Temperature()], Species_j); + FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion_j); + if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion_j); + + /*--- Compute Enthalpy diffusion flux and its jacobian (for implicit iterations) ---*/ + su2double flux_enthalpy_diffusion = 0.0; + su2double jac_flux_enthalpy_diffusion = 0.0; + for (int i_species = 0; i_species < n_species; i_species++) { + flux_enthalpy_diffusion += + 0.5 * (EnthalpyDiffusion_i[i_species] + EnthalpyDiffusion_j[i_species]) * Proj_Mean_GradScalarVar[i_species]; + if (implicit) + jac_flux_enthalpy_diffusion += 0.5 * (GradEnthalpyDiffusion_i[i_species] + GradEnthalpyDiffusion_j[i_species]) * + Proj_Mean_GradScalarVar[i_species]; } - Viscous_Residual_impl(iEdge, geometry, solver_container, numerics, config); + + /*--- Set heat flux and jacobian (for implicit) due to enthalpy diffusion ---*/ + + numerics->SetHeatFluxDiffusion(flux_enthalpy_diffusion); + if (implicit) numerics->SetJacHeatFluxDiffusion(jac_flux_enthalpy_diffusion); } unsigned long CIncNSSolver::SetPrimitive_Variables(CSolver **solver_container, const CConfig *config) { From f962f0b535de41dc1c48b1e30733db8792ccb65c Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 12 Jul 2025 17:19:49 +0200 Subject: [PATCH 114/173] removing getvalue --- SU2_CFD/src/fluid/CFluidCantera.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 5a521740dd4a..2bcaa9f39113 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -89,11 +89,11 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { double massFractions[nsp]{0.0}; for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); - massFractions[speciesIndex] = GetValue(config->GetSpecies_Init()[i_scalar]); + massFractions[speciesIndex] =config->GetSpecies_Init()[i_scalar]; val_scalars_sum += config->GetSpecies_Init()[i_scalar]; } sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); - massFractions[n_species_mixture - 1] = GetValue(1 - val_scalars_sum); + massFractions[n_species_mixture - 1] = 1 - val_scalars_sum; sol->thermo()->setMassFractions(massFractions); su2double T_ref = 298.15; sol->thermo()->setState_TP(T_ref, Pressure_Thermodynamic); From 69d4efaf3644db0448c7cb8bb6e64701b158db0e Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sun, 13 Jul 2025 14:10:37 +0200 Subject: [PATCH 115/173] adding setTDState_h for multicomponent --- SU2_CFD/include/fluid/CFluidModel.hpp | 4 +-- SU2_CFD/include/fluid/CFluidScalar.hpp | 13 +++++----- SU2_CFD/src/fluid/CFluidScalar.cpp | 33 +++++++++++++++++++----- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 10 +++---- SU2_CFD/src/variables/CIncNSVariable.cpp | 24 ++++++++++------- 5 files changed, 52 insertions(+), 32 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 183f011974cb..c8e6cc08b39d 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -358,9 +358,9 @@ class CFluidModel { /*! * \brief Virtual member. * \param[in] val_enthalpy - Enthalpy value at the point. + * \param[in] val_scalars - Scalar mass fractions. */ - virtual void ComputeTempFromEnthalpy(su2double val_enthalpy, su2double* val_temperature, - const su2double* val_scalars = nullptr) {} + virtual void SetTDState_h(su2double val_enthalpy, const su2double* val_scalars = nullptr) {} /*! * \brief Set fluid eddy viscosity provided by a turbulence model needed for computing effective thermal conductivity. diff --git a/SU2_CFD/include/fluid/CFluidScalar.hpp b/SU2_CFD/include/fluid/CFluidScalar.hpp index d7a5c9289bf9..576c0cd54b78 100644 --- a/SU2_CFD/include/fluid/CFluidScalar.hpp +++ b/SU2_CFD/include/fluid/CFluidScalar.hpp @@ -153,15 +153,16 @@ class CFluidScalar final : public CFluidModel { */ void GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusions) override; - /*! - * \brief Compute Temperature from Enthalpy and scalars. - */ - void ComputeTempFromEnthalpy(const su2double val_enthalpy, su2double* val_temperature, - const su2double* val_scalars) override; - /*! * \brief Set the Dimensionless State using Temperature. * \param[in] t - Temperature value at the point. */ void SetTDState_T(su2double val_temperature, const su2double* val_scalars) override; + + /*! + * \brief Virtual member. + * \param[in] val_enthalpy - Enthalpy value at the point. + * \param[in] val_scalars - Scalar mass fractions. + */ + void SetTDState_h(su2double val_enthalpy, const su2double* val_scalars = nullptr) override; }; diff --git a/SU2_CFD/src/fluid/CFluidScalar.cpp b/SU2_CFD/src/fluid/CFluidScalar.cpp index ef28a2c81983..6bea14c4cb94 100644 --- a/SU2_CFD/src/fluid/CFluidScalar.cpp +++ b/SU2_CFD/src/fluid/CFluidScalar.cpp @@ -214,17 +214,14 @@ su2double CFluidScalar::ComputeMeanSpecificHeatCp(const su2double* val_scalars) } su2double CFluidScalar::ComputeEnthalpyFromT(const su2double val_temperature, const su2double* val_scalars){ + /* In future implementations, enthalpy should be computed using numerical integration. For now, as Cp does not + * depend on temperature, but it does depend on mixture composition, ehtalpy is directly computed from + * the expression h_s = Cp(T - T_ref). + */ su2double val_Enthalpy = Cp * (val_temperature - Ref_Temperature); return val_Enthalpy; } -void CFluidScalar::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2double* val_temperature, - const su2double* val_scalars) { - MassToMoleFractions(val_scalars); - su2double val_cp = ComputeMeanSpecificHeatCp(val_scalars); - *val_temperature = val_enthalpy / val_cp + Ref_Temperature; -} - void CFluidScalar::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) { const su2double enthalpy_species_N = specificHeat[n_species_mixture - 1] * (Temperature - Ref_Temperature); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { @@ -260,3 +257,25 @@ void CFluidScalar::SetTDState_T(const su2double val_temperature, const su2double Kt = WilkeConductivity(val_scalars); ComputeMassDiffusivity(); } + +void CFluidScalar::SetTDState_h(const su2double val_enthalpy, const su2double* val_scalars) { + MassToMoleFractions(val_scalars); + ComputeGasConstant(); + Enthalpy = val_enthalpy; + Cp = ComputeMeanSpecificHeatCp(val_scalars); + /* In future implementations, temperature should be computed using Newton-Raphson. For now, as Cp does not + * depend on temperature, but it does depend on mixture composition, temperature is directly solved from the + * expression h_s = Cp(T - T_ref). + */ + Temperature = val_enthalpy / Cp + Ref_Temperature; + Density = Pressure_Thermodynamic / (Temperature * Gas_Constant); + Cv = Cp - Gas_Constant; + + if (wilke) { + Mu = WilkeViscosity(val_scalars); + } else if (davidson) { + Mu = DavidsonViscosity(val_scalars); + } + + Kt = WilkeConductivity(val_scalars); +} diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index e7f7a4ea0233..bc9dde16f821 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1419,12 +1419,9 @@ void CIncEulerSolver::ComputeConsistentExtrapolation(CFluidModel* fluidModel, un const su2double* scalar) { const CIncEulerVariable::CIndices prim_idx(nDim, 0); const su2double enthalpy = primitive[prim_idx.Enthalpy()]; - su2double temperature = primitive[prim_idx.Temperature()]; - fluidModel->ComputeTempFromEnthalpy(enthalpy, &temperature, scalar); + fluidModel->SetTDState_h(enthalpy, scalar); - fluidModel->SetTDState_T(temperature, scalar); - - primitive[prim_idx.Temperature()] = temperature; + primitive[prim_idx.Temperature()] = fluidModel->GetTemperature(); primitive[prim_idx.Density()] = fluidModel->GetDensity(); } @@ -2498,8 +2495,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, if (energy_multicomponent) { CFluidModel* auxFluidModel = solver_container[FLOW_SOL]->GetFluidModel(); const su2double* scalar_inlet = config->GetInlet_SpeciesVal(config->GetMarker_All_TagBound(val_marker)); - auxFluidModel->SetTDState_T(V_inlet[prim_idx.Temperature()], - scalar_inlet); // compute total enthalpy from temperature + auxFluidModel->SetTDState_T(V_inlet[prim_idx.Temperature()], scalar_inlet); V_inlet[prim_idx.Enthalpy()] = auxFluidModel->GetEnthalpy(); } diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index bc909abdb1b6..55524bfef7bb 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -67,22 +67,24 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do if(Energy_Multicomponent){ su2double Enthalpy = Solution(iPoint, nDim +1); - FluidModel->ComputeTempFromEnthalpy(Enthalpy, &Temperature, scalar); + FluidModel->SetTDState_h(Enthalpy, scalar); + Temperature = FluidModel->GetTemperature(); } else { /*--- Set the value of the temperature directly ---*/ Temperature = Solution(iPoint, indices.Temperature()); } auto check_temp = SetTemperature(iPoint, Temperature); - /*--- Use the fluid model to compute the new value of density. - Note that the thermodynamic pressure is constant and decoupled - from the dynamic pressure being iterated. ---*/ + + if (!Energy_Multicomponent) { + /*--- Use the fluid model to compute the new value of density. + Note that the thermodynamic pressure is constant and decoupled + from the dynamic pressure being iterated. ---*/ - /*--- Use the fluid model to compute the new value of density. ---*/ + /*--- Use the fluid model to compute the new value of density. ---*/ - FluidModel->SetTDState_T(Temperature, scalar); + FluidModel->SetTDState_T(Temperature, scalar); - if (!Energy_Multicomponent) { /*--- for FLAMELET: copy the LUT temperature into the solution ---*/ Solution(iPoint, nDim + 1) = FluidModel->GetTemperature(); /*--- for FLAMELET: update the local temperature using LUT variables ---*/ @@ -107,12 +109,14 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do if (Energy_Multicomponent) { su2double Enthalpy = Solution(iPoint, nDim + 1); - FluidModel->ComputeTempFromEnthalpy(Enthalpy, &Temperature, scalar); + FluidModel->SetTDState_h(Enthalpy, scalar); + SetTemperature(iPoint, FluidModel->GetTemperature()); } else { Temperature = Solution(iPoint, indices.Temperature()); + SetTemperature(iPoint, Temperature); + FluidModel->SetTDState_T(Temperature, scalar); } - SetTemperature(iPoint, Temperature); - FluidModel->SetTDState_T(Temperature, scalar); + SetDensity(iPoint, FluidModel->GetDensity()); /*--- Flag this point as non-physical. ---*/ From 500a663c983d1918aec9f8295163329cc2a9bc37 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sun, 13 Jul 2025 16:19:31 +0200 Subject: [PATCH 116/173] updating to develop --- Common/include/CConfig.hpp | 7 ++ Common/include/basic_types/ad_structure.hpp | 18 +++- Common/include/linear_algebra/CSysMatrix.hpp | 22 ++++- Common/src/CConfig.cpp | 2 + .../numerics/turbulent/turb_diffusion.hpp | 83 ++++++++++++++----- .../numerics/turbulent/turb_sources.hpp | 35 +++----- .../include/solvers/CFVMFlowSolverBase.inl | 8 +- SU2_CFD/include/solvers/CScalarSolver.hpp | 1 + SU2_CFD/include/solvers/CScalarSolver.inl | 10 ++- SU2_CFD/include/solvers/CSolver.hpp | 8 +- SU2_CFD/src/solvers/CTurbSASolver.cpp | 74 +++++++++++++++-- TestCases/hybrid_regression.py | 22 ++--- TestCases/hybrid_regression_AD.py | 4 +- TestCases/parallel_regression.py | 44 +++++----- TestCases/parallel_regression_AD.py | 8 +- TestCases/serial_regression.py | 28 +++---- TestCases/serial_regression_AD.py | 4 +- TestCases/tutorials.py | 6 +- TestCases/vandv.py | 12 +-- config_template.cfg | 4 + 20 files changed, 269 insertions(+), 131 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 703768002186..b4ebb9b2f239 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -600,6 +600,7 @@ class CConfig { MUSCL_AdjTurb; /*!< \brief MUSCL scheme for the adj turbulence equations.*/ bool MUSCL_Species; /*!< \brief MUSCL scheme for the species equations.*/ bool Use_Accurate_Jacobians; /*!< \brief Use numerically computed Jacobians for AUSM+up(2) and SLAU(2). */ + bool Use_Accurate_Turb_Jacobians; /*!< \brief Use numerically computed Jacobians for standard SA turbulence model. */ bool EulerPersson; /*!< \brief Boolean to determine whether this is an Euler simulation with Persson shock capturing. */ bool FSI_Problem = false,/*!< \brief Boolean to determine whether the simulation is FSI or not. */ Multizone_Problem; /*!< \brief Boolean to determine whether we are solving a multizone problem. */ @@ -4593,6 +4594,12 @@ class CConfig { */ bool GetUse_Accurate_Jacobians(void) const { return Use_Accurate_Jacobians; } + /*! + * \brief Get whether to "Use Accurate Jacobians" for Standard SA turbulence model. + * \return yes/no. + */ + bool GetUse_Accurate_Turb_Jacobians(void) const { return Use_Accurate_Turb_Jacobians; } + /*! * \brief Get the kind of integration scheme (explicit or implicit) * for the flow equations. diff --git a/Common/include/basic_types/ad_structure.hpp b/Common/include/basic_types/ad_structure.hpp index 5a02b23c2c67..8ec6fabf7bed 100644 --- a/Common/include/basic_types/ad_structure.hpp +++ b/Common/include/basic_types/ad_structure.hpp @@ -52,12 +52,12 @@ inline void StartRecording() {} * \brief Pause the recording of the operations and involved variables. * If called, all operations occuring after the call will not be stored on the computational graph. */ -inline void PauseRecording() {} +inline bool PauseRecording() { return false; } /*! * \brief Resume the recording of the operations and variables after the recording had been paused. */ -inline void ResumeRecording() {} +inline void ResumeRecording(bool wasActive) { (void)wasActive; } /*! * \brief Stops the recording of the operations and variables. @@ -413,9 +413,19 @@ FORCEINLINE void ResetInput(su2double& data) { data = data.getValue(); } FORCEINLINE void StartRecording() { AD::getTape().setActive(); } -FORCEINLINE void PauseRecording() { AD::getTape().setPassive(); } +FORCEINLINE bool PauseRecording() { + if (AD::getTape().isActive()) { + AD::getTape().setPassive(); + return true; + } + return false; +} -FORCEINLINE void ResumeRecording() { AD::getTape().setActive(); } +FORCEINLINE void ResumeRecording(bool wasActive) { + if (wasActive) { + AD::getTape().setActive(); + } +} FORCEINLINE void StopRecording() { AD::getTape().setPassive(); } diff --git a/Common/include/linear_algebra/CSysMatrix.hpp b/Common/include/linear_algebra/CSysMatrix.hpp index 7d0e87b92e35..d3212e7a9f5f 100644 --- a/Common/include/linear_algebra/CSysMatrix.hpp +++ b/Common/include/linear_algebra/CSysMatrix.hpp @@ -553,6 +553,22 @@ class CSysMatrix { SetBlock(block_i, block_j, val_block, alpha); } + /*! + * \brief Returns the 4 blocks ii, ij, ji, jj used by "UpdateBlocks". + * \note This method assumes an FVM-type sparse pattern. + * \param[in] edge - Index of edge that connects iPoint and jPoint. + * \param[in] iPoint - Row to which we add the blocks. + * \param[in] jPoint - Row from which we subtract the blocks. + * \param[out] bii, bij, bji, bjj - Blocks of the matrix. + */ + inline void GetBlocks(unsigned long iEdge, unsigned long iPoint, unsigned long jPoint, ScalarType*& bii, + ScalarType*& bij, ScalarType*& bji, ScalarType*& bjj) { + bii = &matrix[dia_ptr[iPoint] * nVar * nEqn]; + bjj = &matrix[dia_ptr[jPoint] * nVar * nEqn]; + bij = &matrix[edge_ptr(iEdge, 0) * nVar * nEqn]; + bji = &matrix[edge_ptr(iEdge, 1) * nVar * nEqn]; + } + /*! * \brief Update 4 blocks ii, ij, ji, jj (add to i* sub from j*). * \note This method assumes an FVM-type sparse pattern. @@ -566,10 +582,8 @@ class CSysMatrix { template inline void UpdateBlocks(unsigned long iEdge, unsigned long iPoint, unsigned long jPoint, const MatrixType& block_i, const MatrixType& block_j, OtherType scale = 1) { - ScalarType* bii = &matrix[dia_ptr[iPoint] * nVar * nEqn]; - ScalarType* bjj = &matrix[dia_ptr[jPoint] * nVar * nEqn]; - ScalarType* bij = &matrix[edge_ptr(iEdge, 0) * nVar * nEqn]; - ScalarType* bji = &matrix[edge_ptr(iEdge, 1) * nVar * nEqn]; + ScalarType *bii, *bij, *bji, *bjj; + GetBlocks(iEdge, iPoint, jPoint, bii, bij, bji, bjj); unsigned long iVar, jVar, offset = 0; diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index b51462ba183a..03722f67f163 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -2027,6 +2027,8 @@ void CConfig::SetConfig_Options() { /*!\brief CONV_NUM_METHOD_TURB * \n DESCRIPTION: Convective numerical method \ingroup Config*/ addConvectOption("CONV_NUM_METHOD_TURB", Kind_ConvNumScheme_Turb, Kind_Centered_Turb, Kind_Upwind_Turb); + /*!\brief USE_ACCURATE_TURB_JACOBIANS \n DESCRIPTION: Use numerically computed Jacobians for Standard SA model \ingroup Config*/ + addBoolOption("USE_ACCURATE_TURB_JACOBIANS", Use_Accurate_Turb_Jacobians, false); /*!\brief MUSCL_ADJTURB \n DESCRIPTION: Check if the MUSCL scheme should be used \ingroup Config*/ addBoolOption("MUSCL_ADJTURB", MUSCL_AdjTurb, false); diff --git a/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp b/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp index b8edcd9007a7..2977b0343c88 100644 --- a/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp +++ b/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp @@ -52,6 +52,9 @@ class CAvgGrad_TurbSA final : public CAvgGrad_Scalar { using Base::Jacobian_j; const su2double sigma = 2.0/3.0; + const su2double cb2 = 0.622; + + const bool use_accurate_jacobians; /*! * \brief Adds any extra variables to AD @@ -67,17 +70,39 @@ class CAvgGrad_TurbSA final : public CAvgGrad_Scalar { /*--- Compute mean effective viscosity ---*/ + /*--- First Term. Normal diffusion, and conservative part of the quadratic diffusion. + * ||grad nu_t||^2 = div(nu_t grad nu_t) - nu_t div grad nu_t ---*/ const su2double nu_i = Laminar_Viscosity_i/Density_i; const su2double nu_j = Laminar_Viscosity_j/Density_j; - const su2double nu_e = 0.5*(nu_i+nu_j+ScalarVar_i[0]+ScalarVar_j[0]); + const su2double nu_e = 0.5 * (nu_i + nu_j + (1 + cb2) * (ScalarVar_i[0] + ScalarVar_j[0])); + const su2double term_1 = nu_e; - Flux[0] = nu_e*Proj_Mean_GradScalarVar[0]/sigma; + /* Second Term (quadratic diffusion, non conservative). */ + const su2double nu_tilde_i = ScalarVar_i[0]; + const su2double term_2 = cb2 * nu_tilde_i; - /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + const su2double diffusion_coefficient = term_1 - term_2; + Flux[0] = diffusion_coefficient * Proj_Mean_GradScalarVar[0] / sigma; if (implicit) { - Jacobian_i[0][0] = (0.5*Proj_Mean_GradScalarVar[0]-nu_e*proj_vector_ij)/sigma; - Jacobian_j[0][0] = (0.5*Proj_Mean_GradScalarVar[0]+nu_e*proj_vector_ij)/sigma; + /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + Jacobian_i[0][0] = -diffusion_coefficient * proj_vector_ij / sigma; + Jacobian_j[0][0] = diffusion_coefficient * proj_vector_ij / sigma; + + if (use_accurate_jacobians) { + /*--- The diffusion coefficient is also a function of nu_t. ---*/ + const su2double dTerm1_dnut_i = (1 + cb2) * 0.5; + const su2double dTerm1_dnut_j = (1 + cb2) * 0.5; + + const su2double dTerm2_dnut_i = cb2; + const su2double dTerm2_dnut_j = 0.0; + + const su2double dDC_dnut_i = dTerm1_dnut_i - dTerm2_dnut_i; + const su2double dDC_dnut_j = dTerm1_dnut_j - dTerm2_dnut_j; + + Jacobian_i[0][0] += dDC_dnut_i * Proj_Mean_GradScalarVar[0] / sigma; + Jacobian_j[0][0] += dDC_dnut_j * Proj_Mean_GradScalarVar[0] / sigma; + } } } @@ -91,7 +116,8 @@ class CAvgGrad_TurbSA final : public CAvgGrad_Scalar { */ CAvgGrad_TurbSA(unsigned short val_nDim, unsigned short val_nVar, bool correct_grad, const CConfig* config) - : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config) {} + : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config), + use_accurate_jacobians(config->GetUse_Accurate_Turb_Jacobians()) {} }; /*! @@ -118,6 +144,7 @@ class CAvgGrad_TurbSA_Neg final : public CAvgGrad_Scalar { const su2double sigma = 2.0/3.0; const su2double cn1 = 16.0; + const su2double cb2 = 0.622; /*! * \brief Adds any extra variables to AD @@ -136,27 +163,39 @@ class CAvgGrad_TurbSA_Neg final : public CAvgGrad_Scalar { const su2double nu_i = Laminar_Viscosity_i/Density_i; const su2double nu_j = Laminar_Viscosity_j/Density_j; - const su2double nu_ij = 0.5*(nu_i+nu_j); - const su2double nu_tilde_ij = 0.5*(ScalarVar_i[0] + ScalarVar_j[0]); - - su2double nu_e; - - if (nu_tilde_ij > 0.0) { - nu_e = nu_ij + nu_tilde_ij; - } - else { - const su2double Xi = nu_tilde_ij/nu_ij; - const su2double fn = (cn1 + Xi*Xi*Xi)/(cn1 - Xi*Xi*Xi); - nu_e = nu_ij + fn*nu_tilde_ij; + const su2double nu_ij = 0.5 * (nu_i + nu_j); + const su2double nu_tilde_i = ScalarVar_i[0]; + const su2double nu_tilde_j = ScalarVar_j[0]; + const su2double nu_tilde_ij = 0.5 * (nu_tilde_i + nu_tilde_j); + + /*--- Following Diskin's implementation from 10.2514/1.J064629, they propose a new fn function + * to be evaluated at the cell to maintain positivity in the diffusion coefficient, which is + * used in both terms. The new fn term averaged across the face reverts to the original fn + * function. ---*/ + + /*--- Second Term (LHS) ---*/ + const su2double zeta_i = ((1 + cb2) * nu_tilde_ij - cb2 * nu_tilde_i) / nu_ij; + su2double fn_i = 1.0; + if (zeta_i < 0.0) { + fn_i = (cn1 + pow(zeta_i,3)) / (cn1 - pow(zeta_i,3)); } - Flux[0] = nu_e*Proj_Mean_GradScalarVar[0]/sigma; + const su2double term_1 = (nu_ij + (1 + cb2) * nu_tilde_ij * fn_i); + const su2double term_2 = cb2 * nu_tilde_i * fn_i; + Flux[0] = (term_1 - term_2) * Proj_Mean_GradScalarVar[0] / sigma; - /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients + * Exact Jacobians were tested on multiple cases but resulted in divergence of all + * simulations, hence only frozen diffusion coefficient (approximate) Jacobians are used. ---*/ if (implicit) { - Jacobian_i[0][0] = (0.5*Proj_Mean_GradScalarVar[0]-nu_e*proj_vector_ij)/sigma; - Jacobian_j[0][0] = (0.5*Proj_Mean_GradScalarVar[0]+nu_e*proj_vector_ij)/sigma; + const su2double diffusion_coefficient = (term_1 - term_2); + + const su2double dGrad_dnut_i = -proj_vector_ij; + const su2double dGrad_dnut_j = proj_vector_ij; + + Jacobian_i[0][0] = diffusion_coefficient * dGrad_dnut_i / sigma; + Jacobian_j[0][0] = diffusion_coefficient * dGrad_dnut_j / sigma; } } diff --git a/SU2_CFD/include/numerics/turbulent/turb_sources.hpp b/SU2_CFD/include/numerics/turbulent/turb_sources.hpp index 4fa9080e1ad5..1ab24ac6fae4 100644 --- a/SU2_CFD/include/numerics/turbulent/turb_sources.hpp +++ b/SU2_CFD/include/numerics/turbulent/turb_sources.hpp @@ -86,7 +86,7 @@ class CSourceBase_TurbSA : public CNumerics { */ inline void ResidualAxisymmetricDiffusion(su2double sigma) { if (Coord_i[1] < EPS) return; - + const su2double yinv = 1.0 / Coord_i[1]; const su2double& nue = ScalarVar_i[0]; @@ -243,14 +243,14 @@ class CSourceBase_TurbSA : public CNumerics { var.interDestrFactor = 1.0; } - /*--- Compute production, destruction and cross production and jacobian ---*/ - su2double Production = 0.0, Destruction = 0.0, CrossProduction = 0.0; - SourceTerms::get(ScalarVar_i[0], var, Production, Destruction, CrossProduction, Jacobian_i[0]); + /*--- Compute production, destruction and jacobian ---*/ + su2double Production = 0.0, Destruction = 0.0; + SourceTerms::get(ScalarVar_i[0], var, Production, Destruction, Jacobian_i[0]); - Residual = (Production - Destruction + CrossProduction) * Volume; + Residual = (Production - Destruction) * Volume; if (axisymmetric) ResidualAxisymmetricDiffusion(var.sigma); - + Jacobian_i[0] *= Volume; } @@ -423,13 +423,13 @@ struct Edw { }; /*! - * \brief SA source terms classes: production, destruction and cross-productions term and their derivative. + * \brief SA source terms classes: production and destruction term and their derivative. + * \note Quadratic diffusion is included in the viscous fluxes. * \ingroup SourceDiscr * \param[in] nue: SA variable. * \param[in] var: Common SA variables struct. * \param[out] production: Production term. * \param[out] destruction: Destruction term. - * \param[out] cross_production: CrossProduction term. * \param[out] jacobian: Derivative of the combined source term wrt nue. */ struct SourceTerms { @@ -437,10 +437,9 @@ struct SourceTerms { /*! \brief Baseline (Original SA model). */ struct Bsl { static void get(const su2double& nue, const CSAVariables& var, su2double& production, su2double& destruction, - su2double& cross_production, su2double& jacobian) { + su2double& jacobian) { ComputeProduction(nue, var, production, jacobian); ComputeDestruction(nue, var, destruction, jacobian); - ComputeCrossProduction(nue, var, cross_production, jacobian); } static void ComputeProduction(const su2double& nue, const CSAVariables& var, su2double& production, @@ -458,23 +457,17 @@ struct Bsl { jacobian -= var.interDestrFactor * ((var.cw1 * var.d_fw - cb1_k2 * var.d_ft2) * pow(nue, 2) + factor * 2 * nue) / var.dist_i_2; } - static void ComputeCrossProduction(const su2double& nue, const CSAVariables& var, su2double& cross_production, - su2double&) { - cross_production = var.cb2_sigma * var.norm2_Grad; - /*--- No contribution to the jacobian. ---*/ - } }; /*! \brief Negative. */ struct Neg { static void get(const su2double& nue, const CSAVariables& var, su2double& production, su2double& destruction, - su2double& cross_production, su2double& jacobian) { + su2double& jacobian) { if (nue > 0.0) { - Bsl::get(nue, var, production, destruction, cross_production, jacobian); + Bsl::get(nue, var, production, destruction, jacobian); } else { ComputeProduction(nue, var, production, jacobian); ComputeDestruction(nue, var, destruction, jacobian); - ComputeCrossProduction(nue, var, cross_production, jacobian); } } @@ -493,10 +486,6 @@ struct Neg { jacobian -= 2 * dD_dnu * var.interDestrFactor; } - static void ComputeCrossProduction(const su2double& nue, const CSAVariables& var, su2double& cross_production, - su2double& jacobian) { - Bsl::ComputeCrossProduction(nue, var, cross_production, jacobian); - } }; }; @@ -562,7 +551,7 @@ class CCompressibilityCorrection final : public ParentClass { const su2double v = V_i[idx.Velocity() + 1]; const su2double d_axiCorrection = 2.0 * c5 * nue * pow(v * yinv / sound_speed, 2) * Volume; - const su2double axiCorrection = 0.5 * nue * d_axiCorrection; + const su2double axiCorrection = 0.5 * nue * d_axiCorrection; this->Residual -= axiCorrection; this->Jacobian_i[0] -= d_axiCorrection; diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 9ffb59baf2e8..49ca3fdc8f91 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -673,9 +673,11 @@ void CFVMFlowSolverBase::ComputeVorticityAndStrainMag(const CConfig& confi AD::SetPreaccOut(StrainMag(iPoint)); AD::EndPreacc(); - /*--- Max is not differentiable, so we not register them for preacc. ---*/ - strainMax = SU2_TYPE::GetValue(max(strainMax, StrainMag(iPoint))); - omegaMax = SU2_TYPE::GetValue(max(omegaMax, GeometryToolbox::Norm(3, Vorticity))); + /*--- The derivative with respect to strainMax and omegaMax is not required. ---*/ + bool wa = AD::PauseRecording(); + strainMax = max(strainMax, StrainMag(iPoint)); + omegaMax = max(omegaMax, GeometryToolbox::Norm(3, Vorticity)); + AD::ResumeRecording(wa); } END_SU2_OMP_FOR diff --git a/SU2_CFD/include/solvers/CScalarSolver.hpp b/SU2_CFD/include/solvers/CScalarSolver.hpp index 0fc61aa7ab25..363226ebd8c3 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.hpp +++ b/SU2_CFD/include/solvers/CScalarSolver.hpp @@ -77,6 +77,7 @@ class CScalarSolver : public CSolver { /*--- Edge fluxes for reducer strategy (see the notes in CEulerSolver.hpp). ---*/ CSysVector EdgeFluxes; /*!< \brief Flux across each edge. */ + CSysVector EdgeFluxesDiff; /*!< \brief Flux difference between ij and ji for non-conservative discretisation. */ /*! * \brief The highest level in the variable hierarchy this solver can safely use. diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 314354116ff1..bffe6f49dd0d 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -341,15 +341,21 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** template void CScalarSolver::SumEdgeFluxes(CGeometry* geometry) { + const bool nonConservative = EdgeFluxesDiff.GetLocSize() > 0; + SU2_OMP_FOR_STAT(omp_chunk_size) for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { LinSysRes.SetBlock_Zero(iPoint); for (auto iEdge : geometry->nodes->GetEdges(iPoint)) { - if (iPoint == geometry->edges->GetNode(iEdge, 0)) + if (iPoint == geometry->edges->GetNode(iEdge, 0)) { LinSysRes.AddBlock(iPoint, EdgeFluxes.GetBlock(iEdge)); - else + } else { LinSysRes.SubtractBlock(iPoint, EdgeFluxes.GetBlock(iEdge)); + if (nonConservative) { + LinSysRes.SubtractBlock(iPoint, EdgeFluxesDiff.GetBlock(iEdge)); + } + } } } END_SU2_OMP_FOR diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 417e57d08178..1e744e1c4db7 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -191,12 +191,12 @@ class CSolver { CSysVector LinSysSol; /*!< \brief vector to store iterative solution of implicit linear system. */ CSysVector LinSysRes; /*!< \brief vector to store iterative residual of implicit linear system. */ #ifndef CODI_FORWARD_TYPE - CSysMatrix Jacobian; /*!< \brief Complete sparse Jacobian structure for implicit computations. */ - CSysSolve System; /*!< \brief Linear solver/smoother. */ + using JacobianScalarType = su2mixedfloat; #else - CSysMatrix Jacobian; - CSysSolve System; + using JacobianScalarType = su2double; #endif + CSysMatrix Jacobian; /*!< \brief Complete sparse Jacobian structure for implicit computations. */ + CSysSolve System; /*!< \brief Linear solver/smoother. */ CSysVector OutputVariables; /*!< \brief vector to store the extra variables to be written. */ string* OutputHeadingNames; /*!< \brief vector of strings to store the headings for the exra variables */ diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index 4a0d54a95176..18eff14832e2 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -73,8 +73,10 @@ CTurbSASolver::CTurbSASolver(CGeometry *geometry, CConfig *config, unsigned shor LinSysRes.Initialize(nPoint, nPointDomain, nVar, 0.0); System.SetxIsZero(true); - if (ReducerStrategy) + if (ReducerStrategy) { EdgeFluxes.Initialize(geometry->GetnEdge(), geometry->GetnEdge(), nVar, nullptr); + EdgeFluxesDiff.Initialize(geometry->GetnEdge(), geometry->GetnEdge(), nVar, nullptr); + } if (config->GetExtraOutput()) { if (nDim == 2) { nOutputVariables = 13; } @@ -294,15 +296,77 @@ void CTurbSASolver::Postprocessing(CGeometry *geometry, CSolver **solver_contain void CTurbSASolver::Viscous_Residual(const unsigned long iEdge, const CGeometry* geometry, CSolver** solver_container, CNumerics* numerics, const CConfig* config) { - /*--- Define an object to set solver specific numerics contribution. ---*/ - auto SolverSpecificNumerics = [&](unsigned long iPoint, unsigned long jPoint) { + const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); + CFlowVariable* flowNodes = solver_container[FLOW_SOL] ? + su2staticcast_p(solver_container[FLOW_SOL]->GetNodes()) : nullptr; + + /*--- Points in edge. ---*/ + const auto iPoint = geometry->edges->GetNode(iEdge, 0); + const auto jPoint = geometry->edges->GetNode(iEdge, 1); + + /*--- Helper function to compute the flux ---*/ + auto ComputeFlux = [&](unsigned long iPoint, unsigned long jPoint, const su2double* normal) { + numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(jPoint)); + numerics->SetNormal(normal); + + if (flowNodes) { + numerics->SetPrimitive(flowNodes->GetPrimitive(iPoint), flowNodes->GetPrimitive(jPoint)); + } /*--- Roughness heights. ---*/ numerics->SetRoughness(geometry->nodes->GetRoughnessHeight(iPoint), geometry->nodes->GetRoughnessHeight(jPoint)); + + numerics->SetScalarVar(nodes->GetSolution(iPoint), nodes->GetSolution(jPoint)); + numerics->SetScalarVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(jPoint)); + + return numerics->ComputeResidual(config); }; - /*--- Now instantiate the generic implementation with the functor above. ---*/ + /*--- Compute fluxes and jacobians i->j ---*/ + const su2double* normal = geometry->edges->GetNormal(iEdge); + auto residual_ij = ComputeFlux(iPoint, jPoint, normal); - Viscous_Residual_impl(SolverSpecificNumerics, iEdge, geometry, solver_container, numerics, config); + JacobianScalarType *Block_ii = nullptr, *Block_ij = nullptr, *Block_ji = nullptr, *Block_jj = nullptr; + if (implicit) { + Jacobian.GetBlocks(iEdge, iPoint, jPoint, Block_ii, Block_ij, Block_ji, Block_jj); + } + if (ReducerStrategy) { + EdgeFluxes.SubtractBlock(iEdge, residual_ij); + EdgeFluxesDiff.SetBlock(iEdge, residual_ij); + if (implicit) { + /*--- For the reducer strategy the Jacobians are averaged for simplicity. ---*/ + assert(nVar == 1); + Block_ij[0] -= 0.5 * SU2_TYPE::GetValue(residual_ij.jacobian_j[0][0]); + Block_ji[0] += 0.5 * SU2_TYPE::GetValue(residual_ij.jacobian_i[0][0]); + } + } else { + LinSysRes.SubtractBlock(iPoint, residual_ij); + if (implicit) { + assert(nVar == 1); + Block_ii[0] -= SU2_TYPE::GetValue(residual_ij.jacobian_i[0][0]); + Block_ij[0] -= SU2_TYPE::GetValue(residual_ij.jacobian_j[0][0]); + } + } + + /*--- Compute fluxes and jacobians j->i ---*/ + su2double flipped_normal[MAXNDIM]; + for (auto iDim = 0u; iDim < nDim; iDim++) flipped_normal[iDim] = -normal[iDim]; + + auto residual_ji = ComputeFlux(jPoint, iPoint, flipped_normal); + if (ReducerStrategy) { + EdgeFluxesDiff.AddBlock(iEdge, residual_ji); + if (implicit) { + Block_ij[0] += 0.5 * SU2_TYPE::GetValue(residual_ji.jacobian_i[0][0]); + Block_ji[0] -= 0.5 * SU2_TYPE::GetValue(residual_ji.jacobian_j[0][0]); + } + } else { + LinSysRes.SubtractBlock(jPoint, residual_ji); + if (implicit) { + /*--- The order of arguments were flipped in the evaluation of residual_ji, the Jacobian + * associated with point i is stored in jacobian_j and point j in jacobian_i. ---*/ + Block_ji[0] -= SU2_TYPE::GetValue(residual_ji.jacobian_j[0][0]); + Block_jj[0] -= SU2_TYPE::GetValue(residual_ji.jacobian_i[0][0]); + } + } } void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, diff --git a/TestCases/hybrid_regression.py b/TestCases/hybrid_regression.py index 366589a7994f..e4a747f2c913 100644 --- a/TestCases/hybrid_regression.py +++ b/TestCases/hybrid_regression.py @@ -181,7 +181,7 @@ def main(): turb_flatplate.cfg_dir = "rans/flatplate" turb_flatplate.cfg_file = "turb_SA_flatplate.cfg" turb_flatplate.test_iter = 20 - turb_flatplate.test_vals = [-4.316134, -6.737979, -0.187461, 0.057468] + turb_flatplate.test_vals = [-4.316127, -6.738720, -0.187461, 0.057469] test_list.append(turb_flatplate) # ONERA M6 Wing @@ -189,7 +189,7 @@ def main(): turb_oneram6.cfg_dir = "rans/oneram6" turb_oneram6.cfg_file = "turb_ONERAM6.cfg" turb_oneram6.test_iter = 10 - turb_oneram6.test_vals = [-2.408675, -6.662904, 0.238578, 0.158968, 0.000000] + turb_oneram6.test_vals = [-2.408655, -6.628338, 0.238580, 0.158951, 0.000000] test_list.append(turb_oneram6) # NACA0012 (SA, FUN3D finest grid results: CL=1.0983, CD=0.01242) @@ -197,8 +197,8 @@ def main(): turb_naca0012_sa.cfg_dir = "rans/naca0012" turb_naca0012_sa.cfg_file = "turb_NACA0012_sa.cfg" turb_naca0012_sa.test_iter = 5 - turb_naca0012_sa.test_vals = [-12.098325, -14.149988, 1.057665, 0.022971, 20.000000, -2.292707, 0.000000, -12.068169, 0] - turb_naca0012_sa.test_vals_aarch64 = [-12.098325, -14.149988, 1.057665, 0.022971, 20.000000, -2.292707, 0.000000, -12.068169, 0] + turb_naca0012_sa.test_vals = [-12.050637, -16.149098, 1.058588, 0.022984, 20.000000, -2.832819, 0.000000, -14.067279, 0] + turb_naca0012_sa.test_vals_aarch64 = [-12.050637, -16.149098, 1.058588, 0.022984, 20.000000, -2.832819, 0.000000, -14.067279, 0] test_list.append(turb_naca0012_sa) # NACA0012 (SST, FUN3D finest grid results: CL=1.0840, CD=0.01253) @@ -238,7 +238,7 @@ def main(): propeller.cfg_dir = "rans/propeller" propeller.cfg_file = "propeller.cfg" propeller.test_iter = 10 - propeller.test_vals = [-3.389724, -8.409502, 0.000048, 0.056344] + propeller.test_vals = [-3.389724, -8.410479, 0.000048, 0.056344] test_list.append(propeller) ####################################### @@ -332,7 +332,7 @@ def main(): hb_rans_preconditioning.cfg_dir = "harmonic_balance/hb_rans_preconditioning" hb_rans_preconditioning.cfg_file = "davis.cfg" hb_rans_preconditioning.test_iter = 25 - hb_rans_preconditioning.test_vals = [-1.902111, 0.484080, 0.601469, 3.608991, -5.949369] + hb_rans_preconditioning.test_vals = [-1.902098, 0.484244, 0.601482, 3.609005, -5.943887] test_list.append(hb_rans_preconditioning) ############################# @@ -403,7 +403,7 @@ def main(): inc_turb_naca0012.cfg_dir = "incomp_rans/naca0012" inc_turb_naca0012.cfg_file = "naca0012.cfg" inc_turb_naca0012.test_iter = 20 - inc_turb_naca0012.test_vals = [-4.788405, -11.040560, 0.000008, 0.309505] + inc_turb_naca0012.test_vals = [-4.788405, -11.040877, 0.000008, 0.309505] test_list.append(inc_turb_naca0012) # NACA0012, SST_SUST @@ -419,7 +419,7 @@ def main(): inc_weakly_coupled.cfg_dir = "disc_adj_heat" inc_weakly_coupled.cfg_file = "primal.cfg" inc_weakly_coupled.test_iter = 10 - inc_weakly_coupled.test_vals = [-18.894811, -17.879327, -18.412938, -17.855948, -18.343462, -15.659612, 5.545700] + inc_weakly_coupled.test_vals = [-18.095922, -16.331787, -16.514014, -13.703679, -18.203865, -14.053738, 5.545900] test_list.append(inc_weakly_coupled) ###################################### @@ -503,7 +503,7 @@ def main(): ddes_flatplate.cfg_dir = "ddes/flatplate" ddes_flatplate.cfg_file = "ddes_flatplate.cfg" ddes_flatplate.test_iter = 10 - ddes_flatplate.test_vals = [-2.714713, -5.788302, -0.214960, 0.023758, 0.000000] + ddes_flatplate.test_vals = [-2.714713, -5.763293, -0.214960, 0.023758, 0.000000] ddes_flatplate.unsteady = True test_list.append(ddes_flatplate) @@ -582,8 +582,8 @@ def main(): multi_interface.cfg_dir = "turbomachinery/multi_interface" multi_interface.cfg_file = "multi_interface_rst.cfg" multi_interface.test_iter = 5 - multi_interface.test_vals = [-8.632374, -8.895124, -9.350417] - multi_interface.test_vals_aarch64 = [-8.632374, -8.895124, -9.350417] + multi_interface.test_vals = [-8.632229, -8.894737, -9.348730] + multi_interface.test_vals_aarch64 = [-8.632229, -8.894737, -9.348730] test_list.append(multi_interface) ###################################### diff --git a/TestCases/hybrid_regression_AD.py b/TestCases/hybrid_regression_AD.py index 0727b5888735..9b4bdb23c52f 100644 --- a/TestCases/hybrid_regression_AD.py +++ b/TestCases/hybrid_regression_AD.py @@ -78,7 +78,7 @@ def main(): discadj_rans_naca0012_sa.cfg_dir = "disc_adj_rans/naca0012" discadj_rans_naca0012_sa.cfg_file = "turb_NACA0012_sa.cfg" discadj_rans_naca0012_sa.test_iter = 10 - discadj_rans_naca0012_sa.test_vals = [-2.997064, -0.196172, 0.000003, -0.000000, 5.000000, -2.919675, 5.000000, -7.323218] + discadj_rans_naca0012_sa.test_vals = [-2.997050, -0.199287, 0.000003, -0.000000, 5.000000, -2.919668, 5.000000, -7.320138] test_list.append(discadj_rans_naca0012_sa) # Adjoint turbulent NACA0012 SST @@ -123,7 +123,7 @@ def main(): discadj_incomp_turb_NACA0012_sa.cfg_dir = "disc_adj_incomp_rans/naca0012" discadj_incomp_turb_NACA0012_sa.cfg_file = "turb_naca0012_sa.cfg" discadj_incomp_turb_NACA0012_sa.test_iter = 10 - discadj_incomp_turb_NACA0012_sa.test_vals = [10.000000, -3.845995, -1.031096, 0.000000] + discadj_incomp_turb_NACA0012_sa.test_vals = [10.000000, -3.845995, -1.023534, 0.000000] test_list.append(discadj_incomp_turb_NACA0012_sa) # Adjoint Incompressible Turbulent NACA 0012 SST diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 1d1cc8c04f34..2b7050f619ef 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -357,7 +357,7 @@ def main(): rae2822_sa.cfg_dir = "rans/rae2822" rae2822_sa.cfg_file = "turb_SA_RAE2822.cfg" rae2822_sa.test_iter = 20 - rae2822_sa.test_vals = [-2.004689, -5.265797, 0.809463, 0.062016, 0] + rae2822_sa.test_vals = [-2.004689, -5.265730, 0.809462, 0.062011, 0.000000] test_list.append(rae2822_sa) # RAE2822 SST @@ -381,7 +381,7 @@ def main(): turb_flatplate.cfg_dir = "rans/flatplate" turb_flatplate.cfg_file = "turb_SA_flatplate.cfg" turb_flatplate.test_iter = 20 - turb_flatplate.test_vals = [-4.297198, -6.730442, -0.187632, 0.057700] + turb_flatplate.test_vals = [-4.297192, -6.731227, -0.187632, 0.057700] test_list.append(turb_flatplate) # Flat plate (compressible) with species inlet @@ -389,7 +389,7 @@ def main(): turb_flatplate_species.cfg_dir = "rans/flatplate" turb_flatplate_species.cfg_file = "turb_SA_flatplate_species.cfg" turb_flatplate_species.test_iter = 20 - turb_flatplate_species.test_vals = [-4.249479, -0.634915, -1.716291, 1.223196, -3.307930, 9.000000, -6.634088, 5.000000, -6.985954, 10.000000, -6.255640, 0.999903, 0.999903] + turb_flatplate_species.test_vals = [-4.249474, -0.634908, -1.716288, 1.223201, -3.307930, 9.000000, -6.634095, 5.000000, -6.986784, 10.000000, -6.255641, 0.999903, 0.999903] test_list.append(turb_flatplate_species) # Flat plate SST compressibility correction Wilcox @@ -413,7 +413,7 @@ def main(): turb_oneram6.cfg_dir = "rans/oneram6" turb_oneram6.cfg_file = "turb_ONERAM6.cfg" turb_oneram6.test_iter = 10 - turb_oneram6.test_vals = [-2.408685, -6.662907, 0.238579, 0.158968, 0.000000] + turb_oneram6.test_vals = [-2.408664, -6.628340, 0.238581, 0.158952, 0.000000] turb_oneram6.timeout = 3200 test_list.append(turb_oneram6) @@ -422,7 +422,7 @@ def main(): turb_oneram6_vc.cfg_dir = "rans/oneram6" turb_oneram6_vc.cfg_file = "turb_ONERAM6_vc.cfg" turb_oneram6_vc.test_iter = 15 - turb_oneram6_vc.test_vals = [-2.282318, -6.614780, 0.234330, 0.143024, 0.000000] + turb_oneram6_vc.test_vals = [-2.282278, -6.568458, 0.234350, 0.142989, 0.000000] turb_oneram6_vc.timeout = 3200 test_list.append(turb_oneram6_vc) @@ -431,7 +431,7 @@ def main(): turb_oneram6_nk.cfg_dir = "rans/oneram6" turb_oneram6_nk.cfg_file = "turb_ONERAM6_nk.cfg" turb_oneram6_nk.test_iter = 20 - turb_oneram6_nk.test_vals = [-4.828066, -4.426250, -11.417591, 0.224679, 0.044309, 1.000000, -0.642977, 31.384000] + turb_oneram6_nk.test_vals = [-4.827571, -4.425650, -11.379658, 0.224787, 0.044208, 1.000000, -0.642711, 31.384000] turb_oneram6_nk.timeout = 600 turb_oneram6_nk.tol = 0.0001 test_list.append(turb_oneram6_nk) @@ -441,7 +441,7 @@ def main(): turb_naca0012_sa.cfg_dir = "rans/naca0012" turb_naca0012_sa.cfg_file = "turb_NACA0012_sa.cfg" turb_naca0012_sa.test_iter = 5 - turb_naca0012_sa.test_vals = [-12.094695, -14.685268, 1.057665, 0.022971, 20.000000, -1.692967, 20.000000, -4.037673, 0] + turb_naca0012_sa.test_vals = [-12.050143, -16.185204, 1.058588, 0.022984, 20.000000, -1.562786, 20.000000, -3.900124, 0.000000] turb_naca0012_sa.timeout = 3200 test_list.append(turb_naca0012_sa) @@ -507,7 +507,7 @@ def main(): propeller.cfg_dir = "rans/propeller" propeller.cfg_file = "propeller.cfg" propeller.test_iter = 10 - propeller.test_vals = [-3.389724, -8.409502, 0.000048, 0.056344] + propeller.test_vals = [-3.389724, -8.410479, 0.000048, 0.056344] propeller.timeout = 3200 test_list.append(propeller) @@ -646,7 +646,7 @@ def main(): inc_turb_naca0012.cfg_dir = "incomp_rans/naca0012" inc_turb_naca0012.cfg_file = "naca0012.cfg" inc_turb_naca0012.test_iter = 20 - inc_turb_naca0012.test_vals = [-4.788595, -11.040625, -0.000002, 0.309519] + inc_turb_naca0012.test_vals = [-4.788595, -11.040942, -0.000002, 0.309519] test_list.append(inc_turb_naca0012) # NACA0012, SST_SUST @@ -732,7 +732,7 @@ def main(): turbmod_sa_bsl_rae2822.cfg_dir = "turbulence_models/sa/rae2822" turbmod_sa_bsl_rae2822.cfg_file = "turb_SA_BSL_RAE2822.cfg" turbmod_sa_bsl_rae2822.test_iter = 20 - turbmod_sa_bsl_rae2822.test_vals = [-2.004689, 0.742306, 0.497308, -5.265797, 0.809463, 0.062016] + turbmod_sa_bsl_rae2822.test_vals = [-2.004689, 0.742307, 0.497308, -5.265730, 0.809462, 0.062011] test_list.append(turbmod_sa_bsl_rae2822) # SA Negative @@ -740,7 +740,7 @@ def main(): turbmod_sa_neg_rae2822.cfg_dir = "turbulence_models/sa/rae2822" turbmod_sa_neg_rae2822.cfg_file = "turb_SA_NEG_RAE2822.cfg" turbmod_sa_neg_rae2822.test_iter = 10 - turbmod_sa_neg_rae2822.test_vals = [-1.204800, 1.611685, 1.349330, 1.489602, 1.263603, 0.466487, 0] + turbmod_sa_neg_rae2822.test_vals = [-1.345491, 1.448526, 1.208572, -0.846542, 1.263765, 0.494751, 0.000000] turbmod_sa_neg_rae2822.test_vals_aarch64 = [-1.359612, 1.493629, 1.218367, -1.441703, 1.248499, 0.457987, 0] test_list.append(turbmod_sa_neg_rae2822) @@ -749,7 +749,7 @@ def main(): turbmod_sa_comp_rae2822.cfg_dir = "turbulence_models/sa/rae2822" turbmod_sa_comp_rae2822.cfg_file = "turb_SA_COMP_RAE2822.cfg" turbmod_sa_comp_rae2822.test_iter = 20 - turbmod_sa_comp_rae2822.test_vals = [-2.004687, 0.742304, 0.497309, -5.266084, 0.809467, 0.062029] + turbmod_sa_comp_rae2822.test_vals = [-2.004688, 0.742305, 0.497309, -5.266066, 0.809466, 0.062026] test_list.append(turbmod_sa_comp_rae2822) # SA Edwards @@ -757,7 +757,7 @@ def main(): turbmod_sa_edw_rae2822.cfg_dir = "turbulence_models/sa/rae2822" turbmod_sa_edw_rae2822.cfg_file = "turb_SA_EDW_RAE2822.cfg" turbmod_sa_edw_rae2822.test_iter = 20 - turbmod_sa_edw_rae2822.test_vals = [-2.004687, 0.742306, 0.497310, -5.290769, 0.809485, 0.062036] + turbmod_sa_edw_rae2822.test_vals = [-2.004687, 0.742306, 0.497310, -5.290787, 0.809485, 0.062034] test_list.append(turbmod_sa_edw_rae2822) # SA Compressibility and Edwards @@ -765,7 +765,7 @@ def main(): turbmod_sa_comp_edw_rae2822.cfg_dir = "turbulence_models/sa/rae2822" turbmod_sa_comp_edw_rae2822.cfg_file = "turb_SA_COMP_EDW_RAE2822.cfg" turbmod_sa_comp_edw_rae2822.test_iter = 20 - turbmod_sa_comp_edw_rae2822.test_vals = [-2.004685, 0.742307, 0.497311, -5.290750, 0.809487, 0.062045] + turbmod_sa_comp_edw_rae2822.test_vals = [-2.004686, 0.742307, 0.497311, -5.290776, 0.809487, 0.062044] test_list.append(turbmod_sa_comp_edw_rae2822) # SA QCR @@ -773,7 +773,7 @@ def main(): turbmod_sa_qcr_rae2822.cfg_dir = "turbulence_models/sa/rae2822" turbmod_sa_qcr_rae2822.cfg_file = "turb_SA_QCR_RAE2822.cfg" turbmod_sa_qcr_rae2822.test_iter = 20 - turbmod_sa_qcr_rae2822.test_vals = [-2.004793, 0.742353, 0.497315, -5.265977, 0.807841, 0.062027] + turbmod_sa_qcr_rae2822.test_vals = [-2.004794, 0.742354, 0.497315, -5.265910, 0.807835, 0.062022] test_list.append(turbmod_sa_qcr_rae2822) ############################ @@ -785,7 +785,7 @@ def main(): schubauer_klebanoff_transition.cfg_dir = "transition/Schubauer_Klebanoff" schubauer_klebanoff_transition.cfg_file = "transitional_BC_model_ConfigFile.cfg" schubauer_klebanoff_transition.test_iter = 10 - schubauer_klebanoff_transition.test_vals = [-8.215651, -13.240283, 0.000048, 0.007983] + schubauer_klebanoff_transition.test_vals = [-8.215651, -13.239431, 0.000048, 0.007983] test_list.append(schubauer_klebanoff_transition) ##################################### @@ -942,7 +942,7 @@ def main(): hb_rans_preconditioning.cfg_file = "davis.cfg" hb_rans_preconditioning.test_iter = 25 hb_rans_preconditioning.tol = 0.00001 - hb_rans_preconditioning.test_vals = [-1.902098, 0.484070, 0.601481, 3.609002, -5.949356] + hb_rans_preconditioning.test_vals = [-1.902085, 0.484234, 0.601494, 3.609016, -5.943874] test_list.append(hb_rans_preconditioning) ###################################### @@ -1009,7 +1009,7 @@ def main(): ddes_flatplate.cfg_dir = "ddes/flatplate" ddes_flatplate.cfg_file = "ddes_flatplate.cfg" ddes_flatplate.test_iter = 10 - ddes_flatplate.test_vals = [-2.714713, -5.788290, -0.214960, 0.023758, 0.000000] + ddes_flatplate.test_vals = [-2.714713, -5.763284, -0.214960, 0.023758, 0.000000] ddes_flatplate.unsteady = True test_list.append(ddes_flatplate) @@ -1086,7 +1086,7 @@ def main(): Aachen_3D_restart.cfg_dir = "turbomachinery/Aachen_turbine" Aachen_3D_restart.cfg_file = "aachen_3D_MP_restart.cfg" Aachen_3D_restart.test_iter = 5 - Aachen_3D_restart.test_vals = [-7.701448, -8.512241, -6.014939, -6.468738, -5.801759, -4.607179, -5.551037, -5.300771, -3.804188, -5.256055, -5.765160, -3.609605, -2.229276, -2.883962, -0.563469] + Aachen_3D_restart.test_vals = [-7.701447, -8.512235, -6.014939, -6.468414, -5.801735, -4.607179, -5.550688, -5.300764, -3.804188, -5.256009, -5.764984, -3.609605, -2.229276, -2.883960, -0.563469] test_list.append(Aachen_3D_restart) # Jones APU Turbocharger restart @@ -1119,8 +1119,8 @@ def main(): multi_interface.cfg_dir = "turbomachinery/multi_interface" multi_interface.cfg_file = "multi_interface_rst.cfg" multi_interface.test_iter = 5 - multi_interface.test_vals = [-8.632374, -8.895124, -9.350417] - multi_interface.test_vals_aarch64 = [-8.632374, -8.895124, -9.350417] + multi_interface.test_vals = [-8.632229, -8.894737, -9.348730] + multi_interface.test_vals_aarch64 = [-8.632229, -8.894737, -9.348730] test_list.append(multi_interface) ###################################### @@ -1567,7 +1567,7 @@ def main(): species2_primitiveVenturi_mixingmodel_viscosity.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_viscosity.cfg_file = "species2_primitiveVenturi_mixingmodel_viscosity.cfg" species2_primitiveVenturi_mixingmodel_viscosity.test_iter = 50 - species2_primitiveVenturi_mixingmodel_viscosity.test_vals = [-5.232339, -3.617118, -3.857221, -7.533847, -5.126646, 5.000000, -1.682962, 5.000000, -3.474078, 5.000000, -2.086859, 2.495548, 0.985490, 0.600234, 0.909824] + species2_primitiveVenturi_mixingmodel_viscosity.test_vals = [-5.236181, -3.624224, -3.871405, -7.533947, -5.128207, 5.000000, -1.678081, 5.000000, -3.489246, 5.000000, -2.086184, 2.495408, 0.985469, 0.600247, 0.909691] test_list.append(species2_primitiveVenturi_mixingmodel_viscosity) # 2 species (1 eq) primitive venturi mixing using mixing model including heat capacity and mass diffusivity diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index 21ec615f9ff4..ce5ed630cc01 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -83,7 +83,7 @@ def main(): discadj_rans_naca0012_sa.cfg_dir = "disc_adj_rans/naca0012" discadj_rans_naca0012_sa.cfg_file = "turb_NACA0012_sa.cfg" discadj_rans_naca0012_sa.test_iter = 10 - discadj_rans_naca0012_sa.test_vals = [-2.996963, -0.196020, 0.000004, -0.000000, 5.000000, -3.430615, 5.000000, -7.411381] + discadj_rans_naca0012_sa.test_vals = [-2.996948, -0.199135, 0.000004, -0.000000, 5.000000, -3.430662, 5.000000, -7.402623] test_list.append(discadj_rans_naca0012_sa) # Adjoint turbulent NACA0012 SST @@ -128,8 +128,8 @@ def main(): discadj_incomp_turb_NACA0012_sa.cfg_dir = "disc_adj_incomp_rans/naca0012" discadj_incomp_turb_NACA0012_sa.cfg_file = "turb_naca0012_sa.cfg" discadj_incomp_turb_NACA0012_sa.test_iter = 10 - discadj_incomp_turb_NACA0012_sa.test_vals = [10.000000, -3.846020, -1.031079, 0.000000] - discadj_incomp_turb_NACA0012_sa.test_vals_aarch64 = [10.000000, -3.846020, -1.031078, 0.000000] + discadj_incomp_turb_NACA0012_sa.test_vals = [10.000000, -3.846020, -1.023517, 0.000000] + discadj_incomp_turb_NACA0012_sa.test_vals_aarch64 = [10.000000, -3.846020, -1.023517, 0.000000] test_list.append(discadj_incomp_turb_NACA0012_sa) # Adjoint Incompressible Turbulent NACA 0012 SST @@ -256,7 +256,7 @@ def main(): discadj_heat.cfg_dir = "disc_adj_heat" discadj_heat.cfg_file = "disc_adj_heat.cfg" discadj_heat.test_iter = 10 - discadj_heat.test_vals = [-1.999668, 0.670563, 0.000000, 0.006210] + discadj_heat.test_vals = [-1.999669, 0.657451, 0.000000, 0.006210] discadj_heat.test_vals_aarch64 = [-2.226539, 0.605868, 0.000000, -6.256400] test_list.append(discadj_heat) diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 24ab6e72f07b..aba223dcefde 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -218,7 +218,7 @@ def main(): rae2822_sa.cfg_dir = "rans/rae2822" rae2822_sa.cfg_file = "turb_SA_RAE2822.cfg" rae2822_sa.test_iter = 20 - rae2822_sa.test_vals = [-2.020123, -5.269339, 0.807147, 0.060499, 0] + rae2822_sa.test_vals = [-2.020123, -5.269264, 0.807147, 0.060494, 0.000000] test_list.append(rae2822_sa) # RAE2822 SST @@ -242,7 +242,7 @@ def main(): turb_flatplate.cfg_dir = "rans/flatplate" turb_flatplate.cfg_file = "turb_SA_flatplate.cfg" turb_flatplate.test_iter = 20 - turb_flatplate.test_vals = [-4.316135, -6.737979, -0.187461, 0.057468] + turb_flatplate.test_vals = [-4.316128, -6.738720, -0.187461, 0.057469] test_list.append(turb_flatplate) # FLAT PLATE, WALL FUNCTIONS, COMPRESSIBLE SST @@ -258,7 +258,7 @@ def main(): turb_wallfunction_flatplate_sa.cfg_dir = "wallfunctions/flatplate/compressible_SA" turb_wallfunction_flatplate_sa.cfg_file = "turb_SA_flatplate.cfg" turb_wallfunction_flatplate_sa.test_iter = 10 - turb_wallfunction_flatplate_sa.test_vals = [-4.487562, -2.016144, -2.169439, 0.834724, -5.382532, 10.000000, -1.508186, 0.034484, 0.002639] + turb_wallfunction_flatplate_sa.test_vals = [-4.456430, -1.959113, -2.105871, 0.883035, -5.248648, 10.000000, -1.537437, 0.034538, 0.002637] test_list.append(turb_wallfunction_flatplate_sa) # ONERA M6 Wing @@ -266,7 +266,7 @@ def main(): turb_oneram6.cfg_dir = "rans/oneram6" turb_oneram6.cfg_file = "turb_ONERAM6.cfg" turb_oneram6.test_iter = 10 - turb_oneram6.test_vals = [-2.408685, -6.662908, 0.238580, 0.158968, 0.000000] + turb_oneram6.test_vals = [-2.408665, -6.628342, 0.238581, 0.158951, 0.000000] turb_oneram6.timeout = 3200 test_list.append(turb_oneram6) @@ -275,7 +275,7 @@ def main(): turb_naca0012_sa.cfg_dir = "rans/naca0012" turb_naca0012_sa.cfg_file = "turb_NACA0012_sa.cfg" turb_naca0012_sa.test_iter = 5 - turb_naca0012_sa.test_vals = [-12.091778, -14.685322, 1.057665, 0.022971, 20.000000, -2.686203, 20.000000, -4.459916, 0] + turb_naca0012_sa.test_vals = [-12.049550, -16.193702, 1.058588, 0.022984, 20.000000, -3.437275, 20.000000, -4.705227, 0.000000] turb_naca0012_sa.timeout = 3200 test_list.append(turb_naca0012_sa) @@ -322,7 +322,7 @@ def main(): propeller.cfg_dir = "rans/propeller" propeller.cfg_file = "propeller.cfg" propeller.test_iter = 10 - propeller.test_vals = [-3.389724, -8.409502, 0.000048, 0.056344] + propeller.test_vals = [-3.389724, -8.410479, 0.000048, 0.056344] propeller.timeout = 3200 test_list.append(propeller) @@ -441,7 +441,7 @@ def main(): inc_turb_naca0012.cfg_dir = "incomp_rans/naca0012" inc_turb_naca0012.cfg_file = "naca0012.cfg" inc_turb_naca0012.test_iter = 20 - inc_turb_naca0012.test_vals = [-4.788495, -11.040578, 0.000023, 0.309503] + inc_turb_naca0012.test_vals = [-4.788495, -11.040895, 0.000023, 0.309502] test_list.append(inc_turb_naca0012) # NACA0012, SST_SUST @@ -465,7 +465,7 @@ def main(): inc_turb_wallfunction_flatplate_sa.cfg_dir = "wallfunctions/flatplate/incompressible_SA" inc_turb_wallfunction_flatplate_sa.cfg_file = "turb_SA_flatplate.cfg" inc_turb_wallfunction_flatplate_sa.test_iter = 10 - inc_turb_wallfunction_flatplate_sa.test_vals = [-6.894429, -5.717193, -6.743475, -4.242550, -9.587276, 10.000000, -2.879802, 0.001021, 0.003759] + inc_turb_wallfunction_flatplate_sa.test_vals = [-6.894206, -5.715970, -6.743740, -4.242551, -9.550272, 10.000000, -2.879370, 0.001021, 0.003759] test_list.append(inc_turb_wallfunction_flatplate_sa) #################### @@ -558,7 +558,7 @@ def main(): schubauer_klebanoff_transition.cfg_dir = "transition/Schubauer_Klebanoff" schubauer_klebanoff_transition.cfg_file = "transitional_BC_model_ConfigFile.cfg" schubauer_klebanoff_transition.test_iter = 10 - schubauer_klebanoff_transition.test_vals = [-8.284308, -13.240273, 0.000057, 0.007982] + schubauer_klebanoff_transition.test_vals = [-8.284308, -13.239421, 0.000057, 0.007982] test_list.append(schubauer_klebanoff_transition) ##################################### @@ -729,7 +729,7 @@ def main(): hb_rans_preconditioning.cfg_dir = "harmonic_balance/hb_rans_preconditioning" hb_rans_preconditioning.cfg_file = "davis.cfg" hb_rans_preconditioning.test_iter = 25 - hb_rans_preconditioning.test_vals = [-1.902097, 0.484069, 0.601483, 3.609005, -5.949355] + hb_rans_preconditioning.test_vals = [-1.902084, 0.484233, 0.601496, 3.609018, -5.943873] test_list.append(hb_rans_preconditioning) ###################################### @@ -796,7 +796,7 @@ def main(): ddes_flatplate.cfg_dir = "ddes/flatplate" ddes_flatplate.cfg_file = "ddes_flatplate.cfg" ddes_flatplate.test_iter = 10 - ddes_flatplate.test_vals = [-2.714713, -5.788301, -0.214960, 0.023758, 0.000000] + ddes_flatplate.test_vals = [-2.714713, -5.763293, -0.214960, 0.023758, 0.000000] ddes_flatplate.unsteady = True test_list.append(ddes_flatplate) @@ -856,7 +856,7 @@ def main(): Aachen_3D_restart.cfg_dir = "turbomachinery/Aachen_turbine" Aachen_3D_restart.cfg_file = "aachen_3D_MP_restart.cfg" Aachen_3D_restart.test_iter = 5 - Aachen_3D_restart.test_vals = [-7.701448, -8.512359, -6.014939, -6.468741, -5.801762, -4.607173, -5.551041, -5.300777, -3.804188, -5.256055, -5.765225, -3.609601, -2.229277, -2.883896, -0.563470] + Aachen_3D_restart.test_vals = [-7.701448, -8.512353, -6.014939, -6.468417, -5.801739, -4.607173, -5.550692, -5.300771, -3.804187, -5.256008, -5.765048, -3.609601, -2.229277, -2.883894, -0.563470] test_list.append(Aachen_3D_restart) # Jones APU Turbocharger restart @@ -889,8 +889,8 @@ def main(): multi_interface.cfg_dir = "turbomachinery/multi_interface" multi_interface.cfg_file = "multi_interface_rst.cfg" multi_interface.test_iter = 5 - multi_interface.test_vals = [-8.632374, -8.895124, -9.350417] - multi_interface.test_vals_aarch64 = [-8.632374, -8.895124, -9.350417] + multi_interface.test_vals = [-8.632229, -8.894737, -9.348730] + multi_interface.test_vals_aarch64 = [-8.632229, -8.894737, -9.348730] test_list.append(multi_interface) diff --git a/TestCases/serial_regression_AD.py b/TestCases/serial_regression_AD.py index 687a459cb870..9cfb3177caa1 100644 --- a/TestCases/serial_regression_AD.py +++ b/TestCases/serial_regression_AD.py @@ -88,7 +88,7 @@ def main(): discadj_rans_naca0012_sa.cfg_dir = "disc_adj_rans/naca0012" discadj_rans_naca0012_sa.cfg_file = "turb_NACA0012_sa.cfg" discadj_rans_naca0012_sa.test_iter = 10 - discadj_rans_naca0012_sa.test_vals = [-2.996976, -0.196055, 0.000004, -0.000000, 5.000000, -3.971736, 5.000000, -10.464319] + discadj_rans_naca0012_sa.test_vals = [-2.996961, -0.199169, 0.000004, -0.000000, 5.000000, -3.971752, 5.000000, -10.457920] test_list.append(discadj_rans_naca0012_sa) # Adjoint turbulent NACA0012 SST @@ -193,7 +193,7 @@ def main(): discadj_heat.cfg_dir = "disc_adj_heat" discadj_heat.cfg_file = "disc_adj_heat.cfg" discadj_heat.test_iter = 10 - discadj_heat.test_vals = [-2.174678, 0.591525, 0.000000, 0.008748] + discadj_heat.test_vals = [-2.174674, 0.581857, 0.000000, 0.008748] test_list.append(discadj_heat) ################################### diff --git a/TestCases/tutorials.py b/TestCases/tutorials.py index 457d5697a0e0..4fcc604b40ac 100644 --- a/TestCases/tutorials.py +++ b/TestCases/tutorials.py @@ -291,7 +291,7 @@ def main(): tutorial_nicfd_nozzle_pinn.cfg_dir = "../Tutorials/compressible_flow/NICFD_nozzle/PhysicsInformed" tutorial_nicfd_nozzle_pinn.cfg_file = "config_NICFD_PINN.cfg" tutorial_nicfd_nozzle_pinn.test_iter = 20 - tutorial_nicfd_nozzle_pinn.test_vals = [-3.181747, -1.638856, -1.277037, 2.445964, -11.769570] + tutorial_nicfd_nozzle_pinn.test_vals = [-3.181747, -1.638856, -1.277037, 2.445964, -11.759632] tutorial_nicfd_nozzle_pinn.no_restart = True test_list.append(tutorial_nicfd_nozzle_pinn) @@ -301,7 +301,7 @@ def main(): tutorial_unst_naca0012.cfg_dir = "../Tutorials/compressible_flow/Unsteady_NACA0012" tutorial_unst_naca0012.cfg_file = "unsteady_naca0012.cfg" tutorial_unst_naca0012.test_iter = 520 - tutorial_unst_naca0012.test_vals = [520.000000, 0.000000, -5.290694, 0.000000, 0.317272, 0.820972, 0.002144, 0.012805] + tutorial_unst_naca0012.test_vals = [520.000000, 0.000000, -5.292632, 0.000000, 0.300303, 0.770888, 0.002399, 0.014070] tutorial_unst_naca0012.test_vals_aarch64 = [520.000000, 0.000000, -5.298777, 0.000000, 0.288956, 0.736706, 0.002419, 0.007134] tutorial_unst_naca0012.unsteady = True test_list.append(tutorial_unst_naca0012) @@ -311,7 +311,7 @@ def main(): propeller_var_load.cfg_dir = "../Tutorials/compressible_flow/ActuatorDisk_VariableLoad" propeller_var_load.cfg_file = "propeller_variable_load.cfg" propeller_var_load.test_iter = 20 - propeller_var_load.test_vals = [-1.830257, -4.535041, -0.000323, 0.171647] + propeller_var_load.test_vals = [-1.830257, -4.534990, -0.000323, 0.171646] propeller_var_load.timeout = 3200 test_list.append(propeller_var_load) diff --git a/TestCases/vandv.py b/TestCases/vandv.py index d563cc653de0..8c942e27b631 100644 --- a/TestCases/vandv.py +++ b/TestCases/vandv.py @@ -44,9 +44,9 @@ def main(): p30n30 = TestCase('30P30N') p30n30.cfg_dir = "vandv/rans/30p30n" p30n30.cfg_file = "config.cfg" - p30n30.test_iter = 20 - p30n30.test_vals = [-10.582183, -10.106601, -10.474910, -10.182549, -12.679336, 0.052181, 2.829820, 1.318613, -0.221374] - p30n30.test_vals_aarch64 = [-10.582183, -10.106601, -10.474910, -10.182549, -12.679336, 0.052181, 2.829820, 1.318613, -0.221374] + p30n30.test_iter = 5 + p30n30.test_vals = [-11.502310, -11.511459, -11.981995, -11.704990, -14.235571, 0.052235, 2.830394, 1.318894, -0.291726] + p30n30.test_vals_aarch64 = [-11.502310, -11.511459, -11.981995, -11.704990, -14.235571, 0.052235, 2.830394, 1.318894, -0.291726] test_list.append(p30n30) # flat plate - sst-v1994m @@ -72,8 +72,8 @@ def main(): swbli_sa.cfg_dir = "vandv/rans/swbli" swbli_sa.cfg_file = "config_sa.cfg" swbli_sa.test_iter = 5 - swbli_sa.test_vals = [-11.511182, -10.750503, -11.853919, -10.320019, -14.316261, 0.002238, -1.585259, 1.276300] - swbli_sa.test_vals_aarch64 = [-11.511278, -10.750583, -11.854073, -10.320108, -14.316261, 0.002238, -1.585354, 1.276300] + swbli_sa.test_vals = [-11.504424, -10.941741, -12.049925, -10.586263, -16.090385, 0.002242, -1.614365, 1.340100] + swbli_sa.test_vals_aarch64 = [-11.504424, -10.941741, -12.049925, -10.586263, -16.090385, 0.002242, -1.614365, 1.340100] test_list.append(swbli_sa) @@ -90,7 +90,7 @@ def main(): dsma661_sa.cfg_dir = "vandv/rans/dsma661" dsma661_sa.cfg_file = "dsma661_sa_config.cfg" dsma661_sa.test_iter = 5 - dsma661_sa.test_vals = [-11.013046, -8.140606, -8.989695, -5.978550, -10.593381, 0.155689, 0.024173] + dsma661_sa.test_vals = [-11.270155, -8.240208, -9.000574, -5.954878, -10.737828, 0.155687, 0.024232] test_list.append(dsma661_sa) # DSMA661 - SST-V2003m diff --git a/config_template.cfg b/config_template.cfg index 4e2d456170fe..3cb991342235 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -1852,6 +1852,10 @@ CFL_REDUCTION_TURB= 1.0 LOWER_LIMIT_K_FACTOR= 1e-15 LOWER_LIMIT_OMEGA_FACTOR= 1e-5 +% Use numerically computed exact Jacobians for standard SA turbulence model +% Slower per iteration but potentialy more stable and capable of higher CFL +USE_ACCURATE_TURB_JACOBIANS= NO +% % --------------------- HEAT NUMERICAL METHOD DEFINITION ----------------------% % % Value of the thermal diffusivity From bdf7d270eccee1c65155868928261e604eaf709d Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 14 Jul 2025 10:41:58 +0200 Subject: [PATCH 117/173] updating to feature_preconditioning --- SU2_CFD/include/fluid/CFluidCantera.hpp | 13 +- SU2_CFD/include/fluid/CFluidModel.hpp | 4 +- SU2_CFD/include/fluid/CFluidScalar.hpp | 13 +- SU2_CFD/include/solvers/CIncNSSolver.hpp | 13 +- SU2_CFD/src/fluid/CFluidCantera.cpp | 69 +++++----- SU2_CFD/src/fluid/CFluidScalar.cpp | 33 ++++- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 16 +-- SU2_CFD/src/solvers/CIncNSSolver.cpp | 157 ++++++++++++----------- SU2_CFD/src/variables/CIncNSVariable.cpp | 23 ++-- meson.build | 2 +- 10 files changed, 193 insertions(+), 150 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 487bc5ef0051..7e014ecf3896 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -146,12 +146,6 @@ class CFluidCantera final : public CFluidModel { */ inline su2double GetHeatRelease() override { return Heat_Release; } - /*! - * \brief Compute Temperature from Enthalpy and scalars. - */ - void ComputeTempFromEnthalpy(const su2double val_enthalpy, su2double* val_temperature, - const su2double* val_scalars) override; - /*! * \brief Get enthalpy diffusivity terms. */ @@ -172,5 +166,12 @@ class CFluidCantera final : public CFluidModel { * \param[in] t - Temperature value at the point. */ void SetTDState_T(su2double val_temperature, const su2double* val_scalars) override; + + /*! + * \brief Virtual member. + * \param[in] val_enthalpy - Enthalpy value at the point. + * \param[in] val_scalars - Scalar mass fractions. + */ + void SetTDState_h(su2double val_enthalpy, const su2double* val_scalars = nullptr) override; #endif }; \ No newline at end of file diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index aa5aade04d6b..04769fefe4a6 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -386,9 +386,9 @@ class CFluidModel { /*! * \brief Virtual member. * \param[in] val_enthalpy - Enthalpy value at the point. + * \param[in] val_scalars - Scalar mass fractions. */ - virtual void ComputeTempFromEnthalpy(su2double val_enthalpy, su2double* val_temperature, - const su2double* val_scalars = nullptr) {} + virtual void SetTDState_h(su2double val_enthalpy, const su2double* val_scalars = nullptr) {} /*! * \brief Set fluid eddy viscosity provided by a turbulence model needed for computing effective thermal conductivity. diff --git a/SU2_CFD/include/fluid/CFluidScalar.hpp b/SU2_CFD/include/fluid/CFluidScalar.hpp index c611bf3e8aad..2c89dc7f72dd 100644 --- a/SU2_CFD/include/fluid/CFluidScalar.hpp +++ b/SU2_CFD/include/fluid/CFluidScalar.hpp @@ -158,15 +158,16 @@ class CFluidScalar final : public CFluidModel { */ void GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusions) override; - /*! - * \brief Compute Temperature from Enthalpy and scalars. - */ - void ComputeTempFromEnthalpy(const su2double val_enthalpy, su2double* val_temperature, - const su2double* val_scalars) override; - /*! * \brief Set the Dimensionless State using Temperature. * \param[in] t - Temperature value at the point. */ void SetTDState_T(su2double val_temperature, const su2double* val_scalars) override; + + /*! + * \brief Virtual member. + * \param[in] val_enthalpy - Enthalpy value at the point. + * \param[in] val_scalars - Scalar mass fractions. + */ + void SetTDState_h(su2double val_enthalpy, const su2double* val_scalars = nullptr) override; }; diff --git a/SU2_CFD/include/solvers/CIncNSSolver.hpp b/SU2_CFD/include/solvers/CIncNSSolver.hpp index 3e40ac32ccbe..154cfd2f3fce 100644 --- a/SU2_CFD/include/solvers/CIncNSSolver.hpp +++ b/SU2_CFD/include/solvers/CIncNSSolver.hpp @@ -95,8 +95,19 @@ class CIncNSSolver final : public CIncEulerSolver { */ void Compute_Streamwise_Periodic_Recovered_Values(CConfig *config, const CGeometry *geometry, const unsigned short iMesh); + /*! + * \brief Compute the enthalpy due to species diffusion contribution for multicomponent and reacting flows. + * \param[in] iEdge - Edge for which the flux and Jacobians are to be computed. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] numerics - Description of the numerical method. + * \param[in] n_species - Number of species in the mixture that a transport equation is solved. + * \param[in] implicit - Boolean for implicit iterations. + */ + void ComputeEnthalpyDiffusion(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, CNumerics* numerics, + const int n_species, const bool implicit) ; -public: + public: /*! * \brief Constructor of the class. * \param[in] geometry - Geometrical definition of the problem. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 2bcaa9f39113..dd58b8b1967f 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -252,8 +252,35 @@ void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusio } } -void CFluidCantera::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2double* val_temperature, - const su2double* val_scalars) { +void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { + Temperature = val_temperature; + /*--- Set mass fractions. ---*/ + const int nsp = sol->thermo()->nSpecies(); + su2double val_scalars_sum{0.0}; + su2double massFractions[nsp]{0.0}; + for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { + int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); + massFractions[speciesIndex] = val_scalars[i_scalar]; + val_scalars_sum += val_scalars[i_scalar]; + } + massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1 - val_scalars_sum; + sol->thermo()->setMassFractions(massFractions); + sol->thermo()->setState_TP(Temperature, Pressure_Thermodynamic); + Density = sol->thermo()->density(); + Enthalpy = sol->thermo()->enthalpy_mass(); + Cp = sol->thermo()->cp_mass(); + Cv = sol->thermo()->cv_mass(); + Mu = sol->transport()->viscosity(); + Kt = sol->transport()->thermalConductivity(); + + ComputeMassDiffusivity(); + //ComputeChemicalSourceTerm(); + ComputeGradChemicalSourceTerm(val_scalars); + ComputeHeatRelease(); +} + +void CFluidCantera::SetTDState_h(const su2double val_enthalpy, const su2double* val_scalars) { + Enthalpy = val_enthalpy; /*--- convergence criterion for temperature in [K], high accuracy needed for restarts. ---*/ su2double toll = 1e-5; su2double temp_iter = 300.0; @@ -275,16 +302,17 @@ void CFluidCantera::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2dou massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1 - val_scalars_sum; sol->thermo()->setMassFractions(massFractions); + /*--- Computing temperature given enthalpy and species mass fractions using Newton-Raphson. ---*/ while ((abs(delta_temp_iter) > toll) && (counter++ < counter_limit)) { /*--- Set thermodynamic state based on the current value of temperature. ---*/ sol->thermo()->setState_TP(temp_iter, Pressure_Thermodynamic); - su2double Enthalpy = sol->thermo()->enthalpy_mass(); - su2double Cp = sol->thermo()->cp_mass(); + su2double Enthalpy_iter = sol->thermo()->enthalpy_mass(); + su2double Cp_iter = sol->thermo()->cp_mass(); - delta_enthalpy_iter = val_enthalpy - Enthalpy; + delta_enthalpy_iter = Enthalpy - Enthalpy_iter; - delta_temp_iter = delta_enthalpy_iter / Cp; + delta_temp_iter = delta_enthalpy_iter / Cp_iter; temp_iter += delta_temp_iter; if (temp_iter < 0.0) { @@ -292,38 +320,13 @@ void CFluidCantera::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2dou break; } } - *val_temperature = temp_iter; + Temperature = temp_iter; if (counter == counter_limit) { cout << "Warning Newton-Raphson exceed number of max iteration in temperature computation" << endl; } + SetTDState_T(Temperature, val_scalars); } -void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { - Temperature = val_temperature; - /*--- Set mass fractions. ---*/ - const int nsp = sol->thermo()->nSpecies(); - su2double val_scalars_sum{0.0}; - su2double massFractions[nsp]{0.0}; - for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { - int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); - massFractions[speciesIndex] = val_scalars[i_scalar]; - val_scalars_sum += val_scalars[i_scalar]; - } - massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1 - val_scalars_sum; - sol->thermo()->setMassFractions(massFractions); - sol->thermo()->setState_TP(Temperature, Pressure_Thermodynamic); - Density = sol->thermo()->density(); - Enthalpy = sol->thermo()->enthalpy_mass(); - Cp = sol->thermo()->cp_mass(); - Cv = sol->thermo()->cv_mass(); - Mu = sol->transport()->viscosity(); - Kt = sol->transport()->thermalConductivity(); - - ComputeMassDiffusivity(); - //ComputeChemicalSourceTerm(); - ComputeGradChemicalSourceTerm(val_scalars); - ComputeHeatRelease(); -} #else CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* config) { SU2_MPI::Error("SU2 was not compiled with Cantera(-Denable-cantera=true)", CURRENT_FUNCTION); diff --git a/SU2_CFD/src/fluid/CFluidScalar.cpp b/SU2_CFD/src/fluid/CFluidScalar.cpp index 7b8151dc01cd..0203456dd9c9 100644 --- a/SU2_CFD/src/fluid/CFluidScalar.cpp +++ b/SU2_CFD/src/fluid/CFluidScalar.cpp @@ -214,17 +214,14 @@ su2double CFluidScalar::ComputeMeanSpecificHeatCp(const su2double* val_scalars) } su2double CFluidScalar::ComputeEnthalpyFromT(const su2double val_temperature, const su2double* val_scalars){ + /* In future implementations, enthalpy should be computed using numerical integration. For now, as Cp does not + * depend on temperature, but it does depend on mixture composition, enthalpy is directly computed from + * the expression h_s = Cp(T - T_ref). + */ su2double val_Enthalpy = Cp * (val_temperature - Ref_Temperature); return val_Enthalpy; } -void CFluidScalar::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2double* val_temperature, - const su2double* val_scalars) { - MassToMoleFractions(val_scalars); - su2double val_cp = ComputeMeanSpecificHeatCp(val_scalars); - *val_temperature = val_enthalpy / val_cp + Ref_Temperature; -} - void CFluidScalar::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) { const su2double enthalpy_species_N = specificHeat[n_species_mixture - 1] * (Temperature - Ref_Temperature); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { @@ -266,3 +263,25 @@ void CFluidScalar::SetTDState_T(const su2double val_temperature, const su2double Kt = WilkeConductivity(val_scalars); ComputeMassDiffusivity(); } + +void CFluidScalar::SetTDState_h(const su2double val_enthalpy, const su2double* val_scalars) { + MassToMoleFractions(val_scalars); + ComputeGasConstant(); + Enthalpy = val_enthalpy; + Cp = ComputeMeanSpecificHeatCp(val_scalars); + /* In future implementations, temperature should be computed using Newton-Raphson. For now, as Cp does not + * depend on temperature, but it does depend on mixture composition, temperature is directly solved from the + * expression h_s = Cp(T - T_ref). + */ + Temperature = Enthalpy / Cp + Ref_Temperature; + Density = Pressure_Thermodynamic / (Temperature * Gas_Constant); + Cv = Cp - Gas_Constant; + + if (wilke) { + Mu = WilkeViscosity(val_scalars); + } else if (davidson) { + Mu = DavidsonViscosity(val_scalars); + } + + Kt = WilkeConductivity(val_scalars); +} diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index af7a7d42762a..1a27becc78e0 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1401,8 +1401,10 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont lim_i = LimiterHelpers<>::vanAlbadaFunction(Project_Grad_Enthalpy_i, V_ij, EPS); lim_j = LimiterHelpers<>::vanAlbadaFunction(-Project_Grad_Enthalpy_j, V_ij, EPS); } else if (limiter) { - lim_i = 1.0; // nodes->GetLimiter_Primitive(iPoint, iVar); - lim_j = 1.0; // nodes->GetLimiter_Primitive(jPoint, iVar); + /*--- For solving enthalpy instead of temperature, computation of limiters must be added + in future implementation, for now it is limited to van Albada limiter or default value 1.0. ---*/ + lim_i = 1.0; + lim_j = 1.0; } Primitive_i[nDim + 9] = V_i[nDim + 9] + lim_i * Project_Grad_Enthalpy_i; Primitive_j[nDim + 9] = V_j[nDim + 9] + lim_j * Project_Grad_Enthalpy_j; @@ -1486,12 +1488,9 @@ void CIncEulerSolver::ComputeConsistentExtrapolation(CFluidModel* fluidModel, un const su2double* scalar) { const CIncEulerVariable::CIndices prim_idx(nDim, 0); const su2double enthalpy = primitive[prim_idx.Enthalpy()]; - su2double temperature = primitive[prim_idx.Temperature()]; - fluidModel->ComputeTempFromEnthalpy(enthalpy, &temperature, scalar); + fluidModel->SetTDState_h(enthalpy, scalar); - fluidModel->SetTDState_T(temperature, scalar); - - primitive[prim_idx.Temperature()] = temperature; + primitive[prim_idx.Temperature()] = fluidModel->GetTemperature(); primitive[prim_idx.Density()] = fluidModel->GetDensity(); } @@ -2606,8 +2605,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, if (energy_multicomponent) { CFluidModel* auxFluidModel = solver_container[FLOW_SOL]->GetFluidModel(); const su2double* scalar_inlet = config->GetInlet_SpeciesVal(config->GetMarker_All_TagBound(val_marker)); - auxFluidModel->SetTDState_T(V_inlet[prim_idx.Temperature()], - scalar_inlet); // compute total enthalpy from temperature + auxFluidModel->SetTDState_T(V_inlet[prim_idx.Temperature()], scalar_inlet); V_inlet[prim_idx.Enthalpy()] = auxFluidModel->GetEnthalpy(); } diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 4183c6cb3190..17a13d37f224 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -352,87 +352,94 @@ void CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CS const bool energy_multicomponent = (((config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA)) && (config->GetEnergy_Equation())); - const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); /*--- Contribution to heat flux due to enthalpy diffusion for multicomponent and reacting flows ---*/ if (energy_multicomponent) { - CVariable* speciesNodes = solver_container[SPECIES_SOL]->GetNodes(); - /*--- Points in edge ---*/ - - auto iPoint = geometry->edges->GetNode(iEdge, 0); - auto jPoint = geometry->edges->GetNode(iEdge, 1); - - /*--- Points coordinates, and normal vector ---*/ - - const su2double* Normal = geometry->edges->GetNormal(iEdge); - const su2double* Coord_i = geometry->nodes->GetCoord(iPoint); - const su2double* Coord_j = geometry->nodes->GetCoord(jPoint); - - /*--- Obtain fluid model for computing the enthalpy diffusion terms. ---*/ - - CFluidModel* FluidModel = solver_container[FLOW_SOL]->GetFluidModel(); - - /*--- retrieve number of species that are solved and set maximum static array ---*/ - - int n_species = config->GetnSpecies(); - static constexpr size_t MAXNVAR_SPECIES = 20UL; - - /*--- Species variables, and its gradients ---*/ - const su2double* Species_i = speciesNodes->GetSolution(iPoint); - const su2double* Species_j = speciesNodes->GetSolution(jPoint); - CMatrixView Species_Grad_i = speciesNodes->GetGradient(iPoint); - CMatrixView Species_Grad_j = speciesNodes->GetGradient(jPoint); - - /*--- Compute Projected gradient for species variables ---*/ - su2double ProjGradScalarVarNoCorr[MAXNVAR_SPECIES]{0.0}; - su2double Proj_Mean_GradScalarVar[MAXNVAR_SPECIES]{0.0}; - su2double proj_vector_ij = numerics->ComputeProjectedGradient( - nDim, n_species, Normal, Coord_i, Coord_j, Species_Grad_i, Species_Grad_j, true, Species_i, Species_j, - ProjGradScalarVarNoCorr, Proj_Mean_GradScalarVar); - (void)proj_vector_ij; - - /*--- Get enthalpy diffusion terms and its gradient(for implicit) for each species at point i. ---*/ - - su2double EnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; - su2double MassCorrectionDiffusion_i[MAXNVAR_SPECIES]{0.0}; - su2double GradEnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; - FluidModel->SetTDState_T(nodes->GetPrimitive(iPoint)[prim_idx.Temperature()], Species_i); - FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion_i); - FluidModel->GetMassCorrectionDiffusivity(MassCorrectionDiffusion_i); - if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion_i); - - /*--- Repeat the above computations for jPoint. ---*/ - - su2double EnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; - su2double MassCorrectionDiffusion_j[MAXNVAR_SPECIES]{0.0}; - su2double GradEnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; - FluidModel->SetTDState_T(nodes->GetPrimitive(jPoint)[prim_idx.Temperature()], Species_j); - FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion_j); - FluidModel->GetMassCorrectionDiffusivity(MassCorrectionDiffusion_j); - if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion_j); - - /*--- Compute Enthalpy diffusion flux and its jacobian (for implicit iterations) ---*/ - su2double flux_enthalpy_diffusion = 0.0; - su2double flux_massCorrection_diffusion = 0.0; - su2double jac_flux_enthalpy_diffusion = 0.0; - for (int i_species = 0; i_species < n_species; i_species++) { - flux_enthalpy_diffusion += - 0.5 * (EnthalpyDiffusion_i[i_species] + EnthalpyDiffusion_j[i_species]) * Proj_Mean_GradScalarVar[i_species]; - flux_massCorrection_diffusion += 0.5 * - (MassCorrectionDiffusion_i[i_species] + MassCorrectionDiffusion_j[i_species]) * - Proj_Mean_GradScalarVar[i_species]; - if (implicit) - jac_flux_enthalpy_diffusion += 0.5 * (GradEnthalpyDiffusion_i[i_species] + GradEnthalpyDiffusion_j[i_species]) * - Proj_Mean_GradScalarVar[i_species]; - } + const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); + const int n_species = config->GetnSpecies(); + ComputeEnthalpyDiffusion(iEdge, geometry, solver_container, numerics, n_species, implicit); + } - /*--- Set heat flux and jacobian (for implicit) due to enthalpy diffusion ---*/ + Viscous_Residual_impl(iEdge, geometry, solver_container, numerics, config); +} - numerics->SetHeatFluxDiffusion(flux_enthalpy_diffusion); - numerics->SetMassCorrFluxDiffusion(flux_massCorrection_diffusion); - if (implicit) numerics->SetJacHeatFluxDiffusion(jac_flux_enthalpy_diffusion); +void CIncNSSolver::ComputeEnthalpyDiffusion(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, + CNumerics* numerics, const int n_species, const bool implicit) { + + CVariable* speciesNodes = solver_container[SPECIES_SOL]->GetNodes(); + /*--- Points in edge ---*/ + + auto iPoint = geometry->edges->GetNode(iEdge, 0); + auto jPoint = geometry->edges->GetNode(iEdge, 1); + + /*--- Points coordinates, and normal vector ---*/ + + const su2double* Normal = geometry->edges->GetNormal(iEdge); + const su2double* Coord_i = geometry->nodes->GetCoord(iPoint); + const su2double* Coord_j = geometry->nodes->GetCoord(jPoint); + + /*--- Obtain fluid model for computing the enthalpy diffusion terms. ---*/ + + CFluidModel* FluidModel = solver_container[FLOW_SOL]->GetFluidModel(); + + /*--- set maximum static array ---*/ + + static constexpr size_t MAXNVAR_SPECIES = 20UL; + + /*--- Species variables, and its gradients ---*/ + const su2double* Species_i = speciesNodes->GetSolution(iPoint); + const su2double* Species_j = speciesNodes->GetSolution(jPoint); + CMatrixView Species_Grad_i = speciesNodes->GetGradient(iPoint); + CMatrixView Species_Grad_j = speciesNodes->GetGradient(jPoint); + + /*--- Compute Projected gradient for species variables ---*/ + su2double ProjGradScalarVarNoCorr[MAXNVAR_SPECIES]{0.0}; + su2double Proj_Mean_GradScalarVar[MAXNVAR_SPECIES]{0.0}; + su2double proj_vector_ij = + numerics->ComputeProjectedGradient(nDim, n_species, Normal, Coord_i, Coord_j, Species_Grad_i, Species_Grad_j, + true, Species_i, Species_j, ProjGradScalarVarNoCorr, Proj_Mean_GradScalarVar); + (void)proj_vector_ij; + + /*--- Get enthalpy diffusion terms and its gradient(for implicit) for each species at point i. ---*/ + + su2double EnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; + su2double MassCorrectionDiffusion_i[MAXNVAR_SPECIES]{0.0}; + su2double GradEnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; + FluidModel->SetTDState_T(nodes->GetPrimitive(iPoint)[prim_idx.Temperature()], Species_i); + FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion_i); + FluidModel->GetMassCorrectionDiffusivity(MassCorrectionDiffusion_i); + if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion_i); + + /*--- Repeat the above computations for jPoint. ---*/ + + su2double EnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; + su2double MassCorrectionDiffusion_j[MAXNVAR_SPECIES]{0.0}; + su2double GradEnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; + FluidModel->SetTDState_T(nodes->GetPrimitive(jPoint)[prim_idx.Temperature()], Species_j); + FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion_j); + FluidModel->GetMassCorrectionDiffusivity(MassCorrectionDiffusion_j); + if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion_j); + + /*--- Compute Enthalpy diffusion flux and its jacobian (for implicit iterations) ---*/ + su2double flux_enthalpy_diffusion = 0.0; + su2double flux_massCorrection_diffusion = 0.0; + su2double jac_flux_enthalpy_diffusion = 0.0; + for (int i_species = 0; i_species < n_species; i_species++) { + flux_enthalpy_diffusion += + 0.5 * (EnthalpyDiffusion_i[i_species] + EnthalpyDiffusion_j[i_species]) * Proj_Mean_GradScalarVar[i_species]; + flux_massCorrection_diffusion += 0.5 * + (MassCorrectionDiffusion_i[i_species] + MassCorrectionDiffusion_j[i_species]) * + Proj_Mean_GradScalarVar[i_species]; + if (implicit) + jac_flux_enthalpy_diffusion += 0.5 * (GradEnthalpyDiffusion_i[i_species] + GradEnthalpyDiffusion_j[i_species]) * + Proj_Mean_GradScalarVar[i_species]; } - Viscous_Residual_impl(iEdge, geometry, solver_container, numerics, config); + + /*--- Set heat flux and jacobian (for implicit) due to enthalpy diffusion ---*/ + + numerics->SetHeatFluxDiffusion(flux_enthalpy_diffusion); + numerics->SetMassCorrFluxDiffusion(flux_massCorrection_diffusion); + if (implicit) numerics->SetJacHeatFluxDiffusion(jac_flux_enthalpy_diffusion); } unsigned long CIncNSSolver::SetPrimitive_Variables(CSolver **solver_container, const CConfig *config) { diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index e7a2f2bae90e..8217e4db8b70 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -68,22 +68,23 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do if(Energy_Multicomponent){ su2double Enthalpy = Solution(iPoint, nDim +1); - FluidModel->ComputeTempFromEnthalpy(Enthalpy, &Temperature, scalar); + FluidModel->SetTDState_h(Enthalpy, scalar); + Temperature = FluidModel->GetTemperature(); } else { /*--- Set the value of the temperature directly ---*/ Temperature = Solution(iPoint, indices.Temperature()); } auto check_temp = SetTemperature(iPoint, Temperature); - /*--- Use the fluid model to compute the new value of density. - Note that the thermodynamic pressure is constant and decoupled - from the dynamic pressure being iterated. ---*/ + if (!Energy_Multicomponent) { + /*--- Use the fluid model to compute the new value of density. + Note that the thermodynamic pressure is constant and decoupled + from the dynamic pressure being iterated. ---*/ - /*--- Use the fluid model to compute the new value of density. ---*/ + /*--- Use the fluid model to compute the new value of density. ---*/ - if (!check_temp) FluidModel->SetTDState_T(Temperature, scalar); + FluidModel->SetTDState_T(Temperature, scalar); - if (!Energy_Multicomponent) { /*--- for FLAMELET: copy the LUT temperature into the solution ---*/ Solution(iPoint, nDim + 1) = FluidModel->GetTemperature(); /*--- for FLAMELET: update the local temperature using LUT variables ---*/ @@ -108,12 +109,14 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do if (Energy_Multicomponent) { su2double Enthalpy = Solution(iPoint, nDim + 1); - FluidModel->ComputeTempFromEnthalpy(Enthalpy, &Temperature, scalar); + FluidModel->SetTDState_h(Enthalpy, scalar); + SetTemperature(iPoint, FluidModel->GetTemperature()); } else { Temperature = Solution(iPoint, indices.Temperature()); + SetTemperature(iPoint, Temperature); + FluidModel->SetTDState_T(Temperature, scalar); } - SetTemperature(iPoint, Temperature); - FluidModel->SetTDState_T(Temperature, scalar); + SetDensity(iPoint, FluidModel->GetDensity()); /*--- Flag this point as non-physical. ---*/ diff --git a/meson.build b/meson.build index 7d0fbd87acf4..77f126ead2d5 100644 --- a/meson.build +++ b/meson.build @@ -6,7 +6,7 @@ project('SU2', 'c', 'cpp', default_options: ['buildtype=release', 'warning_level=0', 'c_std=c99', - 'cpp_std=c++11']) + 'cpp_std=c++17']) if get_option('enable-cantera') add_global_arguments('-lcantera', language: 'cpp') add_global_arguments('-std=c++17', language: 'cpp') From 310dbe0f28edf5778de4c2af1e7172f9b938a8ee Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 21 Jul 2025 10:23:34 +0200 Subject: [PATCH 118/173] small fix --- SU2_CFD/src/fluid/CFluidCantera.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index dd58b8b1967f..cec89d1dd9ff 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -86,14 +86,13 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { /*--- Set mass fractions. ---*/ const int nsp = sol->thermo()->nSpecies(); su2double val_scalars_sum{0.0}; - double massFractions[nsp]{0.0}; + su2double massFractions[nsp]{0.0}; for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); massFractions[speciesIndex] =config->GetSpecies_Init()[i_scalar]; val_scalars_sum += config->GetSpecies_Init()[i_scalar]; } - sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); - massFractions[n_species_mixture - 1] = 1 - val_scalars_sum; + massFractions[n_species_mixture - 1] = 1.0 - val_scalars_sum; sol->thermo()->setMassFractions(massFractions); su2double T_ref = 298.15; sol->thermo()->setState_TP(T_ref, Pressure_Thermodynamic); @@ -263,7 +262,7 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl massFractions[speciesIndex] = val_scalars[i_scalar]; val_scalars_sum += val_scalars[i_scalar]; } - massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1 - val_scalars_sum; + massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1.0 - val_scalars_sum; sol->thermo()->setMassFractions(massFractions); sol->thermo()->setState_TP(Temperature, Pressure_Thermodynamic); Density = sol->thermo()->density(); @@ -299,7 +298,7 @@ void CFluidCantera::SetTDState_h(const su2double val_enthalpy, const su2double* massFractions[speciesIndex] = val_scalars[i_scalar]; val_scalars_sum += val_scalars[speciesIndex]; } - massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1 - val_scalars_sum; + massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1.0 - val_scalars_sum; sol->thermo()->setMassFractions(massFractions); /*--- Computing temperature given enthalpy and species mass fractions using Newton-Raphson. ---*/ From 729e59487600ad03fcd72634d9636f24e007f3ee Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 26 Jul 2025 16:20:00 +0200 Subject: [PATCH 119/173] updating headers CFluidCantera to subprojects/cantera --- SU2_CFD/src/fluid/CFluidCantera.cpp | 6 +++--- UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp | 2 +- meson.build | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index cec89d1dd9ff..66ed825e995b 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -33,9 +33,9 @@ #ifdef USE_CANTERA #include "../../Common/include/basic_types/ad_structure.hpp" -#include "/home/cristopher/codes/cantera/include/cantera/core.h" -#include "/home/cristopher/codes/cantera/include/cantera/kinetics/Reaction.h" -#include "/home/cristopher/codes/cantera/include/cantera/zerodim.h" +#include "../../../subprojects/cantera/include/cantera/core.h" +#include "../../../subprojects/cantera/include/cantera/kinetics/Reaction.h" +#include "../../../subprojects/cantera/include/cantera/zerodim.h" #include #include diff --git a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp index 7de5e9c4a875..8ed2f7520e85 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp @@ -34,7 +34,7 @@ #define USE_CANTERA #include "../../../Common/include/basic_types/ad_structure.hpp" #include "../../../SU2_CFD/include/fluid/CFluidCantera.hpp" -#include "/home/cristopher/codes/cantera/include/cantera/core.h" +#include "../../../subprojects/cantera/include/cantera/core.h" #include #include diff --git a/meson.build b/meson.build index 629983127aba..a311c48c25ad 100644 --- a/meson.build +++ b/meson.build @@ -315,9 +315,9 @@ endif if get_option('enable-cantera') su2_cpp_args +='-DHAVE_CANTERA' - cantera_include = include_directories(['/home/cristopher/codes/cantera/include']) + cantera_include = include_directories('subprojects/cantera/include') cantera_lib = static_library('cantera', include_directories : cantera_include) - cantera_dep = declare_dependency(link_with : cantera_lib,link_args: ['-L/home/cristopher/codes/cantera/build/lib', '-lcantera'], include_directories : cantera_include) + cantera_dep = declare_dependency(link_with : cantera_lib,link_args: ['-L/home/cristopher/codes/SU2/subprojects/cantera/build/lib', '-lcantera'], include_directories : cantera_include) su2_deps += cantera_dep endif From 982fb56c2556217c19088616bc0209c7c741db19 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 31 Jul 2025 13:52:39 +0200 Subject: [PATCH 120/173] updating parallel_regresion residuals --- TestCases/parallel_regression.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index c1b42fd916c8..c2f8c949e813 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1569,7 +1569,7 @@ def main(): species2_primitiveVenturi_mixingmodel.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel.cfg_file = "species2_primitiveVenturi_mixingmodel.cfg" species2_primitiveVenturi_mixingmodel.test_iter = 50 - species2_primitiveVenturi_mixingmodel.test_vals = [ -5.732153, -4.561603, -4.665933, -5.864167, -0.069493, -5.583639, 5.000000, -1.381549, 5.000000, -4.869625, 5.000000, -1.453019, 0.000378, 0.000362, 0.000016, 0.000000] + species2_primitiveVenturi_mixingmodel.test_vals = [ -5.737415, -4.566668, -4.671780, -5.777603, -0.066800, -5.583554, 5.000000, -1.373807, 5.000000, -4.869219, 5.000000, -1.453021, 0.000381, 0.000365, 0.000016, 0.000000] test_list.append(species2_primitiveVenturi_mixingmodel) # 2 species (1 eq) primitive venturi mixing using mixing model and bounded scalar transport @@ -1577,7 +1577,7 @@ def main(): species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_file = "species2_primitiveVenturi_mixingmodel_boundedscalar.cfg" species2_primitiveVenturi_mixingmodel_boundedscalar.test_iter = 50 - species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.688210, -4.507478, -4.611654, -6.120321, -0.118407, -5.705981, 5.000000, -1.439850, 5.000000, -4.922431, 5.000000, -1.768043, 0.000313, 0.000313, 0.000000, 0.000000] + species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.690396, -4.512158, -4.616488, -5.776093, -0.113176, -5.705291, 5.000000, -1.433234, 5.000000, -4.921121, 5.000000, -1.770744, 0.000318, 0.000318, 0.000000, 0.000000] test_list.append(species2_primitiveVenturi_mixingmodel_boundedscalar) # 2 species (1 eq) primitive venturi mixing using mixing model including viscosity, thermal conductivity and inlet markers for SA turbulence model @@ -1593,7 +1593,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_iter = 50 - species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_vals = [-5.820188, -4.627870, -4.556574, -6.834134, 2.077283, -5.481298, 30.000000, -7.317611, 12.000000, -8.064489, 8.000000, -8.902923, 2.092310, 1.000000, 0.600000, 0.492310] + species2_primitiveVenturi_mixingmodel_heatcapacity_H2.test_vals = [-5.824280, -4.632628, -4.560106, -6.764902, 2.076781, -5.480635, 30.000000, -7.313820, 12.000000, -8.059765, 8.000000, -8.904808, 2.092258, 1.000000, 0.600000, 0.492258] test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2) # 2 species (1 eq) primitive venturi mixing using mixing model including heat capacity and mass diffusivity NonDimensional case @@ -1601,7 +1601,7 @@ def main(): species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg_file = "species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.cfg" species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_iter = 50 - species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.407825, -4.920839, -4.842095, -7.820571, 1.773871, -5.086936, 10.000000, -2.736335, 3.000000, -5.216316, 5.000000, -5.855262, 2.092350, 1.000000, 0.600000, 0.492350] + species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND.test_vals = [-5.400552, -4.915641, -4.836920, -7.711367, 1.771551, -5.086850, 10.000000, -2.741766, 3.000000, -5.104310, 5.000000, -5.859810, 2.092354, 1.000000, 0.600000, 0.492354] test_list.append(species2_primitiveVenturi_mixingmodel_heatcapacity_H2_ND) # 2 species (1 eq) primitive venturi mixing using mixing model solving enthalpy equation using preconditioning + JST convective scheme From 0f7f92cbface6a8355e7c5c88412b6a1fd040822 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 5 Aug 2025 10:00:22 +0200 Subject: [PATCH 121/173] meson options --- .github/workflows/regression.yml | 1 - .gitmodules | 6 ++-- cantera_meson_build.py | 49 ++++++++++++++++++++++++++++++++ meson.build | 11 ++++--- meson_options.txt | 1 - meson_scripts/init.py | 40 +++++++++++++++++--------- subprojects/cantera | 1 + 7 files changed, 87 insertions(+), 22 deletions(-) create mode 100644 cantera_meson_build.py create mode 160000 subprojects/cantera diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index ab85c24ce579..3c14057f42e2 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -27,7 +27,6 @@ jobs: include: - config_set: BaseMPI flags: '-Denable-pywrapper=true -Denable-coolprop=true -Denable-mpp=true -Dinstall-mpp=true -Denable-mlpcpp=true -Denable-tests=true --warnlevel=2' - # flags: '-Denable-pywrapper=true -Denable-coolprop=true -Denable-cantera=true -Denable-mpp=true -Dinstall-mpp=true -Denable-mlpcpp=true -Denable-tests=true --warnlevel=2' - config_set: ReverseMPI flags: '-Denable-autodiff=true -Denable-normal=false -Denable-pywrapper=true -Denable-tests=true --warnlevel=3 --werror' - config_set: ForwardMPI diff --git a/.gitmodules b/.gitmodules index 2c64a8ea75f3..e2d00907384e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -18,9 +18,9 @@ [submodule "subprojects/CoolProp"] path = subprojects/CoolProp url = https://github.com/CoolProp/CoolProp.git -# [submodule "subprojects/cantera"] -# path = subprojects/cantera -# url = https://github.com/cantera/cantera.git +[submodule "subprojects/cantera"] + path = subprojects/cantera + url = https://github.com/cantera/cantera.git [submodule "externals/opdi"] path = externals/opdi url = https://github.com/SciCompKL/OpDiLib diff --git a/cantera_meson_build.py b/cantera_meson_build.py new file mode 100644 index 000000000000..95f61a8a1c8f --- /dev/null +++ b/cantera_meson_build.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 + +## \file cantera_meson_build.py +# \brief create necessary meson.build file for linking cantera to +# SU2. +# \author C.Morales Ubal +# \version 8.2.0 "Harrier" +# +# SU2 Project Website: https://su2code.github.io +# +# The SU2 Project is maintained by the SU2 Foundation +# (http://su2foundation.org) +# +# Copyright 2012-2025, SU2 Contributors (cf. AUTHORS.md) +# +# SU2 is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# SU2 is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with SU2. If not, see +import sys, os + +absolute_path = sys.path[0] +relative_path = "subprojects/cantera" +meson_path = os.path.join(absolute_path, relative_path) + +# Where to create meson.build +meson_build_path = os.path.join(meson_path, "meson.build") + +# Detect filename if already exists +if not os.path.exists(meson_build_path): + print(f"Writing meson.build in {meson_path}") + meson_build_content = ["project('cantera', 'c', 'cpp', default_options: ['cpp_std=c++17'])\n", + "cc = meson.get_compiler('cpp')\n", + "cantera_inc = include_directories('include')\n", + "cantera_lib = cc.find_library('cantera', dirs: [meson.current_source_dir() / 'build' / 'lib'], required: false, static: true)\n", + "cantera_dep = declare_dependency(include_directories: cantera_inc, dependencies: cantera_lib)\n", + "meson.override_dependency('cantera', cantera_dep)"] + # Write the meson.build file + with open(meson_build_path, 'w') as f: + f.writelines(meson_build_content) + print(f"meson.build in {meson_path} Created ") diff --git a/meson.build b/meson.build index 09c39888eeb7..33bddb712947 100644 --- a/meson.build +++ b/meson.build @@ -10,7 +10,6 @@ project('SU2', 'c', 'cpp', 'cpp_std=c++17']) if get_option('enable-cantera') add_global_arguments('-lcantera', language: 'cpp') - add_global_arguments('-std=c++17', language: 'cpp') endif fsmod = import('fs') @@ -327,10 +326,14 @@ if get_option('enable-coolprop') endif if get_option('enable-cantera') + py = find_program('python3','python') + cantera_meson_path = join_paths(meson.current_source_dir(), 'cantera_meson_build.py') + p = run_command(py, cantera_meson_path, check: true) + if p.returncode() != 0 + error(p.stdout()) + endif su2_cpp_args +='-DHAVE_CANTERA' - cantera_include = include_directories('subprojects/cantera/include') - cantera_lib = static_library('cantera', include_directories : cantera_include) - cantera_dep = declare_dependency(link_with : cantera_lib,link_args: ['-L/home/cristopher/codes/SU2/subprojects/cantera/build/lib', '-lcantera'], include_directories : cantera_include) + cantera_dep = dependency('cantera') su2_deps += cantera_dep endif diff --git a/meson_options.txt b/meson_options.txt index 80f1c0bb9f12..812b391cbb6c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -22,7 +22,6 @@ option('enable-mpp', type : 'boolean', value : false, description: 'enable Muta option('install-mpp', type : 'boolean', value : false, description: 'install Mutation++ in the directory defined with --prefix') option('enable-coolprop', type : 'boolean', value : false, description: 'enable CoolProp support') option('enable-cantera', type : 'boolean', value : false, description: 'enable Cantera support') -#option('install-cantera', type : 'boolean', value : false, description: 'install Cantera in the directory defined with --prefix') option('enable-mlpcpp', type : 'boolean', value : false, description: 'enable MLPCpp support') option('enable-gprof', type : 'boolean', value : false, description: 'enable profiling through gprof') option('opdi-backend', type : 'combo', choices : ['auto', 'macro', 'ompt'], value : 'auto', description: 'OpDiLib backend choice') diff --git a/meson_scripts/init.py b/meson_scripts/init.py index e3c7004d36f6..d8df28549326 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -70,8 +70,8 @@ def init_submodules( github_repo_mpp = "https://github.com/mutationpp/Mutationpp" sha_version_coolprop = "bafdea1f39ee873a6bb9833e3a21fe41f90b85e8" github_repo_coolprop = "https://github.com/CoolProp/CoolProp" - # sha_version_cantera = "feb64c2e028f4fa2ba9dc938022f5b2a693b5ddc" - # github_repo_cantera = "https://github.com/cantera/cantera" + sha_version_cantera = "f22643ecb91f7e8d1852197658efc5260d54d4a3" + github_repo_cantera = "https://github.com/cantera/cantera" sha_version_mel = "46205ab019e5224559091375a6d71aabae6bc5b9" github_repo_mel = "https://github.com/pcarruscag/MEL" sha_version_fado = "ce7ee018e4e699af5028d69baa1939fea290e18a" @@ -86,7 +86,7 @@ def init_submodules( ninja_name = "ninja" mpp_name = "Mutationpp" coolprop_name = "CoolProp" - # cantera_name = "cantera" + cantera_name = "cantera" mel_name = "MEL" fado_name = "FADO" mlpcpp_name = "MLPCpp" @@ -101,7 +101,7 @@ def init_submodules( alt_name_fado = base_path + "FADO" alt_name_mpp = cur_dir + os.path.sep + "subprojects" + os.path.sep + "Mutationpp" alt_name_coolprop = cur_dir + os.path.sep + "subprojects" + os.path.sep + "CoolProp" - # alt_name_cantera = cur_dir + os.path.sep + "subprojects" + os.path.sep + "cantera" + alt_name_cantera = cur_dir + os.path.sep + "subprojects" + os.path.sep + "cantera" alt_name_mlpcpp = cur_dir + os.path.sep + "subprojects" + os.path.sep + "MLPCpp" if method == "auto": @@ -130,8 +130,8 @@ def init_submodules( submodule_status(alt_name_mpp, sha_version_mpp) if own_cool: submodule_status(alt_name_coolprop, sha_version_coolprop) - # if own_cantera: - # submodule_status(alt_name_cantera, sha_version_cantera) + if own_cantera: + submodule_status(alt_name_cantera, sha_version_cantera) if own_mel: submodule_status(alt_name_mel, sha_version_mel) if own_fado: @@ -168,13 +168,13 @@ def init_submodules( github_repo_coolprop, sha_version_coolprop, ) - # if own_cantera: - # download_module( - # cantera_name, - # alt_name_cantera, - # github_repo_cantera, - # sha_version_cantera, - # ) + if own_cantera: + download_module( + cantera_name, + alt_name_cantera, + github_repo_cantera, + sha_version_cantera, + ) if own_mel: download_module(mel_name, alt_name_mel, github_repo_mel, sha_version_mel) if own_fado: @@ -255,6 +255,20 @@ def submodule_status(path, sha_commit): print(original_path) os.chdir(original_path) print("CoolProp updated") + if "cantera" in path: + # update cantera + original_path = os.getcwd() + print("update cantera") + absolute_path = sys.path[0] + relative_path = "subprojects/cantera" + full_path = os.path.join(absolute_path, relative_path) + os.chdir(full_path) + print(full_path) + subprocess.run(["git", "submodule", "init"]) + subprocess.run(["git", "submodule", "update"]) + print(original_path) + os.chdir(original_path) + print("cantera updated") # Check that the SHA tag stored in this file matches the one stored in the git index cur_sha_commit = status[1:].split(" ")[0] if cur_sha_commit != sha_commit: diff --git a/subprojects/cantera b/subprojects/cantera new file mode 160000 index 000000000000..f22643ecb91f --- /dev/null +++ b/subprojects/cantera @@ -0,0 +1 @@ +Subproject commit f22643ecb91f7e8d1852197658efc5260d54d4a3 From 5f45862c75344345095b6646376e4208a1f14267 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 5 Aug 2025 13:16:59 +0200 Subject: [PATCH 122/173] cleaning time integration --- Common/include/CConfig.hpp | 9 +---- Common/src/CConfig.cpp | 2 - SU2_CFD/include/fluid/CFluidCantera.hpp | 5 --- SU2_CFD/src/fluid/CFluidCantera.cpp | 51 ++++--------------------- 4 files changed, 8 insertions(+), 59 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index c87d1d7c451f..65fe14a382a7 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -85,8 +85,7 @@ class CConfig { string ChemicalMechanismFile; /*!< \brief Chemical Reaction mechanism used in cantera*/ string PhaseName; /*!< \brief Name of the phase in the chemical mechanism file used in cantera*/ unsigned short n_GasCompositionNames; /*!<\brief number of gases in mixture composition for cantera */ - bool Combustion, /*!< \brief Flag for Combustion Detailed chemistry problems using Cantera */ - Chemistry_Time_Integration; /*!< \brief Flag for Source term tiem-integration for Detailed chemistry using Cantera */ + bool Combustion; /*!< \brief Flag for Combustion Detailed chemistry problems using Cantera */ su2double Spark_Temperature; /*!< \bried Spark temperature used for ignition in detailed chemistry using Cantera*/ string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */ @@ -3961,12 +3960,6 @@ class CConfig { */ bool GetCombustion(void) const { return Combustion; } - /*! - * \brief Get information about the source term time-integration using Cantera. - * \return TRUE if chemistry time-integration using Cantera is used; otherwise FALSE. - */ - bool GetChemistryTimeIntegration(void) const { return Chemistry_Time_Integration; } - /*! * \brief Get High temperature applied during spark ignition. */ diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index b91f163c34c3..e6aaefd919d9 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1212,8 +1212,6 @@ void CConfig::SetConfig_Options() { addStringListOption("GAS_COMPOSITION_NAMES", n_GasCompositionNames, GasCompositionNames); /*\brief COMBUSTION \n DESCRIPTION: Combustion Detailed chemistry using Cantera \n DEFAULT: false \ingroup Config */ addBoolOption("COMBUSTION", Combustion, false); - /*\brief CHEMISTRY_TIME_INTEGRATION \n DESCRIPTION: Source term time-integration for Detailed chemistry using Cantera \n DEFAULT: false \ingroup Config */ - addBoolOption("CHEMISTRY_TIME_INTEGRATION", Chemistry_Time_Integration, false); /*!\brief SCHMIDT_LAM \n DESCRIPTION: Laminar Schmidt number of mass diffusion \n DEFAULT 1.0 (~for Gases) \ingroup Config*/ addDoubleOption("SPARK_TEMPERATURE", Spark_Temperature, 1000.0); diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 7e014ecf3896..e27d8c65554d 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -36,8 +36,6 @@ #define USE_CANTERA namespace Cantera { class Solution; -class IdealGasConstPressureReactor; -class ReactorNet; } #endif @@ -58,12 +56,9 @@ class CFluidCantera final : public CFluidModel { const string Transport_Model; /*!< \brief Transport model used for computing mixture properties*/ const string Chemical_MechanismFile; /*!< \brief Chemical reaction mechanism used for in cantera*/ const string Phase_Name; /*!< \brief Name of the phase used for in cantera*/ - const bool Chemistry_Time_Integration; /*!< \brief bool if time-integration is used for chemical source terms*/ static constexpr int ARRAYSIZE = 16; - Cantera::IdealGasConstPressureReactor* combustor; - Cantera::ReactorNet* sim; std::array gasComposition; /*!< \brief Gas composition. */ std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ std::array chemicalSourceTerm; /*!< \brief chemical source term of all species*/ diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 66ed825e995b..8dba7dd28d56 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -35,7 +35,6 @@ #include "../../../subprojects/cantera/include/cantera/core.h" #include "../../../subprojects/cantera/include/cantera/kinetics/Reaction.h" -#include "../../../subprojects/cantera/include/cantera/zerodim.h" #include #include @@ -50,23 +49,12 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* Prandtl_Number(config->GetPrandtl_Turb()), Transport_Model(config->GetTransport_Model()), Chemical_MechanismFile(config->GetChemical_MechanismFile()), - Phase_Name(config->GetPhase_Name()), - Chemistry_Time_Integration(config->GetChemistryTimeIntegration()){ + Phase_Name(config->GetPhase_Name()){ if (n_species_mixture > ARRAYSIZE) { SU2_MPI::Error("Too many species, increase ARRAYSIZE", CURRENT_FUNCTION); } sol = std::shared_ptr(newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model)); sol->thermo()->getMolecularWeights(&molarMasses[0]); - combustor = nullptr; - sim = nullptr; - if (Chemistry_Time_Integration) { - combustor = new IdealGasConstPressureReactor(); - combustor->insert(sol); - sim = new ReactorNet(); - sim->addReactor(*combustor); - su2double Delta_t_max = 0.1; - combustor->setAdvanceLimit("temperature", GetValue(Delta_t_max)); - } for (int iVar = 0; iVar < n_species_mixture; iVar++) { gasComposition[iVar] = config->GetChemical_GasComposition(iVar); // config->SetChemical_GasComposition(iVar, gasComposition[iVar]); //this should be used for later @@ -116,37 +104,12 @@ void CFluidCantera::ComputeMassDiffusivity() { } void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2double* val_scalars){ - if (Chemistry_Time_Integration) { - combustor->insert(sol); - su2double Delta_t_max = 0.1; - combustor->setAdvanceLimit("temperature", GetValue(Delta_t_max)); - sim->setInitialTime(0.0); - sim->advance(max(1E-15, GetValue(0.0001 * delta_time))); - sim->setTolerances(1E-12, 1E-12); - //const su2double density_new = combustor->density(); - // cout << "time simulated " << setprecision(12) << sim->time() << endl; - // cout << "Temperature before integration: " << setprecision(12) << Temperature << endl; - // cout << "Temperature after integration: " << setprecision(12) << combustor->temperature() << endl; - // cout << "Pressure combustor after integration: " << setprecision(12) << combustor->pressure() << endl; - for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { - int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - const su2double scalar_new = combustor->massFraction(speciesIndex); - //const su2double scalat_old = val_scalars[iVar]; - // cout << "Species before integration: " << setprecision(12) << val_scalars[iVar] << endl; - // cout << "Species after integration: " << setprecision(12) << scalar_new << endl; - cout << "Time simulated: " << setprecision(12) << sim->time() << endl; - const su2double source_term_corr = Density * (scalar_new - val_scalars[iVar]) / abs(sim->time()); - // cout<<"source_term "<thermo()->nSpecies(); - vector netProductionRates(nsp); - sol->kinetics()->getNetProductionRates(&netProductionRates[0]); - for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { - int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - chemicalSourceTerm[iVar] = molarMasses[speciesIndex] * netProductionRates[speciesIndex]; - } + const int nsp = sol->thermo()->nSpecies(); + vector netProductionRates(nsp); + sol->kinetics()->getNetProductionRates(&netProductionRates[0]); + for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { + int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); + chemicalSourceTerm[iVar] = molarMasses[speciesIndex] * netProductionRates[speciesIndex]; } } From 503d9551dc7d6cf2bb1b622614de387ec7b7ac88 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 5 Aug 2025 13:51:29 +0200 Subject: [PATCH 123/173] cleaning grad_chemical_source_term --- SU2_CFD/include/fluid/CFluidCantera.hpp | 13 ----- SU2_CFD/include/fluid/CFluidModel.hpp | 6 --- SU2_CFD/include/numerics/CNumerics.hpp | 15 +----- .../numerics/species/species_sources.hpp | 1 - .../include/variables/CSpeciesVariable.hpp | 24 ---------- SU2_CFD/src/fluid/CFluidCantera.cpp | 47 ------------------- .../src/numerics/species/species_sources.cpp | 7 --- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 7 --- SU2_CFD/src/variables/CSpeciesVariable.cpp | 7 ++- 9 files changed, 4 insertions(+), 123 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index e27d8c65554d..e0bef0136a30 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -62,7 +62,6 @@ class CFluidCantera final : public CFluidModel { std::array gasComposition; /*!< \brief Gas composition. */ std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ std::array chemicalSourceTerm; /*!< \brief chemical source term of all species*/ - std::array gradChemicalSourceTerm; /*!< \brief jacobian chemical source term of all species*/ std::array molarMasses; /*!< \brief Molar masses of all species. */ std::array enthalpyFormation; /*!< \brief Enthalpy of Formation of all species. */ su2double Heat_Release; /*!< \brief heat release due to combustion */ @@ -74,12 +73,6 @@ class CFluidCantera final : public CFluidModel { */ void ComputeMassDiffusivity(); - /*! - * \brief Compute Gradient chemical source terms. - * \param[in] val_scalars - Scalar mass fraction. - */ - void ComputeGradChemicalSourceTerm(const su2double* val_scalars); - /*! * \brief Compute heat release due to combustion. */ @@ -130,12 +123,6 @@ class CFluidCantera final : public CFluidModel { */ inline su2double GetChemicalSourceTerm(int ivar) override { return chemicalSourceTerm[ivar]; } - /*! - * \brief Get Gradient Chemical source term species i with respect to species i. - * \param[in] ivar - index of species. - */ - inline su2double GetGradChemicalSourceTerm(int ivar) override { return gradChemicalSourceTerm[ivar]; } - /*! * \brief Get Heat release due to combustion. */ diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 04769fefe4a6..753476be8187 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -204,12 +204,6 @@ class CFluidModel { */ inline virtual su2double GetChemicalSourceTerm(int iVar) { return 0.0; } - /*! - * \brief Get Gradient Chemical source term of species i with respect to species i. - * \param[in] iVar - index of species. - */ - inline virtual su2double GetGradChemicalSourceTerm(int iVar) { return 0.0; } - /*! * \brief Get Heat release due to combustion. */ diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 7564300b7512..6601193cee04 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -64,9 +64,7 @@ class CNumerics { *Diffusion_Coeff_i, /*!< \brief Species diffusion coefficients at point i. */ *Diffusion_Coeff_j, /*!< \brief Species diffusion coefficients at point j. */ *Chemical_Source_Term_i, /*!< \brief Species diffusion coefficients at point i. */ - *Chemical_Source_Term_j, /*!< \brief Species diffusion coefficients at point j. */ - *Grad_Chemical_Source_Term_i, /*!< \brief Gradient Chemical source term Species at point i. */ - *Grad_Chemical_Source_Term_j; /*!< \brief Gradient Chemical source term Species at point j. */ + *Chemical_Source_Term_j; /*!< \brief Species diffusion coefficients at point j. */ su2double Laminar_Viscosity_i, /*!< \brief Laminar viscosity at point i. */ Laminar_Viscosity_j; /*!< \brief Laminar viscosity at point j. */ @@ -776,17 +774,6 @@ class CNumerics { Chemical_Source_Term_j = val_source_term_j; } - /*! - * \brief Set the gradient of the Chemical source term - * \param[in] val_grad_source_term_i - Value of the gradient of the chemical source term at i. - * \param[in] val_grad_source_term_j - Value of the gradient of the chemical source term at j. - */ - inline void SetGradChemicalSourceTerm(const su2double* val_grad_source_term_i, - const su2double* val_grad_source_term_j) { - Grad_Chemical_Source_Term_i = val_grad_source_term_i; - Grad_Chemical_Source_Term_j = val_grad_source_term_j; - } - /*! * \brief Set the heat flux due to enthalpy diffusion * \param[in] val_heatfluxdiffusion - Value of the heat flux due to enthalpy diffusion. diff --git a/SU2_CFD/include/numerics/species/species_sources.hpp b/SU2_CFD/include/numerics/species/species_sources.hpp index b079eea2c2c5..e86893b47eaf 100644 --- a/SU2_CFD/include/numerics/species/species_sources.hpp +++ b/SU2_CFD/include/numerics/species/species_sources.hpp @@ -103,7 +103,6 @@ class CSourceCombustion_Species : public CSourceBase_Species { protected: const FlowIndices idx; /*!< \brief Object to manage the access to the flow primitives. */ const bool incompressible; - const bool implicit; public: /*! diff --git a/SU2_CFD/include/variables/CSpeciesVariable.hpp b/SU2_CFD/include/variables/CSpeciesVariable.hpp index 52b339d3eb1d..e42238b6908e 100644 --- a/SU2_CFD/include/variables/CSpeciesVariable.hpp +++ b/SU2_CFD/include/variables/CSpeciesVariable.hpp @@ -37,7 +37,6 @@ class CSpeciesVariable : public CScalarVariable { protected: MatrixType Diffusivity; /*!< \brief Matrix (nPoint,nVar) of mass diffusivities for scalar transport. */ MatrixType SpeciesSourceTerm; /*!< \brief Matrix (nPoint, nVar) of chemical source terms for species transport*/ - MatrixType GradSpeciesSourceTerm; /*!< \brief Matrix (nPoint, nVar) of gradient of chemical source terms for species transport*/ VectorType HeatRelease; /*!< \brief Vector of heat release due to combustion for species transport*/ public: @@ -102,29 +101,6 @@ class CSpeciesVariable : public CScalarVariable { */ inline const su2double* GetChemicalSourceTerm(unsigned long iPoint) const { return SpeciesSourceTerm[iPoint]; } - /*! - * \brief Set the gradient of the chemical source term for species transport - * \param[in] val_gradSourceTerm - the gradient of the chemical source term. - * \param[in] val_ivar - eqn. index to the chemical source term. - */ - inline void SetGradChemicalSourceTerm(unsigned long iPoint, su2double val_gradSourceTerm, unsigned short val_ivar) { - GradSpeciesSourceTerm(iPoint, val_ivar) = val_gradSourceTerm; - } - - /*! - * \brief Get the value of the gradient of the chemical source term for species transport - * \param[in] val_ivar - eqn. index to the gradient of the chemical source term. - * \return Value of the gradient of the chemical source term. - */ - inline su2double GetGradChemicalSourceTerm(unsigned long iPoint, unsigned short val_ivar) const { - return GradSpeciesSourceTerm(iPoint, val_ivar); - } - - /*! - * \brief Get the value of the gradient of the chemical source term for species transport - * \return Pointer to the gradient of the chemical source term - */ - inline const su2double* GetGradChemicalSourceTerm(unsigned long iPoint) const { return GradSpeciesSourceTerm[iPoint]; } /*! * \brief Get heat release due to combustion * \param[in] iPoint - Point index. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 8dba7dd28d56..52a53d0cfc8f 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -57,7 +57,6 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* sol->thermo()->getMolecularWeights(&molarMasses[0]); for (int iVar = 0; iVar < n_species_mixture; iVar++) { gasComposition[iVar] = config->GetChemical_GasComposition(iVar); - // config->SetChemical_GasComposition(iVar, gasComposition[iVar]); //this should be used for later } SetEnthalpyFormation(config); @@ -113,50 +112,6 @@ void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2dou } } -void CFluidCantera::ComputeGradChemicalSourceTerm(const su2double* val_scalars) { - const int nsp = sol->thermo()->nSpecies(); - //const su2double meanMolecularWeight = sol->thermo()->meanMolecularWeight(); - vector netProductionRates_T(nsp); - // The universal gas constant times temperature is retrieved from cantera. - const su2double uni_gas_constant_temp = sol->thermo()->RT(); - vector enthalpiesSpecies(nsp); - sol->thermo()->getEnthalpy_RT_ref(&enthalpiesSpecies[0]); - //Eigen::SparseMatrix dW_dC = sol->kinetics()->netProductionRates_ddCi(); - sol->kinetics()->getNetProductionRates_ddT(&netProductionRates_T[0]); - const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); - for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { - int speciesIndex_i = sol->thermo()->speciesIndex(gasComposition[iVar]); - //su2double scalars_sum = 0.0; - const su2double dT_dYi = - uni_gas_constant_temp * (enthalpiesSpecies[speciesN] - enthalpiesSpecies[speciesIndex_i]) / Cp; - gradChemicalSourceTerm[iVar] = molarMasses[speciesIndex_i] * netProductionRates_T[speciesIndex_i] * dT_dYi; - // for (int jVar = 0; jVar < n_species_mixture - 1; jVar++) { - // int speciesIndex_j = sol->thermo()->speciesIndex(gasComposition[jVar]); - // su2double dW_dCi = dW_dC.coeff(iVar,jVar) * molarMasses[speciesIndex_i]; - // if (jVar != iVar) { - // const su2double factor = dW_dCi * Density * val_scalars[jVar] / (molarMasses[speciesIndex_j] / 1000); - // scalars_sum += val_scalars[jVar]; - // gradChemicalSourceTerm[iVar] += - // factor * (-dT_dYi / Temperature + - // meanMolecularWeight * (1 / molarMasses[speciesN] - 1 / molarMasses[speciesIndex_i])); - // } else { - // const su2double factor = dW_dCi * Density / (molarMasses[speciesIndex_j] / 1000); - // scalars_sum += val_scalars[jVar]; - // gradChemicalSourceTerm[iVar] += - // factor * (1.0 + val_scalars[jVar] * - // (-dT_dYi / Temperature + - // meanMolecularWeight * (1 / molarMasses[speciesN] - 1 / molarMasses[speciesIndex_i]))); - // } - // } - // su2double dW_dCN = dW_dC.coeff(iVar, speciesN)* molarMasses[speciesN]; - // const su2double factor = dW_dCN * Density / (molarMasses[speciesN] / 1000); - // gradChemicalSourceTerm[iVar] += - // factor * - // (-1.0 + (1.0 - scalars_sum) * (-dT_dYi / Temperature + meanMolecularWeight * (1 / molarMasses[speciesN] - - // 1 / molarMasses[speciesIndex_i]))); - } -} - void CFluidCantera::ComputeHeatRelease() { const int nsp = sol->thermo()->nSpecies(); vector netProductionRates(nsp); @@ -236,8 +191,6 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl Kt = sol->transport()->thermalConductivity(); ComputeMassDiffusivity(); - //ComputeChemicalSourceTerm(); - ComputeGradChemicalSourceTerm(val_scalars); ComputeHeatRelease(); } diff --git a/SU2_CFD/src/numerics/species/species_sources.cpp b/SU2_CFD/src/numerics/species/species_sources.cpp index 87cc59c75108..2e7ad52c7869 100644 --- a/SU2_CFD/src/numerics/species/species_sources.cpp +++ b/SU2_CFD/src/numerics/species/species_sources.cpp @@ -140,7 +140,6 @@ CSourceCombustion_Species::CSourceCombustion_Species(unsigned short val_nDim, const CConfig* config) : CSourceBase_Species(val_nDim, val_nVar, config), idx(val_nDim, config->GetnSpecies()), - implicit(config->GetKind_TimeIntScheme_Species() == EULER_IMPLICIT), incompressible(config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE) {} template @@ -170,12 +169,6 @@ CNumerics::ResidualType<> CSourceCombustion_Species::ComputeResidual(const CC residual[iVar] += Volume * Chemical_Source_Term_i[iVar]; } - if (implicit) { - for (auto iVar = 0u; iVar < nVar; iVar++) { - jacobian[iVar][iVar] += Volume * Grad_Chemical_Source_Term_i[iVar] / DensityInc_i; - } - } - AD::SetPreaccOut(residual, nVar); AD::EndPreacc(); diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index 4a04c095eae6..e36b7a7b7bff 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -296,7 +296,6 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain unsigned long spark_iter_start, spark_duration; bool ignition = false; su2double temperature; - const bool implicit = (config->GetKind_TimeIntScheme_Species() == EULER_IMPLICIT); /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ if (flamelet_config_options.ignition_method == FLAMELET_INIT_TYPE::SPARK) { @@ -341,11 +340,6 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain solver_container[FLOW_SOL]->GetFluidModel()->ComputeChemicalSourceTerm(delta_time, scalar); const su2double chemical_source_term=solver_container[FLOW_SOL]->GetFluidModel()->GetChemicalSourceTerm(iVar); nodes->SetChemicalSourceTerm(iPoint, chemical_source_term, iVar); - if (implicit) { - const su2double grad_chemical_source_term = - solver_container[FLOW_SOL]->GetFluidModel()->GetGradChemicalSourceTerm(iVar); - nodes->SetGradChemicalSourceTerm(iPoint, grad_chemical_source_term, iVar); - } } } @@ -623,7 +617,6 @@ void CSpeciesSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta numerics->SetChemicalSourceTerm(nodes->GetChemicalSourceTerm(iPoint), nullptr); if (implicit) { - numerics->SetGradChemicalSourceTerm(nodes->GetGradChemicalSourceTerm(iPoint), nullptr); numerics->SetDensity(solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint), solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint)); } diff --git a/SU2_CFD/src/variables/CSpeciesVariable.cpp b/SU2_CFD/src/variables/CSpeciesVariable.cpp index a25e763dd67a..3f267134c888 100644 --- a/SU2_CFD/src/variables/CSpeciesVariable.cpp +++ b/SU2_CFD/src/variables/CSpeciesVariable.cpp @@ -32,11 +32,10 @@ CSpeciesVariable::CSpeciesVariable(const su2double* species_inf, unsigned long n : CScalarVariable(npoint, ndim, nvar, config) { /*--- Allocate space for the mass diffusivity and chemical source term. ---*/ Diffusivity.resize(nPoint, nVar + 1) = su2double(0.0); - SpeciesSourceTerm.resize(nPoint, nVar + 1) = su2double(0.0); - if (config->GetKind_TimeIntScheme_Species() == EULER_IMPLICIT) { - GradSpeciesSourceTerm.resize(nPoint, nVar + 1) = su2double(0.0); + if (config->GetCombustion()) { + SpeciesSourceTerm.resize(nPoint, nVar + 1) = su2double(0.0); + HeatRelease.resize(nPoint) = su2double(0.0); } - HeatRelease.resize(nPoint) = su2double(0.0); for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) for (unsigned long iVar = 0; iVar < nVar; iVar++) From 0a033a9458492da024bbb3a9defe047190aeadf2 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 11 Aug 2025 16:09:58 +0200 Subject: [PATCH 124/173] cleaning temperature limits and Relaxation factor --- Common/include/CConfig.hpp | 16 --------- Common/src/CConfig.cpp | 20 ----------- .../include/solvers/CFVMFlowSolverBase.hpp | 4 +-- SU2_CFD/include/solvers/CIncEulerSolver.hpp | 7 ---- .../include/variables/CIncEulerVariable.hpp | 3 +- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 35 ------------------- SU2_CFD/src/variables/CIncEulerVariable.cpp | 5 --- 7 files changed, 2 insertions(+), 88 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 65fe14a382a7..beb3500efa15 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -581,7 +581,6 @@ class CConfig { bool ReconstructionGradientRequired; /*!< \brief Enable or disable a second gradient calculation for upwind reconstruction only. */ bool LeastSquaresRequired; /*!< \brief Enable or disable memory allocation for least-squares gradient methods. */ bool Energy_Equation; /*!< \brief Solve the energy equation for incompressible flows. */ - bool Relaxation_Inc; /*!< \brief Enable relaxation factor in the energy equation for incompressible flows. */ UPWIND Kind_Upwind, /*!< \brief Upwind scheme. */ @@ -893,8 +892,6 @@ class CConfig { nPrandtl_Lam, /*!< \brief Number of species laminar Prandtl number. */ nPrandtl_Turb, /*!< \brief Number of species turbulent Prandtl number. */ nConstant_Lewis_Number; /*!< \brief Number of species Lewis Number. */ - su2double* Inc_Temperature_Limits; /*!< \brief Temperature limits for incompressible energy equation. */ - unsigned short nInc_Temperature_Limits; /*!< \brief Number of entries of INC_TEMPERATURE_LIMITS */ su2double Diffusivity_Constant; /*!< \brief Constant mass diffusivity for scalar transport. */ su2double Diffusivity_ConstantND; /*!< \brief Non-dim. constant mass diffusivity for scalar transport. */ su2double Schmidt_Number_Laminar; /*!< \brief Laminar Schmidt number for mass diffusion. */ @@ -2165,12 +2162,6 @@ class CConfig { */ su2double GetInc_Temperature_Init(void) const { return Inc_Temperature_Init; } - /*! - * \brief Get the temperature limits for incompressible flows when energy equation is enabled. - * \return minimum and maximum temperature limits. - */ - su2double GetInc_Temperature_Limits(unsigned short iVar) const { return Inc_Temperature_Limits[iVar]; } - /*! * \brief Get the flag for activating species transport clipping. * \return Flag for species clipping. @@ -3985,13 +3976,6 @@ class CConfig { */ bool GetEnergy_Equation(void) const { return Energy_Equation; } - /*! - * \brief Flag for enabling relaxation factor in energy equation for incompressible flows. - * \return Flag for relaxation factor in energy equation for incom - */ - - bool GetRelaxationIncEnergy_Equation(void) const { return Relaxation_Inc; } - /*! * \brief free stream option to initialize the solution * \return free stream option diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index e6aaefd919d9..c5e25dcb08a6 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1383,8 +1383,6 @@ void CConfig::SetConfig_Options() { addEnumOption("INC_DENSITY_MODEL", Kind_DensityModel, DensityModel_Map, INC_DENSITYMODEL::CONSTANT); /*!\brief ENERGY_EQUATION \n DESCRIPTION: Solve the energy equation in the incompressible flow solver. \ingroup Config*/ addBoolOption("INC_ENERGY_EQUATION", Energy_Equation, false); - /* DESCRIPTION: Option to enable the use of Relaxation factor for energy equation in incompressible flows */ - addBoolOption("RELAXATION_ENERGY_INC", Relaxation_Inc, false); /*!\brief INC_DENSITY_REF \n DESCRIPTION: Reference density for incompressible flows \ingroup Config*/ addDoubleOption("INC_DENSITY_REF", Inc_Density_Ref, 1.0); /*!\brief INC_VELOCITY_REF \n DESCRIPTION: Reference velocity for incompressible flows (1.0 by default) \ingroup Config*/ @@ -1406,8 +1404,6 @@ void CConfig::SetConfig_Options() { addDoubleOption("INC_INLET_DAMPING", Inc_Inlet_Damping, 0.1); /*!\brief INC_OUTLET_DAMPING \n DESCRIPTION: Damping factor applied to the iterative updates to the pressure at a mass flow outlet in incompressible flow (0.1 by default). \ingroup Config*/ addDoubleOption("INC_OUTLET_DAMPING", Inc_Outlet_Damping, 0.1); - /*!\brief INC_TEMPERATURE_LIMITS \n DESCRIPTION: Temperature limits (minimum and maximum values) for energy equation in the incompressible solver \ingroup Config*/ - addDoubleListOption("INC_TEMPERATURE_LIMITS", nInc_Temperature_Limits, Inc_Temperature_Limits); /*--- Options related to the species solver. ---*/ @@ -3983,22 +3979,6 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i } } - if (Energy_Equation && (Inc_Temperature_Limits == nullptr)) { - Inc_Temperature_Limits = new su2double[2]; - Inc_Temperature_Limits[0] = 0.0; - Inc_Temperature_Limits[1] = 5000.0; - nInc_Temperature_Limits = 2; - } - - /*--- Check whether the number of entries of INC_TEMPERATURE_LIMITS are equal to 2.--- */ - - if ((nInc_Temperature_Limits != 2) && (Inc_Temperature_Limits != nullptr)) { - SU2_MPI::Error( - "The use of INC_TEMPERATURE_LIMITS requires the number of entries to be equal to 2: Minimum " - "Temperature, Maximum Temperature", - CURRENT_FUNCTION); - } - /*--- Set default values for various fluid properties. ---*/ const su2double Molecular_Weight_Default = 28.96; diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp index 2eac8794a500..d70ad8d3ee0d 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp @@ -982,9 +982,7 @@ class CFVMFlowSolverBase : public CSolver { template void CompleteImplicitIteration_impl(CGeometry *geometry, CConfig *config) { - bool enable_compute_ur = compute_ur; - if (config->GetRelaxationIncEnergy_Equation()) enable_compute_ur = true; - if (enable_compute_ur) ComputeUnderRelaxationFactor(config); + if (compute_ur) ComputeUnderRelaxationFactor(config); /*--- Update solution with under-relaxation and communicate it. ---*/ diff --git a/SU2_CFD/include/solvers/CIncEulerSolver.hpp b/SU2_CFD/include/solvers/CIncEulerSolver.hpp index 0befa4186ad8..02bdb12a3775 100644 --- a/SU2_CFD/include/solvers/CIncEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CIncEulerSolver.hpp @@ -446,11 +446,4 @@ class CIncEulerSolver : public CFVMFlowSolverBase= Inc_Temperature_Limits[1]); + return val_temperature <= 0.0; } /*! diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index e68e985d057d..3c1a51f77ca5 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2084,41 +2084,6 @@ void CIncEulerSolver::CompleteImplicitIteration(CGeometry *geometry, CSolver**, CompleteImplicitIteration_impl(geometry, config); } -void CIncEulerSolver::ComputeUnderRelaxationFactor(const CConfig* config) { - - /* Loop over the solution update given by relaxing the linear - system for this nonlinear iteration. */ - - const su2double allowableRatio = 0.2; - - SU2_OMP_FOR_STAT(omp_chunk_size) - - for (auto iPoint = 0ul; iPoint < nPointDomain; iPoint++) { - su2double localUnderRelaxation = 1.0; - - /*--- Energy ---*/ - - const unsigned long index = iPoint * nVar + nVar - 1; - - su2double ratio = fabs(LinSysSol[index]) / (fabs(nodes->GetSolution(iPoint, nVar - 1)) + EPS); - - if (ratio > allowableRatio) { - localUnderRelaxation = min(allowableRatio / ratio, localUnderRelaxation); - } - - /* Threshold the relaxation factor in the event that there is - a very small value. This helps avoid catastrophic crashes due - to non-realizable states by canceling the update. */ - - if (localUnderRelaxation < 1e-3) localUnderRelaxation = 0.001; - - /* Store the under-relaxation factor for this point. */ - - nodes->SetUnderRelaxation(iPoint, localUnderRelaxation); - } - - END_SU2_OMP_FOR -} void CIncEulerSolver::SetBeta_Parameter(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { diff --git a/SU2_CFD/src/variables/CIncEulerVariable.cpp b/SU2_CFD/src/variables/CIncEulerVariable.cpp index 8936f351d80d..215f351ab55a 100644 --- a/SU2_CFD/src/variables/CIncEulerVariable.cpp +++ b/SU2_CFD/src/variables/CIncEulerVariable.cpp @@ -63,11 +63,6 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *veloci if (config->GetStreamwise_Periodic_Temperature()) Streamwise_Periodic_RecoveredTemperature.resize(nPoint) = su2double(0.0); } - - if (config->GetEnergy_Equation()) { - Inc_Temperature_Limits[0] = config->GetInc_Temperature_Limits(0); - Inc_Temperature_Limits[1] = config->GetInc_Temperature_Limits(1); - } } bool CIncEulerVariable::SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel) { From 18792df7c582dfdf2f76ea5a5565320be2fc1449 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 21 Aug 2025 11:09:10 +0200 Subject: [PATCH 125/173] update multizone restart for species transport --- .github/workflows/regression.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 3c14057f42e2..142f9d3a3855 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -211,7 +211,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2:250717-1402 with: # -t -c - args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} + args: -b ${{github.ref}} -t develop -c feature_restart_preconditioning -s ${{matrix.testscript}} - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2:250717-1402 with: From 5fa9236e5ff235291e0b8218420d7f53432670e1 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 21 Aug 2025 12:02:07 +0200 Subject: [PATCH 126/173] updating residual multizone species transport --- TestCases/parallel_regression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index cf145c331c6d..a2c0d4ead205 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1667,7 +1667,7 @@ def main(): species3_multizone_restart.cfg_dir = "species_transport/multizone" species3_multizone_restart.cfg_file = "configMaster.cfg" species3_multizone_restart.test_iter = 5 - species3_multizone_restart.test_vals = [-3.723247, -3.108855] + species3_multizone_restart.test_vals = [-4.717939, -4.785805] species3_multizone_restart.multizone = True test_list.append(species3_multizone_restart) From 1b52536b9e65ebfde9776cc02e9901984889772d Mon Sep 17 00:00:00 2001 From: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> Date: Mon, 25 Aug 2025 10:37:50 +0200 Subject: [PATCH 127/173] Update SU2_CFD/include/numerics/CNumerics.hpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/include/numerics/CNumerics.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 84a2126507ca..4e26ae757d44 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -136,7 +136,7 @@ class CNumerics { su2double HeatFluxDiffusion; /*!< \brief Heat flux due to enthalpy diffusion for multicomponent. */ su2double - Jac_HeatFluxDiffusion; /*!< \brief Heat flux jacobian due to enthalpy diffusion for multicomponent. */ + JacHeatFluxDiffusion; /*!< \brief Heat flux jacobian due to enthalpy diffusion for multicomponent. */ const su2double *TransVar_i, /*!< \brief Vector of turbulent variables at point i. */ *TransVar_j; /*!< \brief Vector of turbulent variables at point j. */ From 47e77c77cbd2fac2063f7970cc37f931d3a2eb1f Mon Sep 17 00:00:00 2001 From: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> Date: Mon, 25 Aug 2025 10:38:00 +0200 Subject: [PATCH 128/173] Update SU2_CFD/include/numerics/CNumerics.hpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/include/numerics/CNumerics.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 4e26ae757d44..7852bac8eb4e 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -770,7 +770,7 @@ class CNumerics { * \brief Set Jacobian of the heat flux due to enthalpy diffusion * \param[in] val_jacheatfluxdiffusion - Value of the heat flux jacobian due to enthalpy diffusion. */ - inline void SetJacHeatFluxDiffusion(su2double val_jac_heatfluxdiffusion) { + inline void SetJacHeatFluxDiffusion(su2double val_jacheatfluxdiffusion) { Jac_HeatFluxDiffusion = val_jac_heatfluxdiffusion; } From f99a541cac58d7acc811c9a11dce7a3a85a3bd69 Mon Sep 17 00:00:00 2001 From: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> Date: Mon, 25 Aug 2025 10:38:32 +0200 Subject: [PATCH 129/173] Update SU2_CFD/src/fluid/CFluidScalar.cpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/src/fluid/CFluidScalar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/fluid/CFluidScalar.cpp b/SU2_CFD/src/fluid/CFluidScalar.cpp index 6bea14c4cb94..fddd6608f8a5 100644 --- a/SU2_CFD/src/fluid/CFluidScalar.cpp +++ b/SU2_CFD/src/fluid/CFluidScalar.cpp @@ -215,7 +215,7 @@ su2double CFluidScalar::ComputeMeanSpecificHeatCp(const su2double* val_scalars) su2double CFluidScalar::ComputeEnthalpyFromT(const su2double val_temperature, const su2double* val_scalars){ /* In future implementations, enthalpy should be computed using numerical integration. For now, as Cp does not - * depend on temperature, but it does depend on mixture composition, ehtalpy is directly computed from + * depend on temperature, but it does depend on mixture composition, enthalpy is directly computed from * the expression h_s = Cp(T - T_ref). */ su2double val_Enthalpy = Cp * (val_temperature - Ref_Temperature); From d3496d66cce8173c9df570130e6105b099be9ad5 Mon Sep 17 00:00:00 2001 From: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> Date: Mon, 25 Aug 2025 10:38:50 +0200 Subject: [PATCH 130/173] Update SU2_CFD/src/numerics/CNumerics.cpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/src/numerics/CNumerics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/numerics/CNumerics.cpp b/SU2_CFD/src/numerics/CNumerics.cpp index 07c29c029af6..f89179041633 100644 --- a/SU2_CFD/src/numerics/CNumerics.cpp +++ b/SU2_CFD/src/numerics/CNumerics.cpp @@ -54,7 +54,7 @@ CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar, Prandtl_Lam = config->GetPrandtl_Lam(); Prandtl_Turb = config->GetPrandtl_Turb(); Gas_Constant = config->GetGas_ConstantND(); - energy_multicomponent = ((config->GetKind_FluidModel() == FLUID_MIXTURE) && (config->GetEnergy_Equation())); + energy_multicomponent = config->GetKind_FluidModel() == FLUID_MIXTURE && config->GetEnergy_Equation(); tau = new su2double* [nDim]; for (iDim = 0; iDim < nDim; iDim++) From d45faef5687c309314d6ef339fc7c9bac672cceb Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 25 Aug 2025 11:47:38 +0200 Subject: [PATCH 131/173] fixing names according to review comment --- SU2_CFD/include/numerics/CNumerics.hpp | 2 +- SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 4 ++-- SU2_CFD/src/numerics/flow/flow_sources.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 7852bac8eb4e..654e6dea7436 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -771,7 +771,7 @@ class CNumerics { * \param[in] val_jacheatfluxdiffusion - Value of the heat flux jacobian due to enthalpy diffusion. */ inline void SetJacHeatFluxDiffusion(su2double val_jacheatfluxdiffusion) { - Jac_HeatFluxDiffusion = val_jac_heatfluxdiffusion; + JacHeatFluxDiffusion = val_jacheatfluxdiffusion; } /*! diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index 882191d0224d..75fdfd295938 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -659,9 +659,9 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi if (energy_multicomponent){ Mean_Heat_Capacity = 0.5 * (V_i[nDim + 7] + V_j[nDim + 7]); Jacobian_i[nDim + 1][nDim + 1] = - -(Mean_Thermal_Conductivity * proj_vector_ij + Jac_HeatFluxDiffusion) / Mean_Heat_Capacity; + -(Mean_Thermal_Conductivity * proj_vector_ij + JacHeatFluxDiffusion) / Mean_Heat_Capacity; Jacobian_j[nDim + 1][nDim + 1] = - (Mean_Thermal_Conductivity * proj_vector_ij + Jac_HeatFluxDiffusion) / Mean_Heat_Capacity; + (Mean_Thermal_Conductivity * proj_vector_ij + JacHeatFluxDiffusion) / Mean_Heat_Capacity; } else { Jacobian_i[nDim + 1][nDim + 1] = -Mean_Thermal_Conductivity * proj_vector_ij; Jacobian_j[nDim + 1][nDim + 1] = Mean_Thermal_Conductivity * proj_vector_ij; diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index b35d151faefc..3d9cbb4c3535 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -337,7 +337,7 @@ CNumerics::ResidualType<> CSourceIncAxisymmetric_Flow::ComputeResidual(const CCo residual[3] -= Volume * yinv * Thermal_Conductivity_i * PrimVar_Grad_i[nDim + 1][1]; if (multicomponent && energy) { residual[3] -= Volume * yinv * HeatFluxDiffusion; - if (implicit) jacobian[3][3] -= Volume * yinv * Jac_HeatFluxDiffusion / Cp_i; + if (implicit) jacobian[3][3] -= Volume * yinv * JacHeatFluxDiffusion / Cp_i; } } From bbb0882582700c2d9f7c5514d521c58422437d28 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 26 Aug 2025 08:56:43 +0200 Subject: [PATCH 132/173] fixing ComputeConsistentExtrapolation according to review comment --- SU2_CFD/include/solvers/CIncEulerSolver.hpp | 4 ++-- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SU2_CFD/include/solvers/CIncEulerSolver.hpp b/SU2_CFD/include/solvers/CIncEulerSolver.hpp index 02bdb12a3775..527fc4f11e31 100644 --- a/SU2_CFD/include/solvers/CIncEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CIncEulerSolver.hpp @@ -213,8 +213,8 @@ class CIncEulerSolver : public CFVMFlowSolverBaseGetNodes()->GetSolution(iPoint); const su2double* scalar_j = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(jPoint); - ComputeConsistentExtrapolation(GetFluidModel(), nDim, Primitive_i, scalar_i); - ComputeConsistentExtrapolation(GetFluidModel(), nDim, Primitive_j, scalar_j); + ComputeConsistentExtrapolation(GetFluidModel(), nDim, scalar_i, Primitive_i); + ComputeConsistentExtrapolation(GetFluidModel(), nDim, scalar_j, Primitive_j); } /*--- Check for non-physical solutions after reconstruction. If found, @@ -1419,8 +1419,8 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont FinalizeResidualComputation(geometry, pausePreacc, counter_local, config); } -void CIncEulerSolver::ComputeConsistentExtrapolation(CFluidModel* fluidModel, unsigned short nDim, su2double* primitive, - const su2double* scalar) { +void CIncEulerSolver::ComputeConsistentExtrapolation(CFluidModel* fluidModel, unsigned short nDim, + const su2double* scalar, su2double* primitive) { const CIncEulerVariable::CIndices prim_idx(nDim, 0); const su2double enthalpy = primitive[prim_idx.Enthalpy()]; fluidModel->SetTDState_h(enthalpy, scalar); From 9e49e7ad9a7323619805871fa93f46bf72bbfec5 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 1 Sep 2025 16:54:51 +0200 Subject: [PATCH 133/173] adding max changes --- SU2_CFD/src/fluid/CFluidCantera.cpp | 4 ++-- SU2_CFD/src/meson.build | 4 ++-- cantera_meson_build.py | 10 +++++++--- meson.build | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 52a53d0cfc8f..bd2b457fce95 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -33,8 +33,8 @@ #ifdef USE_CANTERA #include "../../Common/include/basic_types/ad_structure.hpp" -#include "../../../subprojects/cantera/include/cantera/core.h" -#include "../../../subprojects/cantera/include/cantera/kinetics/Reaction.h" +#include +#include #include #include diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index ba918ab1ebc0..c3aa8268c9b9 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -199,7 +199,7 @@ if get_option('enable-normal') su2_cfd_lib = static_library('SU2core', su2_cfd_src, install : false, - dependencies : [su2_deps, common_dep], + dependencies : [su2_deps, common_dep, cantera_dep], cpp_args: [default_warning_flags, su2_cpp_args]) su2_cfd_dep = declare_dependency(link_with: su2_cfd_lib, include_directories: su2_cfd_include) @@ -215,7 +215,7 @@ if get_option('enable-autodiff') su2_cfd_lib_ad = static_library('SU2core_AD', su2_cfd_src, install : false, - dependencies : [su2_deps, codi_dep, commonAD_dep], + dependencies : [su2_deps, codi_dep, commonAD_dep, cantera_ad_dep], cpp_args: [default_warning_flags, su2_cpp_args, codi_rev_args]) su2_cfd_dep_ad = declare_dependency(link_with: su2_cfd_lib_ad, include_directories: su2_cfd_include) diff --git a/cantera_meson_build.py b/cantera_meson_build.py index 95f61a8a1c8f..fa74c79762f3 100644 --- a/cantera_meson_build.py +++ b/cantera_meson_build.py @@ -39,10 +39,14 @@ print(f"Writing meson.build in {meson_path}") meson_build_content = ["project('cantera', 'c', 'cpp', default_options: ['cpp_std=c++17'])\n", "cc = meson.get_compiler('cpp')\n", - "cantera_inc = include_directories('include')\n", - "cantera_lib = cc.find_library('cantera', dirs: [meson.current_source_dir() / 'build' / 'lib'], required: false, static: true)\n", + "cantera_inc = include_directories('install/include')\n", + "cantera_lib = cc.find_library('cantera', dirs: [meson.current_source_dir() / 'install' / 'lib'], required: false, static: true)\n", "cantera_dep = declare_dependency(include_directories: cantera_inc, dependencies: cantera_lib)\n", - "meson.override_dependency('cantera', cantera_dep)"] + "meson.override_dependency('cantera', cantera_dep)\n", + "cantera_ad_inc = include_directories('install_ad/include')\n", + "cantera_ad_lib = cc.find_library('cantera', dirs: [meson.current_source_dir() / 'install_ad' / 'lib'], required: false, static: true)\n", + "cantera_ad_dep = declare_dependency(include_directories: cantera_ad_inc, dependencies: cantera_ad_lib)\n", + "meson.override_dependency('cantera_ad', cantera_ad_dep)"] # Write the meson.build file with open(meson_build_path, 'w') as f: f.writelines(meson_build_content) diff --git a/meson.build b/meson.build index 33bddb712947..55918a93d3c5 100644 --- a/meson.build +++ b/meson.build @@ -334,7 +334,7 @@ if get_option('enable-cantera') endif su2_cpp_args +='-DHAVE_CANTERA' cantera_dep = dependency('cantera') - su2_deps += cantera_dep + cantera_ad_dep = dependency('cantera_ad') endif if get_option('enable-mlpcpp') From d66fcebc1233c3f9e11b9bb1b2f48cc69bb1c619 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 3 Sep 2025 21:47:03 +0200 Subject: [PATCH 134/173] removing WorkingVar from numerics and small cleaning --- SU2_CFD/include/numerics/CNumerics.hpp | 3 --- SU2_CFD/src/numerics/flow/convection/centered.cpp | 2 ++ SU2_CFD/src/numerics/flow/convection/fds.cpp | 1 + SU2_CFD/src/solvers/CIncEulerSolver.cpp | 8 ++++---- SU2_CFD/src/solvers/CIncNSSolver.cpp | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 19b67beb8419..cf1cc8afda5c 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -103,9 +103,6 @@ class CNumerics { su2double Enthalpy_i, /*!< \brief Enthalpy at point i. */ Enthalpy_j; /*!< \brief Enthalpy at point j. */ - su2double - WorkingVariable_i, /*!< \brief Working Variable at point i for incompressible solver. */ - WorkingVariable_j; /*!< \brief Working Variable at point j for incompressible solver. */ su2double dist_i, /*!< \brief Distance of point i to the nearest wall. */ dist_j; /*!< \brief Distance of point j to the nearest wall. */ diff --git a/SU2_CFD/src/numerics/flow/convection/centered.cpp b/SU2_CFD/src/numerics/flow/convection/centered.cpp index fca062df2907..e04724408cca 100644 --- a/SU2_CFD/src/numerics/flow/convection/centered.cpp +++ b/SU2_CFD/src/numerics/flow/convection/centered.cpp @@ -89,6 +89,7 @@ CNumerics::ResidualType<> CCentLaxInc_Flow::ComputeResidual(const CConfig* confi su2double U_i[5] = {0.0}, U_j[5] = {0.0}; su2double ProjGridVel = 0.0, ProjVelocity = 0.0; + su2double WorkingVariable_i, WorkingVariable_j; /*--- Primitive variables at point i and j ---*/ @@ -330,6 +331,7 @@ CNumerics::ResidualType<> CCentJSTInc_Flow::ComputeResidual(const CConfig* confi su2double U_i[5] = {0.0}, U_j[5] = {0.0}; su2double ProjGridVel = 0.0; + su2double WorkingVariable_i, WorkingVariable_j; /*--- Primitive variables at point i and j ---*/ diff --git a/SU2_CFD/src/numerics/flow/convection/fds.cpp b/SU2_CFD/src/numerics/flow/convection/fds.cpp index 965d52f9e2d0..a77b82f8977f 100644 --- a/SU2_CFD/src/numerics/flow/convection/fds.cpp +++ b/SU2_CFD/src/numerics/flow/convection/fds.cpp @@ -92,6 +92,7 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; su2double ProjGridVel = 0.0; + su2double WorkingVariable_i, WorkingVariable_j; AD::StartPreacc(); AD::SetPreaccIn(V_i, nDim+10); AD::SetPreaccIn(V_j, nDim+10); AD::SetPreaccIn(Normal, nDim); diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 43d390f6bdf3..5ee15ef5f44f 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -55,7 +55,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned bool time_stepping = config->GetTime_Marching() == TIME_MARCHING::TIME_STEPPING; bool adjoint = (config->GetContinuous_Adjoint()) || (config->GetDiscrete_Adjoint()); const bool centered = config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED; - const bool energy_multicomponent = ((config->GetKind_FluidModel() == FLUID_MIXTURE) && config->GetEnergy_Equation()); + const bool energy_multicomponent = config->GetKind_FluidModel() == FLUID_MIXTURE && config->GetEnergy_Equation(); /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); @@ -2218,7 +2218,7 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain const bool implicit = config->GetKind_TimeIntScheme() == EULER_IMPLICIT; const bool viscous = config->GetViscous(); - const bool energy_multicomponent = ((config->GetKind_FluidModel() == FLUID_MIXTURE) && (config->GetEnergy_Equation())); + const bool energy_multicomponent = config->GetKind_FluidModel() == FLUID_MIXTURE && config->GetEnergy_Equation(); su2double Normal[MAXNDIM] = {0.0}; @@ -2362,7 +2362,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool viscous = config->GetViscous(); - const bool energy_multicomponent = ((config->GetKind_FluidModel() == FLUID_MIXTURE) && (config->GetEnergy_Equation())); + const bool energy_multicomponent = config->GetKind_FluidModel() == FLUID_MIXTURE && config->GetEnergy_Equation(); string Marker_Tag = config->GetMarker_All_TagBound(val_marker); @@ -2623,7 +2623,7 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool viscous = config->GetViscous(); - const bool energy_multicomponent = ((config->GetKind_FluidModel() == FLUID_MIXTURE) && (config->GetEnergy_Equation())); + const bool energy_multicomponent = config->GetKind_FluidModel() == FLUID_MIXTURE && config->GetEnergy_Equation(); string Marker_Tag = config->GetMarker_All_TagBound(val_marker); su2double Normal[MAXNDIM] = {0.0}; diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index a422a5d67d18..c66697eba0f7 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -69,7 +69,7 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container const bool limiter = (config->GetKind_SlopeLimit_Flow() != LIMITER::NONE) && (InnerIter <= config->GetLimiterIter()); const bool van_albada = (config->GetKind_SlopeLimit_Flow() == LIMITER::VAN_ALBADA_EDGE); const bool wall_functions = config->GetWall_Functions(); - const bool energy_multicomponent = (config->GetEnergy_Equation()) && (config->GetKind_FluidModel() == FLUID_MIXTURE); + const bool energy_multicomponent = config->GetEnergy_Equation() && config->GetKind_FluidModel() == FLUID_MIXTURE; /*--- Common preprocessing steps (implemented by CEulerSolver) ---*/ @@ -300,7 +300,7 @@ void CIncNSSolver::Compute_Streamwise_Periodic_Recovered_Values(CConfig *config, void CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config) { - const bool energy_multicomponent = ((config->GetKind_FluidModel() == FLUID_MIXTURE) && config->GetEnergy_Equation()); + const bool energy_multicomponent = config->GetKind_FluidModel() == FLUID_MIXTURE && config->GetEnergy_Equation(); /*--- Contribution to heat flux due to enthalpy diffusion for multicomponent and reacting flows ---*/ if (energy_multicomponent) { From 8ba4b783204e110453c7e13923a9a1be50002234 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 10 Sep 2025 11:48:12 +0200 Subject: [PATCH 135/173] formatting --- SU2_CFD/include/solvers/CIncNSSolver.hpp | 4 ++-- SU2_CFD/src/solvers/CIncNSSolver.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/include/solvers/CIncNSSolver.hpp b/SU2_CFD/include/solvers/CIncNSSolver.hpp index 21fbc65ddeb5..7cc443e6dfee 100644 --- a/SU2_CFD/include/solvers/CIncNSSolver.hpp +++ b/SU2_CFD/include/solvers/CIncNSSolver.hpp @@ -103,8 +103,8 @@ class CIncNSSolver final : public CIncEulerSolver { * \param[in] n_species - Number of species in the mixture that a transport equation is solved. * \param[in] implicit - Boolean for implicit iterations. */ - void ComputeEnthalpyDiffusion(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, CNumerics* numerics, - const int n_species, const bool implicit) ; + void Compute_Enthalpy_Diffusion(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, + CNumerics* numerics, const int n_species, const bool implicit); public: /*! diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index c66697eba0f7..7f02687aa3f2 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -306,13 +306,13 @@ void CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CS if (energy_multicomponent) { const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const int n_species = config->GetnSpecies(); - ComputeEnthalpyDiffusion(iEdge, geometry, solver_container, numerics, n_species, implicit); + Compute_Enthalpy_Diffusion(iEdge, geometry, solver_container, numerics, n_species, implicit); } Viscous_Residual_impl(iEdge, geometry, solver_container, numerics, config); } -void CIncNSSolver::ComputeEnthalpyDiffusion(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, +void CIncNSSolver::Compute_Enthalpy_Diffusion(unsigned long iEdge, CGeometry* geometry, CSolver** solver_container, CNumerics* numerics, const int n_species, const bool implicit) { CVariable* speciesNodes = solver_container[SPECIES_SOL]->GetNodes(); From eaf4970a9db5f6ff3eb846b41b7403d63277a21c Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 10 Sep 2025 15:55:00 +0200 Subject: [PATCH 136/173] fixing unit test for cantera --- SU2_CFD/include/fluid/CFluidCantera.hpp | 4 ++-- SU2_CFD/include/fluid/CFluidModel.hpp | 4 ++-- SU2_CFD/src/fluid/CFluidCantera.cpp | 2 +- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 4 +--- UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp | 5 ++++- UnitTests/meson.build | 7 ++++++- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index e0bef0136a30..2c270cfdf98c 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -113,9 +113,9 @@ class CFluidCantera final : public CFluidModel { /*! * \brief Compute chemical source term for species. - * \param[in] delta_time - time integration flow solver. + * \param[in] val_scalars - Scalar mass fractions. */ - void ComputeChemicalSourceTerm(su2double delta_time, const su2double* val_scalars) override; + void ComputeChemicalSourceTerm(const su2double* val_scalars) override; /*! * \brief Get Chemical source term species. diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 616951b6abb1..7d0feee6e42e 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -194,9 +194,9 @@ class CFluidModel { /*! * \brief Compute chemical source term for species. - * \param[in] delta_time - time integration flow solver. + * \param[in] val_scalars - Scalar mass fractions. */ - virtual void ComputeChemicalSourceTerm(su2double delta_time, const su2double* val_scalars = nullptr) {}; + virtual void ComputeChemicalSourceTerm(const su2double* val_scalars = nullptr) {}; /*! * \brief Get Chemical source term species. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index bd2b457fce95..78bccd133a61 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -102,7 +102,7 @@ void CFluidCantera::ComputeMassDiffusivity() { } } -void CFluidCantera::ComputeChemicalSourceTerm(su2double delta_time, const su2double* val_scalars){ +void CFluidCantera::ComputeChemicalSourceTerm(const su2double* val_scalars) { const int nsp = sol->thermo()->nSpecies(); vector netProductionRates(nsp); sol->kinetics()->getNetProductionRates(&netProductionRates[0]); diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index 3d2d4e958aed..5a6e33bd5a96 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -337,10 +337,8 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain const su2double mass_diffusivity = solver_container[FLOW_SOL]->GetFluidModel()->GetMassDiffusivity(iVar); nodes->SetDiffusivity(iPoint, mass_diffusivity, iVar); if (config->GetCombustion() == true) { - /*--- Retrieve delta time step ---*/ - su2double delta_time = solver_container[FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint); /*--- call function integrate chemical source term ---*/ - solver_container[FLOW_SOL]->GetFluidModel()->ComputeChemicalSourceTerm(delta_time, scalar); + solver_container[FLOW_SOL]->GetFluidModel()->ComputeChemicalSourceTerm(scalar); const su2double chemical_source_term=solver_container[FLOW_SOL]->GetFluidModel()->GetChemicalSourceTerm(iVar); nodes->SetChemicalSourceTerm(iPoint, chemical_source_term, iVar); } diff --git a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp index 8ed2f7520e85..e854ff4476d1 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp @@ -34,7 +34,7 @@ #define USE_CANTERA #include "../../../Common/include/basic_types/ad_structure.hpp" #include "../../../SU2_CFD/include/fluid/CFluidCantera.hpp" -#include "../../../subprojects/cantera/include/cantera/core.h" +#include #include #include @@ -88,6 +88,9 @@ TEST_CASE("Fluid_Cantera_Combustion", "[Reacting_flow]") { /*--- Set state using temperature and scalar ---*/ auxFluidModel->SetTDState_T(Temperature, scalar); + /*--- Compute chemical source terms ---*/ + auxFluidModel->ComputeChemicalSourceTerm(scalar); + /*--- check values for source terms ---*/ su2double sourceTerm_H2 = auxFluidModel->GetChemicalSourceTerm(0); diff --git a/UnitTests/meson.build b/UnitTests/meson.build index cfa80e4ee302..28585530cffd 100644 --- a/UnitTests/meson.build +++ b/UnitTests/meson.build @@ -32,6 +32,11 @@ su2_cfd_tests_dd = files(['Common/simple_directdiff_test.cpp']) # End of unit test listings # ------------------------------------------------------------------------- +if get_option('enable-cantera') + su2_cpp_args += '-DHAVE_CANTERA' + cantera_dep = dependency('cantera') +endif + if get_option('enable-tests') if get_option('enable-normal') unit_test_files = su2_cfd_tests + files(['test_driver.cpp']) @@ -39,7 +44,7 @@ if get_option('enable-tests') 'test_driver', unit_test_files, install : true, - dependencies : [su2_cfd_dep, common_dep, su2_deps, catch2_dep], + dependencies : [su2_cfd_dep, common_dep, su2_deps, catch2_dep, cantera_dep], cpp_args: ['-fPIC', default_warning_flags, su2_cpp_args] ) test('Catch2 test driver', test_driver) From 4fc40d52da947bc3c5feb42c3d0ead2df1ea6342 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 16 Sep 2025 12:36:19 +0200 Subject: [PATCH 137/173] cleaning --- SU2_CFD/src/fluid/CFluidCantera.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 78bccd133a61..cc5966976dce 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -129,26 +129,19 @@ void CFluidCantera::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) { // The universal gas constant times temperature is retrieved from cantera. const su2double uni_gas_constant_temp = sol->thermo()->RT(); vector enthalpiesSpecies(nsp); - vector diff(nsp); sol->thermo()->getEnthalpy_RT_ref(&enthalpiesSpecies[0]); - sol->transport()->getMixDiffCoeffsMass(&diff[0]); const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); enthalpy_diffusions[iVar] = Density * uni_gas_constant_temp * - ((enthalpiesSpecies[speciesIndex] * diff[speciesIndex] / molarMasses[speciesIndex]) - - (enthalpiesSpecies[speciesN] * diff[speciesN] / molarMasses[speciesN])); + ((enthalpiesSpecies[speciesIndex] * massDiffusivity[iVar] / molarMasses[speciesIndex]) - + (enthalpiesSpecies[speciesN] * massDiffusivity[n_species_mixture - 1] / molarMasses[speciesN])); } } void CFluidCantera::GetMassCorrectionDiffusivity(su2double* massCorrection_diffusions) { - const int nsp = sol->thermo()->nSpecies(); - vector diff(nsp); - sol->transport()->getMixDiffCoeffsMass(&diff[0]); - const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { - int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - massCorrection_diffusions[iVar] = Density * (diff[speciesIndex] - diff[speciesN]); + massCorrection_diffusions[iVar] = Density * (massDiffusivity[iVar] - massDiffusivity[n_species_mixture - 1]); } } @@ -157,15 +150,13 @@ void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusio // The universal gas constant is retrieved from cantera,in order to keep consistency with the values retrieve from it. const su2double universal_gas_constant = (sol->thermo()->RT()) / Temperature; vector specificHeatSpecies(nsp); - vector diff(nsp); sol->thermo()->getCp_R_ref(&specificHeatSpecies[0]); - sol->transport()->getMixDiffCoeffsMass(&diff[0]); const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); grad_enthalpy_diffusions[iVar] = Density * universal_gas_constant * - ((specificHeatSpecies[speciesIndex] * diff[speciesIndex] / molarMasses[speciesIndex]) - - (specificHeatSpecies[speciesN] * diff[speciesN] / molarMasses[speciesN])); + ((specificHeatSpecies[speciesIndex] * massDiffusivity[iVar] / molarMasses[speciesIndex]) - + (specificHeatSpecies[speciesN] * massDiffusivity[n_species_mixture - 1] / molarMasses[speciesN])); } } From 6e9383c1a749ba0499279e57eb990548ce4c62f5 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 22 Sep 2025 17:35:46 +0200 Subject: [PATCH 138/173] fix preaccumulation --- SU2_CFD/src/numerics/species/species_sources.cpp | 8 -------- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 4 ---- 2 files changed, 12 deletions(-) diff --git a/SU2_CFD/src/numerics/species/species_sources.cpp b/SU2_CFD/src/numerics/species/species_sources.cpp index b95cb8627188..e61bc89d4b43 100644 --- a/SU2_CFD/src/numerics/species/species_sources.cpp +++ b/SU2_CFD/src/numerics/species/species_sources.cpp @@ -146,17 +146,9 @@ template CNumerics::ResidualType<> CSourceCombustion_Species::ComputeResidual(const CConfig* config) { /*--- Preaccumulation ---*/ AD::StartPreacc(); - AD::SetPreaccIn(ScalarVar_i, nVar); AD::SetPreaccIn(Volume); AD::SetPreaccIn(Chemical_Source_Term_i, nVar); - if (incompressible) { - AD::SetPreaccIn(V_i, nDim+6); - } - else { - AD::SetPreaccIn(V_i, nDim+7); - } - /*--- Initialization. ---*/ for (auto iVar = 0u; iVar < nVar; iVar++) { residual[iVar] = 0.0; diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index 5ca817e6679f..a29b1b1a4c91 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -617,10 +617,6 @@ void CSpeciesSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Set Chemical Source Term ---*/ numerics->SetChemicalSourceTerm(nodes->GetChemicalSourceTerm(iPoint), nullptr); - if (implicit) { - numerics->SetDensity(solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint), - solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint)); - } /*--- Set volume of the dual cell. ---*/ From ae50195415ef20fa4cfaaf97b3c428d547c373cc Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 23 Sep 2025 10:01:53 +0200 Subject: [PATCH 139/173] makinf mass fractions a static array --- SU2_CFD/include/fluid/CFluidCantera.hpp | 10 +++++----- SU2_CFD/src/fluid/CFluidCantera.cpp | 14 ++++++-------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 2c270cfdf98c..1d7b01012de6 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -43,7 +43,7 @@ class Solution; /*! * \class CFluidCantera * \brief Child class for defining reacting incompressible ideal gas mixture model. - * \author: T. Economon + * \author: T. Economon, Cristopher Morales Ubal */ class CFluidCantera final : public CFluidModel { private: @@ -52,20 +52,20 @@ class CFluidCantera final : public CFluidModel { const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */ const su2double GasConstant_Ref; /*!< \brief Gas constant reference needed for Nondimensional problems. */ const su2double Prandtl_Number; /*!< \brief Prandlt number.*/ - string chemical_composition; /*!< \brief Dictionary chemical composition. */ const string Transport_Model; /*!< \brief Transport model used for computing mixture properties*/ const string Chemical_MechanismFile; /*!< \brief Chemical reaction mechanism used for in cantera*/ const string Phase_Name; /*!< \brief Name of the phase used for in cantera*/ static constexpr int ARRAYSIZE = 16; - + + su2double Heat_Release; /*!< \brief heat release due to combustion */ std::array gasComposition; /*!< \brief Gas composition. */ std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ std::array chemicalSourceTerm; /*!< \brief chemical source term of all species*/ std::array molarMasses; /*!< \brief Molar masses of all species. */ std::array enthalpyFormation; /*!< \brief Enthalpy of Formation of all species. */ - su2double Heat_Release; /*!< \brief heat release due to combustion */ - std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ + std::array massFractions; /*!< \brief Mass fractions of all species. */ + std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ std::unique_ptr MassDiffusivityPointers[ARRAYSIZE]; /*! diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index cc5966976dce..88b585aa25e5 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -73,14 +73,14 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { /*--- Set mass fractions. ---*/ const int nsp = sol->thermo()->nSpecies(); su2double val_scalars_sum{0.0}; - su2double massFractions[nsp]{0.0}; + massFractions.fill(0.0); for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); massFractions[speciesIndex] =config->GetSpecies_Init()[i_scalar]; val_scalars_sum += config->GetSpecies_Init()[i_scalar]; } massFractions[n_species_mixture - 1] = 1.0 - val_scalars_sum; - sol->thermo()->setMassFractions(massFractions); + sol->thermo()->setMassFractions(massFractions.data()); su2double T_ref = 298.15; sol->thermo()->setState_TP(T_ref, Pressure_Thermodynamic); // The universal gas constant times temperature is retrieved from cantera. @@ -163,16 +163,15 @@ void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusio void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { Temperature = val_temperature; /*--- Set mass fractions. ---*/ - const int nsp = sol->thermo()->nSpecies(); su2double val_scalars_sum{0.0}; - su2double massFractions[nsp]{0.0}; + massFractions.fill(0.0); for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); massFractions[speciesIndex] = val_scalars[i_scalar]; val_scalars_sum += val_scalars[i_scalar]; } massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1.0 - val_scalars_sum; - sol->thermo()->setMassFractions(massFractions); + sol->thermo()->setMassFractions(massFractions.data()); sol->thermo()->setState_TP(Temperature, Pressure_Thermodynamic); Density = sol->thermo()->density(); Enthalpy = sol->thermo()->enthalpy_mass(); @@ -197,16 +196,15 @@ void CFluidCantera::SetTDState_h(const su2double val_enthalpy, const su2double* int counter = 0; /*--- Set mass fractions. ---*/ - const int nsp = sol->thermo()->nSpecies(); su2double val_scalars_sum{0.0}; - su2double massFractions[nsp]{0.0}; + massFractions.fill(0.0); for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); massFractions[speciesIndex] = val_scalars[i_scalar]; val_scalars_sum += val_scalars[speciesIndex]; } massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1.0 - val_scalars_sum; - sol->thermo()->setMassFractions(massFractions); + sol->thermo()->setMassFractions(massFractions.data()); /*--- Computing temperature given enthalpy and species mass fractions using Newton-Raphson. ---*/ while ((abs(delta_temp_iter) > toll) && (counter++ < counter_limit)) { From d98ed4234ff35fa5b5db15896c2991740aa1412d Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 23 Sep 2025 11:50:45 +0200 Subject: [PATCH 140/173] add preaccumulaiton in SetTDState_T --- SU2_CFD/src/fluid/CFluidCantera.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 88b585aa25e5..abbdd5599379 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -171,6 +171,11 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl val_scalars_sum += val_scalars[i_scalar]; } massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1.0 - val_scalars_sum; + + AD::StartPreacc(); + AD::SetPreaccIn(Temperature); + AD::SetPreaccIn(massFractions, ARRAYSIZE); + sol->thermo()->setMassFractions(massFractions.data()); sol->thermo()->setState_TP(Temperature, Pressure_Thermodynamic); Density = sol->thermo()->density(); @@ -180,6 +185,14 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl Mu = sol->transport()->viscosity(); Kt = sol->transport()->thermalConductivity(); + AD::SetPreaccOut(Enthalpy); + AD::SetPreaccOut(Mu); + AD::SetPreaccOut(Kt); + AD::SetPreaccOut(Density); + AD::SetPreaccOut(Cp); + AD::SetPreaccOut(Cv); + AD::EndPreacc(); + ComputeMassDiffusivity(); ComputeHeatRelease(); } From da4ab089d688c6edbd8f9fba2569a49fe0c4bc91 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 24 Sep 2025 11:32:51 +0200 Subject: [PATCH 141/173] updating residuals --- TestCases/parallel_regression.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 3489f7a908f4..4f7e929f0051 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1667,8 +1667,8 @@ def main(): species_active_transport_temp_limits.cfg_dir = "species_transport/passive_transport_validation" species_active_transport_temp_limits.cfg_file = "active_species_transport_temp_limits.cfg" species_active_transport_temp_limits.test_iter = 50 - species_active_transport_temp_limits.test_vals = [-2.340885, -2.257725, -1.926927, -3.236329, 9.000000, -5.006265, 4.000000, -5.931361, 1.646370, 0.993308, 0.000445, 0.652617] - species_active_transport_temp_limits.test_vals_aarch64 = [-2.340885, -2.257725, -1.926927, -3.236329, 9.000000, -5.006265, 4.000000, -5.931361, 1.646370, 0.993308, 0.000445, 0.652617] + species_active_transport_temp_limits.test_vals = [-1.785041, -2.565628, 2.460433, -3.188111, 9.000000, -5.551493, 3.000000, -5.826106, 1.456438, 0.998134, 0.001475, 0.456829] + species_active_transport_temp_limits.test_vals_aarch64 = [-1.785041, -2.565628, 2.460433, -3.188111, 9.000000, -5.551493, 3.000000, -5.826106, 1.456438, 0.998134, 0.001475, 0.456829] test_list.append(species_active_transport_temp_limits) # species transport, 3 species with multizone (2 fluid regions) From 551ef76b271e8e8f5af73eab2128120355a1b523 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Wed, 24 Sep 2025 14:23:34 +0200 Subject: [PATCH 142/173] removing unnecesary pointers --- SU2_CFD/include/fluid/CFluidCantera.hpp | 5 ----- SU2_CFD/src/fluid/CFluidCantera.cpp | 8 -------- 2 files changed, 13 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 1d7b01012de6..820272f0e8b8 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -66,7 +66,6 @@ class CFluidCantera final : public CFluidModel { std::array enthalpyFormation; /*!< \brief Enthalpy of Formation of all species. */ std::array massFractions; /*!< \brief Mass fractions of all species. */ std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ - std::unique_ptr MassDiffusivityPointers[ARRAYSIZE]; /*! * \brief Compute mass diffusivity for species. @@ -91,10 +90,6 @@ class CFluidCantera final : public CFluidModel { CFluidCantera(su2double val_operating_pressure, const CConfig* config); #ifdef USE_CANTERA - /*! - * \brief Set mass diffusivity model. - */ - void SetMassDiffusivityModel(const CConfig* config) override; /*! * \brief Get fluid laminar viscosity. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index abbdd5599379..953221858df7 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -59,14 +59,6 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* gasComposition[iVar] = config->GetChemical_GasComposition(iVar); } SetEnthalpyFormation(config); - - SetMassDiffusivityModel(config); -} - -void CFluidCantera::SetMassDiffusivityModel(const CConfig* config) { - for (int iVar = 0; iVar < n_species_mixture; iVar++) { - MassDiffusivityPointers[iVar] = MakeMassDiffusivityModel(config, iVar); - } } void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { From a2cf4fd2b932586886dea9be9784504f8f382144 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 3 Oct 2025 13:32:30 +0200 Subject: [PATCH 143/173] fixing spark ignition --- SU2_CFD/include/solvers/CIncNSSolver.hpp | 1 + SU2_CFD/src/solvers/CIncNSSolver.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/include/solvers/CIncNSSolver.hpp b/SU2_CFD/include/solvers/CIncNSSolver.hpp index b5bd6d46a5b3..c12c96be41ec 100644 --- a/SU2_CFD/include/solvers/CIncNSSolver.hpp +++ b/SU2_CFD/include/solvers/CIncNSSolver.hpp @@ -37,6 +37,7 @@ */ class CIncNSSolver final : public CIncEulerSolver { FluidFlamelet_ParsedOptions flamelet_config_options; + su2double TemperatureLimits[2]; /*! * \brief Generic implementation of the isothermal, heatflux and heat-transfer/convection walls. diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 5ea089ea02fc..096a4be4210e 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -42,6 +42,8 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short Viscosity_Inf = config->GetViscosity_FreeStreamND(); Tke_Inf = config->GetTke_FreeStreamND(); + TemperatureLimits[0]= config->GetTemperatureLimits(0); + TemperatureLimits[1]= config->GetTemperatureLimits(1); /*--- Initialize the secondary values for direct derivative approximations ---*/ @@ -103,7 +105,7 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container /*--- retrieve scalars solution. ---*/ su2double* scalars = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(i_point); /*--- Set high temperature for ignition. ---*/ - nodes->SetTemperature(i_point, config->GetSpark_Temperature()); + nodes->SetTemperature(i_point, config->GetSpark_Temperature(), TemperatureLimits); /*--- Set thermodynamic state at high temeprature. ---*/ fluid_model_local->SetTDState_T(config->GetSpark_Temperature(), scalars); /*--- Set total enthalpy at high temperature. ---*/ From 8becc616afaec92b9c3ab11b577c1727cba8399c Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 6 Oct 2025 08:55:10 +0200 Subject: [PATCH 144/173] comment out setPreacc on SetTDState in CFluidCantera.cpp --- SU2_CFD/include/fluid/CFluidCantera.hpp | 1 + SU2_CFD/src/fluid/CFluidCantera.cpp | 25 +++++++++++++------------ SU2_CFD/src/solvers/CIncEulerSolver.cpp | 24 ++---------------------- 3 files changed, 16 insertions(+), 34 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 820272f0e8b8..12c192c2f376 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -66,6 +66,7 @@ class CFluidCantera final : public CFluidModel { std::array enthalpyFormation; /*!< \brief Enthalpy of Formation of all species. */ std::array massFractions; /*!< \brief Mass fractions of all species. */ std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ + vector enthalpiesSpecies; /*! * \brief Compute mass diffusivity for species. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 953221858df7..90cd324ad5bd 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -58,6 +58,7 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* for (int iVar = 0; iVar < n_species_mixture; iVar++) { gasComposition[iVar] = config->GetChemical_GasComposition(iVar); } + enthalpiesSpecies.resize(sol->thermo()->nSpecies()); SetEnthalpyFormation(config); } @@ -77,7 +78,7 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { sol->thermo()->setState_TP(T_ref, Pressure_Thermodynamic); // The universal gas constant times temperature is retrieved from cantera. const su2double uni_gas_constant_temp = sol->thermo()->RT(); - vector enthalpiesSpecies(nsp); + //vector enthalpiesSpecies(nsp); sol->thermo()->getEnthalpy_RT_ref(&enthalpiesSpecies[0]); for (int iVar = 0; iVar < n_species_mixture; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); @@ -120,7 +121,7 @@ void CFluidCantera::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) { const int nsp = sol->thermo()->nSpecies(); // The universal gas constant times temperature is retrieved from cantera. const su2double uni_gas_constant_temp = sol->thermo()->RT(); - vector enthalpiesSpecies(nsp); + //vector enthalpiesSpecies(nsp); sol->thermo()->getEnthalpy_RT_ref(&enthalpiesSpecies[0]); const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { @@ -164,9 +165,9 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl } massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1.0 - val_scalars_sum; - AD::StartPreacc(); - AD::SetPreaccIn(Temperature); - AD::SetPreaccIn(massFractions, ARRAYSIZE); + // AD::StartPreacc(); + // AD::SetPreaccIn(Temperature); + // AD::SetPreaccIn(massFractions, ARRAYSIZE); sol->thermo()->setMassFractions(massFractions.data()); sol->thermo()->setState_TP(Temperature, Pressure_Thermodynamic); @@ -177,13 +178,13 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl Mu = sol->transport()->viscosity(); Kt = sol->transport()->thermalConductivity(); - AD::SetPreaccOut(Enthalpy); - AD::SetPreaccOut(Mu); - AD::SetPreaccOut(Kt); - AD::SetPreaccOut(Density); - AD::SetPreaccOut(Cp); - AD::SetPreaccOut(Cv); - AD::EndPreacc(); + // AD::SetPreaccOut(Enthalpy); + // AD::SetPreaccOut(Mu); + // AD::SetPreaccOut(Kt); + // AD::SetPreaccOut(Density); + // AD::SetPreaccOut(Cp); + // AD::SetPreaccOut(Cv); + // AD::EndPreacc(); ComputeMassDiffusivity(); ComputeHeatRelease(); diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 38599a5c77b7..ff7f3da009c7 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -173,28 +173,8 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned Temperature_Inf = config->GetTemperature_FreeStreamND(); if (energy_multicomponent) { const su2double* scalar_init = config->GetSpecies_Init(); - CFluidModel* auxFluidModel = nullptr; - - switch (config->GetKind_FluidModel()) { - case FLUID_MIXTURE: - - auxFluidModel = new CFluidScalar(config->GetPressure_Thermodynamic(), config); - auxFluidModel->SetTDState_T(Temperature_Inf, scalar_init); // compute total enthalpy from temperature - Enthalpy_Inf = auxFluidModel->GetEnthalpy(); - break; - - case FLUID_CANTERA: - - auxFluidModel = new CFluidCantera(config->GetPressure_Thermodynamic(), config); - auxFluidModel->SetTDState_T(Temperature_Inf, scalar_init); // compute total enthalpy from temperature - Enthalpy_Inf = auxFluidModel->GetEnthalpy(); - break; - - default: - - SU2_MPI::Error("Fluid model not compatible with multicomponent-reacting flows.", CURRENT_FUNCTION); - break; - } + GetFluidModel()->SetTDState_T(Temperature_Inf,scalar_init); + Enthalpy_Inf = GetFluidModel()->GetEnthalpy(); } /*--- Initialize the secondary values for direct derivative approxiations ---*/ From f297c97d3b067c6dba33752ef8559e0f57a1400f Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 10 Oct 2025 14:17:29 +0200 Subject: [PATCH 145/173] adding vector enthalpiesSpecies and specificHeatSpecies --- SU2_CFD/include/fluid/CFluidCantera.hpp | 3 ++- SU2_CFD/src/fluid/CFluidCantera.cpp | 7 +------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 12c192c2f376..80d656323fc0 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -66,7 +66,8 @@ class CFluidCantera final : public CFluidModel { std::array enthalpyFormation; /*!< \brief Enthalpy of Formation of all species. */ std::array massFractions; /*!< \brief Mass fractions of all species. */ std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ - vector enthalpiesSpecies; + vector enthalpiesSpecies; /*!< \brief Molar enthalpies of all species. */ + vector specificHeatSpecies; /*!< \brief Molar heat capacities of all species. */ /*! * \brief Compute mass diffusivity for species. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 90cd324ad5bd..dd98ad8eb56e 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -59,12 +59,12 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* gasComposition[iVar] = config->GetChemical_GasComposition(iVar); } enthalpiesSpecies.resize(sol->thermo()->nSpecies()); + specificHeatSpecies.resize(sol->thermo()->nSpecies()); SetEnthalpyFormation(config); } void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { /*--- Set mass fractions. ---*/ - const int nsp = sol->thermo()->nSpecies(); su2double val_scalars_sum{0.0}; massFractions.fill(0.0); for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { @@ -78,7 +78,6 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { sol->thermo()->setState_TP(T_ref, Pressure_Thermodynamic); // The universal gas constant times temperature is retrieved from cantera. const su2double uni_gas_constant_temp = sol->thermo()->RT(); - //vector enthalpiesSpecies(nsp); sol->thermo()->getEnthalpy_RT_ref(&enthalpiesSpecies[0]); for (int iVar = 0; iVar < n_species_mixture; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); @@ -118,10 +117,8 @@ void CFluidCantera::ComputeHeatRelease() { } void CFluidCantera::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) { - const int nsp = sol->thermo()->nSpecies(); // The universal gas constant times temperature is retrieved from cantera. const su2double uni_gas_constant_temp = sol->thermo()->RT(); - //vector enthalpiesSpecies(nsp); sol->thermo()->getEnthalpy_RT_ref(&enthalpiesSpecies[0]); const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { @@ -139,10 +136,8 @@ void CFluidCantera::GetMassCorrectionDiffusivity(su2double* massCorrection_diffu } void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusions) { - const int nsp = sol->thermo()->nSpecies(); // The universal gas constant is retrieved from cantera,in order to keep consistency with the values retrieve from it. const su2double universal_gas_constant = (sol->thermo()->RT()) / Temperature; - vector specificHeatSpecies(nsp); sol->thermo()->getCp_R_ref(&specificHeatSpecies[0]); const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { From 34077554fd565d8dee3b60585fe5354476f56746 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 31 Oct 2025 09:56:53 +0100 Subject: [PATCH 146/173] fixing iDim --- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 1e497a515a29..b288a1401e0f 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1367,7 +1367,7 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont su2double Project_Grad_Enthalpy_i = 0.0; su2double Project_Grad_Enthalpy_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { + for (auto iDim = 0; iDim < nDim; iDim++) { Project_Grad_Enthalpy_i += Vector_ij[iDim] * nodes->GetAuxVarGradient(iPoint, 1, iDim); Project_Grad_Enthalpy_j -= Vector_ij[iDim] * nodes->GetAuxVarGradient(jPoint, 1, iDim); } From 7ec5676be08e7d62ad438081d6a154522f657c08 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 31 Oct 2025 11:04:32 +0100 Subject: [PATCH 147/173] adding strong maker for isothermal wall --- SU2_CFD/include/solvers/CIncNSSolver.hpp | 6 +- SU2_CFD/src/solvers/CIncNSSolver.cpp | 73 ++++++++++++++---------- 2 files changed, 46 insertions(+), 33 deletions(-) diff --git a/SU2_CFD/include/solvers/CIncNSSolver.hpp b/SU2_CFD/include/solvers/CIncNSSolver.hpp index c12c96be41ec..5a6f3bfb2de2 100644 --- a/SU2_CFD/include/solvers/CIncNSSolver.hpp +++ b/SU2_CFD/include/solvers/CIncNSSolver.hpp @@ -42,10 +42,8 @@ class CIncNSSolver final : public CIncEulerSolver { /*! * \brief Generic implementation of the isothermal, heatflux and heat-transfer/convection walls. */ - void BC_Wall_Generic(const CGeometry *geometry, - const CConfig *config, - unsigned short val_marker, - unsigned short kind_boundary); + void BC_Wall_Generic(const CGeometry* geometry, CSolver** solver_container, const CConfig* config, + unsigned short val_marker, unsigned short kind_boundary); /*! * \brief Compute the velocity^2, SoundSpeed, Pressure, Enthalpy, Viscosity. diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 096a4be4210e..c5b684d9eda2 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -496,7 +496,7 @@ unsigned long CIncNSSolver::SetPrimitive_Variables(CSolver **solver_container, c } -void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *config, +void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, CSolver** solver_container, const CConfig *config, unsigned short val_marker, unsigned short kind_boundary) { const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); @@ -634,36 +634,54 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con if (py_custom) { Twall = geometry->GetCustomBoundaryTemperature(val_marker, iVertex) / config->GetTemperature_Ref(); } - const auto Point_Normal = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); + if (config->GetMarker_StrongBC(Marker_Tag) == true) { + /*--- Strong imposition of the temperature. ---*/ + LinSysRes(iPoint, nDim + 1) = 0.0; + if (multicomponent) { + /*--- Retrieve scalars at wall node. ---*/ + su2double* scalars = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint); + /*--- Retrieve fluid model. ---*/ + CFluidModel* fluid_model_local = solver_container[FLOW_SOL]->GetFluidModel(); + /*--- Set thermodynamic state given wall temperature and species composition. ---*/ + fluid_model_local->SetTDState_T(Twall, scalars); + /*--- Set enthalpy obtained from fluid model. ---*/ + nodes->SetSolution_Old(iPoint, nDim + 1, fluid_model_local->GetEnthalpy()); + } else { + nodes->SetSolution_Old(iPoint, nDim + 1, Twall); + } + nodes->SetEnergy_ResTruncError_Zero(iPoint); + } else { + /*--- Apply a weak boundary condition for the energy equation. ---*/ + const auto Point_Normal = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); - /*--- Get coordinates of i & nearest normal and compute distance ---*/ + /*--- Get coordinates of i & nearest normal and compute distance ---*/ - const auto Coord_i = geometry->nodes->GetCoord(iPoint); - const auto Coord_j = geometry->nodes->GetCoord(Point_Normal); - su2double UnitNormal[MAXNDIM] = {0.0}; - for (auto iDim = 0u; iDim < nDim; ++iDim) UnitNormal[iDim] = Normal[iDim] / Area; - const su2double dist_ij = GeometryToolbox::NormalDistance(nDim, UnitNormal, Coord_i, Coord_j); + const auto Coord_i = geometry->nodes->GetCoord(iPoint); + const auto Coord_j = geometry->nodes->GetCoord(Point_Normal); + su2double UnitNormal[MAXNDIM] = {0.0}; + for (auto iDim = 0u; iDim < nDim; ++iDim) UnitNormal[iDim] = Normal[iDim] / Area; + const su2double dist_ij = GeometryToolbox::NormalDistance(nDim, UnitNormal, Coord_i, Coord_j); - /*--- Compute the normal gradient in temperature using Twall ---*/ + /*--- Compute the normal gradient in temperature using Twall ---*/ - const su2double dTdn = -(nodes->GetTemperature(Point_Normal) - Twall)/dist_ij; + const su2double dTdn = -(nodes->GetTemperature(Point_Normal) - Twall) / dist_ij; - /*--- Get thermal conductivity ---*/ - const su2double thermal_conductivity = nodes->GetThermalConductivity(iPoint); + /*--- Get thermal conductivity ---*/ + const su2double thermal_conductivity = nodes->GetThermalConductivity(iPoint); - /*--- Apply a weak boundary condition for the energy equation. - Compute the residual due to the prescribed heat flux. ---*/ + /*--- Compute the residual due to the prescribed heat flux. ---*/ - LinSysRes(iPoint, nDim+1) -= thermal_conductivity*dTdn*Area; + LinSysRes(iPoint, nDim + 1) -= thermal_conductivity * dTdn * Area; - /*--- Jacobian contribution for temperature equation. ---*/ + /*--- Jacobian contribution for temperature equation. ---*/ - if (implicit) { - if (multicomponent) { - const su2double Cp = nodes->GetSpecificHeatCp(iPoint); - Jacobian.AddVal2Diag(iPoint, nDim + 1, thermal_conductivity * Area / (dist_ij * Cp)); - } else { - Jacobian.AddVal2Diag(iPoint, nDim + 1, thermal_conductivity * Area / dist_ij); + if (implicit) { + if (multicomponent) { + const su2double Cp = nodes->GetSpecificHeatCp(iPoint); + Jacobian.AddVal2Diag(iPoint, nDim + 1, thermal_conductivity * Area / (dist_ij * Cp)); + } else { + Jacobian.AddVal2Diag(iPoint, nDim + 1, thermal_conductivity * Area / dist_ij); + } } } break; @@ -674,19 +692,16 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con void CIncNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver**, CNumerics*, CNumerics*, CConfig *config, unsigned short val_marker) { - - BC_Wall_Generic(geometry, config, val_marker, HEAT_FLUX); + BC_Wall_Generic(geometry, nullptr, config, val_marker, HEAT_FLUX); } -void CIncNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver**, CNumerics*, +void CIncNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver** solver_container, CNumerics*, CNumerics*, CConfig *config, unsigned short val_marker) { - - BC_Wall_Generic(geometry, config, val_marker, ISOTHERMAL); + BC_Wall_Generic(geometry, solver_container, config, val_marker, ISOTHERMAL); } void CIncNSSolver::BC_HeatTransfer_Wall(const CGeometry *geometry, const CConfig *config, const unsigned short val_marker) { - - BC_Wall_Generic(geometry, config, val_marker, HEAT_TRANSFER); + BC_Wall_Generic(geometry, nullptr, config, val_marker, HEAT_TRANSFER); } void CIncNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, From b6e86786a196cf50bc50590c9100bb7f550e6822 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 19 Dec 2025 16:35:20 +0100 Subject: [PATCH 148/173] updating cantera for turbulence and adding flag for combustion --- SU2_CFD/include/fluid/CFluidCantera.hpp | 6 ++- SU2_CFD/src/fluid/CFluidCantera.cpp | 48 ++++++++++--------- .../species2_primitiveVenturi_CANTERA.cfg | 10 ++-- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 2b1993fdc9e4..7b8ceb9bcb6f 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -51,10 +51,12 @@ class CFluidCantera final : public CFluidModel { const int n_species_mixture; /*!< \brief Number of species in mixture. */ const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */ const su2double GasConstant_Ref; /*!< \brief Gas constant reference needed for Nondimensional problems. */ - const su2double Prandtl_Number; /*!< \brief Prandlt number.*/ + const su2double Prandtl_Turb_Number; /*!< \brief Prandlt turbulent number.*/ + const su2double Schmidt_Turb_Number; /*!< \brief Schmidt turbulent number.*/ const string Transport_Model; /*!< \brief Transport model used for computing mixture properties*/ const string Chemical_MechanismFile; /*!< \brief Chemical reaction mechanism used for in cantera*/ const string Phase_Name; /*!< \brief Name of the phase used for in cantera*/ + const bool Combustion; /*!< \brief Flag for problems involving combustion.*/ static constexpr int ARRAYSIZE = 16; @@ -101,7 +103,7 @@ class CFluidCantera final : public CFluidModel { /*! * \brief Get fluid thermal conductivity. */ - inline su2double GetThermalConductivity() override { return Kt + Mu_Turb * Cp / Prandtl_Number; } + inline su2double GetThermalConductivity() override { return Kt + Mu_Turb * Cp / Prandtl_Turb_Number; } /*! * \brief Get fluid mass diffusivity. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 4afd2efeabaa..17cae9b98fbf 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -46,10 +46,12 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* n_species_mixture(config->GetnSpecies() + 1), Pressure_Thermodynamic(value_pressure_operating), GasConstant_Ref(config->GetGas_Constant_Ref()), - Prandtl_Number(config->GetPrandtl_Turb()), + Prandtl_Turb_Number(config->GetPrandtl_Turb()), + Schmidt_Turb_Number(config->GetSchmidt_Number_Turbulent()), Transport_Model(config->GetTransport_Model()), Chemical_MechanismFile(config->GetChemical_MechanismFile()), - Phase_Name(config->GetPhase_Name()){ + Phase_Name(config->GetPhase_Name()), + Combustion(config->GetCombustion()) { if (n_species_mixture > ARRAYSIZE) { SU2_MPI::Error("Too many species, increase ARRAYSIZE", CURRENT_FUNCTION); } @@ -60,7 +62,7 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* } enthalpiesSpecies.resize(sol->thermo()->nSpecies()); specificHeatSpecies.resize(sol->thermo()->nSpecies()); - SetEnthalpyFormation(config); + if (Combustion) SetEnthalpyFormation(config); } void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { @@ -72,7 +74,7 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { massFractions[speciesIndex] =config->GetSpecies_Init()[i_scalar]; val_scalars_sum += config->GetSpecies_Init()[i_scalar]; } - massFractions[n_species_mixture - 1] = 1.0 - val_scalars_sum; + massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1.0 - val_scalars_sum; sol->thermo()->setMassFractions(massFractions.data()); su2double T_ref = 298.15; sol->thermo()->setState_TP(T_ref, Pressure_Thermodynamic); @@ -123,9 +125,15 @@ void CFluidCantera::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) const const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - enthalpy_diffusions[iVar] = Density * uni_gas_constant_temp * - ((enthalpiesSpecies[speciesIndex] * massDiffusivity[iVar] / molarMasses[speciesIndex]) - - (enthalpiesSpecies[speciesN] * massDiffusivity[n_species_mixture - 1] / molarMasses[speciesN])); + enthalpy_diffusions[iVar] = + Density * uni_gas_constant_temp * + ((enthalpiesSpecies[speciesIndex] * massDiffusivity[iVar] / molarMasses[speciesIndex]) - + (enthalpiesSpecies[speciesN] * massDiffusivity[n_species_mixture - 1] / molarMasses[speciesN])); + enthalpy_diffusions[iVar] += + Mu_Turb * uni_gas_constant_temp * + ((enthalpiesSpecies[speciesIndex] / molarMasses[speciesIndex]) - + (enthalpiesSpecies[speciesN] * massDiffusivity[n_species_mixture - 1] / molarMasses[speciesN])) / + Schmidt_Turb_Number; } } @@ -142,9 +150,15 @@ void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusio const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - grad_enthalpy_diffusions[iVar] = Density * universal_gas_constant * - ((specificHeatSpecies[speciesIndex] * massDiffusivity[iVar] / molarMasses[speciesIndex]) - - (specificHeatSpecies[speciesN] * massDiffusivity[n_species_mixture - 1] / molarMasses[speciesN])); + grad_enthalpy_diffusions[iVar] = + Density * universal_gas_constant * + ((specificHeatSpecies[speciesIndex] * massDiffusivity[iVar] / molarMasses[speciesIndex]) - + (specificHeatSpecies[speciesN] * massDiffusivity[n_species_mixture - 1] / molarMasses[speciesN])); + grad_enthalpy_diffusions[iVar] += + Mu_Turb * universal_gas_constant * + ((specificHeatSpecies[speciesIndex] / molarMasses[speciesIndex]) - + (specificHeatSpecies[speciesN] / molarMasses[speciesN])) / + Schmidt_Turb_Number; } } @@ -160,10 +174,6 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl } massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1.0 - val_scalars_sum; - // AD::StartPreacc(); - // AD::SetPreaccIn(Temperature); - // AD::SetPreaccIn(massFractions, ARRAYSIZE); - sol->thermo()->setMassFractions(massFractions.data()); sol->thermo()->setState_TP(Temperature, Pressure_Thermodynamic); Density = sol->thermo()->density(); @@ -173,16 +183,8 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl Mu = sol->transport()->viscosity(); Kt = sol->transport()->thermalConductivity(); - // AD::SetPreaccOut(Enthalpy); - // AD::SetPreaccOut(Mu); - // AD::SetPreaccOut(Kt); - // AD::SetPreaccOut(Density); - // AD::SetPreaccOut(Cp); - // AD::SetPreaccOut(Cv); - // AD::EndPreacc(); - ComputeMassDiffusivity(); - ComputeHeatRelease(); + if (Combustion) ComputeHeatRelease(); } void CFluidCantera::SetTDState_h(const su2double val_enthalpy, const su2double* val_scalars) { diff --git a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg index 1fcd86c880d2..70b917836f5b 100644 --- a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg +++ b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg @@ -23,7 +23,7 @@ INC_DENSITY_INIT= 1.1766 % INC_VELOCITY_INIT= ( 1.00, 0.0, 0.0 ) % -INC_ENERGY_EQUATION= NO +INC_ENERGY_EQUATION= YES INC_TEMPERATURE_INIT= 300.0 % INC_NONDIM= DIMENSIONAL @@ -67,9 +67,9 @@ SPECIFIED_INLET_PROFILE= NO INLET_FILENAME= inlet_venturi.dat INC_INLET_TYPE= VELOCITY_INLET VELOCITY_INLET MARKER_INLET= ( gas_inlet, 300, 1.0, 1.0, 0.0, 0.0,\ - air_axial_inlet, 300, 1.0, 0.0, -1.0, 0.0 ) -MARKER_INLET_SPECIES= (gas_inlet, 0.5,\ - air_axial_inlet, 0.6) + air_axial_inlet, 350, 1.0, 0.0, -1.0, 0.0 ) +MARKER_INLET_SPECIES= (gas_inlet, 0.5,\ + air_axial_inlet, 0.6) % INC_OUTLET_TYPE= PRESSURE_OUTLET MARKER_OUTLET= ( outlet, 0.0) @@ -110,7 +110,7 @@ SLOPE_LIMITER_SPECIES = NONE % TIME_DISCRE_SPECIES= EULER_IMPLICIT % -SPECIES_INIT= 1.0 +SPECIES_INIT= 0.5 SPECIES_CLIPPING= NO SPECIES_CLIPPING_MIN= 0.0 SPECIES_CLIPPING_MAX= 1.0 From eccf97291f193998cbc0a12ef3307825210c1121 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 19 Dec 2025 21:26:57 +0100 Subject: [PATCH 149/173] adding speciesIndices --- SU2_CFD/include/fluid/CFluidCantera.hpp | 6 +-- SU2_CFD/src/fluid/CFluidCantera.cpp | 61 +++++++++++-------------- 2 files changed, 30 insertions(+), 37 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 7b8ceb9bcb6f..ccb49dd1e0d7 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -61,15 +61,15 @@ class CFluidCantera final : public CFluidModel { static constexpr int ARRAYSIZE = 16; su2double Heat_Release; /*!< \brief heat release due to combustion */ - std::array gasComposition; /*!< \brief Gas composition. */ + std::array speciesIndices; /*!< \brief Species indices within Cantera library. */ std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ std::array chemicalSourceTerm; /*!< \brief chemical source term of all species*/ std::array molarMasses; /*!< \brief Molar masses of all species. */ std::array enthalpyFormation; /*!< \brief Enthalpy of Formation of all species. */ std::array massFractions; /*!< \brief Mass fractions of all species. */ std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ - mutable vector enthalpiesSpecies; /*!< \brief Molar enthalpies of all species. */ - mutable vector specificHeatSpecies; /*!< \brief Molar heat capacities of all species. */ + mutable vector enthalpiesSpecies; /*!< \brief Molar enthalpies of all species. */ + mutable vector specificHeatSpecies; /*!< \brief Molar heat capacities of all species. */ /*! * \brief Compute mass diffusivity for species. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 17cae9b98fbf..3a235d9ffee1 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -58,7 +58,7 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* sol = std::shared_ptr(newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model)); sol->thermo()->getMolecularWeights(&molarMasses[0]); for (int iVar = 0; iVar < n_species_mixture; iVar++) { - gasComposition[iVar] = config->GetChemical_GasComposition(iVar); + speciesIndices[iVar] = sol->thermo()->speciesIndex(config->GetChemical_GasComposition(iVar)); } enthalpiesSpecies.resize(sol->thermo()->nSpecies()); specificHeatSpecies.resize(sol->thermo()->nSpecies()); @@ -70,11 +70,10 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { su2double val_scalars_sum{0.0}; massFractions.fill(0.0); for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { - int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); - massFractions[speciesIndex] =config->GetSpecies_Init()[i_scalar]; + massFractions[speciesIndices[i_scalar]] =config->GetSpecies_Init()[i_scalar]; val_scalars_sum += config->GetSpecies_Init()[i_scalar]; } - massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1.0 - val_scalars_sum; + massFractions[speciesIndices[n_species_mixture - 1]] = 1.0 - val_scalars_sum; sol->thermo()->setMassFractions(massFractions.data()); su2double T_ref = 298.15; sol->thermo()->setState_TP(T_ref, Pressure_Thermodynamic); @@ -82,8 +81,8 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { const su2double uni_gas_constant_temp = sol->thermo()->RT(); sol->thermo()->getEnthalpy_RT_ref(enthalpiesSpecies.data()); for (int iVar = 0; iVar < n_species_mixture; iVar++) { - int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - enthalpyFormation[iVar] = uni_gas_constant_temp * enthalpiesSpecies[speciesIndex] / molarMasses[speciesIndex]; + enthalpyFormation[iVar] = + uni_gas_constant_temp * enthalpiesSpecies[speciesIndices[iVar]] / molarMasses[speciesIndices[iVar]]; } } @@ -92,7 +91,7 @@ void CFluidCantera::ComputeMassDiffusivity() { vector diff(nsp); sol->transport()->getMixDiffCoeffsMass(&diff[0]); for (int iVar = 0; iVar < n_species_mixture; iVar++) { - massDiffusivity[iVar] = diff[sol->thermo()->speciesIndex(gasComposition[iVar])]; + massDiffusivity[iVar] = diff[speciesIndices[iVar]]; } } @@ -101,8 +100,7 @@ void CFluidCantera::ComputeChemicalSourceTerm(const su2double* val_scalars) { vector netProductionRates(nsp); sol->kinetics()->getNetProductionRates(&netProductionRates[0]); for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { - int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); - chemicalSourceTerm[iVar] = molarMasses[speciesIndex] * netProductionRates[speciesIndex]; + chemicalSourceTerm[iVar] = molarMasses[speciesIndices[iVar]] * netProductionRates[speciesIndices[iVar]]; } } @@ -112,9 +110,8 @@ void CFluidCantera::ComputeHeatRelease() { sol->kinetics()->getNetProductionRates(&netProductionRates[0]); Heat_Release = 0.0; for (int iVar = 0; iVar < n_species_mixture; iVar++) { - int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); Heat_Release += - -1.0 * enthalpyFormation[speciesIndex] * molarMasses[speciesIndex] * netProductionRates[speciesIndex]; + -1.0 * enthalpyFormation[iVar] * molarMasses[speciesIndices[iVar]] * netProductionRates[speciesIndices[iVar]]; } } @@ -122,18 +119,17 @@ void CFluidCantera::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) const // The universal gas constant times temperature is retrieved from cantera. const su2double uni_gas_constant_temp = sol->thermo()->RT(); sol->thermo()->getEnthalpy_RT_ref(enthalpiesSpecies.data()); - const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { - int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); enthalpy_diffusions[iVar] = Density * uni_gas_constant_temp * - ((enthalpiesSpecies[speciesIndex] * massDiffusivity[iVar] / molarMasses[speciesIndex]) - - (enthalpiesSpecies[speciesN] * massDiffusivity[n_species_mixture - 1] / molarMasses[speciesN])); + ((enthalpiesSpecies[speciesIndices[iVar]] * massDiffusivity[iVar] / molarMasses[speciesIndices[iVar]]) - + (enthalpiesSpecies[speciesIndices[n_species_mixture - 1]] * massDiffusivity[n_species_mixture - 1] / + molarMasses[speciesIndices[n_species_mixture - 1]])); enthalpy_diffusions[iVar] += Mu_Turb * uni_gas_constant_temp * - ((enthalpiesSpecies[speciesIndex] / molarMasses[speciesIndex]) - - (enthalpiesSpecies[speciesN] * massDiffusivity[n_species_mixture - 1] / molarMasses[speciesN])) / - Schmidt_Turb_Number; + ((enthalpiesSpecies[speciesIndices[iVar]] / molarMasses[speciesIndices[iVar]]) - + (enthalpiesSpecies[speciesIndices[n_species_mixture - 1]] * massDiffusivity[n_species_mixture - 1] / + molarMasses[speciesIndices[n_species_mixture - 1]])) / Schmidt_Turb_Number; } } @@ -147,18 +143,17 @@ void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusio // The universal gas constant is retrieved from cantera,in order to keep consistency with the values retrieve from it. const su2double universal_gas_constant = (sol->thermo()->RT()) / Temperature; sol->thermo()->getCp_R_ref(specificHeatSpecies.data()); - const int speciesN = sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1]); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { - int speciesIndex = sol->thermo()->speciesIndex(gasComposition[iVar]); grad_enthalpy_diffusions[iVar] = Density * universal_gas_constant * - ((specificHeatSpecies[speciesIndex] * massDiffusivity[iVar] / molarMasses[speciesIndex]) - - (specificHeatSpecies[speciesN] * massDiffusivity[n_species_mixture - 1] / molarMasses[speciesN])); - grad_enthalpy_diffusions[iVar] += - Mu_Turb * universal_gas_constant * - ((specificHeatSpecies[speciesIndex] / molarMasses[speciesIndex]) - - (specificHeatSpecies[speciesN] / molarMasses[speciesN])) / - Schmidt_Turb_Number; + ((specificHeatSpecies[speciesIndices[iVar]] * massDiffusivity[iVar] / molarMasses[speciesIndices[iVar]]) - + (specificHeatSpecies[speciesIndices[n_species_mixture - 1]] * massDiffusivity[n_species_mixture - 1] / + molarMasses[speciesIndices[n_species_mixture - 1]])); + grad_enthalpy_diffusions[iVar] += Mu_Turb * universal_gas_constant * + ((specificHeatSpecies[speciesIndices[iVar]] / molarMasses[speciesIndices[iVar]]) - + (specificHeatSpecies[speciesIndices[n_species_mixture - 1]] / + molarMasses[speciesIndices[n_species_mixture - 1]])) / + Schmidt_Turb_Number; } } @@ -168,11 +163,10 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl su2double val_scalars_sum{0.0}; massFractions.fill(0.0); for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { - int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); - massFractions[speciesIndex] = val_scalars[i_scalar]; + massFractions[speciesIndices[i_scalar]] = val_scalars[i_scalar]; val_scalars_sum += val_scalars[i_scalar]; } - massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1.0 - val_scalars_sum; + massFractions[speciesIndices[n_species_mixture - 1]] = 1.0 - val_scalars_sum; sol->thermo()->setMassFractions(massFractions.data()); sol->thermo()->setState_TP(Temperature, Pressure_Thermodynamic); @@ -202,11 +196,10 @@ void CFluidCantera::SetTDState_h(const su2double val_enthalpy, const su2double* su2double val_scalars_sum{0.0}; massFractions.fill(0.0); for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { - int speciesIndex = sol->thermo()->speciesIndex(gasComposition[i_scalar]); - massFractions[speciesIndex] = val_scalars[i_scalar]; - val_scalars_sum += val_scalars[speciesIndex]; + massFractions[speciesIndices[i_scalar]] = val_scalars[i_scalar]; + val_scalars_sum += val_scalars[i_scalar]; } - massFractions[sol->thermo()->speciesIndex(gasComposition[n_species_mixture - 1])] = 1.0 - val_scalars_sum; + massFractions[speciesIndices[n_species_mixture - 1]] = 1.0 - val_scalars_sum; sol->thermo()->setMassFractions(massFractions.data()); /*--- Computing temperature given enthalpy and species mass fractions using Newton-Raphson. ---*/ From 8f01f3e160d4dafdc95ef12b6ef435ac304fa199 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Fri, 19 Dec 2025 22:16:48 +0100 Subject: [PATCH 150/173] adding SetMassFractions function --- SU2_CFD/include/fluid/CFluidCantera.hpp | 8 +++++++- SU2_CFD/src/fluid/CFluidCantera.cpp | 26 ++++++++----------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index ccb49dd1e0d7..e99e2b814e17 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -85,7 +85,13 @@ class CFluidCantera final : public CFluidModel { * \brief Set enthalpies of formation. */ void SetEnthalpyFormation(const CConfig* config); - #endif + + /*! + * \brief Set species mass fraction array for Cantera. + * \param[in] val_scalars - Scalar mass fractions. + */ + void SetMassFractions(const su2double* val_scalars); +#endif public: /*! diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 3a235d9ffee1..ccf21efc4e31 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -66,14 +66,7 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* } void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { - /*--- Set mass fractions. ---*/ - su2double val_scalars_sum{0.0}; - massFractions.fill(0.0); - for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { - massFractions[speciesIndices[i_scalar]] =config->GetSpecies_Init()[i_scalar]; - val_scalars_sum += config->GetSpecies_Init()[i_scalar]; - } - massFractions[speciesIndices[n_species_mixture - 1]] = 1.0 - val_scalars_sum; + SetMassFractions(config->GetSpecies_Init()); sol->thermo()->setMassFractions(massFractions.data()); su2double T_ref = 298.15; sol->thermo()->setState_TP(T_ref, Pressure_Thermodynamic); @@ -157,9 +150,7 @@ void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusio } } -void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { - Temperature = val_temperature; - /*--- Set mass fractions. ---*/ +void CFluidCantera::SetMassFractions(const su2double* val_scalars) { su2double val_scalars_sum{0.0}; massFractions.fill(0.0); for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { @@ -167,6 +158,11 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl val_scalars_sum += val_scalars[i_scalar]; } massFractions[speciesIndices[n_species_mixture - 1]] = 1.0 - val_scalars_sum; +} + +void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { + Temperature = val_temperature; + SetMassFractions(val_scalars); sol->thermo()->setMassFractions(massFractions.data()); sol->thermo()->setState_TP(Temperature, Pressure_Thermodynamic); @@ -193,13 +189,7 @@ void CFluidCantera::SetTDState_h(const su2double val_enthalpy, const su2double* int counter = 0; /*--- Set mass fractions. ---*/ - su2double val_scalars_sum{0.0}; - massFractions.fill(0.0); - for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { - massFractions[speciesIndices[i_scalar]] = val_scalars[i_scalar]; - val_scalars_sum += val_scalars[i_scalar]; - } - massFractions[speciesIndices[n_species_mixture - 1]] = 1.0 - val_scalars_sum; + SetMassFractions(val_scalars); sol->thermo()->setMassFractions(massFractions.data()); /*--- Computing temperature given enthalpy and species mass fractions using Newton-Raphson. ---*/ From 523058691f518611824b61e4440265e10ae85252 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sat, 20 Dec 2025 21:20:05 +0100 Subject: [PATCH 151/173] removing nsp and using ARRAYSIZE instead --- SU2_CFD/src/fluid/CFluidCantera.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index ccf21efc4e31..cac52fc04ef9 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -60,8 +60,8 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* for (int iVar = 0; iVar < n_species_mixture; iVar++) { speciesIndices[iVar] = sol->thermo()->speciesIndex(config->GetChemical_GasComposition(iVar)); } - enthalpiesSpecies.resize(sol->thermo()->nSpecies()); - specificHeatSpecies.resize(sol->thermo()->nSpecies()); + enthalpiesSpecies.resize(ARRAYSIZE); + specificHeatSpecies.resize(ARRAYSIZE); if (Combustion) SetEnthalpyFormation(config); } @@ -80,17 +80,15 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { } void CFluidCantera::ComputeMassDiffusivity() { - int nsp = sol->thermo()->nSpecies(); - vector diff(nsp); - sol->transport()->getMixDiffCoeffsMass(&diff[0]); + vector diffusivities(ARRAYSIZE); + sol->transport()->getMixDiffCoeffsMass(&diffusivities[0]); for (int iVar = 0; iVar < n_species_mixture; iVar++) { - massDiffusivity[iVar] = diff[speciesIndices[iVar]]; + massDiffusivity[iVar] = diffusivities[speciesIndices[iVar]]; } } void CFluidCantera::ComputeChemicalSourceTerm(const su2double* val_scalars) { - const int nsp = sol->thermo()->nSpecies(); - vector netProductionRates(nsp); + vector netProductionRates(ARRAYSIZE); sol->kinetics()->getNetProductionRates(&netProductionRates[0]); for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { chemicalSourceTerm[iVar] = molarMasses[speciesIndices[iVar]] * netProductionRates[speciesIndices[iVar]]; @@ -98,8 +96,7 @@ void CFluidCantera::ComputeChemicalSourceTerm(const su2double* val_scalars) { } void CFluidCantera::ComputeHeatRelease() { - const int nsp = sol->thermo()->nSpecies(); - vector netProductionRates(nsp); + vector netProductionRates(ARRAYSIZE); sol->kinetics()->getNetProductionRates(&netProductionRates[0]); Heat_Release = 0.0; for (int iVar = 0; iVar < n_species_mixture; iVar++) { From a22a3bbd7b0faca2dc12bbaa385672b24efff058 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Sun, 11 Jan 2026 20:56:57 +0100 Subject: [PATCH 152/173] cleaning, reformulating and reducing calls --- SU2_CFD/include/fluid/CFluidCantera.hpp | 17 +++---- SU2_CFD/include/fluid/CFluidModel.hpp | 3 +- SU2_CFD/src/fluid/CFluidCantera.cpp | 51 +++++++------------ SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 2 +- SU2_CFD/src/solvers/CIncNSSolver.cpp | 6 +-- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 12 +++-- .../SU2_CFD/fluid/CFluidCantera_tests.cpp | 2 +- 7 files changed, 38 insertions(+), 55 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index e99e2b814e17..1b418ccc17ea 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -68,14 +68,10 @@ class CFluidCantera final : public CFluidModel { std::array enthalpyFormation; /*!< \brief Enthalpy of Formation of all species. */ std::array massFractions; /*!< \brief Mass fractions of all species. */ std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ + vector netProductionRates; /*!< \brief Net chemical production rates of all species*/ mutable vector enthalpiesSpecies; /*!< \brief Molar enthalpies of all species. */ mutable vector specificHeatSpecies; /*!< \brief Molar heat capacities of all species. */ - /*! - * \brief Compute mass diffusivity for species. - */ - void ComputeMassDiffusivity(); - /*! * \brief Compute heat release due to combustion. */ @@ -113,14 +109,14 @@ class CFluidCantera final : public CFluidModel { /*! * \brief Get fluid mass diffusivity. + * \param[in] ivar - index of species. */ - inline su2double GetMassDiffusivity(int ivar) override { return massDiffusivity[ivar]; } + inline su2double GetMassDiffusivity(int ivar) override { return massDiffusivity[speciesIndices[ivar]]; } /*! * \brief Compute chemical source term for species. - * \param[in] val_scalars - Scalar mass fractions. */ - void ComputeChemicalSourceTerm(const su2double* val_scalars) override; + void ComputeChemicalSourceTerm() override; /*! * \brief Get Chemical source term species. @@ -150,7 +146,8 @@ class CFluidCantera final : public CFluidModel { /*! * \brief Set the Dimensionless State using Temperature. - * \param[in] t - Temperature value at the point. + * \param[in] val_temperature - Temperature value at the point. + * \param[in] val_scalars - Scalar mass fractions. */ void SetTDState_T(su2double val_temperature, const su2double* val_scalars) override; @@ -159,6 +156,6 @@ class CFluidCantera final : public CFluidModel { * \param[in] val_enthalpy - Enthalpy value at the point. * \param[in] val_scalars - Scalar mass fractions. */ - void SetTDState_h(su2double val_enthalpy, const su2double* val_scalars = nullptr) override; + void SetTDState_h(su2double val_enthalpy, const su2double* val_scalars) override; #endif }; \ No newline at end of file diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 34b376195e7a..d7b93e0ecd51 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -194,9 +194,8 @@ class CFluidModel { /*! * \brief Compute chemical source term for species. - * \param[in] val_scalars - Scalar mass fractions. */ - virtual void ComputeChemicalSourceTerm(const su2double* val_scalars = nullptr) {}; + virtual void ComputeChemicalSourceTerm() {}; /*! * \brief Get Chemical source term species. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index cac52fc04ef9..6483d3cdb099 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -60,8 +60,9 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* for (int iVar = 0; iVar < n_species_mixture; iVar++) { speciesIndices[iVar] = sol->thermo()->speciesIndex(config->GetChemical_GasComposition(iVar)); } - enthalpiesSpecies.resize(ARRAYSIZE); - specificHeatSpecies.resize(ARRAYSIZE); + enthalpiesSpecies.resize(sol->thermo()->nSpecies()); + specificHeatSpecies.resize(sol->thermo()->nSpecies()); + netProductionRates.resize(sol->thermo()->nSpecies()); if (Combustion) SetEnthalpyFormation(config); } @@ -70,34 +71,22 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { sol->thermo()->setMassFractions(massFractions.data()); su2double T_ref = 298.15; sol->thermo()->setState_TP(T_ref, Pressure_Thermodynamic); - // The universal gas constant times temperature is retrieved from cantera. - const su2double uni_gas_constant_temp = sol->thermo()->RT(); sol->thermo()->getEnthalpy_RT_ref(enthalpiesSpecies.data()); for (int iVar = 0; iVar < n_species_mixture; iVar++) { enthalpyFormation[iVar] = - uni_gas_constant_temp * enthalpiesSpecies[speciesIndices[iVar]] / molarMasses[speciesIndices[iVar]]; + GasConstant * T_ref * enthalpiesSpecies[speciesIndices[iVar]] / molarMasses[speciesIndices[iVar]]; } } -void CFluidCantera::ComputeMassDiffusivity() { - vector diffusivities(ARRAYSIZE); - sol->transport()->getMixDiffCoeffsMass(&diffusivities[0]); - for (int iVar = 0; iVar < n_species_mixture; iVar++) { - massDiffusivity[iVar] = diffusivities[speciesIndices[iVar]]; - } -} - -void CFluidCantera::ComputeChemicalSourceTerm(const su2double* val_scalars) { - vector netProductionRates(ARRAYSIZE); - sol->kinetics()->getNetProductionRates(&netProductionRates[0]); +void CFluidCantera::ComputeChemicalSourceTerm() { + sol->kinetics()->getNetProductionRates(netProductionRates.data()); for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { chemicalSourceTerm[iVar] = molarMasses[speciesIndices[iVar]] * netProductionRates[speciesIndices[iVar]]; } } void CFluidCantera::ComputeHeatRelease() { - vector netProductionRates(ARRAYSIZE); - sol->kinetics()->getNetProductionRates(&netProductionRates[0]); + sol->kinetics()->getNetProductionRates(netProductionRates.data()); Heat_Release = 0.0; for (int iVar = 0; iVar < n_species_mixture; iVar++) { Heat_Release += @@ -106,40 +95,36 @@ void CFluidCantera::ComputeHeatRelease() { } void CFluidCantera::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) const { - // The universal gas constant times temperature is retrieved from cantera. - const su2double uni_gas_constant_temp = sol->thermo()->RT(); sol->thermo()->getEnthalpy_RT_ref(enthalpiesSpecies.data()); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { enthalpy_diffusions[iVar] = - Density * uni_gas_constant_temp * - ((enthalpiesSpecies[speciesIndices[iVar]] * massDiffusivity[iVar] / molarMasses[speciesIndices[iVar]]) - - (enthalpiesSpecies[speciesIndices[n_species_mixture - 1]] * massDiffusivity[n_species_mixture - 1] / + Density * GasConstant * Temperature * + ((enthalpiesSpecies[speciesIndices[iVar]] * massDiffusivity[speciesIndices[iVar]] / molarMasses[speciesIndices[iVar]]) - + (enthalpiesSpecies[speciesIndices[n_species_mixture - 1]] * massDiffusivity[speciesIndices[n_species_mixture - 1]] / molarMasses[speciesIndices[n_species_mixture - 1]])); enthalpy_diffusions[iVar] += - Mu_Turb * uni_gas_constant_temp * + Mu_Turb * GasConstant * Temperature * ((enthalpiesSpecies[speciesIndices[iVar]] / molarMasses[speciesIndices[iVar]]) - - (enthalpiesSpecies[speciesIndices[n_species_mixture - 1]] * massDiffusivity[n_species_mixture - 1] / + (enthalpiesSpecies[speciesIndices[n_species_mixture - 1]] / molarMasses[speciesIndices[n_species_mixture - 1]])) / Schmidt_Turb_Number; } } void CFluidCantera::GetMassCorrectionDiffusivity(su2double* massCorrection_diffusions) { for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { - massCorrection_diffusions[iVar] = Density * (massDiffusivity[iVar] - massDiffusivity[n_species_mixture - 1]); + massCorrection_diffusions[iVar] = Density * (massDiffusivity[speciesIndices[iVar]] - massDiffusivity[speciesIndices[n_species_mixture - 1]]); } } void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusions) const { - // The universal gas constant is retrieved from cantera,in order to keep consistency with the values retrieve from it. - const su2double universal_gas_constant = (sol->thermo()->RT()) / Temperature; sol->thermo()->getCp_R_ref(specificHeatSpecies.data()); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { grad_enthalpy_diffusions[iVar] = - Density * universal_gas_constant * - ((specificHeatSpecies[speciesIndices[iVar]] * massDiffusivity[iVar] / molarMasses[speciesIndices[iVar]]) - - (specificHeatSpecies[speciesIndices[n_species_mixture - 1]] * massDiffusivity[n_species_mixture - 1] / + Density * GasConstant * + ((specificHeatSpecies[speciesIndices[iVar]] * massDiffusivity[speciesIndices[iVar]] / molarMasses[speciesIndices[iVar]]) - + (specificHeatSpecies[speciesIndices[n_species_mixture - 1]] * massDiffusivity[speciesIndices[n_species_mixture - 1]] / molarMasses[speciesIndices[n_species_mixture - 1]])); - grad_enthalpy_diffusions[iVar] += Mu_Turb * universal_gas_constant * + grad_enthalpy_diffusions[iVar] += Mu_Turb * GasConstant * ((specificHeatSpecies[speciesIndices[iVar]] / molarMasses[speciesIndices[iVar]]) - (specificHeatSpecies[speciesIndices[n_species_mixture - 1]] / molarMasses[speciesIndices[n_species_mixture - 1]])) / @@ -170,7 +155,7 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl Mu = sol->transport()->viscosity(); Kt = sol->transport()->thermalConductivity(); - ComputeMassDiffusivity(); + sol->transport()->getMixDiffCoeffsMass(massDiffusivity.data()); if (Combustion) ComputeHeatRelease(); } diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index 45e6614185c6..96608c6992f6 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -545,7 +545,7 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); + AD::SetPreaccIn(V_i, nDim+10); AD::SetPreaccIn(V_j, nDim+10); AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); AD::SetPreaccIn(PrimVar_Grad_i, nVar, nDim); AD::SetPreaccIn(PrimVar_Grad_j, nVar, nDim); diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 31a0493c6625..50ab01cc490a 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -95,18 +95,18 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container if (ignition) { SU2_OMP_FOR_STAT(omp_chunk_size) for (auto i_point = 0u; i_point < nPoint; i_point++) { - /*--- retrieve fluid model. ---*/ + /*--- Retrieve fluid model. ---*/ CFluidModel* fluid_model_local = solver_container[FLOW_SOL]->GetFluidModel(); /*--- Apply ignition temperature within spark radius. ---*/ su2double dist_from_center = 0, spark_radius = flamelet_config_options.spark_init[3]; dist_from_center = GeometryToolbox::SquaredDistance(nDim, geometry->nodes->GetCoord(i_point), flamelet_config_options.spark_init.data()); if (dist_from_center < pow(spark_radius, 2)) { - /*--- retrieve scalars solution. ---*/ + /*--- Retrieve scalars solution. ---*/ su2double* scalars = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(i_point); /*--- Set high temperature for ignition. ---*/ nodes->SetTemperature(i_point, config->GetSpark_Temperature(), TemperatureLimits); - /*--- Set thermodynamic state at high temeprature. ---*/ + /*--- Set thermodynamic state at high temperature. ---*/ fluid_model_local->SetTDState_T(config->GetSpark_Temperature(), scalars); /*--- Set total enthalpy at high temperature. ---*/ nodes->SetSolution(i_point, nDim + 1, fluid_model_local->GetEnthalpy()); diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index a29b1b1a4c91..f12e26361a06 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -310,11 +310,11 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain } SU2_OMP_SAFE_GLOBAL_ACCESS(config->SetGlobalParam(config->GetKind_Solver(), RunTime_EqSystem);) - /*--- Set the laminar mass Diffusivity for the species solver. ---*/ + /*--- Set the laminar mass Diffusivity and chemical source term for the species solver. ---*/ SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0u; iPoint < nPoint; iPoint++) { if (ignition) { - /*--- Apply source terms within spark radius. ---*/ + /*--- Apply ignition temperature within spark radius. ---*/ su2double dist_from_center = 0, spark_radius = flamelet_config_options.spark_init[3]; dist_from_center = GeometryToolbox::SquaredDistance(nDim, geometry->nodes->GetCoord(iPoint), flamelet_config_options.spark_init.data()); @@ -330,6 +330,9 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain solver_container[FLOW_SOL]->GetFluidModel()->SetMassDiffusivityModel(config); solver_container[FLOW_SOL]->GetFluidModel()->SetTDState_T(temperature, scalar); if (config->GetCombustion() == true) { + /*--- Call function to compute chemical source term. ---*/ + solver_container[FLOW_SOL]->GetFluidModel()->ComputeChemicalSourceTerm(); + /*--- Get and set heat release due to combustion. ---*/ const su2double heat_release = solver_container[FLOW_SOL]->GetFluidModel()->GetHeatRelease(); nodes->SetHeatRelease(iPoint, heat_release); } @@ -337,9 +340,8 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain const su2double mass_diffusivity = solver_container[FLOW_SOL]->GetFluidModel()->GetMassDiffusivity(iVar); nodes->SetDiffusivity(iPoint, mass_diffusivity, iVar); if (config->GetCombustion() == true) { - /*--- call function integrate chemical source term ---*/ - solver_container[FLOW_SOL]->GetFluidModel()->ComputeChemicalSourceTerm(scalar); - const su2double chemical_source_term=solver_container[FLOW_SOL]->GetFluidModel()->GetChemicalSourceTerm(iVar); + /*--- Get and Set chemical source term. ---*/ + const su2double chemical_source_term = solver_container[FLOW_SOL]->GetFluidModel()->GetChemicalSourceTerm(iVar); nodes->SetChemicalSourceTerm(iPoint, chemical_source_term, iVar); } } diff --git a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp index e854ff4476d1..0c8586a2a998 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp @@ -89,7 +89,7 @@ TEST_CASE("Fluid_Cantera_Combustion", "[Reacting_flow]") { auxFluidModel->SetTDState_T(Temperature, scalar); /*--- Compute chemical source terms ---*/ - auxFluidModel->ComputeChemicalSourceTerm(scalar); + auxFluidModel->ComputeChemicalSourceTerm(); /*--- check values for source terms ---*/ From 6c467710d0f1812c1efea27ccfb9a4a4a6ccb04b Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 12 Jan 2026 13:10:00 +0100 Subject: [PATCH 153/173] update version --- SU2_CFD/include/fluid/CFluidCantera.hpp | 2 +- SU2_CFD/src/fluid/CFluidCantera.cpp | 2 +- UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 1b418ccc17ea..a80b1e1f4f2f 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -2,7 +2,7 @@ * \file CFluidCantera.hpp * \brief Defines the multicomponent incompressible Ideal Gas model for reacting flows. * \author T. Economon, Cristopher Morales Ubal - * \version 8.1.0 "Harrier" + * \version 8.4.0 "Harrier" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 6483d3cdb099..c7c10284829c 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -2,7 +2,7 @@ * \file CFluidCantera.cpp * \brief Defines the multicomponent incompressible Ideal Gas model for reacting flows. * \author T. Economon, Cristopher Morales Ubal - * \version 8.1.0 "Harrier" + * \version 8.4.0 "Harrier" * * SU2 Project Website: https://su2code.github.io * diff --git a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp index 0c8586a2a998..a5a5e4151335 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp @@ -2,7 +2,7 @@ * \file CFluidCantera_tests.cpp * \brief Unit tests for the Cantera fluid model. * \author C.Morales Ubal - * \version 8.1.0 "Harrier" + * \version 8.4.0 "Harrier" * * SU2 Project Website: https://su2code.github.io * From 224d86254e1cfec524ad9a24c5a76e1160631f22 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 12 Jan 2026 16:01:28 +0100 Subject: [PATCH 154/173] cleaning --- .../solvers/CSpeciesFlameletSolver.hpp | 1 - SU2_CFD/src/fluid/CFluidCantera.cpp | 12 ++---- .../SU2_CFD/fluid/CFluidCantera_tests.cpp | 38 ++++++++----------- 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp b/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp index df61813a3e27..c983bc54284d 100644 --- a/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp +++ b/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp @@ -37,7 +37,6 @@ */ class CSpeciesFlameletSolver final : public CSpeciesSolver { private: - FluidFlamelet_ParsedOptions flamelet_config_options; bool include_mixture_fraction = false; /*!< \brief include mixture fraction as a controlling variable. */ /*! * \brief Compute the preconditioner for low-Mach flows. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index c7c10284829c..b117071c4037 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -29,17 +29,12 @@ #include -#include +// #include #ifdef USE_CANTERA -#include "../../Common/include/basic_types/ad_structure.hpp" - #include #include -#include -#include using namespace Cantera; -using namespace SU2_TYPE; CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* config) : CFluidModel(), @@ -69,12 +64,11 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { SetMassFractions(config->GetSpecies_Init()); sol->thermo()->setMassFractions(massFractions.data()); - su2double T_ref = 298.15; - sol->thermo()->setState_TP(T_ref, Pressure_Thermodynamic); + sol->thermo()->setState_TP(STD_REF_TEMP, Pressure_Thermodynamic); sol->thermo()->getEnthalpy_RT_ref(enthalpiesSpecies.data()); for (int iVar = 0; iVar < n_species_mixture; iVar++) { enthalpyFormation[iVar] = - GasConstant * T_ref * enthalpiesSpecies[speciesIndices[iVar]] / molarMasses[speciesIndices[iVar]]; + GasConstant * STD_REF_TEMP * enthalpiesSpecies[speciesIndices[iVar]] / molarMasses[speciesIndices[iVar]]; } } diff --git a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp index a5a5e4151335..e0af2a0d299a 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp @@ -1,6 +1,6 @@ /*! * \file CFluidCantera_tests.cpp - * \brief Unit tests for the Cantera fluid model. + * \brief Unit tests for Cantera fluid model. * \author C.Morales Ubal * \version 8.4.0 "Harrier" * @@ -29,40 +29,34 @@ #include -#include #if defined(HAVE_CANTERA) #define USE_CANTERA -#include "../../../Common/include/basic_types/ad_structure.hpp" #include "../../../SU2_CFD/include/fluid/CFluidCantera.hpp" #include -#include -#include using namespace Cantera; -using namespace SU2_TYPE; #endif #ifdef USE_CANTERA TEST_CASE("Fluid_Cantera", "[Multicomponent_flow]") { - /*--- Cantera fluid model unit test cases ---*/ + /*--- Cantera fluid model unit test cases. ---*/ SU2_COMPONENT val_software = SU2_COMPONENT::SU2_CFD; CConfig* config = new CConfig("multicomponent_cantera.cfg", val_software, true); CFluidCantera* auxFluidModel = nullptr; - /*--- Create Cantera fluid model ---*/ + /*--- Create Cantera fluid model. ---*/ su2double value_pressure_operating = config->GetPressure_Thermodynamic(); - auxFluidModel= new CFluidCantera(value_pressure_operating, config); - - /*--- get scalar from config file and set temperature ---*/ + auxFluidModel = new CFluidCantera(value_pressure_operating, config); + /*--- Get scalar from config file and set temperature. ---*/ const su2double* scalar = nullptr; - scalar=config->GetSpecies_Init(); + scalar = config->GetSpecies_Init(); const su2double Temperature = 300.0; - /*--- Set state using temperature and scalar ---*/ + /*--- Set state using temperature and scalar. ---*/ auxFluidModel->SetTDState_T(Temperature, scalar); - /*--- check values for density and heat capacity ---*/ + /*--- Check values for density and heat capacity. ---*/ su2double density = auxFluidModel->GetDensity(); su2double cp = auxFluidModel->GetCp(); @@ -70,28 +64,28 @@ TEST_CASE("Fluid_Cantera", "[Multicomponent_flow]") { CHECK(cp == Approx(1277.91)); } TEST_CASE("Fluid_Cantera_Combustion", "[Reacting_flow]") { - /*--- Cantera fluid model unit test cases ---*/ + /*--- Cantera fluid model unit test cases. ---*/ SU2_COMPONENT val_software = SU2_COMPONENT::SU2_CFD; CConfig* config = new CConfig("multicomponent_cantera.cfg", val_software, true); CFluidCantera* auxFluidModel = nullptr; - /*--- Create Cantera fluid model ---*/ + /*--- Create Cantera fluid model. ---*/ su2double value_pressure_operating = config->GetPressure_Thermodynamic(); - auxFluidModel= new CFluidCantera(value_pressure_operating, config); - - /*--- get scalar from config file and set temperature ---*/ + auxFluidModel = new CFluidCantera(value_pressure_operating, config); + + /*--- Get scalar from config file and set temperature. ---*/ const su2double* scalar = nullptr; - scalar=config->GetSpecies_Init(); + scalar = config->GetSpecies_Init(); const su2double Temperature = 1900.0; /*--- Set state using temperature and scalar ---*/ auxFluidModel->SetTDState_T(Temperature, scalar); - /*--- Compute chemical source terms ---*/ + /*--- Compute chemical source terms. ---*/ auxFluidModel->ComputeChemicalSourceTerm(); - /*--- check values for source terms ---*/ + /*--- Check values for source terms. ---*/ su2double sourceTerm_H2 = auxFluidModel->GetChemicalSourceTerm(0); su2double sourceTerm_O2 = auxFluidModel->GetChemicalSourceTerm(1); From 876aa54f391a2f4bad7c0d522f758d83164d3614 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 12 Jan 2026 16:47:49 +0100 Subject: [PATCH 155/173] spelling fixes --- Common/include/CConfig.hpp | 17 +++++++++-------- Common/src/CConfig.cpp | 18 ++++++++++-------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 625dfbf55118..5c0caf2528a7 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -80,14 +80,14 @@ class CConfig { su2double EA_ScaleFactor; /*!< \brief Equivalent Area scaling factor */ su2double AdjointLimit; /*!< \brief Adjoint variable limit */ string* ConvField; /*!< \brief Field used for convergence check.*/ - string FluidName; /*!< \brief name of the applied fluid. */ - string TransportModel; /*!< \brief name transport model used in cantera*/ - string* GasCompositionNames; /*!< \brief gas composition used in cantera*/ - string ChemicalMechanismFile; /*!< \brief Chemical Reaction mechanism used in cantera*/ - string PhaseName; /*!< \brief Name of the phase in the chemical mechanism file used in cantera*/ - unsigned short n_GasCompositionNames; /*!<\brief number of gases in mixture composition for cantera */ - bool Combustion; /*!< \brief Flag for Combustion Detailed chemistry problems using Cantera */ - su2double Spark_Temperature; /*!< \bried Spark temperature used for ignition in detailed chemistry using Cantera*/ + string FluidName; /*!< \brief name of the applied fluid. */ + string TransportModel; /*!< \brief name transport model used in Cantera. */ + string* GasCompositionNames; /*!< \brief gas composition used in Cantera. */ + string ChemicalMechanismFile; /*!< \brief Chemical Reaction mechanism used in Cantera. */ + string PhaseName; /*!< \brief Name of the phase in the chemical mechanism file used in Cantera. */ + unsigned short n_GasCompositionNames; /*!<\brief Number of gases in mixture composition for Cantera. */ + bool Combustion; /*!< \brief Flag for Combustion Detailed chemistry problems using Cantera. */ + su2double Spark_Temperature; /*!< \bried Spark temperature used for ignition in detailed chemistry using Cantera. */ string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */ unsigned short nConvField; /*!< \brief Number of fields used to monitor convergence.*/ @@ -4057,6 +4057,7 @@ class CConfig { /*! * \brief Get High temperature applied during spark ignition. + * \return Spark Temperature. */ const su2double GetSpark_Temperature(void) const { return Spark_Temperature; diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 777d5cf36025..40860947934b 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1221,17 +1221,19 @@ void CConfig::SetConfig_Options() { addEnumOption("FLUID_MODEL", Kind_FluidModel, FluidModel_Map, STANDARD_AIR); /*!\brief FLUID_NAME \n DESCRIPTION: Fluid name \n OPTIONS: see coolprop homepage \n DEFAULT: nitrogen \ingroup Config*/ addStringOption("FLUID_NAME", FluidName, string("nitrogen")); - /*!\brief TRANSPORT_MODEL \n DESCRIPTION: Transport model \n OPTIONS: see cantera homepage \n DEFAULT: mixture-averaged\ingroup Config*/ + + /*!\par CONFIG_CATEGORY: Cantera fluid model \ingroup Config*/ + /*!\brief TRANSPORT_MODEL \n DESCRIPTION: Transport model \n OPTIONS: see Cantera homepage \n DEFAULT: mixture-averaged \ingroup Config*/ addStringOption("TRANSPORT_MODEL", TransportModel, string("mixture-averaged")); - /*!\brief CHEMICAL_MECHANISM_FILE \n DESCRIPTION: Chemical reaction mechanism \n OPTIONS: see cantera homepage \n DEFAULT: gri30.yaml \ingroup Config*/ - addStringOption("CHEMICAL_MECHANISM_FILE", ChemicalMechanismFile, string("gri30.yaml")); - /*!\brief PHASE_NAME\n DESCRIPTION: name of the phase in the chemical mechanism file \n OPTIONS: see cantera homepage \n DEFAULT: gri30 \ingroup Config*/ - addStringOption("PHASE_NAME", PhaseName, string("gri30")); - /*!\brief GAS_COMPOSITION \n DESCRIPTION: Gas composition names \n OPTIONS: see cantera homepage \n DEFAULT: \ingroup Config*/ + /*!\brief CHEMICAL_MECHANISM_FILE \n DESCRIPTION: Chemical reaction mechanism \n OPTIONS: see Cantera homepage \n DEFAULT: h2o2.yaml \ingroup Config*/ + addStringOption("CHEMICAL_MECHANISM_FILE", ChemicalMechanismFile, string("h2o2.yaml")); + /*!\brief PHASE_NAME \n DESCRIPTION: name of the phase in the chemical mechanism file \n OPTIONS: see Cantera homepage \n DEFAULT: gri30 \ingroup Config*/ + addStringOption("PHASE_NAME", PhaseName, string("ohmech")); + /*!\brief GAS_COMPOSITION_NAMES \n DESCRIPTION: Gas composition names \n OPTIONS: see Cantera homepage \n DEFAULT: \ingroup Config*/ addStringListOption("GAS_COMPOSITION_NAMES", n_GasCompositionNames, GasCompositionNames); - /*\brief COMBUSTION \n DESCRIPTION: Combustion Detailed chemistry using Cantera \n DEFAULT: false \ingroup Config */ + /*\brief COMBUSTION \n DESCRIPTION: Combustion Detailed chemistry using Cantera \n DEFAULT: false \ingroup Config*/ addBoolOption("COMBUSTION", Combustion, false); - /*!\brief SCHMIDT_LAM \n DESCRIPTION: Laminar Schmidt number of mass diffusion \n DEFAULT 1.0 (~for Gases) \ingroup Config*/ + /*!\brief SPARK_TEMPERATURE \n DESCRIPTION: Spark temperature used for ignition in detailed chemistry using Cantera \n DEFAULT: 1000 K \ingroup Config*/ addDoubleOption("SPARK_TEMPERATURE", Spark_Temperature, 1000.0); /*!\par CONFIG_CATEGORY: Data-driven fluid model parameters \ingroup Config*/ From 9aeac3bd26a1165caf1167439c4fbdb7ace5797f Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 12 Jan 2026 17:23:28 +0100 Subject: [PATCH 156/173] fixing unit test meson.build --- UnitTests/meson.build | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/UnitTests/meson.build b/UnitTests/meson.build index 28585530cffd..2839e0904b2a 100644 --- a/UnitTests/meson.build +++ b/UnitTests/meson.build @@ -32,19 +32,20 @@ su2_cfd_tests_dd = files(['Common/simple_directdiff_test.cpp']) # End of unit test listings # ------------------------------------------------------------------------- -if get_option('enable-cantera') - su2_cpp_args += '-DHAVE_CANTERA' - cantera_dep = dependency('cantera') -endif if get_option('enable-tests') if get_option('enable-normal') unit_test_files = su2_cfd_tests + files(['test_driver.cpp']) + dependencies_default = [su2_cfd_dep, common_dep, su2_deps, catch2_dep] + if get_option('enable-cantera') + su2_cpp_args += '-DHAVE_CANTERA' + dependencies_default += dependency('cantera') + endif test_driver = executable( 'test_driver', unit_test_files, install : true, - dependencies : [su2_cfd_dep, common_dep, su2_deps, catch2_dep, cantera_dep], + dependencies : dependencies_default, cpp_args: ['-fPIC', default_warning_flags, su2_cpp_args] ) test('Catch2 test driver', test_driver) From 04cdc9e18aea7ee1886a721e541eecb28161049b Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 12 Jan 2026 19:02:57 +0100 Subject: [PATCH 157/173] additional cleaning --- SU2_CFD/src/meson.build | 23 ++++++++++------------- SU2_CFD/src/solvers/CIncNSSolver.cpp | 11 +++++------ 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index 41f211d5d688..d3701fbb54dd 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -195,17 +195,16 @@ if get_option('enable-gprof') profiling_args = ['-pg','-no-pie'] endif -su2_common_deps = [su2_deps, common_dep] - -if get_option('enable-cantera') - su2_common_deps += cantera_dep -endif if get_option('enable-normal') + dependencies_default = [su2_deps, common_dep] + if get_option('enable-cantera') + dependencies_default += cantera_dep + endif su2_cfd_lib = static_library('SU2core', su2_cfd_src, install : false, - dependencies : su2_common_deps, + dependencies : dependencies_default, cpp_args: [default_warning_flags, su2_cpp_args]) su2_cfd_dep = declare_dependency(link_with: su2_cfd_lib, include_directories: su2_cfd_include) @@ -217,17 +216,15 @@ if get_option('enable-normal') link_args: profiling_args) endif -su2_common_deps_AD = [su2_deps, codi_dep, commonAD_dep] - -if get_option('enable-cantera') and get_option('enable-autodiff') - su2_common_deps_AD += cantera_ad_dep -endif - if get_option('enable-autodiff') + dependencies_default_AD = [su2_deps, codi_dep, commonAD_dep] + if get_option('enable-cantera') + dependencies_default_AD += cantera_ad_dep + endif su2_cfd_lib_ad = static_library('SU2core_AD', su2_cfd_src, install : false, - dependencies : su2_common_deps_AD, + dependencies : dependencies_default_AD, cpp_args: [default_warning_flags, su2_cpp_args, codi_rev_args]) su2_cfd_dep_ad = declare_dependency(link_with: su2_cfd_lib_ad, include_directories: su2_cfd_include) diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 887a06be3daf..eff76bcd9f38 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -72,12 +72,11 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container const bool limiter = (config->GetKind_SlopeLimit_Flow() != LIMITER::NONE) && (InnerIter <= config->GetLimiterIter()); const bool van_albada = (config->GetKind_SlopeLimit_Flow() == LIMITER::VAN_ALBADA_EDGE); const bool wall_functions = config->GetWall_Functions(); - const bool energy_multicomponent = config->GetEnergy_Equation() && (config->GetKind_FluidModel() == FLUID_MIXTURE || - config->GetKind_FluidModel() == FLUID_CANTERA); + const bool energy = config->GetEnergy_Equation(); const bool combustion = config->GetCombustion(); - /*--- Setting temperature, enthalpy and themorchemical properties for ignition in reacting flows. ---*/ - if (energy_multicomponent && combustion) { + /*--- Setting temperature, enthalpy and thermophysical properties for ignition in reacting flows. ---*/ + if (energy && combustion) { unsigned long spark_iter_start, spark_duration; bool ignition = false; @@ -110,12 +109,12 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container fluid_model_local->SetTDState_T(config->GetSpark_Temperature(), scalars); /*--- Set total enthalpy at high temperature. ---*/ nodes->SetSolution(i_point, nDim + 1, fluid_model_local->GetEnthalpy()); - /*--- Set thermochemical properties at high temperature for consistency. ---*/ + /*--- Set thermodynamics and transport properties at high temperature for consistency. ---*/ nodes->SetDensity(i_point, fluid_model_local->GetDensity()); nodes->SetSpecificHeatCp(i_point, fluid_model_local->GetCp()); nodes->SetSpecificHeatCv(i_point, fluid_model_local->GetCv()); nodes->SetThermalConductivity(i_point, fluid_model_local->GetThermalConductivity()); - nodes->SetLaminarViscosity(i_point, fluid_model_local->GetThermalConductivity()); + nodes->SetLaminarViscosity(i_point, fluid_model_local->GetLaminarViscosity()); } } END_SU2_OMP_FOR From 57e1b429d06a52e2cc93cbd9c1c9cb45cb982321 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 12 Jan 2026 21:37:04 +0100 Subject: [PATCH 158/173] improve explanation --- cantera_meson_build.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cantera_meson_build.py b/cantera_meson_build.py index fa74c79762f3..65f9009d0c0c 100644 --- a/cantera_meson_build.py +++ b/cantera_meson_build.py @@ -4,14 +4,14 @@ # \brief create necessary meson.build file for linking cantera to # SU2. # \author C.Morales Ubal -# \version 8.2.0 "Harrier" +# \version 8.4.0 "Harrier" # # SU2 Project Website: https://su2code.github.io # # The SU2 Project is maintained by the SU2 Foundation # (http://su2foundation.org) # -# Copyright 2012-2025, SU2 Contributors (cf. AUTHORS.md) +# Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) # # SU2 is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -31,10 +31,10 @@ relative_path = "subprojects/cantera" meson_path = os.path.join(absolute_path, relative_path) -# Where to create meson.build +# Path to the meson.build under SU2/subprojects/cantera/ meson_build_path = os.path.join(meson_path, "meson.build") -# Detect filename if already exists +# Create meson.build in the cantera subproject if it does not already exist if not os.path.exists(meson_build_path): print(f"Writing meson.build in {meson_path}") meson_build_content = ["project('cantera', 'c', 'cpp', default_options: ['cpp_std=c++17'])\n", From aaf9089fca6a8a7da955028d3232f1ea962292f9 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 12 Jan 2026 22:19:34 +0100 Subject: [PATCH 159/173] only add cantera_ad dependency when enable-autodiff is true --- meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 0cdd71434912..60d209c1faf5 100644 --- a/meson.build +++ b/meson.build @@ -336,7 +336,9 @@ if get_option('enable-cantera') endif su2_cpp_args +='-DHAVE_CANTERA' cantera_dep = dependency('cantera') - cantera_ad_dep = dependency('cantera_ad') + if get_option('enable-autodiff') + cantera_ad_dep = dependency('cantera_ad') + endif endif if get_option('enable-mlpcpp') From ef7546bc4f347bb4480a53c4e68fdf39d8f5a206 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Tue, 13 Jan 2026 16:14:27 +0100 Subject: [PATCH 160/173] removing AD options --- SU2_CFD/src/meson.build | 6 +----- cantera_meson_build.py | 6 +----- meson.build | 3 --- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index d3701fbb54dd..cc7d9e79ee30 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -217,14 +217,10 @@ if get_option('enable-normal') endif if get_option('enable-autodiff') - dependencies_default_AD = [su2_deps, codi_dep, commonAD_dep] - if get_option('enable-cantera') - dependencies_default_AD += cantera_ad_dep - endif su2_cfd_lib_ad = static_library('SU2core_AD', su2_cfd_src, install : false, - dependencies : dependencies_default_AD, + dependencies : [su2_deps, codi_dep, commonAD_dep], cpp_args: [default_warning_flags, su2_cpp_args, codi_rev_args]) su2_cfd_dep_ad = declare_dependency(link_with: su2_cfd_lib_ad, include_directories: su2_cfd_include) diff --git a/cantera_meson_build.py b/cantera_meson_build.py index 65f9009d0c0c..3a025dbda416 100644 --- a/cantera_meson_build.py +++ b/cantera_meson_build.py @@ -42,11 +42,7 @@ "cantera_inc = include_directories('install/include')\n", "cantera_lib = cc.find_library('cantera', dirs: [meson.current_source_dir() / 'install' / 'lib'], required: false, static: true)\n", "cantera_dep = declare_dependency(include_directories: cantera_inc, dependencies: cantera_lib)\n", - "meson.override_dependency('cantera', cantera_dep)\n", - "cantera_ad_inc = include_directories('install_ad/include')\n", - "cantera_ad_lib = cc.find_library('cantera', dirs: [meson.current_source_dir() / 'install_ad' / 'lib'], required: false, static: true)\n", - "cantera_ad_dep = declare_dependency(include_directories: cantera_ad_inc, dependencies: cantera_ad_lib)\n", - "meson.override_dependency('cantera_ad', cantera_ad_dep)"] + "meson.override_dependency('cantera', cantera_dep)"] # Write the meson.build file with open(meson_build_path, 'w') as f: f.writelines(meson_build_content) diff --git a/meson.build b/meson.build index 60d209c1faf5..1085f6c48175 100644 --- a/meson.build +++ b/meson.build @@ -336,9 +336,6 @@ if get_option('enable-cantera') endif su2_cpp_args +='-DHAVE_CANTERA' cantera_dep = dependency('cantera') - if get_option('enable-autodiff') - cantera_ad_dep = dependency('cantera_ad') - endif endif if get_option('enable-mlpcpp') From 13bb2f5314a8c6cdec28ba9db342ac209ccb9a06 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 15 Jan 2026 13:20:32 +0100 Subject: [PATCH 161/173] removing flux mass correction due to diffusivity for this PR --- SU2_CFD/include/fluid/CFluidCantera.hpp | 5 ----- SU2_CFD/include/fluid/CFluidModel.hpp | 5 ----- SU2_CFD/include/fluid/CFluidScalar.hpp | 5 ----- SU2_CFD/include/numerics/CNumerics.hpp | 8 -------- SU2_CFD/src/fluid/CFluidCantera.cpp | 6 ------ SU2_CFD/src/fluid/CFluidScalar.cpp | 10 +++++----- SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 2 -- SU2_CFD/src/solvers/CIncNSSolver.cpp | 14 +++----------- 8 files changed, 8 insertions(+), 47 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index a80b1e1f4f2f..95a3492862e4 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -134,11 +134,6 @@ class CFluidCantera final : public CFluidModel { */ void GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) const override; - /*! - * \brief Get enthalpy diffusivity terms. - */ - void GetMassCorrectionDiffusivity(su2double* MassCorrection_diffusions) override; - /*! * \brief Get gradient enthalpy diffusivity terms. */ diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 5a6eb98927d1..c7639c9f0ed8 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -208,11 +208,6 @@ class CFluidModel { */ inline virtual su2double GetHeatRelease() { return 0.0; } - /*! - * \brief Get heat diffusivity terms. - */ - virtual void GetMassCorrectionDiffusivity(su2double* massCorrection_diffusions = nullptr) {} - /*! * \brief Get the enthalpy diffusivity terms for all species being solved. * diff --git a/SU2_CFD/include/fluid/CFluidScalar.hpp b/SU2_CFD/include/fluid/CFluidScalar.hpp index 2ac61028bd62..c8170ff2a9e3 100644 --- a/SU2_CFD/include/fluid/CFluidScalar.hpp +++ b/SU2_CFD/include/fluid/CFluidScalar.hpp @@ -168,11 +168,6 @@ class CFluidScalar final : public CFluidModel { */ void GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusions) const override; - /*! - * \brief Get enthalpy diffusivity terms. - */ - void GetMassCorrectionDiffusivity(su2double* massCorrection_diffusions) override; - /*! * \brief Set the Dimensionless State using Temperature. * \param[in] t - Temperature value at the point. diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 7e0152f1772d..889821d69125 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -134,8 +134,6 @@ class CNumerics { su2double HeatFluxDiffusion; /*!< \brief Heat flux due to enthalpy diffusion for multicomponent. */ su2double - MassCorrFluxDiffusion; /*!< \brief Mass flux correction due to species diffusion for multicomponent. */ - su2double JacHeatFluxDiffusion; /*!< \brief Heat flux jacobian due to enthalpy diffusion for multicomponent. */ const su2double *TransVar_i, /*!< \brief Vector of turbulent variables at point i. */ @@ -776,12 +774,6 @@ class CNumerics { */ inline void SetHeatFluxDiffusion(su2double val_heatfluxdiffusion) { HeatFluxDiffusion = val_heatfluxdiffusion; } - /*! - * \brief Set the mass flux correction due to species diffusion - * \param[in] val_masscorrfluxdiffusion - Value of the mass flux correction due to species diffusion. - */ - inline void SetMassCorrFluxDiffusion(su2double val_masscorrfluxdiffusion) { MassCorrFluxDiffusion = val_masscorrfluxdiffusion; } - /*! * \brief Set Jacobian of the heat flux due to enthalpy diffusion * \param[in] val_jacheatfluxdiffusion - Value of the heat flux jacobian due to enthalpy diffusion. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index b117071c4037..43a4f6df039e 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -104,12 +104,6 @@ void CFluidCantera::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) const } } -void CFluidCantera::GetMassCorrectionDiffusivity(su2double* massCorrection_diffusions) { - for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { - massCorrection_diffusions[iVar] = Density * (massDiffusivity[speciesIndices[iVar]] - massDiffusivity[speciesIndices[n_species_mixture - 1]]); - } -} - void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusions) const { sol->thermo()->getCp_R_ref(specificHeatSpecies.data()); for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { diff --git a/SU2_CFD/src/fluid/CFluidScalar.cpp b/SU2_CFD/src/fluid/CFluidScalar.cpp index 0e7c03940b00..6db0d47e22ef 100644 --- a/SU2_CFD/src/fluid/CFluidScalar.cpp +++ b/SU2_CFD/src/fluid/CFluidScalar.cpp @@ -243,11 +243,11 @@ void CFluidScalar::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusion } } -void CFluidScalar::GetMassCorrectionDiffusivity(su2double* massCorrection_diffusions) { - for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { - massCorrection_diffusions[iVar] = Density * (massDiffusivity[iVar] - massDiffusivity[n_species_mixture - 1]); - } -} +// void CFluidScalar::GetMassCorrectionDiffusivity(su2double* massCorrection_diffusions) { +// for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { +// massCorrection_diffusions[iVar] = Density * (massDiffusivity[iVar] - massDiffusivity[n_species_mixture - 1]); +// } +// } void CFluidScalar::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { MassToMoleFractions(val_scalars); diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index c2783ff66dcb..d7937a85773b 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -554,7 +554,6 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi AD::SetPreaccIn(Normal, nDim); if (energy_multicomponent) { AD::SetPreaccIn(HeatFluxDiffusion); - AD::SetPreaccIn(MassCorrFluxDiffusion); } unsigned short iVar, jVar, iDim; @@ -629,7 +628,6 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity); if (energy_multicomponent) { - Proj_Flux_Tensor[0] += MassCorrFluxDiffusion; Proj_Flux_Tensor[nVar - 1] += HeatFluxDiffusion; } diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index eff76bcd9f38..7aad568e375f 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -361,11 +361,10 @@ void CIncNSSolver::Compute_Enthalpy_Diffusion(unsigned long iEdge, CGeometry* ge /*--- Helper function that retrieves enthalpy diffusion terms. ---*/ auto GetEnthalpyDiffusionTerms = [&](unsigned long Point, const su2double* Species, su2double* EnthalpyDiffusion, - su2double* MassCorrectionDiffusion, su2double* GradEnthalpyDiffusion) { + su2double* GradEnthalpyDiffusion) { FluidModel->SetTDState_T(nodes->GetPrimitive(Point)[prim_idx.Temperature()], Species); FluidModel->SetEddyViscosity(nodes->GetPrimitive(Point)[prim_idx.EddyViscosity()]); FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion); - FluidModel->GetMassCorrectionDiffusivity(MassCorrectionDiffusion); if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion); }; @@ -388,24 +387,18 @@ void CIncNSSolver::Compute_Enthalpy_Diffusion(unsigned long iEdge, CGeometry* ge /*--- Get enthalpy diffusion terms and its gradient(for implicit) for each species at iPoint and jPoint. ---*/ su2double EnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; - su2double MassCorrectionDiffusion_i[MAXNVAR_SPECIES]{0.0}; su2double GradEnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; su2double EnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; - su2double MassCorrectionDiffusion_j[MAXNVAR_SPECIES]{0.0}; su2double GradEnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; - GetEnthalpyDiffusionTerms(iPoint, Species_i, EnthalpyDiffusion_i, MassCorrectionDiffusion_i, GradEnthalpyDiffusion_i); - GetEnthalpyDiffusionTerms(jPoint, Species_j, EnthalpyDiffusion_j, MassCorrectionDiffusion_j, GradEnthalpyDiffusion_j); + GetEnthalpyDiffusionTerms(iPoint, Species_i, EnthalpyDiffusion_i, GradEnthalpyDiffusion_i); + GetEnthalpyDiffusionTerms(jPoint, Species_j, EnthalpyDiffusion_j, GradEnthalpyDiffusion_j); /*--- Compute Enthalpy diffusion flux and its jacobian (for implicit iterations) ---*/ su2double flux_enthalpy_diffusion = 0.0; - su2double flux_massCorrection_diffusion = 0.0; su2double jac_flux_enthalpy_diffusion = 0.0; for (int i_species = 0; i_species < n_species; i_species++) { flux_enthalpy_diffusion += 0.5 * (EnthalpyDiffusion_i[i_species] + EnthalpyDiffusion_j[i_species]) * Proj_Mean_GradScalarVar[i_species]; - flux_massCorrection_diffusion += 0.5 * - (MassCorrectionDiffusion_i[i_species] + MassCorrectionDiffusion_j[i_species]) * - Proj_Mean_GradScalarVar[i_species]; if (implicit) jac_flux_enthalpy_diffusion += 0.5 * (GradEnthalpyDiffusion_i[i_species] + GradEnthalpyDiffusion_j[i_species]) * Proj_Mean_GradScalarVar[i_species]; @@ -414,7 +407,6 @@ void CIncNSSolver::Compute_Enthalpy_Diffusion(unsigned long iEdge, CGeometry* ge /*--- Set heat flux and jacobian (for implicit) due to enthalpy diffusion ---*/ numerics->SetHeatFluxDiffusion(flux_enthalpy_diffusion); - numerics->SetMassCorrFluxDiffusion(flux_massCorrection_diffusion); if (implicit) numerics->SetJacHeatFluxDiffusion(jac_flux_enthalpy_diffusion); } From 9bcd2bd080aeb5775945e9c13b0a6f32b046edd0 Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Thu, 15 Jan 2026 17:25:48 +0100 Subject: [PATCH 162/173] small cleaning --- SU2_CFD/include/numerics/species/species_sources.hpp | 5 +---- SU2_CFD/src/fluid/CFluidScalar.cpp | 6 ------ SU2_CFD/src/numerics/species/species_sources.cpp | 4 +--- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/SU2_CFD/include/numerics/species/species_sources.hpp b/SU2_CFD/include/numerics/species/species_sources.hpp index e496767135f3..c32441e95e3f 100644 --- a/SU2_CFD/include/numerics/species/species_sources.hpp +++ b/SU2_CFD/include/numerics/species/species_sources.hpp @@ -100,9 +100,6 @@ class CSourceAxisymmetric_Species : public CSourceBase_Species { */ template class CSourceCombustion_Species : public CSourceBase_Species { - protected: - const FlowIndices idx; /*!< \brief Object to manage the access to the flow primitives. */ - const bool incompressible; public: /*! @@ -114,7 +111,7 @@ class CSourceCombustion_Species : public CSourceBase_Species { CSourceCombustion_Species(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! - * \brief Residual of the axisymmetric source term. + * \brief Residual of the combustion source term. * \param[in] config - Definition of the particular problem. * \return Lightweight const-view of residual and Jacobian. */ diff --git a/SU2_CFD/src/fluid/CFluidScalar.cpp b/SU2_CFD/src/fluid/CFluidScalar.cpp index 6db0d47e22ef..2335f6e0eebe 100644 --- a/SU2_CFD/src/fluid/CFluidScalar.cpp +++ b/SU2_CFD/src/fluid/CFluidScalar.cpp @@ -243,12 +243,6 @@ void CFluidScalar::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusion } } -// void CFluidScalar::GetMassCorrectionDiffusivity(su2double* massCorrection_diffusions) { -// for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { -// massCorrection_diffusions[iVar] = Density * (massDiffusivity[iVar] - massDiffusivity[n_species_mixture - 1]); -// } -// } - void CFluidScalar::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { MassToMoleFractions(val_scalars); ComputeGasConstant(); diff --git a/SU2_CFD/src/numerics/species/species_sources.cpp b/SU2_CFD/src/numerics/species/species_sources.cpp index 61eee8878b43..8934cc9b2997 100644 --- a/SU2_CFD/src/numerics/species/species_sources.cpp +++ b/SU2_CFD/src/numerics/species/species_sources.cpp @@ -138,9 +138,7 @@ CNumerics::ResidualType<> CSourceAxisymmetric_Species::ComputeResidual(const template CSourceCombustion_Species::CSourceCombustion_Species(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) - : CSourceBase_Species(val_nDim, val_nVar, config), - idx(val_nDim, config->GetnSpecies()), - incompressible(config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE) {} + : CSourceBase_Species(val_nDim, val_nVar, config) {} template CNumerics::ResidualType<> CSourceCombustion_Species::ComputeResidual(const CConfig* config) { From b3db5e2a0d9775ced522b4ba815550ec01eeecef Mon Sep 17 00:00:00 2001 From: Cristopher-Morales Date: Mon, 19 Jan 2026 16:41:08 +0100 Subject: [PATCH 163/173] updating test case --- .../species2_primitiveVenturi_CANTERA.cfg | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg index 70b917836f5b..befcbaeca56b 100644 --- a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg +++ b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg @@ -2,12 +2,12 @@ % % % SU2 configuration file % % Case description: Species mixing with 2 species, i.e. 1 transport equations % -% Including mixture dependent density, viscosity, thermal % -% conductivity % +% Including CANTERA fluid model. Fluid properties obtained % +% directly from CANTERA. % % Author: Cristopher Morales Ubal % % Institution: Eindhoven University of Technology % -% Date: 2022/06/15 % -% File Version 8.0.1 "Harrier" % +% Date: 2026/01/19 % +% File Version 8.4.0 "Harrier" % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -35,29 +35,17 @@ COMBUSTION = NO % THERMODYNAMIC_PRESSURE= 101325.0 % -MOLECULAR_WEIGHT= 28.96 -% -SPECIFIC_HEAT_CP = 1009.39 -% CONDUCTIVITY_MODEL= CANTERA -THERMAL_CONDUCTIVITY_CONSTANT= 0.0357 % -PRANDTL_LAM= 0.72 TURBULENT_CONDUCTIVITY_MODEL= NONE -PRANDTL_TURB= 0.90 % GAS_COMPOSITION_NAMES= H2, O2 CHEMICAL_MECHANISM_FILE= h2o2.yaml PHASE_NAME= ohmech TRANSPORT_MODEL= mixture-averaged % -% -% --------------------------- VISCOSITY MODEL ---------------------------------% -% VISCOSITY_MODEL= CANTERA % -MU_CONSTANT= 1.716E-5 -% % -------------------- BOUNDARY CONDITION DEFINITION --------------------------% % MARKER_HEATFLUX= ( wall, 0.0 ) @@ -130,7 +118,7 @@ CONV_STARTITER= 10 % MESH_FILENAME= primitiveVenturi.su2 SCREEN_OUTPUT= INNER_ITER WALL_TIME \ - RMS_PRESSURE RMS_VELOCITY-X RMS_VELOCITY-Y RMS_TKE RMS_DISSIPATION RMS_SPECIES_0 \ + RMS_PRESSURE RMS_VELOCITY-X RMS_VELOCITY-Y RMS_ENTHALPY RMS_TKE RMS_DISSIPATION RMS_SPECIES_H2 \ LINSOL_ITER LINSOL_RESIDUAL \ LINSOL_ITER_TURB LINSOL_RESIDUAL_TURB \ LINSOL_ITER_SPECIES LINSOL_RESIDUAL_SPECIES SURFACE_SPECIES_VARIANCE @@ -141,7 +129,7 @@ MARKER_ANALYZE= outlet gas_inlet air_axial_inlet % OUTPUT_FILES= RESTART_ASCII, PARAVIEW_MULTIBLOCK VOLUME_OUTPUT= RESIDUAL, PRIMITIVE -OUTPUT_WRT_FREQ= 1000 +OUTPUT_WRT_FREQ= 100 % RESTART_SOL= NO SOLUTION_FILENAME= solution From 93a222dac7a8c6f9e751545132b04cac7ee379cf Mon Sep 17 00:00:00 2001 From: bigfooted Date: Sun, 23 Aug 2026 13:28:31 +0200 Subject: [PATCH 164/173] precommit --- .../SU2_CFD/fluid/CFluidCantera_tests.cpp | 2 +- meson_scripts/build_cantera.py | 30 +++++++++++++++---- meson_scripts/init.py | 2 +- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp index e0af2a0d299a..0062806e5307 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp @@ -92,4 +92,4 @@ TEST_CASE("Fluid_Cantera_Combustion", "[Reacting_flow]") { CHECK(sourceTerm_H2 == Approx(-0.13633797171426)); CHECK(sourceTerm_O2 == Approx(-2.16321066087493)); } -#endif \ No newline at end of file +#endif diff --git a/meson_scripts/build_cantera.py b/meson_scripts/build_cantera.py index ee4f7f492f91..c64ecc169168 100644 --- a/meson_scripts/build_cantera.py +++ b/meson_scripts/build_cantera.py @@ -72,12 +72,30 @@ def main(): parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--source", required=True, help="Path to the Cantera submodule checkout") - parser.add_argument("--prefix", required=True, help="Install prefix for the built library") - parser.add_argument("--stamp", required=True, help="File to create on a successful build, for meson tracking") - parser.add_argument("--boost-inc-dir", default="", help="Explicit Boost header directory (optional)") - parser.add_argument("--eigen-inc-dir", required=True, help="SU2's own Eigen include directory (externals/eigen)") - parser.add_argument("--cpu-arch", default="", help="Value of SU2's -march= target (cpu-arch option), kept in sync so Eigen template code Cantera and SU2 both instantiate is not ODR-mixed across incompatible vectorization ISAs") + parser.add_argument( + "--source", required=True, help="Path to the Cantera submodule checkout" + ) + parser.add_argument( + "--prefix", required=True, help="Install prefix for the built library" + ) + parser.add_argument( + "--stamp", + required=True, + help="File to create on a successful build, for meson tracking", + ) + parser.add_argument( + "--boost-inc-dir", default="", help="Explicit Boost header directory (optional)" + ) + parser.add_argument( + "--eigen-inc-dir", + required=True, + help="SU2's own Eigen include directory (externals/eigen)", + ) + parser.add_argument( + "--cpu-arch", + default="", + help="Value of SU2's -march= target (cpu-arch option), kept in sync so Eigen template code Cantera and SU2 both instantiate is not ODR-mixed across incompatible vectorization ISAs", + ) args = parser.parse_args() if not os.path.exists(os.path.join(args.source, "SConstruct")): diff --git a/meson_scripts/init.py b/meson_scripts/init.py index b0804c779916..a6d4ec225314 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -111,7 +111,7 @@ def init_submodules( alt_name_eigen = base_path + "eigen" alt_name_mpp = cur_dir + os.path.sep + "subprojects" + os.path.sep + "Mutationpp" alt_name_coolprop = cur_dir + os.path.sep + "subprojects" + os.path.sep + "CoolProp" - alt_name_cantera = cur_dir + os.path.sep + "subprojects" + os.path.sep + "cantera" + alt_name_cantera = cur_dir + os.path.sep + "subprojects" + os.path.sep + "cantera" alt_name_mlpcpp = cur_dir + os.path.sep + "subprojects" + os.path.sep + "MLPCpp" if method == "auto": From 285d574faa7378ee6ec6d663af06b76938ee9e02 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Sun, 4 Oct 2026 09:18:24 +0200 Subject: [PATCH 165/173] cleanup, fix small bugs, add jacobian terms. --- Common/include/CConfig.hpp | 30 ++- Common/src/CConfig.cpp | 10 +- SU2_CFD/include/fluid/CFluidCantera.hpp | 105 +++++--- SU2_CFD/include/fluid/CFluidModel.hpp | 17 ++ SU2_CFD/include/numerics/CNumerics.hpp | 16 +- .../numerics/species/species_sources.hpp | 1 + SU2_CFD/include/solvers/CIncNSSolver.hpp | 9 + .../include/variables/CSpeciesVariable.hpp | 16 ++ SU2_CFD/src/fluid/CFluidCantera.cpp | 245 +++++++++++------- SU2_CFD/src/meson.build | 11 +- .../src/numerics/species/species_sources.cpp | 12 +- SU2_CFD/src/output/CFlowOutput.cpp | 15 +- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 20 +- SU2_CFD/src/solvers/CIncNSSolver.cpp | 71 ++--- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 58 ++--- SU2_CFD/src/variables/CIncNSVariable.cpp | 4 +- SU2_CFD/src/variables/CSpeciesVariable.cpp | 1 + .../SU2_CFD/fluid/CFluidCantera_tests.cpp | 72 +++++ .../fluid/multicomponent_cantera_gri30.cfg | 39 +++ UnitTests/SU2_CFD/fluid/one_step_ch4.cfg | 41 +++ UnitTests/SU2_CFD/fluid/one_step_ch4.yaml | 82 ++++++ meson.build | 1 + meson_options.txt | 1 + meson_scripts/build_cantera.py | 20 +- 24 files changed, 671 insertions(+), 226 deletions(-) create mode 100644 UnitTests/SU2_CFD/fluid/multicomponent_cantera_gri30.cfg create mode 100644 UnitTests/SU2_CFD/fluid/one_step_ch4.cfg create mode 100644 UnitTests/SU2_CFD/fluid/one_step_ch4.yaml diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index e80423648b13..43ee3b06c510 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -88,7 +88,8 @@ class CConfig { string PhaseName; /*!< \brief Name of the phase in the chemical mechanism file used in Cantera. */ unsigned short n_GasCompositionNames; /*!<\brief Number of gases in mixture composition for Cantera. */ bool Combustion; /*!< \brief Flag for Combustion Detailed chemistry problems using Cantera. */ - su2double Spark_Temperature; /*!< \bried Spark temperature used for ignition in detailed chemistry using Cantera. */ + bool Chemical_Source_Jacobian; /*!< \brief Flag for the diagonal chemical source Jacobian in the species equations. */ + su2double Spark_Temperature; /*!< \brief Spark temperature used for ignition in detailed chemistry using Cantera. */ string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */ unsigned short nConvField; /*!< \brief Number of fields used to monitor convergence.*/ @@ -3410,6 +3411,14 @@ class CConfig { */ unsigned long GetInnerIter(void) const { return InnerIter; } + /*! + * \brief Get the iteration counter that times a spark ignition. + * \return Outer iteration (multizone), time iteration (unsteady) or inner iteration. + */ + unsigned long GetIgnitionIter() const { + return Multizone_Problem ? OuterIter : (Time_Domain ? TimeIter : InnerIter); + } + /*! * \brief Set the current physical time. * \param[in] val_t - Current physical time. @@ -4111,13 +4120,11 @@ class CConfig { /*! * \brief Returns the gas composition used in Cantera. */ - string GetChemical_GasComposition(unsigned short val_index = 0) const { return GasCompositionNames[val_index]; } - - /*! - * \brief Set the gas composition used in Cantera. - */ - void SetChemical_GasComposition(unsigned short val_index, string gas_composition) const { - GasCompositionNames[val_index] = gas_composition; + string GetChemical_GasComposition(unsigned short val_index = 0) const { + if (val_index >= n_GasCompositionNames) { + SU2_MPI::Error("Index out of range for GAS_COMPOSITION_NAMES.", CURRENT_FUNCTION); + } + return GasCompositionNames[val_index]; } /*! @@ -4126,11 +4133,16 @@ class CConfig { */ bool GetCombustion(void) const { return Combustion; } + /*! + * \brief Get whether the diagonal chemical sink Jacobian is added to the implicit species equations. + */ + bool GetChemical_Source_Jacobian(void) const { return Chemical_Source_Jacobian; } + /*! * \brief Get High temperature applied during spark ignition. * \return Spark Temperature. */ - const su2double GetSpark_Temperature(void) const { + su2double GetSpark_Temperature(void) const { return Spark_Temperature; } diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 4f88883f1352..3bc6e11f89ea 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1287,14 +1287,16 @@ void CConfig::SetConfig_Options() { addStringOption("TRANSPORT_MODEL", TransportModel, string("mixture-averaged")); /*!\brief CHEMICAL_MECHANISM_FILE \n DESCRIPTION: Chemical reaction mechanism \n OPTIONS: see Cantera homepage \n DEFAULT: h2o2.yaml \ingroup Config*/ addStringOption("CHEMICAL_MECHANISM_FILE", ChemicalMechanismFile, string("h2o2.yaml")); - /*!\brief PHASE_NAME \n DESCRIPTION: name of the phase in the chemical mechanism file \n OPTIONS: see Cantera homepage \n DEFAULT: gri30 \ingroup Config*/ + /*!\brief PHASE_NAME \n DESCRIPTION: name of the phase in the chemical mechanism file \n OPTIONS: see Cantera homepage \n DEFAULT: ohmech \ingroup Config*/ addStringOption("PHASE_NAME", PhaseName, string("ohmech")); /*!\brief GAS_COMPOSITION_NAMES \n DESCRIPTION: Gas composition names \n OPTIONS: see Cantera homepage \n DEFAULT: \ingroup Config*/ addStringListOption("GAS_COMPOSITION_NAMES", n_GasCompositionNames, GasCompositionNames); - /*\brief COMBUSTION \n DESCRIPTION: Combustion Detailed chemistry using Cantera \n DEFAULT: false \ingroup Config*/ + /*!\brief COMBUSTION \n DESCRIPTION: Combustion Detailed chemistry using Cantera \n DEFAULT: false \ingroup Config*/ addBoolOption("COMBUSTION", Combustion, false); /*!\brief SPARK_TEMPERATURE \n DESCRIPTION: Spark temperature used for ignition in detailed chemistry using Cantera \n DEFAULT: 1000 K \ingroup Config*/ addDoubleOption("SPARK_TEMPERATURE", Spark_Temperature, 1000.0); + /*!\brief CHEMICAL_SOURCE_JACOBIAN \n DESCRIPTION: Add the diagonal chemical sink Jacobian to the implicit species equations \n DEFAULT: true \ingroup Config*/ + addBoolOption("CHEMICAL_SOURCE_JACOBIAN", Chemical_Source_Jacobian, true); /*!\par CONFIG_CATEGORY: Data-driven fluid model parameters \ingroup Config*/ /*!\brief INTERPOLATION_METHOD \n DESCRIPTION: Interpolation method used to determine the thermodynamic state of the fluid. \n OPTIONS: See \link DataDrivenMethod_Map \endlink DEFAULT: MLP \ingroup Config*/ @@ -4427,7 +4429,7 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i if ((Kind_FluidModel != FLUID_CANTERA) && (Combustion == true)) { SU2_MPI::Error( - "The use of COMBUSTION=YES requires the use of FLUID_MIXTURE=FLUID_CANTERA,\n" + "The use of COMBUSTION=YES requires the use of FLUID_MODEL=FLUID_CANTERA,\n" "detailed chemistry cannot be performed with other fluid models", CURRENT_FUNCTION); } @@ -4465,7 +4467,7 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i if (Ref_Inc_NonDim != DIMENSIONAL) { SU2_MPI::Error( - "The use of FLUID_CANTERA requiere the option INC_NONDIM= DIMENSIONAL, the nondimensionalization is " + "The use of FLUID_CANTERA requires the option INC_NONDIM= DIMENSIONAL, the nondimensionalization is " "currently unavailable.", CURRENT_FUNCTION); } diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 95a3492862e4..99495c6afa71 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -28,7 +28,8 @@ #pragma once #include -#include +#include +#include #include "CFluidModel.hpp" @@ -47,10 +48,9 @@ class Solution; */ class CFluidCantera final : public CFluidModel { private: - #ifdef USE_CANTERA +#ifdef USE_CANTERA const int n_species_mixture; /*!< \brief Number of species in mixture. */ const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */ - const su2double GasConstant_Ref; /*!< \brief Gas constant reference needed for Nondimensional problems. */ const su2double Prandtl_Turb_Number; /*!< \brief Prandlt turbulent number.*/ const su2double Schmidt_Turb_Number; /*!< \brief Schmidt turbulent number.*/ const string Transport_Model; /*!< \brief Transport model used for computing mixture properties*/ @@ -58,24 +58,27 @@ class CFluidCantera final : public CFluidModel { const string Phase_Name; /*!< \brief Name of the phase used for in cantera*/ const bool Combustion; /*!< \brief Flag for problems involving combustion.*/ - static constexpr int ARRAYSIZE = 16; - - su2double Heat_Release; /*!< \brief heat release due to combustion */ - std::array speciesIndices; /*!< \brief Species indices within Cantera library. */ - std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ - std::array chemicalSourceTerm; /*!< \brief chemical source term of all species*/ - std::array molarMasses; /*!< \brief Molar masses of all species. */ - std::array enthalpyFormation; /*!< \brief Enthalpy of Formation of all species. */ - std::array massFractions; /*!< \brief Mass fractions of all species. */ - std::array massDiffusivity; /*!< \brief mass diffusivity of all species. */ - vector netProductionRates; /*!< \brief Net chemical production rates of all species*/ - mutable vector enthalpiesSpecies; /*!< \brief Molar enthalpies of all species. */ - mutable vector specificHeatSpecies; /*!< \brief Molar heat capacities of all species. */ - - /*! - * \brief Compute heat release due to combustion. - */ - void ComputeHeatRelease(); + su2double Heat_Release{0.0}; /*!< \brief heat release due to combustion */ + bool stateFailed{false}; /*!< \brief The last state evaluation did not converge. */ + double minTemperature{0.0}; /*!< \brief Lower temperature bound of the Newton iteration. */ + double maxTemperature{0.0}; /*!< \brief Upper temperature bound of the Newton iteration. */ + double temperatureGuess{0.0}; /*!< \brief Start of the next temperature iteration, 0 if unset. */ + std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ + std::vector speciesIndices; /*!< \brief Mechanism index of each transported species. */ + std::vector chemicalSourceTerm; /*!< \brief Chemical source term of the transported species. */ + std::vector chemicalSourceJacobian; /*!< \brief Diagonal sink Jacobian of the transported species. */ + std::vector enthalpyFormation; /*!< \brief Enthalpy of formation of the transported species. */ + std::vector molarMasses; /*!< \brief Molar masses of all mechanism species. */ + std::vector massFractions; /*!< \brief Mass fractions of all mechanism species. */ + std::vector netProductionRates; /*!< \brief Net production rates of all mechanism species. */ + std::vector destructionRates; /*!< \brief Destruction rates of all mechanism species. */ + mutable std::vector massDiffusivity; /*!< \brief Mass diffusivity of all mechanism species. */ + mutable std::vector enthalpiesSpecies; /*!< \brief Molar enthalpies of all mechanism species. */ + mutable std::vector specificHeatSpecies; /*!< \brief Molar heat capacities of all mechanism species. */ + mutable su2double laminarViscosity{0.0}; /*!< \brief Laminar viscosity at the current state. */ + mutable su2double laminarConductivity{0.0}; /*!< \brief Laminar thermal conductivity at the current state. */ + mutable bool transportValid{false}; /*!< \brief Viscosity and conductivity match the current state. */ + mutable bool diffusivityValid{false}; /*!< \brief Mass diffusivities match the current state. */ /*! * \brief Set enthalpies of formation. @@ -87,6 +90,21 @@ class CFluidCantera final : public CFluidModel { * \param[in] val_scalars - Scalar mass fractions. */ void SetMassFractions(const su2double* val_scalars); + + /*! + * \brief Set the thermodynamic state at the given temperature and the current composition. + */ + void SetThermoState(double val_temperature); + + /*! + * \brief Evaluate viscosity and conductivity of the current state when they are out of date. + */ + void UpdateTransport() const; + + /*! + * \brief Evaluate the mass diffusivities of the current state when they are out of date. + */ + void UpdateDiffusivity() const; #endif public: @@ -95,26 +113,34 @@ class CFluidCantera final : public CFluidModel { */ CFluidCantera(su2double val_operating_pressure, const CConfig* config); - #ifdef USE_CANTERA - +#ifdef USE_CANTERA /*! * \brief Get fluid laminar viscosity. */ - inline su2double GetLaminarViscosity() override { return Mu; } + inline su2double GetLaminarViscosity() override { + UpdateTransport(); + return laminarViscosity; + } /*! * \brief Get fluid thermal conductivity. */ - inline su2double GetThermalConductivity() override { return Kt + Mu_Turb * Cp / Prandtl_Turb_Number; } + inline su2double GetThermalConductivity() override { + UpdateTransport(); + return laminarConductivity + Mu_Turb * Cp / Prandtl_Turb_Number; + } /*! * \brief Get fluid mass diffusivity. * \param[in] ivar - index of species. */ - inline su2double GetMassDiffusivity(int ivar) override { return massDiffusivity[speciesIndices[ivar]]; } + inline su2double GetMassDiffusivity(int ivar) override { + UpdateDiffusivity(); + return massDiffusivity[speciesIndices[ivar]]; + } /*! - * \brief Compute chemical source term for species. + * \brief Compute chemical source term and heat release from the current state. */ void ComputeChemicalSourceTerm() override; @@ -124,11 +150,22 @@ class CFluidCantera final : public CFluidModel { */ inline su2double GetChemicalSourceTerm(int ivar) override { return chemicalSourceTerm[ivar]; } + /*! + * \brief Get the derivative of the chemical source term with respect to the own mass fraction (always <= 0). + * \param[in] ivar - index of species. + */ + inline su2double GetChemicalSourceJacobian(int ivar) override { return chemicalSourceJacobian[ivar]; } + /*! * \brief Get Heat release due to combustion. */ inline su2double GetHeatRelease() override { return Heat_Release; } + /*! + * \brief Whether the last state evaluation failed to converge or needed a temperature far outside the data range. + */ + inline bool GetStateFailed() const override { return stateFailed; } + /*! * \brief Get enthalpy diffusivity terms. */ @@ -147,10 +184,18 @@ class CFluidCantera final : public CFluidModel { void SetTDState_T(su2double val_temperature, const su2double* val_scalars) override; /*! - * \brief Virtual member. + * \brief Set the state from enthalpy by Newton iteration on temperature. * \param[in] val_enthalpy - Enthalpy value at the point. * \param[in] val_scalars - Scalar mass fractions. */ void SetTDState_h(su2double val_enthalpy, const su2double* val_scalars) override; - #endif -}; \ No newline at end of file + + /*! + * \brief Set the start of the next temperature iteration of SetTDState_h, used once. + * \param[in] val_temperature - Temperature guess. + */ + inline void SetTemperatureGuess(su2double val_temperature) override { + temperatureGuess = SU2_TYPE::GetValue(val_temperature); + } +#endif +}; diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index d6734cafdcb7..1ead7e23c5e2 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -203,11 +203,22 @@ class CFluidModel { */ inline virtual su2double GetChemicalSourceTerm(int iVar) { return 0.0; } + /*! + * \brief Get the derivative of the chemical source term of a species with respect to its own mass fraction. + * \param[in] iVar - index of species. + */ + inline virtual su2double GetChemicalSourceJacobian(int iVar) { return 0.0; } + /*! * \brief Get Heat release due to combustion. */ inline virtual su2double GetHeatRelease() { return 0.0; } + /*! + * \brief Whether the last state evaluation failed and the state must be treated as non-physical. + */ + inline virtual bool GetStateFailed() const { return false; } + /*! * \brief Get the enthalpy diffusivity terms for all species being solved. * @@ -392,6 +403,12 @@ class CFluidModel { */ virtual void SetTDState_h(su2double val_enthalpy, const su2double* val_scalars = nullptr) {} + /*! + * \brief Virtual member. Initial temperature for the next iterative SetTDState_h call. + * \param[in] val_temperature - Temperature guess, e.g. the previous value at the point. + */ + virtual void SetTemperatureGuess(su2double val_temperature) {} + /*! * \brief Set fluid eddy viscosity provided by a turbulence model needed for computing effective thermal conductivity. */ diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 009f9a6c00cd..c1470948273a 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -63,8 +63,10 @@ class CNumerics { const su2double *Diffusion_Coeff_i, /*!< \brief Species diffusion coefficients at point i. */ *Diffusion_Coeff_j, /*!< \brief Species diffusion coefficients at point j. */ - *Chemical_Source_Term_i, /*!< \brief Species diffusion coefficients at point i. */ - *Chemical_Source_Term_j; /*!< \brief Species diffusion coefficients at point j. */ + *Chemical_Source_Term_i, /*!< \brief Chemical source terms of the species at point i. */ + *Chemical_Source_Term_j, /*!< \brief Chemical source terms of the species at point j. */ + *Chemical_Source_Jacobian_i, /*!< \brief Derivative of the chemical source terms with respect to the mass fractions at point i. */ + *Chemical_Source_Jacobian_j; /*!< \brief Derivative of the chemical source terms with respect to the mass fractions at point j. */ su2double Laminar_Viscosity_i, /*!< \brief Laminar viscosity at point i. */ Laminar_Viscosity_j; /*!< \brief Laminar viscosity at point j. */ @@ -842,6 +844,16 @@ class CNumerics { Chemical_Source_Term_j = val_source_term_j; } + /*! + * \brief Set the diagonal Jacobian of the chemical source term + * \param[in] val_jacobian_i - Derivatives of the chemical source terms with respect to the own mass fraction at i. + * \param[in] val_jacobian_j - Same at j. + */ + inline void SetChemicalSourceJacobian(const su2double* val_jacobian_i, const su2double* val_jacobian_j) { + Chemical_Source_Jacobian_i = val_jacobian_i; + Chemical_Source_Jacobian_j = val_jacobian_j; + } + /*! * \brief Set the heat flux due to enthalpy diffusion * \param[in] val_heatfluxdiffusion - Value of the heat flux due to enthalpy diffusion. diff --git a/SU2_CFD/include/numerics/species/species_sources.hpp b/SU2_CFD/include/numerics/species/species_sources.hpp index 8eb75eddd955..c7357ef06431 100644 --- a/SU2_CFD/include/numerics/species/species_sources.hpp +++ b/SU2_CFD/include/numerics/species/species_sources.hpp @@ -100,6 +100,7 @@ class CSourceAxisymmetric_Species : public CSourceBase_Species { */ template class CSourceCombustion_Species : public CSourceBase_Species { + const bool chemical_jacobian; /*!< \brief Add the diagonal chemical sink Jacobian to the implicit system. */ public: /*! diff --git a/SU2_CFD/include/solvers/CIncNSSolver.hpp b/SU2_CFD/include/solvers/CIncNSSolver.hpp index b9dc5b18686f..48da3a2b8636 100644 --- a/SU2_CFD/include/solvers/CIncNSSolver.hpp +++ b/SU2_CFD/include/solvers/CIncNSSolver.hpp @@ -38,6 +38,15 @@ class CIncNSSolver final : public CIncEulerSolver { FluidFlamelet_ParsedOptions flamelet_config_options; su2double TemperatureLimits[2]; + su2activematrix EnthalpyDiffusion; /*!< \brief Enthalpy diffusion coefficient of each species at each point. */ + su2activematrix GradEnthalpyDiffusion; /*!< \brief Temperature derivative of EnthalpyDiffusion. */ + + /*! + * \brief Evaluate the enthalpy diffusion coefficients once per point for use by the edge loop. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] config - Definition of the particular problem. + */ + void ComputeEnthalpyDiffusionTerms(CSolver** solver_container, const CConfig* config); /*! * \brief Generic implementation of the isothermal, heatflux and heat-transfer/convection walls. diff --git a/SU2_CFD/include/variables/CSpeciesVariable.hpp b/SU2_CFD/include/variables/CSpeciesVariable.hpp index 110dd4120c5e..6219bc4f28d9 100644 --- a/SU2_CFD/include/variables/CSpeciesVariable.hpp +++ b/SU2_CFD/include/variables/CSpeciesVariable.hpp @@ -37,6 +37,7 @@ class CSpeciesVariable : public CScalarVariable { protected: MatrixType Diffusivity; /*!< \brief Matrix (nPoint,nVar) of mass diffusivities for scalar transport. */ MatrixType SpeciesSourceTerm; /*!< \brief Matrix (nPoint, nVar) of chemical source terms for species transport*/ + MatrixType SpeciesSourceJacobian; /*!< \brief Matrix (nPoint, nVar) of the diagonal chemical source Jacobian. */ VectorType HeatRelease; /*!< \brief Vector of heat release due to combustion for species transport*/ public: @@ -101,6 +102,21 @@ class CSpeciesVariable : public CScalarVariable { */ inline const su2double* GetChemicalSourceTerm(unsigned long iPoint) const { return SpeciesSourceTerm[iPoint]; } + /*! + * \brief Set the derivative of the chemical source term of a species with respect to its own mass fraction. + * \param[in] val_jacobian - the derivative. + * \param[in] val_ivar - species index. + */ + inline void SetChemicalSourceJacobian(unsigned long iPoint, su2double val_jacobian, unsigned short val_ivar) { + SpeciesSourceJacobian(iPoint, val_ivar) = val_jacobian; + } + + /*! + * \brief Get the diagonal chemical source Jacobian of a point. + * \return Pointer to the derivatives of the species source terms with respect to their own mass fractions. + */ + inline const su2double* GetChemicalSourceJacobian(unsigned long iPoint) const { return SpeciesSourceJacobian[iPoint]; } + /*! * \brief Get heat release due to combustion * \param[in] iPoint - Point index. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 43a4f6df039e..29c8bcc258b9 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -27,9 +27,9 @@ #include "../../include/fluid/CFluidCantera.hpp" +#include #include -// #include #ifdef USE_CANTERA #include #include @@ -40,155 +40,204 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* : CFluidModel(), n_species_mixture(config->GetnSpecies() + 1), Pressure_Thermodynamic(value_pressure_operating), - GasConstant_Ref(config->GetGas_Constant_Ref()), Prandtl_Turb_Number(config->GetPrandtl_Turb()), Schmidt_Turb_Number(config->GetSchmidt_Number_Turbulent()), Transport_Model(config->GetTransport_Model()), Chemical_MechanismFile(config->GetChemical_MechanismFile()), Phase_Name(config->GetPhase_Name()), Combustion(config->GetCombustion()) { - if (n_species_mixture > ARRAYSIZE) { - SU2_MPI::Error("Too many species, increase ARRAYSIZE", CURRENT_FUNCTION); - } - sol = std::shared_ptr(newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model)); - sol->thermo()->getMolecularWeights(&molarMasses[0]); - for (int iVar = 0; iVar < n_species_mixture; iVar++) { - speciesIndices[iVar] = sol->thermo()->speciesIndex(config->GetChemical_GasComposition(iVar)); + try { + sol = std::shared_ptr(newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model)); + const auto& thermo = *sol->thermo(); + const size_t nSpeciesMechanism = thermo.nSpecies(); + + molarMasses.resize(nSpeciesMechanism); + massFractions.assign(nSpeciesMechanism, 0.0); + massDiffusivity.assign(nSpeciesMechanism, 0.0); + netProductionRates.assign(nSpeciesMechanism, 0.0); + destructionRates.assign(nSpeciesMechanism, 0.0); + enthalpiesSpecies.assign(nSpeciesMechanism, 0.0); + specificHeatSpecies.assign(nSpeciesMechanism, 0.0); + thermo.getMolecularWeights(molarMasses.data()); + /*--- Moderate extrapolation of the thermodynamic polynomials is allowed beyond the range of the data. ---*/ + minTemperature = 0.5 * thermo.minTemp(); + maxTemperature = 2.0 * thermo.maxTemp(); + + speciesIndices.resize(n_species_mixture); + for (int iVar = 0; iVar < n_species_mixture; iVar++) { + const string name = config->GetChemical_GasComposition(iVar); + const size_t index = thermo.speciesIndex(name); + if (index == npos) { + SU2_MPI::Error("Species '" + name + "' of GAS_COMPOSITION_NAMES is not part of phase '" + Phase_Name + + "' in " + Chemical_MechanismFile + ".", + CURRENT_FUNCTION); + } + if (std::find(speciesIndices.begin(), speciesIndices.begin() + iVar, index) != speciesIndices.begin() + iVar) { + SU2_MPI::Error("Species '" + name + "' appears more than once in GAS_COMPOSITION_NAMES.", CURRENT_FUNCTION); + } + speciesIndices[iVar] = index; + } + + chemicalSourceTerm.assign(n_species_mixture, 0.0); + chemicalSourceJacobian.assign(n_species_mixture, 0.0); + enthalpyFormation.assign(n_species_mixture, 0.0); + if (Combustion) SetEnthalpyFormation(config); + } catch (const CanteraError& error) { + SU2_MPI::Error(string("Cantera error during initialization: ") + error.what(), CURRENT_FUNCTION); } - enthalpiesSpecies.resize(sol->thermo()->nSpecies()); - specificHeatSpecies.resize(sol->thermo()->nSpecies()); - netProductionRates.resize(sol->thermo()->nSpecies()); - if (Combustion) SetEnthalpyFormation(config); } void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { SetMassFractions(config->GetSpecies_Init()); sol->thermo()->setMassFractions(massFractions.data()); - sol->thermo()->setState_TP(STD_REF_TEMP, Pressure_Thermodynamic); + sol->thermo()->setState_TP(STD_REF_TEMP, SU2_TYPE::GetValue(Pressure_Thermodynamic)); sol->thermo()->getEnthalpy_RT_ref(enthalpiesSpecies.data()); for (int iVar = 0; iVar < n_species_mixture; iVar++) { - enthalpyFormation[iVar] = - GasConstant * STD_REF_TEMP * enthalpiesSpecies[speciesIndices[iVar]] / molarMasses[speciesIndices[iVar]]; + const size_t k = speciesIndices[iVar]; + enthalpyFormation[iVar] = GasConstant * STD_REF_TEMP * enthalpiesSpecies[k] / molarMasses[k]; } } void CFluidCantera::ComputeChemicalSourceTerm() { - sol->kinetics()->getNetProductionRates(netProductionRates.data()); - for (int iVar = 0; iVar < n_species_mixture - 1.0; iVar++) { - chemicalSourceTerm[iVar] = molarMasses[speciesIndices[iVar]] * netProductionRates[speciesIndices[iVar]]; + try { + sol->kinetics()->getNetProductionRates(netProductionRates.data()); + sol->kinetics()->getDestructionRates(destructionRates.data()); + } catch (const CanteraError& error) { + SU2_MPI::Error(string("Cantera error in the kinetics evaluation: ") + error.what(), CURRENT_FUNCTION); } -} - -void CFluidCantera::ComputeHeatRelease() { - sol->kinetics()->getNetProductionRates(netProductionRates.data()); Heat_Release = 0.0; for (int iVar = 0; iVar < n_species_mixture; iVar++) { - Heat_Release += - -1.0 * enthalpyFormation[iVar] * molarMasses[speciesIndices[iVar]] * netProductionRates[speciesIndices[iVar]]; + const size_t k = speciesIndices[iVar]; + chemicalSourceTerm[iVar] = molarMasses[k] * netProductionRates[k]; + /*--- The destruction rate is taken proportional to the mass fraction of the species. ---*/ + chemicalSourceJacobian[iVar] = -molarMasses[k] * destructionRates[k] / std::max(massFractions[k], 1e-10); + Heat_Release -= enthalpyFormation[iVar] * chemicalSourceTerm[iVar]; } } void CFluidCantera::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) const { + UpdateDiffusivity(); sol->thermo()->getEnthalpy_RT_ref(enthalpiesSpecies.data()); + const su2double RT = GasConstant * Temperature; + const size_t last = speciesIndices[n_species_mixture - 1]; + const su2double h_last = RT * enthalpiesSpecies[last] / molarMasses[last]; for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { - enthalpy_diffusions[iVar] = - Density * GasConstant * Temperature * - ((enthalpiesSpecies[speciesIndices[iVar]] * massDiffusivity[speciesIndices[iVar]] / molarMasses[speciesIndices[iVar]]) - - (enthalpiesSpecies[speciesIndices[n_species_mixture - 1]] * massDiffusivity[speciesIndices[n_species_mixture - 1]] / - molarMasses[speciesIndices[n_species_mixture - 1]])); - enthalpy_diffusions[iVar] += - Mu_Turb * GasConstant * Temperature * - ((enthalpiesSpecies[speciesIndices[iVar]] / molarMasses[speciesIndices[iVar]]) - - (enthalpiesSpecies[speciesIndices[n_species_mixture - 1]] / - molarMasses[speciesIndices[n_species_mixture - 1]])) / Schmidt_Turb_Number; + const size_t k = speciesIndices[iVar]; + const su2double h_k = RT * enthalpiesSpecies[k] / molarMasses[k]; + enthalpy_diffusions[iVar] = Density * (h_k * massDiffusivity[k] - h_last * massDiffusivity[last]) + + Mu_Turb * (h_k - h_last) / Schmidt_Turb_Number; } } void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusions) const { + UpdateDiffusivity(); sol->thermo()->getCp_R_ref(specificHeatSpecies.data()); + const size_t last = speciesIndices[n_species_mixture - 1]; + const su2double cp_last = GasConstant * specificHeatSpecies[last] / molarMasses[last]; for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { - grad_enthalpy_diffusions[iVar] = - Density * GasConstant * - ((specificHeatSpecies[speciesIndices[iVar]] * massDiffusivity[speciesIndices[iVar]] / molarMasses[speciesIndices[iVar]]) - - (specificHeatSpecies[speciesIndices[n_species_mixture - 1]] * massDiffusivity[speciesIndices[n_species_mixture - 1]] / - molarMasses[speciesIndices[n_species_mixture - 1]])); - grad_enthalpy_diffusions[iVar] += Mu_Turb * GasConstant * - ((specificHeatSpecies[speciesIndices[iVar]] / molarMasses[speciesIndices[iVar]]) - - (specificHeatSpecies[speciesIndices[n_species_mixture - 1]] / - molarMasses[speciesIndices[n_species_mixture - 1]])) / - Schmidt_Turb_Number; + const size_t k = speciesIndices[iVar]; + const su2double cp_k = GasConstant * specificHeatSpecies[k] / molarMasses[k]; + grad_enthalpy_diffusions[iVar] = Density * (cp_k * massDiffusivity[k] - cp_last * massDiffusivity[last]) + + Mu_Turb * (cp_k - cp_last) / Schmidt_Turb_Number; } } void CFluidCantera::SetMassFractions(const su2double* val_scalars) { - su2double val_scalars_sum{0.0}; - massFractions.fill(0.0); - for (int i_scalar = 0; i_scalar < n_species_mixture - 1; i_scalar++) { - massFractions[speciesIndices[i_scalar]] = val_scalars[i_scalar]; - val_scalars_sum += val_scalars[i_scalar]; + double scalarsSum = 0.0; + std::fill(massFractions.begin(), massFractions.end(), 0.0); + for (int iScalar = 0; iScalar < n_species_mixture - 1; iScalar++) { + const double value = SU2_TYPE::GetValue(val_scalars[iScalar]); + massFractions[speciesIndices[iScalar]] = value; + scalarsSum += value; } - massFractions[speciesIndices[n_species_mixture - 1]] = 1.0 - val_scalars_sum; + massFractions[speciesIndices[n_species_mixture - 1]] = 1.0 - scalarsSum; } -void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { +void CFluidCantera::SetThermoState(double val_temperature) { + auto& thermo = *sol->thermo(); + thermo.setState_TP(val_temperature, SU2_TYPE::GetValue(Pressure_Thermodynamic)); Temperature = val_temperature; - SetMassFractions(val_scalars); - - sol->thermo()->setMassFractions(massFractions.data()); - sol->thermo()->setState_TP(Temperature, Pressure_Thermodynamic); - Density = sol->thermo()->density(); - Enthalpy = sol->thermo()->enthalpy_mass(); - Cp = sol->thermo()->cp_mass(); - Cv = sol->thermo()->cv_mass(); - Mu = sol->transport()->viscosity(); - Kt = sol->transport()->thermalConductivity(); - - sol->transport()->getMixDiffCoeffsMass(massDiffusivity.data()); - if (Combustion) ComputeHeatRelease(); + Density = thermo.density(); + Enthalpy = thermo.enthalpy_mass(); + Cp = thermo.cp_mass(); + Cv = thermo.cv_mass(); + transportValid = false; + diffusivityValid = false; } -void CFluidCantera::SetTDState_h(const su2double val_enthalpy, const su2double* val_scalars) { - Enthalpy = val_enthalpy; - /*--- convergence criterion for temperature in [K], high accuracy needed for restarts. ---*/ - su2double toll = 1e-5; - su2double temp_iter = 300.0; - su2double delta_temp_iter = 1e10; - su2double delta_enthalpy_iter; - const int counter_limit = 20; +void CFluidCantera::UpdateTransport() const { + if (transportValid) return; + try { + laminarViscosity = sol->transport()->viscosity(); + laminarConductivity = sol->transport()->thermalConductivity(); + } catch (const CanteraError& error) { + SU2_MPI::Error(string("Cantera error in the transport evaluation: ") + error.what(), CURRENT_FUNCTION); + } + transportValid = true; +} - int counter = 0; +void CFluidCantera::UpdateDiffusivity() const { + if (diffusivityValid) return; + try { + sol->transport()->getMixDiffCoeffsMass(massDiffusivity.data()); + } catch (const CanteraError& error) { + SU2_MPI::Error(string("Cantera error in the diffusivity evaluation: ") + error.what(), CURRENT_FUNCTION); + } + diffusivityValid = true; +} - /*--- Set mass fractions. ---*/ +void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) { SetMassFractions(val_scalars); - sol->thermo()->setMassFractions(massFractions.data()); - - /*--- Computing temperature given enthalpy and species mass fractions using Newton-Raphson. ---*/ - while ((abs(delta_temp_iter) > toll) && (counter++ < counter_limit)) { - /*--- Set thermodynamic state based on the current value of temperature. ---*/ - sol->thermo()->setState_TP(temp_iter, Pressure_Thermodynamic); - - su2double Enthalpy_iter = sol->thermo()->enthalpy_mass(); - su2double Cp_iter = sol->thermo()->cp_mass(); - - delta_enthalpy_iter = Enthalpy - Enthalpy_iter; + try { + sol->thermo()->setMassFractions(massFractions.data()); + SetThermoState(SU2_TYPE::GetValue(val_temperature)); + } catch (const CanteraError& error) { + SU2_MPI::Error(string("Cantera error in SetTDState_T: ") + error.what(), CURRENT_FUNCTION); + } + stateFailed = false; +} - delta_temp_iter = delta_enthalpy_iter / Cp_iter; +void CFluidCantera::SetTDState_h(const su2double val_enthalpy, const su2double* val_scalars) { + /*--- Temperature tolerance in [K], high accuracy needed for restarts. ---*/ + constexpr double tolerance = 1e-5; + constexpr int maxIterations = 20; - temp_iter += delta_temp_iter; - if (temp_iter < 0.0) { - cout << "Warning: Negative temperature has been found during Newton-Raphson" << endl; - break; + SetMassFractions(val_scalars); + const double enthalpy = SU2_TYPE::GetValue(val_enthalpy); + double temperature = std::clamp((temperatureGuess > 0.0) ? temperatureGuess : 300.0, minTemperature, maxTemperature); + temperatureGuess = 0.0; + bool converged = false; + + try { + sol->thermo()->setMassFractions(massFractions.data()); + + /*--- Newton-Raphson on temperature, kept inside the temperature bounds. ---*/ + for (int iter = 0; iter < maxIterations; iter++) { + sol->thermo()->setState_TP(temperature, SU2_TYPE::GetValue(Pressure_Thermodynamic)); + const double delta = (enthalpy - sol->thermo()->enthalpy_mass()) / sol->thermo()->cp_mass(); + if (!std::isfinite(delta)) break; + + const double next = std::clamp(temperature + delta, minTemperature, maxTemperature); + const bool inRange = (next == temperature + delta); + temperature = next; + if (!inRange) break; + if (std::abs(delta) <= tolerance) { + converged = true; + break; + } } + SetThermoState(temperature); + } catch (const CanteraError& error) { + SU2_MPI::Error(string("Cantera error in SetTDState_h: ") + error.what(), CURRENT_FUNCTION); } - Temperature = temp_iter; - if (counter == counter_limit) { - cout << "Warning Newton-Raphson exceed number of max iteration in temperature computation" << endl; - } - SetTDState_T(Temperature, val_scalars); + stateFailed = !converged; } #else CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* config) { - SU2_MPI::Error("SU2 was not compiled with Cantera(-Denable-cantera=true)", CURRENT_FUNCTION); + SU2_MPI::Error( + "FLUID_CANTERA requires SU2 to be compiled with Cantera (-Denable-cantera=true). " + "Automatic differentiation builds do not support Cantera.", + CURRENT_FUNCTION); } -#endif \ No newline at end of file +#endif diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index e045e486a9d4..5ffdc166898a 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -222,12 +222,15 @@ if get_option('enable-normal') link_args: profiling_args) endif +# Cantera works on plain doubles and is not differentiated, so the AD/DD builds compile without it. +cantera_off_args = ['-UHAVE_CANTERA'] + if get_option('enable-autodiff') su2_cfd_lib_ad = static_library('SU2core_AD', su2_cfd_src, install : false, dependencies : [su2_deps, codi_dep, commonAD_dep], - cpp_args: [default_warning_flags, su2_cpp_args, codi_rev_args]) + cpp_args: [default_warning_flags, su2_cpp_args, codi_rev_args, cantera_off_args]) su2_cfd_dep_ad = declare_dependency(link_with: su2_cfd_lib_ad, include_directories: su2_cfd_include) su2_cfd_ad = executable('SU2_CFD_AD', @@ -235,7 +238,7 @@ if get_option('enable-autodiff') install : true, install_rpath : '$ORIGIN/../lib', dependencies : [su2_cfd_dep_ad, su2_deps, codi_dep, commonAD_dep], - cpp_args: ['-fPIC'] + [default_warning_flags, su2_cpp_args, codi_rev_args] + profiling_args, + cpp_args: ['-fPIC'] + [default_warning_flags, su2_cpp_args, codi_rev_args, cantera_off_args] + profiling_args, link_args: profiling_args) endif @@ -244,7 +247,7 @@ if get_option('enable-directdiff') su2_cfd_src, install : false, dependencies : [su2_deps, codi_dep, commonDD_dep], - cpp_args: [default_warning_flags, su2_cpp_args, codi_for_args]) + cpp_args: [default_warning_flags, su2_cpp_args, codi_for_args, cantera_off_args]) su2_cfd_dep_dd = declare_dependency(link_with: su2_cfd_lib_dd, include_directories: su2_cfd_include) su2_cfd_dd = executable('SU2_CFD_DIRECTDIFF', @@ -252,7 +255,7 @@ if get_option('enable-directdiff') install : true, install_rpath : '$ORIGIN/../lib', dependencies : [su2_cfd_dep_dd, su2_deps, codi_dep, commonDD_dep], - cpp_args: ['-fPIC'] + [default_warning_flags, su2_cpp_args, codi_for_args] + profiling_args, + cpp_args: ['-fPIC'] + [default_warning_flags, su2_cpp_args, codi_for_args, cantera_off_args] + profiling_args, link_args: profiling_args) endif diff --git a/SU2_CFD/src/numerics/species/species_sources.cpp b/SU2_CFD/src/numerics/species/species_sources.cpp index 3c02ce3e19e8..3ff41317e153 100644 --- a/SU2_CFD/src/numerics/species/species_sources.cpp +++ b/SU2_CFD/src/numerics/species/species_sources.cpp @@ -138,7 +138,12 @@ CNumerics::ResidualType<> CSourceAxisymmetric_Species::ComputeResidual(const template CSourceCombustion_Species::CSourceCombustion_Species(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) - : CSourceBase_Species(val_nDim, val_nVar, config) {} + : CSourceBase_Species(val_nDim, val_nVar, config), + chemical_jacobian(config->GetKind_TimeIntScheme_Species() == EULER_IMPLICIT && + config->GetChemical_Source_Jacobian()) { + Chemical_Source_Jacobian_i = nullptr; + Chemical_Source_Jacobian_j = nullptr; +} template CNumerics::ResidualType<> CSourceCombustion_Species::ComputeResidual(const CConfig* config) { @@ -159,6 +164,11 @@ CNumerics::ResidualType<> CSourceCombustion_Species::ComputeResidual(const CC residual[iVar] += Volume * Chemical_Source_Term_i[iVar]; } + if (chemical_jacobian && Chemical_Source_Jacobian_i != nullptr) { + for (auto iVar = 0u; iVar < nVar; iVar++) { + jacobian[iVar][iVar] = Volume * Chemical_Source_Jacobian_i[iVar]; + } + } AD::SetPreaccOut(residual, nVar); AD::EndPreacc(); diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 1b57c29b10b8..764550c0b3f1 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -39,6 +39,14 @@ #include "../../include/variables/CPrimitiveIndices.hpp" #include "../../include/fluid/CCoolProp.hpp" +namespace { +/*--- Species label used in output field names: the Cantera species name, otherwise the index. ---*/ +std::string SpeciesOutputLabel(const CConfig* config, unsigned short iVar) { + return (config->GetKind_FluidModel() == FLUID_CANTERA) ? config->GetChemical_GasComposition(iVar) + : std::to_string(iVar); +} +} // namespace + CFlowOutput::CFlowOutput(const CConfig *config, unsigned short nDim, bool fem_output) : CFVMOutput(config, nDim, fem_output), @@ -1546,7 +1554,7 @@ void CFlowOutput::SetVolumeOutputFieldsScalarLimiter(const CConfig* config) { switch (config->GetKind_Species_Model()) { case SPECIES_MODEL::SPECIES_TRANSPORT: for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) - AddVolumeOutput("LIMITER_SPECIES_" + std::to_string(iVar), "Limiter_Species_" + std::to_string(iVar), "LIMITER", "Limiter value of the transported species " + std::to_string(iVar)); + AddVolumeOutput("LIMITER_SPECIES_" + SpeciesOutputLabel(config, iVar), "Limiter_Species_" + SpeciesOutputLabel(config, iVar), "LIMITER", "Limiter value of the transported species " + SpeciesOutputLabel(config, iVar)); break; case SPECIES_MODEL::FLAMELET: { const auto& flamelet_config_options = config->GetFlameletParsedOptions(); @@ -1617,7 +1625,7 @@ void CFlowOutput::SetVolumeOutputFieldsScalarSource(const CConfig* config) { case SPECIES_MODEL::SPECIES_TRANSPORT: if (config->GetPyCustomSource()) { for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++){ - AddVolumeOutput("SPECIES_UDS_" + std::to_string(iVar), "Species_UDS_" + std::to_string(iVar), "SOURCE", "Species User Defined Source " + std::to_string(iVar)); + AddVolumeOutput("SPECIES_UDS_" + SpeciesOutputLabel(config, iVar), "Species_UDS_" + SpeciesOutputLabel(config, iVar), "SOURCE", "Species User Defined Source " + SpeciesOutputLabel(config, iVar)); } } break; @@ -1807,6 +1815,9 @@ void CFlowOutput::LoadVolumeDataScalar(const CConfig* config, const CSolver* con if (config->GetKind_SlopeLimit_Species() != LIMITER::NONE) SetVolumeOutputValue("LIMITER_SPECIES_" + config->GetChemical_GasComposition(iVar), iPoint, Node_Species->GetLimiter(iPoint, iVar)); + if (config->GetPyCustomSource()) + SetVolumeOutputValue("SPECIES_UDS_" + config->GetChemical_GasComposition(iVar), iPoint, + Node_Species->GetUserDefinedSource()(iPoint, iVar)); } else { SetVolumeOutputValue("SPECIES_" + std::to_string(iVar), iPoint, Node_Species->GetSolution(iPoint, iVar)); SetVolumeOutputValue("RES_SPECIES_" + std::to_string(iVar), iPoint, solver[SPECIES_SOL]->LinSysRes(iPoint, iVar)); diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 63f9b3bc4154..d4569e52285e 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -359,8 +359,6 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i case FLUID_CANTERA: - config->SetGas_Constant(UNIVERSAL_GAS_CONSTANT / (config->GetMolecular_Weight() / 1000.0)); - Pressure_Thermodynamic = config->GetPressure_Thermodynamic(); auxFluidModel = new CFluidCantera(Pressure_Thermodynamic, config); auxFluidModel->SetTDState_T(Temperature_FreeStream, config->GetSpecies_Init()); break; @@ -888,15 +886,11 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i case FLUID_CANTERA: ModelTable << "CANTERA"; - Unit << "N.m/kg.K"; - NonDimTable << "Spec. Heat (Cp)" << config->GetSpecific_Heat_Cp() << config->GetSpecific_Heat_Cp() / config->GetSpecific_Heat_CpND() << Unit.str() << config->GetSpecific_Heat_CpND(); - Unit.str(""); - Unit << "g/mol"; - NonDimTable << "Molecular weight" << config->GetMolecular_Weight() << 1.0 << Unit.str() << config->GetMolecular_Weight(); - Unit.str(""); - Unit << "N.m/kg.K"; - NonDimTable << "Gas Constant" << config->GetGas_Constant() << config->GetGas_Constant_Ref() << Unit.str() << config->GetGas_ConstantND(); - Unit.str(""); + if (viscous) { + Unit << "N.m/kg.K"; + NonDimTable << "Spec. Heat (Cp)" << config->GetSpecificHeatCp_FreeStream() << 1.0 << Unit.str() << config->GetSpecificHeatCp_FreeStream(); + Unit.str(""); + } Unit << "Pa"; NonDimTable << "Therm. Pressure" << config->GetPressure_Thermodynamic() << config->GetPressure_Ref() << Unit.str() << config->GetPressure_ThermodynamicND(); Unit.str(""); @@ -1581,10 +1575,14 @@ void CIncEulerSolver::ComputeConsistentExtrapolation(CFluidModel* fluidModel, un SU2_ZONE_SCOPED const CIncEulerVariable::CIndices prim_idx(nDim, 0); const su2double enthalpy = primitive[prim_idx.Enthalpy()]; + fluidModel->SetTemperatureGuess(primitive[prim_idx.Temperature()]); fluidModel->SetTDState_h(enthalpy, scalar); primitive[prim_idx.Temperature()] = fluidModel->GetTemperature(); primitive[prim_idx.Density()] = fluidModel->GetDensity(); + + /*--- A failed state evaluation is flagged as non-physical so that the caller falls back to the cell values. ---*/ + if (fluidModel->GetStateFailed()) primitive[prim_idx.Temperature()] = -1.0; } void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 7911d51198a7..3cac20b3b413 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -57,6 +57,12 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short } if (config->GetCombustion()) flamelet_config_options = config->GetFlameletParsedOptions(); + if ((config->GetKind_FluidModel() == FLUID_MIXTURE || config->GetKind_FluidModel() == FLUID_CANTERA) && + config->GetEnergy_Equation()) { + EnthalpyDiffusion.resize(nPoint, config->GetnSpecies()) = su2double(0.0); + GradEnthalpyDiffusion.resize(nPoint, config->GetnSpecies()) = su2double(0.0); + } + /*--- Set the initial Streamwise periodic pressure drop value. ---*/ if (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE) @@ -79,30 +85,29 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container /*--- Setting temperature, enthalpy and thermophysical properties for ignition in reacting flows. ---*/ if (energy && combustion) { - unsigned long spark_iter_start, spark_duration; bool ignition = false; + su2double spark_radius_squared = 0.0; /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ if (flamelet_config_options.ignition_method == FLAMELET_INIT_TYPE::SPARK) { - auto spark_init = flamelet_config_options.spark_init; - spark_iter_start = ceil(spark_init[4]); - spark_duration = ceil(spark_init[5]); - unsigned long iter = config->GetMultizone_Problem() ? config->GetOuterIter() : config->GetInnerIter(); + const auto& spark_init = flamelet_config_options.spark_init; + const unsigned long spark_iter_start = ceil(spark_init[4]); + const unsigned long spark_duration = ceil(spark_init[5]); + const unsigned long iter = config->GetIgnitionIter(); ignition = ((iter >= spark_iter_start) && (iter <= (spark_iter_start + spark_duration))); + spark_radius_squared = spark_init[3] * spark_init[3]; } SU2_OMP_SAFE_GLOBAL_ACCESS(config->SetGlobalParam(config->GetKind_Solver(), RunTime_EqSystem);) if (ignition) { + CFluidModel* fluid_model_local = solver_container[FLOW_SOL]->GetFluidModel(); SU2_OMP_FOR_STAT(omp_chunk_size) for (auto i_point = 0u; i_point < nPoint; i_point++) { - /*--- Retrieve fluid model. ---*/ - CFluidModel* fluid_model_local = solver_container[FLOW_SOL]->GetFluidModel(); /*--- Apply ignition temperature within spark radius. ---*/ - su2double dist_from_center = 0, spark_radius = flamelet_config_options.spark_init[3]; - dist_from_center = - GeometryToolbox::SquaredDistance(nDim, geometry->nodes->GetCoord(i_point), flamelet_config_options.spark_init.data()); - if (dist_from_center < pow(spark_radius, 2)) { + const su2double dist_from_center = GeometryToolbox::SquaredDistance( + nDim, geometry->nodes->GetCoord(i_point), flamelet_config_options.spark_init.data()); + if (dist_from_center < spark_radius_squared) { /*--- Retrieve scalars solution. ---*/ su2double* scalars = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(i_point); /*--- Set high temperature for ignition. ---*/ @@ -127,6 +132,8 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container CommonPreprocessing(geometry, solver_container, config, iMesh, iRKStep, RunTime_EqSystem, Output); + if (EnthalpyDiffusion.rows() > 0) ComputeEnthalpyDiffusionTerms(solver_container, config); + /*--- Compute gradient for MUSCL reconstruction ---*/ if (config->GetReconstructionGradientRequired() && muscl && !center) { @@ -360,19 +367,6 @@ void CIncNSSolver::Compute_Enthalpy_Diffusion(unsigned long iEdge, CGeometry* ge const su2double* Coord_i = geometry->nodes->GetCoord(iPoint); const su2double* Coord_j = geometry->nodes->GetCoord(jPoint); - /*--- Obtain fluid model for computing the enthalpy diffusion terms. ---*/ - - CFluidModel* FluidModel = solver_container[FLOW_SOL]->GetFluidModel(); - - /*--- Helper function that retrieves enthalpy diffusion terms. ---*/ - auto GetEnthalpyDiffusionTerms = [&](unsigned long Point, const su2double* Species, su2double* EnthalpyDiffusion, - su2double* GradEnthalpyDiffusion) { - FluidModel->SetTDState_T(nodes->GetPrimitive(Point)[prim_idx.Temperature()], Species); - FluidModel->SetEddyViscosity(nodes->GetPrimitive(Point)[prim_idx.EddyViscosity()]); - FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion); - if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion); - }; - /*--- set maximum static array ---*/ static constexpr size_t MAXNVAR_SPECIES = 20UL; @@ -389,14 +383,12 @@ void CIncNSSolver::Compute_Enthalpy_Diffusion(unsigned long iEdge, CGeometry* ge numerics->ComputeProjectedGradient(nDim, n_species, Normal, Coord_i, Coord_j, Species_Grad_i, Species_Grad_j, true, Species_i, Species_j, ProjGradScalarVarNoCorr, Proj_Mean_GradScalarVar); - /*--- Get enthalpy diffusion terms and its gradient(for implicit) for each species at iPoint and jPoint. ---*/ + /*--- Enthalpy diffusion terms and their gradient (for implicit) were stored per point in Preprocessing. ---*/ - su2double EnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; - su2double GradEnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; - su2double EnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; - su2double GradEnthalpyDiffusion_j[MAXNVAR_SPECIES]{0.0}; - GetEnthalpyDiffusionTerms(iPoint, Species_i, EnthalpyDiffusion_i, GradEnthalpyDiffusion_i); - GetEnthalpyDiffusionTerms(jPoint, Species_j, EnthalpyDiffusion_j, GradEnthalpyDiffusion_j); + const su2double* EnthalpyDiffusion_i = EnthalpyDiffusion[iPoint]; + const su2double* EnthalpyDiffusion_j = EnthalpyDiffusion[jPoint]; + const su2double* GradEnthalpyDiffusion_i = GradEnthalpyDiffusion[iPoint]; + const su2double* GradEnthalpyDiffusion_j = GradEnthalpyDiffusion[jPoint]; /*--- Compute Enthalpy diffusion flux and its jacobian (for implicit iterations) ---*/ su2double flux_enthalpy_diffusion = 0.0; @@ -415,6 +407,23 @@ void CIncNSSolver::Compute_Enthalpy_Diffusion(unsigned long iEdge, CGeometry* ge if (implicit) numerics->SetJacHeatFluxDiffusion(jac_flux_enthalpy_diffusion); } +void CIncNSSolver::ComputeEnthalpyDiffusionTerms(CSolver** solver_container, const CConfig* config) { + SU2_ZONE_SCOPED + + CFluidModel* fluid_model = GetFluidModel(); + CVariable* speciesNodes = solver_container[SPECIES_SOL]->GetNodes(); + const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); + + SU2_OMP_FOR_STAT(omp_chunk_size) + for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { + fluid_model->SetTDState_T(nodes->GetPrimitive(iPoint)[prim_idx.Temperature()], speciesNodes->GetSolution(iPoint)); + fluid_model->SetEddyViscosity(nodes->GetPrimitive(iPoint)[prim_idx.EddyViscosity()]); + fluid_model->GetEnthalpyDiffusivity(EnthalpyDiffusion[iPoint]); + if (implicit) fluid_model->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion[iPoint]); + } + END_SU2_OMP_FOR +} + unsigned long CIncNSSolver::SetPrimitive_Variables(CSolver **solver_container, const CConfig *config) { SU2_ZONE_SCOPED diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index f27c3737b7bf..e6d26645bcd7 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -319,56 +319,51 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { SU2_ZONE_SCOPED - unsigned long spark_iter_start, spark_duration; + const bool combustion = config->GetCombustion(); bool ignition = false; - su2double temperature; + su2double spark_radius_squared = 0.0; /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ if (flamelet_config_options.ignition_method == FLAMELET_INIT_TYPE::SPARK) { - auto spark_init = flamelet_config_options.spark_init; - spark_iter_start = ceil(spark_init[4]); - spark_duration = ceil(spark_init[5]); - unsigned long iter = config->GetMultizone_Problem() ? config->GetOuterIter() : config->GetInnerIter(); + const auto& spark_init = flamelet_config_options.spark_init; + const unsigned long spark_iter_start = ceil(spark_init[4]); + const unsigned long spark_duration = ceil(spark_init[5]); + const unsigned long iter = config->GetIgnitionIter(); ignition = ((iter >= spark_iter_start) && (iter <= (spark_iter_start + spark_duration))); + spark_radius_squared = spark_init[3] * spark_init[3]; } SU2_OMP_SAFE_GLOBAL_ACCESS(config->SetGlobalParam(config->GetKind_Solver(), RunTime_EqSystem);) + CFluidModel* fluid_model = solver_container[FLOW_SOL]->GetFluidModel(); + fluid_model->SetMassDiffusivityModel(config); + /*--- Set the laminar mass Diffusivity and chemical source term for the species solver. ---*/ SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0u; iPoint < nPoint; iPoint++) { + su2double temperature = solver_container[FLOW_SOL]->GetNodes()->GetTemperature(iPoint); if (ignition) { /*--- Apply ignition temperature within spark radius. ---*/ - su2double dist_from_center = 0, spark_radius = flamelet_config_options.spark_init[3]; - dist_from_center = - GeometryToolbox::SquaredDistance(nDim, geometry->nodes->GetCoord(iPoint), flamelet_config_options.spark_init.data()); - if (dist_from_center < pow(spark_radius, 2)) { - temperature = config->GetSpark_Temperature(); - } else { - temperature = solver_container[FLOW_SOL]->GetNodes()->GetTemperature(iPoint); - } - } else { - temperature = solver_container[FLOW_SOL]->GetNodes()->GetTemperature(iPoint); + const su2double dist_from_center = GeometryToolbox::SquaredDistance( + nDim, geometry->nodes->GetCoord(iPoint), flamelet_config_options.spark_init.data()); + if (dist_from_center < spark_radius_squared) temperature = config->GetSpark_Temperature(); } const su2double* scalar = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint); - solver_container[FLOW_SOL]->GetFluidModel()->SetMassDiffusivityModel(config); - solver_container[FLOW_SOL]->GetFluidModel()->SetTDState_T(temperature, scalar); - if (config->GetCombustion() == true) { - /*--- Call function to compute chemical source term. ---*/ - solver_container[FLOW_SOL]->GetFluidModel()->ComputeChemicalSourceTerm(); - /*--- Get and set heat release due to combustion. ---*/ - const su2double heat_release = solver_container[FLOW_SOL]->GetFluidModel()->GetHeatRelease(); - nodes->SetHeatRelease(iPoint, heat_release); + fluid_model->SetTDState_T(temperature, scalar); + + /*--- Chemical source terms are only used by the residual of the points owned by this rank. ---*/ + const bool chemistry = combustion && (iPoint < nPointDomain); + if (chemistry) { + fluid_model->ComputeChemicalSourceTerm(); + nodes->SetHeatRelease(iPoint, fluid_model->GetHeatRelease()); } /*--- Recompute viscosity, important to get diffusivity correct across MPI ranks. ---*/ - nodes->SetLaminarViscosity(iPoint, solver_container[FLOW_SOL]->GetFluidModel()->GetLaminarViscosity()); + nodes->SetLaminarViscosity(iPoint, fluid_model->GetLaminarViscosity()); /*--- Set the laminar mass Diffusivity for the species solver. ---*/ for (auto iVar = 0u; iVar <= nVar; iVar++) { - const su2double mass_diffusivity = solver_container[FLOW_SOL]->GetFluidModel()->GetMassDiffusivity(iVar); - nodes->SetDiffusivity(iPoint, mass_diffusivity, iVar); - if (config->GetCombustion() == true) { - /*--- Get and Set chemical source term. ---*/ - const su2double chemical_source_term = solver_container[FLOW_SOL]->GetFluidModel()->GetChemicalSourceTerm(iVar); - nodes->SetChemicalSourceTerm(iPoint, chemical_source_term, iVar); + nodes->SetDiffusivity(iPoint, fluid_model->GetMassDiffusivity(iVar), iVar); + if (chemistry) { + nodes->SetChemicalSourceTerm(iPoint, fluid_model->GetChemicalSourceTerm(iVar), iVar); + nodes->SetChemicalSourceJacobian(iPoint, fluid_model->GetChemicalSourceJacobian(iVar), iVar); } } } // iPoint @@ -718,6 +713,7 @@ void CSpeciesSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Set Chemical Source Term ---*/ numerics->SetChemicalSourceTerm(nodes->GetChemicalSourceTerm(iPoint), nullptr); + numerics->SetChemicalSourceJacobian(nodes->GetChemicalSourceJacobian(iPoint), nullptr); /*--- Set volume of the dual cell. ---*/ diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index 444ab38f4af2..706a6be1f8fa 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -59,8 +59,10 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do SetPressure(iPoint); su2double Enthalpy = Solution(iPoint, nDim + 1); + FluidModel->SetTemperatureGuess(GetTemperature(iPoint)); FluidModel->SetTDState_h(Enthalpy, scalar); su2double Temperature = FluidModel->GetTemperature(); + const bool state_failed = FluidModel->GetStateFailed(); auto check_temp = SetTemperature(iPoint, Temperature, TemperatureLimits); @@ -74,7 +76,7 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do /*--- Non-physical solution found. Revert to old values. ---*/ - if (check_dens || check_temp) { + if (check_dens || check_temp || state_failed) { /*--- Copy the old solution ---*/ diff --git a/SU2_CFD/src/variables/CSpeciesVariable.cpp b/SU2_CFD/src/variables/CSpeciesVariable.cpp index 5f339d6f0e12..7ec6d0e745d7 100644 --- a/SU2_CFD/src/variables/CSpeciesVariable.cpp +++ b/SU2_CFD/src/variables/CSpeciesVariable.cpp @@ -34,6 +34,7 @@ CSpeciesVariable::CSpeciesVariable(const su2double* species_inf, unsigned long n Diffusivity.resize(nPoint, nVar + 1) = su2double(0.0); if (config->GetCombustion()) { SpeciesSourceTerm.resize(nPoint, nVar + 1) = su2double(0.0); + SpeciesSourceJacobian.resize(nPoint, nVar + 1) = su2double(0.0); HeatRelease.resize(nPoint) = su2double(0.0); } diff --git a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp index 0062806e5307..204db1ec1e69 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp @@ -92,4 +92,76 @@ TEST_CASE("Fluid_Cantera_Combustion", "[Reacting_flow]") { CHECK(sourceTerm_H2 == Approx(-0.13633797171426)); CHECK(sourceTerm_O2 == Approx(-2.16321066087493)); } +TEST_CASE("Fluid_Cantera_LargeMechanism", "[Multicomponent_flow]") { + /*--- Three transported species in a mechanism with more species than the transported set. ---*/ + + SU2_COMPONENT val_software = SU2_COMPONENT::SU2_CFD; + CConfig config("multicomponent_cantera_gri30.cfg", val_software, true); + CFluidCantera fluid(config.GetPressure_Thermodynamic(), &config); + + const su2double* scalar = config.GetSpecies_Init(); + fluid.SetTDState_T(300.0, scalar); + const su2double density = fluid.GetDensity(); + CHECK(density > 1.0); + CHECK(density < 1.4); + CHECK(fluid.GetMassDiffusivity(0) > 0.0); + CHECK(fluid.GetLaminarViscosity() > 0.0); + + /*--- Temperature recovered from the enthalpy of a given state. ---*/ + + fluid.SetTDState_T(1500.0, scalar); + const su2double enthalpy = fluid.GetEnthalpy(); + fluid.SetTDState_h(enthalpy, scalar); + CHECK(fluid.GetStateFailed() == false); + CHECK(fluid.GetTemperature() == Approx(1500.0).margin(1e-4)); + + /*--- The result does not depend on the temperature guess, which is used only once. ---*/ + + fluid.SetTemperatureGuess(1490.0); + fluid.SetTDState_h(enthalpy, scalar); + CHECK(fluid.GetTemperature() == Approx(1500.0).margin(1e-4)); + fluid.SetTemperatureGuess(5.0); + fluid.SetTDState_h(enthalpy, scalar); + CHECK(fluid.GetStateFailed() == false); + CHECK(fluid.GetTemperature() == Approx(1500.0).margin(1e-4)); + + /*--- An enthalpy outside the range of the thermodynamic data is flagged. ---*/ + + fluid.SetTDState_h(1e12, scalar); + CHECK(fluid.GetStateFailed() == true); +} +TEST_CASE("Fluid_Cantera_SourceJacobian", "[Reacting_flow]") { + /*--- Diagonal chemical source Jacobian of the one-step methane mechanism. ---*/ + + SU2_COMPONENT val_software = SU2_COMPONENT::SU2_CFD; + CConfig config("one_step_ch4.cfg", val_software, true); + CFluidCantera fluid(config.GetPressure_Thermodynamic(), &config); + + const su2double temperature = 1800.0; + su2double scalar[4] = {0.2226, 0.05, 0.0446, 0.05}; + fluid.SetTDState_T(temperature, scalar); + fluid.ComputeChemicalSourceTerm(); + + const su2double source_O2 = fluid.GetChemicalSourceTerm(0); + const su2double source_CH4 = fluid.GetChemicalSourceTerm(2); + CHECK(source_CH4 < 0.0); + + /*--- Reactants are consumed, so their Jacobian is negative; products have no sink. ---*/ + + CHECK(fluid.GetChemicalSourceJacobian(0) < 0.0); + CHECK(fluid.GetChemicalSourceJacobian(1) == 0.0); + CHECK(fluid.GetChemicalSourceJacobian(2) < 0.0); + CHECK(fluid.GetChemicalSourceJacobian(3) == 0.0); + + /*--- The rate is first order in CH4. The finite difference also contains the density change from moving N2 + * into CH4, which the Jacobian (at fixed density) does not, hence the tolerance. ---*/ + + const su2double delta = 1e-6; + scalar[2] += delta; + fluid.SetTDState_T(temperature, scalar); + fluid.ComputeChemicalSourceTerm(); + const su2double slope_CH4 = (fluid.GetChemicalSourceTerm(2) - source_CH4) / delta; + CHECK(fluid.GetChemicalSourceJacobian(2) == Approx(slope_CH4).epsilon(0.1)); + CHECK(source_O2 < 0.0); +} #endif diff --git a/UnitTests/SU2_CFD/fluid/multicomponent_cantera_gri30.cfg b/UnitTests/SU2_CFD/fluid/multicomponent_cantera_gri30.cfg new file mode 100644 index 000000000000..1ef1cecee024 --- /dev/null +++ b/UnitTests/SU2_CFD/fluid/multicomponent_cantera_gri30.cfg @@ -0,0 +1,39 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Unit test Cantera, 3 transported species in gri30 (53 species)% +% Author: Cristopher Morales Ubal % +% Institution: Eindhoven University of Technology % +% Date: 2024/10/01 % +% File Version 8.1.0 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= INC_NAVIER_STOKES +% +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +INC_DENSITY_MODEL= VARIABLE +% +INC_NONDIM= DIMENSIONAL +% +% -------------------- FLUID PROPERTIES ------------------------------------- % +% +FLUID_MODEL= FLUID_CANTERA +% +CONDUCTIVITY_MODEL= CANTERA +VISCOSITY_MODEL= CANTERA +% +GAS_COMPOSITION_NAMES= CH4, O2, N2 +CHEMICAL_MECHANISM_FILE= gri30.yaml +PHASE_NAME= gri30 +TRANSPORT_MODEL= mixture-averaged +% +% -------------------- SCALAR TRANSPORT ---------------------------------------% +% +KIND_SCALAR_MODEL= SPECIES_TRANSPORT +DIFFUSIVITY_MODEL= CANTERA +% +SPECIES_INIT= 0.05,0.22 diff --git a/UnitTests/SU2_CFD/fluid/one_step_ch4.cfg b/UnitTests/SU2_CFD/fluid/one_step_ch4.cfg new file mode 100644 index 000000000000..a3be9d881fb8 --- /dev/null +++ b/UnitTests/SU2_CFD/fluid/one_step_ch4.cfg @@ -0,0 +1,41 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Unit test Cantera, one-step methane, 4 transported species % +% Author: Cristopher Morales Ubal % +% Institution: Eindhoven University of Technology % +% Date: 2024/10/01 % +% File Version 8.1.0 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= INC_NAVIER_STOKES +% +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +INC_DENSITY_MODEL= VARIABLE +% +INC_NONDIM= DIMENSIONAL +% +% -------------------- FLUID PROPERTIES ------------------------------------- % +% +FLUID_MODEL= FLUID_CANTERA +% +CONDUCTIVITY_MODEL= CANTERA +VISCOSITY_MODEL= CANTERA +% +COMBUSTION= YES +FLAME_INIT_METHOD= SPARK +GAS_COMPOSITION_NAMES= O2, H2O, CH4, CO2, N2 +CHEMICAL_MECHANISM_FILE= one_step_ch4.yaml +PHASE_NAME= ch4_one_step +TRANSPORT_MODEL= mixture-averaged +% +% -------------------- SCALAR TRANSPORT ---------------------------------------% +% +KIND_SCALAR_MODEL= SPECIES_TRANSPORT +DIFFUSIVITY_MODEL= CANTERA +% +SPECIES_INIT= 0.222598,0.0,0.044642,0.0 diff --git a/UnitTests/SU2_CFD/fluid/one_step_ch4.yaml b/UnitTests/SU2_CFD/fluid/one_step_ch4.yaml new file mode 100644 index 000000000000..d174c579b0fc --- /dev/null +++ b/UnitTests/SU2_CFD/fluid/one_step_ch4.yaml @@ -0,0 +1,82 @@ +description: One-step methane mechanism CH4 + 2 O2 => CO2 + 2 H2O used by the Cantera + unit tests. +units: {length: cm, quantity: mol, activation-energy: cal/mol} +phases: +- name: ch4_one_step + thermo: ideal-gas + elements: [O, H, C, N] + species: [O2, H2O, CH4, CO2, N2] + kinetics: gas + reactions: all + transport: mixture-averaged + state: {T: 300.0, P: 101325.0} +species: +- name: O2 + composition: {O: 2} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [3.78245636, -0.00299673416, 9.84730201e-06, -9.68129509e-09, 3.24372837e-12, + -1063.94356, 3.65767573] + - [3.28253784, 0.00148308754, -7.57966669e-07, 2.09470555e-10, -2.16717794e-14, + -1088.45772, 5.45323129] + transport: {model: gas, geometry: linear, diameter: 3.46, well-depth: 107.4, polarizability: 1.6, + rotational-relaxation: 3.8} + note: TPIS89 +- name: H2O + composition: {H: 2, O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [4.19864056, -0.0020364341, 6.52040211e-06, -5.48797062e-09, 1.77197817e-12, + -30293.7267, -0.849032208] + - [3.03399249, 0.00217691804, -1.64072518e-07, -9.7041987e-11, 1.68200992e-14, + -30004.2971, 4.9667701] + transport: {model: gas, geometry: nonlinear, diameter: 2.6, well-depth: 572.4, dipole: 1.84, + rotational-relaxation: 4.0} + note: L 8/89 +- name: CH4 + composition: {C: 1, H: 4} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [5.14987613, -0.0136709788, 4.91800599e-05, -4.84743026e-08, 1.66693956e-11, + -10246.6476, -4.64130376] + - [0.074851495, 0.0133909467, -5.73285809e-06, 1.22292535e-09, -1.0181523e-13, + -9468.34459, 18.437318] + transport: {model: gas, geometry: nonlinear, diameter: 3.75, well-depth: 141.4, + polarizability: 2.6, rotational-relaxation: 13.0} + note: L 8/88 +- name: CO2 + composition: {C: 1, O: 2} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [2.35677352, 0.00898459677, -7.12356269e-06, 2.45919022e-09, -1.43699548e-13, + -48371.9697, 9.90105222] + - [3.85746029, 0.00441437026, -2.21481404e-06, 5.23490188e-10, -4.72084164e-14, + -48759.166, 2.27163806] + transport: {model: gas, geometry: linear, diameter: 3.76, well-depth: 244.0, polarizability: 2.65, + rotational-relaxation: 2.1} + note: L 7/88 +- name: N2 + composition: {N: 2} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [3.298677, 0.0014082404, -3.963222e-06, 5.641515e-09, -2.444854e-12, -1020.8999, + 3.950372] + - [2.92664, 0.0014879768, -5.68476e-07, 1.0097038e-10, -6.753351e-15, -922.7977, + 5.980528] + transport: {model: gas, geometry: linear, diameter: 3.62, well-depth: 97.53, polarizability: 1.76, + rotational-relaxation: 4.0} + note: '121286' +reactions: +- equation: ' CH4 + 2 O2 => CO2 + 2 H2O ' + rate-constant: {A: 11000000000.0, b: 0.0, Ea: 20000} + orders: {CH4: 1.0, O2: 0.5} diff --git a/meson.build b/meson.build index bafb6722db1c..a7700912410a 100644 --- a/meson.build +++ b/meson.build @@ -389,6 +389,7 @@ if get_option('enable-cantera') '--prefix', cantera_prefix, '--stamp', '@OUTPUT@', '--eigen-inc-dir', join_paths(meson.current_source_dir(), 'externals', 'eigen')] + cantera_build_command += ['--jobs', get_option('cantera-build-jobs').to_string()] if get_option('cantera-boost-inc-dir') != '' cantera_build_command += ['--boost-inc-dir', get_option('cantera-boost-inc-dir')] endif diff --git a/meson_options.txt b/meson_options.txt index 7997b3bf7614..abc4abc2623b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -23,6 +23,7 @@ option('enable-mpp', type : 'boolean', value : false, description: 'enable Mutat option('install-mpp', type : 'boolean', value : false, description: 'install Mutation++ in the directory defined with --prefix') option('enable-coolprop', type : 'boolean', value : false, description: 'enable CoolProp support') option('enable-cantera', type : 'boolean', value : false, description: 'enable Cantera support') +option('cantera-build-jobs', type : 'integer', min : 0, value : 4, description: 'number of parallel jobs used to build Cantera from source (0 uses all cores)') option('cantera-boost-inc-dir', type : 'string', value : '', description: 'explicit Boost header directory for building Cantera from source (only needed if SCons cannot auto-detect Boost)') option('enable-mlpcpp', type : 'boolean', value : false, description: 'enable MLPCpp support') option('enable-gprof', type : 'boolean', value : false, description: 'enable profiling through gprof') diff --git a/meson_scripts/build_cantera.py b/meson_scripts/build_cantera.py index c64ecc169168..411f3119f7b7 100644 --- a/meson_scripts/build_cantera.py +++ b/meson_scripts/build_cantera.py @@ -96,6 +96,12 @@ def main(): default="", help="Value of SU2's -march= target (cpu-arch option), kept in sync so Eigen template code Cantera and SU2 both instantiate is not ODR-mixed across incompatible vectorization ISAs", ) + parser.add_argument( + "--jobs", + type=int, + default=4, + help="Number of parallel SCons jobs (0 uses all available cores)", + ) args = parser.parse_args() if not os.path.exists(os.path.join(args.source, "SConstruct")): @@ -129,14 +135,17 @@ def main(): [scons, "build", "install", "prefix=" + args.prefix] + CANTERA_SCONS_ARGS + ["extra_inc_dirs=" + eigen_shim_dir] - + ["-j{}".format(multiprocessing.cpu_count())] + + ["-j{}".format(args.jobs if args.jobs > 0 else multiprocessing.cpu_count())] ) if args.boost_inc_dir: scons_command.append("boost_inc_dir=" + args.boost_inc_dir) if args.cpu_arch: scons_command.append("cc_flags=-march=" + args.cpu_arch) - result = subprocess.run(scons_command, cwd=args.source) + # Cantera adds $CONDA_PREFIX paths to its flags, which would make the build depend on the shell. + scons_env = {key: value for key, value in os.environ.items() if key != "CONDA_PREFIX"} + + result = subprocess.run(scons_command, cwd=args.source, env=scons_env) if result.returncode != 0: sys.exit( "Cantera build failed (see output above). If SCons could not find Boost headers, " @@ -144,6 +153,13 @@ def main(): "or install Boost development headers (e.g. the 'libboost-dev' package)." ) + # With system_fmt=n the installed headers include "cantera/ext/...", which SCons leaves + # in the source tree only; copy them next to the installed headers. + ext_src = os.path.join(args.source, "include", "cantera", "ext") + ext_dst = os.path.join(args.prefix, "include", "cantera", "ext") + if os.path.isdir(ext_src): + shutil.copytree(ext_src, ext_dst, dirs_exist_ok=True) + # meson tracks this custom_target as always-stale, so re-running scons here is cheap # once Cantera itself is up to date; the stamp file just gives meson an output to track. open(args.stamp, "w").close() From 445fb15ac8d8d6be06ac1607eeed99ac6e57495d Mon Sep 17 00:00:00 2001 From: bigfooted Date: Sun, 4 Oct 2026 09:19:58 +0200 Subject: [PATCH 166/173] precommit --- meson_scripts/build_cantera.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/meson_scripts/build_cantera.py b/meson_scripts/build_cantera.py index 411f3119f7b7..95e0019c3855 100644 --- a/meson_scripts/build_cantera.py +++ b/meson_scripts/build_cantera.py @@ -143,7 +143,9 @@ def main(): scons_command.append("cc_flags=-march=" + args.cpu_arch) # Cantera adds $CONDA_PREFIX paths to its flags, which would make the build depend on the shell. - scons_env = {key: value for key, value in os.environ.items() if key != "CONDA_PREFIX"} + scons_env = { + key: value for key, value in os.environ.items() if key != "CONDA_PREFIX" + } result = subprocess.run(scons_command, cwd=args.source, env=scons_env) if result.returncode != 0: From 04e2c58e49448c4f803ac91ff61e87b29b7c54bf Mon Sep 17 00:00:00 2001 From: bigfooted Date: Sun, 4 Oct 2026 16:35:41 +0200 Subject: [PATCH 167/173] do not compute for low temperatures, fix multigrid issues. --- Common/include/CConfig.hpp | 8 ++- Common/include/option_structure.hpp | 7 +++ Common/src/CConfig.cpp | 9 ++++ Common/src/geometry/CMultiGridGeometry.cpp | 49 +++++++++---------- SU2_CFD/include/fluid/CFluidCantera.hpp | 3 +- .../integration/CMultiGridIntegration.hpp | 1 + .../include/limiters/computeLimiters_impl.hpp | 1 + .../numerics/scalar/scalar_edge_flux.hpp | 2 +- SU2_CFD/include/numerics/util.hpp | 2 +- .../include/variables/CSpeciesVariable.hpp | 2 +- SU2_CFD/src/fluid/CFluidCantera.cpp | 9 +++- .../integration/CSingleGridIntegration.cpp | 29 ++++++++--- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 9 ++-- SU2_CFD/src/solvers/CIncNSSolver.cpp | 16 ++++-- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 25 ++++++---- .../SU2_CFD/fluid/CFluidCantera_tests.cpp | 15 ++++++ 16 files changed, 128 insertions(+), 59 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 43ee3b06c510..5c4e07c4fedc 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -89,6 +89,7 @@ class CConfig { unsigned short n_GasCompositionNames; /*!<\brief Number of gases in mixture composition for Cantera. */ bool Combustion; /*!< \brief Flag for Combustion Detailed chemistry problems using Cantera. */ bool Chemical_Source_Jacobian; /*!< \brief Flag for the diagonal chemical source Jacobian in the species equations. */ + su2double Cantera_DC_Min_Temp; /*!< \brief Temperature below which the chemical source terms are set to zero. */ su2double Spark_Temperature; /*!< \brief Spark temperature used for ignition in detailed chemistry using Cantera. */ string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */ @@ -1192,7 +1193,7 @@ class CConfig { su2double *FreeStreamTurboNormal; /*!< \brief Direction to initialize the flow in turbomachinery computation */ su2double Restart_Bandwidth_Agg; /*!< \brief The aggregate of the bandwidth for writing binary restarts (to be averaged later). */ - su2double Max_Vel2; /*!< \brief The maximum velocity^2 in the domain for the incompressible preconditioner. */ + su2double Max_Vel2{0.0}; /*!< \brief The maximum velocity^2 in the domain for the incompressible preconditioner. */ su2double RangePressure[2]; /*!< \brief The pressure difference pmax-pmin in the domain for the target mass flow rate scaling. */ bool topology_optimization; /*!< \brief If the structural solver should consider a variable density field to penalize element stiffness. */ string top_optim_output_file; /*!< \brief File to where the derivatives w.r.t. element densities will be written to. */ @@ -4138,6 +4139,11 @@ class CConfig { */ bool GetChemical_Source_Jacobian(void) const { return Chemical_Source_Jacobian; } + /*! + * \brief Get the temperature below which the chemical source terms are set to zero. + */ + su2double GetCantera_DC_Min_Temp(void) const { return Cantera_DC_Min_Temp; } + /*! * \brief Get High temperature applied during spark ignition. * \return Spark Temperature. diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 34d32614a855..f6bad3933876 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -97,6 +97,13 @@ constexpr passivedouble BOLTZMANN_CONSTANT = 1.3806503E-23; /*!< \brief Boltzm constexpr passivedouble AVOGAD_CONSTANT = 6.0221415E26; /*!< \brief Avogadro's constant, number of particles in one kmole. */ constexpr passivedouble FUND_ELEC_CHARGE_CGS = 4.8032047E-10; /*!< \brief Fundamental electric charge in CGS units, cm^(3/2) g^(1/2) s^(-1). */ constexpr passivedouble STD_REF_TEMP = 298.15; /*!< \brief Standard reference temperature for enthalpy in Kelvin. */ + +/*! + * \brief Maximum number of transported species (scalar equations of the species model). + * \note Sizes the stack storage of the species edge-flux kernel, which is the performance-critical + * user of this limit, and the static arrays of the species solver. Larger values slow the kernel down. + */ +constexpr unsigned short MAX_TRANSPORTED_SPECIES = 8; constexpr passivedouble EPS = 1.0E-16; /*!< \brief Error scale. */ constexpr passivedouble TURB_EPS = 1.0E-16; /*!< \brief Turbulent Error scale. */ diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 3bc6e11f89ea..d1132ec87fdc 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1297,6 +1297,8 @@ void CConfig::SetConfig_Options() { addDoubleOption("SPARK_TEMPERATURE", Spark_Temperature, 1000.0); /*!\brief CHEMICAL_SOURCE_JACOBIAN \n DESCRIPTION: Add the diagonal chemical sink Jacobian to the implicit species equations \n DEFAULT: true \ingroup Config*/ addBoolOption("CHEMICAL_SOURCE_JACOBIAN", Chemical_Source_Jacobian, true); + /*!\brief CANTERA_DC_MIN_TEMP \n DESCRIPTION: Temperature [K] below which the chemical source terms are set to zero \n DEFAULT: 500 K \ingroup Config*/ + addDoubleOption("CANTERA_DC_MIN_TEMP", Cantera_DC_Min_Temp, 500.0); /*!\par CONFIG_CATEGORY: Data-driven fluid model parameters \ingroup Config*/ /*!\brief INTERPOLATION_METHOD \n DESCRIPTION: Interpolation method used to determine the thermodynamic state of the fluid. \n OPTIONS: See \link DataDrivenMethod_Map \endlink DEFAULT: MLP \ingroup Config*/ @@ -6041,6 +6043,13 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i /*--- Once consistency is checked set the var that is used throughout the code. ---*/ nSpecies = nSpecies_Init; + if (nSpecies > MAX_TRANSPORTED_SPECIES) { + SU2_MPI::Error("The species model supports at most " + to_string(MAX_TRANSPORTED_SPECIES) + + " transported species equations, but " + to_string(nSpecies) + + " were given. Increase MAX_TRANSPORTED_SPECIES in option_structure.hpp.", + CURRENT_FUNCTION); + } + /*--- Check whether some variables (or their sums) are in physical bounds. [0,1] for species related quantities. ---*/ /*--- Note, only for species transport, not for flamelet model ---*/ if (Kind_Species_Model == SPECIES_MODEL::SPECIES_TRANSPORT) { diff --git a/Common/src/geometry/CMultiGridGeometry.cpp b/Common/src/geometry/CMultiGridGeometry.cpp index d3bca729bf5b..b8caa00e9c94 100644 --- a/Common/src/geometry/CMultiGridGeometry.cpp +++ b/Common/src/geometry/CMultiGridGeometry.cpp @@ -1422,34 +1422,31 @@ void CMultiGridGeometry::FindNormal_Neighbor(const CConfig* config) { for (auto iVertex = 0ul; iVertex < nVertex[iMarker]; iVertex++) { auto iPoint = vertex[iMarker][iVertex]->GetNode(); - /*--- If the node belong to the domain ---*/ - if (nodes->GetDomain(iPoint)) { - /*--- Compute closest normal neighbor ---*/ - unsigned long Point_Normal = 0; - su2double* Normal = vertex[iMarker][iVertex]->GetNormal(); - su2double cos_max = -1.0; - for (auto jPoint : nodes->GetPoints(iPoint)) { - su2double scalar_prod = 0.0; - su2double norm_vect = 0.0; - su2double norm_Normal = 0.0; - for (auto iDim = 0u; iDim < nDim; iDim++) { - su2double diff_coord = nodes->GetCoord(jPoint, iDim) - nodes->GetCoord(iPoint, iDim); - scalar_prod += diff_coord * Normal[iDim]; - norm_vect += diff_coord * diff_coord; - norm_Normal += Normal[iDim] * Normal[iDim]; - } - norm_vect = sqrt(norm_vect); - norm_Normal = sqrt(norm_Normal); - su2double cos_alpha = scalar_prod / (norm_vect * norm_Normal); - - /*--- Get maximum cosine (not minimum because normals are oriented inwards) ---*/ - if (cos_alpha >= cos_max) { - Point_Normal = jPoint; - cos_max = cos_alpha; - } + /*--- Compute closest normal neighbor, also for halo points, which Friction_Forces visits. ---*/ + unsigned long Point_Normal = 0; + su2double* Normal = vertex[iMarker][iVertex]->GetNormal(); + su2double cos_max = -1.0; + for (auto jPoint : nodes->GetPoints(iPoint)) { + su2double scalar_prod = 0.0; + su2double norm_vect = 0.0; + su2double norm_Normal = 0.0; + for (auto iDim = 0u; iDim < nDim; iDim++) { + su2double diff_coord = nodes->GetCoord(jPoint, iDim) - nodes->GetCoord(iPoint, iDim); + scalar_prod += diff_coord * Normal[iDim]; + norm_vect += diff_coord * diff_coord; + norm_Normal += Normal[iDim] * Normal[iDim]; + } + norm_vect = sqrt(norm_vect); + norm_Normal = sqrt(norm_Normal); + su2double cos_alpha = scalar_prod / (norm_vect * norm_Normal); + + /*--- Get maximum cosine (not minimum because normals are oriented inwards) ---*/ + if (cos_alpha >= cos_max) { + Point_Normal = jPoint; + cos_max = cos_alpha; } - vertex[iMarker][iVertex]->SetNormal_Neighbor(Point_Normal); } + vertex[iMarker][iVertex]->SetNormal_Neighbor(Point_Normal); } } } diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 99495c6afa71..ccd033327714 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -57,6 +57,7 @@ class CFluidCantera final : public CFluidModel { const string Chemical_MechanismFile; /*!< \brief Chemical reaction mechanism used for in cantera*/ const string Phase_Name; /*!< \brief Name of the phase used for in cantera*/ const bool Combustion; /*!< \brief Flag for problems involving combustion.*/ + const su2double Chemistry_Min_Temperature; /*!< \brief Temperature below which the chemistry is skipped. */ su2double Heat_Release{0.0}; /*!< \brief heat release due to combustion */ bool stateFailed{false}; /*!< \brief The last state evaluation did not converge. */ @@ -140,7 +141,7 @@ class CFluidCantera final : public CFluidModel { } /*! - * \brief Compute chemical source term and heat release from the current state. + * \brief Compute chemical source term and heat release from the current state, zero below the minimum temperature. */ void ComputeChemicalSourceTerm() override; diff --git a/SU2_CFD/include/integration/CMultiGridIntegration.hpp b/SU2_CFD/include/integration/CMultiGridIntegration.hpp index d73b4962128f..71f9ef86334a 100644 --- a/SU2_CFD/include/integration/CMultiGridIntegration.hpp +++ b/SU2_CFD/include/integration/CMultiGridIntegration.hpp @@ -325,6 +325,7 @@ class CMultiGridIntegration final : public CIntegration { * independently of the CSysMatrix limit of the same name. ---*/ static constexpr unsigned short MAXNVAR = 25; static constexpr unsigned short MAXNDIM = 3; + static_assert(MAXNVAR >= MAX_TRANSPORTED_SPECIES, "The scalar equations of the species model must fit."); /*--- Early-exit smoothing state (shared across OMP threads via master write + barrier). ---*/ bool mg_early_exit_flag = false; /*!< \brief Shared flag for early exit across OMP threads. */ diff --git a/SU2_CFD/include/limiters/computeLimiters_impl.hpp b/SU2_CFD/include/limiters/computeLimiters_impl.hpp index 7d8beafb03e0..f1499db556fc 100644 --- a/SU2_CFD/include/limiters/computeLimiters_impl.hpp +++ b/SU2_CFD/include/limiters/computeLimiters_impl.hpp @@ -79,6 +79,7 @@ void computeLimiters_impl(CSolver* solver, FieldType& limiter) { constexpr size_t MAXNVAR = 32; + static_assert(MAXNVAR >= MAX_TRANSPORTED_SPECIES, "The scalar equations of the species model must fit."); if (varEnd > MAXNVAR) SU2_MPI::Error("Number of variables is too large, increase MAXNVAR.", CURRENT_FUNCTION); diff --git a/SU2_CFD/include/numerics/scalar/scalar_edge_flux.hpp b/SU2_CFD/include/numerics/scalar/scalar_edge_flux.hpp index 4d2e79608bdf..1981ffc657ab 100644 --- a/SU2_CFD/include/numerics/scalar/scalar_edge_flux.hpp +++ b/SU2_CFD/include/numerics/scalar/scalar_edge_flux.hpp @@ -368,7 +368,7 @@ class CUpwScalarBase : public CUpwScalarFlux Size) { - SU2_MPI::Error("Static arrays are too small for the requested equation count.", CURRENT_FUNCTION); + SU2_MPI::Error("The number of equations exceeds MAX_TRANSPORTED_SPECIES, the size of the static arrays.", CURRENT_FUNCTION); } } diff --git a/SU2_CFD/include/numerics/util.hpp b/SU2_CFD/include/numerics/util.hpp index 92e5144b9c93..bdfc8bb432db 100644 --- a/SU2_CFD/include/numerics/util.hpp +++ b/SU2_CFD/include/numerics/util.hpp @@ -156,7 +156,7 @@ constexpr size_t Dynamic = size_t(-1); * \note The scalar numerics cap the equation count at this value and error above it, so a * configuration that fits them fits these kernels. */ -constexpr size_t MaxScalarVar = 8; +constexpr size_t MaxScalarVar = MAX_TRANSPORTED_SPECIES; /*! * \brief Residual of one edge, accumulated by the convective and the diffusive terms. diff --git a/SU2_CFD/include/variables/CSpeciesVariable.hpp b/SU2_CFD/include/variables/CSpeciesVariable.hpp index 6219bc4f28d9..8e45f5e8313b 100644 --- a/SU2_CFD/include/variables/CSpeciesVariable.hpp +++ b/SU2_CFD/include/variables/CSpeciesVariable.hpp @@ -41,7 +41,7 @@ class CSpeciesVariable : public CScalarVariable { VectorType HeatRelease; /*!< \brief Vector of heat release due to combustion for species transport*/ public: - static constexpr size_t MAXNVAR = 20; /*!< \brief Max number of variables for static arrays. Increase, if necessary. */ + static constexpr size_t MAXNVAR = MAX_TRANSPORTED_SPECIES; /*!< \brief Max number of variables for static arrays. */ /*! * \brief Constructor of the class. diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 29c8bcc258b9..b6fbfd0a1396 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -45,7 +45,8 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* Transport_Model(config->GetTransport_Model()), Chemical_MechanismFile(config->GetChemical_MechanismFile()), Phase_Name(config->GetPhase_Name()), - Combustion(config->GetCombustion()) { + Combustion(config->GetCombustion()), + Chemistry_Min_Temperature(config->GetCantera_DC_Min_Temp()) { try { sol = std::shared_ptr(newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model)); const auto& thermo = *sol->thermo(); @@ -99,6 +100,12 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { } void CFluidCantera::ComputeChemicalSourceTerm() { + if (Temperature < Chemistry_Min_Temperature) { + std::fill(chemicalSourceTerm.begin(), chemicalSourceTerm.end(), 0.0); + std::fill(chemicalSourceJacobian.begin(), chemicalSourceJacobian.end(), 0.0); + Heat_Release = 0.0; + return; + } try { sol->kinetics()->getNetProductionRates(netProductionRates.data()); sol->kinetics()->getDestructionRates(destructionRates.data()); diff --git a/SU2_CFD/src/integration/CSingleGridIntegration.cpp b/SU2_CFD/src/integration/CSingleGridIntegration.cpp index 29c71b2ed360..7dca6641bce0 100644 --- a/SU2_CFD/src/integration/CSingleGridIntegration.cpp +++ b/SU2_CFD/src/integration/CSingleGridIntegration.cpp @@ -95,9 +95,9 @@ void CSingleGridIntegration::SingleGrid_Iteration(CGeometry ****geometry, CSolve SU2_OMP_SAFE_GLOBAL_ACCESS(solvers_fine[HEAT_SOL]->Heat_Fluxes(geometry_fine, solvers_fine, config[iZone]);) } - /*--- If turbulence model, copy the turbulence variables to the coarse levels ---*/ + /*--- Copy the turbulence or species variables to the coarse levels ---*/ - if (RunTime_EqSystem == RUNTIME_TURB_SYS) { + if (RunTime_EqSystem == RUNTIME_TURB_SYS || RunTime_EqSystem == RUNTIME_SPECIES_SYS) { for (unsigned short iMesh = FinestMesh; iMesh < config[iZone]->GetnMGLevels(); iMesh++) { @@ -108,12 +108,25 @@ void CSingleGridIntegration::SingleGrid_Iteration(CGeometry ****geometry, CSolve geometry[iZone][iInst][iMesh+1], config[iZone]); - SetRestricted_EddyVisc(RunTime_EqSystem, - solver_container[iZone][iInst][iMesh][Solver_Position], - solver_container[iZone][iInst][iMesh+1][Solver_Position], - geometry[iZone][iInst][iMesh], - geometry[iZone][iInst][iMesh+1], - config[iZone]); + if (RunTime_EqSystem == RUNTIME_SPECIES_SYS) { + /*--- The flow solver on the coarse level needs the species gradient for the enthalpy diffusion. ---*/ + CSolver* species_coarse = solver_container[iZone][iInst][iMesh+1][Solver_Position]; + CGeometry* geometry_coarse = geometry[iZone][iInst][iMesh+1]; + switch (config[iZone]->GetKind_Gradient_Method()) { + case GREEN_GAUSS: species_coarse->SetSolution_Gradient_GG(geometry_coarse, config[iZone], -1); break; + case WEIGHTED_LEAST_SQUARES: species_coarse->SetSolution_Gradient_LS(geometry_coarse, config[iZone], -1); break; + default: break; + } + } + + if (RunTime_EqSystem == RUNTIME_TURB_SYS) { + SetRestricted_EddyVisc(RunTime_EqSystem, + solver_container[iZone][iInst][iMesh][Solver_Position], + solver_container[iZone][iInst][iMesh+1][Solver_Position], + geometry[iZone][iInst][iMesh], + geometry[iZone][iInst][iMesh+1], + config[iZone]); + } } } diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index d4569e52285e..f1ef80a769bd 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1805,7 +1805,6 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont if(multicomponent && energy){ /*--- retrieve number of species that are solved and set maximum static array ---*/ int n_species = config->GetnSpecies(); - static constexpr size_t MAXNVAR_SPECIES = 20UL; /*--- Obtain fluid model for computing the enthalpy diffusion terms. ---*/ CFluidModel* FluidModel = solver_container[FLOW_SOL]->GetFluidModel(); /*--- retrieve species gradient needed for multicomponent. ---*/ @@ -1813,8 +1812,8 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Set thermodynamic state. ---*/ FluidModel->SetTDState_T(nodes->GetTemperature(iPoint),solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint)); /*--- Get enthalpy diffusion terms and its gradients(for implicit). ---*/ - su2double EnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; - su2double GradEnthalpyDiffusion_i[MAXNVAR_SPECIES]{0.0}; + su2double EnthalpyDiffusion_i[MAX_TRANSPORTED_SPECIES]{0.0}; + su2double GradEnthalpyDiffusion_i[MAX_TRANSPORTED_SPECIES]{0.0}; FluidModel->GetEnthalpyDiffusivity(EnthalpyDiffusion_i); if (implicit) FluidModel->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion_i); /*--- Compute Enthalpy diffusion flux and its jacobian (for implicit iterations) ---*/ @@ -2219,9 +2218,9 @@ void CIncEulerSolver::SetBeta_Parameter(CGeometry *geometry, CSolver **solver_co static su2double MaxVel2; const su2double epsilon2_default = 4.1; - /*--- For now, only the finest mesh level stores the Beta for all levels. ---*/ + /*--- For now, only the finest active mesh level stores the Beta for all levels. ---*/ - if (iMesh == MESH_0) { + if (iMesh == config->GetFinestMesh()) { SU2_OMP_MASTER MaxVel2 = 0.0; END_SU2_OMP_MASTER diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 3cac20b3b413..372820842806 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -27,6 +27,7 @@ #include "../../include/solvers/CIncNSSolver.hpp" #include "../../include/variables/CIncNSVariable.hpp" +#include "../../include/variables/CSpeciesVariable.hpp" #include "../../../Common/include/toolboxes/printing_toolbox.hpp" #include "../../include/solvers/CFVMFlowSolverBase.inl" @@ -369,8 +370,6 @@ void CIncNSSolver::Compute_Enthalpy_Diffusion(unsigned long iEdge, CGeometry* ge /*--- set maximum static array ---*/ - static constexpr size_t MAXNVAR_SPECIES = 20UL; - /*--- Species variables, and its gradients ---*/ const su2double* Species_i = speciesNodes->GetSolution(iPoint); const su2double* Species_j = speciesNodes->GetSolution(jPoint); @@ -378,8 +377,8 @@ void CIncNSSolver::Compute_Enthalpy_Diffusion(unsigned long iEdge, CGeometry* ge CMatrixView Species_Grad_j = speciesNodes->GetGradient(jPoint); /*--- Compute Projected gradient for species variables ---*/ - su2double ProjGradScalarVarNoCorr[MAXNVAR_SPECIES]{0.0}; - su2double Proj_Mean_GradScalarVar[MAXNVAR_SPECIES]{0.0}; + su2double ProjGradScalarVarNoCorr[MAX_TRANSPORTED_SPECIES]{0.0}; + su2double Proj_Mean_GradScalarVar[MAX_TRANSPORTED_SPECIES]{0.0}; numerics->ComputeProjectedGradient(nDim, n_species, Normal, Coord_i, Coord_j, Species_Grad_i, Species_Grad_j, true, Species_i, Species_j, ProjGradScalarVarNoCorr, Proj_Mean_GradScalarVar); @@ -414,12 +413,21 @@ void CIncNSSolver::ComputeEnthalpyDiffusionTerms(CSolver** solver_container, con CVariable* speciesNodes = solver_container[SPECIES_SOL]->GetNodes(); const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); + /*--- The species solver reads the mass diffusivities evaluated here instead of computing them again. ---*/ + const bool share_diffusivity = (config->GetKind_FluidModel() == FLUID_CANTERA); + auto* species = share_diffusivity ? su2staticcast_p(speciesNodes) : nullptr; + const unsigned short nSpecies = config->GetnSpecies(); + SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { fluid_model->SetTDState_T(nodes->GetPrimitive(iPoint)[prim_idx.Temperature()], speciesNodes->GetSolution(iPoint)); fluid_model->SetEddyViscosity(nodes->GetPrimitive(iPoint)[prim_idx.EddyViscosity()]); fluid_model->GetEnthalpyDiffusivity(EnthalpyDiffusion[iPoint]); if (implicit) fluid_model->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion[iPoint]); + if (share_diffusivity) { + for (unsigned short iVar = 0; iVar <= nSpecies; iVar++) + species->SetDiffusivity(iPoint, fluid_model->GetMassDiffusivity(iVar), iVar); + } } END_SU2_OMP_FOR } diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index e6d26645bcd7..9049191aa824 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -110,7 +110,7 @@ void CSpeciesSolver::Initialize(CGeometry* geometry, CConfig* config, unsigned s nPrimVar = nVar; if (nVar > MAXNVAR) - SU2_MPI::Error("Increase static array size MAXNVAR for CSpeciesVariable and proceed.", CURRENT_FUNCTION); + SU2_MPI::Error("The number of species equations exceeds MAX_TRANSPORTED_SPECIES.", CURRENT_FUNCTION); nPoint = geometry->GetnPoint(); nPointDomain = geometry->GetnPointDomain(); @@ -337,9 +337,16 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain CFluidModel* fluid_model = solver_container[FLOW_SOL]->GetFluidModel(); fluid_model->SetMassDiffusivityModel(config); + /*--- The flow solver evaluates the Cantera mass diffusivities together with the enthalpy diffusion. ---*/ + const bool diffusivity_from_flow = (config->GetKind_FluidModel() == FLUID_CANTERA) && config->GetEnergy_Equation(); + /*--- Set the laminar mass Diffusivity and chemical source term for the species solver. ---*/ SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0u; iPoint < nPoint; iPoint++) { + /*--- Chemical source terms are only used by the residual of the points owned by this rank. ---*/ + const bool chemistry = combustion && (iPoint < nPointDomain); + if (diffusivity_from_flow && !chemistry) continue; + su2double temperature = solver_container[FLOW_SOL]->GetNodes()->GetTemperature(iPoint); if (ignition) { /*--- Apply ignition temperature within spark radius. ---*/ @@ -350,22 +357,20 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain const su2double* scalar = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint); fluid_model->SetTDState_T(temperature, scalar); - /*--- Chemical source terms are only used by the residual of the points owned by this rank. ---*/ - const bool chemistry = combustion && (iPoint < nPointDomain); if (chemistry) { fluid_model->ComputeChemicalSourceTerm(); nodes->SetHeatRelease(iPoint, fluid_model->GetHeatRelease()); - } - /*--- Recompute viscosity, important to get diffusivity correct across MPI ranks. ---*/ - nodes->SetLaminarViscosity(iPoint, fluid_model->GetLaminarViscosity()); - /*--- Set the laminar mass Diffusivity for the species solver. ---*/ - for (auto iVar = 0u; iVar <= nVar; iVar++) { - nodes->SetDiffusivity(iPoint, fluid_model->GetMassDiffusivity(iVar), iVar); - if (chemistry) { + for (auto iVar = 0u; iVar <= nVar; iVar++) { nodes->SetChemicalSourceTerm(iPoint, fluid_model->GetChemicalSourceTerm(iVar), iVar); nodes->SetChemicalSourceJacobian(iPoint, fluid_model->GetChemicalSourceJacobian(iVar), iVar); } } + if (!diffusivity_from_flow) { + /*--- Recompute viscosity, important to get diffusivity correct across MPI ranks. ---*/ + nodes->SetLaminarViscosity(iPoint, fluid_model->GetLaminarViscosity()); + /*--- Set the laminar mass Diffusivity for the species solver. ---*/ + for (auto iVar = 0u; iVar <= nVar; iVar++) nodes->SetDiffusivity(iPoint, fluid_model->GetMassDiffusivity(iVar), iVar); + } } // iPoint END_SU2_OMP_FOR diff --git a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp index 204db1ec1e69..9ef337f99645 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp @@ -163,5 +163,20 @@ TEST_CASE("Fluid_Cantera_SourceJacobian", "[Reacting_flow]") { const su2double slope_CH4 = (fluid.GetChemicalSourceTerm(2) - source_CH4) / delta; CHECK(fluid.GetChemicalSourceJacobian(2) == Approx(slope_CH4).epsilon(0.1)); CHECK(source_O2 < 0.0); + + /*--- Below CANTERA_DC_MIN_TEMP (500 K by default) the chemistry is skipped. ---*/ + + scalar[2] -= delta; + fluid.SetTDState_T(400.0, scalar); + fluid.ComputeChemicalSourceTerm(); + for (int iVar = 0; iVar < 4; iVar++) { + CHECK(fluid.GetChemicalSourceTerm(iVar) == 0.0); + CHECK(fluid.GetChemicalSourceJacobian(iVar) == 0.0); + } + CHECK(fluid.GetHeatRelease() == 0.0); + + fluid.SetTDState_T(600.0, scalar); + fluid.ComputeChemicalSourceTerm(); + CHECK(fluid.GetChemicalSourceTerm(2) != 0.0); } #endif From 01ab322fea4dbe7587fa0fe262ffaed7a926d142 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Sun, 4 Oct 2026 21:14:04 +0200 Subject: [PATCH 168/173] add correction velocity. Fix Jacobian with density. --- Common/include/CConfig.hpp | 6 +++ Common/include/option_structure.hpp | 2 +- Common/src/CConfig.cpp | 2 + SU2_CFD/include/fluid/CFluidCantera.hpp | 4 +- .../numerics/scalar/scalar_edge_flux.hpp | 9 ++++ .../numerics/species/species_edge_flux.hpp | 54 +++++++++++++++++++ SU2_CFD/src/fluid/CFluidCantera.cpp | 19 ++++--- .../SU2_CFD/fluid/CFluidCantera_tests.cpp | 2 +- config_template.cfg | 47 ++++++++++++++-- 9 files changed, 131 insertions(+), 14 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 5c4e07c4fedc..1f05561a1e12 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -90,6 +90,7 @@ class CConfig { bool Combustion; /*!< \brief Flag for Combustion Detailed chemistry problems using Cantera. */ bool Chemical_Source_Jacobian; /*!< \brief Flag for the diagonal chemical source Jacobian in the species equations. */ su2double Cantera_DC_Min_Temp; /*!< \brief Temperature below which the chemical source terms are set to zero. */ + bool Cantera_Correction_Velocity; /*!< \brief Flag for the correction velocity of the species diffusion fluxes. */ su2double Spark_Temperature; /*!< \brief Spark temperature used for ignition in detailed chemistry using Cantera. */ string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */ @@ -4144,6 +4145,11 @@ class CConfig { */ su2double GetCantera_DC_Min_Temp(void) const { return Cantera_DC_Min_Temp; } + /*! + * \brief Get whether the species diffusion fluxes are corrected to sum to zero. + */ + bool GetCantera_Correction_Velocity(void) const { return Cantera_Correction_Velocity; } + /*! * \brief Get High temperature applied during spark ignition. * \return Spark Temperature. diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index f6bad3933876..b8d9a9030e70 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -103,7 +103,7 @@ constexpr passivedouble STD_REF_TEMP = 298.15; /*!< \brief Standard reference t * \note Sizes the stack storage of the species edge-flux kernel, which is the performance-critical * user of this limit, and the static arrays of the species solver. Larger values slow the kernel down. */ -constexpr unsigned short MAX_TRANSPORTED_SPECIES = 8; +constexpr unsigned short MAX_TRANSPORTED_SPECIES = 12; constexpr passivedouble EPS = 1.0E-16; /*!< \brief Error scale. */ constexpr passivedouble TURB_EPS = 1.0E-16; /*!< \brief Turbulent Error scale. */ diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index d1132ec87fdc..35365fa0e8cc 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1299,6 +1299,8 @@ void CConfig::SetConfig_Options() { addBoolOption("CHEMICAL_SOURCE_JACOBIAN", Chemical_Source_Jacobian, true); /*!\brief CANTERA_DC_MIN_TEMP \n DESCRIPTION: Temperature [K] below which the chemical source terms are set to zero \n DEFAULT: 500 K \ingroup Config*/ addDoubleOption("CANTERA_DC_MIN_TEMP", Cantera_DC_Min_Temp, 500.0); + /*!\brief CANTERA_CORRECTION_VELOCITY \n DESCRIPTION: Correct the species diffusion fluxes so that they sum to zero \n DEFAULT: true \ingroup Config*/ + addBoolOption("CANTERA_CORRECTION_VELOCITY", Cantera_Correction_Velocity, true); /*!\par CONFIG_CATEGORY: Data-driven fluid model parameters \ingroup Config*/ /*!\brief INTERPOLATION_METHOD \n DESCRIPTION: Interpolation method used to determine the thermodynamic state of the fluid. \n OPTIONS: See \link DataDrivenMethod_Map \endlink DEFAULT: MLP \ingroup Config*/ diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index ccd033327714..9d8578b3e6c8 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -58,6 +58,7 @@ class CFluidCantera final : public CFluidModel { const string Phase_Name; /*!< \brief Name of the phase used for in cantera*/ const bool Combustion; /*!< \brief Flag for problems involving combustion.*/ const su2double Chemistry_Min_Temperature; /*!< \brief Temperature below which the chemistry is skipped. */ + const bool Correction_Velocity; /*!< \brief The diffusive species fluxes are corrected to sum to zero. */ su2double Heat_Release{0.0}; /*!< \brief heat release due to combustion */ bool stateFailed{false}; /*!< \brief The last state evaluation did not converge. */ @@ -152,7 +153,8 @@ class CFluidCantera final : public CFluidModel { inline su2double GetChemicalSourceTerm(int ivar) override { return chemicalSourceTerm[ivar]; } /*! - * \brief Get the derivative of the chemical source term with respect to the own mass fraction (always <= 0). + * \brief Get the derivative of the chemical source term with respect to the own density-weighted mass fraction + * (always <= 0). * \param[in] ivar - index of species. */ inline su2double GetChemicalSourceJacobian(int ivar) override { return chemicalSourceJacobian[ivar]; } diff --git a/SU2_CFD/include/numerics/scalar/scalar_edge_flux.hpp b/SU2_CFD/include/numerics/scalar/scalar_edge_flux.hpp index 1981ffc657ab..7e2f71b6bec0 100644 --- a/SU2_CFD/include/numerics/scalar/scalar_edge_flux.hpp +++ b/SU2_CFD/include/numerics/scalar/scalar_edge_flux.hpp @@ -237,6 +237,8 @@ class CAvgGradScalarBase { self->coefficientJacobians(opt, D, projGrad, res); } + self->diffusionCorrection(opt, iPoint, side_i, jPoint, side_j, rho, projGrad, proj_on_w_i, proj_on_w_j, res); + self->extraDiffusionTerms(idx, opt, iPoint, side_i, jPoint, side_j, rho, normal, vector_ij, res); } @@ -246,6 +248,13 @@ class CAvgGradScalarBase { template FORCEINLINE void coefficientJacobians(Ts&&...) const {} + /*! + * \brief Flux that couples the equations through the projected gradients, with the Jacobians + * w.r.t. the conserved variables. + */ + template + FORCEINLINE void diffusionCorrection(Ts&&...) const {} + /*! * \brief Diffusion of a model that transports more than one gradient, of states it * synthesises from its own containers. diff --git a/SU2_CFD/include/numerics/species/species_edge_flux.hpp b/SU2_CFD/include/numerics/species/species_edge_flux.hpp index e744d8c96553..a1afe5ca88f9 100644 --- a/SU2_CFD/include/numerics/species/species_edge_flux.hpp +++ b/SU2_CFD/include/numerics/species/species_edge_flux.hpp @@ -55,8 +55,61 @@ class CScalarFluxSpeciesBase : public CUpwScalarBase + FORCEINLINE void diffusionCorrection(const ScalarFluxOptions& opt, Int iPoint, const EdgeSide& side_i, + Int jPoint, const EdgeSide& side_j, const CPair& rho, + const Vector& projGrad, const Double& proj_on_w_i, + const Double& proj_on_w_j, EdgeResidual& res) const { + if (!correctionVelocity) return; + + const size_t nEqn = this->nEqn; + auto faceDiffusivity = [&](size_t iVar) { + const Double D_i = gatherVariables(iPoint, side_i.scalarNodes.GetDiffusivity(), iVar); + const Double D_j = gatherVariables(jPoint, side_j.scalarNodes.GetDiffusivity(), iVar); + return 0.5 * (rho.i * D_i + rho.j * D_j); + }; + + /*--- Difference of each species to the remainder, and the face mass flux of the correction. ---*/ + const Double D_last = faceDiffusivity(nEqn); + Vector c; + Double massFlux = 0.0; + for (size_t iVar = 0; iVar < nEqn; ++iVar) { + c(iVar) = faceDiffusivity(iVar) - D_last; + massFlux += c(iVar) * projGrad(iVar); + } + + for (size_t iVar = 0; iVar < nEqn; ++iVar) { + const Double Y_i = gatherVariables(iPoint, side_i.scalarNodes.GetSolution(), iVar); + const Double Y_j = gatherVariables(jPoint, side_j.scalarNodes.GetSolution(), iVar); + const Double Y_face = 0.5 * (Y_i + Y_j); + + const Double flux = Y_face * massFlux; + res.flux_i(iVar) += flux; + if (!opt.oneSided) res.flux_j(iVar) -= flux; + + if (opt.implicit) { + for (size_t jVar = 0; jVar < nEqn; ++jVar) { + const Double coeff = Y_face * c(jVar); + res.jac_ii(iVar, jVar) -= coeff * proj_on_w_i; + if (!opt.oneSided) { + res.jac_ij(iVar, jVar) += coeff * proj_on_w_j; + res.jac_ji(iVar, jVar) += coeff * proj_on_w_i; + res.jac_jj(iVar, jVar) -= coeff * proj_on_w_j; + } + } + } + } + } + /*! * \brief Diffusion coefficients, an i/j average of (rho * mass diffusivity) per species, plus a * turbulent (mu_t/Sc_t) contribution shared by every species, when a turbulence model is @@ -95,6 +148,7 @@ class CScalarFluxSpeciesBase : public CUpwScalarBaseGetChemical_MechanismFile()), Phase_Name(config->GetPhase_Name()), Combustion(config->GetCombustion()), - Chemistry_Min_Temperature(config->GetCantera_DC_Min_Temp()) { + Chemistry_Min_Temperature(config->GetCantera_DC_Min_Temp()), + Correction_Velocity(config->GetCantera_Correction_Velocity()) { try { sol = std::shared_ptr(newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model)); const auto& thermo = *sol->thermo(); @@ -116,8 +117,9 @@ void CFluidCantera::ComputeChemicalSourceTerm() { for (int iVar = 0; iVar < n_species_mixture; iVar++) { const size_t k = speciesIndices[iVar]; chemicalSourceTerm[iVar] = molarMasses[k] * netProductionRates[k]; - /*--- The destruction rate is taken proportional to the mass fraction of the species. ---*/ - chemicalSourceJacobian[iVar] = -molarMasses[k] * destructionRates[k] / std::max(massFractions[k], 1e-10); + /*--- The destruction rate is taken proportional to the mass fraction; the derivative is w.r.t. rho*Y. ---*/ + chemicalSourceJacobian[iVar] = + -molarMasses[k] * destructionRates[k] / (Density * std::max(massFractions[k], 1e-10)); Heat_Release -= enthalpyFormation[iVar] * chemicalSourceTerm[iVar]; } } @@ -127,10 +129,12 @@ void CFluidCantera::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) const sol->thermo()->getEnthalpy_RT_ref(enthalpiesSpecies.data()); const su2double RT = GasConstant * Temperature; const size_t last = speciesIndices[n_species_mixture - 1]; - const su2double h_last = RT * enthalpiesSpecies[last] / molarMasses[last]; + /*--- With the correction velocity every species enthalpy is taken relative to the mixture enthalpy. ---*/ + const su2double h_ref = Correction_Velocity ? Enthalpy : su2double(0.0); + const su2double h_last = RT * enthalpiesSpecies[last] / molarMasses[last] - h_ref; for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { const size_t k = speciesIndices[iVar]; - const su2double h_k = RT * enthalpiesSpecies[k] / molarMasses[k]; + const su2double h_k = RT * enthalpiesSpecies[k] / molarMasses[k] - h_ref; enthalpy_diffusions[iVar] = Density * (h_k * massDiffusivity[k] - h_last * massDiffusivity[last]) + Mu_Turb * (h_k - h_last) / Schmidt_Turb_Number; } @@ -140,10 +144,11 @@ void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusio UpdateDiffusivity(); sol->thermo()->getCp_R_ref(specificHeatSpecies.data()); const size_t last = speciesIndices[n_species_mixture - 1]; - const su2double cp_last = GasConstant * specificHeatSpecies[last] / molarMasses[last]; + const su2double cp_ref = Correction_Velocity ? Cp : su2double(0.0); + const su2double cp_last = GasConstant * specificHeatSpecies[last] / molarMasses[last] - cp_ref; for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { const size_t k = speciesIndices[iVar]; - const su2double cp_k = GasConstant * specificHeatSpecies[k] / molarMasses[k]; + const su2double cp_k = GasConstant * specificHeatSpecies[k] / molarMasses[k] - cp_ref; grad_enthalpy_diffusions[iVar] = Density * (cp_k * massDiffusivity[k] - cp_last * massDiffusivity[last]) + Mu_Turb * (cp_k - cp_last) / Schmidt_Turb_Number; } diff --git a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp index 9ef337f99645..6a7917392cec 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp @@ -161,7 +161,7 @@ TEST_CASE("Fluid_Cantera_SourceJacobian", "[Reacting_flow]") { fluid.SetTDState_T(temperature, scalar); fluid.ComputeChemicalSourceTerm(); const su2double slope_CH4 = (fluid.GetChemicalSourceTerm(2) - source_CH4) / delta; - CHECK(fluid.GetChemicalSourceJacobian(2) == Approx(slope_CH4).epsilon(0.1)); + CHECK(fluid.GetChemicalSourceJacobian(2) * fluid.GetDensity() == Approx(slope_CH4).epsilon(0.1)); CHECK(source_O2 < 0.0); /*--- Below CANTERA_DC_MIN_TEMP (500 K by default) the chemistry is skipped. ---*/ diff --git a/config_template.cfg b/config_template.cfg index 88533d33c689..64e4f9f4cc78 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -465,7 +465,7 @@ SEMI_SPAN= 0.0 % ---- NONEQUILIBRIUM GAS, IDEAL GAS, POLYTROPIC, VAN DER WAALS AND PENG ROBINSON CONSTANTS, CoolProp library -------% % % Fluid model (STANDARD_AIR, IDEAL_GAS, VW_GAS, PR_GAS, -% CONSTANT_DENSITY, INC_IDEAL_GAS, INC_IDEAL_GAS_POLY, MUTATIONPP, SU2_NONEQ, FLUID_MIXTURE, COOLPROP, FLUID_FLAMELET, DATADRIVEN_FLUID) +% CONSTANT_DENSITY, INC_IDEAL_GAS, INC_IDEAL_GAS_POLY, MUTATIONPP, SU2_NONEQ, FLUID_MIXTURE, COOLPROP, FLUID_FLAMELET, DATADRIVEN_FLUID, FLUID_CANTERA) FLUID_MODEL= STANDARD_AIR % To find all available fluid name for CoolProp library, clikc the following link: % http://www.coolprop.org/fluid_properties/PurePseudoPure.html#list-of-fluids @@ -552,7 +552,7 @@ INLET_GAS_COMPOSITION = (0.77, 0.23, 0.0, 0.0, 0.0) % --------------------------- VISCOSITY MODEL ---------------------------------% % -% Viscosity model (SUTHERLAND, CONSTANT_VISCOSITY, POLYNOMIAL_VISCOSITY, FLAMELET). +% Viscosity model (SUTHERLAND, CONSTANT_VISCOSITY, POLYNOMIAL_VISCOSITY, FLAMELET, CANTERA). VISCOSITY_MODEL= SUTHERLAND % % Molecular Viscosity that would be constant (1.716E-5 by default) @@ -574,7 +574,7 @@ MU_POLYCOEFFS= (0.0, 0.0, 0.0, 0.0, 0.0) % --------------------------- THERMAL CONDUCTIVITY MODEL ----------------------% % % Laminar Conductivity model (CONSTANT_CONDUCTIVITY, CONSTANT_PRANDTL, -% POLYNOMIAL_CONDUCTIVITY, FLAMELET). +% POLYNOMIAL_CONDUCTIVITY, FLAMELET, CANTERA). CONDUCTIVITY_MODEL= CONSTANT_PRANDTL % % Molecular Thermal Conductivity that would be constant (0.0257 by default) @@ -930,7 +930,7 @@ KIND_SCALAR_MODEL= NONE % mixing model for species transport (DAVIDSON, WILKE) MIXING_VISCOSITY_MODEL= DAVIDSON % -% Mass diffusivity model (CONSTANT_DIFFUSIVITY, CONSTANT_SCHMIDT, UNITY_LEWIS, CONSTANT_LEWIS, FLAMELET) +% Mass diffusivity model (CONSTANT_DIFFUSIVITY, CONSTANT_SCHMIDT, UNITY_LEWIS, CONSTANT_LEWIS, FLAMELET, CANTERA) DIFFUSIVITY_MODEL= CONSTANT_DIFFUSIVITY % % Mass diffusivity if DIFFUSIVITY_MODEL= CONSTANT_DIFFUSIVITY is chosen. D_air ~= 0.001 @@ -980,6 +980,44 @@ SPECIES_CLIPPING_MAX= 1.0 % Minimum values for scalar clipping SPECIES_CLIPPING_MIN= 0.0 +% --------------------- DETAILED CHEMISTRY WITH CANTERA -----------------------% +% Detailed chemistry with the Cantera library, for INC_NAVIER_STOKES and INC_RANS only. +% Requires FLUID_MODEL= FLUID_CANTERA, VISCOSITY_MODEL= CANTERA, CONDUCTIVITY_MODEL= CANTERA, +% DIFFUSIVITY_MODEL= CANTERA, KIND_SCALAR_MODEL= SPECIES_TRANSPORT, INC_DENSITY_MODEL= VARIABLE +% and INC_NONDIM= DIMENSIONAL, and SU2 built with -Denable-cantera=true. +% +% Chemical mechanism file (YAML), searched in the working directory and in CANTERA_DATA. +CHEMICAL_MECHANISM_FILE= h2o2.yaml +% +% Name of the phase in the mechanism file. +PHASE_NAME= ohmech +% +% Cantera transport model (mixture-averaged, unity-Lewis-number). Mixture-averaged gives a +% mass diffusivity for each species, unity-Lewis-number gives the same one for all of them. +TRANSPORT_MODEL= mixture-averaged +% +% Names of the species in the mechanism, in the order of SPECIES_INIT. The last name is the +% remainder, Y_N = 1 - sum(Y_k), so there is one name more than the number of SPECIES_INIT +% entries. At most MAX_TRANSPORTED_SPECIES (see option_structure.hpp) species are transported. +GAS_COMPOSITION_NAMES= H2, O2, N2 +% +% Add the chemical source terms to the species equations (NO, YES). +% Requires FLAME_INIT_METHOD= SPARK, with SPARK_INIT defining the spark region and duration. +COMBUSTION= NO +% +% Temperature (K) imposed inside the spark region while the spark is active. +SPARK_TEMPERATURE= 1000.0 +% +% Add the diagonal chemical sink Jacobian to the implicit species equations (NO, YES). +CHEMICAL_SOURCE_JACOBIAN= YES +% +% Temperature (K) below which the chemical source terms are set to zero. 0 disables it. +CANTERA_DC_MIN_TEMP= 500.0 +% +% Correct the species diffusion fluxes so that they sum to zero (correction velocity) +% in the species and in the energy equation (NO, YES). +CANTERA_CORRECTION_VELOCITY= YES + % --------------------- FLAMELET MODEL -----------------------------% % The flamelet model uses the prompts INTERPOLATION_METHOD and FILENAMES_INTERPOLATOR % for definition of the flamelet manifold. Either LUT or MLP can be used as options. @@ -1025,6 +1063,7 @@ CONTROLLING_VARIABLE_SOURCE_NAMES= (ProdRateTot_PV, NULL) % of solver iterations. This artificial spark can be applied after a certain number of iterations has passed, allowing for % the flow to evolve before igniting the mixture. % NONE : no artificial solution ignition. +% SPARK is also the ignition of COMBUSTION= YES (Cantera detailed chemistry), see SPARK_TEMPERATURE. % By default, this option is set to NONE FLAME_INIT_METHOD= FLAME_FRONT From 8486ef2b7a1ac83ac813936a5b82228c83568438 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 5 Oct 2026 18:16:20 +0200 Subject: [PATCH 169/173] unintialise 2D continers to prevent slowdown when using larger number of species --- Common/include/containers/C2DContainer.hpp | 13 +++++++++++++ SU2_CFD/include/numerics/util.hpp | 13 ++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Common/include/containers/C2DContainer.hpp b/Common/include/containers/C2DContainer.hpp index 380e43cfba7b..149258dc038e 100644 --- a/Common/include/containers/C2DContainer.hpp +++ b/Common/include/containers/C2DContainer.hpp @@ -349,6 +349,11 @@ class AccessorImpl Date: Mon, 5 Oct 2026 19:11:25 +0200 Subject: [PATCH 170/173] add testcases --- .github/workflows/regression.yml | 6 +- .../1step_methane_air/1S_CH4_MP1.yaml | 949 ++++++++++++++++++ .../2d_slit_burner_fluid.cfg | 180 ++++ .../h2o2_hydrogen_air/2d_slit_burner_h2.cfg | 181 ++++ .../combustion/h2o2_hydrogen_air/h2o2.yaml | 323 ++++++ TestCases/parallel_regression.py | 24 +- 6 files changed, 1659 insertions(+), 4 deletions(-) create mode 100644 TestCases/combustion/1step_methane_air/1S_CH4_MP1.yaml create mode 100644 TestCases/combustion/1step_methane_air/2d_slit_burner_fluid.cfg create mode 100644 TestCases/combustion/h2o2_hydrogen_air/2d_slit_burner_h2.cfg create mode 100644 TestCases/combustion/h2o2_hydrogen_air/h2o2.yaml diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index e1985a4911f2..df30c11f83bc 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -282,7 +282,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2:260405-0054 with: # -t -c - args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} -a "--tapetests" + args: -b ${{github.ref}} -t develop -c feature_cantera -s ${{matrix.testscript}} -a "--tapetests" - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2:260405-0054 with: @@ -330,7 +330,7 @@ jobs: PMIX_MCA_gds: hash with: # -t -c - args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} -a "--tsan" + args: -b ${{github.ref}} -t develop -c feature_cantera -s ${{matrix.testscript}} -a "--tsan" - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2-tsan:260405-0054 with: @@ -375,7 +375,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2-asan:260405-0054 with: # -t -c - args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} -a "--asan" + args: -b ${{github.ref}} -t develop -c feature_cantera -s ${{matrix.testscript}} -a "--asan" - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2-asan:260405-0054 with: diff --git a/TestCases/combustion/1step_methane_air/1S_CH4_MP1.yaml b/TestCases/combustion/1step_methane_air/1S_CH4_MP1.yaml new file mode 100644 index 000000000000..851733695e2a --- /dev/null +++ b/TestCases/combustion/1step_methane_air/1S_CH4_MP1.yaml @@ -0,0 +1,949 @@ +description: |- + CH4_MP1 mechanisme: CH4 + 2 O2 => CO2 + 2 H2O + + + Transport data from file ../transport/gri30_tran.dat. + +generator: cti2yaml +cantera-version: 3.0.1 +date: Sat, 25 Jan 2025 11:22:57 +0100 +input-files: [1S_CH4_MP1.cti] + +units: {length: cm, quantity: mol, activation-energy: cal/mol} + +phases: +- name: CH4_MP1 + thermo: ideal-gas + elements: [O, H, C, N] + species: [O2, H2O, CH4, CO2, N2] + kinetics: gas + reactions: all + state: + T: 300.0 + P: 1.01325e+05 +- name: CH4_MP1_mix + thermo: ideal-gas + elements: [O, H, C, N] + species: [O2, H2O, CH4, CO2, N2] + kinetics: gas + reactions: all + transport: mixture-averaged + state: + T: 300.0 + P: 1.01325e+05 +- name: CH4_MP1_multi + thermo: ideal-gas + elements: [O, H, C, N] + species: [O2, H2O, CH4, CO2, N2] + kinetics: gas + reactions: all + transport: multicomponent + state: + T: 300.0 + P: 1.01325e+05 + +species: +- name: H2 + composition: {H: 2} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [2.34433112, 7.98052075e-03, -1.9478151e-05, 2.01572094e-08, -7.37611761e-12, + -917.935173, 0.683010238] + - [3.3372792, -4.94024731e-05, 4.99456778e-07, -1.79566394e-10, 2.00255376e-14, + -950.158922, -3.20502331] + transport: + model: gas + geometry: linear + diameter: 2.92 + well-depth: 38.0 + polarizability: 0.79 + rotational-relaxation: 280.0 + note: TPIS78 +- name: H + composition: {H: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [2.5, 7.05332819e-13, -1.99591964e-15, 2.30081632e-18, -9.27732332e-22, + 2.54736599e+04, -0.446682853] + - [2.50000001, -2.30842973e-11, 1.61561948e-14, -4.73515235e-18, 4.98197357e-22, + 2.54736599e+04, -0.446682914] + transport: + model: gas + geometry: atom + diameter: 2.05 + well-depth: 145.0 + note: L 7/88 +- name: O + composition: {O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [3.1682671, -3.27931884e-03, 6.64306396e-06, -6.12806624e-09, 2.11265971e-12, + 2.91222592e+04, 2.05193346] + - [2.56942078, -8.59741137e-05, 4.19484589e-08, -1.00177799e-11, 1.22833691e-15, + 2.92175791e+04, 4.78433864] + transport: + model: gas + geometry: atom + diameter: 2.75 + well-depth: 80.0 + note: L 1/90 +- name: O2 + composition: {O: 2} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [3.78245636, -2.99673416e-03, 9.84730201e-06, -9.68129509e-09, 3.24372837e-12, + -1063.94356, 3.65767573] + - [3.28253784, 1.48308754e-03, -7.57966669e-07, 2.09470555e-10, -2.16717794e-14, + -1088.45772, 5.45323129] + transport: + model: gas + geometry: linear + diameter: 3.46 + well-depth: 107.4 + polarizability: 1.6 + rotational-relaxation: 3.8 + note: TPIS89 +- name: OH + composition: {O: 1, H: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [3.99201543, -2.40131752e-03, 4.61793841e-06, -3.88113333e-09, 1.3641147e-12, + 3615.08056, -0.103925458] + - [3.09288767, 5.48429716e-04, 1.26505228e-07, -8.79461556e-11, 1.17412376e-14, + 3858.657, 4.4766961] + transport: + model: gas + geometry: linear + diameter: 2.75 + well-depth: 80.0 + note: RUS 78 +- name: H2O + composition: {H: 2, O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [4.19864056, -2.0364341e-03, 6.52040211e-06, -5.48797062e-09, 1.77197817e-12, + -3.02937267e+04, -0.849032208] + - [3.03399249, 2.17691804e-03, -1.64072518e-07, -9.7041987e-11, 1.68200992e-14, + -3.00042971e+04, 4.9667701] + transport: + model: gas + geometry: nonlinear + diameter: 2.6 + well-depth: 572.4 + dipole: 1.84 + rotational-relaxation: 4.0 + note: L 8/89 +- name: HO2 + composition: {H: 1, O: 2} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [4.30179801, -4.74912051e-03, 2.11582891e-05, -2.42763894e-08, 9.29225124e-12, + 294.80804, 3.71666245] + - [4.0172109, 2.23982013e-03, -6.3365815e-07, 1.1424637e-10, -1.07908535e-14, + 111.856713, 3.78510215] + transport: + model: gas + geometry: nonlinear + diameter: 3.46 + well-depth: 107.4 + rotational-relaxation: 1.0 + note: L 5/89 +- name: H2O2 + composition: {H: 2, O: 2} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [4.27611269, -5.42822417e-04, 1.67335701e-05, -2.15770813e-08, 8.62454363e-12, + -1.77025821e+04, 3.43505074] + - [4.16500285, 4.90831694e-03, -1.90139225e-06, 3.71185986e-10, -2.87908305e-14, + -1.78617877e+04, 2.91615662] + transport: + model: gas + geometry: nonlinear + diameter: 3.46 + well-depth: 107.4 + rotational-relaxation: 3.8 + note: L 7/88 +- name: C + composition: {C: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [2.55423955, -3.21537724e-04, 7.33792245e-07, -7.32234889e-10, 2.66521446e-13, + 8.54438832e+04, 4.53130848] + - [2.49266888, 4.79889284e-05, -7.2433502e-08, 3.74291029e-11, -4.87277893e-15, + 8.54512953e+04, 4.80150373] + transport: + model: gas + geometry: atom + diameter: 3.3 + well-depth: 71.4 + note: L11/88 +- name: CH + composition: {C: 1, H: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [3.48981665, 3.23835541e-04, -1.68899065e-06, 3.16217327e-09, -1.40609067e-12, + 7.07972934e+04, 2.08401108] + - [2.87846473, 9.70913681e-04, 1.44445655e-07, -1.30687849e-10, 1.76079383e-14, + 7.10124364e+04, 5.48497999] + transport: + model: gas + geometry: linear + diameter: 2.75 + well-depth: 80.0 + note: TPIS79 +- name: CH2 + composition: {C: 1, H: 2} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [3.76267867, 9.68872143e-04, 2.79489841e-06, -3.85091153e-09, 1.68741719e-12, + 4.60040401e+04, 1.56253185] + - [2.87410113, 3.65639292e-03, -1.40894597e-06, 2.60179549e-10, -1.87727567e-14, + 4.6263604e+04, 6.17119324] + transport: + model: gas + geometry: linear + diameter: 3.8 + well-depth: 144.0 + note: L S/93 +- name: CH2(S) + composition: {C: 1, H: 2} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [4.19860411, -2.36661419e-03, 8.2329622e-06, -6.68815981e-09, 1.94314737e-12, + 5.04968163e+04, -0.769118967] + - [2.29203842, 4.65588637e-03, -2.01191947e-06, 4.17906e-10, -3.39716365e-14, + 5.09259997e+04, 8.62650169] + transport: + model: gas + geometry: linear + diameter: 3.8 + well-depth: 144.0 + note: L S/93 +- name: CH3 + composition: {C: 1, H: 3} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [3.6735904, 2.01095175e-03, 5.73021856e-06, -6.87117425e-09, 2.54385734e-12, + 1.64449988e+04, 1.60456433] + - [2.28571772, 7.23990037e-03, -2.98714348e-06, 5.95684644e-10, -4.67154394e-14, + 1.67755843e+04, 8.48007179] + transport: + model: gas + geometry: linear + diameter: 3.8 + well-depth: 144.0 + note: L11/89 +- name: CH4 + composition: {C: 1, H: 4} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [5.14987613, -0.0136709788, 4.91800599e-05, -4.84743026e-08, 1.66693956e-11, + -1.02466476e+04, -4.64130376] + - [0.074851495, 0.0133909467, -5.73285809e-06, 1.22292535e-09, -1.0181523e-13, + -9468.34459, 18.437318] + transport: + model: gas + geometry: nonlinear + diameter: 3.75 + well-depth: 141.4 + polarizability: 2.6 + rotational-relaxation: 13.0 + note: L 8/88 +- name: CO + composition: {C: 1, O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [3.57953347, -6.1035368e-04, 1.01681433e-06, 9.07005884e-10, -9.04424499e-13, + -1.4344086e+04, 3.50840928] + - [2.71518561, 2.06252743e-03, -9.98825771e-07, 2.30053008e-10, -2.03647716e-14, + -1.41518724e+04, 7.81868772] + transport: + model: gas + geometry: linear + diameter: 3.65 + well-depth: 98.1 + polarizability: 1.95 + rotational-relaxation: 1.8 + note: TPIS79 +- name: CO2 + composition: {C: 1, O: 2} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [2.35677352, 8.98459677e-03, -7.12356269e-06, 2.45919022e-09, -1.43699548e-13, + -4.83719697e+04, 9.90105222] + - [3.85746029, 4.41437026e-03, -2.21481404e-06, 5.23490188e-10, -4.72084164e-14, + -4.8759166e+04, 2.27163806] + transport: + model: gas + geometry: linear + diameter: 3.76 + well-depth: 244.0 + polarizability: 2.65 + rotational-relaxation: 2.1 + note: L 7/88 +- name: HCO + composition: {H: 1, C: 1, O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [4.22118584, -3.24392532e-03, 1.37799446e-05, -1.33144093e-08, 4.33768865e-12, + 3839.56496, 3.39437243] + - [2.77217438, 4.95695526e-03, -2.48445613e-06, 5.89161778e-10, -5.33508711e-14, + 4011.91815, 9.79834492] + transport: + model: gas + geometry: nonlinear + diameter: 3.59 + well-depth: 498.0 + note: L12/89 +- name: CH2O + composition: {H: 2, C: 1, O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [4.79372315, -9.90833369e-03, 3.73220008e-05, -3.79285261e-08, 1.31772652e-11, + -1.43089567e+04, 0.6028129] + - [1.76069008, 9.20000082e-03, -4.42258813e-06, 1.00641212e-09, -8.8385564e-14, + -1.39958323e+04, 13.656323] + transport: + model: gas + geometry: nonlinear + diameter: 3.59 + well-depth: 498.0 + rotational-relaxation: 2.0 + note: L 8/88 +- name: CH2OH + composition: {C: 1, H: 3, O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [3.86388918, 5.59672304e-03, 5.93271791e-06, -1.04532012e-08, 4.36967278e-12, + -3193.91367, 5.47302243] + - [3.69266569, 8.64576797e-03, -3.7510112e-06, 7.87234636e-10, -6.48554201e-14, + -3242.50627, 5.81043215] + transport: + model: gas + geometry: nonlinear + diameter: 3.69 + well-depth: 417.0 + dipole: 1.7 + rotational-relaxation: 2.0 + note: GUNL93 +- name: CH3O + composition: {C: 1, H: 3, O: 1} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 3000.0] + data: + - [2.106204, 7.216595e-03, 5.338472e-06, -7.377636e-09, 2.07561e-12, + 978.6011, 13.152177] + - [3.770799, 7.871497e-03, -2.656384e-06, 3.944431e-10, -2.112616e-14, + 127.83252, 2.929575] + transport: + model: gas + geometry: nonlinear + diameter: 3.69 + well-depth: 417.0 + dipole: 1.7 + rotational-relaxation: 2.0 + note: '121686' +- name: CH3OH + composition: {C: 1, H: 4, O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [5.71539582, -0.0152309129, 6.52441155e-05, -7.10806889e-08, 2.61352698e-11, + -2.56427656e+04, -1.50409823] + - [1.78970791, 0.0140938292, -6.36500835e-06, 1.38171085e-09, -1.1706022e-13, + -2.53748747e+04, 14.5023623] + transport: + model: gas + geometry: nonlinear + diameter: 3.63 + well-depth: 481.8 + rotational-relaxation: 1.0 + note: L 8/88 +- name: C2H + composition: {C: 2, H: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [2.88965733, 0.0134099611, -2.84769501e-05, 2.94791045e-08, -1.09331511e-11, + 6.68393932e+04, 6.22296438] + - [3.16780652, 4.75221902e-03, -1.83787077e-06, 3.04190252e-10, -1.7723277e-14, + 6.7121065e+04, 6.63589475] + transport: + model: gas + geometry: linear + diameter: 4.1 + well-depth: 209.0 + rotational-relaxation: 2.5 + note: L 1/91 +- name: C2H2 + composition: {C: 2, H: 2} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [0.808681094, 0.0233615629, -3.55171815e-05, 2.80152437e-08, -8.50072974e-12, + 2.64289807e+04, 13.9397051] + - [4.14756964, 5.96166664e-03, -2.37294852e-06, 4.67412171e-10, -3.61235213e-14, + 2.59359992e+04, -1.23028121] + transport: + model: gas + geometry: linear + diameter: 4.1 + well-depth: 209.0 + rotational-relaxation: 2.5 + note: L 1/91 +- name: C2H3 + composition: {C: 2, H: 3} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [3.21246645, 1.51479162e-03, 2.59209412e-05, -3.57657847e-08, 1.47150873e-11, + 3.48598468e+04, 8.51054025] + - [3.016724, 0.0103302292, -4.68082349e-06, 1.01763288e-09, -8.62607041e-14, + 3.46128739e+04, 7.78732378] + transport: + model: gas + geometry: nonlinear + diameter: 4.1 + well-depth: 209.0 + rotational-relaxation: 1.0 + note: L 2/92 +- name: C2H4 + composition: {C: 2, H: 4} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [3.95920148, -7.57052247e-03, 5.70990292e-05, -6.91588753e-08, 2.69884373e-11, + 5089.77593, 4.09733096] + - [2.03611116, 0.0146454151, -6.71077915e-06, 1.47222923e-09, -1.25706061e-13, + 4939.88614, 10.3053693] + transport: + model: gas + geometry: nonlinear + diameter: 3.97 + well-depth: 280.8 + rotational-relaxation: 1.5 + note: L 1/91 +- name: C2H5 + composition: {C: 2, H: 5} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [4.30646568, -4.18658892e-03, 4.97142807e-05, -5.99126606e-08, 2.30509004e-11, + 1.28416265e+04, 4.70720924] + - [1.95465642, 0.0173972722, -7.98206668e-06, 1.75217689e-09, -1.49641576e-13, + 1.285752e+04, 13.4624343] + transport: + model: gas + geometry: nonlinear + diameter: 4.3 + well-depth: 252.3 + rotational-relaxation: 1.5 + note: L12/92 +- name: C2H6 + composition: {C: 2, H: 6} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [4.29142492, -5.5015427e-03, 5.99438288e-05, -7.08466285e-08, 2.68685771e-11, + -1.15222055e+04, 2.66682316] + - [1.0718815, 0.0216852677, -1.00256067e-05, 2.21412001e-09, -1.9000289e-13, + -1.14263932e+04, 15.1156107] + transport: + model: gas + geometry: nonlinear + diameter: 4.3 + well-depth: 252.3 + rotational-relaxation: 1.5 + note: L 8/88 +- name: HCCO + composition: {H: 1, C: 2, O: 1} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 4000.0] + data: + - [2.2517214, 0.017655021, -2.3729101e-05, 1.7275759e-08, -5.0664811e-12, + 2.0059449e+04, 12.490417] + - [5.6282058, 4.0853401e-03, -1.5934547e-06, 2.8626052e-10, -1.9407832e-14, + 1.9327215e+04, -3.9302595] + transport: + model: gas + geometry: nonlinear + diameter: 2.5 + well-depth: 150.0 + rotational-relaxation: 1.0 + note: SRIC91 +- name: CH2CO + composition: {C: 2, H: 2, O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [2.1358363, 0.0181188721, -1.73947474e-05, 9.34397568e-09, -2.01457615e-12, + -7042.91804, 12.215648] + - [4.51129732, 9.00359745e-03, -4.16939635e-06, 9.23345882e-10, -7.94838201e-14, + -7551.05311, 0.632247205] + transport: + model: gas + geometry: nonlinear + diameter: 3.97 + well-depth: 436.0 + rotational-relaxation: 2.0 + note: L 5/90 +- name: HCCOH + composition: {C: 2, O: 1, H: 2} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [1.2423733, 0.031072201, -5.0866864e-05, 4.3137131e-08, -1.4014594e-11, + 8031.6143, 13.874319] + - [5.9238291, 6.79236e-03, -2.5658564e-06, 4.4987841e-10, -2.9940101e-14, + 7264.626, -7.6017742] + transport: + model: gas + geometry: nonlinear + diameter: 3.97 + well-depth: 436.0 + rotational-relaxation: 2.0 + note: SRI91 +- name: N + composition: {N: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 6000.0] + data: + - [2.5, 0.0, 0.0, 0.0, 0.0, 5.6104637e+04, 4.1939087] + - [2.4159429, 1.7489065e-04, -1.1902369e-07, 3.0226245e-11, -2.0360982e-15, + 5.6133773e+04, 4.6496096] + transport: + model: gas + geometry: atom + diameter: 3.3 + well-depth: 71.4 + note: L 6/88 +- name: NH + composition: {N: 1, H: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 6000.0] + data: + - [3.4929085, 3.1179198e-04, -1.4890484e-06, 2.4816442e-09, -1.0356967e-12, + 4.1880629e+04, 1.8483278] + - [2.7836928, 1.329843e-03, -4.2478047e-07, 7.8348501e-11, -5.504447e-15, + 4.2120848e+04, 5.7407799] + transport: + model: gas + geometry: linear + diameter: 2.65 + well-depth: 80.0 + rotational-relaxation: 4.0 + note: And94 +- name: NH2 + composition: {N: 1, H: 2} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 6000.0] + data: + - [4.2040029, -2.1061385e-03, 7.1068348e-06, -5.6115197e-09, 1.6440717e-12, + 2.188591e+04, -0.14184248] + - [2.8347421, 3.2073082e-03, -9.3390804e-07, 1.3702953e-10, -7.9206144e-15, + 2.2171957e+04, 6.5204163] + transport: + model: gas + geometry: nonlinear + diameter: 2.65 + well-depth: 80.0 + polarizability: 2.26 + rotational-relaxation: 4.0 + note: And89 +- name: NH3 + composition: {N: 1, H: 3} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 6000.0] + data: + - [4.2860274, -4.660523e-03, 2.1718513e-05, -2.2808887e-08, 8.2638046e-12, + -6741.7285, -0.62537277] + - [2.6344521, 5.666256e-03, -1.7278676e-06, 2.3867161e-10, -1.2578786e-14, + -6544.6958, 6.5662928] + transport: + model: gas + geometry: nonlinear + diameter: 2.92 + well-depth: 481.0 + dipole: 1.47 + rotational-relaxation: 10.0 + note: J 6/77 +- name: NNH + composition: {N: 2, H: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 6000.0] + data: + - [4.3446927, -4.8497072e-03, 2.0059459e-05, -2.1726464e-08, 7.9469539e-12, + 2.8791973e+04, 2.977941] + - [3.7667544, 2.8915082e-03, -1.041662e-06, 1.6842594e-10, -1.0091896e-14, + 2.8650697e+04, 4.4705067] + transport: + model: gas + geometry: nonlinear + diameter: 3.8 + well-depth: 71.4 + rotational-relaxation: 1.0 + note: T07/93 +- name: NO + composition: {N: 1, O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 6000.0] + data: + - [4.2184763, -4.638976e-03, 1.1041022e-05, -9.3361354e-09, 2.803577e-12, + 9844.623, 2.2808464] + - [3.2606056, 1.1911043e-03, -4.2917048e-07, 6.9457669e-11, -4.0336099e-15, + 9920.9746, 6.3693027] + transport: + model: gas + geometry: linear + diameter: 3.62 + well-depth: 97.53 + polarizability: 1.76 + rotational-relaxation: 4.0 + note: RUS 78 +- name: NO2 + composition: {N: 1, O: 2} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 6000.0] + data: + - [3.9440312, -1.585429e-03, 1.6657812e-05, -2.0475426e-08, 7.8350564e-12, + 2896.6179, 6.3119917] + - [4.8847542, 2.1723956e-03, -8.2806906e-07, 1.574751e-10, -1.0510895e-14, + 2316.4983, -0.11741695] + transport: + model: gas + geometry: nonlinear + diameter: 3.5 + well-depth: 200.0 + rotational-relaxation: 1.0 + note: L 7/88 +- name: N2O + composition: {N: 2, O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 6000.0] + data: + - [2.2571502, 0.011304728, -1.3671319e-05, 9.6819806e-09, -2.9307182e-12, + 8741.7744, 10.757992] + - [4.8230729, 2.6270251e-03, -9.5850874e-07, 1.6000712e-10, -9.7752303e-15, + 8073.4048, -2.2017207] + transport: + model: gas + geometry: linear + diameter: 3.83 + well-depth: 232.4 + rotational-relaxation: 1.0 + note: L 7/88 +- name: HNO + composition: {H: 1, N: 1, O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 6000.0] + data: + - [4.5334916, -5.6696171e-03, 1.8473207e-05, -1.7137094e-08, 5.5454573e-12, + 1.1548297e+04, 1.7498417] + - [2.9792509, 3.4944059e-03, -7.8549778e-07, 5.7479594e-11, -1.9335916e-16, + 1.1750582e+04, 8.6063728] + transport: + model: gas + geometry: nonlinear + diameter: 3.49 + well-depth: 116.7 + rotational-relaxation: 1.0 + note: And93 +- name: CN + composition: {C: 1, N: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 6000.0] + data: + - [3.6129351, -9.5551327e-04, 2.1442977e-06, -3.1516323e-10, -4.6430356e-13, + 5.170834e+04, 3.9804995] + - [3.7459805, 4.3450775e-05, 2.9705984e-07, -6.8651806e-11, 4.4134173e-15, + 5.1536188e+04, 2.7867601] + transport: + model: gas + geometry: linear + diameter: 3.86 + well-depth: 75.0 + rotational-relaxation: 1.0 + note: HBH92 +- name: HCN + composition: {H: 1, C: 1, N: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 6000.0] + data: + - [2.2589886, 0.01005117, -1.3351763e-05, 1.0092349e-08, -3.0089028e-12, + 1.4712633e+04, 8.9164419] + - [3.8022392, 3.1464228e-03, -1.0632185e-06, 1.6619757e-10, -9.799757e-15, + 1.4407292e+04, 1.5754601] + transport: + model: gas + geometry: linear + diameter: 3.63 + well-depth: 569.0 + rotational-relaxation: 1.0 + note: GRI/98 +- name: H2CN + composition: {H: 2, C: 1, N: 1} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 4000.0] + data: + - [2.851661, 5.6952331e-03, 1.07114e-06, -1.622612e-09, -2.3511081e-13, + 2.863782e+04, 8.9927511] + - [5.209703, 2.9692911e-03, -2.8555891e-07, -1.63555e-10, 3.0432589e-14, + 2.7677109e+04, -4.444478] + transport: + model: gas + geometry: linear + diameter: 3.63 + well-depth: 569.0 + rotational-relaxation: 1.0 + note: '41687' +- name: HCNN + composition: {C: 1, N: 2, H: 1} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [2.5243194, 0.015960619, -1.8816354e-05, 1.212554e-08, -3.2357378e-12, + 5.4261984e+04, 11.67587] + - [5.8946362, 3.9895959e-03, -1.598238e-06, 2.9249395e-10, -2.0094686e-14, + 5.3452941e+04, -5.1030502] + transport: + model: gas + geometry: nonlinear + diameter: 2.5 + well-depth: 150.0 + rotational-relaxation: 1.0 + note: SRI/94 +- name: HCNO + composition: {H: 1, N: 1, C: 1, O: 1} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1382.0, 5000.0] + data: + - [2.64727989, 0.0127505342, -1.04794236e-05, 4.41432836e-09, -7.57521466e-13, + 1.92990252e+04, 10.7332972] + - [6.59860456, 3.02778626e-03, -1.07704346e-06, 1.71666528e-10, -1.01439391e-14, + 1.79661339e+04, -10.3306599] + transport: + model: gas + geometry: nonlinear + diameter: 3.83 + well-depth: 232.4 + rotational-relaxation: 1.0 + note: BDEA94 +- name: HOCN + composition: {H: 1, N: 1, C: 1, O: 1} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1368.0, 5000.0] + data: + - [3.78604952, 6.88667922e-03, -3.21487864e-06, 5.17195767e-10, 1.19360788e-14, + -2826.984, 5.63292162] + - [5.89784885, 3.16789393e-03, -1.11801064e-06, 1.77243144e-10, -1.04339177e-14, + -3706.53331, -6.18167825] + transport: + model: gas + geometry: nonlinear + diameter: 3.83 + well-depth: 232.4 + rotational-relaxation: 1.0 + note: BDEA94 +- name: HNCO + composition: {H: 1, N: 1, C: 1, O: 1} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1478.0, 5000.0] + data: + - [3.63096317, 7.30282357e-03, -2.28050003e-06, -6.61271298e-10, 3.62235752e-13, + -1.55873636e+04, 6.19457727] + - [6.22395134, 3.17864004e-03, -1.09378755e-06, 1.70735163e-10, -9.95021955e-15, + -1.66599344e+04, -8.38224741] + transport: + model: gas + geometry: nonlinear + diameter: 3.83 + well-depth: 232.4 + rotational-relaxation: 1.0 + note: BDEA94 +- name: NCO + composition: {N: 1, C: 1, O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 6000.0] + data: + - [2.8269308, 8.8051688e-03, -8.3866134e-06, 4.8016964e-09, -1.3313595e-12, + 1.4682477e+04, 9.5504646] + - [5.1521845, 2.3051761e-03, -8.8033153e-07, 1.4789098e-10, -9.0977996e-15, + 1.4004123e+04, -2.544266] + transport: + model: gas + geometry: linear + diameter: 3.83 + well-depth: 232.4 + rotational-relaxation: 1.0 + note: EA 93 +- name: N2 + composition: {N: 2} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [3.298677, 1.4082404e-03, -3.963222e-06, 5.641515e-09, -2.444854e-12, + -1020.8999, 3.950372] + - [2.92664, 1.4879768e-03, -5.68476e-07, 1.0097038e-10, -6.753351e-15, + -922.7977, 5.980528] + transport: + model: gas + geometry: linear + diameter: 3.62 + well-depth: 97.53 + polarizability: 1.76 + rotational-relaxation: 4.0 + note: '121286' +- name: AR + composition: {Ar: 1} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [2.5, 0.0, 0.0, 0.0, 0.0, -745.375, 4.366] + - [2.5, 0.0, 0.0, 0.0, 0.0, -745.375, 4.366] + transport: + model: gas + geometry: atom + diameter: 3.33 + well-depth: 136.5 + note: '120186' +- name: C3H7 + composition: {C: 3, H: 7} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [1.0515518, 0.02599198, 2.380054e-06, -1.9609569e-08, 9.373247e-12, + 1.0631863e+04, 21.122559] + - [7.7026987, 0.016044203, -5.283322e-06, 7.629859e-10, -3.9392284e-14, + 8298.4336, -15.48018] + transport: + model: gas + geometry: nonlinear + diameter: 4.98 + well-depth: 266.8 + rotational-relaxation: 1.0 + note: L 9/84 +- name: C3H8 + composition: {C: 3, H: 8} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [0.93355381, 0.026424579, 6.1059727e-06, -2.1977499e-08, 9.5149253e-12, + -1.395852e+04, 19.201691] + - [7.5341368, 0.018872239, -6.2718491e-06, 9.1475649e-10, -4.7838069e-14, + -1.6467516e+04, -17.892349] + transport: + model: gas + geometry: nonlinear + diameter: 4.98 + well-depth: 266.8 + rotational-relaxation: 1.0 + note: L 4/85 +- name: CH2CHO + composition: {O: 1, H: 3, C: 2} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [3.409062, 0.010738574, 1.891492e-06, -7.158583e-09, 2.867385e-12, + 1521.4766, 9.55829] + - [5.97567, 8.130591e-03, -2.743624e-06, 4.070304e-10, -2.176017e-14, + 490.3218, -5.045251] + transport: + model: gas + geometry: nonlinear + diameter: 3.97 + well-depth: 436.0 + rotational-relaxation: 2.0 + note: SAND86 +- name: CH3CHO + composition: {C: 2, H: 4, O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 6000.0] + data: + - [4.7294595, -3.1932858e-03, 4.7534921e-05, -5.7458611e-08, 2.1931112e-11, + -2.1572878e+04, 4.1030159] + - [5.4041108, 0.011723059, -4.2263137e-06, 6.8372451e-10, -4.0984863e-14, + -2.2593122e+04, -3.4807917] + transport: + model: gas + geometry: nonlinear + diameter: 3.97 + well-depth: 436.0 + rotational-relaxation: 2.0 + note: L 8/88 + +reactions: +- equation: ' CH4 + 2 O2 => CO2 + 2 H2O ' # Reaction 1 + rate-constant: {A: 1.1e+10, b: 0.0, Ea: 20000} + orders: {CH4: 1.0, O2: 0.5} diff --git a/TestCases/combustion/1step_methane_air/2d_slit_burner_fluid.cfg b/TestCases/combustion/1step_methane_air/2d_slit_burner_fluid.cfg new file mode 100644 index 000000000000..e31e7f3734b4 --- /dev/null +++ b/TestCases/combustion/1step_methane_air/2d_slit_burner_fluid.cfg @@ -0,0 +1,180 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Laminar premixed hydrogen 3D slit burner % +% Author: Cristopher Morales Ubal % +% Institution: Eindhoven University of Technology % +% Date: 2024/06/27 % +% File Version 8.0.0 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= INC_NAVIER_STOKES +KIND_TURB_MODEL= NONE +MATH_PROBLEM= DIRECT +RESTART_SOL = NO +WRT_ZONE_HIST= YES + +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +INC_DENSITY_MODEL= VARIABLE +INC_VELOCITY_INIT= (0.0, 0.2, 0.0) %0.565 +INC_ENERGY_EQUATION= YES +INC_TEMPERATURE_INIT= 300.0 +THERMODYNAMIC_PRESSURE= 101325.0 +INC_NONDIM= DIMENSIONAL + +% -------------------- FLUID MODEL --------------------------------------- % +% +FLUID_MODEL= FLUID_CANTERA +COMBUSTION = YES +VISCOSITY_MODEL= CANTERA +CONDUCTIVITY_MODEL= CANTERA +% +GAS_COMPOSITION_NAMES= O2, H2O, CH4, CO2, N2 +%H2, H, O, O2, OH, H2O, HO2, H2O2, AR, N2 + +CHEMICAL_MECHANISM_FILE= 1S_CH4_MP1.yaml %h2o2.yaml + +PHASE_NAME= CH4_MP1_mix +%ohmech +TRANSPORT_MODEL= unity-Lewis-number +%mixture-averaged % multicomponent % unity-Lewis-number +% +% -------------------- SCALAR TRANSPORT ---------------------------------------% +% +% Using an artificial spark to ignite the solution at some location and iteration +FLAME_INIT_METHOD= SPARK +% Spark parameters in order: +% x-location of spark center (m) +% y-location of spark center (m) +% z-location of spark center (m) +% Spark radius (m) +% Iteration at which the artificial spark starts +% Spark iteration duration +SPARK_INIT= (0.0, 0.002, 0.0, 1e-3, 100, 50) +% (0.0, 0.002, 0.0, 1e-3, 600, 300) +% Controlling variable source terms applied within the spark sphere for the spark +% duration. +SPARK_TEMPERATURE= 1200 +%1400 1200 %1500 +% equivalence ratio phi=0.8 +SPECIES_INIT= 0.222598, 0.0, 0.044642, 0.0 +SPECIES_CLIPPING=YES +SPECIES_CLIPPING_MIN= 0.0, 0.0, 0.0, 0.0 +SPECIES_CLIPPING_MAX= 1.0, 1.0, 1.0, 1.0 + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +% +MARKER_SYM= ( symmetry ) +MARKER_ISOTHERMAL = (solid_fluid, 300) +% +SPECIFIED_INLET_PROFILE= NO +INLET_FILENAME= inlet_venturi.dat +INC_INLET_TYPE= VELOCITY_INLET +MARKER_INLET= ( inlet, 300, 0.2, 0.0, 1.0, 0.0) +MARKER_INLET_SPECIES = (inlet, 0.222598, 0.0, 0.044642, 0.0) +% +% +INC_OUTLET_TYPE= PRESSURE_OUTLET +MARKER_OUTLET= ( outlet, 0.0 ) +% +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES +% +CFL_NUMBER= 1000 +CFL_ADAPT= YES +CFL_ADAPT_PARAM= ( 0.95, 1.01, 100, 10000, 0.1, 100) + +CFL_REDUCTION_SPECIES= 1.0 +% Run commented Iter for good results +ITER= 10000 +% +% +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-03 +LINEAR_SOLVER_ITER= 10 +% +% -------------------- FLOW AND SPECIES NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= FDS +MUSCL_FLOW= NO +SLOPE_LIMITER_FLOW = NONE +TIME_DISCRE_FLOW= EULER_IMPLICIT + +% -------------------------- MULTIGRID PARAMETERS -----------------------------% +% +MGLEVEL=3 +MGCYCLE= V_CYCLE +MG_STARTUP_ITER= 40 +MG_STARTUP_CONVERGENCE= -3 +MG_STARTUP_STAGNATION= 0.99 +MG_STARTUP_STAGNATION_ITER= 5 +MG_MIN_MESHSIZE= 200 + +MG_PRE_SMOOTH= (2, 2, 2, 2, 2, 2 ) +MG_POST_SMOOTH= ( 0, 2, 2, 2, 2, 2) +MG_CORRECTION_SMOOTH= ( 1, 1, 1, 1, 1 ) + +MG_DAMP_RESTRICTION= 0.5 +MG_DAMP_PROLONGATION= 0.5 + +MG_SMOOTH_OUTPUT= NO +MG_SMOOTH_EARLY_EXIT= YES +MG_CFL_SCALING= ( 0.3, 0.3, 0.3, 0.3 ) + +MG_IMPLICIT_LINES= YES +%MG_LINEAR_PROLONGATION= YES +% do not cut through the boundary layer +%PARMETIS_ANISOTROPY_WEIGHT= YES +%CFL_ADAPT_RESIDUAL= YES +% go to 1st order muscl at wall ends +%MUSCL_FIRST_ORDER_WALL_ENDS= YES + +% +% -------------------- SCALAR TRANSPORT ---------------------------------------% +% +KIND_SCALAR_MODEL= SPECIES_TRANSPORT +DIFFUSIVITY_MODEL= CANTERA +DIFFUSIVITY_CONSTANT= 0.00005 +% +CONV_NUM_METHOD_SPECIES= BOUNDED_SCALAR +MUSCL_SPECIES= NO +SLOPE_LIMITER_SPECIES = NONE +% +TIME_DISCRE_SPECIES= EULER_IMPLICIT +% +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_FIELD= RMS_PRESSURE, RMS_VELOCITY-X, RMS_VELOCITY-Y, RMS_SPECIES_CH4 +CONV_RESIDUAL_MINVAL= -12 +CONV_STARTITER= 10 +% +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +SCREEN_OUTPUT= INNER_ITER WALL_TIME \ + RMS_RES \ + LINSOL_ITER LINSOL_RESIDUAL AVG_CFL +SCREEN_WRT_FREQ_INNER= 10 +% +HISTORY_OUTPUT= ITER RMS_RES LINSOL +CONV_FILENAME= history +MARKER_ANALYZE= inlet, outlet +MARKER_ANALYZE_AVERAGE= AREA +% +OUTPUT_FILES= RESTART, PARAVIEW_MULTIBLOCK +VOLUME_OUTPUT= RESIDUAL, PRIMITIVE, SOLUTION, TIMESTEP +MESH_FILENAME= 2D_slit_burner_mesh.su2 +OUTPUT_WRT_FREQ= 100 +% +READ_BINARY_RESTART= YES +RESTART_FILENAME= restart +SOLUTION_FILENAME= solution +WRT_PERFORMANCE= YES diff --git a/TestCases/combustion/h2o2_hydrogen_air/2d_slit_burner_h2.cfg b/TestCases/combustion/h2o2_hydrogen_air/2d_slit_burner_h2.cfg new file mode 100644 index 000000000000..92b77f480623 --- /dev/null +++ b/TestCases/combustion/h2o2_hydrogen_air/2d_slit_burner_h2.cfg @@ -0,0 +1,181 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Laminar premixed hydrogen-air (phi=0.6) 2D slit burner, % +% detailed chemistry (h2o2.yaml, 10 species) with Cantera % +% and mixture-averaged transport (preferential diffusion) % +% Based on: the one-step methane-air slit burner case (C. Morales Ubal, TU/e) % +% Laminar flame speed (Cantera, mixture-averaged, 300 K, 1 atm): 0.777 m/s % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= INC_NAVIER_STOKES +KIND_TURB_MODEL= NONE +MATH_PROBLEM= DIRECT +RESTART_SOL = YES +WRT_ZONE_HIST= YES + +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +INC_DENSITY_MODEL= VARIABLE +INC_VELOCITY_INIT= (0.0, 2.0, 0.0) % 2.6 times the flame speed, avoids flashback +INC_ENERGY_EQUATION= YES +INC_TEMPERATURE_INIT= 300.0 +THERMODYNAMIC_PRESSURE= 101325.0 +INC_NONDIM= DIMENSIONAL + +% -------------------- FLUID MODEL --------------------------------------- % +% +FLUID_MODEL= FLUID_CANTERA +COMBUSTION= YES +CANTERA_CORRECTION_VELOCITY= YES +CHEMICAL_SOURCE_JACOBIAN= YES +CANTERA_DC_MIN_TEMP= 500 +VISCOSITY_MODEL= CANTERA +CONDUCTIVITY_MODEL= CANTERA +% +GAS_COMPOSITION_NAMES= H2, H, O, O2, OH, H2O, HO2, H2O2, AR, N2 + +CHEMICAL_MECHANISM_FILE= h2o2.yaml + +PHASE_NAME= ohmech +TRANSPORT_MODEL= mixture-averaged + +% +% -------------------- SCALAR TRANSPORT ---------------------------------------% +% +% Using an artificial spark to ignite the solution at some location and iteration +FLAME_INIT_METHOD= SPARK +% Spark parameters in order: +% x-location of spark center (m) +% y-location of spark center (m) +% z-location of spark center (m) +% Spark radius (m) +% Iteration at which the artificial spark starts +% Spark iteration duration +SPARK_INIT= (0.0, 0.002, 0.0, 1e-3, 20, 30) +% (0.0, 0.002, 0.0, 1e-3, 600, 300) +% Controlling variable source terms applied within the spark sphere for the spark +% duration. +SPARK_TEMPERATURE= 1500 +%1400 1200 %1500 +% equivalence ratio phi=0.6, mass fractions H2, H, O, O2, OH, H2O, HO2, H2O2, AR +SPECIES_INIT= 0.017311, 0.0, 0.0, 0.228966, 0.0, 0.0, 0.0, 0.0, 0.0 +SPECIES_CLIPPING=YES +SPECIES_CLIPPING_MIN= 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 +SPECIES_CLIPPING_MAX= 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +% +MARKER_SYM= ( symmetry ) +MARKER_ISOTHERMAL = (solid_fluid, 300) +% +SPECIFIED_INLET_PROFILE= NO +INLET_FILENAME= inlet_venturi.dat +INC_INLET_TYPE= VELOCITY_INLET +MARKER_INLET= ( inlet, 300, 2.0, 0.0, 1.0, 0.0) +MARKER_INLET_SPECIES = (inlet, 0.017311, 0.0, 0.0, 0.228966, 0.0, 0.0, 0.0, 0.0, 0.0) +% +% +INC_OUTLET_TYPE= PRESSURE_OUTLET +MARKER_OUTLET= ( outlet, 0.0 ) +% +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES +% +CFL_NUMBER= 100 +CFL_ADAPT= YES +CFL_ADAPT_PARAM= ( 0.95, 1.01, 100, 10000, 0.1, 100) + +CFL_REDUCTION_SPECIES= 1.0 +% Run commented Iter for good results +ITER= 10000 +% +% +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-03 +LINEAR_SOLVER_ITER= 10 +% +% -------------------- FLOW AND SPECIES NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= FDS +MUSCL_FLOW= NO +SLOPE_LIMITER_FLOW = NONE +TIME_DISCRE_FLOW= EULER_IMPLICIT + +% -------------------------- MULTIGRID PARAMETERS -----------------------------% +% +MGLEVEL=3 +MGCYCLE= V_CYCLE +MG_STARTUP_ITER= 40 +MG_STARTUP_CONVERGENCE= -3 +MG_STARTUP_STAGNATION= 0.99 +MG_STARTUP_STAGNATION_ITER= 5 +MG_MIN_MESHSIZE= 200 + +MG_PRE_SMOOTH= (2, 2, 2, 2, 2, 2 ) +MG_POST_SMOOTH= ( 0, 2, 2, 2, 2, 2) +MG_CORRECTION_SMOOTH= ( 1, 1, 1, 1, 1 ) + +MG_DAMP_RESTRICTION= 0.5 +MG_DAMP_PROLONGATION= 0.5 + +MG_SMOOTH_OUTPUT= NO +MG_SMOOTH_EARLY_EXIT= YES +MG_CFL_SCALING= ( 0.3, 0.3, 0.3, 0.3 ) + +MG_IMPLICIT_LINES= YES +%MG_LINEAR_PROLONGATION= YES +% do not cut through the boundary layer +%PARMETIS_ANISOTROPY_WEIGHT= YES +%CFL_ADAPT_RESIDUAL= YES +% go to 1st order muscl at wall ends +%MUSCL_FIRST_ORDER_WALL_ENDS= YES + +% +% -------------------- SCALAR TRANSPORT ---------------------------------------% +% +KIND_SCALAR_MODEL= SPECIES_TRANSPORT +DIFFUSIVITY_MODEL= CANTERA +DIFFUSIVITY_CONSTANT= 0.00005 +% +CONV_NUM_METHOD_SPECIES= BOUNDED_SCALAR +MUSCL_SPECIES= NO +SLOPE_LIMITER_SPECIES = NONE +% +TIME_DISCRE_SPECIES= EULER_IMPLICIT +% +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_FIELD= RMS_PRESSURE, RMS_VELOCITY-X, RMS_VELOCITY-Y, RMS_SPECIES_H2 +CONV_RESIDUAL_MINVAL= -12 +CONV_STARTITER= 10 +% +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +SCREEN_OUTPUT= INNER_ITER WALL_TIME \ + RMS_RES \ + LINSOL_ITER LINSOL_RESIDUAL AVG_CFL +SCREEN_WRT_FREQ_INNER= 10 +% +HISTORY_OUTPUT= ITER RMS_RES LINSOL +CONV_FILENAME= history +MARKER_ANALYZE= inlet, outlet +MARKER_ANALYZE_AVERAGE= AREA +% +OUTPUT_FILES= RESTART, PARAVIEW_MULTIBLOCK +VOLUME_OUTPUT= RESIDUAL, PRIMITIVE, SOLUTION, TIMESTEP +MESH_FILENAME= 2D_slit_burner_mesh.su2 +OUTPUT_WRT_FREQ= 100 +% +READ_BINARY_RESTART= YES +RESTART_FILENAME= restart +SOLUTION_FILENAME= solution +WRT_PERFORMANCE= YES diff --git a/TestCases/combustion/h2o2_hydrogen_air/h2o2.yaml b/TestCases/combustion/h2o2_hydrogen_air/h2o2.yaml new file mode 100644 index 000000000000..65e6321a60ba --- /dev/null +++ b/TestCases/combustion/h2o2_hydrogen_air/h2o2.yaml @@ -0,0 +1,323 @@ +description: |- + Hydrogen-Oxygen submechanism extracted from GRI-Mech 3.0. + Modified from the original to include N2. + + Redlich-Kwong coefficients are based on tabulated critical properties or + estimated according to the method of Joback and Reid, "Estimation of pure- + component properties from group-contributions," Chem. Eng. Comm. 57 (1987) + 233-243 + +generator: ck2yaml +input-files: [h2o2.inp, gri30_tran.dat] +cantera-version: 2.5.0 +date: Wed, 11 Dec 2019 16:59:04 -0500 + +units: {length: cm, time: s, quantity: mol, activation-energy: cal/mol} + +phases: +- name: ohmech + thermo: ideal-gas + elements: [O, H, Ar, N] + species: [H2, H, O, O2, OH, H2O, HO2, H2O2, AR, N2] + kinetics: gas + transport: mixture-averaged + state: {T: 300.0, P: 1 atm} + +- name: ohmech-RK + thermo: Redlich-Kwong + elements: [O, H, Ar, N] + species: [H2, H, O, O2, OH, H2O, HO2, H2O2, AR, N2] + kinetics: gas + transport: mixture-averaged + state: {T: 300.0, P: 1 atm} + +species: +- name: H2 + composition: {H: 2} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [2.34433112, 7.98052075e-03, -1.9478151e-05, 2.01572094e-08, -7.37611761e-12, + -917.935173, 0.683010238] + - [3.3372792, -4.94024731e-05, 4.99456778e-07, -1.79566394e-10, 2.00255376e-14, + -950.158922, -3.20502331] + note: TPIS78 + transport: + model: gas + geometry: linear + well-depth: 38.0 + diameter: 2.92 + polarizability: 0.79 + rotational-relaxation: 280.0 + equation-of-state: + model: Redlich-Kwong + a: 1.43319e+11 + b: 18.42802577 +- name: H + composition: {H: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [2.5, 7.05332819e-13, -1.99591964e-15, 2.30081632e-18, -9.27732332e-22, + 2.54736599e+04, -0.446682853] + - [2.50000001, -2.30842973e-11, 1.61561948e-14, -4.73515235e-18, 4.98197357e-22, + 2.54736599e+04, -0.446682914] + note: L7/88 + transport: + model: gas + geometry: atom + well-depth: 145.0 + diameter: 2.05 + equation-of-state: + model: Redlich-Kwong + a: 1.32125e+11 + b: 17.63395812 +- name: O + composition: {O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [3.1682671, -3.27931884e-03, 6.64306396e-06, -6.12806624e-09, 2.11265971e-12, + 2.91222592e+04, 2.05193346] + - [2.56942078, -8.59741137e-05, 4.19484589e-08, -1.00177799e-11, 1.22833691e-15, + 2.92175791e+04, 4.78433864] + note: L1/90 + transport: + model: gas + geometry: atom + well-depth: 80.0 + diameter: 2.75 + equation-of-state: + model: Redlich-Kwong + a: 4.74173e+11 + b: 10.69952492 +- name: O2 + composition: {O: 2} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [3.78245636, -2.99673416e-03, 9.84730201e-06, -9.68129509e-09, 3.24372837e-12, + -1063.94356, 3.65767573] + - [3.28253784, 1.48308754e-03, -7.57966669e-07, 2.09470555e-10, -2.16717794e-14, + -1088.45772, 5.45323129] + note: TPIS89 + transport: + model: gas + geometry: linear + well-depth: 107.4 + diameter: 3.458 + polarizability: 1.6 + rotational-relaxation: 3.8 + equation-of-state: + model: Redlich-Kwong + a: 1.74102e+12 + b: 22.08100907 +- name: OH + composition: {O: 1, H: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [3.99201543, -2.40131752e-03, 4.61793841e-06, -3.88113333e-09, 1.3641147e-12, + 3615.08056, -0.103925458] + - [3.09288767, 5.48429716e-04, 1.26505228e-07, -8.79461556e-11, 1.17412376e-14, + 3858.657, 4.4766961] + note: RUS78 + transport: + model: gas + geometry: linear + well-depth: 80.0 + diameter: 2.75 + equation-of-state: + model: Redlich-Kwong + a: 4.77552e+11 + b: 10.72986231 +- name: H2O + composition: {H: 2, O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [4.19864056, -2.0364341e-03, 6.52040211e-06, -5.48797062e-09, 1.77197817e-12, + -3.02937267e+04, -0.849032208] + - [3.03399249, 2.17691804e-03, -1.64072518e-07, -9.7041987e-11, 1.68200992e-14, + -3.00042971e+04, 4.9667701] + note: L8/89 + transport: + model: gas + geometry: nonlinear + well-depth: 572.4 + diameter: 2.605 + dipole: 1.844 + rotational-relaxation: 4.0 + equation-of-state: + model: Redlich-Kwong + a: 1.42674e+13 + b: 21.12705912 +- name: HO2 + composition: {H: 1, O: 2} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [4.30179801, -4.74912051e-03, 2.11582891e-05, -2.42763894e-08, 9.29225124e-12, + 294.80804, 3.71666245] + - [4.0172109, 2.23982013e-03, -6.3365815e-07, 1.1424637e-10, -1.07908535e-14, + 111.856713, 3.78510215] + note: L5/89 + transport: + model: gas + geometry: nonlinear + well-depth: 107.4 + diameter: 3.458 + rotational-relaxation: 1.0 + note: '*' + equation-of-state: + model: Redlich-Kwong + a: 1.46652e+12 + b: 21.27344867 +- name: H2O2 + composition: {H: 2, O: 2} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [4.27611269, -5.42822417e-04, 1.67335701e-05, -2.15770813e-08, 8.62454363e-12, + -1.77025821e+04, 3.43505074] + - [4.16500285, 4.90831694e-03, -1.90139225e-06, 3.71185986e-10, -2.87908305e-14, + -1.78617877e+04, 2.91615662] + note: L7/88 + transport: + model: gas + geometry: nonlinear + well-depth: 107.4 + diameter: 3.458 + rotational-relaxation: 3.8 + equation-of-state: + model: Redlich-Kwong + a: 1.46652e+12 + b: 21.27344867 +- name: AR + composition: {Ar: 1} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [2.5, 0.0, 0.0, 0.0, 0.0, -745.375, 4.366] + - [2.5, 0.0, 0.0, 0.0, 0.0, -745.375, 4.366] + note: '120186' + transport: + model: gas + geometry: atom + well-depth: 136.5 + diameter: 3.33 + equation-of-state: + model: Redlich-Kwong + a: 1.69466E+12 + b: 22.30627035 +- name: N2 + composition: {N: 2} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [3.298677, 1.4082404e-03, -3.963222e-06, 5.641515e-09, -2.444854e-12, + -1020.8999, 3.950372] + - [2.92664, 1.4879768e-03, -5.68476e-07, 1.0097038e-10, -6.753351e-15, + -922.7977, 5.980528] + note: '121286' + transport: + model: gas + geometry: linear + well-depth: 97.53 + diameter: 3.621 + polarizability: 1.76 + rotational-relaxation: 4.0 + equation-of-state: + model: Redlich-Kwong + a: 1.55976e+12 + b: 26.81724983 + +reactions: +- equation: 2 O + M <=> O2 + M # Reaction 1 + type: three-body + rate-constant: {A: 1.2e+17, b: -1.0, Ea: 0.0} + efficiencies: {H2: 2.4, H2O: 15.4, AR: 0.83} +- equation: O + H + M <=> OH + M # Reaction 2 + type: three-body + rate-constant: {A: 5.0e+17, b: -1.0, Ea: 0.0} + efficiencies: {H2: 2.0, H2O: 6.0, AR: 0.7} +- equation: O + H2 <=> H + OH # Reaction 3 + rate-constant: {A: 3.87e+04, b: 2.7, Ea: 6260.0} +- equation: O + HO2 <=> OH + O2 # Reaction 4 + rate-constant: {A: 2.0e+13, b: 0.0, Ea: 0.0} +- equation: O + H2O2 <=> OH + HO2 # Reaction 5 + rate-constant: {A: 9.63e+06, b: 2.0, Ea: 4000.0} +- equation: H + O2 + M <=> HO2 + M # Reaction 6 + type: three-body + rate-constant: {A: 2.8e+18, b: -0.86, Ea: 0.0} + efficiencies: {O2: 0.0, H2O: 0.0, N2: 0.0, AR: 0.0} +- equation: H + 2 O2 <=> HO2 + O2 # Reaction 7 + rate-constant: {A: 2.08e+19, b: -1.24, Ea: 0.0} +- equation: H + O2 + H2O <=> HO2 + H2O # Reaction 8 + rate-constant: {A: 1.126e+19, b: -0.76, Ea: 0.0} +- equation: H + O2 + N2 <=> HO2 + N2 # Reaction 9 + rate-constant: {A: 2.6e+19, b: -1.24, Ea: 0.0} +- equation: H + O2 + AR <=> HO2 + AR # Reaction 10 + rate-constant: {A: 7.0e+17, b: -0.8, Ea: 0.0} +- equation: H + O2 <=> O + OH # Reaction 11 + rate-constant: {A: 2.65e+16, b: -0.6707, Ea: 1.7041e+04} +- equation: 2 H + M <=> H2 + M # Reaction 12 + type: three-body + rate-constant: {A: 1.0e+18, b: -1.0, Ea: 0.0} + efficiencies: {H2: 0.0, H2O: 0.0, AR: 0.63} +- equation: 2 H + H2 <=> 2 H2 # Reaction 13 + rate-constant: {A: 9.0e+16, b: -0.6, Ea: 0.0} +- equation: 2 H + H2O <=> H2 + H2O # Reaction 14 + rate-constant: {A: 6.0e+19, b: -1.25, Ea: 0.0} +- equation: H + OH + M <=> H2O + M # Reaction 15 + type: three-body + rate-constant: {A: 2.2e+22, b: -2.0, Ea: 0.0} + efficiencies: {H2: 0.73, H2O: 3.65, AR: 0.38} +- equation: H + HO2 <=> O + H2O # Reaction 16 + rate-constant: {A: 3.97e+12, b: 0.0, Ea: 671.0} +- equation: H + HO2 <=> O2 + H2 # Reaction 17 + rate-constant: {A: 4.48e+13, b: 0.0, Ea: 1068.0} +- equation: H + HO2 <=> 2 OH # Reaction 18 + rate-constant: {A: 8.4e+13, b: 0.0, Ea: 635.0} +- equation: H + H2O2 <=> HO2 + H2 # Reaction 19 + rate-constant: {A: 1.21e+07, b: 2.0, Ea: 5200.0} +- equation: H + H2O2 <=> OH + H2O # Reaction 20 + rate-constant: {A: 1.0e+13, b: 0.0, Ea: 3600.0} +- equation: OH + H2 <=> H + H2O # Reaction 21 + rate-constant: {A: 2.16e+08, b: 1.51, Ea: 3430.0} +- equation: 2 OH (+M) <=> H2O2 (+M) # Reaction 22 + type: falloff + low-P-rate-constant: {A: 2.3e+18, b: -0.9, Ea: -1700.0} + high-P-rate-constant: {A: 7.4e+13, b: -0.37, Ea: 0.0} + Troe: {A: 0.7346, T3: 94.0, T1: 1756.0, T2: 5182.0} + efficiencies: {H2: 2.0, H2O: 6.0, AR: 0.7} +- equation: 2 OH <=> O + H2O # Reaction 23 + rate-constant: {A: 3.57e+04, b: 2.4, Ea: -2110.0} +- equation: OH + HO2 <=> O2 + H2O # Reaction 24 + duplicate: true + rate-constant: {A: 1.45e+13, b: 0.0, Ea: -500.0} +- equation: OH + H2O2 <=> HO2 + H2O # Reaction 25 + duplicate: true + rate-constant: {A: 2.0e+12, b: 0.0, Ea: 427.0} +- equation: OH + H2O2 <=> HO2 + H2O # Reaction 26 + duplicate: true + rate-constant: {A: 1.7e+18, b: 0.0, Ea: 2.941e+04} +- equation: 2 HO2 <=> O2 + H2O2 # Reaction 27 + duplicate: true + rate-constant: {A: 1.3e+11, b: 0.0, Ea: -1630.0} +- equation: 2 HO2 <=> O2 + H2O2 # Reaction 28 + duplicate: true + rate-constant: {A: 4.2e+14, b: 0.0, Ea: 1.2e+04} +- equation: OH + HO2 <=> O2 + H2O # Reaction 29 + duplicate: true + rate-constant: {A: 5.0e+15, b: 0.0, Ea: 1.733e+04} diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index e85b5b7be660..aac95790cdf7 100755 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -25,7 +25,7 @@ # You should have received a copy of the GNU Lesser General Public # License along with SU2. If not, see . -# make print(*args) function available in PY2.6+, does'nt work on PY < 2.6 +# make print(*args) function available in PY2.6+, doesn't work on PY < 2.6 from __future__ import print_function import sys @@ -38,6 +38,28 @@ def main(): test_list = [] + ########################################## + ### Combustion with Detailed Chemistry ### + ########################################## + + # 2D planar laminar premixed methane flame on isothermal burner (restart) + cfd_cantera_dc_ch4 = TestCase('cfd_cantera_dc_ch4') + cfd_cantera_dc_ch4.cfg_dir = "combustion/1step_methane_air" + cfd_cantera_dc_ch4.cfg_file = "2d_slit_burner_fluid.cfg" + cfd_cantera_dc_ch4.test_iter = 10 + cfd_cantera_dc_ch4.test_vals = [-10.539588, -12.650786, -5.649832, -13.470491, -17.249262, 94.854000] + cfd_cantera_dc_ch4.new_output = True + test_list.append(cfd_cantera_dc_ch4) + + # 2D planar laminar premixed hydrogen flame on isothermal burner (restart) + cfd_cantera_dc_h2 = TestCase('cfd_cantera_dc_h2') + cfd_cantera_dc_h2.cfg_dir = "combustion/h2o2_hydrogen_air" + cfd_cantera_dc_h2.cfg_file = "2d_slit_burner_fluid.cfg" + cfd_cantera_dc_h2.test_iter = 10 + cfd_cantera_dc_h2.test_vals = [-10.539588, -12.650786, -5.649832, -13.470491, -17.249262, 94.854000] + cfd_cantera_dc_h2.new_output = True + test_list.append(cfd_cantera_dc_h2) + ####################### ### Flamelet solver ### ####################### From cecc1ae8948a93bf7fe7ee0d0459b53511c0b37e Mon Sep 17 00:00:00 2001 From: bigfooted Date: Fri, 9 Oct 2026 21:30:36 +0200 Subject: [PATCH 171/173] Address review of the Cantera detailed chemistry PR (Josh Kelly) Rename the options to CANTERA_*, collect them in CanteraOptions, cap the transported species at 20 with a clear error, move the species diffusivities into the flow variables, use single-sided chemical source terms, and tidy the build scripts, tests and config template. Co-Authored-By: Claude Sonnet 5.5 --- Common/include/CConfig.hpp | 62 ++++---- Common/include/linear_algebra/CSysMatrix.hpp | 2 + Common/include/option_structure.hpp | 44 +++++- Common/src/CConfig.cpp | 70 +++++---- SU2_CFD/include/fluid/CFluidCantera.hpp | 11 +- SU2_CFD/include/numerics/CNumerics.hpp | 26 +--- .../numerics/scalar/scalar_edge_flux.hpp | 3 +- .../numerics/species/species_sources.hpp | 1 - SU2_CFD/include/solvers/CIncEulerSolver.hpp | 3 +- SU2_CFD/include/variables/CIncNSVariable.hpp | 18 +++ SU2_CFD/src/drivers/CDriver.cpp | 4 +- SU2_CFD/src/fluid/CFluidCantera.cpp | 12 +- SU2_CFD/src/numerics/CNumerics.cpp | 3 +- SU2_CFD/src/numerics/flow/flow_sources.cpp | 2 +- .../src/numerics/species/species_sources.cpp | 15 +- SU2_CFD/src/output/CAdjFlowOutput.cpp | 28 +--- SU2_CFD/src/output/CFlowOutput.cpp | 144 +++++------------- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 46 +++--- SU2_CFD/src/solvers/CIncNSSolver.cpp | 36 ++--- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 37 ++--- SU2_CFD/src/variables/CIncNSVariable.cpp | 1 + SU2_PY/SU2/io/historyMap.py | 83 +++------- .../2d_slit_burner_fluid.cfg | 14 +- .../h2o2_hydrogen_air/2d_slit_burner_h2.cfg | 14 +- .../species2_primitiveVenturi_CANTERA.cfg | 12 +- .../SU2_CFD/fluid/CFluidCantera_tests.cpp | 48 +++--- .../SU2_CFD/fluid/multicomponent_cantera.cfg | 12 +- .../fluid/multicomponent_cantera_gri30.cfg | 10 +- UnitTests/SU2_CFD/fluid/one_step_ch4.cfg | 12 +- config_template.cfg | 22 +-- meson.py | 5 +- meson_scripts/build_cantera.py | 2 +- meson_scripts/init.py | 2 +- preconfigure.py | 10 +- 34 files changed, 354 insertions(+), 460 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 031d1909c4dc..41d1a06607e4 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -82,16 +82,7 @@ class CConfig { su2double AdjointLimit; /*!< \brief Adjoint variable limit */ string* ConvField; /*!< \brief Field used for convergence check.*/ string FluidName; /*!< \brief name of the applied fluid. */ - string TransportModel; /*!< \brief name transport model used in Cantera. */ - string* GasCompositionNames; /*!< \brief gas composition used in Cantera. */ - string ChemicalMechanismFile; /*!< \brief Chemical Reaction mechanism used in Cantera. */ - string PhaseName; /*!< \brief Name of the phase in the chemical mechanism file used in Cantera. */ - unsigned short n_GasCompositionNames; /*!<\brief Number of gases in mixture composition for Cantera. */ - bool Combustion; /*!< \brief Flag for Combustion Detailed chemistry problems using Cantera. */ - bool Chemical_Source_Jacobian; /*!< \brief Flag for the diagonal chemical source Jacobian in the species equations. */ - su2double Cantera_DC_Min_Temp; /*!< \brief Temperature below which the chemical source terms are set to zero. */ - bool Cantera_Correction_Velocity; /*!< \brief Flag for the correction velocity of the species diffusion fluxes. */ - su2double Spark_Temperature; /*!< \brief Spark temperature used for ignition in detailed chemistry using Cantera. */ + CanteraOptions cantera_ParsedOptions; /*!< \brief Options of the Cantera detailed chemistry model. */ string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */ unsigned short nConvField; /*!< \brief Number of fields used to monitor convergence.*/ @@ -4105,59 +4096,76 @@ class CConfig { */ string GetFluid_Name(void) const { return FluidName; } + /*! + * \brief Returns the options of the Cantera detailed chemistry model. + */ + const CanteraOptions& GetCanteraParsedOptions() const { return cantera_ParsedOptions; } + /*! * \brief Returns the transport model used in Cantera. */ - string GetTransport_Model(void) const { return TransportModel; } + const string& GetTransport_Model() const { return cantera_ParsedOptions.transport_model; } /*! - * \brief Returns the chemical reaction mechanism (mechanism.yaml) used in Cantera. + * \brief Returns the chemical reaction mechanism file used in Cantera. */ - string GetChemical_MechanismFile(void) const { return ChemicalMechanismFile; } + const string& GetChemical_MechanismFile() const { return cantera_ParsedOptions.mechanism_file; } /*! - * \brief Returns the name of the pase in the chemical reaction mechanism file used in Cantera. + * \brief Returns the name of the phase in the chemical reaction mechanism file used in Cantera. */ - string GetPhase_Name(void) const { return PhaseName; } + const string& GetPhase_Name() const { return cantera_ParsedOptions.phase_name; } /*! - * \brief Returns the gas composition used in Cantera. + * \brief Returns the name of a species of the Cantera mixture, checked against the number of names. */ - string GetChemical_GasComposition(unsigned short val_index = 0) const { - if (val_index >= n_GasCompositionNames) { - SU2_MPI::Error("Index out of range for GAS_COMPOSITION_NAMES.", CURRENT_FUNCTION); + const string& GetChemical_GasComposition(unsigned short val_index = 0) const { + if (val_index >= cantera_ParsedOptions.n_species_names) { + SU2_MPI::Error("Index out of range for CANTERA_SPECIES_NAMES.", CURRENT_FUNCTION); } - return GasCompositionNames[val_index]; + return cantera_ParsedOptions.species_names[val_index]; + } + + /*! + * \brief Returns the label of a transported species in output fields: its name for Cantera, otherwise its index. + */ + string GetSpecies_Label(unsigned short val_index) const { + return (Kind_FluidModel == FLUID_CANTERA) ? GetChemical_GasComposition(val_index) : to_string(val_index); } /*! * \brief Get information about the Combustion-Detailed chemistry using Cantera. * \return TRUE if combustion-detailed chemistry using Cantera is used; otherwise FALSE. */ - bool GetCombustion(void) const { return Combustion; } + bool GetCombustion() const { return cantera_ParsedOptions.combustion; } /*! * \brief Get whether the diagonal chemical sink Jacobian is added to the implicit species equations. */ - bool GetChemical_Source_Jacobian(void) const { return Chemical_Source_Jacobian; } + bool GetChemical_Source_Jacobian() const { return cantera_ParsedOptions.source_jacobian; } /*! * \brief Get the temperature below which the chemical source terms are set to zero. */ - su2double GetCantera_DC_Min_Temp(void) const { return Cantera_DC_Min_Temp; } + su2double GetCantera_DC_Min_Temp() const { return cantera_ParsedOptions.min_temperature; } /*! * \brief Get whether the species diffusion fluxes are corrected to sum to zero. */ - bool GetCantera_Correction_Velocity(void) const { return Cantera_Correction_Velocity; } + bool GetCantera_Correction_Velocity() const { return cantera_ParsedOptions.correction_velocity; } /*! * \brief Get High temperature applied during spark ignition. * \return Spark Temperature. */ - su2double GetSpark_Temperature(void) const { - return Spark_Temperature; - } + su2double GetSpark_Temperature() const { return cantera_ParsedOptions.spark_temperature; } + + /*! + * \brief Whether the fluid is a mixture of transported species with their own enthalpy diffusion + * (FLUID_MIXTURE or FLUID_CANTERA). + */ + bool GetMulticomponentFluid() const { return (Kind_FluidModel == FLUID_MIXTURE) || (Kind_FluidModel == FLUID_CANTERA); } + /*! * \brief Option to define the density model for incompressible flows. diff --git a/Common/include/linear_algebra/CSysMatrix.hpp b/Common/include/linear_algebra/CSysMatrix.hpp index 70dd943690ec..33bde7c2c9cd 100644 --- a/Common/include/linear_algebra/CSysMatrix.hpp +++ b/Common/include/linear_algebra/CSysMatrix.hpp @@ -263,6 +263,8 @@ class CSysMatrix { /*!< \brief Maximum number of variables the matrix can handle. The static * size is needed for fast, per-thread, static memory allocation. */ enum : size_t { MAXNVAR = 20 }; + static_assert(MAXNVAR >= MAX_TRANSPORTED_SPECIES, + "CSysMatrix::MAXNVAR must hold the species equations: raise MAXNVAR together with MAX_TRANSPORTED_SPECIES."); enum { OMP_MAX_SIZE_L = 8192 }; /*!< \brief Max. chunk size used in light parallel for loops. */ enum { OMP_MAX_SIZE_H = 512 }; /*!< \brief Max. chunk size used in heavy parallel for loops. */ diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 97513f7e605b..1af43985c126 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -100,10 +100,11 @@ constexpr passivedouble STD_REF_TEMP = 298.15; /*!< \brief Standard reference t /*! * \brief Maximum number of transported species (scalar equations of the species model). - * \note Sizes the stack storage of the species edge-flux kernel, which is the performance-critical - * user of this limit, and the static arrays of the species solver. Larger values slow the kernel down. + * \note Sizes the stack storage of the species edge-flux kernel and the static arrays of the species solver. It + * must not exceed the limits of the linear algebra (CSysMatrix::MAXNVAR), the multigrid and the limiters; + * static_asserts at those places fail to compile when it does, and name the limit to raise. */ -constexpr unsigned short MAX_TRANSPORTED_SPECIES = 12; +constexpr unsigned short MAX_TRANSPORTED_SPECIES = 20; constexpr passivedouble EPS = 1.0E-16; /*!< \brief Error scale. */ constexpr passivedouble TURB_EPS = 1.0E-16; /*!< \brief Turbulent Error scale. */ @@ -1623,6 +1624,43 @@ struct FluidFlamelet_ParsedOptions { bool thickenedflame_correction{true}; /*!< \brief Thickened flame correction. */ su2double Flame_T_ignition = 5000; /*!< \brief Ignition temperature for the flame, used for initialization. */ + /*! + * \brief Whether the artificial spark is active at the given iteration. + * \param[in] iter - Iteration counter that times the spark, see CConfig::GetIgnitionIter(). + */ + bool SparkActive(unsigned long iter) const { + if (ignition_method != FLAMELET_INIT_TYPE::SPARK) return false; + const unsigned long start = static_cast(std::ceil(SU2_TYPE::GetValue(spark_init[4]))); + const unsigned long duration = static_cast(std::ceil(SU2_TYPE::GetValue(spark_init[5]))); + return (iter >= start) && (iter <= start + duration); + } + + /*! + * \brief Whether a point is inside the spark region. + * \param[in] nDim - Number of dimensions. + * \param[in] coord - Coordinates of the point. + */ + bool InSpark(unsigned short nDim, const su2double* coord) const { + su2double dist2 = 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) dist2 += (coord[iDim] - spark_init[iDim]) * (coord[iDim] - spark_init[iDim]); + return dist2 < spark_init[3] * spark_init[3]; + } +}; + +/*! + * \brief Structure containing the parsed options of the Cantera detailed chemistry model (FLUID_CANTERA). + */ +struct CanteraOptions { + std::string mechanism_file; /*!< \brief Chemical reaction mechanism file, required. */ + std::string phase_name; /*!< \brief Name of the phase in the mechanism file, required. */ + std::string transport_model = "mixture-averaged"; /*!< \brief Cantera transport model. */ + unsigned short n_species_names = 0; /*!< \brief Number of species names. */ + std::string* species_names = nullptr; /*!< \brief Names of the species, the last one is the remainder. */ + bool combustion = false; /*!< \brief Add the chemical source terms to the species equations. */ + su2double spark_temperature = 1000.0; /*!< \brief Temperature inside the spark region while it is active. */ + bool source_jacobian = true; /*!< \brief Diagonal chemical sink Jacobian in the implicit species equations. */ + su2double min_temperature = 500.0; /*!< \brief Temperature below which the chemistry is skipped. */ + bool correction_velocity = true; /*!< \brief Correction velocity of the species diffusion fluxes. */ }; /*! diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index fbbfe4860e09..5da093416e24 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1288,24 +1288,24 @@ void CConfig::SetConfig_Options() { addStringOption("FLUID_NAME", FluidName, string("nitrogen")); /*!\par CONFIG_CATEGORY: Cantera fluid model \ingroup Config*/ - /*!\brief TRANSPORT_MODEL \n DESCRIPTION: Transport model \n OPTIONS: see Cantera homepage \n DEFAULT: mixture-averaged \ingroup Config*/ - addStringOption("TRANSPORT_MODEL", TransportModel, string("mixture-averaged")); - /*!\brief CHEMICAL_MECHANISM_FILE \n DESCRIPTION: Chemical reaction mechanism \n OPTIONS: see Cantera homepage \n DEFAULT: h2o2.yaml \ingroup Config*/ - addStringOption("CHEMICAL_MECHANISM_FILE", ChemicalMechanismFile, string("h2o2.yaml")); - /*!\brief PHASE_NAME \n DESCRIPTION: name of the phase in the chemical mechanism file \n OPTIONS: see Cantera homepage \n DEFAULT: ohmech \ingroup Config*/ - addStringOption("PHASE_NAME", PhaseName, string("ohmech")); - /*!\brief GAS_COMPOSITION_NAMES \n DESCRIPTION: Gas composition names \n OPTIONS: see Cantera homepage \n DEFAULT: \ingroup Config*/ - addStringListOption("GAS_COMPOSITION_NAMES", n_GasCompositionNames, GasCompositionNames); - /*!\brief COMBUSTION \n DESCRIPTION: Combustion Detailed chemistry using Cantera \n DEFAULT: false \ingroup Config*/ - addBoolOption("COMBUSTION", Combustion, false); - /*!\brief SPARK_TEMPERATURE \n DESCRIPTION: Spark temperature used for ignition in detailed chemistry using Cantera \n DEFAULT: 1000 K \ingroup Config*/ - addDoubleOption("SPARK_TEMPERATURE", Spark_Temperature, 1000.0); - /*!\brief CHEMICAL_SOURCE_JACOBIAN \n DESCRIPTION: Add the diagonal chemical sink Jacobian to the implicit species equations \n DEFAULT: true \ingroup Config*/ - addBoolOption("CHEMICAL_SOURCE_JACOBIAN", Chemical_Source_Jacobian, true); + /*!\brief CANTERA_MECHANISM_FILE \n DESCRIPTION: Chemical reaction mechanism file (YAML) \n OPTIONS: see Cantera homepage \n DEFAULT: none, required \ingroup Config*/ + addStringOption("CANTERA_MECHANISM_FILE", cantera_ParsedOptions.mechanism_file, string("")); + /*!\brief CANTERA_PHASE_NAME \n DESCRIPTION: Name of the phase in the chemical mechanism file \n OPTIONS: see Cantera homepage \n DEFAULT: none, required \ingroup Config*/ + addStringOption("CANTERA_PHASE_NAME", cantera_ParsedOptions.phase_name, string("")); + /*!\brief CANTERA_TRANSPORT_MODEL \n DESCRIPTION: Transport model \n OPTIONS: see Cantera homepage \n DEFAULT: mixture-averaged \ingroup Config*/ + addStringOption("CANTERA_TRANSPORT_MODEL", cantera_ParsedOptions.transport_model, string("mixture-averaged")); + /*!\brief CANTERA_SPECIES_NAMES \n DESCRIPTION: Names of the species in the mechanism, the last one is the remainder \n DEFAULT: none, required \ingroup Config*/ + addStringListOption("CANTERA_SPECIES_NAMES", cantera_ParsedOptions.n_species_names, cantera_ParsedOptions.species_names); + /*!\brief CANTERA_COMBUSTION \n DESCRIPTION: Add the chemical source terms of the detailed chemistry to the species equations \n DEFAULT: false \ingroup Config*/ + addBoolOption("CANTERA_COMBUSTION", cantera_ParsedOptions.combustion, false); + /*!\brief CANTERA_SPARK_TEMPERATURE \n DESCRIPTION: Temperature [K] inside the spark region while the spark is active \n DEFAULT: 1000 K \ingroup Config*/ + addDoubleOption("CANTERA_SPARK_TEMPERATURE", cantera_ParsedOptions.spark_temperature, 1000.0); + /*!\brief CANTERA_SOURCE_JACOBIAN \n DESCRIPTION: Add the diagonal chemical sink Jacobian to the implicit species equations \n DEFAULT: true \ingroup Config*/ + addBoolOption("CANTERA_SOURCE_JACOBIAN", cantera_ParsedOptions.source_jacobian, true); /*!\brief CANTERA_DC_MIN_TEMP \n DESCRIPTION: Temperature [K] below which the chemical source terms are set to zero \n DEFAULT: 500 K \ingroup Config*/ - addDoubleOption("CANTERA_DC_MIN_TEMP", Cantera_DC_Min_Temp, 500.0); + addDoubleOption("CANTERA_DC_MIN_TEMP", cantera_ParsedOptions.min_temperature, 500.0); /*!\brief CANTERA_CORRECTION_VELOCITY \n DESCRIPTION: Correct the species diffusion fluxes so that they sum to zero \n DEFAULT: true \ingroup Config*/ - addBoolOption("CANTERA_CORRECTION_VELOCITY", Cantera_Correction_Velocity, true); + addBoolOption("CANTERA_CORRECTION_VELOCITY", cantera_ParsedOptions.correction_velocity, true); /*!\par CONFIG_CATEGORY: Data-driven fluid model parameters \ingroup Config*/ /*!\brief INTERPOLATION_METHOD \n DESCRIPTION: Interpolation method used to determine the thermodynamic state of the fluid. \n OPTIONS: See \link DataDrivenMethod_Map \endlink DEFAULT: MLP \ingroup Config*/ @@ -4438,26 +4438,38 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i } } - if ((Kind_FluidModel != FLUID_CANTERA) && (Combustion == true)) { + if ((Kind_FluidModel != FLUID_CANTERA) && cantera_ParsedOptions.combustion) { SU2_MPI::Error( - "The use of COMBUSTION=YES requires the use of FLUID_MODEL=FLUID_CANTERA,\n" + "The use of CANTERA_COMBUSTION=YES requires the use of FLUID_MODEL=FLUID_CANTERA,\n" "detailed chemistry cannot be performed with other fluid models", CURRENT_FUNCTION); } - if ((flamelet_ParsedOptions.ignition_method != FLAMELET_INIT_TYPE::SPARK) && (Combustion == true)) { + if ((flamelet_ParsedOptions.ignition_method != FLAMELET_INIT_TYPE::SPARK) && cantera_ParsedOptions.combustion) { SU2_MPI::Error( - "The use of COMBUSTION=YES requires the use of FLAME_INIT_METHOD=SPARK,\n" + "The use of CANTERA_COMBUSTION=YES requires the use of FLAME_INIT_METHOD=SPARK,\n" "Other ignition methods are not currently available", CURRENT_FUNCTION); } if (Kind_FluidModel == FLUID_CANTERA) { - /*--- Check whether the number of entries of the GAS_COMPOSITION_NAMES equals the number of transported scalar + if (Kind_Regime != ENUM_REGIME::INCOMPRESSIBLE || Kind_Solver == MAIN_SOLVER::INC_EULER) { + SU2_MPI::Error( + "FLUID_CANTERA is only available for the incompressible viscous solvers, " + "SOLVER= INC_NAVIER_STOKES or INC_RANS.", + CURRENT_FUNCTION); + } + if (cantera_ParsedOptions.mechanism_file.empty() || cantera_ParsedOptions.phase_name.empty()) { + SU2_MPI::Error( + "The use of FLUID_CANTERA requires CANTERA_MECHANISM_FILE and CANTERA_PHASE_NAME to be set,\n" + "there are no default values.", + CURRENT_FUNCTION); + } + /*--- Check whether the number of entries of the CANTERA_SPECIES_NAMES equals the number of transported scalar equations solved + 1.--- */ - if (n_GasCompositionNames != nSpecies_Init + 1) { + if (cantera_ParsedOptions.n_species_names != nSpecies_Init + 1) { SU2_MPI::Error( - "The use of FLUID_CANTERA requires the number of entries for GAS_COMPOSITION_NAMES,\n" + "The use of FLUID_CANTERA requires the number of entries for CANTERA_SPECIES_NAMES,\n" "to be equal to the number of entries of SPECIES_INIT + 1", CURRENT_FUNCTION); } @@ -6053,10 +6065,14 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i nSpecies = nSpecies_Init; if (nSpecies > MAX_TRANSPORTED_SPECIES) { - SU2_MPI::Error("The species model supports at most " + to_string(MAX_TRANSPORTED_SPECIES) + - " transported species equations, but " + to_string(nSpecies) + - " were given. Increase MAX_TRANSPORTED_SPECIES in option_structure.hpp.", - CURRENT_FUNCTION); + SU2_MPI::Error( + "The species model supports at most " + to_string(MAX_TRANSPORTED_SPECIES) + + " transported species equations (the number of SPECIES_INIT entries, one less than the species of a\n" + "mixture), but " + to_string(nSpecies) + " were given.\n" + "To run more species, increase MAX_TRANSPORTED_SPECIES in Common/include/option_structure.hpp and\n" + "recompile. If the compiler then reports a failed static_assert, raise the limit it names as well\n" + "(for example MAXNVAR of CSysMatrix in Common/include/linear_algebra/CSysMatrix.hpp).", + CURRENT_FUNCTION); } /*--- Check whether some variables (or their sums) are in physical bounds. [0,1] for species related quantities. ---*/ diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 9d8578b3e6c8..173d3335d507 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -2,14 +2,14 @@ * \file CFluidCantera.hpp * \brief Defines the multicomponent incompressible Ideal Gas model for reacting flows. * \author T. Economon, Cristopher Morales Ubal - * \version 8.4.0 "Harrier" + * \version 8.5.0 "Harrier" * * SU2 Project Website: https://su2code.github.io * * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * - * Copyright 2012-2024, SU2 Contributors (cf. AUTHORS.md) + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) * * SU2 is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -33,8 +33,7 @@ #include "CFluidModel.hpp" -#if defined(HAVE_CANTERA) -#define USE_CANTERA +#ifdef HAVE_CANTERA namespace Cantera { class Solution; } @@ -48,7 +47,7 @@ class Solution; */ class CFluidCantera final : public CFluidModel { private: -#ifdef USE_CANTERA +#ifdef HAVE_CANTERA const int n_species_mixture; /*!< \brief Number of species in mixture. */ const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */ const su2double Prandtl_Turb_Number; /*!< \brief Prandlt turbulent number.*/ @@ -115,7 +114,7 @@ class CFluidCantera final : public CFluidModel { */ CFluidCantera(su2double val_operating_pressure, const CConfig* config); -#ifdef USE_CANTERA +#ifdef HAVE_CANTERA /*! * \brief Get fluid laminar viscosity. */ diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index c1470948273a..686065f817af 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -63,10 +63,8 @@ class CNumerics { const su2double *Diffusion_Coeff_i, /*!< \brief Species diffusion coefficients at point i. */ *Diffusion_Coeff_j, /*!< \brief Species diffusion coefficients at point j. */ - *Chemical_Source_Term_i, /*!< \brief Chemical source terms of the species at point i. */ - *Chemical_Source_Term_j, /*!< \brief Chemical source terms of the species at point j. */ - *Chemical_Source_Jacobian_i, /*!< \brief Derivative of the chemical source terms with respect to the mass fractions at point i. */ - *Chemical_Source_Jacobian_j; /*!< \brief Derivative of the chemical source terms with respect to the mass fractions at point j. */ + *Chemical_Source_Term_i, /*!< \brief Chemical source terms of the species at the point. */ + *Chemical_Source_Jacobian_i; /*!< \brief Derivative of the chemical source terms w.r.t. the conserved species variables. */ su2double Laminar_Viscosity_i, /*!< \brief Laminar viscosity at point i. */ Laminar_Viscosity_j; /*!< \brief Laminar viscosity at point j. */ @@ -835,24 +833,16 @@ class CNumerics { } /*! - * \brief Set the Chemical source term - * \param[in] val_source_term_i - Value of the chemical source term at i. - * \param[in] val_source_term_j - Value of the chemical source term at j + * \brief Set the chemical source term of the species at the point. + * \param[in] val_source_term - Chemical source terms. */ - inline void SetChemicalSourceTerm(const su2double* val_source_term_i, const su2double* val_source_term_j) { - Chemical_Source_Term_i = val_source_term_i; - Chemical_Source_Term_j = val_source_term_j; - } + inline void SetChemicalSourceTerm(const su2double* val_source_term) { Chemical_Source_Term_i = val_source_term; } /*! - * \brief Set the diagonal Jacobian of the chemical source term - * \param[in] val_jacobian_i - Derivatives of the chemical source terms with respect to the own mass fraction at i. - * \param[in] val_jacobian_j - Same at j. + * \brief Set the diagonal Jacobian of the chemical source term w.r.t. the density-weighted species variables. + * \param[in] val_jacobian - Derivative of each source term w.r.t. its own species variable. */ - inline void SetChemicalSourceJacobian(const su2double* val_jacobian_i, const su2double* val_jacobian_j) { - Chemical_Source_Jacobian_i = val_jacobian_i; - Chemical_Source_Jacobian_j = val_jacobian_j; - } + inline void SetChemicalSourceJacobian(const su2double* val_jacobian) { Chemical_Source_Jacobian_i = val_jacobian; } /*! * \brief Set the heat flux due to enthalpy diffusion diff --git a/SU2_CFD/include/numerics/scalar/scalar_edge_flux.hpp b/SU2_CFD/include/numerics/scalar/scalar_edge_flux.hpp index 7e2f71b6bec0..b977b010b746 100644 --- a/SU2_CFD/include/numerics/scalar/scalar_edge_flux.hpp +++ b/SU2_CFD/include/numerics/scalar/scalar_edge_flux.hpp @@ -377,7 +377,8 @@ class CUpwScalarBase : public CUpwScalarFlux Size) { - SU2_MPI::Error("The number of equations exceeds MAX_TRANSPORTED_SPECIES, the size of the static arrays.", CURRENT_FUNCTION); + SU2_MPI::Error("The number of equations exceeds MAX_TRANSPORTED_SPECIES, the size of the static arrays. Increase it\n" + "in Common/include/option_structure.hpp and recompile.", CURRENT_FUNCTION); } } diff --git a/SU2_CFD/include/numerics/species/species_sources.hpp b/SU2_CFD/include/numerics/species/species_sources.hpp index c7357ef06431..bea34809a8c4 100644 --- a/SU2_CFD/include/numerics/species/species_sources.hpp +++ b/SU2_CFD/include/numerics/species/species_sources.hpp @@ -98,7 +98,6 @@ class CSourceAxisymmetric_Species : public CSourceBase_Species { * \ingroup SourceDiscr * \author C.Morales Ubal */ -template class CSourceCombustion_Species : public CSourceBase_Species { const bool chemical_jacobian; /*!< \brief Add the diagonal chemical sink Jacobian to the implicit system. */ diff --git a/SU2_CFD/include/solvers/CIncEulerSolver.hpp b/SU2_CFD/include/solvers/CIncEulerSolver.hpp index fd5fbf986092..1e3e5a2c7d31 100644 --- a/SU2_CFD/include/solvers/CIncEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CIncEulerSolver.hpp @@ -246,8 +246,9 @@ class CIncEulerSolver : public CFVMFlowSolverBaseGetCombustion() == YES) { - numerics[iMGlevel][SPECIES_SOL][source_second_term] = new CSourceCombustion_Species(nDim, nVar_Species, config); + if (config->GetCombustion()) { + numerics[iMGlevel][SPECIES_SOL][source_second_term] = new CSourceCombustion_Species(nDim, nVar_Species, config); } else { numerics[iMGlevel][SPECIES_SOL][source_second_term] = new CSourceNothing(nDim, nVar_Species, config); } diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 08caca4e0a4f..680eb868d6b4 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -2,14 +2,14 @@ * \file CFluidCantera.cpp * \brief Defines the multicomponent incompressible Ideal Gas model for reacting flows. * \author T. Economon, Cristopher Morales Ubal - * \version 8.4.0 "Harrier" + * \version 8.5.0 "Harrier" * * SU2 Project Website: https://su2code.github.io * * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * - * Copyright 2012-2024, SU2 Contributors (cf. AUTHORS.md) + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) * * SU2 is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -30,7 +30,7 @@ #include #include -#ifdef USE_CANTERA +#ifdef HAVE_CANTERA #include #include @@ -49,7 +49,7 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* Chemistry_Min_Temperature(config->GetCantera_DC_Min_Temp()), Correction_Velocity(config->GetCantera_Correction_Velocity()) { try { - sol = std::shared_ptr(newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model)); + sol = newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model); const auto& thermo = *sol->thermo(); const size_t nSpeciesMechanism = thermo.nSpecies(); @@ -70,12 +70,12 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* const string name = config->GetChemical_GasComposition(iVar); const size_t index = thermo.speciesIndex(name); if (index == npos) { - SU2_MPI::Error("Species '" + name + "' of GAS_COMPOSITION_NAMES is not part of phase '" + Phase_Name + + SU2_MPI::Error("Species '" + name + "' of CANTERA_SPECIES_NAMES is not part of phase '" + Phase_Name + "' in " + Chemical_MechanismFile + ".", CURRENT_FUNCTION); } if (std::find(speciesIndices.begin(), speciesIndices.begin() + iVar, index) != speciesIndices.begin() + iVar) { - SU2_MPI::Error("Species '" + name + "' appears more than once in GAS_COMPOSITION_NAMES.", CURRENT_FUNCTION); + SU2_MPI::Error("Species '" + name + "' appears more than once in CANTERA_SPECIES_NAMES.", CURRENT_FUNCTION); } speciesIndices[iVar] = index; } diff --git a/SU2_CFD/src/numerics/CNumerics.cpp b/SU2_CFD/src/numerics/CNumerics.cpp index 8f5b8f4c359d..6ec2831cd574 100644 --- a/SU2_CFD/src/numerics/CNumerics.cpp +++ b/SU2_CFD/src/numerics/CNumerics.cpp @@ -54,8 +54,7 @@ CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar, Prandtl_Turb = config->GetPrandtl_Turb(); Gas_Constant = config->GetGas_ConstantND(); energy_multicomponent = - (config->GetKind_FluidModel() == FLUID_MIXTURE || config->GetKind_FluidModel() == FLUID_CANTERA) && - config->GetEnergy_Equation(); + config->GetMulticomponentFluid() && config->GetEnergy_Equation(); tau = new su2double* [nDim]; for (iDim = 0; iDim < nDim; iDim++) diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index 653a98c5375d..45e4d2d2e10e 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -288,7 +288,7 @@ CSourceIncAxisymmetric_Flow::CSourceIncAxisymmetric_Flow(unsigned short val_nDim implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); energy = config->GetEnergy_Equation(); viscous = config->GetViscous(); - multicomponent = (config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA); + multicomponent = config->GetMulticomponentFluid(); } CNumerics::ResidualType<> CSourceIncAxisymmetric_Flow::ComputeResidual(const CConfig* config) { diff --git a/SU2_CFD/src/numerics/species/species_sources.cpp b/SU2_CFD/src/numerics/species/species_sources.cpp index 3ff41317e153..1d5fa5ba847c 100644 --- a/SU2_CFD/src/numerics/species/species_sources.cpp +++ b/SU2_CFD/src/numerics/species/species_sources.cpp @@ -135,18 +135,16 @@ CNumerics::ResidualType<> CSourceAxisymmetric_Species::ComputeResidual(const return ResidualType<>(residual, jacobian, nullptr); } -template -CSourceCombustion_Species::CSourceCombustion_Species(unsigned short val_nDim, unsigned short val_nVar, - const CConfig* config) +CSourceCombustion_Species::CSourceCombustion_Species(unsigned short val_nDim, unsigned short val_nVar, + const CConfig* config) : CSourceBase_Species(val_nDim, val_nVar, config), chemical_jacobian(config->GetKind_TimeIntScheme_Species() == EULER_IMPLICIT && config->GetChemical_Source_Jacobian()) { + Chemical_Source_Term_i = nullptr; Chemical_Source_Jacobian_i = nullptr; - Chemical_Source_Jacobian_j = nullptr; } -template -CNumerics::ResidualType<> CSourceCombustion_Species::ComputeResidual(const CConfig* config) { +CNumerics::ResidualType<> CSourceCombustion_Species::ComputeResidual(const CConfig* config) { /*--- Preaccumulation ---*/ AD::StartPreacc(); AD::SetPreaccIn(Volume); @@ -155,7 +153,7 @@ CNumerics::ResidualType<> CSourceCombustion_Species::ComputeResidual(const CC /*--- Initialization. ---*/ for (auto iVar = 0u; iVar < nVar; iVar++) { residual[iVar] = 0.0; - for (auto jVar = 0; jVar < nVar; jVar++) { + for (auto jVar = 0u; jVar < nVar; jVar++) { jacobian[iVar][jVar] = 0.0; } } @@ -180,6 +178,3 @@ CNumerics::ResidualType<> CSourceCombustion_Species::ComputeResidual(const CC template class CSourceAxisymmetric_Species >; template class CSourceAxisymmetric_Species >; template class CSourceAxisymmetric_Species >; -template class CSourceCombustion_Species >; -template class CSourceCombustion_Species >; -template class CSourceCombustion_Species >; diff --git a/SU2_CFD/src/output/CAdjFlowOutput.cpp b/SU2_CFD/src/output/CAdjFlowOutput.cpp index e5bd2920bf78..d80369a98a8c 100644 --- a/SU2_CFD/src/output/CAdjFlowOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowOutput.cpp @@ -57,11 +57,7 @@ void CAdjFlowOutput::AddHistoryOutputFields_AdjScalarRMS_RES(const CConfig* conf if (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) { for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - if(config->GetKind_FluidModel()==FLUID_CANTERA){ - AddHistoryOutput("RMS_ADJ_SPECIES_" + config->GetChemical_GasComposition(iVar), "rms[A_rho*Y_" + config->GetChemical_GasComposition(iVar) + "]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint transported species.", HistoryFieldType::RESIDUAL); - }else{ - AddHistoryOutput("RMS_ADJ_SPECIES_" + std::to_string(iVar), "rms[A_rho*Y_" + std::to_string(iVar) + "]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint transported species.", HistoryFieldType::RESIDUAL); - } + AddHistoryOutput("RMS_ADJ_SPECIES_" + config->GetSpecies_Label(iVar), "rms[A_rho*Y_" + config->GetSpecies_Label(iVar) + "]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint transported species.", HistoryFieldType::RESIDUAL); } } @@ -98,11 +94,7 @@ void CAdjFlowOutput::AddHistoryOutputFields_AdjScalarMAX_RES(const CConfig* conf if (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) { for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - if(config->GetKind_FluidModel()==FLUID_CANTERA){ - AddHistoryOutput("MAX_ADJ_SPECIES_" + config->GetChemical_GasComposition(iVar), "max[A_rho*Y_" + config->GetChemical_GasComposition(iVar) + "]",ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the adjoint transported species.", HistoryFieldType::RESIDUAL); - }else{ - AddHistoryOutput("MAX_ADJ_SPECIES_" + std::to_string(iVar), "max[A_rho*Y_" + std::to_string(iVar) + "]",ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the adjoint transported species.", HistoryFieldType::RESIDUAL); - } + AddHistoryOutput("MAX_ADJ_SPECIES_" + config->GetSpecies_Label(iVar), "max[A_rho*Y_" + config->GetSpecies_Label(iVar) + "]",ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the adjoint transported species.", HistoryFieldType::RESIDUAL); } } @@ -212,18 +204,10 @@ void CAdjFlowOutput::LoadHistoryDataAdjScalar(const CConfig* config, const CSolv if (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) { for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - if (config->GetKind_FluidModel() == FLUID_CANTERA) { - SetHistoryOutputValue("RMS_ADJ_SPECIES_" + config->GetChemical_GasComposition(iVar), log10(adjspecies_solver->GetRes_RMS(iVar))); - SetHistoryOutputValue("MAX_ADJ_SPECIES_" + config->GetChemical_GasComposition(iVar), log10(adjspecies_solver->GetRes_Max(iVar))); - if (multiZone) { - SetHistoryOutputValue("BGS_ADJ_SPECIES_" + config->GetChemical_GasComposition(iVar), log10(adjspecies_solver->GetRes_BGS(iVar))); - } - } else { - SetHistoryOutputValue("RMS_ADJ_SPECIES_" + std::to_string(iVar), log10(adjspecies_solver->GetRes_RMS(iVar))); - SetHistoryOutputValue("MAX_ADJ_SPECIES_" + std::to_string(iVar), log10(adjspecies_solver->GetRes_Max(iVar))); - if (multiZone) { - SetHistoryOutputValue("BGS_ADJ_SPECIES_" + std::to_string(iVar), log10(adjspecies_solver->GetRes_BGS(iVar))); - } + SetHistoryOutputValue("RMS_ADJ_SPECIES_" + config->GetSpecies_Label(iVar), log10(adjspecies_solver->GetRes_RMS(iVar))); + SetHistoryOutputValue("MAX_ADJ_SPECIES_" + config->GetSpecies_Label(iVar), log10(adjspecies_solver->GetRes_Max(iVar))); + if (multiZone) { + SetHistoryOutputValue("BGS_ADJ_SPECIES_" + config->GetSpecies_Label(iVar), log10(adjspecies_solver->GetRes_BGS(iVar))); } } diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 764550c0b3f1..1faa6e16b272 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -39,15 +39,6 @@ #include "../../include/variables/CPrimitiveIndices.hpp" #include "../../include/fluid/CCoolProp.hpp" -namespace { -/*--- Species label used in output field names: the Cantera species name, otherwise the index. ---*/ -std::string SpeciesOutputLabel(const CConfig* config, unsigned short iVar) { - return (config->GetKind_FluidModel() == FLUID_CANTERA) ? config->GetChemical_GasComposition(iVar) - : std::to_string(iVar); -} -} // namespace - - CFlowOutput::CFlowOutput(const CConfig *config, unsigned short nDim, bool fem_output) : CFVMOutput(config, nDim, fem_output), lastInnerIter(curInnerIter) { @@ -92,11 +83,7 @@ void CFlowOutput::AddAnalyzeSurfaceOutput(const CConfig *config){ if (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) { /// DESCRIPTION: Average Species for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - if(config->GetKind_FluidModel()==FLUID_CANTERA){ - AddHistoryOutput("SURFACE_SPECIES_" + config->GetChemical_GasComposition(iVar), "Avg_Species_" + config->GetChemical_GasComposition(iVar), ScreenOutputFormat::FIXED, "SPECIES_COEFF", "Total average species " + config->GetChemical_GasComposition(iVar) + " on all markers set in MARKER_ANALYZE", HistoryFieldType::COEFFICIENT); - }else{ - AddHistoryOutput("SURFACE_SPECIES_" + std::to_string(iVar), "Avg_Species_" + std::to_string(iVar), ScreenOutputFormat::FIXED, "SPECIES_COEFF", "Total average species " + std::to_string(iVar) + " on all markers set in MARKER_ANALYZE", HistoryFieldType::COEFFICIENT); - } + AddHistoryOutput("SURFACE_SPECIES_" + config->GetSpecies_Label(iVar), "Avg_Species_" + config->GetSpecies_Label(iVar), ScreenOutputFormat::FIXED, "SPECIES_COEFF", "Total average species " + config->GetSpecies_Label(iVar) + " on all markers set in MARKER_ANALYZE", HistoryFieldType::COEFFICIENT); } /// DESCRIPTION: Species Variance AddHistoryOutput("SURFACE_SPECIES_VARIANCE", "Species_Variance", ScreenOutputFormat::SCIENTIFIC, "SPECIES_COEFF", "Total species variance, measure for mixing quality. On all markers set in MARKER_ANALYZE", HistoryFieldType::COEFFICIENT); @@ -138,11 +125,7 @@ void CFlowOutput::AddAnalyzeSurfaceOutput(const CConfig *config){ if (config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT) { /// DESCRIPTION: Average Species for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - if(config->GetKind_FluidModel()==FLUID_CANTERA){ - AddHistoryOutputPerSurface("SURFACE_SPECIES_" + config->GetChemical_GasComposition(iVar), "Avg_Species_" + config->GetChemical_GasComposition(iVar), ScreenOutputFormat::FIXED, "SPECIES_COEFF_SURF", Marker_Analyze, HistoryFieldType::COEFFICIENT); - }else{ - AddHistoryOutputPerSurface("SURFACE_SPECIES_" + std::to_string(iVar), "Avg_Species_" + std::to_string(iVar), ScreenOutputFormat::FIXED, "SPECIES_COEFF_SURF", Marker_Analyze, HistoryFieldType::COEFFICIENT); - } + AddHistoryOutputPerSurface("SURFACE_SPECIES_" + config->GetSpecies_Label(iVar), "Avg_Species_" + config->GetSpecies_Label(iVar), ScreenOutputFormat::FIXED, "SPECIES_COEFF_SURF", Marker_Analyze, HistoryFieldType::COEFFICIENT); } /// DESCRIPTION: Species Variance AddHistoryOutputPerSurface("SURFACE_SPECIES_VARIANCE", "Species_Variance", ScreenOutputFormat::SCIENTIFIC, "SPECIES_COEFF_SURF", Marker_Analyze, HistoryFieldType::COEFFICIENT); @@ -522,12 +505,7 @@ void CFlowOutput::SetAnalyzeSurface(const CSolver* const*solver, const CGeometry if (species) { for (unsigned short iVar = 0; iVar < nSpecies; iVar++) { su2double Species = Surface_Species_Total(iMarker_Analyze, iVar); - if (config->GetKind_FluidModel() == FLUID_CANTERA) { - SetHistoryOutputPerSurfaceValue("SURFACE_SPECIES_" + config->GetChemical_GasComposition(iVar), Species, - iMarker_Analyze); - } else { - SetHistoryOutputPerSurfaceValue("SURFACE_SPECIES_" + std::to_string(iVar), Species, iMarker_Analyze); - } + SetHistoryOutputPerSurfaceValue("SURFACE_SPECIES_" + config->GetSpecies_Label(iVar), Species, iMarker_Analyze); Tot_Surface_Species[iVar] += Species; if (iVar == 0) config->SetSurface_Species_0(iMarker_Analyze, Species); @@ -564,11 +542,7 @@ void CFlowOutput::SetAnalyzeSurface(const CSolver* const*solver, const CGeometry SetHistoryOutputValue("SURFACE_TOTAL_PRESSURE", Tot_Surface_TotalPressure); if (species) { for (unsigned short iVar = 0; iVar < nSpecies; iVar++) { - if (config->GetKind_FluidModel() == FLUID_CANTERA) { - SetHistoryOutputValue("SURFACE_SPECIES_" + config->GetChemical_GasComposition(iVar), Tot_Surface_Species[iVar]); - } else { - SetHistoryOutputValue("SURFACE_SPECIES_" + std::to_string(iVar), Tot_Surface_Species[iVar]); - } + SetHistoryOutputValue("SURFACE_SPECIES_" + config->GetSpecies_Label(iVar), Tot_Surface_Species[iVar]); } SetAnalyzeSurfaceSpeciesVariance(solver, geometry, config, Surface_Species_Total, Surface_MassFlow_Abs_Total, @@ -1090,11 +1064,7 @@ void CFlowOutput::AddHistoryOutputFields_ScalarRMS_RES(const CConfig* config) { switch (config->GetKind_Species_Model()) { case SPECIES_MODEL::SPECIES_TRANSPORT: { for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - if (config->GetKind_FluidModel()==FLUID_CANTERA){ - AddHistoryOutput("RMS_SPECIES_" + config->GetChemical_GasComposition(iVar), "rms[rho*Y_" + config->GetChemical_GasComposition(iVar)+"]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of transported species.", HistoryFieldType::RESIDUAL); - }else{ - AddHistoryOutput("RMS_SPECIES_" + std::to_string(iVar), "rms[rho*Y_" + std::to_string(iVar)+"]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of transported species.", HistoryFieldType::RESIDUAL); - } + AddHistoryOutput("RMS_SPECIES_" + config->GetSpecies_Label(iVar), "rms[rho*Y_" + config->GetSpecies_Label(iVar)+"]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of transported species.", HistoryFieldType::RESIDUAL); } break; } @@ -1162,11 +1132,7 @@ void CFlowOutput::AddHistoryOutputFields_ScalarMAX_RES(const CConfig* config) { switch (config->GetKind_Species_Model()) { case SPECIES_MODEL::SPECIES_TRANSPORT: { for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - if (config->GetKind_FluidModel()==FLUID_CANTERA){ - AddHistoryOutput("MAX_SPECIES_" + config->GetChemical_GasComposition(iVar), "max[rho*Y_" + config->GetChemical_GasComposition(iVar)+"]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of transported species.", HistoryFieldType::RESIDUAL); - }else{ - AddHistoryOutput("MAX_SPECIES_" + std::to_string(iVar), "max[rho*Y_" + std::to_string(iVar)+"]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of transported species.", HistoryFieldType::RESIDUAL); - } + AddHistoryOutput("MAX_SPECIES_" + config->GetSpecies_Label(iVar), "max[rho*Y_" + config->GetSpecies_Label(iVar)+"]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of transported species.", HistoryFieldType::RESIDUAL); } break; } @@ -1230,11 +1196,7 @@ void CFlowOutput::AddHistoryOutputFields_ScalarBGS_RES(const CConfig* config) { switch (config->GetKind_Species_Model()) { case SPECIES_MODEL::SPECIES_TRANSPORT: { for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - if (config->GetKind_FluidModel()==FLUID_CANTERA){ - AddHistoryOutput("BGS_SPECIES_" + config->GetChemical_GasComposition(iVar), "bgs[rho*Y_" + config->GetChemical_GasComposition(iVar)+"]", ScreenOutputFormat::FIXED, "BGS_RES", "Maximum residual of transported species.", HistoryFieldType::RESIDUAL); - }else{ - AddHistoryOutput("BGS_SPECIES_" + std::to_string(iVar), "bgs[rho*Y_" + std::to_string(iVar)+"]", ScreenOutputFormat::FIXED, "BGS_RES", "Maximum residual of transported species.", HistoryFieldType::RESIDUAL); - } + AddHistoryOutput("BGS_SPECIES_" + config->GetSpecies_Label(iVar), "bgs[rho*Y_" + config->GetSpecies_Label(iVar)+"]", ScreenOutputFormat::FIXED, "BGS_RES", "Maximum residual of transported species.", HistoryFieldType::RESIDUAL); } break; } @@ -1347,18 +1309,10 @@ void CFlowOutput::LoadHistoryDataScalar(const CConfig* config, const CSolver* co switch(config->GetKind_Species_Model()) { case SPECIES_MODEL::SPECIES_TRANSPORT: { for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - if (config->GetKind_FluidModel()==FLUID_CANTERA){ - SetHistoryOutputValue("RMS_SPECIES_" + config->GetChemical_GasComposition(iVar), log10(solver[SPECIES_SOL]->GetRes_RMS(iVar))); - SetHistoryOutputValue("MAX_SPECIES_" + config->GetChemical_GasComposition(iVar), log10(solver[SPECIES_SOL]->GetRes_Max(iVar))); - if (multiZone) { - SetHistoryOutputValue("BGS_SPECIES_" + config->GetChemical_GasComposition(iVar), log10(solver[SPECIES_SOL]->GetRes_BGS(iVar))); - } - }else{ - SetHistoryOutputValue("RMS_SPECIES_" + std::to_string(iVar), log10(solver[SPECIES_SOL]->GetRes_RMS(iVar))); - SetHistoryOutputValue("MAX_SPECIES_" + std::to_string(iVar), log10(solver[SPECIES_SOL]->GetRes_Max(iVar))); - if (multiZone) { - SetHistoryOutputValue("BGS_SPECIES_" + std::to_string(iVar), log10(solver[SPECIES_SOL]->GetRes_BGS(iVar))); - } + SetHistoryOutputValue("RMS_SPECIES_" + config->GetSpecies_Label(iVar), log10(solver[SPECIES_SOL]->GetRes_RMS(iVar))); + SetHistoryOutputValue("MAX_SPECIES_" + config->GetSpecies_Label(iVar), log10(solver[SPECIES_SOL]->GetRes_Max(iVar))); + if (multiZone) { + SetHistoryOutputValue("BGS_SPECIES_" + config->GetSpecies_Label(iVar), log10(solver[SPECIES_SOL]->GetRes_BGS(iVar))); } } SetHistoryOutputValue("LINSOL_ITER_SPECIES", solver[SPECIES_SOL]->GetIterLinSolver()); @@ -1434,13 +1388,8 @@ void CFlowOutput::SetVolumeOutputFieldsScalarSolution(const CConfig* config){ switch (config->GetKind_Species_Model()) { case SPECIES_MODEL::SPECIES_TRANSPORT: for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - if (config->GetKind_FluidModel() == FLUID_CANTERA) { - AddVolumeOutput("SPECIES_" + config->GetChemical_GasComposition(iVar), "Species_" + config->GetChemical_GasComposition(iVar), "SOLUTION", - "Species_" + config->GetChemical_GasComposition(iVar) + " mass fraction"); - } else { - AddVolumeOutput("SPECIES_" + std::to_string(iVar), "Species_" + std::to_string(iVar), "SOLUTION", - "Species_" + std::to_string(iVar) + " mass fraction"); - } + AddVolumeOutput("SPECIES_" + config->GetSpecies_Label(iVar), "Species_" + config->GetSpecies_Label(iVar), "SOLUTION", + "Species_" + config->GetSpecies_Label(iVar) + " mass fraction"); } break; case SPECIES_MODEL::FLAMELET: { @@ -1491,13 +1440,7 @@ void CFlowOutput::SetVolumeOutputFieldsScalarResidual(const CConfig* config) { switch (config->GetKind_Species_Model()) { case SPECIES_MODEL::SPECIES_TRANSPORT: for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++){ - if (config->GetKind_FluidModel() == FLUID_CANTERA) { - AddVolumeOutput("RES_SPECIES_" + config->GetChemical_GasComposition(iVar), - "Residual_Species_" + config->GetChemical_GasComposition(iVar), "RESIDUAL", - "Residual of the transported species " + config->GetChemical_GasComposition(iVar)); - } else { - AddVolumeOutput("RES_SPECIES_" + std::to_string(iVar), "Residual_Species_" + std::to_string(iVar), "RESIDUAL", "Residual of the transported species " + std::to_string(iVar)); - } + AddVolumeOutput("RES_SPECIES_" + config->GetSpecies_Label(iVar), "Residual_Species_" + config->GetSpecies_Label(iVar), "RESIDUAL", "Residual of the transported species " + config->GetSpecies_Label(iVar)); } break; case SPECIES_MODEL::FLAMELET: { @@ -1554,7 +1497,7 @@ void CFlowOutput::SetVolumeOutputFieldsScalarLimiter(const CConfig* config) { switch (config->GetKind_Species_Model()) { case SPECIES_MODEL::SPECIES_TRANSPORT: for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) - AddVolumeOutput("LIMITER_SPECIES_" + SpeciesOutputLabel(config, iVar), "Limiter_Species_" + SpeciesOutputLabel(config, iVar), "LIMITER", "Limiter value of the transported species " + SpeciesOutputLabel(config, iVar)); + AddVolumeOutput("LIMITER_SPECIES_" + config->GetSpecies_Label(iVar), "Limiter_Species_" + config->GetSpecies_Label(iVar), "LIMITER", "Limiter value of the transported species " + config->GetSpecies_Label(iVar)); break; case SPECIES_MODEL::FLAMELET: { const auto& flamelet_config_options = config->GetFlameletParsedOptions(); @@ -1582,19 +1525,15 @@ void CFlowOutput::SetVolumeOutputFieldsScalarPrimitive(const CConfig* config) { switch (config->GetKind_Species_Model()) { case SPECIES_MODEL::SPECIES_TRANSPORT: for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++){ - if (config->GetKind_FluidModel() == FLUID_CANTERA) { - AddVolumeOutput("DIFFUSIVITY_" + config->GetChemical_GasComposition(iVar), "Diffusivity_" + config->GetChemical_GasComposition(iVar), "PRIMITIVE", - "Diffusivity of the transported species " + config->GetChemical_GasComposition(iVar)); - if (config->GetCombustion() == true) { - AddVolumeOutput("CHEMICAL_SOURCE_TERM_" + config->GetChemical_GasComposition(iVar), - "Chemical_Source_Term_" + config->GetChemical_GasComposition(iVar), "PRIMITIVE", - "Chemical source term of the transported species " + config->GetChemical_GasComposition(iVar)); - } - } else { - AddVolumeOutput("DIFFUSIVITY_" + std::to_string(iVar), "Diffusivity_" + std::to_string(iVar), "PRIMITIVE", "Diffusivity of the transported species " + std::to_string(iVar)); + AddVolumeOutput("DIFFUSIVITY_" + config->GetSpecies_Label(iVar), "Diffusivity_" + config->GetSpecies_Label(iVar), "PRIMITIVE", + "Diffusivity of the transported species " + config->GetSpecies_Label(iVar)); + if (config->GetCombustion()) { + AddVolumeOutput("CHEMICAL_SOURCE_TERM_" + config->GetSpecies_Label(iVar), + "Chemical_Source_Term_" + config->GetSpecies_Label(iVar), "PRIMITIVE", + "Chemical source term of the transported species " + config->GetSpecies_Label(iVar)); } } - if (config->GetCombustion() == true) + if (config->GetCombustion()) AddVolumeOutput("HEAT_RELEASE", "Heat_Release", "PRIMITIVE", "Heat release due to combustion"); break; default: @@ -1625,7 +1564,7 @@ void CFlowOutput::SetVolumeOutputFieldsScalarSource(const CConfig* config) { case SPECIES_MODEL::SPECIES_TRANSPORT: if (config->GetPyCustomSource()) { for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++){ - AddVolumeOutput("SPECIES_UDS_" + SpeciesOutputLabel(config, iVar), "Species_UDS_" + SpeciesOutputLabel(config, iVar), "SOURCE", "Species User Defined Source " + SpeciesOutputLabel(config, iVar)); + AddVolumeOutput("SPECIES_UDS_" + config->GetSpecies_Label(iVar), "Species_UDS_" + config->GetSpecies_Label(iVar), "SOURCE", "Species User Defined Source " + config->GetSpecies_Label(iVar)); } } break; @@ -1803,33 +1742,18 @@ void CFlowOutput::LoadVolumeDataScalar(const CConfig* config, const CSolver* con case SPECIES_MODEL::SPECIES_TRANSPORT: { const auto Node_Species = solver[SPECIES_SOL]->GetNodes(); for (unsigned short iVar = 0; iVar < config->GetnSpecies(); iVar++) { - if (config->GetKind_FluidModel() == FLUID_CANTERA) { - SetVolumeOutputValue("SPECIES_" + config->GetChemical_GasComposition(iVar), iPoint, Node_Species->GetSolution(iPoint, iVar)); - SetVolumeOutputValue("RES_SPECIES_" + config->GetChemical_GasComposition(iVar), iPoint, - solver[SPECIES_SOL]->LinSysRes(iPoint, iVar)); - SetVolumeOutputValue("DIFFUSIVITY_" + config->GetChemical_GasComposition(iVar), iPoint, - Node_Species->GetDiffusivity(iPoint, iVar)); - if (config->GetCombustion() == true) - SetVolumeOutputValue("CHEMICAL_SOURCE_TERM_" + config->GetChemical_GasComposition(iVar), iPoint, - Node_Species->GetChemicalSourceTerm(iPoint, iVar)); - if (config->GetKind_SlopeLimit_Species() != LIMITER::NONE) - SetVolumeOutputValue("LIMITER_SPECIES_" + config->GetChemical_GasComposition(iVar), iPoint, - Node_Species->GetLimiter(iPoint, iVar)); - if (config->GetPyCustomSource()) - SetVolumeOutputValue("SPECIES_UDS_" + config->GetChemical_GasComposition(iVar), iPoint, - Node_Species->GetUserDefinedSource()(iPoint, iVar)); - } else { - SetVolumeOutputValue("SPECIES_" + std::to_string(iVar), iPoint, Node_Species->GetSolution(iPoint, iVar)); - SetVolumeOutputValue("RES_SPECIES_" + std::to_string(iVar), iPoint, solver[SPECIES_SOL]->LinSysRes(iPoint, iVar)); - SetVolumeOutputValue("DIFFUSIVITY_" + std::to_string(iVar), iPoint, Node_Species->GetDiffusivity(iPoint, iVar)); - if (config->GetKind_SlopeLimit_Species() != LIMITER::NONE) - SetVolumeOutputValue("LIMITER_SPECIES_" + std::to_string(iVar), iPoint, Node_Species->GetLimiter(iPoint, iVar)); - if (config->GetPyCustomSource()) { - SetVolumeOutputValue("SPECIES_UDS_" + std::to_string(iVar), iPoint, Node_Species->GetUserDefinedSource()(iPoint, iVar)); - } - } + const auto label = config->GetSpecies_Label(iVar); + SetVolumeOutputValue("SPECIES_" + label, iPoint, Node_Species->GetSolution(iPoint, iVar)); + SetVolumeOutputValue("RES_SPECIES_" + label, iPoint, solver[SPECIES_SOL]->LinSysRes(iPoint, iVar)); + SetVolumeOutputValue("DIFFUSIVITY_" + label, iPoint, Node_Species->GetDiffusivity(iPoint, iVar)); + if (config->GetCombustion()) + SetVolumeOutputValue("CHEMICAL_SOURCE_TERM_" + label, iPoint, Node_Species->GetChemicalSourceTerm(iPoint, iVar)); + if (config->GetKind_SlopeLimit_Species() != LIMITER::NONE) + SetVolumeOutputValue("LIMITER_SPECIES_" + label, iPoint, Node_Species->GetLimiter(iPoint, iVar)); + if (config->GetPyCustomSource()) + SetVolumeOutputValue("SPECIES_UDS_" + label, iPoint, Node_Species->GetUserDefinedSource()(iPoint, iVar)); } - if (config->GetCombustion() == true) + if (config->GetCombustion()) SetVolumeOutputValue("HEAT_RELEASE", iPoint, Node_Species->GetHeatRelease(iPoint)); break; } diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index f1ef80a769bd..99ad61e089e2 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1420,7 +1420,7 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont const bool limiter = (config->GetKind_SlopeLimit_Flow() != LIMITER::NONE); const bool van_albada = (config->GetKind_SlopeLimit_Flow() == LIMITER::VAN_ALBADA_EDGE); const bool bounded_scalar = config->GetBounded_Scalar(); - const bool multicomponent = ((config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA)); + const bool multicomponent = config->GetMulticomponentFluid(); const su2double kappa = config->GetMUSCL_Kappa_Flow(); const su2double musclRamp = config->GetMUSCLRampValue() * config->GetNewtonKrylovRelaxation(); @@ -1493,11 +1493,14 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont Primitive_i[iVar] = V_i[iVar]; Primitive_j[iVar] = V_j[iVar]; } - if(multicomponent){ + /*--- A failed evaluation of the fluid state is a non-physical reconstruction, like a negative temperature. ---*/ + bool state_failed = false; + if (multicomponent) { const su2double* scalar_i = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint); const su2double* scalar_j = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(jPoint); - ComputeConsistentExtrapolation(GetFluidModel(), nDim, scalar_i, Primitive_i); - ComputeConsistentExtrapolation(GetFluidModel(), nDim, scalar_j, Primitive_j); + const bool failed_i = ComputeConsistentExtrapolation(GetFluidModel(), nDim, scalar_i, Primitive_i); + const bool failed_j = ComputeConsistentExtrapolation(GetFluidModel(), nDim, scalar_j, Primitive_j); + state_failed = failed_i || failed_j; } /*--- Check for non-physical solutions after reconstruction. If found, @@ -1507,14 +1510,17 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont incompressible flow, only the temperature and density need to be checked. Pressure is the dynamic pressure (can be negative). ---*/ - if (config->GetEnergy_Equation()) { - const bool neg_temperature_i = (Primitive_i[prim_idx.Temperature()] < 0.0); - const bool neg_temperature_j = (Primitive_j[prim_idx.Temperature()] < 0.0); + if (config->GetEnergy_Equation() || state_failed) { + bool bad_recon = state_failed; + if (config->GetEnergy_Equation()) { + const bool neg_temperature_i = (Primitive_i[prim_idx.Temperature()] < 0.0); + const bool neg_temperature_j = (Primitive_j[prim_idx.Temperature()] < 0.0); - const bool neg_density_i = (Primitive_i[prim_idx.Density()] < 0.0); - const bool neg_density_j = (Primitive_j[prim_idx.Density()] < 0.0); + const bool neg_density_i = (Primitive_i[prim_idx.Density()] < 0.0); + const bool neg_density_j = (Primitive_j[prim_idx.Density()] < 0.0); - bool bad_recon = neg_temperature_i || neg_temperature_j || neg_density_i || neg_density_j; + bad_recon = bad_recon || neg_temperature_i || neg_temperature_j || neg_density_i || neg_density_j; + } bad_recon = nodes->UpdateNonPhysicalEdgeCounter(iEdge, bad_recon); counter_local += bad_recon; @@ -1570,7 +1576,7 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont FinalizeResidualComputation(geometry, pausePreacc, counter_local, config); } -void CIncEulerSolver::ComputeConsistentExtrapolation(CFluidModel* fluidModel, unsigned short nDim, +bool CIncEulerSolver::ComputeConsistentExtrapolation(CFluidModel* fluidModel, unsigned short nDim, const su2double* scalar, su2double* primitive) { SU2_ZONE_SCOPED const CIncEulerVariable::CIndices prim_idx(nDim, 0); @@ -1581,8 +1587,7 @@ void CIncEulerSolver::ComputeConsistentExtrapolation(CFluidModel* fluidModel, un primitive[prim_idx.Temperature()] = fluidModel->GetTemperature(); primitive[prim_idx.Density()] = fluidModel->GetDensity(); - /*--- A failed state evaluation is flagged as non-physical so that the caller falls back to the cell values. ---*/ - if (fluidModel->GetStateFailed()) primitive[prim_idx.Temperature()] = -1.0; + return fluidModel->GetStateFailed(); } void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, @@ -1604,8 +1609,7 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont const bool energy = config->GetEnergy_Equation(); const bool streamwise_periodic = (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE); const bool streamwise_periodic_temperature = config->GetStreamwise_Periodic_Temperature(); - const bool multicomponent = - ((config->GetKind_FluidModel() == FLUID_MIXTURE) || (config->GetKind_FluidModel() == FLUID_CANTERA)); + const bool multicomponent = config->GetMulticomponentFluid(); AD::StartNoSharedReading(); @@ -2413,9 +2417,7 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain const bool implicit = config->GetKind_TimeIntScheme() == EULER_IMPLICIT; const bool viscous = config->GetViscous(); - const bool energy_multicomponent = - (config->GetKind_FluidModel() == FLUID_MIXTURE || config->GetKind_FluidModel() == FLUID_CANTERA) && - config->GetEnergy_Equation(); + const bool energy_multicomponent = config->GetMulticomponentFluid() && config->GetEnergy_Equation(); const bool species_model = config->GetKind_Species_Model() != SPECIES_MODEL::NONE; su2double Normal[MAXNDIM] = {0.0}; @@ -2611,9 +2613,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool viscous = config->GetViscous(); - const bool energy_multicomponent = - (config->GetKind_FluidModel() == FLUID_MIXTURE || config->GetKind_FluidModel() == FLUID_CANTERA) && - config->GetEnergy_Equation(); + const bool energy_multicomponent = config->GetMulticomponentFluid() && config->GetEnergy_Equation(); const bool species_model = config->GetKind_Species_Model() != SPECIES_MODEL::NONE; string Marker_Tag = config->GetMarker_All_TagBound(val_marker); @@ -2903,9 +2903,7 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool viscous = config->GetViscous(); - const bool energy_multicomponent = - (config->GetKind_FluidModel() == FLUID_MIXTURE || config->GetKind_FluidModel() == FLUID_CANTERA) && - config->GetEnergy_Equation(); + const bool energy_multicomponent = config->GetMulticomponentFluid() && config->GetEnergy_Equation(); string Marker_Tag = config->GetMarker_All_TagBound(val_marker); su2double Normal[MAXNDIM] = {0.0}; diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 372820842806..31d7f0f2e7db 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -27,7 +27,6 @@ #include "../../include/solvers/CIncNSSolver.hpp" #include "../../include/variables/CIncNSVariable.hpp" -#include "../../include/variables/CSpeciesVariable.hpp" #include "../../../Common/include/toolboxes/printing_toolbox.hpp" #include "../../include/solvers/CFVMFlowSolverBase.inl" @@ -58,8 +57,7 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short } if (config->GetCombustion()) flamelet_config_options = config->GetFlameletParsedOptions(); - if ((config->GetKind_FluidModel() == FLUID_MIXTURE || config->GetKind_FluidModel() == FLUID_CANTERA) && - config->GetEnergy_Equation()) { + if (config->GetMulticomponentFluid() && config->GetEnergy_Equation()) { EnthalpyDiffusion.resize(nPoint, config->GetnSpecies()) = su2double(0.0); GradEnthalpyDiffusion.resize(nPoint, config->GetnSpecies()) = su2double(0.0); } @@ -86,18 +84,7 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container /*--- Setting temperature, enthalpy and thermophysical properties for ignition in reacting flows. ---*/ if (energy && combustion) { - bool ignition = false; - su2double spark_radius_squared = 0.0; - - /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ - if (flamelet_config_options.ignition_method == FLAMELET_INIT_TYPE::SPARK) { - const auto& spark_init = flamelet_config_options.spark_init; - const unsigned long spark_iter_start = ceil(spark_init[4]); - const unsigned long spark_duration = ceil(spark_init[5]); - const unsigned long iter = config->GetIgnitionIter(); - ignition = ((iter >= spark_iter_start) && (iter <= (spark_iter_start + spark_duration))); - spark_radius_squared = spark_init[3] * spark_init[3]; - } + const bool ignition = flamelet_config_options.SparkActive(config->GetIgnitionIter()); SU2_OMP_SAFE_GLOBAL_ACCESS(config->SetGlobalParam(config->GetKind_Solver(), RunTime_EqSystem);) @@ -106,9 +93,7 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container SU2_OMP_FOR_STAT(omp_chunk_size) for (auto i_point = 0u; i_point < nPoint; i_point++) { /*--- Apply ignition temperature within spark radius. ---*/ - const su2double dist_from_center = GeometryToolbox::SquaredDistance( - nDim, geometry->nodes->GetCoord(i_point), flamelet_config_options.spark_init.data()); - if (dist_from_center < spark_radius_squared) { + if (flamelet_config_options.InSpark(nDim, geometry->nodes->GetCoord(i_point))) { /*--- Retrieve scalars solution. ---*/ su2double* scalars = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(i_point); /*--- Set high temperature for ignition. ---*/ @@ -338,9 +323,7 @@ void CIncNSSolver::Compute_Streamwise_Periodic_Recovered_Values(CConfig *config, CNumerics::ResidualType<> CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config) { - const bool energy_multicomponent = - (config->GetKind_FluidModel() == FLUID_MIXTURE || config->GetKind_FluidModel() == FLUID_CANTERA) && - config->GetEnergy_Equation(); + const bool energy_multicomponent = config->GetMulticomponentFluid() && config->GetEnergy_Equation(); /*--- Contribution to heat flux due to enthalpy diffusion for multicomponent and reacting flows ---*/ if (energy_multicomponent) { @@ -413,9 +396,10 @@ void CIncNSSolver::ComputeEnthalpyDiffusionTerms(CSolver** solver_container, con CVariable* speciesNodes = solver_container[SPECIES_SOL]->GetNodes(); const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - /*--- The species solver reads the mass diffusivities evaluated here instead of computing them again. ---*/ - const bool share_diffusivity = (config->GetKind_FluidModel() == FLUID_CANTERA); - auto* species = share_diffusivity ? su2staticcast_p(speciesNodes) : nullptr; + /*--- Mass diffusivities are evaluated here and stored in the flow variables, from where the species solver copies + * them (CSpeciesSolver::Preprocessing), instead of being computed again. ---*/ + const bool store_diffusivity = (config->GetKind_FluidModel() == FLUID_CANTERA); + auto* flowNodes = static_cast(nodes); const unsigned short nSpecies = config->GetnSpecies(); SU2_OMP_FOR_STAT(omp_chunk_size) @@ -424,9 +408,9 @@ void CIncNSSolver::ComputeEnthalpyDiffusionTerms(CSolver** solver_container, con fluid_model->SetEddyViscosity(nodes->GetPrimitive(iPoint)[prim_idx.EddyViscosity()]); fluid_model->GetEnthalpyDiffusivity(EnthalpyDiffusion[iPoint]); if (implicit) fluid_model->GetGradEnthalpyDiffusivity(GradEnthalpyDiffusion[iPoint]); - if (share_diffusivity) { + if (store_diffusivity) { for (unsigned short iVar = 0; iVar <= nSpecies; iVar++) - species->SetDiffusivity(iPoint, fluid_model->GetMassDiffusivity(iVar), iVar); + flowNodes->SetMassDiffusivity(iPoint, fluid_model->GetMassDiffusivity(iVar), iVar); } } END_SU2_OMP_FOR diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index 9049191aa824..db41916f3561 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -110,7 +110,8 @@ void CSpeciesSolver::Initialize(CGeometry* geometry, CConfig* config, unsigned s nPrimVar = nVar; if (nVar > MAXNVAR) - SU2_MPI::Error("The number of species equations exceeds MAX_TRANSPORTED_SPECIES.", CURRENT_FUNCTION); + SU2_MPI::Error("The number of species equations exceeds MAX_TRANSPORTED_SPECIES. Increase it in\n" + "Common/include/option_structure.hpp and recompile.", CURRENT_FUNCTION); nPoint = geometry->GetnPoint(); nPointDomain = geometry->GetnPointDomain(); @@ -320,39 +321,31 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain bool Output) { SU2_ZONE_SCOPED const bool combustion = config->GetCombustion(); - bool ignition = false; - su2double spark_radius_squared = 0.0; - - /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ - if (flamelet_config_options.ignition_method == FLAMELET_INIT_TYPE::SPARK) { - const auto& spark_init = flamelet_config_options.spark_init; - const unsigned long spark_iter_start = ceil(spark_init[4]); - const unsigned long spark_duration = ceil(spark_init[5]); - const unsigned long iter = config->GetIgnitionIter(); - ignition = ((iter >= spark_iter_start) && (iter <= (spark_iter_start + spark_duration))); - spark_radius_squared = spark_init[3] * spark_init[3]; - } + const bool ignition = flamelet_config_options.SparkActive(config->GetIgnitionIter()); SU2_OMP_SAFE_GLOBAL_ACCESS(config->SetGlobalParam(config->GetKind_Solver(), RunTime_EqSystem);) CFluidModel* fluid_model = solver_container[FLOW_SOL]->GetFluidModel(); fluid_model->SetMassDiffusivityModel(config); - /*--- The flow solver evaluates the Cantera mass diffusivities together with the enthalpy diffusion. ---*/ + /*--- The flow solver evaluates the Cantera mass diffusivities together with the enthalpy diffusion + * (CIncNSSolver::ComputeEnthalpyDiffusionTerms) and stores them in its variables. ---*/ const bool diffusivity_from_flow = (config->GetKind_FluidModel() == FLUID_CANTERA) && config->GetEnergy_Equation(); + const CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes(); /*--- Set the laminar mass Diffusivity and chemical source term for the species solver. ---*/ SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0u; iPoint < nPoint; iPoint++) { /*--- Chemical source terms are only used by the residual of the points owned by this rank. ---*/ const bool chemistry = combustion && (iPoint < nPointDomain); - if (diffusivity_from_flow && !chemistry) continue; + if (diffusivity_from_flow) { + for (auto iVar = 0u; iVar <= nVar; iVar++) nodes->SetDiffusivity(iPoint, flowNodes->GetDiffusivity(iPoint, iVar), iVar); + if (!chemistry) continue; + } su2double temperature = solver_container[FLOW_SOL]->GetNodes()->GetTemperature(iPoint); - if (ignition) { + if (ignition && flamelet_config_options.InSpark(nDim, geometry->nodes->GetCoord(iPoint))) { /*--- Apply ignition temperature within spark radius. ---*/ - const su2double dist_from_center = GeometryToolbox::SquaredDistance( - nDim, geometry->nodes->GetCoord(iPoint), flamelet_config_options.spark_init.data()); - if (dist_from_center < spark_radius_squared) temperature = config->GetSpark_Temperature(); + temperature = config->GetSpark_Temperature(); } const su2double* scalar = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint); fluid_model->SetTDState_T(temperature, scalar); @@ -659,7 +652,7 @@ void CSpeciesSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool axisymmetric = config->GetAxisymmetric(); - const bool combustion =config->GetCombustion(); + const bool combustion = config->GetCombustion(); if (axisymmetric) { CNumerics *numerics = numerics_container[SOURCE_FIRST_TERM + omp_get_thread_num()*MAX_TERMS]; @@ -717,8 +710,8 @@ void CSpeciesSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta for (auto iPoint = 0u; iPoint < nPointDomain; iPoint++) { /*--- Set Chemical Source Term ---*/ - numerics->SetChemicalSourceTerm(nodes->GetChemicalSourceTerm(iPoint), nullptr); - numerics->SetChemicalSourceJacobian(nodes->GetChemicalSourceJacobian(iPoint), nullptr); + numerics->SetChemicalSourceTerm(nodes->GetChemicalSourceTerm(iPoint)); + numerics->SetChemicalSourceJacobian(nodes->GetChemicalSourceJacobian(iPoint)); /*--- Set volume of the dual cell. ---*/ diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index 706a6be1f8fa..57080c5e8d5b 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -39,6 +39,7 @@ CIncNSVariable::CIncNSVariable(su2double pressure, const su2double *velocity, su DES_LengthScale.resize(nPoint) = su2double(0.0); lesMode.resize(nPoint) = su2double(0.0); Max_Lambda_Visc.resize(nPoint); + if (config->GetKind_FluidModel() == FLUID_CANTERA) MassDiffusivity.resize(nPoint, config->GetnSpecies() + 1) = su2double(0.0); /*--- Allocate memory for the AuxVar and its gradient. See e.g. CIncEulerSolver::Source_Residual: * Axisymmetric: total-viscosity * y-vel / y-coord * Streamwise Periodic: eddy viscosity (mu_t) ---*/ diff --git a/SU2_PY/SU2/io/historyMap.py b/SU2_PY/SU2/io/historyMap.py index 809d0463854d..fdab20449f1f 100644 --- a/SU2_PY/SU2/io/historyMap.py +++ b/SU2_PY/SU2/io/historyMap.py @@ -238,16 +238,10 @@ "HEADER": "bgs[P]", "TYPE": "RESIDUAL", }, - 'BGS_SPECIES_" + std::to_string(iVar': { + 'BGS_SPECIES_" + config->GetSpecies_Label(iVar': { "DESCRIPTION": "BGS residual of " "transported species.", "GROUP": "BGS_RES", - "HEADER": 'bgs[rho*Y_" + ' 'std::to_string(iVar)+"]', - "TYPE": "RESIDUAL", - }, - 'BGS_SPECIES_" + config->GetChemical_GasComposition(iVar': { - "DESCRIPTION": "BGS residual of " "transported species.", - "GROUP": "BGS_RES", - "HEADER": 'bgs[rho*Y_" + ' 'config->GetChemical_GasComposition(iVar)+"]', + "HEADER": 'bgs[rho*Y_" + ' 'config->GetSpecies_Label(iVar)+"]', "TYPE": "RESIDUAL", }, "BGS_TEMPERATURE": { @@ -587,10 +581,10 @@ "HEADER": "d[Secondary_Over_Uniformity]", "TYPE": "D_COEFFICIENT", }, - 'D_SURFACE_SPECIES_" + std::to_string(iVar': { + 'D_SURFACE_SPECIES_" + config->GetSpecies_Label(iVar': { "DESCRIPTION": "Derivative " "value", "GROUP": "D_SPECIES_COEFF", - "HEADER": 'd[Avg_Species_" + ' "std::to_string(iVar]", + "HEADER": 'd[Avg_Species_" + ' "config->GetSpecies_Label(iVar]", "TYPE": "D_COEFFICIENT", }, "D_SURFACE_STATIC_PRESSURE": { @@ -816,16 +810,10 @@ "HEADER": "max[A_Rho]", "TYPE": "RESIDUAL", }, - 'MAX_ADJ_SPECIES_" + std::to_string(iVar': { - "DESCRIPTION": "Maximum residual " "of the adjoint " "transported " "species.", - "GROUP": "MAX_RES", - "HEADER": 'max[A_rho*Y_" + ' "std::to_string(iVar) + " '"]', - "TYPE": "RESIDUAL", - }, - 'MAX_ADJ_SPECIES_" + config->GetChemical_GasComposition(iVar': { + 'MAX_ADJ_SPECIES_" + config->GetSpecies_Label(iVar': { "DESCRIPTION": "Maximum residual " "of the adjoint " "transported " "species.", "GROUP": "MAX_RES", - "HEADER": 'max[A_rho*Y_" + ' "config->GetChemical_GasComposition(iVar) + " '"]', + "HEADER": 'max[A_rho*Y_" + ' "config->GetSpecies_Label(iVar) + " '"]', "TYPE": "RESIDUAL", }, "MAX_ADJ_TEMPERATURE": { @@ -918,16 +906,10 @@ "HEADER": "max[P]", "TYPE": "RESIDUAL", }, - 'MAX_SPECIES_" + config->GetChemical_GasComposition(iVar': { + 'MAX_SPECIES_" + config->GetSpecies_Label(iVar': { "DESCRIPTION": "Maximum residual of " "transported species.", "GROUP": "MAX_RES", - "HEADER": 'max[rho*Y_" + ' 'config->GetChemical_GasComposition(iVar)+"]', - "TYPE": "RESIDUAL", - }, - 'MAX_SPECIES_" + std::to_string(iVar': { - "DESCRIPTION": "Maximum residual of " "transported species.", - "GROUP": "MAX_RES", - "HEADER": 'max[rho*Y_" + ' 'std::to_string(iVar)+"]', + "HEADER": 'max[rho*Y_" + ' 'config->GetSpecies_Label(iVar)+"]', "TYPE": "RESIDUAL", }, "MAX_TEMPERATURE": { @@ -1075,24 +1057,14 @@ "HEADER": "rms[A_P1]", "TYPE": "RESIDUAL", }, - 'RMS_ADJ_SPECIES_" + std::to_string(iVar': { - "DESCRIPTION": "Root-mean square " - "residual of the " - "adjoint " - "transported " - "species.", - "GROUP": "RMS_RES", - "HEADER": 'rms[A_rho*Y_" + ' "std::to_string(iVar) + " '"]', - "TYPE": "RESIDUAL", - }, - 'RMS_ADJ_SPECIES_" + config->GetChemical_GasComposition(iVar': { + 'RMS_ADJ_SPECIES_" + config->GetSpecies_Label(iVar': { "DESCRIPTION": "Root-mean square " "residual of the " "adjoint " "transported " "species.", "GROUP": "RMS_RES", - "HEADER": 'rms[A_rho*Y_" + ' "config->GetChemical_GasComposition(iVar) + " '"]', + "HEADER": 'rms[A_rho*Y_" + ' "config->GetSpecies_Label(iVar) + " '"]', "TYPE": "RESIDUAL", }, "RMS_ADJ_TEMPERATURE": { @@ -1206,16 +1178,10 @@ "HEADER": "rms[R]", "TYPE": "RESIDUAL", }, - 'RMS_SPECIES_" + std::to_string(iVar': { - "DESCRIPTION": "Root-mean square " "residual of " "transported species.", - "GROUP": "RMS_RES", - "HEADER": 'rms[rho*Y_" + ' 'std::to_string(iVar)+"]', - "TYPE": "RESIDUAL", - }, - 'RMS_SPECIES_" + config->GetChemical_GasComposition(iVar': { + 'RMS_SPECIES_" + config->GetSpecies_Label(iVar': { "DESCRIPTION": "Root-mean square " "residual of " "transported species.", "GROUP": "RMS_RES", - "HEADER": 'rms[rho*Y_" + ' 'config->GetChemical_GasComposition(iVar)+"]', + "HEADER": 'rms[rho*Y_" + ' 'config->GetSpecies_Label(iVar)+"]', "TYPE": "RESIDUAL", }, "RMS_TEMPERATURE": { @@ -1390,26 +1356,15 @@ "HEADER": "Secondary_Over_Uniformity", "TYPE": "COEFFICIENT", }, - 'SURFACE_SPECIES_" + std::to_string(iVar': { - "DESCRIPTION": "Total average " - 'species " + ' - "std::to_string(iVar) " - '+ " on all ' - "markers set in " - "MARKER_ANALYZE", - "GROUP": "SPECIES_COEFF", - "HEADER": 'Avg_Species_" + ' "std::to_string(iVar", - "TYPE": "COEFFICIENT", - }, - 'SURFACE_SPECIES_" + config->GetChemical_GasComposition(iVar': { + 'SURFACE_SPECIES_" + config->GetSpecies_Label(iVar': { "DESCRIPTION": "Total average " 'species " + ' - "std::to_string(iVar) " + "config->GetSpecies_Label(iVar) " '+ " on all ' "markers set in " "MARKER_ANALYZE", "GROUP": "SPECIES_COEFF", - "HEADER": 'Avg_Species_" + ' "config->GetChemical_GasComposition(iVar", + "HEADER": 'Avg_Species_" + ' "config->GetSpecies_Label(iVar", "TYPE": "COEFFICIENT", }, "SURFACE_SPECIES_VARIANCE": { @@ -1735,10 +1690,10 @@ "HEADER": "dtavg[Secondary_Over_Uniformity]", "TYPE": "TAVG_D_COEFFICIENT", }, - 'TAVG_D_SURFACE_SPECIES_" + std::to_string(iVar': { + 'TAVG_D_SURFACE_SPECIES_" + config->GetSpecies_Label(iVar': { "DESCRIPTION": "weighted " "time " "average " "derivative " "value", "GROUP": "TAVG_D_SPECIES_COEFF", - "HEADER": 'dtavg[Avg_Species_" ' "+ " "std::to_string(iVar]", + "HEADER": 'dtavg[Avg_Species_" ' "+ " "config->GetSpecies_Label(iVar]", "TYPE": "TAVG_D_COEFFICIENT", }, "TAVG_D_SURFACE_STATIC_PRESSURE": { @@ -1981,10 +1936,10 @@ "HEADER": "tavg[Secondary_Over_Uniformity]", "TYPE": "TAVG_COEFFICIENT", }, - 'TAVG_SURFACE_SPECIES_" + std::to_string(iVar': { + 'TAVG_SURFACE_SPECIES_" + config->GetSpecies_Label(iVar': { "DESCRIPTION": "weighted " "time average " "value", "GROUP": "TAVG_SPECIES_COEFF", - "HEADER": 'tavg[Avg_Species_" ' "+ " "std::to_string(iVar]", + "HEADER": 'tavg[Avg_Species_" ' "+ " "config->GetSpecies_Label(iVar]", "TYPE": "TAVG_COEFFICIENT", }, "TAVG_SURFACE_STATIC_PRESSURE": { diff --git a/TestCases/combustion/1step_methane_air/2d_slit_burner_fluid.cfg b/TestCases/combustion/1step_methane_air/2d_slit_burner_fluid.cfg index e31e7f3734b4..60b86beced88 100644 --- a/TestCases/combustion/1step_methane_air/2d_slit_burner_fluid.cfg +++ b/TestCases/combustion/1step_methane_air/2d_slit_burner_fluid.cfg @@ -5,7 +5,7 @@ % Author: Cristopher Morales Ubal % % Institution: Eindhoven University of Technology % % Date: 2024/06/27 % -% File Version 8.0.0 "Harrier" % +% File Version 8.5.0 "Harrier" % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -29,18 +29,18 @@ INC_NONDIM= DIMENSIONAL % -------------------- FLUID MODEL --------------------------------------- % % FLUID_MODEL= FLUID_CANTERA -COMBUSTION = YES +CANTERA_COMBUSTION = YES VISCOSITY_MODEL= CANTERA CONDUCTIVITY_MODEL= CANTERA % -GAS_COMPOSITION_NAMES= O2, H2O, CH4, CO2, N2 +CANTERA_SPECIES_NAMES= O2, H2O, CH4, CO2, N2 %H2, H, O, O2, OH, H2O, HO2, H2O2, AR, N2 -CHEMICAL_MECHANISM_FILE= 1S_CH4_MP1.yaml %h2o2.yaml +CANTERA_MECHANISM_FILE= 1S_CH4_MP1.yaml %h2o2.yaml -PHASE_NAME= CH4_MP1_mix +CANTERA_PHASE_NAME= CH4_MP1_mix %ohmech -TRANSPORT_MODEL= unity-Lewis-number +CANTERA_TRANSPORT_MODEL= unity-Lewis-number %mixture-averaged % multicomponent % unity-Lewis-number % % -------------------- SCALAR TRANSPORT ---------------------------------------% @@ -58,7 +58,7 @@ SPARK_INIT= (0.0, 0.002, 0.0, 1e-3, 100, 50) % (0.0, 0.002, 0.0, 1e-3, 600, 300) % Controlling variable source terms applied within the spark sphere for the spark % duration. -SPARK_TEMPERATURE= 1200 +CANTERA_SPARK_TEMPERATURE= 1200 %1400 1200 %1500 % equivalence ratio phi=0.8 SPECIES_INIT= 0.222598, 0.0, 0.044642, 0.0 diff --git a/TestCases/combustion/h2o2_hydrogen_air/2d_slit_burner_h2.cfg b/TestCases/combustion/h2o2_hydrogen_air/2d_slit_burner_h2.cfg index 92b77f480623..884fbb289478 100644 --- a/TestCases/combustion/h2o2_hydrogen_air/2d_slit_burner_h2.cfg +++ b/TestCases/combustion/h2o2_hydrogen_air/2d_slit_burner_h2.cfg @@ -29,19 +29,19 @@ INC_NONDIM= DIMENSIONAL % -------------------- FLUID MODEL --------------------------------------- % % FLUID_MODEL= FLUID_CANTERA -COMBUSTION= YES +CANTERA_COMBUSTION= YES CANTERA_CORRECTION_VELOCITY= YES -CHEMICAL_SOURCE_JACOBIAN= YES +CANTERA_SOURCE_JACOBIAN= YES CANTERA_DC_MIN_TEMP= 500 VISCOSITY_MODEL= CANTERA CONDUCTIVITY_MODEL= CANTERA % -GAS_COMPOSITION_NAMES= H2, H, O, O2, OH, H2O, HO2, H2O2, AR, N2 +CANTERA_SPECIES_NAMES= H2, H, O, O2, OH, H2O, HO2, H2O2, AR, N2 -CHEMICAL_MECHANISM_FILE= h2o2.yaml +CANTERA_MECHANISM_FILE= h2o2.yaml -PHASE_NAME= ohmech -TRANSPORT_MODEL= mixture-averaged +CANTERA_PHASE_NAME= ohmech +CANTERA_TRANSPORT_MODEL= mixture-averaged % % -------------------- SCALAR TRANSPORT ---------------------------------------% @@ -59,7 +59,7 @@ SPARK_INIT= (0.0, 0.002, 0.0, 1e-3, 20, 30) % (0.0, 0.002, 0.0, 1e-3, 600, 300) % Controlling variable source terms applied within the spark sphere for the spark % duration. -SPARK_TEMPERATURE= 1500 +CANTERA_SPARK_TEMPERATURE= 1500 %1400 1200 %1500 % equivalence ratio phi=0.6, mass fractions H2, H, O, O2, OH, H2O, HO2, H2O2, AR SPECIES_INIT= 0.017311, 0.0, 0.0, 0.228966, 0.0, 0.0, 0.0, 0.0, 0.0 diff --git a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg index befcbaeca56b..d3b41922d199 100644 --- a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg +++ b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_CANTERA.cfg @@ -7,7 +7,7 @@ % Author: Cristopher Morales Ubal % % Institution: Eindhoven University of Technology % % Date: 2026/01/19 % -% File Version 8.4.0 "Harrier" % +% File Version 8.5.0 "Harrier" % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -31,7 +31,7 @@ INC_NONDIM= DIMENSIONAL % -------------------- FLUID PROPERTIES ------------------------------------- % % FLUID_MODEL= FLUID_CANTERA -COMBUSTION = NO +CANTERA_COMBUSTION = NO % THERMODYNAMIC_PRESSURE= 101325.0 % @@ -39,10 +39,10 @@ CONDUCTIVITY_MODEL= CANTERA % TURBULENT_CONDUCTIVITY_MODEL= NONE % -GAS_COMPOSITION_NAMES= H2, O2 -CHEMICAL_MECHANISM_FILE= h2o2.yaml -PHASE_NAME= ohmech -TRANSPORT_MODEL= mixture-averaged +CANTERA_SPECIES_NAMES= H2, O2 +CANTERA_MECHANISM_FILE= h2o2.yaml +CANTERA_PHASE_NAME= ohmech +CANTERA_TRANSPORT_MODEL= mixture-averaged % VISCOSITY_MODEL= CANTERA % diff --git a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp index 6a7917392cec..1a69fb9d3c3a 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp @@ -2,14 +2,14 @@ * \file CFluidCantera_tests.cpp * \brief Unit tests for Cantera fluid model. * \author C.Morales Ubal - * \version 8.4.0 "Harrier" + * \version 8.5.0 "Harrier" * * SU2 Project Website: https://su2code.github.io * * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * - * Copyright 2012-2024, SU2 Contributors (cf. AUTHORS.md) + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) * * SU2 is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -29,37 +29,30 @@ #include -#if defined(HAVE_CANTERA) -#define USE_CANTERA +#ifdef HAVE_CANTERA #include "../../../SU2_CFD/include/fluid/CFluidCantera.hpp" #include using namespace Cantera; -#endif -#ifdef USE_CANTERA TEST_CASE("Fluid_Cantera", "[Multicomponent_flow]") { /*--- Cantera fluid model unit test cases. ---*/ SU2_COMPONENT val_software = SU2_COMPONENT::SU2_CFD; - CConfig* config = new CConfig("multicomponent_cantera.cfg", val_software, true); - CFluidCantera* auxFluidModel = nullptr; + CConfig config("multicomponent_cantera.cfg", val_software, true); /*--- Create Cantera fluid model. ---*/ - su2double value_pressure_operating = config->GetPressure_Thermodynamic(); - auxFluidModel = new CFluidCantera(value_pressure_operating, config); + CFluidCantera fluid(config.GetPressure_Thermodynamic(), &config); - /*--- Get scalar from config file and set temperature. ---*/ - const su2double* scalar = nullptr; - scalar = config->GetSpecies_Init(); + /*--- Set state using the scalars of the config file and the temperature. ---*/ + const su2double* scalar = config.GetSpecies_Init(); const su2double Temperature = 300.0; - /*--- Set state using temperature and scalar. ---*/ - auxFluidModel->SetTDState_T(Temperature, scalar); + fluid.SetTDState_T(Temperature, scalar); /*--- Check values for density and heat capacity. ---*/ - su2double density = auxFluidModel->GetDensity(); - su2double cp = auxFluidModel->GetCp(); + su2double density = fluid.GetDensity(); + su2double cp = fluid.GetCp(); CHECK(density == Approx(0.924236)); CHECK(cp == Approx(1277.91)); } @@ -67,28 +60,23 @@ TEST_CASE("Fluid_Cantera_Combustion", "[Reacting_flow]") { /*--- Cantera fluid model unit test cases. ---*/ SU2_COMPONENT val_software = SU2_COMPONENT::SU2_CFD; - CConfig* config = new CConfig("multicomponent_cantera.cfg", val_software, true); - CFluidCantera* auxFluidModel = nullptr; + CConfig config("multicomponent_cantera.cfg", val_software, true); /*--- Create Cantera fluid model. ---*/ - su2double value_pressure_operating = config->GetPressure_Thermodynamic(); - auxFluidModel = new CFluidCantera(value_pressure_operating, config); - - /*--- Get scalar from config file and set temperature. ---*/ + CFluidCantera fluid(config.GetPressure_Thermodynamic(), &config); - const su2double* scalar = nullptr; - scalar = config->GetSpecies_Init(); + /*--- Set state using the scalars of the config file and the temperature. ---*/ + const su2double* scalar = config.GetSpecies_Init(); const su2double Temperature = 1900.0; - /*--- Set state using temperature and scalar ---*/ - auxFluidModel->SetTDState_T(Temperature, scalar); + fluid.SetTDState_T(Temperature, scalar); /*--- Compute chemical source terms. ---*/ - auxFluidModel->ComputeChemicalSourceTerm(); + fluid.ComputeChemicalSourceTerm(); /*--- Check values for source terms. ---*/ - su2double sourceTerm_H2 = auxFluidModel->GetChemicalSourceTerm(0); - su2double sourceTerm_O2 = auxFluidModel->GetChemicalSourceTerm(1); + su2double sourceTerm_H2 = fluid.GetChemicalSourceTerm(0); + su2double sourceTerm_O2 = fluid.GetChemicalSourceTerm(1); CHECK(sourceTerm_H2 == Approx(-0.13633797171426)); CHECK(sourceTerm_O2 == Approx(-2.16321066087493)); } diff --git a/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg b/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg index dc4a9dc4c3bb..57ca5db7665c 100644 --- a/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg +++ b/UnitTests/SU2_CFD/fluid/multicomponent_cantera.cfg @@ -5,7 +5,7 @@ % Author: Cristopher Morales Ubal % % Institution: Eindhoven University of Technology % % Date: 2024/10/01 % -% File Version 8.1.0 "Harrier" % +% File Version 8.5.0 "Harrier" % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -22,16 +22,16 @@ INC_NONDIM= DIMENSIONAL % -------------------- FLUID PROPERTIES ------------------------------------- % % FLUID_MODEL= FLUID_CANTERA -COMBUSTION= YES +CANTERA_COMBUSTION= YES FLAME_INIT_METHOD= SPARK % CONDUCTIVITY_MODEL= CANTERA VISCOSITY_MODEL= CANTERA % -GAS_COMPOSITION_NAMES= H2, O2, N2 -CHEMICAL_MECHANISM_FILE= h2o2.yaml -PHASE_NAME= ohmech -TRANSPORT_MODEL= mixture-averaged +CANTERA_SPECIES_NAMES= H2, O2, N2 +CANTERA_MECHANISM_FILE= h2o2.yaml +CANTERA_PHASE_NAME= ohmech +CANTERA_TRANSPORT_MODEL= mixture-averaged % % -------------------- SCALAR TRANSPORT ---------------------------------------% % diff --git a/UnitTests/SU2_CFD/fluid/multicomponent_cantera_gri30.cfg b/UnitTests/SU2_CFD/fluid/multicomponent_cantera_gri30.cfg index 1ef1cecee024..a1b52cc05b7a 100644 --- a/UnitTests/SU2_CFD/fluid/multicomponent_cantera_gri30.cfg +++ b/UnitTests/SU2_CFD/fluid/multicomponent_cantera_gri30.cfg @@ -5,7 +5,7 @@ % Author: Cristopher Morales Ubal % % Institution: Eindhoven University of Technology % % Date: 2024/10/01 % -% File Version 8.1.0 "Harrier" % +% File Version 8.5.0 "Harrier" % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -26,10 +26,10 @@ FLUID_MODEL= FLUID_CANTERA CONDUCTIVITY_MODEL= CANTERA VISCOSITY_MODEL= CANTERA % -GAS_COMPOSITION_NAMES= CH4, O2, N2 -CHEMICAL_MECHANISM_FILE= gri30.yaml -PHASE_NAME= gri30 -TRANSPORT_MODEL= mixture-averaged +CANTERA_SPECIES_NAMES= CH4, O2, N2 +CANTERA_MECHANISM_FILE= gri30.yaml +CANTERA_PHASE_NAME= gri30 +CANTERA_TRANSPORT_MODEL= mixture-averaged % % -------------------- SCALAR TRANSPORT ---------------------------------------% % diff --git a/UnitTests/SU2_CFD/fluid/one_step_ch4.cfg b/UnitTests/SU2_CFD/fluid/one_step_ch4.cfg index a3be9d881fb8..253f06291f51 100644 --- a/UnitTests/SU2_CFD/fluid/one_step_ch4.cfg +++ b/UnitTests/SU2_CFD/fluid/one_step_ch4.cfg @@ -5,7 +5,7 @@ % Author: Cristopher Morales Ubal % % Institution: Eindhoven University of Technology % % Date: 2024/10/01 % -% File Version 8.1.0 "Harrier" % +% File Version 8.5.0 "Harrier" % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -26,12 +26,12 @@ FLUID_MODEL= FLUID_CANTERA CONDUCTIVITY_MODEL= CANTERA VISCOSITY_MODEL= CANTERA % -COMBUSTION= YES +CANTERA_COMBUSTION= YES FLAME_INIT_METHOD= SPARK -GAS_COMPOSITION_NAMES= O2, H2O, CH4, CO2, N2 -CHEMICAL_MECHANISM_FILE= one_step_ch4.yaml -PHASE_NAME= ch4_one_step -TRANSPORT_MODEL= mixture-averaged +CANTERA_SPECIES_NAMES= O2, H2O, CH4, CO2, N2 +CANTERA_MECHANISM_FILE= one_step_ch4.yaml +CANTERA_PHASE_NAME= ch4_one_step +CANTERA_TRANSPORT_MODEL= mixture-averaged % % -------------------- SCALAR TRANSPORT ---------------------------------------% % diff --git a/config_template.cfg b/config_template.cfg index 0074ce0af267..8d94f74f1d4d 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -986,30 +986,30 @@ SPECIES_CLIPPING_MIN= 0.0 % DIFFUSIVITY_MODEL= CANTERA, KIND_SCALAR_MODEL= SPECIES_TRANSPORT, INC_DENSITY_MODEL= VARIABLE % and INC_NONDIM= DIMENSIONAL, and SU2 built with -Denable-cantera=true. % -% Chemical mechanism file (YAML), searched in the working directory and in CANTERA_DATA. -CHEMICAL_MECHANISM_FILE= h2o2.yaml +% Chemical mechanism file (YAML), searched in the working directory and in CANTERA_DATA. Required. +CANTERA_MECHANISM_FILE= h2o2.yaml % -% Name of the phase in the mechanism file. -PHASE_NAME= ohmech +% Name of the phase in the mechanism file. Required. +CANTERA_PHASE_NAME= ohmech % % Cantera transport model (mixture-averaged, unity-Lewis-number). Mixture-averaged gives a % mass diffusivity for each species, unity-Lewis-number gives the same one for all of them. -TRANSPORT_MODEL= mixture-averaged +CANTERA_TRANSPORT_MODEL= mixture-averaged % % Names of the species in the mechanism, in the order of SPECIES_INIT. The last name is the % remainder, Y_N = 1 - sum(Y_k), so there is one name more than the number of SPECIES_INIT -% entries. At most MAX_TRANSPORTED_SPECIES (see option_structure.hpp) species are transported. -GAS_COMPOSITION_NAMES= H2, O2, N2 +% entries. At most MAX_TRANSPORTED_SPECIES (20, see Common/include/option_structure.hpp) are transported. +CANTERA_SPECIES_NAMES= H2, O2, N2 % % Add the chemical source terms to the species equations (NO, YES). % Requires FLAME_INIT_METHOD= SPARK, with SPARK_INIT defining the spark region and duration. -COMBUSTION= NO +CANTERA_COMBUSTION= NO % % Temperature (K) imposed inside the spark region while the spark is active. -SPARK_TEMPERATURE= 1000.0 +CANTERA_SPARK_TEMPERATURE= 1000.0 % % Add the diagonal chemical sink Jacobian to the implicit species equations (NO, YES). -CHEMICAL_SOURCE_JACOBIAN= YES +CANTERA_SOURCE_JACOBIAN= YES % % Temperature (K) below which the chemical source terms are set to zero. 0 disables it. CANTERA_DC_MIN_TEMP= 500.0 @@ -1063,7 +1063,7 @@ CONTROLLING_VARIABLE_SOURCE_NAMES= (ProdRateTot_PV, NULL) % of solver iterations. This artificial spark can be applied after a certain number of iterations has passed, allowing for % the flow to evolve before igniting the mixture. % NONE : no artificial solution ignition. -% SPARK is also the ignition of COMBUSTION= YES (Cantera detailed chemistry), see SPARK_TEMPERATURE. +% SPARK is also the ignition of CANTERA_COMBUSTION= YES (Cantera detailed chemistry), see CANTERA_SPARK_TEMPERATURE. % By default, this option is set to NONE FLAME_INIT_METHOD= FLAME_FRONT diff --git a/meson.py b/meson.py index ca03e47b3f0c..76b1be9e7499 100755 --- a/meson.py +++ b/meson.py @@ -35,8 +35,9 @@ if sys.version_info[0] < 3: raise Exception("Script must be run using Python 3") - # Preconfigure - preconfigure.run(own_meson=True) + # Preconfigure, Cantera is large and only downloaded when it is enabled + use_cantera = any(arg.lower() == "-denable-cantera=true" for arg in sys.argv[1:]) + preconfigure.run(own_meson=True, own_cantera=use_cantera) # Add paths for meson and ninja to environment os.environ["NINJA"] = sys.path[0] + os.path.sep + "ninja" diff --git a/meson_scripts/build_cantera.py b/meson_scripts/build_cantera.py index 95e0019c3855..5f9913dc0774 100644 --- a/meson_scripts/build_cantera.py +++ b/meson_scripts/build_cantera.py @@ -107,7 +107,7 @@ def main(): if not os.path.exists(os.path.join(args.source, "SConstruct")): sys.exit( "Cantera sources not found in '{}'.\n" - "Run './preconfigure.py' (or 'git submodule update --init subprojects/cantera') " + "Run './preconfigure.py --with-cantera' (or 'git submodule update --init subprojects/cantera') " "before configuring with -Denable-cantera=true.".format(args.source) ) diff --git a/meson_scripts/init.py b/meson_scripts/init.py index a6d4ec225314..27ed37bd232a 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -47,7 +47,7 @@ def init_submodules( own_opdi=True, own_mpp=True, own_cool=True, - own_cantera=True, + own_cantera=False, own_mel=True, own_fado=True, own_mlpcpp=True, diff --git a/preconfigure.py b/preconfigure.py index 715d1a72b1fc..bfba6995c5bb 100755 --- a/preconfigure.py +++ b/preconfigure.py @@ -89,7 +89,7 @@ def run( own_opdi=True, own_mpp=True, own_cool=True, - own_cantera=True, + own_cantera=False, own_mel=True, own_fado=True, own_mlpcpp=True, @@ -149,9 +149,9 @@ def run( action="store_false", ) parser.add_argument( - "--no-cantera", - help="do not download own copy of Cantera", - action="store_false", + "--with-cantera", + help="download own copy of Cantera, needed for -Denable-cantera=true", + action="store_true", ) parser.add_argument( "--no-mel", help="do not download own copy of MEL", action="store_false" @@ -176,7 +176,7 @@ def run( own_opdi=args.no_opdi, own_mpp=args.no_mpp, own_cool=args.no_coolprop, - own_cantera=args.no_cantera, + own_cantera=args.with_cantera, own_mel=args.no_mel, own_fado=args.no_fado, own_mlpcpp=args.no_mlpcpp, From 25b58c7c01336a1d9da4eee17ca33344b4b560bc Mon Sep 17 00:00:00 2001 From: bigfooted Date: Fri, 9 Oct 2026 21:36:33 +0200 Subject: [PATCH 172/173] Address review of the Cantera detailed chemistry PR (Evert Bunschoten) Move the ignition spark into CSolver and use it in all three solvers, split it out of CIncNSSolver::Preprocessing, make the Cantera solution and molar masses const, rename GetStateFailed to GetTemperatureIterationFailed, use size_t for the species count, check duplicate species names in CConfig, start the temperature iteration from an enthalpy estimate, and name the limits in the static_assert messages. Co-Authored-By: Claude Sonnet 5.5 --- Common/src/CConfig.cpp | 9 ++++ SU2_CFD/include/fluid/CFluidCantera.hpp | 10 ++-- SU2_CFD/include/fluid/CFluidModel.hpp | 4 +- .../integration/CMultiGridIntegration.hpp | 2 +- .../include/limiters/computeLimiters_impl.hpp | 2 +- SU2_CFD/include/solvers/CIncNSSolver.hpp | 9 +++- SU2_CFD/include/solvers/CSolver.hpp | 17 +++++++ .../solvers/CSpeciesFlameletSolver.hpp | 1 + SU2_CFD/include/solvers/CSpeciesSolver.hpp | 1 - SU2_CFD/src/fluid/CFluidCantera.cpp | 49 ++++++++++++++----- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 10 ++-- SU2_CFD/src/solvers/CIncNSSolver.cpp | 48 +++++++----------- .../src/solvers/CSpeciesFlameletSolver.cpp | 25 +--------- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 5 +- SU2_CFD/src/variables/CIncNSVariable.cpp | 4 +- .../SU2_CFD/fluid/CFluidCantera_tests.cpp | 6 +-- 16 files changed, 113 insertions(+), 89 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 5da093416e24..03cbeafd1049 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -4356,6 +4356,15 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i "to be equal to the number of entries of SPECIES_INIT + 1", CURRENT_FUNCTION); } + for (unsigned short i = 0; i < cantera_ParsedOptions.n_species_names; i++) { + for (unsigned short j = 0; j < i; j++) { + if (cantera_ParsedOptions.species_names[i] == cantera_ParsedOptions.species_names[j]) { + SU2_MPI::Error("Species '" + cantera_ParsedOptions.species_names[i] + + "' appears more than once in CANTERA_SPECIES_NAMES.", + CURRENT_FUNCTION); + } + } + } /*--- Check whether the density model used is correct, in the case of FLUID_MIXTURE the density model must be VARIABLE. Otherwise, if the density model is CONSTANT, the scalars will not have influence the mixture density and it will remain constant through the complete domain. --- */ diff --git a/SU2_CFD/include/fluid/CFluidCantera.hpp b/SU2_CFD/include/fluid/CFluidCantera.hpp index 173d3335d507..9de0e5f68a1e 100644 --- a/SU2_CFD/include/fluid/CFluidCantera.hpp +++ b/SU2_CFD/include/fluid/CFluidCantera.hpp @@ -48,7 +48,7 @@ class Solution; class CFluidCantera final : public CFluidModel { private: #ifdef HAVE_CANTERA - const int n_species_mixture; /*!< \brief Number of species in mixture. */ + const size_t n_species_mixture; /*!< \brief Number of species in mixture. */ const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */ const su2double Prandtl_Turb_Number; /*!< \brief Prandlt turbulent number.*/ const su2double Schmidt_Turb_Number; /*!< \brief Schmidt turbulent number.*/ @@ -60,16 +60,16 @@ class CFluidCantera final : public CFluidModel { const bool Correction_Velocity; /*!< \brief The diffusive species fluxes are corrected to sum to zero. */ su2double Heat_Release{0.0}; /*!< \brief heat release due to combustion */ - bool stateFailed{false}; /*!< \brief The last state evaluation did not converge. */ + bool temperatureIterationFailed{false}; /*!< \brief The last temperature-from-enthalpy iteration did not converge. */ double minTemperature{0.0}; /*!< \brief Lower temperature bound of the Newton iteration. */ double maxTemperature{0.0}; /*!< \brief Upper temperature bound of the Newton iteration. */ double temperatureGuess{0.0}; /*!< \brief Start of the next temperature iteration, 0 if unset. */ - std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ + const std::shared_ptr sol; /*!< \brief Object needed to describe a chemically-reacting solution*/ std::vector speciesIndices; /*!< \brief Mechanism index of each transported species. */ std::vector chemicalSourceTerm; /*!< \brief Chemical source term of the transported species. */ std::vector chemicalSourceJacobian; /*!< \brief Diagonal sink Jacobian of the transported species. */ std::vector enthalpyFormation; /*!< \brief Enthalpy of formation of the transported species. */ - std::vector molarMasses; /*!< \brief Molar masses of all mechanism species. */ + const std::vector molarMasses; /*!< \brief Molar masses of all mechanism species. */ std::vector massFractions; /*!< \brief Mass fractions of all mechanism species. */ std::vector netProductionRates; /*!< \brief Net production rates of all mechanism species. */ std::vector destructionRates; /*!< \brief Destruction rates of all mechanism species. */ @@ -166,7 +166,7 @@ class CFluidCantera final : public CFluidModel { /*! * \brief Whether the last state evaluation failed to converge or needed a temperature far outside the data range. */ - inline bool GetStateFailed() const override { return stateFailed; } + inline bool GetTemperatureIterationFailed() const override { return temperatureIterationFailed; } /*! * \brief Get enthalpy diffusivity terms. diff --git a/SU2_CFD/include/fluid/CFluidModel.hpp b/SU2_CFD/include/fluid/CFluidModel.hpp index 1ead7e23c5e2..6537e94649a2 100644 --- a/SU2_CFD/include/fluid/CFluidModel.hpp +++ b/SU2_CFD/include/fluid/CFluidModel.hpp @@ -215,9 +215,9 @@ class CFluidModel { inline virtual su2double GetHeatRelease() { return 0.0; } /*! - * \brief Whether the last state evaluation failed and the state must be treated as non-physical. + * \brief Whether the last temperature-from-enthalpy iteration failed, so the state is non-physical. */ - inline virtual bool GetStateFailed() const { return false; } + inline virtual bool GetTemperatureIterationFailed() const { return false; } /*! * \brief Get the enthalpy diffusivity terms for all species being solved. diff --git a/SU2_CFD/include/integration/CMultiGridIntegration.hpp b/SU2_CFD/include/integration/CMultiGridIntegration.hpp index 71f9ef86334a..fbabb5c35867 100644 --- a/SU2_CFD/include/integration/CMultiGridIntegration.hpp +++ b/SU2_CFD/include/integration/CMultiGridIntegration.hpp @@ -325,7 +325,7 @@ class CMultiGridIntegration final : public CIntegration { * independently of the CSysMatrix limit of the same name. ---*/ static constexpr unsigned short MAXNVAR = 25; static constexpr unsigned short MAXNDIM = 3; - static_assert(MAXNVAR >= MAX_TRANSPORTED_SPECIES, "The scalar equations of the species model must fit."); + static_assert(MAXNVAR >= MAX_TRANSPORTED_SPECIES, "MAXNVAR (size of the multigrid transfer buffers) must be at least MAX_TRANSPORTED_SPECIES."); /*--- Early-exit smoothing state (shared across OMP threads via master write + barrier). ---*/ bool mg_early_exit_flag = false; /*!< \brief Shared flag for early exit across OMP threads. */ diff --git a/SU2_CFD/include/limiters/computeLimiters_impl.hpp b/SU2_CFD/include/limiters/computeLimiters_impl.hpp index f1499db556fc..cf55444e4a95 100644 --- a/SU2_CFD/include/limiters/computeLimiters_impl.hpp +++ b/SU2_CFD/include/limiters/computeLimiters_impl.hpp @@ -79,7 +79,7 @@ void computeLimiters_impl(CSolver* solver, FieldType& limiter) { constexpr size_t MAXNVAR = 32; - static_assert(MAXNVAR >= MAX_TRANSPORTED_SPECIES, "The scalar equations of the species model must fit."); + static_assert(MAXNVAR >= MAX_TRANSPORTED_SPECIES, "MAXNVAR (size of the limiter work arrays) must be at least MAX_TRANSPORTED_SPECIES."); if (varEnd > MAXNVAR) SU2_MPI::Error("Number of variables is too large, increase MAXNVAR.", CURRENT_FUNCTION); diff --git a/SU2_CFD/include/solvers/CIncNSSolver.hpp b/SU2_CFD/include/solvers/CIncNSSolver.hpp index 48da3a2b8636..a57d1f67d499 100644 --- a/SU2_CFD/include/solvers/CIncNSSolver.hpp +++ b/SU2_CFD/include/solvers/CIncNSSolver.hpp @@ -36,7 +36,6 @@ * \author F. Palacios, T. Economon, T. Albring */ class CIncNSSolver final : public CIncEulerSolver { - FluidFlamelet_ParsedOptions flamelet_config_options; su2double TemperatureLimits[2]; su2activematrix EnthalpyDiffusion; /*!< \brief Enthalpy diffusion coefficient of each species at each point. */ su2activematrix GradEnthalpyDiffusion; /*!< \brief Temperature derivative of EnthalpyDiffusion. */ @@ -48,6 +47,14 @@ class CIncNSSolver final : public CIncEulerSolver { */ void ComputeEnthalpyDiffusionTerms(CSolver** solver_container, const CConfig* config); + /*! + * \brief Set the temperature, enthalpy and properties of the points inside the ignition spark. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] config - Definition of the particular problem. + */ + void ApplySpark(CGeometry* geometry, CSolver** solver_container, const CConfig* config); + /*! * \brief Generic implementation of the isothermal, heatflux and heat-transfer/convection walls. */ diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 7a7b6c726021..0bae5b4b3a2b 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -219,6 +219,23 @@ class CSolver { */ virtual ~CSolver(void); + /*! + * \brief Whether the artificial ignition spark is active at the current iteration. + * \param[in] config - Definition of the particular problem. + */ + static bool SparkActive(const CConfig* config) { + return config->GetFlameletParsedOptions().SparkActive(config->GetIgnitionIter()); + } + + /*! + * \brief Whether a point lies inside the artificial ignition spark region. + * \param[in] config - Definition of the particular problem. + * \param[in] coord - Coordinates of the point. + */ + bool InSpark(const CConfig* config, const su2double* coord) const { + return config->GetFlameletParsedOptions().InSpark(nDim, coord); + } + /*! * \brief Allow outside access to the nodes of the solver, containing conservatives, primitives, etc. * \return Nodes of the solver. diff --git a/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp b/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp index 24234ce3e109..ce4f323fdb65 100644 --- a/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp +++ b/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp @@ -37,6 +37,7 @@ */ class CSpeciesFlameletSolver final : public CSpeciesSolver { private: + FluidFlamelet_ParsedOptions flamelet_config_options; const su2double default_flame_thickness{1.0}; su2double global_flame_thickness; bool calc_flame_thickness{false}; diff --git a/SU2_CFD/include/solvers/CSpeciesSolver.hpp b/SU2_CFD/include/solvers/CSpeciesSolver.hpp index be7577d1ea20..42fc7322b097 100644 --- a/SU2_CFD/include/solvers/CSpeciesSolver.hpp +++ b/SU2_CFD/include/solvers/CSpeciesSolver.hpp @@ -40,7 +40,6 @@ class CSpeciesSolver : public CScalarSolver { protected: unsigned short Inlet_Position; /*!< \brief Column index for scalar variables in inlet files. */ vector Inlet_SpeciesVars; /*!< \brief Species variables at inlet profiles. */ - FluidFlamelet_ParsedOptions flamelet_config_options; vector Wall_SpeciesVars; /*!< \brief Species variables at profiles. */ vector> CustomBoundaryScalar; diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp index 680eb868d6b4..aea94ca6bbf4 100644 --- a/SU2_CFD/src/fluid/CFluidCantera.cpp +++ b/SU2_CFD/src/fluid/CFluidCantera.cpp @@ -36,6 +36,23 @@ using namespace Cantera; +namespace { +std::shared_ptr LoadSolution(const CConfig* config) { + try { + return newSolution(config->GetChemical_MechanismFile(), config->GetPhase_Name(), config->GetTransport_Model()); + } catch (const CanteraError& error) { + SU2_MPI::Error(string("Cantera error during initialization: ") + error.what(), CURRENT_FUNCTION); + return nullptr; + } +} + +std::vector GetMolarMasses(Solution& solution) { + std::vector molarMasses(solution.thermo()->nSpecies()); + solution.thermo()->getMolecularWeights(molarMasses.data()); + return molarMasses; +} +} // namespace + CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* config) : CFluidModel(), n_species_mixture(config->GetnSpecies() + 1), @@ -47,26 +64,25 @@ CFluidCantera::CFluidCantera(su2double value_pressure_operating, const CConfig* Phase_Name(config->GetPhase_Name()), Combustion(config->GetCombustion()), Chemistry_Min_Temperature(config->GetCantera_DC_Min_Temp()), - Correction_Velocity(config->GetCantera_Correction_Velocity()) { + Correction_Velocity(config->GetCantera_Correction_Velocity()), + sol(LoadSolution(config)), + molarMasses(GetMolarMasses(*sol)) { try { - sol = newSolution(Chemical_MechanismFile, Phase_Name, Transport_Model); const auto& thermo = *sol->thermo(); const size_t nSpeciesMechanism = thermo.nSpecies(); - molarMasses.resize(nSpeciesMechanism); massFractions.assign(nSpeciesMechanism, 0.0); massDiffusivity.assign(nSpeciesMechanism, 0.0); netProductionRates.assign(nSpeciesMechanism, 0.0); destructionRates.assign(nSpeciesMechanism, 0.0); enthalpiesSpecies.assign(nSpeciesMechanism, 0.0); specificHeatSpecies.assign(nSpeciesMechanism, 0.0); - thermo.getMolecularWeights(molarMasses.data()); /*--- Moderate extrapolation of the thermodynamic polynomials is allowed beyond the range of the data. ---*/ minTemperature = 0.5 * thermo.minTemp(); maxTemperature = 2.0 * thermo.maxTemp(); speciesIndices.resize(n_species_mixture); - for (int iVar = 0; iVar < n_species_mixture; iVar++) { + for (size_t iVar = 0; iVar < n_species_mixture; iVar++) { const string name = config->GetChemical_GasComposition(iVar); const size_t index = thermo.speciesIndex(name); if (index == npos) { @@ -94,7 +110,7 @@ void CFluidCantera::SetEnthalpyFormation(const CConfig* config) { sol->thermo()->setMassFractions(massFractions.data()); sol->thermo()->setState_TP(STD_REF_TEMP, SU2_TYPE::GetValue(Pressure_Thermodynamic)); sol->thermo()->getEnthalpy_RT_ref(enthalpiesSpecies.data()); - for (int iVar = 0; iVar < n_species_mixture; iVar++) { + for (size_t iVar = 0; iVar < n_species_mixture; iVar++) { const size_t k = speciesIndices[iVar]; enthalpyFormation[iVar] = GasConstant * STD_REF_TEMP * enthalpiesSpecies[k] / molarMasses[k]; } @@ -114,7 +130,7 @@ void CFluidCantera::ComputeChemicalSourceTerm() { SU2_MPI::Error(string("Cantera error in the kinetics evaluation: ") + error.what(), CURRENT_FUNCTION); } Heat_Release = 0.0; - for (int iVar = 0; iVar < n_species_mixture; iVar++) { + for (size_t iVar = 0; iVar < n_species_mixture; iVar++) { const size_t k = speciesIndices[iVar]; chemicalSourceTerm[iVar] = molarMasses[k] * netProductionRates[k]; /*--- The destruction rate is taken proportional to the mass fraction; the derivative is w.r.t. rho*Y. ---*/ @@ -132,7 +148,7 @@ void CFluidCantera::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) const /*--- With the correction velocity every species enthalpy is taken relative to the mixture enthalpy. ---*/ const su2double h_ref = Correction_Velocity ? Enthalpy : su2double(0.0); const su2double h_last = RT * enthalpiesSpecies[last] / molarMasses[last] - h_ref; - for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { + for (size_t iVar = 0; iVar < n_species_mixture - 1; iVar++) { const size_t k = speciesIndices[iVar]; const su2double h_k = RT * enthalpiesSpecies[k] / molarMasses[k] - h_ref; enthalpy_diffusions[iVar] = Density * (h_k * massDiffusivity[k] - h_last * massDiffusivity[last]) + @@ -146,7 +162,7 @@ void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusio const size_t last = speciesIndices[n_species_mixture - 1]; const su2double cp_ref = Correction_Velocity ? Cp : su2double(0.0); const su2double cp_last = GasConstant * specificHeatSpecies[last] / molarMasses[last] - cp_ref; - for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) { + for (size_t iVar = 0; iVar < n_species_mixture - 1; iVar++) { const size_t k = speciesIndices[iVar]; const su2double cp_k = GasConstant * specificHeatSpecies[k] / molarMasses[k] - cp_ref; grad_enthalpy_diffusions[iVar] = Density * (cp_k * massDiffusivity[k] - cp_last * massDiffusivity[last]) + @@ -157,7 +173,7 @@ void CFluidCantera::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusio void CFluidCantera::SetMassFractions(const su2double* val_scalars) { double scalarsSum = 0.0; std::fill(massFractions.begin(), massFractions.end(), 0.0); - for (int iScalar = 0; iScalar < n_species_mixture - 1; iScalar++) { + for (size_t iScalar = 0; iScalar < n_species_mixture - 1; iScalar++) { const double value = SU2_TYPE::GetValue(val_scalars[iScalar]); massFractions[speciesIndices[iScalar]] = value; scalarsSum += value; @@ -206,7 +222,7 @@ void CFluidCantera::SetTDState_T(const su2double val_temperature, const su2doubl } catch (const CanteraError& error) { SU2_MPI::Error(string("Cantera error in SetTDState_T: ") + error.what(), CURRENT_FUNCTION); } - stateFailed = false; + temperatureIterationFailed = false; } void CFluidCantera::SetTDState_h(const su2double val_enthalpy, const su2double* val_scalars) { @@ -216,13 +232,20 @@ void CFluidCantera::SetTDState_h(const su2double val_enthalpy, const su2double* SetMassFractions(val_scalars); const double enthalpy = SU2_TYPE::GetValue(val_enthalpy); - double temperature = std::clamp((temperatureGuess > 0.0) ? temperatureGuess : 300.0, minTemperature, maxTemperature); + double temperature = temperatureGuess; temperatureGuess = 0.0; bool converged = false; try { sol->thermo()->setMassFractions(massFractions.data()); + /*--- Without a guess, start from a single Newton step at the reference temperature. ---*/ + if (!(temperature > 0.0)) { + sol->thermo()->setState_TP(STD_REF_TEMP, SU2_TYPE::GetValue(Pressure_Thermodynamic)); + temperature = STD_REF_TEMP + (enthalpy - sol->thermo()->enthalpy_mass()) / sol->thermo()->cp_mass(); + } + temperature = std::clamp(temperature, minTemperature, maxTemperature); + /*--- Newton-Raphson on temperature, kept inside the temperature bounds. ---*/ for (int iter = 0; iter < maxIterations; iter++) { sol->thermo()->setState_TP(temperature, SU2_TYPE::GetValue(Pressure_Thermodynamic)); @@ -242,7 +265,7 @@ void CFluidCantera::SetTDState_h(const su2double val_enthalpy, const su2double* } catch (const CanteraError& error) { SU2_MPI::Error(string("Cantera error in SetTDState_h: ") + error.what(), CURRENT_FUNCTION); } - stateFailed = !converged; + temperatureIterationFailed = !converged; } #else diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 99ad61e089e2..6475ebc1ef08 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1494,13 +1494,13 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont Primitive_j[iVar] = V_j[iVar]; } /*--- A failed evaluation of the fluid state is a non-physical reconstruction, like a negative temperature. ---*/ - bool state_failed = false; + bool temperature_failed = false; if (multicomponent) { const su2double* scalar_i = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint); const su2double* scalar_j = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(jPoint); const bool failed_i = ComputeConsistentExtrapolation(GetFluidModel(), nDim, scalar_i, Primitive_i); const bool failed_j = ComputeConsistentExtrapolation(GetFluidModel(), nDim, scalar_j, Primitive_j); - state_failed = failed_i || failed_j; + temperature_failed = failed_i || failed_j; } /*--- Check for non-physical solutions after reconstruction. If found, @@ -1510,8 +1510,8 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont incompressible flow, only the temperature and density need to be checked. Pressure is the dynamic pressure (can be negative). ---*/ - if (config->GetEnergy_Equation() || state_failed) { - bool bad_recon = state_failed; + if (config->GetEnergy_Equation() || temperature_failed) { + bool bad_recon = temperature_failed; if (config->GetEnergy_Equation()) { const bool neg_temperature_i = (Primitive_i[prim_idx.Temperature()] < 0.0); const bool neg_temperature_j = (Primitive_j[prim_idx.Temperature()] < 0.0); @@ -1587,7 +1587,7 @@ bool CIncEulerSolver::ComputeConsistentExtrapolation(CFluidModel* fluidModel, un primitive[prim_idx.Temperature()] = fluidModel->GetTemperature(); primitive[prim_idx.Density()] = fluidModel->GetDensity(); - return fluidModel->GetStateFailed(); + return fluidModel->GetTemperatureIterationFailed(); } void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 31d7f0f2e7db..4a2da580d9ff 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -55,7 +55,6 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short default: break; } - if (config->GetCombustion()) flamelet_config_options = config->GetFlameletParsedOptions(); if (config->GetMulticomponentFluid() && config->GetEnergy_Equation()) { EnthalpyDiffusion.resize(nPoint, config->GetnSpecies()) = su2double(0.0); @@ -69,6 +68,24 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short SPvals.Streamwise_Periodic_PressureDrop = config->GetStreamwise_Periodic_PressureDrop(); } +void CIncNSSolver::ApplySpark(CGeometry* geometry, CSolver** solver_container, const CConfig* config) { + CFluidModel* fluid_model_local = solver_container[FLOW_SOL]->GetFluidModel(); + SU2_OMP_FOR_STAT(omp_chunk_size) + for (auto i_point = 0u; i_point < nPoint; i_point++) { + if (!InSpark(config, geometry->nodes->GetCoord(i_point))) continue; + const su2double* scalars = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(i_point); + nodes->SetTemperature(i_point, config->GetSpark_Temperature(), TemperatureLimits); + fluid_model_local->SetTDState_T(config->GetSpark_Temperature(), scalars); + nodes->SetSolution(i_point, nDim + 1, fluid_model_local->GetEnthalpy()); + nodes->SetDensity(i_point, fluid_model_local->GetDensity()); + nodes->SetSpecificHeatCp(i_point, fluid_model_local->GetCp()); + nodes->SetSpecificHeatCv(i_point, fluid_model_local->GetCv()); + nodes->SetThermalConductivity(i_point, fluid_model_local->GetThermalConductivity()); + nodes->SetLaminarViscosity(i_point, fluid_model_local->GetLaminarViscosity()); + } + END_SU2_OMP_FOR +} + void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { SU2_ZONE_SCOPED @@ -82,36 +99,9 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container const bool energy = config->GetEnergy_Equation(); const bool combustion = config->GetCombustion(); - /*--- Setting temperature, enthalpy and thermophysical properties for ignition in reacting flows. ---*/ if (energy && combustion) { - const bool ignition = flamelet_config_options.SparkActive(config->GetIgnitionIter()); - SU2_OMP_SAFE_GLOBAL_ACCESS(config->SetGlobalParam(config->GetKind_Solver(), RunTime_EqSystem);) - - if (ignition) { - CFluidModel* fluid_model_local = solver_container[FLOW_SOL]->GetFluidModel(); - SU2_OMP_FOR_STAT(omp_chunk_size) - for (auto i_point = 0u; i_point < nPoint; i_point++) { - /*--- Apply ignition temperature within spark radius. ---*/ - if (flamelet_config_options.InSpark(nDim, geometry->nodes->GetCoord(i_point))) { - /*--- Retrieve scalars solution. ---*/ - su2double* scalars = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(i_point); - /*--- Set high temperature for ignition. ---*/ - nodes->SetTemperature(i_point, config->GetSpark_Temperature(), TemperatureLimits); - /*--- Set thermodynamic state at high temperature. ---*/ - fluid_model_local->SetTDState_T(config->GetSpark_Temperature(), scalars); - /*--- Set total enthalpy at high temperature. ---*/ - nodes->SetSolution(i_point, nDim + 1, fluid_model_local->GetEnthalpy()); - /*--- Set thermodynamics and transport properties at high temperature for consistency. ---*/ - nodes->SetDensity(i_point, fluid_model_local->GetDensity()); - nodes->SetSpecificHeatCp(i_point, fluid_model_local->GetCp()); - nodes->SetSpecificHeatCv(i_point, fluid_model_local->GetCv()); - nodes->SetThermalConductivity(i_point, fluid_model_local->GetThermalConductivity()); - nodes->SetLaminarViscosity(i_point, fluid_model_local->GetLaminarViscosity()); - } - } - END_SU2_OMP_FOR - } + if (SparkActive(config)) ApplySpark(geometry, solver_container, config); } /*--- Common preprocessing steps (implemented by CEulerSolver) ---*/ diff --git a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp index 1d39f9263381..92e45568c12f 100644 --- a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp @@ -84,27 +84,9 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver unsigned long n_not_in_domain_global = 0; vector scalars_vector(nVar); - unsigned long spark_iter_start, spark_duration; - bool ignition = false; + const bool ignition = SparkActive(config); auto* flowNodes = su2staticcast_p(solver_container[FLOW_SOL]->GetNodes()); - /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ - unsigned long iter; - if (config->GetMultizone_Problem()) { - iter = config->GetOuterIter(); - } else if (config->GetTime_Domain()) { - iter = config->GetTimeIter(); - } else { - iter = config->GetInnerIter(); - } - if ((flamelet_config_options.ignition_method == FLAMELET_INIT_TYPE::SPARK)) { - auto spark_init = flamelet_config_options.spark_init; - spark_iter_start = ceil(spark_init[4]); - spark_duration = ceil(spark_init[5]); - - ignition = ((iter >= spark_iter_start) && (iter <= (spark_iter_start + spark_duration))); - } - SU2_OMP_SAFE_GLOBAL_ACCESS(config->SetGlobalParam(config->GetKind_Solver(), RunTime_EqSystem); n_not_in_domain_local = 0;) @@ -148,11 +130,8 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver if (ignition) { /*--- Apply source terms within spark radius. ---*/ - su2double dist_from_center = 0, - spark_radius = flamelet_config_options.spark_init[3]; - dist_from_center = GeometryToolbox::SquaredDistance(nDim, geometry->nodes->GetCoord(i_point), flamelet_config_options.spark_init.data()); su2double T_local = flowNodes->GetTemperature(i_point); - if (dist_from_center < pow(spark_radius,2) && T_local < flamelet_config_options.Flame_T_ignition) { + if (InSpark(config, geometry->nodes->GetCoord(i_point)) && T_local < flamelet_config_options.Flame_T_ignition) { /*--- Add spark reaction rates to the sources that were just set by SetScalarSources ---*/ const su2double* current_sources = nodes->GetScalarSources(i_point); for (auto iVar = 0u; iVar < nVar; iVar++) { diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index db41916f3561..0aa5da72af0e 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -45,7 +45,6 @@ CSpeciesSolver::CSpeciesSolver(CGeometry* geometry, CConfig* config, const CSolv nVar = config->GetnSpecies(); - if (config->GetCombustion()) flamelet_config_options = config->GetFlameletParsedOptions(); Initialize(geometry, config, iMesh, nVar); @@ -321,7 +320,7 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain bool Output) { SU2_ZONE_SCOPED const bool combustion = config->GetCombustion(); - const bool ignition = flamelet_config_options.SparkActive(config->GetIgnitionIter()); + const bool ignition = SparkActive(config); SU2_OMP_SAFE_GLOBAL_ACCESS(config->SetGlobalParam(config->GetKind_Solver(), RunTime_EqSystem);) CFluidModel* fluid_model = solver_container[FLOW_SOL]->GetFluidModel(); @@ -343,7 +342,7 @@ void CSpeciesSolver::Preprocessing(CGeometry* geometry, CSolver** solver_contain } su2double temperature = solver_container[FLOW_SOL]->GetNodes()->GetTemperature(iPoint); - if (ignition && flamelet_config_options.InSpark(nDim, geometry->nodes->GetCoord(iPoint))) { + if (ignition && InSpark(config, geometry->nodes->GetCoord(iPoint))) { /*--- Apply ignition temperature within spark radius. ---*/ temperature = config->GetSpark_Temperature(); } diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index 57080c5e8d5b..1482b12ad19d 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -63,7 +63,7 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do FluidModel->SetTemperatureGuess(GetTemperature(iPoint)); FluidModel->SetTDState_h(Enthalpy, scalar); su2double Temperature = FluidModel->GetTemperature(); - const bool state_failed = FluidModel->GetStateFailed(); + const bool temperature_failed = FluidModel->GetTemperatureIterationFailed(); auto check_temp = SetTemperature(iPoint, Temperature, TemperatureLimits); @@ -77,7 +77,7 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do /*--- Non-physical solution found. Revert to old values. ---*/ - if (check_dens || check_temp || state_failed) { + if (check_dens || check_temp || temperature_failed) { /*--- Copy the old solution ---*/ diff --git a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp index 1a69fb9d3c3a..464d0c20347b 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidCantera_tests.cpp @@ -100,7 +100,7 @@ TEST_CASE("Fluid_Cantera_LargeMechanism", "[Multicomponent_flow]") { fluid.SetTDState_T(1500.0, scalar); const su2double enthalpy = fluid.GetEnthalpy(); fluid.SetTDState_h(enthalpy, scalar); - CHECK(fluid.GetStateFailed() == false); + CHECK(fluid.GetTemperatureIterationFailed() == false); CHECK(fluid.GetTemperature() == Approx(1500.0).margin(1e-4)); /*--- The result does not depend on the temperature guess, which is used only once. ---*/ @@ -110,13 +110,13 @@ TEST_CASE("Fluid_Cantera_LargeMechanism", "[Multicomponent_flow]") { CHECK(fluid.GetTemperature() == Approx(1500.0).margin(1e-4)); fluid.SetTemperatureGuess(5.0); fluid.SetTDState_h(enthalpy, scalar); - CHECK(fluid.GetStateFailed() == false); + CHECK(fluid.GetTemperatureIterationFailed() == false); CHECK(fluid.GetTemperature() == Approx(1500.0).margin(1e-4)); /*--- An enthalpy outside the range of the thermodynamic data is flagged. ---*/ fluid.SetTDState_h(1e12, scalar); - CHECK(fluid.GetStateFailed() == true); + CHECK(fluid.GetTemperatureIterationFailed() == true); } TEST_CASE("Fluid_Cantera_SourceJacobian", "[Reacting_flow]") { /*--- Diagonal chemical source Jacobian of the one-step methane mechanism. ---*/ From 1a5fcbea242cdff26022b77381e4b581e27dd566 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Fri, 9 Oct 2026 21:52:24 +0200 Subject: [PATCH 173/173] precommit --- Common/include/linear_algebra/CSysMatrix.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Common/include/linear_algebra/CSysMatrix.hpp b/Common/include/linear_algebra/CSysMatrix.hpp index 33bde7c2c9cd..d0aa6124d96a 100644 --- a/Common/include/linear_algebra/CSysMatrix.hpp +++ b/Common/include/linear_algebra/CSysMatrix.hpp @@ -263,8 +263,9 @@ class CSysMatrix { /*!< \brief Maximum number of variables the matrix can handle. The static * size is needed for fast, per-thread, static memory allocation. */ enum : size_t { MAXNVAR = 20 }; - static_assert(MAXNVAR >= MAX_TRANSPORTED_SPECIES, - "CSysMatrix::MAXNVAR must hold the species equations: raise MAXNVAR together with MAX_TRANSPORTED_SPECIES."); + static_assert( + MAXNVAR >= MAX_TRANSPORTED_SPECIES, + "CSysMatrix::MAXNVAR must hold the species equations: raise MAXNVAR together with MAX_TRANSPORTED_SPECIES."); enum { OMP_MAX_SIZE_L = 8192 }; /*!< \brief Max. chunk size used in light parallel for loops. */ enum { OMP_MAX_SIZE_H = 512 }; /*!< \brief Max. chunk size used in heavy parallel for loops. */