forked from rogerwendell/Prob3plusplus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mosc3.c
340 lines (281 loc) · 8.45 KB
/
mosc3.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "mosc.h"
//#include "mosc3.h"
#define re (0)
#define im (1)
static double dm[3][3];
static double mix[3][3][2];
static double Ain[3][3][2];
static double dm21,dm32,s12,s23,s31,dcp;
/*
* Enu : neutrino energy (GeV)
* rho : electron density in matter (ne/Na/(g/cm^3))
* dm21 : m2^2 - m1^2 (eV2)
* dm31 : m3^2 - m1^2 (eV2)
* s12 : sin(th12)
* s23 : sin(th23)
* s31 : sin(th31)
* dcp : delta cp
* cd : cos(delta)
* sd : sin(delta)
*/
/*
* Initialize mixing matrix, etc.
*/
void init_mixing_matrix(dm21f,dm32f,s12f,s23f,s31f,dcpf)
double dm21f,dm32f,s12f,s23f,s31f,dcpf;
{
dm21=dm21f ; dm32=dm32f ;
s12=s12f ; s23=s23f ; s31=s31f ;
dcp=dcpf ;
setMatterFlavor(nue_type);
setmix_sin(s12,s23,s31,dcp,mix);
setmass(dm21,dm32,dm);
memset(Ain,0,3*3*2*sizeof(double));
Ain[0][0][re] = Ain[1][1][re] = Ain[2][2][re] = 1.0;
//printf("Mixing matrix -- real: \n" );
//printf("mix : %f %f %f \n",mix[0][0][0],mix[0][1][0],mix[0][2][0]);
//printf("mix : %f %f %f \n",mix[1][0][0],mix[1][1][0],mix[1][2][0]);
//printf("mix : %f %f %f \n",mix[2][0][0],mix[2][1][0],mix[2][2][0]);
//printf("\n\nMixing matrix -- imag: \n" );
//printf("mix : %f %f %f \n",mix[0][0][1],mix[0][1][1],mix[0][2][1]);
//printf("mix : %f %f %f \n",mix[1][0][1],mix[1][1][1],mix[1][2][1]);
//printf("mix : %f %f %f \n",mix[2][0][1],mix[2][1][1],mix[2][2][1]);
}
/*
* Initialize mixing matrix, etc.
*/
void init_mass_with_mixing_matrix(dm21f,dm32f, lMNS )
double dm21f,dm32f;
double lMNS[][3][2];
{
dm21=dm21f ; dm32=dm32f ;
setMatterFlavor(nue_type);
setmass(dm21,dm32,dm);
// copy local MNS matrix to the static copy
// used by mosc3.h (and subsequently mosc.h) routines
memcpy( mix, lMNS, 3*3*2*sizeof(double));
memset(Ain,0,3*3*2*sizeof(double));
Ain[0][0][re] = Ain[1][1][re] = Ain[2][2][re] = 1.0;
//printf("Mixing matrix -- real: \n" );
//printf("mix : %f %f %f \n",mix[0][0][0],mix[0][1][0],mix[0][2][0]);
//printf("mix : %f %f %f \n",mix[1][0][0],mix[1][1][0],mix[1][2][0]);
//printf("mix : %f %f %f \n",mix[2][0][0],mix[2][1][0],mix[2][2][0]);
//printf("\n\nMixing matrix -- imag: \n" );
//printf("mix : %f %f %f \n",mix[0][0][1],mix[0][1][1],mix[0][2][1]);
//printf("mix : %f %f %f \n",mix[1][0][1],mix[1][1][1],mix[1][2][1]);
//printf("mix : %f %f %f \n",mix[2][0][1],mix[2][1][1],mix[2][2][1]);
}
void get_oscillation_parameters(dm21f,dm32f,s12f,s23f,s31f,dcpf)
double dm21f,dm32f,s12f,s23f,s31f,dcpf;
{
dm21f = dm21;
dm32f = dm32;
s12f = s12;
s23f = s23;
s31f = s31;
dcpf = dcp ;
}
/*
* return oscillation length of delta M^23 sector
*/
void get_wavelength_23(energy, lambda23)
double energy; double* lambda23;
{
*lambda23 = 2.480*(energy)/fabs(dm32);
}
/*
* Return real part of mixing matrix
* (for calculating oscillation probability in vacuum)
*/
void get_mixing_matrix_real(mixtmp)
double mixtmp[3][3];
{
int i,j;
for(j=0;j<3;j++) {
for (i=0;i<3;i++) {
mixtmp[j][i] = mix[j][i][re];
}
}
}
/*
* Obtain transition matrix
*/
void get_transition_matrix(nutypei,Enuf,rhof,Lenf,Aout,phase_offsetf)
int nutypei;
double Enuf,rhof,Lenf;
double Aout[][3][2];
double phase_offsetf ;
{
int nutype;
double Enu, rho, Len ;
double dmMatVac[3][3], dmMatMat[3][3];
double phase_offset;
nutype=nutypei;
Enu=Enuf ;
rho=rhof ;
Len=Lenf ;
phase_offset = phase_offsetf ;
//printf("nutype: %d \n", nutype );
//printf("Mixing matrix -- real: \n" );
//printf("mix : %10.9f %10.9f %10.9f \n",mix[0][0][0],mix[0][1][0],mix[0][2][0]);
//printf("mix : %10.9f %10.9f %10.9f \n",mix[1][0][0],mix[1][1][0],mix[1][2][0]);
//printf("mix : %10.9f %10.9f %10.9f \n",mix[2][0][0],mix[2][1][0],mix[2][2][0]);
//printf("\n\nMixing matrix -- imag: \n" );
//printf("mix : %10.9f %10.9f %10.9f \n",mix[0][0][1],mix[0][1][1],mix[0][2][1]);
//printf("mix : %10.9f %10.9f %10.9f \n",mix[1][0][1],mix[1][1][1],mix[1][2][1]);
//printf("mix : %10.9f %10.9f %10.9f \n",mix[2][0][1],mix[2][1][1],mix[2][2][1]);
/* propagate_mat(Ain,rho,Len,Enu,mix,dm,nutype,Aout); */
getM(Enu, rho, mix, dm, nutype, dmMatMat, dmMatVac);
getA(Len, Enu, rho, mix, dmMatVac, dmMatMat, nutype, Aout,phase_offset);
//printf("(after) Mixing matrix -- real: \n" );
//printf("mix : %10.9f %10.9f %10.9f \n",mix[0][0][0],mix[0][1][0],mix[0][2][0]);
//printf("mix : %10.9f %10.9f %10.9f \n",mix[1][0][0],mix[1][1][0],mix[1][2][0]);
//printf("mix : %10.9f %10.9f %10.9f \n",mix[2][0][0],mix[2][1][0],mix[2][2][0]);
//printf("\n\nMixing matrix -- imag: \n" );
//printf("mix : %10.9f %10.9f %10.9f \n",mix[0][0][1],mix[0][1][1],mix[0][2][1]);
//printf("mix : %10.9f %10.9f %10.9f \n",mix[1][0][1],mix[1][1][1],mix[1][2][1]);
//printf("mix : %10.9f %10.9f %10.9f \n",mix[2][0][1],mix[2][1][1],mix[2][2][1]);
//abort();
}
/*
* multiply complex 3x3 matrix
* C = A X B
*/
void multiply_complex_matrix(A,B,C)
double A[][3][2];
double B[][3][2];
double C[][3][2];
{
int i,j,k;
for (i=0; i<3; i++) {
for (j=0; j<3; j++) {
for (k=0; k<3; k++) {
C[i][j][re] += A[i][k][re]*B[k][j][re]-A[i][k][im]*B[k][j][im];
C[i][j][im] += A[i][k][im]*B[k][j][re]+A[i][k][re]*B[k][j][im];
}
}
}
}
/*
* multiply complex 3x3 matrix and 3 vector
* W = A X V
*/
void multiply_complex_matvec(A,V,W)
double A[][3][2];
double V[][2];
double W[][2];
{
int i;
for(i=0;i<3;i++) {
W[i][re] = A[i][0][re]*V[0][re]-A[i][0][im]*V[0][im]+
A[i][1][re]*V[1][re]-A[i][1][im]*V[1][im]+
A[i][2][re]*V[2][re]-A[i][2][im]*V[2][im] ;
W[i][im] = A[i][0][re]*V[0][im]+A[i][0][im]*V[0][re]+
A[i][1][re]*V[1][im]+A[i][1][im]*V[1][re]+
A[i][2][re]*V[2][im]+A[i][2][im]*V[2][re] ;
}
}
/*
* copy complex 3x3 matrix
* A --> B
*/
void copy_complex_matrix(A,B)
double A[][3][2];
double B[][3][2];
{
memcpy(B,A,sizeof(double)*18);
}
/*
* clear complex 3x3 matrix
*
*/
void clear_complex_matrix(A)
double A[][3][2];
{
memset(A,0,sizeof(double)*18);
}
/*
* oscillation probability in vacuum (w/o CP effect)
*
* nutype : nue=1, numu=2, nutau=3
* energy : neutrino energy (GeV)
* path : path length (km)
* prob[3] : oscillation prob
*
*/
void get_vacuum_probability(nutype,energy,path,prob)
int nutype ;
double energy, path;
double prob[][3];
{
double lovere ;
double s21, s32, s31, ss21, ss32, ss31 ;
int ista, iend ;
// make more precise 20081003 rvw
lovere= 1.26693281*(path)/(energy);
s21 = sin(dm21*lovere);
s32 = sin(dm32*lovere);
s31 = sin((dm21+dm32)*lovere) ;
ss21 = s21*s21 ;
ss32 = s32*s32 ;
ss31 = s31*s31 ;
/* ista = abs(*nutype) - 1 ; */
for ( ista=0 ; ista<3 ; ista++ ) {
for ( iend=0 ; iend<2 ; iend++ ) {
prob[ista][iend] = mix[ista][0][re]*mix[iend][0][re]*
mix[ista][1][re]*mix[iend][1][re]*ss21;
prob[ista][iend] += mix[ista][1][re]*mix[iend][1][re]*
mix[ista][2][re]*mix[iend][2][re]*ss32;
prob[ista][iend] += mix[ista][2][re]*mix[iend][2][re]*
mix[ista][0][re]*mix[iend][0][re]*ss31;
if ( iend == ista ) {
prob[ista][iend] = 1.0-4.0*prob[ista][iend];
} else {
prob[ista][iend] = -4.0*prob[ista][iend];
}
}
prob[ista][2]=1.0-prob[ista][0]-prob[ista][1];
}
}
// want to output flavor composition of
// pure mass eigenstate, state
void convert_from_mass_eigenstate( state, flavor, pure )
int state;
int flavor;
double pure [][2];
{
int i,j;
double mass [3][2];
double conj [3][3][2];
int lstate = state - 1;
int factor = ( flavor > 0 ? -1. : 1. );
// need the conjugate for neutrinos but not for
// anti-neutrinos
for (i=0; i<3; i++) {
mass[i][0] = ( lstate == i ? 1.0 : 0. );
mass[i][1] = ( 0. );
}
for (i=0; i<3; i++) {
for (j=0; j<3; j++) {
conj[i][j][re] = mix[i][j][re];
conj[i][j][im] = factor*mix[i][j][im];
}
}
multiply_complex_matvec(conj, mass, pure);
}
void conjugate_mixing_matrix()
{
int i, j;
double a[3][3][2];
copy_complex_matrix(mix,a);
for (i=0; i<3; i++){
for (j=0; j<3; j++) {
mix[i][j][re] = a[i][j][re];
mix[i][j][im] = -a[i][j][im];
}
}
}