Commit 3ed90ae7 authored by Henry Weller's avatar Henry Weller
Browse files

reactingTwoPhaseEulerFoam: New twoPhaseEulerFoam supporting mass-transfer and reactions

Multi-species, mass-transfer and reaction support and multi-phase
structure provided by William Bainbridge.

Integration of the latest p-U and face-p_U algorithms with William's
multi-phase structure is not quite complete due to design
incompatibilities which needs further development.  However the
integration of the functionality is complete.

The results of the tutorials are not exactly the same for the
twoPhaseEulerFoam and reactingTwoPhaseEulerFoam solvers but are very
similar.  Further analysis in needed to ensure these differences are
physical or to resolve them; in the meantime the twoPhaseEulerFoam
solver will be maintained.
parent 6ba9208e
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
set -x
wclean libso phaseSystems
wclean libso interfacialModels
wclean libso interfacialCompositionModels
wclean libso phaseCompressibleTurbulenceModels
wclean
# ----------------------------------------------------------------- end-of-file
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
set -x
wmakeLnInclude interfacialModels
wmakeLnInclude interfacialCompositionModels
wmake libso phaseSystems
wmake libso interfacialModels
wmake libso interfacialCompositionModels
wmake libso phaseCompressibleTurbulenceModels
wmake
# ----------------------------------------------------------------- end-of-file
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 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/>.
Global
CourantNo
Description
Calculates and outputs the mean and maximum Courant Numbers.
\*---------------------------------------------------------------------------*/
scalar CoNum = 0.0;
scalar meanCoNum = 0.0;
if (mesh.nInternalFaces())
{
scalarField sumPhi
(
fvc::surfaceSum(mag(phi))().internalField()
);
CoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaTValue();
meanCoNum =
0.5*(gSum(sumPhi)/gSum(mesh.V().field()))*runTime.deltaTValue();
}
Info<< "Courant Number mean: " << meanCoNum
<< " max: " << CoNum << endl;
// ************************************************************************* //
#include "CourantNo.H"
{
scalar UrCoNum = 0.5*gMax
(
fvc::surfaceSum(mag(phi1 - phi2))().internalField()/mesh.V().field()
)*runTime.deltaTValue();
Info<< "Max Ur Courant Number = " << UrCoNum << endl;
CoNum = max(CoNum, UrCoNum);
}
{
autoPtr<phaseSystem::heatTransferTable>
heatTransferPtr(fluid.heatTransfer());
phaseSystem::heatTransferTable&
heatTransfer = heatTransferPtr();
{
tmp<fvScalarMatrix> he1Eqn(phase1.heEqn());
if (he1Eqn.valid())
{
he1Eqn =
(
he1Eqn
==
*heatTransfer[phase1.name()]
+ fvOptions(alpha1, rho1, phase1.thermo().he())
);
he1Eqn->relax();
fvOptions.constrain(he1Eqn());
he1Eqn->solve();
}
}
{
tmp<fvScalarMatrix> he2Eqn(phase2.heEqn());
if (he2Eqn.valid())
{
he2Eqn =
(
he2Eqn
==
*heatTransfer[phase2.name()]
+ fvOptions(alpha2, rho2, phase2.thermo().he())
);
he2Eqn->relax();
fvOptions.constrain(he2Eqn());
he2Eqn->solve();
}
}
}
fluid.correctThermo();
reactingTwoPhaseEulerFoam.C
EXE = $(FOAM_APPBIN)/reactingTwoPhaseEulerFoam
EXE_INC = \
-IphaseSystems/lnInclude \
-IinterfacialModels/lnInclude \
-IinterfacialCompositionModels/lnInclude \
-IphaseCompressibleTurbulenceModels/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/phaseCompressible/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/fvOptions/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \
-lreactingTwoPhaseSystem \
-lreactingEulerianInterfacialModels \
-lreactingEulerianInterfacialCompositionModels \
-lphaseReactingTurbulenceModels \
-lfiniteVolume \
-lfvOptions \
-lmeshTools \
-lsampling
{
autoPtr<phaseSystem::massTransferTable>
massTransferPtr(fluid.massTransfer());
phaseSystem::massTransferTable&
massTransfer(massTransferPtr());
PtrList<volScalarField>& Y1 = phase1.Y();
PtrList<volScalarField>& Y2 = phase2.Y();
forAll(Y1, i)
{
tmp<fvScalarMatrix> Y1iEqn(phase1.YiEqn(Y1[i]));
if (Y1iEqn.valid())
{
Y1iEqn =
(
Y1iEqn
==
*massTransfer[Y1[i].name()]
+ fvOptions(alpha1, rho1, Y1[i])
);
Y1iEqn->relax();
Y1iEqn->solve(mesh.solver("Yi"));
}
}
forAll(Y2, i)
{
tmp<fvScalarMatrix> Y2iEqn(phase2.YiEqn(Y2[i]));
if (Y2iEqn.valid())
{
Y2iEqn =
(
Y2iEqn
==
*massTransfer[Y2[i].name()]
+ fvOptions(alpha2, rho2, Y2[i])
);
Y2iEqn->relax();
Y2iEqn->solve(mesh.solver("Yi"));
}
}
fluid.massTransfer(); // updates interfacial mass flow rates
}
phase1.continuityError() =
fvc::ddt(alpha1, rho1) + fvc::div(alphaRhoPhi1)
- (fvOptions(alpha1, rho1)&rho1);
phase2.continuityError() =
fvc::ddt(alpha2, rho2) + fvc::div(alphaRhoPhi2)
- (fvOptions(alpha2, rho2)&rho2);
#include "readGravitationalAcceleration.H"
#include "readhRef.H"
Info<< "Creating phaseSystem\n" << endl;
autoPtr<twoPhaseSystem> fluidPtr
(
twoPhaseSystem::New(mesh)
);
twoPhaseSystem& fluid = fluidPtr();
phaseModel& phase1 = fluid.phase1();
phaseModel& phase2 = fluid.phase2();
volScalarField& alpha1 = phase1;
volScalarField& alpha2 = phase2;
volVectorField& U1 = phase1.U();
surfaceScalarField& phi1 = phase1.phi();
surfaceScalarField& alphaPhi1 = phase1.alphaPhi();
surfaceScalarField& alphaRhoPhi1 = phase1.alphaRhoPhi();
volVectorField& U2 = phase2.U();
surfaceScalarField& phi2 = phase2.phi();
surfaceScalarField& alphaPhi2 = phase2.alphaPhi();
surfaceScalarField& alphaRhoPhi2 = phase2.alphaRhoPhi();
surfaceScalarField& phi = fluid.phi();
dimensionedScalar pMin
(
"pMin",
dimPressure,
fluid.lookup("pMin")
);
#include "gh.H"
rhoThermo& thermo1 = phase1.thermo();
rhoThermo& thermo2 = phase2.thermo();
volScalarField& p = thermo1.p();
volScalarField& rho1 = thermo1.rho();
const volScalarField& psi1 = thermo1.psi();
volScalarField& rho2 = thermo2.rho();
const volScalarField& psi2 = thermo2.psi();
Info<< "Reading field p_rgh\n" << endl;
volScalarField p_rgh
(
IOobject
(
"p_rgh",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell
(
p,
p_rgh,
pimple.dict(),
pRefCell,
pRefValue
);
IOMRFZoneList MRF(mesh);
MRF.correctBoundaryVelocity(U1);
MRF.correctBoundaryVelocity(U2);
massTransferModels/massTransferModel/massTransferModel.C
massTransferModels/massTransferModel/newMassTransferModel.C
massTransferModels/Frossling/Frossling.C
massTransferModels/sphericalMassTransfer/sphericalMassTransfer.C
surfaceTensionModels/surfaceTensionModel/surfaceTensionModel.C
surfaceTensionModels/surfaceTensionModel/newSurfaceTensionModel.C
surfaceTensionModels/constantSurfaceTensionCoefficient/constantSurfaceTensionCoefficient.C
interfaceCompositionModels/interfaceCompositionModel/interfaceCompositionModel.C
interfaceCompositionModels/interfaceCompositionModel/newInterfaceCompositionModel.C
interfaceCompositionModels/InterfaceCompositionModel/InterfaceCompositionModels.C
saturationPressureModels/saturationPressureModel/saturationPressureModel.C
saturationPressureModels/saturationPressureModel/newSaturationPressureModel.C
saturationPressureModels/Antoine/Antoine.C
saturationPressureModels/AntoineExtended/AntoineExtended.C
saturationPressureModels/ArdenBuck/ArdenBuck.C
LIB = $(FOAM_LIBBIN)/libreactingEulerianInterfacialCompositionModels
EXE_INC = \
-I../phaseSystems/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude \
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/phaseCompressible/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-lreactingTwoPhaseSystem \
-lfluidThermophysicalModels \
-lreactionThermophysicalModels \
-lspecie
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 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 "Henry.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Thermo, class OtherThermo>
Foam::interfaceCompositionModels::Henry<Thermo, OtherThermo>::Henry
(
const dictionary& dict,
const phasePair& pair
)
:
InterfaceCompositionModel<Thermo, OtherThermo>(dict, pair),
k_(dict.lookup("k")),
YSolvent_
(
IOobject
(
IOobject::groupName("YSolvent", pair.name()),
pair.phase1().mesh().time().timeName(),
pair.phase1().mesh()
),
pair.phase1().mesh(),
dimensionedScalar("one", dimless, 1)
)
{
if (k_.size() != this->speciesNames_.size())
{
FatalErrorIn
(
"template<class Thermo, class OtherThermo> "
"Foam::interfaceCompositionModels::Henry<Thermo, OtherThermo>:: "
"Henry "
"( "
"const dictionary& dict, "
"const phasePair& pair "
")"
) << "Differing number of species and solubilities"
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Thermo, class OtherThermo>
Foam::interfaceCompositionModels::Henry<Thermo, OtherThermo>::~Henry()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class Thermo, class OtherThermo>
void Foam::interfaceCompositionModels::Henry<Thermo, OtherThermo>::update
(
const volScalarField& Tf
)
{
YSolvent_ = scalar(1);
forAllConstIter(hashedWordList, this->speciesNames_, iter)
{
YSolvent_ -= Yf(*iter, Tf);
}
}
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField>
Foam::interfaceCompositionModels::Henry<Thermo, OtherThermo>::Yf
(
const word& speciesName,
const volScalarField& Tf
) const
{
if (this->speciesNames_.contains(speciesName))
{
const label index = this->speciesNames_[speciesName];
return
k_[index]
*this->otherThermo_.composition().Y(speciesName)
*this->otherThermo_.rhoThermo::rho()
/this->thermo_.rhoThermo::rho();
}
else
{
return
YSolvent_
*this->thermo_.composition().Y(speciesName);
}
}
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField>
Foam::interfaceCompositionModels::Henry<Thermo, OtherThermo>::YfPrime
(
const word& speciesName,
const volScalarField& Tf
) const
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
IOobject::groupName("YfPrime", this->pair_.name()),
this->pair_.phase1().mesh().time().timeName(),
this->pair_.phase1().mesh()
),
this->pair_.phase1().mesh(),
dimensionedScalar("zero", dimless/dimTemperature, 0)
)
);
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 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::Henry
Description
Henry's law for gas solubiliy in liquid. The concentration of the dissolved
species in the liquid is proportional to its partial pressure in the gas.
The dimensionless constant of proportionality between concentrations on
each side of the interface is \f$k\f$, and is given for each species.
Mixing in the gas is assumed to be ideal.
SourceFiles
Henry.C