Solving nonlinear advection diffusion equation with pdepe
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
I am trying to solve the following nonlinear advection diffusion equation with pdepe :

function [x,h] = Transient();
%% Initialization
theta = 50; % degrees - angle of repose of material
n = 8; % r.p.m. - rotation speed of tube
rho = 660; % kg/m3 - bulk density of material
R = 0.075; % m - inner radius of tube
beta = 3; % degrees - inclination angle of kiln
L_tube = 2; % m,lenght of the kiln
mass_flow_rate = 0.5; % kg/min - mass flow of material
x_points=100;
t_points=100;
%% Solving initil condition
xspan_1=[0 L_tube];
h0 = 0.000001; % initial condition (bed height at the discharge end - average of particle diameter)
sol = ode45( @saeman_bed ,xspan_1 ,h0); % solver for unsteady nonliner ode
x = linspace(0,L_tube,x_points);
u_0 = deval(sol,x);
%% Solving with pdepe
m = 0;
x = linspace(0,1,x_points);
t = linspace(0,2,t_points);
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
% Extract the first solution component as u.
u = sol(:,:,1)
function [c,f,s] = pdex1pde(x,t,u,DuDx)
f_H=power((2*u/R)-power(u,2)/power(R,2),0.5);
u_T=2*pi*n*R;
c = f_H;
f = (u_T*R*cotd(theta))*power(f_H,1.5).*DuDx;
s = u_T*tand(beta)/sind(theta)*f_H.*power(1-f_H,0.5).*DuDx;
end
% --------------------------------------------------------------
function u0 = pdex1ic(x)
u0 = transpose(u_0);
% -------------------------------
end
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)
pl = ul+0.000001 % exit
ql = 0;
pr =(3*tan(deg2rad(theta))* mass_flow_rate/rho) / (4*pi*n*power(R,3)) * power((2*ul/R) - power((ul/R),2),(-3/2)) -tan(deg2rad(beta))/cos(deg2rad(theta));
qr = -1;
end
%% function for initial condition
function [dhdx,h] = saeman_bed (z,h);
dhdx = (3*tan(deg2rad(theta))* mass_flow_rate/rho) / (4*pi*n*power(R,3)) * power((2*h/R) - power((h/R),2),(-3/2)) -tan(deg2rad(beta))/cos(deg2rad(theta));
end
end
I have problems with boundary conditions "Unexpected output of BCFUN. For this problem BCFUN must return four column vectors of length 100." . Maybe somebody knows how properly set boundary conditions and pdex1pde function.
Thank you in advance!
채택된 답변
function [x,h] = Transient();
%% Initialization
theta = 50; % degrees - angle of repose of material
n = 8; % r.p.m. - rotation speed of tube
rho = 660; % kg/m3 - bulk density of material
R = 0.075; % m - inner radius of tube
beta = 3; % degrees - inclination angle of kiln
L_tube = 2; % m,lenght of the kiln
mass_flow_rate = 0.5; % kg/min - mass flow of material
x_points=100;
t_points=100;
%% Solving initial condition
xspan_1=[0 L_tube];
h0 = 0.000001; % initial condition (bed height at the discharge end - average of particle diameter)
sol = ode45( @saeman_bed ,xspan_1 ,h0); % solver for unsteady nonliner ode
x = linspace(0,L_tube,x_points);
u0 = deval(sol,x)
%% Solving with pdepe
m = 0;
x = linspace(0,1,x_points);
t = linspace(0,2,t_points);
sol = pdepe(m,@pdex1pde,@(x0)pdex1ic(x0,x,u0),@pdex1bc,x,t);
% Extract the first solution component as u.
u = sol(:,:,1)
function [c,f,s] = pdex1pde(x,t,u,DuDx)
f_H=power((2*u/R)-power(u,2)/power(R,2),0.5);
u_T=2*pi*n*R;
c = f_H;
f = (u_T*R*cotd(theta))*power(f_H,1.5).*DuDx;
s = u_T*tand(beta)/sind(theta)*f_H.*power(1-f_H,0.5).*DuDx;
end
% --------------------------------------------------------------
function u0 = pdex1ic(x0,x,u)
u0 = interp1(x,u,x0);
% -------------------------------
end
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)
pl = ul+0.000001 % exit
ql = 0;
pr =(3*tan(deg2rad(theta))* mass_flow_rate/rho) / (4*pi*n*power(R,3)) * power((2*ul/R) - power((ul/R),2),(-3/2)) -tan(deg2rad(beta))/cos(deg2rad(theta));
qr = -1;
end
%% function for initial condition
function [dhdx,h] = saeman_bed (z,h);
dhdx = (3*tan(deg2rad(theta))* mass_flow_rate/rho) / (4*pi*n*power(R,3)) * power((2*h/R) - power((h/R),2),(-3/2)) -tan(deg2rad(beta))/cos(deg2rad(theta));
end
end
댓글 수: 12
Dear Torsten,
Thank you for your help butnow I have a warning " Warning: Failure at t=2.870379e-04. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (8.673617e-19) at time t."
Your boundary condition at the right end is incorrect.
Note that pr and qr are to be set such that
pr + qr*f = 0
not
pr + qr*dh/dz=0
Alina Mexdi
2018년 11월 26일
편집: Alina Mexdi
2018년 11월 26일
I am new in matlab pdepe function so seems I understand in wrongly, I am trying to code right boundary with this expression : 

