nu-waves


Namenu-waves JSON
Version 1.2.2 PyPI version JSON
download
home_pageNone
SummaryFlavour-oscillation probabilities for neutrinos with numpy/torch backends.
upload_time2025-10-26 20:08:34
maintainerNone
docs_urlNone
authorNadrino
requires_python>=3.9
licenseLGPL-2.1-or-later
keywords pmns neutrino oscillations physics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Neutrino Interferometry - `nu_waves` Python library

## What is it?

**Neutrino Interferometry**, or `nu_waves`, is a simple Python library
that calculate flavor oscillation of neutrinos.
You can input your own parameters and get the oscillation probabilities.


## How to install?

```bash
pip install nu-waves
```


## Features

- Embedded GPU acceleration (MPS, CUDA)
- Oscillation framework with `N` neutrinos
- Vacuum oscillations
- Custom smearing function (L and E)
- Constant matter MSW
- Multi-layer matter MSW
- Earth model (PREM) with `cosz`
- Adiabatic transitions

## Some nice pictures

![vacuum_pmns.jpg](figures/vacuum_pmns.jpg)
![matter_constant_test.jpg](figures/matter_constant_test.jpg)
![matter_prem_test.jpg](figures/matter_prem_test.jpg)
![adiabatic_sun_ssm_test.jpg](figures/adiabatic_sun_ssm_test.jpg)
![vacuum_2d_pmns.jpg](figures/vacuum_2d_pmns.jpg)
![vacuum_2flavors.jpg](figures/vacuum_2flavors.jpg)

## Examples

### 2 flavors oscillation in vacuum

