1. Homepage
2. Programming
3. AMATH 481/581: Scientific Computing - Homework 4: Initial-boundary value problem

# AMATH 481/581: Scientific Computing - Homework 4: Initial-boundary value problem

University of WashingtonAMATH 481AMATH 581Scientific ComputingInitial-boundary value problemPythonVisualization

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 t0

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.

1. (a)  Use the forward Euler method to solve (1) with ∆t = 210 (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.

2. (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 t0 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.8e9π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

1. (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.

2. (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.

3. (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 0y1 and t>0 u(t,x,0)=u(t,x,1)=0 forall 0x1 and t>0

u(0, x, y) = e10((x0.5)2+(y0.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.

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.)

2. (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.)

3. (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.

4. (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,t1/3,t2/3andt=1. Your answer should include a sentence or two about the pros and cons of each method.

## Get in Touch with Our Experts

QQ
WeChat
Whatsapp
University of Washington代写,AMATH 481代写,AMATH 581代写,Scientific Computing代写,Initial-boundary value problem代写,Python代写,Visualization代写,University of Washington代编,AMATH 481代编,AMATH 581代编,Scientific Computing代编,Initial-boundary value problem代编,Python代编,Visualization代编,University of Washington代考,AMATH 481代考,AMATH 581代考,Scientific Computing代考,Initial-boundary value problem代考,Python代考,Visualization代考,University of Washingtonhelp,AMATH 481help,AMATH 581help,Scientific Computinghelp,Initial-boundary value problemhelp,Pythonhelp,Visualizationhelp,University of Washington作业代写,AMATH 481作业代写,AMATH 581作业代写,Scientific Computing作业代写,Initial-boundary value problem作业代写,Python作业代写,Visualization作业代写,University of Washington编程代写,AMATH 481编程代写,AMATH 581编程代写,Scientific Computing编程代写,Initial-boundary value problem编程代写,Python编程代写,Visualization编程代写,University of Washingtonprogramming help,AMATH 481programming help,AMATH 581programming help,Scientific Computingprogramming help,Initial-boundary value problemprogramming help,Pythonprogramming help,Visualizationprogramming help,University of Washingtonassignment help,AMATH 481assignment help,AMATH 581assignment help,Scientific Computingassignment help,Initial-boundary value problemassignment help,Pythonassignment help,Visualizationassignment help,University of Washingtonsolution,AMATH 481solution,AMATH 581solution,Scientific Computingsolution,Initial-boundary value problemsolution,Pythonsolution,Visualizationsolution,