-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalch.f90
230 lines (193 loc) · 8.06 KB
/
calch.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
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
!==============================================================================
subroutine calch( s, n, r, h, dhds, dhdr, dhdsr, dhdrr )
!==============================================================================
!
! Compute the metrics for a curved wall.
! Set the functions xloc, yloc and arc for the
! geometry under consideration.
!
! S. Scott Collis
!
! Revised: 9-23-96
!
!==============================================================================
implicit none
integer :: n, i
real :: s, r(n), h(n), dhds(n), dhdr(n), dhdsr(n), dhdrr(n)
real, external :: xloc, yloc
real :: xl, yl, th, bn1, bn2, dxdy, dydx, dxbds, dybds, dx, dy, &
ddxdx, ddydx, ddxdy, ddydy, d2dxdx2, d2dydx2, d2dxdy2, &
d2dydy2, dbn1, dbn2, d2xdy2, d2ydx2, d2xbds2, d2ybds2, &
d2bn1, d2bn2
real :: a(n), b(n), dads(n), dbds(n)
real, parameter :: zero = 0.0, pt5 = 0.5, one = 1.0, onept5 = 1.5, &
two = 2.0, twopt5 = 2.5, three = 3.0, &
infty = 1.0e30
!==============================================================================
if (s.eq.-one) then
! write(*,*) 'WARNING: Curvature is turned off!'
h = one
dhdr = zero
dhds = zero
dhdrr = zero
dhdsr = zero
return
end if
xl = xloc( zero, s )
yl = yloc( xl )
th = atan2( one, yl )
bn1 = -sin(th)
bn2 = cos(th)
! write(*,"(8(e13.6,1x))") s, xl, yl, th, bn1, bn2
if (xl .eq. zero) then
dydx = infty
else
dydx = one / sqrt( two * xl )
end if
dxbds = one / sqrt(one + dydx**2)
if (xl .eq. zero) then
dxdy = zero
else
dxdy = sqrt( two * xl )
end if
dybds = one / sqrt( dxdy**2 + one )
if (xl .eq. zero) then
dx = zero
dy = one
ddxdx = infty
ddydx = zero
ddxdy = one
ddydy = zero
d2dxdx2 = infty
d2dydx2 = zero
d2dxdy2 = zero
d2dydy2 = zero
else
dx = yl
dy = one
ddxdx = one / yl
ddydx = zero
ddxdy = one
ddydy = zero
d2dxdx2 = -sqrt(two)/(two**2 * xl**onept5)
d2dydx2 = zero
d2dxdy2 = zero
d2dydy2 = zero
end if
if ( abs(bn1) .gt. abs(bn2) ) then
dbn1 = ( -ddydy/(dx**2 + dy**2)**pt5 + pt5*dy*(two*dx*ddxdy + &
two*dy*ddydy)/(dx**2 + dy**2)**onept5 ) * dybds
dbn2 = ( ddxdy/(dx**2 + dy**2)**pt5 - pt5*dx*(two*dx*ddxdy + &
two*dy*ddydy)/(dx**2 + dy**2)**onept5 ) * dybds
else
dbn1 = ( -ddydx/(dx**2 + dy**2)**pt5 + pt5*dy*(two*dx*ddxdx + &
two*dy*ddydx)/(dx**2 + dy**2)**onept5 ) * dxbds
dbn2 = ( ddxdx/(dx**2 + dy**2)**pt5 - pt5*dx*(two*dx*ddxdx + &
two*dy*ddydx)/(dx**2 + dy**2)**onept5 ) * dxbds
end if
if ( abs(bn1) .gt. abs(bn2) ) then
d2xdy2 = one
d2ybds2 = -(one + dxdy**2)**(-onept5) * dxdy * d2xdy2 * dybds
d2xbds2 = d2xdy2*(dybds)**2 + dxdy*d2ybds2
else
d2ydx2 = -one / ( two * sqrt(two) * xl**onept5 )
d2xbds2 = -(one + dydx**2)**(-onept5) * dydx * d2ydx2 * dxbds
d2ybds2 = d2ydx2*(dxbds)**2 + dydx*d2xbds2
end if
if ( abs(bn1) .gt. abs(bn2) ) then
d2bn1 = ((ddxdy*(dy*ddxdy-dx*ddydy)+dx*(dy*d2dxdy2-dx*d2dydy2))/ &
(dx**2+dy**2)**(onept5) - &
(three*dx*(dy*ddxdy-dx*ddydy)*(dx*ddxdy+dy*ddydy))/ &
(dx**2+dy**2)**(twopt5))*(dybds)**2 + &
(-ddydy/(dx**2 + dy**2)**pt5 + pt5*dy*(two*dx*ddxdy + &
two*dy*ddydy)/(dx**2 + dy**2)**onept5) * d2ybds2
d2bn2 = ((ddydy*(dy*ddxdy-dx*ddydy)+dy*(dy*d2dxdy2-dx*d2dydy2))/ &
(dx**2+dy**2)**(onept5) - &
(three*dy*(dy*ddxdy-dx*ddydy)*(dx*ddxdy+dy*ddydy))/ &
(dx**2+dy**2)**(twopt5))*(dybds)**2 + &
(ddxdy/(dx**2 + dy**2)**pt5 - pt5*dx*(two*dx*ddxdy + &
two*dy*ddydy)/(dx**2 + dy**2)**onept5) * d2ybds2
else
d2bn1 = ((ddxdx*(dy*ddxdx-dx*ddydx)+dx*(dy*d2dxdx2-dx*d2dydx2))/ &
(dx**2+dy**2)**(onept5) - &
(three*dx*(dy*ddxdx-dx*ddydx)*(dx*ddxdx+dy*ddydx))/ &
(dx**2+dy**2)**(twopt5))*(dxbds)**2 + &
(-ddydx/(dx**2 + dy**2)**pt5 + pt5*dy*(two*dx*ddxdx + &
two*dy*ddydx)/(dx**2 + dy**2)**onept5) * d2xbds2
d2bn2 = ((ddydx*(dy*ddxdx-dx*ddydx)+dy*(dy*d2dxdx2-dx*d2dydx2))/ &
(dx**2+dy**2)**(onept5) - &
(three*dy*(dy*ddxdx-dx*ddydx)*(dx*ddxdx+dy*ddydx))/ &
(dx**2+dy**2)**(twopt5))*(dxbds)**2 + &
(ddxdx/(dx**2 + dy**2)**pt5 - pt5*dx*(two*dx*ddxdx + &
two*dy*ddydx)/(dx**2 + dy**2)**onept5) * d2xbds2
end if
!.... now form the actual metric and metric derivatives
a = dxbds + r * dbn1
b = dybds + r * dbn2
h = sqrt( a**2 + b**2 )
dads = d2xbds2 + r * d2bn1
dbds = d2ybds2 + r * d2bn2
dhds = ( a * dads + b * dbds ) / h
dhdr = ( a * dbn1 + b * dbn2 ) / h
dhdrr = ( -dhdr**2 + dbn1**2 + dbn2**2 ) / h
dhdsr = -dhds / h**2 * ( a * dbn1 + b * dbn2 ) + &
( dads * dbn1 + a * d2bn1 + dbds * dbn2 + b * d2bn2 ) / h
! do i = 1, n
! write(70,10) r(i), h(i), dhds(i), dhdr(i), dhdsr(i), dhdrr(i)
! end do
10 format( 8(1pe13.6,1x) )
return
end
!==============================================================================
function xloc(x, ds)
!==============================================================================
implicit none
real :: xloc, x, ds
real, external :: rtflsp, func
real :: darc, x1
common /distance/ darc, x1
!==============================================================================
darc = ds
x1 = x
xloc = rtflsp(func, x1, x1 + 2.0 * ds, 1.0e-12)
return
end
!==============================================================================
function yloc(x)
!==============================================================================
! For a parabolic cylinder
!==============================================================================
implicit none
real :: yloc, x
!==============================================================================
yloc = sqrt( 2.0 * x )
return
end
!==============================================================================
function func(x)
!==============================================================================
implicit none
real :: func, x
real, external :: arc
real :: darc, x1
common /distance/ darc, x1
!==============================================================================
func = darc - arc(x1,x)
return
end
!==============================================================================
function arc(x1,x2)
!==============================================================================
! For a parabolic cylinder
!==============================================================================
implicit none
real :: arc, x1, x2, xi1, xi2
!==============================================================================
xi1 = sqrt(x1)
xi2 = sqrt(x2)
arc = sqrt(2.0)*0.5*xi2*sqrt(1.0+2.0*xi2**2) + &
0.5*log(sqrt(2.0)*xi2 + sqrt(1.0+2.0*xi2**2))
arc = arc - ( sqrt(2.0)*0.5*xi1*sqrt(1.0+2.0*xi1**2) + &
0.5*log(sqrt(2.0)*xi1 + sqrt(1.0+2.0*xi1**2)) )
return
end