Lecture7 - Diffusion problem HW 4 INTEGER PARAMETER Prec14=SELECTED_REAL_KIND(14 INTEGER j,nt,ntmax INTEGER PARAMETER jmax=200 REAL(KIND=Prec14

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Diffusion problem, HW 4 INTEGER, PARAMETER :: Prec14=SELECTED_REAL_KIND(14) INTEGER :: j,nt,ntmax INTEGER, PARAMETER :: jmax=200 REAL(KIND=Prec14), DIMENSION(jmax) :: a,b,c,chi REAL(KIND=Prec14), DIMENSION(jmax) :: u REAL(KIND=Prec14), PARAMETER :: L=12.0d0,sigma=1.0d0, tau=L**2 REAL(KIND=Prec14), PARAMETER :: x1=L/2.0d0,x2=3.0d0*L/4.0d0 REAL(KIND=Prec14), PARAMETER :: dx=L/jmax REAL(KIND=Prec14), PARAMETER :: dt=0.01d0 REAL(KIND=Prec14), PARAMETER :: alpha=dt/(2.0d0*dx**2) REAL(KIND=Prec14) :: x,s2pi,pi
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Initial conditions, initial density u(j) pi=4.0d0*datan(1.0d0) s2pi=dsqrt(2.0d0*pi) ntmax=tau/dt/100 do j=1,jmax x=dx*j u(j)=(1.0d0/(sigma*s2pi))*(dexp(-(x-x1)**2/(2.0d0*sigma**2))- dexp(-(x-x2)**2/(2.0d0*sigma**2))) write(6,50) x,u(j) enddo
Background image of page 2
Initialize the matrix Q, stored in a,b,c arrays do j=1,jmax a(j)=-alpha/2.0d0 b(j)=0.5d0+alpha c(j)=-alpha/2.0d0 enddo • A nice little trick in Fortran 90 is we can substitute for the loop: a=-alpha/2.0d0 b=0.5d0+alpha c=-alpha/2.0d0 • Without a loop, compiler will assign all elements in array
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
call tridag(a,b,c,u,chi,jmax) u=chi-u do j=1,jmax x=dx*j if(nt.eq.ntmax) write(6,50) x,u(j) enddo enddo 50 format(2f12.6) All the action… No do-loop! output
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/08/2011 for the course PHZ 5156 taught by Professor Johnson,m during the Fall '08 term at University of Central Florida.

Page1 / 14

Lecture7 - Diffusion problem HW 4 INTEGER PARAMETER Prec14=SELECTED_REAL_KIND(14 INTEGER j,nt,ntmax INTEGER PARAMETER jmax=200 REAL(KIND=Prec14

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online