Skip to content

Commit

Permalink
Merge branch 'CRPropa:master' into documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienDoerner authored Apr 8, 2024
2 parents f4c8b4e + b588923 commit f467ef1
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 56 deletions.
26 changes: 10 additions & 16 deletions .github/workflows/create_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,18 @@ jobs:
fail-fast: false
matrix:
config:
- name: "ubuntu-20"
os: ubuntu-20.04
cxx: "g++-9"
cc: "gcc-9"
fc: "gfortran-9"
swig_builtin: "Off" #uses swig 4.0.1
- name: "ubuntu-22"
os: ubuntu-22.04
cxx: "g++-11"
cc: "gcc-11"
fc: "gfortran-11"
swig_builtin: "On" #uses swig 4.0.2
py: "/usr/bin/python3" #python 3.10

# define steps to take
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Python install
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip' # caching pip dependencies
uses: actions/checkout@v4
- name: Prerequirements
run: |
sudo apt-get update
Expand All @@ -40,9 +36,7 @@ jobs:
run: |
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/.local \
-DENABLE_PYTHON=True -DENABLE_TESTING=ON -DENABLE_SWIG_BUILTIN=${{ matrix.config.swig_builtin }} \
-DSIMD_EXTENSIONS=native -DBUILD_DOC=True -DENABLE_COVERAGE=True
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/.local -DENABLE_PYTHON=True -DPython_EXECUTABLE=${{ matrix.config.py }} -DENABLE_TESTING=On -DENABLE_SWIG_BUILTIN=${{ matrix.config.swig_builtin }} -DSIMD_EXTENSIONS=native -DPython_INSTALL_PACKAGE_DIR=/home/runner/.local/ -DBUILD_DOC=On -DENABLE_COVERAGE=On
- name: Build CRPropa
run: |
cd build
Expand All @@ -63,7 +57,7 @@ jobs:
make doc
tar -zcvf documentation.tar.gz doc
- name: archive documentation
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "documentation"
path: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
py: "/usr/bin/python3" #python 3.10
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Preinstall
run: |
sudo apt-get update
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/testing_OSX.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
py: "/usr/bin/python3"
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Preinstall
run: |
brew install hdf5 fftw cfitsio muparser libomp numpy swig
Expand All @@ -42,7 +42,7 @@ jobs:
make test
- name: Archive test results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "test-report_${{matrix.config.name}}"
path: build/Testing/Temporary/LastTest.log
4 changes: 2 additions & 2 deletions .github/workflows/testing_ubuntu20.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
py: "/usr/bin/python3" #python 3.8
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Preinstall
run: |
sudo apt-get update
Expand All @@ -41,7 +41,7 @@ jobs:
make test
- name: Archive test results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "test-report_${{matrix.config.name}}"
path: build/Testing/Temporary/LastTest.log
4 changes: 2 additions & 2 deletions .github/workflows/testing_ubuntu22.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
py: "/usr/bin/python3" #python 3.10
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Preinstall
run: |
sudo apt-get update
Expand All @@ -41,7 +41,7 @@ jobs:
make test
- name: Archive test results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "test-report_${{matrix.config.name}}"
path: build/Testing/Temporary/LastTest.log
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

### Bug fixes:
* Fixed sign for exponential decay of magn. field strength with Galactic height in LogarithmicSpiralField
* Fixed r term in source distribution for SNR and Pulsar

### New features:

### Interface changes:

### Features that are deprecated and will be removed after this release
* EBL model from Finke et al. 2022

