This preview shows page 1. Sign up to view the full content.
Unformatted text preview: CS 111  Introduction to Computational Science Homework 5
Consider a domain Ω = [−1, 1] in one spatial dimension and the following linear advection equation:
∂u
∂u
+c
= 0,
∂t
∂x (1) where c is the velocity. We take the initial data for u to be u(x, 0) = cos(πx). In this case the exact
solution at time t is given by u(x, t) = cos (π (x − ct)).
1. Using the upwind scheme, solve equation (1) with c = 1 to a ﬁnal time tﬁnal = 2. We will assume
that u is periodic in space as described in class. Take a time step restriction of t = .5 x and
the number of grid points equal to 100.
2. Using the upwind scheme, solve equation (1) with c = −1 to a ﬁnal time tﬁnal = 2. We will
assume that u is periodic in space as described in class. Take a time step restriction of t = .5 x
and the number of grid points equal to 100.
What to turn in: (1) Your code; (2) On one ﬁgure plot the exact solution and the numerical
solution at tﬁnal in the case where c = 1; (3) On another ﬁgure plot the exact solution and the
numerical solution at tﬁnal in the case where c = −1. 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.
 Fall '08
 Staff

Click to edit the document details