def test_RFQ_detuner(self): ''' Test the RFQ as a detuning element in the transverse map ''' bunch_cpu = self.create_gaussian_bunch() bunch_gpu = self.create_gaussian_bunch() detuner = RFQTransverseDetuner(v_2=1.5e9, omega=341e5 * 2.5 * np.pi, phi_0=-np.pi / 4, beta_x_RFQ=200., beta_y_RFQ=99.) transverse_map = tt.TransverseMap(self.s, self.alpha_x, self.beta_x, self.Dx, self.alpha_y, self.beta_y, self.Dy, self.Qx, self.Qy, detuner, printer=SilentPrinter()) self.assertTrue( self._track_cpu_gpu(transverse_map, bunch_cpu, bunch_gpu), 'Transverse tracking with RFQDetuner CPU/GPU differs')
def test_transverse_track_no_detuning(self): ''' Track the GPU bunch through a TransverseMap with no detuning Check if results on CPU and GPU are the same ''' bunch_cpu = self.create_all1_bunch() bunch_gpu = self.create_all1_bunch() transverse_map = tt.TransverseMap(self.s, self.alpha_x, self.beta_x, self.Dx, self.alpha_y, self.beta_y, self.Dy, self.Qx, self.Qy, printer=SilentPrinter()) self.assertTrue( self._track_cpu_gpu(transverse_map, bunch_cpu, bunch_gpu), 'Transverse tracking w/o detuning CPU/GPU differs')
def test_tracking_without_detuner(self): '''Tests whether the cython and pure python version of the TransverseMap yield the same results (x,y,xp,yp) when tracking a beam without detuners ''' pure_python_map = pure_py.TransverseMap(self.s, self.alpha_x, self.beta_x, self.Dx, self.alpha_y, self.beta_y, self.Dy, self.Qx, self.Qy, printer=SilentPrinter()) beam_p = self.create_bunch() for s in pure_python_map: s.track(beam_p)
def test_transverse_track_with_Cdetuning(self): ''' Track the GPU bunch through a TransverseMap with chromaticity (detuning) Check if results on CPU and GPU are the same ''' bunch_cpu = self.create_all1_bunch() bunch_gpu = self.create_all1_bunch() detuner = Chromaticity(Qp_x=[5, 1], Qp_y=[7, 2]) transverse_map = tt.TransverseMap(self.s, self.alpha_x, self.beta_x, self.Dx, self.alpha_y, self.beta_y, self.Dy, self.Qx, self.Qy, detuner, printer=SilentPrinter()) self.assertTrue( self._track_cpu_gpu(transverse_map, bunch_cpu, bunch_gpu), 'Transverse tracking with chromaticity CPU/GPU differs')
def test_transverse_track_with_Adetuning(self): ''' Track the GPU bunch through a TransverseMap with amplitude detuning Check if results on CPU and GPU are the same Special test since it requires the PyCERNmachines module to create the LHC beam. Skip if not available. ''' # Use a real bunch (not all set to 1), otherwise the Action/detuning # gets too big and the numbers blow up. Dx = np.append(np.linspace(0., 20., self.nsegments), [0]) # add some dispersion/alpha lhc = m.LHC(n_segments=self.nsegments, machine_configuration='450GeV', app_x=1e-9, app_y=2e-9, app_xy=-1.5e-11, chromaticity_on=False, amplitude_detuning_on=True, alpha_x=1.2 * np.ones(self.nsegments), D_x=Dx, printer=SilentPrinter()) # create pure Python map, PyCERNmachine uses Cython. adetuner = AmplitudeDetuning(lhc.app_x, lhc.app_y, lhc.app_xy) transverse_map = tt.TransverseMap(lhc.s, lhc.alpha_x, lhc.beta_x, lhc.D_x, lhc.alpha_y, lhc.beta_y, lhc.D_y, lhc.Q_x, lhc.Q_y, adetuner, printer=SilentPrinter()) bunch_cpu = self.create_lhc_bunch(lhc) bunch_gpu = self.create_lhc_bunch(lhc) self.assertTrue( self._track_cpu_gpu(transverse_map, bunch_cpu, bunch_gpu), 'Transverse tracking with Adetuning CPU/GPU differs')