source: trunk/eml/pressure_changers/valve.mso @ 961

Last change on this file since 961 was 920, checked in by Rafael de Pelegrini Soares, 13 years ago

Added color support

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.0 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 920 2010-02-26 17:20:34Z rafael $                                                                       
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 * 'atm' 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
103ATTRIBUTES
104        Pallete = true;
105        Icon    = "icon/Valve";
106        Brief   = "Model of a very simple valve for setting the flow with a controller.";
107        Info    =
108"== ASSUMPTIONS ==
109* nothing happens in this valve
110
111== SET ==
112* MinFlow: the Minimum Flow Allowable in the valve;
113* MaxFlow: the Maximum Flow Allowable in the valve;
114
115== SPECIFY ==
116* the Inlet stream
117* the FlowFraction (the model requires an inlet signal, also you can use a controller for setting the FlowFraction)
118";
119
120PARAMETERS
121        outer PP                as Plugin       (Brief = "External Physical Properties", Type="PP");
122        outer NComp     as Integer      (Brief="Number of Components");
123
124        MinFlow as flow_mol(Brief="Minimum Flow Allowable in the valve", Default=0);
125        MaxFlow as flow_mol(Brief="Maximum Flow Allowable in the valve", Default=1000);
126       
127VARIABLES
128
129in      Inlet                   as stream       (Brief ="Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}",Protected=true);
130out     Outlet                  as stream       (Brief ="Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}",Protected=true);
131in      FlowFraction    as control_signal (Brief ="Flow Signal", PosX=0.5, PosY=0,Protected=true);
132       
133EQUATIONS
134"Overall Molar Balance"
135        Outlet.F = Inlet.F;
136
137"Temperature"
138        Outlet.T = Inlet.T;
139
140"Pressure"
141        Outlet.P = Inlet.P;
142
143"Energy Balance"
144        Outlet.h = Inlet.h;
145
146"Vapour fraction"
147        Outlet.v = Inlet.v;
148
149"Componente Molar Balance"
150        Outlet.z = Inlet.z;
151
152"Flow computation"
153        Outlet.F = MinFlow + FlowFraction*(MaxFlow-MinFlow);
154
155end
156
157Model valve
158
159        ATTRIBUTES
160        Pallete         = true;
161        Icon            = "icon/Valve";
162        Brief   = "Model of a valve.";
163        Info            =
164"== Model of valves ==
165* Linear;
166* Parabolic;
167* Equal;
168* Quick;
169* Hyperbolic.
170       
171== Assumptions ==
172* First Order Dynamic;
173* Only Liquid or Only Vapour;
174* Isentalpic.
175       
176== Specify ==
177* the valve type;
178* the Valve Coefficient (Cv);
179* the valve time constant (Tau).
180";
181
182PARAMETERS
183
184outer PP                        as Plugin       (Brief = "External Physical Properties", Type = "PP");
185outer NComp     as Integer      (Brief = "Number of chemical components", Lower = 1);
186
187        ValveType       as Switcher             (Valid = ["linear", "parabolic", "equal", "quick", "hyperbolic"], Default = "linear");
188        ValidPhases     as Switcher             (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only"], Default="Liquid-Only");
189#       Tau                     as time_sec             (Brief="valve time constant");
190        rho60F                  as dens_mass            (Brief = "Water Mass Density at 60 F",Hidden=true);     
191
192VARIABLES
193        W as flow_mass(DisplayUnit='kg/s');
194        Pdrop                   as press_delta          (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P");
195        Fvol                            as flow_vol                     (Brief = "Volumetric Flow");
196        fc                              as positive                     (Brief = "Opening Function",Hidden=true);
197        Cv                              as Real                                 (Brief="Valve Flow Coefficient", Unit='gal/min/psi^0.5');
198        Cv1                             as Real                                 (Brief="Valve Flow Coefficient", Unit='m^2');
199        Cg                              as Real                                 (Brief="Valve Gas Flow Coefficient", Unit='ft^3/h/psi');
200        C                               as Real                                 (Brief="Liquid-gas Coefficient Ratio", Unit='(ft^3/gal)*(min/h)/(psi^.5)');
201        StemPosition    as fraction                     (Brief = "Actual valve stem position");
202        a as Real;
203        #b as Real (Brief="d", Unit='1/(psi^.5)');
204        vm                              as vol_mol                      (Brief = "Mixture Molar Volume");
205        rho                             as dens_mass            (Brief = "Mixture Mass Density");       
206#       vsp                             as fraction                     (Brief = "Valve stem position",Hidden=true);
207       
208in              Inlet   as stream                       (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}");
209out     Outlet  as streamPH             (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}");
210#in             vsignal as fraction             (Brief = "Flow Signal", PosX=0.5, PosY=0);
211
212SET
213
214        rho60F = 984.252        * 'kg/m^3';
215       
216EQUATIONS
217
218#"First order valve dynamics"
219#       Tau*diff(StemPosition) = vsp-StemPosition;
220
221#"Flow Signal"
222#       vsp = vsignal;
223
224"Pressure Drop"
225        Outlet.P  = Inlet.P - Pdrop;
226
227"Enthalpy Balance"
228        Outlet.h = Inlet.h;
229       
230"Molar Balance"
231        Outlet.F = Inlet.F;
232       
233"Outlet Composition"
234        Outlet.z = Inlet.z;
235       
236        Cv1=Cv*'1/(gal/min/psi^0.5)'*2.3837e-5*'m^2';
237
238switch ValidPhases
239               
240#############################################################
241
242        case "Liquid-Only":
243       
244if Pdrop > 0 * 'atm' then
245
246"Valve Equation - Liquid Flow"
247        Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho);
248        "Liquid-gas Coefficient Ratio"
249        C*Cv=Cg;
250a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P);       
251else
252
253"Valve Equation - Liquid Flow"
254        Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho);
255        "Liquid-gas Coefficient Ratio"
256        C*Cv=Cg;
257a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P);
258end
259       
260"Liquid Mass Density"
261        rho = PP.LiquidDensity(Inlet.T,Inlet.P,Inlet.z);
262
263"Liquid Molar Volume"
264        vm = PP.LiquidVolume(Inlet.T,Inlet.P,Inlet.z);
265       
266
267       
268############################################################
269
270        case "Vapour-Only":
271       
272if Pdrop > 0 * 'atm' then #Update for gas flow !!!!
273       
274"Liquid-gas Coefficient Ratio"
275        C*Cv=Cg;
276        a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P);
277
278        if 1.5708 > a then
279        "Valve Equation - Vapour Flow"
280                #Fvol = fc*Cg*sqrt(Inlet.P/1000*rho60F/rho);####rho60f/rho ok!!!!
281                #Fvol = fc*Cv*sqrt(Pdrop/1000*rho60F/rho);
282                #W = fc*Cv1*sqrt(Pdrop/1000*rho);
283                Fvol = fc*0.13446*'psi^.5'*Cg*sqrt(Inlet.P/1000*rho60F/rho)*sin(a*'rad');
284               
285        else
286        "Valve Equation - Vapour Flow"
287                Fvol = fc*0.13446*Cv*sqrt(Inlet.P*rho60F/rho);
288        end
289else
290
291"Valve Equation - Vapour Flow"
292        Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho);
293
294"Liquid-gas Coefficient Ratio"
295        C*Cv=Cg;
296        a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P);
297end
298       
299"Vapour Mass Density"
300        rho = PP.VapourDensity(Inlet.T,Inlet.P,Inlet.z);
301        #rho=3.708741*'kg/m^3';
302"Vapour Molar Volume"
303        vm = PP.VapourVolume(Inlet.T,Inlet.P,Inlet.z);
304       
305end
306
307######################################################
308
309"Calculate Mass Flow"
310        Fvol = Inlet.F*vm;
311       
312        W=Fvol*rho;
313       
314       
315switch ValveType #Update the valve Type
316       
317        case "linear":
318
319                "Opening Equation"
320                fc = StemPosition;
321
322        case "parabolic":
323
324                "Opening Equation"
325                fc = StemPosition^2;
326
327        case "equal":
328
329                "Opening Equation"
330                fc = StemPosition^2/(2-StemPosition^4)^(1/2);
331
332        case "quick":
333       
334                "Opening Equation"
335                fc = 10*StemPosition/sqrt(1+99*StemPosition^2);
336
337        case "hyperbolic":
338
339                "Opening Equation"
340                fc = 0.1*StemPosition/sqrt(1-0.99*StemPosition^2);
341
342        end
343
344end
345
Note: See TracBrowser for help on using the repository browser.