Group two, parabolic, explicit

From Interactive System for Ice sheet Simulation
Revision as of 19:26, 4 August 2009 by Adamc (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
	program diffusion
 
	implicit none
	real, parameter :: dt = 0.005125
	real, parameter :: dx = 0.1
	real, parameter :: tend = 1.025
	real, parameter :: xend = 1.0
	real, parameter :: pi = 3.14159
	integer :: intt = int(tend/dt)
	integer :: intx = int(xend/dx)
	real, dimension(int(tend/dt)+1,int(xend/dx)+1)  :: u, uExact, uDiff
	integer :: t,i
	real, dimension(int(xend/dx)+1)::xarr=(/((t-1)*dx,t=1,int(xend/dx)+1)/)
 
	uExact(1,:) = sin( pi*xarr )
	u(1,:) = uExact(1,:)	
 
	do t=2, intt+1
                u(t,1)=0.
		u(t,2:intx)=u(t-1,2:intx)+dt* &
			(u(t-1,1:intx-1)-2*u(t-1,2:intx)+u(t-1,3:intx+1))/dx**2
                u(t,intx+1)=0.
		uExact(t,:)=exp(-pi**2*(t-1)*dt)*sin(pi*xarr)
		write (*,*) u(t,:)!-uExact(t,:)
	end do
	end program