xtrack 0.83.1__tar.gz → 0.83.2__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 (308) hide show
  1. {xtrack-0.83.1/xtrack.egg-info → xtrack-0.83.2}/PKG-INFO +1 -1
  2. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_apertures.py +18 -1
  3. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_trajectory_correcton.py +106 -0
  4. xtrack-0.83.2/xtrack/_version.py +1 -0
  5. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/apertures.py +14 -25
  6. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/line.py +33 -4
  7. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/trajectory_correction.py +98 -15
  8. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/twiss.py +2 -0
  9. {xtrack-0.83.1 → xtrack-0.83.2/xtrack.egg-info}/PKG-INFO +1 -1
  10. xtrack-0.83.1/xtrack/_version.py +0 -1
  11. {xtrack-0.83.1 → xtrack-0.83.2}/LICENSE +0 -0
  12. {xtrack-0.83.1 → xtrack-0.83.2}/MANIFEST.in +0 -0
  13. {xtrack-0.83.1 → xtrack-0.83.2}/README.md +0 -0
  14. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/__init__.py +0 -0
  15. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/base_classes.py +0 -0
  16. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/be_beamfields/BB6D.py +0 -0
  17. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/be_beamfields/BB6Ddata.py +0 -0
  18. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/be_beamfields/__init__.py +0 -0
  19. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/be_beamfields/beambeam.py +0 -0
  20. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/be_beamfields/boost.py +0 -0
  21. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/be_beamfields/gaussian_fields.py +0 -0
  22. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/be_beamfields/propagate_sigma_matrix.py +0 -0
  23. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/be_beamfields/qgauss.py +0 -0
  24. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/be_beamfields/slicing.py +0 -0
  25. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/be_beamfields/spacecharge.py +0 -0
  26. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/elements.py +0 -0
  27. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/line.py +0 -0
  28. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/mathlibs.py +0 -0
  29. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/particles.py +0 -0
  30. {xtrack-0.83.1 → xtrack-0.83.2}/ducktrack/temp_pyparticles.py +0 -0
  31. {xtrack-0.83.1 → xtrack-0.83.2}/pyproject.toml +0 -0
  32. {xtrack-0.83.1 → xtrack-0.83.2}/setup.cfg +0 -0
  33. {xtrack-0.83.1 → xtrack-0.83.2}/setup.py +0 -0
  34. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_acceleration.py +0 -0
  35. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_amplitude_detuning.py +0 -0
  36. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_aperture_table.py +0 -0
  37. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_aperture_turn_ele_and_monitor.py +0 -0
  38. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_attr_replicas_and_slices.py +0 -0
  39. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_bucket_with_ref_energy_change.py +0 -0
  40. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_cavity_absolute_time.py +0 -0
  41. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_chromatic_functions_vs_madx.py +0 -0
  42. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_coasting.py +0 -0
  43. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_collective_tracker.py +0 -0
  44. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_collimation.py +0 -0
  45. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_electron_cooler.py +0 -0
  46. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_element_characterization_functions.py +0 -0
  47. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_element_internal_record.py +0 -0
  48. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_elements.py +0 -0
  49. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_elements_classflags.py +0 -0
  50. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_elements_thick.py +0 -0
  51. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_environment.py +0 -0
  52. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_fcc_ee_solenoid_correction.py +0 -0
  53. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_fcc_ee_solenoid_correction_new_optimize_api.py +0 -0
  54. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_footprint.py +0 -0
  55. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_freeze_longitudinal.py +0 -0
  56. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_full_rings.py +0 -0
  57. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_h6_sps_beamline.py +0 -0
  58. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_hvkick.py +0 -0
  59. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_ions.py +0 -0
  60. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_legacy_multiline_to_env.py +0 -0
  61. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_lhc_env.py +0 -0
  62. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_lhc_match_phase_15.py +0 -0
  63. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_line.py +0 -0
  64. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_lumi.py +0 -0
  65. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_mad_writer.py +0 -0
  66. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_madloader.py +0 -0
  67. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_madnginterface.py +0 -0
  68. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_magnet.py +0 -0
  69. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_match_and_track_from_element.py +0 -0
  70. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_match_coupling_knob.py +0 -0
  71. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_match_nested.py +0 -0
  72. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_match_optics_and_ip_knob.py +0 -0
  73. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_match_optics_and_ip_knob_new_optimize_api.py +0 -0
  74. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_match_orbit_bump.py +0 -0
  75. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_match_tune_chroma_cminus.py +0 -0
  76. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_monitor.py +0 -0
  77. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_multi_bunch_gauss.py +0 -0
  78. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_multiline.py +0 -0
  79. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_multisetter.py +0 -0
  80. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_multispecies.py +0 -0
  81. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_native_madloader.py +0 -0
  82. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_optimize_for_tracking.py +0 -0
  83. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_particles.py +0 -0
  84. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_particles_basics.py +0 -0
  85. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_particles_pdg.py +0 -0
  86. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_periodic_symmetric_twiss_and_match.py +0 -0
  87. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_pipeline.py +0 -0
  88. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_prebuild_kernels.py +0 -0
  89. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_ps_against_ptc.py +0 -0
  90. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_ps_multiturn_twiss.py +0 -0
  91. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_psb_chicane.py +0 -0
  92. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_pyht_interface.py +0 -0
  93. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_radial_steering.py +0 -0
  94. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_radiation.py +0 -0
  95. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_radiation_equilibrium_emittances.py +0 -0
  96. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_radiation_equilibrium_emittances_thick.py +0 -0
  97. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_random_gen.py +0 -0
  98. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_random_gen_exp.py +0 -0
  99. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_random_gen_gauss.py +0 -0
  100. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_random_gen_ruth.py +0 -0
  101. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_rbend_rbarc.py +0 -0
  102. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_rf_track.py +0 -0
  103. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_rotation_signs.py +0 -0
  104. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_second_order_taylor_map.py +0 -0
  105. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_seeds.py +0 -0
  106. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_slice_and_insert_with_replicas.py +0 -0
  107. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_slice_elements.py +0 -0
  108. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_slicing.py +0 -0
  109. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_solenoid_bz_map_vs_boris.py +0 -0
  110. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_spacecharge_in_ring.py +0 -0
  111. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_spin.py +0 -0
  112. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_sps_thick.py +0 -0
  113. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_survey.py +0 -0
  114. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_tapering.py +0 -0
  115. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_thick_lhc.py +0 -0
  116. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_tilt_shifts.py +0 -0
  117. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_tracker.py +0 -0
  118. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_twiss.py +0 -0
  119. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_twiss_vs_madx_psb.py +0 -0
  120. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_vs_madx.py +0 -0
  121. {xtrack-0.83.1 → xtrack-0.83.2}/tests/test_xmask_orbit_correction.py +0 -0
  122. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/__init__.py +0 -0
  123. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/_temp/__init__.py +0 -0
  124. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/_temp/boris_and_solenoid_map/__init__.py +0 -0
  125. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/_temp/boris_and_solenoid_map/boris.h +0 -0
  126. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/_temp/boris_and_solenoid_map/solenoid_field.py +0 -0
  127. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/_temp/lhc_match/__init__.py +0 -0
  128. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/_temp/lhc_match/gen_madx_optics_file.py +0 -0
  129. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/_temp/lhc_match/lhc_match.py +0 -0
  130. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/_temp/lhc_match/var_limits.py +0 -0
  131. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/aperture_meas.py +0 -0
  132. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/base_element.py +0 -0
  133. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/__init__.py +0 -0
  134. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/apertures_src/limitellipse.h +0 -0
  135. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/apertures_src/limitpolygon.h +0 -0
  136. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/apertures_src/limitracetrack.h +0 -0
  137. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/apertures_src/limitrect.h +0 -0
  138. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/apertures_src/limitrectellipse.h +0 -0
  139. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/apertures_src/longitudinallimitrect.h +0 -0
  140. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/beam_interaction.py +0 -0
  141. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements.py +0 -0
  142. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/bend.h +0 -0
  143. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/cavity.h +0 -0
  144. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/dipole_fringe.h +0 -0
  145. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/dipoleedge.h +0 -0
  146. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/drift.h +0 -0
  147. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/drift_slice.h +0 -0
  148. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/drift_slice_bend.h +0 -0
  149. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/drift_slice_octupole.h +0 -0
  150. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/drift_slice_quadrupole.h +0 -0
  151. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/drift_slice_rbend.h +0 -0
  152. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/drift_slice_sextupole.h +0 -0
  153. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/electroncooler.h +0 -0
  154. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/elens.h +0 -0
  155. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/exciter.h +0 -0
  156. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/firstordertaylormap.h +0 -0
  157. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/linesegmentmap.h +0 -0
  158. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/magnet.h +0 -0
  159. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/magnet_drift.h +0 -0
  160. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/magnet_edge.h +0 -0
  161. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/magnet_kick.h +0 -0
  162. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/marker.h +0 -0
  163. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/multipole.h +0 -0
  164. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/multipoleedge.h +0 -0
  165. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/nonlinearlens.h +0 -0
  166. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/octupole.h +0 -0
  167. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/quadrupole.h +0 -0
  168. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/rbend.h +0 -0
  169. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/referenceenergyincrease.h +0 -0
  170. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/rfmultipole.h +0 -0
  171. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/second_order_taylor_map.h +0 -0
  172. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/sextupole.h +0 -0
  173. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/simplethinbend.h +0 -0
  174. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/simplethinquadrupole.h +0 -0
  175. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/solenoid.h +0 -0
  176. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/srotation.h +0 -0
  177. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thick_slice_bend.h +0 -0
  178. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thick_slice_drift.h +0 -0
  179. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thick_slice_octupole.h +0 -0
  180. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thick_slice_quadrupole.h +0 -0
  181. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thick_slice_rbend.h +0 -0
  182. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thick_slice_sextupole.h +0 -0
  183. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thick_slice_solenoid.h +0 -0
  184. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thin_slice_bend.h +0 -0
  185. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thin_slice_bend_entry.h +0 -0
  186. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thin_slice_bend_exit.h +0 -0
  187. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thin_slice_octupole.h +0 -0
  188. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thin_slice_octupole_entry.h +0 -0
  189. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thin_slice_octupole_exit.h +0 -0
  190. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thin_slice_quadrupole.h +0 -0
  191. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thin_slice_quadrupole_entry.h +0 -0
  192. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thin_slice_quadrupole_exit.h +0 -0
  193. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thin_slice_rbend.h +0 -0
  194. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thin_slice_rbend_entry.h +0 -0
  195. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thin_slice_rbend_exit.h +0 -0
  196. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thin_slice_sextupole.h +0 -0
  197. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thin_slice_sextupole_entry.h +0 -0
  198. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/thin_slice_sextupole_exit.h +0 -0
  199. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_bend.h +0 -0
  200. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_cavity.h +0 -0
  201. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_dipole_edge_linear.h +0 -0
  202. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_dipole_edge_nonlinear.h +0 -0
  203. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_dipole_fringe.h +0 -0
  204. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_drift.h +0 -0
  205. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_magnet.h +0 -0
  206. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_magnet_drift.h +0 -0
  207. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_magnet_edge.h +0 -0
  208. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_magnet_kick.h +0 -0
  209. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_magnet_radiation.h +0 -0
  210. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_mult_fringe.h +0 -0
  211. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_multipolar_components.h +0 -0
  212. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_multipole.h +0 -0
  213. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_quadrupole.h +0 -0
  214. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_solenoid.h +0 -0
  215. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_srotation.h +0 -0
  216. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_thick_bend.h +0 -0
  217. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_thick_cfd.h +0 -0
  218. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_wedge.h +0 -0
  219. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_xrotation.h +0 -0
  220. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/track_yrotation.h +0 -0
  221. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/wedge.h +0 -0
  222. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/wire.h +0 -0
  223. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/xrotation.h +0 -0
  224. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/xyshift.h +0 -0
  225. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/yrotation.h +0 -0
  226. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/elements_src/zetashift.h +0 -0
  227. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/exciter.py +0 -0
  228. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/magnets.py +0 -0
  229. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/rft_element.py +0 -0
  230. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/slice_elements.py +0 -0
  231. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/beam_elements/slice_elements_thick.py +0 -0
  232. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/environment.py +0 -0
  233. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/footprint.py +0 -0
  234. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/general.py +0 -0
  235. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/headers/atomicadd.h +0 -0
  236. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/headers/checks.h +0 -0
  237. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/headers/constants.h +0 -0
  238. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/headers/particle_states.h +0 -0
  239. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/headers/synrad_spectrum.h +0 -0
  240. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/headers/track.h +0 -0
  241. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/internal_record.py +0 -0
  242. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/json.py +0 -0
  243. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/linear_normal_form.py +0 -0
  244. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/loss_location_refinement/__init__.py +0 -0
  245. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/loss_location_refinement/loss_location_refinement.py +0 -0
  246. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/lumi.py +0 -0
  247. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/mad_loader.py +0 -0
  248. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/mad_parser/__init__.py +0 -0
  249. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/mad_parser/loader.py +0 -0
  250. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/mad_parser/madx.lark +0 -0
  251. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/mad_parser/parse.py +0 -0
  252. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/mad_writer.py +0 -0
  253. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/madng_interface.py +0 -0
  254. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/match.py +0 -0
  255. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/monitors/__init__.py +0 -0
  256. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/monitors/beam_position_monitor.h +0 -0
  257. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/monitors/beam_position_monitor.py +0 -0
  258. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/monitors/beam_profile_monitor.h +0 -0
  259. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/monitors/beam_profile_monitor.py +0 -0
  260. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/monitors/beam_size_monitor.h +0 -0
  261. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/monitors/beam_size_monitor.py +0 -0
  262. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/monitors/last_turns_monitor.h +0 -0
  263. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/monitors/last_turns_monitor.py +0 -0
  264. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/monitors/particles_monitor.h +0 -0
  265. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/monitors/particles_monitor.py +0 -0
  266. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/multiline.py +0 -0
  267. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/multiline_legacy/__init__.py +0 -0
  268. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/multiline_legacy/multiline_legacy.py +0 -0
  269. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/multiline_legacy/shared_knobs.py +0 -0
  270. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/multisetter/__init__.py +0 -0
  271. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/multisetter/multisetter.py +0 -0
  272. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/particles/__init__.py +0 -0
  273. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/particles/constants.py +0 -0
  274. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/particles/masses.py +0 -0
  275. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/particles/particles.py +0 -0
  276. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/particles/pdg.py +0 -0
  277. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/particles/rng_src/base_rng.h +0 -0
  278. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/particles/rng_src/particles_rng.h +0 -0
  279. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/pipeline/__init__.py +0 -0
  280. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/pipeline/core.py +0 -0
  281. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/pipeline/manager.py +0 -0
  282. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/pipeline/multitracker.py +0 -0
  283. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/progress_indicator.py +0 -0
  284. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/random/__init__.py +0 -0
  285. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/random/random_generators.py +0 -0
  286. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/random/random_src/exponential.h +0 -0
  287. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/random/random_src/exponential_integral_Ei.h +0 -0
  288. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/random/random_src/normal.h +0 -0
  289. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/random/random_src/rutherford.h +0 -0
  290. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/random/random_src/uniform.h +0 -0
  291. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/random/random_src/uniform_accurate.h +0 -0
  292. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/slicing.py +0 -0
  293. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/survey.py +0 -0
  294. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/svgutils/__init__.py +0 -0
  295. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/svgutils/parser.py +0 -0
  296. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/svgutils/path.py +0 -0
  297. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/svgutils/svgutils.py +0 -0
  298. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/synctime.py +0 -0
  299. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/tapering.py +0 -0
  300. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/targets.py +0 -0
  301. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/tracker.py +0 -0
  302. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/tracker_data.py +0 -0
  303. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/tracker_src/tracker.h +0 -0
  304. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack/twissplot.py +0 -0
  305. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack.egg-info/SOURCES.txt +0 -0
  306. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack.egg-info/dependency_links.txt +0 -0
  307. {xtrack-0.83.1 → xtrack-0.83.2}/xtrack.egg-info/requires.txt +0 -0
  308. {xtrack-0.83.1 → xtrack-0.83.2}/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.83.1
