示例#1
0
def test_beambeam():
    for context in xo.context.get_test_contexts():
        print(repr(context))

        #################################
        # Generate particles and probes #
        #################################

        n_macroparticles_b1 = int(1e6)
        bunch_intensity_b1 = 2.5e11
        sigma_x_b1 = 3e-3
        sigma_y_b1 = 2e-3
        mean_x_b1 = 1.3e-3
        mean_y_b1 = -1.2e-3

        n_macroparticles_b2 = int(1e6)
        bunch_intensity_b2 = 3e11
        sigma_x_b2 = 1.7e-3
        sigma_y_b2 = 2.1e-3
        mean_x_b2 = -1e-3
        mean_y_b2 = 1.4e-3

        sigma_z = 30e-2
        p0c = 25.92e9
        mass = pmass,
        theta_probes = 30 * np.pi / 180
        r_max_probes = 2e-2
        z_probes = 1.2 * sigma_z
        n_probes = 1000

        from xfields.test_support.temp_makepart import generate_particles_object
        (particles_b1, r_probes, _, _, _) = generate_particles_object(
            n_macroparticles_b1, bunch_intensity_b1, sigma_x_b1, sigma_y_b1,
            sigma_z, p0c, mass, n_probes, r_max_probes, z_probes, theta_probes)
        # Move to right context
        particles_b1 = xp.Particles(_context=context, **particles_b1.to_dict())
        particles_b1.x += mean_x_b1
        particles_b1.y += mean_y_b1

        (particles_b2, r_probes, _, _, _) = generate_particles_object(
            n_macroparticles_b2, bunch_intensity_b2, sigma_x_b2, sigma_y_b2,
            sigma_z, p0c, mass, n_probes, r_max_probes, z_probes, theta_probes)
        particles_b2 = xp.Particles(_context=context, **particles_b2.to_dict())
        particles_b2.x += mean_x_b2
        particles_b2.y += mean_y_b2

        #############
        # Beam-beam #
        #############

        from xfields import BeamBeamBiGaussian2D, mean_and_std

        # if beta0 is array I just take the first
        beta0_b2 = context.nparray_from_context_array(particles_b2.beta0)[0]
        beta0_b1 = context.nparray_from_context_array(particles_b1.beta0)[0]

        bbeam_b1 = BeamBeamBiGaussian2D(
            _context=context,
            n_particles=bunch_intensity_b2,
            q0=particles_b2.q0,
            beta0=beta0_b2,
            sigma_x=None,  # needs to be specified only for weak-strong
            sigma_y=None,  # needs to be specified only for weak-strong
            mean_x=None,  # needs to be specified only for weak-strong
            mean_y=None,  # needs to be specified only for weak-strong
            min_sigma_diff=1e-10)

        # Measure beam properties
        mean_x_meas, sigma_x_meas = mean_and_std(particles_b2.x)
        mean_y_meas, sigma_y_meas = mean_and_std(particles_b2.y)
        # Update bb lens
        bbeam_b1.update(sigma_x=sigma_x_meas,
                        mean_x=mean_x_meas,
                        sigma_y=sigma_y_meas,
                        mean_y=mean_y_meas)
        #Track
        bbeam_b1.track(particles_b1)

        #############################
        # Compare against ducktrack #
        #############################

        p2np = context.nparray_from_context_array
        x_probes = p2np(particles_b1.x[:n_probes])
        y_probes = p2np(particles_b1.y[:n_probes])
        z_probes = p2np(particles_b1.zeta[:n_probes])

        from ducktrack.elements import BeamBeam4D
        bb_b1_dtk = BeamBeam4D(charge=bunch_intensity_b2,
                               sigma_x=sigma_x_b2,
                               sigma_y=sigma_y_b2,
                               x_bb=mean_x_b2,
                               y_bb=mean_y_b2,
                               beta_r=np.float64(beta0_b2))

        p_dtk = dtk.TestParticles(p0c=p0c,
                                  mass=mass,
                                  x=x_probes.copy(),
                                  y=y_probes.copy(),
                                  zeta=z_probes.copy())

        bb_b1_dtk.track(p_dtk)

        assert np.allclose(p_dtk.px,
                           p2np(particles_b1.px[:n_probes]),
                           atol=2e-2 * np.max(np.abs(p_dtk.px)))
        assert np.allclose(p_dtk.py,
                           p2np(particles_b1.py[:n_probes]),
                           atol=2e-2 * np.max(np.abs(p_dtk.py)))
