diff --git a/applications/solvers/combustion/rhoReactingFoam/Make/files b/applications/solvers/combustion/rhoReactingFoam/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..3a97a48fd60990418bf233232acce5b59a82bbb8 --- /dev/null +++ b/applications/solvers/combustion/rhoReactingFoam/Make/files @@ -0,0 +1,3 @@ +rhoReactingFoam.C + +EXE = $(FOAM_APPBIN)/rhoReactingFoam diff --git a/applications/solvers/combustion/rhoReactingFoam/Make/options b/applications/solvers/combustion/rhoReactingFoam/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..e982f635a14fefba2fa2a03153961be4e1bf8fca --- /dev/null +++ b/applications/solvers/combustion/rhoReactingFoam/Make/options @@ -0,0 +1,19 @@ +EXE_INC = \ + -I../XiFoam \ + -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \ + -I$(LIB_SRC)/ODE/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -lcompressibleRASModels \ + -lcompressibleLESModels \ + -lreactionThermophysicalModels \ + -lspecie \ + -lbasicThermophysicalModels \ + -lchemistryModel \ + -lODE \ + -lfiniteVolume diff --git a/applications/solvers/combustion/rhoReactingFoam/YEqn.H b/applications/solvers/combustion/rhoReactingFoam/YEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..cda24ec2f72efc49c797a83bbcbb4ba2be6007b5 --- /dev/null +++ b/applications/solvers/combustion/rhoReactingFoam/YEqn.H @@ -0,0 +1,43 @@ +tmp<fv::convectionScheme<scalar> > mvConvection +( + fv::convectionScheme<scalar>::New + ( + mesh, + fields, + phi, + mesh.divScheme("div(phi,Yi_h)") + ) +); + +{ + label inertIndex = -1; + volScalarField Yt = 0.0*Y[0]; + + for (label i=0; i<Y.size(); i++) + { + if (Y[i].name() != inertSpecie) + { + volScalarField& Yi = Y[i]; + + solve + ( + fvm::ddt(rho, Yi) + + mvConvection->fvmDiv(phi, Yi) + - fvm::laplacian(turbulence->muEff(), Yi) + == + kappa*chemistry.RR(i), + mesh.solver("Yi") + ); + + Yi.max(0.0); + Yt += Yi; + } + else + { + inertIndex = i; + } + } + + Y[inertIndex] = scalar(1) - Yt; + Y[inertIndex].max(0.0); +} diff --git a/applications/solvers/combustion/rhoReactingFoam/chemistry.H b/applications/solvers/combustion/rhoReactingFoam/chemistry.H new file mode 100644 index 0000000000000000000000000000000000000000..d059bd9ed34f1a577175a271ef6e77360bf63bb6 --- /dev/null +++ b/applications/solvers/combustion/rhoReactingFoam/chemistry.H @@ -0,0 +1,24 @@ +{ + Info << "Solving chemistry" << endl; + + chemistry.solve + ( + runTime.value() - runTime.deltaT().value(), + runTime.deltaT().value() + ); + + // turbulent time scale + if (turbulentReaction) + { + volScalarField tk = + Cmix*sqrt(turbulence->muEff()/rho/turbulence->epsilon()); + volScalarField tc = chemistry.tc(); + + // Chalmers PaSR model + kappa = (runTime.deltaT() + tc)/(runTime.deltaT() + tc + tk); + } + else + { + kappa = 1.0; + } +} diff --git a/applications/solvers/combustion/rhoReactingFoam/createFields.H b/applications/solvers/combustion/rhoReactingFoam/createFields.H new file mode 100644 index 0000000000000000000000000000000000000000..d44b4b9171ef0f8f965b1c4732cb21132600f4d4 --- /dev/null +++ b/applications/solvers/combustion/rhoReactingFoam/createFields.H @@ -0,0 +1,85 @@ +Info<< nl << "Reading thermophysicalProperties" << endl; +autoPtr<rhoChemistryModel> pChemistry +( + rhoChemistryModel::New(mesh) +); +rhoChemistryModel& chemistry = pChemistry(); + +hReactionThermo& thermo = chemistry.thermo(); + +basicMultiComponentMixture& composition = thermo.composition(); +PtrList<volScalarField>& Y = composition.Y(); + +word inertSpecie(thermo.lookup("inertSpecie")); + +volScalarField rho +( + IOobject + ( + "rho", + runTime.timeName(), + mesh + ), + thermo.rho() +); + +Info<< "Reading field U\n" << endl; +volVectorField U +( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh +); + + +volScalarField& p = thermo.p(); +const volScalarField& psi = thermo.psi(); +volScalarField& h = thermo.h(); + + +#include "compressibleCreatePhi.H" + +volScalarField kappa +( + IOobject + ( + "kappa", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("zero", dimless, 0.0) +); + +Info << "Creating turbulence model.\n" << nl; +autoPtr<compressible::turbulenceModel> turbulence +( + compressible::turbulenceModel::New + ( + rho, + U, + phi, + thermo + ) +); + +Info<< "Creating field DpDt\n" << endl; +volScalarField DpDt = + fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); + +multivariateSurfaceInterpolationScheme<scalar>::fieldTable fields; + +forAll (Y, i) +{ + fields.add(Y[i]); +} +fields.add(h); + diff --git a/applications/solvers/combustion/rhoReactingFoam/pEqn.H b/applications/solvers/combustion/rhoReactingFoam/pEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..a58cd28decb0cf466b393e4dda16144fd2664c54 --- /dev/null +++ b/applications/solvers/combustion/rhoReactingFoam/pEqn.H @@ -0,0 +1,93 @@ +{ + rho = thermo.rho(); + + // Thermodynamic density needs to be updated by psi*d(p) after the + // pressure solution - done in 2 parts. Part 1: + thermo.rho() -= psi*p; + + volScalarField rUA = 1.0/UEqn.A(); + U = rUA*UEqn.H(); + + if (transonic) + { + surfaceScalarField phiv = + (fvc::interpolate(U) & mesh.Sf()) + + fvc::ddtPhiCorr(rUA, rho, U, phi); + + phi = fvc::interpolate(rho)*phiv; + + surfaceScalarField phid + ( + "phid", + fvc::interpolate(thermo.psi())*phiv + ); + + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix pEqn + ( + fvc::ddt(rho) + fvc::div(phi) + + correction(fvm::ddt(psi, p) + fvm::div(phid, p)) + - fvm::laplacian(rho*rUA, p) + ); + + if (ocorr == nOuterCorr && corr == nCorr && nonOrth == nNonOrthCorr) + { + pEqn.solve(mesh.solver(p.name() + "Final")); + } + else + { + pEqn.solve(); + } + + if (nonOrth == nNonOrthCorr) + { + phi += pEqn.flux(); + } + } + } + else + { + phi = + fvc::interpolate(rho) + *( + (fvc::interpolate(U) & mesh.Sf()) + + fvc::ddtPhiCorr(rUA, rho, U, phi) + ); + + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix pEqn + ( + fvc::ddt(rho) + psi*correction(fvm::ddt(p)) + + fvc::div(phi) + - fvm::laplacian(rho*rUA, p) + ); + + if (ocorr == nOuterCorr && corr == nCorr && nonOrth == nNonOrthCorr) + { + pEqn.solve(mesh.solver(p.name() + "Final")); + } + else + { + pEqn.solve(); + } + + if (nonOrth == nNonOrthCorr) + { + phi += pEqn.flux(); + } + } + } + + // Second part of thermodynamic density update + thermo.rho() += psi*p; + + #include "rhoEqn.H" + #include "compressibleContinuityErrs.H" + + U -= rUA*fvc::grad(p); + U.correctBoundaryConditions(); + + DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); +} diff --git a/applications/solvers/combustion/rhoReactingFoam/readChemistryProperties.H b/applications/solvers/combustion/rhoReactingFoam/readChemistryProperties.H new file mode 100644 index 0000000000000000000000000000000000000000..ab51afe28361cdf65bc74af68961a6732535d6b3 --- /dev/null +++ b/applications/solvers/combustion/rhoReactingFoam/readChemistryProperties.H @@ -0,0 +1,23 @@ +Info<< "Reading chemistry properties\n" << endl; + +IOdictionary chemistryProperties +( + IOobject + ( + "chemistryProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) +); + +Switch turbulentReaction(chemistryProperties.lookup("turbulentReaction")); + +dimensionedScalar Cmix("Cmix", dimless, 1.0); + +if (turbulentReaction) +{ + chemistryProperties.lookup("Cmix") >> Cmix; +} diff --git a/applications/solvers/combustion/rhoReactingFoam/rhoReactingFoam.C b/applications/solvers/combustion/rhoReactingFoam/rhoReactingFoam.C new file mode 100644 index 0000000000000000000000000000000000000000..16f49a197fe9d5028a1db860bf7bb58ddbf7244c --- /dev/null +++ b/applications/solvers/combustion/rhoReactingFoam/rhoReactingFoam.C @@ -0,0 +1,102 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM 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 General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + rhoReactingFoam + +Description + Chemical reaction code using density based thermodynamics package. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "hReactionThermo.H" +#include "turbulenceModel.H" +#include "rhoChemistryModel.H" +#include "chemistrySolver.H" +#include "multivariateScheme.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "readChemistryProperties.H" + #include "readEnvironmentalProperties.H" + #include "createFields.H" + #include "initContinuityErrs.H" + #include "readTimeControls.H" + #include "compressibleCourantNo.H" + #include "setInitialDeltaT.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info << "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readTimeControls.H" + #include "readPISOControls.H" + #include "compressibleCourantNo.H" + #include "setDeltaT.H" + + runTime++; + Info<< "Time = " << runTime.timeName() << nl << endl; + + #include "chemistry.H" + #include "rhoEqn.H" + #include "UEqn.H" + + for (label ocorr=1; ocorr <= nOuterCorr; ocorr++) + { + #include "YEqn.H" + #include "hEqn.H" + + // --- PISO loop + for (int corr=1; corr<=nCorr; corr++) + { + #include "pEqn.H" + } + } + + turbulence->correct(); + + rho = thermo.rho(); + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* //