├── .coveralls.yml ├── lib ├── cparamlib │ ├── NEWS │ ├── AUTHORS │ ├── CMakeLists.txt │ ├── Makefile.am │ └── ChangeLog ├── pybind11 │ ├── pybind11 │ │ ├── py.typed │ │ ├── _version.py │ │ ├── __init__.py │ │ ├── commands.py │ │ └── __main__.py │ ├── .gitattributes │ ├── tools │ │ ├── pyproject.toml │ │ ├── pybind11.pc.in │ │ ├── JoinPaths.cmake │ │ ├── cmake_uninstall.cmake.in │ │ ├── libsize.py │ │ ├── codespell_ignore_lines_from_errors.py │ │ ├── setup_main.py.in │ │ └── check-style.sh │ ├── include │ │ └── pybind11 │ │ │ ├── common.h │ │ │ ├── eigen.h │ │ │ ├── eigen │ │ │ └── common.h │ │ │ └── detail │ │ │ └── typeid.h │ ├── MANIFEST.in │ ├── .readthedocs.yml │ ├── .gitignore │ ├── SECURITY.md │ ├── .clang-format │ ├── .codespell-ignore-lines │ ├── .appveyor.yml │ ├── setup.cfg │ └── LICENSE ├── get_ymw16.sh ├── get_ne2001.sh ├── get_pybind11.sh ├── get_cfitsio.sh ├── get_gtest.sh ├── gtest │ └── googletest │ │ ├── cmake │ │ ├── Config.cmake.in │ │ ├── gtest.pc.in │ │ ├── gtest_main.pc.in │ │ └── libgtest.la.in │ │ ├── docs │ │ └── samples.md │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ ├── test │ │ ├── production.cc │ │ ├── gtest_main_unittest.cc │ │ ├── googletest-uninitialized-test_.cc │ │ ├── gtest_testbridge_test_.cc │ │ ├── gtest_xml_outfile1_test_.cc │ │ ├── gtest_xml_outfile2_test_.cc │ │ └── gtest-typed-test2_test.cc │ │ ├── include │ │ └── gtest │ │ │ └── internal │ │ │ └── custom │ │ │ ├── README.md │ │ │ ├── gtest.h │ │ │ └── gtest-port.h │ │ ├── scripts │ │ └── test │ │ │ └── Makefile │ │ ├── samples │ │ └── sample1.h │ │ └── src │ │ └── gtest_main.cc └── kiss │ ├── CMakeLists.txt │ ├── test │ └── test_uuid.cpp │ ├── include │ └── kiss │ │ ├── string.h │ │ ├── path.h │ │ ├── uuid.h │ │ ├── logger.h │ │ └── convert.h │ └── src │ └── logger.cpp ├── include └── hermes │ ├── .lock │ ├── neutralgas │ ├── GasType.h │ ├── ProfileAbstract.h │ ├── Nakanishi06.h │ ├── NeutralGasAbstract.h │ └── RingData.h │ ├── Signals.h │ ├── Units.h.in │ ├── darkmatter │ ├── GalacticProfile.h │ ├── DarkMatterSpectrum.h │ ├── NFWGProfile.h │ ├── PPPC4DMIDSpectrum.h │ └── PPPC4DMIDChannels.h │ ├── Version.h │ ├── interactions │ ├── BreitWheeler.h │ ├── KleinNishina.h │ ├── BremsstrahlungTsai74.h │ ├── BremsstrahlungAbstract.h │ ├── KelnerAharonianNeutrino.h │ ├── KelnerAharonianGamma.h │ ├── DummyCrossSection.h │ ├── DiffCrossSection.h │ ├── Kamae06Gamma.h │ ├── Kamae06Neutrino.h │ └── AAfragGamma.h │ ├── skymaps │ ├── RotationMeasureSkymap.h │ ├── DispersionMeasureSkymap.h │ ├── RadioSkymap.h │ ├── GammaSkymap.h │ ├── Skymap.h │ ├── RadioSkymapRange.h │ ├── GammaSkymapRange.h │ └── SkymapMask.h │ ├── cosmicrays │ ├── SimpleCR.h │ ├── DummyCR.h │ ├── WMAP07.h │ ├── Sun08.h │ ├── Dragon2D.h │ └── Dragon3D.h │ ├── ionizedgas │ ├── HII_Cordes91.h │ ├── IonizedGasDensity.h │ └── NE2001Simple.h │ ├── units │ ├── UnitsHERMES.h │ ├── UnitsBasic.h │ └── UnitsSimple.h │ ├── HEALPixBits.h │ ├── outputs │ ├── Output.h │ └── TextOutput.h │ ├── ParticleID.h │ ├── magneticfields │ ├── WMAP07.h │ ├── MagneticFieldGrid.h │ └── Sun08.h │ ├── integrators │ ├── BremsstrahlungIntegrator.h │ ├── DarkMatterIntegrator.h │ ├── DispersionMeasureIntegrator.h │ ├── RotationMeasureIntegrator.h │ ├── PiZeroAbsorptionIntegrator.h │ ├── FreeFreeIntegrator.h │ └── SynchroAbsorptionIntegrator.h │ ├── ProgressBar.h │ └── photonfields │ ├── PhotonField.h │ ├── CMB.h │ └── ISRF.h ├── doc ├── sphinx │ ├── pages │ │ ├── Installation.rst │ │ ├── Examples.rst │ │ └── Developers.rst │ ├── components │ │ ├── SkymapsGroup.rst │ │ ├── ChargedGasGroup.rst │ │ ├── CosmicRaysGroup.rst │ │ ├── IntegratorsGroup.rst │ │ ├── NeutralGasGroup.rst │ │ ├── InteractionsGroup.rst │ │ └── PhotonFieldsGroup.rst │ ├── sphinx-requirements.txt │ ├── components.rst │ └── index.rst ├── hermes-pizero-example.png └── clang-format-sources.sh ├── CHANGELOG.md ├── src ├── Signals.cpp ├── ionizedgas │ └── HII_Cordes91.cpp ├── skymaps │ └── Skymap.cpp ├── magneticfields │ ├── WMAP07.cpp │ └── MagneticFieldGrid.cpp ├── cosmicrays │ ├── DummyCR.cpp │ ├── SimpleCR.cpp │ ├── WMAP07.cpp │ └── Sun08.cpp ├── interactions │ ├── KleinNishina.cpp │ ├── DifferentialCrossSection.cpp │ ├── Kamae06Gamma.cpp │ ├── BreitWheeler.cpp │ ├── Kamae06Neutrino.cpp │ └── KelnerAharonianGamma.cpp ├── Version.cpp.in ├── integrators │ ├── RotationMeasureIntegrator.cpp │ ├── DarkMatterIntegrator.cpp │ └── DispersionMeasureIntegrator.cpp ├── neutralgas │ └── Nakanishi06.cpp └── darkmatter │ └── NFWGProfile.cpp ├── python ├── ParticleID.cpp ├── outputs.cpp ├── Common.cpp ├── photonfields.cpp ├── magneticfields.cpp ├── PyHermes.cpp ├── ionizedgas.cpp └── Vectors.cpp ├── .gitignore ├── .readthedocs.yml ├── test ├── testNumericalIntegration.cpp ├── testMFieldModels.cpp ├── testCosmicRays.cpp ├── testBreitWheeler.cpp ├── testHEALPix.cpp ├── testIntegrationMethods.cpp ├── testYMW16.cpp ├── testPicard3D.cpp └── testPhotonField.cpp ├── cmake ├── FindFFTW3F.cmake └── GetGitRevisionDescription.cmake.in └── CITATION.cff /.coveralls.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/cparamlib/NEWS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /include/hermes/.lock: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/pybind11/pybind11/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/pybind11/.gitattributes: -------------------------------------------------------------------------------- 1 | docs/*.svg binary 2 | -------------------------------------------------------------------------------- /doc/sphinx/pages/Installation.rst: -------------------------------------------------------------------------------- 1 | .. mdinclude:: ../../../INSTALL.md 2 | -------------------------------------------------------------------------------- /doc/sphinx/components/SkymapsGroup.rst: -------------------------------------------------------------------------------- 1 | Skymaps 2 | ======= 3 | .. doxygengroup:: Skymaps 4 | 5 | -------------------------------------------------------------------------------- /lib/get_ymw16.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git clone https://bitbucket.org/psrsoft/ymw16.git ymw16 4 | -------------------------------------------------------------------------------- /doc/hermes-pizero-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmicrays/hermes/HEAD/doc/hermes-pizero-example.png -------------------------------------------------------------------------------- /doc/sphinx/components/ChargedGasGroup.rst: -------------------------------------------------------------------------------- 1 | Charged Gas 2 | =========== 3 | .. doxygengroup:: ChargedGas 4 | 5 | -------------------------------------------------------------------------------- /doc/sphinx/components/CosmicRaysGroup.rst: -------------------------------------------------------------------------------- 1 | Cosmic Rays 2 | =========== 3 | .. doxygengroup:: CosmicRays 4 | 5 | -------------------------------------------------------------------------------- /doc/sphinx/components/IntegratorsGroup.rst: -------------------------------------------------------------------------------- 1 | Integrators 2 | =========== 3 | .. doxygengroup:: Integrators 4 | 5 | -------------------------------------------------------------------------------- /doc/sphinx/components/NeutralGasGroup.rst: -------------------------------------------------------------------------------- 1 | Neutral Gas 2 | =========== 3 | .. doxygengroup:: NeutralGas 4 | 5 | -------------------------------------------------------------------------------- /doc/sphinx/components/InteractionsGroup.rst: -------------------------------------------------------------------------------- 1 | Interactions 2 | ============ 3 | .. doxygengroup:: Interactions 4 | 5 | -------------------------------------------------------------------------------- /doc/sphinx/components/PhotonFieldsGroup.rst: -------------------------------------------------------------------------------- 1 | Photon Fields 2 | ============= 3 | .. doxygengroup:: PhotonFields 4 | 5 | -------------------------------------------------------------------------------- /lib/cparamlib/AUTHORS: -------------------------------------------------------------------------------- 1 | Niklas Karlsson 2 | Johann Cohen-Tanugi 3 | -------------------------------------------------------------------------------- /lib/pybind11/tools/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=42", "wheel"] 3 | build-backend = "setuptools.build_meta" 4 | -------------------------------------------------------------------------------- /lib/get_ne2001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | wget http://hosting.astro.cornell.edu/~cordes/NE2001/NE2001_1.0.tar.gz 4 | tar xvf NE2001_1.0.tar.gz -C NE2001 5 | -------------------------------------------------------------------------------- /lib/get_pybind11.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git clone https://github.com/pybind/pybind11.git pybind11 4 | cd pybind11 5 | rm -rf docs tests .git .github 6 | -------------------------------------------------------------------------------- /lib/pybind11/include/pybind11/common.h: -------------------------------------------------------------------------------- 1 | #include "detail/common.h" 2 | #warning "Including 'common.h' is deprecated. It will be removed in v3.0. Use 'pybind11.h'." 3 | -------------------------------------------------------------------------------- /doc/sphinx/sphinx-requirements.txt: -------------------------------------------------------------------------------- 1 | m2r==0.2.1 2 | Sphinx==1.7.9 3 | nbsphinx==0.3.5 4 | breathe==4.10.0 5 | exhale==0.2.3 6 | sphinx-rtd-theme==0.4.3 7 | recommonmark==0.6.0 8 | -------------------------------------------------------------------------------- /doc/sphinx/pages/Examples.rst: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | Various examples can be found in a separate repository: `hermes-examples `_. 5 | -------------------------------------------------------------------------------- /lib/get_cfitsio.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | curl -o cfitsio.tar.gz https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio_latest.tar.gz 4 | tar xvf cfitsio.tar.gz 5 | rm -rf cfitsio.tar.gz 6 | rm -rf cfitsio/docs/ 7 | -------------------------------------------------------------------------------- /lib/get_gtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git clone --branch release-1.10.0 --depth 1 https://github.com/google/googletest.git gtest 4 | cd gtest 5 | find . -maxdepth 1 ! -name 'googletest' -type f -exec rm -f {} + 6 | rm -rf googlemock ci .git docs 7 | -------------------------------------------------------------------------------- /lib/pybind11/tools/pybind11.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix_for_pc_file@ 2 | includedir=@includedir_for_pc_file@ 3 | 4 | Name: @PROJECT_NAME@ 5 | Description: Seamless operability between C++11 and Python 6 | Version: @PROJECT_VERSION@ 7 | Cflags: -I${includedir} 8 | -------------------------------------------------------------------------------- /doc/clang-format-sources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # doc: https://clang.llvm.org/docs/ClangFormatStyleOptions.html 4 | projectrootdir="$(dirname pwd)" 5 | cd $projectrootdir 6 | git ls-files -- '*.cpp' '*.h' | grep "^\(include\|src\|python\|test\)" | xargs clang-format -i --style=file 7 | -------------------------------------------------------------------------------- /lib/pybind11/MANIFEST.in: -------------------------------------------------------------------------------- 1 | prune tests 2 | recursive-include pybind11/include/pybind11 *.h 3 | recursive-include pybind11 *.py 4 | recursive-include pybind11 py.typed 5 | include pybind11/share/cmake/pybind11/*.cmake 6 | include LICENSE README.rst SECURITY.md pyproject.toml setup.py setup.cfg 7 | -------------------------------------------------------------------------------- /lib/pybind11/pybind11/_version.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | 4 | def _to_int(s: str) -> Union[int, str]: 5 | try: 6 | return int(s) 7 | except ValueError: 8 | return s 9 | 10 | 11 | __version__ = "2.12.0.dev1" 12 | version_info = tuple(_to_int(s) for s in __version__.split(".")) 13 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## HERMES v1.0.1 2 | 3 | ### New features 4 | 5 | - Variable X_CO model 6 | 7 | ### Other 8 | 9 | - The code continuous integration migrated from Travis CI to GitHub Actions 10 | 11 | ## HERMES v1.0.0 12 | 13 | The first official release of HERMES used in arXiv:2105.13165 and A&A 653, A18 (2021). 14 | -------------------------------------------------------------------------------- /doc/sphinx/components.rst: -------------------------------------------------------------------------------- 1 | Components 2 | ========== 3 | 4 | .. toctree:: 5 | 6 | components/SkymapsGroup.rst 7 | components/IntegratorsGroup.rst 8 | components/ChargedGasGroup.rst 9 | components/CosmicRaysGroup.rst 10 | components/NeutralGasGroup.rst 11 | components/PhotonFieldsGroup.rst 12 | components/InteractionsGroup.rst 13 | 14 | -------------------------------------------------------------------------------- /src/Signals.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/Signals.h" 2 | 3 | namespace hermes { 4 | 5 | int g_cancel_signal_flag = 0; 6 | 7 | void g_cancel_signal_callback(int sig) { 8 | std::cerr << "hermes::Skymap: Signal " << sig 9 | << " (SIGINT/SIGTERM) received" << std::endl; 10 | g_cancel_signal_flag = sig; 11 | } 12 | 13 | } // namespace hermes 14 | -------------------------------------------------------------------------------- /lib/gtest/googletest/cmake/Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | include(CMakeFindDependencyMacro) 3 | if (@GTEST_HAS_PTHREAD@) 4 | set(THREADS_PREFER_PTHREAD_FLAG @THREADS_PREFER_PTHREAD_FLAG@) 5 | find_dependency(Threads) 6 | endif() 7 | 8 | include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") 9 | check_required_components("@project_name@") 10 | -------------------------------------------------------------------------------- /doc/sphinx/pages/Developers.rst: -------------------------------------------------------------------------------- 1 | Developers 2 | ========== 3 | 4 | General Guidelines 5 | ------------------ 6 | 7 | * Every C++ class that will be exposed in the Python interface should, in general, be passed around with ``std::shared_ptr``, otherwise it cannot be used as a function argument in Python (`see `_). 8 | -------------------------------------------------------------------------------- /include/hermes/neutralgas/GasType.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_NEUTRALGAS_GASTYPE_H 2 | #define HERMES_NEUTRALGAS_GASTYPE_H 3 | 4 | namespace hermes { namespace neutralgas { 5 | /** 6 | * \addtogroup NeutralGas 7 | * @{ 8 | */ 9 | 10 | enum class GasType { HI, H2 }; 11 | 12 | /** @}*/ 13 | }} // namespace hermes::neutralgas 14 | 15 | #endif // HERMES_NEUTRALGAS_GASTYPE_H 16 | -------------------------------------------------------------------------------- /lib/cparamlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8...3.13) 2 | 3 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(cparamlib STATIC 6 | antinue.c 7 | antinumu.c 8 | elec.c 9 | gamma.c 10 | nue.c 11 | numu.c 12 | posi.c 13 | sigma.c 14 | ) 15 | 16 | SET_TARGET_PROPERTIES(cparamlib PROPERTIES COMPILE_FLAGS -fPIC) 17 | 18 | -------------------------------------------------------------------------------- /lib/pybind11/.readthedocs.yml: -------------------------------------------------------------------------------- 1 | # https://blog.readthedocs.com/migrate-configuration-v2/ 2 | 3 | version: 2 4 | 5 | build: 6 | os: ubuntu-22.04 7 | apt_packages: 8 | - librsvg2-bin 9 | tools: 10 | python: "3.11" 11 | 12 | sphinx: 13 | configuration: docs/conf.py 14 | 15 | python: 16 | install: 17 | - requirements: docs/requirements.txt 18 | 19 | formats: 20 | - pdf 21 | -------------------------------------------------------------------------------- /include/hermes/Signals.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_SIGNALS_H 2 | #define HERMES_SIGNALS_H 3 | 4 | #include 5 | #include 6 | #ifndef sighandler_t 7 | typedef void (*sighandler_t)(int); 8 | #endif 9 | 10 | namespace hermes { 11 | 12 | extern int g_cancel_signal_flag; 13 | void g_cancel_signal_callback(int sig); 14 | 15 | } // namespace hermes 16 | 17 | #endif // HERMES_SIGNALS_H 18 | -------------------------------------------------------------------------------- /lib/pybind11/include/pybind11/eigen.h: -------------------------------------------------------------------------------- 1 | /* 2 | pybind11/eigen.h: Transparent conversion for dense and sparse Eigen matrices 3 | 4 | Copyright (c) 2016 Wenzel Jakob 5 | 6 | All rights reserved. Use of this source code is governed by a 7 | BSD-style license that can be found in the LICENSE file. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "eigen/matrix.h" 13 | -------------------------------------------------------------------------------- /doc/sphinx/index.rst: -------------------------------------------------------------------------------- 1 | .. mdinclude:: ../../README.md 2 | 3 | Contents 4 | ======== 5 | 6 | .. toctree:: 7 | :caption: General 8 | :maxdepth: 2 9 | 10 | pages/Installation.rst 11 | pages/Examples.rst 12 | 13 | .. toctree:: 14 | :caption: API 15 | :maxdepth: 2 16 | 17 | components 18 | api/library_root 19 | 20 | .. toctree:: 21 | :caption: Developers 22 | :maxdepth: 2 23 | 24 | pages/Developers.rst 25 | -------------------------------------------------------------------------------- /lib/gtest/googletest/cmake/gtest.pc.in: -------------------------------------------------------------------------------- 1 | prefix=${pcfiledir}/../.. 2 | libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ 3 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ 4 | 5 | Name: gtest 6 | Description: GoogleTest (without main() function) 7 | Version: @PROJECT_VERSION@ 8 | URL: https://github.com/google/googletest 9 | Libs: -L${libdir} -lgtest @CMAKE_THREAD_LIBS_INIT@ 10 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ 11 | -------------------------------------------------------------------------------- /lib/pybind11/include/pybind11/eigen/common.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 The pybind Community. 2 | 3 | #pragma once 4 | 5 | // Common message for `static_assert()`s, which are useful to easily 6 | // preempt much less obvious errors. 7 | #define PYBIND11_EIGEN_MESSAGE_POINTER_TYPES_ARE_NOT_SUPPORTED \ 8 | "Pointer types (in particular `PyObject *`) are not supported as scalar types for Eigen " \ 9 | "types." 10 | -------------------------------------------------------------------------------- /lib/gtest/googletest/cmake/gtest_main.pc.in: -------------------------------------------------------------------------------- 1 | prefix=${pcfiledir}/../.. 2 | libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ 3 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ 4 | 5 | Name: gtest_main 6 | Description: GoogleTest (with main() function) 7 | Version: @PROJECT_VERSION@ 8 | URL: https://github.com/google/googletest 9 | Requires: gtest 10 | Libs: -L${libdir} -lgtest_main @CMAKE_THREAD_LIBS_INIT@ 11 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ 12 | -------------------------------------------------------------------------------- /python/ParticleID.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/ParticleID.h" 2 | 3 | #include 4 | #include 5 | 6 | namespace py = pybind11; 7 | 8 | namespace hermes { 9 | 10 | void init_particleid(py::module &m) { 11 | // PID 12 | py::class_>(m, "PID").def(py::init()); 13 | m.attr("Electron") = PID(-1, 0); 14 | m.attr("Positron") = PID(1, 0); 15 | m.attr("Proton") = PID(1, 1); 16 | m.attr("Helium") = PID(2, 4); 17 | } 18 | 19 | } // namespace hermes 20 | -------------------------------------------------------------------------------- /include/hermes/Units.h.in: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_UNITS_H 2 | #define HERMES_UNITS_H 3 | 4 | @HERMES_UNIT_SYSTEM_DISABLE@ 5 | 6 | #ifndef HERMES_UNITSDISABLE 7 | //#include "hermes/units/UnitsQClass.h" 8 | #include "hermes/units/UnitsHERMES.h" 9 | #else 10 | //#include "hermes/units/UnitsSimple.h" 11 | #endif 12 | 13 | #include "hermes/units/UnitsBasic.h" 14 | #include "hermes/units/UnitsFunctions.h" 15 | #include "hermes/units/UnitsDerived.h" 16 | #include "hermes/units/UnitsLiterals.h" 17 | 18 | #endif // HERMES_UNITS_H 19 | -------------------------------------------------------------------------------- /lib/pybind11/pybind11/__init__.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | if sys.version_info < (3, 6): # noqa: UP036 4 | msg = "pybind11 does not support Python < 3.6. 2.9 was the last release supporting Python 2.7 and 3.5." 5 | raise ImportError(msg) 6 | 7 | 8 | from ._version import __version__, version_info 9 | from .commands import get_cmake_dir, get_include, get_pkgconfig_dir 10 | 11 | __all__ = ( 12 | "version_info", 13 | "__version__", 14 | "get_include", 15 | "get_cmake_dir", 16 | "get_pkgconfig_dir", 17 | ) 18 | -------------------------------------------------------------------------------- /lib/kiss/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8...3.13) 2 | 3 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) 4 | 5 | add_library(kiss STATIC 6 | src/logger.cpp 7 | src/path.cpp 8 | src/string.cpp 9 | src/uuid.cpp 10 | ) 11 | 12 | SET_TARGET_PROPERTIES( kiss PROPERTIES COMPILE_FLAGS -fPIC) 13 | 14 | # testing 15 | if(ENABLE_TESTING) 16 | add_executable(test_uuid test/test_uuid.cpp) 17 | target_link_libraries(test_uuid kiss gtest gtest_main pthread) 18 | add_test(test_uuid test_uuid) 19 | endif(ENABLE_TESTING) 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # CMake 35 | build/* 36 | 37 | # Others 38 | doc/api/* 39 | .coverage 40 | *.dump 41 | *.DS_Store 42 | 43 | # Libraries 44 | 45 | # Editor stuff 46 | *.swp 47 | -------------------------------------------------------------------------------- /lib/cparamlib/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | # 3 | # Author: niklas@slac.stanford.edu 4 | # 5 | 6 | cparamlibdir = $(includedir)/cparamlib 7 | 8 | cparamlib_HEADERS = cparamlib.h 9 | cparamlib_SOURCE = antinue.c antinumu.c elec.c gamma.c nue.c numu.c posi.c sigma.c 10 | LIB_VERSION = 2:3:0 11 | 12 | library_includedir=$(includedir)/cparamlib 13 | 14 | AM_CPPFLAGS = -I$(top_srcdir) 15 | 16 | lib_LTLIBRARIES= libcparamlib.la 17 | libcparamlib_la_SOURCES= $(cparamlib_HEADERS) $(cparamlib_SOURCE) 18 | libcparamlib_la_LDFLAGS= -version-info $(LIB_VERSION) 19 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | # Required 6 | version: 2 7 | 8 | # Build documentation in the docs/ directory with Sphinx 9 | sphinx: 10 | configuration: doc/conf.py 11 | 12 | # Optionally build your docs in additional formats such as PDF 13 | #formats: 14 | # - pdf 15 | 16 | # Optionally set the version of Python and requirements required to build your docs 17 | python: 18 | version: 3.7 19 | install: 20 | - requirements: doc/sphinx-requirements.txt 21 | 22 | -------------------------------------------------------------------------------- /include/hermes/darkmatter/GalacticProfile.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_DARKMATTER_GALACTICPROFILE_H 2 | #define HERMES_DARKMATTER_GALACTICPROFILE_H 3 | 4 | #include "hermes/Units.h" 5 | 6 | namespace hermes { namespace darkmatter { 7 | /** 8 | * \addtogroup DarkMatter 9 | * @{ 10 | */ 11 | 12 | using namespace units; 13 | 14 | class GalacticProfile { 15 | public: 16 | GalacticProfile() {} 17 | virtual ~GalacticProfile() {} 18 | virtual QMassDensity getMassDensity(QLength r) const = 0; 19 | }; 20 | 21 | /** @}*/ 22 | }} // namespace hermes::darkmatter 23 | 24 | #endif // HERMES_DARKMATTER_GALACTICPROFILE_H 25 | -------------------------------------------------------------------------------- /lib/gtest/googletest/cmake/libgtest.la.in: -------------------------------------------------------------------------------- 1 | # libgtest.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Names of this library. 8 | library_names='libgtest.so' 9 | 10 | # Is this an already installed library? 11 | installed=yes 12 | 13 | # Should we warn about portability when linking against -modules? 14 | shouldnotlink=no 15 | 16 | # Files to dlopen/dlpreopen 17 | dlopen='' 18 | dlpreopen='' 19 | 20 | # Directory that this library needs to be installed in: 21 | libdir='@CMAKE_INSTALL_FULL_LIBDIR@' 22 | -------------------------------------------------------------------------------- /include/hermes/Version.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern const char g_GIT_SHA1[]; 4 | extern const char g_GIT_REFSPEC[]; 5 | extern const char g_GIT_DESC[]; 6 | 7 | /** 8 | @fn declare_version 9 | @brief A helper function to track the steering card version 10 | 11 | Use at the beginning of the (python) code by putting the string of 12 | the current version, e.g., declare_version("v0.9-1-ga343b23"). 13 | If there is a mismatch a warning message is shown. 14 | The current version number can be obtained through git: 15 | git describe --tags 16 | or through python: 17 | print(hermes.__version__) 18 | */ 19 | void declare_version(const std::string); 20 | -------------------------------------------------------------------------------- /include/hermes/darkmatter/DarkMatterSpectrum.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_DARKMATTERSPECTRUM_H 2 | #define HERMES_DARKMATTERSPECTRUM_H 3 | 4 | #include "hermes/Units.h" 5 | 6 | namespace hermes { namespace darkmatter { 7 | /** 8 | * \addtogroup DarkMatter 9 | * @{ 10 | */ 11 | 12 | using namespace units; 13 | 14 | class DarkMatterSpectrum { 15 | public: 16 | DarkMatterSpectrum() {} 17 | virtual ~DarkMatterSpectrum() {} 18 | virtual QEnergy getRestMassEnergy() const = 0; 19 | virtual QInverseEnergy getParticlesPerEnergy(QEnergy Egamma) const = 0; 20 | }; 21 | 22 | /** @}*/ 23 | }} // namespace hermes::darkmatter 24 | 25 | #endif // HERMES_DARKMATTERSPECTRUM_H 26 | -------------------------------------------------------------------------------- /include/hermes/interactions/BreitWheeler.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_BREITWHEELER_H 2 | #define HERMES_BREITWHEELER_H 3 | 4 | #include 5 | 6 | #include "hermes/interactions/DiffCrossSection.h" 7 | 8 | namespace hermes { namespace interactions { 9 | /** 10 | * \addtogroup Interactions 11 | * @{ 12 | */ 13 | 14 | class BreitWheeler { 15 | public: 16 | BreitWheeler(); 17 | 18 | QArea getCrossSection(const QEnergy &Egamma, const QEnergy &Eph, const QAngle &theta) const; 19 | QArea integratedOverTheta(const QEnergy &Egamma, const QEnergy &Eph) const; 20 | }; 21 | 22 | /** @}*/ 23 | }} // namespace hermes::interactions 24 | 25 | #endif // HERMES_BREITWHEELER_H 26 | -------------------------------------------------------------------------------- /include/hermes/interactions/KleinNishina.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_KLEINNISHINA_H 2 | #define HERMES_KLEINNISHINA_H 3 | 4 | #include 5 | 6 | #include "hermes/interactions/DiffCrossSection.h" 7 | 8 | namespace hermes { namespace interactions { 9 | /** 10 | * \addtogroup Interactions 11 | * @{ 12 | */ 13 | 14 | class KleinNishina : public DifferentialCrossSection { 15 | public: 16 | KleinNishina(); 17 | 18 | QDiffCrossSection getDiffCrossSection( 19 | const QEnergy &E_electron, const QEnergy &E_photon, 20 | const QEnergy &E_gamma) const override; 21 | }; 22 | 23 | /** @}*/ 24 | }} // namespace hermes::interactions 25 | 26 | #endif // HERMES_KLEINNISHINA_H 27 | -------------------------------------------------------------------------------- /test/testNumericalIntegration.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "gtest/gtest.h" 5 | #include "hermes.h" 6 | 7 | namespace hermes { 8 | 9 | TEST(NumericalIntegration, simpsonIntegration) { 10 | auto integrand = [](const QLength &dist) { 11 | return sin(dist / 1_m * 1_rad); 12 | }; 13 | QLength r = simpsonIntegration( 14 | [integrand](QLength dist) { return integrand(dist); }, 0, 10, 100); 15 | EXPECT_NEAR(static_cast(r), 2 * std::pow(std::sin(5), 2), 0.001); 16 | } 17 | 18 | int main(int argc, char **argv) { 19 | ::testing::InitGoogleTest(&argc, argv); 20 | return RUN_ALL_TESTS(); 21 | } 22 | 23 | } // namespace hermes 24 | -------------------------------------------------------------------------------- /src/ionizedgas/HII_Cordes91.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/ionizedgas/HII_Cordes91.h" 2 | 3 | namespace hermes { namespace ionizedgas { 4 | 5 | HII_Cordes91::HII_Cordes91() { 6 | setTemperature(1e4_K); 7 | 8 | fne1 = 0.025 / 1_cm3; 9 | H1 = 1.00_kpc; 10 | A1 = 20.0_kpc; 11 | fne2 = 0.200 / 1_cm3; 12 | H2 = 0.15_kpc; 13 | A2 = 2.0_kpc; 14 | R2 = 4.0_kpc; 15 | } 16 | 17 | QPDensity HII_Cordes91::getDensity(const Vector3QLength &pos) const { 18 | QLength r = pos.getR(); 19 | QPDensity ne1 = fne1 * exp(-fabs(pos.z) / H1) * exp(-pow<2>(r / A1)); 20 | QPDensity ne2 = fne2 * exp(-fabs(pos.z) / H2) * exp(-pow<2>((r - R2) / A2)); 21 | return ne1 + ne2; 22 | } 23 | 24 | }} // namespace hermes::ionizedgas 25 | -------------------------------------------------------------------------------- /lib/pybind11/.gitignore: -------------------------------------------------------------------------------- 1 | CMakeCache.txt 2 | CMakeFiles 3 | Makefile 4 | cmake_install.cmake 5 | cmake_uninstall.cmake 6 | .DS_Store 7 | *.so 8 | *.pyd 9 | *.dll 10 | *.sln 11 | *.sdf 12 | *.opensdf 13 | *.vcxproj 14 | *.vcxproj.user 15 | *.filters 16 | example.dir 17 | Win32 18 | x64 19 | Release 20 | Debug 21 | .vs 22 | CTestTestfile.cmake 23 | Testing 24 | autogen 25 | MANIFEST 26 | /.ninja_* 27 | /*.ninja 28 | /docs/.build 29 | *.py[co] 30 | *.egg-info 31 | *~ 32 | .*.swp 33 | .DS_Store 34 | /dist 35 | /*build* 36 | .cache/ 37 | sosize-*.txt 38 | pybind11Config*.cmake 39 | pybind11Targets.cmake 40 | /*env* 41 | /.vscode 42 | /pybind11/include/* 43 | /pybind11/share/* 44 | /docs/_build/* 45 | .ipynb_checkpoints/ 46 | tests/main.cpp 47 | -------------------------------------------------------------------------------- /test/testMFieldModels.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | #include "hermes.h" 3 | 4 | namespace hermes { 5 | 6 | TEST(Sun08, disk) { 7 | auto Sun08 = std::make_shared( 8 | magneticfields::Sun08()); 9 | Sun08->setUseHalo(false); 10 | 11 | Vector3QMField B1 = Sun08->getField(Vector3QLength(0, 2_kpc, 0)); 12 | Vector3QMField B2 = Sun08->getField(Vector3QLength(0, -2_kpc, 0)); 13 | 14 | EXPECT_DOUBLE_EQ(static_cast(B1.x), static_cast(-B2.x)); 15 | EXPECT_DOUBLE_EQ(static_cast(B1.y), static_cast(-B2.y)); 16 | } 17 | 18 | int main(int argc, char **argv) { 19 | ::testing::InitGoogleTest(&argc, argv); 20 | return RUN_ALL_TESTS(); 21 | } 22 | 23 | } // namespace hermes 24 | -------------------------------------------------------------------------------- /include/hermes/skymaps/RotationMeasureSkymap.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_ROTATIONMEASURESKYMAP_H 2 | #define HERMES_ROTATIONMEASURESKYMAP_H 3 | 4 | #include 5 | 6 | namespace hermes { 7 | /** 8 | * \addtogroup Skymaps 9 | * @{ 10 | */ 11 | 12 | /** 13 | @class RotationMeasureSkymap 14 | @brief A skymap container for rotation measure (RM). 15 | */ 16 | class RotationMeasureSkymap : public SkymapTemplate { 17 | private: 18 | public: 19 | RotationMeasureSkymap(std::size_t nside) : SkymapTemplate(nside) { 20 | initDefaultOutputUnits(1_rad / 1_m2, "rad m^-2"); 21 | }; 22 | }; 23 | 24 | /** @}*/ 25 | 26 | } // namespace hermes 27 | #endif // HERMES_ROTATIONMEASURESKYMAP_H 28 | -------------------------------------------------------------------------------- /lib/pybind11/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Security updates are applied only to the latest release. 6 | 7 | ## Reporting a Vulnerability 8 | 9 | If you have discovered a security vulnerability in this project, please report it privately. **Do not disclose it as a public issue.** This gives us time to work with you to fix the issue before public exposure, reducing the chance that the exploit will be used before a patch is released. 10 | 11 | Please disclose it at [security advisory](https://github.com/pybind/pybind11/security/advisories/new). 12 | 13 | This project is maintained by a team of volunteers on a reasonable-effort basis. As such, please give us at least 90 days to work on a fix before public exposure. 14 | -------------------------------------------------------------------------------- /include/hermes/neutralgas/ProfileAbstract.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_NEUTRALGAS_PROFILEABSTRACT_H 2 | #define HERMES_NEUTRALGAS_PROFILEABSTRACT_H 3 | 4 | #include "hermes/Units.h" 5 | #include "hermes/Vector3Quantity.h" 6 | #include "hermes/neutralgas/GasType.h" 7 | 8 | namespace hermes { namespace neutralgas { 9 | /** 10 | * \addtogroup NeutralGas 11 | * @{ 12 | */ 13 | 14 | using namespace units; 15 | 16 | class ProfileAbstract { 17 | public: 18 | ProfileAbstract() {} 19 | virtual ~ProfileAbstract() {} 20 | 21 | virtual QPDensity getPDensity(GasType gas, 22 | const Vector3QLength &pos) const = 0; 23 | }; 24 | 25 | /** @}*/ 26 | }} // namespace hermes::neutralgas 27 | 28 | #endif // HERMES_NEUTRALGAS_PROFILEABSTRACT_H 29 | -------------------------------------------------------------------------------- /include/hermes/skymaps/DispersionMeasureSkymap.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_DISPERSIONMEASURESKYMAP_H 2 | #define HERMES_DISPERSIONMEASURESKYMAP_H 3 | 4 | #include 5 | 6 | namespace hermes { 7 | 8 | /** 9 | * \addtogroup Skymaps 10 | * @{ 11 | */ 12 | 13 | /** 14 | @class DispersionMeasureSkymap 15 | @brief A skymap container for dispersion measure (DM). 16 | */ 17 | class DispersionMeasureSkymap 18 | : public SkymapTemplate { 19 | public: 20 | DispersionMeasureSkymap(std::size_t nside) : SkymapTemplate(nside) { 21 | initDefaultOutputUnits(parsec / centimetre3, "parsec^-1 cm^3"); 22 | }; 23 | }; 24 | /** @}*/ 25 | 26 | } // namespace hermes 27 | #endif // HERMES_DISPERSIONMEASURESKYMAP_H 28 | -------------------------------------------------------------------------------- /lib/kiss/test/test_uuid.cpp: -------------------------------------------------------------------------------- 1 | #include "kiss/uuid.h" 2 | 3 | #include "gtest/gtest.h" 4 | 5 | using namespace kiss; 6 | 7 | TEST(testUUID, creation) { 8 | uuid id1 = uuid::parse("69c09be0-638b-11e1-b86c-0800200c9a66"); 9 | uuid id2 = uuid::parse("69c09be0-638b-11e1-b86c-0800200c9a66"); 10 | uuid id3 = uuid::parse("69c09be1-638b-11e1-b86c-0800200c9a66"); 11 | 12 | EXPECT_EQ(id1, id2); 13 | EXPECT_NE(id1, id3); 14 | } 15 | 16 | TEST(testUUID, uniqueness) { 17 | uuid reference = uuid::create(); 18 | 19 | for (size_t i = 0; i < 100000000; i++) { 20 | uuid probe = uuid::create(); 21 | EXPECT_NE(reference, probe); 22 | } 23 | } 24 | 25 | int main(int argc, char **argv) { 26 | ::testing::InitGoogleTest(&argc, argv); 27 | return RUN_ALL_TESTS(); 28 | } 29 | -------------------------------------------------------------------------------- /include/hermes/cosmicrays/SimpleCR.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_SIMPLECRDENSITY_H 2 | #define HERMES_SIMPLECRDENSITY_H 3 | 4 | #include "hermes/cosmicrays/CosmicRayDensity.h" 5 | 6 | namespace hermes { namespace cosmicrays { 7 | /** 8 | * \addtogroup CosmicRays 9 | * @{ 10 | */ 11 | 12 | class SimpleCR : public CosmicRayDensity { 13 | private: 14 | QEnergy minE, maxE; 15 | int steps; 16 | void makeEnergyRange(); 17 | 18 | public: 19 | SimpleCR(const PID &pid = Proton); 20 | SimpleCR(const PID &pid, QEnergy minE, QEnergy maxE, int steps); 21 | QPDensityPerEnergy getDensityPerEnergy( 22 | const QEnergy &E_, const Vector3QLength &pos_) const override; 23 | }; 24 | 25 | /** @}*/ 26 | }} // namespace hermes::cosmicrays 27 | 28 | #endif // HERMES_SIMPLECRDENSITY_H 29 | -------------------------------------------------------------------------------- /include/hermes/neutralgas/Nakanishi06.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_NEUTRALGAS_NAKANISHI06_H 2 | #define HERMES_NEUTRALGAS_NAKANISHI06_H 3 | 4 | #include "hermes/neutralgas/ProfileAbstract.h" 5 | 6 | namespace hermes { namespace neutralgas { 7 | /** 8 | * \addtogroup NeutralGas 9 | * @{ 10 | */ 11 | 12 | class Nakanishi06 : public ProfileAbstract { 13 | private: 14 | public: 15 | Nakanishi06(); 16 | ~Nakanishi06(); 17 | 18 | QPDensity getHIDensity(const Vector3QLength &pos) const; 19 | QPDensity getH2Density(const Vector3QLength &pos) const; 20 | QPDensity getPDensity(GasType gas, 21 | const Vector3QLength &pos) const override; 22 | }; 23 | 24 | /** @}*/ 25 | }} // namespace hermes::neutralgas 26 | 27 | #endif // HERMES_NEUTRALGAS_NAKANISHI06_H 28 | -------------------------------------------------------------------------------- /include/hermes/cosmicrays/DummyCR.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_DUMMYCRDENSITY_H 2 | #define HERMES_DUMMYCRDENSITY_H 3 | 4 | #include "hermes/cosmicrays/CosmicRayDensity.h" 5 | 6 | namespace hermes { namespace cosmicrays { 7 | /** 8 | * \addtogroup CosmicRays 9 | * @{ 10 | */ 11 | 12 | class DummyCR : public CosmicRayDensity { 13 | private: 14 | QEnergy minE, maxE; 15 | int steps; 16 | void makeEnergyRange(); 17 | 18 | public: 19 | DummyCR(); 20 | DummyCR(const PID &pid); 21 | DummyCR(const PID &pid, const QEnergy &minE, const QEnergy &maxE, 22 | int steps); 23 | QPDensityPerEnergy getDensityPerEnergy( 24 | const QEnergy &E_, const Vector3QLength &pos_) const override; 25 | }; 26 | 27 | /** @}*/ 28 | }} // namespace hermes::cosmicrays 29 | 30 | #endif // HERMES_DUMMYCRDENSITY_H 31 | -------------------------------------------------------------------------------- /include/hermes/ionizedgas/HII_Cordes91.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_HIICORDES91_H 2 | #define HERMES_HIICORDES91_H 3 | 4 | #include "hermes/ionizedgas/IonizedGasDensity.h" 5 | 6 | namespace hermes { namespace ionizedgas { 7 | /** 8 | * \addtogroup IonizedGas 9 | * @{ 10 | */ 11 | 12 | /** 13 | * \class HII_Cordes91 14 | * \brief A model of free electron distribution based on Cordes et al. 1991. 15 | * 16 | * Cordes, J. M. et al. 1991, doi:10.1038/354121a0 17 | */ 18 | class HII_Cordes91 : public IonizedGasDensity { 19 | private: 20 | QPDensity fne1, fne2; 21 | QLength H1, A1, H2, A2, R2; 22 | 23 | public: 24 | HII_Cordes91(); 25 | QPDensity getDensity(const Vector3QLength &pos) const override; 26 | }; 27 | 28 | /** @}*/ 29 | }} // namespace hermes::ionizedgas 30 | 31 | #endif // HERMES_HIICORDES91_H 32 | -------------------------------------------------------------------------------- /include/hermes/units/UnitsHERMES.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_UNITSHERMES_H 2 | #define HERMES_UNITSHERMES_H 3 | 4 | #include "UnitsDerived.h" 5 | 6 | namespace hermes { namespace units { 7 | 8 | // HERMES specific types 9 | // ------------------------------------ 10 | // l t m I T N J A 11 | QUANTITY_TYPE(1, -1, 0, 0, 1, 0, 0, 0, 0, QRingCOIntensity); 12 | QUANTITY_TYPE(2, 0, 0, 1, 0, 0, 0, 0, 0, QSynchroConstant); 13 | QUANTITY_TYPE(-2, 1, -1, 0, 0, 0, 0, 0, 0, QPiZeroIntegral); 14 | QUANTITY_TYPE(-3, 0, 0, 0, 0, 0, 0, 1, 0, QRMIntegral); 15 | QUANTITY_TYPE(-3, 1, 0, 0, -1, 0, 0, 0, 0, QRingX0Unit); 16 | QUANTITY_TYPE(-3, 2, -1, 0, 0, 0, 0, 0, 0, QICInnerIntegral); 17 | QUANTITY_TYPE(-5, 1, -1, 0, 0, 0, 0, 0, 0, QGREmissivity); 18 | 19 | }} // namespace hermes::units 20 | 21 | #endif // HERMES_UNITSHERMES_H 22 | -------------------------------------------------------------------------------- /include/hermes/HEALPixBits.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_HEALPIXBITS_H 2 | #define HERMES_HEALPIXBITS_H 3 | 4 | #include 5 | 6 | #include "hermes/Units.h" 7 | 8 | namespace hermes { 9 | 10 | using namespace units; 11 | 12 | static const double UNSEEN = -1.6375e30; 13 | 14 | unsigned int log2(unsigned int x); 15 | 16 | // Adopted from HEALPix pix2ang_ring (https://healpix.sourceforge.io/) 17 | long nside2order(unsigned int nside); 18 | unsigned int nside2npix(unsigned int nside); 19 | QDirection pix2ang_ring(unsigned int nside, unsigned int ipix); 20 | unsigned int ang2pix_ring(unsigned int nside, const QDirection &thetaphi); 21 | unsigned int loc2pix(unsigned int nside, double z, double phi, double sth, 22 | bool have_sth); 23 | 24 | } // namespace hermes 25 | 26 | #endif // HERMES_HEALPIXBITS_H 27 | -------------------------------------------------------------------------------- /lib/kiss/include/kiss/string.h: -------------------------------------------------------------------------------- 1 | #ifndef KISS_STRING_H 2 | #define KISS_STRING_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace kiss { 9 | 10 | #define SPACES " \t\r\n" 11 | 12 | std::string trim_right(const std::string &s, const std::string &t); 13 | std::string trim_left(const std::string &s, const std::string &t); 14 | 15 | std::string trim(const std::string &s, const std::string &t = SPACES); 16 | void explode(const std::string &s, std::vector &v, 17 | const bool trim_spaces, const std::string &t); 18 | std::string implode(const std::vector &v, const std::string &t); 19 | bool ends_with(const std::string &s, const std::string &w); 20 | bool starts_with(const std::string &s, const std::string &w); 21 | 22 | } // namespace kiss 23 | 24 | #endif /* KISS_STRING_H */ 25 | -------------------------------------------------------------------------------- /include/hermes/cosmicrays/WMAP07.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_WMAP07_H 2 | #define HERMES_WMAP07_H 3 | 4 | #include "hermes/cosmicrays/CosmicRayDensity.h" 5 | 6 | namespace hermes { namespace cosmicrays { 7 | /** 8 | * \addtogroup CosmicRays 9 | * @{ 10 | */ 11 | 12 | class WMAP07 : public CosmicRayDensity { 13 | private: 14 | QEnergy minE, maxE; 15 | int spectralIndex; 16 | QEnergy E_0, E_cutoff; 17 | QPDensity C_0, C_Earth; 18 | QLength h_r, h_d, r_Earth; 19 | int steps; 20 | void makeEnergyRange(); 21 | void setParameters(); 22 | 23 | public: 24 | WMAP07(); 25 | WMAP07(QEnergy minE_, QEnergy maxE_, int steps_); 26 | QPDensityPerEnergy getDensityPerEnergy( 27 | const QEnergy &E_, const Vector3QLength &pos_) const override; 28 | }; 29 | 30 | /** @}*/ 31 | }} // namespace hermes::cosmicrays 32 | 33 | #endif // HERMES_WMAP07_H 34 | -------------------------------------------------------------------------------- /include/hermes/neutralgas/NeutralGasAbstract.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_NEUTRALGASABSTRACT_H 2 | #define HERMES_NEUTRALGASABSTRACT_H 3 | 4 | #include "hermes/Grid.h" 5 | #include "hermes/Units.h" 6 | 7 | namespace hermes { namespace neutralgas { 8 | /** 9 | * \addtogroup NeutralGas 10 | * @{ 11 | */ 12 | 13 | class NeutralGasAbstract { 14 | private: 15 | QTemperature gasTemp; 16 | 17 | public: 18 | NeutralGasAbstract() : gasTemp(1e4_K) {} 19 | NeutralGasAbstract(QTemperature T) : gasTemp(T) {} 20 | 21 | virtual ~NeutralGasAbstract() {} 22 | 23 | virtual int getRingNumber() const = 0; 24 | 25 | inline void setTemperature(QTemperature T) { gasTemp = T; } 26 | inline QTemperature getTemperature() const { return gasTemp; } 27 | }; 28 | 29 | /** @}*/ 30 | }} // namespace hermes::neutralgas 31 | 32 | #endif // HERMES_NEUTRALGASABSTRACT_H 33 | -------------------------------------------------------------------------------- /include/hermes/cosmicrays/Sun08.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_SUN08CRDENSITY_H 2 | #define HERMES_SUN08CRDENSITY_H 3 | 4 | #include "hermes/cosmicrays/CosmicRayDensity.h" 5 | 6 | namespace hermes { namespace cosmicrays { 7 | /** 8 | * \addtogroup CosmicRays 9 | * @{ 10 | */ 11 | 12 | class Sun08 : public CosmicRayDensity { 13 | private: 14 | QEnergy minE, maxE; 15 | int spectralIndex; 16 | QEnergy E_0, E_cutoff; 17 | QPDensity C_0; 18 | QLength h_r, h_d, r_Earth; 19 | int steps; 20 | void makeEnergyRange(); 21 | void setParameters(); 22 | 23 | public: 24 | Sun08(); 25 | Sun08(QEnergy minE_, QEnergy maxE_, int steps_); 26 | QPDensityPerEnergy getDensityPerEnergy( 27 | const QEnergy &E_, const Vector3QLength &pos_) const override; 28 | }; 29 | 30 | /** @}*/ 31 | }} // namespace hermes::cosmicrays 32 | 33 | #endif // HERMES_SUN08CRDENSITY_H 34 | -------------------------------------------------------------------------------- /include/hermes/ionizedgas/IonizedGasDensity.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_IONIZEDGASDENSITY_H 2 | #define HERMES_IONIZEDGASDENSITY_H 3 | 4 | #include "hermes/Grid.h" 5 | #include "hermes/Units.h" 6 | 7 | namespace hermes { namespace ionizedgas { 8 | /** 9 | * \addtogroup IonizedGas 10 | * @{ 11 | */ 12 | 13 | class IonizedGasDensity { 14 | private: 15 | QTemperature gasTemp; 16 | 17 | public: 18 | IonizedGasDensity() : gasTemp(1e4_K) {} 19 | IonizedGasDensity(QTemperature T) : gasTemp(T) {} 20 | virtual ~IonizedGasDensity() {} 21 | virtual QPDensity getDensity(const Vector3QLength &pos) const = 0; 22 | 23 | inline void setTemperature(QTemperature T) { gasTemp = T; } 24 | inline QTemperature getTemperature() const { return gasTemp; } 25 | }; 26 | 27 | /** @}*/ 28 | }} // namespace hermes::ionizedgas 29 | 30 | #endif // HERMES_IONIZEDGASDENSITY_H 31 | -------------------------------------------------------------------------------- /python/outputs.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "hermes/outputs/CTAFormat.h" 5 | #include "hermes/outputs/HEALPixFormat.h" 6 | #include "hermes/outputs/Output.h" 7 | 8 | namespace py = pybind11; 9 | 10 | namespace hermes { namespace outputs { 11 | 12 | void init(py::module &m) { 13 | py::module subm = m.def_submodule("outputs"); 14 | subm.doc() = "outputs package"; 15 | 16 | // NOLINTNEXTLINE(bugprone-unused-raii) 17 | py::class_>(subm, "Output"); 18 | py::class_, Output>( 19 | subm, "HEALPixFormat") 20 | .def(py::init()); 21 | py::class_, Output>( 22 | subm, "CTAFormat") 23 | .def(py::init()); 24 | } 25 | 26 | }} // namespace hermes::outputs 27 | -------------------------------------------------------------------------------- /include/hermes/interactions/BremsstrahlungTsai74.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_BREMSSTRAHLUNGTSAI74_H 2 | #define HERMES_BREMSSTRAHLUNGTSAI74_H 3 | 4 | #include "hermes/interactions/BremsstrahlungAbstract.h" 5 | 6 | namespace hermes { namespace interactions { 7 | /** 8 | * \addtogroup Interactions 9 | * @{ 10 | */ 11 | 12 | // Rev. Mod. Phys. 46, 815 (1974). 13 | class BremsstrahlungTsai74 : public BremsstrahlungAbstract { 14 | private: 15 | std::pair RadiationLogarithms(int Z) const; 16 | double computeCoulombCorrection(int Z, std::size_t n_max = 100) const; 17 | 18 | public: 19 | BremsstrahlungTsai74(); 20 | 21 | QDiffCrossSection getDiffCrossSectionForTarget( 22 | Target t, const QEnergy &T_electron, 23 | const QEnergy &E_gamma) const override; 24 | }; 25 | 26 | /** @}*/ 27 | }} // namespace hermes::interactions 28 | 29 | #endif // HERMES_BREMSSTRAHLUNGTSAI74_H 30 | -------------------------------------------------------------------------------- /python/Common.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/Common.h" 2 | #include "hermes/Version.h" 3 | #include "hermes/HEALPixBits.h" 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace py = pybind11; 11 | 12 | namespace hermes { 13 | 14 | void init_common(py::module &m) { 15 | m.def("getDataPath", &getDataPath); 16 | m.def("toGalCoord", &toGalCoord); 17 | m.def("fromGalCoord", &fromGalCoord); 18 | m.def("getLorentzFactor", &getLorentzFactor); 19 | m.def("intensityToTemperature", &intensityToTemperature); 20 | 21 | m.attr("UNSEEN") = UNSEEN; 22 | m.def("ang2pix_ring", &ang2pix_ring); 23 | m.def("pix2ang_ring", &pix2ang_ring); 24 | m.def("nside2npix", &nside2npix); 25 | m.def("nside2order", &nside2order); 26 | m.def("loc2pix", &loc2pix); 27 | 28 | m.attr("__version__") = std::string(g_GIT_DESC); 29 | } 30 | 31 | } // namespace hermes 32 | -------------------------------------------------------------------------------- /include/hermes/outputs/Output.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_OUTPUT_H 2 | #define HERMES_OUTPUT_H 3 | 4 | #include 5 | 6 | namespace hermes { namespace outputs { 7 | 8 | class Output { 9 | public: 10 | const std::string outputName; 11 | 12 | Output() {} 13 | virtual ~Output() {} 14 | 15 | virtual void createTable(int, const std::string &) = 0; 16 | virtual void writeMetadata(int, double, bool, const std::string &) = 0; 17 | virtual void writeKeyValueAsDouble(const std::string &key, double value, 18 | const std::string &description) = 0; 19 | virtual void writeKeyValueAsString(const std::string &key, 20 | const std::string &value, 21 | const std::string &description) = 0; 22 | virtual void writeColumn(int, void *) = 0; 23 | }; 24 | 25 | }} // namespace hermes::outputs 26 | 27 | #endif // HERMES_OUTPUT_H 28 | -------------------------------------------------------------------------------- /src/skymaps/Skymap.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/skymaps/Skymap.h" 2 | 3 | #include 4 | 5 | namespace hermes { 6 | 7 | Skymap::Skymap(std::size_t nside_) { 8 | setNside(nside_); 9 | const std::type_info &info = typeid(*this); 10 | setDescription(info.name()); 11 | } 12 | 13 | std::string Skymap::getDescription() const { return description; } 14 | 15 | void Skymap::setDescription(const std::string &description_) { 16 | description = description_; 17 | } 18 | 19 | void Skymap::setNside(std::size_t nside_) { 20 | nside = nside_; 21 | res = log2(nside_); 22 | npix = nside2npix(nside_); 23 | } 24 | 25 | std::size_t Skymap::getNside() const { return nside; } 26 | 27 | void Skymap::setRes(std::size_t res_) { 28 | res = res_; 29 | setNside(1 << res); // 2*res 30 | } 31 | 32 | std::size_t Skymap::getRes() const { return res; } 33 | 34 | std::size_t Skymap::getNpix() const { return npix; } 35 | 36 | } // namespace hermes 37 | -------------------------------------------------------------------------------- /lib/pybind11/tools/JoinPaths.cmake: -------------------------------------------------------------------------------- 1 | # This module provides function for joining paths 2 | # known from most languages 3 | # 4 | # SPDX-License-Identifier: (MIT OR CC0-1.0) 5 | # Copyright 2020 Jan Tojnar 6 | # https://github.com/jtojnar/cmake-snips 7 | # 8 | # Modelled after Python’s os.path.join 9 | # https://docs.python.org/3.7/library/os.path.html#os.path.join 10 | # Windows not supported 11 | function(join_paths joined_path first_path_segment) 12 | set(temp_path "${first_path_segment}") 13 | foreach(current_segment IN LISTS ARGN) 14 | if(NOT ("${current_segment}" STREQUAL "")) 15 | if(IS_ABSOLUTE "${current_segment}") 16 | set(temp_path "${current_segment}") 17 | else() 18 | set(temp_path "${temp_path}/${current_segment}") 19 | endif() 20 | endif() 21 | endforeach() 22 | set(${joined_path} "${temp_path}" PARENT_SCOPE) 23 | endfunction() 24 | -------------------------------------------------------------------------------- /include/hermes/interactions/BremsstrahlungAbstract.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_BREMSSTRAHLUNGABSTRACT_H 2 | #define HERMES_BREMSSTRAHLUNGABSTRACT_H 3 | 4 | #include "hermes/interactions/DiffCrossSection.h" 5 | 6 | namespace hermes { namespace interactions { 7 | /** 8 | * \addtogroup Interactions 9 | * @{ 10 | */ 11 | 12 | class BremsstrahlungAbstract : public DifferentialCrossSection { 13 | public: 14 | constexpr static std::size_t Ntargets = 3; 15 | enum class Target { HII, HI, He }; 16 | const std::array allTargets = { 17 | // to iterate over targets 18 | Target::HII, Target::HI, Target::He}; 19 | 20 | BremsstrahlungAbstract(){}; 21 | virtual ~BremsstrahlungAbstract(){}; 22 | 23 | virtual QDiffCrossSection getDiffCrossSectionForTarget( 24 | Target t, const QEnergy &T_electron, const QEnergy &E_gamma) const = 0; 25 | }; 26 | 27 | /** @}*/ 28 | }} // namespace hermes::interactions 29 | 30 | #endif // HERMES_BREMSSTRAHLUNGABSTRACT_H 31 | -------------------------------------------------------------------------------- /include/hermes/darkmatter/NFWGProfile.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_DARKMATTER_NFWGPROFILE_H 2 | #define HERMES_DARKMATTER_NFWGPROFILE_H 3 | 4 | #include 5 | 6 | #include "hermes/darkmatter/GalacticProfile.h" 7 | 8 | namespace hermes { namespace darkmatter { 9 | /** 10 | * \addtogroup DarkMatter 11 | * @{ 12 | */ 13 | 14 | class NFWGProfile : public GalacticProfile { 15 | private: 16 | const QMassDensity rho_cr = 9.1e-30 * 1_g / 1_cm3; // WMAP-9 17 | 18 | // input 19 | double gamma; 20 | double concentration; 21 | QMass M_200; 22 | 23 | // derived 24 | QLength R_200; 25 | QMassDensity rho_s; 26 | QLength r_s; 27 | 28 | protected: 29 | void init(); 30 | 31 | public: 32 | NFWGProfile(double gamma, double c, QMass M_200); 33 | ~NFWGProfile() = default; 34 | QMassDensity getMassDensity(QLength r) const override; 35 | QMassDensity getRhoSun() const; 36 | }; 37 | 38 | /** @}*/ 39 | }} // namespace hermes::darkmatter 40 | 41 | #endif // HERMES_DARKMATTER_NFWGPROFILE_H 42 | -------------------------------------------------------------------------------- /include/hermes/outputs/TextOutput.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_TEXTOUTPUT_H 2 | #define HERMES_TEXTOUTPUT_H 3 | 4 | #include "hermes/outputs/Output.h" 5 | 6 | #include 7 | #include 8 | 9 | namespace hermes { 10 | 11 | class TextOutput: public Output { 12 | private: 13 | std::string filename; 14 | std::ostream *out; 15 | std::ofstream outfile; 16 | public: 17 | TextOutput(const std::string &filename); 18 | void initOutput() override; 19 | void createTable(int nrows) override; 20 | void writeMetadata(int nside, double res, 21 | const std::string &description) override; 22 | void writeKeyValueAsDouble( 23 | const std::string &key, double value, 24 | const std::string &description) override; 25 | void writeKeyValueAsString( 26 | const std::string &key, const std::string &value, 27 | const std::string &description) override; 28 | void writeColumn(int nElements, void *array) override; 29 | }; 30 | 31 | } // namespace hermes 32 | 33 | #endif // HERMES_TEXTOUTPUT_H 34 | -------------------------------------------------------------------------------- /include/hermes/ParticleID.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_PARTICLEID_H 2 | #define HERMES_PARTICLEID_H 3 | 4 | #include 5 | 6 | namespace hermes { 7 | 8 | class PID { 9 | protected: 10 | int Z; 11 | int A; 12 | int id; 13 | 14 | public: 15 | PID(int Z_, int A_) : Z(Z_), A(A_) { 16 | assert(A_ >= 0); 17 | id = Z * 100 + A; 18 | } 19 | 20 | int getID() const { return id; } 21 | 22 | virtual ~PID() {} 23 | 24 | bool isNucleus() { return (A > 0); } 25 | 26 | int atomicNr() const { return Z; } 27 | 28 | int massNr() const { return A; } 29 | 30 | bool operator<(const PID &p2) const { return id < p2.getID(); } 31 | 32 | bool operator>(const PID &p2) const { return id > p2.getID(); } 33 | 34 | bool operator==(const PID &p2) const { return id == p2.getID(); } 35 | }; 36 | 37 | static const PID Electron(-1, 0); 38 | static const PID Positron(1, 0); 39 | static const PID Proton(1, 1); 40 | static const PID Helium(2, 4); 41 | 42 | } // namespace hermes 43 | 44 | #endif // HERMES_PARTICLEID_H 45 | -------------------------------------------------------------------------------- /include/hermes/magneticfields/WMAP07.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_WMAP07_H 2 | #define HERMES_WMAP07_H 3 | 4 | #include "hermes/magneticfields/MagneticField.h" 5 | 6 | namespace hermes { namespace magneticfields { 7 | /** 8 | * \addtogroup MagneticFields 9 | * @{ 10 | */ 11 | 12 | /** 13 | @class WMAP07 14 | @brief 3-year WMAP galactic magnetic field model 15 | 16 | The implemention of the galactic magnetic field model used in 3-year WMAP analyses. 17 | Note the distance from the galactic centre 8 kpc. 18 | 19 | See: L. Page et al 2007 ApJS 170 335, 20 | https://iopscience.iop.org/article/10.1086/513699 21 | */ 22 | 23 | class WMAP07 : public MagneticField { 24 | private: 25 | QMField B_0; 26 | QLength r_0; 27 | QLength z_0; 28 | QAngle chi_0; 29 | QAngle psi_1; 30 | QAngle psi_0; 31 | 32 | public: 33 | WMAP07(); 34 | Vector3QMField getField(const Vector3QLength &pos) const override; 35 | }; 36 | 37 | /** @} */ 38 | }} // namespace hermes::magneticfields 39 | 40 | #endif // HERMES_WMAP07_H 41 | -------------------------------------------------------------------------------- /include/hermes/interactions/KelnerAharonianNeutrino.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_KELNERAHARONIANNEUTRINO_H 2 | #define HERMES_KELNERAHARONIANNEUTRINO_H 3 | 4 | /* 5 | Model from Phys.Rev.D74:034018,2006; Erratum-ibid.D79:039901,2009 6 | arXiv:astro-ph/0606058 7 | */ 8 | 9 | #include 10 | 11 | #include "hermes/interactions/DiffCrossSection.h" 12 | #include "hermes/interactions/KelnerAharonianGamma.h" 13 | 14 | namespace hermes { namespace interactions { 15 | /** 16 | * \addtogroup Interactions 17 | * @{ 18 | */ 19 | 20 | class KelnerAharonianNeutrino : public DifferentialCrossSection { 21 | public: 22 | KelnerAharonianNeutrino(); 23 | QDiffCrossSection getDiffCrossSection(const QEnergy &E_proton, const QEnergy &E_nu) const override; 24 | QDiffCrossSection getDiffCrossSection(const PID &projectile, const PID &target, const QEnergy &E_proj, 25 | const QEnergy &E_secondary) const override; 26 | }; 27 | 28 | /** @}*/ 29 | }} // namespace hermes::interactions 30 | 31 | #endif // HERMES_KELNERAHARONIANNEUTRINO_H 32 | -------------------------------------------------------------------------------- /include/hermes/ionizedgas/NE2001Simple.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_NE2001SIMPLE_H 2 | #define HERMES_NE2001SIMPLE_H 3 | 4 | #include "hermes/ionizedgas/IonizedGasDensity.h" 5 | 6 | namespace hermes { namespace ionizedgas { 7 | /** 8 | * \addtogroup IonizedGas 9 | * @{ 10 | */ 11 | 12 | class NE2001Simple : public IonizedGasDensity { 13 | private: 14 | int N_arms; 15 | QNumber F1, F2; 16 | QPDensity n1, n2, n_a, n_GC; 17 | QLength H1, H2, H_a, A1, A2, A_a, R2, R_Sun; 18 | QLength x_GC, y_GC, z_GC, r_GC, h_GC, H_GC; 19 | 20 | double h(const QNumber &x) const; 21 | 22 | public: 23 | NE2001Simple(); 24 | QPDensity getDensity(const Vector3QLength &pos) const override; 25 | QPDensity getThickDiskDensity(const Vector3QLength &pos) const; 26 | QPDensity getThinDiskDensity(const Vector3QLength &pos) const; 27 | QPDensity getSpiralArmsDensity(const Vector3QLength &pos) const; 28 | QPDensity getGalacticCentreDensity(const Vector3QLength &pos) const; 29 | }; 30 | 31 | /** @}*/ 32 | }} // namespace hermes::ionizedgas 33 | 34 | #endif // HERMES_NE2001SIMPLE_H 35 | -------------------------------------------------------------------------------- /cmake/FindFFTW3F.cmake: -------------------------------------------------------------------------------- 1 | # Find FFTW3 with single precision. Sets 2 | # FFTW3F_FOUND = true if fftw3f is found 3 | # FFTW3F_INCLUDE_DIR = fftw3.h 4 | # FFTW3F_LIBRARIES = libfftw3f.a .so 5 | 6 | 7 | find_path(FFTW3F_INCLUDE_DIR fftw3.h 8 | PATH_SUFFIXES include inc 9 | PATHS $ENV{FFTW_BASE} $ENV{FFTW} 10 | ) 11 | message(STATUS "FFTW3F header => ${FFTW3F_INCLUDE_DIR}") 12 | 13 | find_library(FFTW3F_LIBRARIES fftw3f 14 | PATH_SUFFIXES lib 15 | PATHS $ENV{FFTW_BASE} $ENV{FFTW} 16 | ) 17 | message(STATUS "FFTW3F libs => ${FFTW3F_LIBRARIES}") 18 | 19 | set(FFTW3F_FOUND FALSE) 20 | if(FFTW3F_INCLUDE_DIR AND FFTW3F_LIBRARIES) 21 | set(FFTW3F_FOUND TRUE) 22 | MESSAGE(STATUS "FFTW3 with single precision (FFTW3F): Found!") 23 | else() 24 | MESSAGE(STATUS "FFTW3 with single precision (FFTW3F): NOT Found!") 25 | endif() 26 | 27 | MESSAGE(STATUS " Include: ${FFTW3F_INCLUDE_DIR}") 28 | MESSAGE(STATUS " Library: ${FFTW3F_LIBRARIES}") 29 | 30 | mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARIES FFTW3F_FOUND) 31 | -------------------------------------------------------------------------------- /lib/pybind11/tools/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | # Source: https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake 2 | 3 | if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") 4 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") 5 | endif() 6 | 7 | file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) 8 | string(REGEX REPLACE "\n" ";" files "${files}") 9 | foreach(file ${files}) 10 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 11 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 12 | exec_program( 13 | "@CMAKE_COMMAND@" ARGS 14 | "-E remove \"$ENV{DESTDIR}${file}\"" 15 | OUTPUT_VARIABLE rm_out 16 | RETURN_VALUE rm_retval) 17 | if(NOT "${rm_retval}" STREQUAL 0) 18 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 19 | endif() 20 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 21 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 22 | endif() 23 | endforeach() 24 | -------------------------------------------------------------------------------- /include/hermes/integrators/BremsstrahlungIntegrator.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_BREMSSTRAHLUNGINTEGRATOR_H 2 | #define HERMES_BREMSSTRAHLUNGINTEGRATOR_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "hermes/integrators/PiZeroIntegrator.h" 9 | #include "hermes/interactions/BremsstrahlungAbstract.h" 10 | 11 | namespace hermes { 12 | /** 13 | * \addtogroup Integrators 14 | * @{ 15 | */ 16 | 17 | class BremsstrahlungIntegrator : public PiZeroIntegrator { 18 | private: 19 | std::shared_ptr crossSecBrem; 20 | 21 | public: 22 | BremsstrahlungIntegrator( 23 | const std::shared_ptr &, 24 | const std::shared_ptr &, 25 | const std::shared_ptr &); 26 | ~BremsstrahlungIntegrator(); 27 | 28 | QPiZeroIntegral integrateOverEnergy(const Vector3QLength &pos, 29 | const QEnergy &Egamma) const override; 30 | }; 31 | 32 | /** @}*/ 33 | } // namespace hermes 34 | 35 | #endif // HERMES_BREMSSTRAHLUNGINTEGRATOR_H 36 | -------------------------------------------------------------------------------- /src/magneticfields/WMAP07.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/magneticfields/WMAP07.h" 2 | 3 | #include "hermes/Units.h" 4 | 5 | namespace hermes { namespace magneticfields { 6 | 7 | WMAP07::WMAP07() { 8 | // parameters from Waelkens et al. 2009 (Hammurabi) 9 | B_0 = 4.0_muG; 10 | r_0 = 8.0_kpc; 11 | z_0 = 1.0_kpc; 12 | chi_0 = 25.0_deg; 13 | psi_1 = 0.9_deg; 14 | psi_0 = 27.0_deg; // ~35.0_deg in the original paper 15 | } 16 | 17 | Vector3QMField WMAP07::getField(const Vector3QLength &pos_) const { 18 | Vector3QMField B(0); 19 | 20 | QLength rho = sqrt(pos_.x * pos_.x + pos_.y * pos_.y); 21 | QNumber cosphi = pos_.x / rho; 22 | QNumber sinphi = pos_.y / rho; 23 | 24 | if (rho < 3_kpc || rho > 20_kpc) return B; 25 | 26 | QAngle psi = psi_0 + psi_1 * log(rho / r_0); 27 | QAngle chi = chi_0 * tanh(pos_.z / z_0); 28 | 29 | QNumber B_r = cos(psi) * cos(chi); 30 | QNumber B_phi = sin(psi) * cos(chi); 31 | 32 | B.x = B_0 * (B_phi * cosphi - B_r * sinphi); 33 | B.y = B_0 * (B_phi * sinphi + B_r * cosphi); 34 | B.z = B_0 * sin(chi); 35 | 36 | return B; 37 | } 38 | 39 | }} // namespace hermes::magneticfields 40 | -------------------------------------------------------------------------------- /include/hermes/interactions/KelnerAharonianGamma.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_KELNERAHARONIANGAMMA_H 2 | #define HERMES_KELNERAHARONIANGAMMA_H 3 | 4 | /* 5 | Model from Phys.Rev.D74:034018,2006; Erratum-ibid.D79:039901,2009 6 | arXiv:astro-ph/0606058 7 | */ 8 | 9 | #include 10 | 11 | #include "hermes/interactions/DiffCrossSection.h" 12 | 13 | namespace hermes { namespace interactions { 14 | /** 15 | * \addtogroup Interactions 16 | * @{ 17 | */ 18 | 19 | class KelnerAharonianGamma : public DifferentialCrossSection { 20 | public: 21 | KelnerAharonianGamma(); 22 | QDiffCrossSection getDiffCrossSection(const QEnergy &E_proton, const QEnergy &E_gamma) const override; 23 | QDiffCrossSection getDiffCrossSection(const PID &projectile, const PID &target, const QEnergy &E_proj, 24 | const QEnergy &E_secondary) const override; 25 | 26 | // Parametrization based on 27 | // Phys.Rev. D90 (2014) 12, 123014 (astro-ph/1406.7369) 28 | static QArea sigmaInelastic(const QEnergy &Tp); 29 | }; 30 | 31 | /** @}*/ 32 | }} // namespace hermes::interactions 33 | 34 | #endif // HERMES_KELNERAHARONIANGAMMA_H 35 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.1.0 2 | message: "Please cite the following works when using this software: https://ui.adsabs.harvard.edu/abs/2021ascl.soft07030D" 3 | authors: 4 | - family-names: Dundovic 5 | given-names: Andrej 6 | - family-names: Evoli 7 | given-names: Carmelo 8 | - family-names: Gaggero 9 | given-names: Daniele 10 | title: "HERMES: High-Energy Radiative MESsengers" 11 | version: 1.0.0 12 | date-released: 2021-05-27 13 | identifiers: 14 | - type: "ascl-id" 15 | value: "2107.030" 16 | - type: "doi" 17 | value: 10.1051/0004-6361/202140801 18 | - type: "bibcode" 19 | value: "2021ascl.soft07030D" 20 | abstract: "The HERMES (High-Energy Radiative MESsengers) computational framework for line of sight integration creates sky maps in the HEALPix-compatibile format of various galactic radiative processes, including Faraday rotation, synchrotron and free-free radio emission, gamma-ray emission from pion-decay, bremsstrahlung and inverse-Compton. The code is written in C++ and provides numerous integrators, including dispersion measure, rotation measure, and Gamma-ray emissions from Dark Matter annihilation, among others." 21 | -------------------------------------------------------------------------------- /src/cosmicrays/DummyCR.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/cosmicrays/DummyCR.h" 2 | 3 | namespace hermes { namespace cosmicrays { 4 | 5 | DummyCR::DummyCR() 6 | : CosmicRayDensity(Proton), minE(1_GeV), maxE(10_TeV), steps(20) { 7 | makeEnergyRange(); 8 | } 9 | 10 | DummyCR::DummyCR(const PID &pid_) 11 | : CosmicRayDensity(pid_), minE(1_GeV), maxE(10_TeV), steps(20) { 12 | makeEnergyRange(); 13 | } 14 | 15 | DummyCR::DummyCR(const PID &pid_, const QEnergy &minE_, 16 | const QEnergy &maxE_, int steps_) 17 | : CosmicRayDensity(pid_), minE(minE_), maxE(maxE_), steps(steps_) { 18 | makeEnergyRange(); 19 | } 20 | 21 | void DummyCR::makeEnergyRange() { 22 | QEnergy energy = minE; 23 | double energyRatio = 24 | exp(1. / static_cast(steps - 1) * log(maxE / minE)); 25 | 26 | for (int i = 0; i < steps; ++i) { 27 | energyRange.push_back(energy); 28 | energy = energy * energyRatio; 29 | } 30 | } 31 | 32 | QPDensityPerEnergy DummyCR::getDensityPerEnergy( 33 | const QEnergy &E_, const Vector3QLength &pos_) const { 34 | return QPDensityPerEnergy(1); 35 | } 36 | 37 | }} // namespace hermes::cosmicrays 38 | -------------------------------------------------------------------------------- /include/hermes/interactions/DummyCrossSection.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_DUMMYCROSSSECTION_H 2 | #define HERMES_DUMMYCROSSSECTION_H 3 | 4 | #include 5 | 6 | #include "hermes/CacheTools.h" 7 | #include "hermes/interactions/DiffCrossSection.h" 8 | 9 | namespace hermes { namespace interactions { 10 | /** 11 | * \addtogroup Interactions 12 | * @{ 13 | */ 14 | 15 | class DummyCrossSection : public DifferentialCrossSection { 16 | private: 17 | QDiffCrossSection cs; 18 | 19 | public: 20 | DummyCrossSection(const QDiffCrossSection &cs_) 21 | : DifferentialCrossSection(), cs(cs_){}; 22 | 23 | QDiffCrossSection getDiffCrossSection(const QEnergy &E_photon, 24 | const QEnergy &E_gamma) const { 25 | return QDiffCrossSection(cs); 26 | } 27 | 28 | QDiffCrossSection getDiffCrossSection(const QEnergy &E_electron, 29 | const QEnergy &E_photon, 30 | const QEnergy &E_gamma) const { 31 | return QDiffCrossSection(cs); 32 | }; 33 | }; 34 | 35 | /** @}*/ 36 | }} // namespace hermes::interactions 37 | 38 | #endif // HERMES_DUMMYCROSSSECTION_H 39 | -------------------------------------------------------------------------------- /test/testCosmicRays.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "gtest/gtest.h" 5 | #include "hermes.h" 6 | 7 | namespace hermes { 8 | 9 | TEST(CosmicRays, Dragon2D) { 10 | std::vector particletypes = {Proton}; 11 | auto cr_proton = std::make_shared( 12 | cosmicrays::Dragon2D(particletypes)); 13 | Vector3QLength pos_obs(8.3_kpc, 0, 0); 14 | 15 | auto result = cr_proton->getDensityPerEnergy(0, pos_obs); 16 | 17 | EXPECT_NEAR(static_cast(result), 18 | static_cast(3569822.7), 1); 19 | } 20 | 21 | TEST(CosmicRays, Dragon3D) { 22 | std::vector particletypes = {Proton}; 23 | auto cr_proton = std::make_shared( 24 | cosmicrays::Dragon3D(particletypes)); 25 | Vector3QLength pos_obs(8.3_kpc, 0, 0); 26 | 27 | auto result = cr_proton->getDensityPerEnergy(0, pos_obs); 28 | 29 | EXPECT_NEAR(static_cast(result), 30 | static_cast(3217355.3), 1); 31 | } 32 | 33 | 34 | int main(int argc, char **argv) { 35 | ::testing::InitGoogleTest(&argc, argv); 36 | return RUN_ALL_TESTS(); 37 | } 38 | 39 | } // namespace hermes 40 | -------------------------------------------------------------------------------- /include/hermes/neutralgas/RingData.h: -------------------------------------------------------------------------------- 1 | #ifdef HERMES_HAVE_CFITSIO 2 | 3 | #ifndef HERMES_RINGDATA_H 4 | #define HERMES_RINGDATA_H 5 | 6 | #include 7 | #include 8 | 9 | #include "hermes/FITSWrapper.h" 10 | #include "hermes/Units.h" 11 | #include "hermes/neutralgas/GasType.h" 12 | #include "hermes/neutralgas/NeutralGasAbstract.h" 13 | 14 | namespace hermes { namespace neutralgas { 15 | 16 | class RingData { 17 | private: 18 | std::unique_ptr ffile; 19 | 20 | const GasType type; 21 | int n_lon, n_lat, n_rings; 22 | double min_lon, min_lat; 23 | double delta_lon, delta_lat; 24 | std::vector dataVector; 25 | 26 | void readDataFile(const std::string &filename); 27 | double getRawValue(int ring, const QDirection &dir) const; 28 | 29 | public: 30 | RingData(GasType gas); 31 | QColumnDensity getHIColumnDensityInRing(int ring, const QDirection &dir) const; 32 | QRingCOIntensity getCOIntensityInRing(int ring, const QDirection &dir) const; 33 | 34 | GasType getGasType() const; 35 | int getRingNumber() const; 36 | }; 37 | 38 | }} // namespace hermes::neutralgas 39 | 40 | #endif // HERMES_RINGMODEL_H 41 | #endif // HERMES_HAVE_CFITSIO -------------------------------------------------------------------------------- /include/hermes/skymaps/RadioSkymap.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_RADIOSKYMAP_H 2 | #define HERMES_RADIOSKYMAP_H 3 | 4 | #include "hermes/skymaps/SkymapTemplate.h" 5 | 6 | namespace hermes { 7 | 8 | /** 9 | * \addtogroup Skymaps 10 | * @{ 11 | */ 12 | 13 | /** 14 | @class RadioSkymap 15 | @brief A skymap container suitable for radio emissions; saves pixels in units 16 | of temperature (K), specified by frequency (Hz). 17 | */ 18 | class RadioSkymap : public SkymapTemplate { 19 | public: 20 | RadioSkymap(std::size_t nside, QFrequency freq) 21 | : SkymapTemplate(nside, freq, SkymapDefinitions("FREQ")){ 22 | }; 23 | 24 | void setFrequency(QFrequency freq) { 25 | setSkymapParameter(freq); 26 | } 27 | QFrequency getFrequency() const { return skymapParameter; } 28 | void computePixel( 29 | std::size_t ipix, 30 | const std::shared_ptr> 31 | &integrator_) override { 32 | fluxContainer[ipix] = integrator_->integrateOverLOS( 33 | pix2ang_ring(getNside(), ipix), skymapParameter); 34 | } 35 | }; 36 | 37 | /** @}*/ 38 | } // namespace hermes 39 | #endif // HERMES_RADIOSKYMAP_H 40 | -------------------------------------------------------------------------------- /lib/pybind11/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | # See all possible options and defaults with: 3 | # clang-format --style=llvm --dump-config 4 | BasedOnStyle: LLVM 5 | AccessModifierOffset: -4 6 | AllowShortLambdasOnASingleLine: true 7 | AlwaysBreakTemplateDeclarations: Yes 8 | BinPackArguments: false 9 | BinPackParameters: false 10 | BreakBeforeBinaryOperators: All 11 | BreakConstructorInitializers: BeforeColon 12 | ColumnLimit: 99 13 | CommentPragmas: 'NOLINT:.*|^ IWYU pragma:' 14 | IncludeBlocks: Regroup 15 | IndentCaseLabels: true 16 | IndentPPDirectives: AfterHash 17 | IndentWidth: 4 18 | Language: Cpp 19 | SpaceAfterCStyleCast: true 20 | Standard: Cpp11 21 | StatementMacros: ['PyObject_HEAD'] 22 | TabWidth: 4 23 | IncludeCategories: 24 | - Regex: '' 35 | Priority: 4 36 | - Regex: '.*' 37 | Priority: 5 38 | ... 39 | -------------------------------------------------------------------------------- /lib/pybind11/tools/libsize.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | # Internal build script for generating debugging test .so size. 5 | # Usage: 6 | # python libsize.py file.so save.txt -- displays the size of file.so and, if save.txt exists, compares it to the 7 | # size in it, then overwrites save.txt with the new size for future runs. 8 | 9 | if len(sys.argv) != 3: 10 | sys.exit("Invalid arguments: usage: python libsize.py file.so save.txt") 11 | 12 | lib = sys.argv[1] 13 | save = sys.argv[2] 14 | 15 | if not os.path.exists(lib): 16 | sys.exit(f"Error: requested file ({lib}) does not exist") 17 | 18 | libsize = os.path.getsize(lib) 19 | 20 | print("------", os.path.basename(lib), "file size:", libsize, end="") 21 | 22 | if os.path.exists(save): 23 | with open(save) as sf: 24 | oldsize = int(sf.readline()) 25 | 26 | if oldsize > 0: 27 | change = libsize - oldsize 28 | if change == 0: 29 | print(" (no change)") 30 | else: 31 | print(f" (change of {change:+} bytes = {change / oldsize:+.2%})") 32 | else: 33 | print() 34 | 35 | with open(save, "w") as sf: 36 | sf.write(str(libsize)) 37 | -------------------------------------------------------------------------------- /src/interactions/KleinNishina.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/interactions/KleinNishina.h" 2 | 3 | #include "hermes/Common.h" 4 | 5 | namespace hermes { namespace interactions { 6 | 7 | KleinNishina::KleinNishina() {} 8 | 9 | QDiffCrossSection KleinNishina::getDiffCrossSection( 10 | const QEnergy &E_electron, const QEnergy &E_photon, 11 | const QEnergy &E_gamma) const { 12 | constexpr QEnergy mc2_el = m_electron * c_squared; 13 | 14 | QNumber gamma_el = E_electron / mc2_el; // Lorentz_electron 15 | QNumber gamma_el_2 = gamma_el * gamma_el; 16 | QNumber p = 4 * E_photon * E_electron / (mc2_el * mc2_el); 17 | QNumber q = (E_gamma / E_photon) / (4 * gamma_el_2) / 18 | (1_num - E_gamma / E_electron); 19 | 20 | if (q < 1.0 / (4 * gamma_el_2) || q > 1_num) return QDiffCrossSection(0); 21 | 22 | // gamma_el >> 1 is requred for the approximation to work, 23 | // i.e., a relativistic electron, see (eq. 2.48) in Blumenthal et. al., 24 | // 1970 25 | return 3. / 4. * sigma_Thompson / (E_photon * gamma_el_2) * 26 | (2 * q * log(q) + (1_num + 2 * q) * (1_num - q) + 27 | 0.5 * (p * q) * (p * q) * (1_num - q) / (1_num + p * q)); 28 | } 29 | 30 | }} // namespace hermes::interactions 31 | -------------------------------------------------------------------------------- /test/testBreitWheeler.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | #include "hermes.h" 3 | 4 | namespace hermes { 5 | 6 | TEST(Interactions, BreitWheeler) { 7 | auto bw = std::make_shared(interactions::BreitWheeler()); 8 | 9 | QEnergy E_ph = 1_eV; 10 | QEnergy E_gamma = 300_TeV; 11 | QArea res = bw->integratedOverTheta(E_gamma, E_ph); 12 | EXPECT_NEAR(static_cast(res), static_cast(2.80_mbarn), static_cast(0.01_mbarn)); 13 | 14 | E_ph = 1_eV; 15 | E_gamma = 50_TeV; 16 | res = bw->integratedOverTheta(E_gamma, E_ph); 17 | EXPECT_NEAR(static_cast(res), static_cast(12.30_mbarn), static_cast(0.01_mbarn)); 18 | } 19 | 20 | TEST(Interactions, BreitWheelerOverCMB) { 21 | auto bw = std::make_shared(); 22 | auto ph = std::make_shared(); 23 | 24 | auto E_gamma = 50_TeV; 25 | 26 | for (auto itE = std::next(ph->begin()); itE != ph->end(); ++itE) { 27 | auto E_ph = (*itE); 28 | auto res = bw->integratedOverTheta(E_gamma, E_ph); 29 | } 30 | } 31 | 32 | int main(int argc, char **argv) { 33 | ::testing::InitGoogleTest(&argc, argv); 34 | return RUN_ALL_TESTS(); 35 | } 36 | 37 | } // namespace hermes 38 | -------------------------------------------------------------------------------- /lib/gtest/googletest/docs/samples.md: -------------------------------------------------------------------------------- 1 | # Googletest Samples {#samples} 2 | 3 | If you're like us, you'd like to look at 4 | [googletest samples.](https://github.com/google/googletest/tree/master/googletest/samples) 5 | The sample directory has a number of well-commented samples showing how to use a 6 | variety of googletest features. 7 | 8 | * Sample #1 shows the basic steps of using googletest to test C++ functions. 9 | * Sample #2 shows a more complex unit test for a class with multiple member 10 | functions. 11 | * Sample #3 uses a test fixture. 12 | * Sample #4 teaches you how to use googletest and `googletest.h` together to 13 | get the best of both libraries. 14 | * Sample #5 puts shared testing logic in a base test fixture, and reuses it in 15 | derived fixtures. 16 | * Sample #6 demonstrates type-parameterized tests. 17 | * Sample #7 teaches the basics of value-parameterized tests. 18 | * Sample #8 shows using `Combine()` in value-parameterized tests. 19 | * Sample #9 shows use of the listener API to modify Google Test's console 20 | output and the use of its reflection API to inspect test results. 21 | * Sample #10 shows use of the listener API to implement a primitive memory 22 | leak checker. 23 | -------------------------------------------------------------------------------- /lib/kiss/include/kiss/path.h: -------------------------------------------------------------------------------- 1 | #ifndef FILEUTILS_INCLUDED 2 | #define FILEUTILS_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | struct mode { 8 | enum { 9 | none = 0, execute = 1, write = 2, read = 4, rw = 6, rx = 5, rwx = 7 10 | }; 11 | }; 12 | 13 | #ifdef _WIN32 14 | const char path_seperator = '\\'; 15 | #else 16 | const char path_seperator = '/'; 17 | #endif 18 | 19 | bool create_directory(const std::string &path, size_t user_permission = 20 | mode::rwx, size_t group_permission = mode::rx, size_t other_permission = 21 | mode::none); 22 | 23 | bool is_directory(const std::string &path); 24 | 25 | bool list_directory(const std::string &directory, 26 | std::vector &elements); 27 | 28 | bool create_directory_recursive(const std::string &dir, size_t user_permission = 29 | mode::rwx, size_t group_permission = mode::rx, size_t other_permission = 30 | mode::none); 31 | std::string concat_path(const std::string &a, const std::string &b); 32 | 33 | std::string concat_path(const std::string &a, const std::string &b, 34 | const std::string &c); 35 | 36 | void append_file(const std::string &target, const std::string &source, bool binary); 37 | 38 | std::string executable_path(); 39 | 40 | #endif /* FILEUTILS_H */ 41 | -------------------------------------------------------------------------------- /test/testHEALPix.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | #include "hermes.h" 3 | 4 | namespace hermes { 5 | 6 | TEST(HEALPix, consistency) { 7 | QDirection thetaphi; 8 | long nside = 128; 9 | long npix = nside2npix(nside); 10 | 11 | for (long ipix = 0; ipix < npix; ++ipix) { 12 | thetaphi = pix2ang_ring(nside, ipix); 13 | EXPECT_EQ(ang2pix_ring(nside, thetaphi), ipix); 14 | } 15 | } 16 | 17 | TEST(HEALPix, galacticCentre) { 18 | long nside = 2; 19 | 20 | // see fig. 3 in The HEALPix Primer 21 | QDirection thetaphi = {pi / 2, pi + 0.01}; 22 | EXPECT_EQ(ang2pix_ring(nside, thetaphi), 24); 23 | 24 | thetaphi[0] = 0.7; 25 | thetaphi[1] = 2 * pi - 0.1; 26 | EXPECT_EQ(ang2pix_ring(nside, thetaphi), 11); 27 | } 28 | 29 | TEST(HEALPix, pix2ang) { 30 | QDirection thetaphi; 31 | 32 | thetaphi = pix2ang_ring(16, 1440); 33 | EXPECT_NEAR(static_cast(thetaphi[0]), 1.529, 0.001); 34 | EXPECT_EQ(static_cast(thetaphi[1]), 0); 35 | 36 | thetaphi = pix2ang_ring(32, 0); 37 | EXPECT_NEAR(static_cast(thetaphi[0]), 0.0255, 0.001); 38 | EXPECT_NEAR(static_cast(thetaphi[1]), 0.7853, 0.001); 39 | } 40 | 41 | int main(int argc, char **argv) { 42 | ::testing::InitGoogleTest(&argc, argv); 43 | return RUN_ALL_TESTS(); 44 | } 45 | 46 | } // namespace hermes 47 | -------------------------------------------------------------------------------- /include/hermes/interactions/DiffCrossSection.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_DIFFERENTIALCROSSSECTION_H 2 | #define HERMES_DIFFERENTIALCROSSSECTION_H 3 | 4 | #include "hermes/ParticleID.h" 5 | #include "hermes/Units.h" 6 | 7 | namespace hermes { namespace interactions { 8 | /** 9 | * \addtogroup Interactions 10 | * @{ 11 | */ 12 | 13 | using namespace units; 14 | 15 | class DifferentialCrossSection { 16 | protected: 17 | bool cachingEnabled; 18 | 19 | public: 20 | DifferentialCrossSection(bool cachingEnabled = false); 21 | ~DifferentialCrossSection(); 22 | 23 | void enableCaching(); 24 | void disableCaching(); 25 | 26 | virtual QDiffCrossSection getDiffCrossSection(const QEnergy &E_proton, const QEnergy &E_gamma) const; 27 | virtual QDiffCrossSection getDiffCrossSection(const QEnergy &E_electron, const QEnergy &E_photon, 28 | const QEnergy &E_gamma) const; 29 | virtual QDiffCrossSection getDiffCrossSection(const PID &projectile, const PID &target, const QEnergy &E_proj, 30 | const QEnergy &E_secondary) const; 31 | }; 32 | 33 | QNumber nuclearScaling(const PID &projectile, const PID &target); 34 | 35 | /** @}*/ 36 | }} // namespace hermes::interactions 37 | 38 | #endif // HERMES_DIFFERENTIALCROSSSECTION_H 39 | -------------------------------------------------------------------------------- /include/hermes/skymaps/GammaSkymap.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_GAMMASKYMAP_H 2 | #define HERMES_GAMMASKYMAP_H 3 | 4 | #include "hermes/skymaps/SkymapTemplate.h" 5 | 6 | namespace hermes { 7 | /** 8 | * \addtogroup Skymaps 9 | * @{ 10 | */ 11 | 12 | /** 13 | @class GammaSkymap 14 | @brief A skymap container suitable for gamma-ray emissions; saves pixels in 15 | units of differential intensity (GeV^-1 m^-2 s^-1 sr^-1), specified by 16 | gamma-ray energy (J). 17 | */ 18 | class GammaSkymap : public SkymapTemplate { 19 | public: 20 | GammaSkymap(std::size_t nside, QEnergy Egamma) 21 | : SkymapTemplate(nside, Egamma, SkymapDefinitions("ENERGY")) { 22 | initDefaultOutputUnits(1 / (1_GeV * 1_m2 * 1_s * 1_sr), 23 | "GeV^-1 m^-2 s^-1 sr^-1"); 24 | }; 25 | 26 | void setEnergy(QEnergy Egamma) { 27 | setSkymapParameter(Egamma); 28 | } 29 | QEnergy getEnergy() const { return skymapParameter; } 30 | 31 | void computePixel( 32 | std::size_t ipix, 33 | const std::shared_ptr> 34 | &integrator_) override { 35 | fluxContainer[ipix] = integrator_->integrateOverLOS( 36 | pix2ang_ring(getNside(), ipix), skymapParameter); 37 | } 38 | }; 39 | 40 | /** @}*/ 41 | } // namespace hermes 42 | #endif // HERMES_GAMMASKYMAP_H 43 | -------------------------------------------------------------------------------- /lib/pybind11/tools/codespell_ignore_lines_from_errors.py: -------------------------------------------------------------------------------- 1 | """Simple script for rebuilding .codespell-ignore-lines 2 | 3 | Usage: 4 | 5 | cat < /dev/null > .codespell-ignore-lines 6 | pre-commit run --all-files codespell >& /tmp/codespell_errors.txt 7 | python3 tools/codespell_ignore_lines_from_errors.py /tmp/codespell_errors.txt > .codespell-ignore-lines 8 | 9 | git diff to review changes, then commit, push. 10 | """ 11 | 12 | import sys 13 | from typing import List 14 | 15 | 16 | def run(args: List[str]) -> None: 17 | assert len(args) == 1, "codespell_errors.txt" 18 | cache = {} 19 | done = set() 20 | with open(args[0]) as f: 21 | lines = f.read().splitlines() 22 | 23 | for line in sorted(lines): 24 | i = line.find(" ==> ") 25 | if i > 0: 26 | flds = line[:i].split(":") 27 | if len(flds) >= 2: 28 | filename, line_num = flds[:2] 29 | if filename not in cache: 30 | with open(filename) as f: 31 | cache[filename] = f.read().splitlines() 32 | supp = cache[filename][int(line_num) - 1] 33 | if supp not in done: 34 | print(supp) 35 | done.add(supp) 36 | 37 | 38 | if __name__ == "__main__": 39 | run(args=sys.argv[1:]) 40 | -------------------------------------------------------------------------------- /python/photonfields.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "hermes/photonfields/CMB.h" 5 | #include "hermes/photonfields/ISRF.h" 6 | #include "hermes/photonfields/PhotonField.h" 7 | 8 | namespace py = pybind11; 9 | 10 | namespace hermes { namespace photonfields { 11 | 12 | void init(py::module &m) { 13 | py::module subm = m.def_submodule("photonfields"); 14 | subm.doc() = "photon fields package"; 15 | 16 | // charged gas density models 17 | py::class_>(subm, "PhotonField") 18 | .def("getEnergyDensity", 19 | static_cast( 21 | &PhotonField::getEnergyDensity)) 22 | .def("getEnergyDensity", 23 | static_cast( 25 | &PhotonField::getEnergyDensity)) 26 | .def("getEnergyAxis", &PhotonField::getEnergyAxis); 27 | py::class_, PhotonField>(subm, "CMB") 28 | .def(py::init<>()); 29 | py::class_, PhotonField>(subm, "ISRF") 30 | .def(py::init<>()); 31 | } 32 | 33 | }} // namespace hermes::photonfields 34 | -------------------------------------------------------------------------------- /src/cosmicrays/SimpleCR.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/cosmicrays/SimpleCR.h" 2 | 3 | namespace hermes { namespace cosmicrays { 4 | 5 | SimpleCR::SimpleCR(const PID &pid_) 6 | : CosmicRayDensity(pid_), minE(1_GeV), maxE(10_TeV), steps(20) { 7 | makeEnergyRange(); 8 | } 9 | 10 | SimpleCR::SimpleCR(const PID &pid_, QEnergy minE_, QEnergy maxE_, 11 | int steps_) 12 | : CosmicRayDensity(pid_), minE(minE_), maxE(maxE_), steps(steps_) { 13 | makeEnergyRange(); 14 | } 15 | 16 | void SimpleCR::makeEnergyRange() { 17 | QEnergy energy = minE; 18 | energyScaleFactor = 19 | exp(1. / static_cast(steps - 1) * log(maxE / minE)); 20 | 21 | for (int i = 0; i < steps; ++i) { 22 | energyRange.push_back(energy); 23 | energy = energy * energyScaleFactor; 24 | } 25 | } 26 | 27 | QPDensityPerEnergy SimpleCR::getDensityPerEnergy( 28 | const QEnergy &E_, const Vector3QLength &pos_) const { 29 | constexpr int alpha = 3; 30 | auto Phi0 = 0.1 / (1_GeV * 1_cm * 1_cm * 1_s * c_light) * 4_pi; 31 | auto E0 = 1_GeV; 32 | auto E_cutoff = 5_TeV; 33 | 34 | QNumber profile = exp(-1. * fabs(pos_.getZ()) / 1_kpc); 35 | QPDensityPerEnergy spectrum = 36 | Phi0 * pow<-1 * alpha>(E_ / E0) * exp(-E_ / E_cutoff); 37 | 38 | return profile * spectrum; 39 | } 40 | 41 | }} // namespace hermes::cosmicrays 42 | -------------------------------------------------------------------------------- /include/hermes/darkmatter/PPPC4DMIDSpectrum.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_PPPC4DMIDSPECTRUM_H 2 | #define HERMES_PPPC4DMIDSPECTRUM_H 3 | 4 | #include 5 | #include 6 | 7 | #include "hermes/Units.h" 8 | #include "hermes/darkmatter/DarkMatterSpectrum.h" 9 | #include "hermes/darkmatter/PPPC4DMIDChannels.h" 10 | 11 | /* 12 | * M.Cirelli, G.Corcella, A.Hektor, G.Hütsi, M.Kadastik, P.Panci, M.Raidal, 13 | * F.Sala, A.Strumia, "PPPC 4 DM ID: A Poor Particle Physicist Cookbook for Dark 14 | * Matter Indirect Detection", arXiv 1012.4515, JCAP 1103 (2011) 051. Erratum: 15 | * JCAP 1210 (2012) E01. 16 | */ 17 | 18 | namespace hermes { namespace darkmatter { 19 | /** 20 | * \addtogroup DarkMatter 21 | * @{ 22 | */ 23 | 24 | class PPPC4DMIDSpectrum : public DarkMatterSpectrum { 25 | private: 26 | const std::string filename; 27 | const Channel channel; 28 | const Mass mass; 29 | std::vector > spectrum; 30 | void loadData(); 31 | 32 | public: 33 | PPPC4DMIDSpectrum(Channel c, Mass m); 34 | PPPC4DMIDSpectrum(Channel c, Mass m, const std::string &filename); 35 | 36 | QEnergy getRestMassEnergy() const override; 37 | QInverseEnergy getParticlesPerEnergy(QEnergy Egamma) const override; 38 | }; 39 | 40 | /** @}*/ 41 | }} // namespace hermes::darkmatter 42 | 43 | #endif // HERMES_PPPC4DMIDSPECTRUM_H 44 | -------------------------------------------------------------------------------- /include/hermes/integrators/DarkMatterIntegrator.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_DARKMATTERINTEGRATOR_H 2 | #define HERMES_DARKMATTERINTEGRATOR_H 3 | 4 | #include 5 | #include 6 | 7 | #include "hermes/Units.h" 8 | #include "hermes/darkmatter/DarkMatterSpectrum.h" 9 | #include "hermes/darkmatter/GalacticProfile.h" 10 | #include "hermes/integrators/IntegratorTemplate.h" 11 | 12 | namespace hermes { 13 | /** 14 | * \addtogroup Integrators 15 | * @{ 16 | */ 17 | 18 | class DarkMatterIntegrator : public GammaIntegratorTemplate { 19 | private: 20 | std::shared_ptr spectrum; 21 | std::shared_ptr profile; 22 | 23 | public: 24 | DarkMatterIntegrator( 25 | const std::shared_ptr &spectrum, 26 | const std::shared_ptr &profile); 27 | ~DarkMatterIntegrator(); 28 | 29 | QDiffIntensity integrateOverLOS(const QDirection &direction) const override; 30 | QDiffIntensity integrateOverLOS(const QDirection &iterdir, 31 | const QEnergy &Egamma) const override; 32 | QGREmissivity spectralEmissivity(const Vector3QLength &pos, 33 | QEnergy Egamma) const; 34 | }; 35 | 36 | /** @}*/ 37 | } // namespace hermes 38 | 39 | #endif // HERMES_DARKMATTERINTEGRATOR_H 40 | -------------------------------------------------------------------------------- /include/hermes/skymaps/Skymap.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_SKYMAP_H 2 | #define HERMES_SKYMAP_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "hermes/HEALPixBits.h" 9 | #include "hermes/outputs/Output.h" 10 | 11 | namespace hermes { 12 | /** 13 | * \addtogroup Skymaps 14 | * @{ 15 | */ 16 | 17 | /** 18 | \class Skymap 19 | \brief Base abstract class for all Skymaps; provides elementary HEALPix 20 | functions 21 | 22 | res : The resolution index 23 | nside = 2^res : The number of pixels per side. 24 | npix = 12 * nside^2 : The total number of pixels in the map. 25 | */ 26 | class Skymap { 27 | protected: 28 | std::size_t nside; 29 | std::size_t npix; 30 | std::size_t res; 31 | std::string description; 32 | 33 | public: 34 | Skymap(std::size_t nside_); 35 | virtual ~Skymap(){}; 36 | 37 | void setNside(std::size_t nside_); 38 | std::size_t getNside() const; 39 | void setRes(std::size_t res_); 40 | std::size_t getRes() const; 41 | std::size_t getNpix() const; 42 | 43 | std::string getDescription() const; 44 | void setDescription(const std::string &description); 45 | 46 | virtual double getPixelAsDouble(std::size_t i) const = 0; 47 | virtual void save(std::shared_ptr output) const = 0; 48 | }; 49 | 50 | /** @}*/ 51 | } // namespace hermes 52 | 53 | #endif // HERMES_SKYMAP_H 54 | -------------------------------------------------------------------------------- /lib/pybind11/pybind11/commands.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | DIR = os.path.abspath(os.path.dirname(__file__)) 4 | 5 | 6 | def get_include(user: bool = False) -> str: # noqa: ARG001 7 | """ 8 | Return the path to the pybind11 include directory. The historical "user" 9 | argument is unused, and may be removed. 10 | """ 11 | installed_path = os.path.join(DIR, "include") 12 | source_path = os.path.join(os.path.dirname(DIR), "include") 13 | return installed_path if os.path.exists(installed_path) else source_path 14 | 15 | 16 | def get_cmake_dir() -> str: 17 | """ 18 | Return the path to the pybind11 CMake module directory. 19 | """ 20 | cmake_installed_path = os.path.join(DIR, "share", "cmake", "pybind11") 21 | if os.path.exists(cmake_installed_path): 22 | return cmake_installed_path 23 | 24 | msg = "pybind11 not installed, installation required to access the CMake files" 25 | raise ImportError(msg) 26 | 27 | 28 | def get_pkgconfig_dir() -> str: 29 | """ 30 | Return the path to the pybind11 pkgconfig directory. 31 | """ 32 | pkgconfig_installed_path = os.path.join(DIR, "share", "pkgconfig") 33 | if os.path.exists(pkgconfig_installed_path): 34 | return pkgconfig_installed_path 35 | 36 | msg = "pybind11 not installed, installation required to access the pkgconfig files" 37 | raise ImportError(msg) 38 | -------------------------------------------------------------------------------- /python/magneticfields.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "hermes/magneticfields/JF12.h" 5 | #include "hermes/magneticfields/MagneticField.h" 6 | #include "hermes/magneticfields/MagneticFieldGrid.h" 7 | #include "hermes/magneticfields/PT11.h" 8 | #include "hermes/magneticfields/Sun08.h" 9 | #include "hermes/magneticfields/WMAP07.h" 10 | 11 | namespace py = pybind11; 12 | 13 | namespace hermes { namespace magneticfields { 14 | 15 | void init(py::module &m) { 16 | py::module subm = m.def_submodule("magneticfields"); 17 | subm.doc() = "magnetic fields package"; 18 | 19 | py::class_>(subm, 20 | "MagneticField") 21 | .def("getField", &MagneticField::getField); 22 | 23 | py::class_, MagneticField>( 24 | subm, "Sun08") 25 | .def(py::init<>()) 26 | .def("getField", &MagneticField::getField); 27 | 28 | py::class_, MagneticField>( 29 | subm, "PT11") 30 | .def(py::init<>()) 31 | .def("getField", &MagneticField::getField); 32 | 33 | py::class_, MagneticField>( 34 | subm, "JF12") 35 | .def(py::init<>()) 36 | .def("getField", &MagneticField::getField); 37 | } 38 | 39 | }} // namespace hermes::magneticfields 40 | -------------------------------------------------------------------------------- /cmake/GetGitRevisionDescription.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # Internal file for GetGitRevisionDescription.cmake 3 | # 4 | # Requires CMake 2.6 or newer (uses the 'function' command) 5 | # 6 | # Original Author: 7 | # 2009-2010 Ryan Pavlik 8 | # http://academic.cleardefinition.com 9 | # Iowa State University HCI Graduate Program/VRAC 10 | # 11 | # Copyright Iowa State University 2009-2010. 12 | # Distributed under the Boost Software License, Version 1.0. 13 | # (See accompanying file LICENSE_1_0.txt or copy at 14 | # http://www.boost.org/LICENSE_1_0.txt) 15 | 16 | set(HEAD_HASH) 17 | 18 | file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) 19 | 20 | string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) 21 | if(HEAD_CONTENTS MATCHES "ref") 22 | # named branch 23 | string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") 24 | if(EXISTS "@GIT_DIR@/${HEAD_REF}") 25 | configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) 26 | elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}") 27 | configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) 28 | set(HEAD_HASH "${HEAD_REF}") 29 | endif() 30 | else() 31 | # detached HEAD 32 | configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) 33 | endif() 34 | 35 | if(NOT HEAD_HASH) 36 | file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) 37 | string(STRIP "${HEAD_HASH}" HEAD_HASH) 38 | endif() 39 | -------------------------------------------------------------------------------- /lib/pybind11/.codespell-ignore-lines: -------------------------------------------------------------------------------- 1 | template 2 | template 3 | auto &this_ = static_cast(*this); 4 | if (load_impl(temp, false)) { 5 | ssize_t nd = 0; 6 | auto trivial = broadcast(buffers, nd, shape); 7 | auto ndim = (size_t) nd; 8 | int nd; 9 | ssize_t ndim() const { return detail::array_proxy(m_ptr)->nd; } 10 | using op = op_impl; 11 | template 12 | template 13 | class_ &def(const detail::op_ &op, const Extra &...extra) { 14 | class_ &def_cast(const detail::op_ &op, const Extra &...extra) { 15 | @pytest.mark.parametrize("access", ["ro", "rw", "static_ro", "static_rw"]) 16 | struct IntStruct { 17 | explicit IntStruct(int v) : value(v){}; 18 | ~IntStruct() { value = -value; } 19 | IntStruct(const IntStruct &) = default; 20 | IntStruct &operator=(const IntStruct &) = default; 21 | py::class_(m, "IntStruct").def(py::init([](const int i) { return IntStruct(i); })); 22 | py::implicitly_convertible(); 23 | m.def("test", [](int expected, const IntStruct &in) { 24 | [](int expected, const IntStruct &in) { 25 | -------------------------------------------------------------------------------- /lib/pybind11/.appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | image: 3 | - Visual Studio 2017 4 | test: off 5 | skip_branch_with_pr: true 6 | build: 7 | parallel: true 8 | platform: 9 | - x86 10 | environment: 11 | matrix: 12 | - PYTHON: 36 13 | CONFIG: Debug 14 | install: 15 | - ps: | 16 | $env:CMAKE_GENERATOR = "Visual Studio 15 2017" 17 | if ($env:PLATFORM -eq "x64") { $env:PYTHON = "$env:PYTHON-x64" } 18 | $env:PATH = "C:\Python$env:PYTHON\;C:\Python$env:PYTHON\Scripts\;$env:PATH" 19 | python -W ignore -m pip install --upgrade pip wheel 20 | python -W ignore -m pip install pytest numpy --no-warn-script-location pytest-timeout 21 | - ps: | 22 | Start-FileDownload 'https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip' 23 | 7z x eigen-3.3.7.zip -y > $null 24 | $env:CMAKE_INCLUDE_PATH = "eigen-3.3.7;$env:CMAKE_INCLUDE_PATH" 25 | build_script: 26 | - cmake -G "%CMAKE_GENERATOR%" -A "%CMAKE_ARCH%" 27 | -DCMAKE_CXX_STANDARD=14 28 | -DPYBIND11_WERROR=ON 29 | -DDOWNLOAD_CATCH=ON 30 | -DCMAKE_SUPPRESS_REGENERATION=1 31 | . 32 | - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" 33 | - cmake --build . --config %CONFIG% --target pytest -- /m /v:m /logger:%MSBuildLogger% 34 | - cmake --build . --config %CONFIG% --target cpptest -- /m /v:m /logger:%MSBuildLogger% 35 | on_failure: if exist "tests\test_cmake_build" type tests\test_cmake_build\*.log* 36 | -------------------------------------------------------------------------------- /lib/pybind11/tools/setup_main.py.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Setup script (in the sdist or in tools/setup_main.py in the repository) 4 | 5 | from setuptools import setup 6 | 7 | cmdclass = {} 8 | $extra_cmd 9 | 10 | setup( 11 | name="pybind11", 12 | version="$version", 13 | download_url='https://github.com/pybind/pybind11/tarball/v$version', 14 | packages=[ 15 | "pybind11", 16 | "pybind11.include.pybind11", 17 | "pybind11.include.pybind11.detail", 18 | "pybind11.include.pybind11.eigen", 19 | "pybind11.include.pybind11.stl", 20 | "pybind11.share.cmake.pybind11", 21 | "pybind11.share.pkgconfig", 22 | ], 23 | package_data={ 24 | "pybind11": ["py.typed"], 25 | "pybind11.include.pybind11": ["*.h"], 26 | "pybind11.include.pybind11.detail": ["*.h"], 27 | "pybind11.include.pybind11.eigen": ["*.h"], 28 | "pybind11.include.pybind11.stl": ["*.h"], 29 | "pybind11.share.cmake.pybind11": ["*.cmake"], 30 | "pybind11.share.pkgconfig": ["*.pc"], 31 | }, 32 | extras_require={ 33 | "global": ["pybind11_global==$version"] 34 | }, 35 | entry_points={ 36 | "console_scripts": [ 37 | "pybind11-config = pybind11.__main__:main", 38 | ], 39 | "pipx.run": [ 40 | "pybind11 = pybind11.__main__:main", 41 | ] 42 | }, 43 | cmdclass=cmdclass 44 | ) 45 | -------------------------------------------------------------------------------- /lib/kiss/include/kiss/uuid.h: -------------------------------------------------------------------------------- 1 | #ifndef KISS_UUID_H 2 | #define KISS_UUID_H 3 | 4 | #include 5 | 6 | namespace kiss { 7 | 8 | class uuid { 9 | private: 10 | unsigned int ints[4]; /// Storage for the actual 16-digit ID. 11 | 12 | public: 13 | /// Constructor, creates a new uuid. 14 | uuid(); 15 | uuid(unsigned int *p); 16 | uuid(unsigned int a, unsigned int b, unsigned int c, unsigned int d); 17 | 18 | /// Constructor from a string \p id. 19 | 20 | /// Sets the ID to 0 (i.e. all components to 0). 21 | void reset(); 22 | 23 | /// check if all zero 24 | bool valid() const; 25 | 26 | /// Create a new uuid. Standard way of creating a new uuid. 27 | static uuid create(); 28 | 29 | bool operator ==(const uuid& id) const; 30 | bool operator !=(const uuid& id) const; 31 | 32 | /// Less-than-operator, provides ordering of IDs. 33 | bool operator <(const uuid& op) const; 34 | 35 | /// Returns a string representation of the ID. 36 | //std::string str() const; 37 | void print(char *p) const; 38 | 39 | static uuid parse(const char *id); 40 | static uuid parse(const std::string& id); 41 | 42 | unsigned int &operator[](size_t i); 43 | const unsigned int &operator[](size_t i) const; 44 | const unsigned char *data() const; 45 | }; 46 | 47 | } // namespace kiss 48 | 49 | std::ostream& operator <<(std::ostream& os, const kiss::uuid &id); 50 | std::istream& operator >>(std::istream& os, kiss::uuid &id); 51 | 52 | #endif // KISS_UUID_H 53 | -------------------------------------------------------------------------------- /include/hermes/ProgressBar.h: -------------------------------------------------------------------------------- 1 | /* ProgressBar.h 2 | * Adapted from CRPropa3 3 | * https://crpropa.desy.de/ 4 | */ 5 | 6 | #ifndef HERMES_PROGRESSBAR_H 7 | #define HERMES_PROGRESSBAR_H 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace hermes { 15 | 16 | /** 17 | * \addtogroup Core 18 | * @{ 19 | */ 20 | class ProgressBar { 21 | private: 22 | unsigned long _steps; 23 | unsigned long _currentCount; 24 | unsigned long _maxbarLength; 25 | unsigned long _nextStep; 26 | unsigned long _updateSteps; 27 | time_t _startTime; 28 | std::string stringTmpl; 29 | std::string arrow; 30 | bool mutexSet; 31 | std::shared_ptr _mutex; 32 | 33 | public: 34 | /// Initialize a ProgressBar with [steps] number of steps, updated at 35 | /// [updateSteps] intervalls 36 | ProgressBar(unsigned long steps = 0, unsigned long updateSteps = 100); 37 | /// Set mutex when used inside std::thread 38 | void setMutex(std::shared_ptr mutex); 39 | /// Print a given title 40 | void start(const std::string &title); 41 | 42 | /// update the progressbar 43 | /// should be called steps times in a loop 44 | void update(); 45 | 46 | // sets the position of the bar to a given value 47 | void setPosition(unsigned long position); 48 | 49 | /// Mark the progressbar with an error 50 | void setError(); 51 | }; 52 | /** @}*/ 53 | 54 | } // namespace hermes 55 | 56 | #endif // HERMES_PROGRESSBAR_H 57 | -------------------------------------------------------------------------------- /python/PyHermes.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace py = pybind11; 4 | 5 | namespace hermes { 6 | 7 | // main namespace modules 8 | void init_common(py::module &); 9 | void init_integrators(py::module &); 10 | void init_particleid(py::module &); 11 | void init_quantity(py::module &); 12 | void init_skymaps(py::module &); 13 | void init_vectors(py::module &); 14 | 15 | // sub-namespace modules 16 | // clang-format off 17 | namespace cosmicrays { void init(py::module &); } 18 | namespace ionizedgas { void init(py::module &); } 19 | namespace darkmatter { void init(py::module &); } 20 | namespace interactions { void init(py::module &); } 21 | namespace magneticfields { void init(py::module &); } 22 | namespace neutralgas { void init(py::module &); } 23 | namespace outputs { void init(py::module &); } 24 | namespace photonfields { void init(py::module &); } 25 | namespace units { void init(py::module &); } 26 | // clang-format on 27 | 28 | PYBIND11_MODULE(pyhermes, m) { 29 | m.doc() = "HERMES python binding"; 30 | 31 | init_common(m); 32 | init_integrators(m); 33 | init_particleid(m); 34 | init_quantity(m); 35 | init_skymaps(m); 36 | init_vectors(m); 37 | 38 | ionizedgas::init(m); 39 | cosmicrays::init(m); 40 | darkmatter::init(m); 41 | interactions::init(m); 42 | magneticfields::init(m); 43 | neutralgas::init(m); 44 | outputs::init(m); 45 | photonfields::init(m); 46 | units::init(m); 47 | } 48 | 49 | } // namespace hermes 50 | -------------------------------------------------------------------------------- /python/ionizedgas.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "hermes/ionizedgas/IonizedGasDensity.h" 5 | #include "hermes/ionizedgas/HII_Cordes91.h" 6 | #include "hermes/ionizedgas/NE2001Simple.h" 7 | #include "hermes/ionizedgas/YMW16.h" 8 | #include "hermes/neutralgas/RingModel.h" 9 | 10 | namespace py = pybind11; 11 | 12 | namespace hermes { namespace ionizedgas { 13 | 14 | void init(py::module &m) { 15 | py::module subm = m.def_submodule("ionizedgas"); 16 | subm.doc() = "ionized gas package"; 17 | 18 | // charged gas density models 19 | py::class_>( 20 | subm, "IonizedGasDensity") 21 | .def("getDensity", &IonizedGasDensity::getDensity); 22 | py::class_, IonizedGasDensity>( 23 | subm, "HII_Cordes91") 24 | .def(py::init<>()) 25 | .def("getDensity", &IonizedGasDensity::getDensity); 26 | py::class_, IonizedGasDensity>( 27 | subm, "NE2001Simple") 28 | .def(py::init<>()) 29 | .def("getDensity", &IonizedGasDensity::getDensity); 30 | py::class_, IonizedGasDensity>(subm, "YMW16") 31 | .def(py::init<>()) 32 | .def("getDensity", 33 | [](const YMW16 &d, const Vector3QLength &v) -> double { 34 | return static_cast(d.getDensity(v)); 35 | }); 36 | } 37 | 38 | }} // namespace hermes::ionizedgas 39 | -------------------------------------------------------------------------------- /src/cosmicrays/WMAP07.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/cosmicrays/WMAP07.h" 2 | 3 | #include "hermes/Common.h" 4 | 5 | namespace hermes { namespace cosmicrays { 6 | 7 | WMAP07::WMAP07() : minE(1_GeV), maxE(1e4_GeV), steps(10) { 8 | makeEnergyRange(); 9 | setParameters(); 10 | } 11 | 12 | WMAP07::WMAP07(QEnergy minE_, QEnergy maxE_, int steps_) 13 | : minE(minE_), maxE(maxE_), steps(steps_) { 14 | makeEnergyRange(); 15 | setParameters(); 16 | } 17 | 18 | void WMAP07::setParameters() { 19 | spectralIndex = 3; 20 | h_d = 1_kpc; 21 | h_r = 5_kpc; 22 | E_0 = 1_GeV; 23 | E_cutoff = 5_TeV; 24 | C_Earth = 6.4e-5 / 1_cm3; 25 | r_Earth = 8.5_kpc; 26 | C_0 = C_Earth * exp(r_Earth / h_r); 27 | } 28 | 29 | void WMAP07::makeEnergyRange() { 30 | QEnergy energy = minE; 31 | double energyRatio = 32 | exp(1. / static_cast(steps - 1) * log(maxE / minE)); 33 | 34 | for (int i = 0; i < steps; ++i) { 35 | energyRange.push_back(energy); 36 | energy = energy * energyRatio; 37 | } 38 | } 39 | 40 | QPDensityPerEnergy WMAP07::getDensityPerEnergy( 41 | const QEnergy &E_, const Vector3QLength &pos_) const { 42 | QLength rho = sqrt(pos_.x * pos_.x + pos_.y * pos_.y); 43 | 44 | QNumber profile = exp(-rho / h_r) / (std::pow(cosh(pos_.z / h_d), 2)); 45 | return C_0 * profile * 46 | std::pow(static_cast(getLorentzFactor(m_electron, E_)), 47 | -spectralIndex) / 48 | (m_electron * c_squared); 49 | } 50 | 51 | }} // namespace hermes::cosmicrays 52 | -------------------------------------------------------------------------------- /include/hermes/skymaps/RadioSkymapRange.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_RADIOSKYMAPRANGE_H 2 | #define HERMES_RADIOSKYMAPRANGE_H 3 | 4 | #include 5 | 6 | namespace hermes { 7 | /** 8 | * \addtogroup Skymaps 9 | * @{ 10 | */ 11 | 12 | /** 13 | \class RadioSkymapRange 14 | \brief A range of RadioSkymap containers. 15 | */ 16 | class RadioSkymapRange { 17 | private: 18 | typedef std::vector tSkymapsContainer; 19 | tSkymapsContainer skymaps; 20 | std::vector freqs; 21 | QFrequency minFreq, maxFreq; 22 | std::size_t nside; 23 | int freqSteps; 24 | void initFrequencyRange(); 25 | 26 | public: 27 | RadioSkymapRange(std::size_t nside_, QFrequency minFreq_, 28 | QFrequency maxFreq_, int freqSteps_); 29 | ~RadioSkymapRange(); 30 | 31 | void setIntegrator( 32 | const std::shared_ptr>& 33 | integrator); 34 | void setMask(const std::shared_ptr& mask); 35 | std::size_t size(); 36 | 37 | void compute(); 38 | 39 | /** output **/ 40 | void save(const std::shared_ptr& output) const; 41 | 42 | /** iterator goodies */ 43 | typedef typename tSkymapsContainer::iterator iterator; 44 | typedef typename tSkymapsContainer::const_iterator const_iterator; 45 | iterator begin(); 46 | const_iterator begin() const; 47 | iterator end(); 48 | const_iterator end() const; 49 | }; 50 | 51 | /** @}*/ 52 | } // namespace hermes 53 | #endif // HERMES_RADIOSKYMAPRANGE_H 54 | -------------------------------------------------------------------------------- /python/Vectors.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "hermes/Vector3.h" 5 | #include "hermes/Vector3Quantity.h" 6 | 7 | namespace py = pybind11; 8 | 9 | namespace hermes { 10 | 11 | void init_vectors(py::module &m) { 12 | // Vector quantities 13 | py::class_>( 14 | m, "Vector3QLength") 15 | .def(py::init()) 16 | .def(py::init()) 17 | .def("getX", &Vector3QLength::getX) 18 | .def("getY", &Vector3QLength::getY) 19 | .def("getZ", &Vector3QLength::getZ) 20 | .def("getValue", &Vector3QLength::getValue) 21 | .def("getR", &Vector3QLength::getR) 22 | .def("getTheta", &Vector3QLength::getTheta) 23 | .def("getPhi", &Vector3QLength::getPhi) 24 | .def("getAngleTo", &Vector3QLength::getAngleTo) 25 | .def( 26 | "__eq__", 27 | [](const Vector3QLength &self, 28 | const Vector3QLength &other) -> bool { return self == other; }, 29 | py::is_operator()) 30 | .def( 31 | "__add__", 32 | [](const Vector3QLength &self, const Vector3QLength &other) 33 | -> Vector3QLength { return self + other; }, 34 | py::is_operator()) 35 | .def( 36 | "__sub__", 37 | [](const Vector3QLength &self, const Vector3QLength &other) 38 | -> Vector3QLength { return self - other; }, 39 | py::is_operator()); 40 | } 41 | 42 | } // namespace hermes 43 | -------------------------------------------------------------------------------- /lib/gtest/googletest/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file contains a list of people who've made non-trivial 2 | # contribution to the Google C++ Testing Framework project. People 3 | # who commit code to the project are encouraged to add their names 4 | # here. Please keep the list sorted by first names. 5 | 6 | Ajay Joshi 7 | Balázs Dán 8 | Bharat Mediratta 9 | Chandler Carruth 10 | Chris Prince 11 | Chris Taylor 12 | Dan Egnor 13 | Eric Roman 14 | Hady Zalek 15 | Jeffrey Yasskin 16 | Jói Sigurðsson 17 | Keir Mierle 18 | Keith Ray 19 | Kenton Varda 20 | Manuel Klimek 21 | Markus Heule 22 | Mika Raento 23 | Miklós Fazekas 24 | Pasi Valminen 25 | Patrick Hanna 26 | Patrick Riley 27 | Peter Kaminski 28 | Preston Jackson 29 | Rainer Klaffenboeck 30 | Russ Cox 31 | Russ Rufer 32 | Sean Mcafee 33 | Sigurður Ásgeirsson 34 | Tracy Bialik 35 | Vadim Berman 36 | Vlad Losev 37 | Zhanyong Wan 38 | -------------------------------------------------------------------------------- /src/cosmicrays/Sun08.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/cosmicrays/Sun08.h" 2 | 3 | #include "hermes/Common.h" 4 | 5 | namespace hermes { namespace cosmicrays { 6 | 7 | Sun08::Sun08() : minE(1_GeV), maxE(1e4_GeV), steps(10) { 8 | makeEnergyRange(); 9 | setParameters(); 10 | } 11 | 12 | Sun08::Sun08(QEnergy minE_, QEnergy maxE_, int steps_) 13 | : minE(minE_), maxE(maxE_), steps(steps_) { 14 | makeEnergyRange(); 15 | setParameters(); 16 | } 17 | 18 | void Sun08::setParameters() { 19 | spectralIndex = 3; 20 | h_d = 1_kpc; 21 | h_r = 8_kpc; 22 | C_0 = 6.4e-5 / 1_cm3; 23 | r_Earth = 8.5_kpc; 24 | // C_0 = C_Earth * exp(r_Earth/h_r); 25 | } 26 | 27 | void Sun08::makeEnergyRange() { 28 | QEnergy energy = minE; 29 | double energyRatio = 30 | exp(1. / static_cast(steps - 1) * log(maxE / minE)); 31 | 32 | for (int i = 0; i < steps; ++i) { 33 | energyRange.push_back(energy); 34 | energy = energy * energyRatio; 35 | } 36 | } 37 | 38 | QPDensityPerEnergy Sun08::getDensityPerEnergy( 39 | const QEnergy &E_, const Vector3QLength &pos_) const { 40 | if (fabs(pos_.z) > 1_kpc) return QPDensityPerEnergy(0); 41 | 42 | QLength rho = sqrt(pos_.x * pos_.x + pos_.y * pos_.y); 43 | 44 | if (rho < 3_kpc) rho = 3_kpc; 45 | 46 | QNumber profile = exp(-(rho - r_Earth) / h_r - fabs(pos_.z) / h_d); 47 | return C_0 * profile * 48 | std::pow(static_cast(getLorentzFactor(m_electron, E_)), 49 | -spectralIndex) / 50 | (m_electron * c_squared); 51 | } 52 | 53 | }} // namespace hermes::cosmicrays 54 | -------------------------------------------------------------------------------- /include/hermes/skymaps/GammaSkymapRange.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_GAMMASKYMAPRANGE_H 2 | #define HERMES_GAMMASKYMAPRANGE_H 3 | 4 | #include 5 | 6 | namespace hermes { 7 | /** 8 | * \addtogroup Skymaps 9 | * @{ 10 | */ 11 | 12 | /** 13 | @class GammaSkymapRange 14 | @brief A range of GammaSkymap containers. 15 | */ 16 | class GammaSkymapRange { 17 | private: 18 | typedef std::vector tSkymapsContainer; 19 | tSkymapsContainer skymaps; 20 | std::vector energies; 21 | QEnergy minEn, maxEn; 22 | std::size_t nside; 23 | int enSteps; 24 | void initEnergyRange(); 25 | 26 | public: 27 | GammaSkymapRange(std::size_t nside, QEnergy minEn, QEnergy maxEn, 28 | int enSteps); 29 | ~GammaSkymapRange(); 30 | 31 | void setIntegrator( 32 | const std::shared_ptr>& 33 | integrator_); 34 | void setMask(const std::shared_ptr& mask); 35 | 36 | std::size_t size() const; 37 | GammaSkymap operator[](std::size_t ipix) const; 38 | 39 | void compute(); 40 | 41 | /** output **/ 42 | void save(const std::shared_ptr& output) const; 43 | 44 | /** iterator goodies */ 45 | typedef typename tSkymapsContainer::iterator iterator; 46 | typedef typename tSkymapsContainer::const_iterator const_iterator; 47 | iterator begin(); 48 | const_iterator begin() const; 49 | iterator end(); 50 | const_iterator end() const; 51 | }; 52 | 53 | /** @}*/ 54 | } // namespace hermes 55 | #endif // HERMES_GAMMASKYMAPRANGE_H 56 | -------------------------------------------------------------------------------- /include/hermes/integrators/DispersionMeasureIntegrator.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_DISPERSIONMEASUREINTEGRATOR_H 2 | #define HERMES_DISPERSIONMEASUREINTEGRATOR_H 3 | 4 | #include 5 | 6 | #include "hermes/Units.h" 7 | #include "hermes/integrators/IntegratorTemplate.h" 8 | #include "hermes/ionizedgas/IonizedGasDensity.h" 9 | #include "hermes/skymaps/DispersionMeasureSkymap.h" 10 | 11 | /** \file DispersionMeasureIntegrator.h 12 | * Declares DispersionMeasureIntegrator 13 | */ 14 | 15 | namespace hermes { 16 | /** 17 | * \addtogroup Integrators 18 | * @{ 19 | */ 20 | 21 | /** 22 | * \class DispersionMeasureIntegrator 23 | * \brief Calculates dispersion measure (DM) over the LOS 24 | * 25 | * The integrator depends only on a charged gas density model, such as 26 | * chargedgas::YMW16 27 | */ 28 | class DispersionMeasureIntegrator : public DispersionMeasureIntegratorTemplate { 29 | private: 30 | std::shared_ptr gdensity; 31 | 32 | public: 33 | DispersionMeasureIntegrator(const std::shared_ptr &gdensity); 34 | ~DispersionMeasureIntegrator(); 35 | 36 | QDispersionMeasure integrateOverLOS(const QDirection &iterdir) const override; 37 | QDispersionMeasure integrateOverLOS(const QDirection &iterdir, const QNumber &num) const override { 38 | return QDispersionMeasure(0); 39 | } 40 | 41 | tLOSProfile getLOSProfile(const QDirection &direction, int Nsteps) const override; 42 | }; 43 | 44 | /** @}*/ 45 | } // namespace hermes 46 | 47 | #endif // HERMES_DISPERSIONMEASUREINTEGRATOR_H 48 | -------------------------------------------------------------------------------- /src/Version.cpp.in: -------------------------------------------------------------------------------- 1 | #include "hermes/Version.h" 2 | #include "kiss/logger.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #define GIT_SHA1 "@GIT_SHA1@" 10 | #define GIT_REFSPEC "@GIT_REFSPEC@" 11 | #define GIT_DESC "@GIT_DESC@" 12 | const char g_GIT_SHA1[] = GIT_SHA1; 13 | const char g_GIT_REFSPEC[] = GIT_REFSPEC; 14 | const char g_GIT_DESC[] = GIT_DESC; 15 | 16 | std::vector split_version(std::string input) { 17 | std::istringstream ss(input); 18 | std::string part; 19 | std::vector parts; 20 | 21 | while(std::getline(ss, part, '-')) 22 | parts.push_back(part); 23 | 24 | return parts; 25 | } 26 | 27 | void declare_version(const std::string input_version) { 28 | std::string git_version(GIT_DESC); 29 | std::vector git_parts, input_parts; 30 | 31 | git_parts = split_version(git_version); 32 | input_parts = split_version(input_version); 33 | 34 | for(size_t i = 0; i < input_parts.size(); ++i) { 35 | if (git_parts[i].compare(input_parts[i]) != 0) { 36 | KISS_LOG_WARNING << 37 | "Version mismatch! To clear this warning \n" 38 | "review the python code for potential incompatibilities and update \n" 39 | "its version declaration or install the declared version of Hermes. \n" 40 | "- Hermes version: " << git_version << "\n" 41 | "- Python code version: " << input_version << "\n" 42 | "Use git diff to inspect the differences: \n" 43 | " git diff " << input_version << " " << git_version << "\n"; 44 | break; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/gtest/googletest/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /lib/pybind11/tools/check-style.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Script to check include/test code for common pybind11 code style errors. 4 | # 5 | # This script currently checks for 6 | # 7 | # 1. missing space between keyword and parenthesis, e.g.: for(, if(, while( 8 | # 2. Missing space between right parenthesis and brace, e.g. 'for (...){' 9 | # 3. opening brace on its own line. It should always be on the same line as the 10 | # if/while/for/do statement. 11 | # 12 | # Invoke as: tools/check-style.sh 13 | # 14 | 15 | check_style_errors=0 16 | IFS=$'\n' 17 | 18 | 19 | found="$(grep '\<\(if\|for\|while\|catch\)(\|){' "$@" -rn --color=always)" 20 | if [ -n "$found" ]; then 21 | echo -e '\033[31;01mError: found the following coding style problems:\033[0m' 22 | check_style_errors=1 23 | echo "${found//^/ /}" 24 | fi 25 | 26 | found="$(awk ' 27 | function prefix(filename, lineno) { 28 | return " \033[35m" filename "\033[36m:\033[32m" lineno "\033[36m:\033[0m" 29 | } 30 | function mark(pattern, string) { sub(pattern, "\033[01;31m&\033[0m", string); return string } 31 | last && /^\s*{/ { 32 | print prefix(FILENAME, FNR-1) mark("\\)\\s*$", last) 33 | print prefix(FILENAME, FNR) mark("^\\s*{", $0) 34 | last="" 35 | } 36 | { last = /(if|for|while|catch|switch)\s*\(.*\)\s*$/ ? $0 : "" } 37 | ' "$(find include -type f)" "$@")" 38 | if [ -n "$found" ]; then 39 | check_style_errors=1 40 | echo -e '\033[31;01mError: braces should occur on the same line as the if/while/.. statement. Found issues in the following files:\033[0m' 41 | echo "$found" 42 | fi 43 | 44 | exit $check_style_errors 45 | -------------------------------------------------------------------------------- /src/integrators/RotationMeasureIntegrator.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/integrators/RotationMeasureIntegrator.h" 2 | 3 | #include "hermes/integrators/LOSIntegrationMethods.h" 4 | 5 | namespace hermes { 6 | 7 | RotationMeasureIntegrator::RotationMeasureIntegrator(const std::shared_ptr& mfield, 8 | const std::shared_ptr& gdensity) 9 | : RotationMeasureIntegratorTemplate("RotationMeasure"), mfield(mfield), gdensity(gdensity) {} 10 | 11 | RotationMeasureIntegrator::~RotationMeasureIntegrator() {} 12 | 13 | QRotationMeasure RotationMeasureIntegrator::integrateOverLOS(const QDirection& direction) const { 14 | auto integrand = [this, direction](const QLength& dist) { 15 | return this->integralFunction(getGalacticPosition(getObsPosition(), dist, direction)); 16 | }; 17 | 18 | return simpsonIntegration([integrand](QLength dist) { return integrand(dist); }, 0, 19 | getMaxDistance(direction), 500); 20 | } 21 | 22 | QRMIntegral RotationMeasureIntegrator::integralFunction(const Vector3QLength& pos) const { 23 | const auto const_a0 = pow<3>(e_plus) / (8 * pi * pi * epsilon0 * squared(m_electron) * pow<3>(c_light)); 24 | 25 | Vector3QMField B = mfield->getField(pos); 26 | if (B.getR() == 0_muG) return 0; 27 | // TODO(adundovi): optimise 28 | QMField B_parallel = B.getR() * cos((B.getValue()).getAngleTo(pos.getValue())); 29 | 30 | return const_a0 * B_parallel * gdensity->getDensity(pos) * radian; 31 | } 32 | 33 | } // namespace hermes 34 | -------------------------------------------------------------------------------- /include/hermes/cosmicrays/Dragon2D.h: -------------------------------------------------------------------------------- 1 | #ifdef HERMES_HAVE_CFITSIO 2 | 3 | #ifndef HERMES_DRAGON2D_H 4 | #define HERMES_DRAGON2D_H 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "hermes/FITSWrapper.h" 11 | #include "hermes/cosmicrays/CosmicRayDensity.h" 12 | 13 | namespace hermes { namespace cosmicrays { 14 | /** 15 | * \addtogroup CosmicRays 16 | * @{ 17 | */ 18 | 19 | class Dragon2D : public CosmicRayDensity { 20 | private: 21 | std::string filename; 22 | std::unique_ptr ffile; 23 | 24 | void readFile(); 25 | void readEnergyAxis(); 26 | void readSpatialGrid2D(); 27 | void readDensity2D(); 28 | std::size_t calcArrayIndex2D(std::size_t iE, std::size_t ir, 29 | std::size_t iz); 30 | 31 | QLength rmin, rmax, zmin, zmax; 32 | int dimE; 33 | int dimz, dimr; 34 | std::vector> grid; 35 | 36 | // TODO: implement as std::unordered_map 37 | std::map energyIndex; 38 | 39 | public: 40 | Dragon2D(const PID &pid); 41 | Dragon2D(const std::vector &pids); 42 | Dragon2D(const std::string &filename, const PID &pid_); 43 | Dragon2D(const std::string &filename, const std::vector &pids); 44 | QPDensityPerEnergy getDensityPerEnergy( 45 | const QEnergy &E_, const Vector3QLength &pos_) const override; 46 | QPDensityPerEnergy getDensityPerEnergy(int iE_, 47 | const Vector3QLength &pos_) const; 48 | }; 49 | 50 | /** @}*/ 51 | }} // namespace hermes::cosmicrays 52 | 53 | #endif // HERMES_DRAGON2D_H 54 | 55 | #endif // HERMES_HAVE_CFITSIO 56 | -------------------------------------------------------------------------------- /test/testIntegrationMethods.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include "gtest/gtest.h" 6 | #include "hermes.h" 7 | 8 | namespace hermes { 9 | 10 | // test integral f(x) = sin(x)/x 11 | auto integrand = [](const QLength &dist) { 12 | return std::sin(static_cast(dist)) / static_cast(dist); 13 | }; 14 | const double integral_result = 0.6241500516015882032; 15 | 16 | TEST(IntegrationMethods, sumIntegration) { 17 | auto result = sumIntegration( 18 | [](QLength dist) { return integrand(dist); }, 1_m, 1000_m, 450000); 19 | 20 | EXPECT_NEAR(static_cast(result), integral_result, 1e-3); 21 | } 22 | 23 | TEST(IntegrationMethods, trapesoidIntegration) { 24 | auto result = trapesoidIntegration( 25 | [](QLength dist) { return integrand(dist); }, 1_m, 1000_m, 20000); 26 | 27 | EXPECT_NEAR(static_cast(result), integral_result, 1e-4); 28 | } 29 | 30 | TEST(IntegrationMethods, simpsonIntegration) { 31 | auto result = simpsonIntegration( 32 | [](QLength dist) { return integrand(dist); }, 1_m, 1000_m, 4000); 33 | 34 | EXPECT_NEAR(static_cast(result), integral_result, 1e-5); 35 | } 36 | 37 | TEST(IntegrationMethods, gslQAGIntegration) { 38 | auto result = gslQAGIntegration( 39 | [](QLength dist) { return integrand(dist); }, 1_m, 1000_m, 500); 40 | 41 | EXPECT_NEAR(static_cast(result), integral_result, 1e-7); 42 | } 43 | 44 | int main(int argc, char **argv) { 45 | ::testing::InitGoogleTest(&argc, argv); 46 | return RUN_ALL_TESTS(); 47 | } 48 | 49 | } // namespace hermes 50 | -------------------------------------------------------------------------------- /src/integrators/DarkMatterIntegrator.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/integrators/DarkMatterIntegrator.h" 2 | 3 | #include "hermes/integrators/LOSIntegrationMethods.h" 4 | 5 | namespace hermes { 6 | 7 | DarkMatterIntegrator::DarkMatterIntegrator( 8 | const std::shared_ptr &spectrum, 9 | const std::shared_ptr &profile) 10 | : GammaIntegratorTemplate("DarkMatter"), 11 | spectrum(spectrum), 12 | profile(profile) {} 13 | 14 | DarkMatterIntegrator::~DarkMatterIntegrator() {} 15 | 16 | QDiffIntensity DarkMatterIntegrator::integrateOverLOS( 17 | const QDirection &direction) const { 18 | return QDiffIntensity(0); 19 | } 20 | 21 | QDiffIntensity DarkMatterIntegrator::integrateOverLOS( 22 | const QDirection &direction_, const QEnergy &Egamma_) const { 23 | auto integrand = [this, direction_, Egamma_](const QLength &dist) { 24 | return this->spectralEmissivity( 25 | getGalacticPosition(getObsPosition(), dist, direction_), Egamma_); 26 | }; 27 | 28 | return gslQAGSIntegration( 29 | [integrand](QLength dist) { return integrand(dist); }, 0, 30 | getMaxDistance(direction_), 500) / 31 | (4_pi * 1_sr); 32 | } 33 | 34 | QGREmissivity DarkMatterIntegrator::spectralEmissivity( 35 | const Vector3QLength &pos, QEnergy Egamma) const { 36 | const auto sigma_v = 3e-26_cm3 / 1_s; 37 | return 0.5 * sigma_v * pow<4>(c_light) / 38 | pow<2>(spectrum->getRestMassEnergy()) * 39 | spectrum->getParticlesPerEnergy(Egamma) * 40 | pow<2>(profile->getMassDensity(pos.getR())); 41 | } 42 | 43 | } // namespace hermes 44 | -------------------------------------------------------------------------------- /test/testYMW16.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "gtest/gtest.h" 4 | #include "hermes.h" 5 | 6 | namespace hermes { 7 | 8 | TEST(YMW16, compareValues) { 9 | auto gdensity = std::make_shared(ionizedgas::YMW16()); 10 | 11 | // Values obtained from the original model 12 | // https://www.atnf.csiro.au/research/pulsar/ymw16/index.php 13 | // Change in coordinates: 14 | // x' = y 15 | // y' = -x 16 | // z' = z 17 | EXPECT_NEAR(static_cast(5.41746580 / 1_cm3), 18 | static_cast(gdensity->getDensity(Vector3QLength(0, 0, 0))), 1); 19 | EXPECT_NEAR(static_cast(3.891344 / 1_cm3), 20 | static_cast(gdensity->getDensity(Vector3QLength(0, 0, 15_pc))), 1); 21 | EXPECT_NEAR(static_cast(3.67050805 / 1_cm3), 22 | static_cast(gdensity->getDensity(Vector3QLength(100_pc, -100_pc, 0))), 1); 23 | EXPECT_NEAR(static_cast(0.17535603 / 1_cm3), 24 | static_cast(gdensity->getDensity(Vector3QLength(300_pc, 0, 0))), 1); 25 | EXPECT_NEAR(static_cast(0.070453 / 1_cm3), 26 | static_cast(gdensity->getDensity(Vector3QLength(4321_pc, -1234_pc, -111_pc))), 1); 27 | EXPECT_NEAR(static_cast(0.008080 / 1_cm3), 28 | static_cast(gdensity->getDensity(Vector3QLength(-999_pc, 999_pc, 999_pc))), 1); 29 | EXPECT_NEAR(static_cast(0.001527 / 1_cm3), 30 | static_cast(gdensity->getDensity(Vector3QLength(0_pc, -10_kpc, 3_kpc))), 1); 31 | } 32 | 33 | int main(int argc, char **argv) { 34 | ::testing::InitGoogleTest(&argc, argv); 35 | return RUN_ALL_TESTS(); 36 | } 37 | 38 | } // namespace hermes 39 | -------------------------------------------------------------------------------- /lib/pybind11/setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | long_description = file: README.rst 3 | long_description_content_type = text/x-rst 4 | description = Seamless operability between C++11 and Python 5 | author = Wenzel Jakob 6 | author_email = wenzel.jakob@epfl.ch 7 | url = https://github.com/pybind/pybind11 8 | license = BSD 9 | 10 | classifiers = 11 | Development Status :: 5 - Production/Stable 12 | Intended Audience :: Developers 13 | Topic :: Software Development :: Libraries :: Python Modules 14 | Topic :: Utilities 15 | Programming Language :: C++ 16 | Programming Language :: Python :: 3 :: Only 17 | Programming Language :: Python :: 3.6 18 | Programming Language :: Python :: 3.7 19 | Programming Language :: Python :: 3.8 20 | Programming Language :: Python :: 3.9 21 | Programming Language :: Python :: 3.10 22 | Programming Language :: Python :: 3.11 23 | Programming Language :: Python :: 3.12 24 | License :: OSI Approved :: BSD License 25 | Programming Language :: Python :: Implementation :: PyPy 26 | Programming Language :: Python :: Implementation :: CPython 27 | Programming Language :: C++ 28 | Topic :: Software Development :: Libraries :: Python Modules 29 | 30 | keywords = 31 | C++11 32 | Python bindings 33 | 34 | project_urls = 35 | Documentation = https://pybind11.readthedocs.io/ 36 | Bug Tracker = https://github.com/pybind/pybind11/issues 37 | Discussions = https://github.com/pybind/pybind11/discussions 38 | Changelog = https://pybind11.readthedocs.io/en/latest/changelog.html 39 | Chat = https://gitter.im/pybind/Lobby 40 | 41 | [options] 42 | python_requires = >=3.6 43 | zip_safe = False 44 | -------------------------------------------------------------------------------- /lib/kiss/include/kiss/logger.h: -------------------------------------------------------------------------------- 1 | #ifndef KISS_LOG_H 2 | #define KISS_LOG_H 3 | 4 | #include 5 | 6 | namespace kiss { 7 | 8 | enum eLogLevel { 9 | LOG_LEVEL_ERROR, LOG_LEVEL_WARNING, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG 10 | }; 11 | 12 | class Logger { 13 | static std::ostream *stream; 14 | static eLogLevel level; 15 | public: 16 | Logger(eLogLevel level); 17 | ~Logger(); 18 | static std::ostream &getLogStream(); 19 | static void setLogStream(std::ostream *s); 20 | static void setLogStream(std::ostream &s); 21 | 22 | static void setLogLevel(eLogLevel level); 23 | static eLogLevel getLogLevel(); 24 | 25 | static void loadEnvLogLevel(); 26 | 27 | operator std::ostream &() { 28 | return getLogStream(); 29 | } 30 | 31 | template inline Logger& operator<<(T& data) { 32 | #pragma omp critical (KISS_LOGGER) 33 | { 34 | getLogStream() << data; 35 | } 36 | return *this; 37 | } 38 | 39 | inline Logger& operator<<(std::ostream& (*func)(std::ostream&)) { 40 | #pragma omp critical (KISS_LOGGER) 41 | { 42 | getLogStream() << func; 43 | } 44 | return *this; 45 | } 46 | }; 47 | 48 | } // namespace kiss 49 | 50 | #define KISS_LOG_ERROR if (kiss::Logger::getLogLevel() < kiss::LOG_LEVEL_ERROR) {} else kiss::Logger(kiss::LOG_LEVEL_ERROR) 51 | #define KISS_LOG_WARNING if (kiss::Logger::getLogLevel() < kiss::LOG_LEVEL_WARNING) {} else kiss::Logger(kiss::LOG_LEVEL_WARNING) 52 | #define KISS_LOG_INFO if (kiss::Logger::getLogLevel() < kiss::LOG_LEVEL_INFO) {} else kiss::Logger(kiss::LOG_LEVEL_INFO) 53 | #define KISS_LOG_DEBUG if (kiss::Logger::getLogLevel() < kiss::LOG_LEVEL_DEBUG) {} else kiss::Logger(kiss::LOG_LEVEL_DEBUG) 54 | 55 | #endif /* KISSLOG_H */ 56 | -------------------------------------------------------------------------------- /src/neutralgas/Nakanishi06.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/neutralgas/Nakanishi06.h" 2 | 3 | namespace hermes { namespace neutralgas { 4 | 5 | Nakanishi06::Nakanishi06() : ProfileAbstract() {} 6 | Nakanishi06::~Nakanishi06() {} 7 | 8 | /* Nakanishi06, described in arXiv:1607.07886*/ 9 | QPDensity Nakanishi06::getHIDensity(const Vector3QLength &pos) const { 10 | const QLength h_0 = 1.06_pc; 11 | const QPDensity n_0 = 0.94 / 1_cm3; 12 | double r_kpc = static_cast(pos.getR() / 1_kpc); 13 | double exp_1 = std::exp(-r_kpc / 2.4); 14 | double exp_2 = std::exp(-std::pow((r_kpc - 9.5) / 4.8, 2)); 15 | QLength scaleHeight = 16 | h_0 * (116.3 + 19.3 * r_kpc + 4.1 * std::pow(r_kpc, 2) - 17 | 0.05 * std::pow(r_kpc, 3)); 18 | QPDensity densityOnPlane = n_0 * (0.6 * exp_1 + 0.24 * exp_2); 19 | return densityOnPlane * exp(-M_LN2 * pow<2>(pos.z / scaleHeight)); 20 | } 21 | 22 | QPDensity Nakanishi06::getH2Density(const Vector3QLength &pos) const { 23 | double z_kpc = static_cast(pos.z / 1_kpc); 24 | double r_kpc = static_cast(pos.getR() / 1_kpc); 25 | double E1 = 11.2 * std::exp(-pow<2>(r_kpc) / 0.874); 26 | double E2 = 0.83 * std::exp(-pow<2>((r_kpc - 4.0) / 3.2)); 27 | double h = 1.06e-3 * (10.8 * std::exp(0.28 * r_kpc) + 42.78); 28 | return 2.0 * 0.94 * (E1 + E2) * std::exp(-M_LN2 * pow<2>(z_kpc / h)) / 29 | 1_cm3; 30 | } 31 | 32 | QPDensity Nakanishi06::getPDensity(GasType gas, 33 | const Vector3QLength &pos) const { 34 | if (gas == GasType::HI) { 35 | return getHIDensity(pos); 36 | } 37 | if (gas == GasType::H2) { 38 | return getH2Density(pos); 39 | } 40 | return QPDensity(0); 41 | } 42 | 43 | }} // namespace hermes::neutralgas 44 | -------------------------------------------------------------------------------- /src/interactions/DifferentialCrossSection.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/interactions/DiffCrossSection.h" 2 | 3 | namespace hermes { namespace interactions { 4 | 5 | DifferentialCrossSection::DifferentialCrossSection(bool cachingEnabled_) : cachingEnabled(cachingEnabled_) {} 6 | 7 | DifferentialCrossSection::~DifferentialCrossSection() {} 8 | 9 | void DifferentialCrossSection::enableCaching() { cachingEnabled = true; }; 10 | 11 | void DifferentialCrossSection::disableCaching() { cachingEnabled = false; }; 12 | 13 | QDiffCrossSection DifferentialCrossSection::getDiffCrossSection(const QEnergy &E_proton, const QEnergy &E_gamma) const { 14 | return 0; 15 | } 16 | 17 | QDiffCrossSection DifferentialCrossSection::getDiffCrossSection(const QEnergy &E_electron, const QEnergy &E_photon, 18 | const QEnergy &E_gamma) const { 19 | return 0; 20 | } 21 | 22 | QDiffCrossSection DifferentialCrossSection::getDiffCrossSection(const PID &projectile, const PID &target, 23 | const QEnergy &E_proj, 24 | const QEnergy &E_secondary) const { 25 | return QDiffCrossSection(0); 26 | } 27 | 28 | QNumber nuclearScaling(const PID &projectile, const PID &target) { 29 | // Scaling based on Mori, 2009, APP, 31, 5, arXiv:0903.3260 30 | if (projectile == Proton && target == Proton) return 1.0_num; 31 | if (projectile == Proton && target == Helium) return 3.81_num; 32 | if (projectile == Helium && target == Proton) return 3.68_num; 33 | if (projectile == Helium && target == Helium) return 14.2_num; 34 | return QNumber(0); 35 | } 36 | 37 | }} // namespace hermes::interactions 38 | -------------------------------------------------------------------------------- /include/hermes/integrators/RotationMeasureIntegrator.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_RMINTEGRATOR_H 2 | #define HERMES_RMINTEGRATOR_H 3 | 4 | #include 5 | #include 6 | 7 | #include "hermes/Units.h" 8 | #include "hermes/integrators/IntegratorTemplate.h" 9 | #include "hermes/ionizedgas/IonizedGasDensity.h" 10 | #include "hermes/magneticfields/MagneticField.h" 11 | #include "hermes/skymaps/RotationMeasureSkymap.h" 12 | 13 | /** \file RotationMeasureIntegrator.h 14 | * Declares RotationMeasureIntegrator 15 | */ 16 | 17 | namespace hermes { 18 | /** 19 | * \addtogroup Integrators 20 | * @{ 21 | */ 22 | 23 | /** 24 | * \class RotationMeasureIntegrator 25 | * \brief Calculates rotation measure (RM) over the LOS 26 | * 27 | * The integrators depend on a charged gas density and a galactic magnetic field 28 | * model, for example, chargedgas::YMW16 and magneticfields::JF12 29 | */ 30 | class RotationMeasureIntegrator : public IntegratorTemplate { 31 | private: 32 | std::shared_ptr mfield; 33 | std::shared_ptr gdensity; 34 | 35 | QRMIntegral integralFunction(const Vector3QLength& pos) const; 36 | 37 | public: 38 | RotationMeasureIntegrator(const std::shared_ptr& mfield, 39 | const std::shared_ptr& gdensity); 40 | ~RotationMeasureIntegrator(); 41 | 42 | QRotationMeasure integrateOverLOS(const QDirection& iterdir) const override; 43 | QRotationMeasure integrateOverLOS(const QDirection& iterdir, const QNumber& num) const override { 44 | return QRotationMeasure(0); 45 | } 46 | }; 47 | 48 | /** @}*/ 49 | } // namespace hermes 50 | 51 | #endif // HERMES_RMINTEGRATOR_H 52 | -------------------------------------------------------------------------------- /src/darkmatter/NFWGProfile.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/darkmatter/NFWGProfile.h" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace hermes { namespace darkmatter { 9 | 10 | static const double f_NFW(double x, double gamma) { 11 | return 1. / std::pow(x, gamma) / std::pow(1 + x, 3 - gamma); 12 | } 13 | 14 | NFWGProfile::NFWGProfile(double gamma, double concentration, QMass M_200) 15 | : gamma(gamma), concentration(concentration), M_200(M_200) { 16 | init(); 17 | } 18 | 19 | double I_func(double x, void *params) { 20 | double gamma = *(double *)params; 21 | return x * x * f_NFW(x, gamma); 22 | } 23 | 24 | double I(double c, double gamma) { 25 | gsl_integration_workspace *w = gsl_integration_workspace_alloc(1000); 26 | double result, error; 27 | gsl_function F; 28 | F.function = &I_func; 29 | F.params = γ 30 | gsl_integration_qags(&F, 0, c, 0, 1e-7, 1000, w, &result, &error); 31 | gsl_integration_workspace_free(w); 32 | 33 | return result; 34 | } 35 | 36 | void NFWGProfile::init() { 37 | // TODO(adundovi): potentially improve the units system to handle the 1/3 38 | // power 39 | R_200 = 40 | std::pow(static_cast(3. * M_200 / 4. / M_PI / 200. / rho_cr), 41 | 1 / 3.); // definition of virial radius at 200 kpc 42 | r_s = R_200 / ((2. - gamma) * concentration); 43 | rho_s = 200. * rho_cr * std::pow(concentration, 3) / 3. / 44 | I(concentration, gamma); 45 | } 46 | 47 | QMassDensity NFWGProfile::getRhoSun() const { return rho_s; } 48 | 49 | QMassDensity NFWGProfile::getMassDensity(QLength r) const { 50 | auto x = r / r_s; 51 | return rho_s * f_NFW(static_cast(x), static_cast(gamma)); 52 | } 53 | 54 | }} // namespace hermes::darkmatter 55 | -------------------------------------------------------------------------------- /include/hermes/darkmatter/PPPC4DMIDChannels.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_PPPC4DMIDCHANNELS_H 2 | #define HERMES_PPPC4DMIDCHANNELS_H 3 | 4 | namespace hermes { namespace darkmatter { 5 | /** 6 | * \addtogroup DarkMatter 7 | * @{ 8 | */ 9 | 10 | enum class Channel { 11 | e = 2, 12 | mu = 5, 13 | tau = 8, 14 | q = 9, 15 | c = 10, 16 | b = 11, 17 | t = 12, 18 | W = 15, 19 | Z = 18, 20 | h = 21 21 | }; 22 | 23 | enum class Mass { 24 | m5GeV = 5, 25 | m6GeV = 6, 26 | m8GeV = 8, 27 | m10GeV = 10, 28 | m15GeV = 15, 29 | m20GeV = 20, 30 | m25GeV = 25, 31 | m30GeV = 30, 32 | m40GeV = 40, 33 | m50GeV = 50, 34 | m60GeV = 60, 35 | m70GeV = 70, 36 | m80GeV = 80, 37 | m90GeV = 90, 38 | m100GeV = 100, 39 | m110GeV = 110, 40 | m120GeV = 120, 41 | m130GeV = 130, 42 | m140GeV = 140, 43 | m150GeV = 150, 44 | m160GeV = 160, 45 | m180GeV = 180, 46 | m200GeV = 200, 47 | m220GeV = 220, 48 | m240GeV = 240, 49 | m260GeV = 260, 50 | m280GeV = 280, 51 | m300GeV = 300, 52 | m330GeV = 330, 53 | m360GeV = 360, 54 | m400GeV = 400, 55 | m450GeV = 450, 56 | m500GeV = 500, 57 | m550GeV = 550, 58 | m600GeV = 600, 59 | m650GeV = 650, 60 | m700GeV = 700, 61 | m750GeV = 750, 62 | m800GeV = 800, 63 | m900GeV = 900, 64 | m1TeV = 1000, 65 | m1100GeV = 1100, 66 | m1200GeV = 1200, 67 | m1300GeV = 1300, 68 | m1500GeV = 1500, 69 | m1700GeV = 1700, 70 | m2TeV = 2000, 71 | m3TeV = 3000, 72 | m4TeV = 4000, 73 | m5TeV = 5000, 74 | m6TeV = 6000, 75 | m7TeV = 7000, 76 | m8TeV = 8000, 77 | m9TeV = 9000, 78 | m10TeV = 10000, 79 | m12TeV = 12000, 80 | m15TeV = 15000, 81 | m20TeV = 20000, 82 | m30TeV = 30000, 83 | m50TeV = 50000, 84 | m100TeV = 100000 85 | }; 86 | 87 | /** @}*/ 88 | }} // namespace hermes::darkmatter 89 | 90 | #endif // HERMES_PPPC4DMIDCHANNELS_H 91 | -------------------------------------------------------------------------------- /src/integrators/DispersionMeasureIntegrator.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/integrators/DispersionMeasureIntegrator.h" 2 | 3 | #include "hermes/integrators/LOSIntegrationMethods.h" 4 | 5 | namespace hermes { 6 | 7 | DispersionMeasureIntegrator::DispersionMeasureIntegrator(const std::shared_ptr &gdensity) 8 | : DispersionMeasureIntegratorTemplate("DispersionMeasure"), gdensity(gdensity) {} 9 | 10 | DispersionMeasureIntegrator::~DispersionMeasureIntegrator() {} 11 | 12 | QDispersionMeasure DispersionMeasureIntegrator::integrateOverLOS(const QDirection &direction) const { 13 | auto integrand = [this, direction](const QLength &dist) { 14 | return gdensity->getDensity(getGalacticPosition(getObsPosition(), dist, direction)); 15 | }; 16 | 17 | return gslQAGIntegration([this, integrand](QLength dist) { return integrand(dist); }, 18 | 0, getMaxDistance(direction), 500); 19 | } 20 | 21 | DispersionMeasureIntegrator::tLOSProfile DispersionMeasureIntegrator::getLOSProfile(const QDirection &direction, 22 | int Nsteps) const { 23 | auto integrand = [this, direction](const QLength &dist) { 24 | return gdensity->getDensity(getGalacticPosition(getObsPosition(), dist, direction)); 25 | }; 26 | 27 | QLength start = 0_m; 28 | QLength stop = getMaxDistance(direction); 29 | QLength delta_d = (stop - start) / Nsteps; 30 | 31 | tLOSProfile profile; 32 | 33 | for (QLength dist = start; dist <= stop; dist += delta_d) { 34 | profile.first.push_back(dist); 35 | profile.second.push_back(static_cast(integrand(dist))); 36 | } 37 | 38 | return profile; 39 | } 40 | 41 | } // namespace hermes 42 | -------------------------------------------------------------------------------- /include/hermes/integrators/PiZeroAbsorptionIntegrator.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_PIZEROABSORPTIONINTEGRATOR_H 2 | #define HERMES_PIZEROABSORPTIONINTEGRATOR_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "hermes/ProgressBar.h" 9 | #include "hermes/Units.h" 10 | #include "hermes/cosmicrays/CosmicRayDensity.h" 11 | #include "hermes/integrators/PiZeroIntegrator.h" 12 | #include "hermes/interactions/BreitWheeler.h" 13 | #include "hermes/interactions/DiffCrossSection.h" 14 | #include "hermes/neutralgas/RingModel.h" 15 | 16 | namespace hermes { 17 | /** 18 | * \addtogroup Integrators 19 | * @{ 20 | */ 21 | 22 | class PiZeroAbsorptionIntegrator : public PiZeroIntegrator { 23 | private: 24 | std::unique_ptr bwCrossSec{std::make_unique()}; 25 | 26 | public: 27 | PiZeroAbsorptionIntegrator(const std::shared_ptr &, 28 | const std::shared_ptr &, 29 | const std::shared_ptr &); 30 | PiZeroAbsorptionIntegrator(const std::vector> &, 31 | const std::shared_ptr &, 32 | const std::shared_ptr &); 33 | ~PiZeroAbsorptionIntegrator(); 34 | 35 | QDiffIntensity integrateOverLOS(const QDirection &iterdir) const override; 36 | QDiffIntensity integrateOverLOS(const QDirection &iterdir, const QEnergy &Egamma) const override; 37 | 38 | QInverseLength absorptionCoefficient(const QEnergy &Egamma) const; 39 | }; 40 | 41 | /** @}*/ 42 | } // namespace hermes 43 | 44 | #endif // HERMES_PIZEROABSORPTIONINTEGRATOR_H 45 | -------------------------------------------------------------------------------- /lib/pybind11/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Wenzel Jakob , All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | Please also refer to the file .github/CONTRIBUTING.md, which clarifies licensing of 29 | external contributions to this project including patches, pull requests, etc. 30 | -------------------------------------------------------------------------------- /src/interactions/Kamae06Gamma.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/interactions/Kamae06Gamma.h" 2 | 3 | namespace hermes { namespace interactions { 4 | 5 | Kamae06Gamma::Kamae06Gamma() : DifferentialCrossSection(false) {} 6 | 7 | void Kamae06Gamma::setCachingStorage(std::unique_ptr cache_) { 8 | cache = std::move(cache_); 9 | enableCaching(); 10 | auto f = [this](QEnergy E_proton, QEnergy E_gamma) { return this->getDiffCrossSectionDirectly(E_proton, E_gamma); }; 11 | cache->setFunction(f); 12 | }; 13 | 14 | QDiffCrossSection Kamae06Gamma::getDiffCrossSection(const QEnergy &E_proton, const QEnergy &E_gamma) const { 15 | if (cachingEnabled) return cache->getValue(E_proton, E_gamma); 16 | return getDiffCrossSectionDirectly(E_proton, E_gamma); 17 | } 18 | 19 | QDiffCrossSection Kamae06Gamma::getDiffCrossSectionDirectly(const QEnergy &E_proton, const QEnergy &E_gamma) const { 20 | PARAMSET params; /* struct where parameters are stored */ 21 | // memset(¶ms, 0, sizeof(PARAMSET)); 22 | 23 | /* proton kinetic energy in GeV */ 24 | double T_proton_GeV = static_cast(E_proton / 1_GeV); 25 | /* photon energ in GeV */ 26 | double E_gamma_GeV = static_cast(E_gamma / 1_GeV); 27 | 28 | gamma_param(T_proton_GeV, ¶ms); 29 | double dsigma_dlogTp = sigma_incl_tot(ID_GAMMA, E_gamma_GeV, std::min(T_proton_GeV, 1e5), ¶ms); 30 | 31 | return QDiffCrossSection(dsigma_dlogTp / E_gamma_GeV * (1_mbarn / 1_GeV)); 32 | } 33 | 34 | QDiffCrossSection Kamae06Gamma::getDiffCrossSection(const PID &projectile, const PID &target, const QEnergy &E_proj, 35 | const QEnergy &E_secondary) const { 36 | return nuclearScaling(projectile, target) * getDiffCrossSection(E_proj, E_secondary); 37 | } 38 | 39 | }} // namespace hermes::interactions 40 | -------------------------------------------------------------------------------- /include/hermes/units/UnitsBasic.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_UNITSBASIC_H 2 | #define HERMES_UNITSBASIC_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #ifndef HERMES_UNITSDISABLE 9 | #include "UnitsQClass.h" 10 | #else 11 | #include "UnitsSimple.h" 12 | #endif 13 | 14 | #include "UnitsSIPrefixes.h" 15 | 16 | namespace hermes { namespace units { 17 | /** 18 | * \addtogroup Units 19 | * @{ 20 | */ 21 | 22 | // Predefined basic SI units 23 | constexpr QLength metre(1.0); 24 | constexpr QTime second(1.0); 25 | constexpr QMass gram(0.001); 26 | constexpr QECurrent ampere(1.0); 27 | constexpr QTemperature kelvin(1.0); 28 | constexpr QSubstance mole(1.0); 29 | constexpr QLIntensity candela(1.0); 30 | constexpr QAngle radian(1.0); 31 | constexpr QSolidAngle steradian(1.0); 32 | 33 | // SI prefixes for basic SI untis 34 | GENERATE_PREFIXED_UNITS(metre) 35 | GENERATE_PREFIXED_UNITS(second) 36 | GENERATE_PREFIXED_UNITS(gram) 37 | GENERATE_PREFIXED_UNITS(ampere) 38 | GENERATE_PREFIXED_UNITS(kelvin) 39 | GENERATE_PREFIXED_UNITS(mole) 40 | GENERATE_PREFIXED_UNITS(candela) 41 | 42 | // symbols with prefixes for basic SI units 43 | GENERATE_SHORT_PREFIXED_UNITS(metre, m) 44 | GENERATE_SHORT_PREFIXED_UNITS(second, s) 45 | GENERATE_SHORT_PREFIXED_UNITS(gram, g) 46 | GENERATE_SHORT_PREFIXED_UNITS(ampere, a) 47 | GENERATE_SHORT_PREFIXED_UNITS(kelvin, K) 48 | GENERATE_SHORT_PREFIXED_UNITS(mole, mol) 49 | GENERATE_SHORT_PREFIXED_UNITS(candela, cd) 50 | 51 | // Math constants 52 | #ifndef M_PI 53 | #define M_PI 3.1415926535897932384626433832795 54 | #endif 55 | constexpr double pi = M_PI; 56 | 57 | #ifndef M_E 58 | #define M_E 0.5772156649015328606065120900824 59 | #endif 60 | constexpr double eulerGamma = M_E; 61 | 62 | /** @}*/ 63 | }} // namespace hermes::units 64 | 65 | #endif // HERMES_UNITSBASIC_H 66 | -------------------------------------------------------------------------------- /include/hermes/photonfields/PhotonField.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_PHOTONFIELD_H 2 | #define HERMES_PHOTONFIELD_H 3 | 4 | #include "hermes/Grid.h" 5 | #include "hermes/Units.h" 6 | 7 | namespace hermes { namespace photonfields { 8 | /** 9 | * \addtogroup PhotonFields 10 | * @{ 11 | */ 12 | 13 | class PhotonField { 14 | protected: 15 | typedef std::vector tEnergyRange; 16 | mutable tEnergyRange energyRange; 17 | 18 | bool scaleFactorFlag; 19 | double energyScaleFactor; 20 | QEnergy startEnergy, endEnergy; 21 | 22 | public: 23 | typedef tEnergyRange::iterator iterator; 24 | typedef tEnergyRange::const_iterator const_iterator; 25 | 26 | PhotonField() {} 27 | virtual ~PhotonField() {} 28 | 29 | virtual QEnergyDensity getEnergyDensity(const Vector3QLength &pos, 30 | const QEnergy &E_photon) const = 0; 31 | 32 | virtual QEnergyDensity getEnergyDensity(const Vector3QLength &pos, 33 | std::size_t iE) const = 0; 34 | 35 | void setStartEnergy(QEnergy E_) { startEnergy = E_; } 36 | 37 | void setEndEnergy(QEnergy E_) { endEnergy = E_; } 38 | 39 | void setEnergyScaleFactor(double s_) { energyScaleFactor = s_; } 40 | 41 | QEnergy getStartEnergy() const { return startEnergy; } 42 | 43 | QEnergy getEndEnergy() const { return endEnergy; } 44 | 45 | double getEnergyScaleFactor() const { return energyScaleFactor; } 46 | 47 | tEnergyRange getEnergyAxis() const { return energyRange; } 48 | 49 | iterator begin() { return energyRange.begin(); } 50 | const_iterator begin() const { return energyRange.begin(); } 51 | iterator end() { return energyRange.end(); } 52 | const_iterator end() const { return energyRange.end(); } 53 | }; 54 | 55 | /** @}*/ 56 | }} // namespace hermes::photonfields 57 | 58 | #endif // HERMES_PHOTONFIELD_H 59 | -------------------------------------------------------------------------------- /lib/pybind11/pybind11/__main__.py: -------------------------------------------------------------------------------- 1 | # pylint: disable=missing-function-docstring 2 | 3 | import argparse 4 | import sys 5 | import sysconfig 6 | 7 | from ._version import __version__ 8 | from .commands import get_cmake_dir, get_include, get_pkgconfig_dir 9 | 10 | 11 | def print_includes() -> None: 12 | dirs = [ 13 | sysconfig.get_path("include"), 14 | sysconfig.get_path("platinclude"), 15 | get_include(), 16 | ] 17 | 18 | # Make unique but preserve order 19 | unique_dirs = [] 20 | for d in dirs: 21 | if d and d not in unique_dirs: 22 | unique_dirs.append(d) 23 | 24 | print(" ".join("-I" + d for d in unique_dirs)) 25 | 26 | 27 | def main() -> None: 28 | parser = argparse.ArgumentParser() 29 | parser.add_argument( 30 | "--version", 31 | action="version", 32 | version=__version__, 33 | help="Print the version and exit.", 34 | ) 35 | parser.add_argument( 36 | "--includes", 37 | action="store_true", 38 | help="Include flags for both pybind11 and Python headers.", 39 | ) 40 | parser.add_argument( 41 | "--cmakedir", 42 | action="store_true", 43 | help="Print the CMake module directory, ideal for setting -Dpybind11_ROOT in CMake.", 44 | ) 45 | parser.add_argument( 46 | "--pkgconfigdir", 47 | action="store_true", 48 | help="Print the pkgconfig directory, ideal for setting $PKG_CONFIG_PATH.", 49 | ) 50 | args = parser.parse_args() 51 | if not sys.argv[1:]: 52 | parser.print_help() 53 | if args.includes: 54 | print_includes() 55 | if args.cmakedir: 56 | print(get_cmake_dir()) 57 | if args.pkgconfigdir: 58 | print(get_pkgconfig_dir()) 59 | 60 | 61 | if __name__ == "__main__": 62 | main() 63 | -------------------------------------------------------------------------------- /lib/gtest/googletest/test/production.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // This is part of the unit test for gtest_prod.h. 32 | 33 | #include "production.h" 34 | 35 | PrivateCode::PrivateCode() : x_(0) {} 36 | -------------------------------------------------------------------------------- /include/hermes/photonfields/CMB.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_CMB_H 2 | #define HERMES_CMB_H 3 | 4 | #include "hermes/photonfields/PhotonField.h" 5 | 6 | namespace hermes { namespace photonfields { 7 | /** 8 | * \addtogroup PhotonFields 9 | * @{ 10 | */ 11 | 12 | class CMB : public PhotonField { 13 | private: 14 | std::vector density; 15 | 16 | void buildEnergyRange() { 17 | const double scaling = getEnergyScaleFactor(); 18 | const QEnergy E_start = getStartEnergy(); 19 | const QEnergy E_end = getEndEnergy(); 20 | 21 | for (auto E = E_start; E < E_end; E = E * scaling) 22 | energyRange.push_back(E); 23 | } 24 | 25 | void precomputeValues() { 26 | for (auto itE = begin(); itE != end(); ++itE) 27 | density.push_back(getEnergyDensity(Vector3QLength(0), (*itE))); 28 | } 29 | 30 | public: 31 | CMB() { 32 | setEnergyScaleFactor(1.01); 33 | setStartEnergy(1.0e9_Hz * h_planck); 34 | setEndEnergy(1.0e12_Hz * h_planck); 35 | buildEnergyRange(); 36 | precomputeValues(); 37 | } 38 | 39 | QEnergyDensity getEnergyDensity(const Vector3QLength &pos, 40 | const QEnergy &E_photon) const override { 41 | const QTemperature T_CMB(2.725); 42 | QFrequency nu = E_photon / h_planck; 43 | 44 | return getPlanckSpectralEnergyDensity(nu, T_CMB) * nu; 45 | } 46 | 47 | QSpectralEnergyDensity getPlanckSpectralEnergyDensity( 48 | const QFrequency &nu, const QTemperature &T) const { 49 | return (8.0_pi * h_planck * pow<3>(nu)) / pow<3>(c_light) / 50 | (exp(h_planck * nu / (k_boltzmann * T)) - 1.); 51 | } 52 | 53 | QEnergyDensity getEnergyDensity(const Vector3QLength &pos_, 54 | std::size_t iE_) const override { 55 | return density[iE_]; 56 | } 57 | }; 58 | 59 | /** @}*/ 60 | }} // namespace hermes::photonfields 61 | 62 | #endif // HERMES_CMB_H 63 | -------------------------------------------------------------------------------- /include/hermes/photonfields/ISRF.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_ISRF_H 2 | #define HERMES_ISRF_H 3 | 4 | #include 5 | 6 | #include "hermes/photonfields/PhotonField.h" 7 | 8 | namespace hermes { namespace photonfields { 9 | /** 10 | * \addtogroup PhotonFields 11 | * @{ 12 | */ 13 | 14 | class ISRF : public PhotonField { 15 | private: 16 | const static int freqR1 = 200; 17 | const static int freqR2 = 680; 18 | const static int freqR3 = 331; 19 | std::array logwavelenghts; 20 | std::array r_id = { 21 | 0.0, 0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 22 | 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10.0, 23 | 11.0, 12.0, 14.0, 16.0, 18.0, 20.0, 25.0, 30.0}; // in kpc (30) 24 | std::array z_id = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 25 | 0.8, 1.0, 1.2, 1.5, 2.0, 2.5, 3.0, 26 | 4.0, 5.0, 6.0, 8.0, 10.0, 12.0, 15.0, 27 | 20.0, 25.0, 30.0}; // in kpc (24) 28 | std::vector isrf; 29 | 30 | void buildEnergyRange(); 31 | 32 | double getISRF(std::size_t ir, std::size_t iz, std::size_t ifreq) const; 33 | 34 | void loadFrequencyAxis(); 35 | void loadISRF(); 36 | 37 | public: 38 | ISRF(); 39 | std::size_t getSize() const; 40 | QEnergyDensity getEnergyDensity(const QLength &r, const QLength &z, 41 | const QEnergy &E_photon) const; 42 | QEnergyDensity getEnergyDensity(const Vector3QLength &pos, 43 | const QEnergy &E_photon) const override; 44 | QEnergyDensity getEnergyDensity(const Vector3QLength &pos_, 45 | std::size_t iE_) const override; 46 | }; 47 | 48 | /** @}*/ 49 | }} // namespace hermes::photonfields 50 | 51 | #endif // HERMES_ISRF_H 52 | -------------------------------------------------------------------------------- /include/hermes/cosmicrays/Dragon3D.h: -------------------------------------------------------------------------------- 1 | #ifdef HERMES_HAVE_CFITSIO 2 | 3 | #ifndef HERMES_DRAGON3D_H 4 | #define HERMES_DRAGON3D_H 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "hermes/FITSWrapper.h" 12 | #include "hermes/cosmicrays/CosmicRayDensity.h" 13 | 14 | namespace hermes { namespace cosmicrays { 15 | /** 16 | * \addtogroup CosmicRays 17 | * @{ 18 | */ 19 | 20 | class Dragon3D : public CosmicRayDensity { 21 | private: 22 | std::string filename; 23 | std::unique_ptr ffile; 24 | 25 | void readFile(); 26 | void readEnergyAxis(); 27 | void readSpatialGrid3D(); 28 | void readDensity3D(); 29 | std::size_t calcArrayIndex2D(std::size_t iE, std::size_t ir, 30 | std::size_t iz); 31 | 32 | QLength rmin, rmax, zmin, zmax; 33 | QLength xmin, xmax, ymin, ymax; 34 | int dimE; 35 | int dimx, dimy, dimz, dimr; 36 | std::vector> grid; 37 | 38 | // TODO: implement as std::unordered_map 39 | std::map energyIndex; 40 | 41 | public: 42 | Dragon3D(const PID &pid); 43 | Dragon3D(const std::vector &pids); 44 | Dragon3D(const std::string &filename, const PID &pid_); 45 | Dragon3D(const std::string &filename, const std::vector &pids); 46 | QPDensityPerEnergy getDensityPerEnergy( 47 | const QEnergy &E_, const Vector3QLength &pos_) const override; 48 | QPDensityPerEnergy getDensityPerEnergy(int iE_, 49 | const Vector3QLength &pos_) const; 50 | std::array getXBoundaries() const; 51 | std::array getYBoundaries() const; 52 | std::array getZBoundaries() const; 53 | }; 54 | 55 | /** @}*/ 56 | }} // namespace hermes::cosmicrays 57 | 58 | #endif // HERMES_DRAGON3D_H 59 | 60 | #endif // HERMES_HAVE_CFITSIO 61 | -------------------------------------------------------------------------------- /src/magneticfields/MagneticFieldGrid.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/magneticfields/MagneticFieldGrid.h" 2 | 3 | #include 4 | 5 | namespace hermes { namespace magneticfields { 6 | 7 | MagneticFieldGrid::MagneticFieldGrid(std::shared_ptr grid) { 8 | setGrid(std::move(grid)); 9 | } 10 | 11 | void MagneticFieldGrid::setGrid(std::shared_ptr grid) { 12 | this->grid = std::move(grid); 13 | } 14 | 15 | std::shared_ptr MagneticFieldGrid::getGrid() { return grid; } 16 | 17 | Vector3d MagneticFieldGrid::getField(const Vector3d& pos) const { 18 | return grid->interpolate(pos); 19 | } 20 | 21 | ModulatedMagneticFieldGrid::ModulatedMagneticFieldGrid( 22 | const std::shared_ptr& grid, 23 | const std::shared_ptr& modGrid) { 24 | grid->setReflective(false); 25 | modGrid->setReflective(true); 26 | setGrid(grid); 27 | setModulationGrid(modGrid); 28 | } 29 | 30 | void ModulatedMagneticFieldGrid::setGrid(std::shared_ptr g) { 31 | grid = std::move(g); 32 | } 33 | 34 | std::shared_ptr ModulatedMagneticFieldGrid::getGrid() { 35 | return grid; 36 | } 37 | 38 | void ModulatedMagneticFieldGrid::setModulationGrid( 39 | std::shared_ptr g) { 40 | modGrid = std::move(g); 41 | } 42 | 43 | std::shared_ptr ModulatedMagneticFieldGrid::getModulationGrid() { 44 | return modGrid; 45 | } 46 | 47 | void ModulatedMagneticFieldGrid::setReflective(bool gridReflective, 48 | bool modGridReflective) { 49 | grid->setReflective(gridReflective); 50 | modGrid->setReflective(modGridReflective); 51 | } 52 | 53 | Vector3d ModulatedMagneticFieldGrid::getField(const Vector3d& pos) const { 54 | float m = modGrid->interpolate(pos); 55 | Vector3d b = grid->interpolate(pos); 56 | return b * m; 57 | } 58 | 59 | }} // namespace hermes::magneticfields 60 | -------------------------------------------------------------------------------- /test/testPicard3D.cpp: -------------------------------------------------------------------------------- 1 | #ifdef HERMES_HAVE_HDF5 2 | #include "gtest/gtest.h" 3 | #include "hermes.h" 4 | 5 | namespace hermes { 6 | 7 | TEST(Picard3DTest, testDensities) { 8 | std::vector particleTypes = {Helium}; 9 | auto cosmicRayModel = std::make_shared(particleTypes); 10 | double tolerance; 11 | double error = 1e-6; 12 | 13 | auto position = Vector3QLength(-20.0_kpc, -20.0_kpc, -4.0_kpc); 14 | int energy = 0; 15 | auto density = cosmicRayModel->getDensityPerEnergy(energy, position); 16 | double expected = 0.0000000000e+00; 17 | tolerance = expected * error; 18 | EXPECT_NEAR(static_cast(density), expected, tolerance); 19 | 20 | position = Vector3QLength(17.5_kpc, 5.0_kpc, 3.5_kpc); 21 | energy = 20; 22 | density = cosmicRayModel->getDensityPerEnergy(energy, position); 23 | expected = 9.9185357000e-07; 24 | tolerance = expected * error; 25 | EXPECT_NEAR(static_cast(density), expected, tolerance); 26 | 27 | position = Vector3QLength(0.0_kpc, 0.0_kpc, 0.0_kpc); 28 | energy = 30; 29 | density = cosmicRayModel->getDensityPerEnergy(energy, position); 30 | expected = 1.7621159598e-11; 31 | tolerance = expected * error; 32 | EXPECT_NEAR(static_cast(density), expected, tolerance); 33 | 34 | position = Vector3QLength(-1.25_kpc, -1.25_kpc, 3.5_kpc); 35 | energy = 15; 36 | density = cosmicRayModel->getDensityPerEnergy(energy, position); 37 | expected = 1.5442656666e-01; 38 | tolerance = expected * error; 39 | EXPECT_NEAR(static_cast(density), expected, tolerance); 40 | 41 | position = Vector3QLength(20.0_kpc, 20.0_kpc, 4.0_kpc); 42 | energy = 7; 43 | density = cosmicRayModel->getDensityPerEnergy(energy, position); 44 | expected = 0.0000000000e+00; 45 | tolerance = expected / 1e4; 46 | EXPECT_NEAR(static_cast(density), expected, tolerance); 47 | } 48 | 49 | } // namespace hermes 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /lib/cparamlib/ChangeLog: -------------------------------------------------------------------------------- 1 | 2008-05-16 Niklas Karlsson 2 | 3 | * Python Bugfixes in ParamModel.py 4 | 5 | * Documentation updated to reflect updates 6 | 7 | 2008-01-17 Niklas Karlsson 8 | 9 | * Documentation extended with tutorial, though pT example is 10 | still missing. 11 | 12 | * Examples divided into separate executables. 13 | 14 | 2007-12-30 Niklas Karlsson 15 | 16 | * Option --enable-userdoc added so that documentation is not 17 | always built. 18 | 19 | 2007-12-20 Niklas Karlsson 20 | 21 | * Implementation Changed PARAMSET_PT to contain three double arrays 22 | instead of mix of doubles and double arrays. 23 | 24 | 2007-12-14 Niklas Karlsson 25 | 26 | * Documentation A first version of doxygen generated documentation is 27 | implemented. 28 | 29 | 2007-12-07 Niklas Karlsson 30 | 31 | * Now only checks for SWIG if --enable-python is used and only builds 32 | in directory python in that case. 33 | 34 | 2007-09-10 Niklas Karlsson 35 | 36 | * Option --enable-pythonbuild [default = no] changed back to 37 | --enable-python [default = no]. 38 | 39 | 2007-06-04 Niklas Karlsson 40 | 41 | * Interface Major interface changes: 42 | 1. All parameter calculating functions now takes a pointer 43 | to a struct containing necessary parameters. 44 | 2. Added sigma_pt_ for calculation of pT dists. 45 | 46 | * Option --enable-python [default = no] changed to 47 | --enable-pythonbuild [default = no] 48 | 49 | 2006-11-27 Niklas Karlsson 50 | 51 | * Option --enable-python [default = no] added. 52 | 53 | 2006-11-24 Niklas Karlsson 54 | 55 | * Now uses autoconf/automake/libtool. 56 | -------------------------------------------------------------------------------- /include/hermes/integrators/FreeFreeIntegrator.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_FREEFREEINTEGRATOR_H 2 | #define HERMES_FREEFREEINTEGRATOR_H 3 | 4 | #include 5 | #include 6 | 7 | #include "hermes/Units.h" 8 | #include "hermes/integrators/IntegratorTemplate.h" 9 | #include "hermes/ionizedgas/IonizedGasDensity.h" 10 | #include "hermes/magneticfields/MagneticField.h" 11 | 12 | /** \file FreeFreeIntegrator.h 13 | * Declares FreeFreeIntegrator 14 | */ 15 | 16 | namespace hermes { 17 | /** 18 | * \addtogroup Integrators 19 | * @{ 20 | */ 21 | 22 | /** 23 | * \class FreeFreeIntegrator 24 | * \brief Calculates Free-free emission over the LOS 25 | * 26 | * The integrator depends only on a charged gas density model and results 27 | * is calculated based on a specified frequency 28 | */ 29 | class FreeFreeIntegrator : public RadioIntegratorTemplate { 30 | private: 31 | std::shared_ptr gdensity; 32 | 33 | public: 34 | FreeFreeIntegrator(const std::shared_ptr &gdensity); 35 | ~FreeFreeIntegrator(); 36 | 37 | void setFrequency(const QFrequency &freq); 38 | QFrequency getFrequency() const; 39 | 40 | QTemperature integrateOverLOS(const QDirection &iterdir) const override; 41 | QTemperature integrateOverLOS(const QDirection &iterdir, const QFrequency &freq) const override; 42 | 43 | QNumber gauntFactor(const QFrequency &freq, const QTemperature &T, int Z) const; 44 | QEmissivity spectralEmissivityExplicit(const QPDensity &N, const QPDensity &N_e, const QFrequency &freq, 45 | const QTemperature &T, int Z) const; 46 | QEmissivity spectralEmissivity(const Vector3QLength &pos, const QFrequency &freq) const; 47 | QInverseLength absorptionCoefficient(const Vector3QLength &pos, const QFrequency &freq) const; 48 | }; 49 | 50 | /** @}*/ 51 | } // namespace hermes 52 | 53 | #endif // HERMES_FREEFREEINTEGRATOR_H 54 | -------------------------------------------------------------------------------- /include/hermes/integrators/SynchroAbsorptionIntegrator.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_SYNCHROABSORPTIONINTEGRATOR_H 2 | #define HERMES_SYNCHROABSORPTIONINTEGRATOR_H 3 | 4 | #include "hermes/integrators/FreeFreeIntegrator.h" 5 | #include "hermes/integrators/IntegratorTemplate.h" 6 | #include "hermes/integrators/SynchroIntegrator.h" 7 | 8 | /** \file SynchroAbsorptionIntegrator.h 9 | * Declares SynchroAbsorptionIntegrator 10 | */ 11 | 12 | namespace hermes { 13 | /** 14 | * \addtogroup Integrators 15 | * @{ 16 | */ 17 | 18 | /** 19 | * \class SynchroAbsorptionIntegrator 20 | * \brief Calculates synchrotron radiation (DM) over the LOS 21 | * 22 | * The integrator depends on a galactic magnetic field model, such as 23 | * magneticfields.JF12, a cosmic ray lepton distribution and 24 | * a nonrelativistic ionised gas 25 | */ 26 | class SynchroAbsorptionIntegrator : public RadioIntegratorTemplate { 27 | private: 28 | std::shared_ptr mfield; 29 | std::shared_ptr crdensity; 30 | std::shared_ptr gdensity; 31 | std::shared_ptr intSynchro; 32 | std::shared_ptr intFreeFree; 33 | 34 | public: 35 | SynchroAbsorptionIntegrator(const std::shared_ptr &mfield, 36 | const std::shared_ptr &crdensity, 37 | const std::shared_ptr &gdensity); 38 | ~SynchroAbsorptionIntegrator(); 39 | 40 | void setFrequency(const QFrequency &freq); 41 | QFrequency getFrequency() const; 42 | 43 | QTemperature integrateOverLOS(const QDirection &iterdir_) const override; 44 | QTemperature integrateOverLOS(const QDirection &iterdir, const QFrequency &freq) const override; 45 | }; 46 | 47 | /** @}*/ 48 | } // namespace hermes 49 | 50 | #endif // HERMES_SYNCHROABSORPTIONINTEGRATOR_H 51 | -------------------------------------------------------------------------------- /include/hermes/interactions/Kamae06Gamma.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_KAMAE06GAMMA_H 2 | #define HERMES_KAMAE06GAMMA_H 3 | 4 | /* 5 | https://github.com/niklask/cparamlib 6 | 7 | cparamlib is a simple library for calculation of fluxes for stable secondary 8 | particles created in proton-proton interactions in astronomical environment 9 | according to the model described in Tuneyoshi Kamae, Niklas Karlsson, Tsunefumi 10 | Mizuno, Toshinori Abe, and Tatsumi Koi; "Parameterization of $\gamma$, $e^{\pm}$ 11 | and Neutrino Spectra Produced by $p-p$ Interaction in Astronomical Environment" 12 | to appear in Astrophysical Journal (2006) and 13 | Niklas Karlsson and Tuneyoshi Kamae; 14 | "Parameterization of the Angular Distribution of Gamma Rays Produced by P-P 15 | Interaction in Astronomical Environment" to by submitted to Astrophysical 16 | Journal (2007). 17 | */ 18 | 19 | #include 20 | 21 | #include "hermes/CacheTools.h" 22 | #include "hermes/interactions/DiffCrossSection.h" 23 | 24 | extern "C" { 25 | #include "cparamlib.h" 26 | } 27 | 28 | namespace hermes { namespace interactions { 29 | /** 30 | * \addtogroup Interactions 31 | * @{ 32 | */ 33 | 34 | class Kamae06Gamma : public DifferentialCrossSection { 35 | private: 36 | std::unique_ptr cache; 37 | 38 | public: 39 | Kamae06Gamma(); 40 | void setCachingStorage(std::unique_ptr cache); 41 | 42 | QDiffCrossSection getDiffCrossSection(const QEnergy &E_proton, const QEnergy &E_gamma) const override; 43 | QDiffCrossSection getDiffCrossSection(const PID &projectile, const PID &target, const QEnergy &E_proj, 44 | const QEnergy &E_secondary) const override; 45 | 46 | QDiffCrossSection getDiffCrossSectionDirectly(const QEnergy &E_proton, const QEnergy &E_gamma) const; 47 | }; 48 | 49 | /** @}*/ 50 | }} // namespace hermes::interactions 51 | 52 | #endif // HERMES_KAMAE06GAMMA_H 53 | -------------------------------------------------------------------------------- /lib/kiss/include/kiss/convert.h: -------------------------------------------------------------------------------- 1 | #ifndef KISS_CONVERT_H 2 | #define KISS_CONVERT_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace kiss { 11 | 12 | class bad_conversion: public std::runtime_error { 13 | public: 14 | bad_conversion(std::string const& s) : 15 | std::runtime_error(s) { 16 | } 17 | }; 18 | 19 | template 20 | inline std::string str(T const& x) { 21 | std::ostringstream o; 22 | o.imbue(std::locale("C")); 23 | o << x; 24 | if (!o) { 25 | #ifdef DEBUG 26 | std::cerr << "bad_conversion: str(" << typeid(x).name() << ")"; 27 | #endif 28 | throw bad_conversion(std::string("str(") + typeid(x).name() + ")"); 29 | } 30 | return o.str(); 31 | } 32 | 33 | template 34 | inline void convert(const char *s, T& x) { 35 | if (s == 0) { 36 | #ifdef DEBUG 37 | std::cerr << "bad_conversion: convert, null pointer"; 38 | #endif 39 | throw bad_conversion("null pointer"); 40 | } 41 | std::istringstream i(s); 42 | i.imbue(std::locale("C")); 43 | i >> x; 44 | if (!i) { 45 | #ifdef DEBUG 46 | std::cerr << "bad_conversion: convert (" << s << ")"; 47 | #endif 48 | throw bad_conversion(std::string(s) + " to " + typeid(x).name()); 49 | } 50 | } 51 | 52 | template 53 | inline void convert(std::string const& s, T& x) { 54 | std::istringstream i(s); 55 | i.imbue(std::locale("C")); 56 | i >> x; 57 | if (!i) { 58 | #ifdef DEBUG 59 | std::cerr << "bad_conversion: convert (" << s << ")"; 60 | #endif 61 | throw bad_conversion(s + " to " + typeid(x).name()); 62 | } 63 | } 64 | 65 | template 66 | inline T convertTo(std::string const& s, bool failIfLeftoverChars = true) { 67 | T x; 68 | convert(s, x, failIfLeftoverChars); 69 | return x; 70 | } 71 | 72 | } // namespace kiss 73 | 74 | #endif /* KISSCONVERT_H */ 75 | -------------------------------------------------------------------------------- /include/hermes/interactions/Kamae06Neutrino.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_KAMAE06NEUTRINO_H 2 | #define HERMES_KAMAE06NEUTRINO_H 3 | 4 | /* 5 | https://github.com/niklask/cparamlib 6 | 7 | cparamlib is a simple library for calculation of fluxes for stable secondary 8 | particles created in proton-proton interactions in astronomical environment 9 | according to the model described in Tuneyoshi Kamae, Niklas Karlsson, Tsunefumi 10 | Mizuno, Toshinori Abe, and Tatsumi Koi; "Parameterization of $\gamma$, $e^{\pm}$ 11 | and Neutrino Spectra Produced by $p-p$ Interaction in Astronomical Environment" 12 | to appear in Astrophysical Journal (2006) and 13 | Niklas Karlsson and Tuneyoshi Kamae; 14 | "Parameterization of the Angular Distribution of Gamma Rays Produced by P-P 15 | Interaction in Astronomical Environment" to by submitted to Astrophysical 16 | Journal (2007). 17 | */ 18 | 19 | #include 20 | 21 | #include "hermes/CacheTools.h" 22 | #include "hermes/interactions/DiffCrossSection.h" 23 | 24 | extern "C" { 25 | #include "cparamlib.h" 26 | } 27 | 28 | namespace hermes { namespace interactions { 29 | /** 30 | * \addtogroup Interactions 31 | * @{ 32 | */ 33 | 34 | class Kamae06Neutrino : public DifferentialCrossSection { 35 | private: 36 | std::unique_ptr cache; 37 | 38 | public: 39 | Kamae06Neutrino(); 40 | void setCachingStorage(std::unique_ptr cache); 41 | 42 | QDiffCrossSection getDiffCrossSection(const QEnergy &E_proton, const QEnergy &E_nu) const override; 43 | QDiffCrossSection getDiffCrossSection(const PID &projectile, const PID &target, const QEnergy &E_proj, 44 | const QEnergy &E_secondary) const override; 45 | 46 | QDiffCrossSection getDiffCrossSectionDirectly(const QEnergy &E_proton, const QEnergy &E_nu) const; 47 | }; 48 | 49 | /** @}*/ 50 | }} // namespace hermes::interactions 51 | 52 | #endif // HERMES_KAMAE06NEUTRINO_H 53 | -------------------------------------------------------------------------------- /lib/pybind11/include/pybind11/detail/typeid.h: -------------------------------------------------------------------------------- 1 | /* 2 | pybind11/detail/typeid.h: Compiler-independent access to type identifiers 3 | 4 | Copyright (c) 2016 Wenzel Jakob 5 | 6 | All rights reserved. Use of this source code is governed by a 7 | BSD-style license that can be found in the LICENSE file. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include 13 | #include 14 | 15 | #if defined(__GNUG__) 16 | # include 17 | #endif 18 | 19 | #include "common.h" 20 | 21 | PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) 22 | PYBIND11_NAMESPACE_BEGIN(detail) 23 | 24 | /// Erase all occurrences of a substring 25 | inline void erase_all(std::string &string, const std::string &search) { 26 | for (size_t pos = 0;;) { 27 | pos = string.find(search, pos); 28 | if (pos == std::string::npos) { 29 | break; 30 | } 31 | string.erase(pos, search.length()); 32 | } 33 | } 34 | 35 | PYBIND11_NOINLINE void clean_type_id(std::string &name) { 36 | #if defined(__GNUG__) 37 | int status = 0; 38 | std::unique_ptr res{ 39 | abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status), std::free}; 40 | if (status == 0) { 41 | name = res.get(); 42 | } 43 | #else 44 | detail::erase_all(name, "class "); 45 | detail::erase_all(name, "struct "); 46 | detail::erase_all(name, "enum "); 47 | #endif 48 | detail::erase_all(name, "pybind11::"); 49 | } 50 | 51 | inline std::string clean_type_id(const char *typeid_name) { 52 | std::string name(typeid_name); 53 | detail::clean_type_id(name); 54 | return name; 55 | } 56 | 57 | PYBIND11_NAMESPACE_END(detail) 58 | 59 | /// Return a string representation of a C++ type 60 | template 61 | static std::string type_id() { 62 | return detail::clean_type_id(typeid(T).name()); 63 | } 64 | 65 | PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) 66 | -------------------------------------------------------------------------------- /lib/gtest/googletest/include/gtest/internal/custom/README.md: -------------------------------------------------------------------------------- 1 | # Customization Points 2 | 3 | The custom directory is an injection point for custom user configurations. 4 | 5 | ## Header `gtest.h` 6 | 7 | ### The following macros can be defined: 8 | 9 | * `GTEST_OS_STACK_TRACE_GETTER_` - The name of an implementation of 10 | `OsStackTraceGetterInterface`. 11 | * `GTEST_CUSTOM_TEMPDIR_FUNCTION_` - An override for `testing::TempDir()`. See 12 | `testing::TempDir` for semantics and signature. 13 | 14 | ## Header `gtest-port.h` 15 | 16 | The following macros can be defined: 17 | 18 | ### Flag related macros: 19 | 20 | * `GTEST_FLAG(flag_name)` 21 | * `GTEST_USE_OWN_FLAGFILE_FLAG_` - Define to 0 when the system provides its 22 | own flagfile flag parsing. 23 | * `GTEST_DECLARE_bool_(name)` 24 | * `GTEST_DECLARE_int32_(name)` 25 | * `GTEST_DECLARE_string_(name)` 26 | * `GTEST_DEFINE_bool_(name, default_val, doc)` 27 | * `GTEST_DEFINE_int32_(name, default_val, doc)` 28 | * `GTEST_DEFINE_string_(name, default_val, doc)` 29 | 30 | ### Logging: 31 | 32 | * `GTEST_LOG_(severity)` 33 | * `GTEST_CHECK_(condition)` 34 | * Functions `LogToStderr()` and `FlushInfoLog()` have to be provided too. 35 | 36 | ### Threading: 37 | 38 | * `GTEST_HAS_NOTIFICATION_` - Enabled if Notification is already provided. 39 | * `GTEST_HAS_MUTEX_AND_THREAD_LOCAL_` - Enabled if `Mutex` and `ThreadLocal` 40 | are already provided. Must also provide `GTEST_DECLARE_STATIC_MUTEX_(mutex)` 41 | and `GTEST_DEFINE_STATIC_MUTEX_(mutex)` 42 | * `GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)` 43 | * `GTEST_LOCK_EXCLUDED_(locks)` 44 | 45 | ### Underlying library support features 46 | 47 | * `GTEST_HAS_CXXABI_H_` 48 | 49 | ### Exporting API symbols: 50 | 51 | * `GTEST_API_` - Specifier for exported symbols. 52 | 53 | ## Header `gtest-printers.h` 54 | 55 | * See documentation at `gtest/gtest-printers.h` for details on how to define a 56 | custom printer. 57 | -------------------------------------------------------------------------------- /lib/kiss/src/logger.cpp: -------------------------------------------------------------------------------- 1 | #include "kiss/logger.h" 2 | 3 | #include 4 | #include 5 | 6 | namespace kiss { 7 | 8 | std::ostream *Logger::stream = &std::cerr; 9 | eLogLevel Logger::level = LOG_LEVEL_WARNING; 10 | const char* sLoggerLevel[] = { " ERROR ", "WARNING", " INFO ", " DEBUG " }; 11 | 12 | class EnvLogger { 13 | public: 14 | EnvLogger() { 15 | Logger::loadEnvLogLevel(); 16 | } 17 | }; 18 | static EnvLogger _env_log_; 19 | 20 | Logger::Logger(eLogLevel level) { 21 | time_t rawtime; 22 | struct tm * timeinfo; 23 | char buffer[80]; 24 | 25 | time(&rawtime); 26 | timeinfo = localtime(&rawtime); 27 | 28 | strftime(buffer, 80, "%Y-%m-%d %H:%M:%S ", timeinfo); 29 | *stream << buffer; 30 | *stream << "[" << sLoggerLevel[level] << "] "; 31 | } 32 | 33 | Logger::~Logger() { 34 | *stream << std::endl; 35 | } 36 | 37 | std::ostream &Logger::getLogStream() { 38 | return (*stream); 39 | } 40 | 41 | void Logger::setLogStream(std::ostream *s) { 42 | stream = s; 43 | } 44 | 45 | void Logger::setLogStream(std::ostream &s) { 46 | stream = &s; 47 | } 48 | 49 | void Logger::setLogLevel(eLogLevel l) { 50 | level = l; 51 | } 52 | eLogLevel Logger::getLogLevel() { 53 | return (level); 54 | } 55 | 56 | 57 | 58 | 59 | void Logger::loadEnvLogLevel() { 60 | if (::getenv("KISS_LOG_LEVEL")) { 61 | 62 | int level = atoi(::getenv("KISS_LOG_LEVEL")); 63 | switch (level) { 64 | case LOG_LEVEL_ERROR: 65 | Logger::setLogLevel(LOG_LEVEL_ERROR); 66 | break; 67 | case LOG_LEVEL_WARNING: 68 | Logger::setLogLevel(LOG_LEVEL_WARNING); 69 | break; 70 | case LOG_LEVEL_INFO: 71 | Logger::setLogLevel(LOG_LEVEL_INFO); 72 | break; 73 | case LOG_LEVEL_DEBUG: 74 | Logger::setLogLevel(LOG_LEVEL_DEBUG); 75 | break; 76 | default: 77 | std::cerr << "kiss::Logger: unknown log level in KISS_LOG_LEVEL '" 78 | << level << " values from 0-3 expected." << std::endl; 79 | break; 80 | } 81 | } 82 | } 83 | 84 | } // namespace kiss 85 | 86 | -------------------------------------------------------------------------------- /lib/gtest/googletest/include/gtest/internal/custom/gtest.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Injection point for custom user configurations. See README for details 31 | // 32 | // ** Custom implementation starts here ** 33 | 34 | #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 35 | #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 36 | 37 | #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 38 | -------------------------------------------------------------------------------- /include/hermes/magneticfields/MagneticFieldGrid.h: -------------------------------------------------------------------------------- 1 | #ifndef CRPROPA_MAGNETICFIELDGRID_H 2 | #define CRPROPA_MAGNETICFIELDGRID_H 3 | 4 | #include "hermes/Grid.h" 5 | #include "hermes/magneticfields/MagneticField.h" 6 | 7 | namespace hermes { namespace magneticfields { 8 | /** 9 | * \addtogroup MagneticFields 10 | * @{ 11 | */ 12 | 13 | /** 14 | @class MagneticFieldGrid 15 | @brief Magnetic field on a periodic (or reflective), cartesian grid with 16 | trilinear interpolation. 17 | 18 | This class wraps a VectorGrid to serve as a MagneticField. 19 | */ 20 | class MagneticFieldGrid : public MagneticField { 21 | std::shared_ptr grid; 22 | 23 | public: 24 | MagneticFieldGrid(std::shared_ptr grid); 25 | void setGrid(std::shared_ptr grid); 26 | std::shared_ptr getGrid(); 27 | Vector3d getField(const Vector3d& position) const; 28 | }; 29 | 30 | /** 31 | @class ModulatedMagneticFieldGrid 32 | @brief Modulated magnetic field on a periodic grid. 33 | 34 | This class wraps a VectorGrid to serve as a MagneticField. 35 | The field is modulated on-the-fly with a ScalarGrid. 36 | The VectorGrid and ScalarGrid do not need to share the same origin, spacing or 37 | size. 38 | */ 39 | class ModulatedMagneticFieldGrid : public MagneticField { 40 | std::shared_ptr grid; 41 | std::shared_ptr modGrid; 42 | 43 | public: 44 | ModulatedMagneticFieldGrid() {} 45 | ModulatedMagneticFieldGrid(const std::shared_ptr& grid, 46 | const std::shared_ptr& modGrid); 47 | void setGrid(std::shared_ptr grid); 48 | void setModulationGrid(std::shared_ptr modGrid); 49 | std::shared_ptr getGrid(); 50 | std::shared_ptr getModulationGrid(); 51 | void setReflective(bool gridReflective, bool modGridReflective); 52 | Vector3d getField(const Vector3d& position) const; 53 | }; 54 | /** @} */ 55 | }} // namespace hermes::magneticfields 56 | 57 | #endif // CRPROPA_MAGNETICFIELDGRID_H 58 | -------------------------------------------------------------------------------- /include/hermes/interactions/AAfragGamma.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_AAFRAGGAMMA_H 2 | #define HERMES_AAFRAGGAMMA_H 3 | 4 | /* 5 | Model references 6 | (1) S. Koldobskiy, M. Kachelrieß, A. Lskavyan, A. Neronov, S. Ostapchenko, and D. V. Semikoz, “Energy spectra of 7 | secondaries in proton-proton interactions,” Phys. Rev. D, vol. 104, no. 12, p. 123027, 2021, arXiv:2110.00496 8 | (2) M. Kachelrieß, I. V. Moskalenko, and S. Ostapchenko, “AAfrag: Interpolation routines for Monte Carlo results on 9 | secondary production in proton-proton, proton-nucleus and nucleus-nucleus interactions,” Comput. Phys. Commun., vol. 10 | 245, p. 106846, 2019. 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | #include "hermes/interactions/DiffCrossSection.h" 17 | 18 | #define DEFAULT_GAMMASPECTRUM_FILE "Interactions/AAfrag2021Gamma.txt.gz" 19 | #define DEFAULT_NUSPECTRUM_FILE "Interactions/AAfrag2021Neutrino.txt.gz" 20 | 21 | namespace hermes { namespace interactions { 22 | /** 23 | * \addtogroup Interactions 24 | * @{ 25 | */ 26 | 27 | class AAfragXsecs : public DifferentialCrossSection { 28 | protected: 29 | std::vector xs_pp; 30 | std::vector xs_pHe; 31 | std::vector xs_Hep; 32 | std::vector xs_HeHe; 33 | void loadData(const std::string &filename); 34 | 35 | public: 36 | AAfragXsecs(const std::string &filename); 37 | QDiffCrossSection getDiffCrossSection(const QEnergy &E_proton, const QEnergy &E_gamma) const override; 38 | QDiffCrossSection getDiffCrossSection(const PID &projectile, const PID &target, const QEnergy &E_proj, 39 | const QEnergy &E_secondary) const override; 40 | }; 41 | 42 | class AAfragGamma final : public AAfragXsecs { 43 | public: 44 | AAfragGamma() : AAfragXsecs(DEFAULT_GAMMASPECTRUM_FILE) {} 45 | }; 46 | 47 | class AAfragNeutrino final : public AAfragXsecs { 48 | public: 49 | AAfragNeutrino() : AAfragXsecs(DEFAULT_NUSPECTRUM_FILE) {} 50 | }; 51 | 52 | /** @}*/ 53 | 54 | }} // namespace hermes::interactions 55 | #endif // HERMES_AAFRAGGAMMA_H 56 | -------------------------------------------------------------------------------- /lib/gtest/googletest/include/gtest/internal/custom/gtest-port.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Injection point for custom user configurations. See README for details 31 | // 32 | // ** Custom implementation starts here ** 33 | 34 | #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 35 | #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 36 | 37 | #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 38 | -------------------------------------------------------------------------------- /lib/gtest/googletest/test/gtest_main_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | 31 | #include "gtest/gtest.h" 32 | 33 | // Tests that we don't have to define main() when we link to 34 | // gtest_main instead of gtest. 35 | 36 | namespace { 37 | 38 | TEST(GTestMainTest, ShouldSucceed) { 39 | } 40 | 41 | } // namespace 42 | 43 | // We are using the main() function defined in gtest_main.cc, so we 44 | // don't define it here. 45 | -------------------------------------------------------------------------------- /include/hermes/units/UnitsSimple.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_UNITSSIMPLE_H 2 | #define HERMES_UNITSSIMPLE_H 3 | 4 | #define HERMES_UNITSDISABLE 5 | 6 | #include 7 | #include 8 | 9 | #include "UnitsSIPrefixes.h" 10 | 11 | namespace hermes { namespace units { 12 | 13 | typedef double QAMomentum; 14 | typedef double QAcceleration; 15 | typedef double QAngle; 16 | typedef double QAngularMomentum; 17 | typedef double QArea; 18 | typedef double QColumnDensity; 19 | typedef double QMassDensity; 20 | typedef double QDiffCrossSection; 21 | typedef double QDiffFlux; 22 | typedef double QDiffIntensity; 23 | typedef double QDispersionMeasure; 24 | typedef double QECapacitance; 25 | typedef double QECharge; 26 | typedef double QECurrent; 27 | typedef double QEPotential; 28 | typedef double QEResistance; 29 | typedef double QEmissivity; 30 | typedef double QEnergy; 31 | typedef double QEnergyDensity; 32 | typedef double QForce; 33 | typedef double QFrequency; 34 | typedef double QIntensity; 35 | typedef double QInverseEnergy; 36 | typedef double QInverseLength; 37 | typedef double QLIntensity; 38 | typedef double QLength; 39 | typedef double QMField; 40 | typedef double QMass; 41 | typedef double QMomentum; 42 | typedef double QNumber; 43 | typedef double QPDensity; 44 | typedef double QPDensityPerEnergy; 45 | typedef double QPower; 46 | typedef double QPressure; 47 | typedef double QRotationMeasure; 48 | typedef double QSolidAngle; 49 | typedef double QSpectralEnergyDensity; 50 | typedef double QSpeed; 51 | typedef double QSubstance; 52 | typedef double QTemperature; 53 | typedef double QTime; 54 | typedef double QVolume; 55 | 56 | typedef double QRMIntegral; 57 | typedef double QSynchroConstant; 58 | typedef double QPiZeroIntegral; 59 | typedef double QRingCOIntensity; 60 | typedef double QRingX0Unit; 61 | typedef double QICInnerIntegral; 62 | typedef double QGREmissivity; 63 | typedef double QEnergyOverTemperature; 64 | 65 | constexpr double squared(const QNumber &num) { return num * num; } 66 | 67 | }} // namespace hermes::units 68 | 69 | #endif // HERMES_UNITSSIMPLE_H 70 | -------------------------------------------------------------------------------- /src/interactions/BreitWheeler.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/interactions/BreitWheeler.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include "hermes/Common.h" 8 | 9 | #define GSL_LIMIT 10000 10 | #define GSL_KEYINT 3 11 | 12 | namespace hermes { namespace interactions { 13 | 14 | BreitWheeler::BreitWheeler() {} 15 | 16 | QArea BreitWheeler::getCrossSection(const QEnergy &Egamma, const QEnergy &Eph, const QAngle &theta) const { 17 | QNumber costheta = cos(theta); 18 | QNumber chi = Egamma * Eph / (2 * pow<2>(m_electron * c_squared)); 19 | QNumber x = chi * (1_num - costheta); 20 | 21 | if (x < 1_num) return QArea(0); 22 | 23 | QNumber beta = sqrt(1_num - 1 / x); 24 | 25 | return 3. / 16. * sigma_Thompson * (1_num - beta * beta) * 26 | (2 * beta * (beta * beta - 2_num) + (3_num - pow<4>(beta)) * log((1_num + beta) / (1_num - beta))); 27 | } 28 | 29 | QArea BreitWheeler::integratedOverTheta(const QEnergy &Egamma, const QEnergy &Eph) const { 30 | QNumber chi = Egamma * Eph / (2 * pow<2>(m_electron * c_squared)); 31 | QNumber muThreshold = 1.0_num - 1. / chi; 32 | 33 | if (muThreshold < -1.0_num) return QArea(0); 34 | 35 | QNumber a = -1.; 36 | QNumber b = muThreshold; 37 | double abs_error = 0.0; // disabled 38 | double rel_error = 1.0e-4; 39 | int key = GSL_INTEG_GAUSS51; // GSL_INTEG_GAUSS15; 40 | double result = 0; 41 | double error = 0; 42 | 43 | auto integrand = [this, Egamma, Eph](double mu) { 44 | auto th = std::acos(mu); 45 | return (1 - mu) * static_cast(getCrossSection(Egamma, Eph, QAngle(th))); 46 | }; 47 | 48 | gsl_function_pp Fp(integrand); 49 | gsl_function *F = static_cast(&Fp); 50 | 51 | gsl_integration_workspace *w = gsl_integration_workspace_alloc(GSL_LIMIT); 52 | gsl_integration_qag(F, static_cast(a), static_cast(b), abs_error, rel_error, GSL_LIMIT, key, w, 53 | &result, &error); 54 | gsl_integration_workspace_free(w); 55 | 56 | return 0.5 * result; 57 | } 58 | 59 | }} // namespace hermes::interactions 60 | -------------------------------------------------------------------------------- /lib/gtest/googletest/scripts/test/Makefile: -------------------------------------------------------------------------------- 1 | # A Makefile for fusing Google Test and building a sample test against it. 2 | # 3 | # SYNOPSIS: 4 | # 5 | # make [all] - makes everything. 6 | # make TARGET - makes the given target. 7 | # make check - makes everything and runs the built sample test. 8 | # make clean - removes all files generated by make. 9 | 10 | # Points to the root of fused Google Test, relative to where this file is. 11 | FUSED_GTEST_DIR = output 12 | 13 | # Paths to the fused gtest files. 14 | FUSED_GTEST_H = $(FUSED_GTEST_DIR)/gtest/gtest.h 15 | FUSED_GTEST_ALL_CC = $(FUSED_GTEST_DIR)/gtest/gtest-all.cc 16 | 17 | # Where to find the sample test. 18 | SAMPLE_DIR = ../../samples 19 | 20 | # Where to find gtest_main.cc. 21 | GTEST_MAIN_CC = ../../src/gtest_main.cc 22 | 23 | # Flags passed to the preprocessor. 24 | # We have no idea here whether pthreads is available in the system, so 25 | # disable its use. 26 | CPPFLAGS += -I$(FUSED_GTEST_DIR) -DGTEST_HAS_PTHREAD=0 27 | 28 | # Flags passed to the C++ compiler. 29 | CXXFLAGS += -g 30 | 31 | all : sample1_unittest 32 | 33 | check : all 34 | ./sample1_unittest 35 | 36 | clean : 37 | rm -rf $(FUSED_GTEST_DIR) sample1_unittest *.o 38 | 39 | $(FUSED_GTEST_H) : 40 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR) 41 | 42 | $(FUSED_GTEST_ALL_CC) : 43 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR) 44 | 45 | gtest-all.o : $(FUSED_GTEST_H) $(FUSED_GTEST_ALL_CC) 46 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(FUSED_GTEST_DIR)/gtest/gtest-all.cc 47 | 48 | gtest_main.o : $(FUSED_GTEST_H) $(GTEST_MAIN_CC) 49 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_MAIN_CC) 50 | 51 | sample1.o : $(SAMPLE_DIR)/sample1.cc $(SAMPLE_DIR)/sample1.h 52 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1.cc 53 | 54 | sample1_unittest.o : $(SAMPLE_DIR)/sample1_unittest.cc \ 55 | $(SAMPLE_DIR)/sample1.h $(FUSED_GTEST_H) 56 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1_unittest.cc 57 | 58 | sample1_unittest : sample1.o sample1_unittest.o gtest-all.o gtest_main.o 59 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@ 60 | -------------------------------------------------------------------------------- /lib/gtest/googletest/samples/sample1.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | 32 | #ifndef GTEST_SAMPLES_SAMPLE1_H_ 33 | #define GTEST_SAMPLES_SAMPLE1_H_ 34 | 35 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1. 36 | int Factorial(int n); 37 | 38 | // Returns true if and only if n is a prime number. 39 | bool IsPrime(int n); 40 | 41 | #endif // GTEST_SAMPLES_SAMPLE1_H_ 42 | -------------------------------------------------------------------------------- /lib/gtest/googletest/src/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | #include "gtest/gtest.h" 32 | 33 | #ifdef ARDUINO 34 | void setup() { 35 | testing::InitGoogleTest(); 36 | } 37 | 38 | void loop() { RUN_ALL_TESTS(); } 39 | 40 | #else 41 | 42 | GTEST_API_ int main(int argc, char **argv) { 43 | printf("Running main() from %s\n", __FILE__); 44 | testing::InitGoogleTest(&argc, argv); 45 | return RUN_ALL_TESTS(); 46 | } 47 | #endif 48 | -------------------------------------------------------------------------------- /lib/gtest/googletest/test/googletest-uninitialized-test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | 31 | #include "gtest/gtest.h" 32 | 33 | TEST(DummyTest, Dummy) { 34 | // This test doesn't verify anything. We just need it to create a 35 | // realistic stage for testing the behavior of Google Test when 36 | // RUN_ALL_TESTS() is called without 37 | // testing::InitGoogleTest() being called first. 38 | } 39 | 40 | int main() { 41 | return RUN_ALL_TESTS(); 42 | } 43 | -------------------------------------------------------------------------------- /include/hermes/magneticfields/Sun08.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_SUN08_H 2 | #define HERMES_SUN08_H 3 | 4 | #include "hermes/Grid.h" 5 | #include "hermes/GridTools.h" 6 | #include "hermes/magneticfields/MagneticField.h" 7 | 8 | namespace hermes { namespace magneticfields { 9 | /** 10 | * \addtogroup MagneticFields 11 | * @{ 12 | */ 13 | 14 | /** 15 | @class Sun08 16 | @brief 17 | 18 | The implemention of the galactic magnetic field model ASS+RING from Sun et al. 2008. 19 | 20 | See: Sun, X. H., et al. 2008 A&A 477.2 21 | https://www.aanda.org/articles/aa/abs/2008/02/aa8671-07/aa8671-07.html 22 | */ 23 | 24 | class Sun08 : public MagneticField { 25 | private: 26 | bool useTurbulent; 27 | bool useHalo; 28 | std::shared_ptr turbulentGrid; 29 | 30 | QLength R_Sun; 31 | // disk parameters 32 | QLength disk_z_0, disk_R_c; 33 | QLength disk_R_0, disk_R_1, disk_R_2, disk_R_3; 34 | QMField disk_B_0, disk_B_c, disk_B_turbulent; 35 | // halo parameters 36 | QLength halo_z_0, halo_z_1, halo_R_0; 37 | QMField halo_B_0; 38 | QAngle pitch; 39 | QMField B_turbulent; 40 | 41 | public: 42 | Sun08(); 43 | 44 | #ifdef HERMES_HAVE_FFTW3F 45 | // Create a random realization for the turbulent field 46 | void randomTurbulent(int seed = 0); 47 | #endif 48 | 49 | /** 50 | * Set a turbulent grid and activate the turbulent field component 51 | * @param grid vector grid containing a random field of Brms = 1 52 | */ 53 | void setTurbulentGrid(std::shared_ptr grid); 54 | 55 | std::shared_ptr getTurbulentGrid(); 56 | 57 | void setUseTurbulent(bool use); 58 | void setUseHalo(bool use); 59 | bool isUsingTurbulent() const; 60 | bool isUsingHalo() const; 61 | 62 | // Regular field component 63 | Vector3QMField getRegularField(const Vector3QLength &pos) const; 64 | 65 | // Turbulent field component 66 | Vector3QMField getTurbulentField(const Vector3QLength &pos) const; 67 | 68 | // Get the total field 69 | Vector3QMField getField(const Vector3QLength &pos) const override; 70 | }; 71 | 72 | /** @} */ 73 | }} // namespace hermes::magneticfields 74 | 75 | #endif // HERMES_SUN08_H 76 | -------------------------------------------------------------------------------- /lib/gtest/googletest/test/gtest_testbridge_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018, Google LLC. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | 31 | // This program is meant to be run by gtest_test_filter_test.py. Do not run 32 | // it directly. 33 | 34 | #include "gtest/gtest.h" 35 | 36 | // These tests are used to detect if filtering is working. Only 37 | // 'TestThatSucceeds' should ever run. 38 | 39 | TEST(TestFilterTest, TestThatSucceeds) {} 40 | 41 | TEST(TestFilterTest, TestThatFails) { 42 | ASSERT_TRUE(false) << "This test should never be run."; 43 | } 44 | -------------------------------------------------------------------------------- /lib/gtest/googletest/test/gtest_xml_outfile1_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // gtest_xml_outfile1_test_ writes some xml via TestProperty used by 31 | // gtest_xml_outfiles_test.py 32 | 33 | #include "gtest/gtest.h" 34 | 35 | class PropertyOne : public testing::Test { 36 | protected: 37 | void SetUp() override { RecordProperty("SetUpProp", 1); } 38 | void TearDown() override { RecordProperty("TearDownProp", 1); } 39 | }; 40 | 41 | TEST_F(PropertyOne, TestSomeProperties) { 42 | RecordProperty("TestSomeProperty", 1); 43 | } 44 | -------------------------------------------------------------------------------- /lib/gtest/googletest/test/gtest_xml_outfile2_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // gtest_xml_outfile2_test_ writes some xml via TestProperty used by 31 | // gtest_xml_outfiles_test.py 32 | 33 | #include "gtest/gtest.h" 34 | 35 | class PropertyTwo : public testing::Test { 36 | protected: 37 | void SetUp() override { RecordProperty("SetUpProp", 2); } 38 | void TearDown() override { RecordProperty("TearDownProp", 2); } 39 | }; 40 | 41 | TEST_F(PropertyTwo, TestSomeProperties) { 42 | RecordProperty("TestSomeProperty", 2); 43 | } 44 | -------------------------------------------------------------------------------- /src/interactions/Kamae06Neutrino.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/interactions/Kamae06Neutrino.h" 2 | 3 | namespace hermes { namespace interactions { 4 | 5 | Kamae06Neutrino::Kamae06Neutrino() : DifferentialCrossSection(false) {} 6 | 7 | void Kamae06Neutrino::setCachingStorage(std::unique_ptr cache_) { 8 | cache = std::move(cache_); 9 | enableCaching(); 10 | auto f = [this](QEnergy E_proton, QEnergy E_nu) { return this->getDiffCrossSectionDirectly(E_proton, E_nu); }; 11 | cache->setFunction(f); 12 | }; 13 | 14 | QDiffCrossSection Kamae06Neutrino::getDiffCrossSection(const QEnergy &E_proton, const QEnergy &E_nu) const { 15 | if (cachingEnabled) return cache->getValue(E_proton, E_nu); 16 | return getDiffCrossSectionDirectly(E_proton, E_nu); 17 | } 18 | 19 | QDiffCrossSection Kamae06Neutrino::getDiffCrossSectionDirectly(const QEnergy &E_proton, const QEnergy &E_nu) const { 20 | PARAMSET params; /* struct where parameters are stored */ 21 | // memset(¶ms, 0, sizeof(PARAMSET)); 22 | 23 | /* proton kinetic energy in GeV */ 24 | double T_proton_GeV = static_cast(E_proton / 1_GeV); 25 | /* photon energ in GeV */ 26 | double E_nu_GeV = static_cast(E_nu / 1_GeV); 27 | 28 | double dsigma_dlogTp = 0; 29 | nue_param(T_proton_GeV, ¶ms); 30 | dsigma_dlogTp += sigma_incl_tot(ID_NUE, E_nu_GeV, T_proton_GeV, ¶ms); 31 | numu_param(T_proton_GeV, ¶ms); 32 | dsigma_dlogTp += sigma_incl_tot(ID_NUMU, E_nu_GeV, T_proton_GeV, ¶ms); 33 | antinue_param(T_proton_GeV, ¶ms); 34 | dsigma_dlogTp += sigma_incl_tot(ID_ANTINUE, E_nu_GeV, T_proton_GeV, ¶ms); 35 | antinumu_param(T_proton_GeV, ¶ms); 36 | dsigma_dlogTp += sigma_incl_tot(ID_ANTINUMU, E_nu_GeV, T_proton_GeV, ¶ms); 37 | 38 | return QDiffCrossSection(dsigma_dlogTp / E_nu_GeV * (1_mbarn / 1_GeV)); 39 | } 40 | 41 | QDiffCrossSection Kamae06Neutrino::getDiffCrossSection(const PID &projectile, const PID &target, const QEnergy &E_proj, 42 | const QEnergy &E_secondary) const { 43 | return nuclearScaling(projectile, target) * getDiffCrossSection(E_proj, E_secondary); 44 | } 45 | 46 | }} // namespace hermes::interactions 47 | -------------------------------------------------------------------------------- /test/testPhotonField.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "gtest/gtest.h" 4 | #include "hermes.h" 5 | 6 | namespace hermes { 7 | 8 | TEST(CMB, getEnergyDensity) { 9 | auto field = std::make_shared(photonfields::CMB()); 10 | /* 11 | std::ofstream spectrumfile("isrf.txt"); 12 | for (QFrequency f = 1e10_Hz; f < 1e16_Hz; f = f*1.01) { 13 | QEnergy photon_energy = f*h_planck; 14 | spectrumfile << std::scientific << std::setprecision(3) 15 | << f 16 | << "\t" << photon_energy / 1_eV << "\t"; spectrumfile << 17 | field->getEnergyDensity(8.5_kpc, 0., photon_energy) / 1_eV * 1_cm3 << 18 | "\t"; spectrumfile << field->getEnergyDensity(4.0_kpc, 0., 19 | photon_energy) / 1_eV * 1_cm3 << "\t"; spectrumfile << 20 | field->getEnergyDensity(0.01_kpc, 0., photon_energy) / 1_eV * 1_cm3 21 | << "\n"; 22 | } 23 | spectrumfile.close(); 24 | */ 25 | } 26 | 27 | TEST(CMB, ISRF) { 28 | auto photonField = 29 | std::make_shared(photonfields::ISRF()); 30 | 31 | for (auto itE = photonField->begin(); itE != photonField->end(); ++itE) { 32 | // integral += crossSec->getDiffCrossSection(Eelectron_, 33 | // static_cast(*itE), Egamma_) * 34 | // phdensity->getEnergyDensity(pos_, 35 | // static_cast(itE - phdensity->begin())) / (*itE); 36 | } 37 | /* 38 | std::ofstream spectrumfile("isrf.txt"); 39 | for (QFrequency f = 1e10_Hz; f < 1e16_Hz; f = f*1.01) { 40 | QEnergy photon_energy = f*h_planck; 41 | spectrumfile << std::scientific << std::setprecision(3) 42 | << f 43 | << "\t" << photon_energy / 1_eV << "\t"; spectrumfile << 44 | field->getEnergyDensity(8.5_kpc, 0., photon_energy) / 1_eV * 1_cm3 << 45 | "\t"; spectrumfile << field->getEnergyDensity(4.0_kpc, 0., 46 | photon_energy) / 1_eV * 1_cm3 << "\t"; spectrumfile << 47 | field->getEnergyDensity(0.01_kpc, 0., photon_energy) / 1_eV * 1_cm3 48 | << "\n"; 49 | } 50 | spectrumfile.close(); 51 | */ 52 | } 53 | 54 | int main(int argc, char **argv) { 55 | ::testing::InitGoogleTest(&argc, argv); 56 | return RUN_ALL_TESTS(); 57 | } 58 | 59 | } // namespace hermes 60 | -------------------------------------------------------------------------------- /src/interactions/KelnerAharonianGamma.cpp: -------------------------------------------------------------------------------- 1 | #include "hermes/interactions/KelnerAharonianGamma.h" 2 | 3 | #include 4 | 5 | namespace hermes { namespace interactions { 6 | 7 | KelnerAharonianGamma::KelnerAharonianGamma() : DifferentialCrossSection() {} 8 | 9 | QArea KelnerAharonianGamma::sigmaInelastic(const QEnergy &Tp) { 10 | constexpr QEnergy Tp_th = (2.0 * m_pi0 + (m_pi0 * m_pi0) / (2.0 * m_proton)) * c_squared; 11 | 12 | double LX = std::log(static_cast(Tp / Tp_th)); 13 | double Threshold = std::max(0., 1. - std::pow(static_cast(Tp_th / Tp), 1.9)); 14 | 15 | if (Tp < Tp_th) return 0 * mbarn; 16 | 17 | return (30.7 - 0.96 * LX + 0.18 * LX * LX) * std::pow(Threshold, 3.0) * mbarn; 18 | } 19 | 20 | QDiffCrossSection KelnerAharonianGamma::getDiffCrossSection(const QEnergy &E_proton, const QEnergy &E_gamma) const { 21 | if (E_gamma > E_proton) return QDiffCrossSection(0); 22 | 23 | const double L = std::log(static_cast(E_proton / 1_TeV)); // defined in pag. 9 24 | double x = static_cast(E_gamma / E_proton); // defined in pag. 9 25 | 26 | double B_gamma = 1.30 + 0.14 * L + 0.011 * L * L; // Eq. 59 27 | double beta_gamma = 1. / (1.79 + 0.11 * L + 0.008 * L * L); // Eq. 60 28 | double k_gamma = 1. / (0.801 + 0.049 * L + 0.014 * L * L); // Eq. 61 29 | double x2beta = std::pow(x, beta_gamma); 30 | 31 | double F_1 = (1. - x2beta) / (1. + k_gamma * x2beta * (1. - x2beta)); 32 | double F_2 = 4. * beta_gamma * x2beta / (1. - x2beta); 33 | double F_3 = 4. * k_gamma * beta_gamma * x2beta * (1. - 2. * x2beta); 34 | F_3 /= 1. + k_gamma * x2beta * (1. - x2beta); 35 | 36 | double F_gamma = B_gamma * std::log(x) / x * std::pow(F_1, 4); // Eq. 58 37 | F_gamma *= 1. / log(x) - F_2 - F_3; 38 | 39 | return sigmaInelastic(E_proton) * F_gamma / E_proton; 40 | } 41 | 42 | QDiffCrossSection KelnerAharonianGamma::getDiffCrossSection(const PID &projectile, const PID &target, 43 | const QEnergy &E_proj, const QEnergy &E_secondary) const { 44 | return nuclearScaling(projectile, target) * getDiffCrossSection(E_proj, E_secondary); 45 | } 46 | 47 | }} // namespace hermes::interactions 48 | -------------------------------------------------------------------------------- /include/hermes/skymaps/SkymapMask.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMES_SKYMAPMASK_H 2 | #define HERMES_SKYMAPMASK_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "hermes/HEALPixBits.h" 9 | #include "hermes/Vector3.h" 10 | 11 | namespace hermes { 12 | 13 | class SkymapMask { 14 | private: 15 | std::string description; 16 | 17 | protected: 18 | QAngle normalizeAngle(QAngle angle) const; 19 | 20 | public: 21 | SkymapMask(); 22 | std::vector getMask(std::size_t nside); 23 | virtual bool isAllowed(const QDirection &dir) const { return true; } 24 | 25 | virtual std::string getDescription() const; 26 | void setDescription(const std::string &description); 27 | }; 28 | 29 | class InvertMask : public SkymapMask { 30 | private: 31 | std::shared_ptr mask; 32 | 33 | public: 34 | InvertMask(const std::shared_ptr &mask); 35 | bool isAllowed(const QDirection &dir) const override; 36 | }; 37 | 38 | class MaskList : public SkymapMask { 39 | private: 40 | std::vector> list; 41 | 42 | public: 43 | MaskList(); 44 | void addMask(const std::shared_ptr &mask); 45 | bool isAllowed(const QDirection &dir) const override; 46 | }; 47 | 48 | class RectangularWindow : public SkymapMask { 49 | private: 50 | QDirection topleft, bottomright; 51 | bool isAngleBetween(QAngle testAngle, const QAngle open, 52 | QAngle close) const; 53 | 54 | public: 55 | /* In galactic coordinates: b=(-90_deg, 90_deg), l=(0_deg, 360_deg) 56 | Examples: 57 | the galactic north b = 90_deg 58 | the galactic centre b = 0_deg, l = 0_deg */ 59 | RectangularWindow(const std::array &latitude, 60 | const std::array &longitude); 61 | bool isAllowed(const QDirection &dir_) const override; 62 | }; 63 | 64 | class CircularWindow : public SkymapMask { 65 | private: 66 | QDirection centre; 67 | Vector3d v_centre; 68 | QAngle aperature; 69 | 70 | public: 71 | CircularWindow(const QDirection ¢re, const QAngle &aperature); 72 | bool isAllowed(const QDirection &dir) const override; 73 | }; 74 | 75 | } // namespace hermes 76 | 77 | #endif // HERMES_SKYMAPMASK_H 78 | -------------------------------------------------------------------------------- /lib/gtest/googletest/test/gtest-typed-test2_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | 31 | #include 32 | 33 | #include "test/gtest-typed-test_test.h" 34 | #include "gtest/gtest.h" 35 | 36 | #if GTEST_HAS_TYPED_TEST_P 37 | 38 | // Tests that the same type-parameterized test case can be 39 | // instantiated in different translation units linked together. 40 | // (ContainerTest is also instantiated in gtest-typed-test_test.cc.) 41 | INSTANTIATE_TYPED_TEST_SUITE_P(Vector, ContainerTest, 42 | testing::Types >); 43 | 44 | #endif // GTEST_HAS_TYPED_TEST_P 45 | --------------------------------------------------------------------------------