def test_1(self):

        # Modified filling time to match reference case
        TWC = SPS3Section200MHzTWC()
        TWC.tau = 420e-9
        filter, n_taps, n_filling, n_fit = feedforward_filter(TWC,
                                                              4 / 125 * 1e-6,
                                                              debug=False,
                                                              taps=31,
                                                              opt_output=True)
        self.assertEqual(
            n_taps,
            31,
            msg="In TestFeedforwardFilter, test_1: n_taps incorrect")
        self.assertEqual(
            n_filling,
            13,
            msg="In TestFeedforwardFilter, test_1: n_filling incorrect")
        self.assertEqual(
            n_fit, 44, msg="In TestFeedforwardFilter, test_1: n_fit incorrect")

        filter_ref = np.array([
            -0.0227533635, 0.0211514102, 0.0032929202, -0.0026111554,
            0.0119559316, 0.0043905603, 0.0043905603, 0.0040101282,
            -0.0241480816, -0.0237676496, 0.0043905603, 0.0043905603,
            0.0043905603, -0.0107783487, 0.0184915005, 0.0065858404,
            -0.0052223108, 0.0239118633, 0.0087811206, 0.0087811206,
            0.0080202564, 0.0295926259, 0.0237676496, -0.0043905603,
            -0.0043905603, -0.0043905603, -0.0119750148, 0.0026599098,
            -0.0032929202, -0.021005147, 0.022696114
        ])

        np.testing.assert_allclose(
            filter,
            filter_ref,
            rtol=1e-8,
            atol=1e-9,
            err_msg="In TestFeedforwardFilter, test_1: filter array incorrect")

        del TWC
    def test_2(self):

        TWC = SPS3Section200MHzTWC()
        filter, n_taps, n_filling, n_fit = feedforward_filter(TWC,
                                                              self.T_s,
                                                              debug=False,
                                                              opt_output=True)
        self.assertEqual(
            n_taps,
            31,
            msg="In TestFeedforwardFilter, test_2: n_taps incorrect")
        self.assertEqual(
            n_filling,
            18,
            msg="In TestFeedforwardFilter, test_2: n_filling incorrect")
        self.assertEqual(
            n_fit, 49, msg="In TestFeedforwardFilter, test_2: n_fit incorrect")

        #        filter_ref = np.array(
        #            [-0.0070484734, 0.0161859736, 0.0020289928, 0.0020289928,
        #              0.0020289928, -0.0071641302, -0.0162319424, -0.0070388194,
        #              0.0020289928, 0.0020289928, 0.0020289928, - 0.0050718734,
        #              0.0065971343, 0.0030434892, 0.0030434892, 0.0030434892,
        #              0.0030434892, 0.0030434892, -0.0004807475, 0.011136476,
        #              0.0040579856, 0.0040579856, 0.0040579856, 0.0132511086,
        #              0.019651364, 0.0074147518, -0.0020289928, -0.0020289928,
        #             -0.0020289928, -0.0162307252, 0.0071072903])
        filter_ref = np.copy(feedforward_filter_TWC3)

        np.testing.assert_allclose(
            filter,
            filter_ref,
            rtol=1e-8,
            atol=1e-9,
            err_msg="In TestFeedforwardFilter, test_2: filter array incorrect")

        del TWC
示例#3
0
    bigaussian(ring, rf, beam, 1.8e-9/4, seed=1234, reinsertion=True)
    beam2 = Beam(ring, bunches*N_m, bunches*N_b)
    bunch_spacing = 5*rf.t_rf[0, 0]
    buckets = 5 * bunches
    for i in range(bunches):
        beam2.dt[i*N_m:(i+1)*N_m] = beam.dt + i*bunch_spacing
        beam2.dE[i*N_m:(i+1)*N_m] = beam.dE
    profile2 = Profile(beam2, CutOptions=CutOptions(cut_left=0,
        cut_right=bunches*bunch_spacing, n_slices=1000*buckets))
    profile2.track()

    # Compare beam impulse response on coarse and fine grid
    time_fine = profile2.bin_centers - 0.5*profile2.bin_size
    time_coarse = np.linspace(0, rf.t_rev[0], 4620)

    TWC = SPS3Section200MHzTWC()
    TWC.impulse_response_beam(rf.omega_rf[0,0], time_fine, time_coarse)
    h_beam_fine = TWC.h_beam
    h_beam_coarse = TWC.h_beam_coarse
    print(len(time_fine), len(h_beam_fine))
    print(len(time_coarse), len(h_beam_coarse))

    # Calculate fine- and coarse-grid RF charge distribution
    rf_current_fine, rf_current_coarse = rf_beam_current(profile2,
        rf.omega_rf[0, 0], ring.t_rev[0], lpf=False,
        downsample={'Ts': rf.t_rev[0]/rf.harmonic[0, 0], 'points': rf.harmonic[0, 0]})

    OTFB = SPSOneTurnFeedback(rf, beam2, profile2, 3, n_cavities=1,
        Commissioning=CavityFeedbackCommissioning(open_FF=True))
    V_beam_fine = -OTFB.matr_conv(rf_current_fine, h_beam_fine)
    V_beam_coarse = -OTFB.matr_conv(rf_current_coarse, h_beam_coarse)
示例#4
0
ring = Ring(C, alpha, p_s, Particle=Proton(), n_turns=N_t)
logging.info("...... Machine parameters set!")

# Set up RF parameters
rf = RFStation(ring, h, V, phi, n_rf=1)
logging.info("...... RF parameters set!")
T_s = bunch_spacing * rf.t_rf[0, 0]
logging.info("RF period %.6e s", rf.t_rf[0, 0])
logging.info("Sampling period %.6e s", T_s)

if FILTER_DESIGN:

    logging.info("...... Filter design test")
    logging.info("3-section cavity filter design with modified filling time" +
                 " and fixed n_taps")
    TWC = SPS3Section200MHzTWC()
    TWC.tau = 420e-9
    filter, n_taps, n_filling, n_fit = feedforward_filter(TWC,
                                                          4 / 125 * 1e-6,
                                                          debug=True,
                                                          taps=31,
                                                          opt_output=True)
    #    print(filter)

    logging.info("3-section cavity filter design")
    TWC_3 = SPS3Section200MHzTWC()
    filter = feedforward_filter(TWC_3, T_s, debug=True)
    #    print(filter)

    logging.info("4-section cavity filter design")
    TWC_4 = SPS4Section200MHzTWC()