{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# lecture7 - Diffusion problem HW 4 INTEGER PARAMETER...

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

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

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

View Full Document
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
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

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

View Full Document
do nt=1,ntmax 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!
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern