spacepaste

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
        def GetFlux(self, time):

                bx = self.GetField("bx", time) * self.wpewce
                by = self.GetField("by", time) * self.wpewce
                bz = self.GetField("bz", time) * self.wpewce
                
                
                
                flux  = np.zeros((self.ncells[0]+1,self.ncells[1]+1),"float32", order='FORTRAN')
                flux2  = np.zeros((self.ncells[0]+1,self.ncells[1]+1),"float32", order='FORTRAN')

                dx = self.dl[0]
                dz = self.dl[1]
                
                nx = self.ncells[0]
                nz = self.ncells[1]

                j = 0
        
                for i in np.arange(1, nx):
                        flux2[i,0] = flux2[i-1,0] + bz[i-1,0]*dx

                flux[1:,0] = flux[0,0] + np.cumsum(bz[:-1,0]*dx)



                for j in np.arange(1,nz):
                        flux2[0,j] = flux2[0,j-1] - bx[0,j-1]*dz

                flux[0,1:] = flux[0,0] - np.cumsum(bx[0,:-1]*dz)


                for i in np.arange(1,nx):
                        for j in np.arange(1,nz):
                                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)

                #intbxdz = np.cumsum(bx[:,:-1],1)*dz
                #intbzdx = np.cumsum(bz[:-1,],0)*dx

                #flux[1:,1:] = intbzdx[1:,:] - intbxdz[:,1:]
                
                flux[1:, 1:] = np.cumsum(bz[:-1,1:], 0)*dx - np.cumsum(bx[1:,:-1],1)*dz

                print "first row"
                print flux[0,10:20]
                print flux2[0,10:20]

                print "first column"
                print flux[10:20,0]
                print flux2[10:20,0]

                print "middle"
                print flux[10:20,40]
                print flux2[10:20,40]

                return flux