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 | * Author: Rafael de P. Soares and Paula B. Staudt |
---|
17 | * $Id: sample_flashPH.mso 289 2007-06-20 15:07:08Z rafael $ |
---|
18 | *--------------------------------------------------------------------*# |
---|
19 | |
---|
20 | using "streams"; |
---|
21 | |
---|
22 | Model FlashPHSteady |
---|
23 | ATTRIBUTES |
---|
24 | Pallete = true; |
---|
25 | Icon = "Flash"; |
---|
26 | Brief = "Model of a static PH flash."; |
---|
27 | Info = " |
---|
28 | This model shows how to model a pressure enthalpy flash |
---|
29 | directly with the EMSO modeling language. |
---|
30 | |
---|
31 | This model is for demonstration purposes only, the flashPH |
---|
32 | routine available on VRTherm is much more robust. |
---|
33 | |
---|
34 | Assumptions: |
---|
35 | * perfect mixing of both phases; |
---|
36 | |
---|
37 | Specify: |
---|
38 | * the feed stream; |
---|
39 | * the heat duty; |
---|
40 | * the outlet pressure. |
---|
41 | "; |
---|
42 | |
---|
43 | PARAMETERS |
---|
44 | outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); |
---|
45 | outer NComp as Integer; |
---|
46 | B as Real(Default=1000, Brief="Regularization Factor"); |
---|
47 | |
---|
48 | VARIABLES |
---|
49 | in Inlet as stream (Brief="Feed Stream"); |
---|
50 | out OutletL as liquid_stream (Brief="Liquid outlet stream"); |
---|
51 | out OutletV as vapour_stream (Brief="Vapour outlet stream"); |
---|
52 | in Q as heat_rate (Brief="Rate of heat supply"); |
---|
53 | vfrac as fraction(Brief="Real vaporization fraction"); |
---|
54 | vsat as Real(Lower=-0.1, Upper=1.1, Brief="Vaporization fraction if saturated"); |
---|
55 | Tsat as temperature(Lower=173, Upper=1473, Brief="Temperature if saturated"); |
---|
56 | xsat(NComp) as Real(Lower=0, Upper=1, Brief="Liquid composition if saturated"); |
---|
57 | ysat(NComp) as Real(Lower=0, Upper=1, Brief="Vapour composition if saturated"); |
---|
58 | |
---|
59 | zero_one as fraction(Brief="Regularization Variable"); |
---|
60 | one_zero as fraction(Brief="Regularization Variable"); |
---|
61 | |
---|
62 | EQUATIONS |
---|
63 | "Chemical equilibrium" |
---|
64 | PP.LiquidFugacityCoefficient(Tsat, OutletL.P, xsat)*xsat = |
---|
65 | PP.VapourFugacityCoefficient(Tsat, OutletV.P, ysat)*ysat; |
---|
66 | |
---|
67 | "Global Molar Balance" |
---|
68 | Inlet.F = OutletV.F + OutletL.F; |
---|
69 | OutletV.F = Inlet.F * vfrac; |
---|
70 | |
---|
71 | "Component Molar Balance" |
---|
72 | Inlet.F*Inlet.z = OutletL.F*xsat + OutletV.F*ysat; |
---|
73 | sum(xsat) = sum(ysat); |
---|
74 | |
---|
75 | "Energy Balance if saturated" |
---|
76 | Inlet.F*Inlet.h + Q = |
---|
77 | Inlet.F*(1-vsat)*PP.LiquidEnthalpy(Tsat, OutletL.P, xsat) + |
---|
78 | Inlet.F*vsat*PP.VapourEnthalpy(Tsat, OutletV.P, ysat); |
---|
79 | |
---|
80 | "Real Energy Balance" |
---|
81 | Inlet.F*Inlet.h + Q = |
---|
82 | Inlet.F*(1-vfrac)*OutletL.h + Inlet.F*vfrac*OutletV.h; |
---|
83 | |
---|
84 | "Thermal Equilibrium" |
---|
85 | OutletV.T = OutletL.T; |
---|
86 | |
---|
87 | "Mechanical Equilibrium" |
---|
88 | OutletV.P = OutletL.P; |
---|
89 | |
---|
90 | # regularization functions |
---|
91 | zero_one = (1 + tanh(B * vsat))/2; |
---|
92 | one_zero = (1 - tanh(B * (vsat - 1)))/2; |
---|
93 | |
---|
94 | vfrac = zero_one * one_zero * vsat + 1 - one_zero; |
---|
95 | OutletL.z = zero_one*one_zero*xsat + (1-zero_one*one_zero)*Inlet.z; |
---|
96 | OutletV.z = zero_one*one_zero*ysat + (1-zero_one*one_zero)*Inlet.z; |
---|
97 | end |
---|
98 | |
---|
99 | FlowSheet FlashPHTest |
---|
100 | PARAMETERS |
---|
101 | PP as Plugin(Brief="Physical Properties", |
---|
102 | Type="PP", |
---|
103 | Components = ["methane", "isobutene", "benzene"], |
---|
104 | LiquidModel = "IdealLiquid", |
---|
105 | VapourModel = "Ideal" |
---|
106 | ); |
---|
107 | NComp as Integer; |
---|
108 | |
---|
109 | VARIABLES |
---|
110 | Q as heat_rate (Brief="Heat supplied"); |
---|
111 | |
---|
112 | SET |
---|
113 | NComp = PP.NumberOfComponents; |
---|
114 | |
---|
115 | DEVICES |
---|
116 | fl as FlashPHSteady; |
---|
117 | s1 as source; |
---|
118 | |
---|
119 | CONNECTIONS |
---|
120 | s1.Outlet to fl.Inlet; |
---|
121 | Q to fl.Q; |
---|
122 | |
---|
123 | SPECIFY |
---|
124 | s1.Outlet.F = 496.3 * 'kmol/h'; |
---|
125 | s1.Outlet.T = 338 * 'K'; |
---|
126 | s1.Outlet.P = 507.1 * 'kPa'; |
---|
127 | s1.Outlet.z = [0.1, 0.7,0.2]; |
---|
128 | |
---|
129 | fl.OutletL.P = 2.5 * 'atm'; |
---|
130 | |
---|
131 | Q = 0 * 'kJ/h'; |
---|
132 | #fl.OutletL.T = 315.06 * 'K'; |
---|
133 | |
---|
134 | OPTIONS |
---|
135 | Dynamic = false; |
---|
136 | end |
---|
137 | |
---|