Compare commits

...
Sign in to create a new pull request.

8 commits

12 changed files with 411 additions and 18 deletions

View file

@ -1,9 +1,23 @@
before_script:
- "[[ -d ../ThirdParty-4.x ]] || git clone https://github.com/OpenFOAM/ThirdParty-4.x.git ../ThirdParty-4.x"
- source etc/bashrc
- rm -rf platforms
- wclean all
allmake: allmake:
image: park0d/of4builder
tags:
- openfoam4
before_script:
- "[[ -d ../ThirdParty-4.x ]] || git clone https://github.com/OpenFOAM/ThirdParty-4.x.git ../ThirdParty-4.x"
- source etc/bashrc
- rm -rf platforms
- wclean all
script: script:
- ./Allwmake -j - ./Allwmake -j
artifacts:
paths:
- ./
cantera:
image: park0d/of4builder
tags:
- openfoam4
script:
- whereis libcantera

View file

@ -148,7 +148,7 @@ irreversibleReactionDelimiter {space}"=>"{space}
startPDependentSpecie {space}"("{space}"+"{space} startPDependentSpecie {space}"("{space}"+"{space}
pDependentSpecie {specieName}")"{space} pDependentSpecie {specieName}")"{space}
reactionCoeffs {space}{floatNum}{some_space}{floatNum}{some_space}{floatNum}{space} reactionCoeffs {space}{floatNum}{some_space}{floatNum}{some_space}{floatNum}{space}
reactionKeyword {space}[A-Za-z](([A-Za-z0-9)*-])|("("[^+]))*{space} reactionKeyword {space}[A-Za-z](([A-Za-z0-9)*-])|("("[^+]))*((\+({some_space}))?){space}
reactionKeywordSlash {reactionKeyword}"/"{space} reactionKeywordSlash {reactionKeyword}"/"{space}
thirdBodyEfficiency {space}{floatNum}{space}"/"{space} thirdBodyEfficiency {space}{floatNum}{space}"/"{space}
startReactionCoeffs {space}"/"{space} startReactionCoeffs {space}"/"{space}
@ -637,7 +637,8 @@ bool finishReaction = false;
( (
currentSpecieName, currentSpecieName,
1.0, 1.0,
molecularWeight(currentSpecieComposition) molecularWeight(currentSpecieComposition),
chargeNumber(currentSpecieComposition)
), ),
currentLowT, currentLowT,
currentHighT, currentHighT,

View file

@ -144,6 +144,28 @@ Foam::scalar Foam::chemkinReader::molecularWeight
} }
Foam::scalar Foam::chemkinReader::chargeNumber
(
const List<specieElement>& specieComposition
) const
{
scalar nElemCharges = 0.0;
forAll(specieComposition, i)
{
label nAtoms = specieComposition[i].nAtoms;
const word& elementName = specieComposition[i].elementName;
if (elementName[0] == 'e')
{
nElemCharges -= nAtoms;
}
}
return nElemCharges;
}
void Foam::chemkinReader::checkCoeffs void Foam::chemkinReader::checkCoeffs
( (
const scalarList& reactionCoeffs, const scalarList& reactionCoeffs,

View file

@ -254,6 +254,11 @@ private:
const List<specieElement>& specieComposition const List<specieElement>& specieComposition
) const; ) const;
scalar chargeNumber
(
const List<specieElement>& specieComposition
) const;
void finishElements(labelList& currentAtoms); void finishElements(labelList& currentAtoms);
void checkCoeffs void checkCoeffs

View file

