xtrack 0.41.1__tar.gz → 0.42.0__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.
Files changed (188) hide show
  1. {xtrack-0.41.1/xtrack.egg-info → xtrack-0.42.0}/PKG-INFO +1 -1
  2. xtrack-0.42.0/xtrack/_version.py +1 -0
  3. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements.py +153 -4
  4. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/multipolar_kick.h +0 -6
  5. xtrack-0.42.0/xtrack/beam_elements/elements_src/sextupole.h +67 -0
  6. xtrack-0.42.0/xtrack/beam_elements/elements_src/solenoid.h +151 -0
  7. xtrack-0.42.0/xtrack/footprint.py +382 -0
  8. xtrack-0.42.0/xtrack/headers/atomicadd.h +41 -0
  9. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/line.py +35 -40
  10. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/mad_loader.py +29 -29
  11. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/match.py +2 -2
  12. xtrack-0.42.0/xtrack/monitors/__init__.py +6 -0
  13. xtrack-0.42.0/xtrack/monitors/beam_position_monitor.h +67 -0
  14. xtrack-0.42.0/xtrack/monitors/beam_position_monitor.py +138 -0
  15. xtrack-0.42.0/xtrack/monitors/beam_profile_monitor.h +88 -0
  16. xtrack-0.42.0/xtrack/monitors/beam_profile_monitor.py +209 -0
  17. xtrack-0.42.0/xtrack/monitors/beam_size_monitor.h +69 -0
  18. xtrack-0.42.0/xtrack/monitors/beam_size_monitor.py +151 -0
  19. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/multiline/multiline.py +1 -24
  20. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/prebuilt_kernels/kernel_definitions.py +1 -0
  21. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/slicing.py +33 -12
  22. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/survey.py +5 -5
  23. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/tracker.py +17 -11
  24. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/twiss.py +2 -1
  25. {xtrack-0.41.1 → xtrack-0.42.0/xtrack.egg-info}/PKG-INFO +1 -1
  26. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack.egg-info/SOURCES.txt +9 -49
  27. xtrack-0.41.1/tests/test_acceleration.py +0 -44
  28. xtrack-0.41.1/tests/test_aperture_turn_ele_and_monitor.py +0 -253
  29. xtrack-0.41.1/tests/test_apertures.py +0 -251
  30. xtrack-0.41.1/tests/test_collective_tracker.py +0 -177
  31. xtrack-0.41.1/tests/test_collimation.py +0 -426
  32. xtrack-0.41.1/tests/test_compounds.py +0 -291
  33. xtrack-0.41.1/tests/test_element_internal_record.py +0 -827
  34. xtrack-0.41.1/tests/test_elements.py +0 -1484
  35. xtrack-0.41.1/tests/test_elements_thick.py +0 -764
  36. xtrack-0.41.1/tests/test_footprint.py +0 -219
  37. xtrack-0.41.1/tests/test_freeze_longitudinal.py +0 -134
  38. xtrack-0.41.1/tests/test_full_rings.py +0 -204
  39. xtrack-0.41.1/tests/test_ions.py +0 -57
  40. xtrack-0.41.1/tests/test_lhc_match_phase_15.py +0 -585
  41. xtrack-0.41.1/tests/test_line.py +0 -876
  42. xtrack-0.41.1/tests/test_lumi.py +0 -115
  43. xtrack-0.41.1/tests/test_madloader.py +0 -647
  44. xtrack-0.41.1/tests/test_match_and_track_from_element.py +0 -163
  45. xtrack-0.41.1/tests/test_match_nested.py +0 -198
  46. xtrack-0.41.1/tests/test_match_optics_and_ip_knob.py +0 -692
  47. xtrack-0.41.1/tests/test_match_orbit_bump.py +0 -234
  48. xtrack-0.41.1/tests/test_match_tune_chroma_cminus.py +0 -219
  49. xtrack-0.41.1/tests/test_monitor.py +0 -177
  50. xtrack-0.41.1/tests/test_multiline.py +0 -65
  51. xtrack-0.41.1/tests/test_multisetter.py +0 -118
  52. xtrack-0.41.1/tests/test_orbit_correction.py +0 -270
  53. xtrack-0.41.1/tests/test_overriden_particle.py +0 -125
  54. xtrack-0.41.1/tests/test_pipeline.py +0 -132
  55. xtrack-0.41.1/tests/test_prebuild_kernels.py +0 -69
  56. xtrack-0.41.1/tests/test_psb_chicane.py +0 -391
  57. xtrack-0.41.1/tests/test_pyht_interface.py +0 -250
  58. xtrack-0.41.1/tests/test_radial_steering.py +0 -63
  59. xtrack-0.41.1/tests/test_radiation.py +0 -224
  60. xtrack-0.41.1/tests/test_radiation_equilibrium_emittances.py +0 -195
  61. xtrack-0.41.1/tests/test_random_gen.py +0 -95
  62. xtrack-0.41.1/tests/test_random_gen_exp.py +0 -97
  63. xtrack-0.41.1/tests/test_random_gen_gauss.py +0 -95
  64. xtrack-0.41.1/tests/test_random_gen_ruth.py +0 -128
  65. xtrack-0.41.1/tests/test_slicing.py +0 -272
  66. xtrack-0.41.1/tests/test_spacecharge_in_ring.py +0 -221
  67. xtrack-0.41.1/tests/test_sps_thick.py +0 -208
  68. xtrack-0.41.1/tests/test_survey.py +0 -63
  69. xtrack-0.41.1/tests/test_tapering.py +0 -125
  70. xtrack-0.41.1/tests/test_thick_lhc.py +0 -178
  71. xtrack-0.41.1/tests/test_tracker.py +0 -504
  72. xtrack-0.41.1/tests/test_twiss.py +0 -1387
  73. xtrack-0.41.1/tests/test_twiss_vs_madx_psb.py +0 -48
  74. xtrack-0.41.1/tests/test_var_cache.py +0 -211
  75. xtrack-0.41.1/tests/test_vs_madx.py +0 -603
  76. xtrack-0.41.1/xtrack/_version.py +0 -1
  77. xtrack-0.41.1/xtrack/footprint.py +0 -197
  78. xtrack-0.41.1/xtrack/monitors/__init__.py +0 -3
  79. {xtrack-0.41.1 → xtrack-0.42.0}/LICENSE +0 -0
  80. {xtrack-0.41.1 → xtrack-0.42.0}/MANIFEST.in +0 -0
  81. {xtrack-0.41.1 → xtrack-0.42.0}/README.md +0 -0
  82. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/__init__.py +0 -0
  83. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/base_classes.py +0 -0
  84. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/be_beamfields/BB6D.py +0 -0
  85. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/be_beamfields/BB6Ddata.py +0 -0
  86. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/be_beamfields/__init__.py +0 -0
  87. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/be_beamfields/beambeam.py +0 -0
  88. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/be_beamfields/boost.py +0 -0
  89. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/be_beamfields/gaussian_fields.py +0 -0
  90. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/be_beamfields/propagate_sigma_matrix.py +0 -0
  91. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/be_beamfields/qgauss.py +0 -0
  92. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/be_beamfields/slicing.py +0 -0
  93. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/be_beamfields/spacecharge.py +0 -0
  94. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/elements.py +0 -0
  95. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/line.py +0 -0
  96. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/mathlibs.py +0 -0
  97. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/particles.py +0 -0
  98. {xtrack-0.41.1 → xtrack-0.42.0}/ducktrack/temp_pyparticles.py +0 -0
  99. {xtrack-0.41.1 → xtrack-0.42.0}/pyproject.toml +0 -0
  100. {xtrack-0.41.1 → xtrack-0.42.0}/setup.cfg +0 -0
  101. {xtrack-0.41.1 → xtrack-0.42.0}/setup.py +0 -0
  102. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/__init__.py +0 -0
  103. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/_temp/__init__.py +0 -0
  104. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/_temp/lhc_match/__init__.py +0 -0
  105. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/_temp/lhc_match/gen_madx_optics_file.py +0 -0
  106. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/_temp/lhc_match/lhc_match.py +0 -0
  107. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/_temp/lhc_match/var_limits.py +0 -0
  108. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/base_element.py +0 -0
  109. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/__init__.py +0 -0
  110. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/apertures.py +0 -0
  111. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/apertures_src/limitellipse.h +0 -0
  112. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/apertures_src/limitpolygon.h +0 -0
  113. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/apertures_src/limitracetrack.h +0 -0
  114. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/apertures_src/limitrect.h +0 -0
  115. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/apertures_src/limitrectellipse.h +0 -0
  116. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/apertures_src/longitudinallimitrect.h +0 -0
  117. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/beam_interaction.py +0 -0
  118. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/bend.h +0 -0
  119. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/cavity.h +0 -0
  120. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/combinedfunctionmagnet.h +0 -0
  121. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/dipoleedge.h +0 -0
  122. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/drift.h +0 -0
  123. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/drift_elem.h +0 -0
  124. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/elens.h +0 -0
  125. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/exciter.h +0 -0
  126. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/firstordertaylormap.h +0 -0
  127. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/fringe.h +0 -0
  128. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/fringe_track.h +0 -0
  129. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/lineartransfermatrix.h +0 -0
  130. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/linesegmentmap.h +0 -0
  131. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/multipole.h +0 -0
  132. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/nonlinearlens.h +0 -0
  133. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/quadrupole.h +0 -0
  134. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/referenceenergyincrease.h +0 -0
  135. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/rfmultipole.h +0 -0
  136. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/simplethinbend.h +0 -0
  137. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/simplethinquadrupole.h +0 -0
  138. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/srotation.h +0 -0
  139. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/track_thick_bend.h +0 -0
  140. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/track_thick_cfd.h +0 -0
  141. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/track_yrotation.h +0 -0
  142. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/wedge.h +0 -0
  143. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/wedge_track.h +0 -0
  144. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/wire.h +0 -0
  145. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/xrotation.h +0 -0
  146. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/xyshift.h +0 -0
  147. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/yrotation.h +0 -0
  148. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/elements_src/zetashift.h +0 -0
  149. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/beam_elements/exciter.py +0 -0
  150. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/compounds.py +0 -0
  151. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/general.py +0 -0
  152. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/headers/checks.h +0 -0
  153. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/headers/constants.h +0 -0
  154. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/headers/particle_states.h +0 -0
  155. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/headers/synrad_spectrum.h +0 -0
  156. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/internal_record.py +0 -0
  157. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/linear_normal_form.py +0 -0
  158. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/loss_location_refinement/__init__.py +0 -0
  159. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/loss_location_refinement/loss_location_refinement.py +0 -0
  160. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/lumi.py +0 -0
  161. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/monitors/last_turns_monitor.h +0 -0
  162. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/monitors/last_turns_monitor.py +0 -0
  163. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/monitors/particles_monitor.h +0 -0
  164. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/monitors/particles_monitor.py +0 -0
  165. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/multiline/__init__.py +0 -0
  166. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/multiline/shared_knobs.py +0 -0
  167. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/multisetter/__init__.py +0 -0
  168. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/multisetter/multisetter.py +0 -0
  169. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/pipeline/__init__.py +0 -0
  170. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/pipeline/core.py +0 -0
  171. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/pipeline/manager.py +0 -0
  172. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/pipeline/multitracker.py +0 -0
  173. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/prebuild_kernels.py +0 -0
  174. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/prebuilt_kernels/__init__.py +0 -0
  175. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/random/__init__.py +0 -0
  176. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/random/random_generators.py +0 -0
  177. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/random/random_src/exponential.h +0 -0
  178. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/random/random_src/exponential_integral_Ei.h +0 -0
  179. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/random/random_src/normal.h +0 -0
  180. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/random/random_src/rutherford.h +0 -0
  181. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/random/random_src/uniform.h +0 -0
  182. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/tapering.py +0 -0
  183. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/targets.py +0 -0
  184. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/tracker_data.py +0 -0
  185. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack/tracker_src/tracker.h +0 -0
  186. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack.egg-info/dependency_links.txt +0 -0
  187. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack.egg-info/requires.txt +0 -0
  188. {xtrack-0.41.1 → xtrack-0.42.0}/xtrack.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xtrack
