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
Line 
1#*-------------------------------------------------------------------
2* EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC.
3*
4* This LIBRARY is free software; you can distribute it and/or modify
5* it under the therms of the ALSOC FREE LICENSE as available at
6* http://www.enq.ufrgs.br/alsoc.
7*
8* EMSO Copyright (C) 2004 - 2007 ALSOC, original code
9* from http://www.rps.eng.br Copyright (C) 2002-2004.
10* All rights reserved.
11*
12* EMSO is distributed under the therms of the ALSOC LICENSE as
13* available at http://www.enq.ufrgs.br/alsoc.
14*
15*----------------------------------------------------------------------
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
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");
51        zindicator_TrayNumber   as Integer      (Brief="Composition Indicator in the tray");
52        zindicator_Component    as Integer      (Brief="Component to indicate");
53
54end
55
56Model InitializeSection
57
58ATTRIBUTES
59        Pallete = false;
60        Brief = "Initial conditions for column section.";
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);
67        LevelFraction           as fraction             (Brief = "Tray Level Fraction", Default = 0.5);
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
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");
88        ColumnHoldup                                    as positive (Brief = "Column holdup", Default=0.1);
89
90end
91
92
93Model SectionColumnBasic
94
95ATTRIBUTES
96        Pallete = false;
97        Brief   = "Model of a basic column section.";
98        Info    =
99"Model of a basic column section containing a vetor of TRAYS numbered from the top-down.";
100
101PARAMETERS
102        outer PP                as Plugin               (Brief="External Physical Properties", Type="PP");
103        outer NComp     as Integer              (Brief="Number of components");
104
105        NumberOfFeeds                                           as Integer                      (Brief="Number of Feed Trays",Default=3,Protected=true);
106        FeedTrayLocation(NumberOfFeeds)         as Integer                      (Brief="Feed tray Location",Default=2);
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);
110
111        LiquidSideStreamLocation                        as Integer                      (Brief="Liquid Side Stream Location", Default=2);
112        VapourSideStreamLocation                        as Integer                      (Brief="Vapour Side Stream Location", Default=2);
113
114        VapourFlowModel         as Switcher     (Valid = ["Reepmeyer", "Feehery_Fv", "Roffel_Fv", "Klingberg", "Wang_Fv", "Elgue"], Default = "Reepmeyer");
115        LiquidFlowModel         as Switcher     (Valid = ["Francis", "Wang_Fl", "Olsen", "Feehery_Fl", "Roffel_Fl"], Default = "Francis");
116
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);
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);
125        AerationFraction                as Real                 (Brief="Aeration fraction", Default = 1);
126        DryPdropCoeff                   as Real                 (Brief="Dry pressure drop coefficient", Default= 0.60);
127        MurphreeEff                     as Real                 (Brief="Murphree efficiency for All Trays", Default= 1);
128       
129VARIABLES
130
131        INITIALIZATION as InitializeSection (Brief="Column Model Initialization");
132        CONTROL                 as ControlSection (Brief="Column Model Control");
133       
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);
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);
139
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);
142       
143        TRAYS(NumberOfTrays)    as tray                 (Brief="Number of trays in the Column Section",Protected=true);
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");
146
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);
149       
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);
152
153SET
154        VapSideTrayIndex(VapourSideStreamLocation) =1;
155        LiqSideTrayIndex(LiquidSideStreamLocation) =1;
156       
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
169CONNECTIONS
170        TRAYS([2:NumberOfTrays]).OutletVapour   to TRAYS([1:NumberOfTrays-1]).InletVapour;
171        TRAYS([1:NumberOfTrays-1]).OutletLiquid to TRAYS([2:NumberOfTrays]).InletLiquid;
172
173    LiquidConnector to TRAYS(1).InletLiquid;
174    VapourConnector to TRAYS(NumberOfTrays).InletVapour;
175
176INITIAL
177
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"
184        TRAYS(i).Level = INITIALIZATION.LevelFraction*WeirHeight;
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
197EQUATIONS
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
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;
222
223end
224       
225switch VapourFlowModel
226
227        case "Reepmeyer":
228                TRAYS.VFlowModel = 1;
229       
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;
244
245end
246
247"Liquid Inlet Flow"     
248        LiquidConnector.F = LiquidInlet.F;
249
250"Liquid Inlet Temperature"             
251        LiquidConnector.T = LiquidInlet.T;
252
253"Liquid Inlet Pressure"         
254        LiquidConnector.P = LiquidInlet.P;
255
256"Liquid Inlet Composition"             
257        LiquidConnector.z = LiquidInlet.z;
258
259"Liquid Inlet Vapour Fraction"         
260        LiquidConnector.v = LiquidInlet.v;
261
262"Liquid Inlet Enthalpy"         
263        LiquidConnector.h = LiquidInlet.h;
264
265"Vapour Inlet Flow"             
266        VapourConnector.F = VapourInlet.F;
267
268"Vapour Inlet Temperature"             
269        VapourConnector.T = VapourInlet.T;
270
271"Vapour Inlet Pressure"         
272        VapourConnector.P = VapourInlet.P;
273
274"Vapour Inlet Composition"             
275        VapourConnector.z = VapourInlet.z;
276
277"Vapour Inlet Vapour Fraction"         
278        VapourConnector.v = VapourInlet.v;
279
280"Vapour Inlet Enthalpy"         
281        VapourConnector.h = VapourInlet.h;
282
283"Liquid Outlet Flow"   
284        LiquidOutlet.F = TRAYS(NumberOfTrays).OutletLiquid.F;
285
286"Liquid Outlet Temperature"     
287        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
288
289"Liquid Outlet Pressure"       
290        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
291
292"Liquid Outlet Composition"     
293        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
294
295"Vapour Outlet Flow"           
296        VapourOutlet.F = TRAYS(1).OutletVapour.F;
297
298"Vapour Outlet Temperature"             
299        VapourOutlet.T = TRAYS(1).OutletVapour.T;
300
301"Vapour Outlet Pressure"               
302        VapourOutlet.P = TRAYS(1).OutletVapour.P;
303
304"Vapour Outlet Composition"             
305        VapourOutlet.z = TRAYS(1).OutletVapour.z;
306
307"Vapour Draw Off Stream - Flow"         
308        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
309
310"Vapour Draw Off Stream - Temperature"         
311        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
312
313"Vapour Draw Off Stream - Pressure"             
314        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
315
316"Vapour Draw Off Stream - Composition"         
317        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
318
319"Vapour Draw Off Stream"       
320        VapourDrawOffFlow = VapourDrawOff.F;
321
322"Liquid Draw Off Stream - Flow"         
323        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
324
325"Liquid Draw Off Stream - Temperature" 
326        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
327
328"Liquid Draw Off Stream - Pressure"                     
329        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
330
331"Liquid Draw Off Stream - Composition" 
332        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
333
334"Liquid Draw Off Stream"       
335        LiquidDrawOffFlow = LiquidDrawOff.F;
336
337end
338
339Model Section_Column    as SectionColumnBasic
340
341ATTRIBUTES
342        Pallete         = true;
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#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
373for i in 1:NumberOfTrays do
374
375if   i equal FeedTrayLocation(1) then   
376
377"FeedTrayTop Inlet Flow"       
378        FeedTray.F= TRAYS(i).Inlet.F;
379
380"FeedTrayTop Inlet Temperature"
381        FeedTray.T = TRAYS(i).Inlet.T;
382
383"FeedTrayTop Inlet Pressure"
384        FeedTray.P = TRAYS(i).Inlet.P;
385
386"FeedTrayTop Inlet Composition"
387        FeedTray.z = TRAYS(i).Inlet.z;
388
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
397"Inlet Tray - Flow Sealed"
398    0*'mol/h'= TRAYS(i).Inlet.F;
399       
400"Inlet Tray -  Temperature"
401    300*'K' = TRAYS(i).Inlet.T;
402       
403"Inlet Tray -  Pressure"
404    1*'atm' = TRAYS(i).Inlet.P;
405       
406"Inlet Tray -  Composition"
407    0.1 = TRAYS(i).Inlet.z;
408       
409"Inlet Tray -  Vapour Fraction"
410    0 = TRAYS(i).Inlet.v;
411       
412"Inlet Tray -  Enthalpy"
413    0*'J/mol' = TRAYS(i).Inlet.h;
414
415end
416
417end
418
419end
420
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
498"Inlet Tray - Flow Sealed"
499    0*'mol/h'= TRAYS(i).Inlet.F;
500       
501"Inlet Tray -  Temperature"
502    300*'K' = TRAYS(i).Inlet.T;
503       
504"Inlet Tray -  Pressure"
505    1*'atm' = TRAYS(i).Inlet.P;
506       
507"Inlet Tray -  Composition"
508    0.1 = TRAYS(i).Inlet.z;
509       
510"Inlet Tray -  Vapour Fraction"
511    0 = TRAYS(i).Inlet.v;
512       
513"Inlet Tray -  Enthalpy"
514    0*'J/mol' = TRAYS(i).Inlet.h;
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
622"Inlet Tray - Flow Sealed"
623    0*'mol/h'= TRAYS(i).Inlet.F;
624       
625"Inlet Tray -  Temperature"
626    300*'K' = TRAYS(i).Inlet.T;
627       
628"Inlet Tray -  Pressure"
629    1*'atm' = TRAYS(i).Inlet.P;
630       
631"Inlet Tray -  Composition"
632    0.1 = TRAYS(i).Inlet.z;
633       
634"Inlet Tray -  Vapour Fraction"
635    0 = TRAYS(i).Inlet.v;
636       
637"Inlet Tray -  Enthalpy"
638    0*'J/mol' = TRAYS(i).Inlet.h;
639
640end
641
642end
643
644end
645
646end
647
648end
649
650
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);
698        out zCI as control_signal       (Brief="Composition control", Protected = true, PosX=1, PosY=0.8);
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       
703        in      VapourInlet             as stream                               (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1,Protected=true);
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;
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       
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#*
986Model ColumnBasic
987
988ATTRIBUTES
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
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);
1021       
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       
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       
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);
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();
1040        zero_flow = 0 * 'kmol/h';
1041        low_flow = 1E-6 * 'kmol/h';
1042
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;
1046
1047VARIABLES
1048
1049        INITIALIZATION as InitializeSection (Brief = "Column Model Initialization");
1050        CONTROL                 as ControlSection (Brief = "Control");
1051       
1052        out     TCI as control_signal   (Brief="Temperature  Indicator", Protected = true, PosX=1, PosY=0.55);
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"
1077        TRAYS(i).Level = INITIALIZATION.LevelFraction*WeirHeight;
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"
1119        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/PlateArea;
1120
1121"Geometry Constraint"
1122        TrayVolume = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
1123
1124"Energy Holdup"
1125        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletLiquid.h + TRAYS(i).MV*TRAYS(i).OutletVapour.h - TRAYS(i).OutletLiquid.P*TrayVolume;
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
1129        -TRAYS(i).VapourSideStream.F*TRAYS(i).VapourSideStream.h - TRAYS(i).LiquidSideStream.F*TRAYS(i).LiquidSideStream.h + HeatSupply );
1130
1131switch LiquidFlow
1132                case "on":
1133                        switch LiquidFlowModel
1134                                case "default":
1135                                "Francis Equation"
1136                                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'1/s'*WeirLength*((TRAYS(i).Level-(AerationFraction*WeirHeight))/(AerationFraction))^2;
1137                       
1138                                case "Wang_Fl":
1139                                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'m^0.5/s'*WeirLength*((TRAYS(i).Level-(AerationFraction*WeirHeight))/(AerationFraction))^1.5;
1140                       
1141                                case "Olsen":
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';
1143                       
1144                                case "Feehery_Fl":
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';
1146                       
1147                                case "Roffel_Fl":
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';
1150                        end
1151                when TRAYS(i).Level < (AerationFraction *WeirHeight) switchto "off";
1152               
1153                case "off":
1154                "Low level"
1155                TRAYS(i).OutletLiquid.F = 0 * 'mol/h';
1156                when TRAYS(i).Level > (AerationFraction * WeirHeight) switchto "on";
1157        end
1158       
1159switch VapourFlow
1160                case "on":
1161                        switch VapourFlowModel
1162                                case "Reepmeyer":
1163                                TRAYS(i).InletVapour.F*TRAYS(i).vV = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)/(TRAYS(i).rhoV*DryPdropCoeff))*HolesArea;
1164                       
1165                                case "Feehery_Fv":
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);
1167                       
1168                                case "Roffel_Fv":
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';
1170                       
1171                                case "Klingberg":
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);
1173                       
1174                                case "Wang_Fv":
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);
1176                               
1177                                case "Elgue":
1178                                TRAYS(i).InletVapour.F  = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)/ElgueCoeff);
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';
1184                when TRAYS(i).InletVapour.P > TRAYS(i).OutletVapour.P switchto "on";
1185        end
1186
1187end
1188
1189end
1190
1191Model Distillation_kettle_cond                          as ColumnBasic
1192
1193ATTRIBUTES
1194        Pallete         = true;
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;
1203* the condenser vapor outlet flow (OutletVapour.F);
1204* the reboiler liquid outlet flow (OutletLiquid.F);
1205* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1206       
1207== Initial Conditions ==
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;
1211       
1212* the condenser temperature (OutletLiquid.T);
1213* the condenser liquid level (Level);
1214* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1215       
1216* the reboiler temperature (OutletLiquid.T);
1217* the reboiler liquid level (Level);
1218* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1219";
1220
1221SET
1222        NumberOfFeeds = 1;
1223       
1224VARIABLES
1225
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       
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
1243
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       
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);
1254
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
1259EQUATIONS
1260
1261        SPLITTER.RefluxRatio = RefluxRatio;
1262
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
1272
1273if i equal FeedTrayLocation(1) then   
1274
1275"FeedTrayTop Inlet Flow"       
1276        FeedTray.F= TRAYS(i).Inlet.F;
1277
1278"FeedTrayTop Inlet Temperature"
1279        FeedTray.T = TRAYS(i).Inlet.T;
1280
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
1295"Inlet Tray - Flow Sealed"
1296    0*'mol/h'= TRAYS(i).Inlet.F;
1297       
1298"Inlet Tray -  Temperature"
1299    300*'K' = TRAYS(i).Inlet.T;
1300       
1301"Inlet Tray -  Pressure"
1302    1*'atm' = TRAYS(i).Inlet.P;
1303       
1304"Inlet Tray -  Composition"
1305    0.1 = TRAYS(i).Inlet.z;
1306       
1307"Inlet Tray -  Vapour Fraction"
1308    0 = TRAYS(i).Inlet.v;
1309       
1310"Inlet Tray -  Enthalpy"
1311    0*'J/mol' = TRAYS(i).Inlet.h;
1312
1313end
1314
1315end
1316
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
1335        HeatToReboiler  = ConnectorHeatReboiler;
1336        HeatToCondenser = ConnectorHeatCondenser;
1337
1338CONNECTIONS
1339#vapor
1340        REBOILER.OutletVapour   to      TRAYS(NumberOfTrays).InletVapour;
1341        TRAYS(1).OutletVapour   to      CONDENSER.InletVapour;
1342
1343#liquid
1344        CONDENSER.OutletLiquid                          to      SPLITTER.Inlet;
1345        SPLITTER.Reflux                                         to      PUMP.Inlet;
1346        PUMP.Outlet                                             to      TRAYS(1).InletLiquid;
1347        TRAYS(NumberOfTrays).OutletLiquid       to      REBOILER.InletLiquid;
1348
1349#Connectors
1350        CONDENSER.OutletVapour  to ConnectorCondenserVout;
1351        SPLITTER.Distillate             to ConnectorSplitterOut;
1352        REBOILER.OutletLiquid   to ConnectorReboilerLout;
1353
1354        ConnectorHeatReboiler   to REBOILER.InletQ;
1355        ConnectorHeatCondenser  to CONDENSER.InletQ;
1356
1357end
1358
1359Model Distillation_thermosyphon_subcooling      as ColumnBasic
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 ==
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;
1379       
1380* the top tank temperature (OutletLiquid.T);
1381* the top tank liquid level (Level);
1382* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1383       
1384* the bottom tank temperature (OutletLiquid.T);
1385* the bottom tank liquid level (Level);
1386* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1387";
1388
1389SET
1390
1391        NumberOfFeeds = 1;
1392
1393VARIABLES
1394        CONDENSER                       as condenserSteady      (Brief="steady state condenser with subcooling");
1395        REFLUX_DRUM             as TankL                        (Brief="Reflux Drum");
1396        SPLITTER_TOP            as splitter_column      (Brief="splitter which separate reflux and distillate",Protected=true);
1397        PUMP                            as pump                         (Brief="pump in reflux stream");
1398        REBOILER                        as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
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
1404        RefluxRatio             as positive             (Brief="Reflux Ratio",Default=10, Lower = 0.5);
1405
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);
1411        out     PI_reb  as control_signal       (Brief="Pressure Indicator of Reboiler", Protected = true, PosX=1, PosY=0.875);
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       
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);
1418        out     LI_drum as control_signal       (Brief="Level Indicator of Reflux Drum", Protected = true, PosX=1, PosY=0.24);
1419       
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);
1425
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);
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);
1432
1433EQUATIONS
1434
1435        SPLITTER_TOP.RefluxRatio = RefluxRatio;
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
1473"Inlet Tray - Flow Sealed"
1474    0*'mol/h'= TRAYS(i).Inlet.F;
1475       
1476"Inlet Tray -  Temperature"
1477    300*'K' = TRAYS(i).Inlet.T;
1478       
1479"Inlet Tray -  Pressure"
1480    1*'atm' = TRAYS(i).Inlet.P;
1481       
1482"Inlet Tray -  Composition"
1483    0.1 = TRAYS(i).Inlet.z;
1484       
1485"Inlet Tray -  Vapour Fraction"
1486    0 = TRAYS(i).Inlet.v;
1487       
1488"Inlet Tray -  Enthalpy"
1489    0*'J/mol' = TRAYS(i).Inlet.h;
1490
1491end
1492
1493end
1494
1495# Heat Connector Equations
1496        Q_cond  =       ConnectorHeatCondenser;
1497        Q_reb   =       ConnectorHeatReboiler;
1498        Q_drum  =       ConnectorHeatRefluxDrum;
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;
1511       
1512CONNECTIONS
1513#vapor
1514        REBOILER.OutletVapour   to SUMP.InletVapour;
1515        SUMP.OutletVapour               to TRAYS(NumberOfTrays).InletVapour;
1516        TRAYS(1).OutletVapour   to CONDENSER.InletVapour;
1517
1518#liquid
1519        CONDENSER.OutletLiquid                          to REFLUX_DRUM.Inlet;   
1520        REFLUX_DRUM.OutletLiquid                        to SPLITTER_TOP.Inlet;
1521        SPLITTER_TOP.Reflux                     to PUMP.Inlet; 
1522        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
1523        TRAYS(NumberOfTrays).OutletLiquid       to SUMP.InletLiquid;
1524        SUMP.OutletLiquid               to SPLITTER_BOTTOM.Inlet;
1525        SPLITTER_BOTTOM.Outlet2                 to REBOILER.InletLiquid;
1526
1527#Connectors
1528        ConnectorHeatCondenser                  to CONDENSER.InletQ;
1529        ConnectorHeatReboiler                   to REBOILER.InletQ;
1530        ConnectorHeatRefluxDrum                 to REFLUX_DRUM.InletQ;
1531        SPLITTER_TOP.Distillate                 to ConnectorSplitterTop;
1532        SPLITTER_BOTTOM.Outlet1                 to ConnectorSplitterBottom;
1533
1534end
1535
1536Model Distillation_thermosyphon_cond            as ColumnBasic
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;
1546* the condenser vapor outlet flow (OutletVapour.F);
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 ==
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;
1555       
1556* the condenser temperature (OutletLiquid.T);
1557* the condenser liquid level (Level);
1558* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1559       
1560* the bottom tank temperature (OutletLiquid.T);
1561* the bottom tank liquid level (Level);
1562* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1563";
1564
1565SET
1566
1567        NumberOfFeeds = 1;
1568
1569VARIABLES
1570        CONDENSER                       as condenser            (Brief="dynamic condenser without subcooling");
1571        SPLITTER_TOP            as splitter_column      (Brief="splitter which separate reflux and distillate",Protected=true);
1572        PUMP                            as pump                         (Brief="pump in reflux stream");
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");
1575        REBOILER                        as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
1576        RefluxRatio                     as positive             (Brief="Reflux Ratio",Default=10, Lower = 0.5);
1577       
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
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);
1600
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);
1603
1604EQUATIONS
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
1630"Inlet Tray - Flow Sealed"
1631    0*'mol/h'= TRAYS(i).Inlet.F;
1632       
1633"Inlet Tray -  Temperature"
1634    300*'K' = TRAYS(i).Inlet.T;
1635       
1636"Inlet Tray -  Pressure"
1637    1*'atm' = TRAYS(i).Inlet.P;
1638       
1639"Inlet Tray -  Composition"
1640    0.1 = TRAYS(i).Inlet.z;
1641       
1642"Inlet Tray -  Vapour Fraction"
1643    0 = TRAYS(i).Inlet.v;
1644       
1645"Inlet Tray -  Enthalpy"
1646    0*'J/mol' = TRAYS(i).Inlet.h;
1647
1648end
1649
1650end
1651
1652        SPLITTER_TOP.RefluxRatio = RefluxRatio;
1653
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       
1664# Heat Connector Equations
1665        Q_cond  =       ConnectorHeatCondenser;
1666        Q_reb   =       ConnectorHeatReboiler;
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
1688        SUMP.OutletVapour               to TRAYS(NumberOfTrays).InletVapour;
1689        REBOILER.OutletVapour   to SUMP.InletVapour;
1690        TRAYS(1).OutletVapour   to CONDENSER.InletVapour;
1691
1692#liquid
1693        CONDENSER.OutletLiquid          to SPLITTER_TOP.Inlet; 
1694        SPLITTER_TOP.Reflux                             to PUMP.Inlet;
1695        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
1696        TRAYS(NumberOfTrays).OutletLiquid       to SUMP.InletLiquid;
1697        SUMP.OutletLiquid                               to SPLITTER_BOTTOM.Inlet;
1698        SPLITTER_BOTTOM.Outlet2                         to REBOILER.InletLiquid;
1699
1700#Connectors
1701ConnectorHeatCondenser                  to CONDENSER.InletQ;
1702ConnectorHeatReboiler                   to REBOILER.InletQ;
1703CONDENSER.OutletVapour                  to ConnectorCondenserVout;
1704SPLITTER_TOP.Distillate                 to ConnectorSplitterTop;
1705SPLITTER_BOTTOM.Outlet1                 to ConnectorSplitterBottom;
1706
1707end
1708
1709Model Distillation_kettle_subcooling            as ColumnBasic
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;
1723* the reboiler liquid outlet flow (OutletLiquid.F);
1724* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1725       
1726== Initial Conditions ==
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;
1730       
1731* the top tank temperature (OutletLiquid.T);
1732* the top tank liquid level (Level);
1733* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1734       
1735* the reboiler temperature (OutletLiquid.T);
1736* the reboiler liquid level (Level);
1737* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1738";
1739
1740SET
1741
1742        NumberOfFeeds = 1;
1743
1744VARIABLES
1745        CONDENSER               as condenserSteady      (Brief="steady state condenser with subcooling");
1746        REFLUX_DRUM             as TankL                        (Brief="reflux drum");
1747        SPLITTER                as splitter_column              (Brief="splitter to separate reflux and distillate",Protected=true);
1748        PUMP                    as pump                         (Brief="pump in reflux stream");
1749        REBOILER                as reboiler                     (Brief="kettle reboiler");
1750
1751        RefluxRatio                     as positive             (Brief="Reflux Ratio",Default=10, Lower = 0.5);
1752
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       
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);
1776
1777out     LiquidDistillate as liquid_stream       (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.33);
1778out     BottomProduct    as liquid_stream       (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
1779
1780EQUATIONS
1781
1782        SPLITTER.RefluxRatio = RefluxRatio;
1783
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
1819"Inlet Tray - Flow Sealed"
1820    0*'mol/h'= TRAYS(i).Inlet.F;
1821       
1822"Inlet Tray -  Temperature"
1823    300*'K' = TRAYS(i).Inlet.T;
1824       
1825"Inlet Tray -  Pressure"
1826    1*'atm' = TRAYS(i).Inlet.P;
1827       
1828"Inlet Tray -  Composition"
1829    0.1 = TRAYS(i).Inlet.z;
1830       
1831"Inlet Tray -  Vapour Fraction"
1832    0 = TRAYS(i).Inlet.v;
1833       
1834"Inlet Tray -  Enthalpy"
1835    0*'J/mol' = TRAYS(i).Inlet.h;
1836
1837end
1838
1839end
1840
1841#Heat Connectors
1842        Q_cond  = ConnectorHeatCondenser;
1843        Q_reb   = ConnectorHeatReboiler;
1844        Q_drum  = ConnectorHeatAccumulator;
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
1860        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
1861        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
1862
1863#liquid
1864        CONDENSER.OutletLiquid                          to REFLUX_DRUM.Inlet;   
1865        REFLUX_DRUM.OutletLiquid                        to SPLITTER.Inlet;
1866        SPLITTER.Reflux                                         to PUMP.Inlet; 
1867        PUMP.Outlet                                             to TRAYS(1).InletLiquid;
1868        TRAYS(NumberOfTrays).OutletLiquid       to REBOILER.InletLiquid;
1869
1870#Connectors
1871        ConnectorHeatCondenser          to CONDENSER.InletQ;
1872        ConnectorHeatReboiler           to REBOILER.InletQ;
1873        ConnectorHeatAccumulator        to REFLUX_DRUM.InletQ;
1874
1875        SPLITTER.Distillate             to ConnectorSplitterOut;
1876        REBOILER.OutletLiquid   to ConnectorReboilerLout;
1877
1878end
1879
1880Model Rectifier                                                         as ColumnBasic
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;
1890* the InletVapour stream of the bottom tray unless its flow;
1891* the pump pressure difference;
1892* the heat supllied in the condenser;
1893* the condenser vapor outlet flow (OutletVapour.F);
1894* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1895       
1896== Initial Conditions ==
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;
1900       
1901* the condenser temperature (OutletLiquid.T);
1902* the condenser liquid level (Level);
1903* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1904";
1905
1906SET
1907        NumberOfFeeds = 1;
1908
1909VARIABLES
1910        CONDENSER       as condenser    (Brief="dymamic condenser without subcooling");
1911        SPLITTER        as splitter2    (Brief="splitter which separate reflux and distillate");
1912        PUMP            as pump                 (Brief="pump in reflux stream");
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       
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);
1922
1923        in      Q_cond          as power (Brief="Heat supplied to Condenser",PosX=1, PosY=0.04, Protected = true);
1924
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);
1927
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);
1932       
1933EQUATIONS
1934
1935        TI_cond = CONDENSER.TI;
1936        LI_cond = CONDENSER.LI;
1937        PI_cond = CONDENSER.PI;
1938       
1939for i in 1:NumberOfTrays do
1940
1941if i equal FeedTrayLocation(1) then   
1942
1943"FeedTrayTop Inlet Flow"       
1944        FeedTray.F= TRAYS(i).Inlet.F;
1945
1946"FeedTrayTop Inlet Temperature"
1947        FeedTray.T = TRAYS(i).Inlet.T;
1948
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
1963"Inlet Tray - Flow Sealed"
1964    0*'mol/h'= TRAYS(i).Inlet.F;
1965       
1966"Inlet Tray -  Temperature"
1967    300*'K' = TRAYS(i).Inlet.T;
1968       
1969"Inlet Tray -  Pressure"
1970    1*'atm' = TRAYS(i).Inlet.P;
1971       
1972"Inlet Tray -  Composition"
1973    0.1 = TRAYS(i).Inlet.z;
1974       
1975"Inlet Tray -  Vapour Fraction"
1976    0 = TRAYS(i).Inlet.v;
1977       
1978"Inlet Tray -  Enthalpy"
1979    0*'J/mol' = TRAYS(i).Inlet.h;
1980
1981end
1982
1983end
1984
1985        Q_cond = ConnectorHeatCondenser;
1986
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       
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;
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
2013        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
2014
2015#liquid
2016        CONDENSER.OutletLiquid  to SPLITTER.Inlet;     
2017        SPLITTER.Outlet2        to PUMP.Inlet; 
2018        PUMP.Outlet             to TRAYS(1).InletLiquid;
2019
2020#Connectors
2021ConnectorHeatCondenser  to CONDENSER.InletQ;
2022VapourConnector                 to TRAYS(NumberOfTrays).InletVapour;
2023SPLITTER.Outlet1                to ConnectorSplitterOut;
2024CONDENSER.OutletVapour  to ConnectorCondenserVout;
2025
2026end
2027
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
2133Model Rectifier_subcooling as Section_ColumnBasicX
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;
2143* the InletVapour stream of the bottom tray unless its flow;
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 ==
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;
2154       
2155* the top tank temperature (OutletLiquid.T);
2156* the top tank liquid level (Level);
2157* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
2158";
2159       
2160PARAMETERS
2161        CondenserVapourFlow             as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
2162
2163VARIABLES
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)");
2174        SPLITTER                as splitter2                    (Brief="plitter which separate reflux and distillate");
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);
2198
2199EQUATIONS
2200#Heat Connectors
2201        HeatToCondenser         = ConnectorHeatCondenser;
2202        HeatToAccumulator       = ConnectorHeatAccumulator;
2203       
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;
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
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       
2235switch CondenserVapourFlow
2236
2237        case "on":
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";
2241               
2242        case "off":
2243                CONDENSER.InletVapour.F = 0 * 'mol/s';
2244        when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
2245
2246end     
2247
2248CONNECTIONS
2249#vapor
2250        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
2251
2252#liquid
2253        CONDENSER.OutletLiquid          to ACCUMULATOR.Inlet;   
2254        ACCUMULATOR.Outlet                                      to SPLITTER.Inlet;
2255        SPLITTER.Outlet2                to PUMP.Inlet; 
2256        PUMP.Outlet                                             to TRAYS(1).InletLiquid;
2257
2258#Connectors
2259        VapourConnector                         to TRAYS(NumberOfTrays).InletVapour;
2260        ConnectorHeatCondenser                  to CONDENSER.InletQ;
2261        SPLITTER.Outlet1        to ConnectorSplitterTop;
2262        ConnectorHeatAccumulator                        to ACCUMULATOR.InletQ;
2263
2264end
2265
2266Model Reboiled_Stripping_kettle as Section_ColumnBasicX
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;
2277* the InletLiquidiquid stream of the top tray;
2278* the heat supllied in the reboiler;
2279* the reboiler liquid outlet flow (OutletLiquid.F);
2280       
2281== Initial Conditions ==
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;
2285       
2286* the reboiler temperature (OutletLiquid.T);
2287* the reboiler liquid level (Level);
2288* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
2289";
2290
2291VARIABLES
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);
2320
2321CONNECTIONS
2322#vapor
2323        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
2324       
2325#liquid
2326        TRAYS(NumberOfTrays).OutletLiquid to REBOILER.InletLiquid;
2327
2328#Connectors
2329REBOILER.OutletLiquid           to ConnectorReboilerLout;
2330LiquidConnector                 to TRAYS(1).InletLiquid;
2331ConnectorHeatReboiler   to REBOILER.InletQ;
2332
2333EQUATIONS
2334#Heat Connectors
2335        HeatToReboiler = ConnectorHeatReboiler;
2336       
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       
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;
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
2370Model Reboiled_Stripping_thermosyphon as Section_ColumnBasicX
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;
2381* the InletLiquidiquid stream of the top tray;
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 ==
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;
2390
2391* the bottom tank temperature (OutletLiquid.T);
2392* the bottom tank liquid level (Level);
2393* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
2394";
2395
2396VARIABLES
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)");
2406        SPLITTER                as splitter2            (Brief="splitter which separate the bottom product and the stream to reboiler");
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);
2429
2430CONNECTIONS
2431#vapor
2432        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
2433       
2434#liquid
2435        TRAYS(NumberOfTrays).OutletLiquid       to ACCUMULATOR.Inlet;
2436        ACCUMULATOR.Outlet                              to SPLITTER.Inlet;
2437        SPLITTER.Outlet2                                to REBOILER.InletLiquid;
2438
2439#Connectors
2440LiquidConnector                         to TRAYS(1).InletLiquid;
2441ConnectorHeatReboiler           to REBOILER.InletQ;
2442ConnectorHeatAccumulator        to ACCUMULATOR.InletQ;
2443SPLITTER.Outlet1                        to ConnectorSplitterBottom;
2444
2445EQUATIONS
2446#Heat Connectors
2447        HeatToReboiler  = ConnectorHeatReboiler;
2448        HeatToAccumulator       = ConnectorHeatAccumulator;
2449       
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       
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;
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;
2479
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;
2495* the condenser vapor outlet flow (OutletVapour.F);
2496* the reboiler liquid outlet flow (OutletLiquid.F);
2497* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
2498       
2499== Initial Conditions ==
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;
2503       
2504* the condenser temperature (OutletLiquid.T);
2505* the condenser liquid level (Level);
2506* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
2507       
2508* the reboiler temperature (OutletLiquid.T);
2509* the reboiler liquid level (Level);
2510* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
2511";
2512       
2513PARAMETERS
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);
2530        TrayVapourFlow  as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
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");
2545
2546        VolumeOfTray            as volume               (Brief="Total Volume of the tray");
2547        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
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");
2552
2553        stoic(NComp)    as Real(Brief="Stoichiometric matrix");
2554        Hr                                              as energy_mol;
2555       
2556SET
2557
2558        FeedTrayIndex(FeedTrayLocation)         =1;
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
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#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2594        TRAYS(NumberOfTrays)    as trayReac;
2595        CONDENSER                               as condenserReact;
2596        REBOILER                                as reboilerReact;
2597        SPLITTER                                as splitter2;
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);
2618
2619CONNECTIONS
2620#vapor
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;
2624
2625#liquid
2626        CONDENSER.OutletLiquid                                  to SPLITTER.Inlet;     
2627        SPLITTER.Outlet2                                        to PUMP.Inlet;
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;
2631
2632#Connectors
2633        CONDENSER.OutletVapour  to ConnectorCondenserVout;
2634        SPLITTER.Outlet1        to ConnectorSplitterOut;
2635        REBOILER.OutletLiquid   to ConnectorReboilerLout;
2636
2637INITIAL
2638#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2639# Tray Initialization
2640#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2641for i in 1:NumberOfTrays do
2642
2643"The initial temperature of the TRAYS"
2644        TRAYS(i).OutletLiquid.T = INITIALIZATION.TopTemperature+(INITIALIZATION.BottomTemperature-INITIALIZATION.TopTemperature)*((i-1)/(NumberOfTrays-1));
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"
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));
2656end
2657
2658end
2659
2660EQUATIONS
2661
2662for i in [1:NumberOfTrays] do
2663
2664"Murphree Efficiency"
2665        TRAYS(i).OutletVapour.z =  MurphreeEff * (TRAYS(i).yideal - TRAYS(i).InletVapour.z) + TRAYS(i).InletVapour.z;
2666       
2667"Energy Holdup"
2668        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletLiquid.h + TRAYS(i).MV*TRAYS(i).OutletVapour.h - TRAYS(i).OutletLiquid.P*V;
2669
2670"Component Molar Balance"
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-
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"
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
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"
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";
2692               
2693                case "off":
2694                "Prato selado"
2695                CONDENSER.InletVapour.F = 0.0 * 'mol/s';
2696                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-3 * 'atm' switchto "on";
2697        end
2698
2699for i in [1:NumberOfTrays] do
2700
2701        switch TrayLiquidFlow
2702                case "on":
2703                "Francis Equation"
2704                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'1/s'*lw*((TRAYS(i).Level-(beta*hw)+1e-6*'m')/(beta))^2;
2705                when TRAYS(i).Level < (beta * hw) switchto "off";
2706               
2707                case "off":
2708                "Low level"
2709                TRAYS(i).OutletLiquid.F = 0 * 'mol/h';
2710                when TRAYS(i).Level > (beta * hw) + 1e-6*'m' switchto "on";
2711        end
2712
2713        switch TrayVapourFlow
2714                case "on":
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";
2717               
2718                case "off":
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";
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
2733        HeatToReboiler  = REBOILER.InletQ;
2734        HeatToCondenser = CONDENSER.InletQ;
2735
2736"Reboiler Temperature indicator"
2737        TRI * 'K' = REBOILER.OutletLiquid.T;
2738
2739"Reboiler Level indicator"
2740        LRI*REBOILER.V = REBOILER.Level*REBOILER.Across;
2741
2742"Condenser Temperature indicator"
2743        TCI * 'K' = CONDENSER.OutletLiquid.T;
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
2781*#
Note: See TracBrowser for help on using the repository browser.