xtrack 0.88.8__tar.gz → 0.89.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 (348) hide show
  1. {xtrack-0.88.8/xtrack.egg-info → xtrack-0.89.0}/PKG-INFO +1 -1
  2. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/elements.py +213 -0
  3. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_chromatic_functions_vs_madx.py +1 -1
  4. xtrack-0.89.0/tests/test_coupling_edwards_teng.py +131 -0
  5. xtrack-0.89.0/tests/test_elements_classflags.py +57 -0
  6. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_line.py +1 -1
  7. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_madloader.py +32 -37
  8. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_magnet.py +1 -1
  9. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_match_and_track_from_element.py +1 -1
  10. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_match_coupling_knob.py +1 -1
  11. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_match_nested.py +1 -1
  12. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_match_optics_and_ip_knob.py +2 -1
  13. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_match_optics_and_ip_knob_new_optimize_api.py +2 -2
  14. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_match_orbit_bump.py +2 -2
  15. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_match_tune_chroma_cminus.py +3 -3
  16. xtrack-0.89.0/tests/test_misalign.py +450 -0
  17. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_multiline.py +1 -1
  18. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_native_madloader.py +7 -4
  19. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_ps_multiturn_twiss.py +1 -1
  20. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_psb_chicane.py +1 -1
  21. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_radiation.py +1 -1
  22. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_rbend_straight_body.py +313 -313
  23. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_slice_and_insert_with_replicas.py +1 -1
  24. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_sps_thick.py +32 -32
  25. xtrack-0.89.0/tests/test_thick_kickers_rf_crab.py +2189 -0
  26. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_thick_lhc.py +1 -1
  27. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_tilt_shifts.py +91 -96
  28. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_twiss.py +5 -61
  29. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_vs_madx.py +17 -25
  30. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_xmask_orbit_correction.py +1 -1
  31. xtrack-0.89.0/xtrack/_version.py +1 -0
  32. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/base_element.py +164 -70
  33. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/__init__.py +9 -5
  34. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements.py +1236 -600
  35. xtrack-0.89.0/xtrack/beam_elements/elements_src/cavity.h +44 -0
  36. xtrack-0.89.0/xtrack/beam_elements/elements_src/crab_cavity.h +44 -0
  37. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/default_magnet_config.h +2 -0
  38. xtrack-0.89.0/xtrack/beam_elements/elements_src/drift_exact.h +27 -0
  39. xtrack-0.89.0/xtrack/beam_elements/elements_src/drift_exact_slice.h +32 -0
  40. xtrack-0.89.0/xtrack/beam_elements/elements_src/drift_slice_cavity.h +37 -0
  41. xtrack-0.89.0/xtrack/beam_elements/elements_src/drift_slice_crab_cavity.h +37 -0
  42. xtrack-0.89.0/xtrack/beam_elements/elements_src/drift_slice_multipole.h +37 -0
  43. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/legacy_solenoid.h +2 -2
  44. xtrack-0.89.0/xtrack/beam_elements/elements_src/misalignment.h +46 -0
  45. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/multipole.h +6 -10
  46. xtrack-0.89.0/xtrack/beam_elements/elements_src/rfmultipole.h +44 -0
  47. xtrack-0.89.0/xtrack/beam_elements/elements_src/temprf.h +43 -0
  48. xtrack-0.89.0/xtrack/beam_elements/elements_src/thick_slice_cavity.h +47 -0
  49. xtrack-0.89.0/xtrack/beam_elements/elements_src/thick_slice_crab_cavity.h +47 -0
  50. xtrack-0.89.0/xtrack/beam_elements/elements_src/thick_slice_multipole.h +71 -0
  51. xtrack-0.89.0/xtrack/beam_elements/elements_src/thin_slice_cavity.h +47 -0
  52. xtrack-0.89.0/xtrack/beam_elements/elements_src/thin_slice_crab_cavity.h +47 -0
  53. xtrack-0.89.0/xtrack/beam_elements/elements_src/thin_slice_multipole.h +71 -0
  54. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_dipole_edge_nonlinear.h +2 -2
  55. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_magnet.h +18 -153
  56. xtrack-0.89.0/xtrack/beam_elements/elements_src/track_magnet.template.h +510 -0
  57. xtrack-0.89.0/xtrack/beam_elements/elements_src/track_magnet_configure.h +157 -0
  58. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_magnet_edge.h +1 -1
  59. xtrack-0.89.0/xtrack/beam_elements/elements_src/track_misalignments.h +371 -0
  60. xtrack-0.89.0/xtrack/beam_elements/elements_src/track_rf.h +408 -0
  61. xtrack-0.89.0/xtrack/beam_elements/elements_src/track_rf.template.h +327 -0
  62. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_srotation.h +2 -3
  63. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_wedge.h +1 -1
  64. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_xrotation.h +3 -4
  65. xtrack-0.89.0/xtrack/beam_elements/elements_src/track_xyshift.h +17 -0
  66. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_yrotation.h +7 -8
  67. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/xyshift.h +1 -10
  68. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/slice_elements_drift.py +56 -7
  69. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/slice_elements_thick.py +27 -2
  70. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/slice_elements_thin.py +75 -1
  71. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/environment.py +5 -2
  72. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/headers/particle_states.h +2 -0
  73. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/line.py +26 -7
  74. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/mad_loader.py +44 -72
  75. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/mad_parser/loader.py +49 -37
  76. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/mad_writer.py +76 -15
  77. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/particles/particles.py +1 -2
  78. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/survey.py +3 -2
  79. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/tapering.py +14 -5
  80. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/trajectory_correction.py +2 -1
  81. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/twiss.py +137 -138
  82. {xtrack-0.88.8 → xtrack-0.89.0/xtrack.egg-info}/PKG-INFO +1 -1
  83. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack.egg-info/SOURCES.txt +23 -1
  84. xtrack-0.88.8/tests/test_elements_classflags.py +0 -57
  85. xtrack-0.88.8/xtrack/_version.py +0 -1
  86. xtrack-0.88.8/xtrack/beam_elements/elements_src/cavity.h +0 -23
  87. xtrack-0.88.8/xtrack/beam_elements/elements_src/rfmultipole.h +0 -95
  88. xtrack-0.88.8/xtrack/beam_elements/magnets.py +0 -674
  89. {xtrack-0.88.8 → xtrack-0.89.0}/LICENSE +0 -0
  90. {xtrack-0.88.8 → xtrack-0.89.0}/MANIFEST.in +0 -0
  91. {xtrack-0.88.8 → xtrack-0.89.0}/README.md +0 -0
  92. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/__init__.py +0 -0
  93. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/base_classes.py +0 -0
  94. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/be_beamfields/BB6D.py +0 -0
  95. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/be_beamfields/BB6Ddata.py +0 -0
  96. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/be_beamfields/__init__.py +0 -0
  97. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/be_beamfields/beambeam.py +0 -0
  98. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/be_beamfields/boost.py +0 -0
  99. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/be_beamfields/gaussian_fields.py +0 -0
  100. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/be_beamfields/propagate_sigma_matrix.py +0 -0
  101. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/be_beamfields/qgauss.py +0 -0
  102. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/be_beamfields/slicing.py +0 -0
  103. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/be_beamfields/spacecharge.py +0 -0
  104. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/line.py +0 -0
  105. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/mathlibs.py +0 -0
  106. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/particles.py +0 -0
  107. {xtrack-0.88.8 → xtrack-0.89.0}/ducktrack/temp_pyparticles.py +0 -0
  108. {xtrack-0.88.8 → xtrack-0.89.0}/pyproject.toml +0 -0
  109. {xtrack-0.88.8 → xtrack-0.89.0}/setup.cfg +0 -0
  110. {xtrack-0.88.8 → xtrack-0.89.0}/setup.py +0 -0
  111. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_acceleration.py +0 -0
  112. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_amplitude_detuning.py +0 -0
  113. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_aperture_table.py +0 -0
  114. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_aperture_turn_ele_and_monitor.py +0 -0
  115. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_apertures.py +0 -0
  116. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_attr_replicas_and_slices.py +0 -0
  117. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_bucket_with_ref_energy_change.py +0 -0
  118. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_cavity_absolute_time.py +0 -0
  119. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_coasting.py +0 -0
  120. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_collective_tracker.py +0 -0
  121. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_collimation.py +0 -0
  122. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_electron_cooler.py +0 -0
  123. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_element_characterization_functions.py +0 -0
  124. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_element_internal_record.py +0 -0
  125. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_elements.py +0 -0
  126. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_elements_thick.py +0 -0
  127. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_environment.py +0 -0
  128. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_fcc_ee_solenoid_correction.py +0 -0
  129. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_fcc_ee_solenoid_correction_new_optimize_api.py +0 -0
  130. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_footprint.py +0 -0
  131. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_freeze_longitudinal.py +0 -0
  132. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_full_rings.py +0 -0
  133. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_h6_sps_beamline.py +0 -0
  134. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_hvkick.py +0 -0
  135. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_ions.py +0 -0
  136. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_legacy_multiline_to_env.py +0 -0
  137. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_lhc_env.py +0 -0
  138. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_lhc_match_phase_15.py +0 -0
  139. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_load.py +0 -0
  140. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_load_vars.py +0 -0
  141. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_lumi.py +0 -0
  142. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_mad_writer.py +0 -0
  143. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_madnginterface.py +0 -0
  144. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_monitor.py +0 -0
  145. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_multi_bunch_gauss.py +0 -0
  146. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_multisetter.py +0 -0
  147. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_multispecies.py +0 -0
  148. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_optimize_for_tracking.py +0 -0
  149. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_particles.py +0 -0
  150. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_particles_basics.py +0 -0
  151. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_particles_pdg.py +0 -0
  152. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_periodic_symmetric_twiss_and_match.py +0 -0
  153. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_pipeline.py +0 -0
  154. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_prebuild_kernels.py +0 -0
  155. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_ps_against_ptc.py +0 -0
  156. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_pyht_interface.py +0 -0
  157. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_quadrupole_fringe_ptc.py +0 -0
  158. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_quadrupole_wedge.py +0 -0
  159. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_radial_steering.py +0 -0
  160. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_radiation_equilibrium_emittances.py +0 -0
  161. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_radiation_equilibrium_emittances_thick.py +0 -0
  162. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_radiation_integrals.py +0 -0
  163. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_random_gen.py +0 -0
  164. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_random_gen_exp.py +0 -0
  165. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_random_gen_gauss.py +0 -0
  166. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_random_gen_ruth.py +0 -0
  167. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_rbend_rbarc.py +0 -0
  168. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_rf_track.py +0 -0
  169. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_rotation_signs.py +0 -0
  170. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_second_order_taylor_map.py +0 -0
  171. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_seeds.py +0 -0
  172. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_slice_elements.py +0 -0
  173. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_slicing.py +0 -0
  174. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_solenoid_bz_map_vs_boris.py +0 -0
  175. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_solenoid_bz_map_vs_boris_legacy.py +0 -0
  176. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_spacecharge_in_ring.py +0 -0
  177. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_spin.py +0 -0
  178. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_survey.py +0 -0
  179. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_tapering.py +0 -0
  180. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_tracker.py +0 -0
  181. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_trajectory_correcton.py +0 -0
  182. {xtrack-0.88.8 → xtrack-0.89.0}/tests/test_twiss_vs_madx_psb.py +0 -0
  183. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/__init__.py +0 -0
  184. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/_temp/__init__.py +0 -0
  185. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/_temp/boris_and_solenoid_map/__init__.py +0 -0
  186. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/_temp/boris_and_solenoid_map/boris.h +0 -0
  187. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/_temp/boris_and_solenoid_map/solenoid_field.py +0 -0
  188. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/_temp/lhc_match/__init__.py +0 -0
  189. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/_temp/lhc_match/gen_madx_optics_file.py +0 -0
  190. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/_temp/lhc_match/lhc_match.py +0 -0
  191. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/_temp/lhc_match/var_limits.py +0 -0
  192. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/aperture_meas.py +0 -0
  193. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/apertures.py +0 -0
  194. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/apertures_src/limitellipse.h +0 -0
  195. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/apertures_src/limitpolygon.h +0 -0
  196. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/apertures_src/limitracetrack.h +0 -0
  197. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/apertures_src/limitrect.h +0 -0
  198. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/apertures_src/limitrectellipse.h +0 -0
  199. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/apertures_src/longitudinallimitrect.h +0 -0
  200. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/beam_interaction.py +0 -0
  201. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/bend.h +0 -0
  202. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/dipole_fringe.h +0 -0
  203. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/dipoleedge.h +0 -0
  204. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/drift.h +0 -0
  205. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/drift_slice.h +0 -0
  206. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/drift_slice_bend.h +0 -0
  207. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/drift_slice_octupole.h +0 -0
  208. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/drift_slice_quadrupole.h +0 -0
  209. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/drift_slice_rbend.h +0 -0
  210. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/drift_slice_sextupole.h +0 -0
  211. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/drift_slice_uniform_solenoid.h +0 -0
  212. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/electroncooler.h +0 -0
  213. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/elens.h +0 -0
  214. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/exciter.h +0 -0
  215. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/firstordertaylormap.h +0 -0
  216. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/linesegmentmap.h +0 -0
  217. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/magnet.h +0 -0
  218. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/magnet_drift.h +0 -0
  219. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/magnet_edge.h +0 -0
  220. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/magnet_kick.h +0 -0
  221. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/marker.h +0 -0
  222. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/multipoleedge.h +0 -0
  223. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/nonlinearlens.h +0 -0
  224. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/octupole.h +0 -0
  225. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/quadrupole.h +0 -0
  226. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/rbend.h +0 -0
  227. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/referenceenergyincrease.h +0 -0
  228. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/second_order_taylor_map.h +0 -0
  229. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/sextupole.h +0 -0
  230. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/simplethinbend.h +0 -0
  231. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/simplethinquadrupole.h +0 -0
  232. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/slnd.h +0 -0
  233. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/srotation.h +0 -0
  234. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thick_slice_bend.h +0 -0
  235. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thick_slice_octupole.h +0 -0
  236. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thick_slice_quadrupole.h +0 -0
  237. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thick_slice_rbend.h +0 -0
  238. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thick_slice_sextupole.h +0 -0
  239. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thick_slice_uniform_solenoid.h +0 -0
  240. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_bend.h +0 -0
  241. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_bend_entry.h +0 -0
  242. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_bend_exit.h +0 -0
  243. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_octupole.h +0 -0
  244. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_octupole_entry.h +0 -0
  245. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_octupole_exit.h +0 -0
  246. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_quadrupole.h +0 -0
  247. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_quadrupole_entry.h +0 -0
  248. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_quadrupole_exit.h +0 -0
  249. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_rbend.h +0 -0
  250. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_rbend_entry.h +0 -0
  251. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_rbend_exit.h +0 -0
  252. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_sextupole.h +0 -0
  253. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_sextupole_entry.h +0 -0
  254. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_sextupole_exit.h +0 -0
  255. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_uniform_solenoid_entry.h +0 -0
  256. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/thin_slice_uniform_solenoid_exit.h +0 -0
  257. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_cavity.h +0 -0
  258. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_dipole_edge_linear.h +0 -0
  259. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_dipole_fringe.h +0 -0
  260. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_drift.h +0 -0
  261. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_legacy_solenoid.h +0 -0
  262. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_legacy_solenoid_multipolar_components.h +0 -0
  263. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_legacy_solenoid_radiation.h +0 -0
  264. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_magnet_drift.h +0 -0
  265. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_magnet_kick.h +0 -0
  266. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_magnet_radiation.h +0 -0
  267. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_mult_fringe.h +0 -0
  268. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_thick_bend.h +0 -0
  269. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/track_thick_cfd.h +0 -0
  270. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/variable_solenoid.h +0 -0
  271. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/wedge.h +0 -0
  272. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/wire.h +0 -0
  273. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/xrotation.h +0 -0
  274. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/yrotation.h +0 -0
  275. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/elements_src/zetashift.h +0 -0
  276. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/exciter.py +0 -0
  277. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/rft_element.py +0 -0
  278. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/slice_base.py +0 -0
  279. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/beam_elements/slice_elements_edge.py +0 -0
  280. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/footprint.py +0 -0
  281. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/general.py +0 -0
  282. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/headers/atomicadd.h +0 -0
  283. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/headers/checks.h +0 -0
  284. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/headers/constants.h +0 -0
  285. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/headers/synrad_spectrum.h +0 -0
  286. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/headers/track.h +0 -0
  287. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/internal_record.py +0 -0
  288. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/json.py +0 -0
  289. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/linear_normal_form.py +0 -0
  290. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/load.py +0 -0
  291. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/loss_location_refinement/__init__.py +0 -0
  292. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/loss_location_refinement/loss_location_refinement.py +0 -0
  293. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/lumi.py +0 -0
  294. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/mad_parser/__init__.py +0 -0
  295. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/mad_parser/madx.lark +0 -0
  296. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/mad_parser/parse.py +0 -0
  297. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/madng_interface.py +0 -0
  298. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/match.py +0 -0
  299. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/monitors/__init__.py +0 -0
  300. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/monitors/beam_position_monitor.h +0 -0
  301. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/monitors/beam_position_monitor.py +0 -0
  302. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/monitors/beam_profile_monitor.h +0 -0
  303. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/monitors/beam_profile_monitor.py +0 -0
  304. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/monitors/beam_size_monitor.h +0 -0
  305. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/monitors/beam_size_monitor.py +0 -0
  306. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/monitors/last_turns_monitor.h +0 -0
  307. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/monitors/last_turns_monitor.py +0 -0
  308. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/monitors/particles_monitor.h +0 -0
  309. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/monitors/particles_monitor.py +0 -0
  310. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/multiline.py +0 -0
  311. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/multiline_legacy/__init__.py +0 -0
  312. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/multiline_legacy/multiline_legacy.py +0 -0
  313. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/multiline_legacy/shared_knobs.py +0 -0
  314. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/multisetter/__init__.py +0 -0
  315. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/multisetter/multisetter.py +0 -0
  316. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/particles/__init__.py +0 -0
  317. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/particles/constants.py +0 -0
  318. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/particles/masses.py +0 -0
  319. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/particles/pdg.py +0 -0
  320. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/particles/rng_src/base_rng.h +0 -0
  321. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/particles/rng_src/particles_rng.h +0 -0
  322. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/pipeline/__init__.py +0 -0
  323. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/pipeline/core.py +0 -0
  324. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/pipeline/manager.py +0 -0
  325. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/pipeline/multitracker.py +0 -0
  326. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/progress_indicator.py +0 -0
  327. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/random/__init__.py +0 -0
  328. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/random/random_generators.py +0 -0
  329. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/random/random_src/exponential.h +0 -0
  330. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/random/random_src/exponential_integral_Ei.h +0 -0
  331. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/random/random_src/normal.h +0 -0
  332. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/random/random_src/rutherford.h +0 -0
  333. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/random/random_src/uniform.h +0 -0
  334. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/random/random_src/uniform_accurate.h +0 -0
  335. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/slicing.py +0 -0
  336. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/svgutils/__init__.py +0 -0
  337. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/svgutils/parser.py +0 -0
  338. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/svgutils/path.py +0 -0
  339. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/svgutils/svgutils.py +0 -0
  340. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/synctime.py +0 -0
  341. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/targets.py +0 -0
  342. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/tracker.py +0 -0
  343. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/tracker_data.py +0 -0
  344. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/tracker_src/tracker.h +0 -0
  345. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack/twissplot.py +0 -0
  346. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack.egg-info/dependency_links.txt +0 -0
  347. {xtrack-0.88.8 → xtrack-0.89.0}/xtrack.egg-info/requires.txt +0 -0
  348. {xtrack-0.88.8 → xtrack-0.89.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.88.8
3
+ Version: 0.89.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
@@ -4,6 +4,7 @@
4
4
  # ######################################### #
5
5
 
6
6
  import numpy as np
7
+ import xtrack as xt
7
8
  from scipy.constants import c as clight
8
9
  from scipy.constants import epsilon_0
9
10
  from scipy.constants import mu_0
@@ -45,6 +46,7 @@ _factorial = np.array(
45
46
  ]
46
47
  )
