function [t,xs]=dewpt(p,ys,erc,nmax)
% dewpt		- Determines the dew point of a mixture
% function [t,xs]=dewpt(p,ys,erc)
% Argument List:
% Argument    Gives
%    p       pressure in kPa
%    ys      vector of vapor mol fractions.
%   erc      error tolerance
% Returns     Giving
%    t       Dew point temp. in Tdeg.
%    xs      vector of liquid mol fractions in equil.
%            with the vapor at the dew point.
% Ex: start301   to specify the compounds  
%     [t,xs]=dewpt(101,[.4 .4 .2])
%    (will give the dew point at 101kPa for the vapor mol fractions:
%     Compound   vapor mol frac.
%     first          .4
%     second         .4
%     third          .2
if nargin<3
   erc=.0001;
   nmax=10;
end
j=ys>0;
ts=teql(p,j);
tbs=[max(ts),min(ts)];
len=length(ys)+2;
c=[p,len,ys];
 t=ssec2(tbs,'1-sum(c(3:c(2))./kval(x,c(1)))',c,erc,nmax);
xs=ys./kval(t,p);
