/* ************************************************************************ * heat.c: 差分法を用いた熱伝導方程式の解法 (陰解法) * ************************************************************************ */ #include #include #include #define size 11 /* 格子数 */ main() { int i,j,max,jj; double pi, c, r, lambda, theta, x, dx, dt, u[size][2]; double uu[size], a1[size], a2[size], a3[size], a4[size], s[size], p[size]; 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); printf("Input: theta\n"); scanf("%lf", &theta); printf("theta=%f\n", theta); lambda=1.0; c=2.0/pi; dx=pi/(size-1); dt=r*dx*dx/lambda; for(j=0; j