 Timestamp:
 Apr 16, 2008, 7:50:32 PM (14 years ago)
 Location:
 branches/tests
 Files:

 1 added
 2 edited
Legend:
 Unmodified
 Added
 Removed

branches/tests/eml/pressure_changers/pipe.mso
r343 r504 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) 20022004. 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 * Author: Gerson Balbueno Bicca 16 * $Id: pipe.mso 326 20070817 19:25:59Z bicca $ 17 **# 1 18 2 using "streams"; 3 4 Model props 5 6 ATTRIBUTES 7 Pallete = false; 8 Brief = "System properties for the pipe model"; 9 10 PARAMETERS 11 12 outer N as Integer (Brief = "Number of Profile Intervals", Default = 1, Lower = 1, Upper = 100); 13 outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); 14 15 VARIABLES 16 17 Fw as flow_mass (Brief = "Mass Flow Profile" , Symbol = "F_w"); 18 rho(N+1) as dens_mass (Brief = "Mass Density Profile" , Symbol = "\rho"); 19 mu(N+1) as viscosity (Brief = "Viscosity Profile" , Symbol = "\mu"); 20 Re(N+1) as Real (Brief = "Reynolds Number Profile"); 21 Vel(N+1) as velocity (Brief = "Velocity Profile"); 22 vm(N+1) as vol_mol (Brief = "Mixture Molar Volume Profile"); 23 Lfrac(N+1) as fraction (Brief = "Liquid Fraction Profile"); 24 Vfrac(N+1) as fraction (Brief = "Vapour Fraction Profile"); 25 x(N+1,NComp) as fraction (Brief = "Liquid Molar Fraction"); 26 y(N+1,NComp) as fraction (Brief = "Vapour Molar Fraction"); 27 h(N+1) as enth_mol (Brief = "Stream Enthalpy profile"); 28 29 end 19 30 20 31 Model pipe … … 23 34 Pallete = true; 24 35 Icon = "icon/pipe"; 25 Brief = " Model of a simplepipe";36 Brief = "pipe"; 26 37 Info = 27 "testing a model of pressure drop."; 38 "This distributed model describes the pressure drop of a material stream flowing in a pipe. 39 40 ==Assumptions== 41 *Cross sectional area is constant; 42 *Newtonian fluid; 43 *Steadystate; 44 "; 28 45 29 46 PARAMETERS 30 47 31 outer NComp as Integer (Brief = "Number of chemical components", Lower = 1);32 outer PP as Plugin(Brief = "External Physical Properties",Type="PP");33 34 N as Integer (Brief = "Number of Profile Intervals", Default = 1, Lower = 1, Upper = 300);35 pi as Real (Brief="pi number",Default=3.141592 );48 outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); 49 outer PP as Plugin (Brief = "External Physical Properties",Type="PP"); 50 51 N as Integer (Brief = "Number of Profile Intervals", Default = 1, Lower = 1, Upper = 100); 52 pi as Real (Brief="pi number",Default=3.141592, Symbol = "\pi"); 36 53 g as acceleration (Brief="Acceleration of gravity"); 37 Lpipe as length (Brief="Pipe Length"); 38 Hrise as length (Brief="Pipe Rise"); 39 Dpipe as length (Brief="Pipe Inner Diameter"); 40 Apipe as area (Brief="Pipe Area"); 41 Roughness as length (Brief="Pipe Roughness"); 42 43 FlowRegime as Switcher (Brief="Pipe flow regime ",Valid=["laminar","turbulent"],Default="laminar"); 54 Lpipe as length (Brief="Pipe Length", Symbol = "L_{pipe}"); 55 Hrise as length (Brief="Pipe Rise", Symbol = "H_{rise}"); 56 Dpipe as length (Brief="Pipe Inner Diameter", Symbol = "D_{pipe}"); 57 Apipe as area (Brief="Pipe Area", Symbol = "A_{pipe}"); 58 Roughness as length (Brief="Pipe Roughness", Symbol = "\varepsilon"); 59 M(NComp) as molweight (Brief="Component Mol Weight"); 60 FlowRegime as Switcher (Brief="Pipe flow regime ",Valid=["laminar","turbulent"],Default="laminar"); 61 Thermal as Switcher (Brief="Pipe Thermal Specification ",Valid=["Constant Temperature","Linear Temperature profile"],Default="Constant Temperature"); 62 Toutlet as temperature (Brief = "Outlet Temperature", Symbol = "T_{out}"); 44 63 45 64 SET 46 65 47 g = 1*'ga'; 48 Apipe = 0.25*pi*Dpipe^2; 49 50 SUBMODELS 51 52 in Inlet as stream (Brief = "Inlet Stream" , Symbol = "^in"); 53 out Outlet as streamPH (Brief = "Outlet Stream", Symbol = "^out"); 54 66 g = 1*'ga'; 67 Apipe = 0.25*pi*Dpipe^2; 68 M = PP.MolecularWeight(); 69 55 70 VARIABLES 56 71 72 in Inlet as stream (Brief = "Inlet Stream" ,PosX=0, PosY=0.5225, Symbol = "^{in}"); 73 out Outlet as streamPH (Brief = "Outlet Stream",PosX=1, PosY=0.5225, Symbol = "^{out}"); 74 Properties as props (Brief = "Pipe Properties", Symbol = " "); 75 Tincr(N+1) as temperature (Brief = "Temperature Profile", Symbol = "T_{incr}"); 76 57 77 Pdrop as pressure (Brief = "Total Pressure Drop", DisplayUnit = 'kPa',Lower = 0, Symbol = "\Delta P_{drop}"); 78 dPfricTotal as pressure (Brief = "Total Friction Pressure Drop", DisplayUnit = 'kPa',Lower = 0, Symbol = "\Delta Ptotal_{fric}"); 79 dPelvTotal as pressure (Brief = "Total Elevation Pressure Drop", DisplayUnit = 'kPa',Lower = 0 , Symbol = "\Delta Ptotal_{elev}"); 80 dPaccTotal as pressure (Brief = "Total Acceleration Pressure Drop", DisplayUnit = 'kPa',Lower = 0 , Symbol = "\Delta Ptotal_{acc}"); 58 81 dPfric(N+1) as pressure (Brief = "Friction Pressure Drop", DisplayUnit = 'kPa',Lower = 0, Symbol = "\Delta P_{fric}"); 59 82 dPelv(N+1) as pressure (Brief = "Elevation Pressure Drop", DisplayUnit = 'kPa',Lower = 0 , Symbol = "\Delta P_{elev}"); 60 Pincr(N+1) as pressure (Brief = "Pressure Profile", DisplayUnit = 'kPa' , Symbol = "P_{incr}"); 61 Lincr(N+1) as length (Brief = "Length Points", Symbol = "L_{incr}"); 62 Vel(N+1) as velocity (Brief = "Velocity Profile"); 63 vm(N+1) as vol_mol (Brief = "Mixture Molar Volume Profile"); 83 dPacc(N+1) as pressure (Brief = "Acceleration Pressure Drop", DisplayUnit = 'kPa',Lower = 0 , Symbol = "\Delta P_{acc}"); 84 Pincr(N+1) as pressure (Brief = "Pressure Profile", DisplayUnit = 'kPa' , Symbol = "P_{incr}"); 85 Lincr(N+1) as length (Brief = "Length Points", Symbol = "L_{incr}"); 64 86 f(N+1) as fricfactor (Brief = "Friction Factor"); 65 87 66 rho(N+1) as dens_mass (Brief = "Mass Density Profile" , Symbol = "\rho");67 mu(N+1) as viscosity (Brief = "Viscosity Profile" , Symbol = "\mu");68 Re(N+1) as Real (Brief = "Reynolds Number Profile");69 70 88 EQUATIONS 71 89 90 "Mass Flow" 91 Properties.Fw = sum(M*Inlet.z)*Inlet.F; 92 93 "Inlet Boudary for Temperature Profile" 94 Tincr(1) = Inlet.T; 95 96 "Outlet Boundary for Temperature Profile" 97 Tincr(N+1) = Outlet.T; 98 72 99 "Inlet Boudary for Pressure Profile" 73 100 Pincr(1) = Inlet.P; … … 77 104 78 105 "Total Pressure Drop" 79 Pdrop = dPfric(N+1) + dPelv(N+1); 80 106 Pdrop = dPfricTotal+ dPelvTotal + dPaccTotal; 107 108 "Total Pressure Drop for Friction" 109 dPfricTotal = dPfric(N+1); 110 111 "Total Pressure Drop for Elevation" 112 dPelvTotal = dPelv(N+1); 113 114 "Total Pressure Drop for Acceleration " 115 dPaccTotal= sum(dPacc); 116 81 117 "Pipe Initial Length" 82 118 Lincr(1) = 0*'m'; … … 85 121 Outlet.z = Inlet.z; 86 122 87 "Outlet Temperature"88 Outlet.T = Inlet.T;89 90 123 "Molar Balance" 91 124 Outlet.F = Inlet.F; 92 125 126 "Velocity" 127 Properties.Vel(1:N+1) = Inlet.F/Apipe*Properties.vm(1:N+1); 128 129 "Reynolds Number" 130 Properties.Re(1:N+1) = Properties.rho(1:N+1)*Properties.Vel(1:N+1)*Dpipe/Properties.mu(1:N+1); 131 132 "Incremental Friction Pressure Drop" 133 dPfric(1:N+1) = (2*f(1:N+1)*Lincr(1:N+1)*Properties.rho(1:N+1)*Properties.Vel(1:N+1)^2/Dpipe); 134 135 "Incremental Acceleration Pressure Drop at Pipe Entry" 136 dPacc(1) = 0*'Pa'; 137 138 if Hrise > Lpipe 139 140 then 141 "Incremental Elevation Pressure Drop Constraint" 142 dPelv(1:N+1) = Properties.rho(1:N+1)*g*Lincr(1:N+1); 143 144 else 145 "Incremental Elevation Pressure Drop" 146 dPelv(1:N+1) = Properties.rho(1:N+1)*g*Lincr(1:N+1)*(Hrise/abs(Lpipe)); 147 148 end 149 93 150 for i in [1:N+1] 94 151 95 "Velocity" 96 Vel(i) = Inlet.F/Apipe*vm(i); 97 98 "Reynolds Number" 99 Re(i) = rho(i)*Vel(i)*Dpipe/mu(i); 152 "Flash Calculation" 153 [Properties.Vfrac(i), Properties.x(i,:), Properties.y(i,:)] = PP.FlashPH(Pincr(i), Properties.h(i), Inlet.z); 154 155 "Liquid Fraction" 156 Properties.Lfrac(i) = 1Properties.Vfrac(i); 157 158 "Enthalpy" 159 Properties.h(i) = (1Properties.Vfrac(i))*PP.LiquidEnthalpy(Tincr(i),Pincr(i),Properties.x(i,:)) + Properties.Vfrac(i)*PP.VapourEnthalpy(Tincr(i),Pincr(i),Properties.y(i,:)); 100 160 101 161 "Density" 102 rho(i) = PP.LiquidDensity(Inlet.T,Pincr(i),Inlet.z);162 Properties.rho(i) = (1Properties.Vfrac(i))*PP.LiquidDensity(Tincr(i),Pincr(i),Properties.x(i,:))+Properties.Vfrac(i)*PP.VapourDensity(Tincr(i),Pincr(i),Properties.y(i,:)); 103 163 104 164 "Viscosiyty" 105 mu(i) = PP.LiquidViscosity(Inlet.T,Pincr(i),Inlet.z);165 Properties.mu(i) = (1Properties.Vfrac(i))*PP.LiquidViscosity(Tincr(i),Pincr(i),Properties.x(i,:))+Properties.Vfrac(i)*PP.VapourViscosity(Tincr(i),Pincr(i),Properties.y(i,:)); 106 166 107 167 "Molar Volume" 108 vm(i) = PP.LiquidVolume(Inlet.T,Pincr(i),Inlet.z); 109 110 "Incremental Friction Pressure Drop" 111 dPfric(i) = (2*f(i)*Lincr(i)*rho(i)*Vel(i)^2/Dpipe); 112 113 "Incremental Elevation Pressure Drop" 114 dPelv(i) = rho(i)*g*Lincr(i)*(Hrise/Lpipe); 168 Properties.vm(i) = (1Properties.Vfrac(i))*PP.LiquidVolume(Tincr(i),Pincr(i),Properties.x(i,:))+Properties.Vfrac(i)*PP.VapourVolume(Tincr(i),Pincr(i),Properties.y(i,:)); 115 169 116 170 end … … 119 173 120 174 "Outlet Pressure" 121 Pincr(i+1) = Pincr(1)  (dPfric(i+1) + dPelv(i+1)); 122 175 Pincr(i+1) = Pincr(1)  (dPfric(i+1) + dPelv(i+1) + dPacc(i+1)); 176 177 "Incremental Acceleration Pressure Drop" 178 #dPacc(i+1) = (Properties.Fw/Apipe)^2*(1/Properties.rho(i+1)1/Properties.rho(i)); 179 dPacc(i+1) = dPacc(1); 180 123 181 "Incremental Length" 124 Lincr(i+1) = i*Lpipe/N; 182 Lincr(i+1) = i*abs(Lpipe)/N; 183 184 end 185 186 for i in [1:N] 187 188 switch Thermal 189 190 case "Constant Temperature": 191 "Outlet Temperature" 192 Tincr(i+1) = Inlet.T; 193 194 case "Linear Temperature profile": 195 "Outlet Temperature" 196 Toutlet  Tincr(1) = Lpipe*((Tincr(i+1)Tincr(i))/(Lincr(i+1)Lincr(i))); 197 198 end 125 199 126 200 end … … 133 207 134 208 "Friction Factor for Pressure Drop  laminar Flow" 135 f(i)* Re(i) = 16;136 137 when Re(i) > 2300 switchto "turbulent";209 f(i)*Properties.Re(i) = 16; 210 211 when Properties.Re(i) > 2300 switchto "turbulent"; 138 212 139 213 case "turbulent": 140 214 141 215 "Friction Factor for Pressure Drop  Turbulent Flow" 142 1/sqrt(f(i))= 4*log(Roughness/Dpipe/3.7+1.255/ Re(i)/sqrt(f(i)));143 144 when Re(i) <= 2300 switchto "laminar";145 146 end 147 148 end 149 150 end 216 1/sqrt(f(i))= 4*log(Roughness/Dpipe/3.7+1.255/Properties.Re(i)/sqrt(f(i))); 217 218 when Properties.Re(i) <= 2300 switchto "laminar"; 219 220 end 221 222 end 223 224 end 
branches/tests/sample/pressure_changers/sample_pipe.mso
r343 r504 13 13 * available at http://www.enq.ufrgs.br/alsoc. 14 14 * 15 * This sample file needs VRTherm DEMO(www.vrtech.com.br) to run.15 * This sample file needs VRTherm (www.vrtech.com.br) to run. 16 16 * 17 17 * … … 28 28 PP as Plugin(Brief="Physical Properties", 29 29 Type="PP", 30 Components = [ "water" ],30 Components = [ "water" ], 31 31 LiquidModel = "PR", 32 32 VapourModel = "PR" … … 89 89 PP as Plugin(Brief="Physical Properties", 90 90 Type="PP", 91 Components = [ " water"],92 LiquidModel = "PR",93 VapourModel = "PR"91 Components = [ "isobutane", "benzene"], 92 LiquidModel = "PR", 93 VapourModel = "PR" 94 94 ); 95 95 96 NComp as Integer; 96 97 … … 98 99 Tube as pipe; 99 100 Feed as simple_source; 101 Storage as simple_sink; 100 102 101 103 SET 102 104 NComp = PP.NumberOfComponents; 103 Tube.N = 100; 105 Tube.N = 10; 106 107 #Tube.Thermal ="Linear Temperature profile"; 108 #Tube.Toutlet = (90+273.15) * 'K'; 109 110 Tube.Thermal ="Constant Temperature"; 104 111 105 112 CONNECTIONS 106 113 Feed.Outlet to Tube.Inlet; 114 Tube.Outlet to Storage.Inlet; 107 115 108 116 SPECIFY 109 Feed.Outlet.F = 10 * ' mol/s';110 Feed.Outlet.P = 150 * 'kPa';111 Feed.Outlet.T = 281.75* 'K';112 Feed.Outlet.z = [ 1];117 Feed.Outlet.F = 10 * 'kmol/h'; 118 Feed.Outlet.P = 3* 'atm'; 119 Feed.Outlet.T = (110+273.15) * 'K'; 120 Feed.Outlet.z = [0.5,0.5]; 113 121 114 122 SET 115 Tube.Lpipe = 30*'m';116 Tube.Hrise = 5*'m';123 Tube.Lpipe = 5*'m'; 124 Tube.Hrise = 0*'m'; 117 125 118 126 … … 123 131 OPTIONS 124 132 Dynamic = false; 125 NLASolver(126 RelativeAccuracy = 1e6127 );128 133 end
Note: See TracChangeset
for help on using the changeset viewer.