source: branches/gui/eml/pressure_changers/valve.mso @ 586

Last change on this file since 586 was 586, checked in by gerson bicca, 15 years ago

testing a dynamic valve model

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.6 KB
Line 
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 586 2008-08-01 19:40:50Z bicca $                                                                       
18*-------------------------------------------------------------------*#
19
20using "streams";
21       
22
23Model valve
24        ATTRIBUTES
25        Pallete         = true;
26        Icon            = "icon/Valve";
27        Brief           = "Model of a valve.";
28        Info            =
29"== Model of valves ==
30* Linear;
31* Parabolic;
32* Equal;
33* Quick;
34* Hyperbolic.
35       
36== Assumptions ==
37* Steady State;
38* Liquid;
39* Isentalpic.
40       
41== Specify ==
42* the valve type;
43* the inlet stream;
44* the Volumetric Flow (Qv);
45* the Valve Coefficient (cv);
46* the opening (x).
47";
48               
49        PARAMETERS
50        valve_type as Switcher (Valid = ["linear", "parabolic", "equal", "quick", "hyperbolic"], Default = "linear");
51outer PP                as Plugin       (Brief = "External Physical Properties", Type = "PP");
52outer NComp     as Integer      (Brief = "Number of chemical components", Lower = 1);
53        rho60F  as dens_mass;
54
55        VARIABLES
56        Pratio  as positive                     (Brief = "Pressure Ratio", Symbol ="P_{ratio}");       
57        Pdrop   as press_delta          (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P");
58        Qv              as flow_vol                     (Brief = "Volumetric Flow");
59        fc              as positive                     (Brief = "Opening Function");
60        cv              as positive                     (Brief = "Valve Coefficient", Unit = 'm^3/h/kPa^0.5');
61        Gf              as positive                     (Brief = "Specific Gravity");
62        rho     as dens_mass;   
63        vm              as vol_mol                      (Brief = "Mixture Molar Volume");       
64        x               as fraction             (Brief = "Opening");
65in      Inlet   as stream                       (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}");
66out     Outlet  as streamPH                     (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}");
67       
68        SET
69        rho60F = 999.02 * 'kg/m^3';
70       
71        EQUATIONS
72        "Pressure Drop"
73        Outlet.P  = Inlet.P - Pdrop;
74
75        "Pressure Ratio"
76        Outlet.P = Inlet.P * Pratio;
77       
78        "Enthalpy Balance"
79        Outlet.h = Inlet.h;
80       
81        "Molar Balance"
82        Outlet.F = Inlet.F;
83       
84        "Calculate Outlet Composition"
85        Outlet.z = Inlet.z;
86
87        if Pdrop > 0 then
88                "Valve Equation - Flow"
89                Qv = fc*cv*sqrt(Pdrop/Gf);     
90        else
91                "Valve Equation - Closed"
92                Qv = 0 * 'm^3/h';
93        end
94       
95        "Calculate Gf"
96        Gf = rho/rho60F;
97       
98        "Calculate Specific Mass"
99        rho = PP.LiquidDensity(Inlet.T,Inlet.P,Inlet.z);
100       
101        "Calculate Mass Flow"
102        Qv = Inlet.F*vm;       
103       
104        "Calculate Liquid Molar Volume"
105        vm = PP.LiquidVolume(Inlet.T,Inlet.P,Inlet.z);
106       
107        switch valve_type
108        case "linear":
109
110                "Opening Equation"
111                fc = x;
112
113        case "parabolic":
114
115                "Opening Equation"
116                fc = x^2;
117
118        case "equal":
119
120                "Opening Equation"
121                fc = x^2/(2-x^4)^(1/2);
122
123        case "quick":
124       
125                "Opening Equation"
126                fc = 10*x/sqrt(1+99*x^2);
127
128        case "hyperbolic":
129
130                "Opening Equation"
131                fc = 0.1*x/sqrt(1-0.99*x^2);
132
133        end
134
135end
136
137#*-------------------------------------------------------------------
138* Model of a valve (simplified)
139*--------------------------------------------------------------------
140*
141* Author: Paula B. Staudt
142*--------------------------------------------------------------------*#
143Model valve_simplified
144        ATTRIBUTES
145        Pallete         = true;
146        Icon            = "icon/Valve";
147        Brief           = "Model of a very simple valve - used in distillation column models.";
148        Info            =
149"== Assumptions ==
150* no flashing liquid in the valve;
151* the flow in the valve is adiabatic;
152* dynamics in the valve are neglected;
153* linear flow type.
154       
155== Specify ==
156* the inlet stream
157* the plug position (x) OR outlet temperature (Outlet.T) OR outlet pressure (Outlet.P)
158       
159        OR             
160       
161* the inlet stream excluding its flow (Inlet.F)
162* the outlet pressure (Outlet.P) OR outlet flow (Outlet.F)
163* the plug position (x)
164";
165
166        PARAMETERS
167outer PP as Plugin(Type="PP");
168outer NComp as Integer;
169       
170        VARIABLES
171in      Inlet   as stream       (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}");
172out     Outlet  as streamPH     (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}");
173        x as fraction (Brief="Plug Position");
174        rho as dens_mass (Brief="Fluid Density", Default=1e3);
175        v as vol_mol (Brief="Specific volume", Default=1e3);
176        Pdrop     as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P");
177        Pratio  as positive     (Brief = "Pressure Ratio", Symbol ="P_{ratio}");       
178
179        PARAMETERS
180        rho_ref as dens_mass (Brief="Reference Density", Default=1e4);
181        k as Real (Brief="Valve Constant", Unit='gal/min/psi^0.5');
182
183        EQUATIONS
184        "Overall Molar Balance"
185        Inlet.F = Outlet.F;
186       
187        "Componente Molar Balance"
188        Inlet.z = Outlet.z;
189       
190        "Energy Balance"
191        Inlet.h = Outlet.h;
192
193        "Pressure Drop"
194        Outlet.P  = Inlet.P - Pdrop;
195
196        "Pressure Ratio"
197        Outlet.P = Inlet.P * Pratio;
198
199        "Density"
200        rho = Inlet.v*PP.VapourDensity((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z) +
201                (1-Inlet.v)*PP.LiquidDensity((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z);
202
203        "Volume"
204        v = Inlet.v*PP.VapourVolume((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z) +
205                (1-Inlet.v)*PP.LiquidVolume((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z);
206
207        if Pdrop > 0 then
208                "Flow"
209                Outlet.F * v = k*x*sqrt(Pdrop * rho_ref / rho ) ;
210        else
211                "Closed"
212                Outlet.F = 0 * 'kmol/h';
213        end
214end
215
216
217Model valve_flow
218        ATTRIBUTES
219        Pallete         = true;
220        Icon            = "icon/Valve";
221        Brief           = "Model of a very simple valve for setting the flow with a controller.";
222        Info            =
223"== Assumptions ==
224* nothing happens in this valve
225       
226== Specify ==
227* the inlet stream
228* the flow fraction
229";
230
231        PARAMETERS
232outer PP as Plugin(Type="PP");
233outer NComp as Integer;
234
235        MinFlow as flow_mol(Default=0);
236        MaxFlow as flow_mol(Default=1000);
237       
238        VARIABLES
239in      Inlet   as stream       (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}");
240out     Outlet  as stream       (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}");
241in      FlowFraction as fraction (Brief="Flow Signal", PosX=0.5, PosY=0);
242       
243        EQUATIONS
244        "Overall Molar Balance"
245        Outlet.F = Inlet.F;
246        "Temperature"
247        Outlet.T = Inlet.T;
248        "Pressure"
249        Outlet.P = Inlet.P;
250        "Energy Balance"
251        Outlet.h = Inlet.h;
252        "Vapour fraction"
253        Outlet.v = Inlet.v;
254
255        "Componente Molar Balance"
256        Outlet.z = Inlet.z;
257
258        "Flow computation"
259        Outlet.F = MinFlow + FlowFraction*(MaxFlow-MinFlow);
260end
261
262Model valve_liquid_test
263        ATTRIBUTES
264        Pallete         = true;
265        Icon            = "icon/Valve";
266        Brief           = "testing Model of a valve.";
267
268               
269PARAMETERS
270        valve_type      as Switcher (Valid = ["linear", "parabolic", "equal", "quick", "hyperbolic"], Default = "linear");
271outer PP                as Plugin       (Brief = "External Physical Properties", Type = "PP");
272outer NComp     as Integer      (Brief = "Number of chemical components", Lower = 1);
273        rho60F          as dens_mass;
274        tau                 as time_sec (Brief="valve time constant");
275
276VARIABLES
277        Pdrop   as press_delta          (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P");
278        Qv              as flow_vol                     (Brief = "Volumetric Flow");
279        fc              as positive                     (Brief = "Opening Function");
280        cv              as positive                     (Brief = "Valve Coefficient", Unit = 'm^3/h/kPa^0.5');
281        Gf              as positive                     (Brief = "Specific Gravity");
282        rho     as dens_mass;   
283        vm              as vol_mol                      (Brief = "Mixture Molar Volume");       
284        vactual as fraction             (Brief = "Actual valve stem position");
285        vsp     as fraction             (Brief = "Valve stem position");
286in      Inlet   as stream                       (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}");
287out     Outlet  as streamPH                     (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}");
288in      vsignal as fraction             (Brief="Flow Signal", PosX=0.5, PosY=0);
289       
290SET
291        rho60F = 999.02 * 'kg/m^3';
292       
293EQUATIONS
294
295"valve dynamics"
296tau*diff(vactual) = vsp-vactual;
297
298vsp=vsignal;
299
300"Pressure Drop"
301        Outlet.P  = Inlet.P - Pdrop;
302
303"Enthalpy Balance"
304        Outlet.h = Inlet.h;
305       
306"Molar Balance"
307        Outlet.F = Inlet.F;
308       
309"Outlet Composition"
310        Outlet.z = Inlet.z;
311
312if Pdrop > 0 then # update the flow equation !!!!
313
314"Valve Equation - Flow"
315        Qv = 1000*fc*cv*sqrt(Pdrop/Gf);
316               
317else
318
319"Valve Equation - Closed"
320        Qv = 0.1*fc*cv*sqrt(Pdrop/Gf);
321
322end
323       
324"Calculate Gf"
325        Gf = rho/rho60F;
326       
327"Calculate Specific Mass"
328        rho = PP.LiquidDensity(Inlet.T,Inlet.P,Inlet.z);
329       
330"Calculate Mass Flow"
331        Qv = Inlet.F*vm;       
332       
333"Calculate Liquid Molar Volume"
334        vm = PP.LiquidVolume(Inlet.T,Inlet.P,Inlet.z);
335       
336switch valve_type # update the valve characteristic !!!!
337        case "linear":
338
339                "Opening Equation"
340                fc = vactual;
341
342        case "parabolic":
343
344                "Opening Equation"
345                fc = vactual^2;
346
347        case "equal":
348
349                "Opening Equation"
350                fc = vactual^2/(2-vactual^4)^(1/2);
351
352        case "quick":
353       
354                "Opening Equation"
355                fc = 10*vactual/sqrt(1+99*vactual^2);
356
357        case "hyperbolic":
358
359                "Opening Equation"
360                fc = 0.1*vactual/sqrt(1-0.99*vactual^2);
361
362        end
363
364end
365
Note: See TracBrowser for help on using the repository browser.