-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgamma_avg.f90
64 lines (57 loc) · 1.63 KB
/
gamma_avg.f90
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
module gamma_avg
! Functions to determine <gamma> for general and isotropic seed radiation
! fields
use compton
use const
!use zeroin
implicit none
interface
function zeroin(ax,bx,f,tol)
double precision :: ax, bx, tol, zeroin
interface
function f(x)
double precision :: f, x
end function
end interface
end function zeroin
end interface
contains
function gamma_general(eps, eps_s, cos_psi)
! numerical solution of eq. (30)
implicit none
real(dp) :: gamma_general, eps, eps_s, cos_psi
real(dp) :: g_min, g_max, g_th, g_kn
! asymptotic solutions
g_th = sqrt(4*eps_s/(5*eps*(1 - cos_psi)))
g_kn = (4*eps_s)/5
! search region
g_min = max(1.0_dp, min(g_th, g_kn)/10)
g_max = 10*max(g_th, g_kn)
gamma_general = zeroin(g_min, g_max, eq30, epsrel)
contains
function eq30(gg)
implicit none
real(dp) :: eq30, gg
eq30 = eps_s/gg - 1.25_dp*S1(gg*eps*(1 - cos_psi))
end function eq30
end function gamma_general
function gamma_isotropic(eps_s, eps)
! numerical solution of eq. (48)
implicit none
real(dp) :: gamma_isotropic, eps_s, eps
real(dp) :: g_min, g_max, g_th, g_kn
! asymptotic solutions
g_th = sqrt(eps_s/(2*eps))
g_kn = eps_s/0.9419_dp
! search region
g_min = max(1.0_dp, min(g_th, g_kn)/10)
g_max = 10*max(g_th, g_kn)
gamma_isotropic = zeroin(g_min, g_max, eq48, epsrel)
contains
function eq48(gg)
implicit none
real(dp) :: eq48, gg
eq48 = eps_s/gg - 1.5_dp*M1(4*gg*eps)
end function eq48
end function gamma_isotropic
end module gamma_avg