3
+ Version: 0.83.2
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
@@ -361,4 +361,21 @@ def test_aperture_svg_path():
361
361
  xo.assert_allclose(aper.x_vertices, x_expected, atol=1e-6, rtol=0)
362
362
  xo.assert_allclose(aper.y_vertices, y_expected, atol=1e-6, rtol=0)
363
363
  xo.assert_allclose(aper2.x_vertices, x_expected, atol=1e-6, rtol=0)
364
- xo.assert_allclose(aper2.y_vertices, y_expected, atol=1e-6, rtol=0)
364
+ xo.assert_allclose(aper2.y_vertices, y_expected, atol=1e-6, rtol=0)
365
+
366
+ def test_limitrect_to_dict():
367
+
368
+ lrect = xt.LimitRect(min_x=-0.03, max_x=0.03, min_y=0.0, max_y=0.09)
369
+ lrect2 = xt.LimitRect.from_dict(lrect.to_dict())
370
+
371
+ assert lrect2.min_x == lrect.min_x
372
+ assert lrect2.max_x == lrect.max_x
373
+ assert lrect2.min_y == lrect.min_y
374
+ assert lrect2.max_y == lrect.max_y
375
+
376
+ lrectdef = xt.LimitRect()
377
+
378
+ assert lrectdef.min_x == -1e10
379
+ assert lrectdef.max_x == 1e10
380
+ assert lrectdef.min_y == -1e10
381
+ assert lrectdef.max_y == 1e10
@@ -531,3 +531,109 @@ def test_orbit_correction_tilt_monitors():
531
531
 
