0% found this document useful (0 votes)
109 views17 pages

Alvian Iqbal Hanif N 13614013 No.1 Figure 18.4

The document discusses the numerical solution of 4 partial differential equations using MATLAB's pdepe and pdetool functions. For each PDE problem, the document provides the equation, boundary and initial conditions based on figures in the textbook. It also includes the MATLAB code used to solve each problem and compares the numerical solutions to those in the textbook figures, finding them to be similar overall.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
109 views17 pages

Alvian Iqbal Hanif N 13614013 No.1 Figure 18.4

The document discusses the numerical solution of 4 partial differential equations using MATLAB's pdepe and pdetool functions. For each PDE problem, the document provides the equation, boundary and initial conditions based on figures in the textbook. It also includes the MATLAB code used to solve each problem and compares the numerical solutions to those in the textbook figures, finding them to be similar overall.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Alvian Iqbal Hanif N

13614013
No.1 Figure 18.4
𝑢𝑡 + 2𝑢𝑥 = 0
(−5, 𝑡) = 0, (5, 𝑡) = 0

PDE:
Bentuk umum PDE

𝐴𝑢𝑥𝑥 + 2𝐵𝑢𝑥𝑦 + 𝐶𝑢𝑦𝑦 + 𝑃𝑢𝑥 + 𝑄𝑢𝑦 + 𝑅𝑢 = 𝐹


Persamaan figure 18.4,
𝑢𝑡 + 2𝑢𝑥 = 0
Penentuan tipe dari pencarian diskriminan
𝑑 = 𝐵2 − 𝐴𝐶 = 0 − 0 = 0 ≫≫Tipe Parabolic
𝑑𝑢𝑡 − ∇. (𝑐(∇𝑢)) + 𝑎𝑢 = 𝑓
𝑢𝑡 + 2𝑢𝑥 = 0
𝑑 = 1, 𝑐 = 0, 𝑎 = 0, 𝑓 = 0

Boundary Condition:
Kondisi batas untuk (𝑥, 0) dan 𝑢𝑥(0, 𝑡),
Kondisi batas 𝑢(−5, 𝑡) = 0 dan 𝑢(5, 𝑡) = 0

Kondisi awal:

PDEPE
Code:
function pdex1
m = 0;
x = linspace(-5,5,200);
t = linspace(0,2,50);
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
u = sol(:,:,1);
figure;
surf(x,t,u);
title('Numerical solution');
xlabel('Distance x');
ylabel('Time t');

%
---------------------------------------------------------
-----

function [c,f,s] = pdex1pde(x,t,u,DuDx)


c = 1;
f = -2*u;
s = 0;

%
---------------------------------------------------------
------

function u0 = pdex1ic(x)
u0 = exp(-sqrt(0.3)*x.^2);

%
---------------------------------------------------------
-----

function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)


pl = ul;
ql = 0;
pr = ur;
qr = 0;

Hasil:

(a) Hasil Pdetool (b) Hasil PDEPE


No.2 Figure 18.5a
𝑢𝑡 + 3𝑢𝑥 − 𝑢 = 𝑥
(−4, 𝑡) = −12.5𝑡, (4, 𝑡) = 6.25𝑡
(𝑥, 0) = sin 𝑥

PDE:
Bentuk umum persamaan PDE

𝐴𝑢𝑥𝑥 + 2𝐵𝑢𝑥𝑦 + 𝐶𝑢𝑦𝑦 + 𝑃𝑢𝑥 + 𝑄𝑢𝑦 + 𝑅𝑢 = 𝐹


Persamaan untuk gambar 18.5a:
𝑢𝑡 + 3𝑢𝑥 − 𝑢 = 𝑥
Pencarian disriminan untuk penentuan tipe PDE
𝑑 = 𝐵2 − 𝐴𝐶 = 0 − 0 = 0 ≫≫ PDE tipe parabolic
𝑑𝑢𝑡 − ∇. (𝑐(∇𝑢)) + 𝑎𝑢 = 𝑓
𝑢𝑡 + 3𝑢𝑥 − 𝑢 = 𝑥
Sehingga,
𝑑 = 1, 𝑐 = 0, 𝑎 = −1, 𝑓 = 𝑥

