Skip to content

Commit

Permalink
A test
Browse files Browse the repository at this point in the history
  • Loading branch information
giadarol committed Oct 20, 2022
1 parent 2960f97 commit 6a012b0
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 2 deletions.
113 changes: 113 additions & 0 deletions tests/test_beambeam3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,119 @@ def test_beambeam3d():
print(f'after bb off: {cc} = {val_test:.12e}')
assert np.allclose(val_test, val_ref, rtol=0, atol=1e-14)


def test_beambeam3d_gx_gy_singularity():
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

# crossing angle
phi = 0

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

x_co = 0
px_co = 0
y_co = 0
py_co = 0
zeta_co = 0
delta_co = 0

d_x=0
d_px=0
d_y=-0
d_py=0
d_zeta=0
d_delta=0

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)

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]

part= xp.Particles(_context=context, p0c=6500e9)

part.name = 'beam1_bunch1'

bb.track(part)

part.move(xo.context_default)
assert not np.isnan(part.px[0])
assert not np.isnan(part.py[0])



def test_beambeam3d_collective():
for context in xo.context.get_test_contexts():

Expand Down
2 changes: 0 additions & 2 deletions xfields/fieldmaps/bigaussian_src/bigaussian.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ void get_Ex_Ey_gauss(
double Gx, Gy;

if (fabs(sigma_x-sigma_y) < min_sigma_diff){


const double sigma = 0.5*(sigma_x+sigma_y);
if ((x*x+y*y)<1e-14){
Gx = 1./(8*PI*EPSILON_0*sigma*sigma);
Expand Down

0 comments on commit 6a012b0

Please sign in to comment.