Question: Write a program to model this temperature distribution for a grid with six rows and eight columns. a. Read in an initial temperature distribution from
Write a program to model this temperature distribution for a grid with six rows and eight columns.
a. Read in an initial temperature distribution from a file named initialtemps.txt. The format of the file is 6 rows of 8 numbers. Use one 2 dimensional array to store the temperatures.
b. Allow the user to modify the initial distribution, after it is read, by specifying new values for the points on the four sides of the grid (top, left, right, and bottom as shown above).
c. Compute the final temperature distribution by updating the temperatures at each point, moving across the rows until the temperature differences for all the updates are less than a tolerance value that the user is prompted to enter. When a point is updated, its new value should be used to update the next point. Print the final temperature distribution to the screen, with a descriptive header to include the number of iterations (updates of the entire grid) that were required to converge to the final distribution, in a 6 by 8 matrix format. Also, write the final distribution to a file named finaltemps.txt in the same matrix format, but with no other text, so that this file could be read back into the program if that was desired. Run this case for 3 values of tolerance that differ by at least one order of magnitude. Note the change in the number of iterations required for convergence as the tolerance values change and note these results in the header information documenting your program.
Step by Step Solution
3.47 Rating (157 Votes )
There are 3 Steps involved in it
Updated in C program include include include define ROWS 6 define COLUMNS 8 function prototype void ... View full answer
Get step-by-step solutions from verified subject matter experts
