77from xtrack ._temp .boris_and_solenoid_map .solenoid_field import SolenoidField
88
99
10- def test_boris_spatial ():
10+ def test_boris_spatial_solenoid_map ():
1111 delta = np .array ([0 , 4 ])
1212 p0 = xt .Particles (mass0 = xt .ELECTRON_MASS_EV , q0 = 1 ,
1313 energy0 = 45.6e9 / 1000 ,
@@ -114,4 +114,49 @@ def test_boris_spatial():
114114 xo .assert_allclose (ax_ref [i_part , :], mon .ax [i_part , :],
115115 rtol = 0 , atol = np .max (np .abs (ax_ref )* 3e-2 ))
116116 xo .assert_allclose (ay_ref [i_part , :], mon .ay [i_part , :],
117- rtol = 0 , atol = np .max (np .abs (ay_ref )* 3e-2 ))
117+ rtol = 0 , atol = np .max (np .abs (ay_ref )* 3e-2 ))
118+
119+ def test_boris_spatial_drift ():
120+ def zero_field (x , y , z ):
121+ return (0 * x , 0 * y , 0 * z )
122+
123+ integrator = xt .BorisSpatialIntegrator (fieldmap_callable = zero_field ,
124+ s_start = 10 ,
125+ s_end = 20 ,
126+ n_steps = 15000 )
127+
128+ drift = xt .Drift (length = 10 , model = 'exact' )
129+
130+ p0 = xt .Particles ('proton' ,
131+ x = [1e-2 , - 1e-2 ], px = [15e-3 , 0 ], delta = [0 , 2 ], p0c = 1e9 , zeta = 1 )
132+
133+ p_integ = p0 .copy ()
134+ integrator .track (p_integ )
135+
136+ p_drift = p0 .copy ()
137+ drift .track (p_drift )
138+
139+ xo .assert_allclose (p_integ .x , p_drift .x , rtol = 0 , atol = 1e-10 )
140+ xo .assert_allclose (p_integ .px , p_drift .px , rtol = 0 , atol = 1e-10 )
141+ xo .assert_allclose (p_integ .y , p_drift .y , rtol = 0 , atol = 1e-10 )
142+ xo .assert_allclose (p_integ .py , p_drift .py , rtol = 0 , atol = 1e-10 )
143+ xo .assert_allclose (p_integ .s , p_drift .s , rtol = 0 , atol = 1e-10 )
144+ xo .assert_allclose (p_integ .delta , p_drift .delta , rtol = 0 , atol = 1e-10 )
145+ xo .assert_allclose (p_integ .zeta , p_drift .zeta , rtol = 0 , atol = 1e-10 )
146+
147+ # Check behavior with lost particles
148+ p0 = xt .Particles ('proton' ,
149+ x = [1e-2 , - 1e-2 ], px = [15e-3 , 0 ], delta = [0 , 2 ], p0c = 1e9 , zeta = 1 ,
150+ state = [1 , - 1 ])
151+
152+ p_integ = p0 .copy ()
153+ integrator .track (p_integ )
154+ p_drift = p0 .copy ()
155+ drift .track (p_drift )
156+
157+ xo .assert_allclose (p_integ .x , p_drift .x , rtol = 0 , atol = 1e-10 )
158+ xo .assert_allclose (p_integ .px , p_drift .px , rtol = 0 , atol = 1e-10 )
159+ xo .assert_allclose (p_integ .y , p_drift .y , rtol = 0 , atol = 1e-10 )
160+ xo .assert_allclose (p_integ .py , p_drift .py , rtol = 0 , atol = 1e-10 )
161+ xo .assert_allclose (p_integ .s , p_drift .s , rtol = 0 , atol = 1e-10 )
162+ xo .assert_allclose (p_integ .delta , p_drift .delta , rtol = 0 , atol = 1e-10 )
0 commit comments