# Modeling Temperature Transfer

Suppose
you have a thin metal plate where each of the edges are maintained at a constant temperature. You can model the plate as a 2-dimensional array of square cells each of which may have a different temperature. Given the size of the array and the temperature of
the edges, you are to calculate the temperature of an interior cell by averaging the 4 neighboring (cells immediately above, below, left and right) cell temperatures. The temperature of four corner cells will be the average of the two corresponding edge temperatures.
Your program is going to use the case of “immediate” updating in which you will be begin with the cell in the left most interior cell in the top interior row and work across the row, calculating new temperatures for each cell and replacing the old temperatures
with the new ones. Then you will proceed to the second interior row. After calculating the temperatures for the all the interior cells an iteration counter should be updated and the process should repeat until all the cells have change in temperature of less
than a value, epsilon, which indicates that equilibrium has been reached. The temperatures of the edge cells should remain constant.? Your program should prompt the user to enter the size of the array and the temperature of the top edge, bottom edge, left
edge and right edge. The size of the array may not be more than 35 by 20. The temperatures of the edges may not be less than 0 or greater than 300. Store the temperature values in the appropriate cells, the corner cells should be the average of the two bordering
edge cells. You should assume that the interior cells originally are at 0 degrees. The user should also be prompted to enter the value of epsilon that will be used to determine when the plate has reached equilibrium.? After the array has been initialized,
begin the process of determining temperature of the interior cells (the average of the 4 cells that share an edge). The temperatures of the cells on the outside should remain constant, only the temperatures of the internal cells should change. Once the absolute
temperature change of all the interior is less than epsilon you should output the array with the temperatures and state how many iterations were needed to reach the equilibrium temperature distribution. Your program should employ a function to output the 2-D
array. The function should use appropriate formatting so the output of the temperatures in the cell are displayed to 1 decimal place and are aligned.? For example, suppose you had a plate that could be modeled using a 5 by 7 array of cells, with the temperature
of the top edge being at 100 degrees, the bottom edge being at 90 degrees, the left edge being at 75 degrees and the right edges being at 75 degrees. Initially the array would look like: Initial array 87.5 100.0 100.0 100.0 100.0 100.0 87.5 75.0 0.0 0.0 0.0
0.0 0.0 75.0 75.0 0.0 0.0 0.0 0.0 0.0 75.0 75.0 0.0 0.0 0.0 0.0 0.0 75.0 82.5 90.0 90.0 90.0 90.0 90.0 82.5 If we assume epsilon is 0.01 degrees, after 20 iterations equilibrium would be reached and would look as follows: The plate reached equilibrium after
20 iterations. The equilibrium temperatures are 87.5 100.0 100.0 100.0 100.0 100.0 87.5 75.0 87.9 92.6 93.8 92.6 87.9 75.0 75.0 83.9 88.6 90.0 88.6 83.9 75.0 75.0 84.2 87.9 89.0 87.9 84.2 75.0 82.5 90.0 90.0 90.0 90.0 90.0 82.5 ??Hint: When you are testing,
calculate by hand what the array would like after each of the first 3 iterations. Then run your loop for only 3 iterations (rather than when the change is less than epsilon), output after each iteration and compare to your hand calculations. Do not use vectors
for this assignment.

×