source: branches/gui/sample/controllers/sample_PID_MIMO.mso @ 804

Last change on this file since 804 was 735, checked in by gerson bicca, 14 years ago

updates (some samples are obsoletes)

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