コード例 #1
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 = iffb.int_field_border(x_mp,y_mp,self.bias_x,self.bias_y,self.Dh,
										 self.Dh, self.efx, self.efy, self.flag_inside_n_mat)
					   
		else:
			Ex_sc_n=0.
			Ey_sc_n=0.
			
		return Ex_sc_n, Ey_sc_n
コード例 #2
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]
コード例 #3
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]