function hdif=mixe(s,t,in,out) 
% mixe - Energy balance mixer module
%
% mixe will mix multiple inlet streams into one outlet stream
%      with a given state and temperature.
%
% function hdif=mixe(s,t,in,out)
% Arguments:
%      s      the state of the exit stream:
%             'v' for vapor, 'l' for liquid, 's' for solid.
%      t      the temperature of the exit stream in Tdeg.
%      in     the indices of inlet streams, 
%      out    the index of exit stream.
%
% hdif: is the enthalpy out minus the sum of the enthalpies in
%    
% Example:
%     >> mixe('v',55,[2 3 4],6)
%     will mix streams 2, 3 and 4 to form stream 6.
%     Stream 6 will be a vapor at 55 Tdeg.
% 
% OKB, TYLC; help revised by MAH
global ns ne
sne=size(ne);
nc=sne(2)-3;
if length(in)<2
   ns=ne(in,4:(nc+3));
else
   ns=sum(ne(in,4:(nc+3)));
end
j=find(ns);
setne(s,out,t,ns(j),j)
hdif=ne(out,3)-sum(ne(in,3));
