Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
pdepe help

Subject: pdepe help

From: John Wise

Date: 9 Jan, 2011 12:20:05

Message: 1 of 2

Hello everyone
I am trying to solve advection diffusion equation du/dt=Alpha*d^2u/dx^2-a(x)*du/dx
by using pdepe but I couldn't figure out how to complete the code.
u: Temperature
Alpha: thermal diffusivity = 1.6e-7
a(x): velocity changing with time and varys with position
initial conditions
u0=293
boundary conditions:
at x=0 u=tct (tct is increasing each time step)
at x=0.5 du/dx=0

function pdex1
% --------------------
clc; clear all; format compact;
m = 1;
x = linspace(0,0.5,10);
t = linspace(0,10,20);
% ----------------------------------------------
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
u = sol(:,:,1);
figure(1), surf(x,t,u)
title('Numerical solution computed with 20 mesh points.')
xlabel('Distance x'), ylabel('Time t')
figure(2), plot(x,u(end,:))
title('Solution at t = 2')
xlabel('Distance x'), ylabel('u(x,2)')
% --------------------------------------------------------------
function [c,f,s] = pdex1pde(x,t,u,DuDx,a,Alpha)
% --------------------------------------------------------------
c = 1;
f = Alpha*DuDx-a*u;
s = 0;
end
% --------------------------------------------------------------
function u0 = pdex1ic(x)
% --------------------------------------------------------------
u0 = 293;
end
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)
% --------------------------------------------------------------
pl =;
ql =;
pr =;
qr = ;
end
end
any help is apreciated, thank you

Subject: pdepe help

From: Torsten Hennig

Date: 10 Jan, 2011 13:38:03

Message: 2 of 2

> Hello everyone
> I am trying to solve advection diffusion equation
> du/dt=Alpha*d^2u/dx^2-a(x)*du/dx
> by using pdepe but I couldn't figure out how to
> complete the code.
> u: Temperature
> Alpha: thermal diffusivity = 1.6e-7
> a(x): velocity changing with time and varys with
> position
> initial conditions
> u0=293
> boundary conditions:
> at x=0 u=tct (tct is increasing each time step)
> at x=0.5 du/dx=0
>
> function pdex1
> % --------------------
> clc; clear all; format compact;
> m = 1;
> x = linspace(0,0.5,10);
> t = linspace(0,10,20);
> % ----------------------------------------------
> sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
> u = sol(:,:,1);
> figure(1), surf(x,t,u)
> title('Numerical solution computed with 20 mesh
> points.')
> xlabel('Distance x'), ylabel('Time t')
> figure(2), plot(x,u(end,:))
> title('Solution at t = 2')
> xlabel('Distance x'), ylabel('u(x,2)')
> %
> ------------------------------------------------------
> --------
> function [c,f,s] = pdex1pde(x,t,u,DuDx,a,Alpha)
> %
> ------------------------------------------------------
> --------
> c = 1;
> f = Alpha*DuDx-a*u;
> s = 0;

c = 1;
f = Alpha*Dudx;
s = -a*Dudx;

> end
> %
> ------------------------------------------------------
> --------
> function u0 = pdex1ic(x)
> %
> ------------------------------------------------------
> --------
> u0 = 293;
> end
> function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)
> %
> ------------------------------------------------------
> --------
> pl =;
> ql =;
> pr =;
> qr = ;

pl = ul-tct;
ql = 0.0;
pr = 0.0;
qr = 1.0;

> end
> end
> any help is apreciated, thank you

Best wishes
Torsten.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us