xtrack 0.69.7__tar.gz → 0.70.1__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 (260) hide show
  1. {xtrack-0.69.7/xtrack.egg-info → xtrack-0.70.1}/PKG-INFO +2 -1
  2. {xtrack-0.69.7 → xtrack-0.70.1}/setup.py +2 -1
  3. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_acceleration.py +3 -1
  4. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_environment.py +111 -1
  5. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_lhc_match_phase_15.py +4 -4
  6. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_line.py +18 -0
  7. xtrack-0.70.1/tests/test_madnginterface.py +98 -0
  8. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_match_nested.py +1 -1
  9. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_match_optics_and_ip_knob.py +10 -9
  10. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_match_optics_and_ip_knob_new_optimize_api.py +9 -9
  11. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_match_orbit_bump.py +185 -0
  12. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_match_tune_chroma_cminus.py +62 -0
  13. xtrack-0.70.1/tests/test_new_madloader.py +853 -0
  14. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_trajectory_correcton.py +2 -1
  15. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_twiss.py +6 -4
  16. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/__init__.py +1 -1
  17. xtrack-0.70.1/xtrack/_version.py +1 -0
  18. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/apertures.py +44 -0
  19. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements.py +1 -2
  20. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/linesegmentmap.h +2 -2
  21. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/environment.py +207 -90
  22. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/line.py +193 -78
  23. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/mad_loader.py +2 -4
  24. xtrack-0.70.1/xtrack/mad_parser/__init__.py +0 -0
  25. xtrack-0.70.1/xtrack/mad_parser/env_writer.py +147 -0
  26. xtrack-0.70.1/xtrack/mad_parser/loader.py +628 -0
  27. xtrack-0.70.1/xtrack/mad_parser/parse.py +331 -0
  28. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/mad_writer.py +23 -14
  29. xtrack-0.70.1/xtrack/madng_interface.py +251 -0
  30. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/match.py +327 -314
  31. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/particles/particles.py +3 -1
  32. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/twiss.py +38 -17
  33. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/twissplot.py +4 -2
  34. {xtrack-0.69.7 → xtrack-0.70.1/xtrack.egg-info}/PKG-INFO +2 -1
  35. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack.egg-info/SOURCES.txt +7 -0
  36. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack.egg-info/requires.txt +1 -0
  37. xtrack-0.69.7/xtrack/_version.py +0 -1
  38. {xtrack-0.69.7 → xtrack-0.70.1}/LICENSE +0 -0
  39. {xtrack-0.69.7 → xtrack-0.70.1}/MANIFEST.in +0 -0
  40. {xtrack-0.69.7 → xtrack-0.70.1}/README.md +0 -0
  41. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/__init__.py +0 -0
  42. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/base_classes.py +0 -0
  43. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/be_beamfields/BB6D.py +0 -0
  44. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/be_beamfields/BB6Ddata.py +0 -0
  45. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/be_beamfields/__init__.py +0 -0
  46. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/be_beamfields/beambeam.py +0 -0
  47. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/be_beamfields/boost.py +0 -0
  48. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/be_beamfields/gaussian_fields.py +0 -0
  49. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/be_beamfields/propagate_sigma_matrix.py +0 -0
  50. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/be_beamfields/qgauss.py +0 -0
  51. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/be_beamfields/slicing.py +0 -0
  52. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/be_beamfields/spacecharge.py +0 -0
  53. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/elements.py +0 -0
  54. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/line.py +0 -0
  55. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/mathlibs.py +0 -0
  56. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/particles.py +0 -0
  57. {xtrack-0.69.7 → xtrack-0.70.1}/ducktrack/temp_pyparticles.py +0 -0
  58. {xtrack-0.69.7 → xtrack-0.70.1}/pyproject.toml +0 -0
  59. {xtrack-0.69.7 → xtrack-0.70.1}/setup.cfg +0 -0
  60. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_amplitude_detuning.py +0 -0
  61. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_aperture_turn_ele_and_monitor.py +0 -0
  62. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_apertures.py +0 -0
  63. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_attr_replicas_and_slices.py +0 -0
  64. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_cavity_absolute_time.py +0 -0
  65. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_chromatic_functions_vs_madx.py +0 -0
  66. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_coasting.py +0 -0
  67. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_collective_tracker.py +0 -0
  68. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_collimation.py +0 -0
  69. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_element_characterization_functions.py +0 -0
  70. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_element_internal_record.py +0 -0
  71. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_elements.py +0 -0
  72. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_elements_classflags.py +0 -0
  73. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_elements_thick.py +0 -0
  74. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_fcc_ee_solenoid_correction.py +0 -0
  75. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_fcc_ee_solenoid_correction_new_optimize_api.py +0 -0
  76. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_footprint.py +0 -0
  77. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_freeze_longitudinal.py +0 -0
  78. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_full_rings.py +0 -0
  79. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_hvkick.py +0 -0
  80. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_ions.py +0 -0
  81. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_lumi.py +0 -0
  82. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_mad_writer.py +0 -0
  83. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_madloader.py +0 -0
  84. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_match_and_track_from_element.py +0 -0
  85. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_match_coupling_knob.py +0 -0
  86. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_monitor.py +0 -0
  87. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_multiline.py +0 -0
  88. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_multisetter.py +0 -0
  89. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_multispecies.py +0 -0
  90. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_particles_api.py +0 -0
  91. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_periodic_symmetric_twiss_and_match.py +0 -0
  92. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_pipeline.py +0 -0
  93. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_prebuild_kernels.py +0 -0
  94. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_ps_against_ptc.py +0 -0
  95. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_ps_multiturn_twiss.py +0 -0
  96. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_psb_chicane.py +0 -0
  97. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_pyht_interface.py +0 -0
  98. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_radial_steering.py +0 -0
  99. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_radiation.py +0 -0
  100. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_radiation_equilibrium_emittances.py +0 -0
  101. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_random_gen.py +0 -0
  102. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_random_gen_exp.py +0 -0
  103. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_random_gen_gauss.py +0 -0
  104. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_random_gen_ruth.py +0 -0
  105. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_rbend_rbarc.py +0 -0
  106. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_rf_track.py +0 -0
  107. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_rotation_signs.py +0 -0
  108. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_second_order_taylor_map.py +0 -0
  109. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_seeds.py +0 -0
  110. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_slice_and_insert_with_replicas.py +0 -0
  111. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_slice_elements.py +0 -0
  112. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_slicing.py +0 -0
  113. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_solenoid_bz_map_vs_boris.py +0 -0
  114. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_spacecharge_in_ring.py +0 -0
  115. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_sps_thick.py +0 -0
  116. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_survey.py +0 -0
  117. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_tapering.py +0 -0
  118. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_thick_lhc.py +0 -0
  119. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_tilt_shifts.py +0 -0
  120. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_tracker.py +0 -0
  121. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_twiss_vs_madx_psb.py +0 -0
  122. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_vs_madx.py +0 -0
  123. {xtrack-0.69.7 → xtrack-0.70.1}/tests/test_xmask_orbit_correction.py +0 -0
  124. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/_temp/__init__.py +0 -0
  125. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/_temp/boris_and_solenoid_map/__init__.py +0 -0
  126. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/_temp/boris_and_solenoid_map/boris.h +0 -0
  127. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/_temp/boris_and_solenoid_map/solenoid_field.py +0 -0
  128. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/_temp/lhc_match/__init__.py +0 -0
  129. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/_temp/lhc_match/gen_madx_optics_file.py +0 -0
  130. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/_temp/lhc_match/lhc_match.py +0 -0
  131. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/_temp/lhc_match/var_limits.py +0 -0
  132. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/base_element.py +0 -0
  133. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/__init__.py +0 -0
  134. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/apertures_src/limitellipse.h +0 -0
  135. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/apertures_src/limitpolygon.h +0 -0
  136. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/apertures_src/limitracetrack.h +0 -0
  137. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/apertures_src/limitrect.h +0 -0
  138. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/apertures_src/limitrectellipse.h +0 -0
  139. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/apertures_src/longitudinallimitrect.h +0 -0
  140. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/beam_interaction.py +0 -0
  141. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/bend.h +0 -0
  142. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/cavity.h +0 -0
  143. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/dipole_fringe.h +0 -0
  144. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/dipoleedge.h +0 -0
  145. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/drift.h +0 -0
  146. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/drift_elem.h +0 -0
  147. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/drift_slice.h +0 -0
  148. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/drift_slice_bend.h +0 -0
  149. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/drift_slice_octupole.h +0 -0
  150. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/drift_slice_quadrupole.h +0 -0
  151. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/drift_slice_sextupole.h +0 -0
  152. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/elens.h +0 -0
  153. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/exciter.h +0 -0
  154. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/firstordertaylormap.h +0 -0
  155. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/multipole.h +0 -0
  156. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/nonlinearlens.h +0 -0
  157. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/octupole.h +0 -0
  158. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/quadrupole.h +0 -0
  159. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/referenceenergyincrease.h +0 -0
  160. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/rfmultipole.h +0 -0
  161. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/second_order_taylor_map.h +0 -0
  162. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/sextupole.h +0 -0
  163. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/simplethinbend.h +0 -0
  164. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/simplethinquadrupole.h +0 -0
  165. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/solenoid.h +0 -0
  166. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/srotation.h +0 -0
  167. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/thick_slice_bend.h +0 -0
  168. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/thick_slice_drift.h +0 -0
  169. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/thick_slice_octupole.h +0 -0
  170. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/thick_slice_quadrupole.h +0 -0
  171. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/thick_slice_sextupole.h +0 -0
  172. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/thick_slice_solenoid.h +0 -0
  173. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/thin_slice_bend.h +0 -0
  174. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/thin_slice_bend_entry.h +0 -0
  175. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/thin_slice_bend_exit.h +0 -0
  176. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/thin_slice_octupole.h +0 -0
  177. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/thin_slice_quadrupole.h +0 -0
  178. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/thin_slice_sextupole.h +0 -0
  179. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/track_bend.h +0 -0
  180. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/track_dipole_edge_linear.h +0 -0
  181. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/track_dipole_edge_nonlinear.h +0 -0
  182. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/track_dipole_fringe.h +0 -0
  183. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/track_mult_fringe.h +0 -0
  184. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/track_multipolar_components.h +0 -0
  185. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/track_multipole.h +0 -0
  186. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/track_quadrupole.h +0 -0
  187. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/track_solenoid.h +0 -0
  188. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/track_srotation.h +0 -0
  189. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/track_thick_bend.h +0 -0
  190. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/track_thick_cfd.h +0 -0
  191. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/track_wedge.h +0 -0
  192. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/track_xrotation.h +0 -0
  193. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/track_yrotation.h +0 -0
  194. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/wedge.h +0 -0
  195. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/wire.h +0 -0
  196. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/xrotation.h +0 -0
  197. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/xyshift.h +0 -0
  198. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/yrotation.h +0 -0
  199. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/elements_src/zetashift.h +0 -0
  200. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/exciter.py +0 -0
  201. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/rft_element.py +0 -0
  202. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/slice_elements.py +0 -0
  203. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/beam_elements/slice_elements_thick.py +0 -0
  204. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/footprint.py +0 -0
  205. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/general.py +0 -0
  206. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/headers/atomicadd.h +0 -0
  207. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/headers/checks.h +0 -0
  208. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/headers/constants.h +0 -0
  209. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/headers/particle_states.h +0 -0
  210. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/headers/synrad_spectrum.h +0 -0
  211. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/internal_record.py +0 -0
  212. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/json_utils.py +0 -0
  213. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/linear_normal_form.py +0 -0
  214. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/loss_location_refinement/__init__.py +0 -0
  215. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/loss_location_refinement/loss_location_refinement.py +0 -0
  216. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/lumi.py +0 -0
  217. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/monitors/__init__.py +0 -0
  218. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/monitors/beam_position_monitor.h +0 -0
  219. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/monitors/beam_position_monitor.py +0 -0
  220. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/monitors/beam_profile_monitor.h +0 -0
  221. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/monitors/beam_profile_monitor.py +0 -0
  222. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/monitors/beam_size_monitor.h +0 -0
  223. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/monitors/beam_size_monitor.py +0 -0
  224. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/monitors/last_turns_monitor.h +0 -0
  225. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/monitors/last_turns_monitor.py +0 -0
  226. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/monitors/particles_monitor.h +0 -0
  227. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/monitors/particles_monitor.py +0 -0
  228. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/multiline/__init__.py +0 -0
  229. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/multiline/multiline.py +0 -0
  230. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/multiline/shared_knobs.py +0 -0
  231. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/multisetter/__init__.py +0 -0
  232. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/multisetter/multisetter.py +0 -0
  233. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/particles/__init__.py +0 -0
  234. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/particles/constants.py +0 -0
  235. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/particles/rng_src/base_rng.h +0 -0
  236. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/particles/rng_src/particles_rng.h +0 -0
  237. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/pipeline/__init__.py +0 -0
  238. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/pipeline/core.py +0 -0
  239. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/pipeline/manager.py +0 -0
  240. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/pipeline/multitracker.py +0 -0
  241. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/progress_indicator.py +0 -0
  242. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/random/__init__.py +0 -0
  243. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/random/random_generators.py +0 -0
  244. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/random/random_src/exponential.h +0 -0
  245. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/random/random_src/exponential_integral_Ei.h +0 -0
  246. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/random/random_src/normal.h +0 -0
  247. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/random/random_src/rutherford.h +0 -0
  248. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/random/random_src/uniform.h +0 -0
  249. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/random/random_src/uniform_accurate.h +0 -0
  250. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/slicing.py +0 -0
  251. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/survey.py +0 -0
  252. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/synctime.py +0 -0
  253. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/tapering.py +0 -0
  254. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/targets.py +0 -0
  255. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/tracker.py +0 -0
  256. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/tracker_data.py +0 -0
  257. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/tracker_src/tracker.h +0 -0
  258. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack/trajectory_correction.py +0 -0
  259. {xtrack-0.69.7 → xtrack-0.70.1}/xtrack.egg-info/dependency_links.txt +0 -0
  260. {xtrack-0.69.7 → xtrack-0.70.1}/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.69.7
