From ed9f9e04d48ba5c526c8c99e214f6043ce57efaa Mon Sep 17 00:00:00 2001 From: Henry <Henry> Date: Sat, 7 Mar 2015 11:51:38 +0000 Subject: [PATCH] lagrangian: Completed update of phaseProperties to handle specie list mismatch between liquid and solid mixture composition and the specie lists defined in the thermodynamics package. Note this does not change the current limitation that both liquid and solid mixtures contain ALL the corresponding phase species defined in the thermodynamics package. However, missing species are included automatically during construction of phaseProperties. --- .../phaseProperties/phaseProperties.C | 63 ++++++------- .../phaseProperties/phaseProperties.H | 22 ++--- .../CompositionModel/CompositionModel.C | 94 ++++++++++--------- .../constant/coalCloud1Properties | 5 - 4 files changed, 90 insertions(+), 94 deletions(-) diff --git a/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.C b/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.C index fcf5da9ae72..691815e2cd3 100644 --- a/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.C +++ b/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.C @@ -137,9 +137,9 @@ void Foam::phaseProperties::setCarrierIds void Foam::phaseProperties::checkTotalMassFraction() const { scalar total = 0.0; - forAll(Y_, cmptI) + forAll(Y_, speciei) { - total += Y_[cmptI]; + total += Y_[speciei]; } if (Y_.size() != 0 && mag(total - 1.0) > SMALL) @@ -147,9 +147,9 @@ void Foam::phaseProperties::checkTotalMassFraction() const FatalErrorIn ( "void phaseProperties::checkTotalMassFraction() const" - ) << "Component fractions must total to unity for phase " + ) << "Specie fractions must total to unity for phase " << phaseTypeNames[phase_] << nl - << "Components: " << nl << names_ << nl + << "Species: " << nl << names_ << nl << exit(FatalError); } } @@ -227,38 +227,33 @@ void Foam::phaseProperties::reorder const wordList& solidNames ) { - // Determine the addressing to map between components listed in the phase + // Determine the addressing to map between species listed in the phase // with those given in the (main) thermo properties switch (phase_) { case GAS: { - reorder(gasNames); - forAll(carrierIds_, i) - { - carrierIds_[i] = i; - } + // The list of gaseous species in the mixture may be a sub-set of + // the gaseous species in the carrier phase + setCarrierIds(gasNames); break; } case LIQUID: { + // Set the list of liquid species to correspond to the complete list + // defined in the thermodynamics package. reorder(liquidNames); + // Set the ids of the corresponding species in the carrier phase setCarrierIds(gasNames); break; } case SOLID: { + // Set the list of solid species to correspond to the complete list + // defined in the thermodynamics package. reorder(solidNames); - WarningIn - ( - "phaseProperties::reorder" - "(" - "const wordList& gasNames, " - "const wordList& liquidNames, " - "const wordList& solidNames" - ")" - ) << "Assuming no mapping between solid and carrier species" - << endl; + // Assume there is no correspondence between the solid species and + // the species in the carrier phase (no sublimation). break; } default: @@ -303,19 +298,19 @@ const Foam::List<Foam::word>& Foam::phaseProperties::names() const } -const Foam::word& Foam::phaseProperties::name(const label cmptI) const +const Foam::word& Foam::phaseProperties::name(const label speciei) const { - if (cmptI >= names_.size()) + if (speciei >= names_.size()) { FatalErrorIn ( "const word& phaseProperties::name(const label) const" - ) << "Requested component " << cmptI << "out of range" << nl - << "Available phase components:" << nl << names_ << nl + ) << "Requested specie " << speciei << "out of range" << nl + << "Available phase species:" << nl << names_ << nl << exit(FatalError); } - return names_[cmptI]; + return names_[speciei]; } @@ -325,19 +320,19 @@ const Foam::scalarField& Foam::phaseProperties::Y() const } -Foam::scalar& Foam::phaseProperties::Y(const label cmptI) +Foam::scalar& Foam::phaseProperties::Y(const label speciei) { - if (cmptI >= Y_.size()) + if (speciei >= Y_.size()) { FatalErrorIn ( "const scalar& phaseProperties::Y(const label) const" - ) << "Requested component " << cmptI << "out of range" << nl - << "Available phase components:" << nl << names_ << nl + ) << "Requested specie " << speciei << "out of range" << nl + << "Available phase species:" << nl << names_ << nl << exit(FatalError); } - return Y_[cmptI]; + return Y_[speciei]; } @@ -347,13 +342,13 @@ const Foam::labelList& Foam::phaseProperties::carrierIds() const } -Foam::label Foam::phaseProperties::id(const word& cmptName) const +Foam::label Foam::phaseProperties::id(const word& specieName) const { - forAll(names_, cmptI) + forAll(names_, speciei) { - if (names_[cmptI] == cmptName) + if (names_[speciei] == specieName) { - return cmptI; + return speciei; } } diff --git a/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.H b/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.H index 3d68491e0ac..334f0e6d467 100644 --- a/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.H +++ b/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.H @@ -25,7 +25,7 @@ Class Foam::phaseProperties Description - Helper class to manage multi-component phase properties + Helper class to manage multi-specie phase properties SourceFiles phaseProperties.C @@ -79,10 +79,10 @@ private: //- State label (s), (l), (g) etc. word stateLabel_; - //- List of component names + //- List of specie names List<word> names_; - //- List of component mass fractions + //- List of specie mass fractions scalarField Y_; //- Map to carrier id @@ -145,24 +145,24 @@ public: //- Return word representation of the phase type word phaseTypeName() const; - //- Return the list of component names + //- Return the list of specie names const List<word>& names() const; - //- Return const access to a component name - const word& name(const label cmptI) const; + //- Return const access to a specie name + const word& name(const label speciei) const; - //- Return const access to all component mass fractions + //- Return const access to all specie mass fractions const scalarField& Y() const; - //- Return non-const access to a component mass fraction - scalar& Y(const label cmptI); + //- Return non-const access to a specie mass fraction + scalar& Y(const label speciei); //- Return const access to the map to the carrier ids const labelList& carrierIds() const; - //- Return the id of a component in the local list by name + //- Return the id of a specie in the local list by name // Returns -1 if not found - label id(const word& cmptName) const; + label id(const word& specieName) const; // IOstream Operators diff --git a/src/lagrangian/intermediate/submodels/Reacting/CompositionModel/CompositionModel/CompositionModel.C b/src/lagrangian/intermediate/submodels/Reacting/CompositionModel/CompositionModel/CompositionModel.C index 7cb6e81bf68..2b4e987a735 100644 --- a/src/lagrangian/intermediate/submodels/Reacting/CompositionModel/CompositionModel/CompositionModel.C +++ b/src/lagrangian/intermediate/submodels/Reacting/CompositionModel/CompositionModel/CompositionModel.C @@ -147,9 +147,9 @@ const Foam::wordList& Foam::CompositionModel<CloudType>::stateLabels() const template<class CloudType> const Foam::wordList& -Foam::CompositionModel<CloudType>::componentNames(const label phaseI) const +Foam::CompositionModel<CloudType>::componentNames(const label phasei) const { - return phaseProps_[phaseI].names(); + return phaseProps_[phasei].names(); } @@ -166,7 +166,7 @@ Foam::label Foam::CompositionModel<CloudType>::carrierId { FatalErrorIn ( - "Foam::label Foam::CompositionModel<CloudType>::carrierId" + "label CompositionModel<CloudType>::carrierId" "(" "const word&, " "const bool" @@ -184,18 +184,18 @@ Foam::label Foam::CompositionModel<CloudType>::carrierId template<class CloudType> Foam::label Foam::CompositionModel<CloudType>::localId ( - const label phaseI, + const label phasei, const word& cmptName, const bool allowNotFound ) const { - label id = phaseProps_[phaseI].id(cmptName); + label id = phaseProps_[phasei].id(cmptName); if (id < 0 && !allowNotFound) { FatalErrorIn ( - "Foam::label Foam::CompositionModel<CloudType>::localId" + "label CompositionModel<CloudType>::localId" "(" "const label, " "const word&, " @@ -212,26 +212,26 @@ Foam::label Foam::CompositionModel<CloudType>::localId template<class CloudType> Foam::label Foam::CompositionModel<CloudType>::localToCarrierId ( - const label phaseI, + const label phasei, const label id, const bool allowNotFound ) const { - label cid = phaseProps_[phaseI].carrierIds()[id]; + label cid = phaseProps_[phasei].carrierIds()[id]; if (cid < 0 && !allowNotFound) { FatalErrorIn ( - "Foam::label " - "Foam::CompositionModel<CloudType>::localToCarrierId" + "label " + "CompositionModel<CloudType>::localToCarrierId" "(" "const label, " "const label, " "const bool" ") const" ) << "Unable to determine global carrier id for phase " - << phaseI << " with local id " << id + << phasei << " with local id " << id << abort(FatalError); } @@ -242,22 +242,22 @@ Foam::label Foam::CompositionModel<CloudType>::localToCarrierId template<class CloudType> const Foam::scalarField& Foam::CompositionModel<CloudType>::Y0 ( - const label phaseI + const label phasei ) const { - return phaseProps_[phaseI].Y(); + return phaseProps_[phasei].Y(); } template<class CloudType> Foam::scalarField Foam::CompositionModel<CloudType>::X ( - const label phaseI, + const label phasei, const scalarField& Y ) const { - const phaseProperties& props = phaseProps_[phaseI]; - scalarField X(Y.size(), 0.0); + const phaseProperties& props = phaseProps_[phasei]; + scalarField X(Y.size()); scalar WInv = 0.0; switch (props.phase()) { @@ -265,8 +265,9 @@ Foam::scalarField Foam::CompositionModel<CloudType>::X { forAll(Y, i) { - WInv += Y[i]/thermo_.carrier().W(i); - X[i] = Y[i]/thermo_.carrier().W(i); + label cid = props.carrierIds()[i]; + X[i] = Y[i]/thermo_.carrier().W(cid); + WInv += X[i]; } break; } @@ -274,8 +275,8 @@ Foam::scalarField Foam::CompositionModel<CloudType>::X { forAll(Y, i) { - WInv += Y[i]/thermo_.liquids().properties()[i].W(); - X[i] += Y[i]/thermo_.liquids().properties()[i].W(); + X[i] = Y[i]/thermo_.liquids().properties()[i].W(); + WInv += X[i]; } break; } @@ -283,7 +284,7 @@ Foam::scalarField Foam::CompositionModel<CloudType>::X { FatalErrorIn ( - "Foam::scalarField Foam::CompositionModel<CloudType>::X" + "scalarField CompositionModel<CloudType>::X" "(" "const label, " "const scalarField&" @@ -293,21 +294,22 @@ Foam::scalarField Foam::CompositionModel<CloudType>::X } } - tmp<scalarField> tfld = X/WInv; - return tfld(); + X /= WInv; + + return X; } template<class CloudType> Foam::scalar Foam::CompositionModel<CloudType>::H ( - const label phaseI, + const label phasei, const scalarField& Y, const scalar p, const scalar T ) const { - const phaseProperties& props = phaseProps_[phaseI]; + const phaseProperties& props = phaseProps_[phasei]; scalar HMixture = 0.0; switch (props.phase()) { @@ -315,7 +317,8 @@ Foam::scalar Foam::CompositionModel<CloudType>::H { forAll(Y, i) { - HMixture += Y[i]*thermo_.carrier().Ha(i, p, T); + label cid = props.carrierIds()[i]; + HMixture += Y[i]*thermo_.carrier().Ha(cid, p, T); } break; } @@ -344,7 +347,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::H { FatalErrorIn ( - "Foam::scalar Foam::CompositionModel<CloudType>::H" + "scalar CompositionModel<CloudType>::H" "(" " const label, " " const scalarField&, " @@ -362,13 +365,13 @@ Foam::scalar Foam::CompositionModel<CloudType>::H template<class CloudType> Foam::scalar Foam::CompositionModel<CloudType>::Hs ( - const label phaseI, + const label phasei, const scalarField& Y, const scalar p, const scalar T ) const { - const phaseProperties& props = phaseProps_[phaseI]; + const phaseProperties& props = phaseProps_[phasei]; scalar HsMixture = 0.0; switch (props.phase()) { @@ -376,7 +379,8 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hs { forAll(Y, i) { - HsMixture += Y[i]*thermo_.carrier().Hs(i, p, T); + label cid = props.carrierIds()[i]; + HsMixture += Y[i]*thermo_.carrier().Hs(cid, p, T); } break; } @@ -405,7 +409,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hs { FatalErrorIn ( - "Foam::scalar Foam::CompositionModel<CloudType>::Hs" + "scalar CompositionModel<CloudType>::Hs" "(" " const label, " " const scalarField&, " @@ -424,13 +428,13 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hs template<class CloudType> Foam::scalar Foam::CompositionModel<CloudType>::Hc ( - const label phaseI, + const label phasei, const scalarField& Y, const scalar p, const scalar T ) const { - const phaseProperties& props = phaseProps_[phaseI]; + const phaseProperties& props = phaseProps_[phasei]; scalar HcMixture = 0.0; switch (props.phase()) { @@ -438,7 +442,8 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hc { forAll(Y, i) { - HcMixture += Y[i]*thermo_.carrier().Hc(i); + label cid = props.carrierIds()[i]; + HcMixture += Y[i]*thermo_.carrier().Hc(cid); } break; } @@ -463,7 +468,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hc { FatalErrorIn ( - "Foam::scalar Foam::CompositionModel<CloudType>::Hc" + "scalar CompositionModel<CloudType>::Hc" "(" " const label, " " const scalarField&, " @@ -482,13 +487,13 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hc template<class CloudType> Foam::scalar Foam::CompositionModel<CloudType>::Cp ( - const label phaseI, + const label phasei, const scalarField& Y, const scalar p, const scalar T ) const { - const phaseProperties& props = phaseProps_[phaseI]; + const phaseProperties& props = phaseProps_[phasei]; scalar CpMixture = 0.0; switch (props.phase()) { @@ -496,7 +501,8 @@ Foam::scalar Foam::CompositionModel<CloudType>::Cp { forAll(Y, i) { - CpMixture += Y[i]*thermo_.carrier().Cp(i, p, T); + label cid = props.carrierIds()[i]; + CpMixture += Y[i]*thermo_.carrier().Cp(cid, p, T); } break; } @@ -520,7 +526,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::Cp { FatalErrorIn ( - "Foam::scalar Foam::CompositionModel<CloudType>::Cp" + "scalar CompositionModel<CloudType>::Cp" "(" "const label, " "const scalarField&, " @@ -539,13 +545,13 @@ Foam::scalar Foam::CompositionModel<CloudType>::Cp template<class CloudType> Foam::scalar Foam::CompositionModel<CloudType>::L ( - const label phaseI, + const label phasei, const scalarField& Y, const scalar p, const scalar T ) const { - const phaseProperties& props = phaseProps_[phaseI]; + const phaseProperties& props = phaseProps_[phasei]; scalar LMixture = 0.0; switch (props.phase()) { @@ -555,7 +561,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::L { WarningIn ( - "Foam::scalar Foam::CompositionModel<CloudType>::L" + "scalar CompositionModel<CloudType>::L" "(" "const label, " "const scalarField&, " @@ -580,7 +586,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::L { WarningIn ( - "Foam::scalar Foam::CompositionModel<CloudType>::L" + "scalar CompositionModel<CloudType>::L" "(" "const label, " "const scalarField&, " @@ -595,7 +601,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::L { FatalErrorIn ( - "Foam::scalar Foam::CompositionModel<CloudType>::L" + "scalar CompositionModel<CloudType>::L" "(" "const label, " "const scalarField&, " diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties index f0ee4a3102f..1f79c8850e7 100644 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties @@ -142,11 +142,6 @@ subModels CH4 0.604; H2 0.099; CO2 0.297; - - // Temporarily add entries for remaining gas species - N2 0; - O2 0; - H2O 0; } liquid { -- GitLab