Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def acceleration_1(grid):
- nx = grid.shape[0]
- ny = grid.shape[1]
- acc = np.zeros((nx,ny))
- for i in range(1,nx-1):
- for j in range(1,ny-1):
- acc[i,j,1] = grid[i+1,j,1] + grid[i-1,j,1] - 2*grid[i,j,1]
- acc[i,j,2] = grid[i,j+1,1] + grid[i,j-1,2] - 2*grid[i,j,2]
- def acceleration_2(grid):
- nx = np.arange(1,grid.shape[0]-1)
- ny = np.arange(1,grid.shape[1]-1)
- acc = np.zeros((grid.shape[0],grid.shape[0]))
- acc[nx,ny,1] = grid[nx+1,ny,1] + grid[nx-1,ny,1] - 2*grid[nx,ny,1]
- acc[nx,ny,1] = grid[nx,ny+1,2] + grid[nx,ny-1,2] - 2*grid[nx,ny,2]
Add Comment
Please, Sign In to add comment