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

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

 vmon=(pi*pow(dia,3.0))/6.0;
     mmon=rho*vmon;
     Coagc=2.0*kb*Tgas/(3.0*visc); 

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

All Classes Files Functions Variables Typedefs Friends Defines