eReactingFoam-4.x/testApp/chemFoam.C

125 lines
3.6 KiB
C

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Application
chemFoam
Description
Solver for chemistry problems, designed for use on single cell cases to
provide comparison against other chemistry solvers, that uses a single cell
mesh, and fields created from the initial conditions.
\*---------------------------------------------------------------------------*/
#include <cantera/transport.h>
#include <cantera/IdealGasMix.h>
#include "fvCFD.H"
#include "psiReactionThermo.H"
#include "psiChemistryModel.H"
#include "chemistrySolver.H"
#include "OFstream.H"
#include "thermoPhysicsTypes.H"
#include "basicMultiComponentMixture.H"
#include "cellModeller.H"
#include "diffusivityModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::noParallel();
#define CREATE_MESH createSingleCellMesh.H
#define NO_CONTROL
#include "postProcess.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createSingleCellMesh.H"
#include "createFields.H"
#include "createFieldRefs.H"
#include "readInitialConditions.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nCreate Cantera object\n" << endl;
Cantera::IdealGasMix gas_ ("gri30.xml", "gri30_mix");
Cantera::Transport *tr_ = Cantera::newTransportMgr("Mix", &gas_);
label nCanteraSp_ = gas_.nSpecies();
Info<< "\nCreate temperature space\n" << endl;
scalar Tl = 300;
scalar Tu = 3000;
scalarField T(100, 0.0);
forAll (T, i)
{
T[i] = i * (Tu - Tl) / scalar(T.size()) + Tl;
}
// initialize composition array
scalarField XY(nCanteraSp_, 0.0);
forAll(thermo.composition().species(), i)
{
XY[i] = Y[i][0];
}
Info<< "\nTemperature Loop\n" << endl;
forAll(T, i)
{
// OpenFOAM diffusivity model
thermo.T()[0] = T[i];
thermo.he() = thermo.he(p, thermo.T());
thermo.correct();
diff.correct();
// Cantera gas transport
gas_.setState_TPY(T[i], p0, XY.data());
scalarField Dc (composition.species().size(), 0.0);
tr_->getMixDiffCoeffsMass(Dc.data());
forAll(thermo.composition().species(), k)
{
Info << thermo.composition().species()[k] << tab << 100. * (diff.D(k)[0] - Dc[k]) / Dc[k] << endl;
}
Info << "mu" << tab << 100.*(diff.mu()[0] - tr_->viscosity())/tr_->viscosity() << endl;
}
Info << "End" << nl << endl;
return 0;
}
// ************************************************************************* //