multiphaseEuler: phaseTransferModels::reactionDriven: Permit transfers in both directions

The syntax of this model has changed to permit transfers of species in
either direction. A list of transferring species is now given for each
phase, rather than identifying a single reacting phase. For example:

    phaseTransfer
    (
        vapour_particles
        {
            type reactionDriven;

            // TiO2 and TiO2_s are created by reactions in the vapour
            // and are then transferred to the particles
            species.vapour (TiO2 TiO2_s);

            // H2O is created by reactions in the particles and is then
            // transferred to the vapour
            species.particles (H2O);
        }
    );
This commit is contained in:
Will Bainbridge
2024-03-05 11:11:18 +00:00
parent 0840ae5d37
commit 2dd82773fc
5 changed files with 62 additions and 43 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -123,7 +123,7 @@ Foam::blendedPhaseTransferModel::dmdtf() const
&phaseTransferModel::dmdtf, &phaseTransferModel::dmdtf,
"dmdtf", "dmdtf",
phaseTransferModel::dimDmdt, phaseTransferModel::dimDmdt,
true false
); );
} }
@ -137,7 +137,7 @@ Foam::blendedPhaseTransferModel::d2mdtdpf() const
&phaseTransferModel::d2mdtdpf, &phaseTransferModel::d2mdtdpf,
"d2mdtdpf", "d2mdtdpf",
phaseTransferModel::dimD2mdtdp, phaseTransferModel::dimD2mdtdp,
true false
); );
} }
@ -157,7 +157,7 @@ Foam::blendedPhaseTransferModel::dmidtf() const
&phaseTransferModel::dmidtf, &phaseTransferModel::dmidtf,
"dmidtf", "dmidtf",
phaseTransferModel::dimDmdt, phaseTransferModel::dimDmdt,
true false
); );
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2019-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -39,6 +39,20 @@ namespace phaseTransferModels
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<bool Index>
Foam::word Foam::phaseTransferModels::reactionDriven::speciesKey() const
{
return
IOobject::groupName
(
"species",
(!Index ? interface_.phase1() : interface_.phase2()).name()
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::phaseTransferModels::reactionDriven::reactionDriven Foam::phaseTransferModels::reactionDriven::reactionDriven
@ -49,17 +63,22 @@ Foam::phaseTransferModels::reactionDriven::reactionDriven
: :
phaseTransferModel(dict, interface), phaseTransferModel(dict, interface),
interface_(interface), interface_(interface),
reactingName_(dict.lookup("reactingPhase")), species1_(dict.lookupOrDefault<wordList>(speciesKey<0>(), wordList())),
reactingPhase_ species2_(dict.lookupOrDefault<wordList>(speciesKey<1>(), wordList())),
( species_()
reactingName_ == interface_.phase1().name() {
? interface_.phase1() if (!dict.found(speciesKey<0>()) && !dict.found(speciesKey<1>()))
: interface_.phase2() {
), FatalIOErrorInFunction(dict)
otherPhase_(interface.otherPhase(reactingPhase_)), << "No transferring species specified. Specify either "
sign_(reactingName_ == interface_.phase1().name() ? -1 : 1), << speciesKey<0>() << " or " << speciesKey<1>() << " or both."
species_(dict.lookup("species")) << exit(FatalIOError);
{} }
wordList species(species1_);
species.append(species2_);
species_.transfer(species);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -82,18 +101,21 @@ Foam::phaseTransferModels::reactionDriven::dmidtf() const
{ {
HashPtrTable<volScalarField> result; HashPtrTable<volScalarField> result;
forAll(species_, i) const phaseModel& phase1 = interface_.phase1();
const phaseModel& phase2 = interface_.phase2();
forAll(species1_, i)
{ {
const word name = species_[i]; volScalarField& Y1 =
const_cast<volScalarField&>(phase1.Y(species1_[i]));
result.set(species_[i], (- phase1*phase1.R(Y1) & Y1).ptr());
}
volScalarField& Y = forAll(species2_, i)
const_cast<volScalarField&>(reactingPhase_.Y(name)); {
volScalarField& Y2 =
result.set const_cast<volScalarField&>(phase2.Y(species2_[i]));
( result.set(species_[i], (phase2*phase2.R(Y2) & Y2).ptr());
species_[i],
(sign_*reactingPhase_*reactingPhase_.R(Y) & Y).ptr()
);
} }
return result; return result;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2019-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -60,20 +60,21 @@ private:
//- Interface //- Interface
const phaseInterface interface_; const phaseInterface interface_;
//- The name of the phase where the reactions occur //- List of species transferring out of phase 1
const word reactingName_; const hashedWordList species1_;
//- Const reference to the reacting phase //- List of species transferring out of phase 2
const phaseModel& reactingPhase_; const hashedWordList species2_;
//- Const reference to the other phase //- List of all transferring species
const phaseModel& otherPhase_; hashedWordList species_;
//- Sign used to multiply the source terms
const scalar sign_;
//- List of species changing phase // Private Member Functions
const hashedWordList species_;
//- Keyword for the list of species
template<bool Index>
word speciesKey() const;
public: public:

View File

@ -180,9 +180,7 @@ phaseTransfer
particles_dispersedIn_vapour particles_dispersedIn_vapour
{ {
type reactionDriven; type reactionDriven;
reactingPhase vapour; species.vapour (TiO2);
targetPhase particles;
species (TiO2);
} }
} }

View File

@ -192,9 +192,7 @@ phaseTransfer
particles_dispersedIn_vapour particles_dispersedIn_vapour
{ {
type reactionDriven; type reactionDriven;
reactingPhase vapour; species.vapour (TiO2 TiO2_s);
targetPhase particles;
species (TiO2 TiO2_s);
} }
} }