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.

Files changed (350) hide show
  1. xcoll/__init__.py +13 -4
  2. xcoll/beam_elements/__init__.py +14 -6
  3. xcoll/beam_elements/absorber.py +41 -7
  4. xcoll/beam_elements/base.py +1202 -247
  5. xcoll/beam_elements/blowup.py +198 -0
  6. xcoll/beam_elements/elements_src/black_absorber.h +136 -0
  7. xcoll/beam_elements/elements_src/black_crystal.h +129 -0
  8. xcoll/beam_elements/elements_src/blowup.h +42 -0
  9. xcoll/beam_elements/elements_src/emittance_monitor.h +109 -0
  10. xcoll/beam_elements/{collimators_src → elements_src}/everest_block.h +59 -30
  11. xcoll/beam_elements/elements_src/everest_collimator.h +237 -0
  12. xcoll/beam_elements/elements_src/everest_crystal.h +280 -0
  13. xcoll/beam_elements/everest.py +65 -119
  14. xcoll/beam_elements/monitor.py +428 -0
  15. xcoll/colldb.py +276 -747
  16. xcoll/general.py +5 -5
  17. xcoll/headers/checks.h +1 -1
  18. xcoll/headers/particle_states.h +2 -2
  19. xcoll/initial_distribution.py +207 -0
  20. xcoll/install.py +179 -0
  21. xcoll/interaction_record/__init__.py +1 -0
  22. xcoll/interaction_record/interaction_record.py +298 -0
  23. xcoll/interaction_record/interaction_record_src/interaction_record.h +98 -0
  24. xcoll/{impacts → interaction_record}/interaction_types.py +11 -4
  25. xcoll/line_tools.py +82 -0
  26. xcoll/lossmap.py +219 -0
  27. xcoll/manager.py +2 -937
  28. xcoll/rf_sweep.py +1 -1
  29. xcoll/scattering_routines/everest/amorphous.h +232 -0
  30. xcoll/scattering_routines/everest/channeling.h +240 -0
  31. xcoll/scattering_routines/everest/crystal_parameters.h +137 -0
  32. xcoll/scattering_routines/everest/everest.h +11 -30
  33. xcoll/scattering_routines/everest/everest.py +13 -10
  34. xcoll/scattering_routines/everest/jaw.h +28 -197
  35. xcoll/scattering_routines/everest/materials.py +37 -15
  36. xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +31 -10
  37. xcoll/scattering_routines/everest/nuclear_interaction.h +86 -0
  38. xcoll/scattering_routines/everest/properties.h +6 -1
  39. xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.a +0 -0
  40. xcoll/scattering_routines/geant4/collimasim/.git +1 -0
  41. xcoll/scattering_routines/geant4/collimasim/.gitignore +12 -0
  42. xcoll/scattering_routines/geant4/collimasim/.gitmodules +3 -0
  43. xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +26 -0
  44. xcoll/scattering_routines/geant4/collimasim/README.md +21 -0
  45. xcoll/scattering_routines/geant4/collimasim/docs/Makefile +20 -0
  46. xcoll/scattering_routines/geant4/collimasim/docs/make.bat +35 -0
  47. xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +10 -0
  48. xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +59 -0
  49. xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +26 -0
  50. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +37 -0
  51. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +19 -0
  52. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +65 -0
  53. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +73 -0
  54. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +1 -0
  55. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +9 -0
  56. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +386 -0
  57. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +45 -0
  58. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +8 -0
  59. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +16 -0
  60. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +8 -0
  61. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +3 -0
  62. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +19 -0
  63. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +969 -0
  64. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +84 -0
  65. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +48 -0
  66. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +16 -0
  67. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +103 -0
  68. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +45 -0
  69. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +151 -0
  70. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +3 -0
  71. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +297 -0
  72. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +29 -0
  73. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +6 -0
  74. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +180 -0
  75. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +23 -0
  76. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +192 -0
  77. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +11 -0
  78. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +81 -0
  79. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +93 -0
  80. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +310 -0
  81. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +109 -0
  82. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +43 -0
  83. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +171 -0
  84. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +251 -0
  85. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +305 -0
  86. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +1297 -0
  87. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +262 -0
  88. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +396 -0
  89. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +568 -0
  90. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +337 -0
  91. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +13 -0
  92. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +463 -0
  93. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +286 -0
  94. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +155 -0
  95. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +174 -0
  96. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +308 -0
  97. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +91 -0
  98. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +95 -0
  99. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +2050 -0
  100. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +542 -0
  101. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +8 -0
  102. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +648 -0
  103. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +381 -0
  104. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +343 -0
  105. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +48 -0
  106. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +105 -0
  107. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +72 -0
  108. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
  109. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
  110. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +427 -0
  111. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
  112. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +427 -0
  113. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +130 -0
  114. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +96 -0
  115. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +8 -0
  116. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +548 -0
  117. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +605 -0
  118. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +144 -0
  119. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +1432 -0
  120. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +213 -0
  121. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +2 -0
  122. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +65 -0
  123. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +709 -0
  124. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +1021 -0
  125. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +104 -0
  126. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +346 -0
  127. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +467 -0
  128. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +978 -0
  129. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +55 -0
  130. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +606 -0
  131. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +284 -0
  132. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +163 -0
  133. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +121 -0
  134. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +193 -0
  135. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +275 -0
  136. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +1741 -0
  137. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +163 -0
  138. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +65 -0
  139. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +2497 -0
  140. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +1879 -0
  141. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +103 -0
  142. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +375 -0
  143. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +747 -0
  144. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +88 -0
  145. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +11 -0
  146. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +52 -0
  147. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +12 -0
  148. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +6 -0
  149. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +21 -0
  150. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
  151. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +482 -0
  152. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +63 -0
  153. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +41 -0
  154. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +56 -0
  155. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +155 -0
  156. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +503 -0
  157. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +208 -0
  158. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +275 -0
  159. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +73 -0
  160. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +33 -0
  161. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
  162. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +279 -0
  163. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
  164. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +143 -0
  165. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +85 -0
  166. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +179 -0
  167. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +151 -0
  168. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +91 -0
  169. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +85 -0
  170. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +19 -0
  171. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +12 -0
  172. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +26 -0
  173. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +25 -0
  174. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +216 -0
  175. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +163 -0
  176. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +286 -0
  177. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +536 -0
  178. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +107 -0
  179. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +248 -0
  180. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +227 -0
  181. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +202 -0
  182. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +84 -0
  183. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +210 -0
  184. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +550 -0
  185. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +473 -0
  186. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +84 -0
  187. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +21 -0
  188. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +28 -0
  189. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +39 -0
  190. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +46 -0
  191. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +6 -0
  192. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +41 -0
  193. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +35 -0
  194. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +41 -0
  195. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +10 -0
  196. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +165 -0
  197. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +53 -0
  198. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +238 -0
  199. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +126 -0
  200. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +141 -0
  201. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +117 -0
  202. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +41 -0
  203. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +50 -0
  204. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +69 -0
  205. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +42 -0
  206. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +348 -0
  207. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +771 -0
  208. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +47 -0
  209. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +22 -0
  210. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +23 -0
  211. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +326 -0
  212. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +15 -0
  213. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +148 -0
  214. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +272 -0
  215. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +119 -0
  216. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +51 -0
  217. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +5 -0
  218. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +285 -0
  219. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +12 -0
  220. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +265 -0
  221. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +397 -0
  222. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +520 -0
  223. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +49 -0
  224. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +94 -0
  225. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +125 -0
  226. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +331 -0
  227. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +153 -0
  228. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +284 -0
  229. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +107 -0
  230. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +257 -0
  231. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +412 -0
  232. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +517 -0
  233. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +102 -0
  234. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +92 -0
  235. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +233 -0
  236. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +360 -0
  237. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +472 -0
  238. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +593 -0
  239. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +524 -0
  240. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +441 -0
  241. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +103 -0
  242. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +267 -0
  243. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +73 -0
  244. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +59 -0
  245. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +235 -0
  246. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +146 -0
  247. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +189 -0
  248. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +82 -0
  249. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +560 -0
  250. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +651 -0
  251. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +500 -0
  252. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +253 -0
  253. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +452 -0
  254. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +318 -0
  255. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +342 -0
  256. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +291 -0
  257. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +131 -0
  258. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +318 -0
  259. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +144 -0
  260. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +29 -0
  261. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +66 -0
  262. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +44 -0
  263. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +22 -0
  264. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +9 -0
  265. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +510 -0
  266. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +408 -0
  267. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +140 -0
  268. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +117 -0
  269. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +70 -0
  270. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +86 -0
  271. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +257 -0
  272. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +44 -0
  273. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +23 -0
  274. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +39 -0
  275. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +64 -0
  276. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +402 -0
  277. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +233 -0
  278. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +276 -0
  279. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +214 -0
  280. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +3 -0
  281. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +65 -0
  282. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +41 -0
  283. xcoll/scattering_routines/geant4/collimasim/pyproject.toml +8 -0
  284. xcoll/scattering_routines/geant4/collimasim/setup.py +144 -0
  285. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +403 -0
  286. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +100 -0
  287. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +763 -0
  288. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +118 -0
  289. xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +8 -0
  290. xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +63 -0
  291. xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +142 -0
  292. xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +556 -0
  293. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +6 -0
  294. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +24 -0
  295. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +1 -0
  296. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +1 -0
  297. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +1 -0
  298. xcoll/scattering_routines/geant4/collimasim/tests/README.md +25 -0
  299. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +25 -0
  300. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +18 -0
  301. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +68 -0
  302. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +15 -0
  303. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +110 -0
  304. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +7 -0
  305. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +3 -0
  306. xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +54 -0
  307. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +3 -0
  308. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +3 -0
  309. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +5 -0
  310. xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +51 -0
  311. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +65 -0
  312. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +59 -0
  313. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +102 -0
  314. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +75 -0
  315. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +74 -0
  316. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +84 -0
  317. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +159 -0
  318. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +99 -0
  319. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +78 -0
  320. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +88 -0
  321. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +80 -0
  322. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +97 -0
  323. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +96 -0
  324. xcoll/scattering_routines/geometry/__init__.py +6 -0
  325. xcoll/scattering_routines/geometry/collimator_geometry.h +218 -0
  326. xcoll/scattering_routines/geometry/crystal_geometry.h +153 -0
  327. xcoll/scattering_routines/geometry/geometry.py +26 -0
  328. xcoll/scattering_routines/geometry/get_s.h +92 -0
  329. xcoll/scattering_routines/geometry/methods.h +111 -0
  330. xcoll/scattering_routines/geometry/objects.h +154 -0
  331. xcoll/scattering_routines/geometry/rotation.h +23 -0
  332. xcoll/scattering_routines/geometry/segments.h +226 -0
  333. xcoll/scattering_routines/geometry/sort.h +184 -0
  334. {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/METADATA +1 -1
  335. xcoll-0.5.0.dist-info/RECORD +413 -0
  336. xcoll/beam_elements/collimators_src/absorber.h +0 -141
  337. xcoll/beam_elements/collimators_src/everest_collimator.h +0 -142
  338. xcoll/beam_elements/collimators_src/everest_crystal.h +0 -115
  339. xcoll/collimator_settings.py +0 -457
  340. xcoll/impacts/__init__.py +0 -1
  341. xcoll/impacts/impacts.py +0 -102
  342. xcoll/impacts/impacts_src/impacts.h +0 -99
  343. xcoll/scattering_routines/everest/crystal.h +0 -1302
  344. xcoll/scattering_routines/everest/scatter.h +0 -169
  345. xcoll/scattering_routines/everest/scatter_crystal.h +0 -260
  346. xcoll/scattering_routines/fluka/build_fluka_input.py +0 -58
  347. xcoll-0.3.6.dist-info/RECORD +0 -111
  348. {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/LICENSE +0 -0
  349. {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/NOTICE +0 -0
  350. {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,298 @@
1
+ # copyright ############################### #
2
+ # This file is part of the Xcoll Package. #
3
+ # Copyright (c) CERN, 2024. #
4
+ # ######################################### #
5
+
6
+ import xobjects as xo
7
+ import xtrack as xt
8
+
9
+ from .interaction_types import source, interactions, shortcuts, is_point
10
+ from ..general import _pkg_root
11
+
12
+ import numpy as np
13
+ import pandas as pd
14
+
15
+
16
+ class InteractionRecord(xt.BeamElement):
17
+ _xofields = {
18
+ '_index': xt.RecordIndex,
19
+ 'at_element': xo.Int64[:],
20
+ 'at_turn': xo.Int64[:],
21
+ '_inter': xo.Int64[:],
22
+ 'id_before': xo.Int64[:],
23
+ 's_before': xo.Float64[:],
24
+ 'x_before': xo.Float64[:],
25
+ 'px_before': xo.Float64[:],
26
+ 'y_before': xo.Float64[:],
27
+ 'py_before': xo.Float64[:],
28
+ 'zeta_before': xo.Float64[:],
29
+ 'delta_before': xo.Float64[:],
30
+ 'energy_before': xo.Float64[:],
31
+ 'mass_before': xo.Float64[:],
32
+ 'charge_before': xo.Int64[:],
33
+ 'z_before': xo.Int64[:],
34
+ 'a_before': xo.Int64[:],
35
+ 'pdgid_before': xo.Int64[:],
36
+ 'id_after': xo.Int64[:],
37
+ 's_after': xo.Float64[:],
38
+ 'x_after': xo.Float64[:],
39
+ 'px_after': xo.Float64[:],
40
+ 'y_after': xo.Float64[:],
41
+ 'py_after': xo.Float64[:],
42
+ 'zeta_after': xo.Float64[:],
43
+ 'delta_after': xo.Float64[:],
44
+ 'energy_after': xo.Float64[:],
45
+ 'mass_after': xo.Float64[:],
46
+ 'charge_after': xo.Int64[:],
47
+ 'z_after': xo.Int64[:],
48
+ 'a_after': xo.Int64[:],
49
+ 'pdgid_after': xo.Int64[:],
50
+ }
51
+
52
+ allow_track = False
53
+
54
+ _extra_c_sources = [
55
+ source,
56
+ _pkg_root.joinpath('headers','particle_states.h'),
57
+ _pkg_root.joinpath('interaction_record','interaction_record_src','interaction_record.h')
58
+ ]
59
+
60
+
61
+ @classmethod
62
+ def start(cls, *, line=None, elements=None, names=None, record_impacts=None, record_exits=None,
63
+ record_scatterings=None, capacity=1e6, io_buffer=None, coll_ids=None):
64
+ elements, names = _get_xcoll_elements(line, elements, names)
65
+ if len(names) == 0:
66
+ return
67
+ capacity = int(capacity)
68
+
69
+ if getattr(line, 'tracker', None) is None \
70
+ or getattr(line.tracker, 'io_buffer', None) is None:
71
+ if io_buffer is None:
72
+ io_buffer = xt.new_io_buffer(capacity=capacity)
73
+ elif io_buffer is not None:
74
+ raise ValueError("Cannot provide io_buffer when tracker already built!")
75
+ else:
76
+ io_buffer = line.tracker.io_buffer
77
+ if capacity > io_buffer.capacity:
78
+ io_buffer.grow(capacity - io_buffer.capacity)
79
+ if record_impacts is None and record_scatterings is None:
80
+ record_impacts = True
81
+ record_scatterings = True
82
+ elif record_impacts is None:
83
+ record_impacts = not record_scatterings
84
+ elif record_scatterings is None:
85
+ record_scatterings = not record_impacts
86
+ if record_exits is None:
87
+ # record_exits defaults to True only if the other two are True
88
+ record_exits = record_impacts and record_scatterings
89
+ assert record_impacts is True or record_impacts is False
90
+ assert record_exits is True or record_exits is False
91
+ assert record_scatterings is True or record_scatterings is False
92
+ for el in elements:
93
+ if not el.record_impacts and not el.record_exits and not el.record_scatterings:
94
+ el.record_impacts = record_impacts
95
+ el.record_exits = record_exits
96
+ el.record_scatterings = record_scatterings
97
+ record = xt.start_internal_logging(io_buffer=io_buffer, capacity=capacity, \
98
+ elements=elements)
99
+ record._line = line
100
+ record._io_buffer = io_buffer
101
+ recording_elements = names if len(names) > 0 else elements
102
+ record._recording_elements = recording_elements
103
+ if coll_ids is None:
104
+ if line is None:
105
+ if len(names) > 0:
106
+ record._coll_ids = {name: idx for idx, name in enumerate(names)}
107
+ else:
108
+ record._coll_ids = {name: line.element_names.index(name) for name in names}
109
+ else:
110
+ assert len(coll_ids) == len(names)
111
+ record._coll_ids = {name: idx for name, idx in zip(names, coll_ids)}
112
+ if hasattr(record, '_coll_ids'):
113
+ record._coll_names = {vv: kk for kk, vv in record._coll_ids.items()}
114
+ return record
115
+
116
+ def stop(self, *, elements=False, names=False):
117
+ self.assert_class_init()
118
+ elements, names = _get_xcoll_elements(self.line, elements, names)
119
+ if self.line is not None and self.line.tracker is not None:
120
+ self.line.tracker._check_invalidated()
121
+ xt.stop_internal_logging(elements=elements)
122
+ # Removed the stopped collimators from list of logged elements
123
+ stopping_elements = names if len(names) > 0 else elements
124
+ self._recording_elements = list(set(self._recording_elements) - set(stopping_elements))
125
+
126
+
127
+ def assert_class_init(self):
128
+ if not hasattr(self, '_io_buffer') or not hasattr(self, '_line') \
129
+ or not hasattr(self, '_recording_elements'):
130
+ raise ValueError("This InteractionRecord has been manually instantiated, "
131
+ + "hence the expanded API is not available. Use "
132
+ + "InteractionRecord.start() to initialise with extended API.")
133
+
134
+ @property
135
+ def line(self):
136
+ if hasattr(self, '_line'):
137
+ return self._line
138
+
139
+ @property
140
+ def io_buffer(self):
141
+ if hasattr(self, '_io_buffer'):
142
+ return self._io_buffer
143
+
144
+ @property
145
+ def capacity(self):
146
+ if hasattr(self, '_io_buffer'):
147
+ return self.io_buffer.capacity
148
+
149
+ # @capacity.setter
150
+ # def capacity(self, val):
151
+ # if hasattr(self, '_io_buffer'):
152
+ # capacity = int(capacity)
153
+ # if capacity < self.capacity:
154
+ # raise NotImplementedError("Shrinking of capacity not yet implemented!")
155
+ # elif capacity == self.capacity:
156
+ # return
157
+ # else:
158
+ # self.io_buffer.grow(capacity - self.capacity)
159
+ # # TODO: increase capacity of iobuffer AND of fields in record table
160
+
161
+ @property
162
+ def recording_elements(self):
163
+ if hasattr(self, '_recording_elements'):
164
+ return self._recording_elements
165
+
166
+ @recording_elements.setter
167
+ def recording_elements(self, val):
168
+ self.assert_class_init()
169
+ if val is None:
170
+ val = []
171
+ record_start = _get_xcoll_elements(self.line, val)
172
+ self.stop(set(self.recording_elements) - set(record_start))
173
+ elements = [self.line[name] for name in record_start]
174
+ for el in elements: # TODO: this should be smarter
175
+ if not el.record_impacts and not el.record_scatterings:
176
+ el.record_impacts = True
177
+ el.record_scatterings = True
178
+ xt.start_internal_logging(io_buffer=self.io_buffer, capacity=self.capacity, \
179
+ record=self, elements=elements)
180
+ self._recording_elements = record_start
181
+ # Updating coll IDs: careful to correctly overwrite existing values
182
+ self._coll_ids.update({name: self.line.element_names.index(name) for name in record_start})
183
+ self._coll_names = {vv: kk for kk, vv in self._coll_ids.items()}
184
+
185
+ @property
186
+ def interaction_type(self):
187
+ return np.array([interactions[inter] for inter in self._inter])
188
+
189
+ def _collimator_name(self, element_id):
190
+ if not hasattr(self, '_coll_names'):
191
+ return element_id
192
+ elif element_id not in self._coll_names:
193
+ raise ValueError(f"Element {element_id} not found in list of collimators of this record table! "
194
+ + f"Did the line change without updating the list in the table?")
195
+ else:
196
+ return self._coll_names[element_id]
197
+
198
+ def _collimator_id(self, element_name):
199
+ if not hasattr(self, '_coll_ids'):
200
+ return element_name
201
+ elif element_name not in self._coll_ids:
202
+ raise ValueError(f"Element {element_name} not found in list of collimators of this record table! "
203
+ + f"Did the line change without updating the list in the table?")
204
+ else:
205
+ return self._coll_ids[element_name]
206
+
207
+ def to_pandas(self, frame=None):
208
+ if frame is None:
209
+ frame = 'jaw'
210
+ frame = frame.lower()
211
+ if frame not in ['jaw', 'collimator', 'lab']:
212
+ raise ValueError(f"Invalid frame {frame}. Must be 'jaw', 'collimator', or 'lab'!")
213
+ n_rows = self._index.num_recorded
214
+ coll_header = 'collimator' if hasattr(self, '_coll_names') else 'collimator_id'
215
+ df = pd.DataFrame({
216
+ 'turn': self.at_turn[:n_rows],
217
+ coll_header: [self._collimator_name(element_id) for element_id in self.at_element[:n_rows]],
218
+ 'interaction_type': [interactions[inter] for inter in self._inter[:n_rows]],
219
+ **{
220
+ f'{val}_{p}': getattr(self, f'{val}_{p}')[:n_rows]
221
+ for p in ['before', 'after']
222
+ for val in ['id', 's', 'x', 'px', 'y', 'py', 'zeta', 'delta', 'energy', 'mass', 'charge', 'z', 'a', 'pdgid']
223
+ }
224
+ })
225
+ return df
226
+
227
+ # TODO: list of impacted collimators
228
+
229
+
230
+ # TODO: does not work when multiple children
231
+ def interactions_per_collimator(self, collimator=0, *, turn=None):
232
+ if isinstance(collimator, str):
233
+ collimator = self._collimator_id(collimator)
234
+ mask = (self._inter > 0) & (self.at_element == collimator)
235
+ if turn is not None:
236
+ mask = mask & (self.at_turn == turn)
237
+ df = pd.DataFrame({
238
+ 'int': [shortcuts[inter] for inter in self._inter[mask]],
239
+ 'pid': self.id_before[mask]
240
+ })
241
+ return df.groupby('pid', sort=False)['int'].agg(list)
242
+ else:
243
+ df = pd.DataFrame({
244
+ 'int': [shortcuts[inter] for inter in self._inter[mask]],
245
+ 'turn': self.at_turn[mask],
246
+ 'pid': self.id_before[mask]
247
+ })
248
+ return df.groupby(['pid', 'turn'], sort=False)['int'].apply(list)
249
+
250
+ def first_touch_per_turn(self, frame=None):
251
+ n_rows = self._index.num_recorded
252
+ df = pd.DataFrame({'id_before': self.id_before[:n_rows],
253
+ 'at_turn': self.at_turn[:n_rows],
254
+ 'at_element': self.at_element[:n_rows]})
255
+ mask = np.char.startswith(self.interaction_type[:n_rows], 'Enter Jaw')
256
+ idx_first = [group.at_element.idxmin() for _, group in df[mask].groupby(['at_turn', 'id_before'], sort=False)]
257
+ df_first = self.to_pandas(frame=frame).loc[idx_first]
258
+ df_first.insert(2, "jaw", df_first.interaction_type.astype(str).str[-1])
259
+ to_drop = ['interaction_type',
260
+ *[col for col in df_first.columns if col.endswith('_after')]]
261
+ to_rename = {col: col.replace('_before', '') for col in df_first.columns if col.endswith('before')}
262
+ to_rename['id_before'] = 'pid'
263
+ return df_first.drop(columns=to_drop).rename(columns=to_rename)
264
+
265
+
266
+ def _get_xcoll_elements(line=None, elements=None, names=None):
267
+ from xcoll import element_classes
268
+ if names is not None and names is not False and \
269
+ (not hasattr(names, '__iter__') or isinstance(names, str)):
270
+ names = [names]
271
+ if elements is not None and elements is not False and \
272
+ (not hasattr(elements, '__iter__') or isinstance(elements, str)):
273
+ elements = [elements]
274
+ if line is None:
275
+ if elements is None:
276
+ raise ValueError("No line nor elements provided!")
277
+ else:
278
+ if elements is not None and elements is not False:
279
+ raise ValueError("Cannot provide both line and elements!")
280
+ if names is None or names is True:
281
+ elements, names = line.get_elements_of_type(element_classes)
282
+ if len(names) == 0:
283
+ raise ValueError("No Xcoll elements in line!")
284
+ elif names is False:
285
+ names = []
286
+ elements = []
287
+ else:
288
+ assert elements is not False
289
+ for name in names:
290
+ if name not in line.element_names:
291
+ raise ValueError(f"Element {name} not found in line!")
292
+ elements = [line[name] for name in names]
293
+ for idx, element in enumerate(elements):
294
+ if not isinstance(element, element_classes):
295
+ name = name[idx] if names is not None else element.__class__.__name__
296
+ raise ValueError(f"Element {name} not an Xcoll element!")
297
+ return elements, names
298
+
@@ -0,0 +1,98 @@
1
+ // copyright ############################### #
2
+ // This file is part of the Xcoll Package. #
3
+ // Copyright (c) CERN, 2024. #
4
+ // ######################################### #
5
+
6
+
7
+ #ifndef XCOLL_IMPACTS_H
8
+ #define XCOLL_IMPACTS_H
9
+
10
+ // TODO: do we need to pass RecordIndex?
11
+ // probably can do RecordIndex record_index = InteractionRecordData_getp__index(record); ?
12
+ /*gpufun*/
13
+ int64_t InteractionRecordData_log(InteractionRecordData record, RecordIndex record_index, LocalParticle* parent,
14
+ int64_t interaction){
15
+ // This can be used for a point-like interaction where there is no child (or because it's equal to the parent)
16
+ // or to log the parent first, to be followed up with InteractionRecordData_log_child on the same slot
17
+
18
+ int64_t i_slot = -1;
19
+ if (record){
20
+ // Get a slot in the record (this is thread safe)
21
+ i_slot = RecordIndex_get_slot(record_index);
22
+ // The returned slot id is negative if record is NULL or if record is full
23
+
24
+ if (i_slot>=0){
25
+ InteractionRecordData_set_at_element(record, i_slot, LocalParticle_get_at_element(parent));
26
+ InteractionRecordData_set_at_turn(record, i_slot, LocalParticle_get_at_turn(parent));
27
+ InteractionRecordData_set__inter(record, i_slot, interaction);
28
+
29
+ double charge_ratio = LocalParticle_get_charge_ratio(parent);
30
+ double mass_ratio = charge_ratio / LocalParticle_get_chi(parent);
31
+ double energy = ( LocalParticle_get_ptau(parent) + 1 / LocalParticle_get_beta0(parent)
32
+ ) * mass_ratio * LocalParticle_get_p0c(parent);
33
+ // All fields have to be written, or the arrays will not have the same length
34
+ // TODO: maybe this is not true, as we are setting by slot index? Don't the arrays come pre-initialised?
35
+ InteractionRecordData_set_id_before(record, i_slot, LocalParticle_get_particle_id(parent));
36
+ InteractionRecordData_set_s_before(record, i_slot, LocalParticle_get_s(parent));
37
+ InteractionRecordData_set_x_before(record, i_slot, LocalParticle_get_x(parent));
38
+ InteractionRecordData_set_px_before(record, i_slot, LocalParticle_get_px(parent));
39
+ InteractionRecordData_set_y_before(record, i_slot, LocalParticle_get_y(parent));
40
+ InteractionRecordData_set_py_before(record, i_slot, LocalParticle_get_py(parent));
41
+ InteractionRecordData_set_zeta_before(record, i_slot, LocalParticle_get_zeta(parent));
42
+ InteractionRecordData_set_delta_before(record, i_slot, LocalParticle_get_delta(parent));
43
+ InteractionRecordData_set_energy_before(record, i_slot, energy);
44
+ InteractionRecordData_set_mass_before(record, i_slot, mass_ratio*LocalParticle_get_mass0(parent));
45
+ InteractionRecordData_set_charge_before(record, i_slot, charge_ratio*LocalParticle_get_q0(parent));
46
+ // TODO: particle info
47
+ InteractionRecordData_set_z_before(record, i_slot, -1);
48
+ InteractionRecordData_set_a_before(record, i_slot, -1);
49
+ InteractionRecordData_set_pdgid_before(record, i_slot, -1);
50
+
51
+ // TODO: maybe this is not needed
52
+ InteractionRecordData_set_id_after(record, i_slot, -1);
53
+ InteractionRecordData_set_s_after(record, i_slot, -1);
54
+ InteractionRecordData_set_x_after(record, i_slot, -1);
55
+ InteractionRecordData_set_px_after(record, i_slot, -1);
56
+ InteractionRecordData_set_y_after(record, i_slot, -1);
57
+ InteractionRecordData_set_py_after(record, i_slot, -1);
58
+ InteractionRecordData_set_zeta_after(record, i_slot, -1);
59
+ InteractionRecordData_set_delta_after(record, i_slot, -1);
60
+ InteractionRecordData_set_energy_after(record, i_slot, -1);
61
+ InteractionRecordData_set_mass_after(record, i_slot, -1);
62
+ InteractionRecordData_set_charge_after(record, i_slot, -1);
63
+ InteractionRecordData_set_z_after(record, i_slot, -1);
64
+ InteractionRecordData_set_a_after(record, i_slot, -1);
65
+ InteractionRecordData_set_pdgid_after(record, i_slot, -1);
66
+ }
67
+ }
68
+ // printf("Logging %i in slot %i\n", interaction, i_slot);
69
+ return i_slot;
70
+ }
71
+
72
+ /*gpufun*/
73
+ void InteractionRecordData_log_child(InteractionRecordData record, int64_t i_slot, LocalParticle* child){
74
+ if (record && i_slot>=0){
75
+ double charge_ratio = LocalParticle_get_charge_ratio(child);
76
+ double mass_ratio = charge_ratio / LocalParticle_get_chi(child);
77
+ double energy = ( LocalParticle_get_ptau(child) + 1 / LocalParticle_get_beta0(child)
78
+ ) * mass_ratio * LocalParticle_get_p0c(child);
79
+ InteractionRecordData_set_id_after(record, i_slot, LocalParticle_get_particle_id(child));
80
+ InteractionRecordData_set_s_after(record, i_slot, LocalParticle_get_s(child));
81
+ InteractionRecordData_set_x_after(record, i_slot, LocalParticle_get_x(child));
82
+ InteractionRecordData_set_px_after(record, i_slot, LocalParticle_get_px(child));
83
+ InteractionRecordData_set_y_after(record, i_slot, LocalParticle_get_y(child));
84
+ InteractionRecordData_set_py_after(record, i_slot, LocalParticle_get_py(child));
85
+ InteractionRecordData_set_zeta_after(record, i_slot, LocalParticle_get_zeta(child));
86
+ InteractionRecordData_set_delta_after(record, i_slot, LocalParticle_get_delta(child));
87
+ InteractionRecordData_set_energy_after(record, i_slot, energy);
88
+ InteractionRecordData_set_mass_after(record, i_slot, mass_ratio*LocalParticle_get_mass0(child));
89
+ InteractionRecordData_set_charge_after(record, i_slot, charge_ratio*LocalParticle_get_q0(child));
90
+ // TODO: particle info
91
+ InteractionRecordData_set_z_after(record, i_slot, -1);
92
+ InteractionRecordData_set_a_after(record, i_slot, -1);
93
+ InteractionRecordData_set_pdgid_after(record, i_slot, -1);
94
+ // printf("Slot %i: length %f\n", i_slot, ds);
95
+ }
96
+ }
97
+
98
+ #endif /* XCOLL_IMPACTS_H */
@@ -1,6 +1,6 @@
1
1
  # copyright ############################### #
2
2
  # This file is part of the Xcoll Package. #
3
- # Copyright (c) CERN, 2023. #
3
+ # Copyright (c) CERN, 2024. #
4
4
  # ######################################### #
5
5
 
6
6
 
@@ -10,15 +10,16 @@ source = r'''
10
10
 
11
11
  #define XC_UNITIALISED 0 // NAN // Do not use
12
12
 
13
- #define XC_ENTER_JAW -1 // JI // point (no children) Set ds > 0 if entering later
14
- #define XC_EXIT_JAW -2 // JO // point (no children)
13
+ #define XC_ENTER_JAW_L -1 // JI // point (no children) Set ds > 0 if entering later
14
+ #define XC_ENTER_JAW_R -2 // JI // point (no children) Set ds > 0 if entering later
15
+ #define XC_EXIT_JAW -3 // JO // point (no children)
16
+ #define XC_ENTER_JAW -4 // JI // point (no children) Set ds > 0 if entering later still here for compatibility
15
17
  #define XC_ABSORBED 1 // A // point (no children) Don't use 0 (is default for unitialised)
16
18
  #define XC_MULTIPLE_COULOMB_SCATTERING 13 // MCS // continuous
17
19
  #define XC_PN_ELASTIC 14 // PN // point (no children)
18
20
  #define XC_PP_ELASTIC 15 // PP // point (no children)
19
21
  #define XC_SINGLE_DIFFRACTIVE 16 // SD // point (no children)
20
22
  #define XC_COULOMB 17 // C // point (no children)
21
- #define XC_RUTHERFORD 18 // RU // point (no children)
22
23
  #define XC_CHANNELING 100 // CH // continuous
23
24
  #define XC_DECHANNELING 101 // DCH // point (no children)
24
25
  #define XC_VOLUME_REFLECTION_TRANS_CH 102 // VRCH // point (no children) Transition region around +-xpcrit
@@ -43,3 +44,9 @@ shortcuts = {
43
44
  for line in source.split('\n')
44
45
  if len(line.split()) > 1 and line.split()[1][:3] == 'XC_' # select the source lines with the definitions
45
46
  }
47
+
48
+ is_point = {
49
+ int(line.split()[2]): line.split()[6].lower() == 'point'
50
+ for line in source.split('\n')
51
+ if len(line.split()) > 1 and line.split()[1][:3] == 'XC_' # select the source lines with the definitions
52
+ }
xcoll/line_tools.py ADDED
@@ -0,0 +1,82 @@
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, _all_collimator_classes
10
+
11
+
12
+ def assign_optics_to_collimators(line, nemitt_x=None, nemitt_y=None, twiss=None):
13
+ if not line._has_valid_tracker():
14
+ raise Exception("Please build tracker before setting the openings!")
15
+ names = line.get_elements_of_type(_all_collimator_classes)[1]
16
+ tw_upstream, tw_downstream = get_optics_at(names, twiss=twiss, line=line)
17
+ beta_gamma_rel = line.particle_ref._xobject.gamma0[0]*line.particle_ref._xobject.beta0[0]
18
+ for coll in names:
19
+ line[coll].assign_optics(name=coll, nemitt_x=nemitt_x, nemitt_y=nemitt_x, twiss_upstream=tw_upstream,
20
+ twiss_downstream=tw_downstream, beta_gamma_rel=beta_gamma_rel)
21
+
22
+ def get_optics_at(names, *, twiss=None, line=None):
23
+ if twiss is None:
24
+ if not line._has_valid_tracker():
25
+ raise Exception("Please pass a line and build tracker before computing the optics for the openings!")
26
+ twiss = line.twiss()
27
+ if not hasattr(names, '__iter__') and not isinstance(names, str):
28
+ names = [names]
29
+ coll_entry_mask = twiss.mask[names]
30
+ tw_entry = twiss.rows[coll_entry_mask]
31
+ tw_exit = twiss.rows[coll_entry_mask+1]
32
+ tw_exit.name = tw_entry.name
33
+ return tw_entry, tw_exit
34
+
35
+
36
+ def open_collimators(line, names=None):
37
+ if names is None:
38
+ names = line.get_elements_of_type(_all_collimator_classes)[1]
39
+ if len(names) == 0:
40
+ print("No collimators found in line.")
41
+ else:
42
+ for coll in names:
43
+ line[coll].open_jaws(keep_tilts=False)
44
+ line[coll].gap = None
45
+
46
+ def send_to_parking(line, names=None):
47
+ if names is None:
48
+ names = line.get_elements_of_type(_all_collimator_classes)[1]
49
+ if len(names) == 0:
50
+ print("No collimators found in line.")
51
+ else:
52
+ raise NotImplementedError("Need to move this to new type manager or so.")
53
+
54
+
55
+ def enable_scattering(line):
56
+ elements = line.get_elements_of_type(element_classes)[0]
57
+ if len(elements) == 0:
58
+ print("No xcoll elements found in line.")
59
+ else:
60
+ nemitt_x = None
61
+ nemitt_y = None
62
+ for el in elements:
63
+ if hasattr(el, 'optics') and el.optics is not None:
64
+ if nemitt_x is None:
65
+ nemitt_x = el.nemitt_x
66
+ if nemitt_y is None:
67
+ nemitt_y = el.nemitt_y
68
+ if not np.isclose(el.nemitt_x, nemitt_x) \
69
+ or not np.isclose(el.nemitt_x, nemitt_x):
70
+ raise ValueError("Not all collimators have the same "
71
+ + "emittance. This is not supported.")
72
+ if hasattr(el, 'enable_scattering'):
73
+ el.enable_scattering()
74
+
75
+ def disable_scattering(line):
76
+ elements = line.get_elements_of_type(element_classes)[0]
77
+ if len(elements) == 0:
78
+ print("No xcoll elements found in line.")
79
+ else:
80
+ for el in elements:
81
+ if hasattr(el, 'disable_scattering'):
82
+ el.disable_scattering()