Giter Club home page Giter Club logo

sntools's Introduction

sntools

sntools is a Monte Carlo event generator for supernova neutrino interactions.

It is a command line application that uses detailed time- and energy-dependent neutrino fluxes (provided by various supernova models) to generate interactions within the detector volume and write them to event files that can be used as an input for a full detector simulation. sntools was originally developed for Hyper-Kamiokande and later extended to support different detectors and detector materials.

Additionally, sntools can be used as a Python library that implements neutrino cross sections.

This README file should give a brief overview over sntools and help you get started. For more information, see the full documentation for each release on GitHub.

Getting Started

Installation Instructions

First, make sure you have Python 3.8 or higher installed on your computer. Then, in a terminal, run

pip install sntools

to install the latest version of sntools and all dependencies.

Finally, run

python -c 'import sntools; sntools.setup()'

to check whether sntools is working and to download the sample input file for the usage examples below.

Example Usage

To generate your first supernova neutrino events with sntools, open a terminal window and type in the following command:

sntools fluxes/intp2001.data --format nakazato --endtime 50

This generates events for the first 50 ms of a supernova based on the neutrino flux given in the input file fluxes/intp2001.data (which is in the nakazato format) and writes them to a file named outfile.kin in the current directory. (This sample input file is included in the sntools repository. See this web page for more information.)

A more realistic usage that demonstrates more of sntools’ capabilities looks like this:

sntools fluxes/intp2001.data --format nakazato --channel es --detector SuperK --distance 20 --verbose --output intp2001es.kin

This uses the neutrino flux given in the same input file to generate neutrino-electron elastic scattering events in Super-Kamiokande for a supernova at 20 kpc distance. It also produces more verbose output, which lets you see that sntools generates events separately for different neutrino flavours (which have different fluxes and cross sections), before merging them into an output file named intp2001es.kin.

You can also run

sntools -h

to get an overview over all of sntools’ options.

Input

Text file(s) containing information about neutrino fluxes produced by the supernova. sntools distinguishes between three flavours: nu_e, anti-nu_e and nu_x (where nu_x stands for nu_mu or nu_tau or their respective antineutrinos). The following input formats are supported.

Nakazato format

Used by recent simulations by the Nakazato group. Fluxes for 13 and 20 solar mass progenitors are included as fluxes/intp1301.data and fluxes/intp2001.data. A description of the format and fluxes for more progenitors are available online. If you use these included models in your work, please cite Nakazato et al., ApJ Supp. 205 (2013) 2.

Gamma format

Text file containing time, mean energy, mean squared energy and luminosity. These parameters describe a Gamma distribution, which is a good fit to the true spectrum. See fluxes/sample-gamma.txt for an unphysical sample file.

Warren2020 format

Similar to the Gamma format, but in an HDF5 file instead of plain text. Data available online.

Princeton format

Used in recent simulations by the Princeton group.

Totani format

Used in historical simulation by Totani et al., which is the baseline model in the Hyper-Kamiokande Design Report.

Interaction Channels

sntools supports the main interaction channels in water and liquid scintillator.

For water Cherenkov detectors, like Hyper-Kamiokande, these are inverse beta decay, elastic scattering on electrons and charged-current interactions of nu_e and anti-nu_e on oxygen-16 nuclei.

For liquid scintillator detectors, these are inverse beta decay, elastic scattering on electrons, charged-current interactions of nu_e and anti-nu_e on carbon-12 nuclei and neutral-current interactions on carbon-12 nuclei.

Water-based liquid scintillator, a mixture of the two materials, is also supported.

Output

A text file in the NUANCE format (used by the /mygen/vecfile options in WCSim) or the RATPAC format.

Support and Contributing

To report problems or ask for help, open an issue on GitHub or email the lead developer.

Contributions to sntools are welcome! See instructions in the full documentation for help on common ways to extend sntools (e. g. by adding a new detector, input format or interaction channel) and please submit a pull request with your contributions!

