GithubHelp home page GithubHelp logo

hep-mh / acropolis Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 27.99 MB

A library that enables the calculation of photodisintegration constraints for a variety of BSM scenarios

Home Page: https://acropolis.hepforge.org

License: GNU General Public License v3.0

Python 92.16% Shell 0.84% C 2.18% HTML 4.83%
light-elements bsm dark-matter bbn photodisintegration particle-physics physics cosmology dark-sectors decays

acropolis's Introduction

ACROPOLIS

A generiC fRamework fOr Photodisintegration Of LIght elementS

arXiv: 2011.06518 Language: Python3 Version: 1.2.2 DevVersion: 1.3

logo
When using this code for your own scientific publications, please cite

  • ACROPOLIS: A generiC fRamework fOr Photodisintegration Of LIght elementS
    Paul Frederik Depta, Marco Hufnagel, Kai Schmidt-Hoberg
    https://arxiv.org/abs/2011.06518
  • Updated BBN constraints on electromagnetic decays of MeV-scale particles
    Paul Frederik Depta, Marco Hufnagel, Kai Schmidt-Hoberg
    https://arxiv.org/abs/2011.06519
  • BBN constraints on MeV-scale dark sectors. Part II. Electromagnetic decays
    Marco Hufnagel, Kai Schmidt-Hoberg, Sebastian Wild
    https://arxiv.org/abs/1808.09324

The most recent version of the manual can always be found on GitHub in the manual/ folder. The respective publication on arXiv might be out-of-date, especially when new versions of the code become available.

Abstract

The remarkable agreement between observations of the primordial light element abundances and the corresponding theoretical predictions within the standard cosmological history provides a powerful method to constrain physics beyond the standard model of particle physics (BSM). For a given BSM model these primordial element abundances are generally determined by (i) Big Bang Nucleosynthesis and (ii) possible subsequent disintegration processes. The latter potentially change the abundance values due to late-time high-energy injections which may be present in these scenarios. While there are a number of public codes for the first part, no such code is currently available for the second. Here we close this gap and present ACROPOLIS, A generiC fRamework fOr Photodisintegration Of LIght elementS. The widely discussed cases of decays as well as annihilations can be run without prior coding knowledge within example programs. Furthermore, due to its modular structure, ACROPOLIS can easily be extended also to other scenarios.

Changelog

v1.2.2 (April 6, 2022)
  • Implemented fixes for the issues #10 and #11 on GitHub
  • Made some initial plotting functions available in acropolis.plots, which can be used to easily plot the results of parameter scans
  • Improved the output that is printed to the screen (especially for parameter scans if verbose=True)
  • Updated the neutron lifetime to the PDG 2020 recommended value
  • Included some example files, e.g. for parameter scans, in the directory examples/
  • Included a new c-file tools/create_sm_abundance_file.c, which can be used with AlterBBN to generate the file abundance_file.dat for sm.tar.gz
  • Fixed a bug that prohibited running 2d parameter scans without 'fast' parameters
  • Fixed a bug that caused INFO messages to be printed even for verbose=False

v1.2.1 (February 16, 2021)
  • Fixed a bug in DecayModel. Results that have been obtained with older versions can be corrected by multiplying the parameter n0a with an additional factor 2.7012. All results of our papers remain unchanged.
  • Updated the set of initial abundances to the most recent values returned by AlterBBN v2.2 (explicitly, we used failsafe=12)

v1.2 (January 15, 2021)
  • Speed improvements when running non-thermal nucleosynthesis (by a factor 7)
  • Modified the directory structure by moving ./data to ./acropolis/data to transform ACROPOLIS into a proper package, which can be installed via python3 -m pip install . --user (also putting the executables decay and annihilation into your PATH)
  • Added the decay of neutrons and tritium to the calculation
  • For AnnihilationModel, it is now possible to freely choose the dark-matter density parameter (default is 0.12)

