From ddfc287758247f5d033b18927e89532da2790da2 Mon Sep 17 00:00:00 2001 From: sergio <sergio> Date: Fri, 14 Mar 2014 09:36:46 +0000 Subject: [PATCH] ENH: Adding virtual function to basicChemistryModel.H to calculate the consumption rate of specieI in reactionI. This is used by the diffusionMulticomponent combustion model to ignite the mixture --- .../basicChemistryModel/basicChemistryModel.H | 9 +- .../chemistryModel/chemistryModel.C | 84 ++++++++++++++++++- .../chemistryModel/chemistryModel.H | 7 ++ .../basicSolidChemistryModel.C | 25 +++++- .../basicSolidChemistryModel.H | 9 +- 5 files changed, 130 insertions(+), 4 deletions(-) diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H index 55b94ccd5de..89c28de4894 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -146,6 +146,13 @@ public: const label i ) = 0; + //- Return reaction rate of the specieI in reactionI + virtual tmp<DimensionedField<scalar, volMesh> > calculateRR + ( + const label reactionI, + const label specieI + ) const = 0; + // Chemistry solution diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.C index 60c25503819..321c8235d1c 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -626,6 +626,88 @@ Foam::label Foam::chemistryModel<CompType, ThermoType>::nEqns() const } +template<class CompType, class ThermoType> +Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> > +Foam::chemistryModel<CompType, ThermoType>::calculateRR +( + const label reactionI, + const label specieI +) const +{ + scalar pf, cf, pr, cr; + label lRef, rRef; + + const volScalarField rho + ( + IOobject + ( + "rho", + this->time().timeName(), + this->mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + this->thermo().rho() + ); + + tmp<DimensionedField<scalar, volMesh> > tRR + ( + new DimensionedField<scalar, volMesh> + ( + IOobject + ( + "RR", + this->mesh().time().timeName(), + this->mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + this->mesh(), + dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0) + ) + ); + + DimensionedField<scalar, volMesh>& RR = tRR(); + + const scalarField& T = this->thermo().T(); + const scalarField& p = this->thermo().p(); + + forAll(rho, celli) + { + const scalar rhoi = rho[celli]; + const scalar Ti = T[celli]; + const scalar pi = p[celli]; + + scalarField c(nSpecie_, 0.0); + for (label i=0; i<nSpecie_; i++) + { + const scalar Yi = Y_[i][celli]; + c[i] = rhoi*Yi/specieThermo_[i].W(); + } + + const scalar w = omegaI + ( + reactionI, + c, + Ti, + pi, + pf, + cf, + lRef, + pr, + cr, + rRef + ); + + RR[celli] = w*specieThermo_[specieI].W(); + + } + + return tRR; +} + + template<class CompType, class ThermoType> void Foam::chemistryModel<CompType, ThermoType>::calculate() { diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.H index fc6dc79fdbc..368090a2d74 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.H @@ -198,6 +198,13 @@ public: const label i ); + //- Return reaction rate of the specieI in reactionI + virtual tmp<DimensionedField<scalar, volMesh> > calculateRR + ( + const label reactionI, + const label specieI + ) const; + //- Solve the reaction system for the given time step // and return the characteristic time virtual scalar solve(const scalar deltaT); diff --git a/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.C b/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.C index f94db5946b3..123805ada82 100644 --- a/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.C +++ b/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -84,4 +84,27 @@ Foam::basicSolidChemistryModel::RR(const label i) } +Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> > +Foam::basicSolidChemistryModel::calculateRR +( + const label reactionI, + const label specieI +) const +{ + notImplemented + ( + "Foam::DimensionedField<Foam::scalar, Foam::volMesh>&" + "basicSolidChemistryModel::calculateRR(const label)" + ); + + return dynamic_cast<tmp<DimensionedField<scalar, volMesh> >&> + ( + const_cast<DimensionedField<scalar, volMesh>& > + ( + DimensionedField<scalar, volMesh>::null() + ) + ); +} + + // ************************************************************************* // diff --git a/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.H b/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.H index 50d6a2e96be..44e10a31732 100644 --- a/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.H +++ b/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -133,6 +133,13 @@ public: const label i ) const = 0; + //- Returns the reaction rate of the specieI in reactionI + virtual tmp<DimensionedField<scalar, volMesh> > calculateRR + ( + const label reactionI, + const label specieI + ) const; + //- Return sensible enthalpy for gas i [J/Kg] virtual tmp<volScalarField> gasHs ( -- GitLab