### Removed features
* AMRMagneticField - underlying library (saga) is no longer supported.
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ endif(APPLE)
# Download data files (interaction data, masses, decay data ...)
# ----------------------------------------------------------------------------
OPTION(DOWNLOAD_DATA "Download CRPropa data files" ON)
set(CRPROPA_DATAFILE_VER "2023-10-20")
set(CRPROPA_DATAFILE_VER "2024-03-11")
if(DOWNLOAD_DATA)
message("-- Downloading data files from sciebo ~ 73 MB")
file(DOWNLOAD
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ CRPropa
========

![stable release](https://img.shields.io/badge/stable\_release-3.2.1-darkblue)
[![Build status](https://github.com/crpropa/crpropa3/actions/workflows/testing.yml/badge.svg)](https://github.com/crpropa/crpropa3/actions/)
[![Average time to resolve an issue](https://isitmaintained.com/badge/resolution/CRPropa/CRPropa3.svg)](https://isitmaintained.com/project/CRPropa/CRPropa3)
[![Percentage of issues still open](https://isitmaintained.com/badge/open/CRPropa/CRPropa3.svg)](https://isitmaintained.com/project/CRPropa/CRPropa3)

[![Build: ubuntu22](https://github.com/CRPropa/CRPropa3/actions/workflows/testing_ubuntu22.yml/badge.svg)](https://github.com/CRPropa/CRPropa3/actions/workflows/testing_ubuntu22.yml)
[![Build: ubuntu20](https://github.com/CRPropa/CRPropa3/actions/workflows/testing_ubuntu20.yml/badge.svg)](https://github.com/CRPropa/CRPropa3/actions/workflows/testing_ubuntu20.yml)
[![Build: macos14](https://github.com/CRPropa/CRPropa3/actions/workflows/testing_OSX.yml/badge.svg)](https://github.com/CRPropa/CRPropa3/actions/workflows/testing_OSX.yml)
[![Examples](https://github.com/CRPropa/CRPropa3/actions/workflows/test_examples.yml/badge.svg)](https://github.com/CRPropa/CRPropa3/actions/workflows/test_examples.yml)

![Issues](https://img.shields.io/github/issues/crpropa/CRPropa3)
![GitHub Issues or Pull Requests](https://img.shields.io/github/issues-pr/crpropa/CRPropa3)

[![DOI:10.1088/1475-7516/2022/09/035](http://img.shields.io/badge/DOI-10.1088/1475-7516/2022/09/035.svg)](<https://doi.org/10.1088/1475-7516/2022/09/035>)
[![arXiv](https://img.shields.io/badge/arXiv-2208.00107-b31b1b.svg)](https://arxiv.org/abs/2208.00107)
Expand Down
51 changes: 34 additions & 17 deletions doc/pages/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ git clone https://github.com/CRPropa/CRPropa3.git
## Prerequisites
+ C++ Compiler with C++11 support (gcc, clang and icc are known to work)
+ Fortran Compiler: to compile SOPHIA
+ numpy: for scientific computations

Optionally CRPropa can be compiled with the following dependencies to enable certain functionality.
+ Python and SWIG: to use CRPropa from python (tested for > Python 2.7 and > SWIG 3.0.4)
+ Python, NumPy, and SWIG: to use CRPropa from python (tested for >= Python 3.7 and > SWIG 4.0.2)
+ FFTW3: for turbulent magnetic field grids (FFTW3 with single precision is needed)
+ Gadget: magnetic fields for large scale structure data
+ OpenMP: for shared memory parallelization
Expand Down Expand Up @@ -46,12 +45,12 @@ The following packages are provided with the source code and do not need to be i
2. A set of unit tests can be run with ```make test```. If the tests are
successful continue with ```make install``` to install CRPropa at the
specified path, or leave it in the build directory. Make sure the
environment variables are set accordingly: E.g. for an installation under
$HOME/.local and using Python 2.7 set
environment variables are set accordingly: e.g. for an installation under
$HOME/.local and using Python 3 set
```sh
export PATH=$HOME/.local/bin:$PATH
export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH
export PYTHONPATH=$HOME/.local/lib/python2.7/site-packages:$PYTHONPATH
export PYTHONPATH=$HOME/.local/lib/python3.9/site-packages:$PYTHONPATH
export PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH
```

Expand Down Expand Up @@ -110,7 +109,7 @@ worthwhile effort afterwards.
To install python dependencies and libraries use `pip`. Example: `pip install numpy`.
4. Compile and install CRPropa (please note specific [insturctions for different operating systems](#notes-for-specific-operating-systems)).
4. Compile and install CRPropa (please note specific [instructions for different operating systems](#notes-for-specific-operating-systems)).
```sh
cd $CRPROPA_DIR
git clone https://github.com/CRPropa/CRPropa3.git
Expand Down Expand Up @@ -144,7 +143,7 @@ cmake -DENABLE_PYTHON=ON ..
```
+ Set the install path ```-DCMAKE_INSTALL_PREFIX=/my/install/path```
+ Enable Galactic magnetic lens ```-DENABLE_GALACTICMAGETICLENS=ON```
+ Enable Galactic magnetic lens ```-DENABLE_GALACTICMAGNETICLENS=ON```
+ Enable FFTW3 (turbulent magnetic fields) ```-DENABLE_FFTW3F=ON```
+ Enable OpenMP (multi-core parallel computing) ```-DENABLE_OPENMP=ON```
+ Enable Python (Python interface with SWIG) ```-DENABLE_PYTHON=ON```
Expand Down Expand Up @@ -178,11 +177,18 @@ cmake -DENABLE_PYTHON=ON ..
+ Quite often there are multiple Python versions installed in a system. This is likely the cause of many (if not most) of the installation problems related to Python. To prevent conflicts among them, one can explicitly refer to the Python version to be used. Example:
```
-DCMAKE_PYTHON_EXECUTABLE=/usr/bin/python
-DCMAKE_PYTHON_INCLUDE_DIR=<path_to_folder_containing_Python.h>
-DCMAKE_PYTHON_LIBRARY=<path_to_file>/libpython<version_tag>.so
-DPython_EXECUTABLE=/usr/bin/python
-DPython_INCLUDE_DIRS=<path_to_folder_containing_Python.h>
-DPython_LIBRARY=<path_to_file>/libpython<version_tag>.so
```
Note that in systems running OSX, the extension .so should be replaced by .dylib.
Note that in systems running OSX, the extension .so should be replaced by .dylib.
In addition, The path where the CRPropa python module is installed can be specified with the flag:
```
-DPython_INSTALL_PACKAGE_DIR=<path_to_folder>
```
For further details, see [FindPython.cmake](https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython).
## Notes for Specific Operating Systems
Expand All @@ -201,9 +207,21 @@ For Fedora/CentOS/RHEL the required packages to build CRPropa:
```
In case of CentOS/RHEL 7, the SWIG version is too old and has to be built from source.
### Mac OS X
Tested on version 12.5.1 with M1 pro where command line developer tools are installed.
For a clean OS X (Sonoma 14+) installation, if you use Homebrew, the main dependencies can be installed as follows:
```sh
brew install hdf5 fftw cfitsio muparser libomp numpy swig
```
Similarly, if you use MacPorts instead of Homebrew, download the corresponding packages:
```sh
sudo port install hdf5 fftw cfitsio muparser libomp numpy swig
```
Note that if you are using a Mac with Arm64 architecture (M1, M2, or M3 processors), `SIMD_EXTENSIONS` might not run straight away.
Some combinations of versions of the Apple's clang compiler and python might lead to installation errors.
In these cases, the user might want to consider the workaround below (tested on version 12.5.1 with M1 pro where command line developer tools are installed).

Install Python3, and llvm from Homebrew, and specify the following paths to the Python and llvm directories in the Homebrew folder after step 3 of the above installation, e.g. (please use your exact versions):
```sh
export LLVM_DIR="/opt/homebrew/Cellar/llvm/15.0.7_1"
Expand All @@ -219,9 +237,9 @@ with
```sh
cmake .. \
-DCMAKE_INSTALL_PREFIX=$CRPROPA_DIR \
-DPYTHON_EXECUTABLE=$PYTHON_DIR/bin/python$PYTHON_VERSION \
-DPYTHON_LIBRARY=$PYTHON_DIR/lib/libpython$PYTHON_VERSION.dylib \
-DPYTHON_INCLUDE_PATH=$PYTHON_DIR/include/python$PYTHON_VERSION \
-DPython_EXECUTABLE=$PYTHON_DIR/bin/python$PYTHON_VERSION \
-DPython_LIBRARY=$PYTHON_DIR/lib/libpython$PYTHON_VERSION.dylib \
-DPython_INCLUDE_PATH=$PYTHON_DIR/include/python$PYTHON_VERSION \
-DCMAKE_C_COMPILER=$LLVM_DIR/bin/clang \
-DCMAKE_CXX_COMPILER=$LLVM_DIR/bin/clang++ \
-DOpenMP_CXX_FLAGS="-fopenmp -I$LLVM_DIR/lib/clang/$LLVM_VERSION/include" \
Expand All @@ -238,4 +256,3 @@ Check that all paths are set correctly with the following command in the build f
```
and configure and generate again after changes.

13 changes: 13 additions & 0 deletions include/crpropa/PhotonBackground.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,19 @@ class IRB_Saldana21_lower: public TabularPhotonField {
IRB_Saldana21_lower() : TabularPhotonField("IRB_Saldana21_lower", true) {}
};

/**
@class IRB_Finke22
@brief Extragalactic background light model from Finke et al. 2022
Source info:
DOI:10.3847/1538-4357/ac9843
https://iopscience.iop.org/article/10.3847/1538-4357/ac9843/pdf
*/
class IRB_Finke22: public TabularPhotonField {
public:
IRB_Finke22() : TabularPhotonField("IRB_Finke22", true) {}
};

/**
@class URB
@brief Extragalactic background light model from Protheroe & Biermann 1996
Expand Down
22 changes: 11 additions & 11 deletions src/Source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,17 @@ void SourceUniformCylinder::setDescription() {

// ---------------------------------------------------------------------------
SourceSNRDistribution::SourceSNRDistribution() :
rEarth(8.5 * kpc),alpha(2.), beta(3.53), zg(0.3 * kpc) {
rEarth(8.5 * kpc), beta(3.53), zg(0.3 * kpc) {
setAlpha(2.);
setFrMax();
setFzMax(0.3 * kpc);
setRMax(20 * kpc);
setZMax(5 * kpc);
}

SourceSNRDistribution::SourceSNRDistribution(double rEarth, double alpha, double beta, double zg) :
rEarth(rEarth),alpha(alpha), beta(beta), zg(zg) {
rEarth(rEarth), beta(beta), zg(zg) {
setAlpha(alpha);
setFrMax();
setFzMax(zg);
setRMax(20 * kpc);
Expand Down Expand Up @@ -414,7 +416,7 @@ double SourceSNRDistribution::fz(double z) const{
}

double SourceSNRDistribution::getAlpha() const {
return alpha;
return alpha - 1; // -1 to account for the R-term in the volume element dV = R * dR * dphi * dz
}

double SourceSNRDistribution::getBeta() const {
Expand Down Expand Up @@ -458,7 +460,7 @@ double SourceSNRDistribution::getZMax() const {
}

void SourceSNRDistribution::setAlpha(double a) {
alpha = a;
alpha = a + 1.; // add 1 for dV = r * dR * dphi * dz
setRMax(rMax);
setFrMax();
}
Expand Down Expand Up @@ -504,7 +506,7 @@ void SourcePulsarDistribution::prepareParticle(ParticleState& particle) const {
double Rtilde;
while (true) {
Rtilde = random.rand() * rMax;
double fTest = random.rand() * frMax;
double fTest = random.rand() * frMax * 1.1;
double fR = fr(Rtilde);
if (fTest <= fR) {
break;
Expand All @@ -530,10 +532,8 @@ void SourcePulsarDistribution::prepareParticle(ParticleState& particle) const {
}

double SourcePulsarDistribution::fr(double r) const {
double Atilde = (pow(beta, 4.) * exp(-beta)) / (12 * M_PI * pow(rEarth, 2.));
double f = pow(r / rEarth, 2.) * exp(-beta * (r - rEarth) / rEarth);
double fr = Atilde * f;
return fr;
double f = r * pow(r / rEarth, 2.) * exp(-beta * (r - rEarth) / rEarth);
return f;
}

double SourcePulsarDistribution::fz(double z) const{
Expand Down Expand Up @@ -569,8 +569,8 @@ double SourcePulsarDistribution::blurTheta(double thetaTilde, double rTilde) con
}

void SourcePulsarDistribution::setFrMax(double R, double b) {
frMax = pow(b, 2.) / (3 * pow(R, 2.) * M_PI) * exp(-2.);
return;
double r = 3 * R / b;
frMax = fr(r);
}

void SourcePulsarDistribution::setFzMax(double zg) {
Expand Down
Loading

0 comments on commit f467ef1

Please sign in to comment.