xtrack 0.54.1__tar.gz → 0.55.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {xtrack-0.54.1 → xtrack-0.55.0}/PKG-INFO +1 -1
- xtrack-0.55.0/tests/test_cavity_absolute_time.py +47 -0
- xtrack-0.55.0/tests/test_coasting.py +155 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_elements_thick.py +4 -2
- xtrack-0.55.0/tests/test_fcc_ee_solenoid_correction.py +404 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_line.py +1 -1
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_mad_writer.py +1 -1
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_madloader.py +99 -0
- xtrack-0.55.0/tests/test_match_coupling_knob.py +108 -0
- xtrack-0.55.0/tests/test_particles_api.py +135 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_psb_chicane.py +6 -6
- xtrack-0.55.0/tests/test_rf_track.py +122 -0
- xtrack-0.55.0/tests/test_solenoid_bz_map_vs_boris.py +253 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_twiss.py +2 -2
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/__init__.py +1 -1
- xtrack-0.55.0/xtrack/_temp/boris_and_solenoid_map/boris.h +112 -0
- xtrack-0.55.0/xtrack/_temp/boris_and_solenoid_map/solenoid_field.py +95 -0
- xtrack-0.55.0/xtrack/_version.py +1 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/base_element.py +29 -8
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/__init__.py +1 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements.py +8 -1
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/cavity.h +11 -1
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/quadrupole.h +0 -1
- xtrack-0.55.0/xtrack/beam_elements/elements_src/solenoid.h +239 -0
- xtrack-0.55.0/xtrack/beam_elements/rft_element.py +75 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/line.py +38 -5
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/mad_loader.py +80 -27
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/match.py +114 -2
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/multiline/multiline.py +42 -2
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/particles/particles.py +11 -2
- xtrack-0.55.0/xtrack/prebuilt_kernels/__init__.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/prebuilt_kernels/kernel_definitions.py +16 -0
- xtrack-0.55.0/xtrack/synctime.py +101 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/tracker.py +29 -9
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/twiss.py +96 -3
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack.egg-info/PKG-INFO +1 -1
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack.egg-info/SOURCES.txt +12 -0
- xtrack-0.54.1/xtrack/_version.py +0 -1
- xtrack-0.54.1/xtrack/beam_elements/elements_src/solenoid.h +0 -156
- {xtrack-0.54.1 → xtrack-0.55.0}/LICENSE +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/MANIFEST.in +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/README.md +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/__init__.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/base_classes.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/be_beamfields/BB6D.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/be_beamfields/BB6Ddata.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/be_beamfields/__init__.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/be_beamfields/beambeam.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/be_beamfields/boost.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/be_beamfields/gaussian_fields.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/be_beamfields/propagate_sigma_matrix.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/be_beamfields/qgauss.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/be_beamfields/slicing.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/be_beamfields/spacecharge.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/elements.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/line.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/mathlibs.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/particles.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/ducktrack/temp_pyparticles.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/pyproject.toml +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/setup.cfg +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/setup.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_acceleration.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_amplitude_detuning.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_aperture_turn_ele_and_monitor.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_apertures.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_chromatic_functions_vs_madx.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_collective_tracker.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_collimation.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_compounds.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_element_internal_record.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_elements.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_footprint.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_freeze_longitudinal.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_full_rings.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_ions.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_lhc_match_phase_15.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_lumi.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_match_and_track_from_element.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_match_nested.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_match_optics_and_ip_knob.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_match_orbit_bump.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_match_tune_chroma_cminus.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_monitor.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_multiline.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_multisetter.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_multispecies.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_orbit_correction.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_pipeline.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_prebuild_kernels.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_ps_against_ptc.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_ps_multiturn_twiss.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_pyht_interface.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_radial_steering.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_radiation.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_radiation_equilibrium_emittances.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_random_gen.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_random_gen_exp.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_random_gen_gauss.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_random_gen_ruth.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_second_order_taylor_map.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_slicing.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_spacecharge_in_ring.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_sps_thick.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_survey.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_tapering.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_thick_lhc.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_tracker.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_twiss_vs_madx_psb.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_var_cache.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/tests/test_vs_madx.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/_temp/__init__.py +0 -0
- {xtrack-0.54.1/xtrack/prebuilt_kernels → xtrack-0.55.0/xtrack/_temp/boris_and_solenoid_map}/__init__.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/_temp/lhc_match/__init__.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/_temp/lhc_match/gen_madx_optics_file.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/_temp/lhc_match/lhc_match.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/_temp/lhc_match/var_limits.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/apertures.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/apertures_src/limitellipse.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/apertures_src/limitpolygon.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/apertures_src/limitracetrack.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/apertures_src/limitrect.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/apertures_src/limitrectellipse.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/apertures_src/longitudinallimitrect.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/beam_interaction.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/bend.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/dipoleedge.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/drift.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/drift_elem.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/elens.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/exciter.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/firstordertaylormap.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/fringe.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/fringe_track.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/linesegmentmap.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/multipole.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/nonlinearlens.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/octupole.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/referenceenergyincrease.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/rfmultipole.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/second_order_taylor_map.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/sextupole.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/simplethinbend.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/simplethinquadrupole.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/srotation.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/track_srotation.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/track_thick_bend.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/track_thick_cfd.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/track_yrotation.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/wedge.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/wedge_track.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/wire.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/xrotation.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/xyshift.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/yrotation.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/elements_src/zetashift.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/beam_elements/exciter.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/compounds.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/footprint.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/general.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/headers/atomicadd.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/headers/checks.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/headers/constants.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/headers/particle_states.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/headers/synrad_spectrum.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/internal_record.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/linear_normal_form.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/loss_location_refinement/__init__.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/loss_location_refinement/loss_location_refinement.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/lumi.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/mad_writer.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/monitors/__init__.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/monitors/beam_position_monitor.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/monitors/beam_position_monitor.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/monitors/beam_profile_monitor.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/monitors/beam_profile_monitor.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/monitors/beam_size_monitor.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/monitors/beam_size_monitor.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/monitors/last_turns_monitor.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/monitors/last_turns_monitor.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/monitors/particles_monitor.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/monitors/particles_monitor.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/multiline/__init__.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/multiline/shared_knobs.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/multisetter/__init__.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/multisetter/multisetter.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/particles/__init__.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/particles/constants.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/particles/rng_src/base_rng.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/particles/rng_src/particles_rng.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/pipeline/__init__.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/pipeline/core.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/pipeline/manager.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/pipeline/multitracker.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/prebuild_kernels.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/progress_indicator.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/random/__init__.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/random/random_generators.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/random/random_src/exponential.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/random/random_src/exponential_integral_Ei.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/random/random_src/normal.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/random/random_src/rutherford.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/random/random_src/uniform.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/slicing.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/survey.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/tapering.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/targets.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/tracker_data.py +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack/tracker_src/tracker.h +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack.egg-info/dependency_links.txt +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack.egg-info/requires.txt +0 -0
- {xtrack-0.54.1 → xtrack-0.55.0}/xtrack.egg-info/top_level.txt +0 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
import numpy as np
|
2
|
+
import xtrack as xt
|
3
|
+
from xobjects.test_helpers import for_all_test_contexts
|
4
|
+
|
5
|
+
import pathlib
|
6
|
+
|
7
|
+
test_data_folder = pathlib.Path(
|
8
|
+
__file__).parent.joinpath('../test_data').absolute()
|
9
|
+
|
10
|
+
@for_all_test_contexts
|
11
|
+
def test_cavity_absolute_time(test_context):
|
12
|
+
line = xt.Line.from_json(test_data_folder /
|
13
|
+
'hllhc15_thick/lhc_thick_with_knobs.json')
|
14
|
+
line.build_tracker(_context=test_context)
|
15
|
+
line.vv['vrf400'] = 16
|
16
|
+
|
17
|
+
for vv in line.vars.get_table().rows[
|
18
|
+
'on_x.*|on_sep.*|on_crab.*|on_alice|on_lhcb|corr_.*'].name:
|
19
|
+
line.vars[vv] = 0
|
20
|
+
|
21
|
+
tw = line.twiss()
|
22
|
+
|
23
|
+
df_hz = -50
|
24
|
+
h_rf = 35640
|
25
|
+
f_rev = 1/tw.T_rev0
|
26
|
+
df_rev = df_hz / h_rf
|
27
|
+
eta = tw.slip_factor
|
28
|
+
|
29
|
+
f_rf0 = 1/tw.T_rev0 * h_rf
|
30
|
+
|
31
|
+
f_rf = f_rf0 + df_hz
|
32
|
+
line.vars['f_rf'] = f_rf
|
33
|
+
tt = line.get_table()
|
34
|
+
for nn in tt.rows[tt.element_type=='Cavity'].name:
|
35
|
+
line.element_refs[nn].absolute_time = 1 # Need property
|
36
|
+
line.element_refs[nn].frequency = line.vars['f_rf']
|
37
|
+
|
38
|
+
tw1 = line.twiss(search_for_t_rev=True)
|
39
|
+
|
40
|
+
f_rev_expected = f_rf / h_rf
|
41
|
+
|
42
|
+
assert np.isclose(f_rev_expected, 1/tw1.T_rev, atol=1e-5, rtol=0)
|
43
|
+
assert np.allclose(tw1.delta, tw1.delta[0], atol=1e-5, rtol=0) # Check that it is flat
|
44
|
+
delta_expected = -df_rev / f_rev / eta
|
45
|
+
assert np.allclose(tw1.delta, delta_expected, atol=2e-6, rtol=0)
|
46
|
+
tw_off_mom = line.twiss(method='4d', delta0=tw1.delta[0])
|
47
|
+
assert np.allclose(tw1.x, tw_off_mom.x, atol=1e-5, rtol=0)
|
@@ -0,0 +1,155 @@
|
|
1
|
+
import numpy as np
|
2
|
+
import xtrack as xt
|
3
|
+
import pathlib
|
4
|
+
|
5
|
+
from scipy.constants import c as clight
|
6
|
+
|
7
|
+
test_data_folder = pathlib.Path(
|
8
|
+
__file__).parent.joinpath('../test_data').absolute()
|
9
|
+
|
10
|
+
|
11
|
+
def test_coasting():
|
12
|
+
delta0 = 1e-2
|
13
|
+
|
14
|
+
line = xt.Line.from_json(test_data_folder /
|
15
|
+
'psb_injection/line_and_particle.json')
|
16
|
+
|
17
|
+
# RF off!
|
18
|
+
tt = line.get_table()
|
19
|
+
ttcav = tt.rows[tt.element_type == 'Cavity']
|
20
|
+
for nn in ttcav.name:
|
21
|
+
line.element_refs[nn].voltage=0
|
22
|
+
|
23
|
+
line.configure_bend_model(core='bend-kick-bend', edge='full')
|
24
|
+
line.twiss_default['method'] = '4d'
|
25
|
+
|
26
|
+
tw = line.twiss()
|
27
|
+
twom = line.twiss(delta0=delta0)
|
28
|
+
line.discard_tracker()
|
29
|
+
|
30
|
+
# Install dummy collective elements
|
31
|
+
s_sync = np.linspace(0, tw.circumference, 10)
|
32
|
+
line.cut_at_s(s_sync)
|
33
|
+
for ii, ss in enumerate(s_sync):
|
34
|
+
nn = f'sync_here_{ii}'
|
35
|
+
line.insert_element(element=xt.Marker(), name=nn, at_s=ss)
|
36
|
+
line[nn].iscollective = True
|
37
|
+
|
38
|
+
import xtrack.synctime as st
|
39
|
+
st.install_sync_time_at_collective_elements(line)
|
40
|
+
|
41
|
+
import xobjects as xo
|
42
|
+
line.build_tracker(_context=xo.ContextCpu(omp_num_threads='auto'))
|
43
|
+
|
44
|
+
beta1 = tw.beta0 / 0.9
|
45
|
+
|
46
|
+
circumference = tw.circumference
|
47
|
+
zeta_min0 = -circumference/2*tw.beta0/beta1
|
48
|
+
zeta_max0 = circumference/2*tw.beta0/beta1
|
49
|
+
|
50
|
+
num_particles = 50000
|
51
|
+
p = line.build_particles(
|
52
|
+
delta=delta0 + 0 * np.random.uniform(-1, 1, num_particles),
|
53
|
+
x_norm=0, y_norm=0
|
54
|
+
)
|
55
|
+
|
56
|
+
# Need to take beta of actual particles to convert the distribution along the
|
57
|
+
# circumference to a distribution in time
|
58
|
+
p.zeta = (np.random.uniform(0, circumference, num_particles) / p.rvv
|
59
|
+
+ (zeta_max0 - circumference) / p.rvv)
|
60
|
+
|
61
|
+
st.prepare_particles_for_sync_time(p, line)
|
62
|
+
|
63
|
+
p.y[(p.zeta > 1) & (p.zeta < 2)] = 1e-3 # kick
|
64
|
+
p.weight[(p.zeta > 5) & (p.zeta < 10)] *= 1.3
|
65
|
+
|
66
|
+
p0 = p.copy()
|
67
|
+
|
68
|
+
def particles(_, p):
|
69
|
+
return p.copy()
|
70
|
+
|
71
|
+
def intensity(line, particles):
|
72
|
+
return (np.sum(particles.weight[particles.state > 0])
|
73
|
+
/ ((zeta_max0 - zeta_min0)/tw.beta0/clight))
|
74
|
+
|
75
|
+
def z_range(line, particles):
|
76
|
+
mask_alive = particles.state > 0
|
77
|
+
return particles.zeta[mask_alive].min(), particles.zeta[mask_alive].max()
|
78
|
+
|
79
|
+
def long_density(line, particles):
|
80
|
+
mask_alive = particles.state > 0
|
81
|
+
if not(np.any(particles.at_turn[mask_alive] == 0)): # don't check at the first turn
|
82
|
+
assert np.all(particles.zeta[mask_alive] > zeta_min0)
|
83
|
+
assert np.all(particles.zeta[mask_alive] < zeta_max0)
|
84
|
+
return np.histogram(particles.zeta[mask_alive], bins=200,
|
85
|
+
range=(zeta_min0, zeta_max0),
|
86
|
+
weights=particles.weight[mask_alive])
|
87
|
+
|
88
|
+
def y_mean_hist(line, particles):
|
89
|
+
|
90
|
+
mask_alive = particles.state > 0
|
91
|
+
if not(np.any(particles.at_turn[mask_alive] == 0)): # don't check at the first turn
|
92
|
+
assert np.all(particles.zeta[mask_alive] > zeta_min0)
|
93
|
+
assert np.all(particles.zeta[mask_alive] < zeta_max0)
|
94
|
+
return np.histogram(particles.zeta[mask_alive], bins=200,
|
95
|
+
range=(zeta_min0, zeta_max0), weights=particles.y[mask_alive])
|
96
|
+
|
97
|
+
|
98
|
+
line.enable_time_dependent_vars = True
|
99
|
+
num_turns=200
|
100
|
+
line.track(p, num_turns=num_turns, log=xt.Log(intensity=intensity,
|
101
|
+
long_density=long_density,
|
102
|
+
y_mean_hist=y_mean_hist,
|
103
|
+
z_range=z_range,
|
104
|
+
particles=particles
|
105
|
+
), with_progress=10)
|
106
|
+
|
107
|
+
inten = line.log_last_track['intensity']
|
108
|
+
|
109
|
+
f_rev_ave = 1 / tw.T_rev0 * (1 - tw.slip_factor * p.delta.mean())
|
110
|
+
t_rev_ave = 1 / f_rev_ave
|
111
|
+
|
112
|
+
inten_exp = np.sum(p0.weight) / t_rev_ave
|
113
|
+
|
114
|
+
z_axis = line.log_last_track['long_density'][0][1]
|
115
|
+
hist_mat = np.array([rr[0] for rr in line.log_last_track['long_density']])
|
116
|
+
hist_y = np.array([rr[0] for rr in line.log_last_track['y_mean_hist']])
|
117
|
+
|
118
|
+
dz = z_axis[1] - z_axis[0]
|
119
|
+
y_vs_t = np.fliplr(hist_y).flatten() # need to flip because of the minus in z = -beta0 c t
|
120
|
+
intensity_vs_t = np.fliplr(hist_mat).flatten()
|
121
|
+
z_unwrapped = np.arange(0, len(y_vs_t)) * dz
|
122
|
+
t_unwrapped = z_unwrapped / (tw.beta0 * clight)
|
123
|
+
|
124
|
+
z_range_size = z_axis[-1] - z_axis[0]
|
125
|
+
t_range_size = z_range_size / (tw.beta0 * clight)
|
126
|
+
|
127
|
+
import nafflib
|
128
|
+
f_harmons = nafflib.get_tunes(intensity_vs_t, N=50)[0] / (t_unwrapped[1] - t_unwrapped[0])
|
129
|
+
f_nominal = 1 / tw.T_rev0
|
130
|
+
dt_expected = -(twom.zeta[-1] - twom.zeta[0]) / tw.beta0 / clight
|
131
|
+
f_expected = 1 / (tw.T_rev0 + dt_expected)
|
132
|
+
|
133
|
+
f_measured = f_harmons[np.argmin(np.abs(f_harmons - f_nominal))]
|
134
|
+
|
135
|
+
print('f_nominal: ', f_nominal, ' Hz')
|
136
|
+
print('f_expected: ', f_expected, ' Hz')
|
137
|
+
print('f_measured: ', f_measured, ' Hz')
|
138
|
+
print('Error: ', f_measured - f_expected, 'Hz')
|
139
|
+
|
140
|
+
assert np.isclose(f_expected, f_measured, rtol=0, atol=2) # 2 Hz tolerance (to account for random fluctuations)
|
141
|
+
assert np.isclose(np.mean(inten), inten_exp, rtol=1e-2, atol=0)
|
142
|
+
assert np.allclose(p.at_turn, num_turns*0.9, rtol=3e-2, atol=0) #beta1 defaults to 0.1
|
143
|
+
|
144
|
+
tt = line.get_table()
|
145
|
+
tt_synch = tt.rows[tt.element_type=='SyncTime']
|
146
|
+
assert len(tt_synch) == 12
|
147
|
+
assert tt_synch.name[0] == 'synctime_start'
|
148
|
+
assert tt_synch.name[-1] == 'synctime_end'
|
149
|
+
assert np.all(tt_synch.name[5] == 'synctime_4')
|
150
|
+
assert line['synctime_start'].at_start
|
151
|
+
assert not line['synctime_end'].at_start
|
152
|
+
assert not line['synctime_4'].at_start
|
153
|
+
assert line['synctime_end'].at_end
|
154
|
+
assert not line['synctime_start'].at_end
|
155
|
+
assert not line['synctime_4'].at_end
|
@@ -1036,7 +1036,9 @@ def test_solenoid_against_madx(test_context, ks, ksi, length):
|
|
1036
1036
|
@for_all_test_contexts
|
1037
1037
|
def test_solenoid_thick_drift_like(test_context):
|
1038
1038
|
solenoid = xt.Solenoid(ks=1.001e-9, length=1, _context=test_context)
|
1039
|
-
|
1039
|
+
l_drift = xt.Line(elements=[xt.Drift(length=1)])
|
1040
|
+
l_drift.config.XTRACK_USE_EXACT_DRIFTS = True
|
1041
|
+
l_drift.build_tracker(_context=test_context)
|
1040
1042
|
|
1041
1043
|
p0 = xp.Particles(
|
1042
1044
|
x=0.1, px=0.2, y=0.3, py=0.4, zeta=0.5, delta=0.6,
|
@@ -1047,7 +1049,7 @@ def test_solenoid_thick_drift_like(test_context):
|
|
1047
1049
|
solenoid.track(p_sol)
|
1048
1050
|
|
1049
1051
|
p_drift = p0.copy()
|
1050
|
-
|
1052
|
+
l_drift.track(p_drift)
|
1051
1053
|
|
1052
1054
|
p_sol.move(_context=xo.context_default)
|
1053
1055
|
p_drift.move(_context=xo.context_default)
|
@@ -0,0 +1,404 @@
|
|
1
|
+
import numpy as np
|
2
|
+
import xtrack as xt
|
3
|
+
from scipy.constants import c as clight
|
4
|
+
from scipy.constants import e as qe
|
5
|
+
import pathlib
|
6
|
+
|
7
|
+
from cpymad.madx import Madx
|
8
|
+
|
9
|
+
|
10
|
+
test_data_folder = pathlib.Path(
|
11
|
+
__file__).parent.joinpath('../test_data').absolute()
|
12
|
+
|
13
|
+
|
14
|
+
def test_fcc_ee_solenoid_correction():
|
15
|
+
fname = 'fccee_t'; pc_gev = 182.5
|
16
|
+
|
17
|
+
mad = Madx()
|
18
|
+
mad.call(str(test_data_folder) + '/fcc_ee/' + fname + '.seq')
|
19
|
+
mad.beam(particle='positron', pc=pc_gev)
|
20
|
+
mad.use('fccee_p_ring')
|
21
|
+
|
22
|
+
line = xt.Line.from_madx_sequence(mad.sequence.fccee_p_ring, allow_thick=True,
|
23
|
+
deferred_expressions=True)
|
24
|
+
line.particle_ref = xt.Particles(mass0=xt.ELECTRON_MASS_EV,
|
25
|
+
gamma0=mad.sequence.fccee_p_ring.beam.gamma)
|
26
|
+
line.cycle('ip.4', inplace=True)
|
27
|
+
line.append_element(element=xt.Marker(), name='ip.4.l')
|
28
|
+
|
29
|
+
tt = line.get_table()
|
30
|
+
bz_data_file = test_data_folder / 'fcc_ee/Bz_closed_before_quads.dat'
|
31
|
+
|
32
|
+
line.vars['voltca1_ref'] = line.vv['voltca1']
|
33
|
+
if 'voltca2' in line.vars.keys():
|
34
|
+
line.vars['voltca2_ref'] = line.vv['voltca2']
|
35
|
+
else:
|
36
|
+
line.vars['voltca2_ref'] = 0
|
37
|
+
|
38
|
+
line.vars['voltca1'] = 0
|
39
|
+
line.vars['voltca2'] = 0
|
40
|
+
|
41
|
+
import pandas as pd
|
42
|
+
bz_df = pd.read_csv(bz_data_file, sep=r'\s+', skiprows=1, names=['z', 'Bz'])
|
43
|
+
|
44
|
+
l_solenoid = 4.4
|
45
|
+
ds_sol_start = -l_solenoid / 2 * np.cos(15e-3)
|
46
|
+
ds_sol_end = +l_solenoid / 2 * np.cos(15e-3)
|
47
|
+
ip_sol = 'ip.1'
|
48
|
+
|
49
|
+
theta_tilt = 15e-3 # rad
|
50
|
+
|
51
|
+
s_sol_slices = np.linspace(ds_sol_start, ds_sol_end, 1001)
|
52
|
+
bz_sol_slices = np.interp(s_sol_slices, bz_df.z, bz_df.Bz)
|
53
|
+
bz_sol_slices[0] = 0
|
54
|
+
bz_sol_slices[-1] = 0
|
55
|
+
|
56
|
+
P0_J = line.particle_ref.p0c[0] * qe / clight
|
57
|
+
brho = P0_J / qe / line.particle_ref.q0
|
58
|
+
ks = 0.5 * (bz_sol_slices[:-1] + bz_sol_slices[1:]) / brho
|
59
|
+
l_sol_slices = np.diff(s_sol_slices)
|
60
|
+
s_sol_slices_entry = s_sol_slices[:-1]
|
61
|
+
|
62
|
+
sol_slices = []
|
63
|
+
for ii in range(len(s_sol_slices_entry)):
|
64
|
+
sol_slices.append(xt.Solenoid(length=l_sol_slices[ii], ks=0)) # Off for now
|
65
|
+
|
66
|
+
s_ip = tt['s', ip_sol]
|
67
|
+
|
68
|
+
line.discard_tracker()
|
69
|
+
line.insert_element(name='sol_start_'+ip_sol, element=xt.Marker(),
|
70
|
+
at_s=s_ip + ds_sol_start)
|
71
|
+
line.insert_element(name='sol_end_'+ip_sol, element=xt.Marker(),
|
72
|
+
at_s=s_ip + ds_sol_end)
|
73
|
+
|
74
|
+
sol_start_tilt = xt.YRotation(angle=-theta_tilt * 180 / np.pi)
|
75
|
+
sol_end_tilt = xt.YRotation(angle=+theta_tilt * 180 / np.pi)
|
76
|
+
sol_start_shift = xt.XYShift(dx=l_solenoid/2 * np.sin(theta_tilt))
|
77
|
+
sol_end_shift = xt.XYShift(dx=l_solenoid/2 * np.sin(theta_tilt))
|
78
|
+
|
79
|
+
line.element_dict['sol_start_tilt_'+ip_sol] = sol_start_tilt
|
80
|
+
line.element_dict['sol_end_tilt_'+ip_sol] = sol_end_tilt
|
81
|
+
line.element_dict['sol_start_shift_'+ip_sol] = sol_start_shift
|
82
|
+
line.element_dict['sol_end_shift_'+ip_sol] = sol_end_shift
|
83
|
+
|
84
|
+
line.element_dict['sol_entry_'+ip_sol] = xt.Solenoid(length=0, ks=0)
|
85
|
+
line.element_dict['sol_exit_'+ip_sol] = xt.Solenoid(length=0, ks=0)
|
86
|
+
|
87
|
+
|
88
|
+
sol_slice_names = []
|
89
|
+
sol_slice_names.append('sol_entry_'+ip_sol)
|
90
|
+
for ii in range(len(s_sol_slices_entry)):
|
91
|
+
nn = f'sol_slice_{ii}_{ip_sol}'
|
92
|
+
line.element_dict[nn] = sol_slices[ii]
|
93
|
+
sol_slice_names.append(nn)
|
94
|
+
sol_slice_names.append('sol_exit_'+ip_sol)
|
95
|
+
|
96
|
+
tt = line.get_table()
|
97
|
+
names_upstream = list(tt.rows[:'sol_start_'+ip_sol].name)
|
98
|
+
names_downstream = list(tt.rows['sol_end_'+ip_sol:].name[:-1]) # -1 to exclude '_end_point' added by the table
|
99
|
+
|
100
|
+
element_names = (names_upstream
|
101
|
+
+ ['sol_start_tilt_'+ip_sol, 'sol_start_shift_'+ip_sol]
|
102
|
+
+ sol_slice_names
|
103
|
+
+ ['sol_end_shift_'+ip_sol, 'sol_end_tilt_'+ip_sol]
|
104
|
+
+ names_downstream)
|
105
|
+
|
106
|
+
line.element_names = element_names
|
107
|
+
|
108
|
+
# re-insert the ip
|
109
|
+
line.element_dict.pop(ip_sol)
|
110
|
+
tt = line.get_table()
|
111
|
+
line.insert_element(name=ip_sol, element=xt.Marker(),
|
112
|
+
at_s = 0.5 * (tt['s', 'sol_start_'+ip_sol] + tt['s', 'sol_end_'+ip_sol]))
|
113
|
+
|
114
|
+
line.vars['on_corr_ip.1'] = 0
|
115
|
+
|
116
|
+
line.build_tracker()
|
117
|
+
|
118
|
+
# Set strength
|
119
|
+
line.vars['on_sol_'+ip_sol] = 0
|
120
|
+
for ii in range(len(s_sol_slices_entry)):
|
121
|
+
nn = f'sol_slice_{ii}_{ip_sol}'
|
122
|
+
line.element_refs[nn].ks = ks[ii] * line.vars['on_sol_'+ip_sol]
|
123
|
+
|
124
|
+
tt = line.get_table()
|
125
|
+
|
126
|
+
tt.rows['sol_start_ip.1':'sol_end_ip.1'].show()
|
127
|
+
|
128
|
+
line.vars['on_corr_ip.1'] = 1
|
129
|
+
line.vars['ks0.r1'] = 0
|
130
|
+
line.vars['ks1.r1'] = 0
|
131
|
+
line.vars['ks2.r1'] = 0
|
132
|
+
line.vars['ks3.r1'] = 0
|
133
|
+
line.vars['ks4.r1'] = 0
|
134
|
+
line.vars['ks0.l1'] = 0
|
135
|
+
line.vars['ks1.l1'] = 0
|
136
|
+
line.vars['ks2.l1'] = 0
|
137
|
+
line.vars['ks3.l1'] = 0
|
138
|
+
line.vars['ks4.l1'] = 0
|
139
|
+
|
140
|
+
line.element_refs['qc1r1.1'].k1s = line.vars['on_corr_ip.1'] * line.vars['ks0.r1']
|
141
|
+
line.element_refs['qc2r1.1'].k1s = line.vars['on_corr_ip.1'] * line.vars['ks1.r1']
|
142
|
+
line.element_refs['qc2r2.1'].k1s = line.vars['on_corr_ip.1'] * line.vars['ks2.r1']
|
143
|
+
line.element_refs['qc1r2.1'].k1s = line.vars['on_corr_ip.1'] * line.vars['ks3.r1']
|
144
|
+
line.element_refs['qc1l1.4'].k1s = line.vars['on_corr_ip.1'] * line.vars['ks0.l1']
|
145
|
+
line.element_refs['qc2l1.4'].k1s = line.vars['on_corr_ip.1'] * line.vars['ks1.l1']
|
146
|
+
line.element_refs['qc2l2.4'].k1s = line.vars['on_corr_ip.1'] * line.vars['ks2.l1']
|
147
|
+
line.element_refs['qc1l2.4'].k1s = line.vars['on_corr_ip.1'] * line.vars['ks3.l1']
|
148
|
+
|
149
|
+
line.vars['corr_k0.r1'] = 0
|
150
|
+
line.vars['corr_k1.r1'] = 0
|
151
|
+
line.vars['corr_k2.r1'] = 0
|
152
|
+
line.vars['corr_k3.r1'] = 0
|
153
|
+
line.vars['corr_k4.r1'] = 0
|
154
|
+
line.vars['corr_k0.l1'] = 0
|
155
|
+
line.vars['corr_k1.l1'] = 0
|
156
|
+
line.vars['corr_k2.l1'] = 0
|
157
|
+
line.vars['corr_k3.l1'] = 0
|
158
|
+
line.vars['corr_k4.l1'] = 0
|
159
|
+
|
160
|
+
line.element_refs['qc1r1.1'].k1 += line.vars['on_corr_ip.1'] * line.vars['corr_k0.r1']
|
161
|
+
line.element_refs['qc2r1.1'].k1 += line.vars['on_corr_ip.1'] * line.vars['corr_k1.r1']
|
162
|
+
line.element_refs['qc2r2.1'].k1 += line.vars['on_corr_ip.1'] * line.vars['corr_k2.r1']
|
163
|
+
line.element_refs['qc1r2.1'].k1 += line.vars['on_corr_ip.1'] * line.vars['corr_k3.r1']
|
164
|
+
line.element_refs['qc1l1.4'].k1 += line.vars['on_corr_ip.1'] * line.vars['corr_k0.l1']
|
165
|
+
line.element_refs['qc2l1.4'].k1 += line.vars['on_corr_ip.1'] * line.vars['corr_k1.l1']
|
166
|
+
line.element_refs['qc2l2.4'].k1 += line.vars['on_corr_ip.1'] * line.vars['corr_k2.l1']
|
167
|
+
line.element_refs['qc1l2.4'].k1 += line.vars['on_corr_ip.1'] * line.vars['corr_k3.l1']
|
168
|
+
|
169
|
+
|
170
|
+
Strategy = xt.Strategy
|
171
|
+
Teapot = xt.Teapot
|
172
|
+
slicing_strategies = [
|
173
|
+
Strategy(slicing=None), # Default catch-all as in MAD-X
|
174
|
+
Strategy(slicing=Teapot(3), element_type=xt.Bend),
|
175
|
+
Strategy(slicing=Teapot(3), element_type=xt.CombinedFunctionMagnet),
|
176
|
+
# Strategy(slicing=Teapot(50), element_type=xt.Quadrupole), # Starting point
|
177
|
+
Strategy(slicing=Teapot(5), name=r'^qf.*'),
|
178
|
+
Strategy(slicing=Teapot(5), name=r'^qd.*'),
|
179
|
+
Strategy(slicing=Teapot(5), name=r'^qfg.*'),
|
180
|
+
Strategy(slicing=Teapot(5), name=r'^qdg.*'),
|
181
|
+
Strategy(slicing=Teapot(5), name=r'^ql.*'),
|
182
|
+
Strategy(slicing=Teapot(5), name=r'^qs.*'),
|
183
|
+
Strategy(slicing=Teapot(10), name=r'^qb.*'),
|
184
|
+
Strategy(slicing=Teapot(10), name=r'^qg.*'),
|
185
|
+
Strategy(slicing=Teapot(10), name=r'^qh.*'),
|
186
|
+
Strategy(slicing=Teapot(10), name=r'^qi.*'),
|
187
|
+
Strategy(slicing=Teapot(10), name=r'^qr.*'),
|
188
|
+
Strategy(slicing=Teapot(10), name=r'^qu.*'),
|
189
|
+
Strategy(slicing=Teapot(10), name=r'^qy.*'),
|
190
|
+
Strategy(slicing=Teapot(50), name=r'^qa.*'),
|
191
|
+
Strategy(slicing=Teapot(50), name=r'^qc.*'),
|
192
|
+
Strategy(slicing=Teapot(20), name=r'^sy\..*'),
|
193
|
+
Strategy(slicing=Teapot(30), name=r'^mwi\..*'),
|
194
|
+
]
|
195
|
+
line.discard_tracker()
|
196
|
+
line.slice_thick_elements(slicing_strategies=slicing_strategies)
|
197
|
+
|
198
|
+
# Add dipole correctors
|
199
|
+
line.insert_element(name='mcb1.r1', element=xt.Multipole(knl=[0]),
|
200
|
+
at='qc1r1.1_exit')
|
201
|
+
line.insert_element(name='mcb2.r1', element=xt.Multipole(knl=[0]),
|
202
|
+
at='qc1r2.1_exit')
|
203
|
+
line.insert_element(name='mcb1.l1', element=xt.Multipole(knl=[0]),
|
204
|
+
at='qc1l1.4_entry')
|
205
|
+
line.insert_element(name='mcb2.l1', element=xt.Multipole(knl=[0]),
|
206
|
+
at='qc1l2.4_entry')
|
207
|
+
|
208
|
+
line.vars['acb1h.r1'] = 0
|
209
|
+
line.vars['acb1v.r1'] = 0
|
210
|
+
line.vars['acb2h.r1'] = 0
|
211
|
+
line.vars['acb2v.r1'] = 0
|
212
|
+
line.vars['acb1h.l1'] = 0
|
213
|
+
line.vars['acb1v.l1'] = 0
|
214
|
+
line.vars['acb2h.l1'] = 0
|
215
|
+
line.vars['acb2v.l1'] = 0
|
216
|
+
|
217
|
+
line.element_refs['mcb1.r1'].knl[0] = line.vars['on_corr_ip.1']*line.vars['acb1h.r1']
|
218
|
+
line.element_refs['mcb2.r1'].knl[0] = line.vars['on_corr_ip.1']*line.vars['acb2h.r1']
|
219
|
+
line.element_refs['mcb1.r1'].ksl[0] = line.vars['on_corr_ip.1']*line.vars['acb1v.r1']
|
220
|
+
line.element_refs['mcb2.r1'].ksl[0] = line.vars['on_corr_ip.1']*line.vars['acb2v.r1']
|
221
|
+
line.element_refs['mcb1.l1'].knl[0] = line.vars['on_corr_ip.1']*line.vars['acb1h.l1']
|
222
|
+
line.element_refs['mcb2.l1'].knl[0] = line.vars['on_corr_ip.1']*line.vars['acb2h.l1']
|
223
|
+
line.element_refs['mcb1.l1'].ksl[0] = line.vars['on_corr_ip.1']*line.vars['acb1v.l1']
|
224
|
+
line.element_refs['mcb2.l1'].ksl[0] = line.vars['on_corr_ip.1']*line.vars['acb2v.l1']
|
225
|
+
|
226
|
+
tw_thick_no_rad = line.twiss(method='4d')
|
227
|
+
|
228
|
+
assert line.element_names[-1] == 'ip.4.l'
|
229
|
+
assert line.element_names[0] == 'ip.4'
|
230
|
+
|
231
|
+
opt = line.match(
|
232
|
+
only_markers=True,
|
233
|
+
method='4d',
|
234
|
+
start='ip.4', end='ip.4.l',
|
235
|
+
init=tw_thick_no_rad,
|
236
|
+
vary=xt.VaryList(['k1qf4', 'k1qf2', 'k1qd3', 'k1qd1',], step=1e-8,
|
237
|
+
),
|
238
|
+
targets=[
|
239
|
+
xt.TargetSet(at=xt.END, mux=tw_thick_no_rad.qx, muy=tw_thick_no_rad.qy, tol=1e-5),
|
240
|
+
]
|
241
|
+
)
|
242
|
+
opt.solve()
|
243
|
+
|
244
|
+
line.vars['on_sol_ip.1'] = 0
|
245
|
+
tw_sol_off = line.twiss(method='4d')
|
246
|
+
line.vars['on_sol_ip.1'] = 1
|
247
|
+
tw_sol_on = line.twiss(method='4d')
|
248
|
+
|
249
|
+
opt_l = line.match(
|
250
|
+
solve=False,
|
251
|
+
method='4d', n_steps_max=30,
|
252
|
+
start='pqc2le.4', end='ip.1', init=tw_sol_off, init_at=xt.START,
|
253
|
+
vary=[
|
254
|
+
xt.VaryList(['acb1h.l1', 'acb2h.l1','acb1v.l1', 'acb2v.l1'], step=1e-8, tag='corr_l'),
|
255
|
+
xt.VaryList(['ks1.l1', 'ks2.l1', 'ks3.l1', 'ks0.l1'], step=1e-7, tag='skew_l'),
|
256
|
+
xt.VaryList(['corr_k1.l1', 'corr_k2.l1', 'corr_k3.l1', 'corr_k0.l1'], step=1e-6, tag='normal_l'),
|
257
|
+
],
|
258
|
+
targets=[
|
259
|
+
xt.TargetSet(['x', 'y'], value=tw_sol_off, tol=1e-7, at='ip.1', tag='orbit'),
|
260
|
+
xt.TargetSet(['px', 'py'], value=tw_sol_off, tol=1e-10, at='ip.1', tag='orbit'),
|
261
|
+
xt.TargetRmatrix(
|
262
|
+
r13=0, r14=0, r23=0, r24=0, # Y-X block
|
263
|
+
r31=0, r32=0, r41=0, r42=0, # X-Y block,
|
264
|
+
start='pqc2le.4', end='ip.1', tol=1e-6, tag='coupl'),
|
265
|
+
xt.Target('mux', value=tw_sol_off, at='ip.1', tag='mu_ip', weight=0.1, tol=1e-6),
|
266
|
+
xt.Target('muy', value=tw_sol_off, at='ip.1', tag='mu_ip', weight=0.1, tol=1e-6),
|
267
|
+
xt.Target('betx', value=tw_sol_off, at='ip.1', tag='bet_ip', weight=1, tol=1e-5),
|
268
|
+
xt.Target('bety', value=tw_sol_off, at='ip.1', tag='bet_ip', weight=10, tol=1e-6),
|
269
|
+
xt.Target('alfx', value=tw_sol_off, at='ip.1', tag='alf_ip', weight=0.1, tol=1e-4),
|
270
|
+
xt.Target('alfy', value=tw_sol_off, at='ip.1', tag='alf_ip', weight=0.1, tol=1e-4),
|
271
|
+
|
272
|
+
]
|
273
|
+
)
|
274
|
+
|
275
|
+
|
276
|
+
for iter in range(2):
|
277
|
+
# Orbit alone
|
278
|
+
opt_l.disable_all_targets(); opt_l.disable_all_vary()
|
279
|
+
opt_l.enable_targets(tag='orbit'); opt_l.enable_vary(tag='corr_l'); opt_l.solve()
|
280
|
+
|
281
|
+
# Coupling alone
|
282
|
+
opt_l.disable_all_targets(); opt_l.disable_all_vary()
|
283
|
+
opt_l.enable_targets(tag='coupl'); opt_l.enable_vary(tag='skew_l'); opt_l.solve()
|
284
|
+
|
285
|
+
# phase, beta and alpha alone
|
286
|
+
opt_l.disable_all_targets(); opt_l.disable_all_vary()
|
287
|
+
opt_l.enable_vary(tag='normal_l')
|
288
|
+
opt_l.enable_targets(tag='mu_ip'); opt_l.solve()
|
289
|
+
opt_l.enable_targets(tag='bet_ip'); opt_l.solve()
|
290
|
+
opt_l.enable_targets(tag='alf_ip'); opt_l.solve()
|
291
|
+
|
292
|
+
# All together
|
293
|
+
opt_l.enable_all_targets()
|
294
|
+
opt_l.enable_all_vary()
|
295
|
+
opt_l.solve()
|
296
|
+
|
297
|
+
|
298
|
+
opt_r = line.match(
|
299
|
+
solve=False,
|
300
|
+
method='4d', n_steps_max=30,
|
301
|
+
start='ip.1', end='pqc2re.1', init=tw_sol_off, init_at=xt.END,
|
302
|
+
vary=[
|
303
|
+
xt.VaryList(['acb1h.r1', 'acb2h.r1','acb1v.r1', 'acb2v.r1'], step=1e-8, tag='corr_r'),
|
304
|
+
xt.VaryList(['ks1.r1', 'ks2.r1', 'ks3.r1', 'ks0.r1'], step=1e-7, tag='skew_r'),
|
305
|
+
xt.VaryList(['corr_k1.r1', 'corr_k2.r1', 'corr_k3.r1', 'corr_k0.r1'], step=1e-6, tag='normal_r'),
|
306
|
+
],
|
307
|
+
targets=[
|
308
|
+
xt.TargetSet(['x', 'y'], value=tw_sol_off, tol=1e-7, at='ip.1', tag='orbit'),
|
309
|
+
xt.TargetSet(['px', 'py'], value=tw_sol_off, tol=1e-10, at='ip.1', tag='orbit'),
|
310
|
+
xt.TargetRmatrix(r13=0, r14=0, r23=0, r24=0, # Y-X block
|
311
|
+
r31=0, r32=0, r41=0, r42=0, # X-Y block,
|
312
|
+
start='ip.1', end='pqc2re.1', tol=1e-6, tag='coupl'),
|
313
|
+
xt.Target('mux', value=tw_sol_off, at='ip.1', tag='mu_ip', weight=0.1, tol=1e-6),
|
314
|
+
xt.Target('muy', value=tw_sol_off, at='ip.1', tag='mu_ip', weight=0.1, tol=1e-6),
|
315
|
+
xt.Target('betx', value=tw_sol_off, at='ip.1', tag='bet_ip', weight=1, tol=1e-5),
|
316
|
+
xt.Target('bety', value=tw_sol_off, at='ip.1', tag='bet_ip', weight=10, tol=1e-6),
|
317
|
+
xt.Target('alfx', value=tw_sol_off, at='ip.1', tag='alf_ip', weight=0.1, tol=1e-4),
|
318
|
+
xt.Target('alfy', value=tw_sol_off, at='ip.1', tag='alf_ip', weight=0.1, tol=1e-4),
|
319
|
+
|
320
|
+
]
|
321
|
+
)
|
322
|
+
|
323
|
+
for iter in range(2):
|
324
|
+
# Orbit alone
|
325
|
+
opt_r.disable_all_targets(); opt_r.disable_all_vary()
|
326
|
+
opt_r.enable_targets(tag='orbit'); opt_r.enable_vary(tag='corr_r'); opt_r.solve()
|
327
|
+
|
328
|
+
# Coupling alone
|
329
|
+
opt_r.disable_all_targets(); opt_r.disable_all_vary()
|
330
|
+
opt_r.enable_targets(tag='coupl'); opt_r.enable_vary(tag='skew_r'); opt_r.solve()
|
331
|
+
|
332
|
+
# phase, beta and alpha alone
|
333
|
+
opt_r.disable_all_targets(); opt_r.disable_all_vary()
|
334
|
+
opt_r.enable_vary(tag='normal_r')
|
335
|
+
opt_r.enable_targets(tag='mu_ip'); opt_r.solve()
|
336
|
+
opt_r.enable_targets(tag='bet_ip'); opt_r.solve()
|
337
|
+
opt_r.enable_targets(tag='alf_ip'); opt_r.solve()
|
338
|
+
|
339
|
+
# All together
|
340
|
+
opt_r.enable_all_targets()
|
341
|
+
opt_r.enable_all_vary()
|
342
|
+
opt_r.solve()
|
343
|
+
|
344
|
+
line.to_json(fname + '_with_sol_corrected.json')
|
345
|
+
|
346
|
+
tw_sol_on_corrected = line.twiss(method='4d')
|
347
|
+
|
348
|
+
assert_allclose = np.testing.assert_allclose
|
349
|
+
|
350
|
+
# Check that tilt is present
|
351
|
+
assert_allclose(tw_sol_off['x_prime', 'ip.1'], np.tan(0.015), atol=1e-14, rtol=0)
|
352
|
+
|
353
|
+
# Check that solenoid introduces coupling
|
354
|
+
assert tw_sol_on.c_minus > 1e-4
|
355
|
+
|
356
|
+
# Check correction
|
357
|
+
tw_chk = tw_sol_on_corrected
|
358
|
+
|
359
|
+
assert_allclose(tw_chk['x', 'ip.1'], 0, atol=1e-8, rtol=0)
|
360
|
+
assert_allclose(tw_chk['y', 'ip.1'], 0, atol=1e-10, rtol=0)
|
361
|
+
assert_allclose(tw_chk['x_prime', 'ip.1'], tw_sol_off['x_prime', 'ip.1'], atol=1e-9, rtol=0)
|
362
|
+
assert_allclose(tw_chk['y_prime', 'ip.1'], 0, atol=1e-8, rtol=0)
|
363
|
+
assert_allclose(tw_chk['x', 'pqc2re.1'], 0, atol=5e-8, rtol=0)
|
364
|
+
assert_allclose(tw_chk['y', 'pqc2re.1'], 0, atol=5e-8, rtol=0)
|
365
|
+
assert_allclose(tw_chk['x_prime', 'pqc2re.1'], 0, atol=1e-8, rtol=0)
|
366
|
+
assert_allclose(tw_chk['y_prime', 'pqc2re.1'], 0, atol=1e-8, rtol=0)
|
367
|
+
assert_allclose(tw_chk['x', 'pqc2le.4'], 0, atol=5e-8, rtol=0)
|
368
|
+
assert_allclose(tw_chk['y', 'pqc2le.4'], 0, atol=5e-8, rtol=0)
|
369
|
+
assert_allclose(tw_chk['x_prime', 'pqc2le.4'], 0, atol=1e-8, rtol=0)
|
370
|
+
assert_allclose(tw_chk['y_prime', 'pqc2le.4'], 0, atol=1e-8, rtol=0)
|
371
|
+
|
372
|
+
assert tw_chk['ax', 'pqc2le.4'] == 0
|
373
|
+
assert tw_chk['ay', 'pqc2le.4'] == 0
|
374
|
+
assert tw_chk['ax', 'pqc2re.1'] == 0
|
375
|
+
assert tw_chk['ay', 'pqc2re.1'] == 0
|
376
|
+
|
377
|
+
assert_allclose(tw_chk['betx', 'ip.1'], tw_sol_off['betx', 'ip.1'], atol=0, rtol=5e-5)
|
378
|
+
assert_allclose(tw_chk['bety', 'ip.1'], tw_sol_off['bety', 'ip.1'], atol=0, rtol=5e-5)
|
379
|
+
assert_allclose(tw_chk['alfx', 'ip.1'], tw_sol_off['alfx', 'ip.1'], atol=1e-5, rtol=0)
|
380
|
+
assert_allclose(tw_chk['alfy', 'ip.1'], tw_sol_off['alfy', 'ip.1'], atol=1e-5, rtol=0)
|
381
|
+
assert_allclose(tw_chk['mux', 'ip.1'], tw_sol_off['mux', 'ip.1'], atol=2e-6, rtol=0)
|
382
|
+
assert_allclose(tw_chk['muy', 'ip.1'], tw_sol_off['muy', 'ip.1'], atol=2e-6, rtol=0)
|
383
|
+
|
384
|
+
assert_allclose(tw_chk['betx', 'pqc2re.1'], tw_sol_off['betx', 'pqc2re.1'], atol=0, rtol=5e-5)
|
385
|
+
assert_allclose(tw_chk['bety', 'pqc2re.1'], tw_sol_off['bety', 'pqc2re.1'], atol=0, rtol=5e-5)
|
386
|
+
assert_allclose(tw_chk['alfx', 'pqc2re.1'], tw_sol_off['alfx', 'pqc2re.1'], atol=1e-5, rtol=5e-5)
|
387
|
+
assert_allclose(tw_chk['alfy', 'pqc2re.1'], tw_sol_off['alfy', 'pqc2re.1'], atol=1e-5, rtol=5e-5)
|
388
|
+
assert_allclose(tw_chk['mux', 'pqc2re.1'], tw_sol_off['mux', 'pqc2re.1'], atol=2e-6, rtol=5e-5)
|
389
|
+
assert_allclose(tw_chk['muy', 'pqc2re.1'], tw_sol_off['muy', 'pqc2re.1'], atol=2e-6, rtol=5e-5)
|
390
|
+
|
391
|
+
assert_allclose(tw_chk['betx', 'pqc2le.4'], tw_sol_off['betx', 'pqc2le.4'], atol=0, rtol=5e-5)
|
392
|
+
assert_allclose(tw_chk['bety', 'pqc2le.4'], tw_sol_off['bety', 'pqc2le.4'], atol=0, rtol=5e-5)
|
393
|
+
assert_allclose(tw_chk['alfx', 'pqc2le.4'], tw_sol_off['alfx', 'pqc2le.4'], atol=1e-5, rtol=5e-5)
|
394
|
+
assert_allclose(tw_chk['alfy', 'pqc2le.4'], tw_sol_off['alfy', 'pqc2le.4'], atol=1e-5, rtol=5e-5)
|
395
|
+
assert_allclose(tw_chk['mux', 'pqc2le.4'], tw_sol_off['mux', 'pqc2le.4'], atol=2e-6, rtol=5e-5)
|
396
|
+
assert_allclose(tw_chk['muy', 'pqc2le.4'], tw_sol_off['muy', 'pqc2le.4'], atol=2e-6, rtol=5e-5)
|
397
|
+
|
398
|
+
assert tw_chk.c_minus < 1e-6
|
399
|
+
assert_allclose(tw_chk['betx2', 'ip.1'] / tw_chk['betx', 'ip.1'], 0, atol=1e-11)
|
400
|
+
assert_allclose(tw_chk['bety1', 'ip.1'] / tw_chk['bety', 'ip.1'], 0, atol=1e-11)
|
401
|
+
assert_allclose(tw_chk['betx2', 'pqc2re.1'] / tw_chk['betx', 'pqc2re.1'], 0, atol=1e-11)
|
402
|
+
assert_allclose(tw_chk['bety1', 'pqc2re.1'] / tw_chk['bety', 'pqc2re.1'], 0, atol=1e-11)
|
403
|
+
assert_allclose(tw_chk['betx2', 'pqc2le.4'] / tw_chk['betx', 'pqc2le.4'], 0, atol=1e-11)
|
404
|
+
assert_allclose(tw_chk['bety1', 'pqc2le.4'] / tw_chk['bety', 'pqc2le.4'], 0, atol=1e-11)
|
@@ -497,7 +497,7 @@ def test_to_pandas():
|
|
497
497
|
df = line.to_pandas()
|
498
498
|
|
499
499
|
assert tuple(df.columns) == (
|
500
|
-
's', 'element_type', 'name', 'isthick', 'compound_name', 'element')
|
500
|
+
's', 'element_type', 'name', 'isthick', 'iscollective', 'compound_name', 'element')
|
501
501
|
assert len(df) == 4
|
502
502
|
|
503
503
|
def test_check_aperture():
|
@@ -28,7 +28,7 @@ def test_mad_writer(case):
|
|
28
28
|
|
29
29
|
mad = Madx()
|
30
30
|
mad.input(mad_seq)
|
31
|
-
mad.beam(particle='proton', energy=7000e9)
|
31
|
+
mad.beam(particle='proton', energy=7000e9)
|
32
32
|
mad.use('myseq')
|
33
33
|
|
34
34
|
line2 = xt.Line.from_madx_sequence(mad.sequence.myseq, deferred_expressions=True)
|