Can you explain me please how it could be done in a proper way ?
Do I underatsnd correctly that instead of :
qr=-1
it should be
qr = -(u_T*R*cotd(theta))*power(f_H,1.5)
No,
qr = -1/(u_T*R*cotd(theta))*power(f_H,1.5))
And you use "ul" in the calculation of "pr". It has to be "ur".
And where is the 1/3 in the calculation of f ?
And you set h(t,z=0) = -0.000001 as boundary condition. Is this negative value for h correct ?
Alina Mexdi
2018년 11월 26일
편집: Alina Mexdi
2018년 11월 26일
Thank you very much Mr. Torsten . Now it converges but if I plot the results is shows me the following: 

Meaning that nothing changes with time. But in my case it should show me evolution of filling degre of bed in the rotary kiln.
I have tried another BC:
pl = ul-0.00008;
ql = ones(x_points,1).*0;
pr =(3*tan(deg2rad(theta))* mass_flow_rate/rho) / (4*pi*n*power(R,3)) * power((2*ur/R) - power((ur/R),2),(-3/2)) -tan(deg2rad(beta))/cos(deg2rad(theta));
qr = ones(x_points,1).*-1;
ql and qr are set up in this way because otherwise it says that "Unexpected output of BCFUN. For this problem BCFUN must return four column vectors of length 50."
and the resulting plot i:

