function [Cineq,Jacineq] = InEqSep_NN_Un(nvar,into,colind,scl,def)

% Written by Julian Straus, Trondheim 09.12.2018
%
% This function defines the inequality constraints in the reaction section
% section of the simple ammonia loop. It can be modified to define the
% flowsheet differently. The inequalities in this file are given by
%
%   A minimum value for each split ratio
%   The total sum of the split ratio
%   Bounds for the reference temperature
%
% The input of this function is given by
%       nvar:   Total number of variables.
%
%       into:   Input values to the unit operation defined in the
%               flowsheet.
%
%       colind: Indexes of the columns i the Jacobian.
%
% The main output is defined as
%       Ceqdef: Cells containing the equality constraints of the
%               definitions.
%
%       Jacdef: Cells containing the rows of the Jacobian defined by the
%               definitions.
%
% The necessary structures and cells are defined as
%       scl:    Scaling factors of the system defined in cells representing
%               the unit operations defined in par.ReactSec.
%
%       def:    Defined stream values, e.g pressure and composition for all
%               inlets and the pressure of the outlets or the flow of the
%               inlets.

% Predefinition of the returning cells.
Jacineq = cell(def.sizeMat);
Cineq = Jacineq;

%% Inequalities in the neural network
k = 1;
% Calculation of the inequality constraints for the neural network
Cineq{k} = [into{k}(41).*scl{k+20}.Var(41)-83.3784;... 	Split 2
            23.3784 - into{k}(41).*scl{k+20}.Var(41);...
            into{k}(42).*scl{k+20}.Var(42)-17.54;...    Heat Exchanger 8
            9.54 - into{k}(42).*scl{k+20}.Var(42);...
            into{k}(43).*scl{k+20}.Var(43)-0.458;...    Heat Exchanger 9
            -7.542 - into{k}(43).*scl{k+20}.Var(43);...
            into{k}(44).*scl{k+20}.Var(44)+9.1;...      Heat Exchanger 10
            -25.1 - into{k}(44).*scl{k+20}.Var(44)].*scl{k+20}.InEq;

% Calculation of the parts of the Jacobian given by the inequality
% constraint of Split 1
colindineq{k} = colind{k}([41 41 42 42 43 43 44 44]);
Jacineq{k} = sparse(1:numel(Cineq{k}),colindineq{k},...
                    [1 -1 1 -1 1 -1 1 -1].*scl{k+20}.InEq'.*...
                    scl{k+20}.Var([41 41 42 42 43 43 44 44]),...
                    numel(Cineq{k}),nvar);

%% Inequalities in Split 3
k = 7;
% Calculation of the inequality constraints for Split 3
Cineq{k} = [into{k}(26).*scl{k}.Var(26)'-99;...
            0.5 - into{k}(26).*scl{k}.Var(26)'].*scl{k}.InEq;

% Calculation of the parts of the Jacobian given by the inequality
% constraint of Split 3
colindineq{k} = colind{k}([25 25]);
Jacineq{k} = sparse(1:numel(Cineq{k}),colindineq{k},[1 -1].*scl{k}.InEq'.*scl{k}.Var(26),...
                    numel(Cineq{k}),nvar);

