% TERMO.M %%
%
% Compute vapour composition using constant relative volatilty model

function [y] = termo(x,flag,Nt)

global alfa


Nc = 3;

x = x'
x = [
	x
	1 - sum(x)
	];

switch flag
    case 1
        y = zeros(Nt,Nc);
        for i = 1:Nt
            for j = 1:Nc
            y(i,j)=alfa(j)*x(j,i)/sum((x(:,i).*alfa'));
            end
        end
        y = y(:,1:(Nc - 1));
    case 3
    	y = zeros(1,Nc);
        for i = 1:Nc
            y(i)=alfa(i)*x(i)/sum((x.*alfa'));
        end
        y = y(1:(Nc - 1));
end