예제 #1
0
 def get_B(self, xn,yn):
             Bx_n,By_n = iff.int_field(xn,yn,self.xmin,self.ymin,\
                                   self.dx,self.dy,self.Bmap_x,self.Bmap_y)
             # the rescaling factor has already been applied to the map
             Bx_n = Bx_n + self.B0x
             By_n = By_n + self.B0y
             Bz_n = 0*xn + self.B0z
             return Bx_n, By_n, Bz_n
예제 #2
0
 def get_B(self, xn, yn):
     Bx_n,By_n = iff.int_field(xn,yn,self.xmin,self.ymin,\
                           self.dx,self.dy,self.Bmap_x,self.Bmap_y)
     # the rescaling factor has already been applied to the map
     Bx_n = Bx_n + self.B0x
     By_n = By_n + self.B0y
     Bz_n = 0 * xn + self.B0z
     return Bx_n, By_n, Bz_n
예제 #3
0
 def get_sc_eletric_field(self, MP_e):
         
     if MP_e.N_mp>0:    
         ## compute beam electric field
         Ex_sc_n, Ey_sc_n = iff.int_field(MP_e.x_mp[0:MP_e.N_mp],MP_e.y_mp[0:MP_e.N_mp],self.bias_x,self.bias_y,self.Dh,
                                      self.Dh, self.efx, self.efy)
                    
     else:
         Ex_sc_n=0.
         Ey_sc_n=0.
         
     return Ex_sc_n, Ey_sc_n
 def get_sc_eletric_field(self, MP_e):
         
     if MP_e.N_mp>0:    
         ## compute beam electric field
         Ex_sc_n, Ey_sc_n = iff.int_field(MP_e.x_mp[0:MP_e.N_mp],MP_e.y_mp[0:MP_e.N_mp],self.bias_x,self.bias_y,self.Dh,
                                      self.Dh, self.efx, self.efy)
                    
     else:
         Ex_sc_n=0.
         Ey_sc_n=0.
         
     return Ex_sc_n, Ey_sc_n
예제 #5
0
 def get_beam_eletric_field(self, MP_e):
     
     if (self.lam_t_curr>self.lam_th_beam_field) and (MP_e.N_mp>0):    
         ## compute beam electric field
         Ex_n_beam, Ey_n_beam=iff.int_field(MP_e.x_mp[0:MP_e.N_mp],MP_e.y_mp[0:MP_e.N_mp],
                                            self.xmin_beam,self.ymin_beam,self.dx_beam,self.dy_beam,self.Ex_beam,self.Ey_beam)
         Ex_n_beam=qe*self.lam_t_curr*Ex_n_beam;
         Ey_n_beam=qe*self.lam_t_curr*Ey_n_beam;
         
     else:
         Ex_n_beam=0.
         Ey_n_beam=0.
         
     return Ex_n_beam, Ey_n_beam
예제 #6
0
    def gather_rho(self, x_mp, y_mp):
        
        if not (len(x_mp)==len(y_mp)):
            raise ValueError('x_mp, y_mp should have the same length!!!')

        if len(x_mp)>0:    
            ## compute beam distribution
            rho_sc_n, _ = iff.int_field(x_mp,y_mp,self.bias_x,self.bias_y,self.Dh,
                                         self.Dh, self.rho, self.rho)
                       
        else:
            rho_sc_n=0.
            
        return rho_sc_n
예제 #7
0
    def gather_phi(self, x_mp, y_mp):
        
        if not (len(x_mp)==len(y_mp)):
            raise ValueError('x_mp, y_mp should have the same length!!!')

        if len(x_mp)>0:    
            ## compute beam potential
            phi_sc_n, _ = iff.int_field(x_mp,y_mp,self.bias_x,self.bias_y,self.Dh,
                                         self.Dh, self.phi, self.phi)
                       
        else:
            phi_sc_n=0.
            
        return phi_sc_n
