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

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

tray/column revised

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