/* ************************************************************************ * heat.c: 差分法を用いた熱伝導方程式の解法 * ************************************************************************ */ #include #include #include #define size 11 /* 格子数 */ main() { int i,j,max; double pi, c, r, lambda, x, dx, dt, u[size][2]; FILE *output; /* heat.datにデータを保存 */ output = fopen("heat.dat","w"); pi=3.1415926; printf("Input: r\n"); scanf("%lf", &r); printf("r=%g\n", r); printf("Input: max\n"); scanf("%d", &max); printf("max=%d\n", max); lambda=1.0; c=2.0/pi; dx=pi/(size-1); dt=r*dx*dx/lambda; for(j=0; j