3
- Version: 0.41.1
3
+ Version: 0.42.0
4
4
  Summary: Tracking library for particle accelerators
5
5
  Home-page: https://xsuite.readthedocs.io/
6
6
  Download-URL: https://pypi.python.org/pypi/xtrack
@@ -0,0 +1 @@
1
+ __version__ = '0.42.0'
@@ -78,9 +78,6 @@ class Drift(BeamElement):
78
78
  _pkg_root.joinpath('beam_elements/elements_src/drift_elem.h'),
79
79
  ]
80
80
 
81
- def make_slice(self, weight):
82
- return Drift(length=self.length * weight)
83
-
84
81
  @staticmethod
85
82
  def add_slice(weight, container, thick_name, slice_name, _buffer=None):
86
83
  container[slice_name] = Drift(_buffer=_buffer)
@@ -666,7 +663,7 @@ class Multipole(BeamElement):
666
663
  if ksl is not None:
667
664
  nksl[: len(ksl)] = np.array(ksl)
668
665
 
669
- if 'delta_teper' not in kwargs.keys():
666
+ if 'delta_taper' not in kwargs.keys():
670
667
  kwargs['delta_taper'] = 0.0
671
668
 
672
669
  order = n - 1
@@ -873,6 +870,27 @@ class CombinedFunctionMagnet(BeamElement):
873
870
  ref.length = _get_expr(self_or_ref.length) * weight
