Skip to content

Commit b4ef41c

Browse files
committed
Increased slightly tolerances, working on radiation in multipole
1 parent 6677cb9 commit b4ef41c

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

tests/test_full_rings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def test_full_rings(element_by_element=False):
2323
]
2424

2525
tolerances_10_turns = [
26-
(1e-9, 1e-11),
27-
(1e-9, 1e-11),
26+
(1e-9, 3e-11),
27+
(1e-9, 3e-11),
2828
(2e-8, 7e-9)]
2929

3030
for icase, fname_line_particles in enumerate(test_fnames):

xtrack/beam_elements/elements.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ class Multipole(BeamElement):
142142
'length': xo.Float64,
143143
'hxl': xo.Float64,
144144
'hyl': xo.Float64,
145+
'radiation_flag': xo.Int64,
145146
'bal': xo.Float64[:],
146147
}
147148

@@ -209,7 +210,8 @@ def ksl(self):
209210
#return self.bal[idx + 1] * factorial(idx // 2, exact=True)
210211

211212
Multipole.XoStruct.extra_sources = [
212-
_pkg_root.joinpath('headers/rng.h'),
213+
_pkg_root.joinpath('random_number_generator/rng_src/base_rng.h'),
214+
_pkg_root.joinpath('random_number_generator/rng_src/local_particle_rng.h'),
213215
_pkg_root.joinpath('beam_elements/elements_src/multipole.h')]
214216

215217

xtrack/beam_elements/elements_src/multipole.h

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
/*gpufun*/
55
void Multipole_track_local_particle(MultipoleData el, LocalParticle* part0){
66

7+
int64_t radiation_flag = MultipoleData_get_radiation_flag(el);
8+
79
//start_per_particle_block (part0->part)
810
int64_t order = MultipoleData_get_order(el);
911
int64_t index_x = 2 * order;
@@ -36,6 +38,7 @@ void Multipole_track_local_particle(MultipoleData el, LocalParticle* part0){
3638

3739
// compute the average energy loss by synchrotron radiation
3840
double const length = MultipoleData_get_length(el); // m
41+
//if (radiation_flag>0 && length!=0.0) {
3942
if (length!=0.0) {
4043
double const h = hypot(dpx, dpy) / length; // 1/m, 1/rho, curvature
4144
double const p0c = LocalParticle_get_p0c(part); // eV
@@ -47,27 +50,14 @@ void Multipole_track_local_particle(MultipoleData el, LocalParticle* part0){
4750
double const q0 = LocalParticle_get_q0(part); // e
4851
// e^2 / 4 pi epsilon0 eV = (1 / 694461541.7756249) m
4952
double const classical_radius = q0*q0 / m0 / 694461541.7756249; // m, classical electromagnetic radius
50-
double const eloss = 0 * 2.0 / 3.0 * classical_radius*length * beta_gamma*beta_gamma*beta_gamma * h*h * energy; // eV
53+
double const eloss = 2.0 / 3.0 * classical_radius*length * beta_gamma*beta_gamma*beta_gamma * h*h * energy; // eV
5154

5255
// apply the energy kick
53-
LocalParticle_add_to_energy(part, -eloss);
56+
//LocalParticle_add_to_energy(part, -eloss);
57+
LocalParticle_add_to_energy(part, 0.);
5458

55-
// random number generator test
56-
uint32_t s1, s2, s3;
57-
rng_set(&s1, &s2, &s3, 1234);
59+
double r = LocalParticle_generate_random_double(part);
5860

59-
LocalParticle_set___rng_s1(part, s1);
60-
LocalParticle_set___rng_s2(part, s2);
61-
LocalParticle_set___rng_s3(part, s3);
62-
63-
/* uint32_t */ s1 = LocalParticle_get___rng_s1(part);
64-
/* uint32_t */ s2 = LocalParticle_get___rng_s2(part);
65-
/* uint32_t */ s3 = LocalParticle_get___rng_s3(part);
66-
67-
for (int i=0; i<3; i++) {
68-
double r = rng_get(&s1, &s2, &s3);
69-
printf("rnd = %g\n", r);
70-
}
7161
}
7262

7363
if( ( hxl > 0) || ( hyl > 0) || ( hxl < 0 ) || ( hyl < 0 ) )

0 commit comments

Comments
 (0)