Bi-Conjugate Gradient Algorithm for Solution of Integral ...
Transcript of Bi-Conjugate Gradient Algorithm for Solution of Integral ...
this document downloaded from...
chet-aero.com
the wings of flight in an age
of adventure
Use of this document subject to the terms and conditions as stated on the website.
for more downloads visit our other sites Positive Infinity and vulcanhammer.net
.. ~•NO iiO~•OO•~ii .•O• N@ O~iO N00 Oiiiiiii•••••••••••••••H•H•HH•H•••HH••HH••••••••••°•£°°•••°•£•°••°•££••N A W CW°°N£•••• NOD O T? i 8i590iiiii~o~~iiiiiiO~i•@Oi,
Ii OOOOOON@ONIONNOOOOOOOON~iONO~oH ..........H••••••••°°°°°N°•I•••I°••°••°NN•°°°N•£°N° N@°N A V°°•°°•°°••NO•OýRifA Oi I O ioRoiiO•OOi
i @@iii@@iIi~ @@iiiiiiiii iiiii -ojgt Grad~ iiii@@i i@@iii i i•@ ien Alorth @@@i Souto of£Ii• iiiiiii
i~ ~ ~ ~ Itga Equat@@i ii i@@i@i@i@i@@i@ii~ •@@@ ionsi~i Ar@iisiing@i ini~i i Eiiie@@t@@@@ii@@@inii tii cii@i~@@ @ @@~ @i@I
S.. O~i=o==ooo==Oli== ===ooiiooooooooi Ol =oool oil iI ===i oiII oNOliOS catooOtie ioOOOOOriNn gio NOProOOOOONble m sO~~i~ili~II=o o OOO~lilI~iIii~iiiilo~ooNiOOllooo
Ii !i @ iili~i i ! i i ii i i i i ! i ! !i iii iiiiy=
::::::::::::: i iiiiiiiiiiiiiii i i i• i Ii iO~iN@O 0•00i NI~ 0 00000i 000NO~iNiiiNSiiiN 000iOniOOOiiNriNai SiO0nOghiO000000iii~@
......... iiiiiiiii===iiii O~IIo =IIlI~lIIO I~~lO~I~liiiiiii ° °•••••° •°•° °°••° °° ° ° ° °° ° ° =••°•° •°••°•••°••••••°U°°niiiiiiv eiiiliiirsiiiiiiiiiiiiiiiliiiiiiiitOlyo o f T u ls a•••••••••••••••••••••••••••••••••••••••••••
Klau Hatra an J. Merle Niiio
i l i ! @ @ i ........... .................. i@ @ @ @i i@ i i i @i£ .... @ i@@ ii@@ @@R eI @ @ @i@@s@ei @ia@..................................... rtmiiiiiiiiiiiiiiii iiiit
i~~iiiii@@@@EPTMBE 2004..... @@@@@@i@@@i~ii =
NAVAiiiiL@@@iii AI @@@@@@R WARFARE CNE WAP S M iiOiiiiiiiiiiiN..
@@@ ii ========== ........ iiiiiiii = NO@ O iON i==i~iO 0 0i OC Hii~iNOA L A K E C A= OO9i3iiiiii555 6O :1i0ON........................
~ ~ ~ ~~~~~~~~~~~~~~A p o a ........ ........ ...... .......................................... i@b@iut@ii iio @ii @ini@@iI i
Naval Air Warfare Center Weapons Division
FOREWORD
This report details the implementation of applying the bi-conjugant gradient algorithmto solve a volume integral equation. The integral equation is a solution to Maxwell 'sequations and involves scattering of a plane wave from a metallic nano-cyclinder. Thesolution algorithm is outlined, a numerical example is given, and a FORTRAN codelisting is provided. This work was done during a 2-month period at the Naval AirWarfare Center Weapons Division (NAWCWD), China Lake, California, during Juneand Ju ly 2004. The ONR-ASEE Fellowship Program funded it.
Th is report was reviewed for technical accuracy by Pamela L. Overfelt of the Sensorand Signal Sciences Div ision, Research Department, NAWCWD Code 4T4100D.
Approved byC. F. MARKARIAN,HeadResearch Department2 August 2004
Released for publication byKAREN HIGGINSDirector for Research and Engineering
NA WCWD Technical Publication 8590
Under authority ofD. J. VENLET
RADM, U.S. NavyCommander
Published by . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. Technical Information DivisionCollation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Cover, 11 leavesFirst printing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 copies
REPORT DOCUMENTATION PAGE I Form ApprovedOMB No. 070~IBB
Public reporting burden for this collection of Information Is estimated to average 1 hour per response, ind uding the time for reviewing instructions, searching existing datasources, gathering and mainta ining the data needed, and completing and reviewing the collection of information. Send comments regarding this burden estimate or anyother aspect of this collection of information, ind uding suggestions for reducing this burden, to Washington Headquarters Services, Directorate for Information Operationsand Reports , 1215 Jefferson Davis Highway , Suite 1204, Arlington , VA 22202-4302, and to the Office of Management and Budget. Paperwot1< Reduction Project (0704.0188) , Washinllton, D.C. 20503.1. AGENCY USE ONLY (Lea ve B/ank) 2. REPORT DATE 3. REPORT TYPE AND DATES COVER ED
September 2004 June-July 20044. TITlE AND SUBTITlE 5. FUNDING NUMBERS
Bi-Conjugate Gradient Algorithm for Solution of Integral EquationsArising in Electromagnetic Scattering Problems (U)6 AlffilOR(S)
Surendra Singh, Klaus Halterman, and J. Merle Elson7. PERFORMING ORGANIZATION NAME(S) AND ADDRESS(ES) 8. PERFORMING ORGANIZATION
REPORT NUMBER
Naval Air Warfare Center Weapons Division NAWCWD TP 8590China Lake, CA 93555-6100
9. SPONSORINGlM ONITORING AGENCY NAM E(S) AND ADDRESS(ES) 10. SPONSORINGlMONITORINGAGENCY REPORT NUMBER
Office ofNaval Research1900 N. Quincy Ave.Arlington , VA 2220111. SUPPLEMENTARY NOTES
12a DISTRIBUTIO N/AVAILABILITY STATE MENT 12b. DISTRIBUTION CODE
A Statement; public release; distribution unlimited.13. ABSTRACT {Ma Ximum 200 words)
(U) The hi-conjugate gradient (bi-CG) algorithm is applied to numerically solve linear equation systemsresulting from integral equations arising in electromagnetic scattering problems. The basic advantage ofusing this algorithm over traditional methods , such as matrix inversion, is that the algorithm is iterative innature . The iterative nature allows the user to control the residual error in the final solution. Also , thealgorithm can be implemented without storing the coefficient matrix, thus providing huge saving in storagerequirements. It was realized that the existing code that utilized matrix inversion to solve the linear equationsystem was limited to a coarse discretization of the geometry. This code could not handle very fine geometrydiscretization due to storage limitations. With the implementation of the bi-CG algorithm, this limitation wasovercome . The present code can very easily handle very fme discretizations, thereby vastly improving theutility of the computer code. This report outlines the bi-CG algorithm and provides its implementation tosolve an electromagnetic scattering problem of a nanowire illuminated by a plane wave. The report alsoincludes a complete FORTRAN listing of the code.
14. SUBJECT TERMS 15. NUMBER OF PAGES
Iterative Methods , Integral Equations, Electromagnetic Scattering, Bi- 21Conjugate Gradient Algorithm 16. PRICE CODE
17. SECURITY CLASSIFICATION l B. SECURITY CLASSIFICATION 19. SECURITY CLASSIF ICATION 20. LIMITATION OF ABSTRACTOF REPORT OF ABSTRACT OF THIS PAGE
UNCLASSIFIED UNCLASSIFIED UNCLASSIFIED SAR
NSN 7540-01-280- 5500 Standard Form 298 (Rev. 2-89)Prescnbed by ANSI Std. 239-18
29-102
UNCLASSIFIED
SECURITY CLASSIFICATION OF THIS PAGE (When Data Entered)
Standard Form 298 Back (Rev. 2-89) SECURITY CLASS IFICATION OF THIS PAGE
UNCLASSIFIED
NAWCWD TP 8590
CONTENTS
Introduction 3
Bi-Conjugate Gradient Method (hi-CG) 4
Application ofBi-CG Method To Solve an Intregal Equation 6
References 9
Appendix: FORTRAN Code of the Bi-CG Algorithm and Associated FunctionSubprograms. . . .. .. . . . . .. ..... . ... . .. .. .. .. .. . . . ... .. .. . .. . ..... . . .. . .. . . . . .. . .. . .. . . . . . . . .. .. 10
---~-----~-~---------~~~------_._----------- --
NAWCWD TP 8590
INTRODUCTION
The work described in this report was performed in collaboration with ProfessorSurendra Singh, who came to the Naval Air Warfare Center Weapons Division(NAWCWD), China Lake, California, during June and July 2004. Professor Singh, afaculty member in Electrical Engineering Department at The University of Tulsa, Tulsa,Oklahoma, was visiting as an Office of Naval Research-ASEE Summer Faculty Fellow.He worked in the Optics, RF and Material Physics Branch, Sensor and Signal SciencesDivision, Research Department. This work involved learning and implementing the biconjugate gradient algorithm in order to numerically solve linear equation systemsresulting from integral equations arising in electromagnetic scattering problems.
The hi-conjugate gradient (bi-CG) algorithm (Reference 1) is a well-known andestablished iterative technique to solve a system of linear equations of the form A x =b.In this equation the square matrix A and the source or excitation vector b are bothcomplex. The algorithm converges most rapidly if the matrix A is square, symmetric,and positive-definite, This does not imply that the algorithm is not suitable if the matrixis not symmetric. We have applied the algorithm to non-symmetric matrices with goodresults . Details of the bi-CG algorithm are provided in the next section. A variant of thisalgorithm, the bi-CG stabilized (bi-CGSTAB) algorithm (Reference 2), was alsoimplemented. But in the numerical experimentation, we found that the stabilized versiondid not provide any advantage over the earlier version. A very good source for a basicunderstanding of the conjugate gradient method is provided in Reference 3. In the BiConjugate Gradient Method section, we provide the solution of an integral equationknown as the Lippman-Schwinger equation. The 2-dimensional physical probleminvolves a plane wave incident on a cylinder. Note that the original computer code toobtain the numerical solution of the integral equation was developed by Klaus Haltennanand J. Merle Elson at China Lake . This code utilized matrix inversion to solve the systemof equations. The code was modified to accommodate the bi-CG algorithm. A listing ofthe FORTRAN code of the bi-CG algorithm and associated function subprograms isprovided in the Appendix.
3
NAWCWD TP 8590
BI-CONJUGATE GRADIENT METHOD (bi-CG)
The bi-Cfl method is an iterative technique used to solve a system of linear equationsof the form A x = b. The method is most suitable in situations where matrix A is so largethat storing the matrix may pose a significant storage problem. This means that themethod can be implemented without storing the entire A matrix. This is accomplished byjust calculating a single row or column of the matrix at a time. This provides tremendoussavings in storage requirements and allows the user to solve a very large system ofequations. Note that the savings in storage requirements comes at the cost of increasedcomputation time because each iteration of the algorithm requires computing theelements of matrix A twice. In order to increase the computational efficiency inevaluating the matrix elements, we found that the matrix elements involve thecomputation of two types of Hankel functions. The two Hankel function values arecomputed once and stored in two arrays. The arrays are then utilized in computing thematrix elements. This technique provided considerable saving in computation time. It isobserved that the bi-CG algorithm converges a little slower when the matrix A is dense,and that the convergence is faster when the matrix A is sparse. The pseudo-code for thebi-Cfl method is given below:
Initialize the following variables: conv = 10-4, rerr = 100, P=0, and the followingvectors: r = b, rn = 0, x = 0, p = 0, pn = 0, t = 0.
rn = r* (* denotes complex conjugate)vall = b*b
do i = I,nitmif rerr>conv
va12 = r*rrerr = abs(val2/vall)va13 = rn*rif (i* I) P= va13/vaI5p =r+ P ppn =rn + P pnt = A P (This operation can be performed by computing one
row ofA at a time, thus avoiding the storage of matrix A.)
val4 = pn*xa = va13/vaI4x =x+ap
4
NAWCWD TP 8590
r = r-att =transpose(A*) pn (This operation can be performed by
computing one column of the matrix A at a time, thus avoiding the storage of the matrixA.)
rn=rn-atval5 =va13
end ifend do
SUBROUTINE beg (b,nunks,nitm,eonv,ci,nit,rerr)
This subroutine iteratively solves a system of linear equations of the form [A][ei]=[b]using the bi-CO method. The subroutine does not require the storage of the matrix A.Rather it uses two function programs, arow and acol which provide a specific row orcolumn of the matrix, respectively. Note that vector x is replaced by ci.
Input Variables:
nunkns (integer) - Total number of unknowns
b (complex vector) - Righthand side or excitation vector oflength nunkns
nitm (integer) - Maximum number of iterations for bi-CO (typically set it equal tonunkns)
cony (real) - Convergence factor for bi-CO (typically 10-4 to IO-{;)
Output Variables:
ci (complex) - Solution vector oflength nunkns
icount (integer) - Number of iterations needed for bi-CO method to converge
rerr (real) - Residual error. The bi-CO algorithm will stop when the residual error (rerr)becomes less than the pre-specified convergence factor (conv).
FUNCTION arow(i, vee)
This function provides the ith row of matrix A and returns a vector, vec, of lengthnunkns.
5
NAWCWD TP 8590
Input: i (integer) - ith row number of matrix AOutput: vec (complex vector) - ith row ofmatrix A vector oflength, nunkns.
FUNCTION acol (j, vec)
This function provides the jth column of matrix, A, and returns a vector, vec, oflength nunkns.
Input:j (integer) - j th row number of matrix AOutput: vec (complex vector) - jth column of matrix A vector of length, nunkns.
COMPUTATION OF HANKEL FUNCTIONS HO AND HI
The tensor Green's function components require the evaluation of Hankel functionsHo andH.. Because the argument of the Hankel functions depends on the relativedistance between the source (x ',y ') and observation (x,y) point, it was determined thatthere are only a limited number of observation and source point combinations that arerepeated over and over again in the computation of the Green's function. The Hankelfunctions are computed for different combinations of source and observation points andstored in two arrays. Then the stored values are utilized in the computation of the tensorGreen's function, thereby reducing computation time by avoiding repeated computations .
APPLICATION OF bi-CG METHOD TO SOLVE ANINTERGAL EQUATION
Here we provide an example of solving a system of linear equations using the bi-CGmethod. The system of equations is obtained as part of the numerical solution of anintegral equation. The first attempt at solving the equations was done by using thetraditional approach of matrix inversion. However this required storing the matrix A Asthe dimensionality of the problem increased, thereby increasing the number of unknownsas well as the size of matrix A, it was clear that the resulting problem could not be solvedbecause of the limited storage capacity of the personal computer: hence the move to biCG method.
Consider a scattering system described by a dielectric function,E(r), embedded in an
infinite homogeneous background material, EB' When the system is illuminated by an
incident field, EO (r), the total electric field, E(r), is given by the following integralequation (Reference 4):
6
NAWCWD TP 8590
E(r) = EO(r) + f dr lG B(r,r') kg tic(r')E(r')v
where G B(r ,r') is the Green's tensor associated with the infinite background CB'
tiC(r) = C(r) - cB and the integration is over the entire scatterer volume, V. Toimplement a numerical solution to the above integral equation, we define a grid with Nmeshes. Each mesh, i, is centered at position, r., and has a volume, V;, i = 1,2,...N (for a
2-dimensional systems, V; will be replaced by the area of the mesh, i). Representing the
discretized electric field, E; = E(r;) , the dielectric constant, tic; = tic(r;) , and the
Green's function, GB(i,j) = G B(r;,rj ) , the integral equations can be written as a system
of linear equations:
The Green's tensor GB(r,r') is given by
G B(r,r') = l[G~ ]
[G~,]
[G~]
For a complete description of the Green's tensor components, refer to Reference 4.For a geometry with N meshes , N= nx*ny, where nx and ny represent the number ofdivisions of the scatterer in x and y directions , respectively, the total number of unknownsis 3*N to account for the three components of the electric field. Each of the sub-matricesin the tensor Green 's function is now of the order of NxN. Now we provide a 2dimensional scattering problem that uses the above formulation to compute the totalelectric field.
UME RICAL EXAMPLE
We provide a numerical example (Reference 5) utilizing the formulation presented inthis Section. We consider a metal wire of radius = 10 nm with a dielectric constant,E = (-1.07,0.29). The wavelength of the incident field is A=388 nm. The geometry is
discretized in a grid of 250x250 (nx=ny =250), resulting in a total of 125,000 (2*nx*ny )unknowns. The number of unknowns in this example is 2*nx*ny, as only twocomponents of the electric field are needed due to the polarization of the incident field .(Note that if we needed to store the matrix A of dimension (l25,000xI25,000), thestorage space needed would be very large. This provides the motivation for using the bi-
7
NAWCWDTP 8590
CG iterative method , in which case we do not store this matrix) . Figure 1 show theelectric field amplitude relative to the incident field around the wire as it is illuminatedwith a plane wave.
Contour Plot of Relative Field Amplitude
403530252015105
5
0-t===:;:===:Y=:::==r==o
35
40
30
.....-.EC 25-....Q)
+0#roC 20
"'CL-oo 150
I
>-10
X-Coordinate (nm)
FIGURE I. Contour Plot of Relative Field Amplitude.
8
NAWCWD TP 8590
REFERENCES
1. T. K. Sarkar and S. M. Rao. "The Application of Conjugate Gradient Method for theSolution of Electromagnetic Scattering From Arbitrarily Oriented Wire Antennas,"IEEE Trans. Antennas Propag., Vol. 32, No. 4 (April 1994), pp. 398-403.
2. H. A. Van Der Vorst. "Bi-CGSTAB: A Fast and Smoothly Converging Variant ofBi-CG for the Solution of Non-symmetric Linear Systems," SIAM J. Sci. andStatistical Computing, Vol. 13, No. 2 (March 1992), pp. 631-44.
3. Carnegie Mellon University. An Introduction to the Conjugate Gradient MethodWithout the Agonizing Pain, by J. R. Shewchuck. Pittsburgh, Pennsylvania, CMUSchool of Computer Science (http://www.cs.berkley.edu/-jrs/).
4. O. J. F. Martin and N. B. Piller. "Electromagnetic Scattering in PolarizableBackgrounds," Phys. Rev. E, Vol. 58, No. 3 (September 1998), pp. 3909-15.
5. J. P. Kottmann and O. J. F. Martin. "Plasmon Resonances of Silver Nanowires Witha Nonregular Cross Section," Phys. Rev. B, Vol. 64 (8 November 2001) 2354021:235402-10.
9
NAWCWD TP 8590
AppendixFORTRAN CODE OF THE BI-CG ALGORITHM AND ASSOCIATED
FUNCTION SUBPROGRAMS
Here is the listing of the computer code with subroutine beg and functionsubprograms arow and aeol:
bi-conjugant gradient (works)solution to integral equation for e-field
program bcg_methodimplicit nonereal,parameter :: systern_size=40 !total grid size i n nrnreal, parameter :: lambdaO=338 !incident wavelength i n nrnreal, parameter :: L=systern_size /lambdaO !total system size i n
wavelengthsinte g e r, parameter . . nx=60, ny=nx , nxy = nx*ny ! t o t a l number of grid
pointsinteger, parameter .. maxi=3*nxycomplex, parameter .. Im=(O., 1.),zero=(O., O.),one=(l., 0.)complex , dimension(l:3*nxy) .. EO,etotalinteger, dime nsion(l:3*nxy) :: i pivcomplex, d imens i o n ( l: 2* nxy ) : : HO, H1integer , d imension (l:nxy ) :: ix,jycomplex , dime nsion(l: nxy) : : epsreal:: a rg , r_eff,theta,psi, krh o , phi, pi , kx,ky,x,y, wc, wcda,dx,dyreal :: xd,yd, xp, ypcomplex : : mfac t or ,Mx,My ,Mz , k z ,eb , z l ,rnxx, myy , mz zinteger :: i,j,k,icount,ijreal::conv,rerr,rho1,rho2,rho3,rhoINTEGER : : clock_start,c1ock_end,c1ock_rateREAL :: ela p sed_time,fr eal :: r1
CALL SYSTEM_CLOCK (COUNT_RATE=clock_rate) ! Find the rateCALL SYSTEM_CLOCK(COUNT=clock_start) ! Start timing
conv= .OOOl
EO=O.eb=onedx=L/nxdy=dx!dy=.025 !grid size p e r wa ve leng t hpi = acos ( - 1 . )wc = 2. *pi
10
NAWCWD TP 8590
wc d a = wc ** 2 *dx*dytheta= 90.
phi = 90 .I p s i =O.kx=-cos(theta*pi /180 .)ky=- s in( theta*pi /180.)kz=O .k rho =sqrt(eb) !krho /kOr_ef f = sqrt(dx*dy/pi)rnf a c tor=wc*r_eff*Hl_fun(wc*r_eff*krho) /krho+2* Irn/(pi*krho**2 )Mx = I rn*p i/ 4* (2 .-kr h o **2 ) *rnf a c t o rMy=MxMz = Irn*pi /2 *(1 .-kz**2)*rnfactor
k = 0do i = 1 , nx
do j = 1, nyk = k + 1 !k goes up to ny*nxx =i*dxy = j*dyi x (k ) = ijy(k) = ja rg=kx*x+ky*yz l =exp(wc*Irn*arg)
EO(k) =z1*(cos(phi*pi /180.)*sin(theta*pi /180 .)*cos(psi*pi /180.) -&
! sin(phi*pi/180.)*sin(ps i*pi /180.»! EO(k+nxy) =
z1 *( s i n (phi *p i/1 8 0 . ) *s i n ( t h e t a *p i / 18 0 . ) *c os (p s i *p i/ 1 8 0 . ) +&! cos(phi*pi/180.)*sin(psi*pi /180.»!EO(k+2*nxy) = z1*cos(theta*pi /180.)* cos(ps i*pi /180.)
EO (k+2*nxy) = zlend do
end do
eps = zeror1=10./lambd a O !radius in wavelengths
choose sites of delta_epsilon over 20 gridk = 0do i = 1,nx
do j = 1,nyk = k + 1
eps(k) =zero! eps(k) = one*l.Srho1=sqrt(real(i -nx/2)**2+real(j -ny/2) **2)i f (rho1<=int(r1/dx» eps(k) = (-1.07,0.29) - one
r h o 2= s q r t (r e a l (i-nx/ 2 ) **2+r e a l ( j - ny/ 2 ) **2 )if (rho2< =3 .) eps(k) = (-100.,0.) - oner h o 3=s q r t (r e a l (i - 3 * (nx / 4 » **2 +r e a l ( j - ny/ 2 ) **2 )if (rho3 <=3.) eps(k) = (-100.,0.) - one
i f (i >= nx/2-S .and. i <= nx/2+S .and. &j >= ny/2 -S .and. j <= ny/2+S) eps(k) (-100.,0.) - one
! write(4S,44S) ix(k),jy(k) ,real(eps(k»end do
end do!clos e (4 S )
i =1do j=2, nxy
11
NAWCWD TP 8590
x = ix(i)*dx;y=jy(i)*dyxp = ix(j)*dx;yp = jy(j)*dyxd=x-xp;yd=y-yprho = sqrt(xd*xd+yd*yd)arg = wc*krho*rhoij=(ix(i)-ix(j))**2 + (jy(i)-jy(j))**2
HO (ij)=HO_fun(arg)H1(ij)=H1_fun(arg)end do
mxx=Mx-O.5myy=My-O.5mzz=Mz!*****************************************************************************
call bcg(EO,3*nxy,maxi,conv,etotal,icount,rerr)print *, 'number of iterations=',icount-1print *, 'the residual error =',rerr
! print *,testx!***********************************************************************
******
do k = 1, nxy ! Exx = ix(k)*dx ; y = jy(k)*dywrite(97,*) x*lambdaO, y*lambdaO, abs(etotal(k))end do
do k = nxy+1, 2*nxy !Eyx = ix(k-nxy)*dx ; y = jy(k-nxy)*dywrite(98,*) x*lambdaO, y*lambdaO, abs(etotal(k))end do
do k = 2*nxy+l, 3*nxy !Ezx = ix(k-2*nxy)*dx ; y = jy(k-2*nxy)*dywrite(99,*) x*lambdaO, y*lambdaO, abs(etotal(k))end do
do k=1,nxyx = ix(k)*dx ; y = jy(k)*dy
arg=etotal(k)*conjg(etotal(k))+etotal(k+nxy)*conjg(etotal(k+nxy))+etotal(k+2*nxy)*conjg(etotal(k+2*nxy))
write(96,*) x*lambdaO, y*lambdaO, argend do
!**********************************************************************.******
444 format(F6.3,lX,F6.3,1X,F6.3)
CALL SYSTEM_CLOCK (COUNT=clock_end) ! Stop timing! Calculate the elapsed time in seconds:elapsed_time=REAL((clock_end-clock_start))/clock_rateprint *, 'elapsed time =',elapsed_time/60., 'minutes'
contains
subroutine bcg(b,nunkns,nitm,conv,ci,nit,rerr)implicit nonecomplex, intent(in), dimension(1:nunkns) :: b
12
NAWCWD TP 8590
complex, intent(out), dimension(l:nunkns) :: ciinteger, intent(in) nunkns,nitminteger, intent(out) nitreal, intent(in) convreal, intent(out) rerrcomplex,dimension(l:nunkns) :: x,p,pn,r,rncomplex :: beta,alpha,vall,val2,val3,val4,val5,sumxinteger ::i
x=O;p=O;pn=O;ci=O;icount=O;beta=Orerr=lO0r=brn=conjg(r)vall=dot_.product(conjg(b),b)
do nit=1,nitm
if (rerr>conv) thenval2=dot-product(conjg(r),r)rerr=abs(val2/vall)val3=dotproduct(conjg(rn),r)if (nit/=l) beta=val3/val5p=r+beta*ppn=rn+beta*pn
forall (i=l:nunkns) x(i)=dotproduct(conjg(arow(i)),p)
val4=dot-product(conjg(pn),x)alpha=val3/val4ci=ci+alpha*pr=r-alpha*xforall (i=l:nunkns) x(i)=dotproduct(conjg(acol(i)),pn)
rn=rn-alpha*xval5=val3icount=icount+l
print *,'iteration#',nit-iprint *,'residual error',rerrelseexitend if
end doend subroutine bcg
function arow(i)implicit noneinteger, intent(in) :: icomplex, dimension(l:3*nxy) arowinteger :: j,n
n=nxy
do j=l,3*n
if (i<=n) then
if (j<=n) thenif (i==j) thenarow(j)=l.-mxx*eps(j)
elseif (eps(j)==zero) then
13
NAWCWD TP 8590
arow(j) =0.else
arow(j)=-gxx(i,j)*eps(j)end if
end ifelse if (j>n .and. j<=2*n) then
if (eps(j-n)==zero) thenarow(j)=O.elsearow(j)=-gxy(i,j-n)*eps(j-n)end if
else if (j>2*n) thenif (eps(j-2*n)==zero) then
arow(j)=O.elsearow(j)=-gxz(i,j-2*n)*eps(j-2*n)end if
end if
end if
if (i>n .and. i<=2*n) then
if (j<=n) thenif (eps(j)==zero) then
arow(j)=O.elsearow(j)=-gxy(i-n,j)*eps(j)
end ifelse if (j>n .and. j<= 2*n) thenif (i==j) then
arow(j)=l.-myy*eps(j-n)else
if (eps(j-n)==zero) thenarow(j)=O.elsearow(j)=-gyy(i-n,j-n)*eps(j-n)end if
end ifelse if (j>2*n) then
if (eps(j-2*n)==zero) thenarow(j)=O.else
arow(j)=-gyz(i-n ,j-2*n)*eps(j-2*n)end if
end ifend if
if (i>2*n) then
if (j<=n) thenif (eps(j)==zero) then
arow(j)=O.else
arow(j)=-gxz(i-2*n,j)*eps(j)end if
else if (j>n .and~ j<= 2*n) thenif (eps(j-n)==zero) then
arow(j)=O.
14
NAWCWD TP 8590
elsearow(j)=-gyz(i-2*n,j-n)*eps(j-n)end if
else if (j>2*n) thenif (i==j) then
arow(j)=1.-mzz*eps(j-2*n)else
if (eps(j-2*n) ==zero) thenarow(j)=O.else
arow(j)=-gzz(i-2*n,j-2*n)*eps(j-2*n)end if
end ifend if
end if
end doend function arow
function acol(j)implicit noneinteger, intent (in) .. jcomplex, dimension(1:3*nxy) .. acolinteger :: n , i
n=nxydo i=1,3*n
if (i<=n) then
if (j<=n) thenif (i==j) thenacol(i)=l.-mxx*eps(j)
elseif (eps(j)==zero) then
acol(i)=O.else
acol(i)=-gxx(i,j)*eps(j)end if
end ifelse if (j>n .and . j<=2*n) then
if (eps(j-n)==zero) thenacol(i)=O.else
acol(i)=-gxy(i,j-n)*eps(j-n)end if
else if (j>2*n) thenif (eps(j-2*n)==zero) then
acol(i)=O.else
acol(i)=-gxz(i,j-2*n)*eps(j-2*n)end if
end ifend if
if (i>n .and. i<=2*n) then
if (j<=n) thenif (eps(j)==zero) then
15
NAWCWD TP 8590
acol(i)=O.else
acol(i) =-gxy(i-n,j)*eps( j)end if
else if (j>n .and. j<= 2*n) thenif (i==j) then
acol(i) =l.-myy*eps(j-n)else
if (eps(j-n)==zero) thenacol(i)=O.else
acol(i)=-gyy(i-n,j-n)*eps(j-n)end if
end ifelse if (j>2*n) then
if (eps(j-2*n)==zero) thenacol(i)=O.else
acol(i)=-gyz(i-n,j-2*n)*eps(j-2*n)end if
end ifend if
if (i>2*n) then
if (j<=n) thenif (eps(j)==zero) then
acol(i)=O .else
acol(i) =-gxz(i-2*n,j)*eps(j)end if
else if (j>n .and. j<= 2*n) thenif (eps(j-n)==zero) then
acol(i)=O.else
acol(i)=-gyz(i-2*n,j-n)*eps(j-n)end if
else if (j>2*n) thenif (i==j) then
acol(i)=1.-mzz*eps(j-2*n)elseif (eps(j-2*n)==zero) then
acol(i)=O.else
acol(i)=-gzz(i-2*n,j-2*n)*eps(j-2*n)end if
end ifend if
end if
end doend function acol
complex function gxx(i,j)implicit none
16
NAWCWD TP 8590
integer, intent (in) :: i,jinteger:: i j,difl,dif2real :: rho,x,y,xp,yp,rx,ry,c2theta ,xd,yd
x = i x (i ) *dx; y = jy(i)*dyxp = i x ( j ) *dx ; yp = jy(j)*dyxd=x-xp;yd=y -yprho = sqrt(xd*xd+yd*yd)d ifl= i x ( i ) - i x (j ) ; d i f 2= j y ( i )-jy(j )ij =difl*difl+dif2*dif2rx = xd /rhory = yd /rhoc 2 t h eta=r x *r x- ry*rygxx=wcda*Im/4.*((1 . -
krho*rx*krho*rx)*HO(ij)+krho*c2theta*Hl(ij) /(wc*rho))
end function gxx
complex function gxy(i,j)implicit noneinteger, intent (in) :: i,jinteger : : ij,difl,dif2real :: rho,x,y,xp,yp,rx,ry,s2theta,xd,ydif(i /= j) thenx = ix(i)*dx;y=jy(i)*dyxp = ix(j)*dx;yp=jy(j)*dyxd=x-xp;yd=y-yprho = sqrt(xd*xd+yd*yd)arg = wc *krho*rhod ifl= i x ( i ) - i x ( j ) ; d i f 2= j y ( i ) - j y ( j )i j=d i f l *d i f l +d i f 2 *d i f 2rx = xd/rhory = yd/rhos2theta=2*ry*rx
gxy=wcda*Im/8.*krho*krho*s2theta*(2./arg*Hl(ij) -HO(ij))elsegxy = zeroend if
end function gxy
complex function gxz(i,j)implicit none
integer, intent (in) : : i,jinteger :: ij,difl,dif2real :: rho,x,y,xp,yp,rx,xd,ydif(i /= j) thenx =ix(i)*dx ; y =jy(i)*dyxp=ix(j)*dx ; yp=jy(j)*dyxd=x-xp;yd=y-yprho = sqrt(xd*xd+yd*yd)arg = wc*krho*rhodifl= ix(i)-ix(j);dif2=jy(i)-jy(j)i j =difl*difl+dif2*dif2rx = xd/rhogxz=wcda*1./4 . *krho*kz*rx*Hl (ij)elsegxz = zeroend if
end f un c t i on gxz
17
NAWCWD TP 8590
c omple x f unction gyy(i, j )i mp l i c i t nonei n t e g e r , intent (in ) :: i, ji n t e g e r :: ij , d i f l, d i f 2real :: rho ,x ,y,xp ,yp ,rx,ry,c2theta,xd,ydx =i x( i ) *dx iy=jy( i )*dyxp=ix( j)*dx iYP=jy(j)*dyXd=X-XPiyd=y-yprho = sqrt(xd*xd+yd*yd)arg = wc*krho*rhodifl= ix (i)-ix(j);dif2=jy( i) - jy( j )ij =difl*difl+dif2*dif2rx = xd/rhory = yd/rhoc2theta=rx*rx-ry*rygyy=wcda*Im/4 .*((1 .-krho*ry*krho*ry)*HO(ij) -
krho*c2theta*Hl(ij)/(wc*rho))
end function gyy
complex function gyz(i,j)implicit noneinteger , intent (in) :: i, jinteger :: ij ,difl,dif2real:: rho,x,y,xp,yp,ry,xd,ydif(i 1= j) thenx =ix (i)*dx ;y = jy( i )*dyxp=ix(j)*dx ;yp= jy( j)*dyxd=x-xp;yd=y-yprho = sqrt(xd*xd+yd*yd)arg=wc*krho*rhodifl = ix (i ) -ix(j)idif2=jy (i ) - jy( j )ij =difl*difl+dif2*dif2ry=yd/rhogyz=wcda*l. 14 . *krho*kz*ry*Hl (ij)elsegyz = zeroend if
end function gyz
complex f unction gzz (i ,j)implicit noneinteger, intent (in) :: i,jinteger :: ij,difl,dif2real : : rho, x,y,xp,yp,xd,ydx = ix(i)*dx ; y = jy(i)*dyxp = ix(j)*dx i yp = jy(j)*dyxd=x-xp;yd=y-yprho = sqrt(xd*xd+yd*yd)arg = wc*krho*rhodifl= ix(i)-ix(j);dif2=jy(i) - jy( j)i j=difl*difl+dif2*dif2gzz= wcda* Im/4.*(1.-kz*kz)*HO(ij)
end function gzz
FUNCTION HO_fun(z) RESULT (HOou t )IMPLICIT NONEreal, INTENT (IN) :: zreal:: x,J_O,Y_O,f_O,theta,x2,x3,x4,x5,x6,x8,xlO,x12,sqz
18
NAWCWD TP 8590
complex: : HOout
if ( z <= 3.) thenx= z/ 3 .x2 =x*x;x4 =x2*x2;x6=x4*x2;x8=x6*x2;xlO=x8*x2;xl2 =xlO*x2J_O=1 .-2 . 2 4 9 9 9 97 *x 2 +1 . 2 65 62 0 8 *x 4- . 3 l 63 8 6 6 *x 6+ . 044 44 7 9 *x 8 . 0 03 9 4 4 4 *x l O+ . 00 02 l 0 0 *x 1 2Y_O=(2 /pi)*log(z/2.)*J_O+.3674669l+.60559366*x2.74350384*x4+ .25300ll7*x6-.04261214*x8+.00427916*xlO -.00024846*x12e l s ex =3. / zx 2=x*x;x3 =x2*x ;x4=x3*x;x5=x4*x;x6=x5*x;sqz=sqrt(z)f_O=. 7 97 8 84 5 6- . 0 0 00 0 07 7 *x- . 0 05 52 7 4 0*x 2 - . 0 0 0 0 9 5l 2 *x 3 +. 0 0 1 3 7 2 3 7 *x 4 &
- . 0 0 07 2 8 0 5 *x 5 + .OOOl4476*x6
t h e t a= z - . 7 8 53 9 8 l 6 - . 04 1 6 63 97 *x - . 0 0 0 03 9 54 *x 2 + . 0 02 62 57 3 *x 3 - . 0 0 0 54 l 2 5 *x 4 && - . 0 002 9 3 3 3 *x 5+ . OOOl 3 5 5 8 *x 6
J_O =f_O*cos(theta)/sqzY_O=f_O*sin(theta)/sqzend if
HOout=cmplx(J_O,Y_O)END FUNCTION HO_fun
FUNCTION Hl_fun(z) RESULT (Hlout)IMPLICIT NONEr e a l , INTENT (IN) :: zreal:: x,J_l,Y_l,f_l,thetal,x2,x3,x4.x5,x6.x8,xlO,xl2 ,sqzc omp l e x : : Hlout
if (z <= 3.) thenx =z /3.x2 =x*x;x4 =x2*x2;x6=x4*x2;x8=x6*x2;xlO=x8*x2;xl2=xlO*x2J _l=.5*z - .56249985*z*x2+.21093573*z*x4-.03954289*z*x6+.00443319*z*x8.0003l761*z*xlO+.OOOOl109*z*xl2
Y_l=(2 /pi)*log(z /2 .)*J_l-.6366l98/z+.22l209l*x2/z+2.1682709*x4 /z l . 31 64 8 27 *x 6 / z + . 31 2 3 9 51 *x 8 / z - . 04 0 0 97 6*x l O/ z + . 0 02 7 87 3 *x 1 2 / zelsex =3 . /zx2 =x*x;x3 =x2*x;x4=x3*x;x5=x4*x;x6=x5*Xisqz=sqrt(z)f_l= . 7 97 884 5 6+ . 0 0 0 0 01 5 6 *x + . Ol 65 9 6 67 *x 2 + . 0 0 01 7 1 0 5 *x 3 .0024951l*x4+.00ll3653*x5-.00020033*x6
thetal=z-2.356l9449+.12499612*x+.00005650*x2.00637879*x3+.00074348*x4+.00079824*x5-.00029l66*x6
J _l=f_l*cos(thetal)/sqzY_l=f_l*sin(thetal)/sqzend if
Hlout=cmplx(J_l.Y_l)END FUNCTION Hl_fun
end program bcg_method
19
INITIAL DISTRIBUTION
1 Naval War College, Newport (IE22, President)1 Headquarters , 497 INOT, Falls Church (lOG Representative)2 Defense Technical Information Center, Fort Belvoir1 Center for Naval Analyses, Alexandria, VA (Technical Library)8 Surenda Singh, Department of Electrical Engineering, The University ofTulsa, 600
S. College Avenue, Tulsa OK 74104
ON-SITE DISTRIBUTION
4 Code 4BLOOOD (3 plus Archives copy)1 Code 4TOOOOD, Markarian12 Code 4T411OD
Chesnut (1)Elson (5)Haltennan (5)Overfelt (I)