View the step-by-step solution to:

Question can anyone help me with this question, thanks! The following code is a template for an explicit solution to the diffusion (heat) PDE
du
at
Or2
on the
domain Xleft &lt; X &lt; Xright.
*set up the domain
N = 30;
xleft = \$8%?72
xright = \$%%?72
x = linspace(xleft, xright, N) ;
dx = x(2)-x(1) ;
*diffusion constant
D = %%%?72
\$temporal parameters
10
t = 0;
dt = \$9%??? dt has to be suitable for stability
*initial condition
13
u = \$9%??? enter function of x initial condition (remember to make sure u
\$%%is a column vector and to implement the dirichlet boundary condition) ;
15 -
figure(1), plot(x, u)
16
title( ['Current time = ', num2str(t) ])
17
drawnow
18
19
The matrix A which will update the solution u between time steps
20
A = \$%%??? Numerical diffusion equation
21
A(1, :) = \$%%??? Make sure to implement boundary conditions correctly
22
A(N, : ) = \$%%??? Make sure to implement boundary conditions correctly
23
b = @(t) \$39??? enter function of
24
25
Time ends when t&gt;tmax
26 -
uold = -1; &amp;place holder to make sure you enter the loop
27 -
while u(end) &gt; uold
28 -
uold = u(end); \$dont loose the value on the boundary
29
supdate the solution and time
30
u = \$%% ?72
31
t = t+dt;
32
*plot in real time (you can comment this out if it slows your code down)
33 -
figure (1), cla
34 -
plot (x, u)
35
*current time
36
title( ['Current time = ', num2str(t) ])
37
y lim( [0 1] )
38 -
drawnow
39
end
Solve the problem with the following boundary conditions, initial condition and parameters.
Cleft = -1, right = 1, u(x, 0) = 1-(x], u(-1, t) = 0, 2 (1, t) = b(t) = 12, N = 30, D = 1
You will notice that the boundary with the time varying influx immediately starts to increase from t=0. You will also
notice that this scheme is unstable unless the stability condition is met. Therefore, for your answer ensure that
D
At
(4.x)2
= 0.1.
Write in answer the value of u on this boundary at the time step just before it begins to decrease. Your answer should
be rounded to the nearest 0.01.

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
• -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents