% Here we calculate the cooling and heating curves.
% We want to check that we do not have temperature crossover.
% Basis 1 kg methane, that is, 1533 mol combustion gas (hot)
% Assuming constant heat capacities:
   Cph = 1533*30.7; cpcl = 4180; cpcg = 2000;
% Temperatures:
   thinn=663; thut = 160; tcinn=45; tvapor=311; tcut=529;
% Heat of vaporization  hvap at tvapor:
   href = 2400e3; tref=45; hvap = href - (cpcl-cpcg)*(tvapor-tref);
% Total heat per kg cold side = heat water to tvapor  
%                                + evaporate + heat steam to tcut:
   hc= cpcl*(tvapor-tcinn) + hvap + cpcg*(tcut-tvapor);
% Total heat transferred hot side:
   Htot = Cph*(thinn-thut);
% Mass flow cold side from energy balance:
   mc = Htot/hc;
% Heating and cooling curves:
   H(1)  = 0; Tc(1) = tcinn; Th(1) = thut;
   H(2) =  mc*cpcl*(tvapor-tcinn); Tc(2) = tvapor; Th(2) = thut + H(2)/Cph;
   H(3) =  H(2) + mc*hvap; Tc(3) = tvapor; Th(3) = thut + H(3)/Cph;
   H(4) =  Htot; Tc(4) = tcut; Th(4) = thut + H(4)/Cph;
   plot(H,Tc,H,Th)



