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

Last change on this file since 777 was 690, checked in by jjunges, 14 years ago

valve gas update

  • 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 690 2008-11-21 17:02:51Z jjunges $                                                                     
18*-------------------------------------------------------------------*#
19
20using "streams";
21       
22#*-------------------------------------------------------------------
23* Model of a valve (simplified)
24*--------------------------------------------------------------------
25*
26* Author: Paula B. Staudt
27*--------------------------------------------------------------------*#
28Model 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
52outer PP as Plugin(Type="PP");
53outer NComp as Integer;
54       
55        VARIABLES
56in      Inlet   as stream       (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}");
57out     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
99end
100
101Model 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
116outer PP as Plugin(Type="PP");
117outer NComp as Integer;
118
119        MinFlow as flow_mol(Default=0);
120        MaxFlow as flow_mol(Default=1000);
121       
122        VARIABLES
123in      Inlet   as stream       (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}");
124out     Outlet  as stream       (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}");
125in      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);
144end
145
146Model 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
171PARAMETERS
172
173outer PP                        as Plugin       (Brief = "External Physical Properties", Type = "PP");
174outer 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
181VARIABLES
182        W as flow_mass(DisplayUnit='kg/s');
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        Cv1                             as Real                                 (Brief="Valve Flow Coefficient", Unit='m^2');
188        Cg                              as Real                                 (Brief="Valve Gas Flow Coefficient", Unit='ft^3/h/psi');
189        C                               as Real                                 (Brief="Liquid-gas Coefficient Ratio", Unit='(ft^3/gal)*(min/h)/(psi^.5)');
190        StemPosition    as fraction                     (Brief = "Actual valve stem position");
191        a as Real;
192        #b as Real (Brief="d", Unit='1/(psi^.5)');
193        vm                              as vol_mol                      (Brief = "Mixture Molar Volume");
194        rho                             as dens_mass            (Brief = "Mixture Mass Density");       
195#       vsp                             as fraction                     (Brief = "Valve stem position",Hidden=true);
196       
197in              Inlet   as stream                       (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}");
198out     Outlet  as streamPH             (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}");
199#in             vsignal as fraction             (Brief = "Flow Signal", PosX=0.5, PosY=0);
200
201SET
202
203        rho60F = 984.252        * 'kg/m^3';
204       
205EQUATIONS
206
207#"First order valve dynamics"
208#       Tau*diff(StemPosition) = vsp-StemPosition;
209
210#"Flow Signal"
211#       vsp = vsignal;
212
213"Pressure Drop"
214        Outlet.P  = Inlet.P - Pdrop;
215
216"Enthalpy Balance"
217        Outlet.h = Inlet.h;
218       
219"Molar Balance"
220        Outlet.F = Inlet.F;
221       
222"Outlet Composition"
223        Outlet.z = Inlet.z;
224       
225        Cv1=Cv*'1/(gal/min/psi^0.5)'*2.3837e-5*'m^2';
226
227switch ValidPhases
228               
229#############################################################
230
231        case "Liquid-Only":
232       
233if Pdrop > 0 then
234
235"Valve Equation - Liquid Flow"
236        Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho);
237        "Liquid-gas Coefficient Ratio"
238        C*Cv=Cg;
239a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P);       
240else
241
242"Valve Equation - Liquid Flow"
243        Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho);
244        "Liquid-gas Coefficient Ratio"
245        C*Cv=Cg;
246a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P);
247end
248       
249"Liquid Mass Density"
250        rho = PP.LiquidDensity(Inlet.T,Inlet.P,Inlet.z);
251
252"Liquid Molar Volume"
253        vm = PP.LiquidVolume(Inlet.T,Inlet.P,Inlet.z);
254       
255
256       
257############################################################
258
259        case "Vapour-Only":
260       
261if Pdrop > 0 then #Update for gas flow !!!!
262       
263"Liquid-gas Coefficient Ratio"
264        C*Cv=Cg;
265        a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P);
266
267        if 1.5708 > a then
268        "Valve Equation - Vapour Flow"
269                #Fvol = fc*Cg*sqrt(Inlet.P/1000*rho60F/rho);####rho60f/rho ok!!!!
270                #Fvol = fc*Cv*sqrt(Pdrop/1000*rho60F/rho);
271                #W = fc*Cv1*sqrt(Pdrop/1000*rho);
272                Fvol = fc*0.13446*'psi^.5'*Cg*sqrt(Inlet.P/1000*rho60F/rho)*sin(a*'rad');
273               
274        else
275        "Valve Equation - Vapour Flow"
276                Fvol = fc*0.13446*Cv*sqrt(Inlet.P*rho60F/rho);
277        end
278else
279
280"Valve Equation - Vapour Flow"
281        Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho);
282
283"Liquid-gas Coefficient Ratio"
284        C*Cv=Cg;
285        a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P);
286end
287       
288"Vapour Mass Density"
289        rho = PP.VapourDensity(Inlet.T,Inlet.P,Inlet.z);
290        #rho=3.708741*'kg/m^3';
291"Vapour Molar Volume"
292        vm = PP.VapourVolume(Inlet.T,Inlet.P,Inlet.z);
293       
294end
295
296######################################################
297
298"Calculate Mass Flow"
299        Fvol = Inlet.F*vm;
300       
301        W=Fvol*rho;
302       
303       
304switch ValveType #Update the valve Type
305       
306        case "linear":
307
308                "Opening Equation"
309                fc = StemPosition;
310
311        case "parabolic":
312
313                "Opening Equation"
314                fc = StemPosition^2;
315
316        case "equal":
317
318                "Opening Equation"
319                fc = StemPosition^2/(2-StemPosition^4)^(1/2);
320
321        case "quick":
322       
323                "Opening Equation"
324                fc = 10*StemPosition/sqrt(1+99*StemPosition^2);
325
326        case "hyperbolic":
327
328                "Opening Equation"
329                fc = 0.1*StemPosition/sqrt(1-0.99*StemPosition^2);
330
331        end
332
333end
334
Note: See TracBrowser for help on using the repository browser.