Skip to content
Snippets Groups Projects
Commit ed9f9e04 authored by Henry's avatar Henry
Browse files

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.
parent 83e70c33
Branches
Tags
No related merge requests found
...@@ -137,9 +137,9 @@ void Foam::phaseProperties::setCarrierIds ...@@ -137,9 +137,9 @@ void Foam::phaseProperties::setCarrierIds
void Foam::phaseProperties::checkTotalMassFraction() const void Foam::phaseProperties::checkTotalMassFraction() const
{ {
scalar total = 0.0; 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) if (Y_.size() != 0 && mag(total - 1.0) > SMALL)
...@@ -147,9 +147,9 @@ void Foam::phaseProperties::checkTotalMassFraction() const ...@@ -147,9 +147,9 @@ void Foam::phaseProperties::checkTotalMassFraction() const
FatalErrorIn FatalErrorIn
( (
"void phaseProperties::checkTotalMassFraction() const" "void phaseProperties::checkTotalMassFraction() const"
) << "Component fractions must total to unity for phase " ) << "Specie fractions must total to unity for phase "
<< phaseTypeNames[phase_] << nl << phaseTypeNames[phase_] << nl
<< "Components: " << nl << names_ << nl << "Species: " << nl << names_ << nl
<< exit(FatalError); << exit(FatalError);
} }
} }
...@@ -227,38 +227,33 @@ void Foam::phaseProperties::reorder ...@@ -227,38 +227,33 @@ void Foam::phaseProperties::reorder
const wordList& solidNames 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 // with those given in the (main) thermo properties
switch (phase_) switch (phase_)
{ {
case GAS: case GAS:
{ {
reorder(gasNames); // The list of gaseous species in the mixture may be a sub-set of
forAll(carrierIds_, i) // the gaseous species in the carrier phase
{ setCarrierIds(gasNames);
carrierIds_[i] = i;
}
break; break;
} }
case LIQUID: case LIQUID:
{ {
// Set the list of liquid species to correspond to the complete list
// defined in the thermodynamics package.
reorder(liquidNames); reorder(liquidNames);
// Set the ids of the corresponding species in the carrier phase
setCarrierIds(gasNames); setCarrierIds(gasNames);
break; break;
} }
case SOLID: case SOLID:
{ {
// Set the list of solid species to correspond to the complete list
// defined in the thermodynamics package.
reorder(solidNames); reorder(solidNames);
WarningIn // Assume there is no correspondence between the solid species and
( // the species in the carrier phase (no sublimation).
"phaseProperties::reorder"
"("
"const wordList& gasNames, "
"const wordList& liquidNames, "
"const wordList& solidNames"
")"
) << "Assuming no mapping between solid and carrier species"
<< endl;
break; break;
} }
default: default:
...@@ -303,19 +298,19 @@ const Foam::List<Foam::word>& Foam::phaseProperties::names() const ...@@ -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 FatalErrorIn
( (
"const word& phaseProperties::name(const label) const" "const word& phaseProperties::name(const label) const"
) << "Requested component " << cmptI << "out of range" << nl ) << "Requested specie " << speciei << "out of range" << nl
<< "Available phase components:" << nl << names_ << nl << "Available phase species:" << nl << names_ << nl
<< exit(FatalError); << exit(FatalError);
} }
return names_[cmptI]; return names_[speciei];
} }
...@@ -325,19 +320,19 @@ const Foam::scalarField& Foam::phaseProperties::Y() const ...@@ -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 FatalErrorIn
( (
"const scalar& phaseProperties::Y(const label) const" "const scalar& phaseProperties::Y(const label) const"
) << "Requested component " << cmptI << "out of range" << nl ) << "Requested specie " << speciei << "out of range" << nl
<< "Available phase components:" << nl << names_ << nl << "Available phase species:" << nl << names_ << nl
<< exit(FatalError); << exit(FatalError);
} }
return Y_[cmptI]; return Y_[speciei];
} }
...@@ -347,13 +342,13 @@ const Foam::labelList& Foam::phaseProperties::carrierIds() const ...@@ -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;
} }
} }
......
...@@ -25,7 +25,7 @@ Class ...@@ -25,7 +25,7 @@ Class
Foam::phaseProperties Foam::phaseProperties
Description Description
Helper class to manage multi-component phase properties Helper class to manage multi-specie phase properties
SourceFiles SourceFiles
phaseProperties.C phaseProperties.C
...@@ -79,10 +79,10 @@ private: ...@@ -79,10 +79,10 @@ private:
//- State label (s), (l), (g) etc. //- State label (s), (l), (g) etc.
word stateLabel_; word stateLabel_;
//- List of component names //- List of specie names
List<word> names_; List<word> names_;
//- List of component mass fractions //- List of specie mass fractions
scalarField Y_; scalarField Y_;
//- Map to carrier id //- Map to carrier id
...@@ -145,24 +145,24 @@ public: ...@@ -145,24 +145,24 @@ public:
//- Return word representation of the phase type //- Return word representation of the phase type
word phaseTypeName() const; word phaseTypeName() const;
//- Return the list of component names //- Return the list of specie names
const List<word>& names() const; const List<word>& names() const;
//- Return const access to a component name //- Return const access to a specie name
const word& name(const label cmptI) const; 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; const scalarField& Y() const;
//- Return non-const access to a component mass fraction //- Return non-const access to a specie mass fraction
scalar& Y(const label cmptI); scalar& Y(const label speciei);
//- Return const access to the map to the carrier ids //- Return const access to the map to the carrier ids
const labelList& carrierIds() const; 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 // Returns -1 if not found
label id(const word& cmptName) const; label id(const word& specieName) const;
// IOstream Operators // IOstream Operators
......
...@@ -147,9 +147,9 @@ const Foam::wordList& Foam::CompositionModel<CloudType>::stateLabels() const ...@@ -147,9 +147,9 @@ const Foam::wordList& Foam::CompositionModel<CloudType>::stateLabels() const
template<class CloudType> template<class CloudType>
const Foam::wordList& 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 ...@@ -166,7 +166,7 @@ Foam::label Foam::CompositionModel<CloudType>::carrierId
{ {
FatalErrorIn FatalErrorIn
( (
"Foam::label Foam::CompositionModel<CloudType>::carrierId" "label CompositionModel<CloudType>::carrierId"
"(" "("
"const word&, " "const word&, "
"const bool" "const bool"
...@@ -184,18 +184,18 @@ Foam::label Foam::CompositionModel<CloudType>::carrierId ...@@ -184,18 +184,18 @@ Foam::label Foam::CompositionModel<CloudType>::carrierId
template<class CloudType> template<class CloudType>
Foam::label Foam::CompositionModel<CloudType>::localId Foam::label Foam::CompositionModel<CloudType>::localId
( (
const label phaseI, const label phasei,
const word& cmptName, const word& cmptName,
const bool allowNotFound const bool allowNotFound
) const ) const
{ {
label id = phaseProps_[phaseI].id(cmptName); label id = phaseProps_[phasei].id(cmptName);
if (id < 0 && !allowNotFound) if (id < 0 && !allowNotFound)
{ {
FatalErrorIn FatalErrorIn
( (
"Foam::label Foam::CompositionModel<CloudType>::localId" "label CompositionModel<CloudType>::localId"
"(" "("
"const label, " "const label, "
"const word&, " "const word&, "
...@@ -212,26 +212,26 @@ Foam::label Foam::CompositionModel<CloudType>::localId ...@@ -212,26 +212,26 @@ Foam::label Foam::CompositionModel<CloudType>::localId
template<class CloudType> template<class CloudType>
Foam::label Foam::CompositionModel<CloudType>::localToCarrierId Foam::label Foam::CompositionModel<CloudType>::localToCarrierId
( (
const label phaseI, const label phasei,
const label id, const label id,
const bool allowNotFound const bool allowNotFound
) const ) const
{ {
label cid = phaseProps_[phaseI].carrierIds()[id]; label cid = phaseProps_[phasei].carrierIds()[id];
if (cid < 0 && !allowNotFound) if (cid < 0 && !allowNotFound)
{ {
FatalErrorIn FatalErrorIn
( (
"Foam::label " "label "
"Foam::CompositionModel<CloudType>::localToCarrierId" "CompositionModel<CloudType>::localToCarrierId"
"(" "("
"const label, " "const label, "
"const label, " "const label, "
"const bool" "const bool"
") const" ") const"
) << "Unable to determine global carrier id for phase " ) << "Unable to determine global carrier id for phase "
<< phaseI << " with local id " << id << phasei << " with local id " << id
<< abort(FatalError); << abort(FatalError);
} }
...@@ -242,22 +242,22 @@ Foam::label Foam::CompositionModel<CloudType>::localToCarrierId ...@@ -242,22 +242,22 @@ Foam::label Foam::CompositionModel<CloudType>::localToCarrierId
template<class CloudType> template<class CloudType>
const Foam::scalarField& Foam::CompositionModel<CloudType>::Y0 const Foam::scalarField& Foam::CompositionModel<CloudType>::Y0
( (
const label phaseI const label phasei
) const ) const
{ {
return phaseProps_[phaseI].Y(); return phaseProps_[phasei].Y();
} }
template<class CloudType> template<class CloudType>
Foam::scalarField Foam::CompositionModel<CloudType>::X Foam::scalarField Foam::CompositionModel<CloudType>::X
( (
const label phaseI, const label phasei,
const scalarField& Y const scalarField& Y
) const ) const
{ {
const phaseProperties& props = phaseProps_[phaseI]; const phaseProperties& props = phaseProps_[phasei];
scalarField X(Y.size(), 0.0); scalarField X(Y.size());
scalar WInv = 0.0; scalar WInv = 0.0;
switch (props.phase()) switch (props.phase())
{ {
...@@ -265,8 +265,9 @@ Foam::scalarField Foam::CompositionModel<CloudType>::X ...@@ -265,8 +265,9 @@ Foam::scalarField Foam::CompositionModel<CloudType>::X
{ {
forAll(Y, i) forAll(Y, i)
{ {
WInv += Y[i]/thermo_.carrier().W(i); label cid = props.carrierIds()[i];
X[i] = Y[i]/thermo_.carrier().W(i); X[i] = Y[i]/thermo_.carrier().W(cid);
WInv += X[i];
} }
break; break;
} }
...@@ -274,8 +275,8 @@ Foam::scalarField Foam::CompositionModel<CloudType>::X ...@@ -274,8 +275,8 @@ Foam::scalarField Foam::CompositionModel<CloudType>::X
{ {
forAll(Y, i) 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; break;
} }
...@@ -283,7 +284,7 @@ Foam::scalarField Foam::CompositionModel<CloudType>::X ...@@ -283,7 +284,7 @@ Foam::scalarField Foam::CompositionModel<CloudType>::X
{ {
FatalErrorIn FatalErrorIn
( (
"Foam::scalarField Foam::CompositionModel<CloudType>::X" "scalarField CompositionModel<CloudType>::X"
"(" "("
"const label, " "const label, "
"const scalarField&" "const scalarField&"
...@@ -293,21 +294,22 @@ Foam::scalarField Foam::CompositionModel<CloudType>::X ...@@ -293,21 +294,22 @@ Foam::scalarField Foam::CompositionModel<CloudType>::X
} }
} }
tmp<scalarField> tfld = X/WInv; X /= WInv;
return tfld();
return X;
} }
template<class CloudType> template<class CloudType>
Foam::scalar Foam::CompositionModel<CloudType>::H Foam::scalar Foam::CompositionModel<CloudType>::H
( (
const label phaseI, const label phasei,
const scalarField& Y, const scalarField& Y,
const scalar p, const scalar p,
const scalar T const scalar T
) const ) const
{ {
const phaseProperties& props = phaseProps_[phaseI]; const phaseProperties& props = phaseProps_[phasei];
scalar HMixture = 0.0; scalar HMixture = 0.0;
switch (props.phase()) switch (props.phase())
{ {
...@@ -315,7 +317,8 @@ Foam::scalar Foam::CompositionModel<CloudType>::H ...@@ -315,7 +317,8 @@ Foam::scalar Foam::CompositionModel<CloudType>::H
{ {
forAll(Y, i) 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; break;
} }
...@@ -344,7 +347,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::H ...@@ -344,7 +347,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::H
{ {
FatalErrorIn FatalErrorIn
( (
"Foam::scalar Foam::CompositionModel<CloudType>::H" "scalar CompositionModel<CloudType>::H"
"(" "("
" const label, " " const label, "
" const scalarField&, " " const scalarField&, "
...@@ -362,13 +365,13 @@ Foam::scalar Foam::CompositionModel<CloudType>::H ...@@ -362,13 +365,13 @@ Foam::scalar Foam::CompositionModel<CloudType>::H
template<class CloudType> template<class CloudType>
Foam::scalar Foam::CompositionModel<CloudType>::Hs Foam::scalar Foam::CompositionModel<CloudType>::Hs
( (
const label phaseI, const label phasei,
const scalarField& Y, const scalarField& Y,
const scalar p, const scalar p,
const scalar T const scalar T
) const ) const
{ {
const phaseProperties& props = phaseProps_[phaseI]; const phaseProperties& props = phaseProps_[phasei];
scalar HsMixture = 0.0; scalar HsMixture = 0.0;
switch (props.phase()) switch (props.phase())
{ {
...@@ -376,7 +379,8 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hs ...@@ -376,7 +379,8 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hs
{ {
forAll(Y, i) 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; break;
} }
...@@ -405,7 +409,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hs ...@@ -405,7 +409,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hs
{ {
FatalErrorIn FatalErrorIn
( (
"Foam::scalar Foam::CompositionModel<CloudType>::Hs" "scalar CompositionModel<CloudType>::Hs"
"(" "("
" const label, " " const label, "
" const scalarField&, " " const scalarField&, "
...@@ -424,13 +428,13 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hs ...@@ -424,13 +428,13 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hs
template<class CloudType> template<class CloudType>
Foam::scalar Foam::CompositionModel<CloudType>::Hc Foam::scalar Foam::CompositionModel<CloudType>::Hc
( (
const label phaseI, const label phasei,
const scalarField& Y, const scalarField& Y,
const scalar p, const scalar p,
const scalar T const scalar T
) const ) const
{ {
const phaseProperties& props = phaseProps_[phaseI]; const phaseProperties& props = phaseProps_[phasei];
scalar HcMixture = 0.0; scalar HcMixture = 0.0;
switch (props.phase()) switch (props.phase())
{ {
...@@ -438,7 +442,8 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hc ...@@ -438,7 +442,8 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hc
{ {
forAll(Y, i) forAll(Y, i)
{ {
HcMixture += Y[i]*thermo_.carrier().Hc(i); label cid = props.carrierIds()[i];
HcMixture += Y[i]*thermo_.carrier().Hc(cid);
} }
break; break;
} }
...@@ -463,7 +468,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hc ...@@ -463,7 +468,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hc
{ {
FatalErrorIn FatalErrorIn
( (
"Foam::scalar Foam::CompositionModel<CloudType>::Hc" "scalar CompositionModel<CloudType>::Hc"
"(" "("
" const label, " " const label, "
" const scalarField&, " " const scalarField&, "
...@@ -482,13 +487,13 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hc ...@@ -482,13 +487,13 @@ Foam::scalar Foam::CompositionModel<CloudType>::Hc
template<class CloudType> template<class CloudType>
Foam::scalar Foam::CompositionModel<CloudType>::Cp Foam::scalar Foam::CompositionModel<CloudType>::Cp
( (
const label phaseI, const label phasei,
const scalarField& Y, const scalarField& Y,
const scalar p, const scalar p,
const scalar T const scalar T
) const ) const
{ {
const phaseProperties& props = phaseProps_[phaseI]; const phaseProperties& props = phaseProps_[phasei];
scalar CpMixture = 0.0; scalar CpMixture = 0.0;
switch (props.phase()) switch (props.phase())
{ {
...@@ -496,7 +501,8 @@ Foam::scalar Foam::CompositionModel<CloudType>::Cp ...@@ -496,7 +501,8 @@ Foam::scalar Foam::CompositionModel<CloudType>::Cp
{ {
forAll(Y, i) 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; break;
} }
...@@ -520,7 +526,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::Cp ...@@ -520,7 +526,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::Cp
{ {
FatalErrorIn FatalErrorIn
( (
"Foam::scalar Foam::CompositionModel<CloudType>::Cp" "scalar CompositionModel<CloudType>::Cp"
"(" "("
"const label, " "const label, "
"const scalarField&, " "const scalarField&, "
...@@ -539,13 +545,13 @@ Foam::scalar Foam::CompositionModel<CloudType>::Cp ...@@ -539,13 +545,13 @@ Foam::scalar Foam::CompositionModel<CloudType>::Cp
template<class CloudType> template<class CloudType>
Foam::scalar Foam::CompositionModel<CloudType>::L Foam::scalar Foam::CompositionModel<CloudType>::L
( (
const label phaseI, const label phasei,
const scalarField& Y, const scalarField& Y,
const scalar p, const scalar p,
const scalar T const scalar T
) const ) const
{ {
const phaseProperties& props = phaseProps_[phaseI]; const phaseProperties& props = phaseProps_[phasei];
scalar LMixture = 0.0; scalar LMixture = 0.0;
switch (props.phase()) switch (props.phase())
{ {
...@@ -555,7 +561,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::L ...@@ -555,7 +561,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::L
{ {
WarningIn WarningIn
( (
"Foam::scalar Foam::CompositionModel<CloudType>::L" "scalar CompositionModel<CloudType>::L"
"(" "("
"const label, " "const label, "
"const scalarField&, " "const scalarField&, "
...@@ -580,7 +586,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::L ...@@ -580,7 +586,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::L
{ {
WarningIn WarningIn
( (
"Foam::scalar Foam::CompositionModel<CloudType>::L" "scalar CompositionModel<CloudType>::L"
"(" "("
"const label, " "const label, "
"const scalarField&, " "const scalarField&, "
...@@ -595,7 +601,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::L ...@@ -595,7 +601,7 @@ Foam::scalar Foam::CompositionModel<CloudType>::L
{ {
FatalErrorIn FatalErrorIn
( (
"Foam::scalar Foam::CompositionModel<CloudType>::L" "scalar CompositionModel<CloudType>::L"
"(" "("
"const label, " "const label, "
"const scalarField&, " "const scalarField&, "
......
...@@ -142,11 +142,6 @@ subModels ...@@ -142,11 +142,6 @@ subModels
CH4 0.604; CH4 0.604;
H2 0.099; H2 0.099;
CO2 0.297; CO2 0.297;
// Temporarily add entries for remaining gas species
N2 0;
O2 0;
H2O 0;
} }
liquid liquid
{ {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment