COSMOS v7.655  COSMOSv7655
(AirShowerMC)
catmosutil.f
Go to the documentation of this file.
1 ! Compute geometrical relation in the spherical env.
2 !
3 ! |
4 ! |
5 ! | / * .
6 ! | / * t .
7 ! | / *.
8 ! | / . * A
9 ! | / t' . *
10 ! | / . L * zenith angle t, t'
11 ! | B /. * at vertical height h and h'
12 ! | . / * H=R0+h Radius of the earth R0
13 ! ^ | ^. / H' * length AB =L
14 ! ^ | / ^ *
15 ! | / *^ H cos(t) - H'cos(t')=L
16 ! | R0 / * ^ H sin(t) = H'sin(t')
17 ! | / * ^ H' = sqrt(L**2 +H**2 - 2LHcos(t))
18 ! | / * ^
19 ! | / *
20 ! |/ ^ cos(t')= (Hcos(t) - L)/H'
21 !
22 ! ^
23 ! sin(t')=Hsin(t)/H'
24 !
25 !
26 ! test program.
27 !
28 ! program testutil
29 ! implicit none
30 ! include '../../Zglobalc.h'
31 ! include 'Zearth.h'
32 !
33 ! real*8 H, sh, cosz, L, hp, cnewcos, cnewsin, cnewh, cost, sint
34 !
35 ! do sh = 0., 30.d3, 10000.
36 ! H = Eradius + sh
37 ! do cosz=1., 0., -0.2
38 ! do L=0., 100.d3, 1000.
39 ! cost = cnewcos(H, cosz, L)
40 ! sint = cnewsin(H, cosz, L)
41 ! if(abs(cost**2 + sint**2 -1.d0) .gt. 1.d-7) then
42 ! write(*,*) ' ***** '
43 ! endif
44 ! write(*, *) cost**2 + sint**2
45 ! hp = cnewh(H, cosz, L) - Eradius
46 ! write(*, *)' h=', sh, ' cosz=', cosz, ' L=', L, ' hp=',hp
47 ! enddo
48 ! enddo
49 ! enddo
50 ! another test; for clenbetween2h
51 !+++++++++++++++++++++++++++++++++++++++++++++++++++
52 ! program testutil
53 ! implicit none
54 !#include "Zearth.h"
55 ! real*8 clenbetween2h, h1, h2, cost, ans, cnewcos
56 ! real*8 costp
57 ! h1 = Eradius + 0.d3
58 ! h2 = Eradius + 100.d3
59 ! cost = 0.7
60 ! ans = clenbetween2h(h1, h2, cost)
61 ! write(*,*) ans
62 ! costp = cnewcos(h1, cost, ans)
63 ! ans = clenbetween2h(h2, h1, -costp)
64 ! write(*,*) ans
65 ! end
66 !c
67 ! ----------------get cos(t')------------------------
68 ! see also cnewcossin
69  real*8 function cnewcos(H, cost, L)
70 !
71  implicit none
72  real*8 H, cost, L
73 !
74  real*8 eps/1.d-8/, tmp
75 
76  tmp = l/h
77  if(tmp .lt. eps) then
78  cnewcos = (cost - tmp) /
79  * ( ( tmp * (1.-cost**2)/2 -cost)*tmp +1.)
80  elseif(abs(cost) .ne. 1.d0) then
81  cnewcos = (cost - tmp)/ sqrt( (tmp - cost*2)*tmp +1.)
82  else
83  cnewcos = cost
84  endif
85  end
86 ! ---------------get sin(t') -----------------------
87  real*8 function cnewsin(H, cost, L)
88  implicit none
89  real*8 H, cost, L
90 !
91  real*8 cnewh, sint
92 
93  sint = sqrt(1.d0 - cost**2)
94  cnewsin = h * sint/ cnewh(h, cost, l)
95  end
96 ! ------------- get H'----------------------------
97  real*8 function cnewh(H, cost, L)
98  implicit none
99  real*8 H, cost, L, tmp
100 
101  real*8 eps/1.d-8/
102 
103  tmp = l/h
104  if(tmp .lt. eps) then
105  cnewh = h * ( (tmp * (1.d0 -cost**2)/2 - cost )* tmp + 1.d0)
106  else
107  cnewh =h* sqrt( ( tmp - cost*2)*tmp + 1.d0 )
108  endif
109  end
110 ! -----------------------------------
111  subroutine cnewcossin(h1, cos1, leng, h2, cos2, sin2)
112  implicit none
113  real*8 h1 ! input. radial distance from the earth center
114  real*8 cos1 ! input. cos of zenith angle at h1
115  real*8 leng ! input. length in m along cos1 from h1
116  real*8 h2 ! output. radial distance from the earth center
117  real*8 cos2 ! outpu. cos of zenith angle at h2.
118  real*8 sin2 ! output. sin of //
119 
120  real*8 sin1, cnewh
121 
122 ! h1 cos1 - h2 cos2 = leng
123 ! h1 sin1 = h2 sin2
124 
125  sin1 = sqrt(1.d0 - cos1**2)
126  h2 = cnewh(h1, cos1, leng)
127  sin2 = h1 * sin1/h2
128  cos2 = (h1*cos1 -leng)/h2
129  end
130 !
131 ! ------------- get L----------------------------
132 ! get length between two points with radius h1
133 ! and h2. The zenith angle at h1 is cost.
134 ! the length has a sing, so that we can reach
135 ! h2 by proceeding the given length
136 ! from h1 with the zenith angle cost
137  real*8 function clenbetween2h(h1, h2, cost)
138  implicit none
139  real*8 h1, h2, cost
140 
141  real*8 sint, costp, sintp
142  character*120 text
143 
144  sint = sqrt(1.d0 - cost**2)
145  sintp = h1*sint /h2
146  if(sintp .le. 1.0d0) then
147 
148  costp = sqrt(1.d0 - sintp**2)*sign(1.d0, cost)
149  else
150  if(abs(1.d0-sintp**2) .lt. 1.d-6) then
151  costp = 0.
152  else
153  write(text, *) 'h1, h2, cost=', h1, h2, cost,
154  * ' sintp=',sintp
155  call cerrormsg(text, 1)
156  call
157  * cerrormsg('h1,h2,cost invalid at clenbetwee2h', 0)
158  endif
159  endif
160 !
161  clenbetween2h = h1* cost - h2 * costp
162  end
163 !
164 ! ------------- get L--- subroutine version with
165 ! return condition ---------
166 ! get length between two points with radius h1
167 ! and h2. The zenith angle at h1 is cost.
168 ! the length has a sing, so that we can reach
169 ! h2 by proceeding the given length
170 ! from h1 with the zenith angle cost
171 ! In some cases, the given condition cannot be
172 ! satisfied. In that case, icon is set to be 1
173 ! Such a case would happen if the track is far away
174 ! from the Earth center.
175  subroutine clenbetw2h(h1, h2, cost, leng, icon)
176  implicit none
177  real*8 h1, h2, cost
178  real*8 leng ! output
179  integer icon ! output
180 
181  real*8 sint, costp, sintp
182  character*120 text
183 
184  sint = sqrt(1.d0 - cost**2)
185  sintp = h1*sint /h2
186  icon = 0
187  if(sintp .le. 1.0d0) then
188  costp = sqrt(1.d0 - sintp**2)*sign(1.d0, cost)
189  leng = h1* cost - h2 * costp
190  else
191  if(abs(1.d0-sintp**2) .lt. 1.d-6) then
192  costp = 0.
193  leng = h1* cost
194  else
195  icon = 1
196  endif
197  endif
198  end
subroutine cerrormsg(msg, needrtn)
Definition: cerrorMsg.f:4
real *8 function cnewsin(H, cost, L)
Definition: catmosutil.f:88
real *8 function clenbetween2h(h1, h2, cost)
Definition: catmosutil.f:138
subroutine cnewcossin(h1, cos1, leng, h2, cos2, sin2)
Definition: catmosutil.f:112
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5
dE dx *! Nuc Int sampling table d
Definition: cblkMuInt.h:130
subroutine clenbetw2h(h1, h2, cost, leng, icon)
Definition: catmosutil.f:176
real *8 function cnewcos(H, cost, L)
Definition: catmosutil.f:70
real *8 function cnewh(H, cost, L)
Definition: catmosutil.f:98