{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture7 - Diffusion problem HW 4 INTEGER PARAMETER...

Info icon This 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
Image of page 1

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

View Full Document Right 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
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
Image of page 3

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

View Full Document Right Arrow Icon
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!
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern