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

Last change on this file since 577 was 567, checked in by Rafael de Pelegrini Soares, 15 years ago

valve_flow model simplified and now the Sample_Flowsheet is running fast

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.3 KB
RevLine 
[75]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*---------------------------------------------------------------------
[98]16* Author: Estefane Horn, Núbia do Carmo Ferreira
[75]17*$Id: valve.mso 567 2008-07-24 13:45:34Z rafael $                                                                       
18*-------------------------------------------------------------------*#
[57]19
[325]20using "streams";
[57]21       
22
[325]23Model valve
[277]24        ATTRIBUTES
25        Pallete         = true;
[305]26        Icon            = "icon/Valve";
[277]27        Brief           = "Model of a valve.";
28        Info            =
[353]29"== Model of valves ==
30* Linear;
31* Parabolic;
32* Equal;
33* Quick;
34* Hyperbolic.
[57]35       
[353]36== Assumptions ==
37* Steady State;
38* Liquid;
39* Isentalpic.
[277]40       
[353]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";
[277]48               
[57]49        PARAMETERS
[206]50        valve_type as Switcher (Valid = ["linear", "parabolic", "equal", "quick", "hyperbolic"], Default = "linear");
[204]51outer PP                as Plugin       (Brief = "External Physical Properties", Type = "PP");
52outer NComp     as Integer      (Brief = "Number of chemical components", Lower = 1);
[57]53        rho60F  as dens_mass;
54
55        VARIABLES
[372]56        Pratio  as positive                     (Brief = "Pressure Ratio", Symbol ="P_{ratio}");       
57        Pdrop   as press_delta          (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P");
[57]58        Qv              as flow_vol                     (Brief = "Volumetric Flow");
59        fc              as positive                     (Brief = "Opening Function");
[176]60        cv              as positive                     (Brief = "Valve Coefficient", Unit = 'm^3/h/kPa^0.5');
[57]61        Gf              as positive                     (Brief = "Specific Gravity");
62        rho     as dens_mass;   
[196]63        vm              as vol_mol                      (Brief = "Mixture Molar Volume");       
[204]64        x               as fraction             (Brief = "Opening");
[351]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}");
[57]67       
68        SET
[204]69        rho60F = 999.02 * 'kg/m^3';
[57]70       
71        EQUATIONS
[372]72        "Pressure Drop"
73        Outlet.P  = Inlet.P - Pdrop;
74
75        "Pressure Ratio"
76        Outlet.P = Inlet.P * Pratio;
[57]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
[372]87        if Pdrop > 0 then
[109]88                "Valve Equation - Flow"
[372]89                Qv = fc*cv*sqrt(Pdrop/Gf);     
[109]90        else
91                "Valve Equation - Closed"
[176]92                Qv = 0 * 'm^3/h';
[109]93        end
[57]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       
[206]107        switch valve_type
108        case "linear":
[57]109
[204]110                "Opening Equation"
111                fc = x;
[57]112
[206]113        case "parabolic":
114
[204]115                "Opening Equation"
116                fc = x^2;
[57]117
[206]118        case "equal":
[57]119
[204]120                "Opening Equation"
121                fc = x^2/(2-x^4)^(1/2);
[57]122
[206]123        case "quick":
[57]124       
[204]125                "Opening Equation"
126                fc = 10*x/sqrt(1+99*x^2);
[57]127
[206]128        case "hyperbolic":
[57]129
[204]130                "Opening Equation"
131                fc = 0.1*x/sqrt(1-0.99*x^2);
[57]132
[204]133        end
[57]134end
135
[1]136#*-------------------------------------------------------------------
[75]137* Model of a valve (simplified)
[1]138*--------------------------------------------------------------------
139*
140* Author: Paula B. Staudt
141*--------------------------------------------------------------------*#
[204]142Model valve_simplified
[277]143        ATTRIBUTES
144        Pallete         = true;
[305]145        Icon            = "icon/Valve";
[277]146        Brief           = "Model of a very simple valve - used in distillation column models.";
147        Info            =
[353]148"== Assumptions ==
149* no flashing liquid in the valve;
150* the flow in the valve is adiabatic;
151* dynamics in the valve are neglected;
152* linear flow type.
[277]153       
[353]154== Specify ==
155* the inlet stream
156* the plug position (x) OR outlet temperature (Outlet.T) OR outlet pressure (Outlet.P)
[277]157       
158        OR             
159       
[353]160* the inlet stream excluding its flow (Inlet.F)
161* the outlet pressure (Outlet.P) OR outlet flow (Outlet.F)
162* the plug position (x)
163";
[204]164
[1]165        PARAMETERS
[270]166outer PP as Plugin(Type="PP");
[176]167outer NComp as Integer;
[1]168       
169        VARIABLES
[351]170in      Inlet   as stream       (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}");
171out     Outlet  as streamPH     (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}");
[1]172        x as fraction (Brief="Plug Position");
173        rho as dens_mass (Brief="Fluid Density", Default=1e3);
[37]174        v as vol_mol (Brief="Specific volume", Default=1e3);
[372]175        Pdrop     as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P");
176        Pratio  as positive     (Brief = "Pressure Ratio", Symbol ="P_{ratio}");       
[1]177
178        PARAMETERS
179        rho_ref as dens_mass (Brief="Reference Density", Default=1e4);
[176]180        k as Real (Brief="Valve Constant", Unit='gal/min/psi^0.5');
[1]181
182        EQUATIONS
[372]183        "Overall Molar Balance"
[1]184        Inlet.F = Outlet.F;
[372]185       
186        "Componente Molar Balance"
[1]187        Inlet.z = Outlet.z;
188       
189        "Energy Balance"
190        Inlet.h = Outlet.h;
191
[372]192        "Pressure Drop"
193        Outlet.P  = Inlet.P - Pdrop;
194
195        "Pressure Ratio"
196        Outlet.P = Inlet.P * Pratio;
197
[1]198        "Density"
199        rho = Inlet.v*PP.VapourDensity((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z) +
200                (1-Inlet.v)*PP.LiquidDensity((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z);
201
[37]202        "Volume"
203        v = Inlet.v*PP.VapourVolume((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z) +
204                (1-Inlet.v)*PP.LiquidVolume((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z);
205
[372]206        if Pdrop > 0 then
[109]207                "Flow"
[372]208                Outlet.F * v = k*x*sqrt(Pdrop * rho_ref / rho ) ;
[109]209        else
210                "Closed"
[176]211                Outlet.F = 0 * 'kmol/h';
[109]212        end
[1]213end
[558]214
215
216Model valve_flow
217        ATTRIBUTES
218        Pallete         = true;
219        Icon            = "icon/Valve";
[567]220        Brief           = "Model of a very simple valve for setting the flow with a controller.";
[558]221        Info            =
222"== Assumptions ==
[567]223* nothing happens in this valve
[558]224       
225== Specify ==
226* the inlet stream
[567]227* the flow fraction
[558]228";
229
230        PARAMETERS
231outer PP as Plugin(Type="PP");
232outer NComp as Integer;
233
234        MinFlow as flow_mol(Default=0);
235        MaxFlow as flow_mol(Default=1000);
236       
237        VARIABLES
238in      Inlet   as stream       (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}");
[567]239out     Outlet  as stream       (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}");
[558]240in      FlowFraction as fraction (Brief="Flow Signal", PosX=0.5, PosY=0);
241       
242        EQUATIONS
243        "Overall Molar Balance"
[567]244        Outlet.F = Inlet.F;
245        "Temperature"
246        Outlet.T = Inlet.T;
247        "Pressure"
248        Outlet.P = Inlet.P;
[558]249        "Energy Balance"
[567]250        Outlet.h = Inlet.h;
251        "Vapour fraction"
252        Outlet.v = Inlet.v;
[558]253
[567]254        "Componente Molar Balance"
255        Outlet.z = Inlet.z;
[558]256
[567]257        "Flow computation"
[558]258        Outlet.F = MinFlow + FlowFraction*(MaxFlow-MinFlow);
259end
260
Note: See TracBrowser for help on using the repository browser.