示例#2
0
def test_spacecharge_gauss_qgauss():
    for frozen in [True, False]:
        for context in xo.context.get_test_contexts():
            print(f"Test {context.__class__}")

            #################################
            # Generate particles and probes #
            #################################

            n_macroparticles = int(1e6)
            bunch_intensity = 2.5e11
            sigma_x = 3e-3
            sigma_y = 2e-3
            sigma_z = 30e-2
            x0 = 1e-3
            y0 = -4e-3
            p0c = 25.92e9
            mass = pmass,
            theta_probes = 30 * np.pi/180
            r_max_probes = 2e-2
            z_probes = 1.2*sigma_z
            n_probes = 1000

            from xfields.test_support.temp_makepart import generate_particles_object
            (particles_dtk, r_probes, _, _, _) = generate_particles_object(
                                        n_macroparticles,
                                        bunch_intensity,
                                        sigma_x,
                                        sigma_y,
                                        sigma_z,
                                        p0c,
                                        mass,
                                        n_probes,
                                        r_max_probes,
                                        z_probes,
                                        theta_probes)
            particles = xp.Particles(
                    _context=context, **particles_dtk.to_dict())

            particles.x += x0
            particles.y += y0

            ################
            # Space charge #
            ################

            from xfields import LongitudinalProfileQGaussian
            lprofile = LongitudinalProfileQGaussian(
                    _context=context,
                    number_of_particles=bunch_intensity,
                    sigma_z=sigma_z,
                    z0=0.,
                    q_parameter=1. # there is a bug in ducktrack, 
                                   # only q=1 can be tested 
                    )

            from xfields import SpaceChargeBiGaussian
            # Just not to fool myself in the test
            if frozen:
                x0_init = x0
                y0_init = y0
                sx_init = sigma_x
                sy_init = sigma_y
            else:
                x0_init = None
                y0_init = None
                sx_init = None
                sy_init = None

            scgauss = SpaceChargeBiGaussian(
                            _context=context,
                            update_on_track=not(frozen),
                            length=1.,
                            apply_z_kick=False,
                            longitudinal_profile=lprofile,
                            mean_x=x0_init,
                            mean_y=y0_init,
                            sigma_x=sx_init,
                            sigma_y=sy_init,
                            min_sigma_diff=1e-10)

            scgauss.track(particles)

            #############################
            # Compare against ducktrack #
            #############################

            p2np = context.nparray_from_context_array
            x_probes = p2np(particles.x[:n_probes])
            y_probes = p2np(particles.y[:n_probes])
            z_probes = p2np(particles.zeta[:n_probes])

            scdtk = dtk.SCQGaussProfile(
                    number_of_particles = bunch_intensity,
                    bunchlength_rms=sigma_z,
                    sigma_x=sigma_x,
                    sigma_y=sigma_y,
                    length=scgauss.length,
                    q_parameter=scgauss.longitudinal_profile.q_parameter,
                    x_co=x0,
                    y_co=y0)

            p_dtk = dtk.TestParticles(p0c=p0c,
                    mass=mass,
                    x=x_probes.copy(),
                    y=y_probes.copy(),
                    zeta=z_probes.copy())

            scdtk.track(p_dtk)

            assert np.allclose(
                    p2np(particles.px[:n_probes]),
                    p_dtk.px,
                    atol={True:1e-7, False:1e2}[frozen]
                      * np.max(np.abs(p_dtk.px)))
            assert np.allclose(
                    p2np(particles.py[:n_probes]),
                    p_dtk.py,
                    atol={True:1e-7, False:1e2}[frozen]
                      * np.max(np.abs(p_dtk.py)))
