% Fil ycompw.m
% Funksjonen brukes for aa generere Wilsonkoeffisienter

function y = ycompw(Tk,x) 

% This function returns the vector of vapor compositions at given 
% values of temperature (Tk), pressure (P) and liquid composition (X).

global Xglob Pglob NCglob Rglob Wglob Vglob Aglob

NC=NCglob;
A =Aglob;
P =Pglob;

% Antoine equation where Psat [mmHg] and temperature Tk [K]
for i=1:NC
  log10Psat = A(i,1) - A(i,2) / (Tk-273.15 + A(i,3));
  Psat(i)   = 10^log10Psat;
end

% Phase equilibrium where P [atm] and Psat [mmHg]
gamma=wilsonv(Tk,x);
q=Psat'.*x;
y=q.*gamma./(P*760);