3
+ Version: 0.70.1
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
@@ -22,6 +22,7 @@ Requires-Dist: nafflib; extra == "tests"
22
22
  Requires-Dist: PyHEADTAIL; extra == "tests"
23
23
  Requires-Dist: pytest; extra == "tests"
24
24
  Requires-Dist: pytest-mock; extra == "tests"
25
+ Requires-Dist: pymadng; extra == "tests"
25
26
  Provides-Extra: notebooks
26
27
  Requires-Dist: jupyter; extra == "notebooks"
27
28
  Requires-Dist: ipympl; extra == "notebooks"
@@ -48,7 +48,8 @@ setup(
48
48
  'xdeps'
49
49
  ],
50
50
  extras_require={
51
- 'tests': ['cpymad', 'nafflib', 'PyHEADTAIL', 'pytest', 'pytest-mock'],
51
+ 'tests': ['cpymad', 'nafflib', 'PyHEADTAIL', 'pytest', 'pytest-mock',
52
+ 'pymadng'],
52
53
  'notebooks': ['jupyter', 'ipympl', 'xplt'],
53
54
  },
54
55
  )
@@ -89,11 +89,13 @@ def test_energy_program(test_context):
89
89
  line['br1.acwf7l1.1'].frequency = 1e3
90
90
 
