CS410P UC Davis Two Dimensional Lists Simulation Python Solve the entire HW assignment. The HW is related with 2-D dimensional list and computation. CS410P SUMMER 2019
DUE: 6/26/19
ASSIGNMENT 6P
Purpose
The purpose of this assignment is to have you work with two-dimensional lists in the context of a
simulation.
Scenario
The scenario is a heat-flow simulation of the transfer of heat from two sides of a metal plate across the
entire plate. A metal plate, as shown below, begins at a pair of fixed temperature. Heater/cooler A is
placed up against the top and left (north and west) sides of the plate. Heater/cooler B is placed up against
the bottom and right (south and east) sides of the plate. The plate itself starts at two initial temperatures:
T1 and T2, as shown below.
For example, the plate might start at T1=10 degrees and at T2=35 degrees, the first heater/cooler might be
at 80 degrees and the second heater/cooler might be at 60 degrees. As the simulation starts the sides of the
plate will begin to heat up and thus take on temperatures closer to the heaters. This transfer of heat will
continue across the plate until it reaches a stable temperature, where stable is defined, roughly, as not
changing significantly.
Method
To implement this simulation, we will use a finite state element approximation, that is, we will model the
plate with a 2-D list. Only the plate is represented by the 2-D list; thus the heater/coolers are outside (but
exactly adjacent to) the list. The plate will be represented by an (8×6) list: 8 rows and 6 columns, thus 48
elements. The temperature of all the plate elements will be initially set to the two initial plate
temperatures.
To simulate the transfer of heat, you will traverse the entire list over and over. On each traversal, you will
visit each element in your list and compute the new temperature in the following fashion: To determine
the new temperature of a specific element, take the average of its four neighbors (north, east, south, west)
from the previous cycle. Be careful, if you are updating an element on an edge of the plate, then you will
have only THREE plate values and ONE “outside” value, where an “outside” value is the temperature of
one of the heater/coolers. And a corner has two “outside” values. After you complete each traversal you
should print out the two 2-D list of updated temperatures. Then replace the values of the old temperature
by the new one for the next cycle. The simulation of traversals continues until no element in the list
changes by a significant relative amount, where the significant amount is determined by the value of the
last input item (see below). A relative amount means a percent change. Thus a value of .01 signifies a1%
change; it does not mean a change of .01 degree.
Data Structure
To store the simulated transfer of heat, you will store the heat temperatures in a pair of 2-D (8×6) list of
floats, one for the previous temperature values and the other for the new ones being computed. (You are
not allowed to use packages like numPy to simulate arrays).
Input
All input values will come from keyboard input. The input includes 5 floating point values:
The first heater/cooler temperature (A)
The second heater/cooler temperature (B)
The first initial plate temperature (T1)
The second initial temperature (T2)
The stabilizing criterion value
The stabilizing criterion value is a value to indicate when to stop the simulation. The halting condition is
defined as: If NO element in the list changes by a relative amount MORE THAN the stabilizing criterion
then the simulation can stop. (This means that the temperature in the plate is settling down to its final
temperature and continued traversals will only slightly change the temperature distribution). See the
posted files for examples of input.
Output
The output will first echo the input data then display the heat-plate temperatures. You should display each
plate as the temperatures change until the halt criterion is satisfied. Be sure to look at the posted output
examples and follow them closely. Make sure that you have the correct number of iterations.
(sample output shown below which shows the inputs as well as the initial plate temperatures, the first
plate after simulation begins and the last two plates). Sample output files in the public folder contain
complete output.
Details
?
Remember that the stabilization criterion is a relative change, not a degree change. Relative
change is defined as:
|to tn|/to
?
where to is the old temperature and tn is the new temperature
You must use at least the following functions (all of them must be commented):
o
o
o
o
?
?
A function to display the plate temperatures as in the examples. You can assume that the
temperature values will be in the range 0 99.99 and your display should look good for
all temperatures in this range. Your display should look very similar to the sample output.
Display temperatures with 2 decimal places.
A function to initialize the plate
A function that does one update of the plate temperatures i.e. one cycle of simulation
You may have as many other functions as you wish
The program must be split into multiple files:
o The main function must be the only function in one source (code) file
o All the other functions should be in a second source (code) file
o You must not use any global variables
As always test your program carefully and follow good programming style.
.
.
.
.
.
.
.
.
.
.
.
.
.
Grade Key:
A
Printing of plate reasonable showing all temperatures
15
B
Initial plate accurate
10
C
Computation for next cycle accurate
25
D
E
F
K
Stability criteria enforced correctly to stop simulation
Program works correctly for each input file
Programming style, modularity, comments
Late Penalty
15
15
20
Purchase answer to see full
attachment
Consider the following information, and answer the question below. China and England are international trade…
The CPA is involved in many aspects of accounting and business. Let's discuss some other…
For your initial post, share your earliest memory of a laser. Compare and contrast your…
2. The Ajax Co. just decided to save $1,500 a month for the next five…
How to make an insertion sort to sort an array of c strings using the…
Assume the following Keynesian income-expenditure two-sector model: AD = Cp + Ip Cp = Co…