function hdif=reacte(s,tmp,in,out,rs)
% reacte - basic energy-balance reactor module: one exit stream
%
% reacte is a basic reactor module with only one exit stream that
%    includes an energy balance.
%   
% function hdif=reacte(s,tmp,in,out,rs)
% Arguments:
%    s       state of the exit stream: 'v', 'l', or 's'
%    tmp     temperature of exit stream in Tdeg.
%    in      the indices of the inlet streams!
%    out     the index of the exit stream.
%    rs      the reaction rates.
%
% Global Variables used:
%    nc      number of compounds
%    ne      storage array for mass & energy data
%   stoic    stoichiometric coefficient array
% reacte returns the enthalpy of the exit stream minus the sum
%     of the enthalpies of the inlet streams.
% 
% Example:
%      >> reacte('v',920,[1 2],3,0.225);
% 
% JWD, SHD & OKB, TYLC; help revised by MAH
global nc ne stoic
NS=sum([ne(in,4:(nc+3));zeros(1,nc)]); % Total flow into reactor
nout=NS+(rs*stoic);    % Total flow out
j=find(abs(nout)>eps); % Compounds with some flow in them
setne(s,out,tmp,nout(j),j)  % Setting outlet stream
hdif=ne(out,3)-sum(ne(in,3));  % Enthalpy difference