874
871
  ref.order = order
875
872
 
873
+ @classmethod
874
+ def add_thick_slice(cls, weight, container, name, slice_name, _buffer=None):
875
+ self_or_ref = container[name]
876
+ container[slice_name] = cls(
877
+ length=self_or_ref.length * weight,
878
+ num_multipole_kicks=self_or_ref.num_multipole_kicks,
879
+ order=self_or_ref.order,
880
+ _buffer=_buffer,
881
+ )
882
+ ref = container[slice_name]
883
+
884
+ ref.k0 = _get_expr(self_or_ref.k0)
885
+ ref.k1 = _get_expr(self_or_ref.k1)
886
+ ref.h = _get_expr(self_or_ref.h)
887
+
888
+ for ii in range(len(self_or_ref.knl)):
889
+ ref.knl[ii] = _get_expr(self_or_ref.knl[ii]) * weight
890
+
891
+ for ii in range(len(self_or_ref.ksl)):
892
+ ref.ksl[ii] = _get_expr(self_or_ref.ksl[ii]) * weight
893
+
876
894
  @staticmethod
877
895
  def delete_element_ref(ref):
878
896
  # Remove the array fields
@@ -890,6 +908,50 @@ class CombinedFunctionMagnet(BeamElement):
890
908
  # Remove the ref to the element itself
