hwk13 (1)
TRANSCRIPT
8/12/2019 hwk13 (1)
http://slidepdf.com/reader/full/hwk13-1 1/2
EL2008 Homework #13 Semester II 2013/14
Due Date: April 3, 2014
This program will do a temperature simulation of a sheet of metal that has been divided up into 100rows and 100 columns of cells. Initial temperatures are assigned to each cell and then the simulationis run until the temperature of the metal sheet reaches a steady state. The program will be dividedup into several functions.
The first function will initialize each cell on the sheet to a starting temperature. The layer of cellson the edge of the sheet will all be set to 10 degrees. The 18 th row of cells will be set to 20 degreesexcept for the ends of the row which were set to 10. The rest of the cells on the plate will be set to15 degrees. This function does not have a return value and will only serve to initialize thetemperatures in the array.
The next function will perform the simulation. Each new cell temperature will be the average of thetemperatures of the four surrounding cells (up, down, left and right) from the previous array of temperatures.
The cells around the edge of the array will not be changed. Run the simulation until the differenceof the absolute value of two consecutive averages is less than 0.01 degrees. Return the number of iterations needed for the simulation to the main program.
Two functions will be called from the simulation function. First, write a function to compute the
average temperature for the sheet of metal. Take into account the temperatures of the cells aroundthe edges when computing the average. Call this function for the initial temperature distribution andfor each subsequent iteration. Store the average temperature returned from this function into a1-dimensional array for output later. Also, call a function which copies the new temperature arrayto the old array in preparation for the next update. This function will not have a return value but willsimply copy the contents of one 2-dimensional array to another.
The last function called from main will print the number of iterations needed to reach steady stateand then print a column of iteration numbers and a column of temperatures. The temperature a titeration 0 represents the average temperature of the initial values. Format the output as follows:
Number of Iterations: 28Iteration Average Number Temperature 0 14.85 1 14.80 2 14.77 . . . . . .