Main program for the Fokker-Planck example problem with improved QMOM algorithm.
For example, the program is run as ./Fokker_Planck_1D_QMOM 1 4 Fokker_Planck_1D_QMOM.input. This sets dimension = 1 , number of quadrature points = 4, Fokker_Planck.input as the input file to be read. Note selective glex as the moment ordering option is not used for the univariate example. int main (int argc, char **argv) { Declare variable solver_params as an object of the inputs class. solver_params can then access the member function input_reader that reads the input file inputs solver_params Declare as extern variables defined elsewhere in inputs.c. num_steps : total number of time steps, print_interval : intervals at which output is to be printed, dt : time step, tau : time scale, mu : mean of initial normal distribution, std : standard deviation of initial normal distribution extern int num_steps, print_interval; extern double dt; extern double mu, std_dev; extern matrix_int dtuple_set; Invoke the the input_reader function which is a member of the inputs class of which solver_params is declared to be a member. The argv[3] is the third variable in the command line options when running the example. solver_params.input_reader(argv[3]); Declare the dimension of the problem. atoi(argv[1]) assigns the first variable in the command line options to dimension. size_t dimension = atoi(argv[1]);
Declare the number of quadrature points to be used in the problem. atoi(argv[2]) assigns the second variable in the command line options to num_points. size_t num_points = atoi(argv[2]);
The total number of moments required for the chosen dimension and num_points. size_t itot = num_points + dimension*num_points;
Declare the moment vectors and the equivalent quadrature-weights+points vectors. moms is an object of the moments class and quadwts is an object of the quadrature-weights+points class. Both are intialized with the size of the problem itot. Initial conditions for moments (in this example, normal with given mean and standard deviation read in from the input file. moms = moms.univariate_gaussian_raw(dimension, num_points, mu, std_dev); Evolve the moments using the Quadrature method of mmoments. moms.solve(dimension, num_points, dt, num_steps, int print_interval); moms.solve(dimension, num_points, dt, num_steps, print_interval); Exit the program @code return 0; } |