% Do some runs with Burger's Equation t_0 = 0; t_f = 4; N = 200; M = 300; [u1,x,t] = conservative_scheme(@ID,@F_eu,t_0,t_f,M,N,1); [u2,x,t] = conservative_scheme(@ID,@F_lf,t_0,t_f,M,N,1); [u3,x,t] = conservative_scheme(@ID,@F_lw,t_0,t_f,M,N,1); figure(1) for j=1:M+1 plot(x,u1(:,j)) hold on plot(x,u2(:,j),'r') plot(x,u3(:,j),'g') figure(1) hold off end figure(2) clf plot(x,u1(:,1),'LineWidth',2); hold on plot(x,u1(:,M+1),'LineWidth',2); plot(x,u2(:,M+1),'--','LineWidth',2); plot(x,u3(:,M+1),'-.','LineWidth',2); hold off xlabel('x','FontSize',16); ylabel('u','FontSize',16); axis([-pi,pi,-.1,1.3]) print -dps burgers_shock.ps figure(2) figure(3) clf hold on plot(x,u1(:,M+1),'LineWidth',2); plot(x,u2(:,M+1),'--','LineWidth',2); plot(x,u3(:,M+1),'-.','LineWidth',2); axis([1.5,2.5,-.1,1.3]) xlabel('x','FontSize',16); ylabel('u','FontSize',16); hold off print -dps burgers_shock_closeup.ps figure(3) for j=1:M+1 [cross1(j),min1(j)] = extract(x,u1(:,j)); [cross2(j),min2(j)] = extract(x,u2(:,j)); [cross3(j),min3(j)] = extract(x,u3(:,j)); end figure(4) clf plot(cross1,t,'LineWidth',2); hold on plot(cross2,t,'--','LineWidth',2); plot(cross3,t,'-.','LineWidth',2); xlabel('x','FontSize',16); ylabel('t','FontSize',16); axis([0,2,0,4]) print -dps shock_location.ps hold off figure(5) clf plot(cross1,t,'LineWidth',2); hold on plot(cross2,t,'--','LineWidth',2); plot(cross3,t,'-.','LineWidth',2); axis([1.28,1.38,2*1.28,2*1.38]) xlabel('x','FontSize',16); ylabel('t','FontSize',16); print -dps shock_location_closeup.ps hold off slope1 = diff(cross1)./diff(t); slope2 = diff(cross2)./diff(t); slope3 = diff(cross3)./diff(t); % figure(4) % clf % plot(slope1) % hold on % plot(slope2,'r') % plot(slope3,'c') % hold off mean(slope1(M/2:M)) % ans = % 4.9979e-01 mean(slope2(M/2:M)) % ans = % 5.0022e-01 mean(slope3(M/2:M)) % ans = % 4.9995e-01 % Do some runs with Burger's Equation, looking for rarefaction wave t_0 = 0; t_f = 4; N = 200; M = 400; [v,x,t] = conservative_scheme(@shock1,@F_eu,t_0,t_f,M,N,2); [u,x,t] = conservative_scheme(@shock2,@F_eu,t_0,t_f,M,N,2); figure(6) for j=1:M+1 plot(x,v(:,j)) axis([-pi,pi,-1.1,1.1]) figure(6) end figure(7) % plot solutions at times k/4 for k=0..8 plot(x,u(:,1)) hold on plot(x,u(:,25+1)) plot(x,u(:,2*25+1)) plot(x,u(:,3*25+1)) plot(x,u(:,4*25+1)) plot(x,u(:,5*25+1)) plot(x,u(:,6*25+1)) plot(x,u(:,7*25+1)) plot(x,u(:,8*25+1)) axis([-pi,pi,-1.1,1.1]) xlabel('x','FontSize',16); ylabel('u','FontSize',16); print -dps rarefaction_fan.ps figure(7) figure(8) clf % plot solutions at time 1. plot(x,u(:,101)) hold on plot(x,v(:,101),'--') axis([-pi,pi,-1.1,1.1]) xlabel('x','FontSize',16); ylabel('u,v','FontSize',16); print -dps alternate_initial_data.ps figure(8)