Skip to content

Commit d1008a3

Browse files
committed
Merge branch 'master' into milkyway
2 parents ee9da3c + 167fbd0 commit d1008a3

48 files changed

Lines changed: 2199 additions & 276 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/testing_OSX.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ jobs:
1313
cc: "clang"
1414
fc: "gfortran-14"
1515
swig_builtin: "On" #uses swig 4.0.2
16-
py: "/usr/bin/python3"
16+
py: "/usr/bin/python3" # python 3.14
1717
steps:
1818
- name: Checkout repository
1919
uses: actions/checkout@v4
2020
- name: Preinstall
2121
run: |
22-
brew install hdf5 fftw cfitsio muparser libomp swig
23-
pip install numpy==1.26
22+
brew install hdf5 fftw cfitsio muparser libomp swig
23+
python3 -m venv venv
24+
source venv/bin/activate
25+
python -m pip install --upgrade pip
26+
pip install numpy cmake
27+
pip show numpy # cross-check numpy version for Python_NumPy_INCLUDE_DIR
2428
- name: Set up the build
2529
env:
2630
CXX: ${{ matrix.config.cxx }}
@@ -30,7 +34,17 @@ jobs:
3034
run: |
3135
mkdir build
3236
cd build
33-
cmake .. -DENABLE_PYTHON=True -DENABLE_TESTING=On -DENABLE_SWIG_BUILTIN=${{ matrix.config.swig_builtin }} -DSIMD_EXTENSIONS="none"
37+
38+
cmake .. \
39+
-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/venv \
40+
-DENABLE_PYTHON=True \
41+
-DPython_EXECUTABLE=$GITHUB_WORKSPACE/venv/bin/python \
42+
-DCMAKE_CXX_STANDARD=17 \
43+
-DCMAKE_CXX_FLAGS="-std=c++17 -stdlib=libc++" \
44+
-DENABLE_TESTING=On \
45+
-DENABLE_SWIG_BUILTIN=${{ matrix.config.swig_builtin }} \
46+
-DPython_INSTALL_PACKAGE_DIR=$GITHUB_WORKSPACE/venv/lib/python3.14/site-packages
47+
3448
- name: Build CRPropa
3549
run: |
3650
cd build

