xcoll 0.3.4__py3-none-any.whl → 0.3.6__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/beam_elements/base.py +16 -0
- xcoll/colldb.py +5 -6
- xcoll/general.py +1 -1
- xcoll/manager.py +5 -5
- xcoll/rf_sweep.py +90 -19
- {xcoll-0.3.4.dist-info → xcoll-0.3.6.dist-info}/METADATA +1 -1
- {xcoll-0.3.4.dist-info → xcoll-0.3.6.dist-info}/RECORD +10 -10
- {xcoll-0.3.4.dist-info → xcoll-0.3.6.dist-info}/LICENSE +0 -0
- {xcoll-0.3.4.dist-info → xcoll-0.3.6.dist-info}/NOTICE +0 -0
- {xcoll-0.3.4.dist-info → xcoll-0.3.6.dist-info}/WHEEL +0 -0
xcoll/beam_elements/base.py
CHANGED
|
@@ -60,6 +60,14 @@ class BaseBlock(xt.BeamElement):
|
|
|
60
60
|
instance = super().__new__(cls)
|
|
61
61
|
return instance
|
|
62
62
|
|
|
63
|
+
def enable_scattering(self):
|
|
64
|
+
if hasattr(self, '_tracking'):
|
|
65
|
+
self._tracking = True
|
|
66
|
+
|
|
67
|
+
def disable_scattering(self):
|
|
68
|
+
if hasattr(self, '_tracking'):
|
|
69
|
+
self._tracking = False
|
|
70
|
+
|
|
63
71
|
def get_backtrack_element(self, _context=None, _buffer=None, _offset=None):
|
|
64
72
|
return InvalidXcoll(length=-self.length,
|
|
65
73
|
_context=_context, _buffer=_buffer, _offset=_offset)
|
|
@@ -196,6 +204,14 @@ class BaseCollimator(xt.BeamElement):
|
|
|
196
204
|
super().__init__(**kwargs)
|
|
197
205
|
|
|
198
206
|
|
|
207
|
+
def enable_scattering(self):
|
|
208
|
+
if hasattr(self, '_tracking'):
|
|
209
|
+
self._tracking = True
|
|
210
|
+
|
|
211
|
+
def disable_scattering(self):
|
|
212
|
+
if hasattr(self, '_tracking'):
|
|
213
|
+
self._tracking = False
|
|
214
|
+
|
|
199
215
|
@property
|
|
200
216
|
def jaw(self):
|
|
201
217
|
return _get_LR(self, 'jaw', neg=True)
|
xcoll/colldb.py
CHANGED
|
@@ -214,9 +214,6 @@ class CollimatorDatabase:
|
|
|
214
214
|
cry[sline[1]][key] = float(sline[idx])
|
|
215
215
|
else:
|
|
216
216
|
cry[sline[1]][key] = int(sline[idx])
|
|
217
|
-
elif sline[0].lower() == "target":
|
|
218
|
-
variables['xdim'][sline[1]] = float(sline[2])
|
|
219
|
-
variables['ydim'][sline[1]] = float(sline[3])
|
|
220
217
|
elif sline[0].lower() == 'settings':
|
|
221
218
|
pass # Acknowledge and ignore this line
|
|
222
219
|
elif len(sline) == 6:
|
|
@@ -231,7 +228,7 @@ class CollimatorDatabase:
|
|
|
231
228
|
famdct = {key: {'gap': family_settings[key], 'stage': family_types[key]} for key in family_settings}
|
|
232
229
|
names = ['name', 'gap', 'material', 'active_length', 'angle', 'offset']
|
|
233
230
|
|
|
234
|
-
df = pd.read_csv(io.StringIO(coll_data_string), sep='\s+', index_col=False, names=names)
|
|
231
|
+
df = pd.read_csv(io.StringIO(coll_data_string), sep=r'\s+', index_col=False, names=names)
|
|
235
232
|
df['family'] = df['gap'].copy()
|
|
236
233
|
df['family'] = df['family'].apply(lambda s: None if re.match(r'^-?\d+(\.\d+)?$', str(s)) else s)
|
|
237
234
|
df.insert(5,'stage', df['gap'].apply(lambda s: family_types.get(s, 'UNKNOWN')))
|
|
@@ -307,8 +304,8 @@ class CollimatorDatabase:
|
|
|
307
304
|
fam_keys = dcts._family_dict[fam].keys()
|
|
308
305
|
coll_dict = {**{'<<': '*'+fam}, **coll_dict}
|
|
309
306
|
temp_items_to_print = []
|
|
310
|
-
if coll_dict['crystal']:
|
|
311
|
-
temp_items_to_print = ['
|
|
307
|
+
if coll_dict['crystal'] and str(coll_dict['crystal'])!='nan':
|
|
308
|
+
temp_items_to_print = ['bending_radius','xdim','ydim','miscut','crystal', 'thick']
|
|
312
309
|
if coll_dict['angle_L'] == coll_dict['angle_R']:
|
|
313
310
|
coll_dict.update({'angle': coll_dict['angle_L']})
|
|
314
311
|
else:
|
|
@@ -324,6 +321,8 @@ class CollimatorDatabase:
|
|
|
324
321
|
value = {}
|
|
325
322
|
overwritten_keys = coll_dict['overwritten_keys']
|
|
326
323
|
for key, val in coll_dict.items():
|
|
324
|
+
if key == 'active_length':
|
|
325
|
+
key = 'length'
|
|
327
326
|
if (key in coll_items_to_print+temp_items_to_print) and (key not in (set(fam_keys)-set(overwritten_keys))) and (val != 'both'):
|
|
328
327
|
value.update({key: val})
|
|
329
328
|
file.write(_format_dict_entry(coll, value, spacing=' '))
|
xcoll/general.py
CHANGED
xcoll/manager.py
CHANGED
|
@@ -8,7 +8,7 @@ from pathlib import Path
|
|
|
8
8
|
import numpy as np
|
|
9
9
|
import pandas as pd
|
|
10
10
|
|
|
11
|
-
from .beam_elements import BaseCollimator, BlackAbsorber, EverestCollimator, EverestCrystal, _all_collimator_types
|
|
11
|
+
from .beam_elements import BaseCollimator, BlackAbsorber, EverestCollimator, EverestCrystal, _all_collimator_types, element_classes
|
|
12
12
|
from .colldb import CollimatorDatabase
|
|
13
13
|
from .impacts import CollimatorImpacts
|
|
14
14
|
from .scattering_routines.everest.materials import SixTrack_to_xcoll, CrystalMaterial
|
|
@@ -775,14 +775,14 @@ class CollimatorManager:
|
|
|
775
775
|
|
|
776
776
|
def enable_scattering(self):
|
|
777
777
|
# Prepare collimators for tracking
|
|
778
|
-
for
|
|
779
|
-
|
|
778
|
+
for el in self.line.get_elements_of_type(element_classes)[0]:
|
|
779
|
+
el.enable_scattering()
|
|
780
780
|
self._set_record_impacts()
|
|
781
781
|
|
|
782
782
|
def disable_scattering(self):
|
|
783
783
|
# Prepare collimators for tracking
|
|
784
|
-
for
|
|
785
|
-
|
|
784
|
+
for el in self.line.get_elements_of_type(element_classes)[0]:
|
|
785
|
+
el.disable_scattering()
|
|
786
786
|
|
|
787
787
|
@property
|
|
788
788
|
def scattering_enabled(self):
|
xcoll/rf_sweep.py
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
# ######################################### #
|
|
5
5
|
|
|
6
6
|
import numpy as np
|
|
7
|
-
import pandas as pd
|
|
8
7
|
import scipy.constants as sc
|
|
8
|
+
from time import perf_counter
|
|
9
9
|
|
|
10
10
|
import xtrack as xt
|
|
11
|
-
|
|
11
|
+
from xtrack.progress_indicator import progress
|
|
12
12
|
|
|
13
13
|
class RFSweep:
|
|
14
14
|
|
|
@@ -81,7 +81,7 @@ class RFSweep:
|
|
|
81
81
|
+ f"the bucket and remain uncaptured.")
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
def track(self, sweep=0,
|
|
84
|
+
def track(self, sweep=0, particles=None, num_turns=0, verbose=True, *args, **kwargs):
|
|
85
85
|
|
|
86
86
|
# Was there a previous sweep?
|
|
87
87
|
# If yes, we do not overwrite it but continue from there
|
|
@@ -101,20 +101,91 @@ class RFSweep:
|
|
|
101
101
|
raise ValueError("Need to build tracker first!")
|
|
102
102
|
if particles is None:
|
|
103
103
|
raise ValueError("Need particles to track!")
|
|
104
|
+
time = kwargs.pop('time', False)
|
|
105
|
+
with_progress = kwargs.pop('with_progress', False)
|
|
104
106
|
rf_shift_per_turn = sweep / num_turns
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
107
|
+
|
|
108
|
+
# This is taken from xtrack.tracker.Tracker._track
|
|
109
|
+
if time:
|
|
110
|
+
t0 = perf_counter()
|
|
111
|
+
if with_progress:
|
|
112
|
+
if self.line.tracker.enable_pipeline_hold:
|
|
113
|
+
raise ValueError("Progress indicator is not supported with pipeline hold")
|
|
114
|
+
if num_turns < 2:
|
|
115
|
+
raise ValueError('Tracking with progress indicator is only '
|
|
116
|
+
'possible over more than one turn.')
|
|
117
|
+
if with_progress is True:
|
|
118
|
+
batch_size = scaling = 100
|
|
119
|
+
else:
|
|
120
|
+
batch_size = int(with_progress)
|
|
121
|
+
scaling = with_progress if batch_size > 1 else None
|
|
122
|
+
if kwargs.get('turn_by_turn_monitor') is True:
|
|
123
|
+
ele_start = kwargs.get('ele_start') or 0
|
|
124
|
+
ele_stop = kwargs.get('ele_stop')
|
|
125
|
+
if ele_stop is None:
|
|
126
|
+
ele_stop = len(self.line)
|
|
127
|
+
if ele_start >= ele_stop:
|
|
128
|
+
# we need an additional turn and space in the monitor for
|
|
129
|
+
# the incomplete turn
|
|
130
|
+
num_turns += 1
|
|
131
|
+
_, monitor, _, _ = self.line.tracker._get_monitor(particles, True, num_turns)
|
|
132
|
+
kwargs['turn_by_turn_monitor'] = monitor
|
|
133
|
+
|
|
134
|
+
for ii in progress(
|
|
135
|
+
range(0, num_turns, batch_size),
|
|
136
|
+
desc='Tracking',
|
|
137
|
+
unit_scale=scaling,
|
|
138
|
+
):
|
|
139
|
+
one_turn_kwargs = kwargs.copy()
|
|
140
|
+
is_first_batch = ii == 0
|
|
141
|
+
is_last_batch = ii + batch_size >= num_turns
|
|
142
|
+
|
|
143
|
+
if is_first_batch and is_last_batch:
|
|
144
|
+
# This is the only batch, we track as normal
|
|
145
|
+
pass
|
|
146
|
+
elif is_first_batch:
|
|
147
|
+
# Not the last batch, so track until the last element
|
|
148
|
+
one_turn_kwargs['ele_stop'] = None
|
|
149
|
+
one_turn_kwargs['num_turns'] = batch_size
|
|
150
|
+
elif is_last_batch:
|
|
151
|
+
# Not the first batch, so track from the first element
|
|
152
|
+
one_turn_kwargs['ele_start'] = None
|
|
153
|
+
remaining_turns = num_turns % batch_size
|
|
154
|
+
if remaining_turns == 0:
|
|
155
|
+
remaining_turns = batch_size
|
|
156
|
+
one_turn_kwargs['num_turns'] = remaining_turns
|
|
157
|
+
one_turn_kwargs['_reset_log'] = False
|
|
158
|
+
elif not is_first_batch and not is_last_batch:
|
|
159
|
+
# A 'middle batch', track from first to last element
|
|
160
|
+
one_turn_kwargs['num_turns'] = batch_size
|
|
161
|
+
one_turn_kwargs['ele_start'] = None
|
|
162
|
+
one_turn_kwargs['ele_stop'] = None
|
|
163
|
+
one_turn_kwargs['_reset_log'] = False
|
|
164
|
+
self._tracking_func(particles, rf_shift_per_turn, **one_turn_kwargs)
|
|
165
|
+
if not np.any(particles.state == 1):
|
|
166
|
+
break
|
|
167
|
+
|
|
168
|
+
else:
|
|
169
|
+
self._tracking_func(particles, rf_shift_per_turn, num_turns=num_turns, *args, **kwargs)
|
|
170
|
+
|
|
171
|
+
if not np.any(particles.state == 1):
|
|
172
|
+
print(f"All particles lost at turn {particles.at_turn.max()}, stopped sweep at "
|
|
173
|
+
+ f"{self.current_sweep_value}Hz.")
|
|
174
|
+
|
|
175
|
+
if time:
|
|
176
|
+
t1 = perf_counter()
|
|
177
|
+
self.line.tracker._context.synchronize()
|
|
178
|
+
self.line.tracker.time_last_track = t1 - t0
|
|
179
|
+
else:
|
|
180
|
+
self.line.tracker.time_last_track = None
|
|
181
|
+
|
|
182
|
+
def _tracking_func(self, particles, rf_shift_per_turn, num_turns=1, *args, **kwargs):
|
|
183
|
+
existing_sweep = self.current_sweep_value
|
|
184
|
+
for i in range(num_turns):
|
|
185
|
+
sweep = existing_sweep + i*rf_shift_per_turn
|
|
186
|
+
self.line['rf_sweep'].dzeta = self.L * sweep / (self.f_RF + sweep)
|
|
187
|
+
# for cav in cavities:
|
|
188
|
+
# self.line[cav].frequency = freq + sweep
|
|
189
|
+
self.line.track(particles, num_turns=1, *args, **kwargs)
|
|
190
|
+
if not np.any(particles.state == 1):
|
|
191
|
+
break
|
|
@@ -3,23 +3,23 @@ NOTICE,sha256=6DO_E7WCdRKc42vUoVVBPGttvQi4mRt9fAcxj9u8zy8,74
|
|
|
3
3
|
xcoll/__init__.py,sha256=XO53i_KKg6kaJfTCpmNJLy14tou4RMF9MDuXlH70iTQ,642
|
|
4
4
|
xcoll/beam_elements/__init__.py,sha256=4ekQv_1Kxwqd0VSaPzMpVQ1V9RMX5tr-ycBBiTIFyRw,776
|
|
5
5
|
xcoll/beam_elements/absorber.py,sha256=yxF-NhnQs_l7s-M_0AhdKzx0YVgvhujOAwQnAbVTSOs,1260
|
|
6
|
-
xcoll/beam_elements/base.py,sha256=
|
|
6
|
+
xcoll/beam_elements/base.py,sha256=Nwgg2v1RdEEpByFG8AZgL7E6ecESbYm3mqnIfoh5SFQ,15785
|
|
7
7
|
xcoll/beam_elements/collimators_src/absorber.h,sha256=ZsAzIZ3uWP15unMJyuxbuD5lVgFeWAwQsuyOj_ZSkjI,5502
|
|
8
8
|
xcoll/beam_elements/collimators_src/everest_block.h,sha256=Gpr5wyFLtcaNgVj3auKgFWB-2KPP5cjbEWTfC3f9q1U,5596
|
|
9
9
|
xcoll/beam_elements/collimators_src/everest_collimator.h,sha256=wsGIFBb-VMCRhxwK2G5k9SEX-6SzIgRX4XE5g_I2okg,6296
|
|
10
10
|
xcoll/beam_elements/collimators_src/everest_crystal.h,sha256=pX9cmW5lfsUoszR14tXWU4Emu-0VwX4bbfg6Q6pxXR4,5164
|
|
11
11
|
xcoll/beam_elements/everest.py,sha256=JxmREXln3p3c9XEcHp-DgDbXFzc9txiGrxvjOrDUacs,11369
|
|
12
|
-
xcoll/colldb.py,sha256=
|
|
12
|
+
xcoll/colldb.py,sha256=_MywNPz9cDocGPsfXpBVkjADyAGGVFQQRUI4kxOQaOg,49476
|
|
13
13
|
xcoll/collimator_settings.py,sha256=uj25cpSaM-EY7VM65OUq3Cxb8gedSmi-r9mpkP-ikrg,17015
|
|
14
|
-
xcoll/general.py,sha256=
|
|
14
|
+
xcoll/general.py,sha256=Pcqa-FWVvvs3X5gBEhnNw2qmw-Rl9IdCMX2Mww33wt4,525
|
|
15
15
|
xcoll/headers/checks.h,sha256=3CLIa2etrJVKBfxdsHcS8NirqzVDHG9aCbrlMwkWuHw,1586
|
|
16
16
|
xcoll/headers/particle_states.h,sha256=YxpS56_ZD8mhrqKTohcyVe3hbQZ6H9vspYHSVM6a5-U,844
|
|
17
17
|
xcoll/impacts/__init__.py,sha256=yKQdIeLG2CT3qo-iZB6MODm-WHzkTmulgUvOAS41w7E,39
|
|
18
18
|
xcoll/impacts/impacts.py,sha256=J7FfcxIprUMHyn5oZhmjhvBewXOp7kwJtErStOsAwJQ,3953
|
|
19
19
|
xcoll/impacts/impacts_src/impacts.h,sha256=0eq4Z8xDPMJzN8yPF3lTkDsld6W54tbXmynZEbXCh4c,5950
|
|
20
20
|
xcoll/impacts/interaction_types.py,sha256=iHbhC4beN1vZRWeHbALqSFo8lG10R7asc08BRpIqXx0,2493
|
|
21
|
-
xcoll/manager.py,sha256=
|
|
22
|
-
xcoll/rf_sweep.py,sha256=
|
|
21
|
+
xcoll/manager.py,sha256=A7hCuSgS7sSFKoV26Nt8xc_GXUNOm-WRqsGftRoBMzA,45052
|
|
22
|
+
xcoll/rf_sweep.py,sha256=_cnDb2d0_tfVrrwuubLOSyUHpMQHMvmSzYgd_-WfJg0,8936
|
|
23
23
|
xcoll/scattering_routines/everest/__init__.py,sha256=yuCzolZkiL7mHaBXCKHRl66VxjKFB0t9Vyw9TtFv1Bo,286
|
|
24
24
|
xcoll/scattering_routines/everest/constants.h,sha256=9Kus-RKyxsGdlxx9tfMWUz2H5Q-qy6y_F4kddIZzO30,1390
|
|
25
25
|
xcoll/scattering_routines/everest/crystal.h,sha256=WlA_e9ePuVhc9fmMVdSXFBKvHrFvCQ5aG4d67iMrtuQ,54119
|
|
@@ -104,8 +104,8 @@ xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeFlukaIOServer.h,sha256=0
|
|
|
104
104
|
xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeFortranFlukaIO.h,sha256=WxAjG2SPlWqMG38iHBM8GQwh5yp031jAGeyPi4y9G4c,330
|
|
105
105
|
xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeNetIO.c,sha256=JcgCWxbT-ZOeG0c9mz1kk3PfXjaazaUk2P_ROtoBKaY,1452
|
|
106
106
|
xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeNetIO.h,sha256=JTMU9FtCBJkitsnHp7kWKUbPSN4rviRfJgVHK26AuPY,906
|
|
107
|
-
xcoll-0.3.
|
|
108
|
-
xcoll-0.3.
|
|
109
|
-
xcoll-0.3.
|
|
110
|
-
xcoll-0.3.
|
|
111
|
-
xcoll-0.3.
|
|
107
|
+
xcoll-0.3.6.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
108
|
+
xcoll-0.3.6.dist-info/METADATA,sha256=-HXnJmvM23LxNmSOOxUuLhk49SuI8DnG7uIWl7DtHPg,2709
|
|
109
|
+
xcoll-0.3.6.dist-info/NOTICE,sha256=6DO_E7WCdRKc42vUoVVBPGttvQi4mRt9fAcxj9u8zy8,74
|
|
110
|
+
xcoll-0.3.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
111
|
+
xcoll-0.3.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|