heat.py # Calculate heat diffusion for timestep in range (5): for r in range (1, size-1): for c in range (1, size-1 ) b2 [r, c] Fundamentals Lecture (b[r-1, c-1] *0.1 + b[r-1, c) *0.1 + b[r-1,c+i] 0.1 + b[r, c-11*0.1 + b[r,c] *0.2 + b[r, c+1] *0.1 for i in range (size): b2 [1,0] = 10 bb2.copy () plt.title('Heat Diffusion Simulation') plt.imshow (b2, cmap-plt.cm.hot) plt.colorbar () plt.show() + b[r+1, c-1]*0.1 + b[r+1, c) *0.1 + b[r+1, c+1] *0.1) heat.py # Calculate heat diffusion for timestep in range (5): for r in range (1, size-1): Heat Diffusion Simulation for c in range (1, size-1 ): b2 [r,c] Heat Diffusion Simulation (blr-1, c-11*0.1 + b[r-1,c] 0.1 + b[r-1,c+i] 0.1 + b[r,c-i1*0.1 + b[r,c] *0.2 + b[r, c+1]*0.1 for i in range (size): 10 b2 [1,0] bb2.copy() + b[r+1,c-11*0.1 + b[r+1,c] 0.1 + b[r+1,c+1] *0.1) plt.title('Heat Diffusion Simulation') plt.imshow (b2, cmap-plt.cm. hot, interpolation='bilinear') plt.colorbar () plt.show() 27 27/5

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 17RQ
icon
Related questions
Question

Explain how first graph Changes to the second and then third graph.

heat.py
#
# heat.py
#
import matplotlib.pyplot as plt
import numpy as np
size = 10
b = np.zeros((size, size))
# Create heat source
for i in range (size):
b[i,0] = 10
Heat Diffusion Simulation
print ('\nHEAT DIFFUSION SIMULATION\n')
print (Initial array...')
print (b)
#Temp array for storing calculations
np.zeros((size, size))
b2 =
Fundamentals Lectures
26
26
Transcribed Image Text:heat.py # # heat.py # import matplotlib.pyplot as plt import numpy as np size = 10 b = np.zeros((size, size)) # Create heat source for i in range (size): b[i,0] = 10 Heat Diffusion Simulation print ('\nHEAT DIFFUSION SIMULATION\n') print (Initial array...') print (b) #Temp array for storing calculations np.zeros((size, size)) b2 = Fundamentals Lectures 26 26
heat.py
# Calculate heat diffusion
for timestep in range (5):
for r in range (1, size-1):
for c in range (1, size-1 )
b2 [r,c]
Fundamentals Lecture3
(b[r-1,c-11*0.1 + b[r-1,c]*0.1.
+ b[r-1,c+i]*0.1 + b[r,c-i] *0.1
+ b[r, c) *0.2 + b[r, c+1] *0.1
for i in range (size):
b2 [1,0] 10
b = b2.copy ()
plt.title('Heat Diffusion Simulation')
plt.imshow (b2, cmap-plt.cm.hot)
plt.colorbar ()
plt.show()
+ b[r+1, c-1]*0.1 + b[r+1,c] *0.1
+ b[r+1, c+1] *0.1)
heat.py
#Calculate heat diffusion
for timestep in range (5):
Hest Diffusion Simulation
for r in range (1, size-1):
for c in range (1, size-1):
b2 [x, c]
Heat Diffusion Simulation
(b[r-1,c-11*0.1 + b[r-1, c) *0.1
+ b[r-1,c+i] 0.1 + b[r,c-11 0.1
+ b[r,c] 0.2 + b[r,c+1] 0.1
for i in range (size):
b2 [1,01 10
bb2.copy ()
+ b[r+1,c-11*0.1 + b[r+1,c] *0.1
+ b[r+1, c+1] *0.1)
plt.title ('Heat Diffusion Simulation')
plt.imshow (b2, cmap-plt.cm.hot, interpolation='bilinear')
plt.colorbar ()
plt.show()
27
27/5
Transcribed Image Text:heat.py # Calculate heat diffusion for timestep in range (5): for r in range (1, size-1): for c in range (1, size-1 ) b2 [r,c] Fundamentals Lecture3 (b[r-1,c-11*0.1 + b[r-1,c]*0.1. + b[r-1,c+i]*0.1 + b[r,c-i] *0.1 + b[r, c) *0.2 + b[r, c+1] *0.1 for i in range (size): b2 [1,0] 10 b = b2.copy () plt.title('Heat Diffusion Simulation') plt.imshow (b2, cmap-plt.cm.hot) plt.colorbar () plt.show() + b[r+1, c-1]*0.1 + b[r+1,c] *0.1 + b[r+1, c+1] *0.1) heat.py #Calculate heat diffusion for timestep in range (5): Hest Diffusion Simulation for r in range (1, size-1): for c in range (1, size-1): b2 [x, c] Heat Diffusion Simulation (b[r-1,c-11*0.1 + b[r-1, c) *0.1 + b[r-1,c+i] 0.1 + b[r,c-11 0.1 + b[r,c] 0.2 + b[r,c+1] 0.1 for i in range (size): b2 [1,01 10 bb2.copy () + b[r+1,c-11*0.1 + b[r+1,c] *0.1 + b[r+1, c+1] *0.1) plt.title ('Heat Diffusion Simulation') plt.imshow (b2, cmap-plt.cm.hot, interpolation='bilinear') plt.colorbar () plt.show() 27 27/5
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage