'Vy': na([y_aper, y_aper, -y_aper, -y_aper]), 'x_sem_ellip_insc': 0.99 * x_aper, 'y_sem_ellip_insc': 0.99 * y_aper }) picFDSW = PIC_FDSW.FiniteDifferences_ShortleyWeller_SquareGrid(chamb=chamber, Dh=Dh) picFFTPEC = PIC_PEC_FFT.FFT_PEC_Boundary_SquareGrid(x_aper=chamber.x_aper, y_aper=chamber.y_aper, Dh=Dh, fftlib='pyfftw') picFFT = PIC_FFT.FFT_OpenBoundary_SquareGrid(x_aper=chamber.x_aper, y_aper=chamber.y_aper, Dh=Dh, fftlib='pyfftw') picFDSW.scatter(x_part, y_part, nel_part) picFFTPEC.scatter(x_part, y_part, nel_part) picFFT.scatter(x_part, y_part, nel_part) N_rep = 1000 import time t_start_sw = time.mktime(time.localtime()) for _ in range(N_rep): picFDSW.solve() t_stop_sw = time.mktime(time.localtime()) t_sw = t_stop_sw - t_start_sw print('t_sw', t_sw)
sigma = .5 R_cham = 10 * sigma Dh = sigma / 20. from scipy.constants import e, epsilon_0 qe = e eps0 = epsilon_0 chamber = ell.ellip_cham_geom_object(x_aper=R_cham, y_aper=R_cham) #~ picFD = PIC_FD.FiniteDifferences_Staircase_SquareGrid(chamb = chamber, Dh = Dh) #~ picFDSW = PIC_FDSW.FiniteDifferences_ShortleyWeller_SquareGrid(chamb = chamber, Dh = Dh) picFFT = PIC_FFT.FFT_OpenBoundary_SquareGrid(x_aper=chamber.x_aper, y_aper=chamber.y_aper, Dh=Dh) YY, XX = np.meshgrid(picFFT.yg, picFFT.xg) sigmax = sigma sigmay = sigma x_beam_pos = 0. y_beam_pos = 0. rho_mat = 1. / (2. * np.pi * sigmax * sigmay) * np.exp(-(XX - x_beam_pos)**2 / (2. * sigmax**2) - (YY - y_beam_pos)**2 / (2. * sigmay**2)) #pic scatter #~ picFD.solve(rho = rho_mat) #~ picFDSW.solve(rho = rho_mat)
def __init__(self, chamb, Dh, Dt_sc=None, PyPICmode='FiniteDifferences_ShortleyWeller', sparse_solver='scipy_slu', f_telescope=None, target_grid=None, N_nodes_discard=None, N_min_Dh_main=None): print 'Start space charge init.' if PyPICmode == 'FiniteDifferences_ShortleyWeller': import PyPIC.FiniteDifferences_ShortleyWeller_SquareGrid as PIC_FDSW self.PyPICobj = PIC_FDSW.FiniteDifferences_ShortleyWeller_SquareGrid( chamb=chamb, Dh=Dh, sparse_solver=sparse_solver) #To be replaced by a property to make it general (from PyPIC modules not having xn, yn) self.xn = self.PyPICobj.xn self.yn = self.PyPICobj.yn elif PyPICmode == 'ShortleyWeller_WithTelescopicGrids': import PyPIC.FiniteDifferences_ShortleyWeller_SquareGrid as PIC_FDSW PyPICmain = PIC_FDSW.FiniteDifferences_ShortleyWeller_SquareGrid( chamb=chamb, Dh=Dh, sparse_solver=sparse_solver) import PyPIC.MultiGrid as PIC_MG self.PyPICobj = PIC_MG.AddTelescopicGrids( pic_main=PyPICmain, f_telescope=f_telescope, target_grid=target_grid, N_nodes_discard=N_nodes_discard, N_min_Dh_main=N_min_Dh_main, sparse_solver=sparse_solver) self.xn = None #not implemented in this mode (for now) self.yn = None #not implemented in this mode (for now) elif PyPICmode == 'FiniteDifferences_Staircase': import PyPIC.FiniteDifferences_Staircase_SquareGrid as PIC_FDSQ self.PyPICobj = PIC_FDSQ.FiniteDifferences_Staircase_SquareGrid( chamb=chamb, Dh=Dh, sparse_solver=sparse_solver) #To be replaced by a property to make it general (from PyPIC modules not having xn, yn) self.xn = self.PyPICobj.xn self.yn = self.PyPICobj.yn elif PyPICmode == 'FFT_PEC_Boundary': if chamb.chamb_type != 'rect': raise ValueError( '''PyPICmode = 'FFT_PEC_Boundary' can be used only if chamb_type = 'rect' ''' ) import PyPIC.FFT_PEC_Boundary_SquareGrid as PIC_FFT_PEC self.PyPICobj = PIC_FFT_PEC.FFT_PEC_Boundary_SquareGrid( x_aper=chamb.x_aper, y_aper=chamb.y_aper, Dh=Dh) #To be replaced by a property to make it general (from PyPIC modules not having xn, yn) self.xn = None #not implemented in this mode (for now) self.yn = None #not implemented in this mode (for now) elif PyPICmode == 'FFT_OpenBoundary': if chamb.chamb_type != 'rect': raise ValueError( '''PyPICmode = 'FFT_OpenBoundary' can be used only if chamb_type = 'rect' ''' ) import PyPIC.FFT_OpenBoundary_SquareGrid as PIC_FFT_Open self.PyPICobj = PIC_FFT_Open.FFT_OpenBoundary_SquareGrid( x_aper=chamb.x_aper, y_aper=chamb.y_aper, Dh=Dh) #To be replaced by a property to make it general (from PyPIC modules not having xn, yn) self.xn = None #not implemented in this mode (for now) self.yn = None #not implemented in this mode (for now) else: raise ValueError('PyPICmode not racognized') self.Dh = self.PyPICobj.Dh self.xg = self.PyPICobj.xg self.Nxg = self.PyPICobj.Nxg self.bias_x = self.PyPICobj.bias_x self.yg = self.PyPICobj.yg self.Nyg = self.PyPICobj.Nyg self.bias_y = self.PyPICobj.bias_y self.Dt_sc = Dt_sc self.t_last_recom = 0. self.U_sc_eV_stp = 0. self.flag_decimate = (self.Dt_sc is not None) self.flag_recomputed_sc = False print 'Done space charge init.'