/* ************************************************************************ * heat.c: Solution of heat equation using with finite differences * ************************************************************************ */ #include #include #include #define size 11 /* grid size */ #define max 10 /* iterations */ main() { int i,j; double pi, c, r, lambda, x, dx, dt, u[size][2]; FILE *output; /* save data in file eqheat.dat */ output = fopen("heat.dat","w"); pi=3.1415926; printf("Input: r\n"); scanf("%lf", &r); printf("r=%g\n", r); lambda=1.0; c=2.0/pi; dx=pi/(size-1); dt=r*dx*dx/lambda; for(j=0; j