Пример #1
0
def test_madx_kicker(x, px, y, py, pt, beta, length, tilt, hkick, vkick):
    k = Kinematics(beta)
    mi = manzoni.Input(sequence=[
        manzoni.Kicker(
            'K1',
            integrator=MadXIntegrator,
            L=length * _.m,
            TILT=tilt * _.radian,
            HKICK=hkick * _.radian,
            VKICK=vkick * _.radian,
        ),
    ]).freeze()
    deltap = np.sqrt(pt**2 + 2 * pt / beta + 1) - 1
    distribution = np.array([
        [x, px, y, py, deltap, pt],
    ])
    beam = manzoni.Beam(kinematics=k, distribution=distribution)
    observer = manzoni.BeamObserver()
    manzoni.track(beamline=mi, beam=beam, observer=observer)
    r = observer.to_df().iloc[-1]['BEAM_OUT']

    assert np.all(
        np.isclose(
            get_madx_tracking_data_kicker(x, px, y, py, pt, beta, length, tilt,
                                          hkick, vkick), r[:, 0:4]))
Пример #2
0
def test_madx_dipedge(x, px, y, py, pt, beta, h, e1, hgap, fint):
    k = Kinematics(beta)
    mi = manzoni.Input(sequence=[
        manzoni.Drift('D1', L=0.5 * _.m),
        manzoni.DipEdge(
            'DE1',
            integrator=MadXIntegrator,
            H=h * _.m**-1,
            E1=e1 * _.radian,
            HGAP=hgap * _.m,
            FINT=fint,
        ),
        manzoni.Drift('D2', L=0.5 * _.m),
    ]).freeze()
    deltap = np.sqrt(pt**2 + 2 * pt / beta + 1) - 1
    distribution = np.array([
        [x, px, y, py, deltap, pt],
    ])
    beam = manzoni.Beam(kinematics=k, distribution=distribution)
    observer = manzoni.BeamObserver()
    manzoni.track(beamline=mi, beam=beam, observer=observer)
    r = observer.to_df().iloc[-1]['BEAM_OUT']

    assert np.all(
        np.isclose(
            get_madx_tracking_data_dipedge(x, px, y, py, pt, beta, h, e1, hgap,
                                           fint), r[:, 0:4]))
Пример #3
0
def test_madx_rbend_fringe(x, px, y, py, pt, beta, length, angle, k1, e1, e2,
                           hgap, fint, fintx):
    k = Kinematics(beta)
    mi_rbend = manzoni.Input(sequence=[
        manzoni.RBend(
            'B1',
            integrator=MadXIntegrator,
            L=length * _.m,
            K1=k1 * _.m**-2,
            ANGLE=angle * _.radian,
            E1=e1 * _.radian,
            E2=e2 * _.radian,
            HGAP=hgap * _.m,
            FINT=fint,
            FINTX=fintx,
        ),
    ]).freeze()
    deltap = np.sqrt(pt**2 + 2 * pt / beta + 1) - 1
    distribution = np.array([
        [x, px, y, py, deltap, pt],
    ])
    beam = manzoni.Beam(kinematics=k, distribution=distribution)
    observer = manzoni.BeamObserver()
    manzoni.track(beamline=mi_rbend, beam=beam, observer=observer)
    r_rbend = observer.to_df().iloc[-1]['BEAM_OUT']

    assert np.all(
        np.isclose(
            get_madx_tracking_data_bend(x, px, y, py, pt, beta, length, angle,
                                        k1, e1, e2, hgap, fint, fintx,
                                        'RBEND'), r_rbend[:, 0:4]))
Пример #4
0
def test_madx_drift(x, px, y, py, pt, beta, length):
    k = Kinematics(beta)
    mi = manzoni.Input(sequence=[
        manzoni.Drift('B1', integrator=MadXIntegrator, L=length * _.m),
    ]).freeze()
    deltap = np.sqrt(pt**2 + 2 * pt / beta + 1) - 1
    distribution = np.array([
        [x, px, y, py, deltap, pt],
    ])
    beam = manzoni.Beam(kinematics=k, distribution=distribution)
    observer = manzoni.BeamObserver()
    manzoni.track(beamline=mi, beam=beam, observer=observer)
    r = observer.to_df().iloc[-1]['BEAM_OUT']

    assert np.all(
        np.isclose(
            get_madx_tracking_data_drift(x, px, y, py, pt, beta, length),
            r[:, 0:4]))
Пример #5
0
def test_madx_quadrupole(x, px, y, py, pt, beta, length, k1, k1s, tilt):
    k = Kinematics(beta)
    mi = manzoni.Input(sequence=[
        manzoni.Quadrupole('B1',
                           integrator=MadXIntegrator,
                           L=length * _.m,
                           K1=k1 * _.m**-2,
                           K1S=k1s * _.m**-2,
                           TILT=tilt * _.radian),
    ]).freeze()
    deltap = np.sqrt(pt**2 + 2 * pt / beta + 1) - 1
    distribution = np.array([
        [x, px, y, py, deltap, pt],
    ])
    beam = manzoni.Beam(kinematics=k, distribution=distribution)
    observer = manzoni.BeamObserver()
    manzoni.track(beamline=mi, beam=beam, observer=observer)
    r = observer.to_df().iloc[-1]['BEAM_OUT']

    assert np.all(
        np.isclose(
            get_madx_tracking_data_quadrupole(x, px, y, py, pt, beta, length,
                                              k1, k1s, tilt), r[:, 0:4]))