Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- import matplotlib.animation as animation
- n = input()
- m = input()
- def getModel(dt , d , delt):
- grid = np.zeros((n , m))
- for i in range(0 , m):
- grid[0][i] = grid[n-1][i] = 100
- for i in range(1 , n - 1):
- grid[i][0] = 10
- grid[i][m-1] = 10
- t = 0
- # print grid
- while(t < 10):
- tend = np.array((n , m))
- tend = grid
- for i in range(1 , n-1):
- for j in range(1 , m -1):
- tend[i][j] = grid[i][j]+ (dt*d/delt/delt)*(grid[i + 1][j] + grid[i - 1][j] + grid[i][j + 1]+grid[i][j-1]-4*grid[i][j])
- t += dt
- #nexbin(grid)
- def update(i):
- matrice.set_array(grid)
- fig, ax = plt.subplots()
- matrice = ax.matshow(grid)
- plt.colorbar(matrice)
- animation.FuncAnimation(fig, update)
- plt.show()
- grid = tend
- #plt.show(block=True)
- getModel(0.01,30,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement