sequential.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "sequential.H"
00028 #include "addToRunTimeSelectionTable.H"
00029
00030
00031
00032 template<class CompType, class ThermoType>
00033 Foam::sequential<CompType, ThermoType>::sequential
00034 (
00035 ODEChemistryModel<CompType, ThermoType>& model,
00036 const word& modelName
00037 )
00038 :
00039 chemistrySolver<CompType, ThermoType>(model, modelName),
00040 coeffsDict_(model.subDict(modelName + "Coeffs")),
00041 cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))),
00042 equil_(coeffsDict_.lookup("equilibriumRateLimiter"))
00043 {}
00044
00045
00046
00047
00048 template<class CompType, class ThermoType>
00049 Foam::sequential<CompType, ThermoType>::~sequential()
00050 {}
00051
00052
00053
00054
00055 template<class CompType, class ThermoType>
00056 Foam::scalar Foam::sequential<CompType, ThermoType>::solve
00057 (
00058 scalarField &c,
00059 const scalar T,
00060 const scalar p,
00061 const scalar t0,
00062 const scalar dt
00063 ) const
00064 {
00065 scalar tChemInv = SMALL;
00066
00067 scalar pf, cf, pb, cb;
00068 label lRef, rRef;
00069
00070 for (label i=0; i<this->model_.reactions().size(); i++)
00071 {
00072 const Reaction<ThermoType>& R = this->model_.reactions()[i];
00073
00074 scalar om0 = this->model_.omega
00075 (
00076 R, c, T, p, pf, cf, lRef, pb, cb, rRef
00077 );
00078
00079 scalar omeg = 0.0;
00080 if (!equil_)
00081 {
00082 omeg = om0;
00083 }
00084 else
00085 {
00086 if (om0<0.0)
00087 {
00088 omeg = om0/(1.0 + pb*dt);
00089 }
00090 else
00091 {
00092 omeg = om0/(1.0 + pf*dt);
00093 }
00094 }
00095 tChemInv = max(tChemInv, mag(omeg));
00096
00097
00098
00099 for (label s=0; s<R.lhs().size(); s++)
00100 {
00101 label si = R.lhs()[s].index;
00102 scalar sl = R.lhs()[s].stoichCoeff;
00103 c[si] -= dt*sl*omeg;
00104 c[si] = max(0.0, c[si]);
00105 }
00106
00107 for (label s=0; s<R.rhs().size(); s++)
00108 {
00109 label si = R.rhs()[s].index;
00110 scalar sr = R.rhs()[s].stoichCoeff;
00111 c[si] += dt*sr*omeg;
00112 c[si] = max(0.0, c[si]);
00113 }
00114
00115 }
00116
00117 return cTauChem_/tChemInv;
00118 }
00119
00120
00121
Copyright © 2000-2009 OpenCFD Ltd