source: branches/gui/eml/stage_separators/tank.mso @ 795

Last change on this file since 795 was 795, checked in by gerson bicca, 13 years ago

updated tank model (vertical/horizontal orientation with heads flat,elliptical or hemispherical)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 15.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* Author: Paula B. Staudt
16* $Id: tank.mso 795 2009-07-18 20:08:06Z bicca $
17*--------------------------------------------------------------------*#
18
19using "streams";
20
21Model tank
22        ATTRIBUTES
23        Pallete         = true;
24        Icon            = "icon/Tank";
25        Brief           = "Model of a cylindrical tank.";
26        Info            =
27"== Specify ==
28* the Inlet stream;
29* the outlet flow;
30* the InletQ (requires an energy source).
31
32== Initial Conditions ==
33* the tank initial temperature;
34* the tank initial level;
35* the tank initial composition.
36";
37
38PARAMETERS
39        outer PP                as Plugin               (Brief = "External Physical Properties", Type="PP");
40        outer NComp     as Integer;
41       
42        pi                      as positive     (Brief="Pi value", Default=3.141593,Hidden=true);
43        Diameter                as length       (Brief="Tank internal Diameter",Default=1.5);
44        Across                  as area         (Brief="Tank cross section area", Hidden=true);
45        L                       as length       (Brief="Tank length",Default=5);
46
47       
48        Initial_Level                           as length               (Brief="Initial Level of the Tank",Default=1);
49        Initial_Temperature                     as temperature  (Brief="Initial Temperature of Liquid",Default=300);
50        Initial_Composition(NComp)      as positive     (Brief="Initial Liquid Composition",Lower=1E-8, Default=0.10);
51
52SET
53
54        Across = 0.25*pi*(Diameter)^2;
55       
56VARIABLES
57in      Inlet           as stream                       (Brief = "Inlet stream", PosX=0.3037, PosY=0, Symbol="_{in}");
58out     Outlet          as liquid_stream        (Brief = "Outlet liquid stream", PosX=1, PosY=1, Symbol="_{out}");
59in      InletQ          as power                        (Brief="Rate of heat supply", PosX=1, PosY=0.7859, Symbol="_{in}",Protected=true);
60        Vtotal          as volume                       (Brief="Tank total volume",Protected=true);
61        Vfilled         as volume                       (Brief="Tank volume content",Protected=true);
62        Level           as length                       (Brief="Tank level",Protected=true);
63        E                       as energy                       (Brief="Total Energy Holdup on tank",Protected=true);
64        vL                      as volume_mol           (Brief="Liquid Molar Volume",Protected=true);
65        M(NComp)        as mol                          (Brief="Molar Holdup in the tank",Protected=true);
66
67INITIAL
68
69"Initial Level"
70        Level = Initial_Level;
71
72"Initial Liquid Temperature"   
73        Outlet.T = Initial_Temperature;
74
75"Initial Liquid Composition"   
76        Outlet.z(1:NComp-1) = Initial_Composition(1:NComp-1)/sum(Initial_Composition);
77
78EQUATIONS
79
80"Tank total volume"
81        Vtotal = Across*L;
82
83"Mass balance"
84        diff(M) = Inlet.F*Inlet.z - Outlet.F*Outlet.z;
85
86"Energy balance"
87        diff(E) = Inlet.F*Inlet.h - Outlet.F*Outlet.h + InletQ;
88
89"Energy Holdup"
90        E = sum(M)*Outlet.h;
91
92"Mechanical Equilibrium"
93        Inlet.P = Outlet.P;
94
95"Liquid Volume"
96        vL = PP.LiquidVolume(Outlet.T, Outlet.P, Outlet.z);
97
98"Composition"
99        M = Outlet.z*sum(M);
100
101"Level of liquid phase"
102        Level = sum(M)*vL/Across;
103
104"Volume Filled of liquid phase"
105        Vfilled = Level*Across;
106       
107end
108
109Model TankVL
110
111ATTRIBUTES
112        Pallete         = true;
113        Icon            = "icon/TankVL";
114        Brief           = "Model of a Tank With Thermodynamic Equilibrium.";
115        Info            =
116"== ASSUMPTIONS ==
117* perfect mixing of both phases;
118* thermodynamics equilibrium.
119
120== SET ==
121*Orientation: vessel position - vertical or horizontal;
122*Heads (bottom and top heads are identical)
123**elliptical: 2:1 elliptical heads (25% of vessel diameter);
124**hemispherical: hemispherical heads (50% of vessel diameter);
125**flat: flat heads (0% of vessel diameter);
126*Diameter: Vessel diameter;
127*Lenght: Side length of the cylinder shell;
128       
129== SPECIFY ==
130* the Inlet stream;
131* the outlet flows: OutletVapour.F and OutletLiquid.F;
132* the InletQ (the model requires an energy stream, also you can use a controller for setting the heat duty using the heat_flow model).
133
134== OPTIONAL ==
135* the TankVL model has three control ports
136** TI OutletLiquid Temperature Indicator;
137** PI OutletLiquid Pressure Indicator;
138** LI Level Indicator;
139
140== INITIAL CONDITIONS ==
141* Initial_Temperature :  the Tank temperature (OutletLiquid.T);
142* Initial_Level : the Tank liquid level (Level);
143* Initial_Composition : (NoComps) OutletLiquid compositions.
144";
145       
146PARAMETERS
147outer PP                as Plugin       (Brief = "External Physical Properties", Type="PP");
148outer NComp     as Integer      (Brief = "Number of components", Lower = 1);
149
150        Mw(NComp)               as molweight    (Brief="Mol Weight", Hidden=true);
151        pi                      as positive             (Brief="Pi value", Default=3.141593,Hidden=true, Symbol="\pi");
152       
153        Orientation     as Switcher     (Valid=["vertical","horizontal"],Default="vertical");
154        Heads                   as Switcher     (Valid=["elliptical","hemispherical","flat"],Default="flat");
155        Diameter                as length               (Brief="Vessel diameter", Symbol="D_{i}");
156        Lenght                  as length               (Brief="Side length of the cylinder shell", Symbol="L_{vessel}");
157       
158        Vhead_elliptical                as volume               (Brief="Elliptical Head Total Volume",Hidden=true, Symbol="V_{head}^{elliptical}");
159        Vhead_hemispherical     as volume               (Brief="Hemispherical Head Total Volume",Hidden=true, Symbol="V_{head}^{hemispherical}");
160        Vcylinder                               as volume               (Brief="Cylinder Total Volume",Hidden=true, Symbol="V_{cylinder}");
161        radius                                  as length               (Brief="Vessel radius",Hidden=true, Symbol="R_{cylinder}");
162       
163        Levelpercent_Initial                    as positive     (Brief="Initial liquid height in Percent", Default = 0.70);
164        Temperature_Initial                             as temperature  (Brief="Initial Liquid Temperature", Default = 330);
165        Composition_Initial(NComp)              as fraction             (Brief="Initial Composition", Default = 0.10);
166
167SET
168
169        Mw=PP.MolecularWeight();
170
171        Vhead_elliptical        = (pi*Diameter^3)/12;
172        Vhead_hemispherical = (pi*Diameter^3)/6;
173        Vcylinder = 0.25*(pi*Diameter^2)*Lenght;
174        radius = 0.5*Diameter;
175
176VARIABLES
177
178in      Inlet                   as stream                       (Brief="Feed Stream", PosX=0.22, PosY=0, Symbol="_{in}");
179out     OutletLiquid    as liquid_stream        (Brief="Liquid outlet stream", PosX=0.43, PosY=1, Symbol="_{out}^{Liquid}");
180out     OutletVapour    as vapour_stream        (Brief="Vapour outlet stream", PosX=0.68, PosY=0, Symbol="_{out}^{Vapour}");
181in      InletQ                  as power                        (Brief="Heat Duty", PosX=0.735, PosY=1, Protected =true,Symbol="Q_{in}");
182
183        Vtotal                  as volume                       (Brief="Vessel total volume",Protected=true, Symbol="V_{total}");
184        Vfilled                 as volume                       (Brief="Vessel volume content",Protected=true, Symbol="V_{filled}");
185
186        TotalHoldup(NComp)              as mol  (Brief="Molar Holdup in the Vessel", Protected=true);
187        LiquidHoldup                    as mol  (Brief="Molar liquid holdup", Protected=true);
188        VapourHoldup                    as mol  (Brief="Molar vapour holdup", Protected=true);
189       
190        E                       as energy               (Brief="Total Energy Holdup in the Vessel", Protected=true);
191        vL                      as volume_mol   (Brief="Liquid Molar Volume", Protected=true);
192        vV                      as volume_mol   (Brief="Vapour Molar volume", Protected=true);
193        Level           as length               (Brief="liquid height", Protected=true);
194        Across          as area                 (Brief="Vessel cylinder shell Cross section area", Hidden=true, Symbol="A_{cross}");
195        vfrac           as positive     (Brief="Vapourization fraction", Symbol="\phi", Protected=true);
196        Pratio          as positive             (Brief = "Pressure Ratio", Symbol ="P_{ratio}", Protected=true);       
197        Pdrop           as press_delta  (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P", Protected=true);
198
199out     TI as control_signal    (Brief="Temperature Indicator", PosX=0.525, PosY=0, Protected=true);
200out     PI as control_signal    (Brief="Pressure Indicator", PosX=0.368, PosY=0, Protected=true);
201out     LI as control_signal    (Brief="Level Indicator", PosX=1, PosY=0.6, Protected=true);
202
203INITIAL
204
205"Initial level Percent"
206        LI = Levelpercent_Initial;
207       
208"Initial Outlet Liquid Temperature"
209        OutletLiquid.T = Temperature_Initial;
210       
211"Initial Outlet Liquid Composition Normalized"
212        OutletLiquid.z(1:NComp - 1) = Composition_Initial(1:NComp - 1)/sum(Composition_Initial);
213
214EQUATIONS
215
216switch Orientation
217
218case "vertical":
219
220"Vessel Cross Section Area"
221        Across = 0.25*(pi*Diameter^2);
222
223switch Heads
224
225case "elliptical":
226
227"Vessel Total Volume"
228        Vtotal = Vhead_elliptical +     Vcylinder;
229
230if Level < 0.25*Diameter then
231
232"Vessel Filled Volume"
233        Vfilled = 0.25*pi*(((Diameter*Level)/(0.25*Diameter))^2)*(0.25*Diameter-Level/3);
234
235else
236
237"Vessel Filled Volume"
238        Vfilled = 0.25*pi*(Diameter^2)*(Level - 0.25*Diameter/3);
239
240end
241
242case "hemispherical":
243
244"Vessel Total Volume"
245        Vtotal = Vhead_hemispherical + Vcylinder;
246
247if Level < 0.5*Diameter then
248
249"Vessel Filled Volume"
250        Vfilled = 0.25*pi*(Level^2)*(2*Diameter-4*Level/3);
251
252else
253
254"Vessel Filled Volume"
255        Vfilled = 0.25*pi*((2/3)*((0.5*Diameter)^3) - (0.25*(Diameter)^3) + Level*Diameter^2);
256
257end
258
259case "flat":
260
261"Vessel Total Volume"
262        Vtotal = Vcylinder;
263
264"Vessel Filled Volume"
265        Vfilled = Across*Level;
266
267end
268
269case "horizontal":
270
271"Vessel Cross Section Area"
272        Across = (radius^2)*acos((radius-Level)/radius)-(radius-Level)*sqrt((2*radius*Level-Level^2));
273
274switch Heads
275
276case "elliptical":
277
278"Vessel Total Volume"
279        Vtotal = Vhead_elliptical +     Vcylinder;
280
281"Vessel Filled Volume"
282        Vfilled = 0.5236*Level^2*(1.5*Diameter-Level) + Across*Lenght;
283
284case "hemispherical":
285
286"Vessel Total Volume"
287        Vtotal = Vhead_hemispherical + Vcylinder;
288
289"Vessel Filled Volume"
290        Vfilled = 1.0472*Level^2*(1.5*Diameter-Level) + Across*Lenght;
291
292case "flat":
293
294"Vessel Total Volume"
295        Vtotal = Vcylinder;
296
297"Vessel Filled Volume"
298        Vfilled = Across*Lenght;
299
300end
301
302end
303
304"Component Molar Balance"
305        diff(TotalHoldup)=Inlet.F*Inlet.z - OutletLiquid.F*OutletLiquid.z - OutletVapour.F*OutletVapour.z;
306       
307"Energy Balance"
308        diff(E) = Inlet.F*Inlet.h - OutletLiquid.F*OutletLiquid.h - OutletVapour.F*OutletVapour.h + InletQ;
309       
310"Molar Holdup"
311        TotalHoldup = LiquidHoldup*OutletLiquid.z + VapourHoldup*OutletVapour.z;
312       
313"Energy Holdup"
314        E = LiquidHoldup*OutletLiquid.h + VapourHoldup*OutletVapour.h - OutletLiquid.P*Vtotal;
315       
316"Mol fraction normalisation"
317        sum(OutletLiquid.z)=1.0;
318
319"Mol fraction normalisation"
320        sum(OutletLiquid.z)=sum(OutletVapour.z);
321
322"Vaporization Fraction"
323        OutletVapour.F = Inlet.F * vfrac;
324
325"Liquid Volume"
326        vL = PP.LiquidVolume(OutletLiquid.T, OutletLiquid.P, OutletLiquid.z);
327
328"Vapour Volume"
329        vV = PP.VapourVolume(OutletVapour.T, OutletVapour.P, OutletVapour.z);
330       
331"Chemical Equilibrium"
332        PP.LiquidFugacityCoefficient(OutletLiquid.T, OutletLiquid.P, OutletLiquid.z)*OutletLiquid.z =
333                PP.VapourFugacityCoefficient(OutletVapour.T, OutletVapour.P, OutletVapour.z)*OutletVapour.z;
334       
335"Thermal Equilibrium"
336        OutletVapour.T = OutletLiquid.T;
337       
338"Mechanical Equilibrium"
339        OutletVapour.P = OutletLiquid.P;
340
341"Pressure Drop"
342        OutletLiquid.P  = Inlet.P - Pdrop;
343
344"Pressure Ratio"
345        OutletLiquid.P = Inlet.P * Pratio;
346
347"Geometry Constraint"
348        Vtotal = LiquidHoldup * vL + VapourHoldup * vV;
349
350"Temperature indicator"
351        TI * 'K' = OutletLiquid.T;
352
353"Pressure indicator"
354        PI * 'atm' = OutletLiquid.P;
355
356"Level indicator"
357        LI*Vtotal= Vfilled;
358
359"Liquid Level"
360        LiquidHoldup * vL = Vfilled;
361
362end
363
364Model tank_cylindrical
365        ATTRIBUTES
366        Pallete         = true;
367        Icon            = "icon/TankHorizontal";
368        Brief           = "Model of a tank with a lain cylinder geometry.";
369        Info            =
370"== Specify ==
371* the Inlet stream;
372* the outlet flow;
373* the InletQ (requires an energy source).
374
375== Initial Conditions ==
376* the tank initial temperature;
377* the tank initial level;
378* the tank initial composition.
379";
380       
381PARAMETERS
382        outer PP                as Plugin               (Brief = "External Physical Properties", Type="PP");
383        outer NComp     as Integer              (Brief = "Number of Components");
384       
385        pi                      as positive     (Brief="Pi value", Default=3.141593,Hidden=true);
386        eps                     as positive     (Brief="small number",Default=1E-8,Hidden=true);
387        Diameter                as length       (Brief="Tank internal Diameter",Default=1.5);
388        radius                  as length       (Brief="Tank radius",Hidden=true);
389        L                               as length       (Brief="Tank length",Default=5);
390       
391        Initial_Level                           as length               (Brief="Initial Level of the Tank",Default=1);
392        Initial_Temperature                     as temperature  (Brief="Initial Temperature of Liquid",Default=300);
393        Initial_Composition(NComp)      as positive     (Brief="Initial Liquid Composition",Lower=1E-8,Default=0.1);
394
395SET
396        radius = Diameter/2;
397
398VARIABLES
399in      Inlet           as stream                       (Brief="Inlet stream", PosX=0.1825, PosY=0, Symbol="_{in}");
400out     Outlet          as liquid_stream        (Brief="Outlet liquid stream", PosX=1, PosY=1, Symbol="_{out}");
401in      InletQ          as power                        (Brief="Rate of heat supply", PosX=1, PosY=0.6160, Symbol="_{in}",Protected=true);
402        Level           as length                       (Brief="Tank level",Protected=true);
403        Vtotal          as volume                       (Brief="Tank total volume",Protected=true);
404        Vfilled         as volume                       (Brief="Tank volume content",Protected=true);
405        Across          as area                         (Brief="Tank cross section area", Default=2,Protected=true);
406        E                       as energy                       (Brief="Total Energy Holdup on tank",Protected=true);
407        vL                      as volume_mol           (Brief="Liquid Molar Volume",Protected=true);
408        M(NComp)        as mol                          (Brief="Molar Holdup in the tank",Protected=true);
409
410INITIAL
411
412"Initial Level"
413        Level = Initial_Level;
414
415"Initial Liquid Temperature"   
416        Outlet.T = Initial_Temperature;
417
418"Initial Liquid Composition"   
419        Outlet.z(1:NComp-1) = Initial_Composition(1:NComp-1)/sum(Initial_Composition);
420
421EQUATIONS
422
423"Tank total volume"
424        Vtotal = (0.25*pi*(Diameter)^2)*L;
425       
426"Mass balance"
427        diff(M) = Inlet.F*Inlet.z - Outlet.F*Outlet.z;
428       
429"Energy balance"
430        diff(E) = Inlet.F*Inlet.h - Outlet.F*Outlet.h + InletQ;
431
432"Energy Holdup"
433        E = sum(M)*Outlet.h;
434       
435"Mechanical Equilibrium"
436        Inlet.P = Outlet.P;
437       
438"Liquid Volume"
439        vL = PP.LiquidVolume(Outlet.T, Outlet.P, Outlet.z);
440       
441"Composition"
442        M = Outlet.z*sum(M);
443       
444"Cylindrical Area"
445        Across = radius^2 * (asin(1) - asin((radius-Level)/radius) ) + (Level-radius)*sqrt(Level*(2*radius - Level)+eps*'m^2');
446
447"Level of liquid phase"
448        L*Across = sum(M)*vL;
449
450"Volume Filled of liquid phase"
451        Vfilled = L*Across;
452
453end
454
455Model tank_feed
456        ATTRIBUTES
457        Pallete         = true;
458        Icon            = "icon/Tank";
459        Brief           = "Model of a tank with feed stream.";
460        Info            =
461"== Specify ==
462* the Inlet stream;
463* the Feed stream;
464* the outlet flow;
465* the tank Q.
466
467== Initial Conditions ==
468* the tank initial temperature (OutletL.T);
469* the tank initial level (Level);
470* (NoComps - 1) OutletL (OR OutletV) compositions.
471";
472
473        PARAMETERS
474        outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
475        outer NComp as Integer;
476        Across as area (Brief="Tank cross section area", Default=2);
477       
478        VARIABLES
479in      Feed as stream (Brief = "Feed stream", PosX=0.32, PosY=0, Symbol="_{feed}");   
480in      Inlet  as stream (Brief = "Inlet stream", PosX=0.3037, PosY=0, Symbol="_{in}");
481out     Outlet as liquid_stream (Brief = "Outlet liquid stream", PosX=1, PosY=1, Symbol="_{out}");
482in      InletQ as power (Brief="Rate of heat supply", PosX=1, PosY=0.7859, Symbol="_{in}");
483
484        Level    as length(Brief="Tank level");
485        M(NComp) as mol (Brief="Molar Holdup in the tank");
486        E as energy (Brief="Total Energy Holdup on tank");
487        vL as volume_mol (Brief="Liquid Molar Volume");
488
489        EQUATIONS
490        "Mass balance"
491        diff(M) = Feed.F*Feed.z + Inlet.F*Inlet.z - Outlet.F*Outlet.z;
492       
493        "Energy balance"
494        diff(E) = Feed.F*Feed.h + Inlet.F*Inlet.h - Outlet.F*Outlet.h + InletQ;
495
496        "Energy Holdup"
497        E = sum(M)*Outlet.h;
498
499        "Mechanical Equilibrium"
500        Inlet.P = Outlet.P;
501       
502        "Liquid Volume"
503        vL = PP.LiquidVolume(Outlet.T, Outlet.P, Outlet.z);
504       
505        "Composition"
506        M = Outlet.z*sum(M);
507       
508        "Level of liquid phase"
509        Level = sum(M)*vL/Across;
510end
Note: See TracBrowser for help on using the repository browser.