program grating c Program GRATING computes the exact reflection and transmission c coefficients for a p.e.c. strip grating. For this exact c solution, the strip width to cell size ratio is 0.5 and the c excitation is normally incident. The solution is due to Weinstein using c the factorization method. c The geometry is c | c | c \ / c . c c ... ----- ----- ----- ----- ... (in/out of screen) c |<--Ty-->| c c where Ty is measured in wavelengths. THE MAXIMUM CELL SIZE IN c WAVELENGTHS IS 1.0 c c The field reflection and transmission coefficients are computed for the c polarization with the electric field perpendicular to the grid. c For the polarization with the electric field parallel to the grid simply c interchange R and T. Cell sizes are entered as input. c Tom Cwik c December 1985 c Compiler: Fortan77 c Libraries: None c Max_iss is the max number of terms allowd in the summation. Tol is c the difference between terms necessary to terminate the summation. parameter(max_iss = 1000, tol = 0.0001) complex r0,rr0,tt0,cj open(1,file='grating.dat') cj = (0.0,1.0) write(1,8) 8 format(5x,'Ty',6x,'|R|',5x,' 2x,'TERMS SUMMED') write(*,*) 'ENTER: BEGIN Ty, END Ty, DELTA Ty' read(*,*) Tyb,Tye,dTy if(Tye .gt. .99999) then write(*,*) 'MAX Ty OF 1.0 EXCEEDED, Ty END = ',Tye,' ENTERED' stop endif npts = (Tye-Tyb)/dTy + 1 do 1 n = 0,npts-1 Ty = Tyb + n*dTy theta = 0.0 theta_o = 0.0 do 5 is = 1,max_iss theta = theta + asin(0.5*Ty/(float(is) - 0.5)) > - asin(0.5*Ty/float(is)) if(abs(theta-theta_o) .lt.tol) goto 10 theta_o = theta 5 continue 10 continue r0 = -cexp(-cj*2*theta) rr0 = 0.5*(r0+1) tt0 = -0.5*(r0-1) pchk = cabs(rr0)**2 + cabs(tt0)**2 write(1,7) Ty,cabs(rr0),phs(rr0),cabs(tt0),phs(tt0),pchk,is 1 continue 7 format(3x,f6.3,3x,2(f5.3,2x,f6.1,3x),2x,f5.3,5x,i4) stop end function phs(z) complex z pi = 4.*atan(1.) if(real(z).eq.0) then phs = 90. return endif phs = atan2(aimag(z),real(z))*180/pi return end