Problem 1
Homework 4
AMATH 481/581
Consider the initial-boundary value problem
ut =5uxx forall −1<x<2 and t>0 u(t,−1)=0 and u(t,2)=0 forall t≥0
4π u(0,x)=sin 3 (x+1)
The true solution to this initial-boundary value problem is
5·16π2 4π
u(t,x)=exp − 9 t sin 3 (x+1)
In this problem, you will solve the PDE using the method of lines as discussed in class. For all parts, use a second order central difference scheme with ∆x = 0.125 (i.e., 25 total grid points) to discretize uxx. You should get a system of ODEs of the form
u′ = Au (1) The different parts will explore different methods for solving this system. For each
part, solve from time t = 0 until time t = 0.25.
-
(a) Use the forward Euler method to solve (1) with ∆t = 2−10 (i.e., 257 total time points, including t = 0 and t = 0.25). Store your approximation of u(0.25,0) (i.e., the value of u at t = 0.25 and x = 0) in a variable named A1. Store the global error (that is, the maximum of the absolute values of the error at each grid point) in a variable named A2.
-
(b) Use the forward Euler method to solve (1) with ∆t = 1/552 (i.e., 139 total time points, including t = 0 and t = 0.25). Store your approximation of u(0.25,0) (i.e., the value of u at t = 0.25 and x = 0) in a variable named A3. Store the global error (that is, the maximum of the absolute values of the error at each grid point) in a variable named A4.
1
(c) Use the backward Euler method to solve (1) with ∆t = 0.05 (i.e., 6 total time points, including t = 0 and t = 0.25). Store your approximation of u(0.25,0) (i.e., the value of u at t = 0.25 and x = 0) in a variable named A5. Store the global error (that is, the maximum of the absolute values of the error at each grid point) in a variable named A6.
(d) Use the backward Euler method to solve (1) with ∆t = 0.005 (i.e., 51 total time points, including t = 0 and t = 0.25). Store your approximation of u(0.25,0) (i.e., the value of u at t = 0.25 and x = 0) in a variable named A7 in a variable named A8.
Problem 2
Consider the initial-boundary value problem
ut =uxx +10x forall 0<x<1 and t>0 u(t,0)=0 and u(t,1)=10t forall t≥0 u(0, x) = sin(πx) − 0.8 sin(3πx)
The true solution to this initial-boundary value problem is
u(t, x) = 10tx + e−π2t sin(πx) − 0.8e−9π2t sin(3πx)
In this problem, you will solve the PDE using the method of lines as discussed in class. For all parts, use a second order central difference scheme with ∆x = 0.05 (i.e., 21 total grid points) to discretize uxx. You should get a system of ODEs of the form
u′ =Au+c(t) (2) where c(t) is an 19 × 1 vector. The different parts will explore different methods for
solving this system. For each part, solve from time t = 0 until time t = 0.1.
(a) Use the forward Euler method to solve (2) with ∆t = 1/550 (i.e., 56 total time points, including t = 0 and t = 0.1). Store your approximation of u(0.1,0.5) (i.e., the value of u at t = 0.1 and x = 0.5) in a variable named A9. Store the global error (that is, the maximum of the absolute values of the error at each grid point) in a variable named A10.
2
-
(b) Use the forward Euler method to solve (2) with ∆t = 0.0005 (i.e., 201 total time points, including t = 0 and t = 0.1). Store your approximation of u(0.1,0.5) (i.e., the value of u at t = 0.1 and x = 0.5) in a variable named A11. Store the global error a variable named A12.
-
(c) Use the trapezoidal method to solve (2) with ∆t = 0.01 (i.e., 11 total time points, including t = 0 and t = 0.1). Store your approximation of u(0.1, 0.5) (i.e., the value of u at t = 0.1 and x = 0.5) in a variable named A13. Store the global error (that is, the maximum of the absolute values of the error at each grid point) in a variable named A14.
-
(d) Use the trapezoidal method to solve (2) with ∆t = 0.001 (i.e., 101 total time points, including t = 0 and t = 0.1). Store your approximation of u(0.1,0.5) (i.e., the value of u at t = 0.1 and x = 0.5) in a variable named A15. Store the global error (that is, the maximum of the absolute values of the error at each grid point) in a variable named A16.
Problem 3 - Relevant to the written report
Consider the initial-boundary value problem
ut=κ(uxx+uyy) forall0<x,y<1andt>0 u(t,0,y)=u(t,1,y)=0 forall 0≤y≤1 and t>0 u(t,x,0)=u(t,x,1)=0 forall 0≤x≤1 and t>0
u(0, x, y) = e−10((x−0.5)2+(y−0.5)2 for all 0 ≤ x, y ≤ 1
where κ = 0.1 is the diffusion coefficient (just a constant). In this problem, you will solve the (2 dimensional) PDE using the method of lines. For all parts, use a second order central difference scheme for both uxx and uyy with ∆x = ∆y = 0.1 (i.e., 11 total points in both the x and y directions). You should get a system of ODEs of the form
u′ = Au (3)
where each component ui(t) is the value of u at one of the grid points at time t. Order grid points in the same way that we have when studying the Laplace equation. You should end up with the same (symmetric, negative definite) matrix A that we used throughout the last homework (with an extra factor of κ).
3
The different parts will explore different methods for solving this system. For each part, solve from time t = 0 until time t = 1.
-
(a) Use the forward Euler method to solve (3) with ∆t = 1/3 (i.e., using 4 total time points, including t = 0 and t = 1). Store your approximation of u(1,0.5,0.5) (i.e., the value of u at t = 1, x = 0.5 and y = 0.5) in a variable named A17.
For the written report: Make a surface plot of the solution at times t = 0. (A good solution would be to use subplots to put all four in the same figure, but it’s ok as long as all four are on the same page and a reasonable size.)
-
(b) Use the forward Euler method to solve (3) with ∆t = 0.01 (i.e., using 101 total time points, including t = 0 and t = 1). Store your approximation of u(1, 0.5, 0.5) (i.e., the value of u at t = 1, x = 0.5 and y = 0.5) in a variable named A18.
For the written report: Make a surface plot of the solution at times t = 0, t = 0.33, t = 0.67 and t = 1. Make sure that all four plots are visible at once and are all legible. (A good solution would be to use subplots to put all four in the same figure, but it’s ok as long as all four are on the same page and a reasonable size.)
-
(c) Use the trapezoidal method to solve (??) with ∆t = 1/3 (i.e., using 4 total time points, including t = 0 and t = 1). Store your approximation of u(1,0.5,0.5) (i.e., the value of u at t = 1, x = 0.5 and y = 0.5) in a variable named A19.
For the written report: Make a surface plot of the solution at times t = 0, t=1/3,t=2/3andt=1.
-
(d) Use the trapezoidal method to solve (??) with ∆t = 0.01 (i.e., using 101 total time points, including t = 0 and t = 1). Store your approximation of u(1, 0.5, 0.5) (i.e., the value of u at t = 1, x = 0.5 and y = 0.5) in a variable named A20.
For the written report: Make a surface plot of the solution at times t = 0, t = 0.33, t = 0.67 and t = 1. Make sure that all four plots are visible at once and are all legible. (A good solution would be to use subplots to put all four in the same figure, but it’s ok as long as all four are on the same page and a reasonable size.)
4
For the written report: Which of your solutions exhibit stability issues? (This should be obvious.) Suppose that your goal was just to get a rough picture of the solutionatt=0,t≈1/3,t≈2/3andt=1. Your answer should include a sentence or two about the pros and cons of each method.