%Multicomponent NRTL activity coefficients
%lng = ActivityNRTL(n,s) where:
%n   = mole number vector
%s   = parameter struct i.e. alpha[-], tau[K] and t[K]
%lng = logarithm of activity coefficients

%Copyright Tore Haug-Warberg 2003 (course SIK3035, NTNU)

function [lng] = ActivityNRTL(n,s)

T = s.tau/s.t;
A = s.alpha;
G = exp(-T.*A);
x = n./sum(n);
y = G'*x;
z = (T.*G)'*x./y;
e = ones(size(x));

lng = z + G.*(T-e*z')*(x./y);