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: Estefane Horn, Núbia do Carmo Ferreira |
---|
17 | *$Id: valve.mso 587 2008-08-04 22:45:14Z bicca $ |
---|
18 | *-------------------------------------------------------------------*# |
---|
19 | |
---|
20 | using "streams"; |
---|
21 | |
---|
22 | #*------------------------------------------------------------------- |
---|
23 | * Model of a valve (simplified) |
---|
24 | *-------------------------------------------------------------------- |
---|
25 | * |
---|
26 | * Author: Paula B. Staudt |
---|
27 | *--------------------------------------------------------------------*# |
---|
28 | Model valve_simplified |
---|
29 | ATTRIBUTES |
---|
30 | Pallete = true; |
---|
31 | Icon = "icon/Valve"; |
---|
32 | Brief = "Model of a very simple valve - used in distillation column models."; |
---|
33 | Info = |
---|
34 | "== Assumptions == |
---|
35 | * no flashing liquid in the valve; |
---|
36 | * the flow in the valve is adiabatic; |
---|
37 | * dynamics in the valve are neglected; |
---|
38 | * linear flow type. |
---|
39 | |
---|
40 | == Specify == |
---|
41 | * the inlet stream |
---|
42 | * the plug position (x) OR outlet temperature (Outlet.T) OR outlet pressure (Outlet.P) |
---|
43 | |
---|
44 | OR |
---|
45 | |
---|
46 | * the inlet stream excluding its flow (Inlet.F) |
---|
47 | * the outlet pressure (Outlet.P) OR outlet flow (Outlet.F) |
---|
48 | * the plug position (x) |
---|
49 | "; |
---|
50 | |
---|
51 | PARAMETERS |
---|
52 | outer PP as Plugin(Type="PP"); |
---|
53 | outer NComp as Integer; |
---|
54 | |
---|
55 | VARIABLES |
---|
56 | in Inlet as stream (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}"); |
---|
57 | out Outlet as streamPH (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}"); |
---|
58 | x as fraction (Brief="Plug Position"); |
---|
59 | rho as dens_mass (Brief="Fluid Density", Default=1e3); |
---|
60 | v as vol_mol (Brief="Specific volume", Default=1e3); |
---|
61 | Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P"); |
---|
62 | Pratio as positive (Brief = "Pressure Ratio", Symbol ="P_{ratio}"); |
---|
63 | |
---|
64 | PARAMETERS |
---|
65 | rho_ref as dens_mass (Brief="Reference Density", Default=1e4); |
---|
66 | k as Real (Brief="Valve Constant", Unit='gal/min/psi^0.5'); |
---|
67 | |
---|
68 | EQUATIONS |
---|
69 | "Overall Molar Balance" |
---|
70 | Inlet.F = Outlet.F; |
---|
71 | |
---|
72 | "Componente Molar Balance" |
---|
73 | Inlet.z = Outlet.z; |
---|
74 | |
---|
75 | "Energy Balance" |
---|
76 | Inlet.h = Outlet.h; |
---|
77 | |
---|
78 | "Pressure Drop" |
---|
79 | Outlet.P = Inlet.P - Pdrop; |
---|
80 | |
---|
81 | "Pressure Ratio" |
---|
82 | Outlet.P = Inlet.P * Pratio; |
---|
83 | |
---|
84 | "Density" |
---|
85 | rho = Inlet.v*PP.VapourDensity((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z) + |
---|
86 | (1-Inlet.v)*PP.LiquidDensity((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z); |
---|
87 | |
---|
88 | "Volume" |
---|
89 | v = Inlet.v*PP.VapourVolume((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z) + |
---|
90 | (1-Inlet.v)*PP.LiquidVolume((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z); |
---|
91 | |
---|
92 | if Pdrop > 0 then |
---|
93 | "Flow" |
---|
94 | Outlet.F * v = k*x*sqrt(Pdrop * rho_ref / rho ) ; |
---|
95 | else |
---|
96 | "Closed" |
---|
97 | Outlet.F = 0 * 'kmol/h'; |
---|
98 | end |
---|
99 | end |
---|
100 | |
---|
101 | Model valve_flow |
---|
102 | ATTRIBUTES |
---|
103 | Pallete = true; |
---|
104 | Icon = "icon/Valve"; |
---|
105 | Brief = "Model of a very simple valve for setting the flow with a controller."; |
---|
106 | Info = |
---|
107 | "== Assumptions == |
---|
108 | * nothing happens in this valve |
---|
109 | |
---|
110 | == Specify == |
---|
111 | * the inlet stream |
---|
112 | * the flow fraction |
---|
113 | "; |
---|
114 | |
---|
115 | PARAMETERS |
---|
116 | outer PP as Plugin(Type="PP"); |
---|
117 | outer NComp as Integer; |
---|
118 | |
---|
119 | MinFlow as flow_mol(Default=0); |
---|
120 | MaxFlow as flow_mol(Default=1000); |
---|
121 | |
---|
122 | VARIABLES |
---|
123 | in Inlet as stream (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}"); |
---|
124 | out Outlet as stream (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}"); |
---|
125 | in FlowFraction as fraction (Brief="Flow Signal", PosX=0.5, PosY=0); |
---|
126 | |
---|
127 | EQUATIONS |
---|
128 | "Overall Molar Balance" |
---|
129 | Outlet.F = Inlet.F; |
---|
130 | "Temperature" |
---|
131 | Outlet.T = Inlet.T; |
---|
132 | "Pressure" |
---|
133 | Outlet.P = Inlet.P; |
---|
134 | "Energy Balance" |
---|
135 | Outlet.h = Inlet.h; |
---|
136 | "Vapour fraction" |
---|
137 | Outlet.v = Inlet.v; |
---|
138 | |
---|
139 | "Componente Molar Balance" |
---|
140 | Outlet.z = Inlet.z; |
---|
141 | |
---|
142 | "Flow computation" |
---|
143 | Outlet.F = MinFlow + FlowFraction*(MaxFlow-MinFlow); |
---|
144 | end |
---|
145 | |
---|
146 | Model valve |
---|
147 | |
---|
148 | ATTRIBUTES |
---|
149 | Pallete = true; |
---|
150 | Icon = "icon/Valve"; |
---|
151 | Brief = "Model of a valve."; |
---|
152 | Info = |
---|
153 | "== Model of valves == |
---|
154 | * Linear; |
---|
155 | * Parabolic; |
---|
156 | * Equal; |
---|
157 | * Quick; |
---|
158 | * Hyperbolic. |
---|
159 | |
---|
160 | == Assumptions == |
---|
161 | * First Order Dynamic; |
---|
162 | * Only Liquid or Only Vapour; |
---|
163 | * Isentalpic. |
---|
164 | |
---|
165 | == Specify == |
---|
166 | * the valve type; |
---|
167 | * the Valve Coefficient (Cv); |
---|
168 | * the valve time constant (Tau). |
---|
169 | "; |
---|
170 | |
---|
171 | PARAMETERS |
---|
172 | |
---|
173 | outer PP as Plugin (Brief = "External Physical Properties", Type = "PP"); |
---|
174 | outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); |
---|
175 | |
---|
176 | ValveType as Switcher (Valid = ["linear", "parabolic", "equal", "quick", "hyperbolic"], Default = "linear"); |
---|
177 | ValidPhases as Switcher (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only"], Default="Liquid-Only"); |
---|
178 | Tau as time_sec (Brief="valve time constant"); |
---|
179 | rho60F as dens_mass (Brief = "Water Mass Density at 60 F",Hidden=true); |
---|
180 | |
---|
181 | VARIABLES |
---|
182 | |
---|
183 | Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P"); |
---|
184 | Fvol as flow_vol (Brief = "Volumetric Flow"); |
---|
185 | fc as positive (Brief = "Opening Function",Hidden=true); |
---|
186 | Cv as Real (Brief="Valve Flow Coefficient", Unit='gal/min/psi^0.5'); |
---|
187 | StemPosition as fraction (Brief = "Actual valve stem position"); |
---|
188 | |
---|
189 | |
---|
190 | vm as vol_mol (Brief = "Mixture Molar Volume"); |
---|
191 | rho as dens_mass (Brief = "Mixture Mass Density"); |
---|
192 | vsp as fraction (Brief = "Valve stem position",Hidden=true); |
---|
193 | |
---|
194 | in Inlet as stream (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}"); |
---|
195 | out Outlet as streamPH (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}"); |
---|
196 | in vsignal as fraction (Brief = "Flow Signal", PosX=0.5, PosY=0); |
---|
197 | |
---|
198 | SET |
---|
199 | |
---|
200 | rho60F = 984.252 * 'kg/m^3'; |
---|
201 | |
---|
202 | EQUATIONS |
---|
203 | |
---|
204 | "First order valve dynamics" |
---|
205 | Tau*diff(StemPosition) = vsp-StemPosition; |
---|
206 | |
---|
207 | "Flow Signal" |
---|
208 | vsp = vsignal; |
---|
209 | |
---|
210 | "Pressure Drop" |
---|
211 | Outlet.P = Inlet.P - Pdrop; |
---|
212 | |
---|
213 | "Enthalpy Balance" |
---|
214 | Outlet.h = Inlet.h; |
---|
215 | |
---|
216 | "Molar Balance" |
---|
217 | Outlet.F = Inlet.F; |
---|
218 | |
---|
219 | "Outlet Composition" |
---|
220 | Outlet.z = Inlet.z; |
---|
221 | |
---|
222 | switch ValidPhases |
---|
223 | |
---|
224 | case "Liquid-Only": |
---|
225 | |
---|
226 | if Pdrop > 0 then |
---|
227 | |
---|
228 | "Valve Equation - Liquid Flow" |
---|
229 | Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); |
---|
230 | |
---|
231 | else |
---|
232 | |
---|
233 | "Valve Equation - Liquid Flow" |
---|
234 | Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); |
---|
235 | |
---|
236 | end |
---|
237 | |
---|
238 | "Liquid Mass Density" |
---|
239 | rho = PP.LiquidDensity(Inlet.T,Inlet.P,Inlet.z); |
---|
240 | |
---|
241 | "Liquid Molar Volume" |
---|
242 | vm = PP.LiquidVolume(Inlet.T,Inlet.P,Inlet.z); |
---|
243 | |
---|
244 | case "Vapour-Only": |
---|
245 | |
---|
246 | if Pdrop > 0 then #Update for gas flow !!!! |
---|
247 | |
---|
248 | "Valve Equation - Vapour Flow" |
---|
249 | Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); |
---|
250 | |
---|
251 | else |
---|
252 | |
---|
253 | "Valve Equation - Vapour Flow" |
---|
254 | Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); |
---|
255 | |
---|
256 | end |
---|
257 | |
---|
258 | "Vapour Mass Density" |
---|
259 | rho = PP.VapourDensity(Inlet.T,Inlet.P,Inlet.z); |
---|
260 | |
---|
261 | "Vapour Molar Volume" |
---|
262 | vm = PP.VapourVolume(Inlet.T,Inlet.P,Inlet.z); |
---|
263 | |
---|
264 | end |
---|
265 | |
---|
266 | "Calculate Mass Flow" |
---|
267 | Fvol = Inlet.F*vm; |
---|
268 | |
---|
269 | switch ValveType #Update the valve Type |
---|
270 | |
---|
271 | case "linear": |
---|
272 | |
---|
273 | "Opening Equation" |
---|
274 | fc = StemPosition; |
---|
275 | |
---|
276 | case "parabolic": |
---|
277 | |
---|
278 | "Opening Equation" |
---|
279 | fc = StemPosition^2; |
---|
280 | |
---|
281 | case "equal": |
---|
282 | |
---|
283 | "Opening Equation" |
---|
284 | fc = StemPosition^2/(2-StemPosition^4)^(1/2); |
---|
285 | |
---|
286 | case "quick": |
---|
287 | |
---|
288 | "Opening Equation" |
---|
289 | fc = 10*StemPosition/sqrt(1+99*StemPosition^2); |
---|
290 | |
---|
291 | case "hyperbolic": |
---|
292 | |
---|
293 | "Opening Equation" |
---|
294 | fc = 0.1*StemPosition/sqrt(1-0.99*StemPosition^2); |
---|
295 | |
---|
296 | end |
---|
297 | |
---|
298 | end |
---|
299 | |
---|