%  This is the two phase plug flow problem from E. Hairer, Ch. Lubich,
%  and M. Roche, The Numerical Solution of Differential-Algebraic Systems 
%  by Runge-Kutta Methods, Lecture Notes in Math. #1409, Springer, Berlin,
%  1989, specifically the normal flow example.  There are two algebraic 
%  variables.  The variables of HLR correspond to those used here as follows:
%     P <--> y(1), u <--> y(2), y <--> y(3). 

% Copyright 1999, The MathWorks, Inc.

clear all
global y0

%  Consistent initial conditions from HLR:
y0 = zeros(3,1);
y0(1)  =  1.457e8; 
y0(2)  =  1.651469869370661357709407;
y0(3)  =  4.877400707738074248312839;

%  Change the algebraic components to test initialization.
y0(2:3) = 0.5 * y0(2:3);

L = 8.047e6;
tspan = [0 L];
options = odeset('Mass','M','RelTol',1e-6,'AbsTol',1e-6);

[t,y] = ode15s('ex5ode',tspan,y0,options);

plot(t,1e-7*y(:,1),t,y(:,3))
axis([9e5 L 0 15])
title('Two Phase Plug Flow--Normal Flow.')
xlabel('The first component is multiplied by 1e-7.')



