function setne(s,i,t,NS,j)
% setne - used to set stream properties in ne
% 
% function setne(s,i,t,NS,j)
% Arguments:
%      s     the state of the stream: 
%            ('l' for liquid, 'v' for vapor, 's' for solid.)
%      i     the index of the stream.
%      t     the stream temperature in units of Tdeg.
%      NS    the compound molar flow rates (mols/time) for the
%            compounds with indices j in cnms.
% 
% If the last argument is omitted, all compounds are
%     assumed to be given in NS.
% Compounds with indices not in j will be given flowrates of 0.
%
% Example:
%     >> setne('v',2,25,[2 5.5],[2 4])
%     will set properties for stream 2 assumed to be vapor at 25 Tdeg
%     it will set the flows of compounds 2 and 4 as 2 and 5.5 mol/time
%     respectively.  The rest of the flows will be set to 0.
%
% help revised by MAH
global cnms ne
if nargin==4
   hs=HinkJ(t,s);
   E=sum(hs.*NS);
   nst=NS;
else
   hs=HinkJ(t,s,j);
   E=sum(hs.*NS);
   [nc,nr]=size(cnms);
   nst=zeros(1,nc);
   nst(j)=NS;
end
if s(1)=='l'
   ne(i,:)=[t,1,E,nst];
elseif s(1)=='v'
   ne(i,:)=[t,2,E,nst];
elseif s(1)=='s'
   ne(i,:)=[t,0,E,nst];
else
   disp('ERROR..the first letter of the left')
   fprintf(['argument is: ',s(1),'\n'])
   return
end 
