User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 April 18, 2001, 14:15 ADI Method #1 Paul Safier Guest   Posts: n/a Does anyone know of a good resource for information on how to code the ADI method. I would like to see pseudo code ideally. Thanks...

 April 23, 2001, 09:42 Re: ADI Method #2 G. Brady Guest   Posts: n/a Paul, this code in FORTRAN may help, its based on heat transfer on a slab or material. You may need to change the loops to suit. Also, try Numerical Recipes online http://www.ulib.org/webRoot/Books/Nu...pes/bookf.html Regards, Gavin John CODE: ! APPLIED NUMERICAL METHODS, EXAMPLE 7.3 ! Two dimensional unsteady state heat conduction in an infinite ! bar of square cross-section, solved by the I.A.D method ! ! At time TAU = 0, the temperature is zero everywhere, and the ! faces of the bar are subsequently maintained at T = 1. ! The temperatures in the lower right-hand quadrant are printed ! every IFREQ time-steps, until the center temperature exceeds ! TMAX. ! PROGRAM ADI IMPLICIT DOUBLE PRECISION (A-H,O-Z) DIMENSION A(11) !COEFFICIENT VECTOR DIMENSION B(11) !COEFFICIENT VECTOR DIMENSION C(11) !COEFFICIENT VECTOR DIMENSION D(11) !COEFFICIENT VECTOR DIMENSION T(11,11) !VECTOR OF TEMPS AT GRID POINTS DIMENSION TSTAR(11,11) !MATRIX OF TEMPS T* END OF 1/2 TAU DIMENSION TPRIME(11) !TEMPS FROM TRIDAG DIMENSION X(11) !VECTOR OF X CO-ORDS !DIMENSION Y(11) !VECTOR OF Y CO-ORDS !------------------------------------------------------------ !READ AND VERIFY INPUT PARAMETERS !------------------------------------------------------------ PARAMETER (DTAU=0.05) !TIME STEP PARAMETER (TMAX=0.95) !MAX CENTRE TEMP PARAMETER (N=10) !NO. SPACE INCREMENTS PARAMETER (IFREQ=1) !NUMBER OF TIMES BETWEEN SUCESSIVE.. OPEN(UNIT=6,FILE='HEATq1.DAT',STATUS='UNKNOWN') !------------------------------------------------------------ !READ AND CHECK INPUT PARAMETERS !------------------------------------------------------------ NP1=N+1 FLOATN=N DX=1.0/FLOATN !should be n-1?? RATIO=DTAU/(DX*DX) !COURANT NUMBER WRITE(6,*)'DTAU,DX,RATIO,TMAX,N,IFREQ' WRITE(6,*)DTAU,DX,RATIO,TMAX,N,IFREQ !------------------------------------------------------------ !SET INITIAL AND BOUNDARY VALUES !------------------------------------------------------------ DO I=1,N T(I,NP1)=1.0 T(NP1,I)=1.0 TSTAR(I,NP1)=1.0 TSTAR(NP1,I)=1.0 DO J=1,N T(I,J)=0.0 TSTAR(I,J)=0.0 END DO END DO T(NP1,NP1)=1.0 TSTAR(NP1,NP1)=1.0 !------------------------------------------------------------ !SET COEFFICIENT ARRAYS A,B AND C !------------------------------------------------------------ B(1)=2.0*(1.0/RATIO+1.0) F=2.0*(1.0/RATIO-1.0) DO I=2,N A(I)=-1.0 B(I)=B(1) C(I)=-1.0 END DO C(1)=-2.0 ICOUNT=0 TAU=0.0 !TIME !------------------------------------------------------------ !PERFORM CALCULATIONS OVER SUCCESSIVE TIME-STEPS !------------------------------------------------------------ 4 TAU=TAU+DTAU ICOUNT=ICOUNT+1 !------------------------------------------------------------ !COMPUTE TEMPERATURES AT END OF HALF TIME INCREMENT !(IMPLICIT BY COLUMNS) !------------------------------------------------------------ DO J=1,N DO I=1,N IF(J.NE.1)THEN D(I)=T(I,J-1)+F*T(I,J)+T(I,J+1) ELSE D(I)=2.0*T(I,2)+F*T(I,1) END IF D(N)=D(N)+T(NP1,J) END DO CALL TRIDAG(N,A,B,C,D,TPRIME) DO I=1,N TSTAR(I,J)=TPRIME(I) END DO END DO !------------------------------------------------------------ !COMPUTE TEMPERATURE AT END OF WHOLE TIME INCREMENT !(IMPLICIT BY ROWS) !------------------------------------------------------------ DO M=1,N,1 DO J=1,N,1 PRINT*,M,J IF(M.NE.1)THEN D(J)=TSTAR(M-1,J)+F*TSTAR(M,J)+TSTAR(M+1,J) ELSE D(J)=2.0*TSTAR(2,J)+F*TSTAR(1,J) END IF D(N)=D(N)+TSTAR(M,NP1) END DO CALL TRIDAG(N,A,B,C,D,TPRIME) DO J=1,N T(M,J)=TPRIME(J) END DO END DO !------------------------------------------------------------ !PRINT TEMPERATURES THROUGHOUT THE QUADRANT !------------------------------------------------------------ IF(ICOUNT.NE.IFREQ)THEN IF(T(NP1,NP1).LE.TMAX)GOTO 4 !15 IF(T(1,1)-TMAX)4,4,1 ELSE ICOUNT=0 WRITE(6,*)'AT A TIME TAU=',TAU DO I=1,NP1 WRITE(6,*)(T(I,J),J=1,NP1) END DO END IF STOP CONTAINS !------------------------------------------------------------ !FORMAT FOR INPUT AND OUTPUT STATEMENTS !------------------------------------------------------------ !------------------------------------------------------------ SUBROUTINE TRIDAG(L,A,B,C,D,V) !------------------------------------------------------------ ! SUBROUTINE FOR SOLVING A SYSTEM OF LINEAR SIMULTANEOUS ! EQUATIONS HAVING A TRIDIAGONAL COEFFICIENT MATRIX. ! THE EQUATIONS ARE NUMBERED FROM IF THROUGH L, AND THEIR ! SUB-DIAGONAL, DIAGONAL, AND SUPER-DIAGONAL COEFFICIENTS ! ARE STORED IN THE ARRAYS A,B, AND C. THE COMPUTED ! SOLUTION VECTOR V(IF).....V(L) DIMENSION A(1),B(1),C(1),D(1),V(1),BETA(101),GAMMA(101) !------------------------------------------------------------ !COMPUTE INTERMEDIATE ARRAYS BETA AND GAMMA !------------------------------------------------------------ BETA(1)=B(1) GAMMA(1)=D(1)/BETA(1) IFP1=1+1 ! DO I=IFP1,L BETA(I)=B(I)-A(I)*C(I-1)/BETA(I-1) GAMMA(I)=(D(I)-A(I)*GAMMA(I-1))/BETA(I) END DO !------------------------------------------------------------ !COMPUTE FINAL SOLUTION VECTOR V !------------------------------------------------------------ V(L)=GAMMA(L) LAST=L-1 ! DO K=1,LAST I=L-K V(I)=GAMMA(I)-C(I)*V(I+1)/BETA(I) END DO RETURN END SUBROUTINE TRIDAG !------------------------------------------------------------ END PROGRAM ADI

 June 4, 2011, 11:28 #3 New Member   irfan Join Date: May 2011 Posts: 1 Rep Power: 0 Hello, I need a C/C++ code of ADI method for a 2D problem. I have made mine but getting some structural artefacts, would be nice if yomebody share it so that I can compare mine with that. Thanks

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Andyjoe Open Source Meshers: Gmsh, Netgen, CGNS, ... 13 March 14, 2012 05:35 Anorky FLUENT 0 April 27, 2010 10:55 D.S.Nasan Main CFD Forum 6 September 4, 2008 02:08 Dan Gao Main CFD Forum 3 July 5, 2008 01:18 yangqing FLUENT 0 March 20, 2002 20:25

All times are GMT -4. The time now is 18:55.

 Contact Us - CFD Online - Privacy Statement - Top