91
91
  # test to_dict and from_dict
92
+ lbefore = line
92
93
  line_dict = line.to_dict()
93
94
  line = xt.Line.from_dict(line_dict)
95
+ assert np.all(line.vars.get_table().name == lbefore.vars.get_table().name)
94
96
 
95
- # test copy method
96
97
  line = line.copy()
98
+ assert np.all(line.vars.get_table().name == lbefore.vars.get_table().name)
97
99
 
98
100
  line.build_tracker(_context=test_context)
99
101
 
@@ -3,6 +3,7 @@ import xobjects as xo
3
3
  import xdeps as xd
4
4
  import numpy as np
5
5
  import pytest
6
+ import json
6
7
  import pathlib
7
8
 
8
9
  test_data_folder = pathlib.Path(__file__).parent.joinpath('../test_data').absolute()
@@ -1852,4 +1853,113 @@ def test_inpection_methods(container_type):
1852
1853
 
1853
1854
  tt = ee['bb'].get_table()
1854
1855
  assert tt['value', 'k0'] == 2 * (2 * 2 + 1)
1855
- assert tt['expr', 'k0'] == "(2.0 * vars['b'])"
1856
+ assert tt['expr', 'k0'] == "(2.0 * vars['b'])"
1857
+
1858
+
1859
+ def test_vars_features(tmpdir):
1860
+ env = xt.Environment()
1861
+
1862
+ try:
1863
+ env['b'] = '3*a'
1864
+ except KeyError:
1865
+ pass
1866
+ else:
1867
+ raise ValueError('Variable a should not be present')
1868
+
1869
+ env.vars.default_to_zero = True
1870
+ env['b'] = '3*a'
1871
+
1872
+ assert env['a'] == 0
1873
+ assert env['b'] == 0
1874
+
1875
+ env['a'] = 3
1876
+ assert env['b'] == 9
1877
+
1878
+ # Test compact and to_dict
1879
+ tt = env.vars.get_table()
1880
+ assert tt['expr', 'b'] == '(3.0 * a)'
1881
+ dd = tt.to_dict()
1882
+ assert dd['b'] == '(3.0 * a)'
1883
+ assert dd['a'] == 3.0
1884
+
1885
+ ee = xt.Environment()
1886
+ ee.vars.update(dd)
1887
+ assert ee['a'] == 3.0
1888
+ assert ee['b'] == 9.0
1889
+ assert ee.vars.get_table()['expr', 'b'] == '(3.0 * a)'
1890
+
1891
+ with open(tmpdir / 'env.json', 'w') as fid:
1892
+ json.dump(dd, fid)
1893
+
1894
+ ee2 = xt.Environment()
1895
+ ee2.vars.load_json(tmpdir / 'env.json')
1896
+ assert ee2['a'] == 3.0
1897
+ assert ee2['b'] == 9.0
1898
+ assert ee2.vars.get_table()['expr', 'b'] == '(3.0 * a)'
1899
+
1900
+ tt1 = env.vars.get_table(compact=False)
1901
+ assert tt1['expr', 'b'] == "(3.0 * vars['a'])"
1902
+ dd1 = tt1.to_dict()
1903
+ assert dd1['b'] == "(3.0 * vars['a'])"
1904
+ assert dd1['a'] == 3.0
1905
+
1906
+
1907
+ def test_call(tmpdir):
1908
+ def _trim(string):
1909
+ # Reduce indent level by one
1910
+ return '\n'.join(map(lambda line: line[4:], filter(bool, string.split('\n'))))
1911
+
1912
+ preamble = _trim("""
1913
+ import xtrack as xt
1914
+ env = xt.get_environment()
1915
+ env.vars.default_to_zero=True
1916
+ """)
1917
+
1918
+ parameters = _trim("""
1919
+ env['var1'] = 2
1920
+ env['var2'] = 3
1921
+ """)
1922
+
1923
+ elements = _trim("""
1924
+ env.new('sbend', 'Bend')
1925
+ env.new('drift', 'Drift')
1926
+
1927
+ env.new('mb2', 'sbend', length=2)
1928
+ env.new('drx', 'drift', length='var1 + var2')
1929
+ """)
1930
+
1931
+ lattice = _trim("""
1932
+ env.particle_ref = xt.Particles(mass0=xt.ELECTRON_MASS_EV, energy0=45.6e9)
1933
+
1934
+ env.new_line(
1935
+ name='seq',
1936
+ components=['mb2', 'drx', 'mb2', 'drx'],
1937
+ )
1938
+ """)
1939
+
1940
+ parameter_file = tmpdir / 'parameters.py'
1941
+ element_file = tmpdir / 'elements.py'
1942
+ lattice_file = tmpdir / 'lattice.py'
1943
+
1944
+ with parameter_file.open('w') as f:
1945
+ f.write(preamble + parameters)
1946
+
1947
+ with element_file.open('w') as f:
1948
+ f.write(preamble + elements)
1949
+
1950
+ with lattice_file.open('w') as f:
1951
+ f.write(preamble + lattice)
1952
+
1953
+ env = xt.Environment()
1954
+ env.call(parameter_file)
1955
+ env.call(element_file)
1956
+ env.call(lattice_file)
1957
+
1958
+ line, = env.lines.values()
1959
+ assert line.name == 'seq'
1960
+ assert line.element_names == ['mb2', 'drx', 'mb2', 'drx']
1961
+ assert env['mb2'].length == line['mb2'].length == 2
1962
+ assert env['drx'].length == line['drx'].length == 5
1963
+
1964
+ env['var1'] = 10
1965
+ assert env['drx'].length == 13
@@ -559,10 +559,10 @@ def test_lhc_match_phase_15(test_context, config):
559
559
  xt.VaryList(['kqtf.b1', 'kqtd.b1', 'ksf.b1', 'ksd.b1'], step=1e-7),