@ -68,6 +68,70 @@ Foam::scalar Foam::SpecieMixture<MixtureType>::W
} }
template<class MixtureType>
Foam::scalar Foam::SpecieMixture<MixtureType>::z
(
const label speciei
) const
{
return this->getLocalThermo(speciei).z();
}
template<class MixtureType>
Foam::scalar Foam::SpecieMixture<MixtureType>::Qc
(
const label speciei
) const
{
return this->getLocalThermo(speciei).Qc();
}
template<class MixtureType>
Foam::scalar Foam::SpecieMixture<MixtureType>::Qc2
(
const label speciei
) const
{
return this->getLocalThermo(speciei).Qc2();
}
template<class MixtureType>
void Foam::SpecieMixture<MixtureType>::Cp
(
scalarField& Cps,
const scalar p,
const scalar T
) const
{
forAll(this->species(), speciei)
{
Cps[speciei] = this->getLocalThermo(speciei).Cp(p, T);
}
return;
}
template<class MixtureType>
void Foam::SpecieMixture<MixtureType>::Cv
(
scalarField& Cvs,
const scalar p,
const scalar T
) const
{
forAll(this->species(), speciei)
{
Cvs[speciei] = this->getLocalThermo(speciei).Cv(p, T);
}
return;
}
template<class MixtureType> template<class MixtureType>
Foam::scalar Foam::SpecieMixture<MixtureType>::Cp Foam::scalar Foam::SpecieMixture<MixtureType>::Cp
( (

View file

@ -81,6 +81,34 @@ public:
//- Molecular weight of the given specie [kg/kmol] //- Molecular weight of the given specie [kg/kmol]
virtual scalar W(const label speciei) const; virtual scalar W(const label speciei) const;
//- Number of charges of the given specie []
virtual scalar z(const label speciei) const;
//- Specific charge of the given specie []
virtual scalar Qc(const label specieI) const;
//- Absolute specific charge of the given specie []
virtual scalar Qc2(const label specieI) const;
// All species thermo properties
//- Heat capacity at constant pressure [J/(kg K)]
virtual void Cp
(
scalarField& Cps,
const scalar p,
const scalar T
) const;
//- Heat capacity at constant volume [J/(kg K)]
virtual void Cv
(
scalarField& Cvs,
const scalar p,
const scalar T
) const;
// Per specie thermo properties // Per specie thermo properties

View file

@ -81,4 +81,72 @@ Foam::tmp<Foam::volScalarField> Foam::basicSpecieMixture::W() const
} }
Foam::tmp<Foam::volScalarField> Foam::basicSpecieMixture::Qc() const
{
const PtrList<volScalarField>& Y(basicMultiComponentMixture::Y());
tmp<volScalarField> tQc
(
new volScalarField
(
IOobject
(
IOobject::groupName("Qc", Y[0].group()),
Y[0].time().timeName(),
Y[0].mesh()
),
Y[0].mesh(),
dimensionedScalar("zero", dimCurrent*dimTime/dimMass, 0)
)
);
volScalarField& Qc = tQc.ref();
dimensionedScalar Qci("Qci", dimCurrent*dimTime/dimMass, 0);
forAll(Y, i)
{
Qci.value() = this->Qc(i);
Qc += Y[i]*Qci;
// Qc += Y[i]*this->Qc(i);
}
return tQc;
}
Foam::tmp<Foam::volScalarField> Foam::basicSpecieMixture::Qc2() const
{
const PtrList<volScalarField>& Y(basicMultiComponentMixture::Y());
tmp<volScalarField> tQc
(
new volScalarField
(
IOobject
(
IOobject::groupName("Qc2", Y[0].group()),
Y[0].time().timeName(),
Y[0].mesh()
),
Y[0].mesh(),
dimensionedScalar("zero", sqr(dimCurrent*dimTime)/dimMass, 0)
)
);
volScalarField& Qc = tQc.ref();
dimensionedScalar Qc2i("Qc2i", sqr(dimCurrent*dimTime)/dimMass, 0);
forAll(Y, i)
{
Qc2i.value() = this->Qc2(i);
Qc += Y[i]*Qc2i;
//Qc += Y[i]*this->Qc2(i);
}
return tQc;
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -88,9 +88,43 @@ public:
//- Molecular weight of the given specie [kg/kmol] //- Molecular weight of the given specie [kg/kmol]
virtual scalar W(const label speciei) const = 0; virtual scalar W(const label speciei) const = 0;
//- Number of charges of the given specie []
virtual scalar z(const label speciei) const = 0;
//- Specific charge of the given specie [C/kg]
virtual scalar Qc(const label speciei) const = 0;
//- Absolute specific charge of the given specie [C/kg]
virtual scalar Qc2(const label speciei) const = 0;
//- Molecular weight of the mixture [kg/kmol] //- Molecular weight of the mixture [kg/kmol]
tmp<volScalarField> W() const; tmp<volScalarField> W() const;
//- Specific charge of the mixture [C/kg]
tmp<volScalarField> Qc() const;
//- Absolute specific charge of the mixture [C^2/kg]
tmp<volScalarField> Qc2() const;
// All species thermo properties
//- Heat capacity at constant pressure [J/(kg K)]
virtual void Cp
(
scalarField& Cps,
const scalar p,
const scalar T
) const = 0;
//- Heat capacity at constant volume [J/(kg K)]
virtual void Cv
(
scalarField& Cvs,
const scalar p,
const scalar T
) const = 0;
// Per specie thermo properties // Per specie thermo properties

View file

@ -29,6 +29,24 @@ License
/* * * * * * * * * * * * * * * public constants * * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * public constants * * * * * * * * * * * * * * */
//- Universal gas constant (default in [J/(kmol K)])
const Foam::scalar Foam::specie::RR = constant::physicoChemical::R.value()*1000;
//- Standard pressure (default in [Pa])
const Foam::scalar Foam::specie::Pstd = constant::standard::Pstd.value();
//- Standard temperature (default in [K])
const Foam::scalar Foam::specie::Tstd = constant::standard::Tstd.value();
//- Elementary charge (default in [C])
const Foam::scalar Foam::specie::e = constant::electromagnetic::e.value();
//- Avogadro number (default in [1/mol])
const Foam::scalar Foam::specie::NA = constant::physicoChemical::NA.value()*1000;
//- Boltzmann constant (default in [J/K])
const Foam::scalar Foam::specie::k = constant::physicoChemical::k.value();
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(specie, 0); defineTypeNameAndDebug(specie, 0);
@ -41,7 +59,8 @@ Foam::specie::specie(Istream& is)
: :
name_(is), name_(is),
nMoles_(readScalar(is)), nMoles_(readScalar(is)),
molWeight_(readScalar(is)) molWeight_(readScalar(is)),
nCharges_(readScalar(is))
{ {
is.check("specie::specie(Istream& is)"); is.check("specie::specie(Istream& is)");
} }
@ -51,7 +70,8 @@ Foam::specie::specie(const dictionary& dict)
: :
name_(dict.dictName()), name_(dict.dictName()),
nMoles_(readScalar(dict.subDict("specie").lookup("nMoles"))), nMoles_(readScalar(dict.subDict("specie").lookup("nMoles"))),
molWeight_(readScalar(dict.subDict("specie").lookup("molWeight"))) molWeight_(readScalar(dict.subDict("specie").lookup("molWeight"))),
nCharges_(dict.subDict("specie").lookupOrDefault("nCharges", 0.0))
{} {}
@ -62,6 +82,7 @@ void Foam::specie::write(Ostream& os) const
dictionary dict("specie"); dictionary dict("specie");
dict.add("nMoles", nMoles_); dict.add("nMoles", nMoles_);
dict.add("molWeight", molWeight_); dict.add("molWeight", molWeight_);
dict.add("nCharges", nCharges_);
os << indent << dict.dictName() << dict; os << indent << dict.dictName() << dict;
} }
@ -72,7 +93,8 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const specie& st)
{ {
os << st.name_ << tab os << st.name_ << tab
<< st.nMoles_ << tab << st.nMoles_ << tab
<< st.molWeight_; << st.molWeight_ << tab
<< st.nCharges_;
os.check("Ostream& operator<<(Ostream& os, const specie& st)"); os.check("Ostream& operator<<(Ostream& os, const specie& st)");
return os; return os;

View file

@ -77,6 +77,9 @@ class specie
//- Molecular weight of specie [kg/kmol] //- Molecular weight of specie [kg/kmol]
scalar molWeight_; scalar molWeight_;
//- Number of elementary charges of specie
scalar nCharges_;
public: public:
@ -84,6 +87,29 @@ public:
ClassName("specie"); ClassName("specie");
// Public constants
// Thermodynamic constants
//- Universal gas constant [J/(kmol K)]
static const scalar RR;
//- Standard pressure [Pa]
static const scalar Pstd;
//- Standard temperature [K]
static const scalar Tstd;
//- Elementary charge [C]
static const scalar e;
//- Avogadro number [1/kmol]
static const scalar NA;
//- Boltzmann constant [J/K]
static const scalar k;
// Constructors // Constructors
@ -98,6 +124,23 @@ public:
const scalar molWeight const scalar molWeight
); );
//- Construct from components without name
inline specie
(
const scalar nMoles,
const scalar molWeight,
const scalar nCharges
);
//- Construct from components with name
inline specie
(
const word& name,
const scalar nMoles,
const scalar molWeight,
const scalar nCharges
);
//- Construct as copy //- Construct as copy
inline specie(const specie&); inline specie(const specie&);
@ -127,6 +170,27 @@ public:
//- Gas constant [J/(kg K)] //- Gas constant [J/(kg K)]
inline scalar R() const; inline scalar R() const;
//- Charge number
inline scalar z() const;
// Electric charge function
// Mole specific properties
//- Electric charge [C/kmol]
inline scalar qc() const;
// Mass specific properties
//- Electric charge [C/kg]
inline scalar Qc() const;
//- Electric charge squared [C^2/kg]
inline scalar Qc2() const;
// I-O // I-O

