From 43ae91c1f7c57551de6e2575c94ddc80a1dcec51 Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Fri, 27 Nov 2015 15:32:33 +0000 Subject: [PATCH] ENH: Code clean-up --- ...emperatureCoupledMixedFvPatchScalarField.C | 111 +++++---- ...emperatureCoupledMixedFvPatchScalarField.H | 211 ++++++++++-------- 2 files changed, 179 insertions(+), 143 deletions(-) diff --git a/src/thermophysicalModels/properties/liquidPropertiesFvPatchFields/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C b/src/thermophysicalModels/properties/liquidPropertiesFvPatchFields/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C index 4839fbddb76..1bc31648218 100644 --- a/src/thermophysicalModels/properties/liquidPropertiesFvPatchFields/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/properties/liquidPropertiesFvPatchFields/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C @@ -53,11 +53,9 @@ namespace Foam const Foam::NamedEnum < - Foam:: - humidityTemperatureCoupledMixedFvPatchScalarField:: - massTransferMode, + Foam::humidityTemperatureCoupledMixedFvPatchScalarField::massTransferMode, 4 -> Foam::humidityTemperatureCoupledMixedFvPatchScalarField::MassModeTypeNames_; +> Foam::humidityTemperatureCoupledMixedFvPatchScalarField::massModeTypeNames_; // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // @@ -145,11 +143,15 @@ humidityTemperatureCoupledMixedFvPatchScalarField : mixedFvPatchScalarField(p, iF), temperatureCoupledBase(patch(), "fluidThermo", "undefined", "undefined-K"), - mode_(mConstantMass), - TnbrName_("undefined-Tnbr"), - QrNbrName_("undefined-Qr"), - QrName_("undefined-Qr"), - specieName_("undefined"), + mode_(mtConstantMass), + pName_("p"), + UName_("U"), + rhoName_("rho"), + muName_("thermo:mu"), + TnbrName_("T"), + QrNbrName_("none"), + QrName_("none"), + specieName_("none"), liquid_(NULL), liquidDict_(NULL), mass_(patch().size(), 0.0), @@ -182,6 +184,10 @@ humidityTemperatureCoupledMixedFvPatchScalarField mixedFvPatchScalarField(psf, p, iF, mapper), temperatureCoupledBase(patch(), psf), mode_(psf.mode_), + pName_(psf.pName_), + UName_(psf.UName_), + rhoName_(psf.rhoName_), + muName_(psf.muName_), TnbrName_(psf.TnbrName_), QrNbrName_(psf.QrNbrName_), QrName_(psf.QrName_), @@ -212,7 +218,11 @@ humidityTemperatureCoupledMixedFvPatchScalarField : mixedFvPatchScalarField(p, iF), temperatureCoupledBase(patch(), dict), - mode_(mCondensationAndEvaporation), + mode_(mtCondensationAndEvaporation), + pName_(dict.lookupOrDefault<word>("p", "p")), + UName_(dict.lookupOrDefault<word>("U", "U")), + rhoName_(dict.lookupOrDefault<word>("rho", "rho")), + muName_(dict.lookupOrDefault<word>("mu", "thermo:mu")), TnbrName_(dict.lookupOrDefault<word>("Tnbr", "T")), QrNbrName_(dict.lookupOrDefault<word>("QrNbr", "none")), QrName_(dict.lookupOrDefault<word>("Qr", "none")), @@ -255,7 +265,7 @@ humidityTemperatureCoupledMixedFvPatchScalarField if (dict.found("mode")) { - mode_ = MassModeTypeNames_.read(dict.lookup("mode")); + mode_ = massModeTypeNames_.read(dict.lookup("mode")); fluid_ = true; } @@ -263,7 +273,7 @@ humidityTemperatureCoupledMixedFvPatchScalarField { switch(mode_) { - case mConstantMass: + case mtConstantMass: { thickness_ = scalarField("thickness", dict, p.size()); cp_ = scalarField("cp", dict, p.size()); @@ -271,9 +281,9 @@ humidityTemperatureCoupledMixedFvPatchScalarField break; } - case mCondensation: - case mEvaporation: - case mCondensationAndEvaporation: + case mtCondensation: + case mtEvaporation: + case mtCondensationAndEvaporation: { Mcomp_ = readScalar(dict.lookup("carrierMolWeight")); L_ = readScalar(dict.lookup("L")); @@ -286,6 +296,7 @@ humidityTemperatureCoupledMixedFvPatchScalarField { scalarField& Tp = *this; const scalarField& magSf = patch().magSf(); + // Assume initially standard pressure for rho calculation scalar pf = 1e5; thickness_ = scalarField("thickness", dict, p.size()); @@ -316,7 +327,7 @@ humidityTemperatureCoupledMixedFvPatchScalarField << " on patch " << patch().name() << nl << "Please set 'mode' to one of " - << MassModeTypeNames_.sortedToc() + << massModeTypeNames_.sortedToc() << exit(FatalIOError); } } @@ -351,6 +362,10 @@ humidityTemperatureCoupledMixedFvPatchScalarField mixedFvPatchScalarField(psf, iF), temperatureCoupledBase(patch(), psf), mode_(psf.mode_), + pName_(psf.pName_), + UName_(psf.UName_), + rhoName_(psf.rhoName_), + muName_(psf.muName_), TnbrName_(psf.TnbrName_), QrNbrName_(psf.QrNbrName_), QrName_(psf.QrName_), @@ -458,7 +473,7 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::updateCoeffs() const scalarField K(this->kappa(*this)); - // nrb kappa is done separately because I need kappa solid for + // Neighbour kappa done separately because we need kappa solid for the // htc correlation scalarField nbrK(nbrField.kappa(*this)); mpp.distribute(nbrK); @@ -480,7 +495,7 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::updateCoeffs() const scalarField myDelta(patch().deltaCoeffs()); - if (mode_ != mConstantMass) + if (mode_ != mtConstantMass) { scalarField cp(patch().size(), 0.0); scalarField hfg(patch().size(), 0.0); @@ -503,16 +518,16 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::updateCoeffs() ); const fvPatchScalarField& pp = - patch().lookupPatchField<volScalarField, scalar>("p"); + patch().lookupPatchField<volScalarField, scalar>(pName_); const fvPatchVectorField& Up = - patch().lookupPatchField<volVectorField, vector>("U"); + patch().lookupPatchField<volVectorField, vector>(UName_); const fvPatchScalarField& rhop = - patch().lookupPatchField<volScalarField, scalar>("rho"); + patch().lookupPatchField<volScalarField, scalar>(rhoName_); const fvPatchScalarField& mup = - patch().lookupPatchField<volScalarField, scalar>("thermo:mu"); + patch().lookupPatchField<volScalarField, scalar>(muName_); const vectorField Ui(Up.patchInternalField()); const scalarField Yi(Yp.patchInternalField()); @@ -550,15 +565,8 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::updateCoeffs() scalar c = 17.65; scalar TintDeg = Tint - 273; Tdew = - b* - ( - log(RH) - + (c*TintDeg)/(b + TintDeg) - ) - / - ( - c - log(RH) - ((c*TintDeg)/(b + TintDeg)) - ) + 273; + b*(log(RH) + (c*TintDeg)/(b + TintDeg)) + /(c - log(RH) - ((c*TintDeg)/(b + TintDeg))) + 273; } if @@ -566,18 +574,17 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::updateCoeffs() Tf < Tdew && RH > RHmin && ( - mode_ == mCondensation - || mode_ == mCondensationAndEvaporation + mode_ == mtCondensation + || mode_ == mtCondensationAndEvaporation ) ) { - htc[faceI] = - this->htcCondensation(TSat, Re)*nbrK[faceI]/L_; + htc[faceI] = htcCondensation(TSat, Re)*nbrK[faceI]/L_; scalar htcTotal = 1.0/((1.0/myKDelta_[faceI]) + (1.0/htc[faceI])); - // Heat flux W (>0 heat is converted into mass) + // Heat flux [W] (>0 heat is converted into mass) const scalar q = (Tint - Tf)*htcTotal*magSf[faceI]; // Mass flux rate [Kg/s/m2] @@ -595,8 +602,8 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::updateCoeffs() Tf > Tvap_ && mass_[faceI] > 0.0 && ( - mode_ == mEvaporation - || mode_ == mCondensationAndEvaporation + mode_ == mtEvaporation + || mode_ == mtCondensationAndEvaporation ) ) { @@ -606,6 +613,7 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::updateCoeffs() const scalar Sh = this->Sh(Re, Sc); const scalar Ys = Mv*pSat/(Mv*pSat + Mcomp_*(pf - pSat)); + // Mass transfer coefficient [m/s] const scalar hm = Dab*Sh/L_; @@ -620,12 +628,11 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::updateCoeffs() // Total mass accumulated [Kg] mass_[faceI] += dm[faceI]*magSf[faceI]*dt; - htc[faceI] = - this->htcCondensation(TSat, Re)*nbrK[faceI]/L_; + htc[faceI] = htcCondensation(TSat, Re)*nbrK[faceI]/L_; } else if (Tf > Tdew && Tf < Tvap_ && mass_[faceI] > 0.0) { - htc[faceI] = this->htcCondensation(TSat, Re)*nbrK[faceI]/L_; + htc[faceI] = htcCondensation(TSat, Re)*nbrK[faceI]/L_; } else if (mass_[faceI] == 0.0) { @@ -722,10 +729,10 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::updateCoeffs() Info<< mesh.name() << ':' << patch().name() << ':' - << this->dimensionedInternalField().name() << " <- " + << dimensionedInternalField().name() << " <- " << nbrMesh.name() << ':' << nbrPatch.name() << ':' - << this->dimensionedInternalField().name() << " :" << nl + << dimensionedInternalField().name() << " :" << nl << " Total mass flux [Kg/s] : " << Qdm << nl << " Total mass on the wall [Kg] : " << QMass << nl << " Total heat (>0 leaving the wall to the fluid) [W] : " @@ -748,15 +755,21 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::write ) const { mixedFvPatchScalarField::write(os); - os.writeKeyword("QrNbr")<< QrNbrName_ << token::END_STATEMENT << nl; - os.writeKeyword("Qr")<< QrName_ << token::END_STATEMENT << nl; + writeEntryIfDifferent<word>(os, "p", "p", pName_); + writeEntryIfDifferent<word>(os, "U", "U", UName_); + writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + writeEntryIfDifferent<word>(os, "mu", "thermo:mu", muName_); + writeEntryIfDifferent<word>(os, "Tnbr", "T", TnbrName_); + writeEntryIfDifferent<word>(os, "QrNbr", "none", QrNbrName_); + writeEntryIfDifferent<word>(os, "Qr", "none", QrName_); if (fluid_) { - os.writeKeyword("mode")<< MassModeTypeNames_[mode_] - << token::END_STATEMENT <<nl; - os.writeKeyword("specieName")<< specieName_ + os.writeKeyword("mode")<< massModeTypeNames_[mode_] << token::END_STATEMENT <<nl; + + writeEntryIfDifferent<word>(os, "specieName", "none", specieName_); + os.writeKeyword("carrierMolWeight")<< Mcomp_ << token::END_STATEMENT <<nl; @@ -765,7 +778,7 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::write os.writeKeyword("fluid")<< fluid_ << token::END_STATEMENT << nl; mass_.writeEntry("mass", os); - if (mode_ == mConstantMass) + if (mode_ == mtConstantMass) { cp_.writeEntry("cp", os); rho_.writeEntry("rho", os); diff --git a/src/thermophysicalModels/properties/liquidPropertiesFvPatchFields/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.H b/src/thermophysicalModels/properties/liquidPropertiesFvPatchFields/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.H index 95e119eb8cf..9c94c4fcec3 100644 --- a/src/thermophysicalModels/properties/liquidPropertiesFvPatchFields/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.H +++ b/src/thermophysicalModels/properties/liquidPropertiesFvPatchFields/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.H @@ -28,112 +28,120 @@ Class humidityTemperatureCoupledMixedFvPatchScalarField Description - Mixed boundary condition for temperature to be used on coupling flow and - solid regions. This BC can operate in four modes: - - 1) 'inert' : thermal inertia is important and no condensation/evaporation - is taken place. - 2) 'condensation' : just condensation is taken place - 3) 'vaporization' : just evaporation is take place - 4) 'condEvap' : both condensation and evaporation take place - - For 'inert' operation the 'rho', 'thickness' and 'cp' entries are needed. - - In 'condensation' mode when the wall temperature (Tw) is bellow the dew - temperature (Tdew) condesation takes place and the resulting condensed mass - is stored on the wall. - - In 'vaporization' the initial mass is vaporized when Tw is above the - input vaporization temperature (Tvap). - - In 'condEvap', condensation and evaporation take place simultaneously. - - The BC assumes no mass flow on the wall.i.e the mass condensed on a face - remains on that face. It uses a 'lump mass' model to include thermal + Mixed boundary condition for temperature to be used at the coupling + interface between fluid solid regions. + + This boundary condition can operate in four modes: + - \c constantMass: thermal inertia only + - requires \c rho, \c thickness and \cp + - \c condensation: condensation only + - when the wall temperature (Tw) is below the dew temperature (Tdew) + condesation takes place and the resulting condensed mass is stored + on the wall + - \c evaporation: evaporation only + - initial mass is vaporized when Tw is above the input vaporization + temperature (Tvap). + - \c condensationAndEvaporation : condensation and evaporation take place + simultaneously. + + There is no mass flow on the wall, i.e. the mass condensed on a face + remains on that face. It uses a 'lumped mass' model to include thermal inertia effects. - It assumes a drop-wise type of condensation and its heat transfer Nu number - is: + It assumes a drop-wise type of condensation, whereby its heat transfer + Nusselt number is calculated using: + \f{eqnarray*}{ + 51104 + 2044 T & T > 295 & T < 373 \\ + 255510 & T > 373 & + \f} - 51104 + 2044*T T > 295 T < 373 - 255510 T > 373 + Reference: + - T. Bergam, A.Lavine, F. Incropera and D. Dewitt. Heat and Mass Transfer. + 7th Edition. Chapter 10. - T. Bergam, A.Lavine, F. Incropera and D. Dewitt. Heat and Mass Transfer. - 7th Edition. Chapter 10. + The mass transfer correlation used is: - The mass transfer correlation used is hm = Dab*Sh/L + \f[ h_m = D_{ab} \frac{Sc}{L} \f] where: + \vartable + D_{ab} | mass vapour difussivity + L | characteristic length + Sc | Schmidt number + \endvartable - Dab is the mass vapor difussivity - L is the characteristic lenght - Sc the Schmidt number and it is calculated as: + The Schmidt number is calculated using: - 0.664*sqrt(Re)*cbrt(Sc) Re < 5.0E+05 - 0.037*pow(Re, 0.8)*cbrt(Sc) Re > 5.0E+05 + \f{eqnarray*}{ + 0.664 Re^\frac{1}{2} Sc^\frac{1}{3} & Re < 5.0E+05 \\ + 0.037 Re^\frac{4}{5} Sc^\frac{1}{3} & Re > 5.0E+05 + \f} - NOTE: The correclation used to calculate Tdew is for water vapor. - In addition a scalar transport for the carrier specie have to be specified - via function objects or in the main solver. This specie transports the - vapour phase in the main ragion. The BC of this specie on the coupled wall - has to fixedGradient in order to allow condensation or evaporation of the - vapor in or out of this wall + NOTE: + - The correlation used to calculate Tdew is for water vapour. + - A scalar transport equation for the carrier specie is required, e.g. + supplied via a function object or in the main solver. This specie + transports the vapour phase in the main ragion. + - The boundary condition of this specie on the coupled wall must be + fixedGradient in order to allow condensation or evaporation of the + vapour in or out of this wall Example usage: On the fluid side + \verbatim + myInterfacePatchName + { + type thermalHumidityCoupledMixed; + kappa fluidThermo; + kappaName none; - myInterfacePatchName - { - type thermalHumidityCoupledMixed; - kappa fluidThermo; - kappaName none; - - // Modes of operation: inert, condensation, vaporization, condEvap - mode condEvap; + // Modes of operation: inert, condensation, vaporization, condEvap + mode condEvap; - // Carrier species name - specieName H2O; + // Carrier species name + specieName H2O; - // Carrier molecular weight - carrierMolWeight 28.9; + // Carrier molecular weight + carrierMolWeight 28.9; - // Characteristic lenght of the wall - L 0.1; + // Characteristic lenght of the wall + L 0.1; - // Vaporasation temperature - Tvap 273; + // Vaporasation temperature + Tvap 273; - // Liquid properties for the condensed mass - liquid + // Liquid properties for the condensed mass + liquid + { + H2O { - H2O - { - defaultCoeffs yes; - } + defaultCoeffs yes; } + } - // thickness, density and cp required for inert and condensation - // modes - - //thickness uniform 0; - //cp uniform 0; - //rho uniform 0; + // thickness, density and cp required for inert and condensation + // modes - value $internalField; - } + //thickness uniform 0; + //cp uniform 0; + //rho uniform 0; + value $internalField; + } + \endverbatim On the solid side: - - myInterfacePatchName - { - type thermalInertiaMassTransferCoupledMixed; - kappa solidThermo; - kappaName none; - value uniform 260; - } + \verbatim + myInterfacePatchName + { + type thermalInertiaMassTransferCoupledMixed; + kappa solidThermo; + kappaName none; + value uniform 260; + } + \endverbatim SourceFiles @@ -170,10 +178,10 @@ public: //- Modes of mass transfer enum massTransferMode { - mConstantMass, - mCondensation, - mEvaporation, - mCondensationAndEvaporation + mtConstantMass, + mtCondensation, + mtEvaporation, + mtCondensationAndEvaporation }; @@ -181,22 +189,38 @@ private: // Private data - static const NamedEnum<massTransferMode, 4> MassModeTypeNames_; + static const NamedEnum<massTransferMode, 4> massModeTypeNames_; - //- BC mode + //- Operating mode massTransferMode mode_; - //- Name of field on the neighbour region - const word TnbrName_; - //- Name of the radiative heat flux in the neighbout region - const word QrNbrName_; + // Field names + + //- Name of the pressure field + const word pName_; + + //- Name of the velocity field + const word UName_; + + //- Name of the density field + const word rhoName_; - //- Name of the radiative heat flux - const word QrName_; + //- Name of the dynamic viscosity field + const word muName_; + + //- Name of temperature field on the neighbour region + const word TnbrName_; + + //- Name of the radiative heat flux in the neighbout region + const word QrNbrName_; + + //- Name of the radiative heat flux field + const word QrName_; + + //- Name of the species on which the mass transfered (default H2O) + const word specieName_; - //- Name of the species on which the mass transfered (default H2O) - const word specieName_; //- Liquid properties autoPtr<liquidProperties> liquid_; @@ -345,7 +369,7 @@ public: return myKDelta_; } - //- Return mpCpdTpd + //- Return mpCpTp const scalarField mpCpTp() const { return mpCpTp_; @@ -357,7 +381,6 @@ public: return dmHfg_; } - //- Update the coefficients associated with the patch field virtual void updateCoeffs(); -- GitLab