560
560
  xt.VaryList(['kqtf.b2', 'kqtd.b2', 'ksf.b2', 'ksd.b2'], step=1e-7)],
561
561
  targets = [
562
- xt.TargetSet(line='lhcb1', qx=62.315, qy=60.325, tol=1e-10),
563
- xt.TargetSet(line='lhcb1', dqx=10.0, dqy=12.0, tol=1e-5),
564
- xt.TargetSet(line='lhcb2', qx=62.316, qy=60.324, tol=1e-10),
565
- xt.TargetSet(line='lhcb2', dqx=9.0, dqy=11.0, tol=1e-5)])
562
+ xt.TargetSet(line='lhcb1', qx=62.315, qy=60.325, tol=1e-6),
563
+ xt.TargetSet(line='lhcb1', dqx=10.0, dqy=12.0, tol=1e-4),
564
+ xt.TargetSet(line='lhcb2', qx=62.316, qy=60.324, tol=1e-6),
565
+ xt.TargetSet(line='lhcb2', dqx=9.0, dqy=11.0, tol=1e-4)])
566
566
  opt.solve()
567
567
 
568
568
  # Transfer knobs to madx model and check matched values
@@ -1075,3 +1075,21 @@ def test_get_strengths(test_context):
1075
1075
  xo.assert_allclose(line['mbw.a6l3.b2'].h,
1076
1076
  str_table['angle_rad', 'mbw.a6l3.b2'] / str_table['length', 'mbw.a6l3.b2'],
1077
1077
  rtol=0, atol=1e-14)
