def test_rfsystems_initialization(self):
     '''Tests the initialization of RFSystems including setting a
     warningprinter/printer. No assert included, test is passed if
     no exception is thrown.
     '''
     circumference = 1.
     harmonic_list = [1, 2, 3]
     voltage_list = harmonic_list
     phi_offset_list = harmonic_list
     gamma = 19.
     rf = RFSystems(circumference, harmonic_list, voltage_list,
                    phi_offset_list, self.alpha_array, gamma,
                    charge = e,
                    warningprinter=AccumulatorPrinter(),
                    printer=AccumulatorPrinter())
Exemplo n.º 2
0
 def test_z_cuts_warning(self):
     '''Tests whether a warning is raised whenever
     z_cut_tail >= z_cut_head
     '''
     inverse_z_cuts = (-0.1, -0.3)
     warnings = AccumulatorPrinter()
     slicer = UniformBinSlicer(self.nslices,
                               z_cuts=inverse_z_cuts,
                               warningprinter=warnings)
     self.assertTrue(
         len(warnings.log) > 0,
         'no warning generated when z_cut head < z_cut tail')
 def test_linear_map_higher_order_warning(self):
     ''' Tests whether a warning is generated when higher order terms
     are specified for a linear map (alpha_array)
     '''
     alpha_array3 = [1, 2, 3]
     circumference = 1.
     Q_s = 0.011
     warnings = AccumulatorPrinter()
     linear_map = LinearMap(alpha_array3, circumference, Q_s,
                            warningprinter=warnings)
     self.assertTrue(warnings.log, 'No warning generated when specifying' +
                     'higher order terms in LinearMap')
 def test_linear_map_cleans_slices(self):
     '''Tests whether the slice_sets are deleted when the track() method
     of the LinearMap is called
     '''
     circumference = 1.
     Q_s = 0.012
     linear_map = LinearMap(self.alpha_array, circumference, Q_s,
                            printer=AccumulatorPrinter())
     beam = self.create_all1_bunch()
     sliceset_mock = {'mock': 42}
     beam._slice_sets = sliceset_mock
     linear_map.track(beam)
     self.assertFalse(beam._slice_sets, 'slice_sets not deleted after ' +
                      'calling LinearMap.track() [changing the ' +
                      'z-coordinates of the beam]')
Exemplo n.º 5
0
 def test_total_loss_CircXY(self):
     '''Tests whether the CircularApertureXY tags particles outside
     the specified boundary as lost. After tracking, the number
     of particles should be 0
     '''
     bunch = self.create_unif_bunch(xmin=-1., xmax=-0.5,
                                    ymin=-1., ymax=-0.5)
     warnings = AccumulatorPrinter()
     circxy_aperture = CircularApertureXY(radius=0.1,
                                          warningprinter=warnings)
     circxy_aperture.track(bunch)
     n_particles_after = bunch.macroparticlenumber
     self.assertTrue(n_particles_after == 0,
                     'error in CircularApertureXY: the number of ' +
                     'particles should be zero after this operation')
     self.assertTrue(len(warnings.log) > 0,
                     'no warning generated when all particles were lost')
 def test_drift_track(self):
     '''Tests whether the Drift.track() method does not change any
     coordinates other than the z-component
     '''
     beam = self.create_all1_bunch()
     beam2 = self.create_all1_bunch()
     length = 0.1
     drift = Drift(self.alpha_array, length,
                   warningprinter=AccumulatorPrinter())
     drift.track(beam)
     self.assertTrue(np.allclose(beam.x,beam2.x),
                     'x coord of beam has changed in drift.track()')
     self.assertTrue(np.allclose(beam.y,beam2.y),
                     'y coord of beam has changed in drift.track()')
     self.assertTrue(np.allclose(beam.xp,beam2.xp),
                     'xp coord of beam has changed in drift.track()')
     self.assertTrue(np.allclose(beam.yp,beam2.yp),
                     'yp coord of beam has changed in drift.track()')
     self.assertTrue(np.allclose(beam.dp,beam2.dp),
                     'dp coord of beam has changed in drift.track()')