%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   slug_3D_linearize.m
%
%   Script for linearizing the simplified slug model made as 
%   an aid in tuning the model
%
%   Written by :    Espen Storkaas (espen.storkaas@chemeng.ntnu.no)
%   Date:           08.10.02
%   
%   For questions, comments or documentation, contact author
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
global data 
% Inputs for initialization
mG_in=(6.1717e-5)*1.5;
P_feed=0.31e5+1.013e5;
z=0.2;uLs=0.1528;
P1_stasj=0.127e5+1.013e5;
h1_stasj=0.019/2*0.6;%H1=0.2128
P2_stasj=0.037e5+1.013e5;
P0=1.013e5;
gen_data
%Initialization
[x0,y_stasj,data]=initialize(z,mG_in,P_feed,P1_stasj,h1_stasj,P2_stasj,P0,uLs);
if ~isreal(y_stasj);
    disp('something is wrong')
end
u=[z;mG_in;P_feed;P0/1e5];
%Linearizing
[A,B,C,D,E,F]=linearize(@slug_3D_lin,[],x0(1:3),[],u(1),u(2:4));
%Computing poles
disp('Poles')
disp(eig(A)')