示例#3
0
def test_spacecharge_pic():
    for solver in ['FFTSolver2p5D', 'FFTSolver3D']:
        for context in xo.context.get_test_contexts():
            print(f"Test {context.__class__}")

            print(repr(context))

            #################################
            # Generate particles and probes #
            #################################

            n_macroparticles = int(5e6)
            bunch_intensity = 2.5e11
            sigma_x = 3e-3
            sigma_y = 2e-3
            sigma_z = 30e-2
            p0c = 25.92e9
            mass = pmass,
            theta_probes = 30 * np.pi/180
            r_max_probes = 2e-2
            z_probes = 1.2*sigma_z
            n_probes = 1000

            from xfields.test_support.temp_makepart import generate_particles_object
            (particles_gen, r_probes, x_probes,
                    y_probes, z_probes) = generate_particles_object(
                                        n_macroparticles,
                                        bunch_intensity,
                                        sigma_x,
                                        sigma_y,
                                        sigma_z,
                                        p0c,
                                        mass,
                                        n_probes,
                                        r_max_probes,
                                        z_probes,
                                        theta_probes)
            # Transfer particles to context
            particles = xp.Particles(
                    _context=context, **particles_gen.to_dict())

            ######################
            # Space charge (PIC) #
            ######################

            x_lim = 4.*sigma_x
            y_lim = 4.*sigma_y
            z_lim = 4.*sigma_z

            from xfields import SpaceCharge3D

            spcharge = SpaceCharge3D(
                    _context=context,
                    length=1, update_on_track=True, apply_z_kick=False,
                    x_range=(-x_lim, x_lim),
                    y_range=(-y_lim, y_lim),
                    z_range=(-z_lim, z_lim),
                    nx=128, ny=128, nz=25,
                    solver=solver,
                    gamma0=particles_gen.gamma0[0],
                    )

            spcharge.track(particles)

            #############################
            # Compare against ducktrack #
            #############################

            p2np = context.nparray_from_context_array

            scdtk = dtk.SCQGaussProfile(
                    number_of_particles = bunch_intensity,
                    bunchlength_rms=sigma_z,
                    sigma_x=sigma_x,
                    sigma_y=sigma_y,
                    length=spcharge.length,
                    x_co=0.,
                    y_co=0.)

            p_dtk = dtk.TestParticles(p0c=p0c,
                    mass=mass,
                    x=x_probes.copy(),
                    y=y_probes.copy(),
                    zeta=z_probes.copy())

            scdtk.track(p_dtk)

            mask_inside_grid = ((np.abs(x_probes)<0.9*x_lim) &
                                (np.abs(y_probes)<0.9*y_lim))

            assert np.allclose(
                    p2np(particles.px[:n_probes])[mask_inside_grid],
                    p_dtk.px[mask_inside_grid],
                    atol=3e-2*np.max(np.abs(p_dtk.px[mask_inside_grid])))
            assert np.allclose(
                    p2np(particles.py[:n_probes])[mask_inside_grid],
                    p_dtk.py[mask_inside_grid],
                    atol=3e-2*np.max(np.abs(p_dtk.py[mask_inside_grid])))
示例#4
0
print('Check against ducktrack...')
p2np = context.nparray_from_context_array
x_probes = p2np(particles_b1.x[:n_probes])
y_probes = p2np(particles_b1.y[:n_probes])
z_probes = p2np(particles_b1.zeta[:n_probes])

bb_b1_dtk = dtk.BeamBeam4D(charge=bunch_intensity_b2,
                           sigma_x=sigma_x_b2,
                           sigma_y=sigma_y_b2,
                           x_bb=mean_x_b2,
                           y_bb=mean_y_b2,
                           beta_r=np.float64(particles_b2_gen.beta0)[0])

p_dtk = dtk.TestParticles(p0c=p0c,
                          mass=mass,
                          x=x_probes.copy(),
                          y=y_probes.copy(),
                          zeta=z_probes.copy())

bb_b1_dtk.track(p_dtk)

assert np.allclose(p_dtk.px,
                   p2np(particles_b1.px[:n_probes]),
                   atol=2e-2 * np.max(np.abs(p_dtk.px)))
assert np.allclose(p_dtk.py,
                   p2np(particles_b1.py[:n_probes]),
                   atol=2e-2 * np.max(np.abs(p_dtk.px)))

import matplotlib.pyplot as plt
plt.close('all')
plt.figure()
                                 px_co=px_co,
                                 y_co=y_co,
                                 py_co=py_co,
                                 zeta_co=zeta_co,
                                 delta_co=delta_co,
                                 d_x=d_x,
                                 d_px=d_px,
                                 d_y=d_y,
                                 d_py=d_py,
                                 d_zeta=d_zeta,
                                 d_delta=d_delta)

dtk_part = dtk.TestParticles(p0c=6500e9,
                             x=-1.23e-3,
                             px=50e-3,
                             y=2e-3,
                             py=27e-3,
                             sigma=3.,
                             delta=2e-4)