Kondisi batas
Kondisi batas untuk (𝑥, 0) dan 𝑢𝑥(0, 𝑡),
Kondisi batas untuk 𝑢(−4, 𝑡) = −12.5𝑡

untuk 𝑢(4, 𝑡) = 6.25𝑡

Kondisi awal:
(𝑥, 0) = sin 𝑥
PDEPE
 Code:
function pdex1
m = 0;
x = linspace(-5,5,100);
t = linspace(0,0.8,20);
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
u = sol(:,:,1);
figure;
surf(x,t,u);
title('Numerical solution');
xlabel('Distance x');
ylabel('Time t');

%
--------------------------------------------------
-------------

function [c,f,s] = pdex1pde(x,t,u,DuDx)


c = 1;
f = -3*u;
s = u + x;

%
--------------------------------------------------
-------------

function u0 = pdex1ic(x)
u0 = sin(x);
%
--------------------------------------------------
-------------

function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)


pl = -exp(t)*(sin(-5-3*t)-2-3*t)-2+ul;
ql = 0;
pr = -exp(t)*(sin(5-3*t)+8-3*t)+8+ur;
qr = 0;

Hasil :
Numerical solution

10

-5

-10
0.8
0.6 5
0.4
0
0.2
Time t 0 -5 Distance x

(a) Hasil Pdetool (b) Hasil PDEPE

No.2 Figure 18.5b


𝑢𝑡 + 3𝑢𝑥 − 𝑢 = 0
(−4, 𝑡) = −12.5𝑡, (4, 𝑡) = 6.25𝑡
(
𝑥, 0) = sin 𝑥 PDE Specification:
Bentuk umum PDE

𝐴𝑢𝑥𝑥 + 2𝐵𝑢𝑥𝑦 + 𝐶𝑢𝑦𝑦 + 𝑃𝑢𝑥 + 𝑄𝑢𝑦 + 𝑅𝑢 = 𝐹


Persamaan untuk gambar 18.5b:
𝑢𝑡 + 3𝑢𝑥 − 𝑢 = 0
Diskriminan
𝑑 = 𝐵2 − 𝐴𝐶 = 0 − 0 = 0 ≫≫ PDE tipe parabolic
𝑑𝑢𝑡 − ∇. (𝑐(∇𝑢)) + 𝑎𝑢 = 𝑓

𝑢𝑡 + 3𝑢𝑥 − 𝑢 = 0

Sehingga,
𝑑 = 1, 𝑐 = 0, 𝑎 = −1, 𝑓 = 0

Kondisi batas
Kondisi batas untuk (𝑥, 0) dan 𝑢𝑥(0, 𝑡),

untuk 𝑢(−4, 𝑡) = −12.5𝑡


Dan untuk (4, 𝑡) = 6.25𝑡

Kondisi awal :
(𝑥, 0) = sin 𝑥

PDEPE
 Code:
function pdex1
m = 0;
x = linspace(-5,5,200);
t = linspace(0,0.8,50);
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
u = sol(:,:,1);
figure;
surf(x,t,u);
title('Numerical solution');
xlabel('Distance x');
ylabel('Time t');

%
--------------------------------------------------
-------------

function [c,f,s] = pdex1pde(x,t,u,DuDx)


c = 1;
f = -3*u;
s = u;

%
--------------------------------------------------
-------------

function u0 = pdex1ic(x)
u0 = sin(x);

%
--------------------------------------------------
-------------

function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)


pl = -exp(t)*sin(-5-3*t)+ul;
ql = 0;
pr = -exp(t)*sin(5-3*t)+ur;
qr = 0;

Result:
Numerical solution

-1

-2

-3
0.8
0.6 5
0.4
0
0.2
Time t 0 -5 Distance x

(a) Hasil Pdetool (b) Hasil PDEPE

No.3 Figure 18.6


𝑢𝑡 + 𝑥𝑢𝑥 + 𝑢 = 1

(−4, 𝑡) = 1 + 𝑒𝑥(−𝑡) tanh(−1) , 𝑢(4, 𝑡) = 1 + 𝑒𝑥𝑝(−𝑡) tanh(𝑒𝑥𝑝(−𝑡))


