source: branches/gui/eml/stage_separators/column.mso @ 901

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

added composition indicator on the PackedColumn? model

File size: 102.3 KB
RevLine 
[715]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*----------------------------------------------------------------------
16* File containg models of columns: distillation, stripping, absorbers
17* rectifier, ....
18*
19* The default nomenclature is:
20*               Type_Column_reboilertype_condensertyper
21*
22* where:
23*       Type = refluxed or reboiled or section
24*       Column = Stripping, Absorption, Rectifier, Distillation
25*       Reboiler type (if exists) = kettle or thermosyphon
26*       Condenser type (if exists) = with subccoling or without subcooling
27*
28*-----------------------------------------------------------------------
29* Author: Paula B. Staudt
30* $Id: column.mso 511 2008-05-12 17:25:33Z paula $
31*---------------------------------------------------------------------*#
32
33using "tray";
34using "reboiler";
35using "condenser";
36using "mixers_splitters/splitter";
37using "tank";
38using "pressure_changers/pump";
39
[771]40Model ControlSection
41
42ATTRIBUTES
43        Pallete = false;
44        Brief = "Control variables for column section.";
45
46PARAMETERS
47        outer NComp             as Integer      (Brief="Number of components");
48
49        Tindicator_TrayNumber   as Integer      (Brief="Temperature Indicator in the tray");
50        Pindicator_TrayNumber   as Integer      (Brief="Pressure Indicator in the tray");
[901]51        zindicator_TrayNumber   as Integer      (Brief="Composition Indicator in the tray");
52        zindicator_Component    as Integer      (Brief="Component to indicate");
[771]53
54end
55
[715]56Model InitializeSection
57
58ATTRIBUTES
59        Pallete = false;
[719]60        Brief = "Initial conditions for column section.";
[715]61
62PARAMETERS
63        outer NComp             as Integer      (Brief="Number of components");
64
65        TopTemperature          as temperature  (Brief = "Tray Temperature at Column Top", Default = 300);
66        BottomTemperature       as temperature  (Brief = "Tray Temperature at Column Bottom", Default = 330);
[721]67        LevelFraction           as fraction             (Brief = "Tray Level Fraction", Default = 0.5);
[715]68
69        TopComposition(NComp)           as fraction     (Brief = "Component Molar Fraction at Column Top", Default = 0.30);
70        BottomComposition(NComp)        as fraction     (Brief = "Component Molar Fraction at Column Bottom", Default = 0.30);
71
72end
73
[721]74Model InitializeStage
75
76ATTRIBUTES
77        Pallete = false;
78        Brief = "Initial conditions for Packed column section.";
79
80PARAMETERS
81        outer NComp             as Integer      (Brief="Number of components");
82
83        TopStageTemperature             as temperature  (Brief = "Tray Temperature at Column Top", Default = 300);
84        BottomStageTemperature          as temperature  (Brief = "Tray Temperature at Column Bottom", Default = 300);
85       
86        TopStageComposition(NComp)              as fraction     (Brief = "Component Molar Fraction at Top");
87        BottomStageComposition(NComp)   as fraction     (Brief = "Component Molar Fraction at Bottom");
[873]88        ColumnHoldup                                    as positive (Brief = "Column holdup", Default=0.1);
[721]89
90end
91
[715]92
[787]93Model SectionColumnBasic
[775]94
[715]95ATTRIBUTES
[819]96        Pallete = false;
[787]97        Brief   = "Model of a basic column section.";
[819]98        Info    =
[787]99"Model of a basic column section containing a vetor of TRAYS numbered from the top-down.";
[715]100
[775]101PARAMETERS
[787]102        outer PP                as Plugin               (Brief="External Physical Properties", Type="PP");
103        outer NComp     as Integer              (Brief="Number of components");
[819]104
[787]105        NumberOfFeeds                                           as Integer                      (Brief="Number of Feed Trays",Default=3,Protected=true);
106        FeedTrayLocation(NumberOfFeeds)         as Integer                      (Brief="Feed tray Location",Default=2);
[775]107        NumberOfTrays                                           as Integer                      (Brief="Number of trays", Default=8);
108        LiqSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Liquid Side Tray Index", Default=0,Hidden=true);
109        VapSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Vapour Side Tray Index", Default=0,Hidden=true);
[787]110
[775]111        LiquidSideStreamLocation                        as Integer                      (Brief="Liquid Side Stream Location", Default=2);
112        VapourSideStreamLocation                        as Integer                      (Brief="Vapour Side Stream Location", Default=2);
[819]113
[775]114        VapourFlowModel         as Switcher     (Valid = ["Reepmeyer", "Feehery_Fv", "Roffel_Fv", "Klingberg", "Wang_Fv", "Elgue"], Default = "Reepmeyer");
[831]115        LiquidFlowModel         as Switcher     (Valid = ["Francis", "Wang_Fl", "Olsen", "Feehery_Fl", "Roffel_Fl"], Default = "Francis");
[819]116
[816]117        TrayDiameter                    as length               (Brief="Tray Diameter",Default=1.600);
118        TraySpacing                             as length               (Brief="Tray Spacing",Default=0.600);
119        Fraction_HoleArea               as fraction     (Brief="Fraction of the active area that is occupied by the holes with respect to the total tray area",Default=0.10);
120        Fraction_DowncomerArea  as fraction     (Brief="Fraction of the downcomer area with respect to the total tray area",Default=0.20);
[831]121        WeirLength                              as length               (Brief="Weir length", Default = 1);
122        WeirHeight                              as length               (Brief="Weir height", Default= 0.05);
123        TrayLiquidPasses                as positive     (Brief="Number of liquid passes in the tray", Lower = 1,Default=1);
124        HeatSupply                              as heat_rate    (Brief="Rate of heat supply",Default = 0);
[819]125        AerationFraction                as Real                 (Brief="Aeration fraction", Default = 1);
126        DryPdropCoeff                   as Real                 (Brief="Dry pressure drop coefficient", Default= 0.60);
[878]127        MurphreeEff                     as Real                 (Brief="Murphree efficiency for All Trays", Default= 1);
[775]128       
[715]129VARIABLES
[819]130
131        INITIALIZATION as InitializeSection (Brief="Column Model Initialization");
132        CONTROL                 as ControlSection (Brief="Column Model Control");
133       
[787]134        out     TCI as control_signal   (Brief="Temperature  Indicator", Protected = true, PosX=1, PosY=0.73);
135        out     PCI as control_signal   (Brief="Pressure Indicator", Protected = true, PosX=0, PosY=0.24);
[819]136       
137    in  LiquidInlet     as stream         (Brief="Liquid Inlet in the section", PosX=0.70, PosY=0);
138    out VapourOutlet    as vapour_stream  (Brief="Vapour Outlet in the section", PosX=0.30, PosY=0);
[806]139
[819]140    out VapourDrawOff   as vapour_stream  (Brief="Vapour Draw Off Port in the section", PosX=1, PosY=0.35,Protected = true);
141        out LiquidDrawOff   as liquid_stream  (Brief="Liquid Draw Off Port in the section", PosX=1, PosY=0.65,Protected = true);
[787]142       
[819]143        TRAYS(NumberOfTrays)    as tray                 (Brief="Number of trays in the Column Section",Protected=true);
[806]144        VapourDrawOffFlow               as flow_mol     (Brief="Vapour Draw Off Stream Molar Flow Rate");
145        LiquidDrawOffFlow               as flow_mol     (Brief="Vapour Draw Off Stream Molar Flow Rate");
[787]146
[806]147        in      VapourInlet     as stream             (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1);
148        out     LiquidOutlet    as liquid_stream      (Brief="Liquid Outlet in the section", PosX=0.70, PosY=1);
[787]149       
[819]150        LiquidConnector as stream    (Brief="Liquid connection in the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
151        VapourConnector as stream    (Brief="Vapour connection in the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
[878]152
153SET
154        VapSideTrayIndex(VapourSideStreamLocation) =1;
155        LiqSideTrayIndex(LiquidSideStreamLocation) =1;
[819]156       
[878]157        TRAYS.TrayDiameter_                             = TrayDiameter;
158        TRAYS.TraySpacing_                              = TraySpacing;
159        TRAYS.Fraction_HoleArea_                = Fraction_HoleArea;
160        TRAYS.Fraction_DowncomerArea_   = Fraction_DowncomerArea;
161        TRAYS.WeirLength_                               = WeirLength;
162        TRAYS.WeirHeight_                               = WeirHeight;
163        TRAYS.TrayLiquidPasses_                 = TrayLiquidPasses;
164        TRAYS.HeatSupply_                               = HeatSupply;
165        TRAYS.AerationFraction_                 = AerationFraction;
166        TRAYS.DryPdropCoeff_                    = DryPdropCoeff;
167        TRAYS.MurphreeEff_                              = MurphreeEff;
168
[715]169CONNECTIONS
[775]170        TRAYS([2:NumberOfTrays]).OutletVapour   to TRAYS([1:NumberOfTrays-1]).InletVapour;
[819]171        TRAYS([1:NumberOfTrays-1]).OutletLiquid to TRAYS([2:NumberOfTrays]).InletLiquid;
[878]172
[787]173    LiquidConnector to TRAYS(1).InletLiquid;
174    VapourConnector to TRAYS(NumberOfTrays).InletVapour;
[878]175
[775]176INITIAL
[819]177
[775]178for i in 1:NumberOfTrays do
179
180"The initial temperature of the TRAYS"
181        TRAYS(i).OutletLiquid.T = INITIALIZATION.TopTemperature+(INITIALIZATION.BottomTemperature-INITIALIZATION.TopTemperature)*((i-1)/(NumberOfTrays-1));
182
183"The initial Level of the TRAYS"
[816]184        TRAYS(i).Level = INITIALIZATION.LevelFraction*WeirHeight;
[775]185end
186
187for i in 1:NComp-1 do
188
189for j in 1:NumberOfTrays do
190
191"The initial composition of the TRAYS - Normalized"
192        TRAYS(j).OutletLiquid.z(i) = INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) +(INITIALIZATION.BottomComposition(i)/sum(INITIALIZATION.BottomComposition)-INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) )*((j-1)/(NumberOfTrays-1));
193end
194
195end
196
[715]197EQUATIONS
[775]198
199"Tray Temperature Indicator"   
200        #TCI*'K' = TRAYS(min([NumberOfTrays, CONTROL.Tindicator_TrayNumber])).OutletVapour.T;
201        TCI*'K' = TRAYS(CONTROL.Tindicator_TrayNumber).OutletVapour.T;
202
203"Tray Pressure Indicator"       
204        #PCI*'atm' = TRAYS(min([NumberOfTrays, CONTROL.Pindicator_TrayNumber])).OutletVapour.P;
205        PCI*'atm' = TRAYS(CONTROL.Pindicator_TrayNumber).OutletVapour.P;
206
[878]207switch LiquidFlowModel
208       
209        case "Francis":
210                TRAYS.LFlowModel = 1;
211        case "Wang_Fl":
212                TRAYS.LFlowModel = 2;
213       
214        case "Olsen":
215                TRAYS.LFlowModel = 3;
216       
217        case "Feehery_Fl":
218                TRAYS.LFlowModel = 4;
219       
220        case "Roffel_Fl":
221                TRAYS.LFlowModel = 5;
[775]222
[878]223end
224       
225switch VapourFlowModel
[775]226
[878]227        case "Reepmeyer":
228                TRAYS.VFlowModel = 1;
[775]229       
[878]230        case "Feehery_Fv":
231                TRAYS.VFlowModel = 2;                   
232       
233        case "Roffel_Fv":
234                TRAYS.VFlowModel = 3;                   
235       
236        case "Klingberg":
237                TRAYS.VFlowModel = 4;                   
238       
239        case "Wang_Fv":
240                TRAYS.VFlowModel = 5;                   
241       
242        case "Elgue":
243                TRAYS.VFlowModel = 6;
[775]244
245end
246
[721]247"Liquid Inlet Flow"     
248        LiquidConnector.F = LiquidInlet.F;
[715]249
[721]250"Liquid Inlet Temperature"             
[715]251        LiquidConnector.T = LiquidInlet.T;
[721]252
253"Liquid Inlet Pressure"         
[715]254        LiquidConnector.P = LiquidInlet.P;
[721]255
256"Liquid Inlet Composition"             
[715]257        LiquidConnector.z = LiquidInlet.z;
[721]258
259"Liquid Inlet Vapour Fraction"         
[715]260        LiquidConnector.v = LiquidInlet.v;
[721]261
262"Liquid Inlet Enthalpy"         
[715]263        LiquidConnector.h = LiquidInlet.h;
[819]264
[721]265"Vapour Inlet Flow"             
266        VapourConnector.F = VapourInlet.F;
267
268"Vapour Inlet Temperature"             
[715]269        VapourConnector.T = VapourInlet.T;
[721]270
271"Vapour Inlet Pressure"         
[715]272        VapourConnector.P = VapourInlet.P;
[721]273
274"Vapour Inlet Composition"             
[715]275        VapourConnector.z = VapourInlet.z;
[721]276
277"Vapour Inlet Vapour Fraction"         
[715]278        VapourConnector.v = VapourInlet.v;
[721]279
280"Vapour Inlet Enthalpy"         
[715]281        VapourConnector.h = VapourInlet.h;
[819]282
[721]283"Liquid Outlet Flow"   
[735]284        LiquidOutlet.F = TRAYS(NumberOfTrays).OutletLiquid.F;
[721]285
286"Liquid Outlet Temperature"     
[735]287        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
[721]288
289"Liquid Outlet Pressure"       
[735]290        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
[721]291
292"Liquid Outlet Composition"     
[735]293        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
[819]294
[721]295"Vapour Outlet Flow"           
[735]296        VapourOutlet.F = TRAYS(1).OutletVapour.F;
[721]297
298"Vapour Outlet Temperature"             
[735]299        VapourOutlet.T = TRAYS(1).OutletVapour.T;
[721]300
301"Vapour Outlet Pressure"               
[735]302        VapourOutlet.P = TRAYS(1).OutletVapour.P;
[721]303
304"Vapour Outlet Composition"             
[735]305        VapourOutlet.z = TRAYS(1).OutletVapour.z;
[819]306
[721]307"Vapour Draw Off Stream - Flow"         
308        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
[715]309
[721]310"Vapour Draw Off Stream - Temperature"         
[715]311        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
[721]312
313"Vapour Draw Off Stream - Pressure"             
[715]314        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
[721]315
316"Vapour Draw Off Stream - Composition"         
[715]317        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
318
[721]319"Vapour Draw Off Stream"       
320        VapourDrawOffFlow = VapourDrawOff.F;
[819]321
[721]322"Liquid Draw Off Stream - Flow"         
[715]323        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
[721]324
325"Liquid Draw Off Stream - Temperature" 
[715]326        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
[721]327
328"Liquid Draw Off Stream - Pressure"                     
[715]329        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
[721]330
331"Liquid Draw Off Stream - Composition" 
[715]332        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
333
[721]334"Liquid Draw Off Stream"       
[715]335        LiquidDrawOffFlow = LiquidDrawOff.F;
336
337end
[719]338
[787]339Model Section_Column    as SectionColumnBasic
[719]340
341ATTRIBUTES
[715]342        Pallete         = true;
[787]343        Icon            = "icon/SectionColumn";
344        Brief   = "Model of a column section.";
345        Info            =
346"== Model of a column section containing ==
347* NumberOfTrays TRAYS.
348* One Feed Inlet.
349       
350== Specify ==
351* the feed stream of each tray (Inlet);
352* the Murphree eficiency for each tray Emv;
353* the InletLiquid stream of the top tray;
354* the InletVapour stream of the bottom tray.
355       
356== Initial Conditions ==
357* the TRAYS temperature (OutletLiquid.T);
358* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
359* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
360";
361
362SET
363        NumberOfFeeds = 1;
364
365VARIABLES
366       
367        in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
368
369EQUATIONS
370#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
371# Equating Feed Tray Variables to Trays Variables
372#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[791]373for i in 1:NumberOfTrays do
[787]374
[791]375if   i equal FeedTrayLocation(1) then   
[787]376
[791]377"FeedTrayTop Inlet Flow"       
378        FeedTray.F= TRAYS(i).Inlet.F;
[787]379
[791]380"FeedTrayTop Inlet Temperature"
381        FeedTray.T = TRAYS(i).Inlet.T;
[787]382
[791]383"FeedTrayTop Inlet Pressure"
384        FeedTray.P = TRAYS(i).Inlet.P;
[787]385
[791]386"FeedTrayTop Inlet Composition"
387        FeedTray.z = TRAYS(i).Inlet.z;
[787]388
[791]389"FeedTrayTop Inlet Vapour Fraction"
390        FeedTray.v = TRAYS(i).Inlet.v;
391
392"FeedTrayTop Inlet Enthalpy"
393        FeedTray.h = TRAYS(i).Inlet.h;
394
395else
396
[832]397"Inlet Tray - Flow Sealed"
398    0*'mol/h'= TRAYS(i).Inlet.F;
399       
[791]400"Inlet Tray -  Temperature"
[832]401    300*'K' = TRAYS(i).Inlet.T;
402       
[791]403"Inlet Tray -  Pressure"
[832]404    1*'atm' = TRAYS(i).Inlet.P;
405       
[791]406"Inlet Tray -  Composition"
[832]407    0.1 = TRAYS(i).Inlet.z;
408       
[791]409"Inlet Tray -  Vapour Fraction"
[832]410    0 = TRAYS(i).Inlet.v;
411       
[791]412"Inlet Tray -  Enthalpy"
[832]413    0*'J/mol' = TRAYS(i).Inlet.h;
[791]414
[787]415end
416
[791]417end
418
419end
420
[787]421Model Section_Column2   as SectionColumnBasic
422
423ATTRIBUTES
424        Pallete         = true;
425        Icon            = "icon/SectionColumn";
426        Brief   = "Model of a column section.";
427        Info            =
428"== Model of a column section containing ==
429* NumberOfTrays TRAYS.
430* Two Feed Inlets.
431       
432== Specify ==
433* the feed stream of each tray (Inlet);
434* the Murphree eficiency for each tray Emv;
435* the InletLiquid stream of the top tray;
436* the InletVapour stream of the bottom tray.
437       
438== Initial Conditions ==
439* the TRAYS temperature (OutletLiquid.T);
440* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
441* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
442";
443
444SET
445        NumberOfFeeds = 2;
446
447VARIABLES
448       
449        in      FeedTrayOne     as stream               (Brief="Feed stream", PosX=0, PosY=0.45);
450        in      FeedTrayTwo     as stream               (Brief="Feed stream", PosX=0, PosY=0.65);
451
452EQUATIONS
453
454for i in 1:NumberOfTrays do
455
456if   i equal FeedTrayLocation(1) then   
457
458"FeedTrayTop Inlet Flow"       
459        FeedTrayOne.F= TRAYS(i).Inlet.F;
460
461"FeedTrayTop Inlet Temperature"
462        FeedTrayOne.T = TRAYS(i).Inlet.T;
463
464"FeedTrayTop Inlet Pressure"
465        FeedTrayOne.P = TRAYS(i).Inlet.P;
466
467"FeedTrayTop Inlet Composition"
468        FeedTrayOne.z = TRAYS(i).Inlet.z;
469
470"FeedTrayTop Inlet Vapour Fraction"
471        FeedTrayOne.v = TRAYS(i).Inlet.v;
472
473"FeedTrayTop Inlet Enthalpy"
474        FeedTrayOne.h = TRAYS(i).Inlet.h;
475
476else if   i equal FeedTrayLocation(2) then   
477
478"FeedTrayBottom Inlet Flow"     
479        FeedTrayTwo.F= TRAYS(i).Inlet.F;
480
481"FeedTrayBottom Inlet Temperature"
482        FeedTrayTwo.T = TRAYS(i).Inlet.T;
483
484"FeedTrayBottom Inlet Pressure"
485        FeedTrayTwo.P = TRAYS(i).Inlet.P;
486
487"FeedTrayBottom Inlet Composition"
488        FeedTrayTwo.z = TRAYS(i).Inlet.z;
489
490"FeedTrayBottom Inlet Vapour Fraction"
491        FeedTrayTwo.v = TRAYS(i).Inlet.v;
492
493"FeedTrayBottom Inlet Enthalpy"
494        FeedTrayTwo.h = TRAYS(i).Inlet.h;
495
496else
497
[832]498"Inlet Tray - Flow Sealed"
499    0*'mol/h'= TRAYS(i).Inlet.F;
500       
[787]501"Inlet Tray -  Temperature"
[832]502    300*'K' = TRAYS(i).Inlet.T;
503       
[787]504"Inlet Tray -  Pressure"
[832]505    1*'atm' = TRAYS(i).Inlet.P;
506       
[787]507"Inlet Tray -  Composition"
[832]508    0.1 = TRAYS(i).Inlet.z;
509       
[787]510"Inlet Tray -  Vapour Fraction"
[832]511    0 = TRAYS(i).Inlet.v;
512       
[787]513"Inlet Tray -  Enthalpy"
[832]514    0*'J/mol' = TRAYS(i).Inlet.h;
[787]515
516end
517
518end
519
520end
521
522end
523
524Model Section_Column3   as SectionColumnBasic
525
526ATTRIBUTES
527        Pallete         = true;
528        Icon            = "icon/SectionColumn";
529        Brief   = "Model of a column section.";
530        Info            =
531"== Model of a column section containing ==
532* NumberOfTrays TRAYS.
533* Three Feed Inlets.
534       
535== Specify ==
536* the feed stream of each tray (Inlet);
537* the Murphree eficiency for each tray Emv;
538* the InletLiquid stream of the top tray;
539* the InletVapour stream of the bottom tray.
540       
541== Initial Conditions ==
542* the TRAYS temperature (OutletLiquid.T);
543* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
544* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
545";
546
547SET
548        NumberOfFeeds = 3;
549
550VARIABLES
551       
552        in      FeedTrayOne     as stream               (Brief="Feed stream", PosX=0, PosY=0.45);
553        in      FeedTrayTwo     as stream               (Brief="Feed stream", PosX=0, PosY=0.65);
554        in      FeedTrayThree   as stream               (Brief="Feed stream", PosX=0, PosY=0.85);
555
556EQUATIONS
557
558for i in 1:NumberOfTrays do
559
560if   i equal FeedTrayLocation(1) then   
561
562"FeedTrayTop Inlet Flow"       
563        FeedTrayOne.F= TRAYS(i).Inlet.F;
564
565"FeedTrayTop Inlet Temperature"
566        FeedTrayOne.T = TRAYS(i).Inlet.T;
567
568"FeedTrayTop Inlet Pressure"
569        FeedTrayOne.P = TRAYS(i).Inlet.P;
570
571"FeedTrayTop Inlet Composition"
572        FeedTrayOne.z = TRAYS(i).Inlet.z;
573
574"FeedTrayTop Inlet Vapour Fraction"
575        FeedTrayOne.v = TRAYS(i).Inlet.v;
576
577"FeedTrayTop Inlet Enthalpy"
578        FeedTrayOne.h = TRAYS(i).Inlet.h;
579
580else if   i equal FeedTrayLocation(2) then   
581
582"FeedTrayBottom Inlet Flow"     
583        FeedTrayTwo.F= TRAYS(i).Inlet.F;
584
585"FeedTrayBottom Inlet Temperature"
586        FeedTrayTwo.T = TRAYS(i).Inlet.T;
587
588"FeedTrayBottom Inlet Pressure"
589        FeedTrayTwo.P = TRAYS(i).Inlet.P;
590
591"FeedTrayBottom Inlet Composition"
592        FeedTrayTwo.z = TRAYS(i).Inlet.z;
593
594"FeedTrayBottom Inlet Vapour Fraction"
595        FeedTrayTwo.v = TRAYS(i).Inlet.v;
596
597"FeedTrayBottom Inlet Enthalpy"
598        FeedTrayTwo.h = TRAYS(i).Inlet.h;
599
600else if   i equal FeedTrayLocation(3) then   
601
602"FeedTrayBottom Inlet Flow"     
603        FeedTrayThree.F= TRAYS(i).Inlet.F;
604
605"FeedTrayBottom Inlet Temperature"
606        FeedTrayThree.T = TRAYS(i).Inlet.T;
607
608"FeedTrayBottom Inlet Pressure"
609        FeedTrayThree.P = TRAYS(i).Inlet.P;
610
611"FeedTrayBottom Inlet Composition"
612        FeedTrayThree.z = TRAYS(i).Inlet.z;
613
614"FeedTrayBottom Inlet Vapour Fraction"
615        FeedTrayThree.v = TRAYS(i).Inlet.v;
616
617"FeedTrayBottom Inlet Enthalpy"
618        FeedTrayThree.h = TRAYS(i).Inlet.h;
619
620else
621
[832]622"Inlet Tray - Flow Sealed"
623    0*'mol/h'= TRAYS(i).Inlet.F;
624       
[787]625"Inlet Tray -  Temperature"
[832]626    300*'K' = TRAYS(i).Inlet.T;
627       
[787]628"Inlet Tray -  Pressure"
[832]629    1*'atm' = TRAYS(i).Inlet.P;
630       
[787]631"Inlet Tray -  Composition"
[832]632    0.1 = TRAYS(i).Inlet.z;
633       
[787]634"Inlet Tray -  Vapour Fraction"
[832]635    0 = TRAYS(i).Inlet.v;
636       
[787]637"Inlet Tray -  Enthalpy"
[832]638    0*'J/mol' = TRAYS(i).Inlet.h;
[787]639
640end
641
642end
643
644end
645
646end
647
648end
649
[793]650
[885]651Model Packed_Section_ColumnBasic
652
653ATTRIBUTES
654        Pallete         = false;
655        Icon            = "icon/PackedSectionColumn";
656        Brief           = "Model of a packed column section.";
657        Info            =
658"== Model of a packed column section containing ==
659* NStages theoretical stages.
660       
661== Specify ==
662* the feed stream of each tray (Inlet);
663* the InletLiquid stream of the top tray;
664* the InletVapour stream of the bottom tray;
665* the total pressure drop (dP) of the section.
666       
667== Initial Conditions ==
668* the stages temperature (OutletLiquid.T);
669* the stages liquid holdup;
670* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
671";
672       
673PARAMETERS
674
675        outer PP                as Plugin       (Brief = "External Physical Properties", Type="PP");
676        outer NComp     as Integer      (Brief="Number of components",Protected=true);
677       
678
679        NumberOfFeeds                                           as Integer      (Brief="Number of Feed Stages",Default=3,Protected=true);
680        NumberOfStages                                          as Integer      (Brief="Number of Stages", Default=3);
681        FeedStageLocation(NumberOfFeeds)        as Integer      (Brief="Feed Stage Location",Default=2);
682       
683        PackingHeight           as length               (Brief="Height of packing");
684        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
685        ColumnDiameter          as length               (Brief="Column diameter");
686        VoidFraction            as Real                 (Brief="Void fraction of packing, (m^3 void space/m^3 packed bed)");
687        ResistanceCoeff         as positive     (Brief="Resistance coefficient on the liquid load", Default=1);
688        AreaPerPackingVol       as Real                 (Brief="surface area per packing volume", Unit='m^2/m^3');
689        HETP                            as length               (Brief="The Height Equivalent to a Theoretical Plate",Protected=true);
690
691VARIABLES
692
693        INITIALIZATION  as InitializeStage      (Brief = "Column Model Initialization");
694        CONTROL                 as ControlSection (Brief="Column Model Control");
695       
696        out     TCI as control_signal   (Brief="Temperature  Indicator", Protected = true, PosX=1, PosY=0.73);
697        out     PCI as control_signal   (Brief="Pressure Indicator", Protected = true, PosX=0, PosY=0.24);
[901]698        out zCI as control_signal       (Brief="Composition control", Protected = true, PosX=1, PosY=0.8);
[885]699       
700        in      LiquidInlet             as      stream                          (Brief="Liquid Inlet in the section", PosX=0.70, PosY=0,Protected=true);
701        out     VapourOutlet            as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.30, PosY=0,Protected=true);
702       
[901]703        in      VapourInlet             as stream                               (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1,Protected=true);
[885]704        out     LiquidOutlet            as liquid_stream                (Brief="Liquid Outlet in the section", PosX=0.70, PosY=1,Protected=true);
705       
706        LiquidConnector as stream       (Brief="Liquid connection at the middle STAGES", PosX=0.75, PosY=1,Hidden=true);
707        VapourConnector as stream       (Brief="Vapour connection at the middle STAGES", PosX=0.55, PosY=0,Hidden=true);
708       
709        STAGES(NumberOfStages) as packedStage (Brief="Column Stages",Protected=true);
710        PressureDrop               as pressure (Brief="Column Pressure Drop", Protected=true);
711
712SET
713
714        STAGES.Number_Stages                            = NumberOfStages;
715        STAGES.HeightOfPacking                          = PackingHeight;
716        STAGES.HeatOnStage                                      = HeatSupply;
717        STAGES.ColumnInternalDiameter           = ColumnDiameter;
718        STAGES.PackingVoidFraction                      = VoidFraction;
719        STAGES.LiquidResistanceCoeff            = ResistanceCoeff ;
720        STAGES.AreaPerPackingVolume             = AreaPerPackingVol;
721       
722        HETP = PackingHeight/NumberOfStages;   
723
724CONNECTIONS
725
726        STAGES([2:NumberOfStages]).OutletVapour         to STAGES([1:NumberOfStages-1]).InletVapour;
727        STAGES([1:NumberOfStages-1]).OutletLiquid       to STAGES([2:NumberOfStages]).InletLiquid;
728        LiquidConnector                                                         to STAGES(1).InletLiquid;
729        VapourConnector                                                         to STAGES(NumberOfStages).InletVapour;
730
731EQUATIONS
732
733        LiquidConnector.F= LiquidInlet.F;
734        LiquidConnector.T = LiquidInlet.T;
735        LiquidConnector.P = LiquidInlet.P;
736        LiquidConnector.z = LiquidInlet.z;
737        LiquidConnector.v = LiquidInlet.v;
738        LiquidConnector.h = LiquidInlet.h;
739       
740        VapourConnector.F= VapourInlet.F;
741        VapourConnector.T = VapourInlet.T;
742        VapourConnector.P = VapourInlet.P;
743        VapourConnector.z = VapourInlet.z;
744        VapourConnector.v = VapourInlet.v;
745        VapourConnector.h = VapourInlet.h;
746       
747        LiquidOutlet.F= STAGES(NumberOfStages).OutletLiquid.F;
748        LiquidOutlet.T = STAGES(NumberOfStages).OutletLiquid.T;
749        LiquidOutlet.P = STAGES(NumberOfStages).OutletLiquid.P;
750        LiquidOutlet.z = STAGES(NumberOfStages).OutletLiquid.z;
751       
752        VapourOutlet.F= STAGES(1).OutletVapour.F;
753        VapourOutlet.T = STAGES(1).OutletVapour.T;
754        VapourOutlet.P = STAGES(1).OutletVapour.P;
755        VapourOutlet.z = STAGES(1).OutletVapour.z;
756
757"Tray Temperature Indicator"   
758        #TCI*'K' = TRAYS(min([NumberOfTrays, CONTROL.Tindicator_TrayNumber])).OutletVapour.T;
759        TCI*'K' = STAGES(CONTROL.Tindicator_TrayNumber).OutletVapour.T;
760
761"Tray Pressure Indicator"       
762        #PCI*'atm' = TRAYS(min([NumberOfTrays, CONTROL.Pindicator_TrayNumber])).OutletVapour.P;
763        PCI*'atm' = STAGES(CONTROL.Pindicator_TrayNumber).OutletVapour.P;
[901]764       
765"Tray Composition Indicator"   
766        #zCI * .000001 = STAGES(CONTROL.zindicator_TrayNumber).OutletVapour.z(CONTROL.zindicator_Component) * STAGES(CONTROL.zindicator_TrayNumber).Mw(CONTROL.zindicator_Component) ; #/sum(STAGES(CONTROL.zindicator_TrayNumber).Mw*STAGES(CONTROL.zindicator_TrayNumber).OutletLiquid.z);   
767        zCI * 1e-6 = STAGES(CONTROL.zindicator_TrayNumber).OutletLiquid.z(CONTROL.zindicator_Component) * STAGES(CONTROL.zindicator_TrayNumber).Mw(CONTROL.zindicator_Component) / sum(STAGES(CONTROL.zindicator_TrayNumber).Mw*STAGES(CONTROL.zindicator_TrayNumber).OutletLiquid.z);
768       
[885]769"PressureDrop"
770        PressureDrop = STAGES(NumberOfStages).OutletLiquid.P - STAGES(1).OutletLiquid.P;
771
772INITIAL
773
774for i in 1:NumberOfStages do
775
776"The initial temperature of the STAGES"
777        STAGES(i).OutletLiquid.T = INITIALIZATION.TopStageTemperature+(INITIALIZATION.BottomStageTemperature-INITIALIZATION.TopStageTemperature)*((i-1)/(NumberOfStages-1));
778
779"The Column Holdup of the STAGES"
780        STAGES(i).hl = INITIALIZATION.ColumnHoldup;
781
782end
783
784for i in 1:NComp-1 do
785
786for j in 1:NumberOfStages do
787
788"The initial composition of the TRAYS"
789        STAGES(j).OutletLiquid.z(i) = INITIALIZATION.TopStageComposition(i)/sum(INITIALIZATION.TopStageComposition) +(INITIALIZATION.BottomStageComposition(i)/sum(INITIALIZATION.BottomStageComposition)-INITIALIZATION.TopStageComposition(i)/sum(INITIALIZATION.TopStageComposition) )*((j-1)/(NumberOfStages-1));
790
791end
792
793end
794
795end
796
797Model Packed_Section_Column     as Packed_Section_ColumnBasic
798
799        ATTRIBUTES
800        Pallete         = true;
801        Icon            = "icon/PackedSectionColumn";
802        Brief           = "Model of a packed column section.";
803        Info            =
804"== Model of a packed column section containing ==
805* NStages theoretical stages.
806       
807== Specify ==
808* the feed stream of each tray (Inlet);
809* the InletLiquid stream of the top tray;
810* the InletVapour stream of the bottom tray;
811* the total pressure drop (dP) of the section.
812       
813== Initial Conditions ==
814* the stages temperature (OutletLiquid.T);
815* the stages liquid holdup;
816* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
817";
818
819SET
820        NumberOfFeeds = 1;
821
822VARIABLES
823       
824        in      FeedStage       as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
825
826EQUATIONS
827#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
828# Equating Feed Tray Variables to Trays Variables
829#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
830for i in 1:NumberOfStages do
831
832if   i equal FeedStageLocation(1) then   
833
834"FeedTrayTop Inlet Flow"       
835        FeedStage.F= STAGES(i).Inlet.F;
836
837"FeedTrayTop Inlet Temperature"
838        FeedStage.T = STAGES(i).Inlet.T;
839
840"FeedTrayTop Inlet Pressure"
841        FeedStage.P = STAGES(i).Inlet.P;
842
843"FeedTrayTop Inlet Composition"
844        FeedStage.z = STAGES(i).Inlet.z;
845
846"FeedTrayTop Inlet Vapour Fraction"
847        FeedStage.v = STAGES(i).Inlet.v;
848
849"FeedTrayTop Inlet Enthalpy"
850        FeedStage.h = STAGES(i).Inlet.h;
851
852else
853
854"Inlet Tray - Flow Sealed"
855    0*'mol/h'= STAGES(i).Inlet.F;
856       
857"Inlet Tray -  Temperature"
858    300*'K' = STAGES(i).Inlet.T;
859       
860"Inlet Tray -  Pressure"
861    1*'atm' = STAGES(i).Inlet.P;
862       
863"Inlet Tray -  Composition"
864    0.1 = STAGES(i).Inlet.z;
865       
866"Inlet Tray -  Vapour Fraction"
867    0 = STAGES(i).Inlet.v;
868       
869"Inlet Tray -  Enthalpy"
870    0*'J/mol' = STAGES(i).Inlet.h;
871
872end
873
874end
875
876end
877
878Model Packed_Section_Column2    as Packed_Section_ColumnBasic
879
880        ATTRIBUTES
881        Pallete         = true;
882        Icon            = "icon/PackedSectionColumn";
883        Brief           = "Model of a packed column section.";
884        Info            =
885"== Model of a packed column section containing ==
886* NStages theoretical stages.
887       
888== Specify ==
889* the feed stream of each tray (Inlet);
890* the InletLiquid stream of the top tray;
891* the InletVapour stream of the bottom tray;
892* the total pressure drop (dP) of the section.
893       
894== Initial Conditions ==
895* the stages temperature (OutletLiquid.T);
896* the stages liquid holdup;
897* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
898";
899
900SET
901        NumberOfFeeds = 2;
902
903VARIABLES
904       
905        in      FeedStageOne    as stream               (Brief="Feed stream", PosX=0, PosY=0.45);
906        in      FeedStageTwo    as stream               (Brief="Feed stream", PosX=0, PosY=0.65);
907
908EQUATIONS
909#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
910# Equating Feed Stage Variables to Stages Variables
911#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
912
913for i in 1:NumberOfStages do
914
915if   i equal FeedStageLocation(1) then   
916
917"FeedTrayTop Inlet Flow"       
918        FeedStageOne.F= STAGES(i).Inlet.F;
919
920"FeedTrayTop Inlet Temperature"
921        FeedStageOne.T = STAGES(i).Inlet.T;
922
923"FeedTrayTop Inlet Pressure"
924        FeedStageOne.P = STAGES(i).Inlet.P;
925
926"FeedTrayTop Inlet Composition"
927        FeedStageOne.z = STAGES(i).Inlet.z;
928
929"FeedTrayTop Inlet Vapour Fraction"
930        FeedStageOne.v = STAGES(i).Inlet.v;
931
932"FeedTrayTop Inlet Enthalpy"
933        FeedStageOne.h = STAGES(i).Inlet.h;
934
935else if   i equal FeedStageLocation(2) then   
936
937"FeedTrayBottom Inlet Flow"     
938        FeedStageTwo.F= STAGES(i).Inlet.F;
939
940"FeedTrayBottom Inlet Temperature"
941        FeedStageTwo.T = STAGES(i).Inlet.T;
942
943"FeedTrayBottom Inlet Pressure"
944        FeedStageTwo.P = STAGES(i).Inlet.P;
945
946"FeedTrayBottom Inlet Composition"
947        FeedStageTwo.z = STAGES(i).Inlet.z;
948
949"FeedTrayBottom Inlet Vapour Fraction"
950        FeedStageTwo.v = STAGES(i).Inlet.v;
951
952"FeedTrayBottom Inlet Enthalpy"
953        FeedStageTwo.h = STAGES(i).Inlet.h;
954
955else
956
957"Inlet Tray - Flow Sealed"
958    0*'mol/h'= STAGES(i).Inlet.F;
959       
960"Inlet Tray -  Temperature"
961    300*'K' = STAGES(i).Inlet.T;
962       
963"Inlet Tray -  Pressure"
964    1*'atm' = STAGES(i).Inlet.P;
965       
966"Inlet Tray -  Composition"
967    0.1 = STAGES(i).Inlet.z;
968       
969"Inlet Tray -  Vapour Fraction"
970    0 = STAGES(i).Inlet.v;
971       
972"Inlet Tray -  Enthalpy"
973    0*'J/mol' = STAGES(i).Inlet.h;
974
975end
976
977end
978
979end
980
981end
982
983
984# Models to be revised
985#*
[806]986Model ColumnBasic
[787]987
988ATTRIBUTES
[806]989        Pallete = false;
990        Brief   = "Model of a basic column.";
991        Info    =
992"Model of a basic column containing a vetor of TRAYS numbered from the top-down.";
993
994PARAMETERS
995        outer PP                as Plugin       (Brief="External Physical Properties", Type="PP");
996        outer NComp     as Integer      (Brief="Number of components");
997
998        NumberOfFeeds                                           as Integer                      (Brief="Number of Feed Trays",Default=3,Protected=true);
999        FeedTrayLocation(NumberOfFeeds)         as Integer                      (Brief="Feed tray Location",Default=2);
1000        NumberOfTrays                                           as Integer                      (Brief="Number of trays", Default=8);
1001        LiqSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Liquid Side Tray Index", Default=0,Hidden=true);
1002        VapSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Vapour Side Tray Index", Default=0,Hidden=true);
1003        LiquidSideStreamLocation                        as Integer                      (Brief="Liquid Side Stream Location", Default=2);
1004        VapourSideStreamLocation                        as Integer                      (Brief="Vapour Side Stream Location", Default=2);
1005        g                                                                       as acceleration         (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
1006        Mw(NComp)                                                       as molweight            (Brief="Component Mol Weight",Hidden=true);
1007
1008        VapourFlowModel         as Switcher     (Valid = ["Reepmeyer", "Feehery_Fv", "Roffel_Fv", "Klingberg", "Wang_Fv", "Elgue"], Default = "Reepmeyer");
1009        LiquidFlowModel         as Switcher     (Valid = ["default", "Wang_Fl", "Olsen", "Feehery_Fl", "Roffel_Fl"], Default = "default");
1010
[838]1011        TrayDiameter                    as length               (Brief="Tray Diameter",Default=1.600);
1012        TraySpacing                             as length               (Brief="Tray Spacing",Default=0.600);
1013        Fraction_HoleArea               as fraction     (Brief="Fraction of the active area that is occupied by the holes with respect to the total tray area",Default=0.10);
1014        Fraction_DowncomerArea  as fraction     (Brief="Fraction of the downcomer area with respect to the total tray area",Default=0.20);
1015        WeirLength                              as length               (Brief="Weir length", Default = 1);
1016        WeirHeight                              as length               (Brief="Weir height", Default= 0.05);
1017        TrayLiquidPasses                as positive     (Brief="Number of liquid passes in the tray", Lower = 1,Default=1);
1018        HeatSupply                              as heat_rate    (Brief="Rate of heat supply",Default = 0);
1019        AerationFraction                as Real                 (Brief="Aeration fraction", Default = 1);
1020        DryPdropCoeff                   as Real                 (Brief="Dry pressure drop coefficient", Default= 0.60);
[806]1021       
[838]1022        PlateArea               as area         (Brief="Plate area = Atray - Adowncomer",Protected=true);
1023        TrayVolume              as volume       (Brief="Total Volume of the tray",Protected=true);
1024        HolesArea               as area         (Brief="Total holes area",Protected=true);
1025       
[806]1026        FeeheryCoeff            as Real                 (Brief="Feeherys correlation coefficient", Unit='1/m^4', Default=1,Hidden=true);
1027        ElgueCoeff                      as Real                 (Brief="Elgues correlation coefficient", Unit='kg/m/mol^2', Default=1,Hidden=true);
1028        OlsenCoeff                      as Real                 (Brief="Olsens correlation coefficient", Default=1,Hidden=true);
1029       
[838]1030        Pi                      as constant             (Brief="Pi Number",Default=3.14159265, Symbol = "\pi",Hidden=true);
1031        zero_flow       as flow_mol             (Brief = "Stream Flow closed",Default = 0, Hidden=true);
1032        low_flow        as flow_mol             (Brief = "Low stream Flow",Default = 1E-6, Hidden=true);
[806]1033        VapourFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
1034        LiquidFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
1035
1036SET
1037        VapSideTrayIndex(VapourSideStreamLocation) =1;
1038        LiqSideTrayIndex(LiquidSideStreamLocation) =1;
1039        Mw = PP.MolecularWeight();
[838]1040        zero_flow = 0 * 'kmol/h';
1041        low_flow = 1E-6 * 'kmol/h';
[806]1042
[838]1043        PlateArea = 0.25*Pi*(TrayDiameter^2)*(1-Fraction_DowncomerArea);
1044        TrayVolume = 0.25*Pi*(TrayDiameter^2)*TraySpacing;
1045        HolesArea = 0.25*Pi*(TrayDiameter^2)*Fraction_HoleArea;
[806]1046
1047VARIABLES
1048
1049        INITIALIZATION as InitializeSection (Brief = "Column Model Initialization");
1050        CONTROL                 as ControlSection (Brief = "Control");
1051       
[809]1052        out     TCI as control_signal   (Brief="Temperature  Indicator", Protected = true, PosX=1, PosY=0.55);
[806]1053        out     PCI as control_signal   (Brief="Pressure Indicator", Protected = true, PosX=0, PosY=0.23);
1054       
1055        TRAYS(NumberOfTrays)    as tray                 (Brief="Number of trays in the Column Section");
1056        VapourDrawOffFlow               as flow_mol     (Brief="Vapour Draw Off Stream Molar Flow Rate");
1057        LiquidDrawOffFlow               as flow_mol     (Brief="Vapour Draw Off Stream Molar Flow Rate");
1058        MurphreeEff                     as Real                 (Brief="Murphree efficiency for All Trays",Lower=0.01,Upper=1);
1059
1060        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.388,Protected = true);
1061        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.47,Protected = true);
1062
1063CONNECTIONS
1064
1065#Connecting Intermediate Trays
1066        TRAYS([2:NumberOfTrays]).OutletVapour   to TRAYS([1:NumberOfTrays-1]).InletVapour;
1067        TRAYS([1:NumberOfTrays-1]).OutletLiquid         to TRAYS([2:NumberOfTrays]).InletLiquid;
1068       
1069INITIAL
1070
1071for i in 1:NumberOfTrays do
1072
1073"The initial temperature of the TRAYS"
1074        TRAYS(i).OutletLiquid.T = INITIALIZATION.TopTemperature+(INITIALIZATION.BottomTemperature-INITIALIZATION.TopTemperature)*((i-1)/(NumberOfTrays-1));
1075
1076"The initial Level of the TRAYS"
[838]1077        TRAYS(i).Level = INITIALIZATION.LevelFraction*WeirHeight;
[806]1078end
1079
1080for i in 1:NComp-1 do
1081
1082for j in 1:NumberOfTrays do
1083
1084"The initial composition of the TRAYS - Normalized"
1085        TRAYS(j).OutletLiquid.z(i) = INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) +(INITIALIZATION.BottomComposition(i)/sum(INITIALIZATION.BottomComposition)-INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) )*((j-1)/(NumberOfTrays-1));
1086end
1087
1088end
1089
1090EQUATIONS
1091
1092        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1093        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1094        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1095        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1096
1097        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1098        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1099        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1100        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1101
1102        VapourDrawOffFlow = VapourDrawOff.F;
1103        LiquidDrawOffFlow = LiquidDrawOff.F;
1104       
1105"Tray Temperature Indicator"   
1106        #TCI*'K' = TRAYS(min([NumberOfTrays, CONTROL.Tindicator_TrayNumber])).OutletVapour.T;
1107        TCI*'K' = TRAYS(CONTROL.Tindicator_TrayNumber).OutletVapour.T;
1108
1109"Tray Pressure Indicator"       
1110        #PCI*'atm' = TRAYS(min([NumberOfTrays, CONTROL.Pindicator_TrayNumber])).OutletVapour.P;
1111        PCI*'atm' = TRAYS(CONTROL.Pindicator_TrayNumber).OutletVapour.P;
1112
1113for i in [1:NumberOfTrays] do
1114
1115"Murphree Efficiency"
1116        TRAYS(i).OutletVapour.z =  MurphreeEff * (TRAYS(i).yideal - TRAYS(i).InletVapour.z) + TRAYS(i).InletVapour.z;
1117
1118"Level of clear liquid over the weir"
[838]1119        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/PlateArea;
[806]1120
1121"Geometry Constraint"
[838]1122        TrayVolume = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
[806]1123
1124"Energy Holdup"
[838]1125        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletLiquid.h + TRAYS(i).MV*TRAYS(i).OutletVapour.h - TRAYS(i).OutletLiquid.P*TrayVolume;
[806]1126
1127"Energy Balance"
1128        diff(TRAYS(i).E) = ( TRAYS(i).Inlet.F*TRAYS(i).Inlet.h + TRAYS(i).InletLiquid.F*TRAYS(i).InletLiquid.h + TRAYS(i).InletVapour.F*TRAYS(i).InletVapour.h- TRAYS(i).OutletLiquid.F*TRAYS(i).OutletLiquid.h - TRAYS(i).OutletVapour.F*TRAYS(i).OutletVapour.h
[838]1129        -TRAYS(i).VapourSideStream.F*TRAYS(i).VapourSideStream.h - TRAYS(i).LiquidSideStream.F*TRAYS(i).LiquidSideStream.h + HeatSupply );
[806]1130
1131switch LiquidFlow
1132                case "on":
1133                        switch LiquidFlowModel
1134                                case "default":
1135                                "Francis Equation"
[838]1136                                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'1/s'*WeirLength*((TRAYS(i).Level-(AerationFraction*WeirHeight))/(AerationFraction))^2;
[806]1137                       
1138                                case "Wang_Fl":
[838]1139                                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'m^0.5/s'*WeirLength*((TRAYS(i).Level-(AerationFraction*WeirHeight))/(AerationFraction))^1.5;
[806]1140                       
1141                                case "Olsen":
[838]1142                                TRAYS(i).OutletLiquid.F / 'mol/s'= WeirLength*TrayLiquidPasses*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletVapour.z)/(0.665*OlsenCoeff)^1.5 * ((TRAYS(i).ML*sum(Mw*TRAYS(i).OutletLiquid.z)/TRAYS(i).rhoL/PlateArea)-WeirHeight)^1.5 * 'm^0.5/mol';
[806]1143                       
1144                                case "Feehery_Fl":
[838]1145                                TRAYS(i).OutletLiquid.F = WeirLength*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletLiquid.z) * ((TRAYS(i).Level-WeirHeight)/750/'mm')^1.5 * 'm^2/s';
[806]1146                       
1147                                case "Roffel_Fl":
[838]1148                                TRAYS(i).OutletLiquid.F = 2/3*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletLiquid.z)*WeirLength*(TRAYS(i).ML*sum(Mw*TRAYS(i).OutletLiquid.z)/(PlateArea*1.3)/TRAYS(i).rhoL)^1.5*sqrt(2*g/
1149                                                        (2*(1 - 0.3593/'Pa^0.0888545'*abs(TRAYS(i).OutletVapour.F*sum(Mw*TRAYS(i).OutletVapour.z)/(PlateArea*1.3)/sqrt(TRAYS(i).rhoV))^0.177709)-1)); #/'(kg/m)^0.0888545/s^0.177709';
[806]1150                        end
[838]1151                when TRAYS(i).Level < (AerationFraction *WeirHeight) switchto "off";
[806]1152               
1153                case "off":
1154                "Low level"
1155                TRAYS(i).OutletLiquid.F = 0 * 'mol/h';
[838]1156                when TRAYS(i).Level > (AerationFraction * WeirHeight) switchto "on";
[806]1157        end
1158       
1159switch VapourFlow
1160                case "on":
1161                        switch VapourFlowModel
1162                                case "Reepmeyer":
[838]1163                                TRAYS(i).InletVapour.F*TRAYS(i).vV = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)/(TRAYS(i).rhoV*DryPdropCoeff))*HolesArea;
[806]1164                       
1165                                case "Feehery_Fv":
[838]1166                                TRAYS(i).InletVapour.F = TRAYS(i).rhoV/PlateArea/FeeheryCoeff/sum(Mw*TRAYS(i).OutletVapour.z) * sqrt(((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)-(TRAYS(i).rhoV*g*TRAYS(i).ML*TRAYS(i).vL/PlateArea))/TRAYS(i).rhoV);
[806]1167                       
1168                                case "Roffel_Fv":
[838]1169                                TRAYS(i).InletVapour.F^1.08 * 0.0013 * 'kg/m/mol^1.08/s^0.92*1e5' = (TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)*1e5 - (AerationFraction*sum(TRAYS(i).M*Mw)/(PlateArea*1.3)*g*1e5) * (TRAYS(i).rhoV*HolesArea/sum(Mw*TRAYS(i).OutletVapour.z))^1.08 * 'm^1.08/mol^1.08';
[806]1170                       
1171                                case "Klingberg":
[838]1172                                TRAYS(i).InletVapour.F * TRAYS(i).vV = PlateArea * sqrt(((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)-TRAYS(i).rhoL*g*TRAYS(i).Level)/TRAYS(i).rhoV);
[806]1173                       
1174                                case "Wang_Fv":
[838]1175                                TRAYS(i).InletVapour.F * TRAYS(i).vV = PlateArea * sqrt(((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)-TRAYS(i).rhoL*g*TRAYS(i).Level)/TRAYS(i).rhoV*DryPdropCoeff);
[806]1176                               
1177                                case "Elgue":
[838]1178                                TRAYS(i).InletVapour.F  = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)/ElgueCoeff);
[806]1179                        end
1180                when TRAYS(i).InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
1181               
1182                case "off":
1183                TRAYS(i).InletVapour.F = 0 * 'mol/s';
[836]1184                when TRAYS(i).InletVapour.P > TRAYS(i).OutletVapour.P switchto "on";
[806]1185        end
1186
1187end
1188
1189end
1190
[810]1191Model Distillation_kettle_cond                          as ColumnBasic
[806]1192
1193ATTRIBUTES
[787]1194        Pallete         = true;
[715]1195        Icon            = "icon/DistillationKettleCond";
1196        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
1197        Info            =
1198"== Specify ==
1199* the feed stream of each tray (Inlet);
1200* the Murphree eficiency for each tray Emv;
1201* the pump pressure difference;
1202* the heat supllied in reboiler and condenser;
[735]1203* the condenser vapor outlet flow (OutletVapour.F);
1204* the reboiler liquid outlet flow (OutletLiquid.F);
[715]1205* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1206       
1207== Initial Conditions ==
[735]1208* the TRAYS temperature (OutletLiquid.T);
1209* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1210* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]1211       
[735]1212* the condenser temperature (OutletLiquid.T);
[715]1213* the condenser liquid level (Level);
[735]1214* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
[715]1215       
[735]1216* the reboiler temperature (OutletLiquid.T);
[715]1217* the reboiler liquid level (Level);
[735]1218* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
[715]1219";
[806]1220
1221SET
1222        NumberOfFeeds = 1;
[715]1223       
[806]1224VARIABLES
[715]1225
[838]1226        CONDENSER               as condenser;
1227        REBOILER                as reboiler;
1228        SPLITTER                as splitter_column (Brief="splitter which separate reflux and distillate",Protected=true);
1229        PUMP                    as pump;
1230        RefluxRatio             as positive             (Brief="Reflux Ratio",Default=10, Lower = 0.5);
1231       
[806]1232        out     TI_reb  as control_signal       (Brief="Temperature Indicator of Reboiler ",Protected = true, PosX=0.515, PosY=1);
1233        out     LI_reb  as control_signal       (Brief="Level Indicator of Reboiler", Protected = true, PosX=1, PosY=0.935);
1234        out     PI_reb  as control_signal       (Brief="Pressure Indicator of Reboiler", Protected = true, PosX=0.41, PosY=1);
1235       
1236        out     TI_cond         as control_signal       (Brief="Temperature Indicator of Condenser ", Protected = true, PosX=0.52, PosY=0);
1237        out     LI_cond         as control_signal       (Brief="Level Indicator of Condenser", Protected = true, PosX=1, PosY=0.084);
1238        out     PI_cond         as control_signal       (Brief="Pressure Indicator of Condenser", Protected = true, PosX=0.42, PosY=0);
1239       
1240        in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
1241
1242
[838]1243
[806]1244        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler",Protected = true, PosX=1, PosY=0.855);
1245        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", Protected = true, PosX=1, PosY=0.01);
1246
1247
1248        ConnectorHeatReboiler   as power        (Brief="Heat supplied to Reboiler", Hidden=true);
1249        ConnectorHeatCondenser  as power        (Brief="Heat supplied to Condenser", Hidden=true);
1250       
[721]1251        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Condenser", Hidden=true);
1252        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1253        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
[715]1254
[806]1255        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Condenser", PosX=0.615, PosY=0);
1256        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.235);
1257        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.62, PosY=1);
1258
[715]1259EQUATIONS
1260
[838]1261        SPLITTER.RefluxRatio = RefluxRatio;
1262
[806]1263        TI_reb  = REBOILER.TI ;
1264        LI_reb  = REBOILER.LI;
1265        PI_reb  = REBOILER.PI;
1266       
1267        TI_cond = CONDENSER.TI;
1268        LI_cond = CONDENSER.LI;
1269        PI_cond = CONDENSER.PI;
1270       
1271for i in 1:NumberOfTrays do
[715]1272
[806]1273if i equal FeedTrayLocation(1) then   
[715]1274
[806]1275"FeedTrayTop Inlet Flow"       
1276        FeedTray.F= TRAYS(i).Inlet.F;
[715]1277
[806]1278"FeedTrayTop Inlet Temperature"
1279        FeedTray.T = TRAYS(i).Inlet.T;
[715]1280
[806]1281"FeedTrayTop Inlet Pressure"
1282        FeedTray.P = TRAYS(i).Inlet.P;
1283
1284"FeedTrayTop Inlet Composition"
1285        FeedTray.z = TRAYS(i).Inlet.z;
1286
1287"FeedTrayTop Inlet Vapour Fraction"
1288        FeedTray.v = TRAYS(i).Inlet.v;
1289
1290"FeedTrayTop Inlet Enthalpy"
1291        FeedTray.h = TRAYS(i).Inlet.h;
1292
1293else
1294
[832]1295"Inlet Tray - Flow Sealed"
1296    0*'mol/h'= TRAYS(i).Inlet.F;
1297       
[806]1298"Inlet Tray -  Temperature"
[832]1299    300*'K' = TRAYS(i).Inlet.T;
1300       
[806]1301"Inlet Tray -  Pressure"
[832]1302    1*'atm' = TRAYS(i).Inlet.P;
1303       
[806]1304"Inlet Tray -  Composition"
[832]1305    0.1 = TRAYS(i).Inlet.z;
1306       
[806]1307"Inlet Tray -  Vapour Fraction"
[832]1308    0 = TRAYS(i).Inlet.v;
1309       
[806]1310"Inlet Tray -  Enthalpy"
[832]1311    0*'J/mol' = TRAYS(i).Inlet.h;
[806]1312
1313end
1314
1315end
1316
[715]1317# Condenser Connector Equations
1318        ConnectorCondenserVout.T = VapourDistillate.T;
1319        ConnectorCondenserVout.P = VapourDistillate.P;
1320        ConnectorCondenserVout.F = VapourDistillate.F;
1321        ConnectorCondenserVout.z = VapourDistillate.z;
1322
1323# Splitter Connector Equations
1324        ConnectorSplitterOut.T = LiquidDistillate.T;
1325        ConnectorSplitterOut.P = LiquidDistillate.P;
1326        ConnectorSplitterOut.F = LiquidDistillate.F;
1327        ConnectorSplitterOut.z = LiquidDistillate.z;
1328
1329# Reboiler Connector Equations
1330        ConnectorReboilerLout.T = BottomProduct.T;
1331        ConnectorReboilerLout.P = BottomProduct.P;
1332        ConnectorReboilerLout.F = BottomProduct.F;
1333        ConnectorReboilerLout.z = BottomProduct.z;
1334
[719]1335        HeatToReboiler  = ConnectorHeatReboiler;
1336        HeatToCondenser = ConnectorHeatCondenser;
1337
[715]1338CONNECTIONS
1339#vapor
[735]1340        REBOILER.OutletVapour   to      TRAYS(NumberOfTrays).InletVapour;
1341        TRAYS(1).OutletVapour   to      CONDENSER.InletVapour;
[715]1342
1343#liquid
[735]1344        CONDENSER.OutletLiquid                          to      SPLITTER.Inlet;
[838]1345        SPLITTER.Reflux                                         to      PUMP.Inlet;
[806]1346        PUMP.Outlet                                             to      TRAYS(1).InletLiquid;
[735]1347        TRAYS(NumberOfTrays).OutletLiquid       to      REBOILER.InletLiquid;
[715]1348
1349#Connectors
[735]1350        CONDENSER.OutletVapour  to ConnectorCondenserVout;
[838]1351        SPLITTER.Distillate             to ConnectorSplitterOut;
[735]1352        REBOILER.OutletLiquid   to ConnectorReboilerLout;
[715]1353
[719]1354        ConnectorHeatReboiler   to REBOILER.InletQ;
1355        ConnectorHeatCondenser  to CONDENSER.InletQ;
[715]1356
1357end
1358
[808]1359Model Distillation_thermosyphon_subcooling      as ColumnBasic
[715]1360        ATTRIBUTES
1361        Pallete         = true;
1362        Icon            = "icon/DistillationThermosyphonSubcooling";
1363        Brief           = "Model of a distillation column with steady condenser and steady reboiler.";
1364        Info            =
1365"== Specify ==
1366* the feed stream of each tray (Inlet);
1367* the Murphree eficiency for each tray Emv;
1368* the pump head;
1369* the condenser pressure drop;
1370* the heat supllied in top and bottom tanks;
1371* the heat supllied in condenser and reboiler;
1372* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
1373* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1374       
1375== Initial Conditions ==
[735]1376* the TRAYS temperature (OutletLiquid.T);
1377* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1378* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]1379       
[735]1380* the top tank temperature (OutletLiquid.T);
[715]1381* the top tank liquid level (Level);
[735]1382* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
[715]1383       
[735]1384* the bottom tank temperature (OutletLiquid.T);
[715]1385* the bottom tank liquid level (Level);
[735]1386* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
[715]1387";
1388
[808]1389SET
[715]1390
[808]1391        NumberOfFeeds = 1;
[715]1392
1393VARIABLES
[721]1394        CONDENSER                       as condenserSteady      (Brief="steady state condenser with subcooling");
[808]1395        REFLUX_DRUM             as TankL                        (Brief="Reflux Drum");
[838]1396        SPLITTER_TOP            as splitter_column      (Brief="splitter which separate reflux and distillate",Protected=true);
[721]1397        PUMP                            as pump                         (Brief="pump in reflux stream");
1398        REBOILER                        as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
[808]1399        SUMP                            as SumpTank                     (Brief="vessel in the bottom of column");
1400        SPLITTER_BOTTOM         as splitter2            (Brief="splitter to separate the bottom product and the stream to reboiler");
1401       
1402        in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
1403
[838]1404        RefluxRatio             as positive             (Brief="Reflux Ratio",Default=10, Lower = 0.5);
1405
[808]1406in              Q_cond          as power        (Brief="Heat supplied to Condenser",PosX=1, PosY=0, Protected=true);
1407in              Q_reb           as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.96,Protected=true);
1408in              Q_drum  as power        (Brief="Heat supplied to Reflux Drum", PosX=1, PosY=0.30,Protected=true);
1409
1410        out     TI_reb  as control_signal       (Brief="Temperature Indicator of Reboiler ",Protected = true, PosX=1, PosY=0.92);
[809]1411        out     PI_reb  as control_signal       (Brief="Pressure Indicator of Reboiler", Protected = true, PosX=1, PosY=0.875);
[808]1412       
1413        out     TI_cond         as control_signal       (Brief="Temperature Indicator of Condenser ", Protected = true, PosX=0.52, PosY=0);
1414        out     PI_cond         as control_signal       (Brief="Pressure Indicator of Condenser", Protected = true, PosX=0.42, PosY=0);
1415       
[809]1416        out     TI_drum as control_signal       (Brief="Temperature Indicator of Reflux Drum ", Protected = true, PosX=1, PosY=0.20);
1417        out     PI_drum as control_signal       (Brief="Pressure Indicator of Reflux Drum", Protected = true, PosX=1, PosY=0.155);
[808]1418        out     LI_drum as control_signal       (Brief="Level Indicator of Reflux Drum", Protected = true, PosX=1, PosY=0.24);
1419       
[809]1420        out     LI_sump as control_signal       (Brief="Level Indicator of Column Sump", Protected = true, PosX=1, PosY=0.765);
1421        out     TI_sump as control_signal       (Brief="Temperature Indicator of Column Sump ",Protected = true, PosX=1, PosY=0.71);
1422       
1423        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.33);
1424        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=0.06, PosY=1);
[808]1425
[809]1426        in      ConnectorSplitterBottom         as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1427        in      ConnectorSplitterTop            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
[808]1428
1429        ConnectorHeatReboiler           as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1430        ConnectorHeatCondenser          as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1431        ConnectorHeatRefluxDrum         as power        (Brief="Connector for Heat supplied to Reflux Drum", Hidden=true);
[809]1432
[715]1433EQUATIONS
[781]1434
[838]1435        SPLITTER_TOP.RefluxRatio = RefluxRatio;
[809]1436        TI_reb  = REBOILER.TI ;
1437        PI_reb  = REBOILER.PI;
1438       
1439        TI_cond = CONDENSER.TI;
1440        PI_cond = CONDENSER.PI;
1441       
1442        TI_drum = REFLUX_DRUM.TI;
1443        PI_drum = REFLUX_DRUM.PI;
1444        LI_drum = REFLUX_DRUM.LI;
1445       
1446        TI_sump = SUMP.TI;
1447        LI_sump = SUMP.LI;
1448       
1449for i in 1:NumberOfTrays do
1450
1451if i equal FeedTrayLocation(1) then   
1452
1453"FeedTrayTop Inlet Flow"       
1454        FeedTray.F= TRAYS(i).Inlet.F;
1455
1456"FeedTrayTop Inlet Temperature"
1457        FeedTray.T = TRAYS(i).Inlet.T;
1458
1459"FeedTrayTop Inlet Pressure"
1460        FeedTray.P = TRAYS(i).Inlet.P;
1461
1462"FeedTrayTop Inlet Composition"
1463        FeedTray.z = TRAYS(i).Inlet.z;
1464
1465"FeedTrayTop Inlet Vapour Fraction"
1466        FeedTray.v = TRAYS(i).Inlet.v;
1467
1468"FeedTrayTop Inlet Enthalpy"
1469        FeedTray.h = TRAYS(i).Inlet.h;
1470
1471else
1472
[832]1473"Inlet Tray - Flow Sealed"
1474    0*'mol/h'= TRAYS(i).Inlet.F;
1475       
[809]1476"Inlet Tray -  Temperature"
[832]1477    300*'K' = TRAYS(i).Inlet.T;
1478       
[809]1479"Inlet Tray -  Pressure"
[832]1480    1*'atm' = TRAYS(i).Inlet.P;
1481       
[809]1482"Inlet Tray -  Composition"
[832]1483    0.1 = TRAYS(i).Inlet.z;
1484       
[809]1485"Inlet Tray -  Vapour Fraction"
[832]1486    0 = TRAYS(i).Inlet.v;
1487       
[809]1488"Inlet Tray -  Enthalpy"
[832]1489    0*'J/mol' = TRAYS(i).Inlet.h;
[809]1490
1491end
1492
1493end
1494
[721]1495# Heat Connector Equations
[808]1496        Q_cond  =       ConnectorHeatCondenser;
1497        Q_reb   =       ConnectorHeatReboiler;
1498        Q_drum  =       ConnectorHeatRefluxDrum;
[715]1499
1500# Top Splitter Connector Equations
1501        ConnectorSplitterTop.T = LiquidDistillate.T;
1502        ConnectorSplitterTop.P = LiquidDistillate.P;
1503        ConnectorSplitterTop.F = LiquidDistillate.F;
1504        ConnectorSplitterTop.z = LiquidDistillate.z;
1505
1506# Bottom Splitter Connector Equations
1507        ConnectorSplitterBottom.T = BottomProduct.T;
1508        ConnectorSplitterBottom.P = BottomProduct.P;
1509        ConnectorSplitterBottom.F = BottomProduct.F;
1510        ConnectorSplitterBottom.z = BottomProduct.z;
[809]1511       
[715]1512CONNECTIONS
1513#vapor
[808]1514        REBOILER.OutletVapour   to SUMP.InletVapour;
1515        SUMP.OutletVapour               to TRAYS(NumberOfTrays).InletVapour;
[735]1516        TRAYS(1).OutletVapour   to CONDENSER.InletVapour;
[715]1517
1518#liquid
[808]1519        CONDENSER.OutletLiquid                          to REFLUX_DRUM.Inlet;   
1520        REFLUX_DRUM.OutletLiquid                        to SPLITTER_TOP.Inlet;
[838]1521        SPLITTER_TOP.Reflux                     to PUMP.Inlet; 
[735]1522        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
[808]1523        TRAYS(NumberOfTrays).OutletLiquid       to SUMP.InletLiquid;
1524        SUMP.OutletLiquid               to SPLITTER_BOTTOM.Inlet;
[735]1525        SPLITTER_BOTTOM.Outlet2                 to REBOILER.InletLiquid;
[715]1526
1527#Connectors
[721]1528        ConnectorHeatCondenser                  to CONDENSER.InletQ;
1529        ConnectorHeatReboiler                   to REBOILER.InletQ;
[808]1530        ConnectorHeatRefluxDrum                 to REFLUX_DRUM.InletQ;
[838]1531        SPLITTER_TOP.Distillate                 to ConnectorSplitterTop;
[721]1532        SPLITTER_BOTTOM.Outlet1                 to ConnectorSplitterBottom;
[715]1533
1534end
1535
[810]1536Model Distillation_thermosyphon_cond            as ColumnBasic
[715]1537        ATTRIBUTES
1538        Pallete         = true;
1539        Icon            = "icon/DistillationThermosyphonCond";
1540        Brief           = "Model of a distillation column with dynamic condenser and steady reboiler.";
1541        Info            =
1542"== Specify ==
1543* the feed stream of each tray (Inlet);
1544* the Murphree eficiency for each tray Emv;
1545* the pump head;
[735]1546* the condenser vapor outlet flow (OutletVapour.F);
[715]1547* the heat supllied in bottom tank;
1548* the heat supllied in condenser and reboiler;
1549* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
1550       
1551== Initial Conditions ==
[735]1552* the TRAYS temperature (OutletLiquid.T);
1553* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1554* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]1555       
[735]1556* the condenser temperature (OutletLiquid.T);
[715]1557* the condenser liquid level (Level);
[735]1558* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
[715]1559       
[735]1560* the bottom tank temperature (OutletLiquid.T);
[715]1561* the bottom tank liquid level (Level);
[735]1562* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
[715]1563";
1564
[810]1565SET
[715]1566
[810]1567        NumberOfFeeds = 1;
1568
[715]1569VARIABLES
[721]1570        CONDENSER                       as condenser            (Brief="dynamic condenser without subcooling");
[838]1571        SPLITTER_TOP            as splitter_column      (Brief="splitter which separate reflux and distillate",Protected=true);
[721]1572        PUMP                            as pump                         (Brief="pump in reflux stream");
[810]1573        SUMP                            as SumpTank                     (Brief="vessel in the bottom of column");
1574        SPLITTER_BOTTOM         as splitter2            (Brief="splitter who separate the bottom product and the stream to reboiler");
[721]1575        REBOILER                        as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
[838]1576        RefluxRatio                     as positive             (Brief="Reflux Ratio",Default=10, Lower = 0.5);
1577       
[810]1578        in      FeedTray        as stream       (Brief="Feed stream", PosX=0, PosY=0.55);
1579
1580in              Q_cond  as power        (Brief="Heat supplied to Condenser",PosX=1, PosY=0, Protected=true);
1581in              Q_reb   as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.96,Protected=true);
1582
1583        out     TI_cond as control_signal       (Brief="Temperature Indicator of Condenser ", Protected = true, PosX=0.48, PosY=0);
1584        out     LI_cond as control_signal       (Brief="Level Indicator of Condenser", Protected = true, PosX=1, PosY=0.084);
1585        out     PI_cond as control_signal       (Brief="Pressure Indicator of Condenser", Protected = true, PosX=0.40, PosY=0);
1586       
1587        out     TI_reb  as control_signal       (Brief="Temperature Indicator of Reboiler ",Protected = true, PosX=1, PosY=0.92);
1588        out     PI_reb  as control_signal       (Brief="Pressure Indicator of Reboiler", Protected = true, PosX=1, PosY=0.878);
1589       
1590        out     LI_sump as control_signal       (Brief="Level Indicator of Column Sump", Protected = true, PosX=1, PosY=0.76);
1591        out     TI_sump as control_signal       (Brief="Temperature Indicator of Column Sump ",Protected = true, PosX=1, PosY=0.71);
1592       
1593out     VapourDistillate as vapour_stream       (Brief="Vapour outlet stream From Top Condenser", PosX=0.62, PosY=0);
1594out     LiquidDistillate as liquid_stream       (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.185);
1595out     BottomProduct    as liquid_stream       (Brief="Liquid outlet stream From Bottom Splitter", PosX=0.06, PosY=1);
1596
[721]1597in      ConnectorSplitterBottom as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1598in      ConnectorSplitterTop    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1599in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
[715]1600
[810]1601        ConnectorHeatReboiler   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1602        ConnectorHeatCondenser  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
[715]1603
1604EQUATIONS
[810]1605
1606for i in 1:NumberOfTrays do
1607
1608if i equal FeedTrayLocation(1) then   
1609
1610"FeedTrayTop Inlet Flow"       
1611        FeedTray.F= TRAYS(i).Inlet.F;
1612
1613"FeedTrayTop Inlet Temperature"
1614        FeedTray.T = TRAYS(i).Inlet.T;
1615
1616"FeedTrayTop Inlet Pressure"
1617        FeedTray.P = TRAYS(i).Inlet.P;
1618
1619"FeedTrayTop Inlet Composition"
1620        FeedTray.z = TRAYS(i).Inlet.z;
1621
1622"FeedTrayTop Inlet Vapour Fraction"
1623        FeedTray.v = TRAYS(i).Inlet.v;
1624
1625"FeedTrayTop Inlet Enthalpy"
1626        FeedTray.h = TRAYS(i).Inlet.h;
1627
1628else
1629
[832]1630"Inlet Tray - Flow Sealed"
1631    0*'mol/h'= TRAYS(i).Inlet.F;
1632       
[810]1633"Inlet Tray -  Temperature"
[832]1634    300*'K' = TRAYS(i).Inlet.T;
1635       
[810]1636"Inlet Tray -  Pressure"
[832]1637    1*'atm' = TRAYS(i).Inlet.P;
1638       
[810]1639"Inlet Tray -  Composition"
[832]1640    0.1 = TRAYS(i).Inlet.z;
1641       
[810]1642"Inlet Tray -  Vapour Fraction"
[832]1643    0 = TRAYS(i).Inlet.v;
1644       
[810]1645"Inlet Tray -  Enthalpy"
[832]1646    0*'J/mol' = TRAYS(i).Inlet.h;
[810]1647
1648end
1649
1650end
1651
[838]1652        SPLITTER_TOP.RefluxRatio = RefluxRatio;
1653
[810]1654        TI_reb  = REBOILER.TI ;
1655        PI_reb  = REBOILER.PI;
1656       
1657        TI_cond = CONDENSER.TI;
1658        PI_cond = CONDENSER.PI;
1659        LI_cond = CONDENSER.LI;
1660       
1661        TI_sump = SUMP.TI;
1662        LI_sump = SUMP.LI;
1663       
[721]1664# Heat Connector Equations
[810]1665        Q_cond  =       ConnectorHeatCondenser;
1666        Q_reb   =       ConnectorHeatReboiler;
[715]1667
1668# Condenser Connector Equations
1669        ConnectorCondenserVout.T = VapourDistillate.T;
1670        ConnectorCondenserVout.P = VapourDistillate.P;
1671        ConnectorCondenserVout.F = VapourDistillate.F;
1672        ConnectorCondenserVout.z = VapourDistillate.z;
1673
1674# Top Splitter Connector Equations
1675        ConnectorSplitterTop.T = LiquidDistillate.T;
1676        ConnectorSplitterTop.P = LiquidDistillate.P;
1677        ConnectorSplitterTop.F = LiquidDistillate.F;
1678        ConnectorSplitterTop.z = LiquidDistillate.z;
1679
1680# Bottom Splitter Connector Equations
1681        ConnectorSplitterBottom.T = BottomProduct.T;
1682        ConnectorSplitterBottom.P = BottomProduct.P;
1683        ConnectorSplitterBottom.F = BottomProduct.F;
1684        ConnectorSplitterBottom.z = BottomProduct.z;
1685
1686CONNECTIONS
1687#vapor
[810]1688        SUMP.OutletVapour               to TRAYS(NumberOfTrays).InletVapour;
1689        REBOILER.OutletVapour   to SUMP.InletVapour;
1690        TRAYS(1).OutletVapour   to CONDENSER.InletVapour;
[715]1691
1692#liquid
[735]1693        CONDENSER.OutletLiquid          to SPLITTER_TOP.Inlet; 
[838]1694        SPLITTER_TOP.Reflux                             to PUMP.Inlet;
[735]1695        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
[810]1696        TRAYS(NumberOfTrays).OutletLiquid       to SUMP.InletLiquid;
1697        SUMP.OutletLiquid                               to SPLITTER_BOTTOM.Inlet;
[735]1698        SPLITTER_BOTTOM.Outlet2                         to REBOILER.InletLiquid;
[715]1699
1700#Connectors
[721]1701ConnectorHeatCondenser                  to CONDENSER.InletQ;
1702ConnectorHeatReboiler                   to REBOILER.InletQ;
[810]1703CONDENSER.OutletVapour                  to ConnectorCondenserVout;
[838]1704SPLITTER_TOP.Distillate                 to ConnectorSplitterTop;
[721]1705SPLITTER_BOTTOM.Outlet1                 to ConnectorSplitterBottom;
[715]1706
1707end
1708
[811]1709Model Distillation_kettle_subcooling            as ColumnBasic
[715]1710
1711ATTRIBUTES
1712        Pallete         = true;
1713        Icon            = "icon/DistillationKettleSubcooling";
1714        Brief   = "Model of a distillation column with steady condenser and dynamic reboiler.";
1715        Info            =
1716"== Specify ==
1717* the feed stream of each tray (Inlet);
1718* the Murphree eficiency for each tray (Emv);
1719* the pump pressure difference;
1720* the heat supllied in reboiler and condenser;
1721* the heat supllied in the top tank;
1722* the condenser pressure drop;
[735]1723* the reboiler liquid outlet flow (OutletLiquid.F);
[715]1724* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1725       
1726== Initial Conditions ==
[735]1727* the TRAYS temperature (OutletLiquid.T);
1728* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1729* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]1730       
[735]1731* the top tank temperature (OutletLiquid.T);
[715]1732* the top tank liquid level (Level);
[735]1733* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
[715]1734       
[735]1735* the reboiler temperature (OutletLiquid.T);
[715]1736* the reboiler liquid level (Level);
[735]1737* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
[715]1738";
1739
[811]1740SET
1741
1742        NumberOfFeeds = 1;
1743
[715]1744VARIABLES
[721]1745        CONDENSER               as condenserSteady      (Brief="steady state condenser with subcooling");
[811]1746        REFLUX_DRUM             as TankL                        (Brief="reflux drum");
[838]1747        SPLITTER                as splitter_column              (Brief="splitter to separate reflux and distillate",Protected=true);
[721]1748        PUMP                    as pump                         (Brief="pump in reflux stream");
1749        REBOILER                as reboiler                     (Brief="kettle reboiler");
[811]1750
[838]1751        RefluxRatio                     as positive             (Brief="Reflux Ratio",Default=10, Lower = 0.5);
1752
[811]1753        in      Q_cond  as power        (Brief="Heat supplied to Condenser", PosX=1, PosY=0.065, Protected=true);
1754        in      Q_reb   as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.905, Protected=true);
1755        in      Q_drum  as power        (Brief="Heat supplied to Top Vessel", PosX=1, PosY=0.30, Protected=true);
1756
1757        in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
1758
1759        out     TI_reb  as control_signal       (Brief="Temperature Indicator of Reboiler ",Protected = true, PosX=0.515, PosY=1);
1760        out     LI_reb  as control_signal       (Brief="Level Indicator of Reboiler", Protected = true, PosX=1, PosY=0.935);
1761        out     PI_reb  as control_signal       (Brief="Pressure Indicator of Reboiler", Protected = true, PosX=0.41, PosY=1);
1762       
1763        out     TI_cond as control_signal       (Brief="Temperature Indicator of Condenser ", Protected = true, PosX=0.52, PosY=0);
1764        out     PI_cond as control_signal       (Brief="Pressure Indicator of Condenser", Protected = true, PosX=0.42, PosY=0);
1765       
1766        out     TI_drum as control_signal       (Brief="Temperature Indicator of Reflux Drum ", Protected = true, PosX=1, PosY=0.20);
1767        out     PI_drum as control_signal       (Brief="Pressure Indicator of Reflux Drum", Protected = true, PosX=1, PosY=0.155);
1768        out     LI_drum as control_signal       (Brief="Level Indicator of Reflux Drum", Protected = true, PosX=1, PosY=0.24);
1769       
1770       
[721]1771in      ConnectorSplitterOut            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1772in      ConnectorReboilerLout           as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1773        ConnectorHeatReboiler           as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1774        ConnectorHeatCondenser          as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1775        ConnectorHeatAccumulator        as power        (Brief="Connector for Heat supplied to TopVessel", Hidden=true);
[811]1776
1777out     LiquidDistillate as liquid_stream       (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.33);
[721]1778out     BottomProduct    as liquid_stream       (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
[715]1779
[721]1780EQUATIONS
[715]1781
[838]1782        SPLITTER.RefluxRatio = RefluxRatio;
1783
[811]1784        TI_reb  = REBOILER.TI ;
1785        PI_reb  = REBOILER.PI;
1786        LI_reb  = REBOILER.LI;
1787       
1788        TI_cond = CONDENSER.TI;
1789        PI_cond = CONDENSER.PI;
1790       
1791        TI_drum = REFLUX_DRUM.TI;
1792        PI_drum = REFLUX_DRUM.PI;
1793        LI_drum = REFLUX_DRUM.LI;
1794       
1795for i in 1:NumberOfTrays do
1796
1797if i equal FeedTrayLocation(1) then   
1798
1799"FeedTrayTop Inlet Flow"       
1800        FeedTray.F= TRAYS(i).Inlet.F;
1801
1802"FeedTrayTop Inlet Temperature"
1803        FeedTray.T = TRAYS(i).Inlet.T;
1804
1805"FeedTrayTop Inlet Pressure"
1806        FeedTray.P = TRAYS(i).Inlet.P;
1807
1808"FeedTrayTop Inlet Composition"
1809        FeedTray.z = TRAYS(i).Inlet.z;
1810
1811"FeedTrayTop Inlet Vapour Fraction"
1812        FeedTray.v = TRAYS(i).Inlet.v;
1813
1814"FeedTrayTop Inlet Enthalpy"
1815        FeedTray.h = TRAYS(i).Inlet.h;
1816
1817else
1818
[832]1819"Inlet Tray - Flow Sealed"
1820    0*'mol/h'= TRAYS(i).Inlet.F;
1821       
[811]1822"Inlet Tray -  Temperature"
[832]1823    300*'K' = TRAYS(i).Inlet.T;
1824       
[811]1825"Inlet Tray -  Pressure"
[832]1826    1*'atm' = TRAYS(i).Inlet.P;
1827       
[811]1828"Inlet Tray -  Composition"
[832]1829    0.1 = TRAYS(i).Inlet.z;
1830       
[811]1831"Inlet Tray -  Vapour Fraction"
[832]1832    0 = TRAYS(i).Inlet.v;
1833       
[811]1834"Inlet Tray -  Enthalpy"
[832]1835    0*'J/mol' = TRAYS(i).Inlet.h;
[811]1836
1837end
1838
1839end
1840
[721]1841#Heat Connectors
[811]1842        Q_cond  = ConnectorHeatCondenser;
1843        Q_reb   = ConnectorHeatReboiler;
1844        Q_drum  = ConnectorHeatAccumulator;
[715]1845
1846# Splitter Connector Equations
1847        ConnectorSplitterOut.T = LiquidDistillate.T;
1848        ConnectorSplitterOut.P = LiquidDistillate.P;
1849        ConnectorSplitterOut.F = LiquidDistillate.F;
1850        ConnectorSplitterOut.z = LiquidDistillate.z;
1851
1852# Reboiler Connector Equations
1853        ConnectorReboilerLout.T = BottomProduct.T;
1854        ConnectorReboilerLout.P = BottomProduct.P;
1855        ConnectorReboilerLout.F = BottomProduct.F;
1856        ConnectorReboilerLout.z = BottomProduct.z;
1857
1858CONNECTIONS
1859#vapor
[735]1860        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
1861        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
[715]1862
1863#liquid
[811]1864        CONDENSER.OutletLiquid                          to REFLUX_DRUM.Inlet;   
1865        REFLUX_DRUM.OutletLiquid                        to SPLITTER.Inlet;
[838]1866        SPLITTER.Reflux                                         to PUMP.Inlet; 
[811]1867        PUMP.Outlet                                             to TRAYS(1).InletLiquid;
[735]1868        TRAYS(NumberOfTrays).OutletLiquid       to REBOILER.InletLiquid;
[715]1869
1870#Connectors
[811]1871        ConnectorHeatCondenser          to CONDENSER.InletQ;
1872        ConnectorHeatReboiler           to REBOILER.InletQ;
1873        ConnectorHeatAccumulator        to REFLUX_DRUM.InletQ;
[715]1874
[838]1875        SPLITTER.Distillate             to ConnectorSplitterOut;
[811]1876        REBOILER.OutletLiquid   to ConnectorReboilerLout;
[715]1877
1878end
1879
[815]1880Model Rectifier                                                         as ColumnBasic
[715]1881
1882ATTRIBUTES
1883        Pallete         = true;
1884        Icon            = "icon/RefluxedCond";
1885        Brief           = "Model of a rectifier column with dynamic condenser.";
1886        Info            =
1887"== Specify ==
1888* the feed stream of each tray (Inlet);
1889* the Murphree eficiency for each tray Emv;
[735]1890* the InletVapour stream of the bottom tray unless its flow;
[715]1891* the pump pressure difference;
1892* the heat supllied in the condenser;
[735]1893* the condenser vapor outlet flow (OutletVapour.F);
[715]1894* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1895       
1896== Initial Conditions ==
[735]1897* the TRAYS temperature (OutletLiquid.T);
1898* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1899* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]1900       
[735]1901* the condenser temperature (OutletLiquid.T);
[715]1902* the condenser liquid level (Level);
[735]1903* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
[715]1904";
1905
[815]1906SET
1907        NumberOfFeeds = 1;
[715]1908
1909VARIABLES
[721]1910        CONDENSER       as condenser    (Brief="dymamic condenser without subcooling");
[815]1911        SPLITTER        as splitter2    (Brief="splitter which separate reflux and distillate");
[721]1912        PUMP            as pump                 (Brief="pump in reflux stream");
[815]1913
1914        out     TI_cond         as control_signal       (Brief="Temperature Indicator of Condenser ", Protected = true, PosX=0.52, PosY=0);
1915        out     LI_cond         as control_signal       (Brief="Level Indicator of Condenser", Protected = true, PosX=1, PosY=0.084);
1916        out     PI_cond         as control_signal       (Brief="Pressure Indicator of Condenser", Protected = true, PosX=0.42, PosY=0);
1917       
1918        in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
1919       
[721]1920        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.66, PosY=0);
1921        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.24);
[815]1922
1923        in      Q_cond          as power (Brief="Heat supplied to Condenser",PosX=1, PosY=0.04, Protected = true);
1924
[721]1925        in      VapourInlet             as stream                       (Brief="Vapour Inlet in the section", PosX=0.07, PosY=1);
1926        out     LiquidOutlet    as liquid_stream        (Brief="Liquid Outlet in the section", PosX=0.32, PosY=1);
[815]1927
[721]1928        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1929        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
1930                VapourConnector                 as stream       (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
1931                ConnectorHeatCondenser  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
[715]1932       
1933EQUATIONS
1934
[815]1935        TI_cond = CONDENSER.TI;
1936        LI_cond = CONDENSER.LI;
1937        PI_cond = CONDENSER.PI;
1938       
1939for i in 1:NumberOfTrays do
[715]1940
[815]1941if i equal FeedTrayLocation(1) then   
[715]1942
[815]1943"FeedTrayTop Inlet Flow"       
1944        FeedTray.F= TRAYS(i).Inlet.F;
[715]1945
[815]1946"FeedTrayTop Inlet Temperature"
1947        FeedTray.T = TRAYS(i).Inlet.T;
[721]1948
[815]1949"FeedTrayTop Inlet Pressure"
1950        FeedTray.P = TRAYS(i).Inlet.P;
1951
1952"FeedTrayTop Inlet Composition"
1953        FeedTray.z = TRAYS(i).Inlet.z;
1954
1955"FeedTrayTop Inlet Vapour Fraction"
1956        FeedTray.v = TRAYS(i).Inlet.v;
1957
1958"FeedTrayTop Inlet Enthalpy"
1959        FeedTray.h = TRAYS(i).Inlet.h;
1960
1961else
1962
[832]1963"Inlet Tray - Flow Sealed"
1964    0*'mol/h'= TRAYS(i).Inlet.F;
1965       
[815]1966"Inlet Tray -  Temperature"
[832]1967    300*'K' = TRAYS(i).Inlet.T;
1968       
[815]1969"Inlet Tray -  Pressure"
[832]1970    1*'atm' = TRAYS(i).Inlet.P;
1971       
[815]1972"Inlet Tray -  Composition"
[832]1973    0.1 = TRAYS(i).Inlet.z;
1974       
[815]1975"Inlet Tray -  Vapour Fraction"
[832]1976    0 = TRAYS(i).Inlet.v;
1977       
[815]1978"Inlet Tray -  Enthalpy"
[832]1979    0*'J/mol' = TRAYS(i).Inlet.h;
[815]1980
1981end
1982
1983end
1984
1985        Q_cond = ConnectorHeatCondenser;
1986
[715]1987# Condenser Connector Equations
1988        ConnectorCondenserVout.T = VapourDistillate.T;
1989        ConnectorCondenserVout.P = VapourDistillate.P;
1990        ConnectorCondenserVout.F = VapourDistillate.F;
1991        ConnectorCondenserVout.z = VapourDistillate.z;
1992       
1993# Splitter Connector Equations
1994        ConnectorSplitterOut.T = LiquidDistillate.T;
1995        ConnectorSplitterOut.P = LiquidDistillate.P;
1996        ConnectorSplitterOut.F = LiquidDistillate.F;
1997        ConnectorSplitterOut.z = LiquidDistillate.z;
1998       
[735]1999        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletLiquid.F;
2000        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
2001        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
2002        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
[715]2003
2004        VapourConnector.F= VapourInlet.F;
2005        VapourConnector.T = VapourInlet.T;
2006        VapourConnector.P = VapourInlet.P;
2007        VapourConnector.z = VapourInlet.z;
2008        VapourConnector.v = VapourInlet.v;
2009        VapourConnector.h = VapourInlet.h;
2010
2011CONNECTIONS
2012#vapor
[735]2013        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
[715]2014
2015#liquid
[735]2016        CONDENSER.OutletLiquid  to SPLITTER.Inlet;     
[721]2017        SPLITTER.Outlet2        to PUMP.Inlet; 
[735]2018        PUMP.Outlet             to TRAYS(1).InletLiquid;
[715]2019
2020#Connectors
[721]2021ConnectorHeatCondenser  to CONDENSER.InletQ;
[735]2022VapourConnector                 to TRAYS(NumberOfTrays).InletVapour;
[721]2023SPLITTER.Outlet1                to ConnectorSplitterOut;
[815]2024CONDENSER.OutletVapour  to ConnectorCondenserVout;
[715]2025
2026end
2027
[849]2028Model PackedDistillation_kettle_cond as Packed_Section_ColumnBasic
2029        ATTRIBUTES
2030        Pallete         = true;
2031        Icon            = "icon/PackedDistillationKettleCond";
2032        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
2033        Info            =
2034"== Specify ==
2035* the feed stream of each tray (Inlet);
2036* the pump pressure difference;
2037* the total pressure drop (dP) of the packing;
2038* the heat supllied in reboiler and condenser;
2039* the condenser vapor outlet flow (OutletVapour.F);
2040* the reboiler liquid outlet flow (OutletLiquid.F);
2041* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
2042       
2043== Initial Conditions ==
2044* the stages temperature (OutletLiquid.T);
2045* the stages initial molar holdup;
2046* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each stage;
2047       
2048* the condenser temperature (OutletLiquid.T);
2049* the condenser liquid level (Level);
2050* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
2051       
2052* the reboiler temperature (OutletLiquid.T);
2053* the reboiler liquid level (Level);
2054* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
2055";
2056       
2057PARAMETERS
2058
2059        #VapourFlow as Switcher (Valid = ["on", "off"], Hidden = true ,Default = "on");
2060       
2061VARIABLES
2062#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2063# Column Devices
2064#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2065        CONDENSER       as condenser    (Brief="dymamic condenser");
2066        REBOILER        as reboiler             (Brief="kettle reboiler");
2067        SPLITTER        as splitter2            (Brief="splitter which separate reflux and distillate");
2068        PUMP            as pump                 (Brief="pump in reflux stream");
2069#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2070# Heat Ports
2071#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2072        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler",Protected = true, PosX=1, PosY=0.885);
2073        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", Protected = true, PosX=1, PosY=0.034);
2074#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2075# Column Products
2076#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2077        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.66, PosY=0);
2078        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
2079        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.68, PosY=1);
2080#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2081# Column Connectors
2082#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
2083        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
2084        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
2085        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
2086                ConnectorHeatReboiler   as power        (Brief="Heat supplied to Reboiler", Hidden=true);
2087                ConnectorHeatCondenser  as power        (Brief="Heat supplied to Condenser", Hidden=true);
2088
2089CONNECTIONS
2090
2091#vapor
2092        #REBOILER.OutletVapour          to STAGES(NumberOfStages).VapourConnector;
2093        STAGES(1).OutletVapour          to CONDENSER.InletVapour;
2094
2095#liquid
2096        CONDENSER.OutletLiquid                          to SPLITTER.Inlet;     
2097        SPLITTER.Outlet2                                to PUMP.Inlet;
2098        #PUMP.Outlet                                    to STAGES(1).InletLiquid;
2099        STAGES(NumberOfStages).OutletLiquid     to REBOILER.InletLiquid;
2100
2101#Connectors
2102ConnectorHeatReboiler   to REBOILER.InletQ;
2103ConnectorHeatCondenser  to CONDENSER.InletQ;
2104
2105CONDENSER.OutletVapour          to ConnectorCondenserVout;
2106SPLITTER.Outlet1                to ConnectorSplitterOut;
2107REBOILER.OutletLiquid           to ConnectorReboilerLout;
2108
2109EQUATIONS
2110        HeatToReboiler  = ConnectorHeatReboiler;
2111        HeatToCondenser = ConnectorHeatCondenser;
2112       
2113# Condenser Connector Equations
2114        ConnectorCondenserVout.T = VapourDistillate.T;
2115        ConnectorCondenserVout.P = VapourDistillate.P;
2116        ConnectorCondenserVout.F = VapourDistillate.F;
2117        ConnectorCondenserVout.z = VapourDistillate.z;
2118
2119# Splitter Connector Equations
2120        ConnectorSplitterOut.T = LiquidDistillate.T;
2121        ConnectorSplitterOut.P = LiquidDistillate.P;
2122        ConnectorSplitterOut.F = LiquidDistillate.F;
2123        ConnectorSplitterOut.z = LiquidDistillate.z;
2124
2125# Reboiler Connector Equations
2126        ConnectorReboilerLout.T = BottomProduct.T;
2127        ConnectorReboilerLout.P = BottomProduct.P;
2128        ConnectorReboilerLout.F = BottomProduct.F;
2129        ConnectorReboilerLout.z = BottomProduct.z;
2130
2131end
2132
[787]2133Model Rectifier_subcooling as Section_ColumnBasicX
[715]2134
2135ATTRIBUTES
2136        Pallete         = true;
2137        Icon            = "icon/RefluxedSubcooling";
2138        Brief           = "Model of a rectifier column with steady condenser.";
2139        Info            =
2140"== Specify ==
2141* the feed stream of each tray (Inlet);
2142* the Murphree eficiency for each tray Emv;
[735]2143* the InletVapour stream of the bottom tray unless its flow;
[715]2144* the pump head;
2145* the condenser pressure drop;
2146* the heat supllied in  the top tank;
2147* the heat supllied in condenser;
2148* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
2149       
2150== Initial Conditions ==
[735]2151* the TRAYS temperature (OutletLiquid.T);
2152* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
2153* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]2154       
[735]2155* the top tank temperature (OutletLiquid.T);
[715]2156* the top tank liquid level (Level);
[735]2157* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
[715]2158";
2159       
2160PARAMETERS
2161        CondenserVapourFlow             as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
2162
2163VARIABLES
[721]2164#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2165# Column Vapour and Liquid Draw Sides
2166#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2167        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.485,Protected = true);
2168        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.535,Protected = true);
2169#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2170# Column Devices
2171#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2172        CONDENSER               as condenserSteady      (Brief="steady state condenser with subcooling");
2173        ACCUMULATOR             as tank_cylindrical     (Brief="vessel drum (layed cilinder)");
[739]2174        SPLITTER                as splitter2                    (Brief="plitter which separate reflux and distillate");
[721]2175        PUMP                    as pump                         (Brief="pump in reflux stream");
2176        alfaTopo                as Real;
2177#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2178# Column Bottom outlets
2179#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2180        in      VapourInlet             as stream                       (Brief="Vapour Inlet in the section", PosX=0.07, PosY=1);
2181        out     LiquidOutlet    as liquid_stream        (Brief="Liquid Outlet in the section", PosX=0.32, PosY=1);
2182#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2183# Heat Ports
2184#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2185        in      HeatToCondenser         as power        (Brief="Heat supplied to Condenser", PosX=1, PosY=0.070, Protected=true);
2186        in      HeatToAccumulator       as power        (Brief="Heat supplied to Top Accumulator", PosX=1, PosY=0.23, Protected=true);
2187#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2188# Column Top Product
2189#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2190        out     LiquidDistillate                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.285);
2191#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2192# Column Connectors
2193#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2194in      ConnectorSplitterTop            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
2195        VapourConnector                         as stream       (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
2196        ConnectorHeatCondenser          as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
2197        ConnectorHeatAccumulator        as power        (Brief="Connector for Heat supplied to Top Accumulator", Hidden=true);
[715]2198
2199EQUATIONS
[721]2200#Heat Connectors
2201        HeatToCondenser         = ConnectorHeatCondenser;
2202        HeatToAccumulator       = ConnectorHeatAccumulator;
2203       
[735]2204        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletLiquid.F;
2205        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
2206        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
2207        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
[715]2208
2209        VapourConnector.F= VapourInlet.F;
2210        VapourConnector.T = VapourInlet.T;
2211        VapourConnector.P = VapourInlet.P;
2212        VapourConnector.z = VapourInlet.z;
2213        VapourConnector.v = VapourInlet.v;
2214        VapourConnector.h = VapourInlet.h;
2215       
2216# Splitter Connector Equations
2217        ConnectorSplitterTop.T = LiquidDistillate.T;
2218        ConnectorSplitterTop.P = LiquidDistillate.P;
2219        ConnectorSplitterTop.F = LiquidDistillate.F;
2220        ConnectorSplitterTop.z = LiquidDistillate.z;
2221
[729]2222        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
2223        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
2224        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
2225        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
2226
2227        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
2228        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
2229        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
2230        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
2231
2232        VapourDrawOffFlow = VapourDrawOff.F;
2233        LiquidDrawOffFlow = LiquidDrawOff.F;
2234       
[715]2235switch CondenserVapourFlow
2236
2237        case "on":
[735]2238                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo *Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
2239                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
2240        when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
[715]2241               
2242        case "off":
[735]2243                CONDENSER.InletVapour.F = 0 * 'mol/s';
2244        when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
[715]2245
2246end     
2247
2248CONNECTIONS
2249#vapor
[735]2250        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
[715]2251
2252#liquid
[735]2253        CONDENSER.OutletLiquid          to ACCUMULATOR.Inlet;   
[721]2254        ACCUMULATOR.Outlet                                      to SPLITTER.Inlet;
2255        SPLITTER.Outlet2                to PUMP.Inlet; 
[735]2256        PUMP.Outlet                                             to TRAYS(1).InletLiquid;
[715]2257
2258#Connectors
[735]2259        VapourConnector                         to TRAYS(NumberOfTrays).InletVapour;
[721]2260        ConnectorHeatCondenser                  to CONDENSER.InletQ;
2261        SPLITTER.Outlet1        to ConnectorSplitterTop;
2262        ConnectorHeatAccumulator                        to ACCUMULATOR.InletQ;
[715]2263
2264end
2265
[787]2266Model Reboiled_Stripping_kettle as Section_ColumnBasicX
[715]2267       
2268ATTRIBUTES
2269        Pallete         = true;
2270        Icon            = "icon/ReboiledKettle";
2271        Brief           = "Model of a reboiled stripping column with dynamic reboiler.";
2272        Info            =
2273"== Specify ==
2274* the feed stream of each tray (Inlet);
2275* the Murphree eficiency for each tray Emv;
2276* the vapour flow leaving the top of the column;
[735]2277* the InletLiquidiquid stream of the top tray;
[715]2278* the heat supllied in the reboiler;
[735]2279* the reboiler liquid outlet flow (OutletLiquid.F);
[715]2280       
2281== Initial Conditions ==
[735]2282* the TRAYS temperature (OutletLiquid.T);
2283* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
2284* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]2285       
[735]2286* the reboiler temperature (OutletLiquid.T);
[715]2287* the reboiler liquid level (Level);
[735]2288* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
[715]2289";
2290
2291VARIABLES
[721]2292#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2293# Column Vapour and Liquid Draw Sides
2294#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2295        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.28,Protected = true);
2296        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.33,Protected = true);
2297#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2298# Column Devices
2299#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
2300        REBOILER as reboiler (Brief="Kettle Reboiler");
2301#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2302# Heat Port
2303#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2304        in      HeatToReboiler  as power        (Brief="Heat supplied to Reboiler",PosX=1, PosY=0.865,Protected=true);
2305#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2306# Column Top Outlets
2307#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
2308        in      LiquidInlet             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.30, PosY=0);
2309        out     VapourOutlet    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.07, PosY=0);
2310#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2311# Column Bottom Product
2312#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2313        out     BottomProduct   as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.68, PosY=1);
2314#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2315# Column Connectors
2316#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2317        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
2318                LiquidConnector                 as stream       (Brief="Liquid connection at the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
2319                ConnectorHeatReboiler   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
[715]2320
2321CONNECTIONS
2322#vapor
[735]2323        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
[715]2324       
2325#liquid
[735]2326        TRAYS(NumberOfTrays).OutletLiquid to REBOILER.InletLiquid;
[715]2327
2328#Connectors
[735]2329REBOILER.OutletLiquid           to ConnectorReboilerLout;
2330LiquidConnector                 to TRAYS(1).InletLiquid;
[721]2331ConnectorHeatReboiler   to REBOILER.InletQ;
[715]2332
2333EQUATIONS
[721]2334#Heat Connectors
2335        HeatToReboiler = ConnectorHeatReboiler;
2336       
[715]2337        LiquidConnector.F= LiquidInlet.F;
2338        LiquidConnector.T = LiquidInlet.T;
2339        LiquidConnector.P = LiquidInlet.P;
2340        LiquidConnector.z = LiquidInlet.z;
2341        LiquidConnector.v = LiquidInlet.v;
2342        LiquidConnector.h = LiquidInlet.h;
2343       
[735]2344        VapourOutlet.F= TRAYS(1).OutletVapour.F;
2345        VapourOutlet.T = TRAYS(1).OutletVapour.T;
2346        VapourOutlet.P = TRAYS(1).OutletVapour.P;
2347        VapourOutlet.z = TRAYS(1).OutletVapour.z;
[715]2348       
2349# Reboiler Connector Equations
2350        ConnectorReboilerLout.T = BottomProduct.T;
2351        ConnectorReboilerLout.P = BottomProduct.P;
2352        ConnectorReboilerLout.F = BottomProduct.F;
2353        ConnectorReboilerLout.z = BottomProduct.z;
2354       
2355        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
2356        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
2357        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
2358        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
2359
2360        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
2361        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
2362        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
2363        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
2364
2365        VapourDrawOffFlow = VapourDrawOff.F;
2366        LiquidDrawOffFlow = LiquidDrawOff.F;
2367
2368end
2369
[787]2370Model Reboiled_Stripping_thermosyphon as Section_ColumnBasicX
[715]2371
2372ATTRIBUTES
2373        Pallete         = true;
2374        Icon            = "icon/ReboiledThermosyphon";
2375        Brief           = "Model of a reboiled stripping column with steady reboiler.";
2376        Info            =
2377"== Specify ==
2378* the feed stream of each tray (Inlet);
2379* the Murphree eficiency for each tray (Emv);
2380* the vapour flow leaving the top of the column;
[735]2381* the InletLiquidiquid stream of the top tray;
[715]2382* the heat supllied in bottom tank;
2383* the heat supllied in the reboiler;
2384* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
2385       
2386== Initial Conditions ==
[735]2387* the TRAYS temperature (OutletLiquid.T);
2388* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
2389* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]2390
[735]2391* the bottom tank temperature (OutletLiquid.T);
[715]2392* the bottom tank liquid level (Level);
[735]2393* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
[715]2394";
[721]2395
[715]2396VARIABLES
[721]2397#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2398# Column Vapour and Liquid Draw Sides
2399#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2400        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.28,Protected = true);
2401        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.33,Protected = true);
2402#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2403# Column Devices
2404#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2405        REBOILER                as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
[739]2406        SPLITTER                as splitter2            (Brief="splitter which separate the bottom product and the stream to reboiler");
[721]2407        ACCUMULATOR     as tank                         (Brief="vessel in the bottom of column");
2408#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2409# Heat Ports
2410#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2411        in      HeatToReboiler          as power        (Brief="Heat supplied to Reboiler",PosX=1, PosY=0.84,Protected=true);
2412        in      HeatToAccumulator       as power        (Brief="Heat supplied to Bottom Vessel",PosX=0, PosY=0.91,Protected=true);
2413#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2414# Column Top Outlets
2415#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2416        in      LiquidInlet             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.32, PosY=0);
2417        out     VapourOutlet    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.07, PosY=0);
2418#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2419# Column Bottom Product
2420#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2421        out     BottomProduct   as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.19, PosY=1);
2422        LiquidConnector         as stream                       (Brief="Liquid connection at the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
2423#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2424# Column Connectors
2425#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2426        in      ConnectorSplitterBottom         as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
2427        ConnectorHeatReboiler                   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
2428        ConnectorHeatAccumulator                as power        (Brief="Connector for Heat supplied to Bottom Accumulator", Hidden=true);
[715]2429
2430CONNECTIONS
2431#vapor
[735]2432        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
[715]2433       
2434#liquid
[735]2435        TRAYS(NumberOfTrays).OutletLiquid       to ACCUMULATOR.Inlet;
[721]2436        ACCUMULATOR.Outlet                              to SPLITTER.Inlet;
[735]2437        SPLITTER.Outlet2                                to REBOILER.InletLiquid;
[715]2438
2439#Connectors
[735]2440LiquidConnector                         to TRAYS(1).InletLiquid;
[721]2441ConnectorHeatReboiler           to REBOILER.InletQ;
2442ConnectorHeatAccumulator        to ACCUMULATOR.InletQ;
2443SPLITTER.Outlet1                        to ConnectorSplitterBottom;
[715]2444
2445EQUATIONS
[721]2446#Heat Connectors
2447        HeatToReboiler  = ConnectorHeatReboiler;
2448        HeatToAccumulator       = ConnectorHeatAccumulator;
2449       
[715]2450        ConnectorSplitterBottom.T = BottomProduct.T;
2451        ConnectorSplitterBottom.P = BottomProduct.P;
2452        ConnectorSplitterBottom.F = BottomProduct.F;
2453        ConnectorSplitterBottom.z = BottomProduct.z;
2454       
2455        LiquidConnector.F= LiquidInlet.F;
2456        LiquidConnector.T = LiquidInlet.T;
2457        LiquidConnector.P = LiquidInlet.P;
2458        LiquidConnector.z = LiquidInlet.z;
2459        LiquidConnector.v = LiquidInlet.v;
2460        LiquidConnector.h = LiquidInlet.h;
2461       
[735]2462        VapourOutlet.F= TRAYS(1).OutletVapour.F;
2463        VapourOutlet.T = TRAYS(1).OutletVapour.T;
2464        VapourOutlet.P = TRAYS(1).OutletVapour.P;
2465        VapourOutlet.z = TRAYS(1).OutletVapour.z;
[715]2466       
2467        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
2468        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
2469        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
2470        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
2471
2472        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
2473        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
2474        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
2475        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
2476
2477        VapourDrawOffFlow = VapourDrawOff.F;
2478        LiquidDrawOffFlow = LiquidDrawOff.F;
[721]2479
[715]2480end
2481
2482Model ReactiveDistillation
2483       
2484ATTRIBUTES
2485        Pallete         = true;
2486        Icon            = "icon/DistillationReac";
2487        Brief           = "Model of a reactive distillation column with dynamic condenser and reboiler.";
2488        Info            =
2489"== Specify ==
2490* the reaction related variables for each tray, condenser and reboiler;
2491* the feed stream of each tray (Inlet);
2492* the Murphree eficiency for each tray Emv;
2493* the pump pressure difference;
2494* the heat supllied in reboiler and condenser;
[735]2495* the condenser vapor outlet flow (OutletVapour.F);
2496* the reboiler liquid outlet flow (OutletLiquid.F);
[715]2497* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
2498       
2499== Initial Conditions ==
[735]2500* the TRAYS temperature (OutletLiquid.T);
2501* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
2502* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]2503       
[735]2504* the condenser temperature (OutletLiquid.T);
[715]2505* the condenser liquid level (Level);
[735]2506* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
[715]2507       
[735]2508* the reboiler temperature (OutletLiquid.T);
[715]2509* the reboiler liquid level (Level);
[735]2510* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
[715]2511";
2512       
2513PARAMETERS
[721]2514        outer PP        as Plugin       (Type="PP");
2515        outer NComp as Integer  (Brief="Number of Components");
2516#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2517# Section Column Feed Tray - Side Streams  Location and Numbering
2518#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2519        NumberOfTrays                                           as Integer      (Brief="Number of TRAYS", Default=2);
2520        FeedTrayIndex(NumberOfTrays)            as Integer      (Brief="Feed Tray Index", Default=0,Hidden=true);
2521        LiqSideTrayIndex(NumberOfTrays)         as Integer      (Brief="Liquid Side Tray Index", Default=0,Hidden=true);
2522        VapSideTrayIndex(NumberOfTrays)         as Integer      (Brief="Vapour Side Tray Index", Default=0,Hidden=true);
2523        FeedTrayLocation                                        as Integer      (Brief="Feed tray Location", Default=2);
2524        LiquidSideStreamLocation                        as Integer      (Brief="Liquid Side Stream Location", Default=2);
2525        VapourSideStreamLocation                        as Integer      (Brief="Vapour Side Stream Location", Default=2);
2526#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2527# Section Column Flow Model for Liquid and Vapour
2528#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2529        VapourFlow              as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
[715]2530        TrayVapourFlow  as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
[721]2531        TrayLiquidFlow  as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
2532        alfacond                as Real;
2533#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2534# Section Column Tray Geometry and Auxiliar Parameters
2535#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2536        V               as volume               (Brief="Total Volume of the tray",Hidden=true);
2537        Q               as power                (Brief="Rate of heat supply",Hidden=true);
2538        Ap              as area                 (Brief="Plate area = Atray - Adowncomer",Hidden=true);
2539        Ah              as area                 (Brief="Total holes area",Hidden=true);
2540        lw              as length               (Brief="Weir length",Hidden=true);
2541        g               as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
2542        hw              as length               (Brief="Weir height",Hidden=true);
2543        beta    as fraction     (Brief="Aeration fraction");
2544        alfa    as fraction     (Brief="Dry pressure drop coefficient");
[715]2545
2546        VolumeOfTray            as volume               (Brief="Total Volume of the tray");
2547        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
[721]2548        PlateArea                       as area                 (Brief="Plate area = Atray - Adowncomer");
2549        HolesArea                       as area                 (Brief="Total holes area");
2550        WeirLength                      as length               (Brief="Weir length");
2551        WeirHeight                      as length               (Brief="Weir height");
[715]2552
2553        stoic(NComp)    as Real(Brief="Stoichiometric matrix");
2554        Hr                                              as energy_mol;
2555       
2556SET
2557
[721]2558        FeedTrayIndex(FeedTrayLocation)         =1;
[715]2559        VapSideTrayIndex(FeedTrayLocation)      =1;
2560        LiqSideTrayIndex(FeedTrayLocation)      =1;
2561
2562        V=VolumeOfTray;
2563        Q=HeatSupply;
2564        Ap=PlateArea;
2565        Ah=HolesArea;
2566        lw=WeirLength;
2567        hw=WeirHeight ;
2568       
2569VARIABLES
[721]2570#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2571# Tray Initialization For the Whole Column Section
2572#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2573        INITIALIZATION          as InitializeSection    (Brief = "Column Model Initialization");
2574#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2575# Column Feed - Side Stream Flow and Murphree Efficiency
2576#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2577        in      FeedTray                        as stream       (Brief="Feed stream", PosX=0, PosY=0.55);
2578                VapourDrawOffFlow       as flow_mol (Brief = "Stream Molar Flow Rate");
2579                LiquidDrawOffFlow   as flow_mol (Brief = "Stream Molar Flow Rate");
2580                MurphreeEff             as Real         (Brief = "Murphree efficiency");
2581#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2582# Column Vapour and Liquid Draw Sides
2583#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2584        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.395,Protected = true);
2585        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.44,Protected = true);
2586#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2587# Heat Ports
2588#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2589        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.89);
2590        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", PosX=1, PosY=0.07);
2591#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2592# Column Devices
2593#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[715]2594        TRAYS(NumberOfTrays)    as trayReac;
[721]2595        CONDENSER                               as condenserReact;
2596        REBOILER                                as reboilerReact;
[739]2597        SPLITTER                                as splitter2;
[721]2598        PUMP                                    as pump;
2599#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2600# Column Outlets
2601#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2602        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Condenser", PosX=0.59, PosY=0);
2603        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Splitter", PosX=1, PosY=0.23);
2604        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
2605#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2606# Column Connectors
2607#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2608in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
2609in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
2610in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
2611#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2612# Column Control Ports
2613#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2614        out     TRI as control_signal   (Brief="Temperature of Reboiler Indicator", PosX=1, PosY=0.83);
2615        out     LRI as control_signal   (Brief="Level of Reboiler Indicator", PosX=1, PosY=0.855);
2616        out     TCI as control_signal   (Brief="Temperature of Condenser Indicator", PosX=1, PosY=0.01);
2617        out     LCI as control_signal   (Brief="Level of Condenser Indicator", PosX=1, PosY=0.04);
[715]2618
2619CONNECTIONS
2620#vapor
[735]2621        REBOILER.OutletVapour                                   to TRAYS(NumberOfTrays).InletVapour;
2622        TRAYS(1).OutletVapour                                   to CONDENSER.InletVapour;
2623        TRAYS([2:NumberOfTrays]).OutletVapour   to TRAYS([1:NumberOfTrays-1]).InletVapour;
[715]2624
2625#liquid
[735]2626        CONDENSER.OutletLiquid                                  to SPLITTER.Inlet;     
[721]2627        SPLITTER.Outlet2                                        to PUMP.Inlet;
[735]2628        PUMP.Outlet                                             to TRAYS(1).InletLiquid;
2629        TRAYS([1:NumberOfTrays-1]).OutletLiquid         to TRAYS([2:NumberOfTrays]).InletLiquid;
2630        TRAYS(NumberOfTrays).OutletLiquid               to REBOILER.InletLiquid;
[715]2631
2632#Connectors
[735]2633        CONDENSER.OutletVapour  to ConnectorCondenserVout;
[721]2634        SPLITTER.Outlet1        to ConnectorSplitterOut;
[735]2635        REBOILER.OutletLiquid   to ConnectorReboilerLout;
[715]2636
[721]2637INITIAL
2638#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2639# Tray Initialization
2640#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2641for i in 1:NumberOfTrays do
[715]2642
[721]2643"The initial temperature of the TRAYS"
[735]2644        TRAYS(i).OutletLiquid.T = INITIALIZATION.TopTemperature+(INITIALIZATION.BottomTemperature-INITIALIZATION.TopTemperature)*((i-1)/(NumberOfTrays-1));
[721]2645
2646"The initial Level of the TRAYS"
2647        TRAYS(i).Level = INITIALIZATION.LevelFraction*hw;
2648end
2649
2650for i in 1:NComp-1 do
2651
2652for j in 1:NumberOfTrays do
2653
2654"The initial composition of the TRAYS - Normalized"
[735]2655        TRAYS(j).OutletLiquid.z(i) = INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) +(INITIALIZATION.BottomComposition(i)/sum(INITIALIZATION.BottomComposition)-INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) )*((j-1)/(NumberOfTrays-1));
[721]2656end
2657
2658end
2659
[715]2660EQUATIONS
2661
2662for i in [1:NumberOfTrays] do
2663
2664"Murphree Efficiency"
[735]2665        TRAYS(i).OutletVapour.z =  MurphreeEff * (TRAYS(i).yideal - TRAYS(i).InletVapour.z) + TRAYS(i).InletVapour.z;
[715]2666       
2667"Energy Holdup"
[735]2668        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletLiquid.h + TRAYS(i).MV*TRAYS(i).OutletVapour.h - TRAYS(i).OutletLiquid.P*V;
[715]2669
2670"Component Molar Balance"
[735]2671        diff(TRAYS(i).M)=TRAYS(i).Inlet.F*TRAYS(i).Inlet.z + TRAYS(i).InletLiquid.F*TRAYS(i).InletLiquid.z + TRAYS(i).InletVapour.F*TRAYS(i).InletVapour.z- TRAYS(i).OutletLiquid.F*TRAYS(i).OutletLiquid.z - TRAYS(i).OutletVapour.F*TRAYS(i).OutletVapour.z-
[715]2672        TRAYS(i).LiquidSideStream.F*TRAYS(i).LiquidSideStream.z-TRAYS(i).VapourSideStream.F*TRAYS(i).VapourSideStream.z + stoic*TRAYS(i).r3*TRAYS(i).ML*TRAYS(i).vL;
2673       
2674"Energy Balance"
[735]2675        diff(TRAYS(i).E) = ( TRAYS(i).Inlet.F*TRAYS(i).Inlet.h + TRAYS(i).InletLiquid.F*TRAYS(i).InletLiquid.h + TRAYS(i).InletVapour.F*TRAYS(i).InletVapour.h- TRAYS(i).OutletLiquid.F*TRAYS(i).OutletLiquid.h - TRAYS(i).OutletVapour.F*TRAYS(i).OutletVapour.h
[715]2676        -TRAYS(i).VapourSideStream.F*TRAYS(i).VapourSideStream.h - TRAYS(i).LiquidSideStream.F*TRAYS(i).LiquidSideStream.h + Q ) + Hr * TRAYS(i).r3 *TRAYS(i). vL*TRAYS(i).ML;
2677
2678"Level of clear liquid over the weir"
2679        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/Ap;
2680
2681"Geometry Constraint"
2682        V = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
2683
2684end
2685
2686switch VapourFlow
2687                case "on":
2688                "Pressure Drop through the condenser"
[735]2689                CONDENSER.InletVapour.F*TRAYS(1).vV / 'm^2' =
2690                        sqrt((TRAYS(1).OutletVapour.P - CONDENSER.OutletLiquid.P + 1e-8 * 'atm')/(TRAYS(1).rhoV*alfacond));
2691                when TRAYS(1).OutletVapour.P < CONDENSER.OutletLiquid.P switchto "off";
[715]2692               
2693                case "off":
2694                "Prato selado"
[735]2695                CONDENSER.InletVapour.F = 0.0 * 'mol/s';
2696                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-3 * 'atm' switchto "on";
[715]2697        end
2698
2699for i in [1:NumberOfTrays] do
2700
2701        switch TrayLiquidFlow
2702                case "on":
2703                "Francis Equation"
[735]2704                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'1/s'*lw*((TRAYS(i).Level-(beta*hw)+1e-6*'m')/(beta))^2;
[715]2705                when TRAYS(i).Level < (beta * hw) switchto "off";
2706               
2707                case "off":
2708                "Low level"
[735]2709                TRAYS(i).OutletLiquid.F = 0 * 'mol/h';
[715]2710                when TRAYS(i).Level > (beta * hw) + 1e-6*'m' switchto "on";
2711        end
2712
2713        switch TrayVapourFlow
2714                case "on":
[735]2715                TRAYS(i).InletVapour.F*TRAYS(i).vV = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P - TRAYS(i).Level*g*TRAYS(i).rhoL + 1e-8 * 'atm')/(TRAYS(i).rhoV*alfa))*Ah;
2716                when TRAYS(i).InletVapour.P < TRAYS(i).OutletVapour.P + TRAYS(i).Level*g*TRAYS(i).rhoL switchto "off";
[715]2717               
2718                case "off":
[735]2719                TRAYS(i).InletVapour.F = 0 * 'mol/s';
2720                when TRAYS(i).InletVapour.P > TRAYS(i).OutletVapour.P + TRAYS(i).Level*g*TRAYS(i).rhoL + 3e-2 * 'atm' switchto "on";
[715]2721        end
2722
2723end
2724
2725# Connecting Trays
2726        FeedTray.F*FeedTrayIndex= TRAYS.Inlet.F;
2727        FeedTray.T = TRAYS.Inlet.T;
2728        FeedTray.P = TRAYS.Inlet.P;
2729        FeedTray.z = TRAYS.Inlet.z;
2730        FeedTray.v = TRAYS.Inlet.v;
2731        FeedTray.h = TRAYS.Inlet.h;
2732
[721]2733        HeatToReboiler  = REBOILER.InletQ;
2734        HeatToCondenser = CONDENSER.InletQ;
[715]2735
2736"Reboiler Temperature indicator"
[735]2737        TRI * 'K' = REBOILER.OutletLiquid.T;
[715]2738
2739"Reboiler Level indicator"
2740        LRI*REBOILER.V = REBOILER.Level*REBOILER.Across;
2741
2742"Condenser Temperature indicator"
[735]2743        TCI * 'K' = CONDENSER.OutletLiquid.T;
[715]2744
2745"Condenser Level indicator"
2746        LCI*CONDENSER.V = CONDENSER.Level*CONDENSER.Across;
2747
2748# Condenser Connector Equations
2749        ConnectorCondenserVout.T = VapourDistillate.T;
2750        ConnectorCondenserVout.P = VapourDistillate.P;
2751        ConnectorCondenserVout.F = VapourDistillate.F;
2752        ConnectorCondenserVout.z = VapourDistillate.z;
2753
2754# Splitter Connector Equations
2755        ConnectorSplitterOut.T = LiquidDistillate.T;
2756        ConnectorSplitterOut.P = LiquidDistillate.P;
2757        ConnectorSplitterOut.F = LiquidDistillate.F;
2758        ConnectorSplitterOut.z = LiquidDistillate.z;
2759
2760# Reboiler Connector Equations
2761        ConnectorReboilerLout.T = BottomProduct.T;
2762        ConnectorReboilerLout.P = BottomProduct.P;
2763        ConnectorReboilerLout.F = BottomProduct.F;
2764        ConnectorReboilerLout.z = BottomProduct.z;
2765
2766        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
2767        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
2768        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
2769        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
2770
2771        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
2772        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
2773        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
2774        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
2775
2776        VapourDrawOffFlow = VapourDrawOff.F;
2777        LiquidDrawOffFlow = LiquidDrawOff.F;
2778
2779end
2780
[878]2781*#
Note: See TracBrowser for help on using the repository browser.