예제 #1
0
x_aper = 1e-1
y_aper = .5e-1
R_charge = 4e-2
N_part_gen = 100000
Dh = 1e-3

from scipy.constants import e, epsilon_0

qe = e
eps0 = epsilon_0

na = np.array

chamber = poly.polyg_cham_geom_object({'Vx':na([x_aper, -x_aper, -x_aper, x_aper]),
									   '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, sparse_solver = 'PyKLU')
picFD = PIC_FD.FiniteDifferences_Staircase_SquareGrid(chamb = chamber, Dh = Dh, sparse_solver = 'PyKLU')
picFFTPEC = PIC_PEC_FFT.FFT_PEC_Boundary_SquareGrid(x_aper = chamber.x_aper, y_aper = chamber.y_aper, Dh = Dh)

# generate particles
x_part = R_charge*(2.*rand(N_part_gen)-1.)
y_part = R_charge*(2.*rand(N_part_gen)-1.)
mask_keep  = x_part**2+y_part**2<R_charge**2
x_part = x_part[mask_keep]
y_part = y_part[mask_keep]

nel_part = 0*x_part+1.
예제 #2
0
R_charge = 4e-2
N_part_gen = 100000
Dh = 1e-3

from scipy.constants import e, epsilon_0

qe = e
eps0 = epsilon_0

na = np.array

chamber = poly.polyg_cham_geom_object({
    'Vx':
    na([x_aper, -x_aper, -x_aper, x_aper]),
    '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, sparse_solver='PyKLU')
picFD = PIC_FD.FiniteDifferences_Staircase_SquareGrid(chamb=chamber,
                                                      Dh=Dh,
                                                      sparse_solver='PyKLU')
picFFTPEC = PIC_PEC_FFT.FFT_PEC_Boundary_SquareGrid(x_aper=chamber.x_aper,
                                                    y_aper=chamber.y_aper,
                                                    Dh=Dh)

# generate particles
예제 #3
0
x_part = x_aper * (2.0 * rand(N_part_gen) - 1.0)
y_part = y_aper * (2.0 * rand(N_part_gen) - 1.0)

x_on_tree = np.interp(y_part, y_tree, x_tree)

mask_keep = np.logical_and(np.abs(x_part) < x_on_tree, np.abs(x_part) > x_on_tree * 0.8)
x_part = x_part[mask_keep]
y_part = y_part[mask_keep]

nel_part = 0 * x_part + 1.0


chamber = poly.polyg_cham_geom_object(
    {
        "Vx": na([x_aper, -x_aper, -x_aper, x_aper]),
        "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,
    }
)


picFFT = PIC_FFT.FFT_OpenBoundary_SquareGrid(x_aper=chamber.x_aper, y_aper=chamber.y_aper, Dh=Dh)


picFFT.scatter(x_part, y_part, nel_part)

data = picFFT.fgreen

N_rep = 1000

	def __init__(self, L_ecloud, slicer, Dt_ref, pyecl_input_folder='./'):
		
		print 'PyECLOUD for PyHEADTAIL'
		print 'Initializing ecloud from folder: '+pyecl_input_folder
		self.slicer = slicer
		self.Dt_ref = Dt_ref
		self.L_ecloud = L_ecloud	
		
		b_par, x_aper, y_aper, B,\
		gas_ion_flag, P_nTorr, sigma_ion_MBarn, Temp_K, unif_frac, E_init_ion,\
		Emax, del_max, R0, E_th, sigmafit, mufit,\
		Dt, t_end, lam_th, t_ion, N_mp_max,\
		N_mp_regen, N_mp_after_regen, fact_split, fact_clean, nel_mp_ref_0,\
		Nx_regen, Ny_regen, Nvx_regen, Nvy_regen, Nvz_regen,regen_hist_cut,\
		N_mp_regen_low,\
		Dt_sc, Dh_sc, t_sc_ON,Dx_hist,r_center, scrub_en_th,\
		progress_path,  logfile_path, flag_movie, flag_sc_movie,\
		Dt_En_hist, Nbin_En_hist,En_hist_max, \
		photoem_flag, inv_CDF_refl_photoem_file, k_pe_st, refl_frac, alimit, e_pe_sigma,\
		e_pe_max,x0_refl, y0_refl, out_radius, \
		switch_model, switch_no_increase_energy, thresh_low_energy, save_mp_state_time_file, \
		init_unif_flag, Nel_init_unif, E_init_unif, x_max_init_unif, x_min_init_unif, y_max_init_unif, y_min_init_unif,\
		chamb_type, filename_chm, flag_detailed_MP_info, flag_hist_impact_seg,\
		track_method, B0x, B0y, B0z, B_map_file,  Bz_map_file, N_sub_steps, fact_Bmap, B_zero_thrhld,\
		N_mp_soft_regen, N_mp_after_soft_regen,\
		flag_verbose_file, flag_verbose_stdout,\
		flag_presence_sec_beams, sec_b_par_list, phem_resc_fac, dec_fac_secbeam_prof, el_density_probes, save_simulation_state_time_file,\
		x_min_hist_det, x_max_hist_det, y_min_hist_det, y_max_hist_det, Dx_hist_det, dec_fact_out, stopfile= \
		read_parameter_files_pyhdtl(pyecl_input_folder)
		
		#pyeclsaver=pysav.pyecloud_saver(logfile_path)
       
		if switch_model=='ECLOUD_nunif':
			flag_non_unif_sey = 1
		else:
			flag_non_unif_sey = 0
			
		if chamb_type=='ellip':
			chamb=ellip_cham_geom_object(x_aper, y_aper, flag_verbose_file=flag_verbose_file)
		elif chamb_type=='polyg':
			chamb=polyg_cham_geom_object(filename_chm, flag_non_unif_sey,
										 flag_verbose_file=flag_verbose_file, flag_verbose_stdout=flag_verbose_stdout)
		else:
			raise ValueError('Chamber type not recognized (choose: ellip/polyg)')
		
		
		MP_e=MPs.MP_system(N_mp_max, nel_mp_ref_0, fact_split, fact_clean, 
						   N_mp_regen_low, N_mp_regen, N_mp_after_regen,
						   Dx_hist, Nx_regen, Ny_regen, Nvx_regen, Nvy_regen, Nvz_regen, regen_hist_cut, chamb,
						   N_mp_soft_regen=N_mp_soft_regen, N_mp_after_soft_regen=N_mp_after_soft_regen)
		
	
		
		spacech_ele = scc.space_charge(chamb, Dh_sc, Dt_sc=Dt_sc)
		
		#~ sec_beams_list=[]
		#~ if flag_presence_sec_beams:
			#~ N_sec_beams = len(sec_b_par_list)
			#~ for ii in xrange(N_sec_beams):
				#~ print 'Initialize secondary beam %d/%d'%(ii+1, N_sec_beams)
				#~ sb_par = sec_b_par_list[ii]
				#~ sec_beams_list.append(beatim.beam_and_timing(sb_par.flag_bunched_beam, sb_par.fact_beam, sb_par.coast_dens, sb_par.beam_field_file,lam_th,
					 #~ b_spac=sb_par.b_spac, sigmaz=sb_par.sigmaz,t_offs=sb_par.t_offs, filling_pattern_file=sb_par.filling_pattern_file, Dt=Dt, t_end=t_end,
					 #~ beam_long_prof_file=sb_par.beam_long_prof_file, Dh_beam_field=sb_par.Dh_beam_field, chamb=chamb,  sigmax=sb_par.sigmax, sigmay=sb_par.sigmay,
					 #~ x_beam_pos = sb_par.x_beam_pos, y_beam_pos = sb_par.y_beam_pos, save_beam_field_file_as=sb_par.save_beam_field_file_as,
					 #~ flag_secodary_beam = True, t_primary_beam = beamtim.t,
					 #~ Nx=sb_par.Nx, Ny=sb_par.Ny, nimag=sb_par.nimag, progress_mapgen_file = (progress_path+('_mapgen_sec_%d'%ii))))
		
		
		
		if switch_model==0 or switch_model=='ECLOUD':
			sey_mod=SEY_model_ECLOUD(Emax,del_max,R0)
		elif switch_model==1 or switch_model=='ACC_LOW':
			sey_mod=SEY_model_acc_low_ene(Emax,del_max,R0)
		elif switch_model=='ECLOUD_nunif':
			sey_mod=SEY_model_ECLOUD_non_unif(chamb, Emax,del_max,R0)
		elif switch_model=='cos_low_ene':
			sey_mod=SEY_model_cos_le(Emax,del_max,R0)
		elif switch_model=='flat_low_ene':
			sey_mod=SEY_model_flat_le(Emax,del_max,R0)

		
		flag_seg = (flag_hist_impact_seg==1)
		   
		impact_man=imc.impact_management(switch_no_increase_energy, chamb, sey_mod, E_th, sigmafit, mufit,
					 Dx_hist, scrub_en_th, Nbin_En_hist, En_hist_max, thresh_low_energy=thresh_low_energy, flag_seg=flag_seg)
		

		if track_method == 'Boris':
			dynamics=dynB.pusher_Boris(Dt, B0x, B0y, B0z, \
					 B_map_file, fact_Bmap,  Bz_map_file,N_sub_steps=N_sub_steps)
		#~ elif track_method == 'StrongBdip':
			#~ dynamics=dyndip.pusher_dipole_magnet(Dt,B)  
		#~ elif track_method == 'StrongBgen':
			#~ dynamics=dyngen.pusher_strong_B_generalized(Dt, B0x, B0y,  \
					 #~ B_map_file, fact_Bmap, B_zero_thrhld) 
		else:
			raise ValueError("""track_method should be 'Boris' - others are not implemented in the PyHEADTAIL module""")
			   

			
		if init_unif_flag==1:
			MP_e.add_uniform_MP_distrib(Nel_init_unif, E_init_unif, x_max_init_unif, x_min_init_unif, y_max_init_unif, y_min_init_unif)
			
		spacech_ele.flag_decimate = False
			
		self.MP_e = MP_e
		self.dynamics = dynamics
		self.impact_man = impact_man
		self.spacech_ele = spacech_ele
		
		self.save_ele_distributions_last_track = False
		self.save_ele_potential_and_field = False
		self.save_ele_MP_position = False
		self.save_ele_MP_velocity = False
		self.save_ele_MP_size = False
		
		self.init_x = self.MP_e.x_mp.copy()
		self.init_y = self.MP_e.y_mp.copy()
		self.init_z = self.MP_e.z_mp.copy()
		self.init_vx = self.MP_e.vx_mp.copy()
		self.init_vy = self.MP_e.vy_mp.copy()
		self.init_vz = self.MP_e.vz_mp.copy()
		self.init_nel = self.MP_e.nel_mp.copy()
		self.init_N_mp = self.MP_e.N_mp