47
48
 
49
+
48
50
  class Marker(Element):
49
51
 
50
52
  _description = []
@@ -52,6 +54,7 @@ class Marker(Element):
52
54
  def track(self, p):
53
55
  pass
54
56
 
57
+
55
58
  class Drift(Element):
56
59
  """Drift in expanded form"""
57
60
 
@@ -382,6 +385,216 @@ class Elens(Element):
382
385
  p.py = yp/p.rpp
383
386
 
384
387
 
388
+ class Misalignment(Element):
389
+ _description = [
390
+ ("dx", "m", "Misalignment in x", 0),
391
+ ("dy", "m", "Misalignment in y", 0),
392
+ ("ds", "m", "Misalignment in s", 0),
393
+ ("theta", "rad", "Rotation around the y axis (positive s to x)", 0),
394
+ ("phi", "rad", "Rotation around the x axis (positive s to y)", 0),
395
+ ("psi", "rad", "Rotation around the s axis (positive y to x)", 0),
396
+ ("anchor", "", "Reference point, anchor, of the misalignment "
397
+ "(0 for entry, 0.5 for middle, 1 for exit, etc.)", 0),
398
+ ("length", "m", "Length of the element to which the misalignment applies", 0),
399
+ ("angle", "rad", "Angle of bending if applicable (0 for straight)", 0),
400
+ ("tilt", "rad", "Tilt of the element (0 for no tilt, positive for tilt towards x)", 0),
401
+ ("is_exit", "", "Whether we are at the exit of the element", False),
402
+ ]
403
+
404
+ def track(self, particles):
405
+ if not self.is_exit:
406
+ if self.angle:
407
+ self.track_bent_entry(particles)
408
+ else:
409
+ self.track_straight_entry(particles)
410
+ else:
411
+ if self.angle:
412
+ self.track_bent_exit(particles)
413
+ else:
414
+ self.track_straight_exit(particles)
415
+
416
+ def track_bent_entry(self, particles):
417
+ dx, dy, ds = self.dx, self.dy, self.ds
418
+ theta, phi, psi = self.theta, self.phi, self.psi
419
+ f, length, angle, tilt = self.anchor, self.length, self.angle, self.tilt
420
+
421
+ s_phi, c_phi = np.sin(phi), np.cos(phi)
422
+ s_theta, c_theta = np.sin(theta), np.cos(theta)
423
+ s_psi, c_psi = np.sin(psi), np.cos(psi)
424
+ misalignment_matrix = np.array([
425
+ [-s_phi * s_psi * s_theta + c_psi * c_theta, -c_psi * s_phi * s_theta - c_theta * s_psi, c_phi * s_theta, dx],
426
+ [c_phi * s_psi, c_phi * c_psi, s_phi, dy],
427
+ [-c_theta * s_phi * s_psi - c_psi * s_theta, -c_psi * c_theta * s_phi + s_psi * s_theta, c_phi * c_theta, ds],
428
+ [0, 0, 0, 1],
429
+ ])
430
+
431
+ rho = length / angle
432
+ matrix_first_half = np.array([
433
+ [
434
+ (np.cos(f * angle) - 1) * np.cos(tilt) ** 2 + 1,
435
+ (np.cos(f * angle) - 1) * np.cos(tilt) * np.sin(tilt),
436
+ -np.cos(tilt) * np.sin(f * angle),
437
+ rho * (np.cos(f * angle) - 1) * np.cos(tilt),
438
+ ],
439
+ [
440
+ (np.cos(f * angle) - 1) * np.cos(tilt) * np.sin(tilt),
441
+ (np.cos(f * angle) - 1) * np.sin(tilt) ** 2 + 1,
442
+ -np.sin(f * angle) * np.sin(tilt),
443
+ rho * (np.cos(f * angle) - 1) * np.sin(tilt),
444
+ ],
445
+ [
446
+ np.cos(tilt) * np.sin(f * angle),
447
+ np.sin(f * angle) * np.sin(tilt),
448
+ np.cos(f * angle),
449
+ rho * np.sin(f * angle),
450
+ ],
451
+ [0, 0, 0, 1],
452
+ ])
453
+
454
+ inv_matrix_first_half = np.linalg.inv(matrix_first_half)
455
+
456
+ temp = matrix_first_half @ misalignment_matrix
457
+
458
+ misaligned_entry = temp @ inv_matrix_first_half
459
+
460
+ mis_x, mis_y, mis_s = misaligned_entry[:3, 3]
461
+ rot_theta = np.arctan2(misaligned_entry[0, 2], misaligned_entry[2, 2])
462
+ rot_phi = np.arctan2(misaligned_entry[1, 2], np.sqrt(misaligned_entry[1, 0] ** 2 + misaligned_entry[1, 1] ** 2))
463
+ rot_psi = np.arctan2(misaligned_entry[1, 0], misaligned_entry[1, 1])
464
+
465
+ line = xt.Line(
466
+ elements=[
467
+ xt.XYShift(dx=mis_x, dy=mis_y),
468
+ xt.DriftExact(length=mis_s),
469
+ xt.YRotation(angle=np.rad2deg(rot_theta)),
470
+ xt.XRotation(angle=np.rad2deg(-rot_phi)), # flipped angle convention
471
+ xt.SRotation(angle=np.rad2deg(rot_psi)),
472
+ ]
473
+ )
474
+
475
+ particles.zeta -= mis_s
476
+ particles.s -= mis_s
477
+ line.track(particles)
478
+
479
+ def track_straight_entry(self, particles):
480
+ dx, dy, ds = self.dx, self.dy, self.ds
481
+ theta, phi, psi = self.theta, self.phi, self.psi
482
+ f, length, angle = self.anchor, self.length, self.angle
483
+
484
+ mis_x = dx - f * length * np.cos(phi) * np.sin(theta)
485
+ mis_y = dy - f * length * np.sin(phi)
486
+ mis_s = ds - f * length * (np.cos(phi) * np.cos(theta) - 1)
487
+
488
+ line = xt.Line(
489
+ elements=[
490
+ xt.XYShift(dx=mis_x, dy=mis_y),
491
+ xt.Solenoid(length=mis_s),
492
+ xt.YRotation(angle=np.rad2deg(theta)),
493
+ xt.XRotation(angle=np.rad2deg(-phi)), # flipped angle convention
494
+ xt.SRotation(angle=np.rad2deg(psi)),
495
+ ]
496
+ )
497
+
498
+ particles.zeta -= mis_s
499
+ particles.s -= mis_s
500
+ line.track(particles)
501
+
502
+ def track_bent_exit(self, particles):
503
+ dx, dy, ds = self.dx, self.dy, self.ds
504
+ theta, phi, psi = self.theta, self.phi, self.psi
505
+ f, length, angle, tilt = self.anchor, self.length, self.angle, self.tilt
506
+
507
+ s_phi, c_phi = np.sin(phi), np.cos(phi)
508
+ s_theta, c_theta = np.sin(theta), np.cos(theta)
509
+ s_psi, c_psi = np.sin(psi), np.cos(psi)
510
+ misalignment_matrix = np.array([
511
+ [-s_phi * s_psi * s_theta + c_psi * c_theta, -c_psi * s_phi * s_theta - c_theta * s_psi, c_phi * s_theta, dx],
512
+ [c_phi * s_psi, c_phi * c_psi, s_phi, dy],
513
+ [-c_theta * s_phi * s_psi - c_psi * s_theta, -c_psi * c_theta * s_phi + s_psi * s_theta, c_phi * c_theta, ds],
514
+ [0, 0, 0, 1],
515
+ ])
516
+
517
+ m00, m01, m02, m03 = misalignment_matrix[0, :]
518
+ m10, m11, m12, m13 = misalignment_matrix[1, :]
519
+ m20, m21, m22, m23 = misalignment_matrix[2, :]
520
+ inv_misalignment_matrix = np.array([
521
+ [m00, m10, m20, -m00 * m03 - m10 * m13 - m20 * m23],
522
+ [m01, m11, m21, -m01 * m03 - m11 * m13 - m21 * m23],
523
+ [m02, m12, m22, -m02 * m03 - m12 * m13 - m22 * m23],
524
+ [0, 0, 0, 1],
525
+ ])
526
+
527
+ f_compl = 1 - f
528
+ rho = length / angle
529
+ matrix_second_half = np.array([
530
+ [
531
+ (np.cos(f_compl * angle) - 1) * np.cos(tilt) ** 2 + 1,
532
+ (np.cos(f_compl * angle) - 1) * np.cos(tilt) * np.sin(tilt),
533
+ np.cos(tilt) * -np.sin(f_compl * angle),
534
+ rho * (np.cos(f_compl * angle) - 1) * np.cos(tilt),
535
+ ],
536
+ [
537
+ (np.cos(f_compl * angle) - 1) * np.cos(tilt) * np.sin(tilt),
538
+ (np.cos(f_compl * angle) - 1) * np.sin(tilt) ** 2 + 1,
539
+ -np.sin(f_compl * angle) * np.sin(tilt),
540
+ rho * (np.cos(f_compl * angle) - 1) * np.sin(tilt),
541
+ ],
542
+ [
543
+ -np.cos(tilt) * -np.sin(f_compl * angle),
544
+ np.sin(f_compl * angle) * np.sin(tilt),
545
+ np.cos(f_compl * angle),
546
+ rho * np.sin(f_compl * angle),
547
+ ],
548
+ [0, 0, 0, 1],
549
+ ])
550
+
551
+ inv_matrix_second_half = np.linalg.inv(matrix_second_half)
552
+
553
+ realign = inv_matrix_second_half @ inv_misalignment_matrix @ matrix_second_half
554
+
555
+ mis_x, mis_y, mis_s = realign[:3, 3]
556
+ rot_theta = np.arctan2(realign[0, 2], realign[2, 2])
557
+ rot_phi = np.arctan2(realign[1, 2], np.sqrt(realign[1, 0] ** 2 + realign[1, 1] ** 2))
558
+ rot_psi = np.arctan2(realign[1, 0], realign[1, 1])
559
+
560
+ line = xt.Line(
561
+ elements=[
562
+ xt.XYShift(dx=mis_x, dy=mis_y),
563
+ xt.Solenoid(length=mis_s),
564
+ xt.YRotation(angle=np.rad2deg(rot_theta)),
565
+ xt.XRotation(angle=np.rad2deg(-rot_phi)), # flipped angle convention
566
+ xt.SRotation(angle=np.rad2deg(rot_psi)),
567
+ ]
568
+ )
569
+
570
+ particles.zeta -= mis_s
571
+ particles.s -= mis_s
572
+ line.track(particles)
573
+
574
+ def track_straight_exit(self, particles):
575
+ dx, dy, ds = self.dx, self.dy, self.ds
576
+ theta, phi, psi = self.theta, self.phi, self.psi
577
+ f, length, angle = self.anchor, self.length, self.angle
578
+
579
+ mis_x = (f - 1) * length * np.cos(phi) * np.sin(theta) - dx
580
+ mis_y = (f - 1) * length * np.sin(phi) - dy
581
+ mis_s = (f - 1) * length * (np.cos(phi) * np.cos(theta) - 1) - ds
582
+
583
+ line = xt.Line(
584
+ elements=[
585
+ xt.SRotation(angle=np.rad2deg(-psi)),
586
+ xt.XRotation(angle=np.rad2deg(phi)), # flipped angle convention
587
+ xt.YRotation(angle=np.rad2deg(-theta)),
588
+ xt.Solenoid(length=mis_s),
589
+ xt.XYShift(dx=mis_x, dy=mis_y),
590
+ ]
591
+ )
592
+
593
+ particles.zeta -= mis_s
594
+ particles.s -= mis_s
595
+ line.track(particles)
596
+
597
+
385
598
  class Wire(Element):
