PROGRAM RYA DEM C This program demonstrates the use of the coefficients calculated C by the programs trntrx. The program will produce a table of values C for different values of lambda and s as set in the DATA statements. C DOUBLE PRECISION DLAMDA(5),S(4),RYA,RYA11,RYA12,RYA21,RYA22 INTEGER I,J DATA DLAMDA/1D0,.5D0,.25D0,.125D0,2D0/ DATA S/2.01D0,2.1D0,2.5D0,3D0/ WRITE(6,200) 200 FORMAT(1X,'Table of values for Resistance Functions YA') DO 50 J=1,5 WRITE(6,1000)DLAMDA(J) 1000 FORMAT(/1X,'LAMBDA =',F8.3) WRITE(6,100) 100 FORMAT(/10X,'S',10X, & 'RYA(1,1)',8X,'RYA(1,2)',8X,'RYA(2,1)',8X,'RYA(2,2)') DO 50 I=1,4 RYA11=RYA(1,1,S(I),DLAMDA(J)) RYA12=RYA(1,2,S(I),DLAMDA(J)) RYA21=RYA(2,1,S(I),DLAMDA(J)) RYA22=RYA(2,2,S(I),DLAMDA(J)) 50 WRITE(6,1100)S(I),RYA11,RYA12,RYA21,RYA22 1100 FORMAT(F13.3,4F16.5) STOP END C DOUBLE PRECISION FUNCTION RYA(IALPHA,IBETA,S,DLAMDA) C ----------------------- Arguments of function ----------------------- INTEGER IALPHA,IBETA DOUBLE PRECISION S,DLAMDA C --------------------------------------------------------------------- C A C This routine calculates the functions Y (s,lambda) C ALPHA BETA C defined in Jeffrey & Onishi (1984) J. Fluid Mech. Vol 139, 261-290. C Coefficients calculated by one of the programs TRNTRx are summed using C equations (4.19)-(4.20). The subprogram uses equation (1.9a) to convert C any call to one in which lambda.LT.1. It goes forwards or backwards C through the coefficients ( ISTEP) depending upon whether I=1 or 2. C This technique is not explained in the paper; I have forgotten why. C Starting at equn 1.9 we see that Y can be obtained from Y C 22 11 C by inverting lambda. Now looking at equn 3.15 we substitute 1/lambda and C redefine q as k-q. Factoring the lambda**k, we see that lambda**q now C multiplies P(1,q,k-q), which means running 'backwards' through the C coefficients relative to the published case. C C In the program the coefficients are read in from ryaxxx.dat. C The xxx refers to the maximum summation index. There have been C several formats for the files, so the program checks this C first. C ------------------------ Local variables ---------------------------------- DOUBLE PRECISION RYACOF(0:45450),XL,XLP1,G2,G3,G2SUM,G3SUM DOUBLE PRECISION T,ZT,ZL,COEF,EPS INTEGER I,J,ISTEP,IQ,MMIN,MMAX,M,NM, MAXS LOGICAL LOADED CHARACTER*4 ID DATA LOADED/.FALSE./ C ------------------------ Start of executable code ------------------- IF(.NOT.LOADED) THEN OPEN(1,FILE='rya300.dat',STATUS='OLD') READ(1,10) ID,MAXS 10 FORMAT(A4,I5) IF(ID.NE.' RYA') THEN WRITE(*,20) 20 FORMAT(1X,'WRONG COEFFICIENTS FOR RYA') STOP ENDIF READ(1,30) RYACOF 30 FORMAT(D22.16) CLOSE(1) LOADED=.TRUE. ENDIF IF(DLAMDA.GT.1D0) THEN I=3-IALPHA J=3-IBETA XL=1D0/DLAMDA ELSE I=IALPHA J=IBETA XL=DLAMDA ENDIF XLP1=XL+1D0 C C These Gx are the functions g from Jeffrey & Onishi. IF(I.EQ.1) THEN G2=4D0*(2D0*XL+XL**2+2D0*XL**3)/(15D0*XLP1**3) G3=2D0*(16D0-45D0*XL+58D0*XL**2-45D0*XL**3+16D0*XL**4) & /(375D0*XLP1**3) ISTEP=1 ELSE G2=4D0*(2D0+XL+2D0*XL**2)/(15D0*XLP1**3) G3=2D0*(16D0-45D0*XL+58D0*XL**2-45D0*XL**3+16D0*XL**4) & /(375D0*XL*XLP1**3) ISTEP=-1 ENDIF T=2D0/S EPS=1D0-4D0/(S*S) IF(I.EQ.J) THEN ZT=T*T C Notice that because the first coef is a signature we supply the 1. RYA=1D0-(G2+G3*EPS*S*S/4D0)*DLOG(EPS)-G3 MMIN=2 MMAX=MAXS ELSE ZT=T RYA=(G2+G3*EPS*S*S/4D0)*DLOG((S+2D0)/(S-2D0)) RYA=RYA-G3*S MMIN=1 MMAX=MAXS-1 ENDIF T=T*T G2SUM=2D0*G2 G3SUM=4D0*G3 DO 100 M=MMIN,MMAX,2 IF (ISTEP.GT.0) THEN NM = (M*(M+1))/2 ELSE NM = (M*(M+1))/2 +M ENDIF ZL=XLP1**(-M) COEF=0D0 C Some computers may underflow in the next loop. DO 50 IQ=0,M COEF=COEF+RYACOF(NM)*ZL NM=NM+ISTEP ZL=ZL*XL 50 CONTINUE RYA=RYA+ZT*(COEF-((G2SUM-G3SUM/DBLE(M+2))/DBLE(M))) ZT=ZT*T 100 CONTINUE IF(I.EQ.J)RETURN RYA=-RYA*2D0/XLP1 IF(I.EQ.2)RYA=RYA*XL RETURN END