diff --git a/applications/utilities/thermophysical/chemkinToFoam/chemkinToFoam.C b/applications/utilities/thermophysical/chemkinToFoam/chemkinToFoam.C index cb219fb83..e094ee28a 100644 --- a/applications/utilities/thermophysical/chemkinToFoam/chemkinToFoam.C +++ b/applications/utilities/thermophysical/chemkinToFoam/chemkinToFoam.C @@ -67,15 +67,13 @@ int main(int argc, char *argv[]) chemkinReader cr(species, args[1], args[3], args[2], newFormat); - OFstream reactionsFile(args[4]); - reactionsFile - << "elements" << cr.elementNames() << token::END_STATEMENT << nl << nl; - reactionsFile - << "species" << cr.species() << token::END_STATEMENT << nl << nl; + reactionsFile.writeKeyword("elements") + << cr.elementNames() << token::END_STATEMENT << nl << nl; + reactionsFile.writeKeyword("species") + << cr.species() << token::END_STATEMENT << nl << nl; cr.reactions().write(reactionsFile); - // Temporary hack to splice the specie composition data into the thermo file // pending complete integration into the thermodynamics structure @@ -103,6 +101,14 @@ int main(int argc, char *argv[]) thermoDict.write(OFstream(args[5])(), false); + reactionsFile << nl; + + reactionsFile.writeKeyword("Tlow") + << Reaction::TlowDefault + << token::END_STATEMENT << nl; + reactionsFile.writeKeyword("Thigh") + << Reaction::ThighDefault + << token::END_STATEMENT << nl << nl; Info<< "End\n" << endl; diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/StandardChemistryModel/StandardChemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/StandardChemistryModel/StandardChemistryModel.C index ad2c75577..adc979f62 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/StandardChemistryModel/StandardChemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/StandardChemistryModel/StandardChemistryModel.C @@ -56,7 +56,7 @@ Foam::StandardChemistryModel::StandardChemistryModel BasicChemistryModel::template lookupOrDefault ( "Treact", - 0.0 + 0 ) ), RR_(nSpecie_), @@ -80,7 +80,7 @@ Foam::StandardChemistryModel::StandardChemistryModel IOobject::NO_WRITE ), thermo.p().mesh(), - dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0) + dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0) ) ); } @@ -109,8 +109,6 @@ void Foam::StandardChemistryModel::omega scalarField& dcdt ) const { - scalar pf, cf, pr, cr; - label lRef, rRef; dcdt = Zero; @@ -118,24 +116,7 @@ void Foam::StandardChemistryModel::omega { const Reaction& R = reactions_[i]; - const scalar omegai = omega - ( - R, c, T, p, pf, cf, lRef, pr, cr, rRef - ); - - forAll(R.lhs(), s) - { - const label si = R.lhs()[s].index; - const scalar sl = R.lhs()[s].stoichCoeff; - dcdt[si] -= sl*omegai; - } - - forAll(R.rhs(), s) - { - const label si = R.rhs()[s].index; - const scalar sr = R.rhs()[s].stoichCoeff; - dcdt[si] += sr*omegai; - } + R.omega(p, T, c, dcdt); } } @@ -156,123 +137,11 @@ Foam::scalar Foam::StandardChemistryModel::omegaI ) const { const Reaction& R = reactions_[index]; - scalar w = omega(R, c, T, p, pf, cf, lRef, pr, cr, rRef); + scalar w = R.omega(p, T, c, pf, cf, lRef, pr, cr, rRef); return(w); } -template -Foam::scalar Foam::StandardChemistryModel::omega -( - const Reaction& R, - const scalarField& c, - const scalar T, - const scalar p, - scalar& pf, - scalar& cf, - label& lRef, - scalar& pr, - scalar& cr, - label& rRef -) const -{ - const scalar kf = R.kf(p, T, c); - const scalar kr = R.kr(kf, p, T, c); - - pf = 1.0; - pr = 1.0; - - const label Nl = R.lhs().size(); - const label Nr = R.rhs().size(); - - label slRef = 0; - lRef = R.lhs()[slRef].index; - - pf = kf; - for (label s = 1; s < Nl; s++) - { - const label si = R.lhs()[s].index; - - if (c[si] < c[lRef]) - { - const scalar exp = R.lhs()[slRef].exponent; - pf *= pow(max(c[lRef], 0.0), exp); - lRef = si; - slRef = s; - } - else - { - const scalar exp = R.lhs()[s].exponent; - pf *= pow(max(c[si], 0.0), exp); - } - } - cf = max(c[lRef], 0.0); - - { - const scalar exp = R.lhs()[slRef].exponent; - if (exp < 1.0) - { - if (cf > small) - { - pf *= pow(cf, exp - 1.0); - } - else - { - pf = 0.0; - } - } - else - { - pf *= pow(cf, exp - 1.0); - } - } - - label srRef = 0; - rRef = R.rhs()[srRef].index; - - // Find the matrix element and element position for the rhs - pr = kr; - for (label s = 1; s < Nr; s++) - { - const label si = R.rhs()[s].index; - if (c[si] < c[rRef]) - { - const scalar exp = R.rhs()[srRef].exponent; - pr *= pow(max(c[rRef], 0.0), exp); - rRef = si; - srRef = s; - } - else - { - const scalar exp = R.rhs()[s].exponent; - pr *= pow(max(c[si], 0.0), exp); - } - } - cr = max(c[rRef], 0.0); - - { - const scalar exp = R.rhs()[srRef].exponent; - if (exp < 1.0) - { - if (cr > small) - { - pr *= pow(cr, exp - 1.0); - } - else - { - pr = 0.0; - } - } - else - { - pr *= pow(cr, exp - 1.0); - } - } - - return pf*cf - pr*cr; -} - - template void Foam::StandardChemistryModel::derivatives ( @@ -286,29 +155,29 @@ void Foam::StandardChemistryModel::derivatives forAll(c_, i) { - c_[i] = max(c[i], 0.0); + c_[i] = max(c[i], 0); } omega(c_, T, p, dcdt); // Constant pressure // dT/dt = ... - scalar rho = 0.0; - scalar cSum = 0.0; + scalar rho = 0; + scalar cSum = 0; for (label i = 0; i < nSpecie_; i++) { const scalar W = specieThermo_[i].W(); cSum += c_[i]; rho += W*c_[i]; } - scalar cp = 0.0; + scalar cp = 0; for (label i=0; i::derivatives dcdt[nSpecie_] = -dT; // dp/dt = ... - dcdt[nSpecie_ + 1] = 0.0; + dcdt[nSpecie_ + 1] = 0; } @@ -329,7 +198,7 @@ void Foam::StandardChemistryModel::jacobian const scalar t, const scalarField& c, scalarField& dcdt, - scalarSquareMatrix& dfdc + scalarSquareMatrix& J ) const { const scalar T = c[nSpecie_]; @@ -337,131 +206,67 @@ void Foam::StandardChemistryModel::jacobian forAll(c_, i) { - c_[i] = max(c[i], 0.0); + c_[i] = max(c[i], 0); } - dfdc = Zero; - - // Length of the first argument must be nSpecie_ - omega(c_, T, p, dcdt); + J = Zero; + dcdt = Zero; + // To compute the species derivatives of the temperature term, + // the enthalpies of the individual species is needed + scalarField hi(nSpecie_); + scalarField cpi(nSpecie_); + for (label i = 0; i < nSpecie_; i++) + { + hi[i] = specieThermo_[i].ha(p, T); + cpi[i] = specieThermo_[i].cp(p, T); + } + scalar omegaI = 0; + List