% For this version, we do explicit advection and implicit dispersion.
% We use centered differences - uncentered blows up rather quickly.

clear all;

%initial info

N = 300;
T = 0.015;

dx = 2/N;
dt = 1*10^-6;

x = -1:dx:1;

r1 = dt/(2*dx);
r3 = dt/(2*dx^3);

diff1 = sparse([0 r1 zeros(1,N-2) -r1]);
diff3 = sparse([0 -2*r3 r3 zeros(1,N-4) -r3 2*r3]);

d3 = speye(N+1) - toeplitz(diff3,-diff3);
d1 = toeplitz(diff1,-diff1);

U = zeros(N+1,round(T/dt)+1);
temp = zeros(N+1,1);

f1 = 200./(cosh(10.*(x+0.7)).^2);
f2 = 100./(cosh(sqrt(50)*x).^2);

U(:,1) = f1+f2;

for n=2:round(T/dt)+1
	temp = U(:,n-1) + 6*U(:,n-1).*(d1*U(:,n-1));
	U(:,n) = d3\temp;
end