which is exactly what i would like to see as a result. I am doing something crazy or totally wrong? Or why can't I get right evoulution of the function with respect to time with right BC?
Please include again the complete code you are using at the moment.
Alina Mexdi
2018년 11월 26일
편집: Alina Mexdi
2018년 11월 26일
This is the code which produces kind of "right" evolution with time but as you noted wrong BC :
function [x,h] = Transient();
%% Initialization
theta = 36.44; % degrees - angle of repose of material
n = 8; % r.p.m. - rotation speed of tube
rho = 660; % kg/m3 - bulk density of material
R = 0.075; % m - inner radius of tube
beta = 3; % degrees - inclination angle of kiln
L_tube = 2; % m,lenght of the kiln
Time=20;
mass_flow_rate = 0.5; % kg/min - mass flow of material
x_points=50;
t_points=100;
%% Solving initil condition
xspan_1=[0 L_tube];
h0 = 0.00008; % initial condition (bed height at the discharge end - average of particle diameter)
sol = ode45( @saeman_bed ,xspan_1 ,h0); % solver for unsteady nonliner ode
x = linspace(0,L_tube,x_points);
u_0 = deval(sol,x)
%% Solving with pdepe
m = 0;
x = linspace(0,L_tube,x_points);
t = linspace(0,Time,t_points);
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
% Extract the first solution component as u.
u = sol(:,:,1)
% A surface plot is often a good way to study a solution.
surf(x,t,u)
title('Numerical solution.')
xlabel('Distance x')
ylabel('Time t')
% A solution profile can also be illuminating.
figure
plot(x,u(end,:))
title('Solution at t = final')
xlabel('Distance x')
ylabel('Bed height')
function [c,f,s] = pdex1pde(x,t,u,DuDx)
f_H=power((2*u/R)-power(u,2)/power(R,2),0.5);
u_T=2*pi*n*R;
c = f_H;
f = ((u_T/3)*R*cotd(theta))*power(f_H,1.5).*DuDx;
s = u_T*tand(beta)/sind(theta)*f_H.*power(1-f_H,0.5).*DuDx;
end
% --------------------------------------------------------------
function u0 = pdex1ic(x);
u0 = transpose(u_0);
% -------------------------------
end
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t);
pl = ul-0.00008;
ql = ones(x_points,1).*0;
pr =(3*tan(deg2rad(theta))* mass_flow_rate/rho) / (4*pi*n*power(R,3)) * power((2*ur/R) - power((ur/R),2),(-3/2)) -tan(deg2rad(beta))/cos(deg2rad(theta));
qr = ones(x_points,1).*-1;
end
%% function for initial condition
function [dhdx,h] = saeman_bed (z,h);
dhdx = (3*tan(deg2rad(theta))* mass_flow_rate/rho) / (4*pi*n*power(R,3)) * power((2*h/R) - power((h/R),2),(-3/2)) -tan(deg2rad(beta))/cos(deg2rad(theta));
end
end
And this is the code with your corrections and right BC:
function [x,h] = Transient();
%% Initialization
theta = 36.44; % degrees - angle of repose of material
n = 8; % r.p.m. - rotation speed of tube
rho = 660; % kg/m3 - bulk density of material
R = 0.075; % m - inner radius of tube
beta = 3; % degrees - inclination angle of kiln
L_tube = 2; % m,lenght of the kiln
mass_flow_rate = 0.5; % kg/min - mass flow of material
x_points=50;
t_points=30;
%% Solving initial condition
xspan_1=[0 L_tube];
h0 = 0.000001; % initial condition (bed height at the discharge end - average of particle diameter)
sol = ode45( @saeman_bed ,xspan_1 ,h0); % solver for unsteady nonliner ode
x = linspace(0,L_tube,x_points);
u0 = deval(sol,x)
%% Solving with pdepe
m = 0;
x = linspace(0,2,x_points);
t = linspace(0,5,t_points);
sol = pdepe(m,@pdex1pde,@(x0)pdex1ic(x0,x,u0),@pdex1bc,x,t);
% Extract the first solution component as u.
u = sol(:,:,1)
% A surface plot is often a good way to study a solution.
surf(x,t,u)
title('Numerical solution')
xlabel('Distance x')
ylabel('Time t')
% A solution profile can also be illuminating.
figure
plot(x,u(end,:))
title('Solution at t = final')
xlabel('Distance x')
ylabel('Bed height')
function [c,f,s] = pdex1pde(x,t,u,DuDx)
f_H=power((2*u/R)-power(u,2)/power(R,2),0.5);
u_T=2*pi*n*R;
c = f_H;
f = ((u_T/3)*R*cotd(theta))*power(f_H,1.5).*DuDx;
s = u_T*tand(beta)/sind(theta)*f_H.*power(1-f_H,0.5).*DuDx;
end
% --------------------------------------------------------------
function u0 = pdex1ic(x0,x,u)
u0 = interp1(x,u,x0);
% -------------------------------
end
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)
pl = ul-0.000001; % exit
ql = 0;
pr =(3*tan(deg2rad(theta))* mass_flow_rate/rho) / (4*pi*n*power(R,3)) * power((2*ur/R) - power((ur/R),2),(-3/2)) -tan(deg2rad(beta))/cos(deg2rad(theta));
qr = -1/(2*pi*n*R*R*cotd(theta))*power(power((2*ur/R)-power(ur,2)/power(R,2),0.5),1.5);
end
%% function for initial condition
function [dhdx,h] = saeman_bed (z,h);
dhdx = (3*tan(deg2rad(theta))* mass_flow_rate/rho) / (4*pi*n*power(R,3)) * power((2*h/R) - power((h/R),2),(-3/2)) -tan(deg2rad(beta))/cos(deg2rad(theta));
end
end
P.S. in this case I don't understand what is passed to pdex1ic(x0,x,u0) ,namely what is x0 ,becauseit isnot defined anyway.
%% Initialization
theta = 36.44; % degrees - angle of repose of material
n = 8; % r.p.m. - rotation speed of tube
rho = 660; % kg/m3 - bulk density of material
R = 0.075; % m - inner radius of tube
beta = 3; % degrees - inclination angle of kiln
L_tube = 2; % m,lenght of the kiln
mass_flow_rate = 0.5; % kg/min - mass flow of material
x_points=50;
t_points=30;
%% Solving initial condition
xspan_1=[0 L_tube];
h0 = 0.000001; % initial condition (bed height at the discharge end - average of particle diameter)
sol = ode45( @saeman_bed ,xspan_1 ,h0); % solver for unsteady nonliner ode
x = linspace(0,L_tube,x_points);
u0 = deval(sol,x);
%% Solving with pdepe
m = 0;
x = linspace(0,2,x_points);
t = linspace(0,5,t_points);
sol = pdepe(m,@pdex1pde,@(x0)pdex1ic(x0,x,u0),@pdex1bc,x,t);
% Extract the first solution component as u.
u = sol(:,:,1)
% A surface plot is often a good way to study a solution.
surf(x,t,u)
title('Numerical solution')
xlabel('Distance x')
ylabel('Time t')
% A solution profile can also be illuminating.
figure
plot(x,u(1,:),x,u(end,:))
title('Solution at t = final')
xlabel('Distance x')
ylabel('Bed height')
function [c,f,s] = pdex1pde(x,t,u,DuDx)
f_H=power((2*u/R)-power(u,2)/power(R,2),0.5);
u_T=2*pi*n*R;
c = f_H;
f = ((u_T/3)*R*cotd(theta))*power(f_H,1.5).*DuDx;
s = u_T*tand(beta)/sind(theta)*f_H.*power(1-f_H,0.5).*DuDx;
end
% --------------------------------------------------------------
function u0 = pdex1ic(x0,x,u)
u0 = interp1(x,u,x0);
% -------------------------------
end
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)
pl = ul-0.000001; % exit
ql = 0;
pr =(3*tan(deg2rad(theta))* mass_flow_rate/rho) / (4*pi*n*power(R,3)) * power((2*ur/R) - power((ur/R),2),(-3/2)) -tan(deg2rad(beta))/cos(deg2rad(theta));
qr = -1/(2*pi*n*R/3*R*cotd(theta))*power(power((2*ur/R)-power(ur,2)/power(R,2),0.5),1.5);
end
%% function for initial condition
function [dhdx,h] = saeman_bed (z,h);
dhdx = (3*tan(deg2rad(theta))* mass_flow_rate/rho) / (4*pi*n*power(R,3)) * power((2*h/R) - power((h/R),2),(-3/2)) -tan(deg2rad(beta))/cos(deg2rad(theta));
end
end
Dear Torsten,
Still as can be seen the curve doesn't change with the time

Probably I am doing something wrong because my initial profile u (x,0) actually should be considered as a final steady state solution and by transient regime I want to see the evolution of this fucntion till that steady state moment. like here:

But if you start with a steady-state profile obtained from ODE45, why do you expect it should change in the transient calculation ?
In the plot where you see an evolution of the profile, you start with a profile that is not the one obtained from ODE45 as you can see when you compare the two surfaces at time t=0. So you will see an evolution as it is not steady-state.
Thank you very much , now verything became clear. The last question please , I am calculating steady state solution with ode45, and I'm calculating transient one with pdepe and pdepe slightly underestimate the function :
Is it a feature/drawback/difference of the solvers , or I should look carefully for mistakesin my code ?
I don't understand why the ODE45 solution is the steady-state solution of the problem.
The steady-state solution is the solution of the transient problem if you neglect time-dependent terms. In the present problem, remove F_h^1/2 * dh/dt from your PDE equation and leave the boundary conditions as they are. You'll arrive at a second-order ODE for h with one boundary condition at the left and one boundary condition at the right endpoint of the spatial interval. This could be solved using BVP4C.
Maybe the problem you solve with ODE45 is an approximation to the steady-state profile.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 1-D Partial Differential Equations에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
