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

Last change on this file since 822 was 822, checked in by gerson bicca, 14 years ago

updated tank model

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 21.3 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 822 2009-08-11 03:34:40Z bicca $
17*--------------------------------------------------------------------*#
18
19using "streams";
20
21Model TankVL
22
23ATTRIBUTES
24        Pallete         = true;
25        Icon            = "icon/TankVL";
26        Brief           = "Model of a Tank With Thermodynamic Equilibrium.";
27        Info            =
28"== ASSUMPTIONS ==
29* perfect mixing of both phases;
30* thermodynamics equilibrium.
31
32== SET ==
33*Orientation: vessel position - vertical or horizontal;
34*Heads (bottom and top heads are identical)
35**elliptical: 2:1 elliptical heads (25% of vessel diameter);
36**hemispherical: hemispherical heads (50% of vessel diameter);
37**flat: flat heads (0% of vessel diameter);
38*Diameter: Vessel diameter;
39*Lenght: Side length of the cylinder shell;
40       
41== SPECIFY ==
42* the Inlet stream;
43* the outlet flows: OutletVapour.F and OutletLiquid.F;
44* the InletQ (the model requires an energy stream, also you can use a controller for setting the heat duty using the heat_flow model).
45
46== OPTIONAL ==
47* the TankVL model has three control ports
48** TI OutletLiquid Temperature Indicator;
49** PI OutletLiquid Pressure Indicator;
50** LI Level Indicator;
51
52== INITIAL CONDITIONS ==
53* Initial_Temperature :  the Tank temperature (OutletLiquid.T);
54* Levelpercent_Initial : the Tank liquid level in percent (LI);
55* Initial_Composition : (NoComps) OutletLiquid compositions.
56";
57       
58PARAMETERS
59outer PP                as Plugin       (Brief = "External Physical Properties", Type="PP");
60outer NComp     as Integer      (Brief = "Number of components", Lower = 1);
61
62        Mw(NComp)               as molweight    (Brief="Mol Weight", Hidden=true);
63        pi                      as positive             (Brief="Pi value", Default=3.141593,Hidden=true, Symbol="\pi");
64       
65        Orientation     as Switcher     (Valid=["vertical","horizontal"],Default="vertical");
66        Heads                   as Switcher     (Valid=["elliptical","hemispherical","flat"],Default="flat");
67        Diameter                as length               (Brief="Vessel diameter", Symbol="D_{i}");
68        Lenght                  as length               (Brief="Side length of the cylinder shell", Symbol="L_{vessel}");
69       
70        Vhead_elliptical                as volume               (Brief="Elliptical Head Total Volume",Hidden=true, Symbol="V_{head}^{elliptical}");
71        Vhead_hemispherical     as volume               (Brief="Hemispherical Head Total Volume",Hidden=true, Symbol="V_{head}^{hemispherical}");
72        Vcylinder                               as volume               (Brief="Cylinder Total Volume",Hidden=true, Symbol="V_{cylinder}");
73        radius                                  as length               (Brief="Vessel radius",Hidden=true, Symbol="R_{cylinder}");
74       
75        Levelpercent_Initial                    as positive     (Brief="Initial liquid height in Percent", Default = 0.70);
76        Temperature_Initial                             as temperature  (Brief="Initial Liquid Temperature", Default = 330);
77        Composition_Initial(NComp)              as fraction             (Brief="Initial Composition", Default = 0.10);
78
79SET
80
81        Mw=PP.MolecularWeight();
82
83        Vhead_elliptical        = (pi*Diameter^3)/12;
84        Vhead_hemispherical = (pi*Diameter^3)/6;
85        Vcylinder = 0.25*(pi*Diameter^2)*Lenght;
86        radius = 0.5*Diameter;
87
88VARIABLES
89
90in      Inlet                   as stream                       (Brief="Feed Stream", PosX=0.22, PosY=0, Symbol="_{in}");
91out     OutletLiquid    as liquid_stream        (Brief="Liquid outlet stream", PosX=0.43, PosY=1, Symbol="_{out}^{Liquid}");
92out     OutletVapour    as vapour_stream        (Brief="Vapour outlet stream", PosX=0.68, PosY=0, Symbol="_{out}^{Vapour}");
93in      InletQ                  as power                        (Brief="Heat Duty", PosX=0.735, PosY=1, Protected =true,Symbol="Q_{in}");
94
95        Vtotal                  as volume                       (Brief="Vessel total volume",Protected=true, Symbol="V_{total}");
96        Vfilled                 as volume                       (Brief="Vessel volume content",Protected=true, Symbol="V_{filled}");
97
98        TotalHoldup(NComp)              as mol  (Brief="Molar Holdup in the Vessel", Protected=true);
99        LiquidHoldup                    as mol  (Brief="Molar liquid holdup", Protected=true);
100        VapourHoldup                    as mol  (Brief="Molar vapour holdup", Protected=true);
101       
102        E                       as energy               (Brief="Total Energy Holdup in the Vessel", Protected=true);
103        vL                      as volume_mol   (Brief="Liquid Molar Volume", Protected=true);
104        vV                      as volume_mol   (Brief="Vapour Molar volume", Protected=true);
105        Level           as length               (Brief="liquid height", Protected=true);
106        Across          as area                 (Brief="Vessel cylinder shell Cross section area", Hidden=true, Symbol="A_{cross}");
107        Pratio          as positive             (Brief = "Pressure Ratio", Symbol ="P_{ratio}", Protected=true);       
108        Pdrop           as press_delta  (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P", Protected=true);
109
110out     TI as control_signal    (Brief="Temperature Indicator", PosX=0.525, PosY=0, Protected=true);
111out     PI as control_signal    (Brief="Pressure Indicator", PosX=0.368, PosY=0, Protected=true);
112out     LI as control_signal    (Brief="Level Indicator", PosX=1, PosY=0.6, Protected=true);
113
114INITIAL
115
116"Initial level Percent"
117        LI = Levelpercent_Initial;
118       
119"Initial Outlet Liquid Temperature"
120        OutletLiquid.T = Temperature_Initial;
121       
122"Initial Outlet Liquid Composition Normalized"
123        OutletLiquid.z(1:NComp - 1) = Composition_Initial(1:NComp - 1)/sum(Composition_Initial);
124
125EQUATIONS
126
127switch Orientation
128
129case "vertical":
130
131"Vessel Cross Section Area"
132        Across = 0.25*(pi*Diameter^2);
133
134switch Heads
135
136case "elliptical":
137
138"Vessel Total Volume"
139        Vtotal = Vhead_elliptical +     Vcylinder;
140
141if Level < 0.25*Diameter then
142
143"Vessel Filled Volume"
144        Vfilled = 0.25*pi*(((Diameter*Level)/(0.25*Diameter))^2)*(0.25*Diameter-Level/3);
145
146else
147
148"Vessel Filled Volume"
149        Vfilled = 0.25*pi*(Diameter^2)*(Level - 0.25*Diameter/3);
150
151end
152
153case "hemispherical":
154
155"Vessel Total Volume"
156        Vtotal = Vhead_hemispherical + Vcylinder;
157
158if Level < 0.5*Diameter then
159
160"Vessel Filled Volume"
161        Vfilled = 0.25*pi*(Level^2)*(2*Diameter-4*Level/3);
162
163else
164
165"Vessel Filled Volume"
166        Vfilled = 0.25*pi*((2/3)*((0.5*Diameter)^3) - (0.25*(Diameter)^3) + Level*Diameter^2);
167
168end
169
170case "flat":
171
172"Vessel Total Volume"
173        Vtotal = Vcylinder;
174
175"Vessel Filled Volume"
176        Vfilled = Across*Level;
177
178end
179
180case "horizontal":
181
182"Vessel Cross Section Area"
183        Across = (radius^2)*acos((radius-Level)/radius)-(radius-Level)*sqrt((2*radius*Level-Level^2));
184
185switch Heads
186
187case "elliptical":
188
189"Vessel Total Volume"
190        Vtotal = Vhead_elliptical +     Vcylinder;
191
192"Vessel Filled Volume"
193        Vfilled = 0.5236*Level^2*(1.5*Diameter-Level) + Across*Lenght;
194
195case "hemispherical":
196
197"Vessel Total Volume"
198        Vtotal = Vhead_hemispherical + Vcylinder;
199
200"Vessel Filled Volume"
201        Vfilled = 1.0472*Level^2*(1.5*Diameter-Level) + Across*Lenght;
202
203case "flat":
204
205"Vessel Total Volume"
206        Vtotal = Vcylinder;
207
208"Vessel Filled Volume"
209        Vfilled = Across*Lenght;
210
211end
212
213end
214
215"Component Molar Balance"
216        diff(TotalHoldup)=Inlet.F*Inlet.z - OutletLiquid.F*OutletLiquid.z - OutletVapour.F*OutletVapour.z;
217       
218"Energy Balance"
219        diff(E) = Inlet.F*Inlet.h - OutletLiquid.F*OutletLiquid.h - OutletVapour.F*OutletVapour.h + InletQ;
220       
221"Molar Holdup"
222        TotalHoldup = LiquidHoldup*OutletLiquid.z + VapourHoldup*OutletVapour.z;
223       
224"Energy Holdup"
225        E = LiquidHoldup*OutletLiquid.h + VapourHoldup*OutletVapour.h - OutletLiquid.P*Vtotal;
226       
227"Mol fraction normalisation"
228        sum(OutletLiquid.z)=1.0;
229
230"Mol fraction normalisation"
231        sum(OutletLiquid.z)=sum(OutletVapour.z);
232
233"Liquid Volume"
234        vL = PP.LiquidVolume(OutletLiquid.T, OutletLiquid.P, OutletLiquid.z);
235
236"Vapour Volume"
237        vV = PP.VapourVolume(OutletVapour.T, OutletVapour.P, OutletVapour.z);
238       
239"Chemical Equilibrium"
240        PP.LiquidFugacityCoefficient(OutletLiquid.T, OutletLiquid.P, OutletLiquid.z)*OutletLiquid.z =
241                PP.VapourFugacityCoefficient(OutletVapour.T, OutletVapour.P, OutletVapour.z)*OutletVapour.z;
242       
243"Thermal Equilibrium"
244        OutletVapour.T = OutletLiquid.T;
245       
246"Mechanical Equilibrium"
247        OutletVapour.P = OutletLiquid.P;
248
249"Pressure Drop"
250        OutletLiquid.P  = Inlet.P - Pdrop;
251
252"Pressure Ratio"
253        OutletLiquid.P = Inlet.P * Pratio;
254
255"Geometry Constraint"
256        Vtotal = LiquidHoldup * vL + VapourHoldup * vV;
257
258"Temperature indicator"
259        TI * 'K' = OutletLiquid.T;
260
261"Pressure indicator"
262        PI * 'atm' = OutletLiquid.P;
263
264"Level indicator"
265        LI*Vtotal= Vfilled;
266
267"Liquid Level"
268        LiquidHoldup * vL = Vfilled;
269
270end
271
272Model TankL
273
274ATTRIBUTES
275        Pallete         = true;
276        Icon            = "icon/TankL";
277        Brief           = "Model of a Tank.";
278        Info            =
279"== ASSUMPTIONS ==
280* liquid phase only;
281
282== SET ==
283*Orientation: vessel position - vertical or horizontal;
284*Heads (bottom and top heads are identical)
285**elliptical: 2:1 elliptical heads (25% of vessel diameter);
286**hemispherical: hemispherical heads (50% of vessel diameter);
287**flat: flat heads (0% of vessel diameter);
288*Diameter: Vessel diameter;
289*Lenght: Side length of the cylinder shell;
290       
291== SPECIFY ==
292* the Inlet stream;
293* the OutletLiquid.F;
294* the InletQ (the model requires an energy stream, also you can use a controller for setting the heat duty using the heat_flow model).
295
296== OPTIONAL ==
297* the TankL model has three control ports
298** TI OutletLiquid Temperature Indicator;
299** PI OutletLiquid Pressure Indicator;
300** LI Level Indicator;
301
302== INITIAL CONDITIONS ==
303* Initial_Temperature :  the Tank temperature (OutletLiquid.T);
304* Levelpercent_Initial : the Tank liquid level in percent (LI);
305* Initial_Composition : (NoComps) OutletLiquid compositions.
306";
307       
308PARAMETERS
309outer PP                as Plugin       (Brief = "External Physical Properties", Type="PP");
310outer NComp     as Integer      (Brief = "Number of components", Lower = 1);
311
312        pi                      as positive             (Brief="Pi value", Default=3.141593,Hidden=true, Symbol="\pi");
313       
314        Orientation     as Switcher     (Valid=["vertical","horizontal"],Default="vertical");
315        Heads                   as Switcher     (Valid=["elliptical","hemispherical","flat"],Default="flat");
316        Diameter                as length               (Brief="Vessel diameter", Symbol="D_{i}");
317        Lenght                  as length               (Brief="Side length of the cylinder shell", Symbol="L_{vessel}");
318       
319        Vhead_elliptical                as volume               (Brief="Elliptical Head Total Volume",Hidden=true, Symbol="V_{head}^{elliptical}");
320        Vhead_hemispherical     as volume               (Brief="Hemispherical Head Total Volume",Hidden=true, Symbol="V_{head}^{hemispherical}");
321        Vcylinder                               as volume               (Brief="Cylinder Total Volume",Hidden=true, Symbol="V_{cylinder}");
322        radius                                  as length               (Brief="Vessel radius",Hidden=true, Symbol="R_{cylinder}");
323       
324        Levelpercent_Initial                    as positive     (Brief="Initial liquid height in Percent", Default = 0.70);
325        Temperature_Initial                             as temperature  (Brief="Initial Liquid Temperature", Default = 330);
326        Composition_Initial(NComp)              as fraction             (Brief="Initial Composition", Default = 0.10);
327
328SET
329
330        Vhead_elliptical        = (pi*Diameter^3)/12;
331        Vhead_hemispherical = (pi*Diameter^3)/6;
332        Vcylinder = 0.25*(pi*Diameter^2)*Lenght;
333        radius = 0.5*Diameter;
334
335VARIABLES
336
337in      Inlet                   as stream                       (Brief="Feed Stream", PosX=0.22, PosY=0, Symbol="_{in}");
338out     OutletLiquid    as liquid_stream        (Brief="Liquid outlet stream", PosX=0.43, PosY=1, Symbol="_{out}^{Liquid}");
339in      InletQ                  as power                        (Brief="Heat Duty", PosX=0.735, PosY=1, Protected =true,Symbol="Q_{in}");
340
341        Vtotal                  as volume                       (Brief="Vessel total volume",Protected=true, Symbol="V_{total}");
342        Vfilled                 as volume                       (Brief="Vessel volume content",Protected=true, Symbol="V_{filled}");
343
344        TotalHoldup(NComp)              as mol  (Brief="Molar Holdup in the Vessel", Protected=true);
345       
346        E                       as energy               (Brief="Total Energy Holdup in the Vessel", Protected=true);
347        vL                      as volume_mol   (Brief="Liquid Molar Volume", Protected=true);
348        Level           as length               (Brief="liquid height", Protected=true);
349        Across          as area                 (Brief="Vessel cylinder shell Cross section area", Hidden=true, Symbol="A_{cross}");
350
351out     TI as control_signal    (Brief="Temperature Indicator", PosX=0.525, PosY=0, Protected=true);
352out     PI as control_signal    (Brief="Pressure Indicator", PosX=0.368, PosY=0, Protected=true);
353out     LI as control_signal    (Brief="Level Indicator", PosX=1, PosY=0.6, Protected=true);
354
355INITIAL
356
357"Initial level Percent"
358        LI = Levelpercent_Initial;
359       
360"Initial Outlet Liquid Temperature"
361        OutletLiquid.T = Temperature_Initial;
362       
363"Initial Outlet Liquid Composition Normalized"
364        OutletLiquid.z(1:NComp - 1) = Composition_Initial(1:NComp - 1)/sum(Composition_Initial);
365
366EQUATIONS
367
368switch Orientation
369
370case "vertical":
371
372"Vessel Cross Section Area"
373        Across = 0.25*(pi*Diameter^2);
374
375switch Heads
376
377case "elliptical":
378
379"Vessel Total Volume"
380        Vtotal = Vhead_elliptical +     Vcylinder;
381
382if Level < 0.25*Diameter then
383
384"Vessel Filled Volume"
385        Vfilled = 0.25*pi*(((Diameter*Level)/(0.25*Diameter))^2)*(0.25*Diameter-Level/3);
386
387else
388
389"Vessel Filled Volume"
390        Vfilled = 0.25*pi*(Diameter^2)*(Level - 0.25*Diameter/3);
391
392end
393
394case "hemispherical":
395
396"Vessel Total Volume"
397        Vtotal = Vhead_hemispherical + Vcylinder;
398
399if Level < 0.5*Diameter then
400
401"Vessel Filled Volume"
402        Vfilled = 0.25*pi*(Level^2)*(2*Diameter-4*Level/3);
403
404else
405
406"Vessel Filled Volume"
407        Vfilled = 0.25*pi*((2/3)*((0.5*Diameter)^3) - (0.25*(Diameter)^3) + Level*Diameter^2);
408
409end
410
411case "flat":
412
413"Vessel Total Volume"
414        Vtotal = Vcylinder;
415
416"Vessel Filled Volume"
417        Vfilled = Across*Level;
418
419end
420
421case "horizontal":
422
423"Vessel Cross Section Area"
424        Across = (radius^2)*acos((radius-Level)/radius)-(radius-Level)*sqrt((2*radius*Level-Level^2));
425
426switch Heads
427
428case "elliptical":
429
430"Vessel Total Volume"
431        Vtotal = Vhead_elliptical +     Vcylinder;
432
433"Vessel Filled Volume"
434        Vfilled = 0.5236*Level^2*(1.5*Diameter-Level) + Across*Lenght;
435
436case "hemispherical":
437
438"Vessel Total Volume"
439        Vtotal = Vhead_hemispherical + Vcylinder;
440
441"Vessel Filled Volume"
442        Vfilled = 1.0472*Level^2*(1.5*Diameter-Level) + Across*Lenght;
443
444case "flat":
445
446"Vessel Total Volume"
447        Vtotal = Vcylinder;
448
449"Vessel Filled Volume"
450        Vfilled = Across*Lenght;
451
452end
453
454end
455
456"Component Molar Balance"
457        diff(TotalHoldup)=Inlet.F*Inlet.z - OutletLiquid.F*OutletLiquid.z;
458       
459"Energy Balance"
460        diff(E) = Inlet.F*Inlet.h - OutletLiquid.F*OutletLiquid.h + InletQ;
461
462"Energy Holdup"
463        E = sum(TotalHoldup)*OutletLiquid.h;
464
465"Mechanical Equilibrium"
466        Inlet.P = OutletLiquid.P;
467
468"Liquid Volume"
469        vL = PP.LiquidVolume(OutletLiquid.T, OutletLiquid.P, OutletLiquid.z);
470
471"Molar Holdup"
472        TotalHoldup = OutletLiquid.z*sum(TotalHoldup);
473       
474"Liquid Level"
475        Vfilled = sum(TotalHoldup) * vL;
476       
477"Temperature indicator"
478        TI * 'K' = OutletLiquid.T;
479
480"Pressure indicator"
481        PI * 'atm' = OutletLiquid.P;
482
483"Level indicator"
484        LI*Vtotal= Vfilled;
485
486end
487
488Model SumpTank
489
490ATTRIBUTES
491        Pallete         = true;
492        Icon            = "icon/SumpTank";
493        Brief           = "Model of a tank with 2 material inlet streams and with thermodynamic equilibrium.";
494        Info            =
495"== ASSUMPTIONS ==
496* perfect mixing of both phases;
497* thermodynamics equilibrium.
498
499== SET ==
500*Orientation: vessel position - vertical or horizontal;
501*Heads (bottom and top heads are identical)
502**elliptical: 2:1 elliptical heads (25% of vessel diameter);
503**hemispherical: hemispherical heads (50% of vessel diameter);
504**flat: flat heads (0% of vessel diameter);
505*Diameter: Vessel diameter;
506*Lenght: Side length of the cylinder shell;
507       
508== SPECIFY ==
509* the Inlet stream;
510* the outlet flows: OutletVapour.F and OutletLiquid.F;
511* the InletQ (the model requires an energy stream, also you can use a controller for setting the heat duty using the heat_flow model).
512
513== OPTIONAL ==
514* the SumpTank model has three control ports
515** TI OutletLiquid Temperature Indicator;
516** PI OutletLiquid Pressure Indicator;
517** LI Level Indicator;
518
519== INITIAL CONDITIONS ==
520* Initial_Temperature :  the Tank temperature (OutletLiquid.T);
521* Levelpercent_Initial : the Tank liquid level in percent (LI);
522* Initial_Composition : (NoComps) OutletLiquid compositions.
523";
524       
525PARAMETERS
526outer PP                as Plugin       (Brief = "External Physical Properties", Type="PP");
527outer NComp     as Integer      (Brief = "Number of components", Lower = 1);
528
529        Mw(NComp)               as molweight    (Brief="Mol Weight", Hidden=true);
530        pi                      as positive             (Brief="Pi value", Default=3.141593,Hidden=true, Symbol="\pi");
531        g                               as acceleration         (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
532       
533        Heads                   as Switcher     (Valid=["elliptical","hemispherical","flat"],Default="flat");
534        Diameter                as length               (Brief="Vessel diameter", Symbol="D_{i}");
535        Lenght                  as length               (Brief="Side length of the cylinder shell", Symbol="L_{vessel}");
536       
537        Vhead_elliptical                as volume               (Brief="Elliptical Head Total Volume",Hidden=true, Symbol="V_{head}^{elliptical}");
538        Vhead_hemispherical     as volume               (Brief="Hemispherical Head Total Volume",Hidden=true, Symbol="V_{head}^{hemispherical}");
539        Vcylinder                               as volume               (Brief="Cylinder Total Volume",Hidden=true, Symbol="V_{cylinder}");
540        radius                                  as length               (Brief="Vessel radius",Hidden=true, Symbol="R_{cylinder}");
541       
542        Levelpercent_Initial                    as positive     (Brief="Initial liquid height in Percent", Default = 0.70);
543        Temperature_Initial                             as temperature  (Brief="Initial Liquid Temperature", Default = 330);
544        Composition_Initial(NComp)              as fraction             (Brief="Initial Composition", Default = 0.10);
545
546SET
547
548        Mw=PP.MolecularWeight();
549
550        g = 9.81 * 'm/(s^2)';
551        Vhead_elliptical        = (pi*Diameter^3)/12;
552        Vhead_hemispherical = (pi*Diameter^3)/6;
553        Vcylinder = 0.25*(pi*Diameter^2)*Lenght;
554        radius = 0.5*Diameter;
555
556VARIABLES
557
558in      InletLiquid     as stream                       (Brief="Feed Stream", PosX=0.22, PosY=0, Symbol="_{in}");
559out     OutletLiquid    as liquid_stream        (Brief="Liquid outlet stream", PosX=0.50, PosY=1, Symbol="_{out}^{Liquid}");
560in      InletVapour     as stream                       (Brief="Vapour outlet stream", PosX=1, PosY=0.20, Symbol="_{out}^{Vapour}");
561out     OutletVapour    as vapour_stream        (Brief="Vapour outlet stream", PosX=0.68, PosY=0, Symbol="_{out}^{Vapour}");
562        InletQ                  as power                        (Brief="Heat Duty", Protected =false,Symbol="Q_{in}");
563
564        Vtotal                  as volume                       (Brief="Vessel total volume",Protected=true, Symbol="V_{total}");
565        Vfilled                 as volume                       (Brief="Vessel volume content",Protected=true, Symbol="V_{filled}");
566
567        TotalHoldup(NComp)              as mol  (Brief="Molar Holdup in the Vessel", Protected=true);
568        LiquidHoldup                    as mol  (Brief="Molar liquid holdup", Protected=true);
569        VapourHoldup                    as mol  (Brief="Molar vapour holdup", Protected=true);
570       
571        E                       as energy               (Brief="Total Energy Holdup in the Vessel", Protected=true);
572        vL                      as volume_mol   (Brief="Liquid Molar Volume", Protected=true);
573        vV                      as volume_mol   (Brief="Vapour Molar volume", Protected=true);
574        Level           as length               (Brief="liquid height", Protected=true);
575        Across          as area                 (Brief="Vessel cylinder shell Cross section area", Hidden=true, Symbol="A_{cross}");
576        Pdrop           as press_delta  (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P", Protected=true);
577
578        Peq                     as pressure             (Brief="Equilibrium pressure on the liquid surface", Protected=true, DisplayUnit = 'kPa', Symbol="P_{eq}");
579        Pstatic         as pressure             (Brief="Static head at the bottom of the tank", Protected = true, DisplayUnit = 'kPa', Symbol="P_{static}^{Liquid}");
580
581out     LI as control_signal    (Brief="Level Indicator", PosX=1, PosY=0.7, Protected=true);
582out     TI as control_signal    (Brief="Temperature Indicator", PosX=1, PosY=0.6, Protected=true);
583
584INITIAL
585
586"Initial level Percent"
587        LI = Levelpercent_Initial;
588       
589"Initial Outlet Liquid Temperature"
590        OutletLiquid.T = Temperature_Initial;
591       
592"Initial Outlet Liquid Composition Normalized"
593        OutletLiquid.z(1:NComp - 1) = Composition_Initial(1:NComp - 1)/sum(Composition_Initial);
594
595EQUATIONS
596
597"Vessel Cross Section Area"
598        Across = 0.25*(pi*Diameter^2);
599
600switch Heads
601
602case "elliptical":
603
604"Vessel Total Volume"
605        Vtotal = Vhead_elliptical +     Vcylinder;
606
607if Level < 0.25*Diameter then
608
609"Vessel Filled Volume"
610        Vfilled = 0.25*pi*(((Diameter*Level)/(0.25*Diameter))^2)*(0.25*Diameter-Level/3);
611
612else
613
614"Vessel Filled Volume"
615        Vfilled = 0.25*pi*(Diameter^2)*(Level - 0.25*Diameter/3);
616
617end
618
619case "hemispherical":
620
621"Vessel Total Volume"
622        Vtotal = Vhead_hemispherical + Vcylinder;
623
624if Level < 0.5*Diameter then
625
626"Vessel Filled Volume"
627        Vfilled = 0.25*pi*(Level^2)*(2*Diameter-4*Level/3);
628
629else
630
631"Vessel Filled Volume"
632        Vfilled = 0.25*pi*((2/3)*((0.5*Diameter)^3) - (0.25*(Diameter)^3) + Level*Diameter^2);
633
634end
635
636case "flat":
637
638"Vessel Total Volume"
639        Vtotal = Vcylinder;
640
641"Vessel Filled Volume"
642        Vfilled = Across*Level;
643
644end
645
646"Component Molar Balance"
647        diff(TotalHoldup) = InletLiquid.F*InletLiquid.z + InletVapour.F*InletVapour.z- OutletLiquid.F*OutletLiquid.z - OutletVapour.F*OutletVapour.z;
648       
649"Energy Balance"
650        diff(E) = InletLiquid.F*InletLiquid.h + InletVapour.F*InletVapour.h - OutletLiquid.F*OutletLiquid.h - OutletVapour.F*OutletVapour.h + InletQ;
651       
652"Molar Holdup"
653        TotalHoldup = LiquidHoldup*OutletLiquid.z + VapourHoldup*OutletVapour.z;
654       
655"Energy Holdup"
656        E = LiquidHoldup*OutletLiquid.h + VapourHoldup*OutletVapour.h - OutletLiquid.P*Vtotal;
657       
658"Mol fraction normalisation"
659        sum(OutletLiquid.z)=1.0;
660
661"Mol fraction normalisation"
662        sum(OutletLiquid.z)=sum(OutletVapour.z);
663
664"Liquid Volume"
665        vL = PP.LiquidVolume(OutletLiquid.T, Peq, OutletLiquid.z);
666
667"Vapour Volume"
668        vV = PP.VapourVolume(OutletVapour.T, Peq, OutletVapour.z);
669       
670"Chemical Equilibrium"
671        PP.LiquidFugacityCoefficient(OutletLiquid.T, Peq, OutletLiquid.z)*OutletLiquid.z =
672                PP.VapourFugacityCoefficient(OutletVapour.T, Peq, OutletVapour.z)*OutletVapour.z;
673       
674"Thermal Equilibrium"
675        OutletVapour.T = OutletLiquid.T;
676       
677"Mechanical Equilibrium for the Vapour Phase"
678        OutletVapour.P = Peq;
679       
680"Static Head"   
681        Pstatic = PP.LiquidDensity(OutletLiquid.T, Peq, OutletLiquid.z) * g * Level;
682
683"Mechanical Equilibrium for the Liquid Phase"
684        OutletLiquid.P = Peq + Pstatic;
685
686"Pressure Drop"
687        Pdrop = min([InletLiquid.P,InletVapour.P]) - OutletLiquid.P;
688        #OutletLiquid.P  = InletLiquid.P - Pdrop;
689
690"Geometry Constraint"
691        Vtotal = LiquidHoldup * vL + VapourHoldup * vV;
692
693"Level indicator"
694        LI*Vtotal= Vfilled;
695
696"Temperature indicator"
697        TI * 'K' = OutletLiquid.T;
698
699"Liquid Level"
700        LiquidHoldup * vL = Vfilled;
701
702end
703
Note: See TracBrowser for help on using the repository browser.