part = xp.Particles(_context=context, **dtk_part.to_dict())
part.name = 'beam1_bunch1'

ret = bb.track(part, _force_suspend=True)
assert ret.on_hold
ret = bb.track(part)
assert ret is None

print('------------------------')

bb_dtk.track(dtk_part)
示例#6
0
def test_beambeam3d():
    for context in xo.context.get_test_contexts():

        if not isinstance(context, xo.ContextCpu):
            print(f'skipping test_beambeam3d_collective for context {context}')
            continue

        print(repr(context))

        # crossing plane
        alpha = 0.7

        # crossing angle
        phi = 0.8

        # separations
        x_bb_co=5e-3
        y_bb_co=-4e-3
        charge_slices=np.array([1e16, 2e16, 5e16])
        z_slices=np.array([-6., 0.2, 5.5])

        x_co = 2e-3
        px_co= 1e-6
        y_co=-3e-3
        py_co=-2e-6
        zeta_co=0.01
        delta_co=1.2e-3

        d_x=1.5e-3
        d_px=1.6e-6
        d_y=-1.7e-3
        d_py=-1.8e-6
        d_zeta=0.019
        d_delta=3e-4

        for ss in sigma_configurations():

            (Sig_11_0, Sig_12_0, Sig_13_0, Sig_14_0, Sig_22_0, Sig_23_0, Sig_24_0,
                    Sig_33_0, Sig_34_0, Sig_44_0) = ss

            Sig_11_0 = Sig_11_0 + np.zeros_like(charge_slices)
            Sig_12_0 = Sig_12_0 + np.zeros_like(charge_slices)
            Sig_13_0 = Sig_13_0 + np.zeros_like(charge_slices)
            Sig_14_0 = Sig_14_0 + np.zeros_like(charge_slices)
            Sig_22_0 = Sig_22_0 + np.zeros_like(charge_slices)
            Sig_23_0 = Sig_23_0 + np.zeros_like(charge_slices)
            Sig_24_0 = Sig_24_0 + np.zeros_like(charge_slices)
            Sig_33_0 = Sig_33_0 + np.zeros_like(charge_slices)
            Sig_34_0 = Sig_34_0 + np.zeros_like(charge_slices)
            Sig_44_0 = Sig_44_0 + np.zeros_like(charge_slices)

            # I modify one slice to check that properties are working correctly
            Sig_11_0[1] *= 1000
            Sig_12_0[1] *= 1000
            Sig_13_0[1] *= 1000
            Sig_14_0[1] *= 1000
            Sig_22_0[1] *= 1000
            Sig_23_0[1] *= 1000
            Sig_24_0[1] *= 1000
            Sig_33_0[1] *= 1000
            Sig_34_0[1] *= 1000
            Sig_44_0[1] *= 1000

            print('------------------------')

            print(ss)

            bb_dtk = dtk.elements.BeamBeam6D(
                    phi=phi, alpha=alpha,
                    x_bb_co=x_bb_co,
                    y_bb_co=y_bb_co,
                    charge_slices=charge_slices,
                    zeta_slices=z_slices,
                    sigma_11=Sig_11_0[0],
                    sigma_12=Sig_12_0[0],
                    sigma_13=Sig_13_0[0],
                    sigma_14=Sig_14_0[0],
                    sigma_22=Sig_22_0[0],
                    sigma_23=Sig_23_0[0],
                    sigma_24=Sig_24_0[0],
                    sigma_33=Sig_33_0[0],
                    sigma_34=Sig_34_0[0],
                    sigma_44=Sig_44_0[0],
                    x_co=x_co,
                    px_co=px_co,
                    y_co=y_co,
                    py_co=py_co,
                    zeta_co=zeta_co,
                    delta_co=delta_co,
                    d_x=d_x,
                    d_px=d_px,
                    d_y=d_y,
                    d_py=d_py,
                    d_zeta=d_zeta,
                    d_delta=d_delta
                    )

            bb = xf.BeamBeamBiGaussian3D(

                    _context=context,

                    phi=phi, alpha=alpha, other_beam_q0=1,

                    slices_other_beam_num_particles=charge_slices[::-1],
                    slices_other_beam_zeta_center=z_slices[::-1],

                    slices_other_beam_Sigma_11=Sig_11_0,
                    slices_other_beam_Sigma_12=Sig_12_0,
                    slices_other_beam_Sigma_13=Sig_13_0,
                    slices_other_beam_Sigma_14=Sig_14_0,
                    slices_other_beam_Sigma_22=Sig_22_0,
                    slices_other_beam_Sigma_23=Sig_23_0,
                    slices_other_beam_Sigma_24=Sig_24_0,
                    slices_other_beam_Sigma_33=Sig_33_0,
                    slices_other_beam_Sigma_34=Sig_34_0,
                    slices_other_beam_Sigma_44=Sig_44_0,

                    ref_shift_x=x_co,
                    ref_shift_px=px_co,
                    ref_shift_y=y_co,
                    ref_shift_py=py_co,
                    ref_shift_zeta=zeta_co,
                    ref_shift_pzeta=delta_co,

                    other_beam_shift_x=x_bb_co,
                    other_beam_shift_y=y_bb_co,

                    post_subtract_x=d_x,
                    post_subtract_px=d_px,
                    post_subtract_y=d_y,
                    post_subtract_py=d_py,
                    post_subtract_zeta=d_zeta,
                    post_subtract_pzeta=d_delta,
            )

            bb.slices_other_beam_Sigma_11[1] = bb.slices_other_beam_Sigma_11[0]
            bb.slices_other_beam_Sigma_12[1] = bb.slices_other_beam_Sigma_12[0]
            bb.slices_other_beam_Sigma_13[1] = bb.slices_other_beam_Sigma_13[0]
            bb.slices_other_beam_Sigma_14[1] = bb.slices_other_beam_Sigma_14[0]
            bb.slices_other_beam_Sigma_22[1] = bb.slices_other_beam_Sigma_22[0]
            bb.slices_other_beam_Sigma_23[1] = bb.slices_other_beam_Sigma_23[0]
            bb.slices_other_beam_Sigma_24[1] = bb.slices_other_beam_Sigma_24[0]
            bb.slices_other_beam_Sigma_33[1] = bb.slices_other_beam_Sigma_33[0]
            bb.slices_other_beam_Sigma_34[1] = bb.slices_other_beam_Sigma_34[0]
            bb.slices_other_beam_Sigma_44[1] = bb.slices_other_beam_Sigma_44[0]

            dtk_part = dtk.TestParticles(
                    p0c=6500e9,
                    x=-1.23e-3,
                    px = 50e-3,
                    y = 2e-3,
                    py = 27e-3,
                    sigma = 3.,
                    delta = 2e-4)

            part= xp.Particles(_context=context, **dtk_part.to_dict())

            part.name = 'beam1_bunch1'

            ret = bb.track(part)

            bb_dtk.track(dtk_part)

            for cc in 'x px y py zeta delta'.split():
                val_test = getattr(part, cc)[0]
                val_ref = getattr(dtk_part, cc)
                print('')
                print(f'ducktrack: {cc} = {val_ref:.12e}')
                print(f'xsuite:    {cc} = {val_test:.12e}')
                assert np.isclose(val_test, val_ref, rtol=0, atol=5e-12)