891
909
  _unregister_if_preset(ref)
892
910
 
911
+ class Sextupole(BeamElement):
912
+ isthick = True
913
+ has_backtrack = True
914
+
915
+ _xofields={
916
+ 'k2': xo.Float64,
917
+ 'k2s': xo.Float64,
918
+ 'length': xo.Float64,
919
+ }
920
+
921
+ _extra_c_sources = [
922
+ _pkg_root.joinpath('beam_elements/elements_src/drift.h'),
923
+ _pkg_root.joinpath('beam_elements/elements_src/sextupole.h'),
924
+ ]
925
+
926
+ @staticmethod
927
+ def add_slice(weight, container, thick_name, slice_name, _buffer=None):
928
+ self_or_ref = container[thick_name]
929
+
930
+ container[slice_name] = Multipole(knl=np.zeros(3), ksl=np.zeros(3),
931
+ _buffer=_buffer)
932
+ ref = container[slice_name]
933
+
934
+ ref.knl[0] = 0.
935
+ ref.knl[1] = 0.
936
+ ref.knl[2] = weight * (
937
+ _get_expr(self_or_ref.k2) * _get_expr(self_or_ref.length))
938
+
939
+ ref.ksl[0] = 0.
940
+ ref.ksl[1] = 0.
941
+ ref.ksl[2] = weight * (
942
+ _get_expr(self_or_ref.k2s) * _get_expr(self_or_ref.length))
943
+
944
+ ref.order = 2
945
+
946
+ @staticmethod
947
+ def delete_element_ref(ref):
948
+ # Remove the scalar fields
949
+ for field in ['k2', 'k2s', 'length']:
950
+ _unregister_if_preset(getattr(ref, field))
951
+
952
+ # Remove the ref to the element itself
953
+ _unregister_if_preset(ref)
954
+
893
955
 
