Homework_6_2011 - CS 111 - Introduction to Computational...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 111 - Introduction to Computational Science Homework 6 Consider the diffusion equation in the interval [0, 1]: ∂u ∂2u = D 2, ∂t ∂x (1) where D is the diffusion constant. Here, we will take D = .5. An exact solution for this equation is u(x, t) = e−Dt cos(x) and a good approximation can be written as: un+1 − 2un+1 + un+1 un+1 − un i i−1 i i . = D i+1 ∆t ∆x2 (2) 1. Write down the linear system corresponding to (2). 2. Write a code that solve the diffusion equation (1) using the scheme (2) for a final time of ttarget = 1. You can assume that the exact solution is given at the domain’s boundary, i.e. at x = 0 and at x = 1. Take a time step of ∆t = .1 and discretize the interval [0, 1] with 100 points. 3. Use your code to make a movie showing the evolution of your numerical solution along with the exact solution. What to turn in : the linear system from question 1, your code as well as your movie. This can be emailed to the TAs. 1 ...
View Full Document

This note was uploaded on 12/29/2011 for the course CS 111 taught by Professor Staff during the Fall '08 term at UCSB.

Ask a homework question - tutors are online