Guest User

Untitled

a guest
Feb 24th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. Dt = (0.25*DeltaX)/c
  2. # Dt = (16*pi)/3
  3. rows = ceil((16*pi) / Dt)
  4. cols = ceil((4*pi) / DeltaX + 3)
  5.  
  6. u = zeros((rows, cols))
  7. v = zeros((rows, cols))
  8.  
  9. for j in range(cols):
  10. u[0][j] = cos(-DeltaX + j*DeltaX)
  11. v[0][j] = 0
  12.  
  13. for i in range(1, rows):
  14. for j in range(1, cols-1):
  15.  
  16. # u(x,t): fill row (time) i of grid space for columns (space) j
  17. u[i][j] = u[i-1][j] + Dt*(v[i-1][j]) + (a/2)*(u[i-1][j+1] - 2*u[i-1][j] + u[i-1][j-1])
  18.  
  19. # v(x,t): fill row (time) i of grid space for columns (space) j
  20. v[i][j] = v[i-1][j] + ((Dt*pow(c, 2))/pow(DeltaX, 2))*(u[i-1][j+1] - 2*u[i-1][j] + u[i-1][j-1])
  21. + (b/2)*(v[i-1][j+1] - 2*v[i-1][j] + v[i-1][j-1])
  22.  
  23. u = apply_bcs(u, DeltaX, i)
  24. v = apply_bcs(v, DeltaX, i)
Add Comment
Please, Sign In to add comment