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

% Written by Julian Straus, Trondheim 09.12.2018
%
% This function defines the inequality constraints in the reactant makeup
% section of the simple ammonia loop. It can be modified to define the
% flowsheet differently. The inequalities in this file are given by
%
%   The compressor speed
%
% 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 compressors
k = 1;
% Calculation of the inequality constraints for the compressors
Cineq{k} = [into{k}(9).*scl{k}.Var(9)-10493;...
            9980-into{k}(9).*scl{k}.Var(9)].*scl{k}.InEq;

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