Guest User

Untitled

a guest
Feb 19th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. def acceleration_1(grid):
  2.  
  3. nx = grid.shape[0]
  4. ny = grid.shape[1]
  5. acc = np.zeros((nx,ny))
  6. for i in range(1,nx-1):
  7. for j in range(1,ny-1):
  8. acc[i,j,1] = grid[i+1,j,1] + grid[i-1,j,1] - 2*grid[i,j,1]
  9. acc[i,j,2] = grid[i,j+1,1] + grid[i,j-1,2] - 2*grid[i,j,2]
  10.  
  11. def acceleration_2(grid):
  12.  
  13. nx = np.arange(1,grid.shape[0]-1)
  14. ny = np.arange(1,grid.shape[1]-1)
  15. acc = np.zeros((grid.shape[0],grid.shape[0]))
  16.  
  17. acc[nx,ny,1] = grid[nx+1,ny,1] + grid[nx-1,ny,1] - 2*grid[nx,ny,1]
  18. 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