532
532
  # Check that there is no vertical reading in the tilted bpm BPMs
533
533
  xo.assert_allclose(correction.y_correction._position_before, 0, atol=1e-15, rtol=0)
534
+
535
+ def test_orbit_correction_with_limits():
536
+
537
+ line = xt.Line.from_json(test_data_folder
538
+ / 'hllhc15_thick/lhc_thick_with_knobs.json')
539
+ line.build_tracker()
540
+ tt = line.get_table()
541
+
542
+ # Define elements to be used as monitors for orbit correction
543
+ tt_monitors = tt.rows['bpm.*','.*(?<!_entry)$','.*(?<!_exit)$']
544
+ line.steering_monitors_x = tt_monitors.name
545
+ line.steering_monitors_y = tt_monitors.name
546
+
547
+ # Define elements to be used as correctors for orbit correction
548
+ tt_h_correctors = tt.rows['mcb.*'].rows[r'.*h\..*']
549
+ line.steering_correctors_x = tt_h_correctors.name
550
+ tt_v_correctors = tt.rows['mcb.*'].rows[r'.*v\..*']
551
+ line.steering_correctors_y = tt_v_correctors.name
552
+
553
+ # Reference twiss (no misalignments)
554
+ tw_ref = line.twiss4d()
555
+
556
+ # Introduce misalignments on all quadrupoles
557
+ tt = line.get_table()
558
+ tt_quad = tt.rows[tt.element_type == 'Quadrupole']
559
+ rgen = np.random.RandomState(1) # fix seed for random number generator
560
+ shift_x = rgen.randn(len(tt_quad)) * 0.01e-3 # 0.01 mm rms shift on all quads
561
+ shift_y = rgen.randn(len(tt_quad)) * 0.01e-3 # 0.01 mm rms shift on all quads
562
+ for nn_quad, sx, sy in zip(tt_quad.name, shift_x, shift_y):
563
+ line.element_refs[nn_quad].shift_x = sx
564
+ line.element_refs[nn_quad].shift_y = sy
565
+
566
+ # Twiss before correction
567
+ tw_before = line.twiss4d()
568
+
569
+ # Define limits for correctors (in radians)
570
+ limits_x = (-1e-6, 1e-6) # 1 urad
571
+ limits_y = (-1e-6, 1e-6) # 1 urad
572
+
573
+ # Orbit correction without limits as reference
574
+ orbit_correction_basic_no_limits = line.correct_trajectory(twiss_table=tw_ref)
575
+
576
+ #print(np.max(np.abs(orbit_correction_basic_no_limits.x_correction.get_kick_values())))
577
+ #print(np.max(np.abs(orbit_correction_basic_no_limits.y_correction.get_kick_values())))
578
+
579
+ #Assert that at least one corrector is beyond each of the limits
580
+ assert np.any(np.abs(orbit_correction_basic_no_limits.x_correction.get_kick_values()) > limits_x[1])
581
+ assert np.any(np.abs(orbit_correction_basic_no_limits.y_correction.get_kick_values()) > limits_y[1])
582
+ orbit_correction_basic_no_limits.clear_correction_knobs()
583
+
584
+ # Set limits on the line
585
+ line.corrector_limits_x = limits_x
586
+ line.corrector_limits_y = limits_y
587
+
588
+ # First test: Basic method with limits
589
+ orbit_correction_basic = line.correct_trajectory(twiss_table=tw_ref)
590
+
591
+ # Twiss after basic correction
592
+ tw_after_basic = line.twiss4d()
593
+
594
+ # Extract correction strength from basic method
595
+ kicks_x_basic = orbit_correction_basic.x_correction.get_kick_values()
596
+ kicks_y_basic = orbit_correction_basic.y_correction.get_kick_values()
597
+
598
+ # Verify that the basic correction stays within limits
599
+ assert np.all(kicks_x_basic >= limits_x[0])
600
+ assert np.all(kicks_x_basic <= limits_x[1])
601
+ assert np.all(kicks_y_basic >= limits_y[0])
602
+ assert np.all(kicks_y_basic <= limits_y[1])
603
+
604
+ # Verify that the orbit is corrected in the correct direction with basic method
605
+ assert tw_before.x.std() > tw_after_basic.x.std()
606
+ assert tw_before.y.std() > tw_after_basic.y.std()
607
+
608
+ # Clear correction
609
+ orbit_correction_basic.clear_correction_knobs()
610
+
611
+ # Second test: Micado method with limits
612
+ n_micado = 5
613
+ orbit_correction_micado = line.correct_trajectory(twiss_table=tw_ref, n_micado=n_micado, n_iter=1)
614
+
615
+ # Twiss after micado correction
616
+ tw_after_micado = line.twiss4d()
617
+
618
+ # Extract correction strength from micado method
619
+ kicks_x_micado = orbit_correction_micado.x_correction.get_kick_values()
620
+ kicks_y_micado = orbit_correction_micado.y_correction.get_kick_values()
621
+
622
+ # Verify that the micado correction stays within limits
623
+ assert np.all(kicks_x_micado >= limits_x[0])
624
+ assert np.all(kicks_x_micado <= limits_x[1])
625
+ assert np.all(kicks_y_micado >= limits_y[0])
626
+ assert np.all(kicks_y_micado <= limits_y[1])
627
+
628
+ # Verify that the orbit is corrected with micado method
629
+ assert tw_after_micado.y.std() < tw_before.y.std()
630
+ assert tw_after_micado.x.std() < tw_before.x.std()
631
+
632
+ # Verify that micado uses at most the specified number of correctors
633
+ assert np.sum(np.abs(kicks_x_micado) > 1e-10) <= n_micado
634
+ assert np.sum(np.abs(kicks_y_micado) > 1e-10) <= n_micado
635
+
636
+ # Compare the two methods
637
+ # Basic method should use more correctors
638
+ assert np.sum(np.abs(kicks_x_basic) > 1e-10) > n_micado
639
+ assert np.sum(np.abs(kicks_y_basic) > 1e-10) > n_micado
@@ -0,0 +1 @@
1
+ __version__ = '0.83.2'
@@ -33,27 +33,16 @@ class LimitRect(BeamElement):
33
33
  """
34
34
 
35
35
  _xofields = {
36
- "min_x": xo.Float64,
37
- "max_x": xo.Float64,
38
- "min_y": xo.Float64,
39
- "max_y": xo.Float64,
36
+ "min_x": xo.Field(xo.Float64, default=-UNLIMITED),
37
+ "max_x": xo.Field(xo.Float64, default=UNLIMITED),
38
+ "min_y": xo.Field(xo.Float64, default=-UNLIMITED),
39
+ "max_y": xo.Field(xo.Float64, default=UNLIMITED),
40
40
  }
41
41
 
42
42
  has_backtrack = True
43
43
 
44
44
  _extra_c_sources = ['#include <beam_elements/apertures_src/limitrect.h>']
45
45
 
46
- def __init__(
47
- self,
48
- min_x=-UNLIMITED,
49
- max_x=UNLIMITED,
50
- min_y=-UNLIMITED,
51
- max_y=UNLIMITED,
52
- **kwargs,
53
- ):
54
-
55
- super().__init__(min_x=min_x, max_x=max_x, min_y=min_y, max_y=max_y, **kwargs)
56
-
57
46
 
58
47
  class LimitRacetrack(BeamElement):
59
48
  """
