source: branches/newlanguage/eml/pressure_changers/valve.mso @ 204

Last change on this file since 204 was 204, checked in by nubinha, 16 years ago

Changes in the valve models using switch

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.8 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* Model of valves:
17*
18*       - Linear
19*       - Parabolic
20*       - Equal
21*       - Quick
22*       - Hyperbolic
23*       - valve_simplified: a very simple model
24*
25*--------------------------------------------------------------------
26*       - Assumptions
27*               * Steady State
28*               * Isentalpic
29*               * Liquid
30*
31*---------------------------------------------------------------------
32* Author: Estefane Horn, Núbia do Carmo Ferreira
33*$Id: valve.mso 204 2007-03-14 19:09:38Z nubinha $                                                                     
34*-------------------------------------------------------------------*#
35
36using "streams";
37using "pressure_changers/flux_machine_basic";
38       
39
40Model valve as flux_machine_basic_PH
41       
42        PARAMETERS
43        Valve_Type as Switcher (Valid = ["valve_linear", "valve_parabolic", "valve_equal", "valve_quick", "valve_hyperbolic"], Default = "valve_linear");
44outer PP                as Plugin       (Brief = "External Physical Properties", Type = "PP");
45outer NComp     as Integer      (Brief = "Number of chemical components", Lower = 1);
46        rho60F  as dens_mass;
47
48        VARIABLES
49        Pdiff   as press_delta          (Brief = "Pressure Increase");
50        Qv              as flow_vol                     (Brief = "Volumetric Flow");
51        fc              as positive                     (Brief = "Opening Function");
52        cv              as positive                     (Brief = "Valve Coefficient", Unit = 'm^3/h/kPa^0.5');
53        Gf              as positive                     (Brief = "Specific Gravity");
54        rho     as dens_mass;   
55        vm              as vol_mol                      (Brief = "Mixture Molar Volume");       
56        x               as fraction             (Brief = "Opening");
57       
58        SET
59        rho60F = 999.02 * 'kg/m^3';
60       
61        EQUATIONS
62        "Calculate Outlet Stream Pressure"
63        Inlet.P - Outlet.P = Pdiff;
64       
65        "Enthalpy Balance"
66        Outlet.h = Inlet.h;
67       
68        "Molar Balance"
69        Outlet.F = Inlet.F;
70       
71        "Calculate Outlet Composition"
72        Outlet.z = Inlet.z;
73
74        if Pdiff > 0 then
75                "Valve Equation - Flow"
76                Qv = fc*cv*sqrt(Pdiff/Gf);     
77        else
78                "Valve Equation - Closed"
79                Qv = 0 * 'm^3/h';
80        end
81       
82        "Calculate Gf"
83        Gf = rho/rho60F;
84       
85        "Calculate Specific Mass"
86        rho = PP.LiquidDensity(Inlet.T,Inlet.P,Inlet.z);
87       
88        "Calculate Mass Flow"
89        Qv = Inlet.F*vm;       
90       
91        "Calculate Liquid Molar Volume"
92        vm = PP.LiquidVolume(Inlet.T,Inlet.P,Inlet.z);
93       
94        switch Valve_Type
95        case "valve_linear":
96
97                       
98                "Opening Equation"
99                fc = x;
100
101        case "valve_parabolic":
102       
103       
104                "Opening Equation"
105                fc = x^2;
106
107
108        case "valve_equal":
109
110                       
111                "Opening Equation"
112                fc = x^2/(2-x^4)^(1/2);
113
114
115        case "valve_quick":
116       
117                       
118                "Opening Equation"
119                fc = 10*x/sqrt(1+99*x^2);
120
121
122        case "valve_hyperbolic":
123
124                       
125                "Opening Equation"
126                fc = 0.1*x/sqrt(1-0.99*x^2);
127
128        end
129end
130
131#*-------------------------------------------------------------------
132* Model of a valve (simplified)
133*--------------------------------------------------------------------
134*
135*       Streams:
136*               * an  inlet stream
137*               * an  outlet stream
138*
139*       Assumptions:
140*               * no flashing liquid in the valve
141*               * the flow in the valve is adiabatic
142*               * dynamics in the valve are neglected
143*               * linear flow type
144*
145*       Specify:
146*               * the inlet stream
147*               * one of: plug position (x), outlet temperature (Outlet.T) or
148*                                                               outlet pressure (Outlet.P)
149*       or             
150*               * the inlet stream excluding its flow (Inlet.F)
151*               * the outlet pressure (Outlet.P) OR outlet flow (Outlet.F)
152*               * the plug position (x)
153*
154*
155*----------------------------------------------------------------------
156* Author: Paula B. Staudt
157*--------------------------------------------------------------------*#
158Model valve_simplified
159
160        PARAMETERS
161outer PP as Plugin;
162outer NComp as Integer;
163       
164        VARIABLES
165in      Inlet as stream;
166out     Outlet as streamPH;
167        x as fraction (Brief="Plug Position");
168        rho as dens_mass (Brief="Fluid Density", Default=1e3);
169        v as vol_mol (Brief="Specific volume", Default=1e3);
170
171        PARAMETERS
172        rho_ref as dens_mass (Brief="Reference Density", Default=1e4);
173        k as Real (Brief="Valve Constant", Unit='gal/min/psi^0.5');
174
175        EQUATIONS
176        "Molar Balance"
177        Inlet.F = Outlet.F;
178        Inlet.z = Outlet.z;
179       
180        "Energy Balance"
181        Inlet.h = Outlet.h;
182
183        "Vapourisation Fraction"
184        Outlet.v = Inlet.v;
185       
186        "Density"
187        rho = Inlet.v*PP.VapourDensity((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z) +
188                (1-Inlet.v)*PP.LiquidDensity((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z);
189
190        "Volume"
191        v = Inlet.v*PP.VapourVolume((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z) +
192                (1-Inlet.v)*PP.LiquidVolume((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z);
193
194        if Inlet.P > Outlet.P then
195                "Flow"
196                Outlet.F * v = k*x*sqrt((Inlet.P - Outlet.P)*rho_ref / rho ) ;
197        else
198                "Closed"
199                Outlet.F = 0 * 'kmol/h';
200        end
201end
Note: See TracBrowser for help on using the repository browser.