v1.1 (December 1, 2020)
  • For the source terms it is now possible to specify arbitrary monochromatic and continuous contributions, meaning that the latter one is no longer limited to only final-state radiation of photons
  • By including additional JIT compilation steps, the runtime without database files was drastically decreased (by approximately a factor 15)
  • The previously mentioned performance improvements also allowed to drop the large database files alltogether, which results in a better user experience (all database files are now part of the git repo and no additional download is required) and a significantly reduced RAM usage (∼900MB → ∼20MB)
  • Fixed a bug, which could lead to NaNs when calculating heavily suppressed spectra with E0 ≫ me2/(22T)
  • Added a unified way to print the final abundances in order to declutter the wrapper scripts. This makes it easier to focus on the actual important parts when learning how to use ACROPOLIS
  • Moved from bytecode to simple text files for the remaining database file, as the former leads to unexpected behaviour on some machines
  • Added additional info and warning messages for the user's convenience

v1.0 (November 12, 2020)
  • Initial release

Installation from PyPI

This is the recommended way to install ACROPOLIS!

To install ACROPOLIS from PyPI, first make sure that pip is installed on your system and afterwards install ACROPOLIS at user-level by executing the command

python3 -m pip install ACROPOLIS --user

Once the installation is completed, the different modules of ACROPOLIS can directly be imported into our own Python code (just like e.g. numpy). Additionally, the installation also ensures that the two executable decay and annihilation are copied into your PATH and that all dependencies are fulfilled.

If you want to install ACROPOLIS system wide or within a virtual environment, drop the --user flag in the command above and run with sudo if necessary.

If any dependencies of ACROPOLIS conflict with those for other programs in your work environment, it is strongly advised to utilize the capabilities of Python's virtual environments.

Installation from GitHub

To install ACROPOLIS directly from GitHub, execute the command

python3 -m pip install git+https://github.com/hep-mh/acropolis.git --user

Usage without installation

In case you just want to use ACROPOLIS without any additional installation steps, it is necessary to manually check that all dependencies are fulfilled. As specified in setup.py, ACROPOLIS depends on the following packages (older versions might work, but have not been thoroughly tested)

  • NumPy (> 1.19.1)
  • SciPy (>1.5.2)
  • Numba (> 0.51.1)

The most recent versions of these packages can be collectively installed via the command

python3 -m pip install numpy, scipy, numba --user

Afterwards, you can import the different modules into your own Python code, as long as said code resides in the acropolis directory (like decay and annihilation). If you instead want to also use the different modules from other directories, please consider using one of the two previously mentioned installation methods.

Using the example models

ACROPOLIS ships with two executables, decay and annihilation, which wrap the scenarios discussed in section 4.1 and section 4.2 from the manual, respectively. Both of these files need to be called with six command-line arguments each, a list of which can be obtained by running the command of choice without any arguments at all. As an example, the following command runs the process of photodisintegration for an unstable mediator with a mass of 10MeV and a lifetime of 105s that decays exclusively into photons and has an abundance of 10-10 relative to photons at a reference temperature of 10MeV (if you did not install ACROPOLIS via pip, you have to run this command from within the main directory and make sure to append an additional ./ to the beginning of the commands)

decay 10 1e5 10 1e-10 0 1

On a similar note, the following command runs the process of photodisintegration for residual s-wave annihilations of a dark-matter particle with a mass of 10MeV and a cross-section of 10-25 cm³/s that annihilates exclusively into photons

annihilation 10 1e-25 0 0 0 1

Supported platforms

ACROPOLIS works on any platform that supports python3 and clang, the latter of which is required for numba to work.

acropolis's People

Contributors

depta avatar hep-mh avatar kaischmidthoberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

klingfelix

acropolis's Issues

Issue with the interpolator in `InputInterface::_interp_cosmo_data`

I have noticed that the code for the piecewise linear interpolation in InputInterface::_interp_cosmo_data does not work as intended. In particular the follwoing line is not doing what is intended

ix = np.argmin( np.abs( x - val_log ) )

Judging from the logic of the code, this line is supposed to return the index ix of the data point which is to the left of the point in question, but what it actually returns is the index of the data point which is the closest, which might also lie to the right of the point in question.