894
956
  class Quadrupole(BeamElement):
895
957
  isthick = True
@@ -1004,6 +1066,25 @@ class Quadrupole(BeamElement):
1004
1066
  ref.length = _get_expr(self_or_ref.length) * weight
1005
1067
  ref.order = order
1006
1068
 
1069
+ @classmethod
1070
+ def add_thick_slice(cls, weight, container, name, slice_name, _buffer=None):
1071
+ self_or_ref = container[name]
1072
+ container[slice_name] = cls(
1073
+ length=self_or_ref.length * weight,
1074
+ num_multipole_kicks=self_or_ref.num_multipole_kicks,
1075
+ order=self_or_ref.order,
1076
+ _buffer=_buffer,
1077
+ )
1078
+ ref = container[slice_name]
1079
+
1080
+ ref.k1 = _get_expr(self_or_ref.k1)
1081
+
1082
+ for ii in range(len(self_or_ref.knl)):
1083
+ ref.knl[ii] = _get_expr(self_or_ref.knl[ii]) * weight
1084
+
1085
+ for ii in range(len(self_or_ref.ksl)):
1086
+ ref.ksl[ii] = _get_expr(self_or_ref.ksl[ii]) * weight
1087
+
1007
1088
  @staticmethod
1008
1089
  def delete_element_ref(ref):
1009
1090
  # Remove the array fields
@@ -1021,6 +1102,53 @@ class Quadrupole(BeamElement):
1021
1102
  _unregister_if_preset(ref)
1022
1103
 
1023
1104
 
1105
+ class Solenoid(BeamElement):
1106
+ isthick = True
1107
+
1108
+ _xofields = {
1109
+ 'length': xo.Float64,
1110
+ 'ks': xo.Float64,
1111
+ 'ksi': xo.Float64,
1112
+ }
1113
+
1114
+ _extra_c_sources = [
1115
+ _pkg_root.joinpath('beam_elements/elements_src/drift.h'),
1116
+ _pkg_root.joinpath('beam_elements/elements_src/solenoid.h'),
1117
+ ]
1118
+
1119
+ def __init__(self, length=0, ks=0, ksi=0, **kwargs):
1120
+ """
1121
+ Solenoid element.
1122
+
1123
+ Parameters
1124
+ ----------
1125
+ length : float
1126
+ Length of the element in meters.
1127
+ ks : float
1128
+ Strength of the solenoid component in rad / m. Only to be specified
1129
+ when the element is thin, i.e. when `length` == 0.
1130
+ ksi : float
1131
+ Integrated strength of the solenoid component in rad.
1132
+ """
1133
+
1134
+ if '_xobject' in kwargs.keys() and kwargs['_xobject'] is not None:
1135
+ self.xoinitialize(**kwargs)
1136
+ return
1137
+
1138
+ if length == 0:
1139
+ # Fail when trying to create a thin solenoid, as these are not
1140
+ # tested yet
1141
+ raise NotImplementedError('Thin solenoids are not implemented yet.')
1142
+ # self.isthick = False
1143
+
1144
+ if ksi and length:
1145
+ raise ValueError(
1146
+ "The parameter `ksi` can only be specified when `length` == 0."
1147
+ )
1148
+
1149
+ self.xoinitialize(length=length, ks=ks, ksi=ksi, **kwargs)
1150
+
1151
+
1024
1152
  class Bend(BeamElement):
