function out = compressor(x, aux)
d = aux.d;
u = aux.u;
sc = aux.sc;
x = x.*sc.x;
% States
ws = x(1);
h2 = x(2);
Ti = x(3);
Vi = x(4);

% Inputs
h1 = u(1);
s1 = u(2);
P2 = u(3);

% Thermodynamics for i state
Ai  = co2_sw([Ti,Vi,d.Ni]);
si  = -Ai.g(1)/d.Ni;
Pi  = -Ai.g(2);
hi = (-Ti*Ai.g(1)+d.Ni*Ai.g(3))/d.Ni;

out = [ws-(h2-h1);                % Energy balance
       d.eta-(hi-h1)/(h2-h1);       % Efficiency
       s1-si;                       % Isentropic
       P2-Pi]./sc.res;