예제 #8
0
	def gather(self, x_mp, y_mp):
		
		if not (len(x_mp)==len(y_mp)):
			raise ValueError('x_mp, y_mp should have the same length!!!')

		if len(x_mp)>0:    
			## compute beam electric field
			Ex_sc_n, Ey_sc_n = iff.int_field(x_mp,y_mp,self.bias_x,self.bias_y,self.Dh,
										 self.Dh, self.efx, self.efy)
					   
		else:
			Ex_sc_n=0.
			Ey_sc_n=0.
			
		return Ex_sc_n, Ey_sc_n
예제 #9
0
 def field_to_particles(self, *mesh_fields_and_mp_coords, **kwargs):
     [ex, ey], [x, y] = zip(*mesh_fields_and_mp_coords)
     ex = ex.reshape((self.mesh.ny, self.mesh.nx)).T
     ey = ey.reshape((self.mesh.ny, self.mesh.nx)).T
     if hasattr(self.poissonsolver, 'flag_inside_n_mat'):
         flag_inside_n_mat = self.poissonsolver.flag_inside_n_mat
         Ex, Ey = iffb.int_field_border(x, y, self.mesh.x0, self.mesh.y0,
                                        self.mesh.dx, self.mesh.dx, ex, ey,
                                        flag_inside_n_mat)
     else:
         if hasattr(self.poissonsolver, 'flag_border_mat'):
             #Only for Staircase_SquareGrid solver
             ex[self.poissonsolver.flag_border_mat] *= 2
             ey[self.poissonsolver.flag_border_mat] *= 2
         Ex, Ey = iff.int_field(x, y, self.mesh.x0, self.mesh.y0,
                                self.mesh.dx, self.mesh.dx, ex, ey)
     return [Ex, Ey]
예제 #10
0
파일: pypic.py 프로젝트: aoeftiger/PyPIC
 def field_to_particles(self, *mesh_fields_and_mp_coords, **kwargs):
     [ex, ey], [x, y] = zip(*mesh_fields_and_mp_coords)
     ex = ex.reshape((self.mesh.ny, self.mesh.nx)).T
     ey = ey.reshape((self.mesh.ny, self.mesh.nx)).T
     if hasattr(self.poissonsolver, 'flag_inside_n_mat'):
         flag_inside_n_mat = self.poissonsolver.flag_inside_n_mat
         Ex, Ey = iffb.int_field_border(x, y, self.mesh.x0, self.mesh.y0,
                                self.mesh.dx, self.mesh.dx, ex, ey,
                                flag_inside_n_mat)
     else:
         if hasattr(self.poissonsolver, 'flag_border_mat'):
             #Only for Staircase_SquareGrid solver
             ex[self.poissonsolver.flag_border_mat] *= 2
             ey[self.poissonsolver.flag_border_mat] *= 2
         Ex, Ey = iff.int_field(x, y, self.mesh.x0, self.mesh.y0,
                                self.mesh.dx, self.mesh.dx, ex, ey)
     return [Ex, Ey]
예제 #11
0
    def get_beam_eletric_field(self, MP_e):

        if (self.lam_t_curr > self.lam_th_beam_field) and (MP_e.N_mp > 0):
            ## compute beam electric field
            Ex_n_beam, Ey_n_beam = iff.int_field(MP_e.x_mp[0:MP_e.N_mp],
                                                 MP_e.y_mp[0:MP_e.N_mp],
                                                 self.xmin_beam,
                                                 self.ymin_beam, self.dx_beam,
                                                 self.dy_beam, self.Ex_beam,
                                                 self.Ey_beam)
            Ex_n_beam = qe * self.lam_t_curr * Ex_n_beam
            Ey_n_beam = qe * self.lam_t_curr * Ey_n_beam

        else:
            Ex_n_beam = 0.
            Ey_n_beam = 0.

        return Ex_n_beam, Ey_n_beam