FUNCTION CRECT(MAPJ,R,U,V,T,SHAPE,WAVE) C Calcutates the complex coupling coefficient for the C Ith Floquet mode (P,Q,R), and the Jth waveguide mode C (M,N,L) for a rectangular waveguide. MAPJ holds the M,N,L C to J mapping information. While R is provided directly, C P,Q have already been incorporated into the transverse wave number C T=U^2+V^2. SHAPE holds all information on the aperature shape and C array configuration. COMPLEX*16 CRECT,TMNPQ,FACTOR,SCRECT REAL*8 EN,A,B,D1,D2,Z1,Z2,Z3,Z4,U,V,T,UT,UV,SHAPE(20),WAVE(5),PI INTEGER R LOGICAL DEBUG EXTERNAL SCRECT DATA PI /3.141592653589793D0/ DEBUG=.FALSE. IF (DEBUG) WRITE(*,*) 'Beginning Function CRECT.' C Umap M,N,L subscripts fom MAPJ CALL UNMAP(MAPJ,M,N,L) C Calculate Neumann factor for rectangular waveguide IF ((M.EQ.0).OR.(N.EQ.0)) THEN EN=2. ELSE EN=4. END IF C Calculate normalizing factor A=SHAPE(6) B=SHAPE(7) GMN=DBLE(SQRT((EN/(A*B))/((M/A)**2+(N/B)**2))) C Calculate factors common to all possible cases D1=U**2-(M*PI/A)**2 D2=V**2-(N*PI/B)**2 IF (DEBUG) WRITE(*,*) 'U,V,A,B,M,N,D1,D2: ',U,V,A,B,M,N,D1,D2 Z1=DBLE(COS(U*A/2.)) Z2=DBLE(SIN(U*A/2.)) Z3=DBLE(COS(V*B/2.)) Z4=DBLE(SIN(V*B/2.)) IF (T.EQ.0.) THEN C Case of normal incidence. UT=DBLE(COS(WAVE(3))) UV=DBLE(SIN(WAVE(3))) ELSE UT=U/T VT=V/T END IF IF ((D1.EQ.0.).OR.(D2.EQ.0.)) THEN C This is a special case where the standard closed form is C no longer valid CRECT=SCRECT(SHAPE,WAVE,M,N,L,R,U,V,T,D1,D2) RETURN END IF TMNPQ=(((-1)**M)*(Z1-(0,1)*Z2)-(Z1+(0,1)*Z2))* + (((-1)**N)*(Z3-(0,1)*Z4)-(Z3+(0,1)*Z4))/(D1*D2) FACTOR= -(0,1)*PI*GMN/DBLE(SQRT(SHAPE(3)*SHAPE(4))) IF (L.EQ.1) THEN IF (R.EQ.NINT(SHAPE(2))) THEN C find C(M,N,1;P,Q,1) if an inductive mesh or C C(M,N,1;P,Q,2) if a capacitive mesh CRECT=FACTOR*TMNPQ*(U*VT)*((N/B)**2+(M/A)**2) ELSE C find C(M,N,1;P,Q,2) if an inductive mesh or C C(M,N,1;P,Q,1) if a capacitive mesh CRECT=((-1)**R)*FACTOR*TMNPQ*T* + ((N*UT/B)**2-(M*VT/A)**2) END IF ELSE IF (R.EQ.NINT(SHAPE(2))) THEN C find C(M,N,2;P,Q,1) if an inductive mesh or C C(M,N,2;P,Q,2) if a capacitive mesh CRECT=(0.,0.) ELSE C find C(M,N,2;P,Q,2) if an inductive mesh or C C(M,N,2;P,Q,1) if a capacitive mesh CRECT=((-1)**(R+1))*FACTOR*TMNPQ*(M*N*T)/(A*B) END IF END IF RETURN END