.github/workflows/testing_ubuntu20.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/testing_ubuntu22.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ jobs:
2121
- name: Preinstall
2222
run: |
2323
sudo apt-get update
24-
sudo apt-get install libmuparser-dev python3 python3-numpy python3-setuptools libhdf5-serial-dev libomp5 libomp-dev libfftw3-dev libcfitsio-dev lcov
24+
sudo apt-get install libmuparser-dev python3 python3-setuptools libhdf5-serial-dev libomp5 libomp-dev libfftw3-dev libcfitsio-dev lcov
25+
pip install --upgrade pip
26+
pip install numpy
27+
pip show numpy
2528
- name: Set up the build
2629
env:
2730
CXX: ${{ matrix.config.cxx }}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: crpropa-testing_ubuntu24
2+
on: [push, pull_request]
3+
4+
jobs:
5+
x64:
6+
runs-on: ${{ matrix.config.os }}
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
config:
11+
- name: "ubuntu-24"
12+
os: ubuntu-24.04
13+
cxx: "g++-14"
14+
cc: "gcc-14"
15+
fc: "gfortran-14"
16+
swig_builtin: "On"
17+
py: "/usr/bin/python3"
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
- name: Preinstall
22+
run: |
23+
sudo apt-get update
24+
sudo apt-get install libmuparser-dev python-dev-is-python3 libhdf5-serial-dev libomp5 libomp-dev libfftw3-dev libcfitsio-dev lcov
25+
pip install numpy
26+
- name: Set up the build
27+
env:
28+
CXX: ${{ matrix.config.cxx }}
29+
CC: ${{ matrix.config.cc }}
30+
FC: ${{ matrix.config.fc }}
31+
run: |
32+
mkdir build
33+
cd build
34+
cmake .. -DENABLE_PYTHON=True -DENABLE_TESTING=On -DENABLE_SWIG_BUILTIN=${{ matrix.config.swig_builtin }} -DSIMD_EXTENSIONS="none"
35+
- name: Build CRPropa
36+
run: |
37+
cd build
38+
make
39+
- name: Run tests
40+
run: |
41+
cd build
42+
make test
43+
- name: Archive test results
44+
if: always()
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: "test-report_${{matrix.config.os}}"
48+
path: build/Testing/Temporary/LastTest.log
49+
arm:
50+
runs-on: ${{ matrix.config.os }}
51+
strategy:
52+
fail-fast: false
53+
matrix:
54+
config:
55+
- name: "ubuntu-24"
56+
os: ubuntu-24.04-arm
57+
cxx: "g++-14"
58+
cc: "gcc-14"
59+
fc: "gfortran-14"
60+
swig_builtin: "On"
61+
py: "/usr/bin/python3"
62+
steps:
63+
- name: Checkout repository
64+
uses: actions/checkout@v4
65+
- name: Preinstall
66+
run: |
67+
sudo apt-get update
68+
sudo apt-get install libmuparser-dev python-dev-is-python3 libhdf5-serial-dev libomp5 libomp-dev libfftw3-dev libcfitsio-dev lcov
69+
pip install numpy
70+
pip show numpy
71+
- name: Set up the build
72+
env:
73+
CXX: ${{ matrix.config.cxx }}
74+
CC: ${{ matrix.config.cc }}
75+
FC: ${{ matrix.config.fc }}
76+
run: |
77+
mkdir build
78+
cd build
79+
cmake .. -DENABLE_PYTHON=True -DENABLE_TESTING=On -DENABLE_SWIG_BUILTIN=${{ matrix.config.swig_builtin }} -DSIMD_EXTENSIONS="none"
80+
- name: Build CRPropa
81+
run: |
82+
cd build
83+
make
84+
- name: Run tests
85+
run: |
86+
cd build
87+
make test
88+
- name: Archive test results
89+
if: always()
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: "test-report_${{matrix.config.os}}"
93+
path: build/Testing/Temporary/LastTest.log

CHANGELOG.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
## CRPropa vNext
22

33
### Bug fixes:
4-
* Fixed sign for exponential decay of magn. field strength with Galactic height in LogarithmicSpiralField
5-
* Fixed r term in source distribution for SNR and Pulsar
6-
* Fixed wrong mass inheritance for secondaries other than nuclei or electron/positron
4+
* Fixed sign for exponential decay of magn. field strength with Galactic height in LogarithmicSpiralField
5+
* Fixed r term in source distribution for SNR and Pulsar
6+
* Fixed wrong mass inheritance for secondaries other than nuclei or electron/positron
7+
* Fixed wrong generation of interval ranges in ObserverTimeEvolution
78

89
### New features:
10+
911
* Added new backwards-compatible function particleMass that returns particle mass also for non-nuclei
1012
* Added the new Galactic magnetic field models from Unger&Farrar arXiv:2311.12120
1113
* Added EBL model from Finke et al. 2022
14+
* Added ReflectiveShell boundary condition
15+
* Added overridable getTime function to ObserverTimeEvolution which is called instead of detList.
16+
Old functionalities are preserved by adding old functions and setter/getter functions.
17+
1218

1319
### Interface changes:
1420

