function [x,res,t]=Burger_CrankNicolson(model)
dx=2*model.xmax/(model.nPt-1);
dt=model.courant*dx;
s=model.viscosite*dt/(dx*dx);
sa=model.ad*model.courant*model.courant;
rcel=dx/model.viscosite;
qq=model.q*model.courant/3;


[x,u]=conditions_initialles(model.xmax, model.nPt);
ud=0*u;
res=zeros(model.ntemps, model.nPt);

t=(1:model.ntemps)*dt;

i=2:(model.nPt-1);
im2=[1,(1:model.nPt-3)];

for j=1:model.ntemps
	ud(1)=u(1);
	ud(end)=u(end);

	a=-(0.25+0.5*model.q)*model.courant*u(i-1)+model.delta-0.5*s-0.5*sa*u(i-1);
	b=(1+s-2*model.delta+(0.5*model.q*model.courant)*u(i))+sa*u(i);
	c=(0.25-model.q/6)*model.courant*u(i+1)-0.5*s+model.delta-0.5*sa*u(i+1);
    e=model.q/6*model.courant*u(im2);
    
    
	d=(0.5*s+model.delta)*u(i-1)+(1-s-2*model.delta)*u(i)+(0.5*s+model.delta)*u(i+1);

    d(1)=d(1)-a(1)*u(1)-e(1)*u(1);
    d(2)=d(2)-e(2)*u(1);
    d(end)=d(end)-c(end)*u(end);
    
    LL=diag(e(3:end),-2);
	L=diag(a(2:end),-1);
	D=diag(b);
	U=diag(c(1:end-1),1);

	A=D+L+U+LL;
    
	ud(i)=A\d';



	res(j,:)=ud;
	u=ud;
end