示例#7
0
def test_beambeam3d_old_interface():
    for context in xo.context.get_test_contexts():
        print(repr(context))

        # crossing plane
        alpha = 0.7

        # crossing angle
        phi = 0.8

        # separations
        x_bb_co=5e-3
        y_bb_co=-4e-3
        charge_slices=np.array([1e16, 2e16, 5e16])
        z_slices=np.array([-6., 0.2, 5.5])

        x_co = 2e-3
        px_co= 1e-6
        y_co=-3e-3
        py_co=-2e-6
        zeta_co=0.01
        delta_co=1.2e-3

        d_x=1.5e-3
        d_px=1.6e-6
        d_y=-1.7e-3
        d_py=-1.8e-6
        d_zeta=0.019
        d_delta=3e-4

        for ss in sigma_configurations():

            (Sig_11_0, Sig_12_0, Sig_13_0, Sig_14_0, Sig_22_0, Sig_23_0, Sig_24_0,
                    Sig_33_0, Sig_34_0, Sig_44_0) = ss

            Sig_11_0 = Sig_11_0 + np.zeros_like(charge_slices)
            Sig_12_0 = Sig_12_0 + np.zeros_like(charge_slices)
            Sig_13_0 = Sig_13_0 + np.zeros_like(charge_slices)
            Sig_14_0 = Sig_14_0 + np.zeros_like(charge_slices)
            Sig_22_0 = Sig_22_0 + np.zeros_like(charge_slices)
            Sig_23_0 = Sig_23_0 + np.zeros_like(charge_slices)
            Sig_24_0 = Sig_24_0 + np.zeros_like(charge_slices)
            Sig_33_0 = Sig_33_0 + np.zeros_like(charge_slices)
            Sig_34_0 = Sig_34_0 + np.zeros_like(charge_slices)
            Sig_44_0 = Sig_44_0 + np.zeros_like(charge_slices)

            print('------------------------')

            print(ss)

            bb_dtk = dtk.elements.BeamBeam6D(
                    phi=phi, alpha=alpha,
                    x_bb_co=x_bb_co,
                    y_bb_co=y_bb_co,
                    charge_slices=charge_slices,
                    zeta_slices=z_slices,
                    sigma_11=Sig_11_0[0],
                    sigma_12=Sig_12_0[0],
                    sigma_13=Sig_13_0[0],
                    sigma_14=Sig_14_0[0],
                    sigma_22=Sig_22_0[0],
                    sigma_23=Sig_23_0[0],
                    sigma_24=Sig_24_0[0],
                    sigma_33=Sig_33_0[0],
                    sigma_34=Sig_34_0[0],
                    sigma_44=Sig_44_0[0],
                    x_co=x_co,
                    px_co=px_co,
                    y_co=y_co,
                    py_co=py_co,
                    zeta_co=zeta_co,
                    delta_co=delta_co,
                    d_x=d_x,
                    d_px=d_px,
                    d_y=d_y,
                    d_py=d_py,
                    d_zeta=d_zeta,
                    d_delta=d_delta
                    )

            bb = xf.BeamBeamBiGaussian3D(old_interface=bb_dtk.to_dict(), _context=context)

            dtk_part = dtk.TestParticles(
                    p0c=6500e9,
                    x=-1.23e-3,
                    px = 50e-3,
                    y = 2e-3,
                    py = 27e-3,
                    sigma = 3.,
                    delta = 2e-4)

            part=xp.Particles(_context=context, **dtk_part.to_dict())

            bb.track(part)

            bb_dtk.track(dtk_part)

            part.move(_context=xo.ContextCpu())
            for cc in 'x px y py zeta delta'.split():
                val_test = getattr(part, cc)[0]
                val_ref = getattr(dtk_part, cc)
                print('')
                print(f'ducktrack: {cc} = {val_ref:.12e}')
                print(f'xsuite:    {cc} = {val_test:.12e}')
                assert np.isclose(val_test, val_ref, rtol=0, atol=5e-12)
