correct SLFMFoam code indentation - removing tabs
This commit is contained in:
parent
ae06280819
commit
3f21c5788f
6 changed files with 279 additions and 279 deletions
|
|
@ -108,44 +108,44 @@ inline double simpson(scalar min, scalar max, scalar interval, scalarField& ftn)
|
|||
|
||||
inline double integration(scalar deltaftn, scalarField& MFcut, scalarField& Neta, scalarField& pdf, scalarField& f)
|
||||
{
|
||||
double result = 0.0;
|
||||
double min, max, interval;
|
||||
if(deltaftn < 0.5) //one delta function (deltaftn == 0)
|
||||
{
|
||||
for(label i=0; i<= (Neta[MFcut.size()-1]);i++)
|
||||
{
|
||||
if(pdf[i] > 1e-30)
|
||||
{
|
||||
result = f[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(deltaftn > 0.5 && deltaftn < 1.5) //two delta function (deltaftn == 1)
|
||||
{
|
||||
for(label i=0; i<= (Neta[MFcut.size()-1]);i++)
|
||||
{
|
||||
if(pdf[i] > 1e-30)
|
||||
{
|
||||
result += 0.5*f[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(deltaftn > 1.5) //not a delta function (deltaftn == 2)
|
||||
{
|
||||
scalarField ftn = pdf*f;
|
||||
for(label i=0; i<(MFcut.size()-1); i++ )
|
||||
{
|
||||
min = Neta[i];
|
||||
max = Neta[i+1];
|
||||
interval = (MFcut[i+1]-MFcut[i])/(max-min);
|
||||
result += simpson(min, max, interval, ftn);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Integration error
|
||||
}
|
||||
return result;
|
||||
double result = 0.0;
|
||||
double min, max, interval;
|
||||
if(deltaftn < 0.5) //one delta function (deltaftn == 0)
|
||||
{
|
||||
for(label i=0; i<= (Neta[MFcut.size()-1]);i++)
|
||||
{
|
||||
if(pdf[i] > 1e-30)
|
||||
{
|
||||
result = f[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(deltaftn > 0.5 && deltaftn < 1.5) //two delta function (deltaftn == 1)
|
||||
{
|
||||
for(label i=0; i<= (Neta[MFcut.size()-1]);i++)
|
||||
{
|
||||
if(pdf[i] > 1e-30)
|
||||
{
|
||||
result += 0.5*f[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(deltaftn > 1.5) //not a delta function (deltaftn == 2)
|
||||
{
|
||||
scalarField ftn = pdf*f;
|
||||
for(label i=0; i<(MFcut.size()-1); i++ )
|
||||
{
|
||||
min = Neta[i];
|
||||
max = Neta[i+1];
|
||||
interval = (MFcut[i+1]-MFcut[i])/(max-min);
|
||||
result += simpson(min, max, interval, ftn);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Integration error
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//inline double trapz()
|
||||
|
|
@ -161,50 +161,50 @@ inline double integration(scalar deltaftn, scalarField& MFcut, scalarField& Neta
|
|||
// Equation 17
|
||||
inline double lognormalPDF(scalar Nst, scalar Nst_local)
|
||||
{
|
||||
double result, numerator;
|
||||
const double pi = 3.141592;
|
||||
const double sigmaN = 1.0;
|
||||
double result, numerator;
|
||||
const double pi = 3.141592;
|
||||
const double sigmaN = 1.0;
|
||||
|
||||
numerator = sqr(std::log(Nst/Nst_local)+0.5*sqr(sigmaN));
|
||||
result = std::exp(-0.5*numerator/sqr(sigmaN));
|
||||
result = result/std::sqrt(2.0*pi)/Nst/sigmaN;
|
||||
numerator = sqr(std::log(Nst/Nst_local)+0.5*sqr(sigmaN));
|
||||
result = std::exp(-0.5*numerator/sqr(sigmaN));
|
||||
result = result/std::sqrt(2.0*pi)/Nst/sigmaN;
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
//Returns the integral of the lognormalPDF function between a and b, by
|
||||
//ten-point Gauss-Legendre integration, Numerical Recipe 2nd Ed. p.140
|
||||
inline double qgaus(scalar a, scalar b, scalar Nst_local)
|
||||
{
|
||||
double dx, xm, xr, result;
|
||||
static double w[] = {
|
||||
double dx, xm, xr, result;
|
||||
static double w[] = {
|
||||
0.2955242247,
|
||||
0.2692667193,
|
||||
0.2190863625,
|
||||
0.1494513491,
|
||||
0.0666713443
|
||||
};
|
||||
static double x[] = {
|
||||
0.1488743389,
|
||||
0.4333953941,
|
||||
0.6794095682,
|
||||
0.8650633666,
|
||||
0.9739065285
|
||||
};
|
||||
0.2692667193,
|
||||
0.2190863625,
|
||||
0.1494513491,
|
||||
0.0666713443
|
||||
};
|
||||
static double x[] = {
|
||||
0.1488743389,
|
||||
0.4333953941,
|
||||
0.6794095682,
|
||||
0.8650633666,
|
||||
0.9739065285
|
||||
};
|
||||
|
||||
xm = 0.5*(b+a);
|
||||
xr = 0.5*(b-a);
|
||||
result = 0.0;
|
||||
xm = 0.5*(b+a);
|
||||
xr = 0.5*(b-a);
|
||||
result = 0.0;
|
||||
|
||||
for(label i=0 ; i<5 ; i++)
|
||||
{
|
||||
dx = xr*x[i];
|
||||
result = result + w[i]*(lognormalPDF(xm+dx, Nst_local)
|
||||
+ lognormalPDF(xm-dx, Nst_local));
|
||||
}
|
||||
result = xr*result;
|
||||
for(label i=0 ; i<5 ; i++)
|
||||
{
|
||||
dx = xr*x[i];
|
||||
result = result + w[i]*(lognormalPDF(xm+dx, Nst_local)
|
||||
+ lognormalPDF(xm-dx, Nst_local));
|
||||
}
|
||||
result = xr*result;
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
//Returns the P_N(Nst)*dNst
|
||||
|
|
@ -212,190 +212,190 @@ inline double qgaus(scalar a, scalar b, scalar Nst_local)
|
|||
// Equation 16
|
||||
inline void calculate_PdNst(scalar NumofNst, scalarField& Nst, scalar Nst_local, scalarField& result)
|
||||
{
|
||||
const double alarge = 1000.0;
|
||||
scalar a,b;
|
||||
const double alarge = 1000.0;
|
||||
scalar a,b;
|
||||
|
||||
if(Nst_local > 0.5*Nst[0])
|
||||
{
|
||||
a = 0.0;
|
||||
b = 0.5*(Nst[0]+Nst[1]);
|
||||
result[0] = qgaus(a, b, Nst_local);
|
||||
if(Nst_local > 0.5*Nst[0])
|
||||
{
|
||||
a = 0.0;
|
||||
b = 0.5*(Nst[0]+Nst[1]);
|
||||
result[0] = qgaus(a, b, Nst_local);
|
||||
|
||||
for(label i=1 ; i<(NumofNst-1) ; i++)
|
||||
{
|
||||
a = 0.5*(Nst[i]+Nst[i-1]);
|
||||
b = 0.5*(Nst[i]+Nst[i+1]);
|
||||
result[i] = qgaus(a, b, Nst_local);
|
||||
}
|
||||
for(label i=1 ; i<(NumofNst-1) ; i++)
|
||||
{
|
||||
a = 0.5*(Nst[i]+Nst[i-1]);
|
||||
b = 0.5*(Nst[i]+Nst[i+1]);
|
||||
result[i] = qgaus(a, b, Nst_local);
|
||||
}
|
||||
|
||||
a = 0.5*(Nst[NumofNst-1]+Nst[NumofNst-2]);
|
||||
b = alarge;
|
||||
result[NumofNst-1] = qgaus(a, b, Nst_local);
|
||||
}
|
||||
else
|
||||
{
|
||||
result[0] = 1.0;
|
||||
for(label i=1 ; i<NumofNst ; i++)
|
||||
{
|
||||
result[i] = 0.0;
|
||||
}
|
||||
}
|
||||
a = 0.5*(Nst[NumofNst-1]+Nst[NumofNst-2]);
|
||||
b = alarge;
|
||||
result[NumofNst-1] = qgaus(a, b, Nst_local);
|
||||
}
|
||||
else
|
||||
{
|
||||
result[0] = 1.0;
|
||||
for(label i=1 ; i<NumofNst ; i++)
|
||||
{
|
||||
result[i] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void Interpolation(scalarField& eta, scalarField& eta_temp, scalar NumofNst, scalar Nspecies, scalarField& Y_SLFM_temp, scalarField& result)
|
||||
{
|
||||
scalar eta_size(eta.size()), eta_temp_size(eta_temp.size());
|
||||
scalar lower_eta(0), higher_eta(0);
|
||||
scalar lindex(0), hindex(0);
|
||||
scalar frac(0), diff(0);
|
||||
scalar eta_size(eta.size()), eta_temp_size(eta_temp.size());
|
||||
scalar lower_eta(0), higher_eta(0);
|
||||
scalar lindex(0), hindex(0);
|
||||
scalar frac(0), diff(0);
|
||||
|
||||
for(label j=0; j<eta_size ; j++)
|
||||
{
|
||||
for(label jj=0; jj<eta_temp_size ; jj++)
|
||||
{
|
||||
if(eta_temp[jj] <= eta[j])
|
||||
{
|
||||
lower_eta = eta_temp[jj];
|
||||
lindex = jj;
|
||||
}
|
||||
}
|
||||
for(label jj=eta_temp_size-1 ; jj>=0 ; jj--)
|
||||
{
|
||||
if(eta_temp[jj] > eta[j])
|
||||
{
|
||||
higher_eta = eta_temp[jj];
|
||||
hindex = jj;
|
||||
}
|
||||
}
|
||||
for(label j=0; j<eta_size ; j++)
|
||||
{
|
||||
for(label jj=0; jj<eta_temp_size ; jj++)
|
||||
{
|
||||
if(eta_temp[jj] <= eta[j])
|
||||
{
|
||||
lower_eta = eta_temp[jj];
|
||||
lindex = jj;
|
||||
}
|
||||
}
|
||||
for(label jj=eta_temp_size-1 ; jj>=0 ; jj--)
|
||||
{
|
||||
if(eta_temp[jj] > eta[j])
|
||||
{
|
||||
higher_eta = eta_temp[jj];
|
||||
hindex = jj;
|
||||
}
|
||||
}
|
||||
|
||||
frac = (eta[j]-lower_eta)/(higher_eta-lower_eta);
|
||||
frac = (eta[j]-lower_eta)/(higher_eta-lower_eta);
|
||||
|
||||
for(label m=0 ; m<NumofNst ; m++)
|
||||
{
|
||||
for(label i=0 ; i<Nspecies ; i++)
|
||||
{
|
||||
diff = Y_SLFM_temp[(m*eta_temp_size+hindex)*Nspecies+i]
|
||||
- Y_SLFM_temp[(m*eta_temp_size+lindex)*Nspecies+i];
|
||||
for(label m=0 ; m<NumofNst ; m++)
|
||||
{
|
||||
for(label i=0 ; i<Nspecies ; i++)
|
||||
{
|
||||
diff = Y_SLFM_temp[(m*eta_temp_size+hindex)*Nspecies+i]
|
||||
- Y_SLFM_temp[(m*eta_temp_size+lindex)*Nspecies+i];
|
||||
|
||||
result[(m*eta_size+j)*Nspecies+i] = Y_SLFM_temp[(m*eta_temp_size+lindex)*Nspecies+i] + frac*diff;
|
||||
}
|
||||
}
|
||||
}
|
||||
result[(m*eta_size+j)*Nspecies+i] = Y_SLFM_temp[(m*eta_temp_size+lindex)*Nspecies+i] + frac*diff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void select_ij(label ij, scalar& i, scalar& j)
|
||||
{
|
||||
if(ij == 0) //variance for H, O2, CO, OH, CH4, T
|
||||
{
|
||||
i = 0;
|
||||
j = 0;
|
||||
}
|
||||
else if(ij == 1)
|
||||
{
|
||||
i = 1;
|
||||
j = 1;
|
||||
}
|
||||
else if(ij == 2)
|
||||
{
|
||||
i = 2;
|
||||
j = 2;
|
||||
}
|
||||
else if(ij == 3)
|
||||
{
|
||||
i = 3;
|
||||
j = 3;
|
||||
}
|
||||
else if(ij == 4)
|
||||
{
|
||||
i = 4;
|
||||
j = 4;
|
||||
}
|
||||
else if(ij == 5)
|
||||
{
|
||||
i = 5;
|
||||
j = 5;
|
||||
}
|
||||
else if(ij == 6) //covariance between H and O2
|
||||
{
|
||||
i = 0;
|
||||
j = 1;
|
||||
}
|
||||
else if(ij == 7) //covariance between CO and OH
|
||||
{
|
||||
i = 2;
|
||||
j = 3;
|
||||
}
|
||||
else if(ij == 8) //covariance between H and CH4
|
||||
{
|
||||
i = 0;
|
||||
j = 4;
|
||||
}
|
||||
else if(ij == 9) //covariance between SPECIES and T
|
||||
{
|
||||
i = 0;
|
||||
j = 5;
|
||||
}
|
||||
else if(ij == 10)
|
||||
{
|
||||
i = 1;
|
||||
j = 5;
|
||||
}
|
||||
else if(ij == 11)
|
||||
{
|
||||
i = 2;
|
||||
j = 5;
|
||||
}
|
||||
else if(ij == 12)
|
||||
{
|
||||
i = 3;
|
||||
j = 5;
|
||||
}
|
||||
else if(ij == 13)
|
||||
{
|
||||
i = 4;
|
||||
j = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
abort();
|
||||
}
|
||||
if(ij == 0) //variance for H, O2, CO, OH, CH4, T
|
||||
{
|
||||
i = 0;
|
||||
j = 0;
|
||||
}
|
||||
else if(ij == 1)
|
||||
{
|
||||
i = 1;
|
||||
j = 1;
|
||||
}
|
||||
else if(ij == 2)
|
||||
{
|
||||
i = 2;
|
||||
j = 2;
|
||||
}
|
||||
else if(ij == 3)
|
||||
{
|
||||
i = 3;
|
||||
j = 3;
|
||||
}
|
||||
else if(ij == 4)
|
||||
{
|
||||
i = 4;
|
||||
j = 4;
|
||||
}
|
||||
else if(ij == 5)
|
||||
{
|
||||
i = 5;
|
||||
j = 5;
|
||||
}
|
||||
else if(ij == 6) //covariance between H and O2
|
||||
{
|
||||
i = 0;
|
||||
j = 1;
|
||||
}
|
||||
else if(ij == 7) //covariance between CO and OH
|
||||
{
|
||||
i = 2;
|
||||
j = 3;
|
||||
}
|
||||
else if(ij == 8) //covariance between H and CH4
|
||||
{
|
||||
i = 0;
|
||||
j = 4;
|
||||
}
|
||||
else if(ij == 9) //covariance between SPECIES and T
|
||||
{
|
||||
i = 0;
|
||||
j = 5;
|
||||
}
|
||||
else if(ij == 10)
|
||||
{
|
||||
i = 1;
|
||||
j = 5;
|
||||
}
|
||||
else if(ij == 11)
|
||||
{
|
||||
i = 2;
|
||||
j = 5;
|
||||
}
|
||||
else if(ij == 12)
|
||||
{
|
||||
i = 3;
|
||||
j = 5;
|
||||
}
|
||||
else if(ij == 13)
|
||||
{
|
||||
i = 4;
|
||||
j = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
inline void select_species(label i, word& speciei)
|
||||
{
|
||||
if(i == 0)
|
||||
{
|
||||
speciei = "H";
|
||||
}
|
||||
else if(i == 1)
|
||||
{
|
||||
speciei = "O2";
|
||||
}
|
||||
else if(i == 2)
|
||||
{
|
||||
speciei = "CO";
|
||||
}
|
||||
else if(i == 3)
|
||||
{
|
||||
speciei = "OH";
|
||||
}
|
||||
else if(i == 4)
|
||||
{
|
||||
speciei = "CH4";
|
||||
}
|
||||
if(i == 0)
|
||||
{
|
||||
speciei = "H";
|
||||
}
|
||||
else if(i == 1)
|
||||
{
|
||||
speciei = "O2";
|
||||
}
|
||||
else if(i == 2)
|
||||
{
|
||||
speciei = "CO";
|
||||
}
|
||||
else if(i == 3)
|
||||
{
|
||||
speciei = "OH";
|
||||
}
|
||||
else if(i == 4)
|
||||
{
|
||||
speciei = "CH4";
|
||||
}
|
||||
}
|
||||
inline scalar select_CiCj(scalar i)
|
||||
{
|
||||
if(i == 1 || i == 2 || i == 4 || i == 5)
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
else if(i == 0 || i == 3)
|
||||
{
|
||||
return 2.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
abort();
|
||||
}
|
||||
if(i == 1 || i == 2 || i == 4 || i == 5)
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
else if(i == 0 || i == 3)
|
||||
{
|
||||
return 2.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,10 +94,10 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
rho.write();
|
||||
#include "updateYi.H" //update species
|
||||
for(label y=0 ; y<postSpeciesN ; y++)
|
||||
{
|
||||
Y[y].write();
|
||||
}
|
||||
for(label y=0 ; y<postSpeciesN ; y++)
|
||||
{
|
||||
Y[y].write();
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||
|
|
|
|||
|
|
@ -345,13 +345,13 @@ for(label j=0 ; j<=etamax ; j++)
|
|||
|
||||
tmp<fv::convectionScheme<scalar> > mvConvection
|
||||
(
|
||||
fv::convectionScheme<scalar>::New
|
||||
(
|
||||
mesh,
|
||||
fields,
|
||||
phi,
|
||||
mesh.divScheme("div(phi,Yi_h)")
|
||||
)
|
||||
fv::convectionScheme<scalar>::New
|
||||
(
|
||||
mesh,
|
||||
fields,
|
||||
phi,
|
||||
mesh.divScheme("div(phi,Yi_h)")
|
||||
)
|
||||
);
|
||||
|
||||
#include "createMRF.H"
|
||||
|
|
|
|||
|
|
@ -26,16 +26,16 @@ scalarFieldArray2d Rtable
|
|||
|
||||
scalarFieldArray3d Ytable
|
||||
(
|
||||
postSpeciesN,
|
||||
scalarFieldArray2d
|
||||
(
|
||||
etamax+1,
|
||||
scalarFieldArray1d
|
||||
(
|
||||
NVar+1,
|
||||
scalarField(NstList.size(), 0)
|
||||
)
|
||||
)
|
||||
postSpeciesN,
|
||||
scalarFieldArray2d
|
||||
(
|
||||
etamax+1,
|
||||
scalarFieldArray1d
|
||||
(
|
||||
NVar+1,
|
||||
scalarField(NstList.size(), 0)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Info<<"Construct C1 coefficient table"<<endl;
|
||||
|
|
@ -56,9 +56,9 @@ for(label j=0 ; j<=etamax ; j++)
|
|||
Ttable[j][v][n] = bpdf.evaluate(mf, mfVar, etaValue, Y_SLFM[n][Ysize]);
|
||||
Rtable[j][v][n] = bpdf.evaluate(mf, mfVar, etaValue, Rgas_SLFM[n]);
|
||||
for(label y=0 ; y<postSpeciesN ; y++)
|
||||
{
|
||||
Ytable[y][j][v][n] = bpdf.evaluate(mf, mfVar, etaValue, Y_SLFM[n][y]);
|
||||
}
|
||||
{
|
||||
Ytable[y][j][v][n] = bpdf.evaluate(mf, mfVar, etaValue, Y_SLFM[n][y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Info<<j/etamax*100<<"%"<<endl;
|
||||
|
|
|
|||
|
|
@ -66,14 +66,14 @@ forAll(mf, cellI)
|
|||
|
||||
scalar Coeff = AMCcoeff[lowerN];
|
||||
|
||||
if (Equilibrium == true)
|
||||
{
|
||||
Neta[lowerN][cellI] = 0; //Equilibrium
|
||||
}
|
||||
else
|
||||
{
|
||||
Neta[lowerN][cellI] = SDR[cellI]*Coeff*C1coeff; //CSDR at stoichiometic m.f.
|
||||
}
|
||||
if (Equilibrium == true)
|
||||
{
|
||||
Neta[lowerN][cellI] = 0; //Equilibrium
|
||||
}
|
||||
else
|
||||
{
|
||||
Neta[lowerN][cellI] = SDR[cellI]*Coeff*C1coeff; //CSDR at stoichiometic m.f.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,24 +33,24 @@ forAll(rho, cellI)
|
|||
|
||||
for(label y=0 ; y<postSpeciesN ; y++)
|
||||
{
|
||||
scalar y00 = Ytable[y][jl][vl][nl]*(1-jfac)+Ytable[y][jh][vl][nl]*jfac;
|
||||
scalar y01 = Ytable[y][jl][vl][nh]*(1-jfac)+Ytable[y][jh][vl][nh]*jfac;
|
||||
scalar y10 = Ytable[y][jl][vh][nl]*(1-jfac)+Ytable[y][jh][vh][nl]*jfac;
|
||||
scalar y11 = Ytable[y][jl][vh][nh]*(1-jfac)+Ytable[y][jh][vh][nh]*jfac;
|
||||
scalar y00 = Ytable[y][jl][vl][nl]*(1-jfac)+Ytable[y][jh][vl][nl]*jfac;
|
||||
scalar y01 = Ytable[y][jl][vl][nh]*(1-jfac)+Ytable[y][jh][vl][nh]*jfac;
|
||||
scalar y10 = Ytable[y][jl][vh][nl]*(1-jfac)+Ytable[y][jh][vh][nl]*jfac;
|
||||
scalar y11 = Ytable[y][jl][vh][nh]*(1-jfac)+Ytable[y][jh][vh][nh]*jfac;
|
||||
|
||||
scalar y0 = y00*(1-vfac)+y10*vfac;
|
||||
scalar y1 = y01*(1-vfac)+y11*vfac;
|
||||
scalar y0 = y00*(1-vfac)+y10*vfac;
|
||||
scalar y1 = y01*(1-vfac)+y11*vfac;
|
||||
|
||||
scalar ygas = y0*(1-nfac)+y1*nfac;
|
||||
scalar ygas = y0*(1-nfac)+y1*nfac;
|
||||
|
||||
Y[y][cellI] = ygas;
|
||||
Y[y][cellI] = ygas;
|
||||
}
|
||||
}
|
||||
|
||||
//correct processor boundary value of T and rho
|
||||
for(label y=0 ; y<postSpeciesN ; y++)
|
||||
{
|
||||
Y[y].correctBoundaryConditions();
|
||||
Y[y].correctBoundaryConditions();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue