Skip to content

Commit f200ff8

Browse files
authored
Merge pull request #762 from ggarg07/master
Addition of LRI potential
2 parents 12faa1c + d29d387 commit f200ff8

File tree

59 files changed

+212
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+212
-9
lines changed

pisa/stages/osc/lri_params.py

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
"""
2+
LRI Params: Charecterize Long Range Interaction mediator
3+
4+
Developed by following osc_params.py and nsi_params.py
5+
"""
6+
7+
from __future__ import absolute_import, division
8+
9+
import numpy as np
10+
from pisa import CTYPE, FTYPE
11+
from pisa.utils.comparisons import ALLCLOSE_KW, isscalar, recursiveEquality
12+
from pisa.utils.log import Levels, set_verbosity, logging
13+
14+
__all__ = ['LRIParams']
15+
16+
class LRIParams(object):
17+
"""
18+
Holds the mediator information of long range interaction:z'
19+
Assumed three anamoly free symmetries, Le_mu, Le_tau, Lmu_tau(by mixing z and z')).
20+
21+
Attributes
22+
----------
23+
potential matrix : Three 2d float array of shape (3,3), one for each symmetry
24+
25+
Potential matrix holding the potential term of three different symmetris, which is a
26+
function of mediator mass, and the coupling constant of the interaction.
27+
28+
29+
"""
30+
31+
def __init__(self):
32+
33+
self._v_lri = 0.
34+
self._potential_matrix_emu = np.zeros((3, 3), dtype=FTYPE)
35+
self._potential_matrix_etau = np.zeros((3, 3), dtype=FTYPE)
36+
self._potential_matrix_mutau = np.zeros((3, 3), dtype=FTYPE)
37+
38+
# --- LRI potential ---
39+
40+
@property
41+
def v_lri(self):
42+
"""Potential term of symmetry e mu"""
43+
return self._v_lri
44+
45+
@v_lri.setter
46+
def v_lri(self, value):
47+
assert value <1.
48+
self._v_lri = value
49+
50+
@property
51+
def potential_matrix_emu(self):
52+
"""LRI matter interaction potential matrix e mu symmetry"""
53+
54+
v_matrix = np.zeros((3, 3), dtype=FTYPE)
55+
56+
v_matrix[0, 0] = self.v_lri
57+
v_matrix[0, 1] = 0.
58+
v_matrix[0, 2] = 0.
59+
v_matrix[1, 0] = 0.
60+
v_matrix[1, 1] = - self.v_lri
61+
v_matrix[1, 2] = 0.
62+
v_matrix[2, 0] = 0.
63+
v_matrix[2, 1] = 0.
64+
v_matrix[2, 2] = 0.
65+
66+
assert np.allclose(v_matrix, v_matrix.conj().T, **ALLCLOSE_KW)
67+
68+
return v_matrix
69+
70+
@property
71+
def potential_matrix_etau(self):
72+
"""LRI matter interaction potential matrix e tau symmetry"""
73+
74+
v_matrix = np.zeros((3, 3), dtype=FTYPE)
75+
76+
v_matrix[0, 0] = self.v_lri
77+
v_matrix[0, 1] = 0.
78+
v_matrix[0, 2] = 0.
79+
v_matrix[1, 0] = 0.
80+
v_matrix[1, 1] = 0.
81+
v_matrix[1, 2] = 0.
82+
v_matrix[2, 0] = 0.
83+
v_matrix[2, 1] = 0.
84+
v_matrix[2, 2] = - self.v_lri
85+
86+
assert np.allclose(v_matrix, v_matrix.conj().T, **ALLCLOSE_KW)
87+
88+
return v_matrix
89+
90+
@property
91+
def potential_matrix_mutau(self):
92+
"""LRI matter interaction potential matrix mu tau symmetry"""
93+
94+
v_matrix = np.zeros((3, 3), dtype=FTYPE)
95+
96+
v_matrix[0, 0] = 0.
97+
v_matrix[0, 1] = 0.
98+
v_matrix[0, 2] = 0.
99+
v_matrix[1, 0] = 0.
100+
v_matrix[1, 1] = self.v_lri
101+
v_matrix[1, 2] = 0.
102+
v_matrix[2, 0] = 0.
103+
v_matrix[2, 1] = 0.
104+
v_matrix[2, 2] = - self.v_lri
105+
106+
assert np.allclose(v_matrix, v_matrix.conj().T, **ALLCLOSE_KW)
107+
108+
return v_matrix
109+
110+
111+
def test_lri_params():
112+
"""
113+
# TODO: implement me!
114+
"""
115+
pass
116+
117+
if __name__=='__main__':
118+
from pisa import TARGET
119+
from pisa.utils.log import set_verbosity, logging
120+
set_verbosity(1)
121+
test_lri_params()

pisa/stages/osc/prob3.py

+42-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from pisa.stages.osc.nsi_params import StdNSIParams, VacuumLikeNSIParams
1919
from pisa.stages.osc.osc_params import OscParams
2020
from pisa.stages.osc.decay_params import DecayParams
21+
from pisa.stages.osc.lri_params import LRIParams
2122
from pisa.stages.osc.layers import Layers
2223
from pisa.stages.osc.prob3numba.numba_osc_hostfuncs import propagate_array, fill_probs
2324
from pisa.utils.numba_tools import WHERE
@@ -64,6 +65,8 @@ class prob3(Stage):
6465
eps_mutau_phase : quantity (angle)
6566
eps_tautau : quantity (dimensionless)
6667
decay_alpha3 : quantity (energy^2)
68+
v_lri : quantity (eV)
69+
6770
6871
**kwargs
6972
Other kwargs are handled by Stage
@@ -77,6 +80,7 @@ def __init__(
7780
reparam_mix_matrix=False,
7881
neutrino_decay=False,
7982
scale_density=False,
83+
lri_type=None,
8084
**std_kwargs,
8185
):
8286

@@ -155,7 +159,22 @@ def __init__(
155159
else:
156160
decay_params = ()
157161

158-
expected_params = expected_params + nsi_params + decay_params
162+
if lri_type is not None:
163+
choices = ['emu-symmetry', 'etau-symmetry', 'mutau-symmetry']
164+
lri_type = lri_type.strip().lower()
165+
if not lri_type in choices:
166+
raise ValueError(
167+
'Chosen LRI symmetry type "%s" not available! Choose one of %s.'
168+
% (lri_type, choices)
169+
)
170+
self.lri_type = lri_type
171+
172+
if self.lri_type is None:
173+
lri_params = ()
174+
else:
175+
lri_params = ('v_lri',)
176+
177+
expected_params = expected_params + nsi_params + decay_params + lri_params
159178

160179
# init base class
161180
super().__init__(
@@ -169,6 +188,8 @@ def __init__(
169188
self.nsi_params = None
170189
self.decay_params = None
171190
self.decay_matrix = None
191+
self.lri_params = None
192+
self.lri_pot = None
172193
# Note that the interaction potential (Hamiltonian) just scales with the
173194
# electron density N_e for propagation through the Earth,
174195
# even(to very good approx.) in the presence of generalised interactions
@@ -201,6 +222,10 @@ def setup_function(self):
201222
if self.neutrino_decay:
202223
logging.debug('Working with neutrino decay')
203224
self.decay_params = DecayParams()
225+
226+
if self.lri_type is not None:
227+
logging.debug('Working with LRI')
228+
self.lri_params = LRIParams()
204229

205230
# setup the layers
206231
#if self.params.earth_model.value is not None:
@@ -262,6 +287,7 @@ def calc_probs(self, nubar, e_array, rho_array, len_array, out):
262287
self.gen_mat_pot_matrix_complex,
263288
self.decay_flag,
264289
self.decay_matix,
290+
self.lri_pot,
265291
nubar,
266292
e_array,
267293
rho_array,
@@ -337,6 +363,9 @@ def compute_function(self):
337363

338364
if self.neutrino_decay:
339365
self.decay_params.decay_alpha3 = self.params.decay_alpha3.value.m_as('eV**2')
366+
367+
if self.lri_type is not None:
368+
self.lri_params.v_lri = self.params.v_lri.value.m_as('eV')
340369

341370
# now we can proceed to calculate the generalised matter potential matrix
342371
std_mat_pot_matrix = np.zeros((3, 3), dtype=FTYPE) + 1.j * np.zeros((3, 3), dtype=FTYPE)
@@ -361,6 +390,18 @@ def compute_function(self):
361390
else :
362391
self.decay_matix = np.zeros((3, 3), dtype=FTYPE) + 1.j * np.zeros((3, 3), dtype=FTYPE)
363392

393+
self.lri_pot = np.zeros((3, 3), dtype=FTYPE)
394+
types_lri = ['emu-symmetry', 'etau-symmetry', 'etau-symmetry']
395+
if self.lri_type is not None:
396+
if self.lri_type == 'emu-symmetry':
397+
self.lri_pot = self.lri_params.potential_matrix_emu
398+
elif self.lri_type == 'etau-symmetry':
399+
self.lri_pot = self.lri_params.potential_matrix_etau
400+
elif self.lri_type == 'mutau-symmetry':
401+
self.lri_pot = self.lri_params.potential_matrix_mutau
402+
else:
403+
raise Exception("Implemented symmetries are" % types_lri)
404+
364405

365406
for container in self.data:
366407
self.calc_probs(container['nubar'],

pisa/stages/osc/prob3numba/numba_osc_hostfuncs.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -58,29 +58,29 @@
5858

5959

6060
@guvectorize(
61-
[f"({FX}[:,:], {CX}[:,:], {CX}[:,:], {IX}, {CX}[:,:], {IX}, {FX}, {FX}[:], {FX}[:], {FX}[:,:])"],
62-
"(a,a), (a,a), (b,c), (), (b,c), (), (), (i), (i) -> (a,a)",
61+
[f"({FX}[:,:], {CX}[:,:], {CX}[:,:], {IX}, {CX}[:,:], {FX}[:,:], {IX}, {FX}, {FX}[:], {FX}[:], {FX}[:,:])"],
62+
"(a,a), (a,a), (b,c), (), (b,c), (b,c), (), (), (i), (i) -> (a,a)",
6363
target=TARGET,
6464
)
65-
def propagate_array(dm, mix, mat_pot, decay_flag, mat_decay, nubar, energy, densities, distances, probability):
65+
def propagate_array(dm, mix, mat_pot, decay_flag, mat_decay, lri_pot, nubar, energy, densities, distances, probability):
6666
"""wrapper to run `osc_probs_layers_kernel` from host (whether TARGET
6767
is "cuda" or "host")"""
6868
osc_probs_layers_kernel(
69-
dm, mix, mat_pot, decay_flag, mat_decay, nubar, energy, densities, distances, probability
69+
dm, mix, mat_pot, decay_flag, mat_decay, lri_pot, nubar, energy, densities, distances, probability
7070
)
7171

7272

7373
@njit(
74-
[f"({FX}[:,:], {CX}[:,:], {CX}[:,:], {IX}, {CX}[:,:], {IX}, {FX}, {FX}[:], {FX}[:], {FX}[:,:])"],
74+
[f"({FX}[:,:], {CX}[:,:], {CX}[:,:], {IX}, {CX}[:,:], {FX}[:,:], {IX}, {FX}, {FX}[:], {FX}[:], {FX}[:,:])"],
7575
parallel=TARGET == "parallel"
7676
)
7777
def propagate_scalar(
78-
dm, mix, mat_pot, decay_flag, mat_decay, nubar, energy, densities, distances, probability
78+
dm, mix, mat_pot, decay_flag, mat_decay, lri_pot, nubar, energy, densities, distances, probability
7979
):
8080
"""wrapper to run `osc_probs_layers_kernel` from host (whether TARGET
8181
is "cuda" or "host")"""
8282
osc_probs_layers_kernel(
83-
dm, mix, mat_pot, decay_flag, mat_decay, nubar, energy, densities, distances, probability
83+
dm, mix, mat_pot, decay_flag, mat_decay, lri_pot, nubar, energy, densities, distances, probability
8484
)
8585

8686

@@ -97,6 +97,7 @@ def propagate_scalar(
9797
f"{CX}[:,:], " # H_vac
9898
f"{IX}, " # neutrino decay flag
9999
f"{CX}[:,:], " # H_decay
100+
f"{FX}[:,:], " # lri_pot
100101
f"{FX}[:,:], " # dm
101102
f"{CX}[:,:], " # transition_matrix
102103
")"
@@ -114,6 +115,7 @@ def get_transition_matrix_hostfunc(
114115
H_vac,
115116
decay_flag,
116117
H_decay,
118+
lri_pot,
117119
dm,
118120
transition_matrix,
119121
):
@@ -130,6 +132,7 @@ def get_transition_matrix_hostfunc(
130132
H_vac,
131133
decay_flag,
132134
H_decay,
135+
lri_pot,
133136
dm,
134137
transition_matrix,
135138
)

pisa/stages/osc/prob3numba/numba_osc_kernels.py

+24-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120

121121
@myjit
122122
def osc_probs_layers_kernel(
123-
dm, mix, mat_pot, decay_flag, mat_decay, nubar, energy, density_in_layer, distance_in_layer, osc_probs
123+
dm, mix, mat_pot, decay_flag, mat_decay, lri_pot, nubar, energy, density_in_layer, distance_in_layer, osc_probs
124124
):
125125
""" Calculate oscillation probabilities
126126
@@ -144,6 +144,11 @@ def osc_probs_layers_kernel(
144144
145145
mat_decay : complex 2d array
146146
decay matrix with -j*alpha3 = [2,2] element
147+
148+
lri_pot : real 2d array
149+
Potential contribution due to matter with the consideration of
150+
Long Range Interaction. this potential not a generalised one, so
151+
it passed as a separate matrix.
147152
148153
nubar : real int, scalar or Nd array (broadcast dim)
149154
1 for neutrinos, -1 for antineutrinos
@@ -256,6 +261,7 @@ def osc_probs_layers_kernel(
256261
H_vac,
257262
decay_flag,
258263
H_decay,
264+
lri_pot,
259265
dm,
260266
transition_matrix,
261267
)
@@ -306,6 +312,7 @@ def osc_probs_layers_kernel(
306312
H_vac,
307313
decay_flag,
308314
H_decay,
315+
lri_pot,
309316
dm,
310317
transition_matrix,
311318
)
@@ -330,7 +337,9 @@ def osc_probs_layers_kernel(
330337
else:
331338
raw_input_psi[i] = 1.0
332339

340+
333341
matrix_dot_vector(transition_product, raw_input_psi, output_psi)
342+
334343
osc_probs[i][0] += output_psi[0].real ** 2 + output_psi[0].imag ** 2
335344
osc_probs[i][1] += output_psi[1].real ** 2 + output_psi[1].imag ** 2
336345
osc_probs[i][2] += output_psi[2].real ** 2 + output_psi[2].imag ** 2
@@ -348,6 +357,7 @@ def get_transition_matrix(
348357
H_vac,
349358
decay_flag,
350359
H_decay,
360+
lri_pot,
351361
dm,
352362
transition_matrix,
353363
):
@@ -389,6 +399,11 @@ def get_transition_matrix(
389399
390400
decay_flag: int
391401
+1 forstandard oscillations + decay, -1 for standard oscillations
402+
403+
lri_pot : real 2d array
404+
Potential contribution due to matter with the consideration of
405+
Long Range Interaction. this potential not a generalised one, so
406+
it passed as a separate matrix.
392407
393408
dm : real 2d array
394409
Mass splitting matrix, eV^2
@@ -416,6 +431,14 @@ def get_transition_matrix(
416431

417432
get_H_mat(rho, mat_pot, nubar, H_mat)
418433

434+
# Adding the LRI potential to H_mat(lri pot is 2d array with full of zeros in the absence of lri)
435+
for i in range(3):
436+
for j in range(3):
437+
if nubar > 0:
438+
H_mat[i, j] = H_mat[i, j] + lri_pot[i, j]*1e9 #eV/GeV
439+
elif nubar < 0:
440+
H_mat[i, j] = H_mat[i, j] - lri_pot[i, j]*1e9 #ev/Gev
441+
419442
# Get the full Hamiltonian by adding together matter and vacuum parts
420443
one_over_two_e = 0.5 / energy
421444

0 commit comments

Comments
 (0)