Exemplo n.º 1
0
    def test_correctImpedanceFuncion4(self):
        csr_imped = CoherentSynchrotronRadiation(1, gamma=42, chamber_height=4.2)

        self.assertTrue(hasattr(csr_imped, 'f_crit'))
        self.assertTrue(hasattr(csr_imped, 'f_cut'))
        self.assertEqual(csr_imped.imped_calc.__func__,
                         CoherentSynchrotronRadiation._pp_spectrum)
Exemplo n.º 2
0
    def test_energyLoss(self):
        # based on Example 22: Coherent Radiation

        r_bend, energy = 1.273, 40e6  # bending radius [m], particle energy [eV]
        gamma = energy / Electron().mass  # Lorentz factor

        # frequencies at which to compute impedance (from 1e8 to 1e15 Hz)
        frequencies = 10**np.linspace(8, 15, num=200)

        Z_fs = CoherentSynchrotronRadiation(r_bend, gamma=gamma)
        Z_fs.imped_calc(frequencies, low_frequency_transition=1e-4)

        energy_loss = 2 * np.trapz(Z_fs.impedance.real, frequencies) * elCharge  # [eV]

        energy_loss_textbook = Electron().C_gamma * energy**4 / r_bend  # [eV]

        self.assertAlmostEqual(energy_loss, energy_loss_textbook, places=3)
Exemplo n.º 3
0
    def test_lowHighFrequencyTransitionFreeSpace(self):
        csr_imped = CoherentSynchrotronRadiation(1, gamma=42)

        self.assertRaises(ValueError, csr_imped.imped_calc, np.arange(5),
                          high_frequency_transition=0.2)
        self.assertRaises(ValueError, csr_imped.imped_calc, np.arange(5),
                          low_frequency_transition=2)
        self.assertRaises(ValueError, csr_imped.imped_calc, np.arange(5),
                          low_frequency_transition=1.1, high_frequency_transition=1)
    pass
try:
    os.mkdir(this_directory + '../output_files/EX_22_fig')
except FileExistsError:
    pass


h, r_bend = 32e-3, 1.273  # chamber height [m], bending radius [m]

gamma = 40e6 / Electron().mass  # Lorentz factor

# frequencies at which to compute impedance (from 1e8 to 1e15 Hz)
freqs = 10**np.linspace(8, 15, num=200)

# approximate free-space CSR impedance increases as f^2/3
Z_fs_appr = CoherentSynchrotronRadiation(r_bend)
Z_fs_appr.imped_calc(freqs)

# The exact free-space CSR impedance increases as f^2/3 up to the critical frequency...
# ... and is exponentially suppressed above.
Z_fs = CoherentSynchrotronRadiation(r_bend, gamma=gamma)
Z_fs.imped_calc(freqs, high_frequency_transition=10)

f_crit = Z_fs.f_crit  # critical frequency [Hz]

# The approximate parallel-plates impedance is suppressed below the cut-off frequency...
# ... and approaches the approximate free-space CSR impedance for large frequencies.
Z_pp_appr = CoherentSynchrotronRadiation(r_bend, chamber_height=h)
Z_pp_appr.imped_calc(freqs, high_frequency_transition=10)

f_cut = Z_pp_appr.f_cut  # cut-off frequency [Hz]
Exemplo n.º 5
0
    def test_correctImpedanceFuncion3(self):
        csr_imped = CoherentSynchrotronRadiation(1, chamber_height=42)

        self.assertTrue(hasattr(csr_imped, 'f_cut'))
        self.assertEqual(csr_imped.imped_calc.__func__,
                         CoherentSynchrotronRadiation._pp_low_frequency)
Exemplo n.º 6
0
    def test_correctImpedanceFuncion2(self):
        csr_imped = CoherentSynchrotronRadiation(1, gamma=42)

        self.assertTrue(hasattr(csr_imped, 'f_crit'))
        self.assertEqual(csr_imped.imped_calc.__func__,
                         CoherentSynchrotronRadiation._fs_spectrum)
Exemplo n.º 7
0
    def test_correctImpedanceFuncion1(self):
        csr_imped = CoherentSynchrotronRadiation(1)

        self.assertEqual(csr_imped.imped_calc.__func__,
                         CoherentSynchrotronRadiation._fs_low_frequency_wrapper)
Exemplo n.º 8
0
 def test_wrongGamma(self):
     with self.assertRaises(ValueError):
         CoherentSynchrotronRadiation(1, gamma=0.1)
Exemplo n.º 9
0
 def test_wrongChamberHeight(self):
     with self.assertRaises(ValueError):
         CoherentSynchrotronRadiation(1, chamber_height=0)
     with self.assertRaises(ValueError):
         CoherentSynchrotronRadiation(1, chamber_height=-1)
Exemplo n.º 10
0
 def test_wrongBendingRadius(self):
     with self.assertRaises(ValueError):
         CoherentSynchrotronRadiation(-1)
     with self.assertRaises(ValueError):
         CoherentSynchrotronRadiation(0)
Exemplo n.º 11
0
    def test_lowHighFrequencyTransitionApproxPP(self):
        csr_imped = CoherentSynchrotronRadiation(1, chamber_height=42)

        self.assertRaises(ValueError, csr_imped.imped_calc, np.arange(5),
                          high_frequency_transition=0.2)