1078
+
1079
+
1080
+
1081
+ def test_insert_repeated_names():
1082
+
1083
+ line = xt.Line(
1084
+ elements=([xt.Drift(length=0)] # Start line marker
1085
+ + [xt.Drift(length=1) for _ in range(5)]
1086
+ + [xt.Drift(length=0)] # End line marker
1087
+ ),
1088
+ element_names=['d']*7
1089
+ )
1090
+ line.insert_element("m1",xt.Marker(),at="d::3")
1091
+ assert line.element_names[3]=="m1"
1092
+ line.insert_element("m2",xt.Marker(),at="d")
1093
+ assert line.element_names[0]=="m2"
1094
+
1095
+
@@ -0,0 +1,98 @@
1
+ import xtrack as xt
2
+ import xobjects as xo
3
+ import pathlib
4
+ import numpy as np
5
+
6
+ test_data_folder = pathlib.Path(
7
+ __file__).parent.joinpath('../test_data').absolute()
8
+
9
+ def test_madng_twiss():
10
+ rdts = ["f4000", "f3100", "f2020", "f1120", 'f1001']
11
+
12
+ line = xt.Line.from_json(test_data_folder /
13
+ 'hllhc15_thick/lhc_thick_with_knobs.json')
14
+
15
+ line['test_dk1'] = 0
16
+ line['mb.b32l8.b1'].knl[1] = 'test_dk1'
17
+
18
+ tw = line.madng_twiss(normal_form=False)
19
+
20
+ opt = line.match(
21
+ solve=False,
22
+ vary=[
23
+ xt.Vary('on_x1', step=1e-3),
24
+ ],
25
+ targets=(
26
+ tw.target('px_ng', 50e-6, at='ip1'),
27
+ tw.target('py_ng', 0, at='ip1'),
28
+ ),
29
+ )
30
+ opt.step(3)
31
+ tw_after = line.madng_twiss(normal_form=False)
32
+ xo.assert_allclose(tw_after['px_ng', 'ip1'], 50e-6, rtol=5e-3, atol=0)
33
+
34
+ line['on_x1'] = 1.
35
+ xo.assert_allclose(line.madng_twiss()['px_ng', 'ip1'], 1e-6, rtol=5e-3, atol=0)
36
+
37
+ line['on_x1'] = -2.
38
+ xo.assert_allclose(line.madng_twiss()['px_ng', 'ip1'], -2e-6, rtol=5e-3, atol=0)
39
+
40
+ # We just check that rdts are there
41
+ tw_rdt = line.madng_twiss(rdts=rdts)
42
+ assert np.abs(tw_rdt.f4000).max() > 0
43
+ assert np.abs(tw_rdt.f3100).max() > 0
44
+ assert np.abs(tw_rdt.f2020).max() > 0
45
+ assert np.abs(tw_rdt.f1120).max() > 0
46
+
47
+ def test_madng_interface_with_multipole_errors_and_misalignments():
48
+ line = xt.Line.from_json(test_data_folder /
49
+ 'hllhc15_thick/lhc_thick_with_knobs.json')
50
+
51
+ tt = line.get_table()
52
+ tt_quads = tt.rows[tt.element_type=='Quadrupole']
53
+
54
+ # Introduce misalignments on all quadrupoles
55
+ tt = line.get_table()
56
+ tt_quad = tt.rows['mq\..*']
57
+ rgen = np.random.RandomState(1) # fix seed for random number generator
58
+ # (to have reproducible results)
59
+ shift_x = rgen.randn(len(tt_quad)) * 0.01e-3 # 0.01 mm rms shift on all quads
60
+ shift_y = rgen.randn(len(tt_quad)) * 0.01e-3 # 0.01 mm rms shift on all quads
61
+ rot_s = rgen.randn(len(tt_quad)) * 1e-3 # 1 mrad rms rotation on all quads
62
+ k2l = rgen.rand(len(tt_quad)) * 1e-3
63
+
64
+ line['on_error'] = 1.
65
+ for nn_quad, sx, sy, rr, kkk in zip(tt_quad.name, shift_x, shift_y, rot_s, k2l):
66
+ line[nn_quad].shift_x = sx * line.ref['on_error']
67
+ line[nn_quad].shift_y = sy * line.ref['on_error']
68
+ line[nn_quad].rot_s_rad = rr * line.ref['on_error']
69
+ line[nn_quad].knl[2] = kkk * line.ref['on_error']
70
+ tw = line.madng_twiss()
71
+
72
+ xo.assert_allclose(tw.x, tw.x_ng, atol=5e-4*tw.x.std(), rtol=0)
73
+ xo.assert_allclose(tw.y, tw.y_ng, atol=5e-4*tw.y.std(), rtol=0)
74
+ xo.assert_allclose(tw.betx2, tw.beta12_ng, atol=0, rtol=2e-3)
75
+ xo.assert_allclose(tw.bety1, tw.beta21_ng, atol=0, rtol=2e-3)
76
+ xo.assert_allclose(tw.wx_chrom, tw.wx_ng, atol=5e-3*tw.wx_chrom.max(), rtol=0)
77
+ xo.assert_allclose(tw.wy_chrom, tw.wy_ng, atol=5e-3*tw.wy_chrom.max(), rtol=0)
78
+ xo.assert_allclose(tw.ax_chrom, tw.ax_ng, atol=5e-3*tw.wx_chrom.max(), rtol=0)
79
+ xo.assert_allclose(tw.ay_chrom, tw.ay_ng, atol=5e-3*tw.wy_chrom.max(), rtol=0)
80
+ xo.assert_allclose(tw.bx_chrom, tw.bx_ng, atol=5e-3*tw.wx_chrom.max(), rtol=0)
81
+ xo.assert_allclose(tw.by_chrom, tw.by_ng, atol=5e-3*tw.wy_chrom.max(), rtol=0)
82
+
83
+ line['on_error'] = 0
84
+ tw = line.madng_twiss()
85
+ xo.assert_allclose(tw.x, 0, atol=1e-10, rtol=0)
86
+ xo.assert_allclose(tw.y, 0, atol=1e-10, rtol=0)
87
+ xo.assert_allclose(tw.betx2, 0, atol=1e-10, rtol=0)
88
+ xo.assert_allclose(tw.bety1, 0, atol=1e-10, rtol=0)
89
+ xo.assert_allclose(tw.x, tw.x_ng, atol=1e-10, rtol=0)
90
+ xo.assert_allclose(tw.y, tw.y_ng, atol=1e-10, rtol=0)
91
+ xo.assert_allclose(tw.betx2, tw.beta12_ng, atol=1e-10, rtol=0)
92
+ xo.assert_allclose(tw.bety1, tw.beta21_ng, atol=1e-19, rtol=0)
93
+ xo.assert_allclose(tw.wx_chrom, tw.wx_ng, atol=5e-3*tw.wx_chrom.max(), rtol=0)
94
+ xo.assert_allclose(tw.wy_chrom, tw.wy_ng, atol=5e-3*tw.wy_chrom.max(), rtol=0)
95
+ xo.assert_allclose(tw.ax_chrom, tw.ax_ng, atol=5e-3*tw.wx_chrom.max(), rtol=0)
96
+ xo.assert_allclose(tw.ay_chrom, tw.ay_ng, atol=5e-3*tw.wy_chrom.max(), rtol=0)
97
+ xo.assert_allclose(tw.bx_chrom, tw.bx_ng, atol=5e-3*tw.wx_chrom.max(), rtol=0)
98
+ xo.assert_allclose(tw.by_chrom, tw.by_ng, atol=5e-3*tw.wy_chrom.max(), rtol=0)
@@ -166,7 +166,7 @@ def test_match_nested(test_context):
166
166
  xd.Vary(name='kqf.a67', container=collider.vars, step=1e-5),
167
167
  xd.Vary(name='kqd.a67', container=collider.vars, step=1e-5),
168
168
  ])
169
- optimize_phase_arc_67.solve()
169
+ optimize_phase_arc_67.solve(n_steps=5)
170
170
 
171
171
  # Checks
172
172
  resb1_after = action_arc_phase_s67_b1.run()
@@ -184,16 +184,17 @@ def test_ip_knob_matching(test_context):
184
184
  assert np.all(np.array(vactive) == np.array(
185
185
  [True, True, True, True, True, True, True, True, False, False, False, False, False, False]))
186
186
 
187
+ assert len(opt.log()) == 1
187
188
  opt.step(10) # perform 10 steps without checking for convergence
188
189
 
189
190
  ll = opt.log()
190
- assert len(ll) == 11
191
+ assert len(ll) == 13
191
192
  assert ll['vary_active', 0] == 'yyyyyyyyyyyyyy'
192
193
  assert ll['vary_active', 1] == 'yyyyyyyynnnnnn'
193
- assert ll['vary_active', 10] == 'yyyyyyyynnnnnn'
194
+ assert ll['vary_active', 11] == 'yyyyyyyynnnnnn'
194
195
 
195
196
  # Check solution not found
196
- assert ll['tol_met', 10] != 'yyyyyyyy'
197
+ assert ll['tol_met', 12] != 'yyyyyyyy'
197
198
 
198
199
  # Check that mcbxs did not move
199
200
  xo.assert_allclose(ll['vary_8', 1:], init_mcbx_plus, atol=1e-12, rtol=0)
@@ -219,17 +220,17 @@ def test_ip_knob_matching(test_context):
219
220
  ll = opt.log()
220
221
 
221
222
  # Check driving knob is enabled
222
- assert np.all(ll['vary_active', 11:] == 'yyyyyyyyynnnnn')
223
+ assert np.all(ll['vary_active', 13:] == 'yyyyyyyyynnnnn')
223
224
 
224
225
  # Check solution found
225
226
  assert np.all(ll['tol_met', -1] == 'yyyyyyyy')
226
227
 
227
228
  # Check imposed relationship among varys
