Code covered by the BSD License  

Highlights from
Chebfun V4

image thumbnail

Chebfun V4

by

 

30 Apr 2009 (Updated )

Numerical computation with functions instead of numbers.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

Advection-diffusion equation with a jump

Advection-diffusion equation with a jump

Nick Trefethen, November 2010

(Chebfun example ode/AdvDiffJump.m)

The advection-diffusion equation

  0.2u" + u' = -1,    u(-10) = u(10) = 1

has a boundary layer at the left:

LW = 'linewidth'; lw = 2; FS = 'fontsize'; fs = 8;
N = chebop(-10,10);
N.op = @(u) 0.2*diff(u,2) + diff(u);
N.bc = 'dirichlet';
u = N\-1;
plot(u,LW,lw), grid on
axis([-10.1 10 0 20])

Suppose the advection is only turned on on the right half of the domain?

figure
N.op = @(x,u) 0.2*diff(u,2) + (x>=0).*diff(u);
N.bc = 'dirichlet';
v = N\-1;
plot(v,'r',LW,lw), grid on
axis([-10.1 10 0 75])

For fun we can plot both solutions on the same axis.

plot(u,'b',v,'--r',LW,lw), grid on
axis([-10.1 10 0 75])

Contact us