Blame view

Modules/Analytic.py 2.66 KB
8ffbee93   Thomas Fitoussi   Analytic expressi...
1
from Constants import *
f4246390   Thomas Fitoussi   Improve angular d...
2
from numpy import sqrt, abs, cos, sin, arcsin
65135318   Thomas Fitoussi   Reset modules
3
from Read import ReadProfile
7030f150   Thomas Fitoussi   Full reorganisati...
4

8ffbee93   Thomas Fitoussi   Analytic expressi...
5
6
# Value for analytic expression
Ee_default=1e3 #GeV
fb95bd3d   Thomas Fitoussi   Add time delay ve...
7
Egamma_default=1 #GeV
8ffbee93   Thomas Fitoussi   Analytic expressi...
8
9
10
B_default=1e-17 #Gauss
lambda_B_default=0.3 #Mpc

7030f150   Thomas Fitoussi   Full reorganisati...
11
def Analytic_flux(E_ic):
8ffbee93   Thomas Fitoussi   Analytic expressi...
12
   return  me*1e3/4*sqrt(3e9/Ecmb)*1e-9*E_ic**(1/2.) #GeV
7030f150   Thomas Fitoussi   Full reorganisati...
13

8ffbee93   Thomas Fitoussi   Analytic expressi...
14
def Analytic_theta(E_ic,fileId):
65135318   Thomas Fitoussi   Reset modules
15
   Esource,Dsource,B=ReadProfile(fileId,[0,2,4]) #GeV #Mpc #Gauss
8ffbee93   Thomas Fitoussi   Analytic expressi...
16
17
18
19
20
   delta_to_theta=lambda_gg(Esource)/Dsource
   RL0=RL(Esource/2,B)
   Dic0=Dic(Esource/2)
   Ee2= E_ic /Eic(1) #GeV^2 
   delta=Dic0/(2*RL0)*((Esource/2)**2 /Ee2 -1)
65135318   Thomas Fitoussi   Reset modules
21
   return abs(arcsin(delta_to_theta*sin(delta)))
8ffbee93   Thomas Fitoussi   Analytic expressi...
22

fb95bd3d   Thomas Fitoussi   Add time delay ve...
23
def Analytic_delay_vs_theta(theta,fileId):
65135318   Thomas Fitoussi   Reset modules
24
25
26
27
28
29
   Esource,distSource=ReadProfile(fileId,[0,2]) #GeV #Mpc 
   E0_source = Esource*1e-3 #TeV
   lgg = 1.94 #lambda_gg(E0_source)
   delta_ic = arcsin(distSource/lgg*sin(theta))
   Dic0=Dic(E0_source/2)
   c_delta_t = lgg*(1-cos(delta_ic)) - distSource*(1-cos(theta))
fb95bd3d   Thomas Fitoussi   Add time delay ve...
30
31
   return c_delta_t *Mpc/c # sec.

65135318   Thomas Fitoussi   Reset modules
32
33
34
35
36
37
def dt_approx(th):
   lgg = 1.94*Mpc
   D = 131.75*Mpc
   thetamax = arcsin(lgg/D)
   return D**2/lgg /c * th**2 / 2.

fb95bd3d   Thomas Fitoussi   Add time delay ve...
38
def Analytic_delay_vs_Egamma(Egamma, fileId):
65135318   Thomas Fitoussi   Reset modules
39
   Esource,Dsource,B=ReadProfile(fileId,[0,2,4]) #GeV #Mpc #Gauss
fb95bd3d   Thomas Fitoussi   Add time delay ve...
40
41
   RL0=RL(Esource/2,B)
   Dic0=Dic(Esource/2)
65135318   Thomas Fitoussi   Reset modules
42
43
44
45
   E_e = Ee(Egamma)
   delta_ic = Dic0/(2*RL0)*((Esource/2/E_e)**2 -1)
   theta = arcsin(lambda_gg(Esource)/Dsource*sin(delta_ic))
   c_delta_t = lambda_gg(Esource)*(1-cos(delta_ic)) - Dsource*(1-cos(theta))
fb95bd3d   Thomas Fitoussi   Add time delay ve...
46
   return c_delta_t *Mpc/c # sec.
f4246390   Thomas Fitoussi   Improve angular d...
47

8ffbee93   Thomas Fitoussi   Analytic expressi...
48
# Compton accumulation
374f3d52   Thomas Fitoussi   add Weight distri...
49
50
def ECompton_threshold(Compton_threshold = 0.005):
   return Compton_threshold/(4/3*Ecmb/me*1e-3) *me*1e-6 #GeV
8ffbee93   Thomas Fitoussi   Analytic expressi...
51
52
53
54
55
56
57
58
59
60
61

# Compton scattering
def Dic(Ee=Ee_default): # Ee (GeV)
   return 3*(me*1e-6)**2/(4*sigmaT*rhoCMB*1e-9*Ee) /Mpc #Mpc

def lambdaIC():
   return 1/(nCMB*sigmaT*Mpc) #Mpc

def Eic(Ee=Ee_default):
   return 4*Ecmb*Ee**2/(3*me**2)*1e3 #GeV 

fb95bd3d   Thomas Fitoussi   Add time delay ve...
62
63
64
def Ee(Egamma=Egamma_default):
   return sqrt((3*me**2)/(4*Ecmb)*1e-3 *Egamma) #GeV 

8ffbee93   Thomas Fitoussi   Analytic expressi...
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
def tIC():
   return lambdaIC()/(c*yr/Mpc) #yr

# Larmor radius
def RL(Ee=Ee_default,B=B_default):
   return (Ee/erg_to_GeV)/(e*B) /Mpc #Mpc

# Magnetic deflection
def delta(Ee=Ee_default,B=B_default):
   return lambdaIC()/RL(Ee,B)*degre

def Delta(Ee=Ee_default,B=B_default,lambda_B=lambda_B_default):
   Delta1=Dic(Ee)/RL(Ee,B)*degre                #degre if Dic >> lambda_B 
   Delta2=sqrt(Dic(Ee)*lambda_B)/RL(Ee,B)*degre #degre if Dic << lambda_B
   return Delta1, Delta2

# Threshold energy when Dic = RL
def Ethreshold_ic(Ee=Ee_default,B=B_default):
   return Eic(Ee)*Dic(Ee)/RL(Ee,B) # GeV
# Pair production

def Ethreshold_gg():
   return (me)**2/Eebl *1e-3 #GeV

fb95bd3d   Thomas Fitoussi   Add time delay ve...
89
90
def lambda_gg(Egamma=1): # Egamma (GeV)
   return 800. /(Egamma)#Mpc (from Durrer and Neronov 2013)