Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Allwmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ wmake src/dfChemistryModel
wmake src/TurbulenceModels/compressible
wmake src/regionModels/surfaceFilmModels
src/lagrangian/Allwmake $targetType $*
wmake src/dfCombustionModels

wmake applications/solvers/df0DFoam
wmake applications/solvers/dfLowMachFoam
Expand Down
2 changes: 1 addition & 1 deletion applications/solvers/df0DFoam/EEqn.H
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
volScalarField& he = thermo.he();
if (constProp == "volume") he[0] = u0 + p[0]/rho[0];
chemistry.correctThermo();
chemistry->correctThermo();
}
4 changes: 3 additions & 1 deletion applications/solvers/df0DFoam/Make/options
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ EXE_INC = -std=c++14 \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(DF_SRC)/CanteraMixture/lnInclude \
-I$(DF_SRC)/dfChemistryModel \
-I$(DF_SRC)/dfChemistryModel/lnInclude \
-I$(DF_SRC)/dfCombustionModels/lnInclude \
-I$(CANTERA_ROOT)/include \
-I$(TORCH_ROOT)/include \
-I$(TORCH_ROOT)/include/torch/csrc/api/include
Expand All @@ -27,6 +28,7 @@ EXE_LIBS = \
-ldfCompressibleTurbulenceModels \
-lCanteraMixture \
-ldfChemistryModel \
-ldfCombustionModels \
$(CANTERA_ROOT)/lib/libcantera.so \
$(TORCH_ROOT)/lib/libtorch.so \
$(TORCH_ROOT)/lib/libc10.so \
Expand Down
6 changes: 4 additions & 2 deletions applications/solvers/df0DFoam/YEqn.H
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ tmp<fv::convectionScheme<scalar>> mvConvection
);

{
chemistry.solve(mesh.time().deltaTValue());
//chemistry.solve(mesh.time().deltaTValue());
combustion->correct();

volScalarField Yt(0.0*Y[0]);

Expand All @@ -24,7 +25,8 @@ tmp<fv::convectionScheme<scalar>> mvConvection
(
fvm::ddt(rho, Yi)
==
chemistry.RR(i)
//chemistry.RR(i)
combustion->R(Yi)
//+ fvOptions(rho, Yi)
);

Expand Down
18 changes: 11 additions & 7 deletions applications/solvers/df0DFoam/createFields.H
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,16 @@ multivariateSurfaceInterpolationScheme<scalar>::fieldTable fields;
#include "createMRF.H"
//#include "createFvOptions.H"



dfChemistryModel<basicThermo> chemistry(thermo);
PtrList<volScalarField>& Y = chemistry.Y();
const word inertSpecie(chemistry.lookup("inertSpecie"));
const label inertIndex(chemistry.species()[inertSpecie]);
Info<< "Creating reaction model\n" << endl;
autoPtr<CombustionModel<basicThermo>> combustion
(
CombustionModel<basicThermo>::New(thermo, turbulence())
);
Info<< "end Creating reaction model\n" << endl;
dfChemistryModel<basicThermo>* chemistry = combustion->chemistry();
PtrList<volScalarField>& Y = chemistry->Y();
const word inertSpecie(chemistry->lookup("inertSpecie"));
const label inertIndex(chemistry->species()[inertSpecie]);

forAll(Y, i)
{
Expand All @@ -116,4 +120,4 @@ if
}

volScalarField& he = thermo.he();
scalar u0 = he[0] - p[0]/rho[0];
scalar u0 = he[0] - p[0]/rho[0];
2 changes: 2 additions & 0 deletions applications/solvers/df0DFoam/df0DFoam.C
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Description
//#include "fvOptions.H"
#include "localEulerDdtScheme.H"
#include "fvcSmooth.H"
#include "basicThermo.H"
#include "CombustionModel.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Expand Down
2 changes: 1 addition & 1 deletion applications/solvers/dfHighSpeedFoam/Make/options
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ EXE_INC = -std=c++14 \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(DF_SRC)/CanteraMixture/lnInclude \
-I$(DF_SRC)/dfChemistryModel \
-I$(DF_SRC)/dfChemistryModel/lnInclude \
-I$(CANTERA_ROOT)/include \
-I$(TORCH_ROOT)/include \
-I$(TORCH_ROOT)/include/torch/csrc/api/include
Expand Down
2 changes: 1 addition & 1 deletion applications/solvers/dfLowMachFoam/Make/options
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ EXE_INC = -std=c++14 \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/Pstream/mpi \
-I$(DF_SRC)/CanteraMixture/lnInclude \
-I$(DF_SRC)/dfChemistryModel \
-I$(DF_SRC)/dfChemistryModel/lnInclude \
-I$(CANTERA_ROOT)/include \
-I$(TORCH_ROOT)/include \
-I$(TORCH_ROOT)/include/torch/csrc/api/include
Expand Down
2 changes: 1 addition & 1 deletion applications/solvers/dfSprayFoam/Make/options
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ EXE_INC = -std=c++14 \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalProperties/lnInclude \
-I$(DF_SRC)/thermophysicalModels/SLGThermo/lnInclude \
-I$(DF_SRC)/CanteraMixture/lnInclude \
-I$(DF_SRC)/dfChemistryModel \
-I$(DF_SRC)/dfChemistryModel/lnInclude \
-I$(CANTERA_ROOT)/include \
-I$(TORCH_ROOT)/include \
-I$(TORCH_ROOT)/include/torch/csrc/api/include
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object combustionProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

combustionModel laminar;

// ************************************************************************* //
8 changes: 4 additions & 4 deletions src/dfChemistryModel/dfChemistryModel.C
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,13 @@ Foam::scalar Foam::dfChemistryModel<ThermoType>::torchSolve
Cantera::ReactorNet sim;
sim.addReactor(react);
setNumerics(sim);
sim.advance(deltaT);
sim.advance(deltaT[cellI]);

CanteraGas_->getMassFractions(yTemp_.begin());

for (size_t i=0; i<CanteraGas_->nSpecies(); i++)
{
RR_[i][cellI] = (yTemp_[i] - yPre_[i])*rhoi/deltaT;
RR_[i][cellI] = (yTemp_[i] - yPre_[i])*rhoi/deltaT[cellI];
const scalar hc = CanteraGas_->Hf298SS(i)/CanteraGas_->molecularWeight(i); // J/kg
Qdot_[cellI] -= hc*RR_[i][cellI];
}
Expand All @@ -439,13 +439,13 @@ Foam::scalar Foam::dfChemistryModel<ThermoType>::torchSolve
for (size_t i=0; i<(CanteraGas_->nSpecies()); i++)//
{
u_[i+2] = outputs[cellI][i+2].item().to<double>()*Ystd_[i+2]+Ymu_[i+2];
yTemp_[i] = pow((yBCT_[i] + u_[i+2]*deltaT)*lambda+1,1/lambda);
yTemp_[i] = pow((yBCT_[i] + u_[i+2]*deltaT[cellI])*lambda+1,1/lambda);
Yt += yTemp_[i];
}
for (size_t i=0; i<CanteraGas_->nSpecies(); i++)
{
yTemp_[i] = yTemp_[i] / Yt;
RR_[i][torch_cell[cellI]] = (yTemp_[i] - Y_[i][torch_cell[cellI]])*rho_[torch_cell[cellI]]/deltaT;
RR_[i][torch_cell[cellI]] = (yTemp_[i] - Y_[i][torch_cell[cellI]])*rho_[torch_cell[cellI]]/deltaT[cellI];
const scalar hc = CanteraGas_->Hf298SS(i)/CanteraGas_->molecularWeight(i); // J/kg
Qdot_[torch_cell[cellI]] -= hc*RR_[i][torch_cell[cellI]];
}
Expand Down
2 changes: 2 additions & 0 deletions src/dfChemistryModel/dfChemistryModel.H
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ public:

// update T, psi, mu, alpha, rhoD, hai (if needed)
void correctThermo();

ThermoType& thermo() {return thermo_;}
};


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2018 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/>.

