-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolid_angle.f90
52 lines (34 loc) · 865 Bytes
/
solid_angle.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
module solid_angle
use precision, only: dp
implicit none
real(kind=dp), parameter :: pi = 3.14159265359
contains
real(kind=dp) function cc (xx,yy,zz,nn)
implicit none
integer, intent(in) :: xx,yy,zz,nn
real :: x,y,z,n
x = real(xx)
y = real(yy)
z = real(zz)
n = real(nn)
if (zz.ne.0) then
cc = acos(sqrt((n*n)/(x*x+n*n))*cos(atan(y/z)))
else
cc = acos(sqrt((n*n)/(x*x+n*n))*cos(pi/2))
endif
end function cc
real(kind=dp) function ss (xx,yy,zz,nn)
implicit none
integer, intent(in) :: xx,yy,zz,nn
real :: x,y,z,n
x = real(xx)
y = real(yy)
z = real(zz)
n = real(nn)
if (zz.ne.0) then
ss = asin(sqrt((n*n)/(x*x+n*n))*sin(atan(y/z)))
else
ss = asin(sqrt((n*n)/(x*x+n*n))*sin(pi/2))
endif
end function ss
end module solid_angle