function res = condenser(x, aux)
u = aux.u;
d = aux.d;
sc = aux.sc;
x = x.*sc.x;
T = [u(1);x(1:5)];
A = x(6:10);
Q = x(11:15);
Nl = x(16:19);
Nv = x(20:21);
f = x(22);
P = x(23);
n = u(2);
Ths = u(3);
h = [d.Cpg*(T(1:2)-d.Tref)+d.hvap;
     f*d.Cpl*(T(3:end)-d.Tref)+(1-f)*(d.Cpg*(T(3:end)-d.Tref)+d.hvap)];
Vv = [1;0.5].*A(1:2)/sum(A)*d.Vcon;
Vl = [0.5;ones(3,1)].*A(2:end)/sum(A)*d.Vcon;

res = [Q+n*(h(1:end-1)-h(2:end));
       Q-d.Ucon.*A.*(Ths-[(T(1)+T(2))/2; T(3:end)]);
       A(3:4)-A(4:5);
       Nl-rhol(d).*Vl;
       Nv-rhov([(T(1)+T(2))/2;T(3)], P*ones(2,1), d).*Vv;
       P-psat(T(2),d);
       T(2)-T(3);
       (T(3:5)-T(4:6))*(1-f)]./sc.res;