@@ -77,10 +66,10 @@ class LimitRacetrack(BeamElement):
77
66
  """
78
67
 
79
68
  _xofields = {
80
- "min_x": xo.Float64,
81
- "max_x": xo.Float64,
82
- "min_y": xo.Float64,
83
- "max_y": xo.Float64,
69
+ "min_x": xo.Field(xo.Float64, default=-UNLIMITED),
70
+ "max_x": xo.Field(xo.Float64, default=UNLIMITED),
71
+ "min_y": xo.Field(xo.Float64, default=-UNLIMITED),
72
+ "max_y": xo.Field(xo.Float64, default=UNLIMITED),
84
73
  "a": xo.Float64,
85
74
  "b": xo.Float64,
86
75
  }
@@ -435,8 +424,8 @@ class LimitRectEllipse(BeamElement):
435
424
  """
436
425
 
437
426
  _xofields = {
438
- "max_x": xo.Float64,
439
- "max_y": xo.Float64,
427
+ "max_x": xo.Field(xo.Float64, default=UNLIMITED),
428
+ "max_y": xo.Field(xo.Float64, default=UNLIMITED),
440
429
  "a_squ": xo.Float64,
441
430
  "b_squ": xo.Float64,
442
431
  "a_b_squ": xo.Float64,
@@ -533,10 +522,10 @@ class LongitudinalLimitRect(BeamElement):
533
522
  """
534
523
 
535
524
  _xofields = {
536
- "min_zeta": xo.Float64,
537
- "max_zeta": xo.Float64,
538
- "min_pzeta": xo.Float64,
539
- "max_pzeta": xo.Float64,
525
+ "min_zeta": xo.Field(xo.Float64, default=-UNLIMITED),
526
+ "max_zeta": xo.Field(xo.Float64, default=UNLIMITED),
527
+ "min_pzeta": xo.Field(xo.Float64, default=-UNLIMITED),
528
+ "max_pzeta": xo.Field(xo.Float64, default=UNLIMITED),
540
529
  }
541
530
 
542
531
  has_backtrack = True
@@ -165,6 +165,8 @@ class Line:
165
165
  self._extra_config['steering_monitors_y'] = None
166
166
  self._extra_config['steering_correctors_x'] = None
167
167
  self._extra_config['steering_correctors_y'] = None
168
+ self._extra_config['corrector_limits_x'] = None
169
+ self._extra_config['corrector_limits_y'] = None
168
170
 
169
171
  if env is None:
170
172
  env = xt.Environment()
@@ -1590,8 +1592,8 @@ class Line:
1590
1592
  monitor_names_x=None, corrector_names_x=None,
1591
1593
  monitor_names_y=None, corrector_names_y=None,
1592
1594
  n_micado=None, n_singular_values=None, rcond=None,
1593
- monitor_alignment=None,
1594
- ):
1595
+ monitor_alignment=None, corrector_limits_x=None,
1596
+ corrector_limits_y=None):
1595
1597
 
1596
1598
  '''
1597
1599
  Correct the beam trajectory using linearized response matrix from optics
@@ -1642,6 +1644,14 @@ class Line:
1642
1644
  rcond : float
1643
1645
  Cutoff for small singular values (relative to the largest singular
1644
1646
  value). Singular values smaller than `rcond` are considered zero.
1647
+ corrector_limits_x : tuple of array-like or None
1648
+ Limits for the horizontal corrector strengths. If not None, it should be a tuple
1649
+ of two arrays (lower_limits, upper_limits) with the same length as
1650
+ the number of horizontal correctors. If None, no limits are applied.
1651
+ corrector_limits_y : tuple of array-like or None
1652
+ Limits for the vertical corrector strengths. If not None, it should be a tuple
1653
+ of two arrays (lower_limits, upper_limits) with the same length as
1654
+ the number of vertical correctors. If None, no limits are applied.
1645
1655
 
1646
1656
  Returns
1647
1657
  -------
@@ -1658,7 +1668,9 @@ class Line:
1658
1668
  corrector_names_y=corrector_names_y,
1659
1669
  n_micado=n_micado, n_singular_values=n_singular_values,
1660
1670
  rcond=rcond,
1661
- monitor_alignment=monitor_alignment)
1671
+ monitor_alignment=monitor_alignment,
1672
+ corrector_limits_x=corrector_limits_x,
1673
+ corrector_limits_y=corrector_limits_y)
1662
1674
 
1663
1675
  if run:
1664
1676
  correction.correct(planes=planes, n_iter=n_iter)
@@ -3085,7 +3097,8 @@ class Line:
3085
3097
  if mode != 'deprecated':
3086
3098
  raise NameError('mode is deprecated, use model instead')
3087
3099
 
3088
- self._check_valid_tracker()
3100
+ if not self._has_valid_tracker():
3101
+ self.build_tracker()
3089
3102
 
3090
3103
  assert model in [None, 'mean', 'quantum']
3091
3104
  assert model_beamstrahlung in [None, 'mean', 'quantum']
@@ -4694,6 +4707,22 @@ class Line:
4694
4707
  def steering_correctors_y(self, value):
4695
4708
  self._extra_config['steering_correctors_y'] = value
4696
4709
 
4710
+ @property
4711
+ def corrector_limits_x(self):
4712
+ return self._extra_config.get('corrector_limits_x', None)
4713
+
4714
+ @corrector_limits_x.setter
4715
+ def corrector_limits_x(self, value):
4716
+ self._extra_config['corrector_limits_x'] = value
4717
+
4718
+ @property
4719
+ def corrector_limits_y(self):
4720
+ return self._extra_config.get('corrector_limits_y', None)
4721
+
4722
+ @corrector_limits_y.setter
4723
+ def corrector_limits_y(self, value):
4724
+ self._extra_config['corrector_limits_y'] = value
4725
+
4697
4726
  def __getitem__(self, key):
4698
4727
  if np.issubdtype(key.__class__, np.integer):
4699
4728
  key = self.element_names[key]
@@ -1,8 +1,13 @@
1
1
  import numpy as np
2
+ from scipy.optimize import lsq_linear
2
3
  import xtrack as xt
3
4
 
5
+ import logging
6
+ logger = logging.getLogger(__name__)
7
+ logger.addHandler(logging.StreamHandler())
8
+
4
9
  def _compute_correction(x_iter, response_matrix, n_micado=None, rcond=None,
5
- n_singular_values=None):
10
+ n_singular_values=None, corrector_limits=None):
6
11
 
7
12
  if isinstance(response_matrix, (list, tuple)):
8
13
  assert len(response_matrix) == 3 # U, S, Vt
@@ -36,8 +41,17 @@ def _compute_correction(x_iter, response_matrix, n_micado=None, rcond=None,
36
41
  mask_corr[i_used] = True
37
42
 
38
43
  # Compute the correction with least squares
39
- _, residual_x, rank_x, sval_x = np.linalg.lstsq(
40
- response_matrix[:, mask_corr], -x_iter, rcond=rcond)
44
+ if corrector_limits is None:
45
+ _, residual_x, rank_x, sval_x = np.linalg.lstsq(
46
+ response_matrix[:, mask_corr], -x_iter, rcond=rcond)
47
+ else:
48
+ # Apply limits only to the active correctors
49
+ active_limits = (corrector_limits[0][mask_corr], corrector_limits[1][mask_corr])
50
+ result = lsq_linear(response_matrix[:, mask_corr], -x_iter,
51
+ bounds=active_limits)
52
+ if not result.success:
53
+ logger.warning(f'Bounded Least Squares warning: {result.message}')
54
+ residual_x = np.array([result.cost])
41
55
  residuals.append(residual_x[0])
42
56
  used_correctors.append(np.nanargmin(residuals))
43
57
 
@@ -48,16 +62,26 @@ def _compute_correction(x_iter, response_matrix, n_micado=None, rcond=None,
48
62
  mask_corr[:] = True
49
63
 
50
64
  # Compute the correction with least squares
51
- if mask_corr.all() and S is not None:
52
- # Can reuse the SVD decomposition
65
+ if mask_corr.all() and S is not None and corrector_limits is None:
66
+ # Can reuse the SVD decomposition only for unbounded case
53
67
  S_inv = np.zeros_like(S)
54
68
  S_inv[S > 0] = 1 / S[S > 0]
55
69
  if rcond is not None:
56
70
  S_inv[S < rcond * S[0]] = 0
57
71
  correction_masked = Vh.T.conj() @ (np.diag(S_inv) @ (U.T.conj() @ (-x_iter)))
58
72
  else:
59
- correction_masked, residual_x, rank_x, sval_x = np.linalg.lstsq(
60
- response_matrix[:, mask_corr], -x_iter, rcond=rcond)
73
+ if corrector_limits is None:
74
+ correction_masked, residual_x, rank_x, sval_x = np.linalg.lstsq(
75
+ response_matrix[:, mask_corr], -x_iter, rcond=rcond)
76
+ else:
77
+ # Apply limits only to the active correctors
78
+ active_limits = (corrector_limits[0][mask_corr], corrector_limits[1][mask_corr])
79
+ result = lsq_linear(response_matrix[:, mask_corr], -x_iter,
80
+ bounds=active_limits)
81
+ if not result.success:
82
+ logger.warning(f'Bounded Least Squares warning: {result.message}')
83
+ correction_masked = result.x
84
+
61
85
  correction_x = np.zeros(n_hcorrectors)
62
86
  correction_x[mask_corr] = correction_masked
63
87
 
@@ -104,7 +128,7 @@ class OrbitCorrectionSinglePlane:
104
128
 
105
129
  def __init__(self, line, plane, monitor_names, corrector_names,
106
130
  start=None, end=None, twiss_table=None, n_micado=None,
107
- n_singular_values=None, rcond=None,
131
+ n_singular_values=None, rcond=None, corrector_limits=None,
108
132
  x_init=0, px_init=0, y_init=0, py_init=0, zeta_init=0, delta_init=0,
109
133
  monitor_alignment=None):
110
134
 
@@ -164,6 +188,29 @@ class OrbitCorrectionSinglePlane:
164
188
  assert len(monitor_names) > 0
165
189
  assert len(corrector_names) > 0
166
190
 
191
+ if corrector_limits is None:
192
+ corrector_limits = getattr(line, f'corrector_limits_{plane}')
193
+
194
+ if corrector_limits is not None:
195
+ assert isinstance(corrector_limits, tuple)
196
+ assert len(corrector_limits) == 2
197
+
198
+ if isinstance(corrector_limits[0], (int, float)):
199
+ corrector_limits = (
200
+ np.ones(len(corrector_names)) * corrector_limits[0],
201
+ np.ones(len(corrector_names)) * corrector_limits[1]
202
+ )
203
+
204
+ elif isinstance(corrector_limits[0], (list, tuple)):
205
+ corrector_limits = (
206
+ np.array(corrector_limits[0]),
207
+ np.array(corrector_limits[1])
208
+ )
209
+
210
+ assert len(corrector_limits) == 2
211
+ assert len(corrector_limits[0]) == len(corrector_limits[1])
212
+ assert len(corrector_limits[0]) == len(corrector_names)
213
+
167
214
  self.line = line
168
215
  self.plane = plane
169
216
  self.monitor_names = monitor_names
@@ -173,6 +220,7 @@ class OrbitCorrectionSinglePlane:
173
220
  self.n_micado = n_micado
174
221
  self.rcond = rcond
175
222
  self.n_singular_values = n_singular_values
223
+ self.corrector_limits = corrector_limits
176
224
 
177
225
  self.response_matrix = _build_response_matrix(plane=self.plane,
178
226
  tw=self.twiss_table, monitor_names=self.monitor_names,
@@ -208,7 +256,8 @@ class OrbitCorrectionSinglePlane:
208
256
  self._add_correction_knobs()
209
257
 
210
258
  def correct(self, n_iter='auto', n_micado=None, n_singular_values=None,
211
- rcond=None, stop_iter_factor=0.1, verbose=True, _tw_orbit=None):
259
+ rcond=None, stop_iter_factor=0.1, verbose=True, _tw_orbit=None,
260
+ corrector_limits=None):
212
261
 
213
262
  if _tw_orbit is not None and n_iter !=1:
214
263
  raise ValueError('`_tw_orbit` can only be used with `n_iter=1`')
@@ -219,6 +268,7 @@ class OrbitCorrectionSinglePlane:
219
268
  assert stop_iter_factor < 1
220
269
 
221
270
  pos_rms_prev = 0
271
+ relative_limits = corrector_limits
222
272
 
223
273
  i_iter = 0
224
274
  while True:
@@ -242,13 +292,19 @@ class OrbitCorrectionSinglePlane:
242
292
 
243
293
  correction = self._compute_correction(position=position,
244
294
  n_micado=n_micado, rcond=rcond,
245
- n_singular_values=n_singular_values)
295
+ n_singular_values=n_singular_values,
296
+ corrector_limits=relative_limits)
246
297
  self._apply_correction(correction)
247
298
 
248
299
  i_iter += 1
249
300
  if n_iter != 'auto' and i_iter >= n_iter:
250
301
  break
251
302
 
303
+ if corrector_limits is not None:
304
+ current_correction = self.get_kick_values()
305
+ relative_limits = (corrector_limits[0] - current_correction,
306
+ corrector_limits[1] - current_correction)
307
+
252
308
  if _tw_orbit is None:
253
309
  position = self._measure_position()
254
310
  self._position_after = position
@@ -292,7 +348,7 @@ class OrbitCorrectionSinglePlane:
292
348
  return position
293
349
 
294
350
  def _compute_correction(self, position, n_micado=None,
295
- n_singular_values=None, rcond=None):
351
+ n_singular_values=None, rcond=None, corrector_limits=None):
296
352
 
297
353
  if rcond is None:
298
354
  rcond = self.rcond
@@ -303,10 +359,11 @@ class OrbitCorrectionSinglePlane:
303
359
  if n_micado is None:
304
360
  n_micado = self.n_micado
305
361
 
362
+
306
363
  correction = _compute_correction(position,
307
364
  response_matrix=(self.singular_vectors_out, self.singular_values, self.singular_vectors_in),
308
365
  n_micado=n_micado,
309
- rcond=rcond, n_singular_values=n_singular_values)
366
+ rcond=rcond, n_singular_values=n_singular_values, corrector_limits=corrector_limits)
310
367
 
311
368
  return correction
312
369
 
@@ -375,7 +432,8 @@ class TrajectoryCorrection:
375
432
  monitor_names_y=None, corrector_names_y=None,
376
433
  monitor_alignment=None,
377
434
  x_init=0, px_init=0, y_init=0, py_init=0, zeta_init=0, delta_init=0,
378
- n_micado=None, n_singular_values=None, rcond=None):
435
+ n_micado=None, n_singular_values=None, rcond=None,
436
+ corrector_limits_x=None, corrector_limits_y=None):
379
437
 
380
438
  '''
381
439
  Trajectory correction using linearized response matrix from optics
@@ -418,6 +476,14 @@ class TrajectoryCorrection:
418
476
  rcond : float
419
477
  Cutoff for small singular values (relative to the largest singular
420
478
  value). Singular values smaller than `rcond` are considered zero.
479
+ corrector_limits_x : tuple of array-like or None
480
+ Limits for the horizontal corrector strengths. If not None, it should be a tuple
481
+ of two arrays (lower_limits, upper_limits) with the same length as
482
+ the number of horizontal correctors. If None, no limits are applied.
483
+ corrector_limits_y : tuple of array-like or None
484
+ Limits for the vertical corrector strengths. If not None, it should be a tuple
485
+ of two arrays (lower_limits, upper_limits) with the same length as
486
+ the number of vertical correctors. If None, no limits are applied.
421
487
  '''
422
488
 
423
489
  if isinstance(rcond, (tuple, list)):
@@ -452,6 +518,7 @@ class TrajectoryCorrection:
452
518
  corrector_names=corrector_names_x, start=start, end=end,
453
519
  twiss_table=twiss_table, n_micado=n_micado_x,
454
520
  n_singular_values=n_singular_values_x, rcond=rcond_x,
521
+ corrector_limits=corrector_limits_x,
455
522
  x_init=x_init, px_init=px_init, y_init=y_init, py_init=py_init,
456
523
  zeta_init=zeta_init, delta_init=delta_init,
457
524
  monitor_alignment=monitor_alignment)
@@ -466,6 +533,7 @@ class TrajectoryCorrection:
466
533
  corrector_names=corrector_names_y, start=start, end=end,
467
534
  twiss_table=twiss_table, n_micado=n_micado_y,
468
535
  n_singular_values=n_singular_values_y, rcond=rcond_y,
536
+ corrector_limits=corrector_limits_y,
469
537
  x_init=x_init, px_init=px_init, y_init=y_init, py_init=py_init,
470
538
  zeta_init=zeta_init, delta_init=delta_init,
471
539
  monitor_alignment=monitor_alignment)
@@ -543,19 +611,26 @@ class TrajectoryCorrection:
543
611
 
544
612
  tw_orbit = a_correction._compute_tw_orbit()
545
613
 
614
+ if self.x_correction is not None:
615
+ relative_limits_x = self.x_correction.corrector_limits
616
+ if self.y_correction is not None:
617
+ relative_limits_y = self.y_correction.corrector_limits
618
+
546
619
  while True:
547
620
 
548
621
  if self.x_correction is not None and 'x' in planes:
549
622
  self.x_correction.correct(n_micado=n_micado_x,
550
623
  n_singular_values=n_singular_values_x,
551
624
  rcond=rcond_x, verbose=False, n_iter=1,
552
- _tw_orbit=tw_orbit)
625
+ _tw_orbit=tw_orbit,
626
+ corrector_limits=relative_limits_x)
553
627
 
554
628
  if self.y_correction is not None and 'y' in planes:
555
629
  self.y_correction.correct(n_micado=n_micado_y,
556
630
  n_singular_values=n_singular_values_y,
557
631
  rcond=rcond_y, verbose=False, n_iter=1,
558
- _tw_orbit=tw_orbit)
632
+ _tw_orbit=tw_orbit,
633
+ corrector_limits=relative_limits_y)
559
634
 
560
635
  tw_orbit_prev = tw_orbit
561
636
  tw_orbit = a_correction._compute_tw_orbit()
@@ -579,11 +654,19 @@ class TrajectoryCorrection:
579
654
  old_position = self.x_correction._measure_position(tw_orbit_prev)
580
655
  str_2print += (f'x_rms: {old_position.std():.2e}'
581
656
  f' -> {new_position.std():.2e}, ')
657
+ if self.x_correction.corrector_limits is not None:
658
+ correction_kicks_x = self.x_correction.get_kick_values()
659
+ relative_limits_x = (self.x_correction.corrector_limits[0] - correction_kicks_x,
660
+ self.x_correction.corrector_limits[1] - correction_kicks_x)
582
661
  if self.y_correction is not None and 'y' in planes:
583
662
  new_position = self.y_correction._measure_position(tw_orbit)
584
663
  old_position = self.y_correction._measure_position(tw_orbit_prev)
585
664
  str_2print += (f'y_rms: {old_position.std():.2e}'
586
665
  f' -> {new_position.std():.2e}')
666
+ if self.y_correction.corrector_limits is not None:
667
+ correction_kicks_y = self.y_correction.get_kick_values()
668
+ relative_limits_y = (self.y_correction.corrector_limits[0] - correction_kicks_y,
669
+ self.y_correction.corrector_limits[1] - correction_kicks_y)
587
670
  print(str_2print)
588
671
  if stop_x and stop_y:
589
672
  break
@@ -2778,6 +2778,8 @@ class TwissInit:
2778
2778
  particle_on_co.s = s_ele_twiss
2779
2779
  self.__dict__['particle_on_co'] = particle_on_co
2780
2780
  self._temp_co_data = None
2781
+ else:
2782
+ particle_on_co = self.particle_on_co
2781
2783
 
2782
2784
  if self._temp_optics_data is not None:
2783
2785
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xtrack
3
- Version: 0.83.1
3
+ Version: 0.83.2
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
@@ -1 +0,0 @@
1
- __version__ = '0.83.1'
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