228
- xo.assert_allclose(ll['vary_8', 11], ll['vary_9', 11], atol=1e-12, rtol=0)
229
- xo.assert_allclose(ll['vary_8', 11], ll['vary_10', 11], atol=1e-12, rtol=0)
230
- xo.assert_allclose(ll['vary_8', 11], -ll['vary_11', 11], atol=1e-12, rtol=0)
231
- xo.assert_allclose(ll['vary_8', 11], -ll['vary_12', 11], atol=1e-12, rtol=0)
232
- xo.assert_allclose(ll['vary_8', 11], -ll['vary_13', 11], atol=1e-12, rtol=0)
229
+ xo.assert_allclose(ll['vary_8', 13], ll['vary_9', 13], atol=1e-12, rtol=0)
230
+ xo.assert_allclose(ll['vary_8', 13], ll['vary_10', 13], atol=1e-12, rtol=0)
231
+ xo.assert_allclose(ll['vary_8', 13], -ll['vary_11', 13], atol=1e-12, rtol=0)
232
+ xo.assert_allclose(ll['vary_8', 13], -ll['vary_12', 13], atol=1e-12, rtol=0)
233
+ xo.assert_allclose(ll['vary_8', 13], -ll['vary_13', 13], atol=1e-12, rtol=0)
233
234
 
234
235
  opt.generate_knob()
235
236
 
@@ -187,13 +187,13 @@ def test_ip_knob_matching_new_optimize_api(test_context):
187
187
  opt.step(10) # perform 10 steps without checking for convergence
188
188
 
189
189
  ll = opt.log()
190
- assert len(ll) == 11
190
+ assert len(ll) == 13
191
191
  assert ll['vary_active', 0] == 'yyyyyyyyyyyyyy'
192
192
  assert ll['vary_active', 1] == 'yyyyyyyynnnnnn'
193
- assert ll['vary_active', 10] == 'yyyyyyyynnnnnn'
193
+ assert ll['vary_active', 12] == 'yyyyyyyynnnnnn'
194
194
 
195
195
  # Check solution not found
196
- assert ll['tol_met', 10] != 'yyyyyyyy'
196
+ assert ll['tol_met', 11] != 'yyyyyyyy'
197
197
 
198
198
  # Check that mcbxs did not move
199
199
  xo.assert_allclose(ll['vary_8', 1:], init_mcbx_plus, atol=1e-12, rtol=0)
@@ -219,17 +219,17 @@ def test_ip_knob_matching_new_optimize_api(test_context):
219
219
  ll = opt.log()
220
220
 
221
221
  # Check driving knob is enabled
222
- assert np.all(ll['vary_active', 11:] == 'yyyyyyyyynnnnn')
222
+ assert np.all(ll['vary_active', 13:] == 'yyyyyyyyynnnnn')
223
223
 
224
224
  # Check solution found
225
225
  assert np.all(ll['tol_met', -1] == 'yyyyyyyy')
226
226
 
227
227
  # Check imposed relationship among varys
228
- xo.assert_allclose(ll['vary_8', 11], ll['vary_9', 11], atol=1e-12, rtol=0)
229
- xo.assert_allclose(ll['vary_8', 11], ll['vary_10', 11], atol=1e-12, rtol=0)
230
- xo.assert_allclose(ll['vary_8', 11], -ll['vary_11', 11], atol=1e-12, rtol=0)
231
- xo.assert_allclose(ll['vary_8', 11], -ll['vary_12', 11], atol=1e-12, rtol=0)
232
- xo.assert_allclose(ll['vary_8', 11], -ll['vary_13', 11], atol=1e-12, rtol=0)
228
+ xo.assert_allclose(ll['vary_8', 13], ll['vary_9', 13], atol=1e-12, rtol=0)
229
+ xo.assert_allclose(ll['vary_8', 13], ll['vary_10', 13], atol=1e-12, rtol=0)
230
+ xo.assert_allclose(ll['vary_8', 13], -ll['vary_11', 13], atol=1e-12, rtol=0)
231
+ xo.assert_allclose(ll['vary_8', 13], -ll['vary_12', 13], atol=1e-12, rtol=0)
232
+ xo.assert_allclose(ll['vary_8', 13], -ll['vary_13', 13], atol=1e-12, rtol=0)
233
233
 
234
234
  opt.generate_knob()
235
235
 
@@ -856,3 +856,188 @@ def test_match_bump_common_elements_targets_from_tables(test_context):
856
856
  xo.assert_allclose(tw.lhcb2['py', 'ip5'] + tw.lhcb1['py', 'ip5'], 0, rtol=0, atol=1e-10)
857
857
  xo.assert_allclose(tw.lhcb2['y', 's.ds.r5.b2'], 0, rtol=0, atol=1e-9)
858
858
  xo.assert_allclose(tw.lhcb2['py', 's.ds.r5.b2'], 0, rtol=0, atol=1e-9)
