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 694 2008-11-24 00:39:38Z bicca $ |
---|
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 | h as enth_mol (Brief = "Stream Enthalpy"); |
---|
41 | v as fraction (Brief = "Vapourization fraction"); |
---|
42 | z(NComp) as fraction (Brief = "Stream Molar 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",Hidden=true); |
---|
104 | y(NComp) as fraction (Brief = "Vapour Molar Fraction",Hidden=true); |
---|
105 | |
---|
106 | EQUATIONS |
---|
107 | "Flash Calculation" |
---|
108 | [v, x, y] = PP.FlashPH(P, h, z); |
---|
109 | |
---|
110 | "Enthalpy" |
---|
111 | h = (1-v)*PP.LiquidEnthalpy(T, P, x) + v*PP.VapourEnthalpy(T, P, y); |
---|
112 | |
---|
113 | end |
---|
114 | |
---|
115 | Model streamPHS as streamPH |
---|
116 | ATTRIBUTES |
---|
117 | Brief = "Stream with built-in flash calculation"; |
---|
118 | Info = " |
---|
119 | This model should be used when the vaporization fraction |
---|
120 | is unknown. |
---|
121 | |
---|
122 | The built-in flash calculation will determine the stream |
---|
123 | state as a function of the overall composition '''z''', the |
---|
124 | pressure '''P''' and the enthalpy '''h'''. |
---|
125 | |
---|
126 | Additionally, the liquid composition '''x''', the vapor |
---|
127 | composition '''y''' and the stream entropy are calculated. |
---|
128 | "; |
---|
129 | Pallete = false; |
---|
130 | |
---|
131 | PARAMETERS |
---|
132 | outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); |
---|
133 | |
---|
134 | VARIABLES |
---|
135 | s as entr_mol (Brief = "Stream Entropy"); |
---|
136 | |
---|
137 | EQUATIONS |
---|
138 | |
---|
139 | "Entropy" |
---|
140 | s = (1-v)*PP.LiquidEntropy(T, P, x) + v*PP.VapourEntropy(T, P, y); |
---|
141 | |
---|
142 | end |
---|
143 | |
---|
144 | Model sink |
---|
145 | ATTRIBUTES |
---|
146 | Pallete = true; |
---|
147 | Icon = "icon/Sink"; |
---|
148 | Brief = "Material stream sink"; |
---|
149 | Info = " |
---|
150 | This model should be used for boundary streams when additional |
---|
151 | information about the stream is desired. |
---|
152 | |
---|
153 | Some of the additional informations calculated by this models are: |
---|
154 | * Mass density |
---|
155 | * Mass flow |
---|
156 | * Mass compostions |
---|
157 | * Specific volume |
---|
158 | * Vapour fraction |
---|
159 | * Volumetric flow |
---|
160 | * Liquid and Vapour compositions |
---|
161 | "; |
---|
162 | |
---|
163 | PARAMETERS |
---|
164 | outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); |
---|
165 | outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); |
---|
166 | M(NComp) as molweight (Brief = "Component Mol Weight"); |
---|
167 | |
---|
168 | SET |
---|
169 | |
---|
170 | M = PP.MolecularWeight(); |
---|
171 | |
---|
172 | VARIABLES |
---|
173 | in Inlet as stream (Brief = "Inlet Stream", PosX=0, PosY=0.5308, Protected=true,Symbol="_{in}"); |
---|
174 | v as fraction (Brief = "Vapourization fraction",Hidden=true); |
---|
175 | x(NComp) as fraction (Brief = "Liquid Molar Fraction",Hidden=true); |
---|
176 | y(NComp) as fraction (Brief = "Vapour Molar Fraction",Hidden=true); |
---|
177 | zmass(NComp) as fraction (Brief = "Mass Fraction"); |
---|
178 | Mw as molweight (Brief = "Average Mol Weight"); |
---|
179 | vm as volume_mol (Brief = "Molar Volume"); |
---|
180 | rho as dens_mass (Brief = "Stream Mass Density"); |
---|
181 | rhom as dens_mol (Brief = "Stream Molar Density"); |
---|
182 | Fw as flow_mass (Brief = "Stream Mass Flow"); |
---|
183 | Fvol as flow_vol (Brief = "Volumetric Flow"); |
---|
184 | T_Cdeg as temperature (Brief = "Temperature in °C", Lower=-200); |
---|
185 | |
---|
186 | EQUATIONS |
---|
187 | "Flash Calculation" |
---|
188 | [v, x, y] = PP.FlashPH(Inlet.P, Inlet.h, Inlet.z); |
---|
189 | |
---|
190 | "Average Molecular Weight" |
---|
191 | Mw = sum(M*Inlet.z); |
---|
192 | |
---|
193 | "Molar Density" |
---|
194 | rhom * vm = 1; |
---|
195 | |
---|
196 | "Mass or Molar Density" |
---|
197 | rhom * Mw = rho; |
---|
198 | |
---|
199 | "Flow Mass" |
---|
200 | Fw = Mw*Inlet.F; |
---|
201 | |
---|
202 | "Molar Volume" |
---|
203 | vm = (1-v)*PP.LiquidVolume(Inlet.T, Inlet.P, x) + v*PP.VapourVolume(Inlet.T,Inlet.P,y); |
---|
204 | |
---|
205 | "Volumetric Flow" |
---|
206 | Fvol = Inlet.F*vm ; |
---|
207 | |
---|
208 | "Mass Fraction" |
---|
209 | zmass = M*Inlet.z / Mw; |
---|
210 | |
---|
211 | "Temperature in °C" |
---|
212 | T_Cdeg = Inlet.T - 273.15 * 'K'; |
---|
213 | |
---|
214 | end |
---|
215 | |
---|
216 | Model simple_sink |
---|
217 | ATTRIBUTES |
---|
218 | Pallete = true; |
---|
219 | Icon = "icon/Sink"; |
---|
220 | Brief = "Simple material stream sink"; |
---|
221 | Info = " |
---|
222 | This model should be used for boundary streams when no additional |
---|
223 | information about the stream is desired. |
---|
224 | "; |
---|
225 | |
---|
226 | VARIABLES |
---|
227 | in Inlet as stream (Brief = "Inlet Stream", PosX=0, PosY=0.5308, Protected=true,Symbol="_{in}"); |
---|
228 | end |
---|
229 | |
---|
230 | Model energy_source |
---|
231 | ATTRIBUTES |
---|
232 | Pallete = true; |
---|
233 | Icon = "icon/energy_source"; |
---|
234 | Brief = "Energy stream source"; |
---|
235 | |
---|
236 | VARIABLES |
---|
237 | out OutletQ as power(Brief = "Outlet energy stream", PosX=1, PosY=0.46, Symbol="_{out}"); |
---|
238 | |
---|
239 | end |
---|
240 | |
---|
241 | Model work_source |
---|
242 | ATTRIBUTES |
---|
243 | Pallete = true; |
---|
244 | Icon = "icon/work_source"; |
---|
245 | Brief = "Work stream source"; |
---|
246 | |
---|
247 | VARIABLES |
---|
248 | out Work as power(Brief = "Outlet work stream", PosX=1, PosY=0.46, Symbol="_{out}"); |
---|
249 | |
---|
250 | end |
---|
251 | |
---|
252 | Model info_stream |
---|
253 | ATTRIBUTES |
---|
254 | Pallete = true; |
---|
255 | Icon = "icon/Info_Stream"; |
---|
256 | Brief = "Material stream information"; |
---|
257 | Info = " |
---|
258 | This model should be used for middle streams when additional |
---|
259 | information about the stream is desired. |
---|
260 | |
---|
261 | Some of the additional informations calculated by this models are: |
---|
262 | * Mass density |
---|
263 | * Mass flow |
---|
264 | * Mass compostions |
---|
265 | * Specific volume |
---|
266 | * Vapour fraction |
---|
267 | * Volumetric flow |
---|
268 | * Liquid and Vapour compositions |
---|
269 | * Viscosity |
---|
270 | * Heat Capacity |
---|
271 | * Thermal Conductivity |
---|
272 | * Temperature in Celsius Degrees |
---|
273 | "; |
---|
274 | |
---|
275 | PARAMETERS |
---|
276 | outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); |
---|
277 | outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); |
---|
278 | M(NComp) as molweight (Brief = "Component Mol Weight"); |
---|
279 | |
---|
280 | SET |
---|
281 | |
---|
282 | M = PP.MolecularWeight(); |
---|
283 | |
---|
284 | VARIABLES |
---|
285 | |
---|
286 | in Inlet as stream (Brief = "Inlet Stream", PosX=0, PosY=0.5308, Protected=true , Symbol="_{in}"); |
---|
287 | out Outlet as stream (Brief = "Outlet Stream", PosX=1, PosY=0.5308, Protected=true , Symbol="_{out}"); |
---|
288 | |
---|
289 | v as fraction (Brief = "Vapourization fraction",Hidden=true); |
---|
290 | x(NComp) as fraction (Brief = "Liquid Molar Fraction",Hidden=true); |
---|
291 | y(NComp) as fraction (Brief = "Vapour Molar Fraction",Hidden=true); |
---|
292 | |
---|
293 | Fw as flow_mass (Brief = "Stream Mass Flow",Protected=true); |
---|
294 | Fvol as flow_vol (Brief = "Volumetric Flow",Protected=true); |
---|
295 | T_Cdeg as temperature (Brief = "Temperature in °C", Lower=-200,Protected=true); |
---|
296 | |
---|
297 | Mu as viscosity (Brief="Stream Viscosity",Lower=0.0001, Symbol = "\mu",Protected=true); |
---|
298 | Cp as cp_mol (Brief="Stream Molar Heat Capacity", Upper=1e10,Protected=true); |
---|
299 | K as conductivity (Brief="Stream Thermal Conductivity", Default=1.0, Lower=1e-5, Upper=500,Protected=true); |
---|
300 | Mw as molweight (Brief = "Average Mol Weight",Protected=true); |
---|
301 | vm as volume_mol (Brief = "Molar Volume",Protected=true); |
---|
302 | rho as dens_mass (Brief = "Stream Mass Density",Protected=true); |
---|
303 | rhom as dens_mol (Brief = "Stream Molar Density",Protected=true); |
---|
304 | s as entr_mol (Brief = "Stream Entropy",Protected=true); |
---|
305 | zmass(NComp) as fraction (Brief = "Mass Fraction",Protected=true); |
---|
306 | |
---|
307 | EQUATIONS |
---|
308 | |
---|
309 | "Flash Calculation" |
---|
310 | [v, x, y] = PP.FlashPH(Inlet.P, Inlet.h, Inlet.z); |
---|
311 | |
---|
312 | "Average Molecular Weight" |
---|
313 | Mw = sum(M*Inlet.z); |
---|
314 | |
---|
315 | "Mass Density" |
---|
316 | rho * ((1-v)/PP.LiquidDensity(Inlet.T,Inlet.P,x) + v/PP.VapourDensity(Inlet.T,Inlet.P,y)) = 1; |
---|
317 | |
---|
318 | "Mass or Molar Density" |
---|
319 | rhom * Mw = rho; |
---|
320 | |
---|
321 | "Flow Mass" |
---|
322 | Fw = Mw*Inlet.F; |
---|
323 | |
---|
324 | "Molar Volume" |
---|
325 | vm = (1-v)*PP.LiquidVolume(Inlet.T, Inlet.P, x) + v*PP.VapourVolume(Inlet.T,Inlet.P,y); |
---|
326 | |
---|
327 | "Volumetric Flow" |
---|
328 | Fvol = Inlet.F*vm ; |
---|
329 | |
---|
330 | "Mass Fraction" |
---|
331 | zmass = M*Inlet.z / Mw; |
---|
332 | |
---|
333 | "Stream Heat Capacity" |
---|
334 | Cp = (1-v)*PP.LiquidCp(Inlet.T, Inlet.P, x) + v*PP.VapourCp(Inlet.T,Inlet.P,y); |
---|
335 | |
---|
336 | "Stream Viscosity" |
---|
337 | Mu = (1-v)*PP.LiquidViscosity(Inlet.T, Inlet.P, x) + v*PP.VapourViscosity(Inlet.T,Inlet.P,y); |
---|
338 | |
---|
339 | "Stream ThermalConductivity" |
---|
340 | K = (1-v)*PP.LiquidThermalConductivity(Inlet.T, Inlet.P, x) + v*PP.VapourThermalConductivity(Inlet.T,Inlet.P,y); |
---|
341 | |
---|
342 | "Stream Overall Entropy" |
---|
343 | s = (1-v)*PP.LiquidEntropy(Inlet.T, Inlet.P, x) + v*PP.VapourEntropy(Inlet.T, Inlet.P, y); |
---|
344 | |
---|
345 | "Temperature in °C" |
---|
346 | T_Cdeg = Inlet.T - 273.15 * 'K'; |
---|
347 | |
---|
348 | "Outlet Flow" |
---|
349 | Outlet.F = Inlet.F; |
---|
350 | |
---|
351 | "Outlet Temperature" |
---|
352 | Outlet.T = Inlet.T; |
---|
353 | |
---|
354 | "Outlet Pressure" |
---|
355 | Outlet.P = Inlet.P; |
---|
356 | |
---|
357 | "Outlet Vapour Fraction" |
---|
358 | Outlet.v = Inlet.v; |
---|
359 | |
---|
360 | "Outlet Enthalpy" |
---|
361 | Outlet.h = Inlet.h; |
---|
362 | |
---|
363 | "Outlet Composition" |
---|
364 | Outlet.z= Inlet.z; |
---|
365 | |
---|
366 | end |
---|
367 | |
---|
368 | Model source |
---|
369 | |
---|
370 | ATTRIBUTES |
---|
371 | Pallete = true; |
---|
372 | Icon = "icon/Source"; |
---|
373 | Brief = "Material stream source"; |
---|
374 | Info = " |
---|
375 | This model should be used for boundary streams. |
---|
376 | Usually these streams are known and come from another process |
---|
377 | units. |
---|
378 | |
---|
379 | The user should specify: |
---|
380 | * Total molar (mass or volumetric) flow |
---|
381 | * Temperature |
---|
382 | * Pressure |
---|
383 | * Molar or mass composition |
---|
384 | |
---|
385 | No matter the specification set, the model will calculate some |
---|
386 | additional properties: |
---|
387 | * Mass density |
---|
388 | * Mass flow |
---|
389 | * Mass compostions |
---|
390 | * Specific volume |
---|
391 | * Vapour fraction |
---|
392 | * Volumetric flow |
---|
393 | * Liquid and Vapour compositions |
---|
394 | "; |
---|
395 | |
---|
396 | PARAMETERS |
---|
397 | outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); |
---|
398 | outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); |
---|
399 | M(NComp) as molweight (Brief = "Component Mol Weight"); |
---|
400 | CompositionBasis as Switcher (Brief = "Molar or Mass Composition", Valid = ["Molar", "Mass"], Default="Molar"); |
---|
401 | ValidPhases as Switcher (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid"); |
---|
402 | |
---|
403 | |
---|
404 | SET |
---|
405 | |
---|
406 | M = PP.MolecularWeight(); |
---|
407 | |
---|
408 | VARIABLES |
---|
409 | |
---|
410 | out Outlet as stream (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true); |
---|
411 | |
---|
412 | Composition(NComp) as fraction (Brief = "Stream Composition"); |
---|
413 | SumOfComposition as positive (Brief = "Sum of Stream Composition",Protected=true); |
---|
414 | F as flow_mol (Brief = "Stream Molar Flow Rate"); |
---|
415 | Fw as flow_mass (Brief = "Stream Mass Flow"); |
---|
416 | Fvol as flow_vol (Brief = "Volumetric Flow"); |
---|
417 | T as temperature (Brief = "Stream Temperature"); |
---|
418 | T_Cdeg as temperature (Brief = "Temperature in °C", Lower=-200); |
---|
419 | P as pressure (Brief = "Stream Pressure"); |
---|
420 | |
---|
421 | x(NComp) as fraction (Brief = "Liquid Molar Fraction",Hidden=true); |
---|
422 | y(NComp) as fraction (Brief = "Vapour Molar Fraction",Hidden=true); |
---|
423 | |
---|
424 | Mw as molweight (Brief = "Average Mol Weight",Protected=true); |
---|
425 | vm as volume_mol (Brief = "Molar Volume",Protected=true); |
---|
426 | rho as dens_mass (Brief = "Stream Mass Density",Protected=true); |
---|
427 | rhom as dens_mol (Brief = "Stream Molar Density",Protected=true); |
---|
428 | |
---|
429 | zmass(NComp) as fraction (Brief = "Mass Fraction",Protected=true); |
---|
430 | |
---|
431 | EQUATIONS |
---|
432 | |
---|
433 | switch CompositionBasis |
---|
434 | |
---|
435 | case "Molar": |
---|
436 | "Stream Molar Composition" |
---|
437 | Outlet.z = Composition/sum(Composition); |
---|
438 | |
---|
439 | "Stream Mass Composition" |
---|
440 | zmass = M*Outlet.z / Mw; |
---|
441 | |
---|
442 | case "Mass": |
---|
443 | "Stream Mass Composition" |
---|
444 | zmass = Composition/sum(Composition); |
---|
445 | |
---|
446 | "Stream Molar Composition" |
---|
447 | Outlet.z*sum(zmass/M) = zmass/M; |
---|
448 | |
---|
449 | end |
---|
450 | |
---|
451 | switch ValidPhases |
---|
452 | |
---|
453 | case "Liquid-Only": |
---|
454 | |
---|
455 | "Vapour Fraction" |
---|
456 | Outlet.v = 0; |
---|
457 | |
---|
458 | "Liquid Composition" |
---|
459 | x = Outlet.z; |
---|
460 | |
---|
461 | "Vapour Composition" |
---|
462 | y = Outlet.z; |
---|
463 | |
---|
464 | "Overall Enthalpy" |
---|
465 | Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x); |
---|
466 | |
---|
467 | "Molar Volume" |
---|
468 | vm = PP.LiquidVolume(Outlet.T, Outlet.P, x); |
---|
469 | |
---|
470 | case "Vapour-Only": |
---|
471 | |
---|
472 | "Vapor Fraction" |
---|
473 | Outlet.v = 1; |
---|
474 | |
---|
475 | "Liquid Composition" |
---|
476 | x = Outlet.z; |
---|
477 | |
---|
478 | "Vapour Composition" |
---|
479 | y = Outlet.z; |
---|
480 | |
---|
481 | "Overall Enthalpy" |
---|
482 | Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y); |
---|
483 | |
---|
484 | "Molar Volume" |
---|
485 | vm = PP.VapourVolume(Outlet.T, Outlet.P, y); |
---|
486 | |
---|
487 | |
---|
488 | case "Vapour-Liquid": |
---|
489 | |
---|
490 | "Flash Calculation" |
---|
491 | [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z); |
---|
492 | |
---|
493 | "Overall Enthalpy" |
---|
494 | Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y); |
---|
495 | |
---|
496 | "Molar Volume" |
---|
497 | vm = (1-Outlet.v)*PP.LiquidVolume(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourVolume(Outlet.T,Outlet.P,y); |
---|
498 | |
---|
499 | end |
---|
500 | |
---|
501 | "Sum of Composition" |
---|
502 | SumOfComposition = sum(Composition); |
---|
503 | |
---|
504 | "Molar Density" |
---|
505 | rhom * vm = 1; |
---|
506 | |
---|
507 | "Average Molecular Weight" |
---|
508 | Mw = sum(M*Outlet.z); |
---|
509 | |
---|
510 | "Mass or Molar Density" |
---|
511 | rhom * Mw = rho; |
---|
512 | |
---|
513 | "Flow Mass" |
---|
514 | Fw = Mw*Outlet.F; |
---|
515 | |
---|
516 | "Volumetric Flow" |
---|
517 | Fvol = Outlet.F*vm ; |
---|
518 | |
---|
519 | "Temperature in °C" |
---|
520 | T_Cdeg = Outlet.T - 273.15 * 'K'; |
---|
521 | |
---|
522 | "Equate Flow" |
---|
523 | Outlet.F = F; |
---|
524 | |
---|
525 | "Equate Pressures" |
---|
526 | Outlet.P = P; |
---|
527 | |
---|
528 | "Equate Temperatures" |
---|
529 | Outlet.T = T; |
---|
530 | |
---|
531 | end |
---|
532 | |
---|
533 | Model simple_source |
---|
534 | |
---|
535 | ATTRIBUTES |
---|
536 | Pallete = true; |
---|
537 | Icon = "icon/Source"; |
---|
538 | Brief = "Simple Material stream source"; |
---|
539 | Info = " |
---|
540 | This model should be used for boundary streams. |
---|
541 | Usually these streams are known and come from another process |
---|
542 | units. |
---|
543 | |
---|
544 | The user should specify: |
---|
545 | * Total molar flow |
---|
546 | * Temperature |
---|
547 | * Pressure |
---|
548 | * Molar composition |
---|
549 | "; |
---|
550 | |
---|
551 | PARAMETERS |
---|
552 | outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); |
---|
553 | outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); |
---|
554 | M(NComp) as molweight (Brief = "Component Mol Weight"); |
---|
555 | ValidPhases as Switcher (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid"); |
---|
556 | |
---|
557 | |
---|
558 | SET |
---|
559 | |
---|
560 | M = PP.MolecularWeight(); |
---|
561 | |
---|
562 | VARIABLES |
---|
563 | |
---|
564 | out Outlet as stream (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true); |
---|
565 | |
---|
566 | MolarComposition(NComp) as fraction (Brief = "Stream Molar Composition"); |
---|
567 | SumOfComposition as positive (Brief = "Sum of Stream Composition",Protected=true); |
---|
568 | F as flow_mol (Brief = "Stream Molar Flow Rate"); |
---|
569 | T as temperature (Brief = "Stream Temperature"); |
---|
570 | T_Cdeg as temperature (Brief = "Temperature in °C", Lower=-200); |
---|
571 | P as pressure (Brief = "Stream Pressure"); |
---|
572 | |
---|
573 | x(NComp) as fraction (Brief = "Liquid Molar Fraction",Hidden=true); |
---|
574 | y(NComp) as fraction (Brief = "Vapour Molar Fraction",Hidden=true); |
---|
575 | |
---|
576 | |
---|
577 | EQUATIONS |
---|
578 | |
---|
579 | "Sum of Composition" |
---|
580 | SumOfComposition = sum(MolarComposition); |
---|
581 | |
---|
582 | "Stream Molar Composition" |
---|
583 | Outlet.z = MolarComposition/sum(MolarComposition); |
---|
584 | |
---|
585 | |
---|
586 | switch ValidPhases |
---|
587 | |
---|
588 | case "Liquid-Only": |
---|
589 | |
---|
590 | "Vapour Fraction" |
---|
591 | Outlet.v = 0; |
---|
592 | |
---|
593 | "Liquid Composition" |
---|
594 | x = Outlet.z; |
---|
595 | |
---|
596 | "Vapour Composition" |
---|
597 | y = Outlet.z; |
---|
598 | |
---|
599 | "Overall Enthalpy" |
---|
600 | Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x); |
---|
601 | |
---|
602 | |
---|
603 | case "Vapour-Only": |
---|
604 | |
---|
605 | "Vapor Fraction" |
---|
606 | Outlet.v = 1; |
---|
607 | |
---|
608 | "Liquid Composition" |
---|
609 | x = Outlet.z; |
---|
610 | |
---|
611 | "Vapour Composition" |
---|
612 | y = Outlet.z; |
---|
613 | |
---|
614 | "Overall Enthalpy" |
---|
615 | Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y); |
---|
616 | |
---|
617 | |
---|
618 | case "Vapour-Liquid": |
---|
619 | |
---|
620 | "Flash Calculation" |
---|
621 | [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z); |
---|
622 | |
---|
623 | "Overall Enthalpy" |
---|
624 | Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y); |
---|
625 | |
---|
626 | |
---|
627 | end |
---|
628 | |
---|
629 | "Temperature in °C" |
---|
630 | T_Cdeg = Outlet.T - 273.15 * 'K'; |
---|
631 | |
---|
632 | "Equate Flow" |
---|
633 | Outlet.F = F; |
---|
634 | |
---|
635 | "Equate Pressures" |
---|
636 | Outlet.P = P; |
---|
637 | |
---|
638 | "Equate Temperatures" |
---|
639 | Outlet.T = T; |
---|
640 | |
---|
641 | end |
---|
642 | |
---|
643 | Model sourceNoFlow |
---|
644 | |
---|
645 | ATTRIBUTES |
---|
646 | Pallete = true; |
---|
647 | Icon = "icon/SourceNoFlow"; |
---|
648 | Brief = "Simple Material stream source with no flow."; |
---|
649 | Info = " |
---|
650 | This model should be used for boundary streams. |
---|
651 | Usually these streams are known and come from another process |
---|
652 | units."; |
---|
653 | |
---|
654 | PARAMETERS |
---|
655 | outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); |
---|
656 | outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); |
---|
657 | |
---|
658 | VARIABLES |
---|
659 | |
---|
660 | out Outlet as stream (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true); |
---|
661 | |
---|
662 | EQUATIONS |
---|
663 | |
---|
664 | "Stream Molar Composition" |
---|
665 | Outlet.z = 1/NComp; |
---|
666 | |
---|
667 | "Stream Molar Enthalpy" |
---|
668 | Outlet.h = 0 * 'J/mol'; |
---|
669 | |
---|
670 | "Stream Temperature" |
---|
671 | Outlet.T = 300 * 'K'; |
---|
672 | |
---|
673 | "Stream Molar Flow" |
---|
674 | Outlet.F = 0 * 'kmol/h'; |
---|
675 | |
---|
676 | "Stream Pressure" |
---|
677 | Outlet.P = 1 * 'atm'; |
---|
678 | |
---|
679 | "Stream Vapour Fraction" |
---|
680 | Outlet.v = 0; |
---|
681 | |
---|
682 | end |
---|
683 | |
---|
684 | Model sinkNoFlow |
---|
685 | ATTRIBUTES |
---|
686 | Pallete = true; |
---|
687 | Icon = "icon/SinkNoFlow"; |
---|
688 | Brief = "Simple material stream sink"; |
---|
689 | Info = " |
---|
690 | This model should be used for seal an outlet material stream port. |
---|
691 | "; |
---|
692 | |
---|
693 | VARIABLES |
---|
694 | in Inlet as stream (Brief = "Inlet Stream", PosX=0, PosY=0.5308, Protected=true,Symbol="_{in}"); |
---|
695 | |
---|
696 | EQUATIONS |
---|
697 | "Stream Molar Flow" |
---|
698 | Inlet.F = 0 * 'kmol/h'; |
---|
699 | |
---|
700 | end |
---|