CMakeLists.txt

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ if(ENABLE_GIT)
7070
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
7171
git_describe(GIT_DESC --tags)
7272
endif(ENABLE_GIT)
73-
IF(NOT ENABLE_GIT OR (${GIT_SHA1} STREQUAL "GITDIR-NOTFOUND"))
73+
IF(NOT ENABLE_GIT OR ("${GIT_SHA1}" STREQUAL "GITDIR-NOTFOUND"))
7474
set(GIT_REFSPEC "")
7575
set(GIT_SHA1 "")
7676
set(GIT_DESC "${CRPROPA_RELEASE_VERSION}-no-git")
@@ -157,7 +157,7 @@ list(APPEND CRPROPA_EXTRA_LIBRARIES sophia gfortran)
157157
list(APPEND CRPROPA_EXTRA_INCLUDES libs/sophia)
158158

159159
# Galactic magnetic lenses
160-
option(ENABLE_GALACTICMAGNETICLENS "Galactic Magnetic Lens" ON)
160+
option(ENABLE_GALACTICMAGNETICLENS "Galactic Magnetic Lens" OFF)
161161
option(INSTALL_EIGEN "Install provided EIGEN headers" OFF)
162162
SET(EIGEN_PATH "" CACHE STRING "Use EIGEN from this path instead of the version shipped with CRPropa")
163163
SET(WITH_GALACTIC_LENSES FALSE)
@@ -407,8 +407,10 @@ add_library(crpropa SHARED
407407
src/magneticField/turbulentField/SimpleGridTurbulence.cpp
408408
src/magneticField/TF17Field.cpp
409409
src/magneticField/UF23Field.cpp
410+
src/magneticField/KST24Field.cpp
410411
src/magneticField/CMZField.cpp
411412
src/advectionField/AdvectionField.cpp
413+
src/advectionField/TimeDependentAdvectionField.cpp
412414
src/massDistribution/ConstantDensity.cpp
413415
src/massDistribution/Cordes.cpp
414416
src/massDistribution/Ferriere.cpp
@@ -456,6 +458,8 @@ find_package(Python 3.0 REQUIRED COMPONENTS Interpreter Development NumPy)
456458
if(ENABLE_PYTHON AND Python_FOUND)
457459
find_package(SWIG 3.0 REQUIRED)
458460
include_directories(${Python_INCLUDE_DIRS})
461+
add_definitions(-DCRPROPA_HAVE_PYTHON)
462+
list(APPEND CRPROPA_SWIG_DEFINES -DCRPROPA_HAVE_PYTHON)
459463

460464
# print Python info in detail
461465
message(STATUS "Python: Found!")
@@ -470,23 +474,29 @@ if(ENABLE_PYTHON AND Python_FOUND)
470474
message(STATUS " development libraries: NOT found!")
471475
endif(Python_Development_FOUND)
472476

473-
477+
474478
# use Python_INSTALL_PACKAGE_DIR if provided; otherwise, install in Python_SITELIB
475479
set(Python_INSTALL_PACKAGE_DIR "${Python_SITELIB}" CACHE PATH "folder in which the python package is installed")
476480
message(STATUS " package install directory: ${Python_INSTALL_PACKAGE_DIR}")
477-
478-
481+
479482
# look for NumPy
480483
if(Python_NumPy_FOUND)
481-
set(CMAKE_SWIG_FLAGS -DWITHNUMPY ${CRP})
482-
list(APPEND CRPROPA_SWIG_DEFINES -DWITHNUMPY)
483-
include_directories(${Python_NumPy_INCLUDE_DIRS})
484-
message(STATUS "NumPy: Found!")
485-
message(STATUS " headers: ${Python_NumPy_INCLUDE_DIRS} (version ${Python_NumPy_VERSION})")
484+
set(CMAKE_SWIG_FLAGS -DWITHNUMPY ${CRP})
485+
list(APPEND CRPROPA_SWIG_DEFINES -DWITHNUMPY)
486+
include_directories(${Python_NumPy_INCLUDE_DIRS})
487+
message(STATUS "NumPy: Found!")
488+
message(STATUS " headers: ${Python_NumPy_INCLUDE_DIRS} (version ${Python_NumPy_VERSION})")
486489
elseif(Python_NumPy_FOUND)
487-
message(STATUS "NumPy: NOT found!")
488-
message(STATUS " CRPropa might work just fine with Python, but features like Galactic lenses will not be available.")
490+
message(STATUS "NumPy: NOT found!")
491+
message(STATUS " CRPropa might work just fine with Python, but features like Galactic lenses will not be available.")
489492
endif(Python_NumPy_FOUND)
493+
494+
# deactivate lenses if NumPy version is >= 2.0
495+
if(Python_NumPy_VERSION VERSION_GREATER_EQUAL 2.0 AND WITH_GALACTIC_LENSES)
496+
set(WITH_GALACTIC_LENSES FALSE CACHE BOOL "" FORCE)
497+
set(ENABLE_GALACTICMAGNETICLENS OFF CACHE BOOL "" FORCE)
498+
message(WARNING "NumPy version >= 2.0 detected, disabling Galactic lenses support")
499+
endif()
490500

491501
if(SWIG_VERSION VERSION_GREATER 4.0)
492502
# Use swig 4 builtin doxygen instead of external program

doc/pages/Simulation-Modules.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ General interactions/processes
4141
Conditional modules implement certain conditions for stopping propagation.
4242
They provide interfaces to act onReject or onAccept of a cosmic ray.
4343
Boundary modules can be used to limit the simulation volume.
44-
Periodic- and ReflectiveBox implement boundary conditions for the particles. They are useful for a 3D setup where an initial volume is to be repeated (periodically or reflectively). When using them, a couple of things need to be considered. Observers will shadow the volume behind if they are set to inactivate particles. Also Observers should be placed at a distance to the boundaries that is larger than the maximum step size of the propagator, since step size limitation does not work beyond periodic/reflective boundaries.
44+
Periodic-/ReflectiveBox and ReflectiveShell implement boundary conditions for the particles. They are useful for a 3D setup where an initial volume is to be repeated (periodically or reflectively). When using them, a couple of things need to be considered. Observers will shadow the volume behind if they are set to inactivate particles. Also Observers should be placed at a distance to the boundaries that is larger than the maximum step size of the propagator, since step size limitation does not work beyond periodic/reflective boundaries.
4545

4646
* **MaximumTrajectoryLength** - Stop after reaching maximum trajectory length
4747
* **MinimumEnergy** - Stop after reaching a minimum energy
@@ -53,6 +53,7 @@ Periodic- and ReflectiveBox implement boundary conditions for the particles. The
5353
* **CylindricalBoundary** - Cylindric simulation volume
5454
* **PeriodicBox** - Periodic boundary conditions for the particle: If a particle leaves the box it will enter from the opposite side and the initial position will be changed as if it had come from that side.
5555
* **ReflectiveBox** - Reflective boundary conditions for the particle: If a particle leaves the box it will be reflected (mirrored) and the initial position will be changed as if it had come from that side.
56+
* **ReflectiveShell** - Reflective spherical boundary condition for the particle; If a particle crosses the shell during the current step it will be reflected back at the boundary according to the law of reflection. Particles coming from the outside are only reflected if the current step ends inside the shell.
5657
* **DetectionLength** - Detects the candidate at a given trajectory length.
5758

5859
### Observers

doc/pages/acceleration.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ The exact nature of the dependency is subject of ongoing research. Here,
3030
so far only quasi-linear theory, a simplistic approach to diffusion of charged
3131
particles in magnetic fields is implemented in the corresponding modifier :cpp:class:`crpropa::QuasiLinearTheory`.
3232

33+
In the diffusive picture, the diffusive picture as an interplay between diffusion,
34+
advection and adiabatic cooling. Simple shock configurations are shown in the following
35+
example notebook using the DiffusionSDE module:
3336

37+
.. toctree::
38+
example_notebooks/acceleration/diffusive_shock_acceleration.ipynb
3439

3540

3641

0 commit comments

Comments
 (0)