필터 지우기
필터 지우기

Solving multiple PDE with using PDEPE

조회 수: 8 (최근 30일)
Sait Mutlu Karahan
Sait Mutlu Karahan 2022년 6월 2일
편집: Torsten 2022년 6월 4일
Hi guys,
I have a trouble to use pdepe. I want to solve 4 different partial differential equation and here is the my boundary conditions. Here is the my problem's physical setup.
Acoording to this physical setup here is the my boundary conditions.
Here is the my initial condition.
And my pdes are:
L = 1500; %lenght
x = linspace(0,L,1501); %x values from 0 to 1000 and dx=1 meter
t = linspace(0,10,11); %t values from 0 to 10 and dt=1 day
m = 0;
%coordinate and it is also explained in the form of pdepe
sol = pdepe(m,@headpde,@headic,@headbc,x,t);%solution of head partial dif. equ. with
colormap hot %
imagesc(x,t,sol) %
colorbar % Graph of the t<=0 to t<=20
hold on %
xlabel('Distance x','interpreter','latex') %
ylabel('Time t','interpreter','latex') %
title('Head Distribution for $0 \le x \le 1500$ and $0 \le t \le 10$','interpreter','latex')
function [c,f,s] = headpde(x,t,u,dudx)
c = [6.67*10^-4;5*10^-4;4*10^-4;3.33*10^-4];
f = [1;1;1;1].*dudx;
s = [0;2*10^-6;4*10^-6;0];
end
function u0 = headic(x) %initial condition of pde
u0 = (-2/150*x)+60; % equation of initial condition
end
function [pl,ql,pr,qr] = headbc(xl,ul,xr,ur,t) %Boundary condition of pde
pl = ul-60; %Left side boundary condition is fixed and %it is equal to 60 this line represents that
ql = 0;
pr = ur-40; %Right side boundary condition is fixed and %it is equal to 40
qr = 0; %qr shows that again in the right side of %the boundary condition
end
I wrote this code for only t is between 0 to 10 days. But it gives errors. For this reason I will be grateful if you could help me!
P.S. I'm a new learner that's why if you be kind to me I would be appreciate :)

채택된 답변

Torsten
Torsten 2022년 6월 2일
편집: Torsten 2022년 6월 4일
L = 1500; %lenght
x = linspace(0,L,1501); %x values from 0 to 1000 and dx=1 meter
t = linspace(0,20,21); %t values from 0 to 10 and dt=1 day
m = 0; %coordinate and it is also explained in the form of pdepe
sol = pdepe(m,@headpde,@headic,@headbc,x,t);%solution of head partial dif. equ. with
colormap hot %
imagesc(x,t,sol) %
colorbar % Graph of the t<=0 to t<=20
hold on %
xlabel('Distance x','interpreter','latex') %
ylabel('Time t','interpreter','latex') %
title('Head Distribution for $0 \le x \le 1500$ and $0 \le t \le 10$','interpreter','latex')
function [pl,ql,pr,qr] = headbc(xl,ul,xr,ur,t) %Boundary condition of pde
if t <= 10
pl = ul - 60;
ql = 0.0;
else
pl = ul - (60-(t-10));
ql = 0.0;
end
pr = ur - 40;
qr = 0;
end
function [c,f,s] = headpde(x,t,u,dudx)
if x <= 500
c = 6.67e-4;
f = dudx;
s = 0;
elseif x > 500 && x <=800
c = 5e-4;
f = dudx;
s = 2e-6;
elseif x > 800 && x <= 1100
c = 4e-4;
f = dudx;
s = 4e-6;
else
c = 3.33e-4;
f = dudx;
s = 0.0;
end
end
function ic = headic(x)
ic = -2/150*x + 60;
end
  댓글 수: 1
Sait Mutlu Karahan
Sait Mutlu Karahan 2022년 6월 2일
Hi Torsten! You are truly a life saver! Thanks for replying my two problems and thanks for your time! You really help me a lot! Thanks many times :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Eigenvalue Problems에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by