source: branches/gui/sample/controllers/sample_PIDIncr_MIMO.mso @ 683

Last change on this file since 683 was 530, checked in by Argimiro Resende Secchi, 15 years ago

Fix some examples.

File size: 10.5 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 PID MIMO application
17* (dual control of a distillation column)
18*--------------------------------------------------------------------
19*
20* This sample file needs VRTherm (www.vrtech.com.br) to run
21* the distillation column flowsheet.
22*
23*----------------------------------------------------------------------
24* Author: Argimiro R. Secchi
25* $Id: sample_PID_MIMO.mso 313 2007-07-14 16:45:55Z arge $
26*--------------------------------------------------------------------*#
27
28using "stage_separators/column";
29using "controllers/PIDIncr";
30
31FlowSheet Column_MPID
32        PARAMETERS
33        PP      as Plugin(Brief="Physical Properties",
34                Type="PP",
35                Components = [ "isobutane", "n-pentane", "propylene",
36                        "benzene", "isobutene" ],
37                LiquidModel = "PR",
38                VapourModel = "PR"
39        );
40        NComp   as Integer;
41       
42        Qcmin as heat_rate (Brief="Minimum Condenser Heat supplied");
43        Qcmax as heat_rate (Brief="Maximum Condenser Heat supplied");
44        Qrmin as heat_rate (Brief="Minimum Reboiler Heat supplied");
45        Qrmax as heat_rate (Brief="Maximum Reboiler Heat supplied");
46        Frmin as flow_mol (Brief="Minimum bottom flow rate");
47        Frmax as flow_mol (Brief="Maximum bottom flow rate");
48        Fcmin as flow_mol (Brief="Minimum reflux flow rate");
49        Fcmax as flow_mol (Brief="Maximum reflux flow rate");
50        Hmint as length (Brief="Minimum liquid level in top tank");
51        Hmaxt as length (Brief="Maximum liquid level in top tank");
52    Hminb as length (Brief="Minimum liquid level in reboiler");
53        Hmaxb as length (Brief="Maximum liquid level in reboiler");
54        Pmax as pressure (Brief="Maximum column pressure");
55        Pmin as pressure (Brief="Minimum column pressure");
56        Tmax as temperature (Brief="Maximum column temperature");
57        Tmin as temperature (Brief="Minimum column temperature");
58        RRmax as positive (Brief="Maximum reflux ratio");
59        RRmin as positive (Brief="Minimum reflux ratio");
60       
61        VARIABLES
62        Qc as energy_source (Brief="Heat rate removed from condenser");
63        Qr as energy_source (Brief="Heat rate supplied to reboiler");
64        Had_top as Real (Brief="Dimensionless condenser level");
65        Had_bot as Real (Brief="Dimensionless reboiler level");
66        Pad as Real (Brief="Dimensionless pressure");
67        P_sp as pressure (Brief="Pressure setpoint");
68        Tad as Real (Brief="Dimensionless temperature");
69        T_sp as temperature (Brief="Condenser temperature setpoint");
70        RR      as positive (Brief="Reflux ratio");
71        LC_sp as length (Brief="Condenser level setpoint");
72        LR_sp as length (Brief="Reboiler level setpoint");
73        xtop as fraction (Brief="Controlled top composition");
74        xbot as fraction (Brief="Controlled bottom composition");
75        xtop_sp as fraction (Brief="Controlled top composition setpoint");
76        xbot_sp as fraction (Brief="Controlled bottom composition setpoint");
77
78        SET
79        NComp = PP.NumberOfComponents;
80
81        DEVICES
82        col as Distillation_kettle_cond;
83        feed as source;
84        zero as stream;
85        TCcond as PIDIncr;
86        LCtop as PIDIncr;
87        LCbot as PIDIncr;
88        PC as PIDIncr;
89        PID11 as PIDIncr;
90        PID22 as PIDIncr;
91        PID12 as PIDIncr;
92        PID21 as PIDIncr;
93
94        CONNECTIONS
95        feed.Outlet to col.trays(5).Inlet;
96        zero to col.reb.Inlet;
97        zero to col.trays([1:4]).Inlet;
98        zero to col.trays([6:col.NTrays]).Inlet;
99        Qc.OutletQ to col.cond.InletQ;
100        Qr.OutletQ to col.reb.InletQ;
101
102        EQUATIONS
103   "Temperature Controller"
104        TCcond.Parameters.tau = 0*'s'; 
105        TCcond.Parameters.tauSet = 0*'s';       
106        TCcond.Parameters.alpha = 0.3;
107        TCcond.Parameters.bias = 0.5;   
108        TCcond.Parameters.gamma = 1;
109        TCcond.Parameters.beta = 1;
110        TCcond.Options.action = 1;
111        TCcond.Options.clip = 1;
112        TCcond.Options.autoMan = 0;
113        TCcond.Parameters.intTime = 60*'s';
114        TCcond.Parameters.gain = 0.6;
115        TCcond.Parameters.derivTime = 1*'s';
116        TCcond.Ports.setPoint = (T_sp - Tmin)/(Tmax-Tmin);
117        TCcond.Ports.input = Tad;
118        Tad = (col.cond.OutletL.T-Tmin)/(Tmax-Tmin);
119        Qc.OutletQ.Q = Qcmin+(Qcmax-Qcmin)*TCcond.Ports.output;
120
121        "Pressure Controller"
122        PC.Parameters.tau = 0*'s';     
123        PC.Parameters.tauSet = 0*'s';   
124        PC.Parameters.alpha = 0.3;
125        PC.Parameters.bias = 0;
126        PC.Parameters.gamma = 1;
127        PC.Parameters.beta = 1;
128        PC.Options.action = -1;
129        PC.Options.clip = 1;
130        PC.Options.autoMan = 0;
131        PC.Parameters.intTime = 50*'s';
132        PC.Parameters.gain = 0.5;
133        PC.Parameters.derivTime = 1*'s';
134        PC.Ports.setPoint = (P_sp-Pmin)/(Pmax-Pmin);
135        PC.Ports.input = Pad;
136        Pad = (col.cond.OutletV.P-Pmin)/(Pmax-Pmin);
137        col.cond.OutletV.F = (Fcmin+(Fcmax-Fcmin)*PC.Ports.output);     
138       
139        "Ttop Level Controller"
140        LCtop.Parameters.tau = 0*'s';   
141        LCtop.Parameters.tauSet = 0*'s';       
142        LCtop.Parameters.alpha = 0.3;
143        LCtop.Parameters.bias = 0.5;   
144        LCtop.Parameters.gamma = 1;
145        LCtop.Parameters.beta = 1;
146        LCtop.Options.action = -1;
147        LCtop.Options.clip = 1;
148        LCtop.Options.autoMan = 0;
149        LCtop.Parameters.intTime = 20*'s';
150        LCtop.Parameters.gain = 1;
151        LCtop.Parameters.derivTime = 0*'s';
152        LCtop.Ports.setPoint = (LC_sp - Hmint)/(Hmaxt-Hmint);
153        LCtop.Ports.input = Had_top;
154        Had_top = (col.cond.Level-Hmint)/(Hmaxt-Hmint);
155        col.sptop.Outlet1.F = Fcmin + (Fcmax-Fcmin) * LCtop.Ports.output;
156
157        "Tbottom Level Controller"
158        LCbot.Parameters.tau = 0*'s';   
159        LCbot.Parameters.tauSet = 0*'s';       
160        LCbot.Parameters.alpha = 0.3;
161        LCbot.Parameters.bias = 0.5;   
162        LCbot.Parameters.gamma = 1;
163        LCbot.Parameters.beta = 1;
164        LCbot.Options.action = -1;
165        LCbot.Options.clip = 1;
166        LCbot.Options.autoMan = 0;
167        LCbot.Parameters.intTime = 100*'s';
168        LCbot.Parameters.gain = 1;
169        LCbot.Parameters.derivTime = 0*'s';
170        LCbot.Ports.setPoint = (LR_sp - Hminb)/(Hmaxb-Hminb);
171        LCbot.Ports.input = Had_bot;
172        Had_bot = (col.reb.Level-Hminb)/(Hmaxb-Hminb);
173        col.reb.OutletL.F = Frmin + (Frmax-Frmin) * LCbot.Ports.output;
174
175        "MIMO PID Controller"
176        PID11.Parameters.tau = 0*'s';   
177        PID11.Parameters.tauSet = 0*'s';       
178        PID11.Parameters.alpha = 0.3;
179        PID11.Parameters.bias = 0.1;   
180        PID11.Parameters.gamma = 1;
181        PID11.Parameters.beta = 1;
182        PID11.Options.action = -1;
183        PID11.Options.clip = 1;
184        PID11.Options.autoMan = 0;
185        PID11.Parameters.intTime = 60*'s';
186        PID11.Parameters.gain = 0.6;
187        PID11.Parameters.derivTime = 0*'s';
188        PID11.Ports.setPoint = xtop_sp;
189        PID11.Ports.input = xtop;
190
191        PID12.Parameters.tau = 0*'s';   
192        PID12.Parameters.tauSet = 0*'s';       
193        PID12.Parameters.alpha = 0.3;
194        PID12.Parameters.bias = 0.0;   
195        PID12.Parameters.gamma = 1;
196        PID12.Parameters.beta = 1;
197        PID12.Options.action = -1;
198        PID12.Options.clip = 1;
199        PID12.Options.autoMan = 0;
200        PID12.Parameters.intTime = 100*'s';
201        PID12.Parameters.gain = 0.5;
202        PID12.Parameters.derivTime = 0*'s';
203        PID12.Ports.setPoint = xbot_sp;
204        PID12.Ports.input = xbot;
205
206        RR = RRmin + (RRmax-RRmin) * (PID11.Ports.output + PID12.Ports.output);
207
208        PID21.Parameters.tau = 0*'s';   
209        PID21.Parameters.tauSet = 0*'s';       
210        PID21.Parameters.alpha = 0.3;
211        PID21.Parameters.bias = 0.0;   
212        PID21.Parameters.gamma = 1;
213        PID21.Parameters.beta = 1;
214        PID21.Options.action = 1;
215        PID21.Options.clip = 1;
216        PID21.Options.autoMan = 0;
217        PID21.Parameters.intTime = 100*'s';
218        PID21.Parameters.gain = 0.5;
219        PID21.Parameters.derivTime = 0*'s';
220        PID21.Ports.setPoint = xtop_sp;
221        PID21.Ports.input = xtop;
222
223        PID22.Parameters.tau = 0*'s';   
224        PID22.Parameters.tauSet = 0*'s';       
225        PID22.Parameters.alpha = 0.3;
226        PID22.Parameters.bias = 0.5;   
227        PID22.Parameters.gamma = 1;
228        PID22.Parameters.beta = 1;
229        PID22.Options.action = -1;
230        PID22.Options.clip = 1;
231        PID22.Options.autoMan = 0;
232        PID22.Parameters.intTime = 60*'s';
233        PID22.Parameters.gain = 0.6;
234        PID22.Parameters.derivTime = 0*'s';
235        PID22.Ports.setPoint = xbot_sp;
236        PID22.Ports.input = xbot;
237       
238        Qr.OutletQ.Q = Qrmin + (Qrmax-Qrmin) * (PID21.Ports.output + PID22.Ports.output);
239
240        RR * (col.cond.OutletV.F + col.sptop.Outlet1.F) = col.sptop.Outlet2.F;
241        xtop = col.cond.OutletL.z(4); # benzene
242        xbot = col.reb.OutletL.z(3); # propylene
243
244        if time < 1 * 'h' then
245                feed.Outlet.F = 113.4 * 'kmol/h';
246        else
247                feed.Outlet.F = 120 * 'kmol/h';
248        end
249
250        SPECIFY
251        feed.Outlet.T = 290 * 'K';
252        feed.Outlet.P = 6 * 'bar';
253        feed.Outlet.z = 1/NComp;
254       
255        zero.F = 0 * 'kmol/h';
256        zero.T = 300 * 'K';
257        zero.P = 1 * 'atm';
258        zero.z = 1/NComp;
259        zero.v = 0;
260        zero.h = 0 * 'J/mol';
261       
262#       Qr.OutletQ.Q = 3e6 * 'kJ/h';
263        col.pump1.dP = 16 * 'kPa';
264        col.trays.Emv = 1;
265#       col.sptop.Outlet2.F = 75 * 'kmol/h'; # reflux
266    col.alfaTopo = 2;
267
268        xtop_sp = 1e-3; # benzene
269        xbot_sp = 5e-5; # propylene
270        P_sp = 5.0*'bar';
271        T_sp = (15+273.15) * 'K';
272        LC_sp = 1.0 * 'm';
273        LR_sp = 1.0 * 'm';
274
275        SET
276        col.NTrays = 8;
277        col.cond.V = 2 * 'm^3';
278        col.cond.Across = 1 * 'm^2';
279        col.trays.V = 4 * 'ft^3';
280        col.trays.Ah = 0.394 * 'ft^2';
281        col.trays.lw = 20.94 * 'in';
282        col.trays.hw = 0.125 * 'ft';
283        col.trays.Q = 0 * 'kW';
284        col.trays.beta = 0.6;
285        col.trays.alfa = 4;
286        col.trays.Ap = 3.94 * 'ft^2';
287        col.reb.V = 2 * 'm^3';
288        col.reb.Across = 1 * 'm^2';
289
290        # Controllers type
291        TCcond.PID_Select = "Ideal_AW";
292        PC.PID_Select = "Ideal_AW";
293        LCtop.PID_Select = "Ideal_AW";
294        LCbot.PID_Select = "Ideal_AW";
295        PID11.PID_Select = "Ideal_AW";
296        PID12.PID_Select = "Ideal_AW";
297        PID21.PID_Select = "Ideal_AW";
298        PID22.PID_Select = "Ideal_AW";
299
300        Qrmax = 5e6 * 'kJ/h';
301        Qrmin = 1e6 * 'kJ/h';
302        Frmin = 0 * 'kmol/h';
303        Frmax = 60 * 'kmol/h';
304        Fcmin = 0 * 'kmol/h';
305        Fcmax = 120 * 'kmol/h';
306        Hmint = 0 * 'm';
307        Hmaxt = 2 * 'm';
308        Hminb = 0 * 'm';
309        Hmaxb = 2 * 'm';
310        Pmin = 0.5 * 'bar';
311        Pmax = 10 * 'bar';
312        Qcmax = -5e5 * 'kJ/h';
313        Qcmin = -5e6 * 'kJ/h';
314        Tmax = (30+273.15) * 'K';
315        Tmin = (-20+273.15) * 'K';
316        RRmax = 5;
317        RRmin = 0.1;
318
319        INITIAL
320        # condenser
321        col.cond.OutletL.T = 260 *'K';
322        col.cond.Level = 1 * 'm';
323        col.cond.OutletL.z([1:4]) = [0.2, 0.2, 0.4, 0.05];
324
325        # reboiler
326        col.reb.OutletL.T = 350 *'K';
327        col.reb.Level = 1 * 'm';
328        col.reb.OutletL.z([1:4]) = [0.1, 0.4, 0.1, 0.3];
329
330        # column trays
331        col.trays.OutletL.T = [290:(330-290)/(col.NTrays-1):330] * 'K';
332        col.trays.Level = 1.2 * col.trays.hw;
333        col.trays.OutletL.z([1:4]) = [0.15, 0.3, 0.25, 0.2];
334
335        OPTIONS
336        TimeStep = 0.1;
337        TimeEnd = 6;
338        TimeUnit = 'h';
339        InitialFile = "Column_MPID.rlt";
340        DAESolver(File="dassl");
341        #GuessFile = "Column_MPID.rlt";
342        #Dynamic = false;
343end
344
Note: See TracBrowser for help on using the repository browser.