Monday November 25, 2013
This simple model of heat transfer in an object in two dimensions is an "I Am the Average of My Neighbors" model.
In this model, heat travels through an object in two dimensions. The model is dynamic and discrete, i.e. it involves the passage of time, which occurs in individual, distinct time steps.
Each point in the object has a temperature at each time step of the model. Temperature of a point in a given time step is calculated by averaging the temperatures of the neighboring points in the previous time step. For example, if a point is surrounded by neighboring points with temperatures of 1, 2, 3, and 4, in the next time step it will have a temperature of (1+2+3+4)/4 = 2.5. If it instead has only two neighbors with temperatures of 10 and 11, in the next time step it will have a temperature of (10+11)/2 = 10.5.
In this model, assume the left side of the object is initially given a positive temperature, while the rest of the object starts off with a temperature of 0.
Write a program that takes as input the number of time steps, the number of rows and number of columns of points in the object, and the initial temperature for the left side of the object. The program should print out the temperature of each point in the object at each time step, using two decimal places. An example is shown below for 3 time steps, 3 rows, 3 columns, and 100 as the initial temperature for the left side of the object:
100.00 0.00 0.00
100.00 0.00 0.00
100.00 0.00 0.00
50.00 33.33 0.00
66.67 25.00 0.00
50.00 33.33 0.00
50.00 25.00 16.67
41.67 33.33 8.33
50.00 25.00 16.67
Each point in the object has a temperature at each time step of the model. Temperature of a point in a given time step is calculated by averaging the temperatures of the neighboring points in the previous time step. For example, if a point is surrounded by neighboring points with temperatures of 1, 2, 3, and 4, in the next time step it will have a temperature of (1+2+3+4)/4 = 2.5. If it instead has only two neighbors with temperatures of 10 and 11, in the next time step it will have a temperature of (10+11)/2 = 10.5.
In this model, assume the left side of the object is initially given a positive temperature, while the rest of the object starts off with a temperature of 0.
Write a program that takes as input the number of time steps, the number of rows and number of columns of points in the object, and the initial temperature for the left side of the object. The program should print out the temperature of each point in the object at each time step, using two decimal places. An example is shown below for 3 time steps, 3 rows, 3 columns, and 100 as the initial temperature for the left side of the object:
100.00 0.00 0.00
100.00 0.00 0.00
100.00 0.00 0.00
50.00 33.33 0.00
66.67 25.00 0.00
50.00 33.33 0.00
50.00 25.00 16.67
41.67 33.33 8.33
50.00 25.00 16.67
Show solution
Challenge Resources:
Simple Heat zip file
—
zip file containing the C code for a solution to the Simple Heat challenge problem.
©19942018

Shodor

Privacy Policy

NSDL

XSEDE

Blue Waters

ACM SIGHPC





Not Logged In. Login