Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 7th, 2012  |  syntax: Python  |  size: 1.24 KB  |  views: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.         def GetFlux(self, time):
  2.  
  3.                 bx = self.GetField("bx", time) * self.wpewce
  4.                 by = self.GetField("by", time) * self.wpewce
  5.                 bz = self.GetField("bz", time) * self.wpewce
  6.                
  7.                
  8.                
  9.                 flux  = np.zeros((self.ncells[0]+1,self.ncells[1]+1),"float32", order='FORTRAN')
  10.                 flux2  = np.zeros((self.ncells[0]+1,self.ncells[1]+1),"float32", order='FORTRAN')
  11.  
  12.                 dx = self.dl[0]
  13.                 dz = self.dl[1]
  14.                
  15.                 nx = self.ncells[0]
  16.                 nz = self.ncells[1]
  17.  
  18.                 j = 0
  19.        
  20. #               for i in np.arange(1, nx):
  21. #                       flux2[i,0] = flux2[i-1,0] + bz[i-1,0]*dx
  22.  
  23.                 flux[1:,0] = flux[0,0] + np.cumsum(bz[:-1,0]*dx)
  24.  
  25.  
  26.  
  27. #               for j in np.arange(1,nz):
  28. #                       flux2[0,j] = flux2[0,j-1] - bx[0,j-1]*dz
  29.  
  30.                 flux[0,1:] = flux[0,0] - np.cumsum(bx[0,:-1]*dz)
  31.  
  32.  
  33. #               for i in np.arange(1,nx):
  34. #                       for j in np.arange(1,nz):
  35. #                               flux2[i,j] = 0.5*(flux2[i-1,j] + bz[i-1,j]*dx) + 0.5*(flux2[i,j-1] - bx[i,j-1]*dz)
  36.  
  37.                 return flux2
clone this paste RAW Paste Data