xcoll 0.5.12__py3-none-any.whl → 0.6.1__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 (336) hide show
  1. xcoll/__init__.py +5 -18
  2. xcoll/__init__.py.orig +26 -0
  3. xcoll/beam_elements/__init__.py +1 -0
  4. xcoll/beam_elements/absorber.py +12 -2
  5. xcoll/beam_elements/base.py +162 -62
  6. xcoll/beam_elements/blowup.py +1 -0
  7. xcoll/beam_elements/elements_src/black_absorber.h +57 -58
  8. xcoll/beam_elements/elements_src/black_crystal.h +49 -50
  9. xcoll/beam_elements/elements_src/everest_block.h +21 -11
  10. xcoll/beam_elements/elements_src/everest_collimator.h +100 -91
  11. xcoll/beam_elements/elements_src/everest_crystal.h +145 -140
  12. xcoll/beam_elements/elements_src/transparent_collimator.h +126 -0
  13. xcoll/beam_elements/elements_src/transparent_crystal.h +118 -0
  14. xcoll/beam_elements/everest.py +16 -5
  15. xcoll/beam_elements/monitor.py +1 -0
  16. xcoll/beam_elements/transparent.py +83 -0
  17. xcoll/colldb.py +15 -6
  18. xcoll/general.py +1 -1
  19. xcoll/general.py.orig +20 -0
  20. xcoll/headers/particle_states.py +51 -0
  21. xcoll/initial_distribution.py +121 -91
  22. xcoll/initial_distribution.py.orig +256 -0
  23. xcoll/interaction_record/interaction_record.py +2 -1
  24. xcoll/interaction_record/interaction_types.py +2 -2
  25. xcoll/line_tools.py +163 -73
  26. xcoll/lossmap.py +519 -127
  27. xcoll/plot.py +109 -0
  28. xcoll/rf_sweep.py +6 -0
  29. xcoll/scattering_routines/engine.py +414 -217
  30. xcoll/scattering_routines/environment.py +297 -0
  31. xcoll/scattering_routines/everest/amorphous.h +95 -71
  32. xcoll/scattering_routines/everest/{channeling.h → channelling.h} +121 -112
  33. xcoll/scattering_routines/everest/constants.h +1 -1
  34. xcoll/scattering_routines/everest/crystal_parameters.h +9 -9
  35. xcoll/scattering_routines/everest/everest.h +8 -3
  36. xcoll/scattering_routines/everest/everest.py +2 -1
  37. xcoll/scattering_routines/everest/ionisation_loss.h +141 -0
  38. xcoll/scattering_routines/everest/jaw.h +19 -24
  39. xcoll/scattering_routines/everest/materials.py +2 -0
  40. xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
  41. xcoll/scattering_routines/everest/nuclear_interaction.h +35 -19
  42. xcoll/scattering_routines/everest/properties.h +3 -72
  43. xcoll/xaux.py +65 -109
  44. {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/METADATA +5 -5
  45. xcoll-0.6.1.dist-info/RECORD +138 -0
  46. xcoll/_manager.py +0 -22
  47. xcoll/headers/particle_states.h +0 -25
  48. xcoll/install.py +0 -35
  49. xcoll/scattering_routines/geant4/collimasim/.git +0 -1
  50. xcoll/scattering_routines/geant4/collimasim/.gitignore +0 -12
  51. xcoll/scattering_routines/geant4/collimasim/.gitmodules +0 -3
  52. xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +0 -26
  53. xcoll/scattering_routines/geant4/collimasim/README.md +0 -21
  54. xcoll/scattering_routines/geant4/collimasim/docs/Makefile +0 -20
  55. xcoll/scattering_routines/geant4/collimasim/docs/make.bat +0 -35
  56. xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +0 -10
  57. xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +0 -59
  58. xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +0 -26
  59. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +0 -37
  60. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +0 -19
  61. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +0 -65
  62. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +0 -73
  63. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +0 -1
  64. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +0 -9
  65. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +0 -386
  66. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +0 -45
  67. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +0 -8
  68. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +0 -16
  69. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +0 -8
  70. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +0 -3
  71. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +0 -19
  72. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +0 -969
  73. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +0 -84
  74. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +0 -48
  75. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +0 -16
  76. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +0 -103
  77. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +0 -45
  78. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +0 -151
  79. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +0 -3
  80. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +0 -297
  81. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +0 -29
  82. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +0 -6
  83. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +0 -180
  84. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +0 -23
  85. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +0 -192
  86. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +0 -11
  87. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +0 -81
  88. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +0 -93
  89. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +0 -310
  90. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +0 -109
  91. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +0 -43
  92. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +0 -171
  93. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +0 -251
  94. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +0 -305
  95. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +0 -1297
  96. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +0 -262
  97. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +0 -396
  98. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +0 -568
  99. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +0 -337
  100. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +0 -13
  101. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +0 -463
  102. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +0 -286
  103. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +0 -155
  104. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +0 -174
  105. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +0 -308
  106. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +0 -91
  107. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +0 -95
  108. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +0 -2050
  109. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +0 -542
  110. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +0 -8
  111. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +0 -648
  112. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +0 -381
  113. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +0 -343
  114. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +0 -48
  115. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +0 -105
  116. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +0 -72
  117. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
  118. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
  119. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +0 -427
  120. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
  121. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +0 -427
  122. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +0 -130
  123. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +0 -96
  124. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +0 -8
  125. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +0 -548
  126. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +0 -605
  127. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +0 -144
  128. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +0 -1432
  129. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +0 -213
  130. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +0 -2
  131. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +0 -65
  132. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +0 -709
  133. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +0 -1021
  134. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +0 -104
  135. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +0 -346
  136. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +0 -467
  137. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +0 -978
  138. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +0 -55
  139. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +0 -606
  140. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +0 -284
  141. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +0 -163
  142. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +0 -121
  143. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +0 -193
  144. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +0 -275
  145. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +0 -1741
  146. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +0 -163
  147. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +0 -65
  148. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +0 -2497
  149. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +0 -1879
  150. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +0 -103
  151. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +0 -375
  152. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +0 -747
  153. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +0 -88
  154. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +0 -11
  155. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +0 -52
  156. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +0 -12
  157. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +0 -6
  158. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +0 -21
  159. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
  160. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +0 -482
  161. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +0 -63
  162. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +0 -41
  163. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +0 -56
  164. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +0 -155
  165. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +0 -503
  166. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +0 -208
  167. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +0 -275
  168. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +0 -73
  169. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +0 -33
  170. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
  171. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +0 -279
  172. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
  173. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +0 -143
  174. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +0 -85
  175. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +0 -179
  176. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +0 -151
  177. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +0 -91
  178. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +0 -85
  179. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +0 -19
  180. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +0 -12
  181. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +0 -26
  182. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +0 -25
  183. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +0 -216
  184. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +0 -163
  185. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +0 -286
  186. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +0 -536
  187. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +0 -107
  188. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +0 -248
  189. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +0 -227
  190. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +0 -202
  191. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +0 -84
  192. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +0 -210
  193. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +0 -550
  194. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +0 -473
  195. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +0 -84
  196. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +0 -21
  197. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +0 -28
  198. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +0 -39
  199. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +0 -46
  200. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +0 -6
  201. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +0 -41
  202. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +0 -35
  203. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +0 -41
  204. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +0 -10
  205. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +0 -165
  206. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +0 -53
  207. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +0 -238
  208. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +0 -126
  209. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +0 -141
  210. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +0 -117
  211. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +0 -41
  212. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +0 -50
  213. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +0 -69
  214. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +0 -42
  215. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +0 -348
  216. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +0 -771
  217. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +0 -47
  218. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +0 -22
  219. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +0 -23
  220. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +0 -326
  221. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +0 -15
  222. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +0 -148
  223. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +0 -272
  224. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +0 -119
  225. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +0 -51
  226. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +0 -5
  227. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +0 -285
  228. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +0 -12
  229. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +0 -265
  230. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +0 -397
  231. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +0 -520
  232. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +0 -49
  233. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +0 -94
  234. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +0 -125
  235. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +0 -331
  236. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +0 -153
  237. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +0 -284
  238. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +0 -107
  239. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +0 -257
  240. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +0 -412
  241. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +0 -517
  242. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +0 -102
  243. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +0 -92
  244. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +0 -233
  245. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +0 -360
  246. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +0 -472
  247. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +0 -593
  248. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +0 -524
  249. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +0 -441
  250. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +0 -103
  251. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +0 -267
  252. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +0 -73
  253. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +0 -59
  254. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +0 -235
  255. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +0 -146
  256. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +0 -189
  257. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +0 -82
  258. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +0 -560
  259. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +0 -651
  260. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +0 -500
  261. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +0 -253
  262. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +0 -452
  263. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +0 -318
  264. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +0 -342
  265. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +0 -291
  266. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +0 -131
  267. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +0 -318
  268. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +0 -144
  269. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +0 -29
  270. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +0 -66
  271. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +0 -44
  272. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +0 -22
  273. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +0 -9
  274. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +0 -510
  275. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +0 -408
  276. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +0 -140
  277. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +0 -117
  278. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +0 -70
  279. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +0 -86
  280. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +0 -257
  281. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +0 -44
  282. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +0 -23
  283. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +0 -39
  284. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +0 -64
  285. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +0 -402
  286. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +0 -233
  287. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +0 -276
  288. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +0 -214
  289. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +0 -3
  290. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +0 -65
  291. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +0 -41
  292. xcoll/scattering_routines/geant4/collimasim/pyproject.toml +0 -8
  293. xcoll/scattering_routines/geant4/collimasim/setup.py +0 -144
  294. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +0 -403
  295. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +0 -100
  296. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +0 -763
  297. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +0 -118
  298. xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +0 -8
  299. xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +0 -63
  300. xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +0 -142
  301. xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +0 -556
  302. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +0 -6
  303. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +0 -24
  304. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +0 -1
  305. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +0 -1
  306. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +0 -1
  307. xcoll/scattering_routines/geant4/collimasim/tests/README.md +0 -25
  308. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +0 -25
  309. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +0 -18
  310. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +0 -68
  311. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +0 -15
  312. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +0 -110
  313. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +0 -7
  314. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +0 -3
  315. xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +0 -54
  316. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +0 -3
  317. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +0 -3
  318. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +0 -5
  319. xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +0 -51
  320. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +0 -65
  321. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +0 -59
  322. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +0 -102
  323. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +0 -75
  324. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +0 -74
  325. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +0 -84
  326. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +0 -159
  327. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +0 -99
  328. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +0 -78
  329. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +0 -88
  330. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +0 -80
  331. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +0 -97
  332. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +0 -96
  333. xcoll-0.5.12.dist-info/RECORD +0 -415
  334. {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/LICENSE +0 -0
  335. {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/NOTICE +0 -0
  336. {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/WHEEL +0 -0
@@ -1,556 +0,0 @@
1
- import re
2
- import io
3
- import sys
4
- import numpy as np
5
- import warnings
6
- import json
7
-
8
- import pandas as pd
9
-
10
- import xtrack as xt
11
- import collimasim as cs
12
-
13
- import subprocess
14
-
15
- from enum import Enum, unique
16
- from pathlib import Path
17
-
18
- from contextlib import redirect_stdout, redirect_stderr, contextmanager
19
-
20
- @unique
21
- class MissingCollimatorAction(Enum):
22
- ERROR = "error"
23
- WARN = "warn"
24
- SKIP = "skip"
25
-
26
-
27
- # Suppress some pandas warning that do not apply to the use case at hand
28
- pd.options.mode.chained_assignment = None
29
-
30
-
31
- def _calc_betagamma(E0, E):
32
- gamma = float(E)/E0
33
- beta = np.sqrt(1.-(1./gamma)**2)
34
-
35
- return beta*gamma
36
-
37
-
38
- def _norm_to_geom_emittance(norm_emittance, E0, E):
39
- betagamma = _calc_betagamma(E0, E)
40
- return norm_emittance / betagamma
41
-
42
-
43
- def _geom_to_norm_emittance(geom_emittance, E0, E):
44
- betagamma = _calc_betagamma(E0, E)
45
- return betagamma * geom_emittance
46
-
47
-
48
- def _get_twiss_header(tfsfile):
49
- header = None
50
- line_no = 0
51
- with open(tfsfile, "r") as filein:
52
- for idx, line in enumerate(filein):
53
- if line.startswith("*"): # This is the header line, preamble lines start with @
54
- header = line.replace("*", "").strip().split() # Strip the comment char
55
- line_no = idx + 1 # As zero counted
56
- break # End the loop early - information found
57
-
58
- return header, line_no
59
-
60
-
61
- def _load_collimators_tfs(tfsfile):
62
- header, header_line_no = _get_twiss_header(tfsfile)
63
-
64
- required_columns = {"KEYWORD", "NAME", "BETX", "BETY", "ALFX", "ALFY", "DX", "DY", "X", "Y", "PT"}
65
-
66
- if not required_columns.issubset(set(required_columns)):
67
- raise KeyError("The required columns in the MAD-X"
68
- " TFS file are: {}".format(" ".join(list(required_columns))))
69
-
70
- twiss = pd.read_csv(tfsfile, delim_whitespace=True, skiprows=header_line_no+1,
71
- index_col=False, names=header)
72
-
73
- twiss_coll = twiss[twiss["KEYWORD"] == "COLLIMATOR"] # Collimators only
74
- twiss_coll = twiss[list(required_columns)] # Reduce the data fields
75
- twiss_coll["NAME"] = twiss_coll["NAME"].str.lower() # Make the names lowercase for easy processing
76
-
77
- twiss_coll.rename(columns={key: key.lower() for key in list(twiss_coll.columns)}, inplace=True)
78
- twiss_coll.rename(columns={'pt': 'delta'}, inplace=True) # rename PT to delta for consistency
79
- twiss_coll = twiss_coll.set_index("name").T
80
-
81
- return twiss_coll.to_dict()
82
-
83
-
84
- def _load_collimators_xtrack(xt_twiss):
85
- required_columns = {"name", "betx", "bety", "alfx", "alfy", "dx", "dy", "x", "y", "delta"}
86
- twiss_coll = pd.DataFrame({key: xt_twiss[key] for key in required_columns})
87
- twiss_coll = twiss_coll.set_index('name').T
88
-
89
- return twiss_coll.to_dict()
90
-
91
-
92
- def _colldb_format_detector(colldb_file):
93
- # Detect the likely format of a colldb file
94
- lines = []
95
- formats = ('collgaps', 'old_colldb', 'new_colldb', 'yaml_colldb')
96
- formats_found = {fmt: False for fmt in formats}
97
-
98
- all_old_colldb_lines = True
99
- all_collgaps_lines = True
100
- has_yaml_syntax = False
101
- with open(colldb_file, 'r') as infile:
102
- for l_no, line in enumerate(infile):
103
- line = line.strip()
104
- if line.startswith("#"):
105
- continue # Comment
106
- if len(line.strip()) == 0:
107
- continue # Empty line
108
- lines.append(line)
109
- # Detect based on the number of items on a line or
110
- # special charecters for the case of yaml
111
- if line == '---' or ':' in line:
112
- has_yaml_syntax = True
113
- elif len(line.split()) == 1: # Line from an old CollDB
114
- all_collgaps_lines = False
115
- elif len(line.split()) == 13: # Line from collgaps
116
- all_old_colldb_lines = False
117
- else:
118
- all_collgaps_lines = False
119
- all_old_colldb_lines = False
120
-
121
- formats_found['yaml_colldb'] = has_yaml_syntax
122
- formats_found['old_colldb'] = all_old_colldb_lines
123
- formats_found['collgaps'] = all_collgaps_lines
124
- # The default case is the new CollDB
125
- # The loader there has checking for valid formats
126
- formats_found['new_colldb'] = not all_old_colldb_lines \
127
- and not all_collgaps_lines \
128
- and not has_yaml_syntax
129
- assert sum(formats_found.values()) == 1
130
-
131
- likely_format = [key for key in formats_found if formats_found[key] == True][0]
132
- print(f"Detected CollDB format: {likely_format}")
133
- return likely_format
134
-
135
-
136
- def _load_colldb_yaml(filename):
137
- raise ValueError('Loading of yaml format CollDB not implemented yet.')
138
-
139
-
140
- def _load_colldb_old(filename):
141
-
142
- float_num = r'[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?' # Float
143
- sep = r'\s+'
144
-
145
- # Not sure what the value 3 from last is, so it is not named
146
- coll_re = re.compile(r'''
147
- #{sep}
148
- (?P<name>.+){sep}
149
- (?P<name_lower>.+){sep}
150
- (?P<nsigma>{float_num}){sep}
151
- (?P<material>[a-zA-Z]+){sep}
152
- (?P<length>{float_num}){sep}
153
- (?P<angle>{float_num}){sep}
154
- ({float_num}){sep}
155
- (?P<betax>{float_num}){sep}
156
- (?P<betay>{float_num}){sep}
157
- '''.format(sep=sep, float_num=float_num), re.VERBOSE)
158
-
159
- with open(filename, "r") as infile:
160
- colldb_contents = infile.read()
161
-
162
- # List of dicts for each match (collimator)
163
- matches = [m.groupdict() for m in coll_re.finditer(colldb_contents)]
164
-
165
- # Make into a dict by name for easy access
166
- collimator_data = {}
167
- for m in matches:
168
- cname = m["name"].lower().strip()
169
- collimator_data[cname] = {"nsigma" : float(m["nsigma"]),
170
- "angle" : float(m["angle"]),
171
- "length" : float(m["length"]),
172
- "material": m["material"],
173
- }
174
-
175
- #print(collimator_data)
176
- return collimator_data
177
-
178
-
179
- def _load_colldb_new(filename):
180
- with open(filename, "r") as infile:
181
- coll_data_string = ""
182
- family_settings = {}
183
- family_types = {}
184
- onesided = {}
185
- tilted = {}
186
-
187
- for l_no, line in enumerate(infile):
188
- if line.startswith("#"):
189
- continue # Comment
190
- if len(line.strip()) == 0:
191
- continue # Empty line
192
- sline = line.split()
193
- if len(sline) < 6:
194
- if sline[0].lower() == "nsig_fam":
195
- family_settings[sline[1]] = sline[2]
196
- family_types[sline[1]] = sline[3]
197
- elif sline[0].lower() == "onesided":
198
- onesided[sline[1]] = int(sline[2])
199
- elif sline[0].lower() == "tilted":
200
- tilted[sline[1]] = [float(sline[2]), float(sline[3])]
201
- elif sline[0].lower() == "settings":
202
- pass # Acknowledge and ignore this line
203
- else:
204
- raise ValueError(f"Unknown setting {line}")
205
- else:
206
- coll_data_string += line
207
-
208
- names = ["name", "opening", "material", "length", "angle", "offset"]
209
-
210
- df = pd.read_csv(io.StringIO(coll_data_string), delim_whitespace=True,
211
- index_col=False, skip_blank_lines=True, names=names)
212
-
213
- df["angle"] = np.deg2rad(df["angle"]) # convert to radians
214
- df["name"] = df["name"].str.lower() # Make the names lowercase for easy processing
215
- df["nsigma"] = df["opening"].apply(lambda s: float(family_settings.get(s, s)))
216
- df["type"] = df["opening"].apply(lambda s: family_types.get(s, "UNKNOWN"))
217
- df["side"] = df["name"].apply(lambda s: onesided.get(s, 0))
218
- df["tilt_left"] = df["name"].apply(lambda s: np.deg2rad(tilted.get(s, [0, 0])[0]))
219
- df["tilt_right"] = df["name"].apply(lambda s: np.deg2rad(tilted.get(s, [0, 0])[1]))
220
- df = df.set_index("name").T
221
-
222
- # Ensure the collimators marked as one-sided or tilted are actually defined
223
- defined_set = set(df.columns) # The data fram was transposed so columns are names
224
- onesided_set = set(onesided.keys())
225
- tilted_set = set(tilted.keys())
226
- if not onesided_set.issubset(defined_set):
227
- different = onesided_set - defined_set
228
- raise SystemExit('One-sided collimators not defined: {}'.format(", ".join(different)))
229
- if not tilted_set.issubset(defined_set):
230
- different = tilted_set - defined_set
231
- raise SystemExit('Tilted collimators not defined: {}'.format(",".join(different)))
232
- return df.to_dict()
233
-
234
-
235
- def _load_collgaps(filename):
236
- names = ["id", "name", "angle", "betax", "betay", "halfgap", "material",
237
- "length", "sigx", "sigy", "tilt1", "tilt2", "nsigma"]
238
-
239
- df = pd.read_csv(filename, delim_whitespace=True, index_col=False, names=names, header=0, comment='#')
240
- df["name"] = df["name"].str.lower() # Make the names lowercase for easy processing
241
- df = df.set_index("name").T
242
-
243
- return df.to_dict()
244
-
245
-
246
- def _subprocess_bdsim_get_mass(pdg_id, json_out_file):
247
- '''
248
- This is worker function for get_mass_from_pdg_id(pdg_id), do not use
249
- on it's own
250
- '''
251
- # Initialise BDSIM (the Geant4 kernel)
252
- dummy_bdsim_file = Path('_dummy_settings.gmad')
253
- with open(dummy_bdsim_file, 'w') as bdsimfile:
254
- # ignored, just need the file and beam definition to launch bdsim
255
- # it needs to be an ion so the ion tables get loaded, in addition to
256
- # all the normal particles
257
- bdsimfile.write('beam, particle="ion 208 82", momentum=42*GeV;\n')
258
-
259
- # dummy values as we only case about the mass
260
- g4link = cs.XtrackInterface(bdsimConfigFile=str(dummy_bdsim_file),
261
- referencePdgId=int(pdg_id),
262
- referenceEk=42, # BDSIM expects GeV
263
- relativeEnergyCut=0.42,
264
- seed=42, referenceIonCharge=0,
265
- batchMode=True)
266
-
267
- mass = g4link.getReferenceMass() * 1e9 # convert to eV
268
-
269
- dummy_bdsim_file.unlink()
270
-
271
- with open(Path(json_out_file), 'w') as outfile:
272
- json.dump(obj={'mass_ev': mass}, fp=outfile)
273
-
274
-
275
- def get_mass_from_pdg_id(pdg_id):
276
- '''
277
- This is a hacky utility function that is neccessary because
278
- BDSIM isn't re-entry safe when loaded from the pybind11 c++ extension,
279
- and there is no good way to reload the extension. Subprocess
280
- offsers complete isolation so can safely load a dummy BDSIM and get the
281
- mass of the particle.
282
- '''
283
- # Serialize the argument to pass it to the subprocess
284
- kwargs = {'json_out_file': 'reference_mass.json', 'pdg_id': pdg_id}
285
- argument_str = json.dumps(kwargs)
286
-
287
- subprocess.run([sys.executable, "-c",
288
- ("import os;"
289
- "import sys;"
290
- "import json;"
291
- "sys.stdout = open(os.devnull, 'w');"
292
- "from collimasim.xtrack_collimator import _subprocess_bdsim_get_mass;"
293
- f"_subprocess_bdsim_get_mass(**json.loads('{argument_str}'))")],
294
- stdout = subprocess.DEVNULL, # Don't need the output from this - chceked later
295
- # stderr = subprocess.DEVNULL,
296
- )
297
-
298
- # The output is in a json file, load and delete when done
299
- mass_file_path = Path(kwargs['json_out_file'])
300
- if not mass_file_path.exists():
301
- raise Exception(f'Coud not load mass for PDG ID {pdg_id}.')
302
-
303
- with open(mass_file_path, 'r') as infile:
304
- mass = json.load(infile)['mass_ev']
305
- mass_file_path.unlink()
306
- return mass
307
-
308
-
309
- class Geant4CollimationManager:
310
-
311
- def __init__(self, collimator_file, bdsim_config_file, tfs_file, emittance_norm, reference_pdg_id,
312
- reference_kinetic_energy, relative_energy_cut, seed, material_rename_map={}, batchMode=True):
313
-
314
- unit_GeV = 1e9 # GeV to MeV
315
-
316
- # Energy units in Xtrack are eV
317
- self.collimator_file = collimator_file
318
- self.bdsim_config_file = bdsim_config_file
319
- self.tfs_file = tfs_file
320
- self.reference_pdg_id = reference_pdg_id
321
- self.reference_kinetic_energy = reference_kinetic_energy
322
- self.relative_energy_cut = relative_energy_cut
323
- self.seed = seed
324
-
325
- self.material_rename_map = material_rename_map
326
-
327
- # Allow for an asymmetric beam via a in iterable emittance assignment
328
- try:
329
- iter(emittance_norm)
330
- self.emit_norm_x = emittance_norm[0]
331
- self.emit_norm_y = emittance_norm[1]
332
- except TypeError:
333
- self.emit_norm_x = emittance_norm
334
- self.emit_norm_y = emittance_norm
335
-
336
- # Initialise BDSIM (the Geant4 kernel)
337
- self.g4link = cs.XtrackInterface(bdsimConfigFile=self.bdsim_config_file,
338
- referencePdgId=self.reference_pdg_id,
339
- referenceEk=self.reference_kinetic_energy / unit_GeV, # BDSIM expects GeV
340
- relativeEnergyCut=self.relative_energy_cut,
341
- seed=self.seed, referenceIonCharge=0, batchMode=batchMode)
342
- # Batch mode disables visualisation
343
-
344
- self.reference_mass = self.g4link.getReferenceMass() * unit_GeV # BDSIM gives the mass in GeV
345
-
346
- # Load the collimator settings and optics separately as not sure if all MAD-X collimators are needed
347
- if isinstance(self.tfs_file, xt.twiss.TwissTable):
348
- self._collimator_optics = _load_collimators_xtrack(self.tfs_file)
349
- elif isinstance(self.tfs_file, str):
350
- self._collimator_optics = _load_collimators_tfs(self.tfs_file)
351
- else:
352
- raise Exception('Collimator optics can only be an Xtrack twiss dict,'
353
- ' or a path to a MAD-X twiss file')
354
- if isinstance(self.collimator_file, str):
355
- self._collimator_settings = self._load_collimator_data(self.collimator_file)
356
- elif isinstance(self.collimator_file, dict):
357
- self._collimator_settings = self.collimator_file
358
- else:
359
- raise Exception(f'Unsupported collimator data fromat {self.collimator_file}')
360
-
361
- self.collimators = {}
362
- self._load_collimators()
363
- #self._load_collimators_collgaps()
364
-
365
- # Debug
366
- #for cname in self.collimators:
367
- # print(cname, self.collimators[cname]["nsigma"], self.collimators[cname]["halfgap"])
368
-
369
- #with open(f"cgaps_{self.collimator_file}", "w") as outfile:
370
- # for cname in self.collimators:
371
- # outfile.write("{} {} {}\n".format(cname,
372
- # self.collimators[cname]["nsigma"],
373
- # self.collimators[cname]["halfgap"]))
374
-
375
- def _load_collimator_data(self, collimator_file):
376
- detected_format = _colldb_format_detector(collimator_file)
377
- loader_dispatch = {'collgaps': _load_collgaps,
378
- 'new_colldb': _load_colldb_new,
379
- 'old_colldb': _load_colldb_old,
380
- 'yaml_colldb': _load_colldb_yaml}
381
-
382
- data = loader_dispatch[detected_format](collimator_file)
383
- return data
384
-
385
- def _calc_collimator_halfgap(self, name):
386
- # Calculate the geometric emittances first
387
- totalEnergy = self.reference_kinetic_energy + self.reference_mass
388
- emit_geom_x = _norm_to_geom_emittance(self.emit_norm_x, self.reference_mass, totalEnergy)
389
- emit_geom_y = _norm_to_geom_emittance(self.emit_norm_y, self.reference_mass, totalEnergy)
390
-
391
- betx = self._collimator_optics[name]["betx"]
392
- bety = self._collimator_optics[name]["bety"]
393
-
394
- nsigma = self._collimator_settings[name]["nsigma"]
395
- angle = self._collimator_settings[name]["angle"]
396
-
397
- a = nsigma * np.sqrt(betx * emit_geom_x)
398
- b = nsigma * np.sqrt(bety * emit_geom_y)
399
-
400
- x = a * np.cos(angle)
401
- y = b * np.sin(angle)
402
-
403
- return np.sqrt(x**2 + y**2)
404
-
405
- def _load_collimators(self):
406
-
407
- for cname in self._collimator_settings:
408
- cdata = self._collimator_settings[cname]
409
- copt = self._collimator_optics[cname]
410
-
411
- if cdata['nsigma'] < 900:
412
- halfgap = self._calc_collimator_halfgap(cname)
413
-
414
- mat_def = cdata["material"]
415
- material = self.material_rename_map.get(mat_def, mat_def)
416
-
417
- # Compute the offset for the collimators - placed around the closed orbit
418
- x_offset = copt['x']
419
- y_offset = copt['y']
420
-
421
- self.g4link.addCollimator(cname, material, cdata["length"],
422
- apertureLeft=halfgap, apertureRight=halfgap,
423
- rotation=cdata["angle"],
424
- xOffset=x_offset, yOffset=y_offset,
425
- jawTiltLeft=cdata.get("tilt_left", 0.),
426
- jawTiltRight=cdata.get("tilt_right", 0.),
427
- side=cdata.get("side", 0))
428
-
429
- # Merge all the info about the collimator in the same dictionary for storage
430
- self.collimators[cname] = {**cdata, **copt}
431
- self.collimators[cname]["halfgap"] = halfgap
432
- else:
433
- print(f'Collimator {cname} with gap of {cdata["nsigma"]} sigma ignored.')
434
-
435
- def _load_collimators_collgaps(self):
436
- collimators = np.genfromtxt(self.collimator_file, dtype=None, encoding=None, comments='#')
437
-
438
- # This would be nicer with pandas, but don't need the dependency just for this one bit
439
- for coll in collimators:
440
- name = coll[1]
441
- material = coll[6]
442
- length = float(coll[7])
443
- angle = float(coll[2])
444
- halfgap = float(coll[5])
445
-
446
- # TODO: add the closed orbit at the collimator
447
- # side=0 means both jaws
448
- side = 0 # Default for now
449
-
450
- self.g4link.addCollimator(name, material, length, aperture=halfgap*2,
451
- rotation=angle, xOffset=0, yOffset=0, side=0)
452
-
453
- self.collimators[name] = {"material": material,
454
- "length": length,
455
- "halfgap": halfgap,
456
- "angle": angle,
457
- "side": side,
458
- }
459
-
460
- def process_collimator(self, collimator_name, particles):
461
- self.g4link.clearData() # Clear the old data - bunch particles and hits
462
-
463
- print(f"Processing collimator: {collimator_name}")
464
-
465
- # This temp delta is necessary because for primary particles, the coordinates are
466
- # modified in place. But for the longitudinal plane there are 3 coordinates that must
467
- # be updated, so pass a copy of the delta for the update in place and trigger the
468
- # correct update of the 3 coordinates later
469
- delta_temp = particles._delta.copy()
470
-
471
- # Using a list allows to package the required coordinates without copying
472
- coordinates = [particles.x, particles.y, particles.px, particles.py,
473
- particles.zeta, delta_temp, particles.chi, particles.charge_ratio,
474
- particles.s, particles.pdg_id, particles.particle_id, particles.state,
475
- particles.at_element, particles.at_turn]
476
-
477
- self.g4link.addParticles(coordinates)
478
- # The collimators must be defined already in the g4manager
479
- self.g4link.selectCollimator(collimator_name)
480
-
481
- self.g4link.collimate() # Performs the physical interaction simulation
482
-
483
- # Modifies the primary coordinates in place and returns a list of arrays for the
484
- # coordinates of the secondary particles.
485
- products = self.g4link.collimateReturn(coordinates)
486
-
487
- # Force the update using the private member _delta
488
- # as the update_delta method only updates the delta for active particles
489
- particles._delta[:len(delta_temp)] = delta_temp
490
- particles.update_delta(delta_temp)
491
-
492
- return products
493
-
494
- def make_xtg4_collimator(self, name):
495
- name = name.lower()
496
- if name not in self.collimators:
497
- raise KeyError(f"Collimator {name} is not defined in the Geant4 model")
498
-
499
- g4coll = cs.Geant4Collimator(name=name, g4manager=self)
500
- xtg4coll = xt.BeamInteraction(name=name, interaction_process=g4coll,
501
- length=self.collimators[name]["length"])
502
-
503
- return xtg4coll
504
-
505
- def place_all_collimators(self, sequence, on_missing=None):
506
- # Make the collimators
507
- for name in self.collimators:
508
- coll = self.make_xtg4_collimator(name)
509
- self.place_xtg4_collimator(sequence, coll, on_missing=on_missing)
510
-
511
-
512
- def place_xtg4_collimator(self, sequence, xtg4_collimator, on_missing=None):
513
- '''
514
- A function to expand a collimator from a marker or an active-length-only
515
- collimator to a full-size element. To achieve that, all the elements found
516
- inside the collimator length are discarded, and the outer-most drifts are
517
- trimmed to fit the thick collimator.
518
- '''
519
-
520
- coll_name = xtg4_collimator.interaction_process.name
521
- coll_length = xtg4_collimator.length
522
-
523
- if on_missing is None:
524
- on_missing = "warn"
525
- exception_type = MissingCollimatorAction(on_missing)
526
-
527
- try:
528
- coll_idx = sequence.element_names.index(coll_name.lower())
529
- except ValueError:
530
- msg = f"Collimator {coll_name} not found in sequence"
531
- if exception_type == MissingCollimatorAction.ERROR:
532
- raise ValueError(msg)
533
- elif exception_type == MissingCollimatorAction.WARN:
534
- warnings.warn(msg)
535
-
536
- s_pos = sequence.get_s_elements()
537
-
538
- s_ups = s_pos[coll_idx]
539
- s_dns = s_pos[coll_idx + 1]
540
- s_cent = (s_ups + s_dns) / 2
541
- len_c_xt = s_dns - s_ups
542
-
543
- coll_edge_ups = s_cent - coll_length / 2
544
- coll_edge_dns = s_cent + coll_length / 2
545
-
546
- sequence.insert_element(at_s=coll_edge_ups, element=xtg4_collimator, name=coll_name.lower())
547
-
548
-
549
- class Geant4Collimator:
550
- def __init__(self, name, g4manager):
551
- self.name = name
552
- self.g4manager = g4manager
553
-
554
- def interact(self, particles):
555
- # The track method is needed for tracking in Xtrack
556
- return self.g4manager.process_collimator(self.name, particles)
@@ -1,6 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: collimasim
3
- Version: 0.0.1
4
- Summary: Python bindings of BDSIM (Geant4) for collimation studies
5
- Author: Andrey Abramov, Laurie Nevay
6
- Author-email: andrey.abramov@cern.ch
@@ -1,24 +0,0 @@
1
- README.md
2
- pyproject.toml
3
- setup.py
4
- src/collimasim/__init__.py
5
- src/collimasim/pyCollimatorPass.py
6
- src/collimasim/xtrack_collimator.py
7
- src/collimasim.egg-info/PKG-INFO
8
- src/collimasim.egg-info/SOURCES.txt
9
- src/collimasim.egg-info/dependency_links.txt
10
- src/collimasim.egg-info/not-zip-safe
11
- src/collimasim.egg-info/top_level.txt
12
- tests/test_pyat.py
13
- tests/test_pyat_passmethod.py
14
- tests/test_pyat_tracking.py
15
- tests/test_xtrack.py
16
- tests/test_xtrack_angle.py
17
- tests/test_xtrack_colldb_load.py
18
- tests/test_xtrack_interaction.py
19
- tests/test_xtrack_interaction_ion.py
20
- tests/test_xtrack_ions.py
21
- tests/test_xtrack_lost_energy.py
22
- tests/test_xtrack_tilt.py
23
- tests/test_xtrack_tracking.py
24
- tests/test_xtrack_tracking_ions.py
@@ -1,25 +0,0 @@
1
- # Test suite for collimasim
2
-
3
- To run all the tests successfully, both `Xsuite` and `pyAT` must be installed
4
-
5
- To run with pytest, the extension `pytest-forked` must be installed
6
-
7
- ```
8
- pip install pytest-forked
9
- ```
10
-
11
- and then
12
-
13
- ```
14
- pytest --forked --continue-on-collection-errors
15
- ```
16
- in the `collimasim/tests` directory to run the tests.
17
-
18
- This is because collimasim is currently not re-entry safe.
19
- Once an instance of BDSIM has been launched in a process,
20
- no further instances can be launched in that process.
21
- This appears to be due to the global state not being reset
22
- properly after the BDISM instance terminates.
23
- To be investigated in the future.
24
- The flag --continue-on-collection-errors ensures that
25
- the Xsuite tests run if pyAT isn't isntalled and vice versa.
@@ -1,25 +0,0 @@
1
- # Database for cleaning insertion collimators. Prepared: 23 Jun 2021
2
- 6
3
- #
4
-
5
- TCP.A.B1
6
- tcp.a.b1
7
- 1
8
- C
9
- 0.05
10
- 0
11
- 0.0000000000000000
12
- 1.1
13
- 1.1
14
-
15
- #
16
- TCP.B.B1
17
- tcp.b.b1
18
- 1
19
- C
20
- 0.05
21
- 1.5707963267948966
22
- 0.0000000000000000
23
- 1.1
24
- 1.1
25
- #
@@ -1,18 +0,0 @@
1
- # Automatically converted collimator DB from old format file 'CollDB_HL.data'
2
- # Families
3
- NSIG_FAM tcph 10.000000 PRIMARY
4
- NSIG_FAM tcpv 80.000000 PRIMARY
5
- NSIG_FAM tcsh 11.500000 SECONDARY
6
- NSIG_FAM tcsv 89.500000 SECONDARY
7
- #
8
- # Collimators
9
- # name opening/fam mat. length[m] angle[deg] offset[m]
10
- tcp.a.b1 tcph C 0.600000 0.000000 0.000000
11
- tcp.b.b1 tcpv C 0.600000 90.00000 0.000000
12
- tcs.b1.b1 tcsv C 1.000000 90.00000 0.000000
13
- tcs.a1.b1 tcsh C 1.000000 0.000000 0.000000
14
- tcs.a2.b1 tcsh C 1.000000 0.000000 0.000000
15
- tcs.b2.b1 tcsv C 1.000000 90.00000 0.000000
16
- #
17
- # Additional Collimator Settings
18
- SETTINGS