1 | #*------------------------------------------------------------------- |
---|
2 | * EMSO Model Library (EML) Copyright (C) 2004 - 2008 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 - 2008 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 | * Flash separator sample file. |
---|
17 | *-------------------------------------------------------------------- |
---|
18 | * |
---|
19 | * This sample file needs VRTherm (www.vrtech.com.br) to run. |
---|
20 | * |
---|
21 | *-------------------------------------------------------------------- |
---|
22 | * Author: Rafael de Pelegrini Soares |
---|
23 | * $Id: Sample_flash_pid.mso 735 2009-02-27 02:00:39Z bicca $ |
---|
24 | *------------------------------------------------------------------# |
---|
25 | |
---|
26 | using "stage_separators/flash"; |
---|
27 | using "controllers/PIDIncr"; |
---|
28 | |
---|
29 | FlowSheet Flash_Dynamic |
---|
30 | |
---|
31 | PARAMETERS |
---|
32 | PP as Plugin(Brief="Physical Properties",Type="PP", |
---|
33 | Components = ["n-butane", "benzene", "n-octane"], |
---|
34 | LiquidModel = "PR", |
---|
35 | VapourModel = "PR"); |
---|
36 | NComp as Integer; |
---|
37 | #Maximum and minimum vapor and liquid flow rates |
---|
38 | FVMin as flow_mol; |
---|
39 | FVMax as flow_mol; |
---|
40 | FLMax as flow_mol; |
---|
41 | FLMin as flow_mol; |
---|
42 | #Maximum and minimum pressure |
---|
43 | PMin as pressure; |
---|
44 | PMax as pressure; |
---|
45 | #Maximum and minimum level |
---|
46 | LMax as length; |
---|
47 | LMin as length; |
---|
48 | |
---|
49 | VARIABLES |
---|
50 | L_ad as Real (Brief="Dimensionless level"); |
---|
51 | P_ad as Real (Brief="Dimensionless pressure"); |
---|
52 | Q as energy_source (Brief="Heat supplied"); |
---|
53 | |
---|
54 | DEVICES |
---|
55 | pidL as PIDIncr; #Level controller |
---|
56 | pidP as PIDIncr; #Pressure controller |
---|
57 | fl as flash; |
---|
58 | s1 as source; |
---|
59 | |
---|
60 | SET |
---|
61 | NComp = PP.NumberOfComponents; |
---|
62 | |
---|
63 | pidL.PID_Select = "Parallel_AWBT"; |
---|
64 | pidP.PID_Select = "Parallel_AWBT"; |
---|
65 | |
---|
66 | #Flash model parameters |
---|
67 | fl.V = 10 * 'm^3'; |
---|
68 | fl.diameter = 0.5 * 'm'; |
---|
69 | fl.orientation = "vertical"; |
---|
70 | |
---|
71 | #Maximum and minimum values |
---|
72 | PMax=2.36 *'atm'; |
---|
73 | PMin=0 *'atm'; |
---|
74 | LMax=2 *'m'; |
---|
75 | LMin=0 *'m'; |
---|
76 | FVMax=300*'kmol/h'; |
---|
77 | FVMin=0*'kmol/h'; |
---|
78 | FLMax=692.7*'kmol/h'; |
---|
79 | FLMin=0*'kmol/h'; |
---|
80 | |
---|
81 | CONNECTIONS |
---|
82 | s1.Outlet to fl.Inlet; |
---|
83 | Q.OutletQ to fl.InletQ; |
---|
84 | |
---|
85 | SET |
---|
86 | #Level controller configuration |
---|
87 | pidL.bias=0.5; |
---|
88 | pidL.gain=1.1776; |
---|
89 | pidL.derivTime=19*'s'; |
---|
90 | pidL.intTime=76*'s'; |
---|
91 | pidL.tau=1*'s'; |
---|
92 | pidL.tauSet=1*'s'; |
---|
93 | pidL.alpha =1; |
---|
94 | pidL.beta =1; |
---|
95 | pidL.gamma =1; |
---|
96 | pidL.Mode = "Automatic"; |
---|
97 | pidL.Clip = "Clipped"; |
---|
98 | pidL.Action = "Direct"; |
---|
99 | |
---|
100 | #Pressure controller parameters |
---|
101 | pidP.bias=0.5; |
---|
102 | pidP.gain=0.9275; |
---|
103 | pidP.derivTime=18*'s'; |
---|
104 | pidP.intTime=72*'s'; |
---|
105 | pidP.tau=1*'s'; |
---|
106 | pidP.tauSet=1*'s'; |
---|
107 | pidP.alpha =1; |
---|
108 | pidP.beta =1; |
---|
109 | pidP.gamma =1; |
---|
110 | #Pressure controller configuration |
---|
111 | pidP.Mode = "Automatic"; |
---|
112 | pidP.Clip = "Clipped"; |
---|
113 | pidP.Action = "Direct"; |
---|
114 | |
---|
115 | SPECIFY |
---|
116 | |
---|
117 | Q.OutletQ = 1026.32 * 'kJ/s'; |
---|
118 | |
---|
119 | #Level controller parameters |
---|
120 | pidL.Ports.setPoint=0.5; |
---|
121 | |
---|
122 | |
---|
123 | EQUATIONS |
---|
124 | #Feed stream |
---|
125 | s1.Composition = [0.3, 0.3, 0.4]; |
---|
126 | s1.P = 5 * 'atm'; |
---|
127 | |
---|
128 | #Disturbance |
---|
129 | if time < 0.5*'h' then |
---|
130 | s1.T = 338 * 'K'; |
---|
131 | s1.F = 496.3 * 'kmol/h'; |
---|
132 | else |
---|
133 | s1.T = 360 * 'K'; |
---|
134 | s1.F = 450 * 'kmol/h'; |
---|
135 | end |
---|
136 | |
---|
137 | #Control variables: fl.Level and fl.OutletV.P |
---|
138 | #Normalized control variables |
---|
139 | L_ad*(LMax-LMin)=fl.Level-LMin; |
---|
140 | P_ad*(PMax-PMin)=fl.OutletV.P-PMin; |
---|
141 | |
---|
142 | #Controllers input ports |
---|
143 | pidL.Ports.input=L_ad; |
---|
144 | pidP.Ports.input=P_ad; |
---|
145 | |
---|
146 | #Setpoint change |
---|
147 | if time < 2*'h' then |
---|
148 | pidP.Ports.setPoint=0.501822; |
---|
149 | else |
---|
150 | pidP.Ports.setPoint=0.8474576; |
---|
151 | end |
---|
152 | |
---|
153 | #Controllers output ports |
---|
154 | #Manipulated variables: fl.OutletV.F (pressure control) and fl.OutletL.F (level control) |
---|
155 | fl.OutletV.F = pidP.Ports.output*(FVMax-FVMin)+FVMin; |
---|
156 | fl.OutletL.F = pidL.Ports.output*(FLMax-FLMin)+FLMin; |
---|
157 | |
---|
158 | INITIAL |
---|
159 | fl.OutletL.T = 340 *'K'; |
---|
160 | fl.Level = 1* 'm'; |
---|
161 | fl.OutletL.z(1) = 0.1; |
---|
162 | fl.OutletL.z(2) = 0.1; |
---|
163 | |
---|
164 | OPTIONS |
---|
165 | TimeStep = 0.02; |
---|
166 | TimeEnd = 3; |
---|
167 | TimeUnit = 'h'; |
---|
168 | DAESolver(File="dassl"); |
---|
169 | end |
---|
170 | |
---|
171 | |
---|
172 | |
---|