function [tof,vof]=flsh(t,p,zs,erc)
% flsh          - Performs a flash calculation & returns t for sep & V/F
% function [tof,vof]=flsh(t,p,zs,erc)
% flash calculation for compounds in cnms
% Argument List:
% Argument   Gives
%    t      temperature in units of Tdeg.
%    p      pressure in kPa.
%    zs     feed composition in mol fraction.
%    erc    error tolerance, default is .0001
% tof is the ratio of the flow in the vapor to that in the
%  feed of each compound.
% vof is V/F
% Example:>> start301b
%             (start a file that contains benzene, toluene, 
%             and o-xylene in that order)
%         >> tof=flsh(375,101,[.4 .4 .2])
%             of if you want to use V/F
%         >> [tof,vof]=flsh(375,101,[.4 .4 .2])
if nargin<4
   erc=.0001;
end
ks=kval(t,p);
omks=1-ks;
P1=[zs;omks];
fx='sum(P1(1,:).*P1(2,:)./(1-x.*P1(2,:)))';
x=0;
f1=eval(fx);
x=1;
f2=eval(fx);
if f1*f2>=0
   disp('There is no V/F for this flash.')
   return
end
vof=fzero(fx,[0 1],erc,[],P1);
tof=vof*ks./(1-vof.*P1(2,:));
