% function of the nonlinear constraints 
% to optimize the steady state model
% Johannes Jäschke
% 2010


function [C Ceq] = nonlincon(x,par)
C=[];
% steady state model

%parametres
F =par.F;
CAin = par.CAin; 
CBin = par.CBin; 
Hrx = par.Hrx;
rho = par.rho;
tau = par.tau;
E1 = par.E1; 
E2 = par.E2;
Cp = par.Cp;
C1 = par.C1;
C2 = par.C2;

R  = par.R;
% States
CA = x(1);
CB = x(2);
T  = x(3);
% Inputs
Ti = x(4);


% kinetics:
k1 = C1*60*exp(-E1/R/T);
k2 = C2*60*exp(-E2/R/T);
r = k1*CA-k2*CB;

Ceq  = [1/tau*(CAin-CA)-r;
        1/tau*(CBin-CB)+r;
        1/tau*(Ti-T)+(-Hrx)/(rho*Cp)*r];
