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

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

updates - added thermosyphon reboiler / fixed sump tank

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 25.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 805 2009-07-24 17:03:40Z 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 TankL
365
366ATTRIBUTES
367        Pallete         = true;
368        Icon            = "icon/TankL";
369        Brief           = "Model of a Tank.";
370        Info            =
371"== ASSUMPTIONS ==
372* liquid phase only;
373
374== SET ==
375*Orientation: vessel position - vertical or horizontal;
376*Heads (bottom and top heads are identical)
377**elliptical: 2:1 elliptical heads (25% of vessel diameter);
378**hemispherical: hemispherical heads (50% of vessel diameter);
379**flat: flat heads (0% of vessel diameter);
380*Diameter: Vessel diameter;
381*Lenght: Side length of the cylinder shell;
382       
383== SPECIFY ==
384* the Inlet stream;
385* the OutletLiquid.F;
386* the InletQ (the model requires an energy stream, also you can use a controller for setting the heat duty using the heat_flow model).
387
388== OPTIONAL ==
389* the TankL model has three control ports
390** TI OutletLiquid Temperature Indicator;
391** PI OutletLiquid Pressure Indicator;
392** LI Level Indicator;
393
394== INITIAL CONDITIONS ==
395* Initial_Temperature :  the Tank temperature (OutletLiquid.T);
396* Initial_Level : the Tank liquid level (Level);
397* Initial_Composition : (NoComps) OutletLiquid compositions.
398";
399       
400PARAMETERS
401outer PP                as Plugin       (Brief = "External Physical Properties", Type="PP");
402outer NComp     as Integer      (Brief = "Number of components", Lower = 1);
403
404        pi                      as positive             (Brief="Pi value", Default=3.141593,Hidden=true, Symbol="\pi");
405       
406        Orientation     as Switcher     (Valid=["vertical","horizontal"],Default="vertical");
407        Heads                   as Switcher     (Valid=["elliptical","hemispherical","flat"],Default="flat");
408        Diameter                as length               (Brief="Vessel diameter", Symbol="D_{i}");
409        Lenght                  as length               (Brief="Side length of the cylinder shell", Symbol="L_{vessel}");
410       
411        Vhead_elliptical                as volume               (Brief="Elliptical Head Total Volume",Hidden=true, Symbol="V_{head}^{elliptical}");
412        Vhead_hemispherical     as volume               (Brief="Hemispherical Head Total Volume",Hidden=true, Symbol="V_{head}^{hemispherical}");
413        Vcylinder                               as volume               (Brief="Cylinder Total Volume",Hidden=true, Symbol="V_{cylinder}");
414        radius                                  as length               (Brief="Vessel radius",Hidden=true, Symbol="R_{cylinder}");
415       
416        Levelpercent_Initial                    as positive     (Brief="Initial liquid height in Percent", Default = 0.70);
417        Temperature_Initial                             as temperature  (Brief="Initial Liquid Temperature", Default = 330);
418        Composition_Initial(NComp)              as fraction             (Brief="Initial Composition", Default = 0.10);
419
420SET
421
422        Vhead_elliptical        = (pi*Diameter^3)/12;
423        Vhead_hemispherical = (pi*Diameter^3)/6;
424        Vcylinder = 0.25*(pi*Diameter^2)*Lenght;
425        radius = 0.5*Diameter;
426
427VARIABLES
428
429in      Inlet                   as stream                       (Brief="Feed Stream", PosX=0.22, PosY=0, Symbol="_{in}");
430out     OutletLiquid    as liquid_stream        (Brief="Liquid outlet stream", PosX=0.43, PosY=1, Symbol="_{out}^{Liquid}");
431in      InletQ                  as power                        (Brief="Heat Duty", PosX=0.735, PosY=1, Protected =true,Symbol="Q_{in}");
432
433        Vtotal                  as volume                       (Brief="Vessel total volume",Protected=true, Symbol="V_{total}");
434        Vfilled                 as volume                       (Brief="Vessel volume content",Protected=true, Symbol="V_{filled}");
435
436        TotalHoldup(NComp)              as mol  (Brief="Molar Holdup in the Vessel", Protected=true);
437       
438        E                       as energy               (Brief="Total Energy Holdup in the Vessel", Protected=true);
439        vL                      as volume_mol   (Brief="Liquid Molar Volume", Protected=true);
440        Level           as length               (Brief="liquid height", Protected=true);
441        Across          as area                 (Brief="Vessel cylinder shell Cross section area", Hidden=true, Symbol="A_{cross}");
442
443out     TI as control_signal    (Brief="Temperature Indicator", PosX=0.525, PosY=0, Protected=true);
444out     PI as control_signal    (Brief="Pressure Indicator", PosX=0.368, PosY=0, Protected=true);
445out     LI as control_signal    (Brief="Level Indicator", PosX=1, PosY=0.6, Protected=true);
446
447INITIAL
448
449"Initial level Percent"
450        LI = Levelpercent_Initial;
451       
452"Initial Outlet Liquid Temperature"
453        OutletLiquid.T = Temperature_Initial;
454       
455"Initial Outlet Liquid Composition Normalized"
456        OutletLiquid.z(1:NComp - 1) = Composition_Initial(1:NComp - 1)/sum(Composition_Initial);
457
458EQUATIONS
459
460switch Orientation
461
462case "vertical":
463
464"Vessel Cross Section Area"
465        Across = 0.25*(pi*Diameter^2);
466
467switch Heads
468
469case "elliptical":
470
471"Vessel Total Volume"
472        Vtotal = Vhead_elliptical +     Vcylinder;
473
474if Level < 0.25*Diameter then
475
476"Vessel Filled Volume"
477        Vfilled = 0.25*pi*(((Diameter*Level)/(0.25*Diameter))^2)*(0.25*Diameter-Level/3);
478
479else
480
481"Vessel Filled Volume"
482        Vfilled = 0.25*pi*(Diameter^2)*(Level - 0.25*Diameter/3);
483
484end
485
486case "hemispherical":
487
488"Vessel Total Volume"
489        Vtotal = Vhead_hemispherical + Vcylinder;
490
491if Level < 0.5*Diameter then
492
493"Vessel Filled Volume"
494        Vfilled = 0.25*pi*(Level^2)*(2*Diameter-4*Level/3);
495
496else
497
498"Vessel Filled Volume"
499        Vfilled = 0.25*pi*((2/3)*((0.5*Diameter)^3) - (0.25*(Diameter)^3) + Level*Diameter^2);
500
501end
502
503case "flat":
504
505"Vessel Total Volume"
506        Vtotal = Vcylinder;
507
508"Vessel Filled Volume"
509        Vfilled = Across*Level;
510
511end
512
513case "horizontal":
514
515"Vessel Cross Section Area"
516        Across = (radius^2)*acos((radius-Level)/radius)-(radius-Level)*sqrt((2*radius*Level-Level^2));
517
518switch Heads
519
520case "elliptical":
521
522"Vessel Total Volume"
523        Vtotal = Vhead_elliptical +     Vcylinder;
524
525"Vessel Filled Volume"
526        Vfilled = 0.5236*Level^2*(1.5*Diameter-Level) + Across*Lenght;
527
528case "hemispherical":
529
530"Vessel Total Volume"
531        Vtotal = Vhead_hemispherical + Vcylinder;
532
533"Vessel Filled Volume"
534        Vfilled = 1.0472*Level^2*(1.5*Diameter-Level) + Across*Lenght;
535
536case "flat":
537
538"Vessel Total Volume"
539        Vtotal = Vcylinder;
540
541"Vessel Filled Volume"
542        Vfilled = Across*Lenght;
543
544end
545
546end
547
548"Component Molar Balance"
549        diff(TotalHoldup)=Inlet.F*Inlet.z - OutletLiquid.F*OutletLiquid.z;
550       
551"Energy Balance"
552        diff(E) = Inlet.F*Inlet.h - OutletLiquid.F*OutletLiquid.h + InletQ;
553
554"Energy Holdup"
555        E = sum(TotalHoldup)*OutletLiquid.h;
556
557"Mechanical Equilibrium"
558        Inlet.P = OutletLiquid.P;
559
560"Liquid Volume"
561        vL = PP.LiquidVolume(OutletLiquid.T, OutletLiquid.P, OutletLiquid.z);
562
563"Molar Holdup"
564        TotalHoldup = OutletLiquid.z*sum(TotalHoldup);
565       
566"Liquid Level"
567        Vfilled = sum(TotalHoldup) * vL;
568       
569"Temperature indicator"
570        TI * 'K' = OutletLiquid.T;
571
572"Pressure indicator"
573        PI * 'atm' = OutletLiquid.P;
574
575"Level indicator"
576        LI*Vtotal= Vfilled;
577
578end
579
580Model SumpTank
581
582ATTRIBUTES
583        Pallete         = true;
584        Icon            = "icon/SumpTank";
585        Brief           = "Model of a Tank With Thermodynamic Equilibrium.";
586        Info            =
587"== ASSUMPTIONS ==
588* perfect mixing of both phases;
589* thermodynamics equilibrium.
590
591== SET ==
592*Orientation: vessel position - vertical or horizontal;
593*Heads (bottom and top heads are identical)
594**elliptical: 2:1 elliptical heads (25% of vessel diameter);
595**hemispherical: hemispherical heads (50% of vessel diameter);
596**flat: flat heads (0% of vessel diameter);
597*Diameter: Vessel diameter;
598*Lenght: Side length of the cylinder shell;
599       
600== SPECIFY ==
601* the Inlet stream;
602* the outlet flows: OutletVapour.F and OutletLiquid.F;
603* the InletQ (the model requires an energy stream, also you can use a controller for setting the heat duty using the heat_flow model).
604
605== OPTIONAL ==
606* the TankVL model has three control ports
607** TI OutletLiquid Temperature Indicator;
608** PI OutletLiquid Pressure Indicator;
609** LI Level Indicator;
610
611== INITIAL CONDITIONS ==
612* Initial_Temperature :  the Tank temperature (OutletLiquid.T);
613* Initial_Level : the Tank liquid level (Level);
614* Initial_Composition : (NoComps) OutletLiquid compositions.
615";
616       
617PARAMETERS
618outer PP                as Plugin       (Brief = "External Physical Properties", Type="PP");
619outer NComp     as Integer      (Brief = "Number of components", Lower = 1);
620
621        Mw(NComp)               as molweight    (Brief="Mol Weight", Hidden=true);
622        pi                      as positive             (Brief="Pi value", Default=3.141593,Hidden=true, Symbol="\pi");
623       
624        Heads                   as Switcher     (Valid=["elliptical","hemispherical","flat"],Default="flat");
625        Diameter                as length               (Brief="Vessel diameter", Symbol="D_{i}");
626        Lenght                  as length               (Brief="Side length of the cylinder shell", Symbol="L_{vessel}");
627       
628        Vhead_elliptical                as volume               (Brief="Elliptical Head Total Volume",Hidden=true, Symbol="V_{head}^{elliptical}");
629        Vhead_hemispherical     as volume               (Brief="Hemispherical Head Total Volume",Hidden=true, Symbol="V_{head}^{hemispherical}");
630        Vcylinder                               as volume               (Brief="Cylinder Total Volume",Hidden=true, Symbol="V_{cylinder}");
631        radius                                  as length               (Brief="Vessel radius",Hidden=true, Symbol="R_{cylinder}");
632       
633        Levelpercent_Initial                    as positive     (Brief="Initial liquid height in Percent", Default = 0.70);
634        Temperature_Initial                             as temperature  (Brief="Initial Liquid Temperature", Default = 330);
635        Composition_Initial(NComp)              as fraction             (Brief="Initial Composition", Default = 0.10);
636
637SET
638
639        Mw=PP.MolecularWeight();
640
641        Vhead_elliptical        = (pi*Diameter^3)/12;
642        Vhead_hemispherical = (pi*Diameter^3)/6;
643        Vcylinder = 0.25*(pi*Diameter^2)*Lenght;
644        radius = 0.5*Diameter;
645
646VARIABLES
647
648in      InletLiquid     as stream                       (Brief="Feed Stream", PosX=0.22, PosY=0, Symbol="_{in}");
649out     OutletLiquid    as liquid_stream        (Brief="Liquid outlet stream", PosX=0.50, PosY=1, Symbol="_{out}^{Liquid}");
650in      InletVapour     as stream                       (Brief="Vapour outlet stream", PosX=1, PosY=0.20, Symbol="_{out}^{Vapour}");
651out     OutletVapour    as vapour_stream        (Brief="Vapour outlet stream", PosX=0.68, PosY=0, Symbol="_{out}^{Vapour}");
652        InletQ                  as power                        (Brief="Heat Duty", Protected =false,Symbol="Q_{in}");
653
654        Vtotal                  as volume                       (Brief="Vessel total volume",Protected=true, Symbol="V_{total}");
655        Vfilled                 as volume                       (Brief="Vessel volume content",Protected=true, Symbol="V_{filled}");
656
657        TotalHoldup(NComp)              as mol  (Brief="Molar Holdup in the Vessel", Protected=true);
658        LiquidHoldup                    as mol  (Brief="Molar liquid holdup", Protected=true);
659        VapourHoldup                    as mol  (Brief="Molar vapour holdup", Protected=true);
660       
661        E                       as energy               (Brief="Total Energy Holdup in the Vessel", Protected=true);
662        vL                      as volume_mol   (Brief="Liquid Molar Volume", Protected=true);
663        vV                      as volume_mol   (Brief="Vapour Molar volume", Protected=true);
664        Level           as length               (Brief="liquid height", Protected=true);
665        Across          as area                 (Brief="Vessel cylinder shell Cross section area", Hidden=true, Symbol="A_{cross}");
666        #vfrac          as positive     (Brief="Vapourization fraction", Symbol="\phi", Protected=true);
667        #Pratio                 as positive             (Brief = "Pressure Ratio", Symbol ="P_{ratio}", Protected=true);       
668        Pdrop           as press_delta  (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P", Protected=true);
669
670out     LI as control_signal    (Brief="Level Indicator", PosX=1, PosY=0.6, Protected=true);
671
672INITIAL
673
674"Initial level Percent"
675        LI = Levelpercent_Initial;
676       
677"Initial Outlet Liquid Temperature"
678        OutletLiquid.T = Temperature_Initial;
679       
680"Initial Outlet Liquid Composition Normalized"
681        OutletLiquid.z(1:NComp - 1) = Composition_Initial(1:NComp - 1)/sum(Composition_Initial);
682
683EQUATIONS
684
685"Vessel Cross Section Area"
686        Across = 0.25*(pi*Diameter^2);
687
688switch Heads
689
690case "elliptical":
691
692"Vessel Total Volume"
693        Vtotal = Vhead_elliptical +     Vcylinder;
694
695if Level < 0.25*Diameter then
696
697"Vessel Filled Volume"
698        Vfilled = 0.25*pi*(((Diameter*Level)/(0.25*Diameter))^2)*(0.25*Diameter-Level/3);
699
700else
701
702"Vessel Filled Volume"
703        Vfilled = 0.25*pi*(Diameter^2)*(Level - 0.25*Diameter/3);
704
705end
706
707case "hemispherical":
708
709"Vessel Total Volume"
710        Vtotal = Vhead_hemispherical + Vcylinder;
711
712if Level < 0.5*Diameter then
713
714"Vessel Filled Volume"
715        Vfilled = 0.25*pi*(Level^2)*(2*Diameter-4*Level/3);
716
717else
718
719"Vessel Filled Volume"
720        Vfilled = 0.25*pi*((2/3)*((0.5*Diameter)^3) - (0.25*(Diameter)^3) + Level*Diameter^2);
721
722end
723
724case "flat":
725
726"Vessel Total Volume"
727        Vtotal = Vcylinder;
728
729"Vessel Filled Volume"
730        Vfilled = Across*Level;
731
732end
733
734"Component Molar Balance"
735        diff(TotalHoldup) = InletLiquid.F*InletLiquid.z + InletVapour.F*InletVapour.z- OutletLiquid.F*OutletLiquid.z - OutletVapour.F*OutletVapour.z;
736       
737"Energy Balance"
738        diff(E) = InletLiquid.F*InletLiquid.h + InletVapour.F*InletVapour.h - OutletLiquid.F*OutletLiquid.h - OutletVapour.F*OutletVapour.h + InletQ;
739       
740"Molar Holdup"
741        TotalHoldup = LiquidHoldup*OutletLiquid.z + VapourHoldup*OutletVapour.z;
742       
743"Energy Holdup"
744        E = LiquidHoldup*OutletLiquid.h + VapourHoldup*OutletVapour.h - OutletLiquid.P*Vtotal;
745       
746"Mol fraction normalisation"
747        sum(OutletLiquid.z)=1.0;
748
749"Mol fraction normalisation"
750        sum(OutletLiquid.z)=sum(OutletVapour.z);
751
752#"Vaporization Fraction"
753        #OutletVapour.F = (InletLiquid.F + InletVapour.F)* vfrac;
754
755"Liquid Volume"
756        vL = PP.LiquidVolume(OutletLiquid.T, OutletLiquid.P, OutletLiquid.z);
757
758"Vapour Volume"
759        vV = PP.VapourVolume(OutletVapour.T, OutletVapour.P, OutletVapour.z);
760       
761"Chemical Equilibrium"
762        PP.LiquidFugacityCoefficient(OutletLiquid.T, OutletLiquid.P, OutletLiquid.z)*OutletLiquid.z =
763                PP.VapourFugacityCoefficient(OutletVapour.T, OutletVapour.P, OutletVapour.z)*OutletVapour.z;
764       
765"Thermal Equilibrium"
766        OutletVapour.T = OutletLiquid.T;
767       
768"Mechanical Equilibrium"
769        OutletVapour.P = OutletLiquid.P;
770
771"Pressure Drop"
772        #OutletLiquid.P  = min([InletLiquid.P,InletVapour.P]) - Pdrop;
773        OutletLiquid.P  = InletLiquid.P - Pdrop;
774
775#"Pressure Ratio"
776        #OutletLiquid.P = InletLiquid.P * Pratio;
777
778"Geometry Constraint"
779        Vtotal = LiquidHoldup * vL + VapourHoldup * vV;
780
781"Level indicator"
782        LI*Vtotal= Vfilled;
783
784"Liquid Level"
785        LiquidHoldup * vL = Vfilled;
786
787end
788
789Model tank_feed
790        ATTRIBUTES
791        Pallete         = false;
792        Icon            = "icon/Tank";
793        Brief           = "Model of a tank with feed stream.";
794        Info            =
795"== Specify ==
796* the Inlet stream;
797* the Feed stream;
798* the outlet flow;
799* the tank Q.
800
801== Initial Conditions ==
802* the tank initial temperature (OutletL.T);
803* the tank initial level (Level);
804* (NoComps - 1) OutletL (OR OutletV) compositions.
805";
806
807        PARAMETERS
808        outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
809        outer NComp as Integer;
810        Across as area (Brief="Tank cross section area", Default=2);
811       
812        VARIABLES
813in      Feed as stream (Brief = "Feed stream", PosX=0.32, PosY=0, Symbol="_{feed}");   
814in      Inlet  as stream (Brief = "Inlet stream", PosX=0.3037, PosY=0, Symbol="_{in}");
815out     Outlet as liquid_stream (Brief = "Outlet liquid stream", PosX=1, PosY=1, Symbol="_{out}");
816in      InletQ as power (Brief="Rate of heat supply", PosX=1, PosY=0.7859, Symbol="_{in}");
817
818        Level    as length(Brief="Tank level");
819        M(NComp) as mol (Brief="Molar Holdup in the tank");
820        E as energy (Brief="Total Energy Holdup on tank");
821        vL as volume_mol (Brief="Liquid Molar Volume");
822
823        EQUATIONS
824        "Mass balance"
825        diff(M) = Feed.F*Feed.z + Inlet.F*Inlet.z - Outlet.F*Outlet.z;
826       
827        "Energy balance"
828        diff(E) = Feed.F*Feed.h + Inlet.F*Inlet.h - Outlet.F*Outlet.h + InletQ;
829
830        "Energy Holdup"
831        E = sum(M)*Outlet.h;
832
833        "Mechanical Equilibrium"
834        Inlet.P = Outlet.P;
835       
836        "Liquid Volume"
837        vL = PP.LiquidVolume(Outlet.T, Outlet.P, Outlet.z);
838       
839        "Composition"
840        M = Outlet.z*sum(M);
841       
842        "Level of liquid phase"
843        Level = sum(M)*vL/Across;
844end
Note: See TracBrowser for help on using the repository browser.