386
599
  """Current-carrying wire"""
387
600
 
@@ -11,7 +11,7 @@ test_data_folder = pathlib.Path(
11
11
 
12
12
  import numpy as np
13
13
 
14
- @for_all_test_contexts
14
+ @for_all_test_contexts(excluding=('ContextCupy', 'ContextPyopencl'))
15
15
  def test_chromatic_functions_vs_madx(test_context):
16
16
 
17
17
  collider = xt.load(test_data_folder /
@@ -0,0 +1,131 @@
1
+ import pathlib
2
+
3
+ import numpy as np
4
+
5
+ import xobjects as xo
6
+ import xtrack as xt
7
+
8
+ from cpymad.madx import Madx
9
+
10
+ test_data_folder = pathlib.Path(
11
+ __file__).parent.joinpath('../test_data').absolute()
12
+
13
+ def test_coupling_edwards_teng():
14
+
15
+ mad = Madx()
16
+ mad.call(str(test_data_folder / 'lhc_2024/lhc.seq'))
17
+ mad.call(str(test_data_folder / 'lhc_2024/injection_optics.madx'))
18
+
19
+ mad.beam()
20
+ mad.use('lhcb1')
21
+
22
+ mad.globals.on_x1 = 0
23
+ mad.globals.on_x2h = 0
24
+ mad.globals.on_x2v = 0
25
+ mad.globals.on_x5 = 0
26
+ mad.globals.on_x8h = 0
27
+ mad.globals.on_x8v = 0
28
+
29
+ mad.globals.on_sep1 = 0
30
+ mad.globals.on_sep2h = 0
31
+ mad.globals.on_sep2v = 0
32
+ mad.globals.on_sep5 = 0
33
+ mad.globals.on_sep8h = 0
34
+ mad.globals.on_sep8v = 0
35
+
36
+ mad.globals.on_a2 = 0
37
+ mad.globals.on_a8 = 0
38
+
39
+ mad.globals['kqs.a67b1'] = 1e-4
40
+
41
+ twmad = mad.twiss()
42
+
43
+ line = xt.Line.from_madx_sequence(mad.sequence.lhcb1, deferred_expressions=True)
44
+ line.particle_ref = xt.Particles(p0c=450e9)
45
+ tw = line.twiss4d(coupling_edw_teng=True)
46
+
47
+
48
+ r11_mad, r12_mad, r21_mad, r22_mad = twmad.r11, twmad.r12, twmad.r21, twmad.r22
49
+
50
+ s_mad = twmad.s
51
+
52
+ r11_mad_at_s = np.interp(tw.s, s_mad, r11_mad)
53
+ r12_mad_at_s = np.interp(tw.s, s_mad, r12_mad)
54
+ r21_mad_at_s = np.interp(tw.s, s_mad, r21_mad)
55
+ r22_mad_at_s = np.interp(tw.s, s_mad, r22_mad)
56
+ betx_mad_at_s = np.interp(tw.s, s_mad, twmad.betx)
57
+ bety_mad_at_s = np.interp(tw.s, s_mad, twmad.bety)
58
+ alfx_mad_at_s = np.interp(tw.s, s_mad, twmad.alfx)
59
+ alfy_mad_at_s = np.interp(tw.s, s_mad, twmad.alfy)
60
+
61
+ rdt_mad_at_s = compute_rdt(r11_mad_at_s, r12_mad_at_s, r21_mad_at_s, r22_mad_at_s,
62
+ betx_mad_at_s, bety_mad_at_s, alfx_mad_at_s, alfy_mad_at_s)
63
+
64
+ xo.assert_allclose(tw.r11_edw_teng, r11_mad_at_s,
65
+ rtol=1e-5, atol=1e-5*np.max(np.abs(r11_mad_at_s)))
66
+ xo.assert_allclose(tw.r12_edw_teng, r12_mad_at_s,
67
+ rtol=1e-5, atol=1e-5*np.max(np.abs(r12_mad_at_s)))
68
+ xo.assert_allclose(tw.r21_edw_teng, r21_mad_at_s,
69
+ rtol=1e-5, atol=1e-5*np.max(np.abs(r21_mad_at_s)))
70
+ xo.assert_allclose(tw.r22_edw_teng, r22_mad_at_s,
71
+ rtol=1e-5, atol=1e-5*np.max(np.abs(r22_mad_at_s)))
72
+ xo.assert_allclose(tw.betx_edw_teng, betx_mad_at_s, atol=0, rtol=1e-5)
73
+
74
+ xo.assert_allclose(tw.betx_edw_teng, betx_mad_at_s, atol=0, rtol=5e-8)
75
+ xo.assert_allclose(tw.alfx_edw_teng, alfx_mad_at_s, atol=1e-4, rtol=1e-8)
76
+ xo.assert_allclose(tw.bety_edw_teng, bety_mad_at_s, atol=0, rtol=5e-8)
77
+ xo.assert_allclose(tw.alfy_edw_teng, alfy_mad_at_s, atol=1e-4, rtol=1e-8)
78
+
79
+ xo.assert_allclose(tw.f1001, rdt_mad_at_s['f1001'],
80
+ atol=1e-5 * np.max(np.abs(rdt_mad_at_s['f1001'])))
81
+ xo.assert_allclose(tw.f1010, rdt_mad_at_s['f1010'],
82
+ atol=1e-5 * np.max(np.abs(rdt_mad_at_s['f1010'])))
83
+
84
+
85
+ def compute_rdt(r11, r12, r21, r22, betx, bety, alfx, alfy):
86
+
87
+ '''
88
+ Developed by CERN OMC team.
89
+ Ported from:
90
+ https://pypi.org/project/optics-functions/
91
+ https://github.com/pylhc/optics_functions
92
+
93
+ Based on Calaga, Tomas, https://journals.aps.org/prab/pdf/10.1103/PhysRevSTAB.8.034001
94
+ '''
95
+
96
+ n = len(r11)
97
+ assert len(r12) == n
98
+ assert len(r21) == n
99
+ assert len(r22) == n
100
+ gx, r, inv_gy = np.zeros((n, 2, 2)), np.zeros((n, 2, 2)), np.zeros((n, 2, 2))
101
+
102
+ # Eq. (16) C = 1 / (1 + |R|) * -J R J
103
+ # rs form after -J R^T J
104
+ r[:, 0, 0] = r22
105
+ r[:, 0, 1] = -r12
106
+ r[:, 1, 0] = -r21
107
+ r[:, 1, 1] = r11
108
+
109
+ r *= 1 / np.sqrt(1 + np.linalg.det(r)[:, None, None])
110
+
111
+ # Cbar = Gx * C * Gy^-1, Eq. (5)
112
+ sqrt_betax = np.sqrt(betx)
113
+ sqrt_betay = np.sqrt(bety)
114
+
115
+ gx[:, 0, 0] = 1 / sqrt_betax
116
+ gx[:, 1, 0] = alfx * gx[:, 0, 0]
117
+ gx[:, 1, 1] = sqrt_betax
118
+
119
+ inv_gy[:, 1, 1] = 1 / sqrt_betay
120
+ inv_gy[:, 1, 0] = -alfy * inv_gy[:, 1, 1]
121
+ inv_gy[:, 0, 0] = sqrt_betay
122
+
123
+ c = np.matmul(gx, np.matmul(r, inv_gy))
124
+ gamma = np.sqrt(1 - np.linalg.det(c))
125
+
126
+ # Eq. (9) and Eq. (10)
127
+ denom = 1 / (4 * gamma)
128
+ f1001 = denom * (+c[:, 0, 1] - c[:, 1, 0] + (c[:, 0, 0] + c[:, 1, 1]) * 1j)
129
+ f1010 = denom * (-c[:, 0, 1] - c[:, 1, 0] + (c[:, 0, 0] - c[:, 1, 1]) * 1j)
130
+
131
+ return {'f1001': f1001, 'f1010': f1010}
@@ -0,0 +1,57 @@
1
+ import xtrack as xt
2
+
3
+ checks = [
4
+ (xt.Drift, dict(_isthick=True, allow_rot_and_shift=False, rot_and_shift_from_parent=None , _inherit_strengths=None)),
5
+ (xt.Multipole, dict(allow_rot_and_shift=True , rot_and_shift_from_parent=None , _inherit_strengths=None)),
6
+ (xt.Marker, dict(_isthick=False, allow_rot_and_shift=False, rot_and_shift_from_parent=None , _inherit_strengths=None)),
7
+ (xt.ReferenceEnergyIncrease, dict(_isthick=False, allow_rot_and_shift=False, rot_and_shift_from_parent=None , _inherit_strengths=None)),
8
+ (xt.Cavity, dict(_isthick=True, allow_rot_and_shift=True , rot_and_shift_from_parent=None , _inherit_strengths=None)),
9
+ (xt.XYShift, dict(_isthick=False, allow_rot_and_shift=False, rot_and_shift_from_parent=None , _inherit_strengths=None)),
10
+ (xt.ZetaShift, dict(_isthick=False, allow_rot_and_shift=False, rot_and_shift_from_parent=None , _inherit_strengths=None)),
11
+ (xt.Elens, dict(_isthick=False, allow_rot_and_shift=True , rot_and_shift_from_parent=None , _inherit_strengths=None)),
12
+ (xt.Wire, dict(_isthick=False, allow_rot_and_shift=True , rot_and_shift_from_parent=None , _inherit_strengths=None)),
13
+ (xt.SRotation, dict(_isthick=False, allow_rot_and_shift=False, rot_and_shift_from_parent=None , _inherit_strengths=None)),
14
+ (xt.YRotation, dict(_isthick=False, allow_rot_and_shift=False, rot_and_shift_from_parent=None , _inherit_strengths=None)),
15
+ (xt.Solenoid, dict(_isthick=True , allow_rot_and_shift=True , rot_and_shift_from_parent=None , _inherit_strengths=None)),
16
+ (xt.UniformSolenoid, dict(_isthick=True , allow_rot_and_shift=True , rot_and_shift_from_parent=None , _inherit_strengths=None)),
17
+ (xt.VariableSolenoid, dict(_isthick=True , allow_rot_and_shift=True , rot_and_shift_from_parent=None , _inherit_strengths=None)),
18
+ (xt.RFMultipole, dict(_isthick=False, allow_rot_and_shift=True , rot_and_shift_from_parent=None , _inherit_strengths=None)),
19
+ (xt.DipoleEdge, dict(_isthick=False, allow_rot_and_shift=True , rot_and_shift_from_parent=None , _inherit_strengths=None)),
20
+ (xt.SimpleThinBend, dict(_isthick=False, allow_rot_and_shift=False, rot_and_shift_from_parent=None , _inherit_strengths=None)),
21
+ (xt.SimpleThinQuadrupole, dict(_isthick=False, allow_rot_and_shift=False, rot_and_shift_from_parent=None , _inherit_strengths=None)),
22
+ (xt.LineSegmentMap, dict(_isthick=True , allow_rot_and_shift=True , rot_and_shift_from_parent=None , _inherit_strengths=None)),
23
+ (xt.NonLinearLens, dict(_isthick=False, allow_rot_and_shift=True , rot_and_shift_from_parent=None , _inherit_strengths=None)),
24
+ (xt.LimitEllipse, dict(_isthick=False, allow_rot_and_shift=True , rot_and_shift_from_parent=None , _inherit_strengths=None)),
25
+ (xt.LimitRectEllipse, dict(_isthick=False, allow_rot_and_shift=True , rot_and_shift_from_parent=None , _inherit_strengths=None)),
26
+ (xt.LimitRect, dict(_isthick=False, allow_rot_and_shift=True , rot_and_shift_from_parent=None , _inherit_strengths=None)),
27
+ (xt.LimitRacetrack, dict(_isthick=False, allow_rot_and_shift=True , rot_and_shift_from_parent=None , _inherit_strengths=None)),
28
+ (xt.LimitPolygon, dict(_isthick=False, allow_rot_and_shift=True , rot_and_shift_from_parent=None , _inherit_strengths=None)),
29
+ (xt.DriftSlice, dict(_isthick=True, allow_rot_and_shift=False, rot_and_shift_from_parent=False, _inherit_strengths=False)),
30
+ (xt.DriftSliceBend, dict(_isthick=True, allow_rot_and_shift=False, rot_and_shift_from_parent=False, _inherit_strengths=False)),
31
+ (xt.DriftSliceOctupole, dict(_isthick=True, allow_rot_and_shift=False, rot_and_shift_from_parent=False, _inherit_strengths=False)),
32
+ (xt.DriftSliceQuadrupole, dict(_isthick=True, allow_rot_and_shift=False, rot_and_shift_from_parent=False, _inherit_strengths=False)),
33
+ (xt.DriftSliceSextupole, dict(_isthick=True, allow_rot_and_shift=False, rot_and_shift_from_parent=False, _inherit_strengths=False)),
34
+ (xt.ThickSliceBend, dict(_isthick=True, allow_rot_and_shift=False, rot_and_shift_from_parent=True , _inherit_strengths=True )),
35
+ (xt.ThickSliceOctupole, dict(_isthick=True, allow_rot_and_shift=False, rot_and_shift_from_parent=True , _inherit_strengths=True )),
36
+ (xt.ThickSliceUniformSolenoid,dict(_isthick=True, allow_rot_and_shift=False, rot_and_shift_from_parent=True , _inherit_strengths=True )),
37
+ (xt.ThickSliceQuadrupole, dict(_isthick=True, allow_rot_and_shift=False, rot_and_shift_from_parent=True , _inherit_strengths=True )),
38
+ (xt.ThickSliceSextupole, dict(_isthick=True, allow_rot_and_shift=False, rot_and_shift_from_parent=True , _inherit_strengths=True )),
39
+ (xt.ThinSliceBend, dict(_isthick=False, allow_rot_and_shift=False, rot_and_shift_from_parent=True , _inherit_strengths=True )),
40
+ (xt.ThinSliceBendEntry, dict(_isthick=False, allow_rot_and_shift=False, rot_and_shift_from_parent=True , _inherit_strengths=False)),
41
+ (xt.ThinSliceBendExit, dict(_isthick=False, allow_rot_and_shift=False, rot_and_shift_from_parent=True , _inherit_strengths=False)),
42
+ (xt.ThinSliceOctupole, dict(_isthick=False, allow_rot_and_shift=False, rot_and_shift_from_parent=True , _inherit_strengths=True )),
43
+ (xt.ThinSliceQuadrupole, dict(_isthick=False, allow_rot_and_shift=False, rot_and_shift_from_parent=True , _inherit_strengths=True )),
44
+ (xt.ThinSliceSextupole, dict(_isthick=False, allow_rot_and_shift=False, rot_and_shift_from_parent=True , _inherit_strengths=True )),
45
+ (xt.ThinSliceUniformSolenoidEntry, dict(_isthick=False, allow_rot_and_shift=False, rot_and_shift_from_parent=True , _inherit_strengths=False)),
46
+ (xt.ThinSliceUniformSolenoidExit, dict(_isthick=False, allow_rot_and_shift=False, rot_and_shift_from_parent=True , _inherit_strengths=False)),
47
+ ]
48
+
49
+ def test_elements_classflags():
50
+ for cls, kwargs in checks:
51
+ for kk, vv in kwargs.items():
52
+ if vv is not None:
53
+ assert getattr(cls, kk) == kwargs[kk], (
54
+ f'{cls.__name__}.{kk} is {getattr(cls, kk)} instead of {kwargs[kk]}')
55
+ else:
56
+ assert not hasattr(cls, kk), (
57
+ f'{cls.__name__}.{kk} should not be defined')
@@ -867,7 +867,7 @@ def test_insert_thin_elements_at_s_basic(test_context):
867
867
  assert t1.s[-2] == 5.
868
868
  assert t1.s[-3] == 5.
869
869
 
870
- @for_all_test_contexts
870
+ @for_all_test_contexts(excluding=('ContextCupy', 'ContextPyopencl'))
871
871
  def test_insert_thin_elements_at_s_lhc(test_context):
872
872
 
873
873
  line = xt.load(test_data_folder /
@@ -366,17 +366,24 @@ def test_thick_kicker_option():
366
366
 
367
367
  beam; use, sequence=ss;
368
368
  """)
369
- line = MadLoader(mad.sequence.ss, enable_expressions=True, allow_thick=True, enable_thick_kickers=True).make_line()
369
+ line = xt.Line.from_madx_sequence(mad.sequence.ss, deferred_expressions=True)
370
370
 
371
371
  _, vk, hk, ki, vk_thin, hk_thin, ki_thin, _ = line.elements
372
372
 
373
- assert isinstance(vk, xt.Magnet)
374
- assert isinstance(hk, xt.Magnet)
375
- assert isinstance(ki, xt.Magnet)
373
+ assert isinstance(vk, xt.Multipole)
374
+ assert isinstance(hk, xt.Multipole)
375
+ assert isinstance(ki, xt.Multipole)
376
376
  assert isinstance(vk_thin, xt.Multipole)
377
377
  assert isinstance(hk_thin, xt.Multipole)
378
378
  assert isinstance(ki_thin, xt.Multipole)
379
379
 
380
+ assert vk.isthick
381
+ assert hk.isthick
382
+ assert ki.isthick
383
+ assert not vk_thin.isthick
384
+ assert not hk_thin.isthick
385
+ assert not ki_thin.isthick
386
+
380
387
  def assert_integrated_strength_eq(value, expected):
381
388
  padded_expected = np.zeros_like(value)
382
389
  padded_expected[:len(expected)] = expected
@@ -512,7 +519,7 @@ def test_mad_elements_import():
512
519
  k2: kick2, at=0.34;
513
520
  k3: kick3, at=0.35;
514
521
  de0: dipedge0, at=0.38;
515
- r0: rfm0, at=0.4;
522
+ !r0: rfm0, at=0.4; # Loading of RFMultipole not supported anymore
516
523
  cb0: crab0, at=0.41;
517
524
  cb1: crab1, at=0.42;
518
525
  w: wire1, at=1;
@@ -608,44 +615,32 @@ def test_mad_elements_import():
608
615
  assert line['de0'].fint == 4
609
616
  assert line['de0'].hgap == 0.02
610
617
 
611
- assert isinstance(line['r0'], xt.RFMultipole)
612
- assert line.get_s_position('r0') == 0.4
613
- assert np.all(line['r0'].knl == np.array([2, 3]))
614
- assert np.all(line['r0'].ksl == np.array([0, 5]))
615
- assert np.all(line['r0'].pn == np.array([0.3 * 360, 0.4 * 360]))
616
- assert np.all(line['r0'].ps == np.array([0.5 * 360, 0.6 * 360]))
617
- assert line['r0'].voltage == 2e6
618
- assert line['r0'].order == 1
619
- assert line['r0'].frequency == 100e6
620
- assert line['r0'].lag == 180
621
-
622
- assert isinstance(line['cb0'], xt.RFMultipole)
618
+ # Loading of RFMultipole not supported anymore:
619
+ #
620
+ # assert isinstance(line['r0'], xt.RFMultipole)
621
+ # assert line.get_s_position('r0') == 0.4
622
+ # assert np.all(line['r0'].knl == np.array([2, 3, 0, 0, 0, 0]))
623
+ # assert np.all(line['r0'].ksl == np.array([0, 5, 0, 0, 0, 0]))
624
+ # assert np.all(line['r0'].pn == np.array([0.3 * 360, 0.4 * 360, 0, 0, 0, 0]))
625
+ # assert np.all(line['r0'].ps == np.array([0.5 * 360, 0.6 * 360, 0, 0, 0, 0]))
626
+ # assert line['r0'].voltage == 2e6
627
+ # assert line['r0'].order == 5
628
+ # assert line['r0'].frequency == 100e6
629
+ # assert line['r0'].lag == 180
630
+
631
+ assert isinstance(line['cb0'], xt.CrabCavity)
623
632
  assert line.get_s_position('cb0') == 0.41
624
- assert len(line['cb0'].knl) == 1
625
- assert len(line['cb0'].ksl) == 1
626
- xo.assert_allclose(line['cb0'].knl[0], 2 * 1e6 / line.particle_ref.p0c[0],
633
+ xo.assert_allclose(line['cb0'].crab_voltage, 2 * 1e6,
627
634
  rtol=0, atol=1e-12)
628
- assert np.all(line['cb0'].ksl == 0)
629
- assert np.all(line['cb0'].pn == np.array([270]))
630
- assert np.all(line['cb0'].ps == 0.)
631
- assert line['cb0'].voltage == 0
632
- assert line['cb0'].order == 0
635
+ assert np.all(line['cb0'].lag == 180)
633
636
  assert line['cb0'].frequency == 100e6
634
- assert line['cb0'].lag == 0
635
637
 
636
- assert isinstance(line['cb1'], xt.RFMultipole)
638
+ assert isinstance(line['cb1'], xt.CrabCavity)
637
639
  assert line.get_s_position('cb1') == 0.42
638
- assert len(line['cb1'].knl) == 1
639
- assert len(line['cb1'].ksl) == 1
640
- xo.assert_allclose(line['cb1'].ksl[0], -2 * 1e6 / line.particle_ref.p0c[0],
641
- rtol=0, atol=1e-12)
642
- assert np.all(line['cb1'].knl == 0)
643
- assert np.all(line['cb1'].ps == np.array([270]))
644
- assert np.all(line['cb1'].pn == 0.)
645
- assert line['cb1'].voltage == 0
646
- assert line['cb1'].order == 0
640
+ assert line['cb1'].crab_voltage == 2 * 1e6
641
+ assert np.all(line['cb1'].lag == 180)
642
+ xo.assert_allclose(line['cb1'].rot_s_rad, np.pi / 2, rtol=0, atol=1e-12)
647
643
  assert line['cb1'].frequency == 100e6
648
- assert line['cb1'].lag == 0
649
644
 
650
645
  assert isinstance(line['w'], xt.Wire)
651
646
  assert line.get_s_position('w') == 1
@@ -5,7 +5,7 @@ import xtrack as xt
5
5
  import xobjects as xo
6
6
  from xobjects.test_helpers import for_all_test_contexts
7
7
 
8
- from xtrack.beam_elements.magnets import Magnet, MagnetEdge
8
+ from xtrack import Magnet, MagnetEdge
9
9
 
10
10
 
11
11
  def make_particles(context):
@@ -17,7 +17,7 @@ test_data_folder = pathlib.Path(
17
17
  __file__).parent.joinpath('../test_data').absolute()
18
18
 
19
19
 
20
- @for_all_test_contexts
20
+ @for_all_test_contexts(excluding=('ContextCupy', 'ContextPyopencl'))
21
21
  def test_match_and_track_from_element(test_context):
22
22
  # Load machine model (from pymask)
23
23
  filename = test_data_folder.joinpath('lhc_no_bb/line_and_particle.json')
@@ -9,7 +9,7 @@ from xobjects.test_helpers import for_all_test_contexts
9
9
  test_data_folder = pathlib.Path(
10
10
  __file__).parent.joinpath('../test_data').absolute()
11
11
 
12
- @for_all_test_contexts
12
+ @for_all_test_contexts(excluding=('ContextCupy', 'ContextPyopencl'))
13
13
  def test_match_coupling_knob(test_context):
14
14
  line = xt.load(test_data_folder /
15
15
  'hllhc14_no_errors_with_coupling_knobs/line_b1.json')
@@ -92,7 +92,7 @@ class ActionMatchPhaseWithMQTs(xd.Action):
92
92
  self.line.vars[kk] = mqt_knob_values[kk]
93
93
  return res
94
94
 
95
- @for_all_test_contexts
95
+ @for_all_test_contexts(excluding=('ContextCupy', 'ContextPyopencl'))
96
96
  def test_match_nested(test_context):
97
97
 
98
98
  # Load the line
@@ -9,7 +9,8 @@ from xobjects.test_helpers import for_all_test_contexts
9
9
  test_data_folder = pathlib.Path(
10
10
  __file__).parent.joinpath('../test_data').absolute()
11
11
 
12
- @for_all_test_contexts
12
+
13
+ @for_all_test_contexts(excluding=('ContextCupy', 'ContextPyopencl'))
13
14
  def test_ip_knob_matching(test_context):
14
15
 
15
16
  collider = xt.load(test_data_folder /
@@ -9,7 +9,7 @@ from xobjects.test_helpers import for_all_test_contexts
9
9
  test_data_folder = pathlib.Path(
10
10
  __file__).parent.joinpath('../test_data').absolute()
11
11
 
12
- @for_all_test_contexts
12
+ @for_all_test_contexts(excluding=('ContextCupy', 'ContextPyopencl'))
13
13
  def test_ip_knob_matching_new_optimize_api(test_context):
14
14
 
15
15
  collider = xt.load(test_data_folder /
@@ -326,7 +326,7 @@ def test_ip_knob_matching_new_optimize_api(test_context):
326
326
  xo.assert_allclose(tw.lhcb1['px', 'ip8'], 120e-6, atol=1e-9, rtol=0)
327
327
  xo.assert_allclose(tw.lhcb2['px', 'ip8'], -120e-6, atol=1e-9, rtol=0)
328
328
 
329
- @for_all_test_contexts
329
+ @for_all_test_contexts(excluding=('ContextCupy', 'ContextPyopencl'))
330
330
  def test_match_ir8_optics_new_optimize_api(test_context):
331
331
 
332
332
  collider = xt.load(test_data_folder /
@@ -601,7 +601,7 @@ def test_match_bump_sets_implicit_end(test_context):
601
601
  xo.assert_allclose(tw['y', 'mq.33l8.b1'], tw_before['y', 'mq.33l8.b1'], atol=1e-6)
602
602
  xo.assert_allclose(tw['py', 'mq.33l8.b1'], tw_before['py', 'mq.33l8.b1'], atol=1e-7)
603
603
 
604
- @for_all_test_contexts
604
+ @for_all_test_contexts(excluding=('ContextCupy', 'ContextPyopencl'))
605
605
  def test_match_bump_sets_init_end(test_context):
606
606
 
607
607
  line = xt.load(test_data_folder /
@@ -636,7 +636,7 @@ def test_match_bump_sets_init_end(test_context):
636
636
  xo.assert_allclose(tw['y', 'mq.33l8.b1'], tw_before['y', 'mq.33l8.b1'], atol=1e-6)
637
637
  xo.assert_allclose(tw['py', 'mq.33l8.b1'], tw_before['py', 'mq.33l8.b1'], atol=1e-7)
638
638
 
639
- @for_all_test_contexts
639
+ @for_all_test_contexts(excluding=('ContextCupy', 'ContextPyopencl'))
640
640
  def test_match_bump_sets_init_middle(test_context):
641
641
 
642
642
  line = xt.load(test_data_folder /