1025
1153
  isthick = True
1026
1154
  has_backtrack = True
@@ -1160,6 +1288,27 @@ class Bend(BeamElement):
1160
1288
  ref.length = _get_expr(self_or_ref.length) * weight
1161
1289
  ref.order = order
1162
1290
 
1291
+ @classmethod
1292
+ def add_thick_slice(cls, weight, container, name, slice_name, _buffer=None):
1293
+ self_or_ref = container[name]
1294
+ container[slice_name] = cls(
1295
+ length=self_or_ref.length * weight,
1296
+ num_multipole_kicks=self_or_ref.num_multipole_kicks,
1297
+ order=self_or_ref.order,
1298
+ _buffer=_buffer,
1299
+ )
1300
+ ref = container[slice_name]
1301
+
1302
+ ref.k0 = _get_expr(self_or_ref.k0)
1303
+ ref.h = _get_expr(self_or_ref.h)
1304
+ ref.length = _get_expr(self_or_ref.length) * weight
1305
+
1306
+ for ii in range(len(self_or_ref.knl)):
1307
+ ref.knl[ii] = _get_expr(self_or_ref.knl[ii]) * weight
1308
+
1309
+ for ii in range(len(self_or_ref.ksl)):
1310
+ ref.ksl[ii] = _get_expr(self_or_ref.ksl[ii]) * weight
1311
+
1163
1312
  @staticmethod
1164
1313
  def delete_element_ref(ref):
1165
1314
  # Remove the array fields
