Math 104C Homework #4 ∗ Instructor: Xu Yang General Instructions: Please write your homework papers neatly. You need to turn in both your codes and descriptions on the appropriate runs you made by following Grader’s instructions. Write your own code, individually. Do not copy codes! 1. Consider the Heat Equation in the unit square [0,1] × [0,1] with initial condition{ ut = D(uxx + uyy) u(0, x, y) = sin(pix) sin(piy) (1) and the homogeneous Dirichlet boundary condition u = 0. (a) Implement the Peaceman-Rachford ADI method to find an approximation to this initial- boundary value problem. (b) Accuracy check. To verify the accuracy of a scheme and as a check for possible bugs one should always do a resolution study. Suppose that v(k) is your numerical approximation at fixed time computed using time-step size k, then second order in time accuracy means that v(k) = u+ c2k 2 + c3k 3 + · · · , (2) where u is the exact value. Keeping the spatial resultion fixed (hx = hy = h, uniform grid) now compute using k/2 then your approximation satisfies: v(k/2) = u+ 1 4 c2k 2 + 1 8 c3k 3 + · · · , (3) then for v(k/4), etc. Then the ratios: R(k) = v(k)− v(k/2) v(k/2)− v(k/4) (4) (c) Compute solution for D = 1 and plot it for at three different times. ∗All course materials (class lectures and discussions, handouts, homework assignments, examinations, web ma- terials) and the intellectual content of the course itself are protected by United States Federal Copyright Law, the California Civil Code. The UC Policy 102.23 expressly prohibits students (and all other persons) from recording lectures or discussions and from distributing or selling lectures notes and all other course materials without the prior written permission of the instructor. 1 2. Consider the one-way wave equation ut + ux = 0 on the interval [−1, 3] and for t ≥ 0 with the following two sets of initial conditions: u(x, 0) = { 1− |x| if |x| ≤ 1, 0 otherwise, (5) and u(x, 0) = e−5x 2 . (6) (a) Use the forward-time forward-space scheme: un+1j − unj k + unj+1 − unj h = 0, with right-point boundary condition un+1M = u n+1 M−1 where xM = 3 to compute an approx- imation to the solution at several (up to 40) time steps. Use h = 0.02 and λ = k/h = 0.8. Demonstrate numerically (plot the solution) the instability of the scheme and show that the instability appears sooner with the less smooth initial data. (b) Comment on the localization of the onset of instability for initial data (5) and give an estimate of the expected growth rate of the instability per time step. (c) Using the left boundary condition u(−1) = 0, write a stable scheme and compute the corresponding approximation for data sets (5) and (6). Plot the approximations at representative time steps. Use again h = 0.02 and λ = k/h = 0.8. 2
学霸联盟