capytaine 2.2.1__cp38-cp38-macosx_14_0_arm64.whl → 2.3__cp38-cp38-macosx_14_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. capytaine/.dylibs/libgcc_s.1.1.dylib +0 -0
  2. capytaine/.dylibs/libgfortran.5.dylib +0 -0
  3. capytaine/.dylibs/libquadmath.0.dylib +0 -0
  4. capytaine/__about__.py +1 -1
  5. capytaine/__init__.py +2 -1
  6. capytaine/bem/airy_waves.py +7 -2
  7. capytaine/bem/problems_and_results.py +78 -34
  8. capytaine/bem/solver.py +127 -39
  9. capytaine/bodies/bodies.py +30 -10
  10. capytaine/bodies/predefined/rectangles.py +2 -0
  11. capytaine/green_functions/FinGreen3D/.gitignore +1 -0
  12. capytaine/green_functions/FinGreen3D/FinGreen3D.f90 +3589 -0
  13. capytaine/green_functions/FinGreen3D/LICENSE +165 -0
  14. capytaine/green_functions/FinGreen3D/Makefile +16 -0
  15. capytaine/green_functions/FinGreen3D/README.md +24 -0
  16. capytaine/green_functions/FinGreen3D/test_program.f90 +39 -0
  17. capytaine/green_functions/LiangWuNoblesse/.gitignore +1 -0
  18. capytaine/green_functions/LiangWuNoblesse/LICENSE +504 -0
  19. capytaine/green_functions/LiangWuNoblesse/LiangWuNoblesseWaveTerm.f90 +751 -0
  20. capytaine/green_functions/LiangWuNoblesse/Makefile +18 -0
  21. capytaine/green_functions/LiangWuNoblesse/README.md +2 -0
  22. capytaine/green_functions/LiangWuNoblesse/test_program.f90 +28 -0
  23. capytaine/green_functions/abstract_green_function.py +55 -3
  24. capytaine/green_functions/delhommeau.py +186 -115
  25. capytaine/green_functions/hams.py +204 -0
  26. capytaine/green_functions/libs/Delhommeau_float32.cpython-38-darwin.so +0 -0
  27. capytaine/green_functions/libs/Delhommeau_float64.cpython-38-darwin.so +0 -0
  28. capytaine/io/bemio.py +14 -2
  29. capytaine/io/mesh_loaders.py +1 -1
  30. capytaine/io/wamit.py +479 -0
  31. capytaine/io/xarray.py +257 -113
  32. capytaine/matrices/linear_solvers.py +1 -1
  33. capytaine/meshes/clipper.py +1 -0
  34. capytaine/meshes/collections.py +11 -1
  35. capytaine/meshes/mesh_like_protocol.py +37 -0
  36. capytaine/meshes/meshes.py +17 -6
  37. capytaine/meshes/symmetric.py +11 -2
  38. capytaine/post_pro/kochin.py +4 -4
  39. capytaine/tools/lists_of_points.py +3 -3
  40. capytaine/tools/prony_decomposition.py +60 -4
  41. capytaine/tools/symbolic_multiplication.py +12 -0
  42. capytaine/tools/timer.py +64 -0
  43. {capytaine-2.2.1.dist-info → capytaine-2.3.dist-info}/METADATA +9 -2
  44. capytaine-2.3.dist-info/RECORD +92 -0
  45. capytaine-2.2.1.dist-info/RECORD +0 -76
  46. {capytaine-2.2.1.dist-info → capytaine-2.3.dist-info}/LICENSE +0 -0
  47. {capytaine-2.2.1.dist-info → capytaine-2.3.dist-info}/WHEEL +0 -0
  48. {capytaine-2.2.1.dist-info → capytaine-2.3.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,3589 @@
1
+ module fingreen3D_module
2
+
3
+ implicit none
4
+
5
+ contains
6
+
7
+ ! ==================================================================================
8
+ !
9
+ ! Purpose: This program computes the three-dimensional free-surface
10
+ ! Green function for finite depth and the derivatives of it
11
+ !
12
+ ! Code Original Author: Yingyi Liu created on 2013.09.07
13
+ !
14
+ ! License:
15
+ !
16
+ ! This routine is part of FinGreen3D.
17
+ !
18
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
19
+ ! under the terms of the GNU Lesser General Public License as published by the
20
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
21
+ ! any later version.
22
+ !
23
+ ! You should have received a copy of the GNU General Public License (either V3
24
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
25
+ !
26
+ ! Modified on:
27
+ !
28
+ ! July 21, 2016
29
+ !
30
+ ! Reference:
31
+ !
32
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
33
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
34
+ ! and management, 2018
35
+ !
36
+ ! Remark: The Green function can be decomposed into following form,
37
+ ! where the rankine part can be evaluated separately
38
+ ! based on the method of Hess and Smith (1964) or Newman (1986)
39
+ ! in constant panel method due to its high singularity
40
+ !
41
+ ! G= 1/r+1/r'+Gw,
42
+ ! where
43
+ ! r: dsqrt((x-x')^2+(y-y')^2+(z-z')^2);
44
+ ! r': dsqrt((x-x')^2+(y-y')^2+(z+z')^2).
45
+ ! Parameters:
46
+ ! Input: RR --- horizontal distance between the field and the source point
47
+ ! ZF --- z, vertical coordinate of the field point
48
+ ! ZP --- z', vertical coordinate of the source point
49
+ ! V --- wave number in deep water,i.e., w^2/g
50
+ ! WVN --- the first elememnt is the positive root of the dispersion
51
+ ! equation V = k*tanh(k*h), the rest elements are the real
52
+ ! roots of the equation um*tanh(um*h)= -V
53
+ ! (w:circular frequency,g:gravity acceleration)
54
+ ! NK --- number of elements in the array WVN
55
+ ! H --- water depth (h>0)
56
+ !
57
+ ! Output: GRN(1) --- value of Green's function
58
+ ! GRN(2) --- derivative of Green's function with respect to R
59
+ ! GRN(3) --- derivative of Green's function with respect to z
60
+ !
61
+ ! Contributors list:
62
+ ! Yingyi Liu
63
+ ! Matthieu Ancellin
64
+ ! to be continued...
65
+ !
66
+ ! ==================================================================================
67
+ !!-------------------------------------------------------------------------------!!
68
+ ! Level-1 (Top-level) driver subroutine !
69
+ !!-------------------------------------------------------------------------------!!
70
+
71
+ SUBROUTINE fingreen3d_routine(RR,ZF,ZP,V,WVN,NK,H,GRN)
72
+
73
+ INTEGER, INTENT(IN) :: NK
74
+ REAL*8,INTENT(IN) :: RR,ZF,ZP,V,WVN(1:NK),H
75
+ COMPLEX*16,INTENT(OUT) :: GRN(3)
76
+
77
+ REAL*8 R,R1,PI4,G,RHP,WK
78
+ COMPLEX*16 FG(3)
79
+
80
+ DATA G,PI4 /9.807D0,12.56637061435917D0/
81
+
82
+ ! Initialize parameters based on the inputs
83
+
84
+ R =DSQRT(RR**2+(ZP-ZF)**2)
85
+ R1 =DSQRT(RR**2+(ZP+ZF)**2)
86
+
87
+ WK=WVN(1)
88
+
89
+ ! Choose an appropriate method to calculate the Green function
90
+ ! based on the value of RHP (R/h)
91
+ !
92
+ RHP=DABS(RR/H)
93
+ IF (RHP.LT.0.0005D0) THEN
94
+ CALL LINTON(RR,ZF,ZP,V,WK,WVN,NK,H,FG)
95
+ ELSEIF (RHP.GE.0.0005D0.AND.RHP.LT.0.05D0) THEN
96
+ CALL PIDCOCK(RR,ZF,ZP,V,WK,WVN,NK,H,FG)
97
+ ELSEIF (RHP.GE.0.05D0.AND.RHP.LT.0.5D0) THEN
98
+ CALL EIGENE(RR,ZF,ZP,WK,WVN,NK,H,FG)
99
+ ELSE
100
+ CALL EIGEN(RR,ZF,ZP,WK,WVN,NK,H,FG)
101
+ ENDIF
102
+
103
+ ! Post-process the Green function's value
104
+ ! if R=0, the value of its derivative with respect to R should be zero
105
+ !
106
+ GRN(:)=DCMPLX(0.D0,0.D0)
107
+
108
+ GRN(1)=FG(1)
109
+ IF(RR.NE.0.0D0) THEN
110
+ GRN(2)=FG(2)
111
+ ELSE
112
+ GRN(2)=DCMPLX(0.D0,0.D0)
113
+ ENDIF
114
+ GRN(3)=FG(3)
115
+
116
+ RETURN
117
+ END SUBROUTINE fingreen3d_routine
118
+
119
+ ! ==================================================================================
120
+ ! Purpose: This subroutine computes roots of the water-wave dispersion equation
121
+ ! in finite water depth, by using a higher-order iterative method
122
+ !
123
+ ! License:
124
+ !
125
+ ! This routine is part of FinGreen3D.
126
+ !
127
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
128
+ ! under the terms of the GNU Lesser General Public License as published by the
129
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
130
+ ! any later version.
131
+ !
132
+ ! You should have received a copy of the GNU General Public License (either V3
133
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
134
+ !
135
+ ! Author:
136
+ !
137
+ ! Yingyi Liu on Mar.23, 2017
138
+ !
139
+ ! Reference:
140
+ !
141
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
142
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
143
+ ! and management, 2018
144
+ !
145
+ ! J.N. Newman
146
+ ! Numerical solutions of the water-wave dispersion relation
147
+ ! Applied Ocean Research 12 (1990) 14-18
148
+ !
149
+ ! Parameters:
150
+ ! Input: NRT --- Integer, the number of roots required
151
+ ! W --- Real, wave angular frequency
152
+ ! H --- Real, water depth (h>0)
153
+ ! Output: WVN --- Real, an array storing roots of the dispersion equation
154
+ ! ==================================================================================
155
+
156
+ SUBROUTINE DISPERSION(WVN,NRT,W,H)
157
+ !
158
+ ! Evaluation of the roots of the following equations
159
+ ! by higher-order iterative method
160
+ ! first root stored in WVN is from Eq. (i)
161
+ ! the rest roots are from Eq. (ii)
162
+ ! i) w*w/g = k tanh ( kh )
163
+ ! ii) -w*w/g = Um tan ( Umh )
164
+ !
165
+
166
+ INTEGER,INTENT(IN):: NRT
167
+ REAL*8,INTENT(IN):: W,H
168
+ REAL*8,INTENT(OUT):: WVN(1:NRT)
169
+ INTEGER I, M
170
+ REAL*8 T,X,U,Y,DNM,G,PI
171
+ REAL*8 FUN,DFUN,D2FUN,TRIAL,EXX
172
+
173
+ DATA G,PI/9.807d0,3.141592653589793d0/
174
+
175
+ !------------------------------------------------------------------
176
+ ! I. calculation of wave number (root of Eq. (i))
177
+ !------------------------------------------------------------------
178
+ !
179
+ ! initialize iteration by an accurate Chebyshev approximation
180
+ ! if y=x, use the approximation directly insteady of iteration
181
+ ! to avoid the singularity in the denomenator of the transcendental
182
+ ! function; otherwise, do the iterative procedure.
183
+ !
184
+ X=W*W*H/G
185
+ IF (X.GT.0.D0.AND.X.LE.2.D0) THEN
186
+ Y=DSQRT(X)*(0.9994D0+0.1701D0*X+0.0305*X*X)
187
+ ELSE
188
+ T=X*DEXP(-2.D0*X)
189
+ Y=X+2.D0*T-6.D0*T*T
190
+ ENDIF
191
+
192
+ IF (DABS(Y-X).LT.1.E-10) THEN
193
+ WVN(1)=X/H
194
+ ELSE
195
+ M=0
196
+ EXX=1.D0
197
+ DO WHILE (EXX.GT.1.0D-10)
198
+ TRIAL=Y
199
+ DNM=TRIAL*TRIAL-X*X
200
+ FUN=DLOG((TRIAL+X)/(TRIAL-X))/2.D0-TRIAL
201
+ DFUN=-X/DNM-1.D0
202
+ D2FUN=2.D0*X*TRIAL/(DNM*DNM)
203
+ Y=TRIAL-FUN/DFUN*(1.D0+(FUN/DFUN)*(D2FUN/DFUN)/2.D0)
204
+ EXX=DABS(Y-TRIAL)
205
+ M=M+1
206
+ ENDDO
207
+ WVN(1)=Y/H
208
+ ENDIF
209
+
210
+ !------------------------------------------------------------------
211
+ ! II. calcultion of roots of Eq. (ii), which characterizes
212
+ ! the evanescene modes in eigenfunction
213
+ !------------------------------------------------------------------
214
+ !
215
+ ! initialize iteration by a suitable starting approximation
216
+ !
217
+ U=3.D0*X/(7.D0+3.D0*X)
218
+ T=0.0159D0+0.1032D0*U+4.3152D0*U*U-2.8768D0*U*U*U
219
+ !
220
+ ! perform iterative procedure to find exact solution of Um (m=1,..NRT-1)
221
+ ! of the transcendental equation Eq. (ii)
222
+ !
223
+ DO I=2,NRT
224
+ M=0
225
+ EXX=1.D0
226
+ DO WHILE (EXX.GT.1.0D-10)
227
+ TRIAL=T
228
+ Y=(I-1)*PI-TRIAL
229
+ DNM=Y*Y+X*X
230
+ FUN=ATAN2(X,Y)-TRIAL
231
+ DFUN=X/DNM-1.D0
232
+ D2FUN=2.D0*X*TRIAL/(DNM*DNM)
233
+ T=TRIAL-FUN/DFUN*(1.D0+(FUN/DFUN)*(D2FUN/DFUN)/2.D0)
234
+ EXX=DABS(T-TRIAL)
235
+ M=M+1
236
+ ENDDO
237
+ Y=(I-1)*PI-T
238
+ WVN(I)=Y/H
239
+ T=T-PI*X/(X*X+PI*I*(PI*(I-1)-T))
240
+ ENDDO
241
+
242
+ END SUBROUTINE DISPERSION
243
+
244
+ !!-------------------------------------------------------------------------------!!
245
+ ! Belows are Level-2 (intermediate-level) subroutines !
246
+ !!-------------------------------------------------------------------------------!!
247
+
248
+ ! ==================================================================================
249
+ ! Purpose: This program computes Green function and its derivatives
250
+ ! using series expansion, without epsilon algorithm, in the region
251
+ ! R/H.GT.0.5. The terms needed is 2~10 to 10^-6 accuracy,
252
+ ! with a maximum number of term 10.
253
+ !
254
+ ! License:
255
+ !
256
+ ! This routine is part of FinGreen3D.
257
+ !
258
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
259
+ ! under the terms of the GNU Lesser General Public License as published by the
260
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
261
+ ! any later version.
262
+ !
263
+ ! You should have received a copy of the GNU General Public License (either V3
264
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
265
+ !
266
+ ! Code Original Author:
267
+ !
268
+ ! Yingyi Liu on Sept 7, 2013
269
+ !
270
+ ! Modified on:
271
+ !
272
+ ! July 21, 2016
273
+ !
274
+ ! Reference:
275
+ !
276
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
277
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
278
+ ! and management, 2018
279
+ !
280
+ ! Parameters:
281
+ ! Input: R --- horizontal distance of the source point and the field point
282
+ ! ZF,ZP --- Z coordinates of the source point and the field point
283
+ ! V --- wave number in deep water , i.e., V= w^2/g
284
+ ! WK --- positive root of the dispersion equation k*tanh(k*h)= V
285
+ ! WVN --- The first elememnt is WK, the rest elements are
286
+ ! the real roots of the equation um*tanh(um*h)= -V
287
+ ! NK --- number of elements in the array WVN
288
+ ! H --- water depth (h>0)
289
+ ! Output: GRN --- Green function value and its derivatives
290
+ !
291
+ ! Contributors list:
292
+ ! Yingyi Liu
293
+ ! to be continued...
294
+ !.
295
+ ! ==================================================================================
296
+
297
+ SUBROUTINE EIGEN(R,ZF,ZP,WK,WVN,NK,H,GRN)
298
+
299
+ INTEGER I,NK,NT
300
+ REAL*8 J0,J1,Y0,Y1,K0,K1
301
+ REAL*8 PI,KM,PM,RM(3)
302
+ REAL*8 SR,SR1,DSRR,DSRZ,DSR1R,DSR1Z
303
+ REAL*8,INTENT(IN)::R,ZF,ZP,H,WK,WVN(1:NK)
304
+
305
+ COMPLEX*16,INTENT(OUT):: GRN(3)
306
+ COMPLEX*16 CI,P0,DP0,NM0
307
+
308
+ DATA PI,CI/3.141592653589793d0,(0.D0,1.0D0)/
309
+
310
+ ! initialize some important parameters
311
+ !
312
+ NT=10
313
+
314
+ NM0=H/2.D0*(1.D0+DSINH(2.D0*WK*H)/(2.D0*WK*H))
315
+ P0=PI/NM0*DCOSH(WK*(ZF+H))*DCOSH(WK*(ZP+H))
316
+ DP0=PI/NM0*DSINH(WK*(ZF+H))*DCOSH(WK*(ZP+H))
317
+
318
+ ! calculate the imaginary part of the Green function
319
+ !
320
+ CALL JY01B(WK*R,J0,J1,Y0,Y1)
321
+
322
+ GRN(1)=P0*(CI*J0-Y0)
323
+ GRN(2)=-WK*P0*(CI*J1-Y1)
324
+ GRN(3)=WK*DP0*(CI*J0-Y0)
325
+
326
+ ! calculate the real part of the Green function
327
+ ! the trunction terms number depends on the value of RHP
328
+ !
329
+ DO I=2,NT
330
+
331
+ KM=WVN(I)
332
+
333
+ PM = 4.D0/(1.D0+DSIN(2.D0*KM*H)/(2.D0*KM*H))/H
334
+
335
+ CALL IK01A(KM*R,K0,K1)
336
+
337
+ RM(1) = PM*K0*DCOS(KM*(ZF+H))*DCOS(KM*(ZP+H))
338
+ RM(2) = -PM*KM*K1*DCOS(KM*(ZF+H))*DCOS(KM*(ZP+H))
339
+ RM(3) = -PM*KM*K0*DSIN(KM*(ZF+H))*DCOS(KM*(ZP+H))
340
+
341
+ GRN(1)= GRN(1)+RM(1)
342
+ GRN(2)= GRN(2)+RM(2)
343
+ GRN(3)= GRN(3)+RM(3)
344
+
345
+ IF (DABS(RM(1)).LT.1.E-6.AND.DABS(RM(2)).LT.1.E-6.AND.DABS(RM(3)).LT.1.E-6) THEN
346
+ EXIT
347
+ ENDIF
348
+
349
+ ENDDO
350
+
351
+ ! exclude the singular terms for the purpose of analytical integration over panels
352
+ !
353
+ SR=DSQRT(R**2+(ZF-ZP)**2)
354
+ SR1=DSQRT(R**2+(ZF+ZP)**2)
355
+
356
+ DSRR=R/SR
357
+ DSRZ=(ZF-ZP)/SR
358
+ DSR1R=R/SR1
359
+ DSR1Z=(ZF+ZP)/SR1
360
+
361
+ GRN(1)=GRN(1)-(1.D0/SR+1.D0/SR1)
362
+ GRN(2)=GRN(2)+(DSRR/SR**2+DSR1R/SR1**2)
363
+ GRN(3)=GRN(3)+(DSRZ/SR**2+DSR1Z/SR1**2)
364
+
365
+ RETURN
366
+ END SUBROUTINE EIGEN
367
+
368
+ ! ==================================================================================
369
+ ! Purpose: This program computes Green function and its derivatives
370
+ ! using series expansion, with epsilon algorithm, in the region
371
+ ! R/H.GT.0.01 and R/H.LT.0.5. The terms needed is 10~80 to
372
+ ! 10^-5 accuracy, with a maximum number of term 80.
373
+ !
374
+ ! License:
375
+ !
376
+ ! This routine is part of FinGreen3D.
377
+ !
378
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
379
+ ! under the terms of the GNU Lesser General Public License as published by the
380
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
381
+ ! any later version.
382
+ !
383
+ ! You should have received a copy of the GNU General Public License (either V3
384
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
385
+ !
386
+ ! Code Original Author:
387
+ !
388
+ ! Yingyi Liu on Sept 7, 2013
389
+ !
390
+ ! Modified on:
391
+ !
392
+ ! July 21, 2016
393
+ !
394
+ ! Reference:
395
+ !
396
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
397
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
398
+ ! and management, 2018
399
+ !
400
+ ! Parameters:
401
+ ! Input: R --- Horizontal distance of the source point and the field point
402
+ ! ZF,ZP --- Z coordinates of the source point and the field point
403
+ ! V --- wave number in deep water , i.e., V= w^2/g
404
+ ! WK --- positive root of the dispersion equation k*tanh(k*h)= V
405
+ ! WVN --- The first elememnt is WK, the rest elements are
406
+ ! the real roots of the equation um*tanh(um*h)= -V
407
+ ! NK --- number of elements in the array WVN
408
+ ! H --- water depth (h>0)
409
+ ! Output: GRN --- Green function value and its derivatives
410
+ !
411
+ ! Contributors list:
412
+ ! Yingyi Liu
413
+ ! to be continued...
414
+ !
415
+ ! ==================================================================================
416
+
417
+ SUBROUTINE EIGENE(R,ZF,ZP,WK,WVN,NK,H,GRN)
418
+
419
+ INTEGER I,NK,NT,I_PADE,K_PADE
420
+ REAL*8 J0,J1,Y0,Y1,K0,K1
421
+ REAL*8 PI,KM,PM,RM(3),RL(3),ERR,RHP
422
+ REAL*8 SR,SR1,DSRR,DSRZ,DSR1R,DSR1Z
423
+ REAL*8 G(0:NK-1),GR(0:NK-1),GZ(0:NK-1)
424
+ REAL*8,INTENT(IN)::R,ZF,ZP,H,WK,WVN(1:NK)
425
+
426
+ COMPLEX*16,INTENT(OUT):: GRN(3)
427
+ COMPLEX*16 CI,P0,DP0,NM0
428
+
429
+ DATA PI,CI/3.141592653589793d0,(0.D0,1.0D0)/
430
+
431
+ ! initialize some important parameters
432
+ !
433
+ RHP=DABS(R/H)
434
+ NT=INT(-88.89*RHP+54.45)
435
+
436
+ NM0=H/2.D0*(1.D0+DSINH(2.D0*WK*H)/(2.D0*WK*H))
437
+ P0=PI/NM0*DCOSH(WK*(ZF+H))*DCOSH(WK*(ZP+H))
438
+ DP0=PI/NM0*DSINH(WK*(ZF+H))*DCOSH(WK*(ZP+H))
439
+
440
+ ! calculate the imaginary part of the Green function
441
+ !
442
+ CALL JY01B(WK*R,J0,J1,Y0,Y1)
443
+
444
+ GRN(1)=P0*(CI*J0-Y0)
445
+ GRN(2)=-WK*P0*(CI*J1-Y1)
446
+ GRN(3)=WK*DP0*(CI*J0-Y0)
447
+
448
+ ! calculate the real part of the Green function
449
+ ! the trunction terms number depends on the value of RHP
450
+ !
451
+ G(0)= 0.D0
452
+ GR(0)= 0.D0
453
+ GZ(0)= 0.D0
454
+
455
+ DO I=2,NT
456
+
457
+ KM=WVN(I)
458
+
459
+ PM = 4.D0/(1.D0+DSIN(2.D0*KM*H)/(2.D0*KM*H))/H
460
+
461
+ CALL IK01A(KM*R,K0,K1)
462
+
463
+ RM(1) = PM*K0*DCOS(KM*(ZF+H))*DCOS(KM*(ZP+H))
464
+ RM(2) = -PM*KM*K1*DCOS(KM*(ZF+H))*DCOS(KM*(ZP+H))
465
+ RM(3) = -PM*KM*K0*DSIN(KM*(ZF+H))*DCOS(KM*(ZP+H))
466
+
467
+ G(I-1)= G(I-2)+RM(1)
468
+ GR(I-1)= GR(I-2)+RM(2)
469
+ GZ(I-1)= GZ(I-2)+RM(3)
470
+
471
+ ENDDO
472
+
473
+ ! call the epsilon algorithm to approximate the limit of the infinite series
474
+ !
475
+ CALL Limes (NT-1,G(0:NT-1),RL(1),I_PADE,K_PADE,ERR)
476
+ CALL Limes (NT-1,GR(0:NT-1),RL(2),I_PADE,K_PADE,ERR)
477
+ CALL Limes (NT-1,GZ(0:NT-1),RL(3),I_PADE,K_PADE,ERR)
478
+
479
+ GRN(1)= GRN(1)+RL(1)
480
+ GRN(2)= GRN(2)+RL(2)
481
+ GRN(3)= GRN(3)+RL(3)
482
+
483
+ ! exclude the singular terms for the purpose of analytical integration over panels
484
+ !
485
+ SR=DSQRT(R**2+(ZF-ZP)**2)
486
+ SR1=DSQRT(R**2+(ZF+ZP)**2)
487
+
488
+ DSRR=R/SR
489
+ DSRZ=(ZF-ZP)/SR
490
+ DSR1R=R/SR1
491
+ DSR1Z=(ZF+ZP)/SR1
492
+
493
+ GRN(1)=GRN(1)-(1.D0/SR+1.D0/SR1)
494
+ GRN(2)=GRN(2)+(DSRR/SR**2+DSR1R/SR1**2)
495
+ GRN(3)=GRN(3)+(DSRZ/SR**2+DSR1Z/SR1**2)
496
+
497
+ RETURN
498
+ END SUBROUTINE EIGENE
499
+
500
+
501
+ ! ==================================================================================
502
+ ! Purpose: This program computes Green function and its derivatives
503
+ ! using Pidcock's method, with epsilon algorithm, in the region
504
+ ! R/H.GT.0.0005 and R/H.LT.0.01. The terms needed is 50~100 to
505
+ ! 10^-4 accuracy, with a maximum number of term 100.
506
+ !
507
+ ! License:
508
+ !
509
+ ! This routine is part of FinGreen3D.
510
+ !
511
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
512
+ ! under the terms of the GNU Lesser General Public License as published by the
513
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
514
+ ! any later version.
515
+ !
516
+ ! You should have received a copy of the GNU General Public License (either V3
517
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
518
+ !
519
+ ! Code Original Author:
520
+ !
521
+ ! Yingyi Liu on Sept 7, 2013
522
+ !
523
+ ! Modified on:
524
+ !
525
+ ! July 21, 2016
526
+ !
527
+ ! Reference:
528
+ !
529
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
530
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
531
+ ! and management, 2018
532
+ !
533
+ ! Parameters:
534
+ ! Input: R --- horizontal distance of the source point and the field point
535
+ ! ZF,ZP --- Z coordinates of the source point and the field point
536
+ ! V --- wave number in deep water , i.e., V= w^2/g
537
+ ! WK --- positive root of the dispersion equation k*tanh(k*h)= V
538
+ ! WVN --- The first elememnt is WK, the rest elements are
539
+ ! the real roots of the equation um*tanh(um*h)= -V
540
+ ! NK --- number of elements in the array WVN
541
+ ! H --- water depth (h>0)
542
+ ! Output: GRN --- Green function value and its derivatives
543
+ !
544
+ ! Contributors list:
545
+ ! Yingyi Liu
546
+ ! to be continued...
547
+ !
548
+ ! ==================================================================================
549
+
550
+ SUBROUTINE PIDCOCK(R,ZF,ZP,V,WK,WVN,NK,H,GRN)
551
+
552
+ INTEGER NK,NT,I,I_PADE,K_PADE
553
+
554
+ REAL*8 J0,J1,Y0,Y1,K0,K0T,K1,K1T
555
+ REAL*8 NM0,P0,DP0,X,PI,GA
556
+ REAL*8 RM(3),SM(3),RL(3),ERR,RHP
557
+ REAL*8 UM,UMT,MP,AC,AM,AMT,DAM,DAMT
558
+ REAL*8 SR,SR1,DSRR,DSRZ,DSR1R,DSR1Z
559
+ REAL*8 G(0:NK-1),GR(0:NK-1),GZ(0:NK-1)
560
+ REAL*8,INTENT(IN)::R,ZF,ZP,H,V,WK,WVN(1:NK)
561
+ !REAL*8,EXTERNAL:: IMGS,DGSR,DGSZ
562
+
563
+ COMPLEX*16,INTENT(OUT):: GRN(3)
564
+ COMPLEX*16 CI
565
+
566
+ DATA PI,GA /3.141592653589793D0,0.5772156649015328D0/
567
+ DATA CI/(0.0D0, 1.0D0)/
568
+
569
+ ! initialize some important parameters
570
+ !
571
+ NM0=H/2.D0*(1.D0+DSINH(2.D0*WK*H)/(2.D0*WK*H))
572
+ P0=PI/NM0*DCOSH(WK*(ZF+H))*DCOSH(WK*(ZP+H))
573
+ DP0=WK*PI/NM0*DSINH(WK*(ZF+H))*DCOSH(WK*(ZP+H))
574
+
575
+ ! calculate the imaginary part of the Green function
576
+ !
577
+ CALL JY01B(WK*R,J0,J1,Y0,Y1)
578
+
579
+ GRN(1)=P0*(CI*J0-Y0)+2.D0/H*(GA+DLOG(R/4.D0/H))
580
+ GRN(2)=-WK*P0*(CI*J1-Y1)+2.D0/(R*H)
581
+ GRN(3)=DP0*(CI*J0-Y0)
582
+
583
+ ! calculate the real part, for the infinite series of Eq.(13)
584
+ ! the series applies an acceleration method by subtracting an asymptotic series
585
+ !
586
+ RHP=DABS(R/H)
587
+ NT=INT(-1010.10*RHP+100.50)
588
+
589
+ G(0)= 0.D0
590
+ GR(0)= 0.D0
591
+ GZ(0)= 0.D0
592
+
593
+ DO I=2,NT
594
+
595
+ MP=(I-1)*PI
596
+ UMT=MP/H
597
+ UM=WVN(I)
598
+ X=UM*R
599
+
600
+ CALL IK01A(X,K0,K1)
601
+ CALL IK01A(UMT*R,K0T,K1T)
602
+
603
+ AC=(UM**2+V**2)/((UM**2+V**2)*H-V)
604
+ AM=AC*DCOS(UM*(ZF+H))*DCOS(UM*(ZP+H))
605
+ AMT=DCOS(UMT*(ZF+H))*DCOS(UMT*(ZP+H))/H
606
+ DAM=-UM*AC*DSIN(UM*(ZF+H))*DCOS(UM*(ZP+H))
607
+ DAMT=-UMT*DSIN(UMT*(ZF+H))*DCOS(UMT*(ZP+H))/H
608
+
609
+ RM(1)= AM*K0-AMT*K0T
610
+ RM(2)= -UM*AM*K1+UMT*AMT*K1T
611
+ RM(3)= DAM*K0-DAMT*K0T
612
+
613
+ G(I-1)= G(I-2)+RM(1)
614
+ GR(I-1)= GR(I-2)+RM(2)
615
+ GZ(I-1)= GZ(I-2)+RM(3)
616
+
617
+ ENDDO
618
+
619
+ ! call the epsilon algorithm to approximate the limit of the infinite series
620
+ !
621
+ CALL Limes (NT-1,G(0:NT-1),RL(1),I_PADE,K_PADE,ERR)
622
+ CALL Limes (NT-1,GR(0:NT-1),RL(2),I_PADE,K_PADE,ERR)
623
+ CALL Limes (NT-1,GZ(0:NT-1),RL(3),I_PADE,K_PADE,ERR)
624
+
625
+ SM(1)= 4.D0*RL(1)
626
+ SM(2)= 4.D0*RL(2)
627
+ SM(3)= 4.D0*RL(3)
628
+
629
+ ! calculate the sum of Rankine terms by Chebyshev approximations
630
+ !
631
+ GRN(1)=GRN(1)+SM(1)+IMGS(R,ZF,ZP,H)
632
+ GRN(2)=GRN(2)+SM(2)+DGSR(R,ZF,ZP,H)
633
+ GRN(3)=GRN(3)+SM(3)+DGSZ(R,ZF,ZP,H)
634
+
635
+ ! exclude the singular terms for the purpose of analytical integration over panels
636
+ !
637
+ SR=DSQRT(R**2+(ZF-ZP)**2)
638
+ SR1=DSQRT(R**2+(ZF+ZP)**2)
639
+
640
+ DSRR=R/SR
641
+ DSRZ=(ZF-ZP)/SR
642
+ DSR1R=R/SR1
643
+ DSR1Z=(ZF+ZP)/SR1
644
+
645
+ GRN(1)=GRN(1)-(1.D0/SR+1.D0/SR1)
646
+ GRN(2)=GRN(2)+(DSRR/SR**2+DSR1R/SR1**2)
647
+ GRN(3)=GRN(3)+(DSRZ/SR**2+DSR1Z/SR1**2)
648
+
649
+ RETURN
650
+ END SUBROUTINE PIDCOCK
651
+
652
+
653
+ ! ==================================================================================
654
+ ! Purpose: This program computes Green function and its derivatives
655
+ ! using Linton's method, with epsilon algorithm, in the region
656
+ ! R/H.LT.0.0005. The terms needed is about 3~10 to
657
+ ! 10^-6 accuracy, with a maximum number of term 10.
658
+ !
659
+ ! License:
660
+ !
661
+ ! This routine is part of FinGreen3D.
662
+ !
663
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
664
+ ! under the terms of the GNU Lesser General Public License as published by the
665
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
666
+ ! any later version.
667
+ !
668
+ ! You should have received a copy of the GNU General Public License (either V3
669
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
670
+ !
671
+ ! Code Original Author:
672
+ !
673
+ ! Yingyi Liu on Sept 7, 2013
674
+ !
675
+ ! Modified on:
676
+ !
677
+ ! July 21, 2016
678
+ !
679
+ ! Reference:
680
+ !
681
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
682
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
683
+ ! and management, 2018
684
+ !
685
+ ! Parameters:
686
+ ! Input: R --- horizontal distance of the source point and the field point
687
+ ! ZF,ZP --- Z coordinates of the source point and the field point
688
+ ! V --- wave number in deep water , i.e., V= w^2/g
689
+ ! WK --- positive root of the dispersion equation k*tanh(k*h)= V
690
+ ! WVNO --- The first elememnt is WK, the rest elements are
691
+ ! the real roots of the equation um*tanh(um*h)= -V
692
+ ! NK --- number of elements in the array WVNO
693
+ ! H --- water depth (h>0)
694
+ ! Output: GRN --- Green function value and its derivatives
695
+ !
696
+ ! Contributors list:
697
+ ! Yingyi Liu
698
+ ! to be continued...
699
+ !
700
+ ! ==================================================================================
701
+
702
+ SUBROUTINE LINTON(R,ZF,ZP,V,WK,WVNO,NK,H,GRN)
703
+
704
+ INTEGER NK,NT,I,FLAG
705
+ REAL*8 PA,A,PI,EPS,SQPI
706
+ REAL*8 SR,SR1,SR2,DSRR,DSRZ,DSR1R,DSR1Z,DSR2R,DSR2Z
707
+ REAL*8 RO(4),DROR(4),DROZ(4),ERRSUM(3),BJ0,BJ1
708
+ REAL*8 COF(NK),DCOF(NK)
709
+ REAL*8,INTENT(IN)::R,ZF,ZP,H,V,WK,WVNO(NK)
710
+ COMPLEX*16,INTENT(OUT):: GRN(3)
711
+ COMPLEX*16 KM,RM(3),CI
712
+ !REAL*8,EXTERNAL:: ERFCC,DERFCC,AQUADF,G3,G1,G2,FAC,F2
713
+ !COMPLEX*16,EXTERNAL::NM
714
+
715
+ DATA PI,EPS/3.141592653589793D0,1.E-6/
716
+ DATA CI/(0.0D0, 1.0D0)/
717
+
718
+ SQPI=DSQRT(PI)
719
+
720
+ !-----------------------------------------------------------------------------
721
+ ! I. Optimal selection of the parameter A
722
+ !-----------------------------------------------------------------------------
723
+
724
+ FLAG=2
725
+
726
+ IF (FLAG.EQ.1) THEN
727
+ A=0.25D0
728
+ ELSEIF(FLAG.EQ.2) THEN
729
+ IF (V.LT.0.02D0) THEN
730
+ A=3324.2D0*V**3-258.89D0*V**2+8.3958D0*V+1.3208D0
731
+ ELSEIF (V.LT.0.1D0) THEN
732
+ A=-30.303D0*V**3-2.8138D0*V**2+2.7740D0*V+0.05052D0
733
+ ELSEIF (V.LT.1.0D0) THEN
734
+ A=1.5699D0*V**3-2.5075D0*V**2+1.8316D0*V+0.1077D0
735
+ ELSE
736
+ A=-0.000069641D0*V**3-0.0017082D0*V**2+0.45566D0*V+0.80551D0
737
+ ENDIF
738
+ A=DABS(A)/(WK*H)
739
+ ENDIF
740
+ !
741
+ ! PRINT*,A
742
+ !
743
+ !-----------------------------------------------------------------------------
744
+ ! II. Initialisation of various parameters
745
+ !-----------------------------------------------------------------------------
746
+
747
+ PA=A*H
748
+ SR=DSQRT(R**2+(ZF-ZP)**2)
749
+ SR1=DSQRT(R**2+(2.D0*H+ZF+ZP)**2)
750
+ SR2=DSQRT(R**2+(ZF+ZP)**2)
751
+
752
+ CALL RCHI(R,ZF,ZP,H,RO,DROR,DROZ)
753
+
754
+ DSRR=R/SR
755
+ DSRZ=(ZF-ZP)/SR
756
+ DSR1R=R/SR1
757
+ DSR1Z=(2.D0*H+ZF+ZP)/SR1
758
+ DSR2R=R/SR2
759
+ DSR2Z=(ZF+ZP)/SR2
760
+ !
761
+ !-----------------------------------------------------------------------------
762
+ ! III. Calculating the part of evanescent modes
763
+ !-----------------------------------------------------------------------------
764
+
765
+ GRN(:) = (0.0D0, 0.0D0)
766
+ NT=20
767
+
768
+ CALL COEF(R,PA,A,NT,WVNO,WK,COF)
769
+ CALL DCOEF(R,PA,A,NT,WVNO,WK,DCOF)
770
+
771
+ DO I=1,NT
772
+
773
+ IF (I.EQ.1) THEN
774
+ KM=-CI*WK
775
+ ELSE
776
+ KM=WVNO(I)
777
+ ENDIF
778
+
779
+ RM(1)= -COF(I)/NM(H,KM)*CDCOS(KM*(ZF+H))*CDCOS(KM*(ZP+H))
780
+ RM(2)= -DCOF(I)/NM(H,KM)*CDCOS(KM*(ZF+H))*CDCOS(KM*(ZP+H))
781
+ RM(3)= COF(I)*KM/NM(H,KM)*CDSIN(KM*(ZF+H))*CDCOS(KM*(ZP+H))
782
+
783
+ GRN(1)= GRN(1)+RM(1)
784
+ GRN(2)= GRN(2)+RM(2)
785
+ GRN(3)= GRN(3)+RM(3)
786
+
787
+
788
+ IF (I.GT.2.AND.CDABS(RM(1)).LT.EPS.AND.CDABS(RM(2)).LT.EPS.AND.CDABS(RM(3)).LT.EPS) THEN
789
+ EXIT
790
+ ENDIF
791
+
792
+ ENDDO
793
+ !
794
+ !-----------------------------------------------------------------------------
795
+ ! IV. Calculating the part of Error functions
796
+ !-----------------------------------------------------------------------------
797
+
798
+ ERRSUM(:)=0.D0
799
+
800
+ DO I=1,4
801
+
802
+ ERRSUM(1)=ERRSUM(1)+ERFCC(RO(I)/PA)/(4.D0*PI*RO(I))
803
+ ERRSUM(2)=ERRSUM(2)+(DERFCC(RO(I)/PA)/PA*DROR(I)*RO(I)-DROR(I)*ERFCC(RO(I)/PA))/(4.D0*PI*RO(I)**2)
804
+ ERRSUM(3)=ERRSUM(3)+(DERFCC(RO(I)/PA)/PA*DROZ(I)*RO(I)-DROZ(I)*ERFCC(RO(I)/PA))/(4.D0*PI*RO(I)**2)
805
+
806
+ ENDDO
807
+
808
+
809
+ IF (DABS(SR).GT.1.E-6) THEN
810
+
811
+ ERRSUM(1)=ERRSUM(1)+(ERFCC(SR/PA)-1.D0)/(4.D0*PI*SR)+ERFCC(SR1/PA)/(4.D0*PI*SR1)-1.D0/(4.D0*PI*SR2)
812
+ ERRSUM(2)=ERRSUM(2)-(ERFCC(SR/PA)-1.D0)/(4.D0*PI*SR**2)*DSRR+DERFCC(SR/PA)/(4.D0*PI*SR*PA)*DSRR-ERFCC(SR1/PA) &
813
+ /(4.D0*PI*SR1**2)*DSR1R+DERFCC(SR1/PA)/(4.D0*PI*SR1*PA)*DSR1R+DSR2R/(4.D0*PI*SR2**2)
814
+ ERRSUM(3)=ERRSUM(3)-(ERFCC(SR/PA)-1.D0)/(4.D0*PI*SR**2)*DSRZ+DERFCC(SR/PA)/(4.D0*PI*SR*PA)*DSRZ-ERFCC(SR1/PA) &
815
+ /(4.D0*PI*SR1**2)*DSR1Z+DERFCC(SR1/PA)/(4.D0*PI*SR1*PA)*DSR1Z+DSR2Z/(4.D0*PI*SR2**2)
816
+
817
+ ELSE
818
+
819
+ ERRSUM(1)=ERRSUM(1)+ERFCC(SR1/PA)/(4.D0*PI*SR1)-1.D0/(4.D0*PI*SR2)
820
+ ERRSUM(2)=ERRSUM(2)-ERFCC(SR1/PA)/(4.D0*PI*SR1**2)*DSR1R+DERFCC(SR1/PA)/(4.D0*PI*SR1*PA)*DSR1R+DSR2R/(4.D0*PI*SR2**2)
821
+ ERRSUM(3)=ERRSUM(3)-ERFCC(SR1/PA)/(4.D0*PI*SR1**2)*DSR1Z+DERFCC(SR1/PA)/(4.D0*PI*SR1*PA)*DSR1Z+DSR2Z/(4.D0*PI*SR2**2)
822
+
823
+ ENDIF
824
+ !
825
+ !-----------------------------------------------------------------------------
826
+ ! V. Calculating the part of integration
827
+ !-----------------------------------------------------------------------------
828
+
829
+ GRN(1)= GRN(1)-ERRSUM(1)-V/2.D0/PI*AQUADF(V,R,ZF,ZP,H,0.D0,PA/2.D0,EPS,1)
830
+ GRN(2)= GRN(2)-ERRSUM(2)+V/2.D0/PI*AQUADF(V,R,ZF,ZP,H,0.D0,PA/2.D0,EPS,2)
831
+ GRN(3)= GRN(3)-ERRSUM(3)-V/2.D0/PI*AQUADF(V,R,ZF,ZP,H,0.D0,PA/2.D0,EPS,3)
832
+
833
+
834
+ CALL JY01BJ(WK*R,BJ0,BJ1)
835
+
836
+
837
+ KM=-CI*WK
838
+ GRN(1)= GRN(1)-CI/4.D0/NM(H,KM)*BJ0*DCOSH(WK*(ZF+H))*DCOSH(WK*(ZP+H))
839
+ GRN(2)= GRN(2)+CI*WK/4.D0/NM(H,KM)*BJ1*DCOSH(WK*(ZF+H))*DCOSH(WK*(ZP+H))
840
+ GRN(3)= GRN(3)-CI*WK/4.D0/NM(H,KM)*BJ0*DSINH(WK*(ZF+H))*DCOSH(WK*(ZP+H))
841
+
842
+
843
+ GRN(1)= -4.D0*PI*GRN(1)
844
+ GRN(2)= -4.D0*PI*GRN(2)
845
+ GRN(3)= -4.D0*PI*GRN(3)
846
+
847
+
848
+ RETURN
849
+ END SUBROUTINE LINTON
850
+
851
+ !!-------------------------------------------------------------------------------!!
852
+ ! Belows are Level-3 (low level) self-contained subroutines !
853
+ !!-------------------------------------------------------------------------------!!
854
+
855
+ ! ==================================================================================
856
+ ! Purpose: This program computes Rankine image source
857
+ !
858
+ ! License:
859
+ !
860
+ ! This routine is part of FinGreen3D.
861
+ !
862
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
863
+ ! under the terms of the GNU Lesser General Public License as published by the
864
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
865
+ ! any later version.
866
+ !
867
+ ! You should have received a copy of the GNU General Public License (either V3
868
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
869
+ !
870
+ ! Code Original Author:
871
+ !
872
+ ! Yingyi Liu on Sept 7, 2013
873
+ !
874
+ ! Modified on:
875
+ !
876
+ ! July 21, 2016
877
+ !
878
+ ! Reference:
879
+ !
880
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
881
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
882
+ ! and management, 2018
883
+ !
884
+ ! Parameters:
885
+ ! Input: R --- horizontal distance of the source point and the field point
886
+ ! ZF,ZP --- Z coordinates of the source point and the field point
887
+ ! H --- water depth (h>0)
888
+ ! Output: IMGS --- value of the Rankine image source in Pidcock's method
889
+ !
890
+ ! Contributors list:
891
+ ! Yingyi Liu
892
+ ! to be continued...
893
+ !
894
+ ! ==================================================================================
895
+
896
+ REAL*8 FUNCTION IMGS(R,ZF,ZP,H)
897
+
898
+ INTEGER L,M,N
899
+ REAL*8 R,ZF,ZP,H,AMN(0:4,0:4)
900
+ REAL*8 T1,T2,T3,SUM1,SUM2
901
+ !REAL*8,EXTERNAL::RS
902
+
903
+ DATA AMN /0.D0,-0.02525711D0,0.00086546D0,-0.00004063D0, &
904
+ 0.00000193D0,0.05051418D0,-0.00692380D0,0.00073292D0, &
905
+ -0.00006636D0,0.00000398D0,0.00230838D0,-0.00097875D0, &
906
+ 0.00020597D0,-0.00003333D0,0.00000524D0,0.00012934D0, &
907
+ -0.00010879D0,0.00003965D0,-0.00000891D0,0.0D0, &
908
+ 0.00000913D0,-0.00001270D0,0.00000466D0,0.0D0,0.D0/
909
+
910
+ T1=R/H
911
+ T2=(ZF-ZP)/H
912
+ T3=(ZF+ZP+2.D0*H)/H
913
+
914
+ SUM1=0.D0
915
+ DO L=-1,1
916
+ SUM1=SUM1+1.D0/RS(T1,T2+2.D0*L)+1.D0/RS(T1,T3+2.D0*L)
917
+ ENDDO
918
+
919
+ SUM2=0.D0
920
+ DO M=0,4
921
+ DO N=0,4
922
+ SUM2=SUM2+AMN(M,N)*T1**(2.D0*M)*(T2**(2.D0*N)+T3**(2.D0*N))
923
+ ENDDO
924
+ ENDDO
925
+
926
+ IMGS=(SUM1-2.D0+SUM2)/H
927
+
928
+ RETURN
929
+ END FUNCTION IMGS
930
+
931
+
932
+ ! ==================================================================================
933
+ ! Purpose: This program computes the derivative of Rankine image source
934
+ ! with respect to R
935
+ !
936
+ ! License:
937
+ !
938
+ ! This routine is part of FinGreen3D.
939
+ !
940
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
941
+ ! under the terms of the GNU Lesser General Public License as published by the
942
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
943
+ ! any later version.
944
+ !
945
+ ! You should have received a copy of the GNU General Public License (either V3
946
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
947
+ !
948
+ ! Code Original Author:
949
+ !
950
+ ! Yingyi Liu on Sept 7, 2013
951
+ !
952
+ ! Modified on:
953
+ !
954
+ ! July 21, 2016
955
+ !
956
+ ! Reference:
957
+ !
958
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
959
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
960
+ ! and management, 2018
961
+ !
962
+ ! Parameters:
963
+ ! Input: R --- horizontal distance of the source point and the field point
964
+ ! ZF,ZP --- Z coordinates of the source point and the field point
965
+ ! H --- water depth (h>0)
966
+ ! Output: DGSR --- derivative of the Rankine image source with respect to R
967
+ !
968
+ ! Contributors list:
969
+ ! Yingyi Liu
970
+ ! to be continued...
971
+ !
972
+ ! ==================================================================================
973
+
974
+ REAL*8 FUNCTION DGSR(R,ZF,ZP,H)
975
+
976
+ INTEGER L,M,N
977
+ REAL*8 R,ZF,ZP,H,AMN(0:4,0:4)
978
+ REAL*8 T1,T2,T3,SUM1,SUM2
979
+ !REAL*8,EXTERNAL::RS
980
+
981
+ DATA AMN /0.D0,-0.02525711D0,0.00086546D0,-0.00004063D0, &
982
+ 0.00000193D0,0.05051418D0,-0.00692380D0,0.00073292D0, &
983
+ -0.00006636D0,0.00000398D0,0.00230838D0,-0.00097875D0, &
984
+ 0.00020597D0,-0.00003333D0,0.00000524D0,0.00012934D0, &
985
+ -0.00010879D0,0.00003965D0,-0.00000891D0,0.0D0, &
986
+ 0.00000913D0,-0.00001270D0,0.00000466D0,0.0D0,0.D0/
987
+
988
+ T1=R/H
989
+ T2=(ZF-ZP)/H
990
+ T3=(ZF+ZP+2.D0*H)/H
991
+
992
+ SUM1=0.D0
993
+ DO L=-1,1
994
+ SUM1=SUM1+T1/(RS(T1,T2+2.D0*L))**3+T1/(RS(T1,T3+2.D0*L))**3
995
+ ENDDO
996
+
997
+ SUM2=0.D0
998
+ DO M=1,4
999
+ DO N=0,4
1000
+ SUM2=SUM2+2.D0*M*AMN(M,N)*T1**(2.D0*M-1.D0)*(T2**(2.D0*N)+T3**(2.D0*N))
1001
+ ENDDO
1002
+ ENDDO
1003
+
1004
+ DGSR=(-SUM1+SUM2)/H**2
1005
+
1006
+ RETURN
1007
+ END FUNCTION DGSR
1008
+
1009
+ ! ==================================================================================
1010
+ ! Purpose: This program computes the derivative of Rankine image source
1011
+ ! with respect to z
1012
+ !
1013
+ ! License:
1014
+ !
1015
+ ! This routine is part of FinGreen3D.
1016
+ !
1017
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
1018
+ ! under the terms of the GNU Lesser General Public License as published by the
1019
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
1020
+ ! any later version.
1021
+ !
1022
+ ! You should have received a copy of the GNU General Public License (either V3
1023
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
1024
+ !
1025
+ ! Code Original Author:
1026
+ !
1027
+ ! Yingyi Liu on Sept 7, 2013
1028
+ !
1029
+ ! Modified on:
1030
+ !
1031
+ ! July 21, 2016
1032
+ !
1033
+ ! Reference:
1034
+ !
1035
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
1036
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
1037
+ ! and management, 2018
1038
+ !
1039
+ ! Parameters:
1040
+ ! Input: R --- horizontal distance of the source point and the field point
1041
+ ! ZF,ZP --- Z coordinates of the source point and the field point
1042
+ ! H --- water depth (h>0)
1043
+ ! Output: DGSZ --- derivative of the Rankine image source with respect to z
1044
+ !
1045
+ ! Contributors list:
1046
+ ! Yingyi Liu
1047
+ ! to be continued...
1048
+ !
1049
+ ! ==================================================================================
1050
+
1051
+ REAL*8 FUNCTION DGSZ(R,ZF,ZP,H)
1052
+
1053
+ INTEGER L,M,N
1054
+ REAL*8 R,ZF,ZP,H,AMN(0:4,0:4)
1055
+ REAL*8 T1,T2,T3,SUM1,SUM2
1056
+ !REAL*8,EXTERNAL::RS
1057
+
1058
+ DATA AMN /0.D0,-0.02525711D0,0.00086546D0,-0.00004063D0, &
1059
+ 0.00000193D0,0.05051418D0,-0.00692380D0,0.00073292D0, &
1060
+ -0.00006636D0,0.00000398D0,0.00230838D0,-0.00097875D0, &
1061
+ 0.00020597D0,-0.00003333D0,0.00000524D0,0.00012934D0, &
1062
+ -0.00010879D0,0.00003965D0,-0.00000891D0,0.0D0, &
1063
+ 0.00000913D0,-0.00001270D0,0.00000466D0,0.0D0,0.D0/
1064
+
1065
+ T1=R/H
1066
+ T2=(ZF-ZP)/H
1067
+ T3=(ZF+ZP+2.D0*H)/H
1068
+
1069
+ SUM1=0.D0
1070
+ DO L=-1,1
1071
+ SUM1=SUM1+(T2+2.D0*L)/(RS(T1,T2+2.D0*L))**3+(T3+2.D0*L)/(RS(T1,T3+2.D0*L))**3
1072
+ ENDDO
1073
+
1074
+ SUM2=0.D0
1075
+ DO M=0,4
1076
+ DO N=1,4
1077
+ SUM2=SUM2+2.D0*N*AMN(M,N)*T1**(2.D0*M)*(T2**(2.D0*N-1.D0)+T3**(2.D0*N-1.D0))
1078
+ ENDDO
1079
+ ENDDO
1080
+
1081
+ DGSZ=(-SUM1+SUM2)/H**2
1082
+
1083
+ RETURN
1084
+ END FUNCTION DGSZ
1085
+
1086
+ !
1087
+ ! ======================================================
1088
+ ! Function Dsqrt(R^2+Z^2)
1089
+ ! ======================================================
1090
+
1091
+ REAL*8 FUNCTION RS(R,Z)
1092
+
1093
+ REAL*8 R,Z
1094
+
1095
+ RS=DSQRT(R**2+Z**2)
1096
+
1097
+
1098
+ RETURN
1099
+ END FUNCTION RS
1100
+
1101
+
1102
+ ! ==================================================================================
1103
+ ! Purpose: This program computes the expansion coefficients in
1104
+ ! Linton's method
1105
+ !
1106
+ ! License:
1107
+ !
1108
+ ! This routine is part of FinGreen3D.
1109
+ !
1110
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
1111
+ ! under the terms of the GNU Lesser General Public License as published by the
1112
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
1113
+ ! any later version.
1114
+ !
1115
+ ! You should have received a copy of the GNU General Public License (either V3
1116
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
1117
+ !
1118
+ ! Code Original Author:
1119
+ !
1120
+ ! Yingyi Liu on Sept 7, 2013
1121
+ !
1122
+ ! Modified on:
1123
+ !
1124
+ ! July 21, 2016
1125
+ !
1126
+ ! Reference:
1127
+ !
1128
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
1129
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
1130
+ ! and management, 2018
1131
+ !
1132
+ ! Parameters:
1133
+ ! Input: R --- horizontal distance of the source point and the field point
1134
+ ! PA --- a key parameter determining convergence, i.e., PA= a*h
1135
+ ! A --- a key parameter related with convergence
1136
+ ! M --- number of elements in the array WVNO
1137
+ ! WVNO --- The first elememnt is WK, the rest elements are
1138
+ ! the real roots of the equation um*tanh(um*h)= -V
1139
+ ! WK --- positive root of the dispersion equation k*tanh(k*h)= V
1140
+ ! Output: COF --- expansion coefficients in Linton's expression
1141
+ !
1142
+ ! Contributors list:
1143
+ ! Yingyi Liu
1144
+ ! to be continued...
1145
+ !
1146
+ ! ==================================================================================
1147
+
1148
+ SUBROUTINE COEF(R,PA,A,M,WVNO,WK,COF)
1149
+
1150
+ INTEGER I
1151
+ INTEGER,INTENT(IN)::M
1152
+ REAL*8,INTENT(IN)::R,PA,A,WVNO(M),WK
1153
+ REAL*8,INTENT(OUT)::COF(M)
1154
+ !REAL*8,EXTERNAL:: SA0,AQUAD,SAM,F1
1155
+ REAL*8 BY0,DNT,EPS,STEP,P1,E1,EI
1156
+ REAL*8 PI
1157
+
1158
+ DATA PI/3.141592653589793D0/
1159
+
1160
+ EPS=1.E-6
1161
+ STEP=100.D0
1162
+ DNT=PA**2/4.D0
1163
+
1164
+ ! calculate the first expansion coefficient A0
1165
+ !
1166
+ IF (DABS(R).LT.1.E-6) THEN
1167
+
1168
+ CALL EIX(WK**2*DNT,EI)
1169
+ COF(1)=-EI/4.D0/PI
1170
+
1171
+ ELSEIF (R/A.LE.0.5D0) THEN
1172
+
1173
+ COF(1)=SA0(R,PA,WK)
1174
+
1175
+ ELSE
1176
+
1177
+ CALL JY01BY0(WK*R,BY0)
1178
+ COF(1)=-BY0/4.D0-AQUAD(R,WK,1,0.0D0,DNT,EPS,1)
1179
+
1180
+ ENDIF
1181
+
1182
+ ! calculate the rest expansion coefficients Ai (i=2,m)
1183
+ ! the truncation terms number depends on whether the series
1184
+ ! converged to a specified accuracy or not
1185
+
1186
+ DO I=2,M
1187
+
1188
+ IF (DABS(R).LT.1.E-6) THEN
1189
+
1190
+ CALL E1XA(WVNO(I)**2*DNT,E1)
1191
+ COF(I)=E1/4.D0/PI
1192
+
1193
+ ELSEIF (R/A.LE.1.D0) THEN
1194
+
1195
+ COF(I)=SAM(R,PA,WVNO(I))
1196
+
1197
+ ELSE
1198
+
1199
+ P1=DNT+STEP
1200
+ DO WHILE (DABS(F1(R,WVNO(I),I,P1)).GT.EPS)
1201
+ P1=P1+STEP
1202
+ ENDDO
1203
+
1204
+ COF(I)=AQUAD(R,WVNO(I),I,DNT,P1,EPS,1)
1205
+
1206
+ ENDIF
1207
+
1208
+ ENDDO
1209
+
1210
+
1211
+ RETURN
1212
+ END SUBROUTINE COEF
1213
+
1214
+ ! ==================================================================================
1215
+ ! Purpose: This program computes derivative of the expansion coefficients
1216
+ ! with respect to R in Linton's method
1217
+ !
1218
+ ! License:
1219
+ !
1220
+ ! This routine is part of FinGreen3D.
1221
+ !
1222
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
1223
+ ! under the terms of the GNU Lesser General Public License as published by the
1224
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
1225
+ ! any later version.
1226
+ !
1227
+ ! You should have received a copy of the GNU General Public License (either V3
1228
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
1229
+ !
1230
+ ! Code Original Author:
1231
+ !
1232
+ ! Yingyi Liu on Sept 7, 2013
1233
+ !
1234
+ ! Modified on:
1235
+ !
1236
+ ! July 21, 2016
1237
+ !
1238
+ ! Reference:
1239
+ !
1240
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
1241
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
1242
+ ! and management, 2018
1243
+ !
1244
+ ! Parameters:
1245
+ ! Input: R --- horizontal distance of the source point and the field point
1246
+ ! PA --- a key parameter determining convergence, i.e., PA= a*h
1247
+ ! A --- a key parameter related with convergence
1248
+ ! M --- number of elements in the array WVNO
1249
+ ! WVNO --- The first elememnt is WK, the rest elements are
1250
+ ! the real roots of the equation um*tanh(um*h)= -V
1251
+ ! WK --- positive root of the dispersion equation k*tanh(k*h)= V
1252
+ ! Output: DCOEF --- derivative of expansion coefficients with respect to R
1253
+ !
1254
+ ! Contributors list:
1255
+ ! Yingyi Liu
1256
+ ! to be continued...
1257
+ !
1258
+ ! ==================================================================================
1259
+
1260
+ SUBROUTINE DCOEF(R,PA,A,M,WVNO,WK,DCOF)
1261
+
1262
+ INTEGER I
1263
+ INTEGER,INTENT(IN)::M
1264
+ REAL*8,INTENT(IN)::R,PA,A,WVNO(M),WK
1265
+ REAL*8,INTENT(OUT)::DCOF(M)
1266
+ !REAL*8,EXTERNAL:: DSA0,DSAM,AQUAD,F2
1267
+ REAL*8 BY1,DNT,EPS,STEP,P1
1268
+
1269
+ EPS=1.E-6
1270
+ STEP=100.D0
1271
+ DNT=PA**2/4.D0
1272
+
1273
+ ! calculate the derivative of the first expansion coefficient A0
1274
+ !
1275
+ IF (DABS(R).LT.1.E-6) THEN
1276
+
1277
+ DCOF(1)=0.D0
1278
+
1279
+ ELSEIF (R/A.LE.0.5D0) THEN
1280
+
1281
+ DCOF(1)=DSA0(R,PA,WK)
1282
+
1283
+ ELSE
1284
+
1285
+ CALL JY01BY1(WK*R,BY1)
1286
+ DCOF(1)=WK*BY1/4.D0-AQUAD(R,WK,1,0.0D0,DNT,EPS,2)
1287
+
1288
+ ENDIF
1289
+
1290
+ ! calculate the derivative of the rest expansion coefficients Ai (i=2,m)
1291
+ ! the truncation terms number depends on whether the series
1292
+ ! converged to a specified accuracy or not
1293
+
1294
+ DO I=2,M
1295
+
1296
+ IF (DABS(R).LT.1.E-6) THEN
1297
+
1298
+ DCOF(I)=0.D0
1299
+
1300
+ ELSEIF (R/A.LE.1.D0) THEN
1301
+
1302
+ DCOF(I)=DSAM(R,PA,WVNO(I))
1303
+
1304
+ ELSE
1305
+
1306
+ P1=DNT+STEP
1307
+ DO WHILE (DABS(F2(R,WVNO(I),I,P1)).GT.EPS)
1308
+ P1=P1+STEP
1309
+ ENDDO
1310
+
1311
+ DCOF(I)=AQUAD(R,WVNO(I),I,DNT,P1,EPS,2)
1312
+
1313
+ ENDIF
1314
+
1315
+ ENDDO
1316
+
1317
+ RETURN
1318
+ END SUBROUTINE DCOEF
1319
+
1320
+ ! ==================================================================================
1321
+ ! Purpose: This program computes the series representations of expansion
1322
+ ! coefficients (m=0)
1323
+ !
1324
+ ! License:
1325
+ !
1326
+ ! This routine is part of FinGreen3D.
1327
+ !
1328
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
1329
+ ! under the terms of the GNU Lesser General Public License as published by the
1330
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
1331
+ ! any later version.
1332
+ !
1333
+ ! You should have received a copy of the GNU General Public License (either V3
1334
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
1335
+ !
1336
+ ! Code Original Author:
1337
+ !
1338
+ ! Yingyi Liu on Sept 7, 2013
1339
+ !
1340
+ ! Modified on:
1341
+ !
1342
+ ! July 17, 2018
1343
+ !
1344
+ ! Reference:
1345
+ !
1346
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
1347
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
1348
+ ! and management, 2018
1349
+ !
1350
+ ! Parameters:
1351
+ ! Input: R --- horizontal distance of the source point and the field point
1352
+ ! PA --- a key parameter determining convergence, i.e., PA= a*h
1353
+ ! A --- a key parameter related with convergence
1354
+ ! M --- number of elements in the array WVNO
1355
+ ! WVNO --- The first elememnt is WK, the rest elements are
1356
+ ! the real roots of the equation um*tanh(um*h)= -V
1357
+ ! WK --- positive root of the dispersion equation k*tanh(k*h)= V
1358
+ ! Output: SA0 --- value of first expansion coefficient by series representation (m=0)
1359
+ !
1360
+ ! Contributors list:
1361
+ ! Yingyi Liu
1362
+ ! to be continued...
1363
+ !
1364
+ ! ==================================================================================
1365
+
1366
+
1367
+ REAL*8 FUNCTION SA0(R,PA,WK)
1368
+
1369
+ REAL*8,INTENT(IN)::R,PA,WK
1370
+ INTEGER N,P
1371
+ REAL*8 GA,PI,EPS,PSI,RM,EN,SGN,FACN
1372
+ !REAL*8,EXTERNAL::SYMB,FAC
1373
+
1374
+ DATA GA,PI,EPS/0.5772156649015328D0 ,3.141592653589793D0,1.E-6/
1375
+
1376
+ N=1
1377
+ RM=100.D0
1378
+ SA0=-GA-2.D0*DLOG(WK*PA/2.D0)
1379
+ SGN=-1.D0
1380
+ FACN=1.D0
1381
+
1382
+ ! Loop: the summation stops at the condition when RM meets the tolerance
1383
+ !
1384
+ DO WHILE (DABS(RM).GT.EPS)
1385
+
1386
+ CALL ENXA(N+1,(R/PA)**2,EN)
1387
+
1388
+ PSI=0.D0
1389
+ DO P=1,N
1390
+ PSI=PSI+1.D0/P
1391
+ ENDDO
1392
+
1393
+ ! calculate the value of each term in the infinite series expansion
1394
+ !
1395
+ RM=SGN*(R/PA)**(2.D0*N)/FACN/N-(WK*PA/2.D0)**(2.D0*N)/FACN*EN-2.D0*SGN &
1396
+ /FACN**2*(WK*R/2.D0)**(2.D0*N)*(DLOG(WK*R/2.D0)+GA-PSI)
1397
+
1398
+ !RM=-(WK*PA/2.D0)**(2.D0*N)/FACN*EN
1399
+
1400
+ SA0=SA0+RM
1401
+
1402
+ N=N+1
1403
+ SGN=-SGN ! Sign function depends on the power n
1404
+ FACN=FACN*N ! factorial of the numbers from 1 to n
1405
+
1406
+ ENDDO
1407
+
1408
+ SA0=SA0/4.D0/PI
1409
+
1410
+ RETURN
1411
+ END FUNCTION SA0
1412
+
1413
+ ! ==================================================================================
1414
+ ! Purpose: This program computes the series representations of expansion
1415
+ ! coefficients with respect to R in Linton's method (m=0)
1416
+ !
1417
+ ! License:
1418
+ !
1419
+ ! This routine is part of FinGreen3D.
1420
+ !
1421
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
1422
+ ! under the terms of the GNU Lesser General Public License as published by the
1423
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
1424
+ ! any later version.
1425
+ !
1426
+ ! You should have received a copy of the GNU General Public License (either V3
1427
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
1428
+ !
1429
+ ! Code Original Author:
1430
+ !
1431
+ ! Yingyi Liu on Sept 7, 2013
1432
+ !
1433
+ ! Modified on:
1434
+ !
1435
+ ! July 17, 2018
1436
+ !
1437
+ ! Reference:
1438
+ !
1439
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
1440
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
1441
+ ! and management, 2018
1442
+ !
1443
+ ! Parameters:
1444
+ ! Input: R --- horizontal distance of the source point and the field point
1445
+ ! PA --- a key parameter determining convergence, i.e., PA= a*h
1446
+ ! A --- a key parameter related with convergence
1447
+ ! M --- number of elements in the array WVNO
1448
+ ! WVNO --- The first elememnt is WK, the rest elements are
1449
+ ! the real roots of the equation um*tanh(um*h)= -V
1450
+ ! WK --- positive root of the dispersion equation k*tanh(k*h)= V
1451
+ ! Output: DSA0 --- derivative value of first expansion coefficient by series
1452
+ ! representation (m=0)
1453
+ !
1454
+ ! Contributors list:
1455
+ ! Yingyi Liu
1456
+ ! to be continued...
1457
+ !
1458
+ ! ==================================================================================
1459
+
1460
+ REAL*8 FUNCTION DSA0(R,PA,WK)
1461
+
1462
+ REAL*8,INTENT(IN)::R,PA,WK
1463
+ INTEGER N,P
1464
+ REAL*8 GA,PI,EPS,PSI,RM,EN,SGN,FACN
1465
+ !REAL*8,EXTERNAL::SYMB,FAC
1466
+
1467
+ DATA GA,PI,EPS/0.5772156649015328D0 ,3.141592653589793D0,1.E-6/
1468
+
1469
+ N=1
1470
+ RM=100.D0
1471
+ DSA0=0.D0
1472
+ SGN=-1.D0
1473
+ FACN=1.D0
1474
+
1475
+ ! Loop: the summation stops at the condition when RM meets the tolerance
1476
+ !
1477
+ DO WHILE (DABS(RM).GT.EPS)
1478
+
1479
+ CALL ENXA(N,(R/PA)**2,EN)
1480
+
1481
+ PSI=0.D0
1482
+ DO P=1,N
1483
+ PSI=PSI+1.D0/P
1484
+ ENDDO
1485
+
1486
+ ! calculate the value of each term in the infinite series expansion
1487
+ !
1488
+ RM=2.D0*SGN*(R/PA)**(2.D0*N-1.D0)/FACN/PA+(WK*PA/2.D0)**(2.D0*N)/FACN*EN*2.D0*R/PA**2-2.D0*SGN*N*WK &
1489
+ /FACN**2*(WK*R/2.D0)**(2.D0*N-1.D0)*(DLOG(WK*R/2.D0)+GA-PSI)-2.D0*SGN/FACN**2*(WK*R/2.D0)**(2.D0*N)/R
1490
+
1491
+ DSA0=DSA0+RM
1492
+
1493
+ N=N+1
1494
+ SGN=-SGN ! Sign function depends on the power n
1495
+ FACN=FACN*N ! factorial of the numbers from 1 to n
1496
+
1497
+ ENDDO
1498
+
1499
+ DSA0=DSA0/4.D0/PI
1500
+
1501
+ RETURN
1502
+ END FUNCTION DSA0
1503
+
1504
+ ! ==================================================================================
1505
+ ! Purpose: This program computes the series representations of expansion
1506
+ ! coefficients (m>=1,m=1,2,3,4...)
1507
+ !
1508
+ ! License:
1509
+ !
1510
+ ! This routine is part of FinGreen3D.
1511
+ !
1512
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
1513
+ ! under the terms of the GNU Lesser General Public License as published by the
1514
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
1515
+ ! any later version.
1516
+ !
1517
+ ! You should have received a copy of the GNU General Public License (either V3
1518
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
1519
+ !
1520
+ ! Code Original Author:
1521
+ !
1522
+ ! Yingyi Liu on Sept 7, 2013
1523
+ !
1524
+ ! Modified on:
1525
+ !
1526
+ ! July 17, 2018
1527
+ !
1528
+ ! Reference:
1529
+ !
1530
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
1531
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
1532
+ ! and management, 2018
1533
+ !
1534
+ ! Parameters:
1535
+ ! Input: R --- horizontal distance of the source point and the field point
1536
+ ! PA --- a key parameter determining convergence, i.e., PA= a*h
1537
+ ! A --- a key parameter related with convergence
1538
+ ! M --- number of elements in the array WVNO
1539
+ ! WVNO --- The first elememnt is WK, the rest elements are
1540
+ ! the real roots of the equation um*tanh(um*h)= -V
1541
+ ! WK --- positive root of the dispersion equation k*tanh(k*h)= V
1542
+ ! Output: SAM --- value of first expansion coefficient by series representation
1543
+ ! (m>=1,m=1,2,3,4...)
1544
+ !
1545
+ ! Contributors list:
1546
+ ! Yingyi Liu
1547
+ ! to be continued...
1548
+ !
1549
+ ! ==================================================================================
1550
+
1551
+ REAL*8 FUNCTION SAM(R,PA,WVN)
1552
+
1553
+ REAL*8,INTENT(IN)::R,PA,WVN
1554
+ INTEGER N
1555
+ REAL*8 GA,PI,EPS,RM,EN,SGN,FACN
1556
+ !REAL*8,EXTERNAL::SYMB,FAC
1557
+
1558
+ DATA GA,PI,EPS/0.5772156649015328D0 ,3.141592653589793D0,1.E-6/
1559
+
1560
+ N=0
1561
+ RM=100.D0
1562
+ SAM=0.D0
1563
+ SGN=1.D0
1564
+ FACN=1.D0
1565
+
1566
+ ! Loop: the summation stops at the condition when RM meets the tolerance
1567
+ !
1568
+ DO WHILE (DABS(RM).GT.EPS)
1569
+
1570
+ CALL ENXA(N+1,(WVN*PA/2.D0)**2,EN)
1571
+
1572
+ RM=SGN*(R/PA)**(2.D0*N)/FACN*EN
1573
+
1574
+ SAM=SAM+RM
1575
+
1576
+ N=N+1
1577
+ SGN=-SGN ! Sign function depends on the power n
1578
+ FACN=FACN*N ! factorial of the numbers from 1 to n
1579
+
1580
+ ENDDO
1581
+
1582
+ SAM=SAM/4.D0/PI
1583
+
1584
+ RETURN
1585
+ END FUNCTION SAM
1586
+
1587
+ ! ==================================================================================
1588
+ ! Purpose: This program computes the series representations of expansion
1589
+ ! coefficients with respect to R in Linton's method (m>=1,m=1,2,3,4...)
1590
+ !
1591
+ ! License:
1592
+ !
1593
+ ! This routine is part of FinGreen3D.
1594
+ !
1595
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
1596
+ ! under the terms of the GNU Lesser General Public License as published by the
1597
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
1598
+ ! any later version.
1599
+ !
1600
+ ! You should have received a copy of the GNU General Public License (either V3
1601
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
1602
+ !
1603
+ ! Code Original Author:
1604
+ !
1605
+ ! Yingyi Liu on Sept 7, 2013
1606
+ !
1607
+ ! Modified on:
1608
+ !
1609
+ ! July 17, 2018
1610
+ !
1611
+ ! Reference:
1612
+ !
1613
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
1614
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
1615
+ ! and management, 2018
1616
+ !
1617
+ ! Parameters:
1618
+ ! Input: R --- horizontal distance of the source point and the field point
1619
+ ! PA --- a key parameter determining convergence, i.e., PA= a*h
1620
+ ! A --- a key parameter related with convergence
1621
+ ! M --- number of elements in the array WVNO
1622
+ ! WVNO --- The first elememnt is WK, the rest elements are
1623
+ ! the real roots of the equation um*tanh(um*h)= -V
1624
+ ! WK --- positive root of the dispersion equation k*tanh(k*h)= V
1625
+ ! Output: DSAM --- derivative value of first expansion coefficient by series
1626
+ ! representation (m>=1,m=1,2,3,4...)
1627
+ !
1628
+ ! Contributors list:
1629
+ ! Yingyi Liu
1630
+ ! to be continued...
1631
+ !
1632
+ ! ==================================================================================
1633
+
1634
+ REAL*8 FUNCTION DSAM(R,PA,WVN)
1635
+
1636
+ REAL*8,INTENT(IN)::R,PA,WVN
1637
+ INTEGER N
1638
+ REAL*8 GA,PI,EPS,RM,EN,SGN,FACN
1639
+ !REAL*8,EXTERNAL::SYMB,FAC
1640
+
1641
+ DATA GA,PI,EPS/0.5772156649015328D0 ,3.141592653589793D0,1.E-6/
1642
+
1643
+ N=1
1644
+ RM=100.D0
1645
+ DSAM=0.D0
1646
+ SGN=-1.D0
1647
+ FACN=1.D0
1648
+
1649
+ ! Loop: the summation stops at the condition when RM meets the tolerance
1650
+ !
1651
+ DO WHILE (DABS(RM).GT.EPS)
1652
+
1653
+ CALL ENXA(N+1,(WVN*PA/2.D0)**2,EN)
1654
+
1655
+ RM=2.D0*N*SGN*(R/PA)**(2.D0*N-1.D0)/FACN/PA*EN
1656
+
1657
+ DSAM=DSAM+RM
1658
+
1659
+ N=N+1
1660
+ SGN=-SGN ! Sign function depends on the power n
1661
+ FACN=FACN*N ! factorial of the numbers from 1 to n
1662
+
1663
+ ENDDO
1664
+
1665
+ DSAM=DSAM/4.D0/PI
1666
+
1667
+ RETURN
1668
+ END FUNCTION DSAM
1669
+
1670
+ ! ==================================================================================
1671
+ ! Purpose: This program computes the expansion coefficients and its
1672
+ ! derivative in Linton's method by integral form.
1673
+ !
1674
+ ! License:
1675
+ !
1676
+ ! This routine is part of FinGreen3D.
1677
+ !
1678
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
1679
+ ! under the terms of the GNU Lesser General Public License as published by the
1680
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
1681
+ ! any later version.
1682
+ !
1683
+ ! You should have received a copy of the GNU General Public License (either V3
1684
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
1685
+ !
1686
+ ! Code Original Author:
1687
+ !
1688
+ ! Yingyi Liu on Sept 7, 2013
1689
+ !
1690
+ ! Modified on:
1691
+ !
1692
+ ! July 21, 2016
1693
+ !
1694
+ ! Reference:
1695
+ !
1696
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
1697
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
1698
+ ! and management, 2018
1699
+ !
1700
+ ! Parameters:
1701
+ ! Input: R --- horizontal distance of the source point and the field point
1702
+ ! WVN --- The input wave number
1703
+ ! NO --- the term number to be calculated in Linton's expansion
1704
+ ! T --- integration variable
1705
+ ! FUNTAG --- 1: calculate function value; 2: calculate derivative value
1706
+ ! Output: FUN --- value of expansion coefficient or its derivative by integral
1707
+ ! representation
1708
+ !
1709
+ ! Contributors list:
1710
+ ! Yingyi Liu
1711
+ ! to be continued...
1712
+ !
1713
+ ! ==================================================================================
1714
+
1715
+ REAL*8 FUNCTION FUN(R,WVN,NO,T,FUNTAG)
1716
+
1717
+ INTEGER,INTENT(IN)::NO,FUNTAG
1718
+ REAL*8,INTENT(IN)::R,WVN,T
1719
+ !REAL*8,EXTERNAL::F1,F2
1720
+
1721
+ SELECT CASE(FUNTAG)
1722
+
1723
+
1724
+ CASE(1)
1725
+ FUN=F1(R,WVN,NO,T)
1726
+
1727
+ CASE(2)
1728
+ FUN=F2(R,WVN,NO,T)
1729
+
1730
+
1731
+ END SELECT
1732
+
1733
+ RETURN
1734
+ END FUNCTION FUN
1735
+
1736
+
1737
+ ! ==================================================================================
1738
+ ! Purpose: This program computes the expansion coefficients and its
1739
+ ! derivative in Linton's method by integral form.
1740
+ !
1741
+ ! License:
1742
+ !
1743
+ ! This routine is part of FinGreen3D.
1744
+ !
1745
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
1746
+ ! under the terms of the GNU Lesser General Public License as published by the
1747
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
1748
+ ! any later version.
1749
+ !
1750
+ ! You should have received a copy of the GNU General Public License (either V3
1751
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
1752
+ !
1753
+ ! Code Original Author:
1754
+ !
1755
+ ! Yingyi Liu on Sept 7, 2013
1756
+ !
1757
+ ! Modified on:
1758
+ !
1759
+ ! July 21, 2016
1760
+ !
1761
+ ! Reference:
1762
+ !
1763
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
1764
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
1765
+ ! and management, 2018
1766
+ !
1767
+ ! Parameters:
1768
+ ! Input: R --- horizontal distance of the source point and the field point
1769
+ ! WVN --- The input wave number
1770
+ ! NO --- the term number to be calculated in Linton's expansion
1771
+ ! T --- integration variable
1772
+ ! FUNTAG --- 1: calculate function value; 2: calculate derivative value
1773
+ ! Output: FUN --- value of expansion coefficient or its derivative by integral
1774
+ ! representation
1775
+ !
1776
+ ! Contributors list:
1777
+ ! Yingyi Liu
1778
+ ! to be continued...
1779
+ !
1780
+ ! ==================================================================================
1781
+
1782
+ REAL*8 FUNCTION FUNF(V,R,ZF,ZP,H,T,FUNTAG)
1783
+
1784
+ INTEGER,INTENT(IN)::FUNTAG
1785
+ REAL*8,INTENT(IN)::V,R,ZF,ZP,H,T
1786
+ !REAL*8,EXTERNAL::G1,G2,G3
1787
+
1788
+ SELECT CASE(FUNTAG)
1789
+
1790
+
1791
+ ! INTEGRAND OF L1
1792
+ CASE(1)
1793
+ FUNF=G1(V,R,ZF,ZP,H,T)
1794
+
1795
+ ! INTEGRAND OF L1R
1796
+ CASE(2)
1797
+ FUNF=G2(V,R,ZF,ZP,H,T)
1798
+
1799
+ ! INTEGRAND OF L1Z
1800
+ CASE(3)
1801
+ FUNF=G3(V,R,ZF,ZP,H,T)
1802
+
1803
+
1804
+ END SELECT
1805
+
1806
+ RETURN
1807
+ END FUNCTION FUNF
1808
+
1809
+ ! ==================================================================================
1810
+ ! Purpose: This program computes the value of expansion coefficients
1811
+ ! in Linton's method by integral form.
1812
+ !
1813
+ ! License:
1814
+ !
1815
+ ! This routine is part of FinGreen3D.
1816
+ !
1817
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
1818
+ ! under the terms of the GNU Lesser General Public License as published by the
1819
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
1820
+ ! any later version.
1821
+ !
1822
+ ! You should have received a copy of the GNU General Public License (either V3
1823
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
1824
+ !
1825
+ ! Code Original Author:
1826
+ !
1827
+ ! Yingyi Liu on Sept 7, 2013
1828
+ !
1829
+ ! Modified on:
1830
+ !
1831
+ ! July 21, 2016
1832
+ !
1833
+ ! Reference:
1834
+ !
1835
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
1836
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
1837
+ ! and management, 2018
1838
+ !
1839
+ ! Parameters:
1840
+ ! Input: R --- horizontal distance of the source point and the field point
1841
+ ! WVN --- The input wave number
1842
+ ! NO --- the term number to be calculated in Linton's expansion
1843
+ ! T --- integration variable
1844
+ ! Output: F1 --- value of expansion coefficient by integral representation
1845
+ !
1846
+ ! Contributors list:
1847
+ ! Yingyi Liu
1848
+ ! to be continued...
1849
+ !
1850
+ ! ==================================================================================
1851
+
1852
+ REAL*8 FUNCTION F1(R,WVN,NO,T)
1853
+
1854
+ INTEGER NO
1855
+ REAL*8,INTENT(IN)::R,WVN,T
1856
+ REAL*8 PI
1857
+
1858
+ DATA PI/3.141592653589793D0/
1859
+
1860
+ IF (DABS(T).LT.1.D-8) THEN
1861
+
1862
+ F1=0.D0
1863
+
1864
+ ELSE
1865
+
1866
+ IF (NO.EQ.1) THEN
1867
+
1868
+ F1=DEXP(-R**2/4.D0/T+WVN**2*T)/4.D0/PI/T
1869
+
1870
+ ELSE
1871
+
1872
+ F1=DEXP(-R**2/4.D0/T-WVN**2*T)/4.D0/PI/T
1873
+
1874
+ ENDIF
1875
+
1876
+ ENDIF
1877
+
1878
+
1879
+ RETURN
1880
+ END FUNCTION F1
1881
+
1882
+ ! ==================================================================================
1883
+ ! Purpose: This program computes derivative of the expansion coefficients
1884
+ ! in Linton's method by integral form.
1885
+ !
1886
+ ! License:
1887
+ !
1888
+ ! This routine is part of FinGreen3D.
1889
+ !
1890
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
1891
+ ! under the terms of the GNU Lesser General Public License as published by the
1892
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
1893
+ ! any later version.
1894
+ !
1895
+ ! You should have received a copy of the GNU General Public License (either V3
1896
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
1897
+ !
1898
+ ! Code Original Author:
1899
+ !
1900
+ ! Yingyi Liu on Sept 7, 2013
1901
+ !
1902
+ ! Modified on:
1903
+ !
1904
+ ! July 21, 2016
1905
+ !
1906
+ ! Reference:
1907
+ !
1908
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
1909
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
1910
+ ! and management, 2018
1911
+ !
1912
+ ! Parameters:
1913
+ ! Input: R --- horizontal distance of the source point and the field point
1914
+ ! WVN --- The input wave number
1915
+ ! NO --- the term number to be calculated in Linton's expansion
1916
+ ! T --- integration variable
1917
+ ! Output: F2 --- derivative value of the expansion coefficient by integral
1918
+ ! representation
1919
+ !
1920
+ ! Contributors list:
1921
+ ! Yingyi Liu
1922
+ ! to be continued...
1923
+ !
1924
+ ! ==================================================================================
1925
+
1926
+ REAL*8 FUNCTION F2(R,WVN,NO,T)
1927
+
1928
+
1929
+ INTEGER NO
1930
+ REAL*8,INTENT(IN)::R,WVN,T
1931
+ REAL*8 PI
1932
+
1933
+ DATA PI/3.141592653589793D0/
1934
+
1935
+ IF (DABS(T).LT.1.D-8) THEN
1936
+
1937
+ F2=0.D0
1938
+
1939
+ ELSE
1940
+
1941
+ IF (NO.EQ.1) THEN
1942
+
1943
+ F2=-R*DEXP(-R**2/4.D0/T+WVN**2*T)/8.D0/PI/T**2
1944
+
1945
+ ELSE
1946
+
1947
+ F2=-R*DEXP(-R**2/4.D0/T-WVN**2*T)/8.D0/PI/T**2
1948
+
1949
+ ENDIF
1950
+
1951
+ ENDIF
1952
+
1953
+ RETURN
1954
+ END FUNCTION F2
1955
+
1956
+ ! ==================================================================================
1957
+ ! Purpose: This program computes the value of the survival integral
1958
+ ! in L1 function in Linton's method.
1959
+ !
1960
+ ! License:
1961
+ !
1962
+ ! This routine is part of FinGreen3D.
1963
+ !
1964
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
1965
+ ! under the terms of the GNU Lesser General Public License as published by the
1966
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
1967
+ ! any later version.
1968
+ !
1969
+ ! You should have received a copy of the GNU General Public License (either V3
1970
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
1971
+ !
1972
+ ! Code Original Author:
1973
+ !
1974
+ ! Yingyi Liu on Sept 7, 2013
1975
+ !
1976
+ ! Modified on:
1977
+ !
1978
+ ! July 21, 2016
1979
+ !
1980
+ ! Reference:
1981
+ !
1982
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
1983
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
1984
+ ! and management, 2018
1985
+ !
1986
+ ! Parameters:
1987
+ ! Input: V --- wave number in deep water , i.e., V= w^2/g
1988
+ ! R --- horizontal distance of the source point and the field point
1989
+ ! ZF,ZP --- Z coordinates of the source point and the field point
1990
+ ! H --- water depth (h>0)
1991
+ ! T --- integration variable
1992
+ ! Output: G1 --- value of the survival integral in L1 in Linton's
1993
+ ! representation
1994
+ !
1995
+ ! Contributors list:
1996
+ ! Yingyi Liu
1997
+ ! to be continued...
1998
+ !
1999
+ ! ==================================================================================
2000
+
2001
+ REAL*8 FUNCTION G1(V,R,ZF,ZP,H,T)
2002
+
2003
+ REAL*8,INTENT(IN)::V,R,ZF,ZP,H,T
2004
+ INTEGER I
2005
+ REAL*8 SUM,VAL(4)
2006
+ !REAL*8,EXTERNAL::ERFCC
2007
+
2008
+ IF (DABS(T).LT.1.D-8) THEN
2009
+
2010
+ G1=0.D0
2011
+
2012
+ ELSE
2013
+
2014
+ CALL CHI(ZF,ZP,H,VAL)
2015
+
2016
+ SUM=0.D0
2017
+ DO I=1,4
2018
+ SUM=SUM+DEXP(-V*VAL(I))*ERFCC(VAL(I)/2.D0/T-V*T)
2019
+ ENDDO
2020
+
2021
+ G1=DEXP(V**2*T**2-R**2/4.D0/T**2)*SUM/T
2022
+
2023
+ ENDIF
2024
+
2025
+ RETURN
2026
+ END FUNCTION G1
2027
+
2028
+ ! ==================================================================================
2029
+ ! Purpose: This program computes derivative of the survival integral
2030
+ ! in L1 function with respect to R in Linton's method.
2031
+ !
2032
+ ! License:
2033
+ !
2034
+ ! This routine is part of FinGreen3D.
2035
+ !
2036
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
2037
+ ! under the terms of the GNU Lesser General Public License as published by the
2038
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
2039
+ ! any later version.
2040
+ !
2041
+ ! You should have received a copy of the GNU General Public License (either V3
2042
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
2043
+ !
2044
+ ! Code Original Author:
2045
+ !
2046
+ ! Yingyi Liu on Sept 7, 2013
2047
+ !
2048
+ ! Modified on:
2049
+ !
2050
+ ! July 21, 2016
2051
+ !
2052
+ ! Reference:
2053
+ !
2054
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
2055
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
2056
+ ! and management, 2018
2057
+ !
2058
+ ! Parameters:
2059
+ ! Input: V --- wave number in deep water , i.e., V= w^2/g
2060
+ ! R --- horizontal distance of the source point and the field point
2061
+ ! ZF,ZP --- Z coordinates of the source point and the field point
2062
+ ! H --- water depth (h>0)
2063
+ ! T --- integration variable
2064
+ ! Output: G2 --- derivative value of the survival integral in L1 with respect
2065
+ ! to R in Linton's representation
2066
+ !
2067
+ ! Contributors list:
2068
+ ! Yingyi Liu
2069
+ ! to be continued...
2070
+ !
2071
+ ! ==================================================================================
2072
+
2073
+ REAL*8 FUNCTION G2(V,R,ZF,ZP,H,T)
2074
+
2075
+
2076
+ REAL*8,INTENT(IN)::V,R,ZF,ZP,H,T
2077
+ INTEGER I
2078
+ REAL*8 SUM,VAL(4)
2079
+ !REAL*8,EXTERNAL::ERFCC
2080
+
2081
+ IF (DABS(T).LT.1.D-8) THEN
2082
+
2083
+ G2=0.D0
2084
+
2085
+ ELSE
2086
+
2087
+ CALL CHI(ZF,ZP,H,VAL)
2088
+
2089
+ SUM=0.D0
2090
+ DO I=1,4
2091
+ SUM=SUM+DEXP(-V*VAL(I))*ERFCC(VAL(I)/2.D0/T-V*T)
2092
+ ENDDO
2093
+
2094
+ G2=R/2.D0/T**3*DEXP(V**2*T**2-R**2/4.D0/T**2)*SUM
2095
+
2096
+ ENDIF
2097
+
2098
+ RETURN
2099
+ END FUNCTION G2
2100
+
2101
+ ! ==================================================================================
2102
+ ! Purpose: This program computes derivative of the survival integral
2103
+ ! in L1 function with respect to z in Linton's method.
2104
+ !
2105
+ ! License:
2106
+ !
2107
+ ! This routine is part of FinGreen3D.
2108
+ !
2109
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
2110
+ ! under the terms of the GNU Lesser General Public License as published by the
2111
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
2112
+ ! any later version.
2113
+ !
2114
+ ! You should have received a copy of the GNU General Public License (either V3
2115
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
2116
+ !
2117
+ ! Code Original Author:
2118
+ !
2119
+ ! Yingyi Liu on Sept 7, 2013
2120
+ !
2121
+ ! Modified on:
2122
+ !
2123
+ ! July 21, 2016
2124
+ !
2125
+ ! Reference:
2126
+ !
2127
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
2128
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
2129
+ ! and management, 2018
2130
+ !
2131
+ ! Parameters:
2132
+ ! Input: V --- wave number in deep water , i.e., V= w^2/g
2133
+ ! R --- horizontal distance of the source point and the field point
2134
+ ! ZF,ZP --- Z coordinates of the source point and the field point
2135
+ ! H --- water depth (h>0)
2136
+ ! T --- integration variable
2137
+ ! Output: G3 --- derivative value of the survival integral in L1 with respect
2138
+ ! to z in Linton's representation
2139
+ !
2140
+ ! Contributors list:
2141
+ ! Yingyi Liu
2142
+ ! to be continued...
2143
+ !
2144
+ ! ==================================================================================
2145
+
2146
+ REAL*8 FUNCTION G3(V,R,ZF,ZP,H,T)
2147
+
2148
+ REAL*8,INTENT(IN)::V,R,ZF,ZP,H,T
2149
+ INTEGER I
2150
+ REAL*8 SUM,VAL(4),DVAL(4)
2151
+ !REAL*8,EXTERNAL::ERFCC,DERFCC
2152
+
2153
+ IF (DABS(T).LT.1.D-8) THEN
2154
+
2155
+ G3=0.D0
2156
+
2157
+ ELSE
2158
+
2159
+ CALL CHI(ZF,ZP,H,VAL)
2160
+ CALL DCHI(DVAL)
2161
+
2162
+ SUM=0.D0
2163
+ DO I=1,4
2164
+ SUM=SUM-V*DVAL(I)*DEXP(-V*VAL(I))*ERFCC(VAL(I)/2.D0/T-V*T) &
2165
+ +DEXP(-V*VAL(I))*DERFCC(VAL(I)/2.D0/T-V*T)*DVAL(I)/2.D0/T
2166
+ ENDDO
2167
+
2168
+ G3=DEXP(V**2*T**2-R**2/4.D0/T**2)*SUM/T
2169
+
2170
+ ENDIF
2171
+
2172
+
2173
+ RETURN
2174
+ END FUNCTION G3
2175
+ !
2176
+ ! ===========================================================
2177
+ ! Functions 1/dsqrt(R^2+chi(1,i)^2) and their derivatives
2178
+ ! Code Original Author: Yingyi Liu 2013.09.07
2179
+ ! ===========================================================
2180
+
2181
+ SUBROUTINE RCHI(R,ZF,ZP,H,RO,DROR,DROZ)
2182
+
2183
+ INTEGER I
2184
+ REAL*8 R,ZF,ZP,H
2185
+ REAL*8 RO(4),DROR(4),DROZ(4),VAL(4)
2186
+
2187
+
2188
+ CALL CHI(ZF,ZP,H,VAL)
2189
+
2190
+ DO I=1,4
2191
+
2192
+ RO(I)=DSQRT(R**2+VAL(I)**2)
2193
+ DROR(I)=R/DSQRT(R**2+VAL(I)**2)
2194
+ DROZ(I)=VAL(I)*(-1.D0)**I/DSQRT(R**2+VAL(I)**2)
2195
+
2196
+ ENDDO
2197
+
2198
+ RETURN
2199
+ END SUBROUTINE RCHI
2200
+ !
2201
+ ! ===========================================================
2202
+ ! Function Chi(1,i)
2203
+ ! Code Original Author: Yingyi Liu 2013.09.07
2204
+ ! ===========================================================
2205
+
2206
+ SUBROUTINE CHI(ZF,ZP,H,VAL)
2207
+
2208
+ REAL*8 ZF,ZP,H,VAL(4)
2209
+
2210
+ VAL(1)=-ZP-ZF
2211
+ VAL(2)=2.D0*H-ZP+ZF
2212
+ VAL(3)=2.D0*H+ZP-ZF
2213
+ VAL(4)=4.D0*H+ZP+ZF
2214
+
2215
+ RETURN
2216
+ END SUBROUTINE CHI
2217
+ !
2218
+ ! ===========================================================
2219
+ ! The derivative of function Chi(1,i) with respect to z
2220
+ ! Code Original Author: Yingyi Liu 2013.09.07
2221
+ ! ===========================================================
2222
+
2223
+ SUBROUTINE DCHI(DVAL)
2224
+
2225
+ REAL*8 DVAL(4)
2226
+
2227
+ DVAL(1)=-1.D0
2228
+ DVAL(2)=1.D0
2229
+ DVAL(3)=-1.D0
2230
+ DVAL(4)=1.D0
2231
+
2232
+ RETURN
2233
+ END SUBROUTINE DCHI
2234
+
2235
+ !
2236
+ ! ===========================================================
2237
+ ! Function Nm
2238
+ ! Code Original Author: Yingyi Liu 2013.09.07
2239
+ ! ===========================================================
2240
+
2241
+ FUNCTION NM(H,WVN)
2242
+
2243
+ REAL*8 H
2244
+ COMPLEX*16 NM,WVN
2245
+
2246
+ NM=H/2.D0*(1.D0+CDSIN(2.D0*WVN*H)/(2.D0*WVN*H))
2247
+
2248
+ RETURN
2249
+ END FUNCTION NM
2250
+ !
2251
+ ! ===========================================================
2252
+ ! Derivative of the complementary error function
2253
+ ! Code Original Author: Yingyi Liu 2013.09.07
2254
+ ! ===========================================================
2255
+
2256
+ FUNCTION DERFCC(X)
2257
+
2258
+ REAL*8 DERFCC,X
2259
+ REAL*8 PI
2260
+
2261
+ DATA PI/3.141592653589793D0/
2262
+
2263
+ DERFCC=-2.D0/DSQRT(PI)*DEXP(-X**2.D0)
2264
+
2265
+ RETURN
2266
+ END FUNCTION DERFCC
2267
+
2268
+ !
2269
+ ! ===========================================================
2270
+ ! The complementary error function erfc(x)
2271
+ ! Code Original Author: Yingyi Liu 2013.09.07
2272
+ ! ===========================================================
2273
+
2274
+ FUNCTION ERFCC(X)
2275
+ REAL*8 ERFCC,X,ERR
2276
+
2277
+ CALL ERROR(X,ERR)
2278
+ ERFCC=1.D0-ERR
2279
+
2280
+ RETURN
2281
+ END FUNCTION ERFCC
2282
+
2283
+
2284
+
2285
+ ! ==================================================================================
2286
+ ! Purpose: This program computes the 1D integral value of an external
2287
+ ! integrand function in a finite interval (A,B) using standard
2288
+ ! Kronrod extension of Gauss-Lengendre rule, here using the
2289
+ ! commonly used standard pair (G7,K15).
2290
+ !
2291
+ ! License:
2292
+ !
2293
+ ! This routine is part of FinGreen3D.
2294
+ !
2295
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
2296
+ ! under the terms of the GNU Lesser General Public License as published by the
2297
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
2298
+ ! any later version.
2299
+ !
2300
+ ! You should have received a copy of the GNU General Public License (either V3
2301
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
2302
+ !
2303
+ ! Code Original Author:
2304
+ !
2305
+ ! Yingyi Liu on June 2, 2012
2306
+ !
2307
+ ! Modified on:
2308
+ !
2309
+ ! July 21, 2016
2310
+ !
2311
+ ! Reference:
2312
+ !
2313
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
2314
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
2315
+ ! and management, 2018
2316
+ !
2317
+ ! Yingyi Liu, Ying Gou, Bin Teng, Shigeo Yoshida
2318
+ ! An Extremely Efficient Boundary Element Method for Wave Interaction with Long
2319
+ ! Cylindrical Structures Based on Free-Surface Green's Functions.
2320
+ ! Computation, 4(2016), 36
2321
+ !
2322
+ ! Parameters:
2323
+ ! Input: V,R,ZF,ZP,H --- variables of the integrated function, should be
2324
+ ! changed by the user when he/she uses this program separately
2325
+ ! from this library for other purpose.
2326
+ ! A,B --- the two end-points of the interval (A,B).
2327
+ ! FUNTAG --- a flag for indicating which function components to be integrated.
2328
+ ! Ext. Routine: FUN --- the external subroutine of the function integrand to be integrated,
2329
+ ! this should be specified by the user when he/she uses this program
2330
+ ! separately from this library for other purpose.
2331
+ ! Output: GK_INT --- the integral value calculated by Gauss-Kronrod rule,
2332
+ ! which is the final output and more accurate.
2333
+ ! ERR --- the error estimate of this integration within interval (A,B).
2334
+ !
2335
+ ! Passed Variables:
2336
+ ! XGQ(7),WGQ(7) --- the abscissas and weights for the Gauss rule.
2337
+ ! XKQ(15),WKQ(15) --- the abscissas and weights for the Gauss-Kronrod rule.
2338
+ ! G_INT --- the integral value calculated by Gauss rule.
2339
+ ! STF(7) --- the stored integrand function value calculated by Gauss rule,
2340
+ ! which can be reused by the Gauss-Kronrod rule.
2341
+ !
2342
+ ! Contributors list:
2343
+ ! Yingyi Liu
2344
+ ! to be continued...
2345
+ !
2346
+ ! ==================================================================================
2347
+
2348
+ SUBROUTINE GK_INTEGF(V,R,ZF,ZP,H,A,B,GK_INT,ERR,FUNTAG)
2349
+
2350
+ INTEGER,INTENT(IN)::FUNTAG
2351
+ REAL*8,INTENT(IN)::V,R,ZF,ZP,H,A,B
2352
+ REAL*8,INTENT(OUT)::GK_INT,ERR
2353
+ !REAL*8,EXTERNAL::FUNF
2354
+ INTEGER I
2355
+ REAL*8 XGQ(7),WGQ(7),XKQ(15),WKQ(15),STF(7),G_INT
2356
+
2357
+
2358
+ ! ** matrix XGQ store the Gauss-Legendre sampling points(7)
2359
+ !
2360
+ DATA XGQ/-0.949107912342759D0,-0.741531185599394D0, &
2361
+ -0.405845151377397D0, 0.000000000000000D0, &
2362
+ 0.405845151377397D0, 0.741531185599394D0, &
2363
+ 0.949107912342759D0/
2364
+ !
2365
+ ! ** matrix WGQ store the Gauss-Legendre weighting factors
2366
+ !
2367
+ DATA WGQ/ 0.129484966168870D0, 0.279705391489277D0, &
2368
+ 0.381830050505119D0, 0.417959183673469D0, &
2369
+ 0.381830050505119D0, 0.279705391489277D0, &
2370
+ 0.129484966168870D0/
2371
+ !
2372
+ ! ** matrix XKQ store the Kronrod sampling points(15)
2373
+ !
2374
+ DATA XKQ/-0.991455371120813D0,-0.949107912342759D0, &
2375
+ -0.864864423359769D0,-0.741531185599394D0, &
2376
+ -0.586087235467691D0,-0.405845151377397D0, &
2377
+ -0.207784955007898D0, 0.000000000000000D0, &
2378
+ 0.207784955007898D0, 0.405845151377397D0, &
2379
+ 0.586087235467691D0, 0.741531185599394D0, &
2380
+ 0.864864423359769D0, 0.949107912342759D0, &
2381
+ 0.991455371120813D0/
2382
+ !
2383
+ ! ** matrix WKQ store the weighting factors for the Kronrod
2384
+ ! sampling points
2385
+ !
2386
+ DATA WKQ/ 0.022935322010529D0, 0.063092092629979D0, &
2387
+ 0.104790010322250D0, 0.140653259715525D0, &
2388
+ 0.169004726639267D0, 0.190350578064785D0, &
2389
+ 0.204432940075298D0, 0.209482141084728D0, &
2390
+ 0.204432940075298D0, 0.190350578064785D0, &
2391
+ 0.169004726639267D0, 0.140653259715525D0, &
2392
+ 0.104790010322250D0, 0.063092092629979D0, &
2393
+ 0.022935322010529D0/
2394
+
2395
+ G_INT=0.0D0
2396
+ DO I=1,7
2397
+ STF(I)=FUNF(V,R,ZF,ZP,H,1/2.0D0*(B+A+(B-A)*XGQ(I)),FUNTAG)
2398
+ G_INT=G_INT+WGQ(I)*(B-A)/2.0D0*STF(I)
2399
+ END DO
2400
+
2401
+ GK_INT=0.0D0
2402
+ DO I=1,15
2403
+ IF (MOD(I,2)==0) THEN
2404
+ GK_INT=GK_INT+WKQ(I)*(B-A)/2.0D0*STF(I/2)
2405
+ ELSE
2406
+ GK_INT=GK_INT+WKQ(I)*(B-A)/2.0D0*FUNF(V,R,ZF,ZP,H,1/2.0D0*(B+A+(B-A)*XKQ(I)),FUNTAG)
2407
+ ENDIF
2408
+ END DO
2409
+ ERR=(200.0D0*DABS(GK_INT-G_INT))**(1.5D0)
2410
+
2411
+ RETURN
2412
+ END SUBROUTINE GK_INTEGF
2413
+
2414
+
2415
+ ! ==================================================================================
2416
+ ! Purpose: This program using an adaptive quadrature method to compute the
2417
+ ! integral value of an external integrand function in a finite
2418
+ ! interval (A,B) by automatically dividing the interval into halves
2419
+ ! and continuously calling the Gauss-Kronrod subroutine in order
2420
+ ! to finally meet the requested accuracy Eps.
2421
+ !
2422
+ ! License:
2423
+ !
2424
+ ! This routine is part of FinGreen3D.
2425
+ !
2426
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
2427
+ ! under the terms of the GNU Lesser General Public License as published by the
2428
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
2429
+ ! any later version.
2430
+ !
2431
+ ! You should have received a copy of the GNU General Public License (either V3
2432
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
2433
+ !
2434
+ ! Code Original Author:
2435
+ !
2436
+ ! Yingyi Liu on June 2, 2012
2437
+ !
2438
+ ! Modified on:
2439
+ !
2440
+ ! July 21, 2016
2441
+ !
2442
+ ! Reference:
2443
+ !
2444
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
2445
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
2446
+ ! and management, 2018
2447
+ !
2448
+ ! Yingyi Liu, Ying Gou, Bin Teng, Shigeo Yoshida
2449
+ ! An Extremely Efficient Boundary Element Method for Wave Interaction with Long
2450
+ ! Cylindrical Structures Based on Free-Surface Green's Functions.
2451
+ ! Computation, 4(2016), 36
2452
+ !
2453
+ ! Parameters:
2454
+ ! Input: V,R,ZF,ZP,H --- variables of the integrated function, should be
2455
+ ! changed by the user when he/she uses this program separately
2456
+ ! from this library for other purpose.
2457
+ ! A,B --- the two end-points of the interval (A,B).
2458
+ ! EPS --- the requested tolerance for the integration.
2459
+ ! FUNTAG --- a flag for indicating which function components to be integrated.
2460
+ ! Ext. Routine: GK_INTEG --- the external subroutine of Gauss-Kronrod rule, this should be
2461
+ ! modified a little by the user when he/she uses this program
2462
+ ! separately from this library for other purpose.
2463
+ ! Output: ANS --- the result of integration.
2464
+ !
2465
+ ! Passed Variables:
2466
+ ! GK_INT --- the integral value calculated by subroutine GK_INTEG.
2467
+ ! ERR --- the error estimate calculated by subroutine GK_INTEG.
2468
+ !
2469
+ ! Contributors list:
2470
+ ! Yingyi Liu
2471
+ ! to be continued...
2472
+ !
2473
+ ! ==================================================================================
2474
+
2475
+ RECURSIVE REAL*8 FUNCTION AQUADF(V,R,ZF,ZP,H,A,B,EPS,FUNTAG) RESULT(ANS)
2476
+
2477
+ REAL*8,INTENT(IN)::V,R,ZF,ZP,H,A,B,EPS
2478
+ INTEGER,INTENT(IN)::FUNTAG
2479
+ REAL*8 GK_INT,ERR
2480
+
2481
+ ANS=0.0D0
2482
+ CALL GK_INTEGF(V,R,ZF,ZP,H,A,B,GK_INT,ERR,FUNTAG)
2483
+
2484
+ IF (ERR>EPS.AND.DABS(A-B)>EPS) THEN
2485
+ ANS=ANS+AQUADF(V,R,ZF,ZP,H,A,(A+B)/2.0D0,EPS,FUNTAG)+AQUADF(V,R,ZF,ZP,H,(A+B)/2.0D0,B,EPS,FUNTAG)
2486
+ ELSE
2487
+ ANS=ANS+GK_INT
2488
+ ENDIF
2489
+
2490
+ RETURN
2491
+ END FUNCTION AQUADF
2492
+
2493
+
2494
+
2495
+ ! ==================================================================================
2496
+ ! Purpose: This program computes the 1D integral value of an external
2497
+ ! integrand function in a finite interval (A,B) using standard
2498
+ ! Kronrod extension of Gauss-Lengendre rule, here using the
2499
+ ! commonly used standard pair (G7,K15).
2500
+ !
2501
+ ! License:
2502
+ !
2503
+ ! This routine is part of FinGreen3D.
2504
+ !
2505
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
2506
+ ! under the terms of the GNU Lesser General Public License as published by the
2507
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
2508
+ ! any later version.
2509
+ !
2510
+ ! You should have received a copy of the GNU General Public License (either V3
2511
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
2512
+ !
2513
+ ! Code Original Author:
2514
+ !
2515
+ ! Yingyi Liu on June 2, 2012
2516
+ !
2517
+ ! Modified on:
2518
+ !
2519
+ ! July 21, 2016
2520
+ !
2521
+ ! Reference:
2522
+ !
2523
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
2524
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
2525
+ ! and management, 2018
2526
+ !
2527
+ ! Yingyi Liu, Ying Gou, Bin Teng, Shigeo Yoshida
2528
+ ! An Extremely Efficient Boundary Element Method for Wave Interaction with Long
2529
+ ! Cylindrical Structures Based on Free-Surface Green's Functions.
2530
+ ! Computation, 4(2016), 36
2531
+ !
2532
+ ! Parameters:
2533
+ ! Input: R,WVN,NO --- variables of the integrated function, should be
2534
+ ! changed by the user when he/she uses this program separately
2535
+ ! from this library for other purpose.
2536
+ ! A,B --- the two end-points of the interval (A,B).
2537
+ ! FUNTAG --- a flag for indicating which function components to be integrated.
2538
+ ! Ext. Routine: FUN --- the external subroutine of the function integrand to be integrated,
2539
+ ! this should be specified by the user when he/she uses this program
2540
+ ! separately from this library for other purpose.
2541
+ ! Output: GK_INT --- the integral value calculated by Gauss-Kronrod rule,
2542
+ ! which is the final output and more accurate.
2543
+ ! ERR --- the error estimate of this integration within interval (A,B).
2544
+ !
2545
+ ! Passed Variables:
2546
+ ! XGQ(7),WGQ(7) --- the abscissas and weights for the Gauss rule.
2547
+ ! XKQ(15),WKQ(15) --- the abscissas and weights for the Gauss-Kronrod rule.
2548
+ ! G_INT --- the integral value calculated by Gauss rule.
2549
+ ! STF(7) --- the stored integrand function value calculated by Gauss rule,
2550
+ ! which can be reused by the Gauss-Kronrod rule.
2551
+ !
2552
+ ! Contributors list:
2553
+ ! Yingyi Liu
2554
+ ! to be continued...
2555
+ !
2556
+ ! ==================================================================================
2557
+
2558
+ SUBROUTINE GK_INTEG(R,WVN,NO,A,B,GK_INT,ERR,FUNTAG)
2559
+
2560
+ INTEGER,INTENT(IN)::NO,FUNTAG
2561
+ REAL*8,INTENT(IN)::R,WVN,A,B
2562
+ REAL*8,INTENT(OUT)::GK_INT,ERR
2563
+ !REAL*8,EXTERNAL::FUN
2564
+ INTEGER I
2565
+ REAL*8 XGQ(7),WGQ(7),XKQ(15),WKQ(15),STF(7),G_INT
2566
+
2567
+
2568
+ ! ** matrix XGQ store the Gauss-Legendre sampling points(7)
2569
+ !
2570
+ DATA XGQ/-0.949107912342759D0,-0.741531185599394D0, &
2571
+ -0.405845151377397D0, 0.000000000000000D0, &
2572
+ 0.405845151377397D0, 0.741531185599394D0, &
2573
+ 0.949107912342759D0/
2574
+ !
2575
+ ! ** matrix WGQ store the Gauss-Legendre weighting factors
2576
+ !
2577
+ DATA WGQ/ 0.129484966168870D0, 0.279705391489277D0, &
2578
+ 0.381830050505119D0, 0.417959183673469D0, &
2579
+ 0.381830050505119D0, 0.279705391489277D0, &
2580
+ 0.129484966168870D0/
2581
+ !
2582
+ ! ** matrix XKQ store the Kronrod sampling points(15)
2583
+ !
2584
+ DATA XKQ/-0.991455371120813D0,-0.949107912342759D0, &
2585
+ -0.864864423359769D0,-0.741531185599394D0, &
2586
+ -0.586087235467691D0,-0.405845151377397D0, &
2587
+ -0.207784955007898D0, 0.000000000000000D0, &
2588
+ 0.207784955007898D0, 0.405845151377397D0, &
2589
+ 0.586087235467691D0, 0.741531185599394D0, &
2590
+ 0.864864423359769D0, 0.949107912342759D0, &
2591
+ 0.991455371120813D0/
2592
+ !
2593
+ ! ** matrix WKQ store the weighting factors for the Kronrod
2594
+ ! sampling points
2595
+ !
2596
+ DATA WKQ/ 0.022935322010529D0, 0.063092092629979D0, &
2597
+ 0.104790010322250D0, 0.140653259715525D0, &
2598
+ 0.169004726639267D0, 0.190350578064785D0, &
2599
+ 0.204432940075298D0, 0.209482141084728D0, &
2600
+ 0.204432940075298D0, 0.190350578064785D0, &
2601
+ 0.169004726639267D0, 0.140653259715525D0, &
2602
+ 0.104790010322250D0, 0.063092092629979D0, &
2603
+ 0.022935322010529D0/
2604
+
2605
+ G_INT=0.0D0
2606
+ DO I=1,7
2607
+ STF(I)=FUN(R,WVN,NO,1/2.0D0*(B+A+(B-A)*XGQ(I)),FUNTAG)
2608
+ G_INT=G_INT+WGQ(I)*(B-A)/2.0D0*STF(I)
2609
+ END DO
2610
+
2611
+ GK_INT=0.0D0
2612
+ DO I=1,15
2613
+ IF (MOD(I,2)==0) THEN
2614
+ GK_INT=GK_INT+WKQ(I)*(B-A)/2.0D0*STF(I/2)
2615
+ ELSE
2616
+ GK_INT=GK_INT+WKQ(I)*(B-A)/2.0D0*FUN(R,WVN,NO,1/2.0D0*(B+A+(B-A)*XKQ(I)),FUNTAG)
2617
+ ENDIF
2618
+ END DO
2619
+
2620
+ ERR=(200.0D0*DABS(GK_INT-G_INT))**(1.5D0)
2621
+
2622
+ RETURN
2623
+ END SUBROUTINE GK_INTEG
2624
+
2625
+
2626
+ ! ==================================================================================
2627
+ ! Purpose: This program using an adaptive quadrature method to compute the
2628
+ ! integral value of an external integrand function in a finite
2629
+ ! interval (A,B) by automatically dividing the interval into halves
2630
+ ! and continuously calling the Gauss-Kronrod subroutine in order
2631
+ ! to finally meet the requested accuracy Eps.
2632
+ !
2633
+ ! License:
2634
+ !
2635
+ ! This routine is part of FinGreen3D.
2636
+ !
2637
+ ! FinGreen3D is a free software package: you can redistribute it and/or modify it
2638
+ ! under the terms of the GNU Lesser General Public License as published by the
2639
+ ! Free Software Foundation, either version 3 of the License, or (at your option)
2640
+ ! any later version.
2641
+ !
2642
+ ! You should have received a copy of the GNU General Public License (either V3
2643
+ ! or later), along with FinGreen3D. If not, see <http://www.gnu.org/licenses/>.
2644
+ !
2645
+ ! Code Original Author:
2646
+ !
2647
+ ! Yingyi Liu on June 2, 2012
2648
+ !
2649
+ ! Modified on:
2650
+ !
2651
+ ! July 21, 2016
2652
+ !
2653
+ ! Reference:
2654
+ !
2655
+ ! Yingyi Liu et al. A reliable open-source package for performance evaluation of
2656
+ ! floating renewable energy systems in coastal and offshore regions. Energy Conversion
2657
+ ! and management, 2018
2658
+ !
2659
+ ! Yingyi Liu, Ying Gou, Bin Teng, Shigeo Yoshida
2660
+ ! An Extremely Efficient Boundary Element Method for Wave Interaction with Long
2661
+ ! Cylindrical Structures Based on Free-Surface Green's Functions.
2662
+ ! Computation, 4(2016), 36
2663
+ !
2664
+ ! Parameters:
2665
+ ! Input: R,WVN,NO --- variables of the integrated function, should be
2666
+ ! changed by the user when he/she uses this program separately
2667
+ ! from this library for other purpose.
2668
+ ! A,B --- the two end-points of the interval (A,B).
2669
+ ! EPS --- the requested tolerance for the integration.
2670
+ ! FUNTAG --- a flag for indicating which function components to be integrated.
2671
+ ! Ext. Routine: GK_INTEG --- the external subroutine of Gauss-Kronrod rule, this should be
2672
+ ! modified a little by the user when he/she uses this program
2673
+ ! separately from this library for other purpose.
2674
+ ! Output: ANS --- the result of integration.
2675
+ !
2676
+ ! Passed Variables:
2677
+ ! GK_INT --- the integral value calculated by subroutine GK_INTEG.
2678
+ ! ERR --- the error estimate calculated by subroutine GK_INTEG.
2679
+ !
2680
+ ! Contributors list:
2681
+ ! Yingyi Liu
2682
+ ! to be continued...
2683
+ !
2684
+ ! ==================================================================================
2685
+
2686
+ RECURSIVE REAL*8 FUNCTION AQUAD(R,WVN,NO,A,B,EPS,FUNTAG) RESULT(ANS)
2687
+
2688
+ REAL*8,INTENT(IN)::R,WVN,A,B,EPS
2689
+ INTEGER,INTENT(IN)::NO,FUNTAG
2690
+ REAL*8 GK_INT,ERR
2691
+
2692
+ ANS=0.0D0
2693
+ CALL GK_INTEG(R,WVN,NO,A,B,GK_INT,ERR,FUNTAG)
2694
+
2695
+ IF (ERR>EPS.AND.DABS(A-B)>EPS) THEN
2696
+ ANS=ANS+AQUAD(R,WVN,NO,A,(A+B)/2.0D0,EPS,FUNTAG)+AQUAD(R,WVN,NO,(A+B)/2.0D0,B,EPS,FUNTAG)
2697
+ ELSE
2698
+ ANS=ANS+GK_INT
2699
+ ENDIF
2700
+
2701
+ RETURN
2702
+ END FUNCTION AQUAD
2703
+
2704
+ !!---------------------------------------------------------------------------!!
2705
+ ! Belows are third-party (external) Level-3 (low level) subroutines !
2706
+ !!---------------------------------------------------------------------------!!
2707
+ !
2708
+ ! ============================================================================
2709
+ ! Purpose: This program computes the error function
2710
+ ! erf(x) using subroutine ERROR
2711
+ ! License:
2712
+ !
2713
+ ! This routine is copyrighted by Shanjie Zhang and Jianming Jin. However,
2714
+ ! they give permission to incorporate this routine into a user program
2715
+ ! provided that the copyright is acknowledged.
2716
+ !
2717
+ ! Author:
2718
+ !
2719
+ ! Shanjie Zhang, Jianming Jin
2720
+ !
2721
+ ! Reference:
2722
+ !
2723
+ ! Shanjie Zhang, Jianming Jin,
2724
+ ! Computation of Special Functions,
2725
+ ! Wiley, 1996,
2726
+ ! ISBN: 0-471-11963-6,
2727
+ ! LC: QA351.C45.
2728
+ !
2729
+ ! Modified on:
2730
+ ! 25 July 2017, by Yingyi Liu
2731
+ !
2732
+ ! Parameters:
2733
+ ! Input: x --- Argument of erf(x)
2734
+ ! Output: ERR --- erf(x)
2735
+ ! Example:
2736
+ ! x erf(x)
2737
+ ! ---------------------
2738
+ ! 1.0 .84270079
2739
+ ! 2.0 .99532227
2740
+ ! 3.0 .99997791
2741
+ ! 4.0 .99999998
2742
+ ! 5.0 1.00000000
2743
+ ! ============================================================================
2744
+
2745
+ SUBROUTINE ERROR(X,ERR)
2746
+
2747
+ IMPLICIT NONE
2748
+ INTEGER K
2749
+ REAL*8 EPS,PI,X,X2,ER,R,C0,ERR
2750
+
2751
+ EPS=1.0D-15
2752
+ PI=3.141592653589793D0
2753
+ X2=X*X
2754
+ IF (DABS(X).LT.3.5D0) THEN
2755
+ ER=1.0D0
2756
+ R=1.0D0
2757
+ DO K=1,50
2758
+ R=R*X2/(K+0.5D0)
2759
+ ER=ER+R
2760
+ IF (DABS(R).LE.DABS(ER)*EPS) EXIT
2761
+ ENDDO
2762
+ C0=2.0D0/DSQRT(PI)*X*DEXP(-X2)
2763
+ ERR=C0*ER
2764
+ ELSE
2765
+ ER=1.0D0
2766
+ R=1.0D0
2767
+ DO K=1,12
2768
+ R=-R*(K-0.5D0)/X2
2769
+ ER=ER+R
2770
+ ENDDO
2771
+ C0=DEXP(-X2)/(DABS(X)*DSQRT(PI))
2772
+ ERR=1.0D0-C0*ER
2773
+ IF (X.LT.0.0) ERR=-ERR
2774
+ ENDIF
2775
+ RETURN
2776
+ END
2777
+
2778
+ !
2779
+ ! ============================================================================
2780
+ ! Purpose: This program computes the exponential integral
2781
+ ! En(x) using subroutine ENXB
2782
+ ! License:
2783
+ !
2784
+ ! This routine is copyrighted by Shanjie Zhang and Jianming Jin. However,
2785
+ ! they give permission to incorporate this routine into a user program
2786
+ ! provided that the copyright is acknowledged.
2787
+ !
2788
+ ! Author:
2789
+ !
2790
+ ! Shanjie Zhang, Jianming Jin
2791
+ !
2792
+ ! Reference:
2793
+ !
2794
+ ! Shanjie Zhang, Jianming Jin,
2795
+ ! Computation of Special Functions,
2796
+ ! Wiley, 1996,
2797
+ ! ISBN: 0-471-11963-6,
2798
+ ! LC: QA351.C45.
2799
+ !
2800
+ ! Modified on:
2801
+ ! 25 July 2017, by Yingyi Liu
2802
+ !
2803
+ ! Parameters:
2804
+ ! Input : x --- Argument of En(x)
2805
+ ! n --- Order of En(x) (n = 0,1,2,...)
2806
+ ! Output: EN --- En(x)
2807
+ ! Example: x = 10.0
2808
+ ! n En(x)
2809
+ ! ----------------------
2810
+ ! 0 .45399930D-05
2811
+ ! 1 .41569689D-05
2812
+ ! 2 .38302405D-05
2813
+ ! 3 .35487626D-05
2814
+ ! 4 .33041014D-05
2815
+ ! 5 .30897289D-05
2816
+ ! ============================================================================
2817
+ !
2818
+ SUBROUTINE ENXA(N,X,EN)
2819
+
2820
+ IMPLICIT NONE
2821
+ INTEGER N,K
2822
+ REAL*8 X,E0,E1,EN
2823
+
2824
+ E0=DEXP(-X)/X
2825
+
2826
+ CALL E1XA(X,E1)
2827
+
2828
+ IF (N.EQ.0) THEN
2829
+ EN=E0
2830
+ ELSEIF (N.EQ.1) THEN
2831
+ EN=E1
2832
+ ELSE
2833
+ DO K=2,N
2834
+ EN=(DEXP(-X)-X*E1)/(K-1.0D0)
2835
+ E1=EN
2836
+ ENDDO
2837
+ ENDIF
2838
+
2839
+ RETURN
2840
+ END
2841
+
2842
+ !
2843
+ ! ============================================================================
2844
+ ! Purpose: This program computes the exponential integral
2845
+ ! E1(x) using subroutine E1XA
2846
+ ! License:
2847
+ !
2848
+ ! This routine is copyrighted by Shanjie Zhang and Jianming Jin. However,
2849
+ ! they give permission to incorporate this routine into a user program
2850
+ ! provided that the copyright is acknowledged.
2851
+ !
2852
+ ! Author:
2853
+ !
2854
+ ! Shanjie Zhang, Jianming Jin
2855
+ !
2856
+ ! Reference:
2857
+ !
2858
+ ! Shanjie Zhang, Jianming Jin,
2859
+ ! Computation of Special Functions,
2860
+ ! Wiley, 1996,
2861
+ ! ISBN: 0-471-11963-6,
2862
+ ! LC: QA351.C45.
2863
+ !
2864
+ ! Modified on:
2865
+ ! 25 July 2017, by Yingyi Liu
2866
+ !
2867
+ ! Parameters:
2868
+ ! Input : x --- Argument of E1(x) ( x > 0 )
2869
+ ! Output: E1 --- E1(x)
2870
+ ! Example:
2871
+ ! x E1(x)
2872
+ ! ----------------------
2873
+ ! 0.0 .1000000+301
2874
+ ! 1.0 .2193839E+00
2875
+ ! 2.0 .4890051E-01
2876
+ ! 3.0 .1304838E-01
2877
+ ! 4.0 .3779352E-02
2878
+ ! 5.0 .1148296E-02
2879
+ ! ============================================================================
2880
+ !
2881
+ SUBROUTINE E1XA(X,E1)
2882
+
2883
+ IMPLICIT NONE
2884
+ REAL*8 X,E1,ES1,ES2
2885
+
2886
+ IF (X.EQ.0.0) THEN
2887
+ E1=1.0D+300
2888
+ ELSE IF (X.LE.1.0) THEN
2889
+ E1=-DLOG(X)+((((1.07857D-3*X-9.76004D-3)*X+5.519968D-2)*X-0.24991055D0)*X+0.99999193D0)*X-0.57721566D0
2890
+ ELSE
2891
+ ES1=(((X+8.5733287401D0)*X+18.059016973D0)*X+8.6347608925D0)*X+0.2677737343D0
2892
+ ES2=(((X+9.5733223454D0)*X+25.6329561486D0)*X+21.0996530827D0)*X+3.9584969228D0
2893
+ E1=DEXP(-X)/X*ES1/ES2
2894
+ ENDIF
2895
+ RETURN
2896
+ END
2897
+
2898
+ !
2899
+ ! ============================================================================
2900
+ ! Purpose: This program computes the exponential integral
2901
+ ! Ei(x) using subroutine EIX
2902
+ ! License:
2903
+ !
2904
+ ! This routine is copyrighted by Shanjie Zhang and Jianming Jin. However,
2905
+ ! they give permission to incorporate this routine into a user program
2906
+ ! provided that the copyright is acknowledged.
2907
+ !
2908
+ ! Author:
2909
+ !
2910
+ ! Shanjie Zhang, Jianming Jin
2911
+ !
2912
+ ! Reference:
2913
+ !
2914
+ ! Shanjie Zhang, Jianming Jin,
2915
+ ! Computation of Special Functions,
2916
+ ! Wiley, 1996,
2917
+ ! ISBN: 0-471-11963-6,
2918
+ ! LC: QA351.C45.
2919
+ !
2920
+ ! Modified on:
2921
+ ! 25 July 2017, by Yingyi Liu
2922
+ !
2923
+ ! Parameters:
2924
+ ! Input : x --- Argument of Ei(x)
2925
+ ! Output: EI --- Ei(x) ( x > 0 )
2926
+ ! Example:
2927
+ ! x Ei(x)
2928
+ ! -----------------------
2929
+ ! 0 -.10000000+301
2930
+ ! 1 .18951178E+01
2931
+ ! 2 .49542344E+01
2932
+ ! 3 .99338326E+01
2933
+ ! 4 .19630874E+02
2934
+ ! 5 .40185275E+02
2935
+ ! ============================================================================
2936
+
2937
+ SUBROUTINE EIX(X,EI)
2938
+
2939
+ IMPLICIT NONE
2940
+ INTEGER K
2941
+ REAL*8 X,EI,R,GA
2942
+
2943
+ IF (X.EQ.0.0) THEN
2944
+ EI=-1.0D+300
2945
+ ELSE IF (X.LE.40.0) THEN
2946
+ EI=1.0D0
2947
+ R=1.0D0
2948
+ DO K=1,100
2949
+ R=R*K*X/(K+1.0D0)**2
2950
+ EI=EI+R
2951
+ IF (DABS(R/EI).LE.1.0D-15) EXIT
2952
+ ENDDO
2953
+ GA=0.5772156649015328D0
2954
+ EI=GA+DLOG(X)+X*EI
2955
+ ELSE
2956
+ EI=1.0D0
2957
+ R=1.0D0
2958
+ DO K=1,20
2959
+ R=R*K/X
2960
+ EI=EI+R
2961
+ ENDDO
2962
+ EI=DEXP(X)/X*EI
2963
+ ENDIF
2964
+ RETURN
2965
+ END
2966
+
2967
+ !
2968
+ ! ============================================================================
2969
+ ! Purpose: This program computes the gamma function
2970
+ ! GAMMA(x) for x > 0 or its logarithm using
2971
+ ! subroutine LGAMA
2972
+ ! License:
2973
+ !
2974
+ ! This routine is copyrighted by Shanjie Zhang and Jianming Jin. However,
2975
+ ! they give permission to incorporate this routine into a user program
2976
+ ! provided that the copyright is acknowledged.
2977
+ !
2978
+ ! Author:
2979
+ !
2980
+ ! Shanjie Zhang, Jianming Jin
2981
+ !
2982
+ ! Reference:
2983
+ !
2984
+ ! Shanjie Zhang, Jianming Jin,
2985
+ ! Computation of Special Functions,
2986
+ ! Wiley, 1996,
2987
+ ! ISBN: 0-471-11963-6,
2988
+ ! LC: QA351.C45.
2989
+ !
2990
+ ! Modified on:
2991
+ ! 25 July 2017, by Yingyi Liu
2992
+ !
2993
+ ! Parameters:
2994
+ ! Purpose: Compute gamma function GAMMA(x) or ln[GAMMA(x)]
2995
+ ! Input: x --- Argument of GAMMA(x) ( x > 0 )
2996
+ ! KF --- Function code
2997
+ ! KF=1 for GAMMA(x); KF=0 for ln[GAMMA(x)]
2998
+ ! Output: GL --- GAMMA(x) or ln[GAMMA(x)]
2999
+ ! Examples:
3000
+ ! x GAMMA(x)
3001
+ ! -------------------------
3002
+ ! 0.5 .1772453851D+01
3003
+ ! 2.5 .1329340388D+01
3004
+ ! 5.0 .2400000000D+02
3005
+ ! 7.5 .1871254306D+04
3006
+ ! 10.0 .3628800000D+06
3007
+ ! ============================================================================
3008
+
3009
+ SUBROUTINE LGAMA(KF,X,GL)
3010
+
3011
+ IMPLICIT NONE
3012
+ INTEGER K,KF,N
3013
+ REAL*8 X,X0,GL,X2,XP,GL0
3014
+
3015
+ REAL*8 A(10)
3016
+ DATA A/8.333333333333333D-02,-2.777777777777778D-03, &
3017
+ 7.936507936507937D-04,-5.952380952380952D-04, &
3018
+ 8.417508417508418D-04,-1.917526917526918D-03, &
3019
+ 6.410256410256410D-03,-2.955065359477124D-02, &
3020
+ 1.796443723688307D-01,-1.39243221690590D+00/
3021
+
3022
+ X0=X
3023
+ IF (X.EQ.1.0.OR.X.EQ.2.0) THEN
3024
+ GL=0.0D0
3025
+ IF (KF.EQ.1) GL=DEXP(GL)
3026
+ ELSE IF (X.LE.7.0) THEN
3027
+ N=INT(7-X)
3028
+ X0=X+N
3029
+ X2=1.0D0/(X0*X0)
3030
+ XP=6.283185307179586477D0
3031
+ GL0=A(10)
3032
+ DO K=9,1,-1
3033
+ GL0=GL0*X2+A(K)
3034
+ ENDDO
3035
+ GL=GL0/X0+0.5D0*DLOG(XP)+(X0-.5D0)*DLOG(X0)-X0
3036
+ IF (X.LE.7.0) THEN
3037
+ DO K=1,N
3038
+ GL=GL-DLOG(X0-1.0D0)
3039
+ X0=X0-1.0D0
3040
+ ENDDO
3041
+ ENDIF
3042
+ IF (KF.EQ.1) GL=DEXP(GL)
3043
+ ENDIF
3044
+
3045
+ RETURN
3046
+ END
3047
+
3048
+
3049
+
3050
+
3051
+ !-----------------------------------------------------------------------------
3052
+ !+ Finds the limit of a series
3053
+ SUBROUTINE Limes &
3054
+ ( N, & ! in
3055
+ S, & ! inout
3056
+ rLimes, & ! out
3057
+ i_Pade, & ! out
3058
+ k_Pade, & ! out
3059
+ err ) ! out
3060
+
3061
+ ! Description:
3062
+ ! Finds the limit of a series in the case where only
3063
+ ! the first N+1 terms are known.
3064
+ !
3065
+ ! Method:
3066
+ ! The subroutine operates by applying the epsilon-algorithm
3067
+ ! to the sequence of partial sums of a seris supplied on input.
3068
+ ! For description of the algorithm, please see:
3069
+ !
3070
+ ! [1] T. Mishonov and E. Penev, Int. J. Mod. Phys. B 14, 3831 (2000)
3071
+ !
3072
+ ! Owners: Todor Mishonov & Evgeni Penev
3073
+ !
3074
+ ! History:
3075
+ ! Version Date Comment
3076
+ ! ======= ==== =======
3077
+ ! 1.0 01/04/2000 Original code. T. Mishonov & E. Penev
3078
+ !
3079
+ ! Code Description:
3080
+ ! Language: Fortran 90.
3081
+ ! Software Standards: "European Standards for Writing and
3082
+ ! Documenting Exchangeable Fortran 90 Code".
3083
+ !
3084
+ ! Declarations:
3085
+ IMPLICIT NONE
3086
+
3087
+ !* Subroutine arguments
3088
+ ! Scalar arguments with intent(in):
3089
+ INTEGER, INTENT (IN) :: N ! width of the epsilon-table
3090
+
3091
+ ! Array arguments with intent(inout):
3092
+ REAL*8, INTENT (INOUT) :: S(0:N) ! sequential row of the epsilon-table
3093
+
3094
+ ! Scalar arguments with intent(out)
3095
+ REAL*8, INTENT (OUT) :: rLimes ! value of the series limes
3096
+ INTEGER, INTENT (OUT) :: i_Pade ! power of the numerator
3097
+ INTEGER, INTENT (OUT) :: k_Pade ! power of the denominator
3098
+ REAL*8, INTENT (OUT) :: err ! empirical error
3099
+
3100
+ !* End of Subroutine arguments
3101
+
3102
+ ! Local parameters ! these two need no description ;-)
3103
+ REAL*8, PARAMETER :: zero = 0.0
3104
+ REAL*8, PARAMETER :: one = 1.0
3105
+
3106
+ ! Local scalars
3107
+ REAL*8 :: A_max ! maximum element of A
3108
+ INTEGER :: i ! index variable for columns
3109
+ INTEGER :: k ! index variable for rows
3110
+
3111
+ ! Local arrays
3112
+ REAL*8 :: A(0:N) ! auxiliary row of the epsilon-table
3113
+
3114
+ !- End of header --------------------------------------------------------------
3115
+
3116
+ ! Parse input: the algorithm cannot employ more elements than supplied on
3117
+ ! input, i.e. N <= size(S)
3118
+ !
3119
+ IF ( N > SIZE (S(:)) ) THEN
3120
+ WRITE (*, '(A)') '*** Illegal input to Limes: N > size(S)'
3121
+ STOP 1
3122
+ END IF
3123
+
3124
+ ! Algorithm not applicable for N < 2
3125
+ !
3126
+ IF ( N < 2 ) THEN
3127
+ WRITE (*, '(A)') '*** Illegal input to Limes: N < 2'
3128
+ STOP 2
3129
+ END IF
3130
+
3131
+ !-----------------------------------------------------------------------------
3132
+ ! I. Initialize with natural assignments
3133
+ !-----------------------------------------------------------------------------
3134
+
3135
+ rLimes = S(N) ! the N-th partial sum
3136
+ err = ABS ( S(N) - S(N-1) ) ! error -> |S(N) - S(N-1)|
3137
+ i_Pade = N ! Pade approximant [N/0]
3138
+ k_Pade = 0 !
3139
+ A(:) = zero ! auxiliary row initially set to zero
3140
+ A_max = zero ! max. element set to zero
3141
+ k = 1 ! algorithm starts from the first row
3142
+
3143
+ !-----------------------------------------------------------------------------
3144
+ ! II. Main loop: fill in the epsilon table, check for convergence ...
3145
+ ! (provision against division by zero employs pseudo-inverse numbers)
3146
+ !-----------------------------------------------------------------------------
3147
+ DO
3148
+ IF ( N - 2 * k + 1 < 0 ) EXIT
3149
+
3150
+ ! Update the auxiliary row A(i) of the epsilon-table
3151
+ ! by applying the "cross rule".
3152
+ !
3153
+ DO i=0, N - 2 * k + 1
3154
+ IF ( S(i+1) /= S(i) ) THEN
3155
+ A(i) = A(i+1) + one/(S(i+1) - S(i))
3156
+ ELSE
3157
+ A(i) = A(i+1)
3158
+ END IF
3159
+ END DO
3160
+ IF ( N - 2 * k < 0 ) EXIT
3161
+
3162
+ ! Update the sequential row S(i) of the epsilon-table
3163
+ ! by applying the "cross rule".
3164
+ !
3165
+ DO i=0, N - 2 * k
3166
+ IF ( A(i+1) /= A(i) ) THEN
3167
+ S(i) = S(i+1) + one/(A(i+1) - A(i))
3168
+ ELSE
3169
+ S(i) = S(i+1)
3170
+ END IF
3171
+
3172
+ ! Check for convergence, based on A_max; see Ref. [1]
3173
+ !
3174
+ IF ( ABS ( A(i) ) > A_max ) THEN
3175
+ A_max = ABS ( A(i) )
3176
+ rLimes = S(i)
3177
+ k_Pade = k
3178
+ i_Pade = i + k_Pade
3179
+ err = one/A_max
3180
+ IF ( S(i+1) == S(i) ) RETURN
3181
+ END IF
3182
+ END DO
3183
+ k = k + 1 ! increment row index
3184
+ END DO
3185
+
3186
+ END SUBROUTINE Limes
3187
+
3188
+
3189
+ !
3190
+ ! ============================================================================
3191
+ ! Purpose: Compute modified Bessel functions I0(x), I1(1),
3192
+ ! K0(x) and K1(x), and their derivatives
3193
+ ! License:
3194
+ !
3195
+ ! This routine is copyrighted by Shanjie Zhang and Jianming Jin. However,
3196
+ ! they give permission to incorporate this routine into a user program
3197
+ ! provided that the copyright is acknowledged.
3198
+ !
3199
+ ! Author:
3200
+ !
3201
+ ! Shanjie Zhang, Jianming Jin
3202
+ !
3203
+ ! Reference:
3204
+ !
3205
+ ! Shanjie Zhang, Jianming Jin,
3206
+ ! Computation of Special Functions,
3207
+ ! Wiley, 1996,
3208
+ ! ISBN: 0-471-11963-6,
3209
+ ! LC: QA351.C45.
3210
+ !
3211
+ ! Modified on:
3212
+ ! 25 July 2017, by Yingyi Liu
3213
+ !
3214
+ ! Parameters:
3215
+ ! Input : x --- Argument ( x � 0 )
3216
+ ! Output: BK0 --- K0(x)
3217
+ ! BK1 --- K1(x)
3218
+ ! ============================================================================
3219
+ !
3220
+
3221
+ SUBROUTINE IK01A(X,BK0,BK1)
3222
+
3223
+ IMPLICIT NONE
3224
+ INTEGER K,K0
3225
+ REAL*8 PI,EL,X,X2,BI0,BI1,BK0,BK1,R,XR,CA,CT,W0,WW,CB,XR2
3226
+ REAL*8 A(12),B(12),A1(8)
3227
+
3228
+ PI=3.141592653589793D0
3229
+ EL=0.5772156649015329D0
3230
+ X2=X*X
3231
+ IF (X.EQ.0.0D0) THEN
3232
+ BI0=1.0D0
3233
+ BI1=0.0D0
3234
+ BK0=1.0D+300
3235
+ BK1=1.0D+300
3236
+ RETURN
3237
+ ELSE IF (X.LE.18.0D0) THEN
3238
+ BI0=1.0D0
3239
+ R=1.0D0
3240
+ DO K=1,50
3241
+ R=0.25D0*R*X2/(K*K)
3242
+ BI0=BI0+R
3243
+ IF (DABS(R/BI0).LT.1.0D-15) EXIT
3244
+ ENDDO
3245
+ BI1=1.0D0
3246
+ R=1.0D0
3247
+ DO K=1,50
3248
+ R=0.25D0*R*X2/(K*(K+1))
3249
+ BI1=BI1+R
3250
+ IF (DABS(R/BI1).LT.1.0D-15) EXIT
3251
+ ENDDO
3252
+ BI1=0.5D0*X*BI1
3253
+ ELSE
3254
+ DATA A/0.125D0,7.03125D-2, &
3255
+ 7.32421875D-2,1.1215209960938D-1, &
3256
+ 2.2710800170898D-1,5.7250142097473D-1, &
3257
+ 1.7277275025845D0,6.0740420012735D0, &
3258
+ 2.4380529699556D01,1.1001714026925D02, &
3259
+ 5.5133589612202D02,3.0380905109224D03/
3260
+ DATA B/-0.375D0,-1.171875D-1, &
3261
+ -1.025390625D-1,-1.4419555664063D-1, &
3262
+ -2.7757644653320D-1,-6.7659258842468D-1, &
3263
+ -1.9935317337513D0,-6.8839142681099D0, &
3264
+ -2.7248827311269D01,-1.2159789187654D02, &
3265
+ -6.0384407670507D02,-3.3022722944809D03/
3266
+ K0=12
3267
+ IF (X.GE.35.0) K0=9
3268
+ IF (X.GE.50.0) K0=7
3269
+ CA=DEXP(X)/DSQRT(2.0D0*PI*X)
3270
+ BI0=1.0D0
3271
+ XR=1.0D0/X
3272
+ DO K=1,K0
3273
+ BI0=BI0+A(K)*XR**K
3274
+ ENDDO
3275
+ BI0=CA*BI0
3276
+ BI1=1.0D0
3277
+ DO K=1,K0
3278
+ BI1=BI1+B(K)*XR**K
3279
+ ENDDO
3280
+ BI1=CA*BI1
3281
+ ENDIF
3282
+ IF (X.LE.9.0D0) THEN
3283
+ CT=-(DLOG(X/2.0D0)+EL)
3284
+ BK0=0.0D0
3285
+ W0=0.0D0
3286
+ R=1.0D0
3287
+ DO K=1,50
3288
+ W0=W0+1.0D0/K
3289
+ R=0.25D0*R/(K*K)*X2
3290
+ BK0=BK0+R*(W0+CT)
3291
+ IF (DABS((BK0-WW)/BK0).LT.1.0D-15) EXIT
3292
+ WW=BK0
3293
+ ENDDO
3294
+ BK0=BK0+CT
3295
+ ELSE
3296
+ DATA A1/0.125D0,0.2109375D0, &
3297
+ 1.0986328125D0,1.1775970458984D01, &
3298
+ 2.1461706161499D02,5.9511522710323D03, &
3299
+ 2.3347645606175D05,1.2312234987631D07/
3300
+ CB=0.5D0/X
3301
+ XR2=1.0D0/X2
3302
+ BK0=1.0D0
3303
+ DO K=1,8
3304
+ BK0=BK0+A1(K)*XR2**K
3305
+ ENDDO
3306
+ BK0=CB*BK0/BI0
3307
+ ENDIF
3308
+ BK1=(1.0D0/X-BI1*BK0)/BI0
3309
+
3310
+ RETURN
3311
+ END
3312
+
3313
+ !
3314
+ ! ============================================================================
3315
+ ! Purpose: Compute Bessel functions J0(x), J1(x), Y0(x),
3316
+ ! Y1(x), and their derivatives
3317
+ ! License:
3318
+ !
3319
+ ! This routine is copyrighted by Shanjie Zhang and Jianming Jin. However,
3320
+ ! they give permission to incorporate this routine into a user program
3321
+ ! provided that the copyright is acknowledged.
3322
+ !
3323
+ ! Author:
3324
+ !
3325
+ ! Shanjie Zhang, Jianming Jin
3326
+ !
3327
+ ! Reference:
3328
+ !
3329
+ ! Shanjie Zhang, Jianming Jin,
3330
+ ! Computation of Special Functions,
3331
+ ! Wiley, 1996,
3332
+ ! ISBN: 0-471-11963-6,
3333
+ ! LC: QA351.C45.
3334
+ !
3335
+ ! Modified on:
3336
+ ! 25 July 2017, by Yingyi Liu
3337
+ !
3338
+ ! Parameters:
3339
+ ! Input : x --- Argument of Jn(x) & Yn(x) ( x � 0 )
3340
+ ! Output: BJ0 --- J0(x)
3341
+ ! BJ1 --- J1(x)
3342
+ ! BY0 --- Y0(x)
3343
+ ! BY1 --- Y1(x)
3344
+ ! ============================================================================
3345
+ !
3346
+ SUBROUTINE JY01B(X,BJ0,BJ1,BY0,BY1)
3347
+
3348
+ IMPLICIT NONE
3349
+ REAL*8 PI,X,BJ0,BY0,T,T2,A0,P0,Q0,TA0,BJ1,BY1,P1,Q1,TA1
3350
+
3351
+ PI=3.141592653589793D0
3352
+ IF (X.EQ.0.0D0) THEN
3353
+ BJ0=1.0D0
3354
+ BJ1=0.0D0
3355
+ BY0=-1.0D+300
3356
+ BY1=-1.0D+300
3357
+ RETURN
3358
+ ELSE IF (X.LE.4.0D0) THEN
3359
+ T=X/4.0D0
3360
+ T2=T*T
3361
+ BJ0=((((((-.5014415D-3*T2+.76771853D-2)*T2-.0709253492D0)*T2+.4443584263D0) &
3362
+ *T2-1.7777560599D0)*T2+3.9999973021D0)*T2-3.9999998721D0)*T2+1.0D0
3363
+ BJ1=T*(((((((-.1289769D-3*T2+.22069155D-2)*T2-.0236616773D0)*T2+.1777582922D0) &
3364
+ *T2-.8888839649D0)*T2+2.6666660544D0)*T2-3.9999999710D0)*T2+1.9999999998D0)
3365
+ BY0=(((((((-.567433D-4*T2+.859977D-3)*T2-.94855882D-2)*T2+.0772975809D0)*T2-.4261737419D0) &
3366
+ *T2+1.4216421221D0)*T2-2.3498519931D0)*T2+1.0766115157)*T2+.3674669052D0
3367
+ BY0=2.0D0/PI*DLOG(X/2.0D0)*BJ0+BY0
3368
+ BY1=((((((((.6535773D-3*T2-.0108175626D0)*T2+.107657606D0)*T2-.7268945577D0)*T2+3.1261399273D0) &
3369
+ *T2-7.3980241381D0)*T2+6.8529236342D0)*T2+.3932562018D0)*T2-.6366197726D0)/X
3370
+ BY1=2.0D0/PI*DLOG(X/2.0D0)*BJ1+BY1
3371
+ ELSE
3372
+ T=4.0D0/X
3373
+ T2=T*T
3374
+ A0=DSQRT(2.0D0/(PI*X))
3375
+ P0=((((-.9285D-5*T2+.43506D-4)*T2-.122226D-3)*T2+.434725D-3)*T2-.4394275D-2)*T2+.999999997D0
3376
+ Q0=T*(((((.8099D-5*T2-.35614D-4)*T2+.85844D-4)*T2-.218024D-3)*T2+.1144106D-2)*T2-.031249995D0)
3377
+ TA0=X-.25D0*PI
3378
+ BJ0=A0*(P0*DCOS(TA0)-Q0*DSIN(TA0))
3379
+ BY0=A0*(P0*DSIN(TA0)+Q0*DCOS(TA0))
3380
+ P1=((((.10632D-4*T2-.50363D-4)*T2+.145575D-3)*T2-.559487D-3)*T2+.7323931D-2)*T2+1.000000004D0
3381
+ Q1=T*(((((-.9173D-5*T2+.40658D-4)*T2-.99941D-4)*T2+.266891D-3)*T2-.1601836D-2)*T2+.093749994D0)
3382
+ TA1=X-.75D0*PI
3383
+ BJ1=A0*(P1*DCOS(TA1)-Q1*DSIN(TA1))
3384
+ BY1=A0*(P1*DSIN(TA1)+Q1*DCOS(TA1))
3385
+ ENDIF
3386
+
3387
+ RETURN
3388
+ END
3389
+
3390
+ !
3391
+ ! ============================================================================
3392
+ ! Purpose: Compute Bessel functions J0(x), J1(x), Y0(x),
3393
+ ! Y1(x), and their derivatives
3394
+ ! License:
3395
+ !
3396
+ ! This routine is copyrighted by Shanjie Zhang and Jianming Jin. However,
3397
+ ! they give permission to incorporate this routine into a user program
3398
+ ! provided that the copyright is acknowledged.
3399
+ !
3400
+ ! Author:
3401
+ !
3402
+ ! Shanjie Zhang, Jianming Jin
3403
+ !
3404
+ ! Reference:
3405
+ !
3406
+ ! Shanjie Zhang, Jianming Jin,
3407
+ ! Computation of Special Functions,
3408
+ ! Wiley, 1996,
3409
+ ! ISBN: 0-471-11963-6,
3410
+ ! LC: QA351.C45.
3411
+ !
3412
+ ! Modified on:
3413
+ ! 25 July 2017, by Yingyi Liu
3414
+ !
3415
+ ! Description:
3416
+ ! This is a derived version from the subroutine JY01B.
3417
+ !
3418
+ ! Parameters:
3419
+ ! Input : x --- Argument of Jn(x) & Yn(x) ( x � 0 )
3420
+ ! Output: BJ0 --- J0(x)
3421
+ ! BJ1 --- J1(x)
3422
+ ! ============================================================================
3423
+ !
3424
+ SUBROUTINE JY01BJ(X,BJ0,BJ1)
3425
+
3426
+ IMPLICIT NONE
3427
+ REAL*8 PI,X,BJ0,BJ1,T,T2,A0,P0,Q0,TA0,P1,Q1,TA1
3428
+
3429
+ PI=3.141592653589793D0
3430
+ IF (X.EQ.0.0D0) THEN
3431
+ BJ0=1.0D0
3432
+ BJ1=0.0D0
3433
+ RETURN
3434
+ ELSE IF (X.LE.4.0D0) THEN
3435
+ T=X/4.0D0
3436
+ T2=T*T
3437
+ BJ0=((((((-.5014415D-3*T2+.76771853D-2)*T2-.0709253492D0)*T2+.4443584263D0) &
3438
+ *T2-1.7777560599D0)*T2+3.9999973021D0)*T2-3.9999998721D0)*T2+1.0D0
3439
+ BJ1=T*(((((((-.1289769D-3*T2+.22069155D-2)*T2-.0236616773D0)*T2+.1777582922D0) &
3440
+ *T2-.8888839649D0)*T2+2.6666660544D0)*T2-3.9999999710D0)*T2+1.9999999998D0)
3441
+ ELSE
3442
+ T=4.0D0/X
3443
+ T2=T*T
3444
+ A0=DSQRT(2.0D0/(PI*X))
3445
+ P0=((((-.9285D-5*T2+.43506D-4)*T2-.122226D-3)*T2+.434725D-3)*T2-.4394275D-2)*T2+.999999997D0
3446
+ Q0=T*(((((.8099D-5*T2-.35614D-4)*T2+.85844D-4)*T2-.218024D-3)*T2+.1144106D-2)*T2-.031249995D0)
3447
+ TA0=X-.25D0*PI
3448
+ BJ0=A0*(P0*DCOS(TA0)-Q0*DSIN(TA0))
3449
+ P1=((((.10632D-4*T2-.50363D-4)*T2+.145575D-3)*T2-.559487D-3)*T2+.7323931D-2)*T2+1.000000004D0
3450
+ Q1=T*(((((-.9173D-5*T2+.40658D-4)*T2-.99941D-4)*T2+.266891D-3)*T2-.1601836D-2)*T2+.093749994D0)
3451
+ TA1=X-.75D0*PI
3452
+ BJ1=A0*(P1*DCOS(TA1)-Q1*DSIN(TA1))
3453
+ ENDIF
3454
+
3455
+ RETURN
3456
+ END
3457
+
3458
+ !
3459
+ ! ============================================================================
3460
+ ! Purpose: Compute Bessel functions J0(x), J1(x), Y0(x),
3461
+ ! Y1(x), and their derivatives
3462
+ ! License:
3463
+ !
3464
+ ! This routine is copyrighted by Shanjie Zhang and Jianming Jin. However,
3465
+ ! they give permission to incorporate this routine into a user program
3466
+ ! provided that the copyright is acknowledged.
3467
+ !
3468
+ ! Author:
3469
+ !
3470
+ ! Shanjie Zhang, Jianming Jin
3471
+ !
3472
+ ! Reference:
3473
+ !
3474
+ ! Shanjie Zhang, Jianming Jin,
3475
+ ! Computation of Special Functions,
3476
+ ! Wiley, 1996,
3477
+ ! ISBN: 0-471-11963-6,
3478
+ ! LC: QA351.C45.
3479
+ !
3480
+ ! Modified on:
3481
+ ! 25 July 2017, by Yingyi Liu
3482
+ !
3483
+ ! Description:
3484
+ ! This is a derived version from the subroutine JY01B.
3485
+ !
3486
+ ! Parameters:
3487
+ ! Input : x --- Argument of Jn(x) & Yn(x) ( x � 0 )
3488
+ ! Output: BJ0 --- J0(x)
3489
+ ! BJ1 --- J1(x)
3490
+ ! BY0 --- Y0(x)
3491
+ ! BY1 --- Y1(x)
3492
+ ! ============================================================================
3493
+ !
3494
+ SUBROUTINE JY01BY0(X,BY0)
3495
+
3496
+ IMPLICIT NONE
3497
+ REAL*8 PI,X,BJ0,BY0,T,T2,A0,P0,Q0,TA0
3498
+
3499
+ PI=3.141592653589793D0
3500
+ IF (X.EQ.0.0D0) THEN
3501
+ BJ0=1.0D0
3502
+ BY0=-1.0D+300
3503
+ RETURN
3504
+ ELSE IF (X.LE.4.0D0) THEN
3505
+ T=X/4.0D0
3506
+ T2=T*T
3507
+ BJ0=((((((-.5014415D-3*T2+.76771853D-2)*T2-.0709253492D0)*T2+.4443584263D0) &
3508
+ *T2-1.7777560599D0)*T2+3.9999973021D0)*T2-3.9999998721D0)*T2+1.0D0
3509
+ BY0=(((((((-.567433D-4*T2+.859977D-3)*T2-.94855882D-2)*T2+.0772975809D0)*T2 &
3510
+ -.4261737419D0)*T2+1.4216421221D0)*T2-2.3498519931D0)*T2+1.0766115157)*T2+.3674669052D0
3511
+ BY0=2.0D0/PI*DLOG(X/2.0D0)*BJ0+BY0
3512
+ ELSE
3513
+ T=4.0D0/X
3514
+ T2=T*T
3515
+ A0=DSQRT(2.0D0/(PI*X))
3516
+ P0=((((-.9285D-5*T2+.43506D-4)*T2-.122226D-3)*T2+.434725D-3)*T2-.4394275D-2)*T2+.999999997D0
3517
+ Q0=T*(((((.8099D-5*T2-.35614D-4)*T2+.85844D-4)*T2-.218024D-3)*T2+.1144106D-2)*T2-.031249995D0)
3518
+ TA0=X-.25D0*PI
3519
+ BY0=A0*(P0*DSIN(TA0)+Q0*DCOS(TA0))
3520
+ ENDIF
3521
+
3522
+ RETURN
3523
+ END
3524
+
3525
+ !
3526
+ ! ============================================================================
3527
+ ! Purpose: Compute Bessel functions J0(x), J1(x), Y0(x),
3528
+ ! Y1(x), and their derivatives
3529
+ ! License:
3530
+ !
3531
+ ! This routine is copyrighted by Shanjie Zhang and Jianming Jin. However,
3532
+ ! they give permission to incorporate this routine into a user program
3533
+ ! provided that the copyright is acknowledged.
3534
+ !
3535
+ ! Author:
3536
+ !
3537
+ ! Shanjie Zhang, Jianming Jin
3538
+ !
3539
+ ! Reference:
3540
+ !
3541
+ ! Shanjie Zhang, Jianming Jin,
3542
+ ! Computation of Special Functions,
3543
+ ! Wiley, 1996,
3544
+ ! ISBN: 0-471-11963-6,
3545
+ ! LC: QA351.C45.
3546
+ !
3547
+ ! Modified on:
3548
+ ! 25 July 2017, by Yingyi Liu
3549
+ !
3550
+ ! Description:
3551
+ ! This is a derived version from the subroutine JY01B.
3552
+ !
3553
+ ! Parameters:
3554
+ ! Input : x --- Argument of Jn(x) & Yn(x) ( x � 0 )
3555
+ ! Output: BY1 --- Y1(x)
3556
+ ! ============================================================================
3557
+ !
3558
+ SUBROUTINE JY01BY1(X,BY1)
3559
+
3560
+ IMPLICIT NONE
3561
+ REAL*8 PI,X,BJ1,BY1,T,T2,A0,P1,Q1,TA1
3562
+
3563
+ PI=3.141592653589793D0
3564
+ IF (X.EQ.0.0D0) THEN
3565
+ BJ1=0.0D0
3566
+ BY1=-1.0D+300
3567
+ RETURN
3568
+ ELSE IF (X.LE.4.0D0) THEN
3569
+ T=X/4.0D0
3570
+ T2=T*T
3571
+ BJ1=T*(((((((-.1289769D-3*T2+.22069155D-2)*T2-.0236616773D0)*T2+.1777582922D0) &
3572
+ *T2-.8888839649D0)*T2+2.6666660544D0)*T2-3.9999999710D0)*T2+1.9999999998D0)
3573
+ BY1=((((((((.6535773D-3*T2-.0108175626D0)*T2+.107657606D0)*T2-.7268945577D0)*T2+3.1261399273D0) &
3574
+ *T2-7.3980241381D0)*T2+6.8529236342D0)*T2+.3932562018D0)*T2-.6366197726D0)/X
3575
+ BY1=2.0D0/PI*DLOG(X/2.0D0)*BJ1+BY1
3576
+ ELSE
3577
+ T=4.0D0/X
3578
+ T2=T*T
3579
+ A0=DSQRT(2.0D0/(PI*X))
3580
+ P1=((((.10632D-4*T2-.50363D-4)*T2+.145575D-3)*T2-.559487D-3)*T2+.7323931D-2)*T2+1.000000004D0
3581
+ Q1=T*(((((-.9173D-5*T2+.40658D-4)*T2-.99941D-4)*T2+.266891D-3)*T2-.1601836D-2)*T2+.093749994D0)
3582
+ TA1=X-.75D0*PI
3583
+ BY1=A0*(P1*DSIN(TA1)+Q1*DCOS(TA1))
3584
+ ENDIF
3585
+
3586
+ RETURN
3587
+ END
3588
+
3589
+ end module fingreen3D_module