Question

Example 9.2. One-Dimensional Parabolic PDE: Heat Flow Equation Consider the parabolic PDE 5 1.0515 for 0s1,0S10.1(E92.1) with

0 0
Add a comment Improve this question Transcribed image text
Answer #1

i) Ex|lići.tforward Culov method me di reren fi vence and eenelditerence dijerendie N (evels in Jime let tte re ave loo inter

MATLAB Code for explicit forward Eular method:

clc; clear;
delta_t = 0.001; %%% grid size in time
delta_x=0.1; %%% grid size in space
m = 10; %%% number of grid points
N = 100; %%% levels in time
lemda =delta_t/delta_x^2;
x(1:m+1)= delta_x * ((1:m+1)-1);
%%%%%%%%%%% initial condition
for i = 1:m+1
u(1,i) = sin(pi * x(i));
end
%%%%% boundary conditions
u(1,1)= 0;
u(1,m+1)= 0;
%%%%% solution of the equation
for n = 1:N+1
u(n+1,1)= 0;
u(n+1,m+1)= 0;
for i = 2 : m
u(n+1,i) =lemda*(u(n,i+1)+u(n,i-1))+(1-2*lemda)* u(n,i)
end
end

OHS. | Page No. Date h綿 h廾 = 1+1 д太 InidHI ad bo«.dercodiHa, C0써 わ1 he madn 1, 2- i CaimScanber

MATLAB Code for Crank Nicholson method:

clc; clear;
delta_t = 0.001; %%% grid size in time
delta_x=0.1; %%% grid size in space
m = 10; %%% number of grid points
N = 100; %%% levels in time
lemda =delta_t/delta_x^2;
x(1:m+1)= delta_x * ((1:m+1)-1);
a1(1:m-1)=1+lemda;
a2(1:m-2)= -lemda/2;
a3(1:m-2)= -lemda/2;
A=diag(a1)+ diag(a2,1)+ diag(a3,-1);
b1(1:m-1)=1-lemda;
b2(1:m-2)= lemda/2;
b3(1:m-2)= lemda/2;
B=diag(b1)+ diag(b2,1)+ diag(b3,-1);
for i = 1:m+1
u(1,i) = sin(pi * x(i));
end
%%%%% boundary conditions
u(1,1)= 0;
u(1,m+1)= 0;
%%%%% solution of the equation
for n = 1:N+1
C = B* u(n,2:m)';
u(n+1,2:m) = inv(A)* C
end

Comments:

the 2D and 3D plots can be drawn by using plot (x,y) and plot3 (x,y,z) command in MATLAB. I will upload them soon.

Add a comment
Know the answer?
Add Answer to:
Example 9.2. One-Dimensional Parabolic PDE: Heat Flow Equation Consider the parabolic PDE 5 1.0515 for 0s1,0S10.1(E92.1) with the initial condition and the boundary conditions E9 2.2 Solve the par...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT