diff --git a/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.C b/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.C index fcf5da9ae..691815e2c 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::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 3d68491e0..334f0e6d4 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 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& 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 7cb6e81bf..2b4e987a7 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::stateLabels() const template const Foam::wordList& -Foam::CompositionModel::componentNames(const label phaseI) const +Foam::CompositionModel::componentNames(const label phasei) const { - return phaseProps_[phaseI].names(); + return phaseProps_[phasei].names(); } @@ -166,7 +166,7 @@ Foam::label Foam::CompositionModel::carrierId { FatalErrorIn ( - "Foam::label Foam::CompositionModel::carrierId" + "label CompositionModel::carrierId" "(" "const word&, " "const bool" @@ -184,18 +184,18 @@ Foam::label Foam::CompositionModel::carrierId template Foam::label Foam::CompositionModel::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::localId" + "label CompositionModel::localId" "(" "const label, " "const word&, " @@ -212,26 +212,26 @@ Foam::label Foam::CompositionModel::localId template Foam::label Foam::CompositionModel::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::localToCarrierId" + "label " + "CompositionModel::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::localToCarrierId template const Foam::scalarField& Foam::CompositionModel::Y0 ( - const label phaseI + const label phasei ) const { - return phaseProps_[phaseI].Y(); + return phaseProps_[phasei].Y(); } template Foam::scalarField Foam::CompositionModel::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::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::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::X { FatalErrorIn ( - "Foam::scalarField Foam::CompositionModel::X" + "scalarField CompositionModel::X" "(" "const label, " "const scalarField&" @@ -293,21 +294,22 @@ Foam::scalarField Foam::CompositionModel::X } } - tmp tfld = X/WInv; - return tfld(); + X /= WInv; + + return X; } template Foam::scalar Foam::CompositionModel::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::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::H { FatalErrorIn ( - "Foam::scalar Foam::CompositionModel::H" + "scalar CompositionModel::H" "(" " const label, " " const scalarField&, " @@ -362,13 +365,13 @@ Foam::scalar Foam::CompositionModel::H template Foam::scalar Foam::CompositionModel::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::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::Hs { FatalErrorIn ( - "Foam::scalar Foam::CompositionModel::Hs" + "scalar CompositionModel::Hs" "(" " const label, " " const scalarField&, " @@ -424,13 +428,13 @@ Foam::scalar Foam::CompositionModel::Hs template Foam::scalar Foam::CompositionModel::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::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::Hc { FatalErrorIn ( - "Foam::scalar Foam::CompositionModel::Hc" + "scalar CompositionModel::Hc" "(" " const label, " " const scalarField&, " @@ -482,13 +487,13 @@ Foam::scalar Foam::CompositionModel::Hc template Foam::scalar Foam::CompositionModel::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::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::Cp { FatalErrorIn ( - "Foam::scalar Foam::CompositionModel::Cp" + "scalar CompositionModel::Cp" "(" "const label, " "const scalarField&, " @@ -539,13 +545,13 @@ Foam::scalar Foam::CompositionModel::Cp template Foam::scalar Foam::CompositionModel::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::L { WarningIn ( - "Foam::scalar Foam::CompositionModel::L" + "scalar CompositionModel::L" "(" "const label, " "const scalarField&, " @@ -580,7 +586,7 @@ Foam::scalar Foam::CompositionModel::L { WarningIn ( - "Foam::scalar Foam::CompositionModel::L" + "scalar CompositionModel::L" "(" "const label, " "const scalarField&, " @@ -595,7 +601,7 @@ Foam::scalar Foam::CompositionModel::L { FatalErrorIn ( - "Foam::scalar Foam::CompositionModel::L" + "scalar CompositionModel::L" "(" "const label, " "const scalarField&, " diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties index f0ee4a310..1f79c8850 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 {