|
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
|