```python
import numpy as np
import matplotlib.pyplot as plt
from nu_waves.models.mixing import Mixing
from nu_waves.models.spectrum import Spectrum
from nu_waves.propagation.oscillator import Oscillator
import nu_waves.utils.flavors as flavors

# sterile test
osc_amplitude = 0.1  # sin^2(2\theta)
angles = {(1, 2): np.arcsin(np.sqrt(osc_amplitude)) / 2}
pmns = Mixing(n_neutrinos=2, mixing_angles=angles)
U_pmns = pmns.build_mixing_matrix()
print(np.round(U_pmns, 3))

# 1 eV^2
spec = Spectrum(n_neutrinos=2, m_lightest=0.)
spec._generate_dm2_matrix({(2, 1): 1})
spec.summary()
m2_diag = np.diag(spec.get_m2())

# oscillator object that calculates the oscillation probability
osc = Oscillator(mixing_matrix=U_pmns, m2_list=spec.get_m2())

# get the oscillation probabilities
E_fixed = 3E-3
L_min, L_max = 1e-3, 20e-3
L_list = np.linspace(L_min, L_max, 200)
print(L_list)
P = osc.probability(
    L_km=L_list, E_GeV=E_fixed,
    flavor_emit=flavors.electron,
    flavor_det=flavors.electron,  # muon could be sterile
    antineutrino=True
)

# draw it
plt.figure(figsize=(6.5, 4.0))

plt.plot(L_list * 1000, P, label=r"$P_{e e}$ disappearance", lw=2)
plt.plot(L_list * 1000, [1] * len(L_list), "--", label="Total probability", lw=1.5)

plt.xlabel(r"$L_\nu$ [m]")
plt.ylabel(r"Probability")
plt.title(f"eV$^2$ sterile with $E_\\nu$ = {E_fixed * 1000} MeV")
# plt.xlim(L_min, L_max)
plt.ylim(0, 1.05)
plt.legend()
plt.tight_layout()
plt.show()
```



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "nu-waves",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "PMNS, neutrino, oscillations, physics",
    "author": "Nadrino",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/fc/d7/b1c8813ed420f140e61282750495eb9d1fd3e11b8125726505647b5deabf/nu_waves-1.2.2.tar.gz",
    "platform": null,
    "description": "# Neutrino Interferometry - `nu_waves` Python library\n\n## What is it?\n\n**Neutrino Interferometry**, or `nu_waves`, is a simple Python library\nthat calculate flavor oscillation of neutrinos.\nYou can input your own parameters and get the oscillation probabilities.\n\n\n## How to install?\n\n```bash\npip install nu-waves\n```\n\n\n## Features\n\n- Embedded GPU acceleration (MPS, CUDA)\n- Oscillation framework with `N` neutrinos\n- Vacuum oscillations\n- Custom smearing function (L and E)\n- Constant matter MSW\n- Multi-layer matter MSW\n- Earth model (PREM) with `cosz`\n- Adiabatic transitions\n\n## Some nice pictures\n\n![vacuum_pmns.jpg](figures/vacuum_pmns.jpg)\n![matter_constant_test.jpg](figures/matter_constant_test.jpg)\n![matter_prem_test.jpg](figures/matter_prem_test.jpg)\n![adiabatic_sun_ssm_test.jpg](figures/adiabatic_sun_ssm_test.jpg)\n![vacuum_2d_pmns.jpg](figures/vacuum_2d_pmns.jpg)\n![vacuum_2flavors.jpg](figures/vacuum_2flavors.jpg)\n\n## Examples\n\n### 2 flavors oscillation in vacuum\n\n```python\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom nu_waves.models.mixing import Mixing\nfrom nu_waves.models.spectrum import Spectrum\nfrom nu_waves.propagation.oscillator import Oscillator\nimport nu_waves.utils.flavors as flavors\n\n# sterile test\nosc_amplitude = 0.1  # sin^2(2\\theta)\nangles = {(1, 2): np.arcsin(np.sqrt(osc_amplitude)) / 2}\npmns = Mixing(n_neutrinos=2, mixing_angles=angles)\nU_pmns = pmns.build_mixing_matrix()\nprint(np.round(U_pmns, 3))\n\n# 1 eV^2\nspec = Spectrum(n_neutrinos=2, m_lightest=0.)\nspec._generate_dm2_matrix({(2, 1): 1})\nspec.summary()\nm2_diag = np.diag(spec.get_m2())\n\n# oscillator object that calculates the oscillation probability\nosc = Oscillator(mixing_matrix=U_pmns, m2_list=spec.get_m2())\n\n# get the oscillation probabilities\nE_fixed = 3E-3\nL_min, L_max = 1e-3, 20e-3\nL_list = np.linspace(L_min, L_max, 200)\nprint(L_list)\nP = osc.probability(\n    L_km=L_list, E_GeV=E_fixed,\n    flavor_emit=flavors.electron,\n    flavor_det=flavors.electron,  # muon could be sterile\n    antineutrino=True\n)\n\n# draw it\nplt.figure(figsize=(6.5, 4.0))\n\nplt.plot(L_list * 1000, P, label=r\"$P_{e e}$ disappearance\", lw=2)\nplt.plot(L_list * 1000, [1] * len(L_list), \"--\", label=\"Total probability\", lw=1.5)\n\nplt.xlabel(r\"$L_\\nu$ [m]\")\nplt.ylabel(r\"Probability\")\nplt.title(f\"eV$^2$ sterile with $E_\\\\nu$ = {E_fixed * 1000} MeV\")\n# plt.xlim(L_min, L_max)\nplt.ylim(0, 1.05)\nplt.legend()\nplt.tight_layout()\nplt.show()\n```\n\n\n",
    "bugtrack_url": null,
    "license": "LGPL-2.1-or-later",
    "summary": "Flavour-oscillation probabilities for neutrinos with numpy/torch backends.",
    "version": "1.2.2",
    "project_urls": {
        "Homepage": "https://github.com/nadrino/neutrino-interferometry",
        "Issues": "https://github.com/nadrino/neutrino-interferometry/issues"
    },
    "split_keywords": [
        "pmns",
        " neutrino",
        " oscillations",
        " physics"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2bc0fad7063b2e859cd3c5183f1ea66aa2e46f6dfc6559e5a6f427d9bb8e6ba8",
                "md5": "cdbc665d5845e33681d12980107f2eb0",
                "sha256": "c3836b17948dfe299dc1801d0361ccf31954aed5be682fe4f7ef35145a44267a"
            },
            "downloads": -1,
            "filename": "nu_waves-1.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cdbc665d5845e33681d12980107f2eb0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 42065,
            "upload_time": "2025-10-26T20:08:32",
            "upload_time_iso_8601": "2025-10-26T20:08:32.930931Z",
            "url": "https://files.pythonhosted.org/packages/2b/c0/fad7063b2e859cd3c5183f1ea66aa2e46f6dfc6559e5a6f427d9bb8e6ba8/nu_waves-1.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "fcd7b1c8813ed420f140e61282750495eb9d1fd3e11b8125726505647b5deabf",
                "md5": "7b300696a2e229cea2090c250acf2831",
                "sha256": "bebcb8dad9cecd157737a0e62a41f105370a2ac89ab551ab4e0ba628f4ef2faf"
            },
            "downloads": -1,
            "filename": "nu_waves-1.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "7b300696a2e229cea2090c250acf2831",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 35967,
            "upload_time": "2025-10-26T20:08:34",
            "upload_time_iso_8601": "2025-10-26T20:08:34.412082Z",
            "url": "https://files.pythonhosted.org/packages/fc/d7/b1c8813ed420f140e61282750495eb9d1fd3e11b8125726505647b5deabf/nu_waves-1.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-26 20:08:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nadrino",
    "github_project": "neutrino-interferometry",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "nu-waves"
}
        
Elapsed time: 1.81375s