function [ UA, NTU_A, NTU_B ] = hxsizing( Q, T1in, T1out, T2in, T2out )
%This is hxsizing.m - This file corresponds to the recursive routine to
%determnine UA values for all heat exchangers.
% %   Input arguments
%   Q = Heat duty [Kj/s]
%   T1in = Inlet temperature for side 1 [K]
%   T1out = outlet temperature for side 1 [K]
%   T2in = Inlet temperature for side 2 [K]
%   T2out = Outlet temperature for side 2 [K]
% %  Output arguments
% UA = Overall heat transfer coefficient*Area [Kj/(sK)]

% Find cold and hot side 



% Calculate LMTD
% Counter-current: DeltaA: T1in - T2out. DeltaB: T2in - T1out.
DeltaA = abs(T1in - T2out);
DeltaB = abs(T2in - T1out);

LMTD=(DeltaA-DeltaB)/log(DeltaA/DeltaB);

% Calculate UA based on Q=UALMTD

UA=Q/LMTD;

% Calculate NTU 

NTU_A = DeltaA/LMTD;
NTU_B = DeltaB/LMTD;

end

