xcoll 0.5.3__py3-none-any.whl → 0.5.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xcoll might be problematic. Click here for more details.
- xcoll/__init__.py +2 -2
- xcoll/_manager.py +22 -0
- xcoll/beam_elements/__init__.py +1 -1
- xcoll/beam_elements/absorber.py +1 -1
- xcoll/beam_elements/base.py +1 -1
- xcoll/beam_elements/blowup.py +1 -1
- xcoll/beam_elements/elements_src/black_absorber.h +1 -1
- xcoll/beam_elements/elements_src/black_crystal.h +1 -1
- xcoll/beam_elements/elements_src/blowup.h +1 -1
- xcoll/beam_elements/elements_src/emittance_monitor.h +1 -1
- xcoll/beam_elements/elements_src/everest_block.h +8 -18
- xcoll/beam_elements/elements_src/everest_collimator.h +7 -18
- xcoll/beam_elements/elements_src/everest_crystal.h +18 -24
- xcoll/beam_elements/everest.py +7 -2
- xcoll/beam_elements/monitor.py +1 -1
- xcoll/colldb.py +1 -1
- xcoll/general.py +2 -2
- xcoll/headers/checks.h +1 -1
- xcoll/headers/particle_states.h +1 -1
- xcoll/initial_distribution.py +32 -20
- xcoll/install.py +1 -1
- xcoll/interaction_record/interaction_record.py +1 -1
- xcoll/interaction_record/interaction_record_src/interaction_record.h +1 -1
- xcoll/interaction_record/interaction_types.py +1 -1
- xcoll/line_tools.py +113 -61
- xcoll/lossmap.py +4 -4
- xcoll/rf_sweep.py +1 -1
- xcoll/scattering_routines/everest/__init__.py +1 -1
- xcoll/scattering_routines/everest/amorphous.h +11 -9
- xcoll/scattering_routines/everest/channeling.h +4 -4
- xcoll/scattering_routines/everest/constants.h +1 -1
- xcoll/scattering_routines/everest/crystal_parameters.h +36 -16
- xcoll/scattering_routines/everest/everest.h +10 -2
- xcoll/scattering_routines/everest/everest.py +1 -1
- xcoll/scattering_routines/everest/jaw.h +1 -2
- xcoll/scattering_routines/everest/materials.py +1 -1
- xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +9 -8
- xcoll/scattering_routines/everest/nuclear_interaction.h +1 -1
- xcoll/scattering_routines/everest/properties.h +1 -1
- xcoll/scattering_routines/geometry/__init__.py +1 -1
- xcoll/scattering_routines/geometry/collimator_geometry.h +1 -1
- xcoll/scattering_routines/geometry/crystal_geometry.h +1 -1
- xcoll/scattering_routines/geometry/geometry.py +1 -1
- xcoll/scattering_routines/geometry/get_s.h +1 -1
- xcoll/scattering_routines/geometry/methods.h +1 -1
- xcoll/scattering_routines/geometry/objects.h +1 -1
- xcoll/scattering_routines/geometry/rotation.h +1 -1
- xcoll/scattering_routines/geometry/segments.h +1 -1
- xcoll/scattering_routines/geometry/sort.h +1 -1
- xcoll/scattering_routines/geometry/temp.c +953 -0
- {xcoll-0.5.3.dist-info → xcoll-0.5.5.dist-info}/METADATA +1 -1
- {xcoll-0.5.3.dist-info → xcoll-0.5.5.dist-info}/RECORD +55 -54
- xcoll/manager.py +0 -10
- {xcoll-0.5.3.dist-info → xcoll-0.5.5.dist-info}/LICENSE +0 -0
- {xcoll-0.5.3.dist-info → xcoll-0.5.5.dist-info}/NOTICE +0 -0
- {xcoll-0.5.3.dist-info → xcoll-0.5.5.dist-info}/WHEEL +0 -0
xcoll/line_tools.py
CHANGED
|
@@ -1,82 +1,134 @@
|
|
|
1
1
|
# copyright ############################### #
|
|
2
|
-
# This file is part of the Xcoll
|
|
2
|
+
# This file is part of the Xcoll package. #
|
|
3
3
|
# Copyright (c) CERN, 2024. #
|
|
4
4
|
# ######################################### #
|
|
5
5
|
|
|
6
6
|
import numpy as np
|
|
7
|
+
import warnings
|
|
8
|
+
warnings.simplefilter("always")
|
|
9
|
+
|
|
7
10
|
import xtrack as xt
|
|
8
11
|
|
|
9
12
|
from .beam_elements import element_classes, _all_collimator_classes
|
|
10
13
|
|
|
11
14
|
|
|
15
|
+
class XcollCollimatorAPI:
|
|
16
|
+
def __init__(self, line):
|
|
17
|
+
self._line = line
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def line(self):
|
|
21
|
+
return self._line
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def get_optics_at(self, names, *, twiss=None):
|
|
25
|
+
if twiss is None:
|
|
26
|
+
if not self.line._has_valid_tracker():
|
|
27
|
+
raise Exception("Please build the tracker before computing the optics for the openings!")
|
|
28
|
+
twiss = self.line.twiss()
|
|
29
|
+
if not hasattr(names, '__iter__') and not isinstance(names, str):
|
|
30
|
+
names = [names]
|
|
31
|
+
coll_entry_indices = twiss.rows.indices[names]
|
|
32
|
+
tw_entry = twiss.rows[coll_entry_indices]
|
|
33
|
+
tw_exit = twiss.rows[coll_entry_indices+1]
|
|
34
|
+
tw_exit.name = tw_entry.name
|
|
35
|
+
return tw_entry, tw_exit
|
|
36
|
+
|
|
37
|
+
def assign_optics(self, nemitt_x=None, nemitt_y=None, twiss=None):
|
|
38
|
+
if not self.line._has_valid_tracker():
|
|
39
|
+
raise Exception("Please build tracker before setting the openings!")
|
|
40
|
+
names = self.line.get_elements_of_type(_all_collimator_classes)[1]
|
|
41
|
+
tw_upstream, tw_downstream = self.get_optics_at(names, twiss=twiss)
|
|
42
|
+
beta_gamma_rel = self.line.particle_ref._xobject.gamma0[0]*self.line.particle_ref._xobject.beta0[0]
|
|
43
|
+
for coll in names:
|
|
44
|
+
self.line[coll].assign_optics(name=coll, nemitt_x=nemitt_x, nemitt_y=nemitt_x, twiss_upstream=tw_upstream,
|
|
45
|
+
twiss_downstream=tw_downstream, beta_gamma_rel=beta_gamma_rel)
|
|
46
|
+
|
|
47
|
+
def open(self, names=None):
|
|
48
|
+
if names is None:
|
|
49
|
+
names = self.line.get_elements_of_type(_all_collimator_classes)[1]
|
|
50
|
+
if len(names) == 0:
|
|
51
|
+
print("No collimators found in line.")
|
|
52
|
+
else:
|
|
53
|
+
for coll in names:
|
|
54
|
+
self.line[coll].open_jaws(keep_tilts=False)
|
|
55
|
+
self.line[coll].gap = None
|
|
56
|
+
|
|
57
|
+
def to_parking(self, names=None):
|
|
58
|
+
if names is None:
|
|
59
|
+
names = self.line.get_elements_of_type(_all_collimator_classes)[1]
|
|
60
|
+
if len(names) == 0:
|
|
61
|
+
print("No collimators found in line.")
|
|
62
|
+
else:
|
|
63
|
+
raise NotImplementedError("Need to move this to new type manager or so.")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class XcollScatteringAPI:
|
|
67
|
+
def __init__(self, line):
|
|
68
|
+
self._line = line
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def line(self):
|
|
72
|
+
return self._line
|
|
73
|
+
|
|
74
|
+
def enable(self):
|
|
75
|
+
elements = self.line.get_elements_of_type(element_classes)[0]
|
|
76
|
+
if len(elements) == 0:
|
|
77
|
+
print("No xcoll elements found in line.")
|
|
78
|
+
else:
|
|
79
|
+
nemitt_x = None
|
|
80
|
+
nemitt_y = None
|
|
81
|
+
for el in elements:
|
|
82
|
+
if hasattr(el, 'optics') and el.optics is not None:
|
|
83
|
+
if nemitt_x is None:
|
|
84
|
+
nemitt_x = el.nemitt_x
|
|
85
|
+
if nemitt_y is None:
|
|
86
|
+
nemitt_y = el.nemitt_y
|
|
87
|
+
if not np.isclose(el.nemitt_x, nemitt_x) \
|
|
88
|
+
or not np.isclose(el.nemitt_x, nemitt_x):
|
|
89
|
+
raise ValueError("Not all collimators have the same "
|
|
90
|
+
+ "emittance. This is not supported.")
|
|
91
|
+
if hasattr(el, 'enable_scattering'):
|
|
92
|
+
el.enable_scattering()
|
|
93
|
+
|
|
94
|
+
def disable(self):
|
|
95
|
+
elements = self.line.get_elements_of_type(element_classes)[0]
|
|
96
|
+
if len(elements) == 0:
|
|
97
|
+
print("No xcoll elements found in line.")
|
|
98
|
+
else:
|
|
99
|
+
for el in elements:
|
|
100
|
+
if hasattr(el, 'disable_scattering'):
|
|
101
|
+
el.disable_scattering()
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
12
106
|
def assign_optics_to_collimators(line, nemitt_x=None, nemitt_y=None, twiss=None):
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
tw_upstream, tw_downstream = get_optics_at(names, twiss=twiss, line=line)
|
|
17
|
-
beta_gamma_rel = line.particle_ref._xobject.gamma0[0]*line.particle_ref._xobject.beta0[0]
|
|
18
|
-
for coll in names:
|
|
19
|
-
line[coll].assign_optics(name=coll, nemitt_x=nemitt_x, nemitt_y=nemitt_x, twiss_upstream=tw_upstream,
|
|
20
|
-
twiss_downstream=tw_downstream, beta_gamma_rel=beta_gamma_rel)
|
|
107
|
+
warnings.warn("The function xcoll.assign_optics_to_collimators() is deprecated and will be "
|
|
108
|
+
+ "removed in the future. Please use line.scattering.assign_optics() instead.", DeprecationWarning)
|
|
109
|
+
line.collimators.assign_optics(nemitt_x=nemitt_x, nemitt_y=nemitt_y, twiss=twiss)
|
|
21
110
|
|
|
22
111
|
def get_optics_at(names, *, twiss=None, line=None):
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
twiss = line.twiss()
|
|
27
|
-
if not hasattr(names, '__iter__') and not isinstance(names, str):
|
|
28
|
-
names = [names]
|
|
29
|
-
coll_entry_indices = twiss.rows.indices[names]
|
|
30
|
-
tw_entry = twiss.rows[coll_entry_indices]
|
|
31
|
-
tw_exit = twiss.rows[coll_entry_indices+1]
|
|
32
|
-
tw_exit.name = tw_entry.name
|
|
33
|
-
return tw_entry, tw_exit
|
|
34
|
-
|
|
112
|
+
warnings.warn("The function xcoll.get_optics_at() is deprecated and will be "
|
|
113
|
+
+ "removed in the future. Please use line.scattering.get_optics_at() instead.", DeprecationWarning)
|
|
114
|
+
return line.collimators.get_optics_at(names=names, twiss=twiss)
|
|
35
115
|
|
|
36
116
|
def open_collimators(line, names=None):
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
print("No collimators found in line.")
|
|
41
|
-
else:
|
|
42
|
-
for coll in names:
|
|
43
|
-
line[coll].open_jaws(keep_tilts=False)
|
|
44
|
-
line[coll].gap = None
|
|
117
|
+
warnings.warn("The function xcoll.open_collimators() is deprecated and will be "
|
|
118
|
+
+ "removed in the future. Please use line.scattering.open_collimators() instead.", DeprecationWarning)
|
|
119
|
+
line.collimators.open(names=names)
|
|
45
120
|
|
|
46
121
|
def send_to_parking(line, names=None):
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
print("No collimators found in line.")
|
|
51
|
-
else:
|
|
52
|
-
raise NotImplementedError("Need to move this to new type manager or so.")
|
|
53
|
-
|
|
122
|
+
warnings.warn("The function xcoll.send_to_parking() is deprecated and will be "
|
|
123
|
+
+ "removed in the future. Please use line.scattering.send_to_parking() instead.", DeprecationWarning)
|
|
124
|
+
line.collimators.to_parking(names=names)
|
|
54
125
|
|
|
55
126
|
def enable_scattering(line):
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
else:
|
|
60
|
-
nemitt_x = None
|
|
61
|
-
nemitt_y = None
|
|
62
|
-
for el in elements:
|
|
63
|
-
if hasattr(el, 'optics') and el.optics is not None:
|
|
64
|
-
if nemitt_x is None:
|
|
65
|
-
nemitt_x = el.nemitt_x
|
|
66
|
-
if nemitt_y is None:
|
|
67
|
-
nemitt_y = el.nemitt_y
|
|
68
|
-
if not np.isclose(el.nemitt_x, nemitt_x) \
|
|
69
|
-
or not np.isclose(el.nemitt_x, nemitt_x):
|
|
70
|
-
raise ValueError("Not all collimators have the same "
|
|
71
|
-
+ "emittance. This is not supported.")
|
|
72
|
-
if hasattr(el, 'enable_scattering'):
|
|
73
|
-
el.enable_scattering()
|
|
127
|
+
warnings.warn("The function xcoll.enable_scattering() is deprecated and will be "
|
|
128
|
+
+ "removed in the future. Please use line.scattering.enable() instead.", DeprecationWarning)
|
|
129
|
+
line.scattering.enable()
|
|
74
130
|
|
|
75
131
|
def disable_scattering(line):
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
else:
|
|
80
|
-
for el in elements:
|
|
81
|
-
if hasattr(el, 'disable_scattering'):
|
|
82
|
-
el.disable_scattering()
|
|
132
|
+
warnings.warn("The function xcoll.disable_scattering() is deprecated and will be "
|
|
133
|
+
+ "removed in the future. Please use line.scattering.disable() instead.", DeprecationWarning)
|
|
134
|
+
line.scattering.disable()
|
xcoll/lossmap.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# copyright ############################### #
|
|
2
|
-
# This file is part of the Xcoll
|
|
2
|
+
# This file is part of the Xcoll package. #
|
|
3
3
|
# Copyright (c) CERN, 2024. #
|
|
4
4
|
# ######################################### #
|
|
5
5
|
|
|
@@ -160,14 +160,14 @@ class LossMap:
|
|
|
160
160
|
coll_mask = (self._part.state <= -330) & (self._part.state >= -340)
|
|
161
161
|
coll_losses = np.array([self._line.element_names[i]
|
|
162
162
|
for i in self._part.at_element[coll_mask]])
|
|
163
|
-
coll_lengths = [self._line[j].length for j in collimator_names]
|
|
163
|
+
coll_lengths = [self._line[j].length for j in collimator_names]
|
|
164
164
|
coll_pos = [(self._line.get_s_position(i) + self._line[i].length/2)
|
|
165
165
|
for i in collimator_names]
|
|
166
166
|
|
|
167
167
|
if self._line_is_reversed:
|
|
168
168
|
coll_pos = [self._machine_length - s for s in coll_pos]
|
|
169
169
|
|
|
170
|
-
coll_types = [self._line[i].__class__.__name__ for i in collimator_names]
|
|
170
|
+
coll_types = [self._line[i].__class__.__name__ for i in collimator_names]
|
|
171
171
|
coll_weights = self._weights[coll_mask]
|
|
172
172
|
nabs = [coll_weights[coll_losses == j].sum() for j in collimator_names]
|
|
173
173
|
|
|
@@ -198,7 +198,7 @@ class LossMap:
|
|
|
198
198
|
# Create output arrays
|
|
199
199
|
aper_pos = np.unique(aper_s)
|
|
200
200
|
aper_weights = self._weights[aper_mask]
|
|
201
|
-
aper_nabs = [aper_weights[aper_s == j].sum() for j in aper_pos]
|
|
201
|
+
aper_nabs = [aper_weights[aper_s == j].sum() for j in aper_pos]
|
|
202
202
|
aper_names = [name_dict[ss] for ss in aper_pos]
|
|
203
203
|
|
|
204
204
|
aper_energy = 0
|
xcoll/rf_sweep.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// copyright ############################### #
|
|
2
|
-
// This file is part of the Xcoll
|
|
2
|
+
// This file is part of the Xcoll package. #
|
|
3
3
|
// Copyright (c) CERN, 2023. #
|
|
4
4
|
// ######################################### #
|
|
5
5
|
|
|
@@ -99,7 +99,7 @@ double amorphous_transport(EverestData restrict everest, LocalParticle* part, do
|
|
|
99
99
|
double Channel(EverestData restrict everest, LocalParticle* part, CrystalGeometry restrict cg, double pc, double length);
|
|
100
100
|
|
|
101
101
|
/*gpufun*/
|
|
102
|
-
double Amorphous(EverestData restrict everest, LocalParticle* part, CrystalGeometry restrict cg, double pc, double length) {
|
|
102
|
+
double Amorphous(EverestData restrict everest, LocalParticle* part, CrystalGeometry restrict cg, double pc, double length, int8_t allow_VI) {
|
|
103
103
|
|
|
104
104
|
if (LocalParticle_get_state(part) < 1){
|
|
105
105
|
// Do nothing if already absorbed
|
|
@@ -159,7 +159,7 @@ double Amorphous(EverestData restrict everest, LocalParticle* part, CrystalGeome
|
|
|
159
159
|
// ------------------------------------------------------------------------
|
|
160
160
|
// Compare the 3 lengths: the first one encountered is what will be applied
|
|
161
161
|
// ------------------------------------------------------------------------
|
|
162
|
-
if (length_VI <= fmin(length_nucl, length_exit)){
|
|
162
|
+
if (length_VI <= fmin(length_nucl, length_exit) && allow_VI == 1){
|
|
163
163
|
// MCS to volume interaction
|
|
164
164
|
pc = amorphous_transport(everest, part, pc, length_VI, 0);
|
|
165
165
|
#ifdef XCOLL_REFINE_ENERGY
|
|
@@ -170,7 +170,7 @@ double Amorphous(EverestData restrict everest, LocalParticle* part, CrystalGeome
|
|
|
170
170
|
// Volume Reflection
|
|
171
171
|
volume_reflection(everest, part, 0);
|
|
172
172
|
// We call the main Amorphous function for the leftover
|
|
173
|
-
pc = Amorphous(everest, part, cg, pc, length - length_VI);
|
|
173
|
+
pc = Amorphous(everest, part, cg, pc, length - length_VI, 0);
|
|
174
174
|
|
|
175
175
|
} else {
|
|
176
176
|
// Volume Capture
|
|
@@ -180,7 +180,7 @@ double Amorphous(EverestData restrict everest, LocalParticle* part, CrystalGeome
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
#ifdef XCOLL_TRANSITION
|
|
183
|
-
} else if (length_VR_trans <= fmin(length_nucl, length_exit)){
|
|
183
|
+
} else if (length_VR_trans <= fmin(length_nucl, length_exit) && allow_VI == 1){
|
|
184
184
|
// Transition region between VR and AM for t_P < xp - tI < t_P + 2t_c
|
|
185
185
|
#ifdef XCOLL_REFINE_ENERGY
|
|
186
186
|
calculate_critical_angle(everest, part, cg, pc);
|
|
@@ -193,10 +193,12 @@ double Amorphous(EverestData restrict everest, LocalParticle* part, CrystalGeome
|
|
|
193
193
|
// We are on the VR side
|
|
194
194
|
pc = amorphous_transport(everest, part, pc, length_VR_trans, 0);
|
|
195
195
|
volume_reflection(everest, part, XC_VOLUME_REFLECTION_TRANS_MCS);
|
|
196
|
-
pc =
|
|
196
|
+
pc = Amorphous(everest, part, cg, pc, length - length_VR_trans, 0);
|
|
197
197
|
} else {
|
|
198
198
|
// We are on the AM side
|
|
199
|
-
|
|
199
|
+
// if (sc) InteractionRecordData_log(record, record_index, part, XC_MULTIPLE_COULOMB_TRANS_VR);
|
|
200
|
+
pc = amorphous_transport(everest, part, pc, length_VR_trans, XC_MULTIPLE_COULOMB_TRANS_VR);
|
|
201
|
+
pc = Amorphous(everest, part, cg, pc, length - length_VR_trans, 0);
|
|
200
202
|
}
|
|
201
203
|
#endif
|
|
202
204
|
|
|
@@ -209,7 +211,7 @@ double Amorphous(EverestData restrict everest, LocalParticle* part, CrystalGeome
|
|
|
209
211
|
LocalParticle_set_state(part, XC_LOST_ON_EVEREST_CRYSTAL);
|
|
210
212
|
} else {
|
|
211
213
|
// We call the main Amorphous function for the leftover
|
|
212
|
-
pc = Amorphous(everest, part, cg, pc, length - length_nucl);
|
|
214
|
+
pc = Amorphous(everest, part, cg, pc, length - length_nucl, 1);
|
|
213
215
|
}
|
|
214
216
|
|
|
215
217
|
} else {
|
|
@@ -222,7 +224,7 @@ double Amorphous(EverestData restrict everest, LocalParticle* part, CrystalGeome
|
|
|
222
224
|
// We drift until re-entry
|
|
223
225
|
Drift_single_particle_4d(part, s4 - exit_point);
|
|
224
226
|
// We call the main Amorphous function for the leftover
|
|
225
|
-
pc = Amorphous(everest, part, cg, pc, length - length_exit - s4 + exit_point);
|
|
227
|
+
pc = Amorphous(everest, part, cg, pc, length - length_exit - s4 + exit_point, 1);
|
|
226
228
|
}
|
|
227
229
|
}
|
|
228
230
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// copyright ############################### #
|
|
2
|
-
// This file is part of the Xcoll
|
|
2
|
+
// This file is part of the Xcoll package. #
|
|
3
3
|
// Copyright (c) CERN, 2023. #
|
|
4
4
|
// ######################################### #
|
|
5
5
|
|
|
@@ -156,7 +156,7 @@ double Channel(EverestData restrict everest, LocalParticle* part, CrystalGeometr
|
|
|
156
156
|
#endif
|
|
157
157
|
volume_reflection(everest, part, XC_VOLUME_REFLECTION_TRANS_CH);
|
|
158
158
|
#endif
|
|
159
|
-
pc = Amorphous(everest, part, cg, pc, length);
|
|
159
|
+
pc = Amorphous(everest, part, cg, pc, length, 1);
|
|
160
160
|
|
|
161
161
|
} else {
|
|
162
162
|
// CHANNEL
|
|
@@ -207,7 +207,7 @@ double Channel(EverestData restrict everest, LocalParticle* part, CrystalGeometr
|
|
|
207
207
|
pc = result_chan[1];
|
|
208
208
|
free(result_chan);
|
|
209
209
|
if (sc) InteractionRecordData_log(record, record_index, part, XC_DECHANNELING);
|
|
210
|
-
pc = Amorphous(everest, part, cg, pc, length - channeled_length);
|
|
210
|
+
pc = Amorphous(everest, part, cg, pc, length - channeled_length, 1);
|
|
211
211
|
|
|
212
212
|
} else {
|
|
213
213
|
// Channel up to L_nucl, then scatter, then amorphous
|
|
@@ -229,7 +229,7 @@ double Channel(EverestData restrict everest, LocalParticle* part, CrystalGeometr
|
|
|
229
229
|
#ifndef XCOLL_REFINE_ENERGY
|
|
230
230
|
calculate_scattering(everest, pc);
|
|
231
231
|
#endif
|
|
232
|
-
pc = Amorphous(everest, part, cg, pc, length - channeled_length);
|
|
232
|
+
pc = Amorphous(everest, part, cg, pc, length - channeled_length, 1);
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// copyright ############################### #
|
|
2
|
-
// This file is part of the Xcoll
|
|
2
|
+
// This file is part of the Xcoll package. #
|
|
3
3
|
// Copyright (c) CERN, 2023. #
|
|
4
4
|
// ######################################### #
|
|
5
5
|
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
/*gpufun*/
|
|
14
|
-
void calculate_initial_angle(EverestData restrict everest, LocalParticle* part, CrystalGeometry restrict cg)
|
|
14
|
+
void calculate_initial_angle(EverestData restrict everest, LocalParticle* part, CrystalGeometry restrict cg){
|
|
15
15
|
double R = cg->bending_radius;
|
|
16
16
|
double s = LocalParticle_get_s(part);
|
|
17
17
|
double x = LocalParticle_get_x(part);
|
|
@@ -24,7 +24,7 @@ void calculate_initial_angle(EverestData restrict everest, LocalParticle* part,
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
/*gpufun*/
|
|
27
|
-
void calculate_opening_angle(EverestData restrict everest, LocalParticle* part, CrystalGeometry restrict cg)
|
|
27
|
+
void calculate_opening_angle(EverestData restrict everest, LocalParticle* part, CrystalGeometry restrict cg){
|
|
28
28
|
double t = cg->bending_angle;
|
|
29
29
|
double xd = cg->width;
|
|
30
30
|
double R = cg->bending_radius;
|
|
@@ -76,27 +76,47 @@ void calculate_opening_angle(EverestData restrict everest, LocalParticle* part,
|
|
|
76
76
|
|
|
77
77
|
|
|
78
78
|
/*gpufun*/
|
|
79
|
-
|
|
79
|
+
double _critical_angle0(EverestCollData restrict coll, double pc){
|
|
80
80
|
// Define typical angles/probabilities for orientation 110
|
|
81
|
-
double eum =
|
|
82
|
-
double
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
double Rcrit = pc/(2.e-6*sqrt(eta)*eum)*ai; // Critical curvature radius [m] // pc is actually beta pc
|
|
81
|
+
double eum = coll->eum;
|
|
82
|
+
double eta = coll->eta;
|
|
83
|
+
return sqrt(2.e-9*eta*eum/pc); // Critical angle (rad) for straight crystals // pc is actually beta pc
|
|
84
|
+
}
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
/*gpufun*/
|
|
87
|
+
double _critical_radius(EverestCollData restrict coll, double pc){
|
|
88
|
+
// Define typical angles/probabilities for orientation 110
|
|
89
|
+
double eum = coll->eum;
|
|
90
|
+
double ai = coll->ai;
|
|
91
|
+
double eta = coll->eta;
|
|
92
|
+
return pc/(2.e-6*sqrt(eta)*eum)*ai; // Critical curvature radius [m] // pc is actually beta pc
|
|
93
|
+
}
|
|
91
94
|
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
/*gpufun*/
|
|
96
|
+
double _critical_angle(EverestCollData restrict coll, double t_c0, double Rc_over_R){
|
|
97
|
+
double t_c = 0;
|
|
98
|
+
if (Rc_over_R <= 1.) {
|
|
99
|
+
// Otherwise no channeling possible
|
|
100
|
+
t_c = t_c0*(1 - Rc_over_R); // Critical angle for curved crystal
|
|
101
|
+
if (coll->orient == 2) {
|
|
102
|
+
t_c *= 0.98;
|
|
103
|
+
}
|
|
94
104
|
}
|
|
105
|
+
return t_c;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/*gpufun*/
|
|
109
|
+
void calculate_critical_angle(EverestData restrict everest, LocalParticle* part, CrystalGeometry restrict cg, double pc){
|
|
110
|
+
// Define typical angles/probabilities for orientation 110
|
|
111
|
+
everest->t_c0 = _critical_angle0(everest->coll, pc);
|
|
112
|
+
double Rcrit = _critical_radius(everest->coll, pc);
|
|
113
|
+
everest->Rc_over_R = Rcrit / fabs(cg->bending_radius);
|
|
114
|
+
everest->t_c = _critical_angle(everest->coll, everest->t_c0, everest->Rc_over_R);
|
|
95
115
|
}
|
|
96
116
|
|
|
97
117
|
|
|
98
118
|
/*gpufun*/
|
|
99
|
-
void calculate_VI_parameters(EverestData restrict everest, LocalParticle* part, double pc)
|
|
119
|
+
void calculate_VI_parameters(EverestData restrict everest, LocalParticle* part, double pc){
|
|
100
120
|
|
|
101
121
|
double ratio = everest->Rc_over_R;
|
|
102
122
|
double t_c0 = everest->t_c0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// copyright ############################### #
|
|
2
|
-
// This file is part of the Xcoll
|
|
2
|
+
// This file is part of the Xcoll package. #
|
|
3
3
|
// Copyright (c) CERN, 2024. #
|
|
4
4
|
// ######################################### #
|
|
5
5
|
|
|
@@ -64,6 +64,14 @@ typedef struct EverestData_ {
|
|
|
64
64
|
typedef EverestData_ *EverestData;
|
|
65
65
|
|
|
66
66
|
|
|
67
|
+
/*gpufun*/
|
|
68
|
+
double LocalParticle_get_energy(LocalParticle* part){
|
|
69
|
+
double mass_ratio = LocalParticle_get_charge_ratio(part) / LocalParticle_get_chi(part);
|
|
70
|
+
return (LocalParticle_get_ptau(part)*LocalParticle_get_p0c(part) \
|
|
71
|
+
+ LocalParticle_get_energy0(part)) * mass_ratio;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
67
75
|
/*gpufun*/
|
|
68
76
|
double drift_zeta_single(double rvv, double xp, double yp, double length){
|
|
69
77
|
double const rv0v = 1./rvv;
|
|
@@ -94,4 +102,4 @@ void RandomRutherford_set_by_xcoll_material(RandomRutherfordData ran, GeneralMat
|
|
|
94
102
|
RandomRutherford_set(ran, A, B, lcut, hcut);
|
|
95
103
|
}
|
|
96
104
|
|
|
97
|
-
#endif /* XCOLL_EVEREST_ENGINE_H */
|
|
105
|
+
#endif /* XCOLL_EVEREST_ENGINE_H */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// copyright ############################### #
|
|
2
|
-
// This file is part of the Xcoll
|
|
2
|
+
// This file is part of the Xcoll package. #
|
|
3
3
|
// Copyright (c) CERN, 2024. #
|
|
4
4
|
// ######################################### #
|
|
5
5
|
|
|
@@ -59,7 +59,6 @@ double jaw(EverestData restrict everest, LocalParticle* part, double p, double l
|
|
|
59
59
|
double s = LocalParticle_get_s(part) - s0;
|
|
60
60
|
p = p-m_dpodx*s; // TODO: This is correct: ionisation loss is only calculated and applied at end of while (break)
|
|
61
61
|
}
|
|
62
|
-
|
|
63
62
|
return p*1e9; // Back to eV
|
|
64
63
|
}
|
|
65
64
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// copyright ############################### #
|
|
2
|
-
// This file is part of the Xcoll
|
|
2
|
+
// This file is part of the Xcoll package. #
|
|
3
3
|
// Copyright (c) CERN, 2024. #
|
|
4
4
|
// ######################################### #
|
|
5
5
|
|
|
@@ -39,7 +39,7 @@ double soln3(double a, double b, double dh, double smax) {
|
|
|
39
39
|
}
|
|
40
40
|
return s;
|
|
41
41
|
}
|
|
42
|
-
if (a == 0) {
|
|
42
|
+
if (a == 0) {
|
|
43
43
|
if (b > 0) {
|
|
44
44
|
s = pow(b,2);
|
|
45
45
|
} else {
|
|
@@ -160,15 +160,16 @@ void mcs(EverestData restrict everest, LocalParticle* part, double length, doubl
|
|
|
160
160
|
x = res[0];
|
|
161
161
|
xp = res[1];
|
|
162
162
|
free(res);
|
|
163
|
-
if (x
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
if (x < 0) {
|
|
164
|
+
// extrapolation back to where x = 0
|
|
165
|
+
s = rlen0 - rlen + (s - x/xp);
|
|
166
|
+
x = 0.0;
|
|
167
|
+
break;
|
|
166
168
|
}
|
|
167
169
|
if (s + dh >= rlen) {
|
|
168
170
|
s = rlen0;
|
|
169
|
-
break;
|
|
171
|
+
break;
|
|
170
172
|
}
|
|
171
|
-
// go to 10
|
|
172
173
|
rlen = rlen - s;
|
|
173
174
|
}
|
|
174
175
|
|
|
@@ -198,4 +199,4 @@ void mcs(EverestData restrict everest, LocalParticle* part, double length, doubl
|
|
|
198
199
|
if (sc) InteractionRecordData_log_child(record, i_slot, part);
|
|
199
200
|
}
|
|
200
201
|
|
|
201
|
-
#endif /* XCOLL_EVEREST_MCS_H */
|
|
202
|
+
#endif /* XCOLL_EVEREST_MCS_H */
|