Please note that this project is released with a Contributor Code of Conduct (see CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.

sntools's People

Contributors

jostmigenda avatar swakely avatar ekneale avatar mcolomermolla avatar tdealtry avatar yschnellbach avatar arfon avatar cwwalter avatar

Stargazers

 avatar Tom Killestein avatar Samuel Timothy Spencer avatar Matteo Agostini avatar  avatar Bradley J. Kavanagh avatar Steven Gardiner avatar  avatar Justin Vasel avatar Kollan House avatar Paul Emmerich avatar

Watchers

James Cloos avatar  avatar  avatar

sntools's Issues

Packaging improvements

Prompted by @benjaminrose’s suggestions in this comment on the JOSS review:

Tests don't install the package via pip. They currently test the source code, good. But don't test what will be sent installed from pypi, less good. This explains how you are testing your project directory and not how it will be installed by users, https://hynek.me/articles/testing-packaging/. This is a valid test suite, but may not be doing what you expect.

Some background:
Since I didn’t have experience with Python packaging before working on sntools, I tried to stick close to the official recommendations (1, 2), which did not mention the src folder structure recommended in the linked blog post. (Though now that I’ve looked into it, it seems to me that this is hotly debated.)

I think my first step to improve packaging should be to set up a GitHub Action that automatically packages sntools and publishes it to PyPI whenever there’s a new release. (That will largely eliminate human error, which is probably the main source of packaging issues.) I’ll check how it’s possible to install & test as part of that action and will update this issue accordingly.

Remove Cherenkov threshold for LS detectors

[based on discussions with Yixuan Jiang]

Some channels (most importantly es, where the contribution at low energies is strongest) currently enforce a Cherenkov threshold on the outgoing particle. While this makes sense for water Cherenkov detectors (to avoid simulating undetectable events), we should remove this threshold for LS detectors.

Drop support for Python 2.7

Following the end of support for Python 2.7 and in line with many other packages in the scientific Python ecosystem (including sntools’ dependencies, NumPy and SciPy), I plan to drop support for Python 2.7 soon.

  • v0.7.4 (to be released soon) will print a warning message when running under Python 2.7 and point people here.
  • If any further bugfix updates (v0.7.x) appear, they will remain compatible with Python 2.7
  • Future feature updates (either v0.8 or v1.0) will drop support for Python 2.7 and will likely require Python 3.6 or 3.7.

This issue will be updated with any progress on this.

NC interactions on oxygen

These interactions could make up about 5% of events for a SN burst detection in Super-K. A theoretical calculation of the cross-sections was performed by Langanke et al., arXiv:nucl-th/9511032; experimental data appears to be non-existent.

The main issues here are

  • the low energy of events (typically gammas with just above 5 MeV)
  • large uncertainty of the cross-section

and as a result, this interaction is not currently considered in the HK Design Report.

adopt features from snewpy

snewpy is a SNOwGLoBES frontend developed by members of the SNEWS 2.0 collaboration. Like SNOwGLoBES, it’s not a replacement for sntools; but it does have features that would be useful in sntools, too:

  • support for more flavour transformations
  • support for more supernova models

Time- and energy-independent flavour transformations should be straightforward to add to sntools, analogous to the current implementation of MSW effect in normal/inverted mass ordering. (However, it will be necessary to change the command line interface to e.g. --transformation=AdiabaticMSW_NMO (instead of --ordering=normal), once additional transformations are available.)

Time- or energy-dependent flavour transformations will require further changes to sntools.

For additional supernova models, I need to check if it’s possible to write an adapter that maps snewpy’s interface to the one expected of an input format in sntools.

No module named 'snewpy.models.loaders'

Dear Jost,

I've noticed a minor typo in the sntools/format/init.py file that affects compatibility with the latest version of snewpy. Specifically, at line 165, the correct code should be:

sn_model = getattr(import_module('snewpy.models.ccsn_loaders'), format)(abspath(file))

Could you modify?

Best regards,
Pierre-Alexandre

CC interactions on oxygen-18 (and oxygen-17)

At the proto-collaboration meeting, Neil McCauley pointed out that nu_e CC interactions on oxygen-17/18 have a much lower threshold energy than the analogous oxygen-16 interaction, which leads to much higher cross-sections at low energies.

After a brief search, I’ve found two relevant papers:

  • Haxton: PRD 36 (1998) 2283 calculates the cross-sections theoretically. Fig. 1 shows the cross-section; the "bump" in the solid line at low energies comes from oxygen-17/18. This implies that those isotopes are negligible (compared to oxygen-16) at energies above ~20 MeV.
  • Haxton & Robertson, arXiv:nucl-th/9806081 calculates the cross-sections averaged over the solar boron-8 flux and finds that the oxygen-18 event rate is about 6.7% of the total solar neutrino signal (i.e. ~14× smaller than elastic scattering on electrons), while the oxygen-17 interaction is negligible (cross-section and natural abundance are about 3.5 and 5 times smaller than for oxygen-18).

My very rough guess (based on this and the HK Design Report) is that we might see 100–200 events from this oxygen-17/18 channel in HK. This would be a little more than the oxygen-16 channel interaction in the worst case (Totani1998 model, no oscillations), but an order of magnitude fewer events then we’d see for the oxygen-16 channel in the NH/IH scenarios.
Also, the oxygen-17/18 channel would depend only weakly on the mean neutrino energy.

add NuHepMC output format

The NuHepMC output format (see arXiv:2310.13211) that’s been in the works for a while now looks like it’s almost ready. Notably, the new Hyper-K detector simulation expects to use this as the standard input format for all event generators; so sntools should add support for this output format.

See also the NuHepMC organisation on GitHub.

Documentation improvements

Various minor documentation improvements, as suggested by @benjaminrose in this post in the JOSS review.

  • Make clear(er) that sntools is a command line app.
  • Compiled version of documentation.
  • First example should run more quickly.
  • Simplify arguments of first example

updated IBD cross section

This paper by Ricciardi et al. (2022) has an improved evaluation of the IBD cross section, showing up to ~1% (at 100 MeV) difference compared to the Strumia & Vissani XS currently implemented, as well as a more precise evaluation of the uncertainty.

It would be nice to implement this updated cross section.

generate events for multiple channels

Currently, one can either generate events for all supported channels in the respective detector (default) or for a single channel (with e.g. the --channel ibd command line argument). It may be useful to select multiple interaction channels, e.g. by allowing multiple occurrences of the argument, e.g. --channel o16e --channel o16eb.

Allow a random seed to be set

For reproducibility, it'd be nice to have the option to set a seed in genevts.py

From our discussions, you've noted that you used both random and np.random So these should both have seeds sets. Whether they're the same, indpendently settable, or have an offset (e.g. SEED and SEED + 10) I have no opinion on

interactions on carbon-13

These interaction channels are mainly relevant at low energies due to their energy threshold, which is much lower than that of equivalent interactions on carbon-12.

However, carbon-13 makes up only about 1% of carbon nuclei in nature. Thus, even at low energies I’d estimate that the event rate of these interactions is about an order of magnitude smaller than that of neutrino-electron scattering. That would make this a very minor correction.

A theoretical calculation (including a nice numerical fit) of the cross-section is available.

numerical issue in O16 CC cross sections

Discovered this issue while working on a PR for SNOwGLoBES: The oxygen-16 CC cross sections are implemented using a fit from arXiv:1809.08398, that has four "excitation energy" parameters. If the neutrino energy is barely higher than one of these excitation energies, the cross section has an unphysical spike (because the fit function diverges as the difference between neutrino energy and excitation energy goes to zero).

Sample code to demonstrate:

from sntools.interaction_channels import o16e
for i in range(1,5):
    eG, a, b, c = o16e.fit_parameters[i]
    eNu = 29.350001 # excitation energy of the 4th group: 29.35 MeV
    print(f"*** {i}: eNu={eNu}, eG={eG} ***")
    if eNu - eG > 0:
        d = log10(eNu**0.25 - eG**0.25)
        log_sigma = a + b * d + c * d**2
        print(f"d = {d}\nlog_sigma = {log_sigma}\npartial_dSigma_dE(eNu, eNu-eG, {i}) = {o16e.partial_dSigma_dE(eNu, eNu - eG,i)}\n")

In reality, the difference between eNu and eG needs to be above the detector threshold (e.g. 0.8 MeV in water Cherenkov detectors). Enforcing that may be sufficient to fix this?

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.