Ignore:
Timestamp:
Jun 12, 2007, 1:19:07 AM (16 years ago)
Author:
Argimiro Resende Secchi
Message:

Improve CSTR_noniso_pid.mso sample.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sample/controllers/CSTR_noniso_pid.mso

    r190 r257  
    3939        Ea  as energy_mol               (DisplayUnit='kJ/kmol');
    4040        R   as Real                     (Unit='kJ/mol/K');
    41         ro  as dens_mol                 (DisplayUnit='kmol/m^3');
    42         Cp  as cp_mol                   (DisplayUnit='kJ/kmol/K');
     41        ro  as dens_mass                (DisplayUnit='kg/m^3');
     42        Cp  as cp_mass                  (DisplayUnit='kJ/kg/K');
    4343        U   as heat_trans_coeff (DisplayUnit='kW/m^2/K');
    4444        Hr  as heat_reaction    (DisplayUnit='kJ/kmol');
     
    5454        rA           as reaction_mol;
    5555        k        as frequency   (DisplayUnit='1/h');
     56        q                as heat_rate   (DisplayUnit='kJ/h');
     57        qr               as heat_rate   (DisplayUnit='kJ/h');
    5658in  Inlet    as corrente;
    5759out Outlet   as corrente;
     
    6365       
    6466        "Balanço de Massa por Componente"
    65         tau * diff(Ca) = (Inlet.Ca - Ca) - (-rA) * tau;
    66        
     67        V * diff(Ca) = Inlet.F * (Inlet.Ca - Ca) - (-rA) * V;
     68
     69        "Tempo de residência médio"
     70        tau * Inlet.F = V;
     71
     72        "Balanço de energia"
     73        ro * V * Cp * diff(T) = Inlet.F * ro * Cp * (Inlet.T - T) + qr - q;
     74
     75        "Taxa de calor transferido"
     76        q = U * At * (T - Tw);
     77
     78        "Taxa de calor gerado"
     79        qr = (-Hr) * (-rA) * V;
     80       
     81        "Taxa de reação"
     82        -rA = k * Ca;
     83       
     84        "Equação de Arrhenius"
     85        k = ko * exp(-Ea/(R*T));
     86       
     87        "Geometria"
     88        A * h = V;
     89       
     90        "Equação da válvula"
     91        Outlet.F = Cv * sqrt(h);
     92
    6793        "Mistura perfeita"
    6894        Outlet.Ca = Ca;
    6995        Outlet.T  = T;
    70        
    71         "Taxa de reação"
    72         -rA = k * Ca;
    73        
    74         "Equação de Arrhenius"
    75         k = ko * exp(-Ea/(R*T));
    76        
    77         "Tempo de residência médio"
    78         tau * Inlet.F = V;
    79        
    80         "Geometria"
    81         A * h = V;
    82        
    83         "Equação da válvula"
    84         Outlet.F = Cv * sqrt(h);
    85        
    86         "Balanço de energia"
    87         tau * diff(T) = (Inlet.T - T) - U*At*(T-Tw)/(ro*V*Cp)*tau + (-Hr)*(-rA)*tau/(ro*Cp);
    88 
    8996end
    9097
     
    105112        Tmin as temperature;
    106113        Tmax as temperature;
     114        Lsp as length;
     115        Tsp as temperature;
    107116       
    108117        CONNECTIONS
     
    113122        CSTR1.R   = 8.3144 * 'kJ/kmol/K';
    114123        CSTR1.U   = 300 * 'kJ/h/m^2/K';
    115         CSTR1.ro  = 55.56 * 'kmol/m^3';
    116         CSTR1.Cp  = 70*'kJ/kmol/K';
     124        CSTR1.ro  = 1000 * 'kg/m^3';
     125        CSTR1.Cp  = 4*'kJ/kg/K';
    117126        CSTR1.Hr  = -7000 * 'kJ/kmol';
    118127        CSTR1.Ea  = 6e4 * 'kJ/kmol';
     
    132141       
    133142        "Variáveis manipulada"
    134         CSTR1.Cv  = 2.2136 * 'm^2.5/h' * (1 - PIDL.Ports.output);
     143        CSTR1.Cv  = 2.2136 * 'm^2.5/h' * PIDL.Ports.output;
    135144        CSTR1.Tw  = PIDT.Ports.output*(Tmax-Tmin)+Tmin;
    136145       
    137         #distúrbio regulatório
    138         if time<1.6e5 then     
    139                 FEED.T = 300 * 'K';
    140         else
    141                 FEED.T = 285 * 'K';
    142         end
    143 
    144 
    145146        #Parâmetros do PID de nível
    146147        PIDL.Parameters.bias=0;
    147148        PIDL.Parameters.alpha=0.1;
    148         PIDL.Options.action=1;
     149        PIDL.Options.action=-1;
    149150        PIDL.Parameters.gamma=1;
    150151        PIDL.Parameters.beta=1;
    151152        PIDL.Options.clip=1;
    152153        PIDL.Options.autoMan=0;
    153         PIDL.Parameters.gain=20;
    154         PIDL.Parameters.intTime=5*'h';
     154        PIDL.Parameters.gain=1;
     155        PIDL.Parameters.intTime=2.5*'h';
    155156        PIDL.Parameters.derivTime=0*'s';
    156         PIDL.Ports.setPoint=0.55;
     157        PIDL.Ports.setPoint=(Lsp - Lmin)/(Lmax - Lmin);
    157158        PIDL.Parameters.tau=1*'s';
    158159        PIDL.Parameters.tauSet=1*'s';
     
    165166        PIDT.Options.clip=1;
    166167        PIDT.Options.autoMan=0;
    167         PIDT.Parameters.gain=40;
    168         PIDT.Parameters.intTime=5*'h';
     168        PIDT.Parameters.gain=1;
     169        PIDT.Parameters.intTime=2.5*'h';
    169170        PIDT.Parameters.derivTime=1*'h';
    170         PIDT.Ports.setPoint=0.85;
     171        PIDT.Ports.setPoint=(Tsp - Tmin)/(Tmax - Tmin);
    171172        PIDT.Parameters.tau=1*'s';
    172173        PIDT.Parameters.tauSet=1*'s';   
     
    182183        FEED.F = 3.5 * 'm^3/h';
    183184
     185        #distúrbio regulatório
     186        if time < 50 * 'h' then
     187                FEED.T = 300 * 'K';
     188        else
     189                FEED.T = 285 * 'K';
     190        end
     191
     192        #mudança de set-point
     193        if time < 100 * 'h' then
     194          Tsp = 630 * 'K';
     195        else
     196          Tsp = 400 * 'K';
     197        end
     198
     199        if time < 150 * 'h' then
     200          Lsp = 2.5 * 'm';
     201        else
     202          Lsp = 4 * 'm';
     203        end
     204
    184205        INITIAL
    185206        CSTR1.Ca = 50 * 'kmol/m^3';
    186207        CSTR1.h = 2.5 * 'm';
    187         CSTR1.T = 650 * 'K';
     208        CSTR1.T = 550 * 'K';
    188209       
    189210        OPTIONS
    190         TimeStep = 0.1;
    191         TimeEnd = 100;
     211        TimeStep = 1;
     212        TimeEnd = 250;
    192213        TimeUnit = 'h';
     214        DAESolver(File = "dasslc");
    193215end
Note: See TracChangeset for help on using the changeset viewer.