From 9bc87005ad4be979efef7f8e44685104ef3521d2 Mon Sep 17 00:00:00 2001 From: sergio <sergio> Date: Fri, 26 May 2017 10:18:01 -0700 Subject: [PATCH] Adding optional build of the thermo tpe per reaction. This thermo is not necessary for solid reactions. NOTE: in Reaction.C constructors bool initReactionThermo is used by solidReaction where there is no need of setting a lhs - rhs thermo type for each reaction. This is needed for mechanism with reversible reactions --- .../Reactions/solidReaction/solidReaction.C | 4 +-- .../reaction/Reactions/Reaction/Reaction.C | 28 +++++++++++++------ .../reaction/Reactions/Reaction/Reaction.H | 17 ++++++++--- .../simplePMMApanel/0/panelRegion/{Qr => qr} | 2 +- .../simplePMMApanel/constant/pyrolysisZones | 2 +- .../constant/chemistryProperties | 2 +- .../counterFlowFlame2D/constant/reactions | 9 ++++++ .../constant/thermo.compressibleGas | 23 +++++++++++++++ 8 files changed, 69 insertions(+), 18 deletions(-) rename tutorials/combustion/fireFoam/LES/simplePMMApanel/0/panelRegion/{Qr => qr} (98%) diff --git a/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.C b/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.C index bffd5f8d2f2..18d2a9367c8 100644 --- a/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.C +++ b/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,7 +67,7 @@ Foam::solidReaction<ReactionThermo>::solidReaction const dictionary& dict ) : - Reaction<ReactionThermo>(species, thermoDatabase, dict), + Reaction<ReactionThermo>(species, thermoDatabase, dict, false), pyrolisisGases_(dict.parent().parent().lookup("gaseousSpecies")), glhs_(), grhs_() diff --git a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.C b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.C index e994ff1dce0..645cc4fc806 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.C +++ b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -111,19 +111,20 @@ void Foam::Reaction<ReactionThermo>::setThermo const HashPtrTable<ReactionThermo>& thermoDatabase ) { + typename ReactionThermo::thermoType rhsThermo ( rhs_[0].stoichCoeff - *(*thermoDatabase[species_[rhs_[0].index]]).W() - *(*thermoDatabase[species_[rhs_[0].index]]) + *(*thermoDatabase[species_[rhs_[0].index]]).W() + *(*thermoDatabase[species_[rhs_[0].index]]) ); for (label i=1; i<rhs_.size(); ++i) { rhsThermo += rhs_[i].stoichCoeff - *(*thermoDatabase[species_[rhs_[i].index]]).W() - *(*thermoDatabase[species_[rhs_[i].index]]); + *(*thermoDatabase[species_[rhs_[i].index]]).W() + *(*thermoDatabase[species_[rhs_[i].index]]); } typename ReactionThermo::thermoType lhsThermo @@ -154,7 +155,8 @@ Foam::Reaction<ReactionThermo>::Reaction const speciesTable& species, const List<specieCoeffs>& lhs, const List<specieCoeffs>& rhs, - const HashPtrTable<ReactionThermo>& thermoDatabase + const HashPtrTable<ReactionThermo>& thermoDatabase, + bool initReactionThermo ) : ReactionThermo::thermoType(*thermoDatabase[species[0]]), @@ -163,7 +165,10 @@ Foam::Reaction<ReactionThermo>::Reaction lhs_(lhs), rhs_(rhs) { - setThermo(thermoDatabase); + if (initReactionThermo) + { + setThermo(thermoDatabase); + } } @@ -325,7 +330,8 @@ Foam::Reaction<ReactionThermo>::Reaction ( const speciesTable& species, const HashPtrTable<ReactionThermo>& thermoDatabase, - const dictionary& dict + const dictionary& dict, + bool initReactionThermo ) : ReactionThermo::thermoType(*thermoDatabase[species[0]]), @@ -339,7 +345,11 @@ Foam::Reaction<ReactionThermo>::Reaction lhs_, rhs_ ); - setThermo(thermoDatabase); + + if (initReactionThermo) + { + setThermo(thermoDatabase); + } } diff --git a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.H b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.H index d96134aac95..7b3b8ea571e 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.H +++ b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -186,18 +186,27 @@ public: const speciesTable& species, const List<specieCoeffs>& lhs, const List<specieCoeffs>& rhs, - const HashPtrTable<ReactionThermo>& thermoDatabase + const HashPtrTable<ReactionThermo>& thermoDatabase, + bool initReactionThermo = true ); //- Construct as copy given new speciesTable - Reaction(const Reaction<ReactionThermo>&, const speciesTable& species); + Reaction + ( + const Reaction<ReactionThermo>&, + const speciesTable& species + ); //- Construct from dictionary + // NOTE: initReactionThermo is used by solidReaction where there is no + // need of setting a lhs - rhs thermo type for each reaction. This is + // needed for mechanism with reversible reactions Reaction ( const speciesTable& species, const HashPtrTable<ReactionThermo>& thermoDatabase, - const dictionary& dict + const dictionary& dict, + bool initReactionThermo = true ); //- Construct and return a clone diff --git a/tutorials/combustion/fireFoam/LES/simplePMMApanel/0/panelRegion/Qr b/tutorials/combustion/fireFoam/LES/simplePMMApanel/0/panelRegion/qr similarity index 98% rename from tutorials/combustion/fireFoam/LES/simplePMMApanel/0/panelRegion/Qr rename to tutorials/combustion/fireFoam/LES/simplePMMApanel/0/panelRegion/qr index 654cb3ae748..ba9e5916fb1 100644 --- a/tutorials/combustion/fireFoam/LES/simplePMMApanel/0/panelRegion/Qr +++ b/tutorials/combustion/fireFoam/LES/simplePMMApanel/0/panelRegion/qr @@ -11,7 +11,7 @@ FoamFile format ascii; class volScalarField; location "0"; - object Qr; + object qr; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/combustion/fireFoam/LES/simplePMMApanel/constant/pyrolysisZones b/tutorials/combustion/fireFoam/LES/simplePMMApanel/constant/pyrolysisZones index a099495670d..f5fd1efacc5 100644 --- a/tutorials/combustion/fireFoam/LES/simplePMMApanel/constant/pyrolysisZones +++ b/tutorials/combustion/fireFoam/LES/simplePMMApanel/constant/pyrolysisZones @@ -29,7 +29,7 @@ FoamFile filmCoupled false; - radFluxName Qr; + qrHSource on; minimumDelta 1e-6; diff --git a/tutorials/combustion/reactingFoam/laminar/counterFlowFlame2D/constant/chemistryProperties b/tutorials/combustion/reactingFoam/laminar/counterFlowFlame2D/constant/chemistryProperties index 22ec9ceabe4..c22fa78d78a 100644 --- a/tutorials/combustion/reactingFoam/laminar/counterFlowFlame2D/constant/chemistryProperties +++ b/tutorials/combustion/reactingFoam/laminar/counterFlowFlame2D/constant/chemistryProperties @@ -33,7 +33,7 @@ EulerImplicitCoeffs odeCoeffs { - solver Rosenbrock43; + solver Rosenbrock34; absTol 1e-12; relTol 0.01; } diff --git a/tutorials/combustion/reactingFoam/laminar/counterFlowFlame2D/constant/reactions b/tutorials/combustion/reactingFoam/laminar/counterFlowFlame2D/constant/reactions index e548bae90ff..842baa512be 100644 --- a/tutorials/combustion/reactingFoam/laminar/counterFlowFlame2D/constant/reactions +++ b/tutorials/combustion/reactingFoam/laminar/counterFlowFlame2D/constant/reactions @@ -1,3 +1,12 @@ +elements +( +O +C +H +N +); + + species ( O2 diff --git a/tutorials/combustion/reactingFoam/laminar/counterFlowFlame2D/constant/thermo.compressibleGas b/tutorials/combustion/reactingFoam/laminar/counterFlowFlame2D/constant/thermo.compressibleGas index 371a3bb6c87..4bbb98aa343 100644 --- a/tutorials/combustion/reactingFoam/laminar/counterFlowFlame2D/constant/thermo.compressibleGas +++ b/tutorials/combustion/reactingFoam/laminar/counterFlowFlame2D/constant/thermo.compressibleGas @@ -21,6 +21,10 @@ O2 { molWeight 31.9988; } + elements + { + O 2; + } thermodynamics { Tlow 200; @@ -42,6 +46,11 @@ H2O { molWeight 18.0153; } + elements + { + O 1; + H 2; + } thermodynamics { Tlow 200; @@ -63,6 +72,11 @@ CH4 { molWeight 16.0428; } + elements + { + C 1; + H 4; + } thermodynamics { Tlow 200; @@ -84,6 +98,11 @@ CO2 { molWeight 44.01; } + elements + { + C 1; + O 2; + } thermodynamics { Tlow 200; @@ -105,6 +124,10 @@ N2 { molWeight 28.0134; } + elements + { + N 2; + } thermodynamics { Tlow 200; -- GitLab