859
+
860
+ @for_all_test_contexts
861
+ def test_match_bump_clone_and_ref_in_inequality(test_context):
862
+
863
+ line = xt.Line.from_json(test_data_folder /
864
+ 'hllhc14_no_errors_with_coupling_knobs/line_b1.json')
865
+ line.build_tracker(test_context)
866
+
867
+ GreaterThan = xt.GreaterThan
868
+ LessThan = xt.LessThan
869
+
870
+ tw0 = line.twiss()
871
+ opt = line.match(
872
+ name='bump',
873
+ solve=False,
874
+ solver='jacobian',
875
+ # Portion of the beam line to be modified and initial conditions
876
+ start='mq.33l8.b1',
877
+ end='mq.17l8.b1',
878
+ init=tw0, init_at=xt.START,
879
+ # Dipole corrector strengths to be varied
880
+ vary=[
881
+ xt.Vary(name='acbv32.l8b1', step=1e-10, weight=0.7),
882
+ xt.Vary(name='acbv28.l8b1', step=1e-10, weight=0.3),
883
+ xt.Vary(name='acbv26.l8b1', step=1e-10),
884
+ xt.Vary(name='acbv24.l8b1', step=1e-10),
885
+ xt.Vary(name='acbv22.l8b1', step=1e-10, weight=1000),
886
+ xt.Vary(name='acbv18.l8b1', step=1e-10),
887
+ ],
888
+ targets=[
889
+ xt.Target('py', at='mb.b26l8.b1', value=0, tol=1e-6, weight=1e3),
890
+ xt.Target('y', at='mb.b26l8.b1', value=3e-3, tol=1e-4),
891
+ xt.Target('y', at='mq.17l8.b1', value=tw0, tol=1e-6),
892
+ xt.Target('py', at='mq.17l8.b1', value=tw0, tol=1e-7, weight=1e3),
893
+ ]
894
+ )
895
+
896
+ # Check target_mismatch
897
+ assert opt.name == 'bump'
898
+ ts = opt.target_status(ret=True)
899
+ assert len(ts) == 4
900
+ assert np.all(ts.tol_met == np.array([True, False, True, True]))
901
+ tm = opt.target_mismatch(ret=True)
902
+ assert len(tm) == 1
903
+ assert tm.id[0] == 1
904
+
905
+ opt.solve()
906
+
907
+ # I want to limit the negative excursion ot the bump
908
+ opt2 = opt.clone(name='limit',
909
+ add_targets=[
910
+ xt.Target('y', GreaterThan(-2e-3), at='mq.30l8.b1', tol=1e-6),
911
+ xt.Target('y', GreaterThan(-1e-3), at='mq.30l8.b1', tol=1e-6)])
912
+ opt2.solve()
913
+
914
+ assert opt2.name == 'limit'
915
+ assert len(opt2.targets) == 6
916
+ tm = opt2.target_mismatch(ret=True)
917
+ assert(len(tm) == 0)
918
+
919
+ tw = line.twiss()
920
+
921
+ assert np.isclose(tw['y', 'mq.33l8.b1'], 0, atol=1e-6, rtol=0)
922
+ assert np.isclose(tw['y', 'mq.17l8.b1'], 0, atol=1e-6, rtol=0)
923
+ assert np.isclose(tw['py', 'mq.17l8.b1'], 0, atol=1e-8, rtol=0)
924
+ assert np.isclose(tw['py', 'mq.33l8.b1'], 0, atol=1e-6, rtol=0)
925
+
926
+ assert np.isclose(tw['y', 'mb.b26l8.b1'], 3e-3, atol=1e-6, rtol=0)
927
+ assert np.isclose(tw['py', 'mb.b26l8.b1'], 0, atol=1e-8, rtol=0)
928
+
929
+ assert np.isclose(tw['y', 'mq.30l8.b1'], -1e-3, atol=1e-6, rtol=0)
930
+
931
+ # Test variable in inequality
932
+ line['myvar'] = -5e-3
933
+ line['myvar2'] = 4e-3
934
+ opt3 = opt2.clone(name='ineq',
935
+ add_targets=[
936
+ xt.Target('y', GreaterThan(line.ref['myvar']), at='mq.30l8.b1', tol=1e-6),
937
+ xt.Target('y', LessThan(line.ref['myvar2']), at='mb.b26l8.b1', tol=1e-6)])
938
+
939
+ assert len(opt3.target_mismatch(ret=True)) == 0
940
+ assert opt3.target_status(ret=True).residue[-1] == 0
941
+
942
+ line['myvar'] = -0.5e-3
943
+ line['myvar2'] = 2e-3
944
+ opt3.disable(target=1)
945
+ assert len(opt3.target_mismatch(ret=True)) == 2
946
+ xo.assert_allclose(opt3.target_mismatch(ret=True).residue[-2], -0.5e-3,
947
+ atol=1e-5, rtol=0)
948
+ xo.assert_allclose(opt3.target_mismatch(ret=True).residue[-1], -1e-3,
949
+ atol=1e-5, rtol=0)
950
+
951
+ opt3.solve()
952
+ assert len(opt3.target_mismatch(ret=True)) == 1 # The disabled target
953
+ assert opt3.target_mismatch(ret=True).id[0] == 1
954
+
955
+ tw = line.twiss()
956
+
957
+ assert np.isclose(tw['y', 'mq.33l8.b1'], 0, atol=1e-6, rtol=0)
958
+ assert np.isclose(tw['y', 'mq.17l8.b1'], 0, atol=1e-6, rtol=0)
959
+ assert np.isclose(tw['py', 'mq.17l8.b1'], 0, atol=1e-8, rtol=0)
960
+ assert np.isclose(tw['py', 'mq.33l8.b1'], 0, atol=1e-6, rtol=0)
961
+
962
+ assert np.isclose(tw['y', 'mb.b26l8.b1'], 2e-3, atol=1e-6, rtol=0)
963
+ assert np.isclose(tw['py', 'mb.b26l8.b1'], 0, atol=1e-8, rtol=0)
964
+
965
+ assert np.isclose(tw['y', 'mq.30l8.b1'], -0.5e-3, atol=1e-6, rtol=0)
966
+
967
+
968
+ def test_match_autogen_tags_and_clone_options():
969
+
970
+ line = xt.Line.from_json(test_data_folder /
971
+ "hllhc15_thick/lhc_thick_with_knobs.json")
972
+
973
+ opt = line.match(
974
+ start='mq.30l8.b1', end='mq.23l8.b1',
975
+ betx=1, bety=1, y=0, py=0,
976
+ vary=[xt.VaryList(['acbv30.l8b1', 'acbv28.l8b1',],
977
+ step=1e-10, limits=[-1e-3, 1e-3]),
978
+ xt.VaryList(['acbv26.l8b1', 'acbv24.l8b1'],
979
+ step=1e-10, limits=[-1e-3, 1e-3], tag='mytag')],
980
+ targets = [
981
+ xt.TargetSet(y=3e-3, py=0, at='mb.b28l8.b1'),
982
+ xt.TargetSet(y=0, py=0, at=xt.END)
983
+ ])
984
+
985
+ # Check autogenerated tags
986
+ assert opt.targets[0].tag == 'mb.b28l8.b1_y'
987
+ assert opt.targets[1].tag == 'mb.b28l8.b1_py'
988
+ assert opt.targets[2].tag == 'END_y'
989
+ assert opt.targets[3].tag == 'END_py'
990
+
991
+ # Check target getitem
992
+ assert opt.targets[0] == opt.targets['mb.b28l8.b1_y']
993
+ assert opt.targets[1] == opt.targets['mb.b28l8.b1_py']
994
+ assert opt.targets[2] == opt.targets['END_y']
995
+ assert opt.targets[3] == opt.targets['END_py']
996
+
997
+ assert opt.targets['END.*'][0] is opt.targets[2]
998
+ assert opt.targets['END.*'][1] is opt.targets[3]
999
+
1000
+ assert np.all(
1001
+ opt.targets.status(ret=True).tag == opt.target_status(ret=True).tag)
1002
+
1003
+ assert opt.vary['myt.*'][0] is opt.vary[2]
1004
+ assert opt.vary['myt.*'][1] is opt.vary[3]
1005
+ assert np.all(opt.vary.status(ret=True).tag == np.array(['', '', 'mytag', 'mytag']))
1006
+ assert np.all(opt.vary.status(ret=True).tag == opt.vary_status(ret=True).tag)
1007
+ assert np.all(opt.vary.status(ret=True).name == np.array(
1008
+ ['acbv30.l8b1', 'acbv28.l8b1', 'acbv26.l8b1', 'acbv24.l8b1']))
1009
+
1010
+ opt1 = opt.clone(name='opt1')
1011
+ assert opt1.name == 'opt1'
1012
+ assert str(opt1.targets[0]) == str(opt.targets[0])
1013
+ assert str(opt1.targets[1]) == str(opt.targets[1])
1014
+ assert str(opt1.targets[2]) == str(opt.targets[2])
1015
+ assert str(opt1.targets[3]) == str(opt.targets[3])
1016
+ assert str(opt1.vary[0]) == str(opt.vary[0])
1017
+ assert str(opt1.vary[1]) == str(opt.vary[1])
1018
+ assert str(opt1.vary[2]) == str(opt.vary[2])
1019
+ assert str(opt1.vary[3]) == str(opt.vary[3])
1020
+
1021
+ opt2 = opt.clone(name='opt2', remove_vary=True)
1022
+ assert len(opt2.vary) == 0
1023
+ assert str(opt2.targets[0]) == str(opt.targets[0])
1024
+ assert str(opt2.targets[1]) == str(opt.targets[1])
1025
+ assert str(opt2.targets[2]) == str(opt.targets[2])
1026
+ assert str(opt2.targets[3]) == str(opt.targets[3])
1027
+
1028
+ opt3 = opt.clone(name='opt3', remove_targets=True,
1029
+ add_targets=[xt.TargetSet(y=3e-3, py=0, at='mb.b28l8.b1')])
1030
+ assert len(opt3.targets) == 2
1031
+ assert opt.targets[0].tag == 'mb.b28l8.b1_y'
1032
+ assert opt.targets[1].tag == 'mb.b28l8.b1_py'
1033
+ assert str(opt3.vary[0]) == str(opt.vary[0])
1034
+ assert str(opt3.vary[1]) == str(opt.vary[1])
1035
+ assert str(opt3.vary[2]) == str(opt.vary[2])
1036
+ assert str(opt3.vary[3]) == str(opt.vary[3])
1037
+
1038
+ opt4 = opt.clone(name='opt4', remove_vary=True, remove_targets=False,
1039
+ add_vary=xt.VaryList(['acbv30.l8b1', 'acbv28.l8b1']),
1040
+ )
1041
+ assert len(opt4.vary) == 2
1042
+ assert opt.vary[0].name == 'acbv30.l8b1'
1043
+ assert opt.vary[1].name == 'acbv28.l8b1'
@@ -1,6 +1,7 @@
1
1
  import json
