0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00This represents a temperature distribution where the cell in the second row and zeroth column is hot (at temperature 1) and the remaining cells are cold (at temperature 0). We write this fact as u[2,0] = 1, u[i,j] = 0 for [i,j] different from [2,0].
What is the temperatue u at future times, given that (a) the temperatures are held fixed at the edges of the plate and (b) the rest of the plate is well insulated? The physics governing temperature in a thin plate is the same as that governing temperature in a thin rod:
The rate of change of the temperature at a given point is proportional to the difference between the average temperature near the point and the temperature at the point.Let us see how this applies to our model, in which we have divided the rod into finitely many cells each of which has a unique temperature. This is, of course an approximation, since the temperature in a cell will in fact vary. However, if the cell is small, the approximation will be a good one. Now, assuming that u[i,j] is the temperature of the cell in position (i,j) at time t, let uu[i,j] denote the temperature of the cell in position (i,j) at time t + h, where h is small. Then our principle reads
uu[i,j] = u[i,j] + k(( u[i-1,j] + u[i+1,j] + u[i,j-1] + u[i,j+1] )/4 - u[i] ) for i = 1..N-2, j = 1..N-2Here k is the constant of proportionality. Note that when k = 1, this is particularly simple:
uu[i] = ( u[i-1,j] + u[i+1,j] + u[i,j-1] + u[i,j+1] )/4 for i = 1..N-2, j = N-2
It is not difficult to write a program which computes and displays the future temperatures of a thin, insulated rod given a temperature distribution at time t = 0. The outline is the same as in the case of the long thin rod:
PSEUDOPROGRAM: Constants: N, the number of cells in a row or column T, the number of time steps Variables: u, an array which holds the current temperature distribution uu, an array which holds the "next" temperature distribution Program: Set up the array u; Print it out; For t from 1 to T: Compute uu from u Print out uu Copy uu into uHere is a more detailed outline of the program, written in pseudo-C:
#define N 5 /* number of cells in a row or column */ #define T 5 /* number of time steps */ main() { /* Note that in C we refer to the temperature of the cell in position (i,j) as u[i][j]. */ double u[N][N], uu[N][N]; /* temperature arrays */ int i,j,t; /* initialize u */ for( i=0; i < N; i++ ) for( j=0; j < N; j++ ) u[i][j] = 0; u[2][0] = 10; /* Note the use of a double loop to process the array. The index i controls the cell row and the index j controls the cell column. This is the model you should use in converting the pseudoprogram to a program. */ /* display u */ printf("\n t = 0: \n\n"); for( i=0; i < N; i++ ){ for( j= 0; j < N; j++ ) printf("%5.2f", u[i][j] ); printf("\n"); } printf("\n"); /* Compute and display future temperatures */ for( t=1; t < T; t++ ) { /* carry forward boundary temperatures */ /* compute interior temperatures */ /* display temperature at time t */ /* update u */ }