Friday, April 25, 2014

The Crank-Nicolson Method for finite-difference of Parabolic Problems.

This is the last section we covered in Numerical Analysis class.

This is the heat distribution over time of a thin heated rod along the x-axis.  The approximation works by taking evenly spaced points along the length of the rod, over the time-axis.

The code is here:  Parabolic_FinDiff_Final02.c
Using this library: matrix.c  matrix.h

Compiled with the following command:
gcc  matrix.c Parabolic_FinDiff_Final02.c -lm -o prog02
The problem required that the step spacing along the x-axis be .2 and once that was working I tried .1, then .01 which works with 400x400 matrices and 400x1 vectors. At .2 and .1 the program ran in about 25ms.  At .01 step size the program took 9 seconds to write the results to a file.  Running the program at .002, which works with 2000x2000 matrices takes 18 minutes and 43 seconds and takes up 9% of system memory.

I am currently running  at .001 step size which will create 4000x4000 matrices to see if that breaks my matrix library. This only took 4 hours to run.  At a matrix size of 4000, the program takes up 36% of system memory.

Step, estimated result, and actual results.
Last section of results at .01 step size.




No comments:

Post a Comment