2
2
  import pathlib
3
3
  import time
4
+ from scipy.optimize import minimize
4
5
 
5
6
  import xobjects as xo
6
7
  import xpart as xp
@@ -130,6 +131,67 @@ def test_match_tune_chromaticity(test_context):
130
131
  xo.assert_allclose(tw_final['dqx'], 6.0, atol=0.05)
131
132
  xo.assert_allclose(tw_final['dqy'], 4.0, atol=0.05)
132
133
 
134
+ @for_all_test_contexts
135
+ def test_match_tune_chromaticity_scalar(test_context):
136
+
137
+ with open(path_line) as f:
138
+ dct = json.load(f)
139
+
140
+ line = xt.Line.from_dict(dct['line'])
141
+ line.particle_ref = xp.Particles.from_dict(dct['particle'])
142
+
143
+ line.build_tracker(_context=test_context)
144
+
145
+ print('\nInitial twiss parameters')
146
+ tw_before = line.twiss()
147
+ print(f"Qx = {tw_before['qx']:.5f} Qy = {tw_before['qy']:.5f} "
148
+ f"Q'x = {tw_before['dqx']:.5f} Q'y = {tw_before['dqy']:.5f}")
149
+
150
+ print(f"kqtf.b1 = {line.vars['kqtf.b1']._value}")
151
+ print(f"kqtd.b1 = {line.vars['kqtd.b1']._value}")
152
+ print(f"ksf.b1 = {line.vars['ksf.b1']._value}")
153
+ print(f"ksd.b1 = {line.vars['ksd.b1']._value}")
154
+
155
+ t1 = time.time()
156
+ opt = line.match(
157
+ solve=False,
158
+ vary=[
159
+ xt.Vary('kqtf.b1', step=1e-8),
160
+ xt.Vary('kqtd.b1', step=1e-8),
161
+ xt.Vary('ksf.b1', step=1e-8),
162
+ xt.Vary('ksd.b1', step=1e-8),
163
+ ],
164
+ targets = [
165
+ xt.Target('qx', 62.315, tol=1e-4),
166
+ xt.Target('qy', 60.325, tol=1e-4),
167
+ xt.Target('dqx', 10.0, tol=0.05),
168
+ xt.Target('dqy', 12.0, tol=0.05)])
169
+
170
+ merit_function = opt.get_merit_function(return_scalar=True, check_limits=False)
171
+ opt.check_limits = False
172
+ bounds = [(-1e-4, 1e-4), (-1e-4, 1e-4), (-10, 10), (-10, 10)]
173
+ x0 = merit_function.get_x()
174
+
175
+ result = minimize(merit_function, x0=x0, bounds=bounds, jac=merit_function.get_jacobian, method='L-BFGS-B')
176
+
177
+ t2 = time.time()
178
+ print('\nTime fsolve: ', t2-t1)
179
+
180
+ merit_function.set_x(result.x)
181
+
182
+ tw_final = line.twiss()
183
+ print('\nFinal twiss parameters')
184
+ print(f"Qx = {tw_final['qx']:.5f} Qy = {tw_final['qy']:.5f} "
185
+ f"Q'x = {tw_final['dqx']:.5f} Q'y = {tw_final['dqy']:.5f}")
186
+ print(f"kqtf.b1 = {line.vars['kqtf.b1']._value}")
187
+ print(f"kqtd.b1 = {line.vars['kqtd.b1']._value}")
188
+ print(f"ksf.b1 = {line.vars['ksf.b1']._value}")
189
+ print(f"ksd.b1 = {line.vars['ksd.b1']._value}")
190
+
191
+ xo.assert_allclose(tw_final['qx'], 62.315, atol=1e-7)
192
+ xo.assert_allclose(tw_final['qy'], 60.325, atol=1e-7)
193
+ xo.assert_allclose(tw_final['dqx'], 10.0, atol=0.05)
194
+ xo.assert_allclose(tw_final['dqy'], 12.0, atol=0.05)
133
195
 
134
196
  @for_all_test_contexts
135
197
  def test_match_coupling(test_context):