void user_source ( size_t  dimension,
size_t  num_points,
double  y[],
double  f[],
double  growth[] 
)

Function that returns the growth and source terms.

Function where the user enters the evaluation of the source terms and growth terms.

External function to compute user defined source terms.

Author:
Rochan R. Upadhyay
Parameters:
dimension: Dimension of the problem
num_points: Number of quadrature points
y: C style vector that contains quadrature points and weights. Details below.
f: C style vector containing moments of the source terms of the Population Balance equation
growth: C style vector that contains the growth terms (not the moments of the growth term)

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).

Date:
10/12/2010

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;    
 } 

 All Classes Files Functions Variables Typedefs Friends Defines