(𝑥, 0) = tanh 𝑥

PDE Specification:
Bentuk umum PDE

𝐴𝑢𝑥𝑥 + 2𝐵𝑢𝑥𝑦 + 𝐶𝑢𝑦𝑦 + 𝑃𝑢𝑥 + 𝑄𝑢𝑦 + 𝑅𝑢 = 𝐹


Persamaan untuk gambar 18.6:
𝑢𝑡 + 𝑥𝑢𝑥 + 𝑢 = 1
Diskriminan
𝑑 = 𝐵2 − 𝐴𝐶 = 0 − 0 = 0 ≫≫ PDE tipe parabolic
𝑑𝑢𝑡 − ∇. (𝑐(∇𝑢)) + 𝑎𝑢 = 𝑓

𝑢𝑡 + 𝑥𝑢𝑥 + 𝑢 = 1
Sehingga,
𝑑 = 1, 𝑐 = 0, 𝑎 = 1, 𝑓 = 1

Kondisi batas :
Kondisi batas untuk (𝑥, 0) dan 𝑢𝑥(0, 𝑡),.

Sedangkan untuk (−4, 𝑡) = 1 + 𝑒𝑥(−𝑡) tanh(−1)

Dan untuk (4, 𝑡) = 1 + 𝑒𝑥(−𝑡) tanh(𝑒𝑥𝑝(−𝑡))

Kondisi awal:
(𝑥, 0) = tanh 𝑥
PDEPE
 Code:
function pdex1
m = 0;
x = linspace(-5,5,100);
t = linspace(0,2,40);
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
u = sol(:,:,1);
figure;
surf(x,t,u);
title('Numerical solution');
xlabel('Distance x');
ylabel('Time t');

%
--------------------------------------------------
---------

function [c,f,s] = pdex1pde(x,t,u,DuDx)


c = 1;
f = -x*u;
s = 1 - u;

%
--------------------------------------------------
----------

function u0 = pdex1ic(x)
u0 = tanh(x);

%
--------------------------------------------------
----------
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)
pl = -exp(-t)*tanh(-5*exp(-t))-1+ul;
ql = 0;
pr = -exp(-t)*tanh(5*exp(-t))-1+ur;
qr = 0;
Hasil

(a) Hasil Pdetool (b) Hasil PDEPE

No.4 Figure 18.7


𝑢𝑡 + 𝑢 𝑥 = 𝑢 2
(−5, 𝑡) = 0, (5, 𝑡) = 1
(𝑥, 0) = sin 𝑥
PDE Specification:
Bentuk umum PDE

𝐴𝑢𝑥𝑥 + 2𝐵𝑢𝑥𝑦 + 𝐶𝑢𝑦𝑦 + 𝑃𝑢𝑥 + 𝑄𝑢𝑦 + 𝑅𝑢 = 𝐹


Persamaan untuk gambar 18.7:
𝑢𝑡 + 𝑢𝑥 = 𝑢2
Diskriminan
𝑑 = 𝐵2 − 𝐴𝐶 = 0 − 0 = 0 ≫≫PDE tipe parabolic
𝑑𝑢𝑡 − ∇. (𝑐(∇𝑢)) + 𝑎𝑢 = 𝑓
𝑢𝑡 + 𝑢 𝑥 = 𝑢 2
Sehingga,
𝑑 = 1, 𝑐 = 0, 𝑎 = 0, 𝑓 = 𝑢2

Kondisi batas :
Kondisi batas untuk (𝑥, 0) dan 𝑢𝑥(0, 𝑡),

Sedangkan untuk (−5, 𝑡) = 0

Dan untuk (5, 𝑡) = 1


Kondisi awal :
(𝑥, 0) = sin 𝑥

Hasil

(a) Hasil Pdetool (b) Figure 18.7

Analisis
Hasil yang diperoleh dari penggunaan pdetool dan PDEPE dengan gambar
dari buku Jeffrey cukup sama. Perbedaannya hanyalah banyaknya mesh yang
digunakan sehingga terlihat hasil yang terlihat kasar. Kondisi batas, kondisi awal,
dan persamaan yang digunakan sama dengan masalah yang tertera pada buku
Jeffrey.

You might also like