Function where the user enters the evaluation of the source terms and growth terms.
The vector y contains the num_points weights W_i and the num_points * quadrature points x_{k,i}. With k = 0 to dimension-1 and i = 0 to n = 0 to num_points-1. The ordering is as follows: [ W_0,...,W_{num_points-1},x_{0,0},...,x_{0,num_points-1},x_{1,0},...,x_{1,num_points-1},...,x_{dimension-1,0},...,x_{dimension,num_points-1}] The user should compute moments of the source terms aand return the vector f of size num_points * (dimension + 1). The growth terms which are velocities in internal space, should be provided in the vector growth again of size num_points * (dimension + 1). Examples of writing functions for numerous applications are provided in the Examples section. Function where the user enters the evaluation of the source terms and growth terms. External function to compute user defined source terms.
The vector y contains the num_points weights W_i and the num_points * quadrature points x_{k,i}. With k = 0 to dimension-1 and i = 0 to n = 0 to num_points-1. The ordering is as follows: [ W_0,...,W_{num_points-1},x_{0,0},...,x_{0,num_points-1},x_{1,0},...,x_{1,num_points-1},...,x_{dimension-1,0},...,x_{dimension,num_points-1}] The user should compute moments of the source terms aand return the vector f of size num_points * (dimension + 1). The growth terms which are velocities in internal space, should be provided in the vector growth again of size num_points * (dimension + 1).
Function where the user enters the evaluation of the source terms and growth terms. External function to compute user defined source terms.
The vector y contains the num_points weights W_i and the num_points * quadrature points x_{k,i}. With k = 0 to dimension-1 and i = 0 to n = 0 to num_points-1. The ordering is as follows: [ W_0,...,W_{num_points-1},x_{0,0},...,x_{0,num_points-1},x_{1,0},...,x_{1,num_points-1},...,x_{dimension-1,0},...,x_{dimension,num_points-1}] For this example, the user should compute moments of the output variable and return them as source terms. The growth terms are unused and should be returned as zero. Note for GLD reconstruction only the first five moments and needed and hence only these moments are computed.
Declaration of variables needed for computing source terms. vmon : volume of the monomer, mmon : mass of monomer, Coagc : coagulation term, Kc : Coagulation kernel double vmon, mmon, Coagc, Kc;
Computation of vmon,mmon, Coagc Definition of the size of the problem itot, i.e. the number of moments that need to be evolved. In this example, dimension = 1 size_t itot = dimension*num_points + num_points;
Outer loop over the total nuber of moments. for( size_t i = 0; i < itot; i++ ) { Computing source terms for the moment equations. Here the source terms involve double integrals. So the quadrature sums have nested loops. f[i] = 0.0; for( size_t j = 0; j < num_points; j++ ){ for( size_t k = 0; k < num_points; k++ ){ Kc=Coagc*(pow(y[j+num_points]*vmon,1.0/3.0)+pow(y[k+num_points]*vmon,1.0/3.0))* (pow(y[j+num_points]*vmon,-1.0/3.0)+pow(y[k+num_points]*vmon,-1.0/3.0)); f[i] += (pow(y[j+num_points]+y[k+num_points],i)-pow(y[j+num_points],i)-pow(y[k+num_points],i))* Kc*y[j]*y[k]*init_num;}} f[i] *= 0.5; The growth terms are zero for this example. growth[i] = 0.0; Return control to the calling routines. return;
}
Definition of the size of the problem itot, i.e. the number of moments that need to be evolved. In this example, dimension = 1 size_t itot = dimension*num_points + num_points;
Outer loop over the total number of moments. for( size_t i = 0; i < itot; i++ ) { Computing source terms for the moment equations. Here the source terms involve integrals of the term that models diffusion in internal space. f[i] = 0.0; for( size_t j = 0; j < num_points; j++ ){ f[i] += j*(j-1)*pow(y[j+num_points],j-2)*y[j]} f[i] *= std_noise; The growth terms are given by (y-y^3) for this example. growth[i] = (y[i+num_points]-pow(y[i+num_points],3.0)); Return control to the calling routines. return;
}
Definition of the size of the problem itot, i.e. the number of moments that need to be evolved. In this example, dimension = 1 size_t itot = dimension*num_points + num_points;
Outer loop over the total number of moments. for( size_t i = 0; i < itot; i++ ) { Computing source terms for the moment equations. Here the source terms involve integrals of the term that models diffusion in internal space. Here we have a bivariate problem with two variables x_{1} and x_{2}. The matrix dtuple_set contains the 2-tuples that index the moments. At this point it is upto the user to assign each variable to a particular dimension by associating the moment index with the variable. The first index is the 'principal dimension' for which larger number of higher order moments are selected. Let us associate x_{1} with the principal dimension. f[i] = 0.0; For each row i the matrix entry dtuple_set.get(i,0) contains the first index of the bivariate moment set. dtuple_set.get(i,0) contains the second index for the bivariate moment set. In this example, if the second index is 0 or 1 then the diffusive source term is zero. if (dtuple_set.get(i,1) == 0 || dtuple_set.get(i,1) == 1){ f[i] = 0.0;} Otherwise compute diffusive source terms. Here we assign x_{1} which is y[j+num_points] to be the principal dimension and assign it the second index l1. We assign the second variable y[j+2*num_points] to the second dimension. else { for( size_t j = 0; j < num_points; j++ ){ int l1 = dtuple_set.get(i,0); int l2 = dtuple_set.get(i,1); f[i] += l2*(l2-1)*pow(y[j+2*num_points],l2-2)*pow(y[j+num_points],l1)*y[j];} f[i] *= std_noise;} Let x_{1} and x_{2} denote the two variables (dimensions). We choose x_{1} to be the first dimension and x_{2} to be the second dimension. Note that due to SGLO more moments of x_{1} will be tracked. The growth terms are x_{2} for the first variable x_{1} and -mu*(x_{1}^2 - 1)x_{2} - x_{1} for the second variable x_{2}. growth[i] = 0.0; Specify growth terms for the first variable (dimension). if(i >= num_points && i < 2*num_points) growth[i] = y[i+num_points];
Specify growth terms for the second variable (dimension). if(i >= 2*num_points && i < 3*num_points) growth[i] = -std_noise*y[i]-0.5*y[i-num_points]
Return control to the calling routines. return;
}
Computation of various quantities needed for the ASET model. double anum, adenom, term1, term2, time; double Z[num_points]; anum=-0.21*(pow(g,0.5))*(pow(1.0-aLr,1.0/3.0)); adenom=pow(rhoa*Ca*Ta*(pow(g,0.5)),1.0/3.0)*Ar; term1=anum/adenom; term2=(1.0-aLc)/(rhoa*Ca*Ta*Ar); double Zf = Zf_factor*Z0; Now loop over the quadrature points to compute the smoke height for each heat release rate. The vector y[] contains quadrature points and weights of the heat release rate distribution. for(size_t ipt=0; ipt < num_points; ipt++){ Z[ipt] = Z0; Evolve the ODE upto the critical time Z[ipt]=Z[ipt]+dt*(term1*(pow(y[ipt+num_points],1.0/3.0)) (pow(Z[ipt]-Zf,5.0/3.0))-term2*y[ipt+num_points]); if(Z[ipt] <= Zf){Z[ipt]=Zf;}} } Now compute the moments of Z at the critical time. Only the first five moments are required for the GLD reconstruction. The vector for (size_t l = 0; l < 6; l++){ f[l] = 0.0; for (size_t i = 0; i < num_points; i++){ f[l] += y[i]*pow(Z[i],(int)l);}} Return control to the calling routines. return;
}
Definition of the size of the problem itot, i.e. the number of moments that need to be evolved. In this example, dimension = 1 size_t itot = dimension*num_points + num_points;
Outer loop over the total number of moments. for( size_t i = 0; i < itot; i++ ) { Computing source terms for the moment equations. For QMOM the source terms involve integrals of the term that models growth and diffusion in internal space. The growth terms are given by (y-y^3) for this example. f[i] = 0.0; for( size_t j = 0; j < num_points; j++ ){ f[i] += j*(j-1)*pow(y[j+num_points],j-2)*y[j]} f[i] *= std_noise; if (i > 0){ for( size_t j = 0; j < num_points; j++ ){ f[i] += i*(y[j+num_points]-pow(y[j+num_points],3.0))*pow(y[j+num_points],i-1)*y[j];} } growth[i] = (y[i+num_points]-pow(y[i+num_points],3.0)); Return control to the calling routines. return;
}
Declaration of variables needed for computing source terms. vmon : volume of the monomer, mmon : mass of monomer, Coagc : coagulation term, Kc : Coagulation kernel double vmon, mmon, Coagc, Kc;
Computation of vmon,mmon, Coagc Definition of the size of the problem itot, i.e. the number of moments that need to be evolved. In this example, dimension = 1 size_t itot = dimension*num_points + num_points;
Outer loop over the total nuber of moments. for( size_t i = 0; i < itot; i++ ) { Computing source terms for the moment equations. Here the source terms involve double integrals. So the quadrature sums have nested loops. f[i] = 0.0; for( size_t j = 0; j < num_points; j++ ){ for( size_t k = 0; k < num_points; k++ ){ Kc=Coagc*(pow(y[j+num_points]*vmon,1.0/3.0)+pow(y[k+num_points]*vmon,1.0/3.0))* (pow(y[j+num_points]*vmon,-1.0/3.0)+pow(y[k+num_points]*vmon,-1.0/3.0)); f[i] += (pow(y[j+num_points]+y[k+num_points],i)-pow(y[j+num_points],i)-pow(y[k+num_points],i))* Kc*y[j]*y[k]*init_num;}} f[i] *= 0.5; The growth terms are zero for this example. growth[i] = 0.0; Return control to the calling routines. return;
}
Definition of the size of the problem itot, i.e. the number of moments that need to be evolved. In this example, dimension = 1 size_t itot = dimension*num_points + num_points;
Outer loop over the total number of moments. for( size_t i = 0; i < itot; i++ ) { Computing source terms for the moment equations. Here the source terms involve integrals of the term that models diffusion in internal space. f[i] = 0.0; for( size_t j = 0; j < num_points; j++ ){ f[i] += j*(j-1)*pow(y[j+num_points],j-2)*y[j]} f[i] *= std_noise; The growth terms are given by (y-y^3) for this example. growth[i] = (y[i+num_points]-pow(y[i+num_points],3.0)); Return control to the calling routines. return;
}
Definition of the size of the problem itot, i.e. the number of moments that need to be evolved. In this example, dimension = 1 size_t itot = dimension*num_points + num_points;
Outer loop over the total number of moments. for( size_t i = 0; i < itot; i++ ) { Computing source terms for the moment equations. Here the source terms involve integrals of the term that models diffusion in internal space. Here we have a bivariate problem with two variables x_{1} and x_{2}. The matrix dtuple_set contains the 2-tuples that index the moments. At this point it is upto the user to assign each variable to a particular dimension by associating the moment index with the variable. The first index is the 'principal dimension' for which larger number of higher order moments are selected. Let us associate x_{1} with the principal dimension. f[i] = 0.0; For each row i the matrix entry dtuple_set.get(i,0) contains the first index of the bivariate moment set. dtuple_set.get(i,0) contains the second index for the bivariate moment set. In this example, if the second index is 0 or 1 then the diffusive source term is zero. if (dtuple_set.get(i,1) == 0 || dtuple_set.get(i,1) == 1){ f[i] = 0.0;} Otherwise compute diffusive source terms. Here we assign x_{1} which is y[j+num_points] to be the principal dimension and assign it the second index l1. We assign the second variable y[j+2*num_points] to the second dimension. else { for( size_t j = 0; j < num_points; j++ ){ int l1 = dtuple_set.get(i,0); int l2 = dtuple_set.get(i,1); f[i] += l2*(l2-1)*pow(y[j+2*num_points],l2-2)*pow(y[j+num_points],l1)*y[j];} f[i] *= std_noise;} Let x_{1} and x_{2} denote the two variables (dimensions). We choose x_{1} to be the first dimension and x_{2} to be the second dimension. Note that due to SGLO more moments of x_{1} will be tracked. The growth terms are x_{2} for the first variable x_{1} and -mu*(x_{1}^2 - 1)x_{2} - x_{1} for the second variable x_{2}. growth[i] = 0.0; Specify growth terms for the first variable (dimension). if(i >= num_points && i < 2*num_points) growth[i] = y[i+num_points];
Specify growth terms for the second variable (dimension). if(i >= 2*num_points && i < 3*num_points) growth[i] = -std_noise*y[i]-0.5*y[i-num_points]
Return control to the calling routines. return;
}
Computation of various quantities needed for the ASET model. double anum, adenom, term1, term2, time; double Z[num_points]; anum=-0.21*(pow(g,0.5))*(pow(1.0-aLr,1.0/3.0)); adenom=pow(rhoa*Ca*Ta*(pow(g,0.5)),1.0/3.0)*Ar; term1=anum/adenom; term2=(1.0-aLc)/(rhoa*Ca*Ta*Ar); double Zf = Zf_factor*Z0; Now loop over the quadrature points to compute the smoke height for each heat release rate. The vector y[] contains quadrature points and weights of the heat release rate distribution. for(size_t ipt=0; ipt < num_points; ipt++){ Z[ipt] = Z0; Evolve the ODE upto the critical time Z[ipt]=Z[ipt]+dt*(term1*(pow(y[ipt+num_points],1.0/3.0)) (pow(Z[ipt]-Zf,5.0/3.0))-term2*y[ipt+num_points]); if(Z[ipt] <= Zf){Z[ipt]=Zf;}} } Now compute the moments of Z at the critical time. Only the first five moments are required for the GLD reconstruction. The vector for (size_t l = 0; l < 6; l++){ f[l] = 0.0; for (size_t i = 0; i < num_points; i++){ f[l] += y[i]*pow(Z[i],(int)l);}} Return control to the calling routines. return;
}
Definition of the size of the problem itot, i.e. the number of moments that need to be evolved. In this example, dimension = 1 size_t itot = dimension*num_points + num_points;
Outer loop over the total number of moments. for( size_t i = 0; i < itot; i++ ) { Computing source terms for the moment equations. For QMOM the source terms involve integrals of the term that models growth and diffusion in internal space. The growth terms are given by (y-y^3) for this example. f[i] = 0.0; for( size_t j = 0; j < num_points; j++ ){ f[i] += j*(j-1)*pow(y[j+num_points],j-2)*y[j]} f[i] *= std_noise; if (i > 0){ for( size_t j = 0; j < num_points; j++ ){ f[i] += i*(y[j+num_points]-pow(y[j+num_points],3.0))*pow(y[j+num_points],i-1)*y[j];} } growth[i] = (y[i+num_points]-pow(y[i+num_points],3.0)); Return control to the calling routines. return;
}
|