source: trunk/sample/controllers/CSTR_noniso_pid.mso @ 233

Last change on this file since 233 was 190, checked in by Rafael de Pelegrini Soares, 17 years ago

Adapted PID models for the new language (the usage of switcher is still pending)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.3 KB
Line 
1#*-------------------------------------------------------------------
2* EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC.
3*
4* This LIBRARY is free software; you can distribute it and/or modify
5* it under the therms of the ALSOC FREE LICENSE as available at
6* http://www.enq.ufrgs.br/alsoc.
7*
8* EMSO Copyright (C) 2004 - 2007 ALSOC, original code
9* from http://www.rps.eng.br Copyright (C) 2002-2004.
10* All rights reserved.
11*
12* EMSO is distributed under the therms of the ALSOC LICENSE as
13* available at http://www.enq.ufrgs.br/alsoc.
14*
15*--------------------------------------------------------------------
16* Sample file for controllers
17*----------------------------------------------------------------------
18* Author:
19* $Id: CSTR_noniso_pid.mso 190 2007-03-07 18:09:13Z rafael $
20*--------------------------------------------------------------------*#
21
22using "controllers/PIDs";
23
24const_valv as positive(Brief = "Valve Constant", Default=1,Lower=0,Upper=100, Unit='m^2.5/h');
25
26Model corrente
27        VARIABLES
28        Ca     as conc_mol;
29        F      as flow_vol;
30        T      as temperature;
31end
32
33Model CSTR
34
35        PARAMETERS
36        ko  as frequency                (DisplayUnit='1/h');
37        A   as area;
38        At  as area;   
39        Ea  as energy_mol               (DisplayUnit='kJ/kmol');
40        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');
43        U   as heat_trans_coeff (DisplayUnit='kW/m^2/K');
44        Hr  as heat_reaction    (DisplayUnit='kJ/kmol');
45       
46        VARIABLES
47        Cv       as const_valv;
48        T        as temperature;
49        Tw       as temperature;
50        V        as volume;
51        Ca       as conc_mol;
52        h        as length;
53        tau      as time_h;
54        rA           as reaction_mol;
55        k        as frequency   (DisplayUnit='1/h');
56in  Inlet    as corrente;
57out Outlet   as corrente;
58
59        EQUATIONS
60
61        "Balanço de Massa Global"
62        diff(V) = Inlet.F - Outlet.F;
63       
64        "Balanço de Massa por Componente"
65        tau * diff(Ca) = (Inlet.Ca - Ca) - (-rA) * tau;
66       
67        "Mistura perfeita"
68        Outlet.Ca = Ca;
69        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
89end
90
91# processo com 1 CSTR controlado
92FlowSheet CSTR_controller
93
94        DEVICES
95        FEED as corrente;
96        CSTR1 as CSTR;
97        PIDL as PID_Ideal_AWBT;
98        PIDT as PID_Ideal_AWBT;
99 
100        VARIABLES
101        L_ad as Real;
102        Lmin as length;
103        Lmax as length;
104        T_ad as Real;
105        Tmin as temperature;
106        Tmax as temperature;
107       
108        CONNECTIONS
109        FEED to CSTR1.Inlet;
110       
111        SET
112#       Parâmetros do CSTR"
113        CSTR1.R   = 8.3144 * 'kJ/kmol/K';
114        CSTR1.U   = 300 * 'kJ/h/m^2/K';
115        CSTR1.ro  = 55.56 * 'kmol/m^3';
116        CSTR1.Cp  = 70*'kJ/kmol/K';
117        CSTR1.Hr  = -7000 * 'kJ/kmol';
118        CSTR1.Ea  = 6e4 * 'kJ/kmol';
119        CSTR1.ko  = 89 * '1/s';
120        CSTR1.A   = 8 * 'm^2';
121        CSTR1.At  = 25 * 'm^2';
122       
123        EQUATIONS
124
125        "Equações do PID para controle de nível"
126        L_ad*(Lmax-Lmin)=CSTR1.h-Lmin;
127        PIDL.Ports.input=L_ad;
128
129        "Equações do PID para controle de temperatura"
130        T_ad*(Tmax-Tmin)=CSTR1.T-Tmin;
131        PIDT.Ports.input=T_ad;
132       
133        "Variáveis manipulada"
134        CSTR1.Cv  = 2.2136 * 'm^2.5/h' * (1 - PIDL.Ports.output);
135        CSTR1.Tw  = PIDT.Ports.output*(Tmax-Tmin)+Tmin;
136       
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
145        #Parâmetros do PID de nível
146        PIDL.Parameters.bias=0;
147        PIDL.Parameters.alpha=0.1;
148        PIDL.Options.action=1;
149        PIDL.Parameters.gamma=1;
150        PIDL.Parameters.beta=1;
151        PIDL.Options.clip=1;
152        PIDL.Options.autoMan=0;
153        PIDL.Parameters.gain=20;
154        PIDL.Parameters.intTime=5*'h';
155        PIDL.Parameters.derivTime=0*'s';
156        PIDL.Ports.setPoint=0.55;
157        PIDL.Parameters.tau=1*'s';
158        PIDL.Parameters.tauSet=1*'s';
159       
160        PIDT.Parameters.bias = 0;
161        PIDT.Parameters.alpha=0.1;
162        PIDT.Options.action=1;
163        PIDT.Parameters.gamma=1;
164        PIDT.Parameters.beta=1;
165        PIDT.Options.clip=1;
166        PIDT.Options.autoMan=0;
167        PIDT.Parameters.gain=40;
168        PIDT.Parameters.intTime=5*'h';
169        PIDT.Parameters.derivTime=1*'h';
170        PIDT.Ports.setPoint=0.85;
171        PIDT.Parameters.tau=1*'s';
172        PIDT.Parameters.tauSet=1*'s';   
173       
174        "Valores limites para normalizações"
175        Lmax=5*'m';
176        Lmin=0*'m';
177        Tmax=700*'K';
178        Tmin=230*'K';   
179       
180        "Variáveís da corrente de alimentação"
181        FEED.Ca = 300 * 'kmol/m^3';
182        FEED.F = 3.5 * 'm^3/h';
183
184        INITIAL
185        CSTR1.Ca = 50 * 'kmol/m^3';
186        CSTR1.h = 2.5 * 'm';
187        CSTR1.T = 650 * 'K';
188       
189        OPTIONS
190        TimeStep = 0.1;
191        TimeEnd = 100;
192        TimeUnit = 'h';
193end
Note: See TracBrowser for help on using the repository browser.