%% Header
% Purpose:  Creating the process transfer function G (struct).
% Author:   Axel Lodemel Holene (based on work done by Chriss
%           Grimholt (2011) and Martin S. Foss (2012)).
% E-mail:   axel.holene@gmail.com
% Date:     February 2013
% About:    G = 
%                   k                               Process gain
%                   tau1                   Process time constant
%                   tau2                   Process time constant
%                   theta                     Process time delay
%                   tf                 Process transfer function

function G = model(modelId)
    s = zpk('s') ;                  % Transfer function variable

    G.k     = 1   ;                        % Common process gain
    G.tau1  = 1   ;             % Common process time constant 1

    switch modelId
        case 1
            G.case = 1 ;
            G.tau2  = 0.5*G.tau1 ;     % Process time constant 2
            G.theta = 1          ;          % Process time delay
        case 2
            G.case = 2 ;
            G.tau2  = 0.8*G.tau1 ;     % Process time constant 2
            G.theta = 1 ;                   % Process time delay
        case 3
            G.case = 3 ;
            G.tau2  = 0.3*G.tau1 ;     % Process time constant 2
            G.theta = 1 ;                   % Process time delay
        case 4
            G.case = 4 ;
            G.tau2  = 0.5*G.tau1 ;     % Process time constant 2
            G.theta = G.tau2/1.5 ;          % Process time delay
        case 5
            G.case = 5 ;
            G.tau2  = 0.8*G.tau1 ;     % Process time constant 2
            G.theta = G.tau2/1.5 ;          % Process time delay
        case 6
            G.case = 6 ;
            G.tau2  = 0.3*G.tau1 ;     % Process time constant 2
            G.theta = G.tau2/1.5 ;          % Process time delay
        case 7
            G.case = 7 ;
            G.tau2  = 0.5*G.tau1 ;     % Process time constant 2
            G.theta = G.tau2/2.0 ;          % Process time delay
        case 8
            G.case = 8 ;
            G.tau2  = 0.8*G.tau1 ;     % Process time constant 2
            G.theta = G.tau2/2.0 ;          % Process time delay
        case 9
            G.case = 9 ;
            G.tau2  = 0.3*G.tau1 ;     % Process time constant 2
            G.theta = G.tau2/2.0 ;          % Process time delay
        case 10
            G.case = 10 ;
            % G.tau1  = 100 ;
            G.tau2  = 0 ;
            G.theta = 1 ;
            % G.k = 100 ;
            G.tfnd  = G.k/s ;
            G.tf    = G.tfnd*exp(-G.theta*s) ;
            return
        case 11
            G.case = 11 ;
            G.tau1  = 1 ;
            G.tau2  = 0 ;
            G.theta = 1 ;
        case 12
            G.case = 12 ;
            G.tau1  = 8 ;
            G.tau2  = 0 ;
            G.theta = 1 ;
        case 13
            G.case = 13 ;
            G.tau1  = 0.005 ;
            G.tau2  = 0 ;
            G.theta = 1 ;
        case 14
            G.case = 14 ;
            % G.k    = 20 ;
            G.tau1 = 20 ;
            G.tau2 = 0 ;
            G.theta = 1 ;
    end
    %% Process transfer functions
    G.tfnd = G.k/((G.tau1*s + 1)*(G.tau2*s + 1)) ;
    G.tf   = G.tfnd*exp(-G.theta*s) ;
end