|
[Sponsors] |
April 6, 2004, 06:23 |
ADI
|
#1 |
Guest
Posts: n/a
|
It is strange but I can not make an ADI program work for a 2-D heat conduction equation with Forward Time Central Space. I wrote a program that sweeps in X-direction and then Sweeps in Y-direction . But the results are not ok. Is there anything wrong? anyone can help please?
|
|
April 6, 2004, 06:40 |
Re: ADI
|
#2 |
Guest
Posts: n/a
|
> It is strange but I can not make an ADI program work for a 2-D heat conduction equation with Forward Time Central Space.
It looks like you have an explicit scheme, for which you do not need ADI. ADI means Alternating Direction _Implicit_ method, doesn't it |
|
April 6, 2004, 06:45 |
Re: ADI
|
#3 |
Guest
Posts: n/a
|
I know what is ADI, and it is a two step method that solves the 2d heat equation implicitly at each half time steps. if you like, please have a look at the code:
! Program for 2D Heat Conduction Equation with ADI/FTCS ! FTCS= Forward Time Central Space ! Equation is Non-dimensionalized as: DT*/Dt*=D2T*/Dx*2+D2T*/Dy*2 real to(100,100),t(100,100),tm(100,100) real dx,dy,dt integer ni,nj,ntstep real a(100),b(100),c(100),d(100),f(100) xl=1. yl=1. ni=21 nj=21 dt=0.0001 ntstep=1000000 100 ddx=xl/real(ni-1) 101 ddy=yl/real(nj-1) write(*,*),'End Time=',ntstep*dt ! Initial values do i=1,ni do j=1,nj to(i,j)=0.0 enddo enddo ! Boundary conditions do j=1,nj to(1,j)=1. enddo do i=1,ni to(i,1)=1. enddo NTIME=1 DX=dt/(ddx**2.)/2. DY=dt/(ddy**2.)/2. 37 continue ! Y- ! FTCS Implicit ! a,b,c coeffcients do i=3,ni-2 c(i)=-DX b(i)=1.+2.*DX a(i)=-DX enddo c(2)=-DX b(2)=1.+2.*DX a(2)=0. c(ni-1)=0. b(ni-1)=1.+2.*DX a(ni-1)=-DX ! Y-sweep starts here do j=2,nj-1 do i=3,ni-2 RHSI=to(i,j+1)-2.*to(i,j)+to(i,j-1) d(i)=to(i,j)+DY*RHSI enddo RHS2=to(2,j+1)-2.*to(2,j)+to(2,j-1) d(2)=to(2,j)+DY*RHS2+DX*to(1,j) RHSNIM1=to(ni-1,j+1)-2.*to(ni-1,j)+to(ni-1,j-1) d(ni-1)=to(ni-1,j)+DY*RHSNIM1+DX*to(ni,j) call tridag (ni,a,b,c,d,f) do ii=2,ni-1 tm(ii,j)=f(ii) enddo enddo ! X- ! FTCS Implicit ! a,b,c coeffcients do j=3,nj-2 c(j)=-DY b(j)=1.+2.*DY a(j)=-DY enddo c(2)=-DY b(2)=1.+2.*DY a(2)=0. c(nj-1)=0. b(nj-1)=1.+2.*DY a(nj-1)=-DY ! X-sweep starts here do i=2,ni-1 do j=3,nj-2 RHSJ=tm(i+1,j)-2.*tm(i,j)+tm(i-1,j) d(j)=tm(i,j)+DX*RHSJ enddo RHS2=tm(i+1,2)-2.*tm(i,2)+tm(i-1,2) d(2)=tm(i,2)+DX*RHS2+DY*to(i,1) RHSNJM1=tm(i+1,nj-1)-2.*tm(i,nj-1)+tm(i-1,nj-1) d(nj-1)=tm(i,nj-1)+DX*RHSNJM1+DY*to(i,nj) call tridag (nj,a,b,c,d,f) do jj=2,nj-1 to(i,jj)=f(jj) enddo enddo NTIME=NTIME+1 IF(NTIME.ge.ntstep) then goto 117 else print*,NTIME*dt goto 37 endif ! Writing Results in a File 117 print*,'end................................',NTIME *dt open(unit=15,file='t.dat',form='formatted',status= 'unknown') write(15,*) 'VARIABLES= X Y T' write(15,82) ni,nj 82 format(1x,'ZONE T="Zone-One", I=',i3,' ,J= ',i3,' ,F=POINT') do j=1,nj do i=1,ni write(15,88)real(i-1)*ddx,real(j-1)*ddy,to(i,j) enddo enddo 88 format(1x,3(1pe15.6,2x)) close(15) end c----------------------------------------------------------------------- subroutine tridag (n, a, b, c, d, f) c----------------------------------------------------------------------- c..source: numerical recipies (modified) c..IMP: this is written to work in 2 to n-1 set c..computes the solution vector of a tridiagonal system of linear c..equations. a,b,c contain influence coefficients A(j-1),A(j),A(j+1). c..d contains the known right hand side. solution returned in f. c..a(2) and c(n-1) are not used real a(n),b(n),c(n),d(n),f(n) real gam(256) bet = b(2) f(2) = d(2)/bet do i=3,n-1 gam(i) = c(i-1) / bet bet = b(i) - a(i)*gam(i) if(bet.eq.0.) pause 'tridag failed' f(i) = (d(i) - a(i)*f(i-1)) / bet end do do i=n-2,2,-1 f(i) = f(i) - gam(i+1)*f(i+1) end do return end |
|
April 6, 2004, 07:03 |
Re: ADI
|
#4 |
Guest
Posts: n/a
|
If you have a forward time scheme, you do not have an implicit system that you would need ADI method (or any other iterative method, for that matter) to solve. You have an _explicit_ relation for the temperature at each new time level. It is only when you have backward time or Crank-Nicolson scheme that you need ADI.
Does your scheme look like this? (T(i,j,n+1)-T(i,j,n))/dt = (T(i+1,j,n)-2*T(i,j,n)+T(i-1,j,n))/dx^2 + (T(i,j+1,n)-2*T(i,j,n)+T(i,j-1,n))/dy^2 where n is a time index and i,j are space indices. |
|
April 6, 2004, 07:22 |
Re: ADI
|
#5 |
Guest
Posts: n/a
|
ADI. As I said, it is Alternating Direction Implicit. I do NOT solve the equation as you wrote, you could have seen it in the code I listed there. I solve the equation in two half time steps, n+1/2, and then n+1. At first half time steps, the d2T/dx2 is solved implicitly using TDMA or Thomas algorithm if you are familiar with this, the subroutine for that is listed as well. In first hal time step, it is solved implicitly for x, and a sweep in y-direction is carried out. Then, in the second half time step, between n+1/2 and n+1, d2T/dx2 is assumed known and d2T/dy2 is solved implicitly at time step n+1. For example you can have a look at :
1-CA Fletcher, Computational Techniques for Flud Dynamics, Vol. 1 p. 252 2- TJ Chung, computational fluid dynamics, p. 66 3- JH Ferziger and M Peric, computational methods for fluid dynamics, p. 99 |
|
April 6, 2004, 08:07 |
Re: ADI
|
#6 |
Guest
Posts: n/a
|
I do know what ADI is. If you use it, you don't have a Forward time scheme.
I do not have time to debug your program. |
|
April 6, 2004, 08:31 |
Re: ADI
|
#7 |
Guest
Posts: n/a
|
good for you that you know what is ADI. your mum is proud of you
|
|
April 6, 2004, 09:51 |
Re: ADI
|
#8 |
Guest
Posts: n/a
|
Actually the thing that will make it explicit or implicit is what time level the RHS is evaluated at, not the form of the difference used for the time derivative. FTCS is solved in many cases using ADI, when the RHS is evaluated at the n+1 time level. For the original poster, I would suggest doing a time-step study, because ADI is not unconditionally stable. The splitting error grows with the time step you use. Beyond that, what kind of problems are you seeing?
|
|
April 6, 2004, 11:10 |
Re: ADI
|
#9 |
Guest
Posts: n/a
|
I found the error, it works now.
|
|
April 6, 2004, 23:59 |
ADI stability
|
#10 |
Guest
Posts: n/a
|
"ADI is not unconditionally stable"
There is a misconception that ADI (in general) is unconditionally stable. Can we have discussion on this. |
|
April 7, 2004, 11:01 |
Re: ADI stability
|
#11 |
Guest
Posts: n/a
|
No ADI is not unconditionally stable, because the RHS is explicitly defined/calculated
|
|
April 7, 2004, 13:30 |
Re: ADI stability
|
#12 |
Guest
Posts: n/a
|
ADI comes is many flavors, some are unconditionally stable, some are not.
e.g. The 2-step Peaceman Rachford scheme for 2-D parabolic equations is unconditionally stable (for appropriate BCs). But going to 3-D imposes a condition on stability. A discussion on ADI stability could probably go on forever! Ref: Chapter 4 of J. W. Thomas, Numerical Partial Differential Equations: Finite Difference Methods, Springer, 1995. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Use SOR or ADI for solving the time dependent reynolds equation | Hermano | Main CFD Forum | 1 | July 5, 2010 10:47 |
ADI implicit doesn't converge | George Papadakis | Main CFD Forum | 2 | July 8, 2009 14:27 |
algo for ADI or fractional step scheme handling crossderivative terms | HaKu | Main CFD Forum | 8 | April 4, 2009 03:10 |
Adi in 2D???sos | xiegang | Main CFD Forum | 0 | October 14, 2003 09:04 |
ADI of N-S equations | Zhou Yongcheng | Main CFD Forum | 5 | January 18, 2001 08:58 |