xtrack 0.46.2__tar.gz → 0.46.4__tar.gz
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.
- {xtrack-0.46.2/xtrack.egg-info → xtrack-0.46.4}/PKG-INFO +1 -1
- xtrack-0.46.4/xtrack/_version.py +1 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/__init__.py +1 -1
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/beam_interaction.py +37 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements.py +2 -1
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/line.py +17 -11
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/progress_indicator.py +2 -1
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/tapering.py +1 -1
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/tracker.py +26 -25
- {xtrack-0.46.2 → xtrack-0.46.4/xtrack.egg-info}/PKG-INFO +1 -1
- xtrack-0.46.2/xtrack/_version.py +0 -1
- {xtrack-0.46.2 → xtrack-0.46.4}/LICENSE +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/MANIFEST.in +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/README.md +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/__init__.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/base_classes.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/be_beamfields/BB6D.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/be_beamfields/BB6Ddata.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/be_beamfields/__init__.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/be_beamfields/beambeam.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/be_beamfields/boost.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/be_beamfields/gaussian_fields.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/be_beamfields/propagate_sigma_matrix.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/be_beamfields/qgauss.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/be_beamfields/slicing.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/be_beamfields/spacecharge.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/elements.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/line.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/mathlibs.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/particles.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/ducktrack/temp_pyparticles.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/pyproject.toml +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/setup.cfg +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/setup.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/__init__.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/_temp/__init__.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/_temp/lhc_match/__init__.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/_temp/lhc_match/gen_madx_optics_file.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/_temp/lhc_match/lhc_match.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/_temp/lhc_match/var_limits.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/base_element.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/apertures.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/apertures_src/limitellipse.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/apertures_src/limitpolygon.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/apertures_src/limitracetrack.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/apertures_src/limitrect.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/apertures_src/limitrectellipse.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/apertures_src/longitudinallimitrect.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/bend.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/cavity.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/combinedfunctionmagnet.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/dipoleedge.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/drift.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/drift_elem.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/elens.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/exciter.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/firstordertaylormap.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/fringe.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/fringe_track.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/lineartransfermatrix.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/linesegmentmap.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/multipolar_kick.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/multipole.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/nonlinearlens.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/quadrupole.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/referenceenergyincrease.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/rfmultipole.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/second_order_taylor_map.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/sextupole.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/simplethinbend.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/simplethinquadrupole.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/solenoid.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/srotation.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/track_thick_bend.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/track_thick_cfd.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/track_yrotation.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/wedge.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/wedge_track.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/wire.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/xrotation.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/xyshift.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/yrotation.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/elements_src/zetashift.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/beam_elements/exciter.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/compounds.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/footprint.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/general.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/headers/atomicadd.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/headers/checks.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/headers/constants.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/headers/particle_states.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/headers/synrad_spectrum.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/internal_record.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/linear_normal_form.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/loss_location_refinement/__init__.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/loss_location_refinement/loss_location_refinement.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/lumi.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/mad_loader.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/match.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/monitors/__init__.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/monitors/beam_position_monitor.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/monitors/beam_position_monitor.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/monitors/beam_profile_monitor.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/monitors/beam_profile_monitor.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/monitors/beam_size_monitor.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/monitors/beam_size_monitor.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/monitors/last_turns_monitor.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/monitors/last_turns_monitor.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/monitors/particles_monitor.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/monitors/particles_monitor.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/multiline/__init__.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/multiline/multiline.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/multiline/shared_knobs.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/multisetter/__init__.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/multisetter/multisetter.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/pipeline/__init__.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/pipeline/core.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/pipeline/manager.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/pipeline/multitracker.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/prebuild_kernels.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/prebuilt_kernels/__init__.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/prebuilt_kernels/kernel_definitions.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/random/__init__.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/random/random_generators.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/random/random_src/exponential.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/random/random_src/exponential_integral_Ei.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/random/random_src/normal.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/random/random_src/rutherford.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/random/random_src/uniform.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/slicing.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/survey.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/targets.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/tracker_data.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/tracker_src/tracker.h +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack/twiss.py +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack.egg-info/SOURCES.txt +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack.egg-info/dependency_links.txt +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack.egg-info/requires.txt +0 -0
- {xtrack-0.46.2 → xtrack-0.46.4}/xtrack.egg-info/top_level.txt +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = '0.46.4'
|
@@ -6,7 +6,7 @@
|
|
6
6
|
from .elements import *
|
7
7
|
from .exciter import Exciter
|
8
8
|
from .apertures import *
|
9
|
-
from .beam_interaction import BeamInteraction
|
9
|
+
from .beam_interaction import BeamInteraction, ParticlesInjectionSample
|
10
10
|
from ..base_element import BeamElement
|
11
11
|
|
12
12
|
element_classes = tuple(v for v in globals().values() if isinstance(v, type) and issubclass(v, BeamElement))
|
@@ -58,3 +58,40 @@ class BeamInteraction:
|
|
58
58
|
parent_particle_id = products['parent_particle_id'])
|
59
59
|
|
60
60
|
particles.add_particles(new_particles)
|
61
|
+
|
62
|
+
class ParticlesInjectionSample:
|
63
|
+
|
64
|
+
def __init__(self, particles_to_inject, line, element_name, num_particles_to_inject):
|
65
|
+
self.particles_to_inject = particles_to_inject.copy()
|
66
|
+
self.line = line
|
67
|
+
self.element_name = element_name
|
68
|
+
self.num_particles_to_inject = num_particles_to_inject
|
69
|
+
|
70
|
+
def track(self, particles):
|
71
|
+
|
72
|
+
if not isinstance(particles._context, xo.ContextCpu):
|
73
|
+
raise ValueError('This element only works with CPU context')
|
74
|
+
|
75
|
+
self.particles_to_inject.at_turn += 1
|
76
|
+
|
77
|
+
if not self.num_particles_to_inject:
|
78
|
+
return
|
79
|
+
|
80
|
+
assert self.element_name in self.line.element_names
|
81
|
+
assert self.line[self.element_name] is self
|
82
|
+
at_element = self.line.element_names.index(self.element_name)
|
83
|
+
s_element = self.line.tracker._tracker_data_base.element_s_locations[at_element]
|
84
|
+
|
85
|
+
# Get random particles to inject
|
86
|
+
idx_inject = np.random.default_rng().choice(len(self.particles_to_inject.x),
|
87
|
+
size=self.num_particles_to_inject, replace=False)
|
88
|
+
|
89
|
+
mask_inject = np.zeros(len(self.particles_to_inject.x), dtype=bool)
|
90
|
+
mask_inject[idx_inject] = True
|
91
|
+
|
92
|
+
p_inj = self.particles_to_inject.filter(mask_inject)
|
93
|
+
p_inj.s = s_element
|
94
|
+
p_inj.at_element = at_element
|
95
|
+
p_inj.update_p0c_and_energy_deviations(p0c=self.line.particle_ref.p0c[0])
|
96
|
+
|
97
|
+
particles.add_particles(p_inj)
|
@@ -1964,7 +1964,8 @@ class LineSegmentMap(BeamElement):
|
|
1964
1964
|
self._xobject = nargs['_xobject']
|
1965
1965
|
return
|
1966
1966
|
|
1967
|
-
assert longitudinal_mode in [
|
1967
|
+
assert longitudinal_mode in [
|
1968
|
+
'linear_fixed_qs', 'nonlinear', 'linear_fixed_rf', 'frozen', None]
|
1968
1969
|
|
1969
1970
|
nargs['qx'] = qx
|
1970
1971
|
nargs['qy'] = qy
|
@@ -43,6 +43,9 @@ from .internal_record import (start_internal_logging_for_elements_of_type,
|
|
43
43
|
|
44
44
|
from .general import _print
|
45
45
|
|
46
|
+
# For xdeps compatibility
|
47
|
+
isref = (xd.refs.isref if hasattr(xd.refs, 'isref') else xd.refs._isref)
|
48
|
+
|
46
49
|
log = logging.getLogger(__name__)
|
47
50
|
|
48
51
|
|
@@ -131,7 +134,8 @@ class Line:
|
|
131
134
|
|
132
135
|
self.particle_ref = particle_ref
|
133
136
|
|
134
|
-
|
137
|
+
if energy_program is not None:
|
138
|
+
self.energy_program = energy_program # setter will take care of completing
|
135
139
|
|
136
140
|
self._var_management = None
|
137
141
|
self._line_vars = None
|
@@ -206,7 +210,7 @@ class Line:
|
|
206
210
|
self.metadata = dct['metadata']
|
207
211
|
|
208
212
|
if ('energy_program' in self.element_dict
|
209
|
-
and self['energy_program'] is not None):
|
213
|
+
and self.element_dict['energy_program'] is not None):
|
210
214
|
self.energy_program.line = self
|
211
215
|
|
212
216
|
_print('Done loading line from dict. ')
|
@@ -660,6 +664,9 @@ class Line:
|
|
660
664
|
out.config.update(self.config.copy())
|
661
665
|
out._extra_config.update(self._extra_config.copy())
|
662
666
|
|
667
|
+
if out.energy_program is not None:
|
668
|
+
out.energy_program.line = out
|
669
|
+
|
663
670
|
return out
|
664
671
|
|
665
672
|
def build_tracker(
|
@@ -3136,8 +3143,7 @@ class Line:
|
|
3136
3143
|
'Xdeps expression need to be enabled to use `energy_program`')
|
3137
3144
|
if self.energy_program.needs_complete:
|
3138
3145
|
self.energy_program.complete_init(self)
|
3139
|
-
|
3140
|
-
self.energy_program.line = self
|
3146
|
+
self.energy_program.line = self
|
3141
3147
|
self.element_refs['energy_program'].t_turn_s_line = self.vars['t_turn_s']
|
3142
3148
|
|
3143
3149
|
def __getitem__(self, ii):
|
@@ -3736,7 +3742,7 @@ class LineVars:
|
|
3736
3742
|
|
3737
3743
|
def __setitem__(self, key, value):
|
3738
3744
|
if self.cache_active:
|
3739
|
-
if
|
3745
|
+
if isref(value) or isinstance(value, VarSetter):
|
3740
3746
|
raise ValueError('Cannot set a variable to a ref when the '
|
3741
3747
|
'cache is active')
|
3742
3748
|
self._setter_from_cache(key)(value)
|
@@ -3922,7 +3928,6 @@ class EnergyProgram:
|
|
3922
3928
|
self.kinetic_energy0 = kinetic_energy0
|
3923
3929
|
self.t_s = t_s
|
3924
3930
|
self.needs_complete = True
|
3925
|
-
self.needs_line = True
|
3926
3931
|
|
3927
3932
|
def complete_init(self, line):
|
3928
3933
|
|
@@ -3974,20 +3979,19 @@ class EnergyProgram:
|
|
3974
3979
|
self.line = line
|
3975
3980
|
|
3976
3981
|
self.needs_complete = False
|
3977
|
-
self.needs_line = False
|
3978
3982
|
del self.p0c
|
3979
3983
|
del self.kinetic_energy0
|
3980
3984
|
|
3981
3985
|
def get_t_s_at_turn(self, i_turn):
|
3982
3986
|
assert not self.needs_complete, 'EnergyProgram not complete'
|
3983
|
-
assert not
|
3987
|
+
assert self.line is not None, 'EnergyProgram not associated to a line'
|
3984
3988
|
out = self.t_at_turn_interpolator(i_turn)
|
3985
3989
|
|
3986
3990
|
return out
|
3987
3991
|
|
3988
3992
|
def get_p0c_at_t_s(self, t_s):
|
3989
3993
|
assert not self.needs_complete, 'EnergyProgram not complete'
|
3990
|
-
assert not
|
3994
|
+
assert self.line is not None, 'EnergyProgram not associated to a line'
|
3991
3995
|
return self.p0c_interpolator(t_s)
|
3992
3996
|
|
3993
3997
|
def get_beta0_at_t_s(self, t_s):
|
@@ -4035,5 +4039,7 @@ class EnergyProgram:
|
|
4035
4039
|
self.p0c_interpolator = xd.FunctionPieceWiseLinear.from_dict(
|
4036
4040
|
dct['p0c_interpolator'])
|
4037
4041
|
self.needs_complete = False
|
4038
|
-
self
|
4039
|
-
|
4042
|
+
return self
|
4043
|
+
|
4044
|
+
def copy(self, _context=None, _buffer=None, _offeset=None):
|
4045
|
+
return self.from_dict(self.to_dict())
|
@@ -87,7 +87,8 @@ def progress(iterable: Iterable, **options):
|
|
87
87
|
|
88
88
|
|
89
89
|
try:
|
90
|
-
from tqdm
|
90
|
+
from tqdm import tqdm
|
91
|
+
# from tqdm.autonotebook import tqdm # to be enabled when tqdm is fixed
|
91
92
|
set_default_indicator(tqdm)
|
92
93
|
except ModuleNotFoundError:
|
93
94
|
pass
|
@@ -35,7 +35,7 @@ def compensate_radiation_energy_loss(line, delta0=0, rtol_eneloss=1e-12,
|
|
35
35
|
line.track(p_test, turn_by_turn_monitor='ONE_TURN_EBE')
|
36
36
|
mon = line.record_last_track
|
37
37
|
eloss = -(mon.ptau[0, -1] - mon.ptau[0, 0]) * p_test.p0c[0]
|
38
|
-
if abs(eloss) < p_test.energy0[0] * rtol_eneloss:
|
38
|
+
if p_test.state[0] > 0 and abs(eloss) < p_test.energy0[0] * rtol_eneloss:
|
39
39
|
if verbose: _print(" - No compensation needed")
|
40
40
|
return
|
41
41
|
|
@@ -282,7 +282,14 @@ class Tracker:
|
|
282
282
|
"This tracker is not anymore valid, most probably because the corresponding line has been unfrozen. "
|
283
283
|
"Please rebuild the tracker, for example using `line.build_tracker(...)`.")
|
284
284
|
|
285
|
-
def _track(self, particles, *args, with_progress: Union[bool, int]
|
285
|
+
def _track(self, particles, *args, with_progress: Union[bool, int]=False,
|
286
|
+
time=False, **kwargs):
|
287
|
+
|
288
|
+
out = None
|
289
|
+
|
290
|
+
if time:
|
291
|
+
t0 = perf_counter()
|
292
|
+
|
286
293
|
assert self.iscollective in (True, False)
|
287
294
|
if self.iscollective or self.line.enable_time_dependent_vars:
|
288
295
|
tracking_func = self._track_with_collective
|
@@ -319,7 +326,16 @@ class Tracker:
|
|
319
326
|
tracking_func(particles, *args, **one_turn_kwargs)
|
320
327
|
# particles.reorganize() # could be done in the future to optimize GPU usage
|
321
328
|
else:
|
322
|
-
|
329
|
+
out = tracking_func(particles, *args, **kwargs)
|
330
|
+
|
331
|
+
if time:
|
332
|
+
t1 = perf_counter()
|
333
|
+
self._context.synchronize()
|
334
|
+
self.time_last_track = t1 - t0
|
335
|
+
else:
|
336
|
+
self.time_last_track = None
|
337
|
+
|
338
|
+
return out
|
323
339
|
|
324
340
|
@property
|
325
341
|
def particle_ref(self) -> xp.Particles:
|
@@ -797,13 +813,9 @@ class Tracker:
|
|
797
813
|
turn_by_turn_monitor=None,
|
798
814
|
freeze_longitudinal=False,
|
799
815
|
backtrack=False,
|
800
|
-
time=False,
|
801
816
|
_session_to_resume=None
|
802
817
|
):
|
803
818
|
|
804
|
-
if time:
|
805
|
-
t0 = perf_counter()
|
806
|
-
|
807
819
|
if ele_start is None:
|
808
820
|
ele_start = 0
|
809
821
|
|
@@ -871,9 +883,10 @@ class Tracker:
|
|
871
883
|
ii_first_active = int((state > 0).argmax())
|
872
884
|
if ii_first_active == 0 and particles._xobject.state[0] <= 0:
|
873
885
|
# No active particles
|
874
|
-
|
886
|
+
at_turn = 0 # convenient for multi-turn injection
|
887
|
+
else:
|
888
|
+
at_turn = particles._xobject.at_turn[ii_first_active]
|
875
889
|
|
876
|
-
at_turn = particles._xobject.at_turn[ii_first_active]
|
877
890
|
if self.line.energy_program is not None:
|
878
891
|
t_turn = self.line.energy_program.get_t_s_at_turn(at_turn)
|
879
892
|
else:
|
@@ -881,6 +894,11 @@ class Tracker:
|
|
881
894
|
t_turn = (at_turn * self._tracker_data_base.line_length
|
882
895
|
/ (beta0 * clight))
|
883
896
|
|
897
|
+
# Clean leftover from previous trackings
|
898
|
+
if (self.line._t_last_update_time_dependent_vars and
|
899
|
+
t_turn < self.line._t_last_update_time_dependent_vars):
|
900
|
+
self.line._t_last_update_time_dependent_vars = None
|
901
|
+
|
884
902
|
if (self.line._t_last_update_time_dependent_vars is None
|
885
903
|
or self.line.dt_update_time_dependent_vars is None
|
886
904
|
or t_turn > self.line._t_last_update_time_dependent_vars
|
@@ -995,12 +1013,6 @@ class Tracker:
|
|
995
1013
|
|
996
1014
|
self.record_last_track = monitor
|
997
1015
|
|
998
|
-
if time:
|
999
|
-
t1 = perf_counter()
|
1000
|
-
self._context.synchronize()
|
1001
|
-
self.time_last_track = t1 - t0
|
1002
|
-
else:
|
1003
|
-
self.time_last_track = None
|
1004
1016
|
|
1005
1017
|
def _track_no_collective(
|
1006
1018
|
self,
|
@@ -1012,7 +1024,6 @@ class Tracker:
|
|
1012
1024
|
turn_by_turn_monitor=None,
|
1013
1025
|
freeze_longitudinal=False,
|
1014
1026
|
backtrack=False,
|
1015
|
-
time=False,
|
1016
1027
|
_force_no_end_turn_actions=False,
|
1017
1028
|
):
|
1018
1029
|
|
@@ -1042,9 +1053,6 @@ class Tracker:
|
|
1042
1053
|
self.particles_class = particles.__class__
|
1043
1054
|
self.local_particle_src = particles.gen_local_particle_api()
|
1044
1055
|
|
1045
|
-
if time:
|
1046
|
-
t0 = perf_counter()
|
1047
|
-
|
1048
1056
|
if freeze_longitudinal:
|
1049
1057
|
kwargs = locals().copy()
|
1050
1058
|
kwargs.pop('self')
|
@@ -1227,13 +1235,6 @@ class Tracker:
|
|
1227
1235
|
|
1228
1236
|
self.record_last_track = monitor
|
1229
1237
|
|
1230
|
-
if time:
|
1231
|
-
self._context.synchronize()
|
1232
|
-
t1 = perf_counter()
|
1233
|
-
self.time_last_track = t1 - t0
|
1234
|
-
else:
|
1235
|
-
self.time_last_track = None
|
1236
|
-
|
1237
1238
|
@staticmethod
|
1238
1239
|
def _get_default_monitor_class():
|
1239
1240
|
return xt.ParticlesMonitor
|
xtrack-0.46.2/xtrack/_version.py
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
__version__ = '0.46.2'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|