Пример #1
0
    def test_other_synchronous_data_other_input(self):
        # Test passing other sync data

        length = 300  # m
        alpha_0 = 1e-3
        particle = Proton()
        momentum = 26e9  # eV/c
        tot_energy = 26e9  # eV
        kin_energy = 26e9  # eV
        bending_radius = 70  # m
        b_field = momentum / c / particle.charge / bending_radius  # T

        with self.subTest('Other sync data - Direct - tot_energy'):
            ring = Ring.direct_input(particle,
                                     length,
                                     alpha_0,
                                     energy=tot_energy)
            np.testing.assert_allclose(tot_energy, ring.energy)

        with self.subTest('Other sync data - Direct - kin_energy'):
            # NB: allclose due to double conversion
            ring = Ring.direct_input(particle,
                                     length,
                                     alpha_0,
                                     kin_energy=kin_energy)
            np.testing.assert_allclose(kin_energy, ring.kin_energy)

        with self.subTest('Other sync data - Direct - b_field'):
            # NB: allclose due to double conversion
            ring = Ring.direct_input(particle,
                                     length,
                                     alpha_0,
                                     bending_field=b_field,
                                     bending_radius=bending_radius)
            np.testing.assert_allclose(momentum, ring.momentum)
Пример #2
0
    def test_simple_input_othermethods(self):
        # Test other methods to pass the simplest input

        length = 300  # m
        alpha_0 = 1e-3
        momentum = 26e9  # eV/c
        particle = Proton()

        section = RingSection(length, alpha_0, momentum)
        ring_reference = Ring(particle, [section])

        with self.subTest('Simple input - Single section'):
            ring = Ring(particle, section)
            np.testing.assert_equal(ring_reference.circumference,
                                    ring.circumference)
            np.testing.assert_equal(ring_reference.alpha_0, ring.alpha_0)
            np.testing.assert_equal(ring_reference.momentum, ring.momentum)

        with self.subTest('Simple input - Single section tuple'):
            ring = Ring(particle, (section, ))
            np.testing.assert_equal(ring_reference.circumference,
                                    ring.circumference)
            np.testing.assert_equal(ring_reference.alpha_0, ring.alpha_0)
            np.testing.assert_equal(ring_reference.momentum, ring.momentum)

        with self.subTest('Simple input - Direct classmethod'):
            ring = Ring.direct_input(particle, length, alpha_0, momentum)
            np.testing.assert_equal(ring_reference.circumference,
                                    ring.circumference)
            np.testing.assert_equal(ring_reference.alpha_0, ring.alpha_0)
            np.testing.assert_equal(ring_reference.momentum, ring.momentum)
Пример #3
0
    def test_non_linear_momentum_compaction_other_input(self):
        # Test passing non linear momentum compaction factor

        length = 300  # m
        alpha_0 = 1e-3
        momentum = 26e9  # eV/c
        particle = Proton()
        alpha_1 = 1e-6
        alpha_2 = 1e-9
        alpha_5 = 1e-12

        ring = Ring.direct_input(particle,
                                 length,
                                 alpha_0,
                                 momentum,
                                 alpha_1=alpha_1,
                                 alpha_2=alpha_2,
                                 alpha_5=alpha_5)

        with self.subTest('Simple input - Direct input'):
            np.testing.assert_equal(alpha_1, ring.alpha_1)
            np.testing.assert_equal(alpha_2, ring.alpha_2)
            np.testing.assert_equal(alpha_5, ring.alpha_5)
Пример #4
0
# To declare a Ring with time based programs (multiple, including orbit bump)
length = 628
alpha_0 = [[0, 0.1, 0.2], [1e-3, 1.1e-3, 1e-3]]
alpha_1 = [[0, 0.1, 0.2], [1e-6, 0.9e-6, 1e-6]]
momentum = [[0, 0.1, 0.2], [26e9, 26e9, 26e9]]
orbit_bump = [[0, 0.1, 0.2], [0., 1e-3, 0.]]
particle = Proton()

section = RingSection(length, alpha_0, momentum, alpha_1=alpha_1,
                      orbit_bump=orbit_bump)
ring = Ring(particle, section, eta_orders=1, interpolation='derivative',
            t_start=0.01)

ring = Ring.direct_input(particle, length, alpha_0, momentum,
                         alpha_1=alpha_1,
                         eta_orders=1, interpolation='derivative',
                         t_start=0.01)

print('-- Programs - Multiple time based programs and orbit bump')
print(f'Ring circumference {ring.circumference_design} [m]')
print(f'Ring circumference with bump {ring.circumference} [m]')
print(f'Revolution frequency {ring.f_rev_design} [Hz]')
print(f'Revolution frequency with bump {ring.f_rev} [Hz]')
print(f'Orbit bump {ring.orbit_bump} [m]')
print(f'Cycle time {ring.cycle_time} [s]')
print(f'Sync. data - Momentum {ring.momentum} [eV/c]')
print(f'Energy gain {ring.delta_E[0:9]} [eV/c]')
print(f'Linear momentum compaction {ring.alpha_0}')
print(f'Non-linear momentum compaction 1 {ring.alpha_1}')
print(f'Linear slippage factor {ring.eta_0}')
print(f'Non-linear slippage factor 1 {ring.eta_1}')