PROGRAM RGY DEM C This program demonstrates the use of the coefficients calculated C by the programs trntrx or trnstx. The program will produce a table C of values for different values of lambda as set in the DATA statements. C DOUBLE PRECISION DLAMDA(9),RGY,RGY11,RGY12,RGY21,RGY22 INTEGER J DATA DLAMDA/.5D0,1D0,2D0,3D0,4D0,5D0,10D0,20D0,100D0/ WRITE(6,5) 5 FORMAT(1X, &'RESISTANCE FUNCTIONS from Jeffrey, Phys. Fluids, 1992') WRITE(6,7) 7 FORMAT(1X,'vol A4, p16.') WRITE(6,8) 8 FORMAT(/1X,'Tabulation of the RGY appearing in eqs. (27), (29)') WRITE(6,10) 10 FORMAT(1X,' LAMBDA RGY11 RGY12 RGY21 RGY22'/) DO 50 J=1,9 RGY11=RGY(1,1,DLAMDA(J)) RGY12=RGY(1,2,DLAMDA(J)) RGY21=RGY(2,1,DLAMDA(J)) RGY22=RGY(2,2,DLAMDA(J)) 50 WRITE(6,101)DLAMDA(J),RGY11,RGY12,RGY21,RGY22 101 FORMAT(1X,F8.3,4F10.5) STOP END DOUBLE PRECISION FUNCTION RGY(IALPHA,IBETA,DLAMDA) C ----------------------- Arguments of function ----------------------- DOUBLE PRECISION DLAMDA INTEGER IALPHA,IBETA C --------------------------------------------------------------------- C This calculates the function RGY defined in Jeffrey, 'The calculation C of the low Reynolds number resistance functions for two unequal spheres', C Phys. Fluids (1992). C Coefficients calculated by one of the programs trntrx or trnstx are C summed using equations (29). C The subprogram works by converting any call to one in which C lambda.LT.1. It goes forwards or backwards through the coefficients C (the variable ISTEP) depending upon whether I=1 or 2. C This version was written during August 1988. Cosmetic changes made C in August 1997. C ------------------------- Local variables --------------------------- DOUBLE PRECISION RYGCOF(0:45450) DOUBLE PRECISION XL,XLP1,G2,G3,G2SUM,G3SUM,ZL,COEF INTEGER I,J,ISTEP,IQ,MMIN,MMAX,M,NM,ISIGN LOGICAL LOADED CHARACTER*4 ID DATA LOADED/.FALSE./ C --------------------- Start of executable code ---------------------- IF( .NOT.LOADED) THEN OPEN(3,FILE='ryg300.dat',STATUS='OLD') READ(3,10) ID,MAXS 10 FORMAT(A4,I5) IF( ID.NE.' RYG') THEN WRITE(*,20) 20 FORMAT( 1X,'WRONG COEFFICIENTS FOR RGY') STOP ENDIF READ(3,30)RYGCOF 30 FORMAT(D22.16) CLOSE(3) LOADED=.TRUE. ENDIF IF(DLAMDA.GT.1D0) THEN I=3-IALPHA J=3-IBETA XL=1D0/DLAMDA C RYG and RGY change sign when we invert lambda ISIGN = -1 ELSE I=IALPHA J=IBETA XL=DLAMDA ISIGN = 1 ENDIF XLP1=XL+1D0 C C These Gx are the functions g from Jeffrey (1991) (i=1,2 in paper) IF(I.EQ.1) THEN G2=(4D0*XL-XL**2+7D0*XL**3)/(10D0*XLP1**3) G3=(32D0-179*XL+532D0*XL**2-356*XL**3+221D0*XL**4) & /(500D0*XLP1**3) ISTEP=1 ELSE G2=(7D0-XL+4D0*XL**2)/(10D0*XLP1**3) G3=(221D0-356D0*XL+532D0*XL**2-179D0*XL**3+32D0*XL**4) & /(500D0*XL*XLP1**3) C These expressions essentially invert lambda. ISIGN =-ISIGN ISTEP=-1 ENDIF IF(I.NE.J) THEN RGY=-G3 MMIN=2 MMAX=MAXS ELSE RGY=2D0*(G2*DLOG(2D0)-G3) MMIN=1 MMAX=MAXS-1 ENDIF 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 will underflow in the next loop. DO 50 IQ=0,M COEF=COEF+RYGCOF(NM)*ZL NM=NM+ISTEP ZL=ZL*XL 50 CONTINUE RGY=RGY+COEF-(G2SUM-G3SUM/DBLE(M+2))/DBLE(M) 100 CONTINUE RGY=DBLE(ISIGN)*RGY IF(I.EQ.J) RETURN RGY=-RGY*4D0/XLP1**2 IF(I.EQ.2)RGY=RGY*XL**2 RETURN END