View file

@ -41,7 +41,8 @@ inline specie::specie
: :
name_(name), name_(name),
nMoles_(nMoles), nMoles_(nMoles),
molWeight_(molWeight) molWeight_(molWeight),
nCharges_(0.0)
{} {}
@ -52,7 +53,36 @@ inline specie::specie
) )
: :
nMoles_(nMoles), nMoles_(nMoles),
molWeight_(molWeight) molWeight_(molWeight),
nCharges_(0.0)
{}
inline specie::specie
(
const word& name,
const scalar nMoles,
const scalar molWeight,
const scalar nCharges
)
:
name_(name),
nMoles_(nMoles),
molWeight_(molWeight),
nCharges_(nCharges)
{}
inline specie::specie
(
const scalar nMoles,
const scalar molWeight,
const scalar nCharges
)
:
nMoles_(nMoles),
molWeight_(molWeight),
nCharges_(nCharges)
{} {}
@ -62,7 +92,8 @@ inline specie::specie(const specie& st)
: :
name_(st.name_), name_(st.name_),
nMoles_(st.nMoles_), nMoles_(st.nMoles_),
molWeight_(st.molWeight_) molWeight_(st.molWeight_),
nCharges_(st.nCharges_)
{} {}
@ -70,7 +101,8 @@ inline specie::specie(const word& name, const specie& st)
: :
name_(name), name_(name),
nMoles_(st.nMoles_), nMoles_(st.nMoles_),
molWeight_(st.molWeight_) molWeight_(st.molWeight_),
nCharges_(st.nCharges_)
{} {}
@ -100,6 +132,30 @@ inline scalar specie::R() const
} }
inline scalar specie::z() const
{
return nCharges_;
}
inline scalar specie::qc() const
{
return nCharges_ * NA * e;
}
inline scalar specie::Qc() const
{
return nCharges_ * NA * e / molWeight_;
}
inline scalar specie::Qc2() const
{
return nCharges_ * nCharges_ * NA * e * e / molWeight_;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void specie::operator=(const specie& st) inline void specie::operator=(const specie& st)
@ -107,6 +163,7 @@ inline void specie::operator=(const specie& st)
//name_ = st.name_; //name_ = st.name_;
nMoles_ = st.nMoles_; nMoles_ = st.nMoles_;
molWeight_ = st.molWeight_; molWeight_ = st.molWeight_;
nCharges_ = st.nCharges_;
} }
@ -114,6 +171,10 @@ inline void specie::operator+=(const specie& st)
{ {
scalar sumNmoles = max(nMoles_ + st.nMoles_, SMALL); scalar sumNmoles = max(nMoles_ + st.nMoles_, SMALL);
nCharges_ =
nMoles_/sumNmoles*nCharges_
+ st.nMoles_/sumNmoles*st.nCharges_;
molWeight_ = molWeight_ =
nMoles_/sumNmoles*molWeight_ nMoles_/sumNmoles*molWeight_
+ st.nMoles_/sumNmoles*st.molWeight_; + st.nMoles_/sumNmoles*st.molWeight_;
@ -130,6 +191,10 @@ inline void specie::operator-=(const specie& st)
diffnMoles = SMALL; diffnMoles = SMALL;
} }
nCharges_ =
nMoles_/diffnMoles*nCharges_
- st.nMoles_/diffnMoles*st.nCharges_;
molWeight_ = molWeight_ =
nMoles_/diffnMoles*molWeight_ nMoles_/diffnMoles*molWeight_
- st.nMoles_/diffnMoles*st.molWeight_; - st.nMoles_/diffnMoles*st.molWeight_;
@ -154,7 +219,9 @@ inline specie operator+(const specie& st1, const specie& st2)
( (
sumNmoles, sumNmoles,
st1.nMoles_/sumNmoles*st1.molWeight_ st1.nMoles_/sumNmoles*st1.molWeight_
+ st2.nMoles_/sumNmoles*st2.molWeight_ + st2.nMoles_/sumNmoles*st2.molWeight_,
st1.nMoles_/sumNmoles*st1.nCharges_
+ st2.nMoles_/sumNmoles*st2.nCharges_
); );
} }
@ -171,7 +238,9 @@ inline specie operator-(const specie& st1, const specie& st2)
( (
diffNmoles, diffNmoles,
st1.nMoles_/diffNmoles*st1.molWeight_ st1.nMoles_/diffNmoles*st1.molWeight_
- st2.nMoles_/diffNmoles*st2.molWeight_ - st2.nMoles_/diffNmoles*st2.molWeight_,
st1.nMoles_/diffNmoles*st1.nCharges_
- st2.nMoles_/diffNmoles*st2.nCharges_
); );
} }
@ -181,7 +250,8 @@ inline specie operator*(const scalar s, const specie& st)
return specie return specie
( (
s*st.nMoles_, s*st.nMoles_,
st.molWeight_ st.molWeight_,
st.nCharges_
); );
} }

View file

@ -336,6 +336,7 @@ public:
) const; ) const;
// I-O // I-O
//- Write to Ostream //- Write to Ostream