xcoll 0.3.6__py3-none-any.whl → 0.5.0__py3-none-any.whl
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.
Potentially problematic release.
This version of xcoll might be problematic. Click here for more details.
- xcoll/__init__.py +13 -4
- xcoll/beam_elements/__init__.py +14 -6
- xcoll/beam_elements/absorber.py +41 -7
- xcoll/beam_elements/base.py +1202 -247
- xcoll/beam_elements/blowup.py +198 -0
- xcoll/beam_elements/elements_src/black_absorber.h +136 -0
- xcoll/beam_elements/elements_src/black_crystal.h +129 -0
- xcoll/beam_elements/elements_src/blowup.h +42 -0
- xcoll/beam_elements/elements_src/emittance_monitor.h +109 -0
- xcoll/beam_elements/{collimators_src → elements_src}/everest_block.h +59 -30
- xcoll/beam_elements/elements_src/everest_collimator.h +237 -0
- xcoll/beam_elements/elements_src/everest_crystal.h +280 -0
- xcoll/beam_elements/everest.py +65 -119
- xcoll/beam_elements/monitor.py +428 -0
- xcoll/colldb.py +276 -747
- xcoll/general.py +5 -5
- xcoll/headers/checks.h +1 -1
- xcoll/headers/particle_states.h +2 -2
- xcoll/initial_distribution.py +207 -0
- xcoll/install.py +179 -0
- xcoll/interaction_record/__init__.py +1 -0
- xcoll/interaction_record/interaction_record.py +298 -0
- xcoll/interaction_record/interaction_record_src/interaction_record.h +98 -0
- xcoll/{impacts → interaction_record}/interaction_types.py +11 -4
- xcoll/line_tools.py +82 -0
- xcoll/lossmap.py +219 -0
- xcoll/manager.py +2 -937
- xcoll/rf_sweep.py +1 -1
- xcoll/scattering_routines/everest/amorphous.h +232 -0
- xcoll/scattering_routines/everest/channeling.h +240 -0
- xcoll/scattering_routines/everest/crystal_parameters.h +137 -0
- xcoll/scattering_routines/everest/everest.h +11 -30
- xcoll/scattering_routines/everest/everest.py +13 -10
- xcoll/scattering_routines/everest/jaw.h +28 -197
- xcoll/scattering_routines/everest/materials.py +37 -15
- xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +31 -10
- xcoll/scattering_routines/everest/nuclear_interaction.h +86 -0
- xcoll/scattering_routines/everest/properties.h +6 -1
- xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.a +0 -0
- xcoll/scattering_routines/geant4/collimasim/.git +1 -0
- xcoll/scattering_routines/geant4/collimasim/.gitignore +12 -0
- xcoll/scattering_routines/geant4/collimasim/.gitmodules +3 -0
- xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +26 -0
- xcoll/scattering_routines/geant4/collimasim/README.md +21 -0
- xcoll/scattering_routines/geant4/collimasim/docs/Makefile +20 -0
- xcoll/scattering_routines/geant4/collimasim/docs/make.bat +35 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +10 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +26 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +37 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +1 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +9 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +386 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +45 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +16 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +969 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +48 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +16 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +45 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +151 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +297 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +29 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +180 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +192 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +11 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +81 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +93 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +310 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +109 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +43 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +171 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +251 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +305 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +1297 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +262 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +396 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +568 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +337 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +13 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +463 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +286 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +155 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +174 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +308 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +91 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +95 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +2050 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +542 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +648 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +381 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +343 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +48 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +105 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +72 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +427 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +427 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +130 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +96 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +548 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +605 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +144 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +1432 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +213 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +2 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +709 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +1021 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +104 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +346 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +467 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +978 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +55 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +606 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +284 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +121 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +193 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +275 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +1741 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +2497 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +1879 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +375 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +747 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +88 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +11 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +52 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +21 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +482 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +63 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +56 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +155 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +503 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +208 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +275 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +33 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +279 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +143 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +85 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +179 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +151 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +91 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +85 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +26 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +25 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +216 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +286 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +536 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +107 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +248 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +227 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +202 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +210 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +550 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +473 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +21 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +28 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +39 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +46 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +35 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +10 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +165 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +53 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +238 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +126 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +141 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +117 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +50 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +69 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +42 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +348 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +771 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +47 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +22 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +326 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +15 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +148 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +272 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +119 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +51 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +5 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +285 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +265 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +397 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +520 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +49 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +94 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +125 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +331 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +153 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +284 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +107 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +257 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +412 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +517 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +102 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +92 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +233 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +360 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +472 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +593 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +524 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +441 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +267 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +235 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +146 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +189 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +82 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +560 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +651 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +500 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +253 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +452 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +318 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +342 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +291 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +131 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +318 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +144 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +29 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +66 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +44 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +22 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +9 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +510 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +408 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +140 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +117 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +70 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +86 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +257 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +44 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +39 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +64 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +402 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +233 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +276 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +214 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +41 -0
- xcoll/scattering_routines/geant4/collimasim/pyproject.toml +8 -0
- xcoll/scattering_routines/geant4/collimasim/setup.py +144 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +403 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +100 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +763 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +118 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +8 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +63 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +142 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +556 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +6 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +24 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +1 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +1 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +1 -0
- xcoll/scattering_routines/geant4/collimasim/tests/README.md +25 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +25 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +18 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +68 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +15 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +110 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +7 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +54 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +5 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +51 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +65 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +102 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +75 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +74 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +84 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +159 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +99 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +78 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +88 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +80 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +97 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +96 -0
- xcoll/scattering_routines/geometry/__init__.py +6 -0
- xcoll/scattering_routines/geometry/collimator_geometry.h +218 -0
- xcoll/scattering_routines/geometry/crystal_geometry.h +153 -0
- xcoll/scattering_routines/geometry/geometry.py +26 -0
- xcoll/scattering_routines/geometry/get_s.h +92 -0
- xcoll/scattering_routines/geometry/methods.h +111 -0
- xcoll/scattering_routines/geometry/objects.h +154 -0
- xcoll/scattering_routines/geometry/rotation.h +23 -0
- xcoll/scattering_routines/geometry/segments.h +226 -0
- xcoll/scattering_routines/geometry/sort.h +184 -0
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/METADATA +1 -1
- xcoll-0.5.0.dist-info/RECORD +413 -0
- xcoll/beam_elements/collimators_src/absorber.h +0 -141
- xcoll/beam_elements/collimators_src/everest_collimator.h +0 -142
- xcoll/beam_elements/collimators_src/everest_crystal.h +0 -115
- xcoll/collimator_settings.py +0 -457
- xcoll/impacts/__init__.py +0 -1
- xcoll/impacts/impacts.py +0 -102
- xcoll/impacts/impacts_src/impacts.h +0 -99
- xcoll/scattering_routines/everest/crystal.h +0 -1302
- xcoll/scattering_routines/everest/scatter.h +0 -169
- xcoll/scattering_routines/everest/scatter_crystal.h +0 -260
- xcoll/scattering_routines/fluka/build_fluka_input.py +0 -58
- xcoll-0.3.6.dist-info/RECORD +0 -111
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/LICENSE +0 -0
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/NOTICE +0 -0
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/WHEEL +0 -0
xcoll/general.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# copyright ############################### #
|
|
2
2
|
# This file is part of the Xcoll Package. #
|
|
3
|
-
# Copyright (c) CERN,
|
|
3
|
+
# Copyright (c) CERN, 2024. #
|
|
4
4
|
# ######################################### #
|
|
5
5
|
|
|
6
6
|
from pathlib import Path
|
|
@@ -9,8 +9,8 @@ _pkg_root = Path(__file__).parent.absolute()
|
|
|
9
9
|
|
|
10
10
|
citation = "F.F. Van der Veken, et al.: Recent Developments with the New Tools for Collimation Simulations in Xsuite, Proceedings of HB2023, Geneva, Switzerland."
|
|
11
11
|
|
|
12
|
-
#
|
|
12
|
+
# ======================
|
|
13
13
|
# Do not change
|
|
14
|
-
#
|
|
15
|
-
__version__ = '0.
|
|
16
|
-
#
|
|
14
|
+
# ======================
|
|
15
|
+
__version__ = '0.5.0'
|
|
16
|
+
# ======================
|
xcoll/headers/checks.h
CHANGED
xcoll/headers/particle_states.h
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// copyright ############################### #
|
|
2
2
|
// This file is part of the Xcoll Package. #
|
|
3
|
-
// Copyright (c) CERN,
|
|
3
|
+
// Copyright (c) CERN, 2024. #
|
|
4
4
|
// ######################################### #
|
|
5
5
|
|
|
6
6
|
#ifndef XCOLL_STATES_H
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
#define XC_ERR_NOT_IMPLEMENTED -391
|
|
22
22
|
#define XC_ERR_INVALID_XOFIELD -392
|
|
23
23
|
#define XC_ERR -399
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
#endif /* XCOLL_STATES_H */
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# copyright ############################### #
|
|
2
|
+
# This file is part of the Xcoll Package. #
|
|
3
|
+
# Copyright (c) CERN, 2024. #
|
|
4
|
+
# ######################################### #
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
import xtrack as xt
|
|
9
|
+
import xobjects as xo
|
|
10
|
+
import xpart as xp
|
|
11
|
+
|
|
12
|
+
from .beam_elements import _all_collimator_classes, EverestCrystal
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def generate_pencil_on_collimator(line, name, num_particles, *, side='+-', pencil_spread=1e-6,
|
|
16
|
+
impact_parameter=0, sigma_z=7.61e-2, tw=None, longitudinal=None,
|
|
17
|
+
longitudinal_betatron_cut=None):
|
|
18
|
+
"""
|
|
19
|
+
Generate a pencil beam on a collimator.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
if not line._has_valid_tracker():
|
|
23
|
+
raise Exception("Please build tracker before generating pencil distribution!")
|
|
24
|
+
|
|
25
|
+
coll = line[name]
|
|
26
|
+
|
|
27
|
+
if not isinstance(coll, tuple(_all_collimator_classes)):
|
|
28
|
+
raise ValueError("Need to provide a valid collimator!")
|
|
29
|
+
|
|
30
|
+
if coll.optics is None:
|
|
31
|
+
raise Exception("Need to assign optics to collimators before generating pencil distribution!")
|
|
32
|
+
|
|
33
|
+
num_particles = int(num_particles)
|
|
34
|
+
|
|
35
|
+
if coll.side == 'left':
|
|
36
|
+
side = '+'
|
|
37
|
+
if coll.side == 'right':
|
|
38
|
+
side = '-'
|
|
39
|
+
|
|
40
|
+
# Define the plane
|
|
41
|
+
angle = coll.angle
|
|
42
|
+
if abs(np.mod(angle-90,180)-90) < 1e-6:
|
|
43
|
+
plane = 'x'
|
|
44
|
+
transv_plane = 'y'
|
|
45
|
+
elif abs(np.mod(angle,180)-90) < 1e-6:
|
|
46
|
+
plane = 'y'
|
|
47
|
+
transv_plane = 'x'
|
|
48
|
+
else:
|
|
49
|
+
raise NotImplementedError("Pencil beam on a skew collimator not yet supported!")
|
|
50
|
+
|
|
51
|
+
if tw is None:
|
|
52
|
+
tw = line.twiss() # TODO: can we do this smarter by caching?
|
|
53
|
+
|
|
54
|
+
# Is it converging or diverging? # TODO: This might change with a tilt!!!!!!
|
|
55
|
+
s_front = line.get_s_position(name)
|
|
56
|
+
s_back = s_front + coll.length
|
|
57
|
+
is_converging = tw[f'alf{plane}', name] > 0
|
|
58
|
+
print(f"Collimator {name} is {'con' if is_converging else 'di'}verging.")
|
|
59
|
+
|
|
60
|
+
beam_sizes = tw.get_beam_covariance(nemitt_x=coll.nemitt_x, nemitt_y=coll.nemitt_y)
|
|
61
|
+
if is_converging:
|
|
62
|
+
# pencil at front of jaw
|
|
63
|
+
match_at_s = s_front
|
|
64
|
+
sigma = beam_sizes.rows[name:f'{name}%%1'][f'sigma_{plane}'][0]
|
|
65
|
+
sigma_transv = beam_sizes.rows[name:f'{name}%%1'][f'sigma_{transv_plane}'][0]
|
|
66
|
+
else:
|
|
67
|
+
# pencil at back of jaw
|
|
68
|
+
match_at_s = s_back
|
|
69
|
+
sigma = beam_sizes.rows[name:f'{name}%%1'][f'sigma_{plane}'][1]
|
|
70
|
+
sigma_transv = beam_sizes.rows[name:f'{name}%%1'][f'sigma_{transv_plane}'][1]
|
|
71
|
+
dr_sigmas = pencil_spread/sigma
|
|
72
|
+
|
|
73
|
+
# Generate 4D coordinates
|
|
74
|
+
# TODO: there is some looping in the calculation here and in xpart. Can it be improved?
|
|
75
|
+
if side == '+-':
|
|
76
|
+
num_plus = int(num_particles/2)
|
|
77
|
+
num_min = int(num_particles - num_plus)
|
|
78
|
+
coords_plus = _generate_4D_pencil_one_jaw(line, name, num_plus, plane, '+', impact_parameter, dr_sigmas, match_at_s, is_converging)
|
|
79
|
+
coords_min = _generate_4D_pencil_one_jaw(line, name, num_min, plane, '-', impact_parameter, dr_sigmas, match_at_s, is_converging)
|
|
80
|
+
coords = [ [*c_plus, *c_min] for c_plus, c_min in zip(coords_plus, coords_min)]
|
|
81
|
+
else:
|
|
82
|
+
coords = _generate_4D_pencil_one_jaw(line, name, num_particles, plane, side, impact_parameter, dr_sigmas, match_at_s, is_converging)
|
|
83
|
+
pencil = coords[0]
|
|
84
|
+
p_pencil = coords[1]
|
|
85
|
+
transverse_norm = coords[2]
|
|
86
|
+
p_transverse_norm = coords[3]
|
|
87
|
+
|
|
88
|
+
# Longitudinal plane
|
|
89
|
+
# TODO: make this more general, make this better
|
|
90
|
+
if longitudinal is None:
|
|
91
|
+
delta = 0
|
|
92
|
+
zeta = 0
|
|
93
|
+
elif longitudinal == 'matched_dispersion':
|
|
94
|
+
raise NotImplementedError
|
|
95
|
+
# if longitudinal_betatron_cut is None:
|
|
96
|
+
# cut = 0
|
|
97
|
+
# else:
|
|
98
|
+
# cut = np.random.uniform(-longitudinal_betatron_cut, longitudinal_betatron_cut,
|
|
99
|
+
# num_particles)
|
|
100
|
+
# delta = generate_delta_from_dispersion(line, name, plane=plane, position_mm=pencil,
|
|
101
|
+
# nemitt_x=nemitt_x, nemitt_y=nemitt_y, twiss=tw,
|
|
102
|
+
# betatron_cut=cut, match_at_front=is_converging)
|
|
103
|
+
# zeta = 0
|
|
104
|
+
elif longitudinal == 'bucket':
|
|
105
|
+
zeta, delta = xp.generate_longitudinal_coordinates(
|
|
106
|
+
num_particles=num_particles, distribution='gaussian', sigma_z=sigma_z, line=line
|
|
107
|
+
)
|
|
108
|
+
elif not hasattr(longitudinal, '__iter__'):
|
|
109
|
+
raise ValueError
|
|
110
|
+
elif len(longitudinal) != 2:
|
|
111
|
+
raise ValueError
|
|
112
|
+
elif isinstance(longitudinal, str):
|
|
113
|
+
raise ValueError
|
|
114
|
+
elif isinstance(longitudinal, dict):
|
|
115
|
+
zeta = longitudinal['zeta']
|
|
116
|
+
delta = longitudinal['delta']
|
|
117
|
+
else:
|
|
118
|
+
zeta = longitudinal[0]
|
|
119
|
+
delta = longitudinal[1]
|
|
120
|
+
|
|
121
|
+
# Build the particles
|
|
122
|
+
if plane == 'x':
|
|
123
|
+
part = xp.build_particles(
|
|
124
|
+
x=pencil, px=p_pencil, y_norm=transverse_norm, py_norm=p_transverse_norm,
|
|
125
|
+
zeta=zeta, delta=delta, nemitt_x=coll.nemitt_x, nemitt_y=coll.nemitt_y,
|
|
126
|
+
line=line, at_element=name, match_at_s=match_at_s,
|
|
127
|
+
_context=coll._buffer.context
|
|
128
|
+
)
|
|
129
|
+
else:
|
|
130
|
+
part = xp.build_particles(
|
|
131
|
+
x_norm=transverse_norm, px_norm=p_transverse_norm, y=pencil, py=p_pencil,
|
|
132
|
+
zeta=zeta, delta=delta, nemitt_x=coll.nemitt_x, nemitt_y=coll.nemitt_y,
|
|
133
|
+
line=line, at_element=name, match_at_s=match_at_s,
|
|
134
|
+
_context=coll._buffer.context
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
part._init_random_number_generator()
|
|
138
|
+
|
|
139
|
+
return part
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def generate_delta_from_dispersion(line, at_element, *, plane, position_mm, nemitt_x, nemitt_y,
|
|
143
|
+
twiss=None, betatron_cut=0, match_at_front=True):
|
|
144
|
+
if line.tracker is None:
|
|
145
|
+
raise ValueError("Need to build tracker first!")
|
|
146
|
+
if not hasattr(betatron_cut, '__iter__'):
|
|
147
|
+
if hasattr(position_mm, '__iter__'):
|
|
148
|
+
betatron_cut = np.full_like(position_mm, betatron_cut)
|
|
149
|
+
elif not hasattr(position_mm, '__iter__'):
|
|
150
|
+
position_mm = np.full_like(betatron_cut, position_mm)
|
|
151
|
+
elif len(position_mm) != len(betatron_cut):
|
|
152
|
+
raise ValueError
|
|
153
|
+
if plane not in ['x', 'y']:
|
|
154
|
+
raise ValueError("The variable 'plane' needs to be either 'x' or 'y'!")
|
|
155
|
+
|
|
156
|
+
if twiss is None:
|
|
157
|
+
twiss = line.twiss()
|
|
158
|
+
|
|
159
|
+
beam_sizes = twiss.get_beam_covariance(nemitt_x=nemitt_x, nemitt_y=nemitt_y)
|
|
160
|
+
beam_sizes = beam_sizes.rows[at_element:f'{at_element}%%1'][f'sigma_{plane}']
|
|
161
|
+
sigma = beam_sizes[0] if match_at_front else beam_sizes[1]
|
|
162
|
+
delta = (position_mm - betatron_cut*sigma - twiss.rows[at_element][plane])
|
|
163
|
+
delta /= twiss.rows[at_element][f'd{plane}']
|
|
164
|
+
|
|
165
|
+
return delta
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def _generate_4D_pencil_one_jaw(line, name, num_particles, plane, side, impact_parameter,
|
|
169
|
+
dr_sigmas, match_at_s, is_converging):
|
|
170
|
+
coll = line[name]
|
|
171
|
+
|
|
172
|
+
if side == '+':
|
|
173
|
+
if is_converging:
|
|
174
|
+
if isinstance(coll, EverestCrystal):
|
|
175
|
+
pencil_pos = coll.jaw_U + impact_parameter
|
|
176
|
+
else:
|
|
177
|
+
pencil_pos = coll.jaw_LU + impact_parameter
|
|
178
|
+
else:
|
|
179
|
+
if isinstance(coll, EverestCrystal):
|
|
180
|
+
pencil_pos = coll.jaw_D - impact_parameter
|
|
181
|
+
else:
|
|
182
|
+
pencil_pos = coll.jaw_LD + impact_parameter
|
|
183
|
+
elif side == '-':
|
|
184
|
+
if is_converging:
|
|
185
|
+
if isinstance(coll, EverestCrystal):
|
|
186
|
+
pencil_pos = coll.jaw_U - impact_parameter
|
|
187
|
+
else:
|
|
188
|
+
pencil_pos = coll.jaw_RU - impact_parameter
|
|
189
|
+
else:
|
|
190
|
+
if isinstance(coll, EverestCrystal):
|
|
191
|
+
pencil_pos = coll.jaw_D + impact_parameter
|
|
192
|
+
else:
|
|
193
|
+
pencil_pos = coll.jaw_RD - impact_parameter
|
|
194
|
+
|
|
195
|
+
# Collimator plane: generate pencil distribution
|
|
196
|
+
pencil, p_pencil = xp.generate_2D_pencil_with_absolute_cut(
|
|
197
|
+
num_particles, plane=plane, absolute_cut=pencil_pos, line=line,
|
|
198
|
+
dr_sigmas=dr_sigmas, nemitt_x=coll.nemitt_x, nemitt_y=coll.nemitt_y,
|
|
199
|
+
at_element=name, side=side,match_at_s=match_at_s
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
# Other plane: generate gaussian distribution in normalized coordinates
|
|
203
|
+
transverse_norm = np.random.normal(size=num_particles)
|
|
204
|
+
p_transverse_norm = np.random.normal(size=num_particles)
|
|
205
|
+
|
|
206
|
+
return [pencil, p_pencil, transverse_norm, p_transverse_norm]
|
|
207
|
+
|
xcoll/install.py
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# copyright ############################### #
|
|
2
|
+
# This file is part of the Xcoll Package. #
|
|
3
|
+
# Copyright (c) CERN, 2024. #
|
|
4
|
+
# ######################################### #
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
import xtrack as xt
|
|
8
|
+
|
|
9
|
+
from .beam_elements import element_classes
|
|
10
|
+
|
|
11
|
+
def install_elements(line, names, elements, *, at_s=None, apertures=None, need_apertures=False, s_tol=1.e-6):
|
|
12
|
+
if line._has_valid_tracker():
|
|
13
|
+
raise Exception("Tracker already built!\nPlease install collimators before building "
|
|
14
|
+
+ "tracker!")
|
|
15
|
+
|
|
16
|
+
if not hasattr(names, '__iter__') or isinstance(names, str):
|
|
17
|
+
names = [names]
|
|
18
|
+
if not hasattr(elements, '__iter__') or isinstance(elements, str):
|
|
19
|
+
elements = [elements]
|
|
20
|
+
names = np.array(names)
|
|
21
|
+
length = np.array([coll.length for coll in elements])
|
|
22
|
+
assert len(length) == len(names)
|
|
23
|
+
if not hasattr(at_s, '__iter__'):
|
|
24
|
+
at_s = [at_s for _ in range(len(names))]
|
|
25
|
+
assert len(at_s) == len(names)
|
|
26
|
+
if isinstance(apertures, str) or not hasattr(apertures, '__iter__'):
|
|
27
|
+
apertures = [apertures for _ in range(len(names))]
|
|
28
|
+
assert len(apertures) == len(names)
|
|
29
|
+
|
|
30
|
+
# Verify elements
|
|
31
|
+
for el in elements:
|
|
32
|
+
assert isinstance(el, element_classes)
|
|
33
|
+
el._tracking = False
|
|
34
|
+
|
|
35
|
+
# Get positions
|
|
36
|
+
tab = line.get_table()
|
|
37
|
+
tt = tab.rows[[name for name in names if name in line.element_names]]
|
|
38
|
+
s_start = []
|
|
39
|
+
for name, s, l in zip(names, at_s, length):
|
|
40
|
+
if s is None:
|
|
41
|
+
s_start.append(_get_s_start(line, name, l, tt))
|
|
42
|
+
else:
|
|
43
|
+
s_start.append(s)
|
|
44
|
+
s_start = np.array(s_start)
|
|
45
|
+
s_end = s_start + length
|
|
46
|
+
|
|
47
|
+
# Check positions
|
|
48
|
+
l_line = line.get_length()
|
|
49
|
+
for s1, s2, name, s3 in zip(s_start, s_end, names, at_s):
|
|
50
|
+
check_element_position(line, name, s1, s2, s3, l_line, s_tol=s_tol)
|
|
51
|
+
|
|
52
|
+
# Look for apertures
|
|
53
|
+
aper_upstream = []
|
|
54
|
+
aper_downstream = []
|
|
55
|
+
for s1, s2, name, aper in zip(s_start, s_end, names, apertures):
|
|
56
|
+
if not need_apertures:
|
|
57
|
+
aper_upstream.append(None)
|
|
58
|
+
aper_downstream.append(None)
|
|
59
|
+
else:
|
|
60
|
+
aper1, aper2 = get_aperture_for_element(line, name, s1, s2, aper, tab, s_tol=s_tol)
|
|
61
|
+
aper_upstream.append(aper1)
|
|
62
|
+
aper_downstream.append(aper2)
|
|
63
|
+
|
|
64
|
+
# Remove elements at location of collimator (by changing them into markers)
|
|
65
|
+
for s1, s2, name in zip(s_start, s_end, names):
|
|
66
|
+
prepare_space_for_element(line, name, s1, s2, tab=tab, s_tol=s_tol)
|
|
67
|
+
|
|
68
|
+
# Install
|
|
69
|
+
line._insert_thick_elements_at_s(element_names=list(names), elements=elements, at_s=s_start, s_tol=s_tol)
|
|
70
|
+
|
|
71
|
+
# Install apertures
|
|
72
|
+
if need_apertures:
|
|
73
|
+
for s1, name, aper1, aper2 in zip(s_start, names, aper_upstream, aper_downstream):
|
|
74
|
+
line.insert_element(element=aper1, name=f'{name}_aper_upstream', at=name, s_tol=s_tol)
|
|
75
|
+
idx = line.element_names.index(name) + 1
|
|
76
|
+
line.insert_element(element=aper2, name=f'{name}_aper_downstream', at=idx, s_tol=s_tol)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _get_s_start(line, name, length, tab=None):
|
|
80
|
+
if tab is None:
|
|
81
|
+
tab = line.get_table()
|
|
82
|
+
if name in line.element_names and hasattr(line[name], 'length'):
|
|
83
|
+
existing_length = line[name].length
|
|
84
|
+
else:
|
|
85
|
+
existing_length = 0
|
|
86
|
+
if name not in tab.name:
|
|
87
|
+
raise ValueError(f"Element {name} not found in line. Need to mmanually provide `at_s`.")
|
|
88
|
+
return tab.rows[name].s[0] + existing_length/2. - length/2
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def check_element_position(line, name, s_start, s_end, at_s, length=None, s_tol=1.e-6):
|
|
92
|
+
if at_s is None:
|
|
93
|
+
if name not in line.element_names:
|
|
94
|
+
raise ValueError(f"Element {name} not found in line. Provide `at_s`.")
|
|
95
|
+
elif name in line.element_names:
|
|
96
|
+
if at_s < s_start or at_s > s_end:
|
|
97
|
+
raise ValueError(f"Element {name} already exists in line at different "
|
|
98
|
+
+ f"location: at_s = {at_s}, exists at [{s_start}, {s_end}].")
|
|
99
|
+
if length is None:
|
|
100
|
+
length = line.get_length()
|
|
101
|
+
if s_start <= s_tol:
|
|
102
|
+
raise ValueError(f"Position of {name} too close to start of line. Please cycle.")
|
|
103
|
+
if s_end >= length - s_tol:
|
|
104
|
+
raise ValueError(f"Position of {name} too close to end of line. Please cycle.")
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def get_apertures_at_s(tab, s, s_tol=1.e-6):
|
|
108
|
+
tab_s = tab.rows[s-s_tol:s+s_tol:'s']
|
|
109
|
+
aper = tab_s.rows[[cls.startswith('Limit') for cls in tab_s.element_type]]
|
|
110
|
+
if len(aper) == 0:
|
|
111
|
+
return None
|
|
112
|
+
elif len(aper) == 1:
|
|
113
|
+
return aper.name[0]
|
|
114
|
+
else:
|
|
115
|
+
raise ValueError(f"Multiple apertures found at location {s} with "
|
|
116
|
+
+ f"tolerance {s_tol}: {aper.name}. Not supported.")
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def get_aperture_for_element(line, name, s_start, s_end, aperture=None, tab=None, s_tol=1.e-6):
|
|
120
|
+
if aperture is not None:
|
|
121
|
+
if isinstance(aperture, str):
|
|
122
|
+
aper1 = line[aperture]
|
|
123
|
+
aper2 = line[aperture]
|
|
124
|
+
elif hasattr(aperture, '__iter__'):
|
|
125
|
+
if len(aperture) != 2:
|
|
126
|
+
raise ValueError(f"The value `aperture` should be None or a list "
|
|
127
|
+
+ f"[upstream, downstream].")
|
|
128
|
+
assert aperture[0] is not None and aperture[1] is not None
|
|
129
|
+
if isinstance(aperture[0], str):
|
|
130
|
+
aper1 = line[aperture[0]]
|
|
131
|
+
if isinstance(aperture[1], str):
|
|
132
|
+
aper2 = line[aperture[1]]
|
|
133
|
+
else:
|
|
134
|
+
aper1 = aperture
|
|
135
|
+
aper2 = aperture
|
|
136
|
+
if not xt.line._is_aperture(aper1, line):
|
|
137
|
+
raise ValueError(f"Not a valid aperture: {aper1}")
|
|
138
|
+
if not xt.line._is_aperture(aper2, line):
|
|
139
|
+
raise ValueError(f"Not a valid aperture: {aper2}")
|
|
140
|
+
return aper1.copy(), aper2.copy()
|
|
141
|
+
else:
|
|
142
|
+
if tab is None:
|
|
143
|
+
tab = line.get_table()
|
|
144
|
+
aper1 = get_apertures_at_s(tab, s_start, s_tol=s_tol)
|
|
145
|
+
aper2 = get_apertures_at_s(tab, s_end, s_tol=s_tol)
|
|
146
|
+
if aper1 is None and aper2 is not None:
|
|
147
|
+
aper1 = aper2
|
|
148
|
+
print(f"Warning: Could not find upstream aperture for {name}! "
|
|
149
|
+
+ f"Used copy of downstream aperture. Proceed with caution.")
|
|
150
|
+
elif aper2 is None and aper1 is not None:
|
|
151
|
+
aper2 = aper1
|
|
152
|
+
print(f"Warning: Could not find downstream aperture for {name}! "
|
|
153
|
+
+ f"Used copy of upstream aperture. Proceed with caution.")
|
|
154
|
+
elif aper1 is None and aper2 is None:
|
|
155
|
+
aper_mid = get_apertures_at_s(tab, (s_start+s_end)/2, s_tol=s_tol)
|
|
156
|
+
if aper_mid is None:
|
|
157
|
+
raise ValueError(f"No aperture found for {name}! Please provide one.")
|
|
158
|
+
if line[aper_mid].allow_rot_and_shift \
|
|
159
|
+
and xt.base_element._tranformations_active(line[aper_mid]):
|
|
160
|
+
print(f"Warning: Using the centre aperture for {name}, but "
|
|
161
|
+
+ f"transformations are present. Proceed with caution.")
|
|
162
|
+
aper1 = aper_mid
|
|
163
|
+
aper2 = aper_mid
|
|
164
|
+
return line[aper1].copy(), line[aper2].copy()
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def prepare_space_for_element(line, name, s_start, s_end, tab=None, s_tol=1.e-6):
|
|
168
|
+
if tab is None:
|
|
169
|
+
tab = line.get_table()
|
|
170
|
+
tt = tab.rows[s_start-s_tol:s_end+s_tol:'s']
|
|
171
|
+
for element_name, element_type in zip(tt.name[:-1], tt.element_type[:-1]):
|
|
172
|
+
if element_type == 'Marker' or element_type.startswith('Drift'):
|
|
173
|
+
continue
|
|
174
|
+
if not element_type.startswith('Limit'):
|
|
175
|
+
print(f"Warning: Removed active element {element_name} "
|
|
176
|
+
+ f"at location inside collimator {name}!")
|
|
177
|
+
length = line[element_name].length if hasattr(line[element_name], 'length') else 0
|
|
178
|
+
line.element_dict[element_name] = xt.Drift(length=length)
|
|
179
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .interaction_record import InteractionRecord
|