%% Settling tank
% Glycerol-rich phase:
GP_MetOH = 0.98*B*xx(1,1);
GP_TG = 0*xx(1,2);
GP_DG = 0.4*B*xx(1,3);
GP_MG = 0.8*B*xx(1,4);
GP_GL = 0.999*B*xx(1,5);
GP_BD = 0.001*B*xx(1,6);

GP = [GP_MetOH GP_TG GP_DG GP_MG GP_GL GP_BD];
GP_wt = GP.*Mw;
GP_tot = sum(GP_wt);
GP_per = GP_wt/GP_tot;


% Ester-rich phase:
EP = ((B*xx(1,:))-GP);
EP_wt = EP.*Mw;
EP_tot = sum(EP_wt);
EP_per = EP_wt/EP_tot;

%           TG             DG            MG           GL
GL_tot = EP_per(1,2) + EP_per(1,3) + EP_per(1,4) + EP_per(1,5);

%% Methanol Flash
CGL_MetOH = 0.01*GP_MetOH;
CGL_TG = GP_TG;
CGL_DG = 0.98*GP_DG;
CGL_MG = 0.99*GP_MG;
CGL_GL = 0.99*GP_GL;
CGL_BD = 0.95*GP_BD;
CGL = [CGL_MetOH CGL_TG CGL_DG CGL_MG CGL_GL CGL_BD];
CGL_wt = CGL.*Mw;
CGL_tot = sum(CGL_wt);
CGL_per = CGL_wt/CGL_tot;

CMet = GP - CGL;
CMet_wt = CMet.*Mw;
CMet_tot = sum(CMet_wt);
CMet_per = CMet_wt/CMet_tot;

