Hi everyone,
I'm trying to solve a problem on a binary liquid-liiquid equilibrium using the van Laar equation for the activity coefficient. Through experimental data for the excess enthalpy of mix I've adjusted the A and B parameters. Now I want to calculate the binodal curve.
function b = binodal_vanLaar(x1, x2, T)
A = -334.05903 + 2.21014*T - 0.00359*(T^2);
B = 0.0000520359*exp(0.03136*T);
gama1_a = exp(A/((1 + ((A*x1)/(B*(1-x1))))^2));
gama2_a = exp(B/((1 + ((B*(1-x1))/(A*x1)))^2));
gama1_b = exp(A/((1 + ((A*x2)/(B*(1-x2))))^2));
gama2_b = exp(B/((1 + ((B*(1-x2))/(A*x2)))^2));
b(1) = x1*gama1_a - x2*gama1_b;
b(2) = (1-x1)*gama2_a - (1-x2)*gama2_b;
The idea is to fix the molar fraction of component 1 in fase (') and using fsolve() calculate the molar fraction of component 1 in fase (") and the temperature of equilibrium.
x1 = linspace(0.2800, 0.9700, 1000);
fun = @(x_b, T)binodal_vanLaar(x_a, x_b, T);
G2(i,:) = fsolve(fun, [x_b T]);
When I try to run a similar code, but with only one variable in the @() it run perfectly ok. But now I'm getting this error mensage.
Not enough input arguments.
Error in teste_binodal_vanLaar>@(x_b,T)binodal_vanLaar(x_a,x_b,T) (line 15)
fun = @(x_b, T)binodal_vanLaar(x_a, x_b, T);
Error in fsolve (line 264)
fuser = feval(funfcn{3},x,varargin{:});
Error in teste_binodal_vanLaar (line 16)
G2(i,:) = fsolve(fun, [x_b T]);
Failure in initial objective function evaluation. FSOLVE cannot continue.
Can someone, please, help me understand what I'm doing wrong?
Thanks in advance.