示例#8
0
def test_beambeam3d_collective():
    for context in xo.context.get_test_contexts():

        if not isinstance(context, xo.ContextCpu):
            print(f'skipping test_beambeam3d_collective for context {context}')
            continue

        print(repr(context))

        # crossing plane
        alpha = 0.7

        # crossing angle
        phi = 0.8

        # separations
        x_bb_co=5e-3
        y_bb_co=-4e-3
        charge_slices=np.array([1e16, 2e16, 5e16])
        z_slices=np.array([-6., 0.2, 5.5])

        x_co = 2e-3
        px_co= 1e-6
        y_co=-3e-3
        py_co=-2e-6
        zeta_co=0.01
        delta_co=1.2e-3

        d_x=1.5e-3
        d_px=1.6e-6
        d_y=-1.7e-3
        d_py=-1.8e-6
        d_zeta=0.019
        d_delta=3e-4

        for ss in sigma_configurations():

            (Sig_11_0, Sig_12_0, Sig_13_0, Sig_14_0, Sig_22_0, Sig_23_0, Sig_24_0,
                    Sig_33_0, Sig_34_0, Sig_44_0) = ss

            Sig_11_0 = Sig_11_0 + np.zeros_like(charge_slices)
            Sig_12_0 = Sig_12_0 + np.zeros_like(charge_slices)
            Sig_13_0 = Sig_13_0 + np.zeros_like(charge_slices)
            Sig_14_0 = Sig_14_0 + np.zeros_like(charge_slices)
            Sig_22_0 = Sig_22_0 + np.zeros_like(charge_slices)
            Sig_23_0 = Sig_23_0 + np.zeros_like(charge_slices)
            Sig_24_0 = Sig_24_0 + np.zeros_like(charge_slices)
            Sig_33_0 = Sig_33_0 + np.zeros_like(charge_slices)
            Sig_34_0 = Sig_34_0 + np.zeros_like(charge_slices)
            Sig_44_0 = Sig_44_0 + np.zeros_like(charge_slices)

            print('------------------------')

            print(ss)

            bb_dtk = dtk.elements.BeamBeam6D(
                    phi=phi, alpha=alpha,
                    x_bb_co=x_bb_co,
                    y_bb_co=y_bb_co,
                    charge_slices=charge_slices,
                    zeta_slices=z_slices,
                    sigma_11=Sig_11_0[0],
                    sigma_12=Sig_12_0[0],
                    sigma_13=Sig_13_0[0],
                    sigma_14=Sig_14_0[0],
                    sigma_22=Sig_22_0[0],
                    sigma_23=Sig_23_0[0],
                    sigma_24=Sig_24_0[0],
                    sigma_33=Sig_33_0[0],
                    sigma_34=Sig_34_0[0],
                    sigma_44=Sig_44_0[0],
                    x_co=x_co,
                    px_co=px_co,
                    y_co=y_co,
                    py_co=py_co,
                    zeta_co=zeta_co,
                    delta_co=delta_co,
                    d_x=d_x,
                    d_px=d_px,
                    d_y=d_y,
                    d_py=d_py,
                    d_zeta=d_zeta,
                    d_delta=d_delta
                    )

            slicer = xf.TempSlicer(bin_edges = [-10, -5, 0, 5, 10])
            config_for_update=xf.ConfigForUpdateBeamBeamBiGaussian3D(
                pipeline_manager=None,
                element_name=None,
                partner_element_name=None,
                slicer=slicer,
                collision_schedule={'beam1_bunch1': 'beam2_bunch1',},
                update_every=None # Never updates (test in weakstrong mode)
                )


            bb = xf.BeamBeamBiGaussian3D(

                    _context=context,

                    config_for_update=config_for_update,

                    phi=phi, alpha=alpha, other_beam_q0=1,

                    slices_other_beam_num_particles=charge_slices[::-1],
                    slices_other_beam_zeta_center=z_slices[::-1],

                    slices_other_beam_Sigma_11=Sig_11_0,
                    slices_other_beam_Sigma_12=Sig_12_0,
                    slices_other_beam_Sigma_13=Sig_13_0,
                    slices_other_beam_Sigma_14=Sig_14_0,
                    slices_other_beam_Sigma_22=Sig_22_0,
                    slices_other_beam_Sigma_23=Sig_23_0,
                    slices_other_beam_Sigma_24=Sig_24_0,
                    slices_other_beam_Sigma_33=Sig_33_0,
                    slices_other_beam_Sigma_34=Sig_34_0,
                    slices_other_beam_Sigma_44=Sig_44_0,

                    ref_shift_x=x_co,
                    ref_shift_px=px_co,
                    ref_shift_y=y_co,
                    ref_shift_py=py_co,
                    ref_shift_zeta=zeta_co,
                    ref_shift_pzeta=delta_co,

                    other_beam_shift_x=x_bb_co,
                    other_beam_shift_y=y_bb_co,

                    post_subtract_x=d_x,
                    post_subtract_px=d_px,
                    post_subtract_y=d_y,
                    post_subtract_py=d_py,
                    post_subtract_zeta=d_zeta,
                    post_subtract_pzeta=d_delta,
            )

            dtk_part = dtk.TestParticles(
                    p0c=6500e9,
                    x=-1.23e-3,
                    px = 50e-3,
                    y = 2e-3,
                    py = 27e-3,
                    sigma = 3.,
                    delta = 2e-4)

            part= xp.Particles(_context=context, **dtk_part.to_dict())

            part.name = 'beam1_bunch1'

            ret = bb.track(part, _force_suspend=True)
            assert ret.on_hold
            ret = bb.track(part)
            assert ret is None

            bb_dtk.track(dtk_part)

            for cc in 'x px y py zeta delta'.split():
                val_test = getattr(part, cc)[0]
                val_ref = getattr(dtk_part, cc)
                print('')
                print(f'ducktrack: {cc} = {val_ref:.12e}')
                print(f'xsuite:    {cc} = {val_test:.12e}')
                assert np.isclose(val_test, val_ref, rtol=0, atol=5e-12)