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 basic streams |
---|
17 | *---------------------------------------------------------------------- |
---|
18 | * Author: Paula B. Staudt and Rafael de P. Soares |
---|
19 | * $Id: streams.mso 501 2008-04-14 20:06:18Z paula $ |
---|
20 | *---------------------------------------------------------------------*# |
---|
21 | |
---|
22 | using "types"; |
---|
23 | |
---|
24 | Model stream |
---|
25 | ATTRIBUTES |
---|
26 | Pallete = false; |
---|
27 | Brief = "General Material Stream"; |
---|
28 | Info = |
---|
29 | "This is the basic building block for the EML models. |
---|
30 | Every model should have input and output streams derived |
---|
31 | from this model."; |
---|
32 | |
---|
33 | PARAMETERS |
---|
34 | outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); |
---|
35 | |
---|
36 | VARIABLES |
---|
37 | F as flow_mol (Brief = "Stream Molar Flow Rate"); |
---|
38 | T as temperature (Brief = "Stream Temperature"); |
---|
39 | P as pressure (Brief = "Stream Pressure"); |
---|
40 | z(NComp) as fraction (Brief = "Stream Molar Fraction"); |
---|
41 | h as enth_mol (Brief = "Stream Enthalpy"); |
---|
42 | v as fraction (Brief = "Vapourization fraction"); |
---|
43 | end |
---|
44 | |
---|
45 | Model liquid_stream as stream |
---|
46 | ATTRIBUTES |
---|
47 | Pallete = false; |
---|
48 | Brief = "Liquid Material Stream"; |
---|
49 | Info = |
---|
50 | "Model for liquid material streams. |
---|
51 | This model should be used only when the phase of the stream |
---|
52 | is known ''a priori''."; |
---|
53 | |
---|
54 | PARAMETERS |
---|
55 | outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); |
---|
56 | |
---|
57 | EQUATIONS |
---|
58 | "Liquid Enthalpy" |
---|
59 | h = PP.LiquidEnthalpy(T, P, z); |
---|
60 | "Liquid stream" |
---|
61 | v = 0; |
---|
62 | end |
---|
63 | |
---|
64 | Model vapour_stream as stream |
---|
65 | ATTRIBUTES |
---|
66 | Pallete = false; |
---|
67 | Brief = "Vapour Material Stream"; |
---|
68 | Info = |
---|
69 | "Model for vapour material streams. |
---|
70 | This model should be used only when the phase of the stream |
---|
71 | is known ''a priori''."; |
---|
72 | |
---|
73 | PARAMETERS |
---|
74 | outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); |
---|
75 | |
---|
76 | EQUATIONS |
---|
77 | "Vapour Enthalpy" |
---|
78 | h = PP.VapourEnthalpy(T, P, z); |
---|
79 | "Vapour stream" |
---|
80 | v = 1; |
---|
81 | end |
---|
82 | |
---|
83 | Model streamPH as stream |
---|
84 | ATTRIBUTES |
---|
85 | Brief = "Stream with built-in flash calculation"; |
---|
86 | Info = " |
---|
87 | This model should be used when the vaporization fraction |
---|
88 | is unknown. |
---|
89 | |
---|
90 | The built-in flash calculation will determine the stream |
---|
91 | state as a function of the overall composition '''z''', the |
---|
92 | pressure '''P''' and the enthalpy '''h'''. |
---|
93 | |
---|
94 | Additionally, the liquid composition '''x''' and the vapor |
---|
95 | composition '''y''' are calculated. |
---|
96 | "; |
---|
97 | Pallete = false; |
---|
98 | |
---|
99 | PARAMETERS |
---|
100 | outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); |
---|
101 | |
---|
102 | VARIABLES |
---|
103 | x(NComp) as fraction (Brief = "Liquid Molar Fraction"); |
---|
104 | y(NComp) as fraction (Brief = "Vapour Molar Fraction"); |
---|
105 | s as entr_mol (Brief = "Stream Entropy"); |
---|
106 | |
---|
107 | EQUATIONS |
---|
108 | "Flash Calculation" |
---|
109 | [v, x, y] = PP.FlashPH(P, h, z); |
---|
110 | |
---|
111 | "Enthalpy" |
---|
112 | h = (1-v)*PP.LiquidEnthalpy(T, P, x) + |
---|
113 | v*PP.VapourEnthalpy(T, P, y); |
---|
114 | |
---|
115 | "Entropy" |
---|
116 | s = (1-v)*PP.LiquidEntropy(T, P, x) + |
---|
117 | v*PP.VapourEntropy(T, P, y); |
---|
118 | end |
---|
119 | |
---|
120 | Model source |
---|
121 | ATTRIBUTES |
---|
122 | Pallete = true; |
---|
123 | Icon = "icon/Source"; |
---|
124 | Brief = "Material stream source"; |
---|
125 | Info = " |
---|
126 | This model should be used for boundary streams. |
---|
127 | Usually these streams are known and come from another process |
---|
128 | units. |
---|
129 | |
---|
130 | The user should specify: |
---|
131 | * Total molar (mass or volumetric) flow |
---|
132 | * Temperature |
---|
133 | * Pressure |
---|
134 | * Molar (mass or volumetric) composition |
---|
135 | |
---|
136 | No matter the specification set, the model will calculate some |
---|
137 | additional properties: |
---|
138 | * Mass density |
---|
139 | * Mass flow |
---|
140 | * Mass compostions |
---|
141 | * Specific volume |
---|
142 | * Vapour fraction |
---|
143 | * Volumetric flow |
---|
144 | * Liquid and Vapour compositions |
---|
145 | "; |
---|
146 | |
---|
147 | PARAMETERS |
---|
148 | outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); |
---|
149 | outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); |
---|
150 | M(NComp) as molweight (Brief = "Component Mol Weight"); |
---|
151 | rhoModel as Switcher (Brief = "Density model", Valid = ["volume", "correlation"], Default="volume"); |
---|
152 | |
---|
153 | SET |
---|
154 | |
---|
155 | M = PP.MolecularWeight(); |
---|
156 | |
---|
157 | VARIABLES |
---|
158 | out Outlet as stream (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}"); |
---|
159 | x(NComp) as fraction (Brief = "Liquid Molar Fraction"); |
---|
160 | y(NComp) as fraction (Brief = "Vapour Molar Fraction"); |
---|
161 | hl as enth_mol (Brief = "Liquid Enthalpy"); |
---|
162 | hv as enth_mol (Brief = "Vapour Enthalpy"); |
---|
163 | s as entr_mol (Brief = "Stream Entropy"); |
---|
164 | sl as entr_mol (Brief = "Liquid Entropy"); |
---|
165 | sv as entr_mol (Brief = "Vapour Entropy"); |
---|
166 | zmass(NComp) as fraction (Brief = "Mass Fraction"); |
---|
167 | Mw as molweight (Brief = "Average Mol Weight"); |
---|
168 | vm as volume_mol (Brief = "Molar Volume"); |
---|
169 | rho as dens_mass (Brief = "Stream Mass Density"); |
---|
170 | rhom as dens_mol (Brief = "Stream Molar Density"); |
---|
171 | Fw as flow_mass (Brief = "Stream Mass Flow"); |
---|
172 | Fvol as flow_vol (Brief = "Volumetric Flow"); |
---|
173 | T_Cdeg as temperature (Brief = "Temperature in °C", Lower=-200); |
---|
174 | |
---|
175 | EQUATIONS |
---|
176 | "Flash Calculation" |
---|
177 | [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z); |
---|
178 | |
---|
179 | "Overall Enthalpy" |
---|
180 | Outlet.h = (1-Outlet.v)*hl + Outlet.v*hv; |
---|
181 | |
---|
182 | "Liquid Enthalpy" |
---|
183 | hl = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x); |
---|
184 | |
---|
185 | "Vapour Enthalpy" |
---|
186 | hv = PP.VapourEnthalpy(Outlet.T, Outlet.P, y); |
---|
187 | |
---|
188 | "Overall Entropy" |
---|
189 | s = (1-Outlet.v)*sl + Outlet.v*sv; |
---|
190 | |
---|
191 | "Liquid Entropy" |
---|
192 | sl = PP.LiquidEntropy(Outlet.T, Outlet.P, x); |
---|
193 | |
---|
194 | "Vapour Entropy" |
---|
195 | sv = PP.VapourEntropy(Outlet.T, Outlet.P, y); |
---|
196 | |
---|
197 | "Average Molecular Weight" |
---|
198 | Mw = sum(M*Outlet.z); |
---|
199 | |
---|
200 | switch rhoModel |
---|
201 | case "volume": |
---|
202 | "Molar Density" |
---|
203 | rhom * vm = 1; |
---|
204 | |
---|
205 | case "correlation": |
---|
206 | "Mass Density" |
---|
207 | rho*((1-Outlet.v)/PP.LiquidDensity(Outlet.T,Outlet.P,x) + Outlet.v/PP.VapourDensity(Outlet.T,Outlet.P,y)) = 1; |
---|
208 | end |
---|
209 | |
---|
210 | "Mass or Molar Density" |
---|
211 | rhom * Mw = rho; |
---|
212 | |
---|
213 | "Flow Mass" |
---|
214 | Fw = Mw*Outlet.F; |
---|
215 | |
---|
216 | "Molar Volume" |
---|
217 | vm = (1-Outlet.v)*PP.LiquidVolume(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourVolume(Outlet.T,Outlet.P,y); |
---|
218 | |
---|
219 | "Volumetric Flow" |
---|
220 | Fvol = Outlet.F*vm ; |
---|
221 | |
---|
222 | "Mass Fraction" |
---|
223 | zmass = M*Outlet.z / Mw; |
---|
224 | |
---|
225 | "Temperature in °C" |
---|
226 | T_Cdeg = Outlet.T - 273.15 * 'K'; |
---|
227 | |
---|
228 | end |
---|
229 | |
---|
230 | Model simple_source |
---|
231 | ATTRIBUTES |
---|
232 | Pallete = true; |
---|
233 | Icon = "icon/Source"; |
---|
234 | Brief = "Simple material stream source"; |
---|
235 | Info = " |
---|
236 | This model should be used for boundary streams. |
---|
237 | Usually these streams are known and come from another process |
---|
238 | units. |
---|
239 | |
---|
240 | The user should specify: |
---|
241 | * Total molar flow |
---|
242 | * Temperature |
---|
243 | * Pressure |
---|
244 | * Molar composition |
---|
245 | "; |
---|
246 | |
---|
247 | PARAMETERS |
---|
248 | outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); |
---|
249 | outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); |
---|
250 | |
---|
251 | VARIABLES |
---|
252 | out Outlet as stream (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}"); |
---|
253 | x(NComp) as fraction (Brief = "Liquid Molar Fraction"); |
---|
254 | y(NComp) as fraction (Brief = "Vapour Molar Fraction"); |
---|
255 | hl as enth_mol (Brief = "Liquid Enthalpy"); |
---|
256 | hv as enth_mol (Brief = "Vapour Enthalpy"); |
---|
257 | s as entr_mol (Brief = "Stream Entropy"); |
---|
258 | sl as entr_mol (Brief = "Liquid Entropy"); |
---|
259 | sv as entr_mol (Brief = "Vapour Entropy"); |
---|
260 | |
---|
261 | EQUATIONS |
---|
262 | "Flash Calculation" |
---|
263 | [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z); |
---|
264 | |
---|
265 | "Overall Enthalpy" |
---|
266 | Outlet.h = (1-Outlet.v)*hl + Outlet.v*hv; |
---|
267 | |
---|
268 | "Liquid Enthalpy" |
---|
269 | hl = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x); |
---|
270 | |
---|
271 | "Vapour Enthalpy" |
---|
272 | hv = PP.VapourEnthalpy(Outlet.T, Outlet.P, y); |
---|
273 | |
---|
274 | "Overall Entropy" |
---|
275 | s = (1-Outlet.v)*sl + Outlet.v*sv; |
---|
276 | |
---|
277 | "Liquid Entropy" |
---|
278 | sl = PP.LiquidEntropy(Outlet.T, Outlet.P, x); |
---|
279 | |
---|
280 | "Vapour Entropy" |
---|
281 | sv = PP.VapourEntropy(Outlet.T, Outlet.P, y); |
---|
282 | end |
---|
283 | |
---|
284 | Model sink |
---|
285 | ATTRIBUTES |
---|
286 | Pallete = true; |
---|
287 | Icon = "icon/Sink"; |
---|
288 | Brief = "Material stream sink"; |
---|
289 | Info = " |
---|
290 | This model should be used for boundary streams when additional |
---|
291 | information about the stream is desired. |
---|
292 | |
---|
293 | Some of the additional informations calculated by this models are: |
---|
294 | * Mass density |
---|
295 | * Mass flow |
---|
296 | * Mass compostions |
---|
297 | * Specific volume |
---|
298 | * Vapour fraction |
---|
299 | * Volumetric flow |
---|
300 | * Liquid and Vapour compositions |
---|
301 | "; |
---|
302 | |
---|
303 | PARAMETERS |
---|
304 | outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); |
---|
305 | outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); |
---|
306 | M(NComp) as molweight (Brief = "Component Mol Weight"); |
---|
307 | rhoModel as Switcher (Brief = "Density model", Valid = ["volume", "correlation"], Default="volume"); |
---|
308 | |
---|
309 | SET |
---|
310 | |
---|
311 | M = PP.MolecularWeight(); |
---|
312 | |
---|
313 | VARIABLES |
---|
314 | in Inlet as stream (Brief = "Inlet Stream", PosX=0, PosY=0.5308, Symbol="_{in}"); |
---|
315 | v as fraction (Brief = "Vapourization fraction"); |
---|
316 | x(NComp) as fraction (Brief = "Liquid Molar Fraction"); |
---|
317 | y(NComp) as fraction (Brief = "Vapour Molar Fraction"); |
---|
318 | zmass(NComp) as fraction (Brief = "Mass Fraction"); |
---|
319 | Mw as molweight (Brief = "Average Mol Weight"); |
---|
320 | vm as volume_mol (Brief = "Molar Volume"); |
---|
321 | rho as dens_mass (Brief = "Stream Mass Density"); |
---|
322 | rhom as dens_mol (Brief = "Stream Molar Density"); |
---|
323 | Fw as flow_mass (Brief = "Stream Mass Flow"); |
---|
324 | Fvol as flow_vol (Brief = "Volumetric Flow"); |
---|
325 | s as entr_mol (Brief = "Stream Entropy"); |
---|
326 | T_Cdeg as temperature (Brief = "Temperature in °C", Lower=-200); |
---|
327 | |
---|
328 | EQUATIONS |
---|
329 | "Flash Calculation" |
---|
330 | [v, x, y] = PP.FlashPH(Inlet.P, Inlet.h, Inlet.z); |
---|
331 | |
---|
332 | "Average Molecular Weight" |
---|
333 | Mw = sum(M*Inlet.z); |
---|
334 | |
---|
335 | switch rhoModel |
---|
336 | case "volume": |
---|
337 | "Molar Density" |
---|
338 | rhom * vm = 1; |
---|
339 | |
---|
340 | case "correlation": |
---|
341 | "Mass Density" |
---|
342 | rho * ((1-v)/PP.LiquidDensity(Inlet.T,Inlet.P,x) + v/PP.VapourDensity(Inlet.T,Inlet.P,y)) = 1; |
---|
343 | end |
---|
344 | |
---|
345 | "Mass or Molar Density" |
---|
346 | rhom * Mw = rho; |
---|
347 | |
---|
348 | "Flow Mass" |
---|
349 | Fw = Mw*Inlet.F; |
---|
350 | |
---|
351 | "Molar Volume" |
---|
352 | vm = (1-v)*PP.LiquidVolume(Inlet.T, Inlet.P, x) + v*PP.VapourVolume(Inlet.T,Inlet.P,y); |
---|
353 | |
---|
354 | "Volumetric Flow" |
---|
355 | Fvol = Inlet.F*vm ; |
---|
356 | |
---|
357 | "Mass Fraction" |
---|
358 | zmass = M*Inlet.z / Mw; |
---|
359 | |
---|
360 | "Overall Entropy" |
---|
361 | s = (1-v)*PP.LiquidEntropy(Inlet.T, Inlet.P, x) + |
---|
362 | v*PP.VapourEntropy(Inlet.T, Inlet.P, y); |
---|
363 | |
---|
364 | "Temperature in °C" |
---|
365 | T_Cdeg = Inlet.T - 273.15 * 'K'; |
---|
366 | |
---|
367 | end |
---|
368 | |
---|
369 | Model simple_sink |
---|
370 | ATTRIBUTES |
---|
371 | Pallete = true; |
---|
372 | Icon = "icon/Sink"; |
---|
373 | Brief = "Simple material stream sink"; |
---|
374 | Info = " |
---|
375 | This model should be used for boundary streams when no additional |
---|
376 | information about the stream is desired. |
---|
377 | "; |
---|
378 | |
---|
379 | VARIABLES |
---|
380 | in Inlet as stream (Brief = "Inlet Stream", PosX=0, PosY=0.5308, Symbol="_{in}"); |
---|
381 | end |
---|
382 | |
---|
383 | Model energy_stream |
---|
384 | ATTRIBUTES |
---|
385 | Pallete = false; |
---|
386 | Brief = "General Energy Stream"; |
---|
387 | Info = |
---|
388 | "This is the basic building block for the EML models. |
---|
389 | Every model should have input and output energy streams |
---|
390 | derived from this model."; |
---|
391 | |
---|
392 | VARIABLES |
---|
393 | Q as heat_rate(Brief="Energy rate"); |
---|
394 | end |
---|
395 | |
---|
396 | Model energy_source |
---|
397 | ATTRIBUTES |
---|
398 | Pallete = true; |
---|
399 | Icon = "icon/energy_source"; |
---|
400 | Brief = "Enegry stream source"; |
---|
401 | |
---|
402 | VARIABLES |
---|
403 | out OutletQ as energy_stream (Brief = "Outlet energy stream", PosX=1, PosY=0.5349, Symbol="_{out}"); |
---|
404 | end |
---|