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

Last change on this file since 488 was 295, checked in by gerson bicca, 16 years ago

updated controllers models

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.8 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 295 2007-06-21 19:48:17Z bicca $
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_mass                (DisplayUnit='kg/m^3');
42        Cp  as cp_mass                  (DisplayUnit='kJ/kg/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');
56        q                as heat_rate   (DisplayUnit='kJ/h');
57        qr               as heat_rate   (DisplayUnit='kJ/h');
58in  Inlet    as corrente;
59out Outlet   as corrente;
60
61        EQUATIONS
62
63        "Balanço de Massa Global"
64        diff(V) = Inlet.F - Outlet.F;
65       
66        "Balanço de Massa por Componente"
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
93        "Mistura perfeita"
94        Outlet.Ca = Ca;
95        Outlet.T  = T;
96end
97
98# processo com 1 CSTR controlado
99FlowSheet CSTR_controller
100
101        DEVICES
102        FEED as corrente;
103        CSTR1 as CSTR;
104        PIDL as PID;
105        PIDT as PID;
106 
107        VARIABLES
108        L_ad as Real;
109        Lmin as length;
110        Lmax as length;
111        T_ad as Real;
112        Tmin as temperature;
113        Tmax as temperature;
114        Lsp as length;
115        Tsp as temperature;
116       
117        CONNECTIONS
118        FEED to CSTR1.Inlet;
119       
120        SET
121#       Parâmetros do CSTR"
122        CSTR1.R   = 8.3144 * 'kJ/kmol/K';
123        CSTR1.U   = 300 * 'kJ/h/m^2/K';
124        CSTR1.ro  = 1000 * 'kg/m^3';
125        CSTR1.Cp  = 4*'kJ/kg/K';
126        CSTR1.Hr  = -7000 * 'kJ/kmol';
127        CSTR1.Ea  = 6e4 * 'kJ/kmol';
128        CSTR1.ko  = 89 * '1/s';
129        CSTR1.A   = 8 * 'm^2';
130        CSTR1.At  = 25 * 'm^2';
131       
132        PIDL.PID_Select = "Ideal_AWBT";
133        PIDT.PID_Select = "Ideal_AWBT";
134       
135        EQUATIONS
136
137        "Equações do PID para controle de nível"
138        L_ad*(Lmax-Lmin)=CSTR1.h-Lmin;
139        PIDL.Ports.input=L_ad;
140
141        "Equações do PID para controle de temperatura"
142        T_ad*(Tmax-Tmin)=CSTR1.T-Tmin;
143        PIDT.Ports.input=T_ad;
144       
145        "Variáveis manipulada"
146        CSTR1.Cv  = 2.2136 * 'm^2.5/h' * PIDL.Ports.output;
147        CSTR1.Tw  = PIDT.Ports.output*(Tmax-Tmin)+Tmin;
148       
149        #Parâmetros do PID de nível
150        PIDL.Parameters.bias=0;
151        PIDL.Parameters.alpha=0.1;
152        PIDL.Options.action=-1;
153        PIDL.Parameters.gamma=1;
154        PIDL.Parameters.beta=1;
155        PIDL.Options.clip=1;
156        PIDL.Options.autoMan=0;
157        PIDL.Parameters.gain=1;
158        PIDL.Parameters.intTime=2.5*'h';
159        PIDL.Parameters.derivTime=0*'s';
160        PIDL.Ports.setPoint=(Lsp - Lmin)/(Lmax - Lmin);
161        PIDL.Parameters.tau=1*'s';
162        PIDL.Parameters.tauSet=1*'s';
163       
164        PIDT.Parameters.bias = 0;
165        PIDT.Parameters.alpha=0.1;
166        PIDT.Options.action=1;
167        PIDT.Parameters.gamma=1;
168        PIDT.Parameters.beta=1;
169        PIDT.Options.clip=1;
170        PIDT.Options.autoMan=0;
171        PIDT.Parameters.gain=1;
172        PIDT.Parameters.intTime=2.5*'h';
173        PIDT.Parameters.derivTime=1*'h';
174        PIDT.Ports.setPoint=(Tsp - Tmin)/(Tmax - Tmin);
175        PIDT.Parameters.tau=1*'s';
176        PIDT.Parameters.tauSet=1*'s';   
177       
178        "Valores limites para normalizações"
179        Lmax=5*'m';
180        Lmin=0*'m';
181        Tmax=700*'K';
182        Tmin=230*'K';   
183       
184        "Variáveís da corrente de alimentação"
185        FEED.Ca = 300 * 'kmol/m^3';
186        FEED.F = 3.5 * 'm^3/h';
187
188        #distúrbio regulatório
189        if time < 50 * 'h' then
190                FEED.T = 300 * 'K';
191        else
192                FEED.T = 285 * 'K';
193        end
194
195        #mudança de set-point
196        if time < 100 * 'h' then
197          Tsp = 630 * 'K';
198        else
199          Tsp = 400 * 'K';
200        end
201
202        if time < 150 * 'h' then
203          Lsp = 2.5 * 'm';
204        else
205          Lsp = 4 * 'm';
206        end
207
208        INITIAL
209        CSTR1.Ca = 50 * 'kmol/m^3';
210        CSTR1.h = 2.5 * 'm';
211        CSTR1.T = 550 * 'K';
212       
213        OPTIONS
214        TimeStep = 1;
215        TimeEnd = 250;
216        TimeUnit = 'h';
217        DAESolver(File = "dasslc");
218end
Note: See TracBrowser for help on using the repository browser.