mango-osc 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mango/__init__.py +80 -0
- mango/constants.py +82 -0
- mango/decoherence.py +116 -0
- mango/earth.py +468 -0
- mango/eigensolve.py +76 -0
- mango/globes.py +483 -0
- mango/hamiltonian.py +90 -0
- mango/layers.py +82 -0
- mango/nonunitarity.py +288 -0
- mango/nsi.py +54 -0
- mango/nufast.py +176 -0
- mango/ode.py +161 -0
- mango/oscillator.py +368 -0
- mango/params.py +69 -0
- mango/pmns.py +42 -0
- mango/propagator.py +132 -0
- mango/solar.py +380 -0
- mango/stat.py +134 -0
- mango/sterile.py +118 -0
- mango_osc-0.3.0.dist-info/METADATA +602 -0
- mango_osc-0.3.0.dist-info/RECORD +24 -0
- mango_osc-0.3.0.dist-info/WHEEL +5 -0
- mango_osc-0.3.0.dist-info/licenses/LICENSE +27 -0
- mango_osc-0.3.0.dist-info/top_level.txt +1 -0
mango/__init__.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""jaxnu — a differentiable neutrino oscillation calculator in JAX.
|
|
2
|
+
|
|
3
|
+
Float64 is required for oscillation phases (Delta m^2 ~ 1e-3 eV^2) and is enabled
|
|
4
|
+
on import.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import jax as _jax
|
|
10
|
+
|
|
11
|
+
_jax.config.update("jax_enable_x64", True)
|
|
12
|
+
|
|
13
|
+
from . import constants # noqa: E402
|
|
14
|
+
from .params import OscParams, nufit_no # noqa: E402
|
|
15
|
+
from . import earth # noqa: E402
|
|
16
|
+
from .earth import LayeredEarth, prem_layered # noqa: E402
|
|
17
|
+
from . import globes as globes # noqa: E402 (generic GLoBES/AEDL loader)
|
|
18
|
+
from . import nufast as nufast # noqa: E402 (fast analytic constant-density)
|
|
19
|
+
from . import solar # noqa: E402 (solar profile + adiabatic MSW)
|
|
20
|
+
from .solar import probability_solar # noqa: E402
|
|
21
|
+
from . import ode # noqa: E402 (continuous-density backend)
|
|
22
|
+
from . import nsi as nsi # noqa: E402 (non-standard interactions)
|
|
23
|
+
from . import sterile as sterile # noqa: E402 (3+N sterile front-end)
|
|
24
|
+
from . import decoherence as decoherence # noqa: E402 (Lindblad / wave packets)
|
|
25
|
+
from . import nonunitarity as nonunitarity # noqa: E402 (alpha parametrization)
|
|
26
|
+
from . import stat as stat # noqa: E402 (Fisher information & chi2 utilities)
|
|
27
|
+
from .decoherence import Decoherence, WavePacket # noqa: E402
|
|
28
|
+
from .nonunitarity import NonUnitarity # noqa: E402
|
|
29
|
+
from .nsi import NSI # noqa: E402
|
|
30
|
+
from .sterile import ( # noqa: E402
|
|
31
|
+
Sterile3plus1,
|
|
32
|
+
NFlavorParams,
|
|
33
|
+
pmns_3plus1,
|
|
34
|
+
pmns_nflavor,
|
|
35
|
+
)
|
|
36
|
+
from .oscillator import ( # noqa: E402
|
|
37
|
+
Flavor,
|
|
38
|
+
n_flavors,
|
|
39
|
+
probability_constant,
|
|
40
|
+
probability_vacuum,
|
|
41
|
+
probability_profile,
|
|
42
|
+
probability_earth,
|
|
43
|
+
select,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
__all__ = [
|
|
47
|
+
"OscParams",
|
|
48
|
+
"nufit_no",
|
|
49
|
+
"Flavor",
|
|
50
|
+
"n_flavors",
|
|
51
|
+
"probability_constant",
|
|
52
|
+
"probability_vacuum",
|
|
53
|
+
"probability_profile",
|
|
54
|
+
"probability_earth",
|
|
55
|
+
"probability_solar",
|
|
56
|
+
"select",
|
|
57
|
+
"NSI",
|
|
58
|
+
"Decoherence",
|
|
59
|
+
"WavePacket",
|
|
60
|
+
"NonUnitarity",
|
|
61
|
+
"decoherence",
|
|
62
|
+
"nonunitarity",
|
|
63
|
+
"stat",
|
|
64
|
+
"Sterile3plus1",
|
|
65
|
+
"NFlavorParams",
|
|
66
|
+
"pmns_3plus1",
|
|
67
|
+
"pmns_nflavor",
|
|
68
|
+
"LayeredEarth",
|
|
69
|
+
"prem_layered",
|
|
70
|
+
"constants",
|
|
71
|
+
"earth",
|
|
72
|
+
"globes",
|
|
73
|
+
"nufast",
|
|
74
|
+
"solar",
|
|
75
|
+
"ode",
|
|
76
|
+
"nsi",
|
|
77
|
+
"sterile",
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
__version__ = "0.3.0"
|
mango/constants.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""Physical constants and unit conversions.
|
|
2
|
+
|
|
3
|
+
The numerical core of :mod:`jaxnu` works entirely in **natural units**
|
|
4
|
+
(``hbar = c = 1``): energies in eV, lengths in eV^-1, masses^2 in eV^2. Unit
|
|
5
|
+
conversions for the user-facing API (GeV, km, g/cm^3) live here so that no magic
|
|
6
|
+
factors leak into the physics modules.
|
|
7
|
+
|
|
8
|
+
All values are derived from first principles (CODATA / PDG) so the matter
|
|
9
|
+
potential is not an opaque "7.6e-14" literal.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
# --- fundamental constants ---------------------------------------------------
|
|
15
|
+
# Fermi coupling constant, G_F / (hbar c)^3 = 1.1663787e-5 GeV^-2.
|
|
16
|
+
GF_EV = 1.1663787e-23 # eV^-2
|
|
17
|
+
NA = 6.02214076e23 # Avogadro's number, mol^-1
|
|
18
|
+
|
|
19
|
+
# hbar * c = 197.3269804 MeV * fm => 1 m = 5.067730716e6 eV^-1.
|
|
20
|
+
HBARC_MEV_FM = 197.3269804
|
|
21
|
+
# hbar c in eV * m = (MeV->eV) * (fm->m):
|
|
22
|
+
HBARC_EV_M = HBARC_MEV_FM * 1.0e6 * 1.0e-15 # ~1.973269804e-7 eV*m
|
|
23
|
+
M_TO_INV_EV = 1.0 / HBARC_EV_M # eV^-1 per metre (~5.06773e6)
|
|
24
|
+
|
|
25
|
+
# --- length conversions (to eV^-1) ------------------------------------------
|
|
26
|
+
KM_TO_INV_EV = M_TO_INV_EV * 1.0e3 # eV^-1 per km (~5.06773e9)
|
|
27
|
+
CM_TO_INV_EV = M_TO_INV_EV * 1.0e-2 # eV^-1 per cm (~5.06773e4)
|
|
28
|
+
|
|
29
|
+
# --- energy conversions (to eV) ---------------------------------------------
|
|
30
|
+
GEV_TO_EV = 1.0e9
|
|
31
|
+
|
|
32
|
+
# --- matter-potential prefactor ---------------------------------------------
|
|
33
|
+
# Electron number density N_e [eV^3] = rho[g/cm^3] * Y_e * NA * (1 cm)^-3,
|
|
34
|
+
# with (1 cm)^-3 expressed in eV^3 via CM_TO_INV_EV.
|
|
35
|
+
# Charged-current potential V = sqrt(2) G_F N_e [eV].
|
|
36
|
+
import math as _math
|
|
37
|
+
|
|
38
|
+
# N_e [eV^3] per (g/cm^3 * Y_e):
|
|
39
|
+
_NE_PER_RHO_YE = NA / CM_TO_INV_EV**3 # ~4.627e9 eV^3
|
|
40
|
+
# V [eV] per (g/cm^3 * Y_e):
|
|
41
|
+
V_FACTOR_EV = _math.sqrt(2.0) * GF_EV * _NE_PER_RHO_YE # ~7.63e-14 eV
|
|
42
|
+
|
|
43
|
+
# --- Earth geometry ----------------------------------------------------------
|
|
44
|
+
R_EARTH_KM = 6371.0 # mean Earth radius
|
|
45
|
+
|
|
46
|
+
__all__ = [
|
|
47
|
+
"GF_EV",
|
|
48
|
+
"NA",
|
|
49
|
+
"KM_TO_INV_EV",
|
|
50
|
+
"CM_TO_INV_EV",
|
|
51
|
+
"GEV_TO_EV",
|
|
52
|
+
"V_FACTOR_EV",
|
|
53
|
+
"R_EARTH_KM",
|
|
54
|
+
"matter_potential_eV",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def matter_potential_eV(rho_gcc, ye):
|
|
59
|
+
"""Charged-current matter potential ``V = sqrt(2) G_F N_e`` in eV.
|
|
60
|
+
|
|
61
|
+
Parameters
|
|
62
|
+
----------
|
|
63
|
+
rho_gcc : array_like
|
|
64
|
+
Matter mass density in g/cm^3.
|
|
65
|
+
ye : array_like
|
|
66
|
+
Electron fraction ``Y_e = N_e / (N_p + N_n)`` (~0.5 for the Earth).
|
|
67
|
+
"""
|
|
68
|
+
return V_FACTOR_EV * rho_gcc * ye
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def matter_potentials(rho_gcc, ye):
|
|
72
|
+
"""Charged-current and sterile-sector potentials ``(V_CC, V_NC)`` in eV.
|
|
73
|
+
|
|
74
|
+
``V_CC = sqrt(2) G_F N_e`` acts on nu_e. Sterile neutrinos feel neither the
|
|
75
|
+
CC nor the neutral-current potential; after subtracting the (flavor-universal)
|
|
76
|
+
active NC term, the sterile diagonal entry of the matter Hamiltonian is
|
|
77
|
+
``V_NC = (1/2) sqrt(2) G_F N_n`` with ``N_n = rho N_A (1 - Y_e)``. Returns 0
|
|
78
|
+
for ``V_NC`` when ``Y_e = 1`` (no neutrons).
|
|
79
|
+
"""
|
|
80
|
+
v_cc = V_FACTOR_EV * rho_gcc * ye
|
|
81
|
+
v_nc = 0.5 * V_FACTOR_EV * rho_gcc * (1.0 - ye)
|
|
82
|
+
return v_cc, v_nc
|
mango/decoherence.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""Quantum decoherence and wave-packet decoherence in neutrino oscillations.
|
|
2
|
+
|
|
3
|
+
Environmental (Lindblad-type) decoherence or wave-packet separation damp the
|
|
4
|
+
interference terms between (matter) Hamiltonian eigenstates:
|
|
5
|
+
|
|
6
|
+
P(a->b) = sum_ij V_bi V_ai* V_bj* V_aj exp(-i (w_i - w_j) L) D_ij(L)
|
|
7
|
+
|
|
8
|
+
where ``V``/``w`` are the eigenvectors/eigenvalues of the (matter) Hamiltonian
|
|
9
|
+
and ``D_ij`` is the damping factor (``D_ii = 1``):
|
|
10
|
+
|
|
11
|
+
* **Lindblad** (:class:`Decoherence`): ``D_ij = exp(-Gamma_ij L)`` with
|
|
12
|
+
``Gamma_ij = gamma_ij (E / E0)^n`` — the standard phenomenological model with
|
|
13
|
+
a power-law energy dependence (``n`` in {-2, -1, 0, 1, 2} in the literature).
|
|
14
|
+
* **Wave packets** (:class:`WavePacket`): ``D_ij = exp(-(L/L_coh^ij)^2)`` with
|
|
15
|
+
coherence length ``L_coh = 2 sqrt(2) E sigma_x / |dw_ij|`` (equivalently
|
|
16
|
+
``4 sqrt(2) E^2 sigma_x / |dm~^2_ij|``), driven by the production wave-packet
|
|
17
|
+
size ``sigma_x``.
|
|
18
|
+
|
|
19
|
+
Both parameter sets are differentiable PyTrees, so ``jax.grad`` works through
|
|
20
|
+
``gamma`` / ``sigma_x`` — e.g. for decoherence sensitivity forecasts. In the
|
|
21
|
+
``gamma -> 0`` / ``sigma_x -> inf`` limit the standard oscillation probability is
|
|
22
|
+
recovered exactly; in the fully-decohered limit the interference-averaged
|
|
23
|
+
probability ``sum_i |V_bi|^2 |V_ai|^2`` is obtained.
|
|
24
|
+
|
|
25
|
+
Scope: vacuum and constant-density matter (a single layer). Through a varying
|
|
26
|
+
profile the state is no longer pure after the first layer and the density
|
|
27
|
+
matrix has to be propagated; that is not implemented yet.
|
|
28
|
+
|
|
29
|
+
The damping acts between eigenstates of the local matter Hamiltonian, i.e. the
|
|
30
|
+
Lindblad operators commute with H (energy conservation), as in the layered
|
|
31
|
+
treatment of Coloma, Lopez-Pavon, Martinez-Soler & Nunokawa, Eur. Phys. J. C 78
|
|
32
|
+
(2018) 614 [arXiv:1803.04438]. The damping indices refer to the matter
|
|
33
|
+
eigenstates sorted by eigenvalue -- in vacuum with normal ordering these are the
|
|
34
|
+
usual mass states 1, 2, 3; above the MSW resonance they are not.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
from __future__ import annotations
|
|
38
|
+
|
|
39
|
+
import dataclasses
|
|
40
|
+
|
|
41
|
+
import jax
|
|
42
|
+
import jax.numpy as jnp
|
|
43
|
+
|
|
44
|
+
from . import constants as C
|
|
45
|
+
from .hamiltonian import matter_hamiltonian
|
|
46
|
+
from .oscillator import select
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@jax.tree_util.register_dataclass
|
|
50
|
+
@dataclasses.dataclass(frozen=True)
|
|
51
|
+
class Decoherence:
|
|
52
|
+
"""Lindblad decoherence: ``Gamma_ij = gamma_ij * (E / E0_GeV)^n`` (gammas in eV).
|
|
53
|
+
|
|
54
|
+
``n`` is a static (non-differentiable) power index.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
gamma21: jax.Array = 0.0
|
|
58
|
+
gamma31: jax.Array = 0.0
|
|
59
|
+
gamma32: jax.Array = 0.0
|
|
60
|
+
E0_GeV: jax.Array = 1.0
|
|
61
|
+
n: int = dataclasses.field(default=0, metadata=dict(static=True))
|
|
62
|
+
|
|
63
|
+
def damping(self, dw, energy_eV, length_invEV):
|
|
64
|
+
"""(3, 3) damping matrix for eigenvalue differences ``dw[i,j]``."""
|
|
65
|
+
g = jnp.zeros((3, 3))
|
|
66
|
+
g = g.at[1, 0].set(self.gamma21).at[0, 1].set(self.gamma21)
|
|
67
|
+
g = g.at[2, 0].set(self.gamma31).at[0, 2].set(self.gamma31)
|
|
68
|
+
g = g.at[2, 1].set(self.gamma32).at[1, 2].set(self.gamma32)
|
|
69
|
+
scale = (energy_eV / (self.E0_GeV * C.GEV_TO_EV)) ** self.n
|
|
70
|
+
return jnp.exp(-g * scale * length_invEV)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@jax.tree_util.register_dataclass
|
|
74
|
+
@dataclasses.dataclass(frozen=True)
|
|
75
|
+
class WavePacket:
|
|
76
|
+
"""Wave-packet decoherence with production wave-packet size ``sigma_x_m`` (meters)."""
|
|
77
|
+
|
|
78
|
+
sigma_x_m: jax.Array = 1.0e-3
|
|
79
|
+
|
|
80
|
+
def damping(self, dw, energy_eV, length_invEV):
|
|
81
|
+
sigma_x = self.sigma_x_m * C.M_TO_INV_EV # -> eV^-1
|
|
82
|
+
arg = length_invEV * dw / (2.0 * jnp.sqrt(2.0) * energy_eV * sigma_x)
|
|
83
|
+
return jnp.exp(-(arg ** 2))
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _prob_single(params, energy_eV, length_invEV, v_cc, model, anti):
|
|
87
|
+
h = matter_hamiltonian(params.pmns(), params.msquared(), energy_eV, v_cc,
|
|
88
|
+
anti=anti)
|
|
89
|
+
w, V = jnp.linalg.eigh(h)
|
|
90
|
+
dw = w[:, None] - w[None, :]
|
|
91
|
+
M = jnp.exp(-1j * dw * length_invEV) * model.damping(jnp.abs(dw), energy_eV,
|
|
92
|
+
length_invEV)
|
|
93
|
+
Cmat = V[:, None, :] * jnp.conj(V)[None, :, :] # C[b, a, i] = V_bi V_ai*
|
|
94
|
+
P = jnp.einsum("bai,ij,baj->ba", Cmat, M, jnp.conj(Cmat))
|
|
95
|
+
return jnp.real(P)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def probability(params, energy_GeV, baseline_km, model, density=0.0, ye=0.5,
|
|
99
|
+
anti=False, flavor_in=None, flavor_out=None):
|
|
100
|
+
"""Oscillation probabilities with decoherence (vacuum or constant density).
|
|
101
|
+
|
|
102
|
+
``model`` is a :class:`Decoherence` or :class:`WavePacket`; ``energy_GeV``
|
|
103
|
+
may be a scalar or 1-D array. Returns ``P[..., out, in]`` (or a selected
|
|
104
|
+
channel). Differentiable in ``params`` *and* the decoherence parameters.
|
|
105
|
+
"""
|
|
106
|
+
energy_eV = jnp.asarray(energy_GeV) * C.GEV_TO_EV
|
|
107
|
+
length_invEV = jnp.asarray(baseline_km) * C.KM_TO_INV_EV
|
|
108
|
+
v_cc = C.matter_potential_eV(density, ye)
|
|
109
|
+
|
|
110
|
+
def core(e):
|
|
111
|
+
return _prob_single(params, e, length_invEV, v_cc, model, anti)
|
|
112
|
+
|
|
113
|
+
p = core(energy_eV) if energy_eV.ndim == 0 else jax.vmap(core)(energy_eV)
|
|
114
|
+
if flavor_in is not None and flavor_out is not None:
|
|
115
|
+
return select(p, flavor_in, flavor_out)
|
|
116
|
+
return p
|