\*---------------------------------------------------------------------------*/

#include "ChemistryCombustion.H"

// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

template<class ReactionThermo>
Foam::ChemistryCombustion<ReactionThermo>::ChemistryCombustion
(
const word& modelType,
ReactionThermo& thermo,
const compressibleTurbulenceModel& turb,
const word& combustionProperties
)
:
CombustionModel<ReactionThermo>
(
modelType,
thermo,
turb,
combustionProperties
)
{}


// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

template<class ReactionThermo>
Foam::ChemistryCombustion<ReactionThermo>::
~ChemistryCombustion()
{}


// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //

template<class ReactionThermo>
ReactionThermo&
Foam::ChemistryCombustion<ReactionThermo>::thermo()
{
return this->chemistryPtr_->thermo();
}


template<class ReactionThermo>
const ReactionThermo&
Foam::ChemistryCombustion<ReactionThermo>::thermo() const
{
return this->chemistryPtr_->thermo();
}


// ************************************************************************* //
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2018 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/>.

Class
Foam::ChemistryCombustion

Description
Chemistry model wrapper for combustion models

SourceFiles
ChemistryCombustion.C

\*---------------------------------------------------------------------------*/

#ifndef ChemistryCombustion_H
#define ChemistryCombustion_H

#include "dfChemistryModel.H"
#include "autoPtr.H"
#include "CombustionModel.H"
//#include "BasicChemistryModel.H"


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

/*---------------------------------------------------------------------------*\
class ChemistryCombustion Declaration
\*---------------------------------------------------------------------------*/

template<class ReactionThermo>
class ChemistryCombustion
:
public CombustionModel<ReactionThermo>
{
protected:

// Protected data


public:

// Constructors

//- Construct from components and thermo
ChemistryCombustion
(
const word& modelType,
ReactionThermo& thermo,
const compressibleTurbulenceModel& turb,
const word& combustionProperties
);


//- Destructor
virtual ~ChemistryCombustion();


// Member Functions

//- Return access to the thermo package
virtual ReactionThermo& thermo();

//- Return const access to the thermo package
virtual const ReactionThermo& thermo() const;

};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#ifdef NoRepository
#include "ChemistryCombustion.C"
#endif

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //
Loading