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 | * Model of tanks |
---|
17 | *-------------------------------------------------------------------- |
---|
18 | * Streams: |
---|
19 | * * an inlet stream |
---|
20 | * * an outlet stream |
---|
21 | * |
---|
22 | * Specify: |
---|
23 | * * the Inlet stream |
---|
24 | * * the Outlet flow |
---|
25 | * * the tank Q |
---|
26 | * |
---|
27 | * Initial: |
---|
28 | * * the tank temperature (OutletL.T) |
---|
29 | * * the tank level (h) |
---|
30 | * * (NoComps - 1) Outlet compositions |
---|
31 | *---------------------------------------------------------------------- |
---|
32 | * Author: Paula B. Staudt |
---|
33 | * $Id: tank.mso 783 2009-06-30 15:28:57Z bicca $ |
---|
34 | *--------------------------------------------------------------------*# |
---|
35 | |
---|
36 | using "streams"; |
---|
37 | |
---|
38 | Model tank |
---|
39 | ATTRIBUTES |
---|
40 | Pallete = true; |
---|
41 | Icon = "icon/Tank"; |
---|
42 | Brief = "Model of a cylindrical tank."; |
---|
43 | Info = |
---|
44 | "== Specify == |
---|
45 | * the Inlet stream; |
---|
46 | * the outlet flow; |
---|
47 | * the InletQ (requires an energy source). |
---|
48 | |
---|
49 | == Initial Conditions == |
---|
50 | * the tank initial temperature; |
---|
51 | * the tank initial level; |
---|
52 | * the tank initial composition. |
---|
53 | "; |
---|
54 | |
---|
55 | PARAMETERS |
---|
56 | outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); |
---|
57 | outer NComp as Integer; |
---|
58 | |
---|
59 | pi as positive (Brief="Pi value", Default=3.141593,Hidden=true); |
---|
60 | Diameter as length (Brief="Tank internal Diameter",Default=1.5); |
---|
61 | Across as area (Brief="Tank cross section area", Hidden=true); |
---|
62 | L as length (Brief="Tank length",Default=5); |
---|
63 | |
---|
64 | |
---|
65 | Initial_Level as length (Brief="Initial Level of the Tank",Default=1); |
---|
66 | Initial_Temperature as temperature (Brief="Initial Temperature of Liquid",Default=300); |
---|
67 | Initial_Composition(NComp) as positive (Brief="Initial Liquid Composition",Lower=1E-8, Default=0.10); |
---|
68 | |
---|
69 | SET |
---|
70 | |
---|
71 | Across = 0.25*pi*(Diameter)^2; |
---|
72 | |
---|
73 | VARIABLES |
---|
74 | in Inlet as stream (Brief = "Inlet stream", PosX=0.3037, PosY=0, Symbol="_{in}"); |
---|
75 | out Outlet as liquid_stream (Brief = "Outlet liquid stream", PosX=1, PosY=1, Symbol="_{out}"); |
---|
76 | in InletQ as power (Brief="Rate of heat supply", PosX=1, PosY=0.7859, Symbol="_{in}",Protected=true); |
---|
77 | Vtotal as volume (Brief="Tank total volume",Protected=true); |
---|
78 | Vfilled as volume (Brief="Tank volume content",Protected=true); |
---|
79 | Level as length (Brief="Tank level",Protected=true); |
---|
80 | E as energy (Brief="Total Energy Holdup on tank",Protected=true); |
---|
81 | vL as volume_mol (Brief="Liquid Molar Volume",Protected=true); |
---|
82 | M(NComp) as mol (Brief="Molar Holdup in the tank",Protected=true); |
---|
83 | |
---|
84 | INITIAL |
---|
85 | |
---|
86 | "Initial Level" |
---|
87 | Level = Initial_Level; |
---|
88 | |
---|
89 | "Initial Liquid Temperature" |
---|
90 | Outlet.T = Initial_Temperature; |
---|
91 | |
---|
92 | "Initial Liquid Composition" |
---|
93 | Outlet.z(1:NComp-1) = Initial_Composition(1:NComp-1)/sum(Initial_Composition); |
---|
94 | |
---|
95 | EQUATIONS |
---|
96 | |
---|
97 | "Tank total volume" |
---|
98 | Vtotal = Across*L; |
---|
99 | |
---|
100 | "Mass balance" |
---|
101 | diff(M) = Inlet.F*Inlet.z - Outlet.F*Outlet.z; |
---|
102 | |
---|
103 | "Energy balance" |
---|
104 | diff(E) = Inlet.F*Inlet.h - Outlet.F*Outlet.h + InletQ; |
---|
105 | |
---|
106 | "Energy Holdup" |
---|
107 | E = sum(M)*Outlet.h; |
---|
108 | |
---|
109 | "Mechanical Equilibrium" |
---|
110 | Inlet.P = Outlet.P; |
---|
111 | |
---|
112 | "Liquid Volume" |
---|
113 | vL = PP.LiquidVolume(Outlet.T, Outlet.P, Outlet.z); |
---|
114 | |
---|
115 | "Composition" |
---|
116 | M = Outlet.z*sum(M); |
---|
117 | |
---|
118 | "Level of liquid phase" |
---|
119 | Level = sum(M)*vL/Across; |
---|
120 | |
---|
121 | "Volume Filled of liquid phase" |
---|
122 | Vfilled = Level*Across; |
---|
123 | |
---|
124 | end |
---|
125 | |
---|
126 | #*---------------------------------------------------------- |
---|
127 | * |
---|
128 | *Model of a tank with a lain cylinder geometry |
---|
129 | * |
---|
130 | *---------------------------------------------------------*# |
---|
131 | Model tank_cylindrical |
---|
132 | ATTRIBUTES |
---|
133 | Pallete = true; |
---|
134 | Icon = "icon/TankHorizontal"; |
---|
135 | Brief = "Model of a tank with a lain cylinder geometry."; |
---|
136 | Info = |
---|
137 | "== Specify == |
---|
138 | * the Inlet stream; |
---|
139 | * the outlet flow; |
---|
140 | * the InletQ (requires an energy source). |
---|
141 | |
---|
142 | == Initial Conditions == |
---|
143 | * the tank initial temperature; |
---|
144 | * the tank initial level; |
---|
145 | * the tank initial composition. |
---|
146 | "; |
---|
147 | |
---|
148 | PARAMETERS |
---|
149 | outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); |
---|
150 | outer NComp as Integer (Brief = "Number of Components"); |
---|
151 | |
---|
152 | pi as positive (Brief="Pi value", Default=3.141593,Hidden=true); |
---|
153 | eps as positive (Brief="small number",Default=1E-8,Hidden=true); |
---|
154 | Diameter as length (Brief="Tank internal Diameter",Default=1.5); |
---|
155 | radius as length (Brief="Tank radius",Hidden=true); |
---|
156 | L as length (Brief="Tank length",Default=5); |
---|
157 | |
---|
158 | Initial_Level as length (Brief="Initial Level of the Tank",Default=1); |
---|
159 | Initial_Temperature as temperature (Brief="Initial Temperature of Liquid",Default=300); |
---|
160 | Initial_Composition(NComp) as positive (Brief="Initial Liquid Composition",Lower=1E-8,Default=0.1); |
---|
161 | |
---|
162 | SET |
---|
163 | radius = Diameter/2; |
---|
164 | |
---|
165 | VARIABLES |
---|
166 | in Inlet as stream (Brief="Inlet stream", PosX=0.1825, PosY=0, Symbol="_{in}"); |
---|
167 | out Outlet as liquid_stream (Brief="Outlet liquid stream", PosX=1, PosY=1, Symbol="_{out}"); |
---|
168 | in InletQ as power (Brief="Rate of heat supply", PosX=1, PosY=0.6160, Symbol="_{in}",Protected=true); |
---|
169 | Level as length (Brief="Tank level",Protected=true); |
---|
170 | Vtotal as volume (Brief="Tank total volume",Protected=true); |
---|
171 | Vfilled as volume (Brief="Tank volume content",Protected=true); |
---|
172 | Across as area (Brief="Tank cross section area", Default=2,Protected=true); |
---|
173 | E as energy (Brief="Total Energy Holdup on tank",Protected=true); |
---|
174 | vL as volume_mol (Brief="Liquid Molar Volume",Protected=true); |
---|
175 | M(NComp) as mol (Brief="Molar Holdup in the tank",Protected=true); |
---|
176 | |
---|
177 | INITIAL |
---|
178 | |
---|
179 | "Initial Level" |
---|
180 | Level = Initial_Level; |
---|
181 | |
---|
182 | "Initial Liquid Temperature" |
---|
183 | Outlet.T = Initial_Temperature; |
---|
184 | |
---|
185 | "Initial Liquid Composition" |
---|
186 | Outlet.z(1:NComp-1) = Initial_Composition(1:NComp-1)/sum(Initial_Composition); |
---|
187 | |
---|
188 | EQUATIONS |
---|
189 | |
---|
190 | "Tank total volume" |
---|
191 | Vtotal = (0.25*pi*(Diameter)^2)*L; |
---|
192 | |
---|
193 | "Mass balance" |
---|
194 | diff(M) = Inlet.F*Inlet.z - Outlet.F*Outlet.z; |
---|
195 | |
---|
196 | "Energy balance" |
---|
197 | diff(E) = Inlet.F*Inlet.h - Outlet.F*Outlet.h + InletQ; |
---|
198 | |
---|
199 | "Energy Holdup" |
---|
200 | E = sum(M)*Outlet.h; |
---|
201 | |
---|
202 | "Mechanical Equilibrium" |
---|
203 | Inlet.P = Outlet.P; |
---|
204 | |
---|
205 | "Liquid Volume" |
---|
206 | vL = PP.LiquidVolume(Outlet.T, Outlet.P, Outlet.z); |
---|
207 | |
---|
208 | "Composition" |
---|
209 | M = Outlet.z*sum(M); |
---|
210 | |
---|
211 | "Cylindrical Area" |
---|
212 | Across = radius^2 * (asin(1) - asin((radius-Level)/radius) ) + (Level-radius)*sqrt(Level*(2*radius - Level)+eps*'m^2'); |
---|
213 | |
---|
214 | "Level of liquid phase" |
---|
215 | L*Across = sum(M)*vL; |
---|
216 | |
---|
217 | "Volume Filled of liquid phase" |
---|
218 | Vfilled = L*Across; |
---|
219 | |
---|
220 | end |
---|
221 | |
---|
222 | Model tank_feed |
---|
223 | ATTRIBUTES |
---|
224 | Pallete = true; |
---|
225 | Icon = "icon/Tank"; |
---|
226 | Brief = "Model of a tank with feed stream."; |
---|
227 | Info = |
---|
228 | "== Specify == |
---|
229 | * the Inlet stream; |
---|
230 | * the Feed stream; |
---|
231 | * the outlet flow; |
---|
232 | * the tank Q. |
---|
233 | |
---|
234 | == Initial Conditions == |
---|
235 | * the tank initial temperature (OutletL.T); |
---|
236 | * the tank initial level (Level); |
---|
237 | * (NoComps - 1) OutletL (OR OutletV) compositions. |
---|
238 | "; |
---|
239 | |
---|
240 | PARAMETERS |
---|
241 | outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); |
---|
242 | outer NComp as Integer; |
---|
243 | Across as area (Brief="Tank cross section area", Default=2); |
---|
244 | |
---|
245 | VARIABLES |
---|
246 | in Feed as stream (Brief = "Feed stream", PosX=0.32, PosY=0, Symbol="_{feed}"); |
---|
247 | in Inlet as stream (Brief = "Inlet stream", PosX=0.3037, PosY=0, Symbol="_{in}"); |
---|
248 | out Outlet as liquid_stream (Brief = "Outlet liquid stream", PosX=1, PosY=1, Symbol="_{out}"); |
---|
249 | in InletQ as power (Brief="Rate of heat supply", PosX=1, PosY=0.7859, Symbol="_{in}"); |
---|
250 | |
---|
251 | Level as length(Brief="Tank level"); |
---|
252 | M(NComp) as mol (Brief="Molar Holdup in the tank"); |
---|
253 | E as energy (Brief="Total Energy Holdup on tank"); |
---|
254 | vL as volume_mol (Brief="Liquid Molar Volume"); |
---|
255 | |
---|
256 | EQUATIONS |
---|
257 | "Mass balance" |
---|
258 | diff(M) = Feed.F*Feed.z + Inlet.F*Inlet.z - Outlet.F*Outlet.z; |
---|
259 | |
---|
260 | "Energy balance" |
---|
261 | diff(E) = Feed.F*Feed.h + Inlet.F*Inlet.h - Outlet.F*Outlet.h + InletQ; |
---|
262 | |
---|
263 | "Energy Holdup" |
---|
264 | E = sum(M)*Outlet.h; |
---|
265 | |
---|
266 | "Mechanical Equilibrium" |
---|
267 | Inlet.P = Outlet.P; |
---|
268 | |
---|
269 | "Liquid Volume" |
---|
270 | vL = PP.LiquidVolume(Outlet.T, Outlet.P, Outlet.z); |
---|
271 | |
---|
272 | "Composition" |
---|
273 | M = Outlet.z*sum(M); |
---|
274 | |
---|
275 | "Level of liquid phase" |
---|
276 | Level = sum(M)*vL/Across; |
---|
277 | end |
---|