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

Last change on this file since 828 was 828, checked in by mamuller, 13 years ago

model TankL: Added the static head contribution to the OutletLiquid? pressure.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 21.6 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 828 2009-08-13 19:03:22Z mamuller $
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        g                               as acceleration         (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
314       
315        Orientation     as Switcher     (Valid=["vertical","horizontal"],Default="vertical");
316        Heads                   as Switcher     (Valid=["elliptical","hemispherical","flat"],Default="flat");
317        Diameter                as length               (Brief="Vessel diameter", Symbol="D_{i}");
318        Lenght                  as length               (Brief="Side length of the cylinder shell", Symbol="L_{vessel}");
319       
320        Vhead_elliptical                as volume               (Brief="Elliptical Head Total Volume",Hidden=true, Symbol="V_{head}^{elliptical}");
321        Vhead_hemispherical     as volume               (Brief="Hemispherical Head Total Volume",Hidden=true, Symbol="V_{head}^{hemispherical}");
322        Vcylinder                               as volume               (Brief="Cylinder Total Volume",Hidden=true, Symbol="V_{cylinder}");
323        radius                                  as length               (Brief="Vessel radius",Hidden=true, Symbol="R_{cylinder}");
324       
325        Levelpercent_Initial                    as positive     (Brief="Initial liquid height in Percent", Default = 0.70);
326        Temperature_Initial                             as temperature  (Brief="Initial Liquid Temperature", Default = 330);
327        Composition_Initial(NComp)              as fraction             (Brief="Initial Composition", Default = 0.10);
328
329SET
330
331        Vhead_elliptical        = (pi*Diameter^3)/12;
332        Vhead_hemispherical = (pi*Diameter^3)/6;
333        Vcylinder = 0.25*(pi*Diameter^2)*Lenght;
334        radius = 0.5*Diameter;
335
336VARIABLES
337
338in      Inlet                   as stream                       (Brief="Feed Stream", PosX=0.22, PosY=0, Symbol="_{in}");
339out     OutletLiquid    as liquid_stream        (Brief="Liquid outlet stream", PosX=0.43, PosY=1, Symbol="_{out}^{Liquid}");
340in      InletQ                  as power                        (Brief="Heat Duty", PosX=0.735, PosY=1, Protected =true,Symbol="Q_{in}");
341
342        Vtotal                  as volume                       (Brief="Vessel total volume",Protected=true, Symbol="V_{total}");
343        Vfilled                 as volume                       (Brief="Vessel volume content",Protected=true, Symbol="V_{filled}");
344
345        TotalHoldup(NComp)              as mol  (Brief="Molar Holdup in the Vessel", Protected=true);
346       
347        E                       as energy               (Brief="Total Energy Holdup in the Vessel", Protected=true);
348        vL                      as volume_mol   (Brief="Liquid Molar Volume", Protected=true);
349        Level           as length               (Brief="liquid height", Protected=true);
350        Across          as area                 (Brief="Vessel cylinder shell Cross section area", Hidden=true, Symbol="A_{cross}");
351
352        Pstatic         as pressure             (Brief="Static head at the bottom of the tank", Protected = true, Symbol="P_{static}^{Liquid}");
353
354out     TI as control_signal    (Brief="Temperature Indicator", PosX=0.525, PosY=0, Protected=true);
355out     PI as control_signal    (Brief="Pressure Indicator", PosX=0.368, PosY=0, Protected=true);
356out     LI as control_signal    (Brief="Level Indicator", PosX=1, PosY=0.6, Protected=true);
357
358INITIAL
359
360"Initial level Percent"
361        LI = Levelpercent_Initial;
362       
363"Initial Outlet Liquid Temperature"
364        OutletLiquid.T = Temperature_Initial;
365       
366"Initial Outlet Liquid Composition Normalized"
367        OutletLiquid.z(1:NComp - 1) = Composition_Initial(1:NComp - 1)/sum(Composition_Initial);
368
369EQUATIONS
370
371switch Orientation
372
373case "vertical":
374
375"Vessel Cross Section Area"
376        Across = 0.25*(pi*Diameter^2);
377
378switch Heads
379
380case "elliptical":
381
382"Vessel Total Volume"
383        Vtotal = Vhead_elliptical +     Vcylinder;
384
385if Level < 0.25*Diameter then
386
387"Vessel Filled Volume"
388        Vfilled = 0.25*pi*(((Diameter*Level)/(0.25*Diameter))^2)*(0.25*Diameter-Level/3);
389
390else
391
392"Vessel Filled Volume"
393        Vfilled = 0.25*pi*(Diameter^2)*(Level - 0.25*Diameter/3);
394
395end
396
397case "hemispherical":
398
399"Vessel Total Volume"
400        Vtotal = Vhead_hemispherical + Vcylinder;
401
402if Level < 0.5*Diameter then
403
404"Vessel Filled Volume"
405        Vfilled = 0.25*pi*(Level^2)*(2*Diameter-4*Level/3);
406
407else
408
409"Vessel Filled Volume"
410        Vfilled = 0.25*pi*((2/3)*((0.5*Diameter)^3) - (0.25*(Diameter)^3) + Level*Diameter^2);
411
412end
413
414case "flat":
415
416"Vessel Total Volume"
417        Vtotal = Vcylinder;
418
419"Vessel Filled Volume"
420        Vfilled = Across*Level;
421
422end
423
424case "horizontal":
425
426"Vessel Cross Section Area"
427        Across = (radius^2)*acos((radius-Level)/radius)-(radius-Level)*sqrt((2*radius*Level-Level^2));
428
429switch Heads
430
431case "elliptical":
432
433"Vessel Total Volume"
434        Vtotal = Vhead_elliptical +     Vcylinder;
435
436"Vessel Filled Volume"
437        Vfilled = 0.5236*Level^2*(1.5*Diameter-Level) + Across*Lenght;
438
439case "hemispherical":
440
441"Vessel Total Volume"
442        Vtotal = Vhead_hemispherical + Vcylinder;
443
444"Vessel Filled Volume"
445        Vfilled = 1.0472*Level^2*(1.5*Diameter-Level) + Across*Lenght;
446
447case "flat":
448
449"Vessel Total Volume"
450        Vtotal = Vcylinder;
451
452"Vessel Filled Volume"
453        Vfilled = Across*Lenght;
454
455end
456
457end
458
459"Component Molar Balance"
460        diff(TotalHoldup)=Inlet.F*Inlet.z - OutletLiquid.F*OutletLiquid.z;
461       
462"Energy Balance"
463        diff(E) = Inlet.F*Inlet.h - OutletLiquid.F*OutletLiquid.h + InletQ;
464
465"Energy Holdup"
466        E = sum(TotalHoldup)*OutletLiquid.h;
467
468"Static Head"   
469        Pstatic = PP.LiquidDensity(OutletLiquid.T, Inlet.P, OutletLiquid.z) * g * Level;
470
471"Mechanical Equilibrium"
472        Inlet.P + Pstatic = OutletLiquid.P;
473
474"Liquid Volume"
475        vL = PP.LiquidVolume(OutletLiquid.T, OutletLiquid.P, OutletLiquid.z);
476
477"Molar Holdup"
478        TotalHoldup = OutletLiquid.z*sum(TotalHoldup);
479       
480"Liquid Level"
481        Vfilled = sum(TotalHoldup) * vL;
482       
483"Temperature indicator"
484        TI * 'K' = OutletLiquid.T;
485
486"Pressure indicator"
487        PI * 'atm' = OutletLiquid.P;
488
489"Level indicator"
490        LI*Vtotal= Vfilled;
491
492end
493
494Model SumpTank
495
496ATTRIBUTES
497        Pallete         = true;
498        Icon            = "icon/SumpTank";
499        Brief           = "Model of a tank with 2 material inlet streams and with thermodynamic equilibrium.";
500        Info            =
501"== ASSUMPTIONS ==
502* perfect mixing of both phases;
503* thermodynamics equilibrium.
504
505== SET ==
506*Orientation: vessel position - vertical or horizontal;
507*Heads (bottom and top heads are identical)
508**elliptical: 2:1 elliptical heads (25% of vessel diameter);
509**hemispherical: hemispherical heads (50% of vessel diameter);
510**flat: flat heads (0% of vessel diameter);
511*Diameter: Vessel diameter;
512*Lenght: Side length of the cylinder shell;
513       
514== SPECIFY ==
515* the Inlet stream;
516* the outlet flows: OutletVapour.F and OutletLiquid.F;
517* the InletQ (the model requires an energy stream, also you can use a controller for setting the heat duty using the heat_flow model).
518
519== OPTIONAL ==
520* the SumpTank model has three control ports
521** TI OutletLiquid Temperature Indicator;
522** PI OutletLiquid Pressure Indicator;
523** LI Level Indicator;
524
525== INITIAL CONDITIONS ==
526* Initial_Temperature :  the Tank temperature (OutletLiquid.T);
527* Levelpercent_Initial : the Tank liquid level in percent (LI);
528* Initial_Composition : (NoComps) OutletLiquid compositions.
529";
530       
531PARAMETERS
532outer PP                as Plugin       (Brief = "External Physical Properties", Type="PP");
533outer NComp     as Integer      (Brief = "Number of components", Lower = 1);
534
535        Mw(NComp)               as molweight    (Brief="Mol Weight", Hidden=true);
536        pi                      as positive             (Brief="Pi value", Default=3.141593,Hidden=true, Symbol="\pi");
537        g                               as acceleration         (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
538       
539        Heads                   as Switcher     (Valid=["elliptical","hemispherical","flat"],Default="flat");
540        Diameter                as length               (Brief="Vessel diameter", Symbol="D_{i}");
541        Lenght                  as length               (Brief="Side length of the cylinder shell", Symbol="L_{vessel}");
542       
543        Vhead_elliptical                as volume               (Brief="Elliptical Head Total Volume",Hidden=true, Symbol="V_{head}^{elliptical}");
544        Vhead_hemispherical     as volume               (Brief="Hemispherical Head Total Volume",Hidden=true, Symbol="V_{head}^{hemispherical}");
545        Vcylinder                               as volume               (Brief="Cylinder Total Volume",Hidden=true, Symbol="V_{cylinder}");
546        radius                                  as length               (Brief="Vessel radius",Hidden=true, Symbol="R_{cylinder}");
547       
548        Levelpercent_Initial                    as positive     (Brief="Initial liquid height in Percent", Default = 0.70);
549        Temperature_Initial                             as temperature  (Brief="Initial Liquid Temperature", Default = 330);
550        Composition_Initial(NComp)              as fraction             (Brief="Initial Composition", Default = 0.10);
551
552SET
553
554        Mw=PP.MolecularWeight();
555
556        g = 9.81 * 'm/(s^2)';
557        Vhead_elliptical        = (pi*Diameter^3)/12;
558        Vhead_hemispherical = (pi*Diameter^3)/6;
559        Vcylinder = 0.25*(pi*Diameter^2)*Lenght;
560        radius = 0.5*Diameter;
561
562VARIABLES
563
564in      InletLiquid     as stream                       (Brief="Feed Stream", PosX=0.22, PosY=0, Symbol="_{in}");
565out     OutletLiquid    as liquid_stream        (Brief="Liquid outlet stream", PosX=0.50, PosY=1, Symbol="_{out}^{Liquid}");
566in      InletVapour     as stream                       (Brief="Vapour outlet stream", PosX=1, PosY=0.20, Symbol="_{out}^{Vapour}");
567out     OutletVapour    as vapour_stream        (Brief="Vapour outlet stream", PosX=0.68, PosY=0, Symbol="_{out}^{Vapour}");
568        InletQ                  as power                        (Brief="Heat Duty", Protected =false,Symbol="Q_{in}");
569
570        Vtotal                  as volume                       (Brief="Vessel total volume",Protected=true, Symbol="V_{total}");
571        Vfilled                 as volume                       (Brief="Vessel volume content",Protected=true, Symbol="V_{filled}");
572
573        TotalHoldup(NComp)              as mol  (Brief="Molar Holdup in the Vessel", Protected=true);
574        LiquidHoldup                    as mol  (Brief="Molar liquid holdup", Protected=true);
575        VapourHoldup                    as mol  (Brief="Molar vapour holdup", Protected=true);
576       
577        E                       as energy               (Brief="Total Energy Holdup in the Vessel", Protected=true);
578        vL                      as volume_mol   (Brief="Liquid Molar Volume", Protected=true);
579        vV                      as volume_mol   (Brief="Vapour Molar volume", Protected=true);
580        Level           as length               (Brief="liquid height", Protected=true);
581        Across          as area                 (Brief="Vessel cylinder shell Cross section area", Hidden=true, Symbol="A_{cross}");
582        #Pdrop          as press_delta  (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P", Protected=true);
583
584        Peq             as pressure             (Brief="Equilibrium pressure on the liquid surface", Protected=true, Symbol="P_{eq}");
585        Pstatic         as pressure             (Brief="Static head at the bottom of the tank", Protected = true, Symbol="P_{static}^{Liquid}");
586
587out     LI as control_signal    (Brief="Level Indicator", PosX=1, PosY=0.7, Protected=true);
588out     TI as control_signal    (Brief="Temperature Indicator", PosX=1, PosY=0.6, Protected=true);
589
590INITIAL
591
592"Initial level Percent"
593        LI = Levelpercent_Initial;
594       
595"Initial Outlet Liquid Temperature"
596        OutletLiquid.T = Temperature_Initial;
597       
598"Initial Outlet Liquid Composition Normalized"
599        OutletLiquid.z(1:NComp - 1) = Composition_Initial(1:NComp - 1)/sum(Composition_Initial);
600
601EQUATIONS
602
603"Vessel Cross Section Area"
604        Across = 0.25*(pi*Diameter^2);
605
606switch Heads
607
608case "elliptical":
609
610"Vessel Total Volume"
611        Vtotal = Vhead_elliptical +     Vcylinder;
612
613if Level < 0.25*Diameter then
614
615"Vessel Filled Volume"
616        Vfilled = 0.25*pi*(((Diameter*Level)/(0.25*Diameter))^2)*(0.25*Diameter-Level/3);
617
618else
619
620"Vessel Filled Volume"
621        Vfilled = 0.25*pi*(Diameter^2)*(Level - 0.25*Diameter/3);
622
623end
624
625case "hemispherical":
626
627"Vessel Total Volume"
628        Vtotal = Vhead_hemispherical + Vcylinder;
629
630if Level < 0.5*Diameter then
631
632"Vessel Filled Volume"
633        Vfilled = 0.25*pi*(Level^2)*(2*Diameter-4*Level/3);
634
635else
636
637"Vessel Filled Volume"
638        Vfilled = 0.25*pi*((2/3)*((0.5*Diameter)^3) - (0.25*(Diameter)^3) + Level*Diameter^2);
639
640end
641
642case "flat":
643
644"Vessel Total Volume"
645        Vtotal = Vcylinder;
646
647"Vessel Filled Volume"
648        Vfilled = Across*Level;
649
650end
651
652"Component Molar Balance"
653        diff(TotalHoldup) = InletLiquid.F*InletLiquid.z + InletVapour.F*InletVapour.z- OutletLiquid.F*OutletLiquid.z - OutletVapour.F*OutletVapour.z;
654       
655"Energy Balance"
656        diff(E) = InletLiquid.F*InletLiquid.h + InletVapour.F*InletVapour.h - OutletLiquid.F*OutletLiquid.h - OutletVapour.F*OutletVapour.h + InletQ;
657       
658"Molar Holdup"
659        TotalHoldup = LiquidHoldup*OutletLiquid.z + VapourHoldup*OutletVapour.z;
660       
661"Energy Holdup"
662        E = LiquidHoldup*OutletLiquid.h + VapourHoldup*OutletVapour.h - OutletLiquid.P*Vtotal;
663       
664"Mol fraction normalisation"
665        sum(OutletLiquid.z)=1.0;
666
667"Mol fraction normalisation"
668        sum(OutletLiquid.z)=sum(OutletVapour.z);
669
670"Liquid Volume"
671        vL = PP.LiquidVolume(OutletLiquid.T, Peq, OutletLiquid.z);
672
673"Vapour Volume"
674        vV = PP.VapourVolume(OutletVapour.T, Peq, OutletVapour.z);
675       
676"Chemical Equilibrium"
677        PP.LiquidFugacityCoefficient(OutletLiquid.T, Peq, OutletLiquid.z)*OutletLiquid.z =
678                PP.VapourFugacityCoefficient(OutletVapour.T, Peq, OutletVapour.z)*OutletVapour.z;
679       
680"Thermal Equilibrium"
681        OutletVapour.T = OutletLiquid.T;
682       
683"Mechanical Equilibrium for the Vapour Phase"
684        OutletVapour.P = Peq;
685       
686"Static Head"   
687        Pstatic = PP.LiquidDensity(OutletLiquid.T, Peq, OutletLiquid.z) * g * Level;
688
689"Mechanical Equilibrium for the Liquid Phase"
690        OutletLiquid.P = Peq + Pstatic;
691
692#*"Pressure Drop"
693        Pdrop = min([InletLiquid.P,InletVapour.P]) - OutletLiquid.P;
694        #OutletLiquid.P  = InletLiquid.P - Pdrop;
695*#
696
697"Geometry Constraint"
698        Vtotal = LiquidHoldup * vL + VapourHoldup * vV;
699
700"Level indicator"
701        LI*Vtotal= Vfilled;
702
703"Temperature indicator"
704        TI * 'K' = OutletLiquid.T;
705
706"Liquid Level"
707        LiquidHoldup * vL = Vfilled;
708
709end
710
Note: See TracBrowser for help on using the repository browser.