diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/Make/files b/applications/solvers/Lagrangian/reactingParcelFoam/Make/files new file mode 100644 index 0000000000..ea13ecb0c5 --- /dev/null +++ b/applications/solvers/Lagrangian/reactingParcelFoam/Make/files @@ -0,0 +1,3 @@ +reactingParcelFoam.C + +EXE = $(FOAM_USER_APPBIN)/reactingParcelFoam diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/Make/options b/applications/solvers/Lagrangian/reactingParcelFoam/Make/options new file mode 100644 index 0000000000..21575a94ae --- /dev/null +++ b/applications/solvers/Lagrangian/reactingParcelFoam/Make/options @@ -0,0 +1,40 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I${LIB_SRC}/meshTools/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \ + -I$(LIB_SRC)/lagrangian/basic/lnInclude \ + -I$(LIB_SRC)/lagrangian/intermediate/lnInclude \ + -I$(LIB_SRC)/lagrangian/coalCombustion/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/pdfs/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/liquids/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/liquidMixture/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/solids/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/solidMixture/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/combustion/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \ + -I$(LIB_SRC)/ODE/lnInclude + +EXE_LIBS = \ + -L$(FOAM_USER_LIBBIN) \ + -lfiniteVolume \ + -lmeshTools \ + -lcompressibleRASModels \ + -lcompressibleLESModels \ + -llagrangian \ + -llagrangianIntermediate \ + -lcoalCombustion\ + -lspecie \ + -lbasicThermophysicalModels \ + -lliquids \ + -lliquidMixture \ + -lsolids \ + -lsolidMixture \ + -lthermophysicalFunctions \ + -lcombustionThermophysicalModels \ + -lchemistryModel \ + -lradiation \ + -lODE diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/UEqn.H b/applications/solvers/Lagrangian/reactingParcelFoam/UEqn.H new file mode 100644 index 0000000000..ce4292dec9 --- /dev/null +++ b/applications/solvers/Lagrangian/reactingParcelFoam/UEqn.H @@ -0,0 +1,16 @@ + fvVectorMatrix UEqn + ( + fvm::ddt(rho, U) + + fvm::div(phi, U) + + turbulence->divDevRhoReff(U) + == + rho.dimensionedInternalField()*g + + reactingParcels.SU1() + ); + + UEqn.relax(); + + if (momentumPredictor) + { + solve(UEqn == -fvc::grad(p)); + } diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/YEqn.H b/applications/solvers/Lagrangian/reactingParcelFoam/YEqn.H new file mode 100644 index 0000000000..d7dd43e6d7 --- /dev/null +++ b/applications/solvers/Lagrangian/reactingParcelFoam/YEqn.H @@ -0,0 +1,45 @@ + +tmp > mvConvection +( + fv::convectionScheme::New + ( + mesh, + fields, + phi, + mesh.divScheme("div(phi,Yi_h)") + ) +); + + +{ + label inertIndex = -1; + volScalarField Yt = 0.0*Y[0]; + + for (label i=0; ifvmDiv(phi, Yi) + - fvm::laplacian(turbulence->muEff(), Yi) + == + reactingParcels.Srho1(i) + + kappa*chemistry.RR(i)().dimensionedInternalField() + ); + + Yi.max(0.0); + Yt += Yi; + } + else + { + inertIndex = i; + } + } + + Y[inertIndex] = scalar(1) - Yt; + Y[inertIndex].max(0.0); + +} diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/additionalOutput.H b/applications/solvers/Lagrangian/reactingParcelFoam/additionalOutput.H new file mode 100644 index 0000000000..9edd35eb7c --- /dev/null +++ b/applications/solvers/Lagrangian/reactingParcelFoam/additionalOutput.H @@ -0,0 +1,48 @@ +{ + tmp tdQ + ( + new volScalarField + ( + IOobject + ( + "dQ", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar + ( + "zero", + dimensionSet(1, -3, -1, 0, 0, 0, 0), + 0.0 + ) + ) + ); + + scalarField& dQ = tdQ(); + + scalarField cp(dQ.size(), 0.0); + + forAll(Y, i) + { + volScalarField RRi = chemistry.RR(i); + + forAll(h, celli) + { + scalar Ti = T[celli]; + cp[celli] += Y[i][celli]*chemistry.specieThermo()[i].Cp(Ti); + scalar hi = chemistry.specieThermo()[i].h(Ti); + scalar RR = RRi[celli]; + dQ[celli] -= hi*RR; + } + } + + forAll(dQ, celli) + { + dQ[celli] /= cp[celli]; + } + + tdQ().write(); +} diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/chemistry.H b/applications/solvers/Lagrangian/reactingParcelFoam/chemistry.H new file mode 100644 index 0000000000..07b1e9953b --- /dev/null +++ b/applications/solvers/Lagrangian/reactingParcelFoam/chemistry.H @@ -0,0 +1,25 @@ +{ + Info << "Solving chemistry" << endl; + + chemistry.solve + ( + runTime.value() - runTime.deltaT().value(), + runTime.deltaT().value() + ); + + // turbulent time scale + if (turbulentReaction) + { + DimensionedField tk = + Cmix*sqrt(turbulence->muEff()/rho/turbulence->epsilon()); + DimensionedField tc = + chemistry.tc()().dimensionedInternalField(); + + // Chalmers PaSR model + kappa = (runTime.deltaT() + tc)/(runTime.deltaT() + tc + tk); + } + else + { + kappa = 1.0; + } +} diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/createClouds.H b/applications/solvers/Lagrangian/reactingParcelFoam/createClouds.H new file mode 100644 index 0000000000..238ee3b18b --- /dev/null +++ b/applications/solvers/Lagrangian/reactingParcelFoam/createClouds.H @@ -0,0 +1,42 @@ +Info<< "\nConstructing interpolation" << endl; + +Info << "\nConstructing gas properties" << endl; +/* +PtrList gasProperties(Y.size()); +forAll(gasProperties, i) +{ + gasProperties.set + ( + i, + new specieConstProperties + ( + dynamic_cast > > >&> + (thermo()).speciesData()[i] + ) + ); +} +*/ +PtrList gasProperties(Y.size()); +forAll(gasProperties, i) +{ + gasProperties.set + ( + i, + new specieReactingProperties + ( + dynamic_cast(thermo()).speciesData()[i] + ) + ); +} + +Info<< "\nConstructing reacting cloud" << endl; +basicReactingCloud reactingParcels +( + "reactingCloud1", + rho, + U, + g, + thermo(), + gasProperties +); diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/createFields.H b/applications/solvers/Lagrangian/reactingParcelFoam/createFields.H new file mode 100644 index 0000000000..079a4f2e1d --- /dev/null +++ b/applications/solvers/Lagrangian/reactingParcelFoam/createFields.H @@ -0,0 +1,141 @@ + Info<< "Reading thermophysical properties\n" << endl; + + autoPtr thermo + ( + hCombustionThermo::New(mesh) + ); + + combustionMixture& composition = thermo->composition(); + PtrList& Y = composition.Y(); + + word inertSpecie(thermo->lookup("inertSpecie")); + + volScalarField& p = thermo->p(); + volScalarField& h = thermo->h(); + const volScalarField& T = thermo->T(); + const volScalarField& psi = thermo->psi(); + + volScalarField rho + ( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + thermo->rho() + ); + +// lagrangian coal density field +/* volScalarField rholc + ( + IOobject + ( + "rholc", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("zero", dimensionSet(1, -3, 0, 0, 0, 0, 0), 0.0) + ); + +// lagrangian limestone density field + volScalarField rhols + ( + IOobject + ( + "rhols", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("zero", dimensionSet(1, -3, 0, 0, 0, 0, 0), 0.0) + ); + +// lagrangian total density field + volScalarField rhol + ( + IOobject + ( + "rhol", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("zero", dimensionSet(1, -3, 0, 0, 0, 0, 0), 0.0) + );*/ + + Info<< "\nReading field U\n" << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + +# include "compressibleCreatePhi.H" + + DimensionedField kappa + ( + IOobject + ( + "kappa", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("zero", dimless, 0.0) + ); + + Info<< "Creating turbulence model\n" << endl; + autoPtr 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); + + Info << "Constructing chemical mechanism" << endl; + chemistryModel chemistry + ( + thermo(), + rho + ); + + multivariateSurfaceInterpolationScheme::fieldTable fields; + + forAll (Y, i) + { + fields.add(Y[i]); + } + fields.add(h); + + Info<< "Creating radiation model\n" << endl; + autoPtr radiation + ( + radiation::radiationModel::New(T) + ); diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/hEqn.H b/applications/solvers/Lagrangian/reactingParcelFoam/hEqn.H new file mode 100644 index 0000000000..e4fc046097 --- /dev/null +++ b/applications/solvers/Lagrangian/reactingParcelFoam/hEqn.H @@ -0,0 +1,20 @@ +{ + fvScalarMatrix hEqn + ( + fvm::ddt(rho, h) + + fvm::div(phi, h) + - fvm::laplacian(turbulence->alphaEff(), h) + == + DpDt + + reactingParcels.Sh1() + + radiation->Sh(thermo()) + ); + + hEqn.relax(); + + hEqn.solve(); + + thermo->correct(); + + radiation->correct(); +} diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/pEqn.H b/applications/solvers/Lagrangian/reactingParcelFoam/pEqn.H new file mode 100644 index 0000000000..5516afe515 --- /dev/null +++ b/applications/solvers/Lagrangian/reactingParcelFoam/pEqn.H @@ -0,0 +1,72 @@ +rho = thermo->rho(); + +volScalarField rUA = 1.0/UEqn.A(); +U = rUA*UEqn.H(); + +if (transonic) +{ + surfaceScalarField phid + ( + "phid", + fvc::interpolate(thermo->psi()) + *( + (fvc::interpolate(U) & mesh.Sf()) + + fvc::ddtPhiCorr(rUA, rho, U, phi) + ) + ); + + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix pEqn + ( + fvm::ddt(psi, p) + + fvm::div(phid, p) + - fvm::laplacian(rho*rUA, p) + == + reactingParcels.Srho1() + ); + + 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 + ( + fvm::ddt(psi, p) + + fvc::div(phi) + - fvm::laplacian(rho*rUA, p) + == + reactingParcels.Srho1() + ); + + pEqn.solve(); + + if (nonOrth == nNonOrthCorr) + { + phi += pEqn.flux(); + } + } +} + +#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/Lagrangian/reactingParcelFoam/reactingParcelFoam.C b/applications/solvers/Lagrangian/reactingParcelFoam/reactingParcelFoam.C new file mode 100644 index 0000000000..122f7dffb7 --- /dev/null +++ b/applications/solvers/Lagrangian/reactingParcelFoam/reactingParcelFoam.C @@ -0,0 +1,120 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 + +Description + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "hCombustionThermo.H" +#include "turbulenceModel.H" +#include "basicThermoCloud.H" +#include "basicReactingCloud.H" +#include "chemistryModel.H" +#include "chemistrySolver.H" +#include "ReactingCloudThermoTypes.H" +#include "radiationModel.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 "createClouds.H" +# include "readPISOControls.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; + + Info << "Evolving reacting cloud" << endl; + + reactingParcels.evolve(); + + reactingParcels.info(); + +# include "chemistry.H" +# include "rhoEqn.H" + + // --- PIMPLE loop + for (int ocorr=1; ocorr<=nOuterCorr; ocorr++) + { +# include "UEqn.H" +# include "YEqn.H" + + // --- PISO loop + for (int corr=1; corr<=nCorr; corr++) + { +# include "hEqn.H" +# include "pEqn.H" + } + + Info<< "T gas min/max = " << min(T).value() << ", " + << max(T).value() << endl; + } + + turbulence->correct(); + + rho = thermo->rho(); + + if (runTime.write()) + { +# include "additionalOutput.H" + } + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return(0); +} + + +// ************************************************************************* // diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/readChemistryProperties.H b/applications/solvers/Lagrangian/reactingParcelFoam/readChemistryProperties.H new file mode 100644 index 0000000000..1a60e6fb34 --- /dev/null +++ b/applications/solvers/Lagrangian/reactingParcelFoam/readChemistryProperties.H @@ -0,0 +1,22 @@ +Info<< "Reading chemistry properties\n" << endl; + +IOdictionary chemistryProperties +( + IOobject + ( + "chemistryProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) +); + +Switch turbulentReaction(chemistryProperties.lookup("turbulentReaction")); + +dimensionedScalar Cmix("Cmix", dimless, 1.0); + +if (turbulentReaction) +{ + chemistryProperties.lookup("Cmix") >> Cmix; +} diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/rhoEqn.H b/applications/solvers/Lagrangian/reactingParcelFoam/rhoEqn.H new file mode 100644 index 0000000000..d6b129452e --- /dev/null +++ b/applications/solvers/Lagrangian/reactingParcelFoam/rhoEqn.H @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 + +Global + rhoEqn + +Description + Solve the continuity for density. + +\*---------------------------------------------------------------------------*/ + +{ + solve + ( + fvm::ddt(rho) + + fvc::div(phi) + == + reactingParcels.Srho1() + ); +} + +// ************************************************************************* //