PROGRAM AXITR4 C This program solves the AXIsymmetric TRanslation of two spheres. C It calculates coefficients for the resistance functions C as yet not given final names which give the average pressure C at the centre of a particle. requested by John Brady. C To calculate large numbers of terms, the memory requirements are: C C MAXS MMAX DIMENSION P OR V MEMORY (PER 8 BYTES) FACO C ---- ---- ---------------- ------ (for each array) ---- C 15 16 475 4KB 8,8 C 50 51 12152 97KB 26,26 C 100 101 89927 700KB 51,51 C 150 151 295827 2.4KB 76,76 C 200 201 692352 5.5MB 101,101 C 250 251 1342002 10.7MB 126,126 C 300 301 2307277 18.5MB 151,151 C DOUBLE PRECISION P(0:2307277),V(0:2307277),FAC0(151,151),XN,XS DOUBLE PRECISION FCTR1,FCTR2,FCTR3,FCTRV,FAC,PSUM,VSUM INTEGER MMAX,MAXS,NM,N,IS,M,NQ,IQ,INDX1,JS,IP COMMON /ARRAYS/P,V,FAC0 C This COMMON block reduces disk space requirements with many compilers C and helps memory management on some computers. MAXS=300 MMAX=MAXS+1 C First tabulate FAC0. DO 10 N=1,(MMAX+1)/2 XN=DBLE(N) FAC0(N,1)=1D0+XN DO 10 IS=2,(MMAX+1)/2 XS=DBLE(IS) FAC0(N,IS)=FAC0(N,IS-1)*(XN+XS)/XS 10 CONTINUE C We set the initial conditions. P(INDX1(1,0,0))=1D0 V(INDX1(1,0,0))=1D0 C We start at N=1, Q=0, P=M and proceed keeping M fixed. C NM is the solution of the equation M=N+P+Q-1=NM+NM-1+0-1, except C the last time through when only N=1 and 2 are calculated. DO 500 M=1,MMAX write(*,*)m NM=M/2+1 IF(M.EQ.MMAX)NM=2 DO 400 N=1,NM C The equation for NQ is M=N+P+Q-1=N+N-1+NQ-1 NQ=M-2*N+2 XN=DBLE(N) FCTR1=XN*(XN+.5D0)/(XN+1D0) FCTR2=XN*(XN-.5D0)/(XN+1D0) FCTR3=XN*(2D0*XN*XN-.5D0)/(XN+1D0) FCTRV=2D0*XN/((XN+1D0)*(2D0*XN+3D0)) C Now that M, N, Q are specified, I know P (denoted IP) as well. C We obtain JS from the equation JS-1=IQ-JS. DO 300 IQ=0,NQ IP=M-IQ-N+1 PSUM=0D0 VSUM=0D0 C If Q=0, the sum does not need to be done. This would happen anyway C in FORTRAN 77 because JS=0 when Q=0. However, in FORTRAN IV a test C was needed. IF (IQ.EQ.0D0) GO TO 250 JS=(IQ+1)/2 DO 200 IS=1,JS XS=DBLE(IS) FAC=FAC0(N,IS) C The way the loops and the index mapping are set up, the first term C in (3.9) will always be legal, but the other terms in (3.8)-(3.9) must be C tested to make certain that the INDX1 is legal (an illegal argument to C INDX1 means that the term can be shown analytically to be zero). C PSUM=PSUM+FAC*FCTR1*(2D0*XN*XS-XN-XS+2D0)* & P(INDX1(IS,IQ-IS,IP-N+1))/((XN+XS)*(2D0*XS-1D0)) IF(IP.GT.N) THEN PSUM=PSUM-FAC*FCTR2*P(INDX1(IS,IQ-IS,IP-N-1)) VSUM=VSUM-FAC*FCTRV*P(INDX1(IS,IQ-IS,IP-N-1)) ENDIF C The largest value of IS for the next term is given by IS-1=IQ-IS-2 C Thus IS=(IQ-1)/2=(IQ+1)/2-1=JS-1. Thus we skip this if IS=JS. IF(IS.LT.JS) THEN PSUM=PSUM-FAC*FCTR3*V(INDX1(IS,IQ-IS-2,IP-N+1))/(2D0*XS+1D0) ENDIF 200 CONTINUE 250 P(INDX1(N,IP,IQ))=PSUM V(INDX1(N,IP,IQ))=PSUM+VSUM 300 CONTINUE 400 CONTINUE 500 CONTINUE C C We suppose the normalization is C 4 pi a_1^2 X^P_11 = 4 pi a_1^2 sum( p_{0n} ,etc) C = 4 pi a_1^2 sum( 1.5 sum P(etc) ) do 650 m=1,maxs NM = (M*(M+1))/2 v(nm)=0d0 do 640 iq=1,m-1 ip=m-iq psum=0d0 do 630 n=1,(iq+1)/2 psum=psum+p( indx1(n,iq-n,ip-1) ) 630 continue 640 v( nm+iq) = 1.5d0*psum v(nm+m)=0d0 650 continue C v(0) = -12d0 MMAX=((MAXS+1)*(MAXS+2))/2 -1 OPEN (1,FILE='rxpcof.dat',STATUS='NEW') WRITE(1,670) MAXS 670 FORMAT(' RXP',I5) C We do not use an implied DO loop because the computer (ETA-10) crashes. C The FORMAT may need a leading space on some compilers. DO 690 M=0,MMAX 690 WRITE (1,700)V(M) 700 FORMAT(D22.16) CLOSE(1) C Previously the equal spheres case was written out separatly using C the commented out code below C OPEN (3,FILE='rxpeqcof.dat') C DO 940 M=0,MAXS C VSUM=0D0 C NM=((M+1)*M)/2 C DO 930 IQ=0,M C VSUM=VSUM+V(NM+IQ) C930 CONTINUE C VSUM=VSUM*2D0**(-M) C WRITE(3,700)VSUM C940 CONTINUE C CLOSE(3) STOP END INTEGER FUNCTION INDX1(N,IP,IQ) C This function maps 3-dimensional arrays onto 1-dimensional arrays. C For each array element P(n,p,q) we define M=n+p+q-1, which is the primary C variable. For each value of M, we find that the array elements are C non-zero only for 1=< n = P(n,n-1,m-2n+2). C INDX1 uses these facts to set up a triangular scheme for each M to convert C it to a linear array. The array is filled as follows: C n,p,q= 1,M,0 1,M-1,1 ....................... 1,1,M-1 1,0,M C ***** 2,M-1,0 2,M-2,1 ............... 2,1,M-2 C ***** ******* .................... C ***** ******* n,M-n+1,0 ... n,n-1,M-2n+2 C Note that the integer arithmetic relies on correct divisibility. C --------------------------- Arguments ------------------------ INTEGER N,IP,IQ C ------------------------- Local Variables -------------------- INTEGER M,M2,LM M=IP+IQ+N-1 M2=M/2 LM=( M2*(M2+1) )/2 LM=LM*(M2+1)+ ( LM*(M2+2) )/3 C LM is calculated as above to avoid overflow. C If MMAX=200, then LM = 681750 LM=LM+(M-2*M2)*(M2+1)*(M2+1) INDX1=LM+(N-1)*(M-N+3)+IQ RETURN END