This will in general lead to discontinuities right in the middle between two data points (cf. plots below). Assuming that the x-values are in increasing order, it is also important to check whether the closest data point has a value x[ix] that is bigger than val. If so, ix has to be decreased by one. Note that this will automatically include the rather artificial decrease of ix when ix points to the end of the x-array. Therefore, it is sufficient to replace the line if ix == N - 1: by if x[ix] >= log_val:. In the case the initial x-array is not sorted in increasing order, both arrays x and y have to be sorted first.

Attached you will find plots that show the issue in a minimal working example. The red line denotes the original test function and the red dots refer to the discrete data points. The blue line shows the result of the buggy interpolation, whereas the yellow line shows the interpolation after the fix is applied.
For x in increasing order the plot is shown here, the corresponding plot for x in decreasing order is shown
here.

The code for this MWE can be found here (note to change the file type from .py.txt back to .py as github does not allow for .py files to be uploaded.

I suggest to fix this issue by changing

def _interp_cosmo_data(self, val, xc, yc):
    x = self._sCosmoDataLog[:,xc]
    y = self._sCosmoDataLog[:,yc]
    N = self._sCosmoDataShp[0]

    val_log = log10(val)
    # Extract the index corresponding to
    # the data entries above and below 'val'
    ix = np.argmin( np.abs( x - val_log ) )
    if ix == N - 1:
        ix -= 1

    m = (y[ix+1] - y[ix])/(x[ix+1] - x[ix])
    b = y[ix] - m*x[ix]

    return 10**(m*val_log + b)

to

def _interp_cosmo_data(self, val, xc, yc):
    x = self._sCosmoDataLog[:,xc]
    y = self._sCosmoDataLog[:,yc]
    N = self._sCosmoDataShp[0]

    # Sort x and y in increasing order
    o = np.argsort(x)
    x = x[o]
    y = y[o]

    val_log = log10(val)
    # Extract the index corresponding to
    # the data entries above and below 'val'
    ix = np.argmin( np.abs( x - val_log ) )
    if x[ix] >= val_log:
        ix -= 1

    m = (y[ix+1] - y[ix])/(x[ix+1] - x[ix])
    b = y[ix] - m*x[ix]

    return 10**(m*val_log + b)

in acropolis/input.py starting at line 98.

Note that as long as the original function is sampled well enough, this bug is not as severe, but it should be fixed anyway.

Cheers,
Patrick

Issues with vanishing decay rates

Occasionally some decay rates vanish, e.g. the Be7+a>He3+He4 rate is exactly 0 for low temperatures for the following parameter point (using the decay model)

3.17367 1.60439e+10 10 5.7220383e-10 0 1

I don't know how sensible these values are, but they are not unique, and many such points are easily reached in large parameter scans.

These decay rates are so small that are below the precision limit and are effectively set to 0, which causes problems down the line when setting up the interpolators using log scale, and acropolis fails with an NaN error. I don't think this is a conceptual problem, really small rates are possible as far as I can tell, so it should be just a computational problem on how to handle these really small rates. Locally I've just regularized all zeroes in the grids to the minimum float value of the system, which is enough for the log interpolator to work fine. This is my suggested fix to acropolis/utils.py

@@ -2,6 +2,8 @@
 from math import log, pow
 # numpy
 import numpy as np
+# sys
+import sys
 
 
 class LogInterp(object):
@@ -11,6 +13,9 @@ class LogInterp(object):
         self._sLogBase = log(self._sBase)
 
         self._sFillValue = fill_value
+ 
+        x_grid = [x if x > 0 else sys.float_info.min for x in x_grid]
+        y_grid = [y if y > 0 else sys.float_info.min for y in y_grid]
 
         self._sXLog = np.log(x_grid)/self._sLogBase
         self._sYLog = np.log(y_grid)/self._sLogBase

I hope this helps you with implementing a fix to this in this or any other way.

Cheers,
Tomas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.