@@ -27,12 +27,6 @@ void multipolar_kick(
27
27
  double dpx = knl[index] * inv_factorial;
28
28
  double dpy = ksl[index] * inv_factorial;
29
29
 
30
- #ifdef XTRACK_MULTIPOLE_TAPER
31
- double const delta_taper = LocalParticle_get_delta(part);
32
- dpx = dpx * (1 + delta_taper);
33
- dpy = dpy * (1 + delta_taper);
34
- #endif
35
-
36
30
  double const x = LocalParticle_get_x(part);
37
31
  double const y = LocalParticle_get_y(part);
38
32
  double const chi = LocalParticle_get_chi(part);
@@ -0,0 +1,67 @@
1
+ // copyright ############################### //
2
+ // This file is part of the Xtrack Package. //
3
+ // Copyright (c) CERN, 2023. //
4
+ // ######################################### //
5
+
6
+ #ifndef XTRACK_SEXTUPOLE_H
7
+ #define XTRACK_SEXTUPOLE_H
8
+
9
+ /*gpufun*/
10
+ void Sextupole_track_local_particle(
11
+ SextupoleData el,
12
+ LocalParticle* part0
13
+ ) {
14
+ double length = SextupoleData_get_length(el);
15
+
16
+ #ifdef XSUITE_BACKTRACK
17
+ length = -length;
18
+ #endif
19
+
20
+ double const k2 = SextupoleData_get_k2(el);
21
+ double const k2s = SextupoleData_get_k2s(el);
22
+
23
+ double const knl2 = k2 * length;
24
+ double const ksl2 = k2s * length;
25
+
26
+ //start_per_particle_block (part0->part)
27
+
28
+ // Drift
29
+ Drift_single_particle(part, length / 2.);
30
+
31
+ // Sextupolar kick
32
+ int64_t index = 2;
33
+ double const inv_factorial = 0.5; // 1 / factorial(2)
34
+ double dpx = knl2 * inv_factorial;
35
+ double dpy = ksl2 * inv_factorial;
36
+
37
+ double const x = LocalParticle_get_x(part);
38
+ double const y = LocalParticle_get_y(part);
39
+ double const chi = LocalParticle_get_chi(part);
40
+
41
+ while( index > 0 )
42
+ {
43
+ double const zre = dpx * x - dpy * y;
44
+ double const zim = dpx * y + dpy * x;
45
+
46
+ index -= 1;
47
+
48
+ dpx = zre;
49
+ dpy = zim;
50
+ }
51
+
52
+ dpx = -chi * dpx; // rad
53
+ dpy = chi * dpy; // rad
54
+
55
+ LocalParticle_add_to_px(part, dpx);
56
+ LocalParticle_add_to_py(part, dpy);
57
+
58
+ // Drift
59
+ Drift_single_particle(part, length / 2.);
60
+
61
+
62
+ //end_per_particle_block
63
+
64
+
65
+ }
66
+
67
+ #endif // XTRACK_SEXTUPOLE_H
@@ -0,0 +1,151 @@
1
+ // copyright ############################### //
2
+ // This file is part of the Xtrack Package. //
3
+ // Copyright (c) CERN, 2023. //
4
+ // ######################################### //
5
+
6
+ #ifndef XTRACK_SOLENOID_H
7
+ #define XTRACK_SOLENOID_H
8
+
9
+ #define IS_ZERO(X) (fabs(X) < 1e-9)
10
+
11
+ /*gpufun*/
12
+ void Solenoid_thin_track_single_particle(LocalParticle*, double, double, double);
13
+
14
+ /*gpufun*/
15
+ void Solenoid_thick_track_single_particle(LocalParticle*, double, double);
16
+
17
+
18
+ /*gpufun*/
19
+ void Solenoid_track_local_particle(SolenoidData el, LocalParticle* part0) {
20
+ // Parameters
21
+ const double length = SolenoidData_get_length(el);
22
+ const double ks = SolenoidData_get_ks(el);
23
+ const double ksi = SolenoidData_get_ksi(el);
24
+
25
+ if (IS_ZERO(length)) {
26
+ //start_per_particle_block (part0->part)
27
+ Solenoid_thin_track_single_particle(part, length, ks, ksi);
28
+ //end_per_particle_block
29
+ }
30
+ else {
31
+ //start_per_particle_block (part0->part)
32
+ Solenoid_thick_track_single_particle(part, length, ks);
33
+ //end_per_particle_block
34
+ }
35
+ }
36
+
37
+
38
+ /*gpufun*/
39
+ void Solenoid_thin_track_single_particle(
40
+ LocalParticle* part,
41
+ double length,
42
+ double ks,
43
+ double ksi
44
+ ) {
45
+ const double sk = ks / 2; // todo?: flip sign to change beam direction
46
+ const double skl = ksi / 2;
47
+ const double beta0 = LocalParticle_get_beta0(part);
48
+
49
+ // Particle coordinates
50
+ const double x = LocalParticle_get_x(part);
51
+ const double px = LocalParticle_get_px(part);
52
+ const double y = LocalParticle_get_y(part);
53
+ const double py = LocalParticle_get_py(part);
54
+ const double t = LocalParticle_get_zeta(part) / beta0;
55
+ const double pt = LocalParticle_get_ptau(part);
56
+ const double delta = LocalParticle_get_delta(part);
57
+
58
+ // Useful quantities
59
+ const double psigf = pt / beta0;
60
+ const double betas = beta0;
61
+
62
+ const double onedp = 1 + delta;
63
+ const double fppsig = (1 + (betas * betas) * psigf) / onedp;
64
+
65
+ // Set up C, S, Q, R, Z
66
+ const double cosTh = cos(skl / onedp);
67
+ const double sinTh = sin(skl / onedp);
68
+ const double Q = -skl * sk / onedp;
69
+ const double Z = fppsig / (onedp * onedp) * skl;
70
+ const double R = Z * sk;
71
+
72
+ const double pxf = px + x * Q;
73
+ const double pyf = py + y * Q;
74
+ const double sigf = t * betas - 0.5 * (x * x + y * y) * R;
75
+
76
+ // Final angles after solenoid
77
+ const double pxf_ = pxf * cosTh + pyf * sinTh;
78
+ const double pyf_ = -pxf * sinTh + pyf * cosTh;
79
+
80
+ // Calculate new coordinates
81
+ const double new_x = x * cosTh + y * sinTh;
82
+ const double new_px = pxf_;
83
+ const double new_y = -x * sinTh + y * cosTh;
84
+ const double new_py = pyf_;
85
+ const double new_zeta = sigf + (x * new_py - y * new_px) * Z;
86
+
87
+ LocalParticle_set_x(part, new_x);
88
+ LocalParticle_set_px(part, new_px);
89
+ LocalParticle_set_y(part, new_y);
90
+ LocalParticle_set_py(part, new_py);
91
+ LocalParticle_set_zeta(part, new_zeta);
92
+ }
93
+
94
+
95
+ /*gpufun*/
96
+ void Solenoid_thick_track_single_particle(
97
+ LocalParticle* part,
98
+ double length,
99
+ double ks
100
+ ) {
101
+ const double sk = ks / 2; // todo?: flip sign to change beam direction
102
+
103
+ if (IS_ZERO(sk)) {
104
+ Drift_single_particle(part, length);
105
+ return;
106
+ }
107
+
108
+ const double skl = sk * length;
109
+
110
+ // Particle coordinates
111
+ const double x = LocalParticle_get_x(part);
112
+ const double px = LocalParticle_get_px(part);
113
+ const double y = LocalParticle_get_y(part);
114
+ const double py = LocalParticle_get_py(part);
115
+ const double delta = LocalParticle_get_delta(part);
116
+ const double rvv = LocalParticle_get_rvv(part);
117
+
118
+ // set up constants
119
+ const double pk1 = px + sk * y;
120
+ const double pk2 = py - sk * x;
121
+ const double ptr2 = pk1 * pk1 + pk2 * pk2;
122
+ const double one_plus_delta = 1 + delta;
123
+ const double one_plus_delta_sq = one_plus_delta * one_plus_delta;
124
+ const double pz = sqrt(one_plus_delta_sq - ptr2);
125
+
126
+ // set up constants
127
+ const double cosTh = cos(skl / pz);
128
+ const double sinTh = sin(skl / pz);
129
+
130
+ const double si = sin(skl / pz) / sk;
131
+ const double rps[4] = {
132
+ cosTh * x + sinTh * y,
133
+ cosTh * px + sinTh * py,
134
+ cosTh * y - sinTh * x,
135
+ cosTh * py - sinTh * px
136
+ };
137
+ const double new_x = cosTh * rps[0] + si * rps[1];
138
+ const double new_px = cosTh * rps[1] - sk * sinTh * rps[0];
139
+ const double new_y = cosTh * rps[2] + si * rps[3];
140
+ const double new_py = cosTh * rps[3] - sk * sinTh * rps[2];
141
+ const double add_to_zeta = length * (1 - one_plus_delta / (pz * rvv));
142
+
143
+ LocalParticle_set_x(part, new_x);
144
+ LocalParticle_set_px(part, new_px);
145
+ LocalParticle_set_y(part, new_y);
146
+ LocalParticle_set_py(part, new_py);
147
+ LocalParticle_add_to_zeta(part, add_to_zeta);
148
+ LocalParticle_add_to_s(part, length);
149
+ }
150
+
151
+ #endif // XTRACK_SOLENOID_H