source: branches/new_gui/eml/stage_separators/column.mso @ 889

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

fixed: relocated folders

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 Packed_Section_ColumnBasic
650
651ATTRIBUTES
652        Pallete         = false;
653        Icon            = "icon/PackedSectionColumn";
654        Brief           = "Model of a packed column section.";
655        Info            =
656"== Model of a packed column section containing ==
657* NStages theoretical stages.
658       
659== Specify ==
660* the feed stream of each tray (Inlet);
661* the InletLiquid stream of the top tray;
662* the InletVapour stream of the bottom tray;
663* the total pressure drop (dP) of the section.
664       
665== Initial Conditions ==
666* the stages temperature (OutletLiquid.T);
667* the stages liquid holdup;
668* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
669";
670       
671PARAMETERS
672
673        outer PP                as Plugin       (Brief = "External Physical Properties", Type="PP");
674        outer NComp     as Integer      (Brief="Number of components",Protected=true);
675       
676
677        NumberOfFeeds                                           as Integer      (Brief="Number of Feed Stages",Default=3,Protected=true);
678        NumberOfStages                                          as Integer      (Brief="Number of Stages", Default=3);
679        FeedStageLocation(NumberOfFeeds)        as Integer      (Brief="Feed Stage Location",Default=2);
680       
681        PackingHeight           as length               (Brief="Height of packing");
682        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
683        ColumnDiameter          as length               (Brief="Column diameter");
684        VoidFraction            as Real                 (Brief="Void fraction of packing, (m^3 void space/m^3 packed bed)");
685        ResistanceCoeff         as positive     (Brief="Resistance coefficient on the liquid load", Default=1);
686        AreaPerPackingVol       as Real                 (Brief="surface area per packing volume", Unit='m^2/m^3');
687        HETP                            as length               (Brief="The Height Equivalent to a Theoretical Plate",Protected=true);
688
689VARIABLES
690
691        INITIALIZATION  as InitializeStage      (Brief = "Column Model Initialization");
692        CONTROL                 as ControlSection (Brief="Column Model Control");
693       
694        out     TCI as control_signal   (Brief="Temperature  Indicator", Protected = true, PosX=1, PosY=0.73);
695        out     PCI as control_signal   (Brief="Pressure Indicator", Protected = true, PosX=0, PosY=0.24);
696       
697        in      LiquidInlet             as      stream                          (Brief="Liquid Inlet in the section", PosX=0.70, PosY=0,Protected=true);
698        out     VapourOutlet            as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.30, PosY=0,Protected=true);
699       
700        in              VapourInlet             as stream                               (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1,Protected=true);
701        out     LiquidOutlet            as liquid_stream                (Brief="Liquid Outlet in the section", PosX=0.70, PosY=1,Protected=true);
702       
703        LiquidConnector as stream       (Brief="Liquid connection at the middle STAGES", PosX=0.75, PosY=1,Hidden=true);
704        VapourConnector as stream       (Brief="Vapour connection at the middle STAGES", PosX=0.55, PosY=0,Hidden=true);
705       
706        STAGES(NumberOfStages) as packedStage (Brief="Column Stages",Protected=true);
707        PressureDrop               as pressure (Brief="Column Pressure Drop", Protected=true);
708
709SET
710
711        STAGES.Number_Stages                            = NumberOfStages;
712        STAGES.HeightOfPacking                          = PackingHeight;
713        STAGES.HeatOnStage                                      = HeatSupply;
714        STAGES.ColumnInternalDiameter           = ColumnDiameter;
715        STAGES.PackingVoidFraction                      = VoidFraction;
716        STAGES.LiquidResistanceCoeff            = ResistanceCoeff ;
717        STAGES.AreaPerPackingVolume             = AreaPerPackingVol;
718       
719        HETP = PackingHeight/NumberOfStages;   
720
721CONNECTIONS
722
723        STAGES([2:NumberOfStages]).OutletVapour         to STAGES([1:NumberOfStages-1]).InletVapour;
724        STAGES([1:NumberOfStages-1]).OutletLiquid       to STAGES([2:NumberOfStages]).InletLiquid;
725        LiquidConnector                                                         to STAGES(1).InletLiquid;
726        VapourConnector                                                         to STAGES(NumberOfStages).InletVapour;
727
728EQUATIONS
729
730        LiquidConnector.F= LiquidInlet.F;
731        LiquidConnector.T = LiquidInlet.T;
732        LiquidConnector.P = LiquidInlet.P;
733        LiquidConnector.z = LiquidInlet.z;
734        LiquidConnector.v = LiquidInlet.v;
735        LiquidConnector.h = LiquidInlet.h;
736       
737        VapourConnector.F= VapourInlet.F;
738        VapourConnector.T = VapourInlet.T;
739        VapourConnector.P = VapourInlet.P;
740        VapourConnector.z = VapourInlet.z;
741        VapourConnector.v = VapourInlet.v;
742        VapourConnector.h = VapourInlet.h;
743       
744        LiquidOutlet.F= STAGES(NumberOfStages).OutletLiquid.F;
745        LiquidOutlet.T = STAGES(NumberOfStages).OutletLiquid.T;
746        LiquidOutlet.P = STAGES(NumberOfStages).OutletLiquid.P;
747        LiquidOutlet.z = STAGES(NumberOfStages).OutletLiquid.z;
748       
749        VapourOutlet.F= STAGES(1).OutletVapour.F;
750        VapourOutlet.T = STAGES(1).OutletVapour.T;
751        VapourOutlet.P = STAGES(1).OutletVapour.P;
752        VapourOutlet.z = STAGES(1).OutletVapour.z;
753
754"Tray Temperature Indicator"   
755        #TCI*'K' = TRAYS(min([NumberOfTrays, CONTROL.Tindicator_TrayNumber])).OutletVapour.T;
756        TCI*'K' = STAGES(CONTROL.Tindicator_TrayNumber).OutletVapour.T;
757
758"Tray Pressure Indicator"       
759        #PCI*'atm' = TRAYS(min([NumberOfTrays, CONTROL.Pindicator_TrayNumber])).OutletVapour.P;
760        PCI*'atm' = STAGES(CONTROL.Pindicator_TrayNumber).OutletVapour.P;
761
762"PressureDrop"
763        PressureDrop = STAGES(NumberOfStages).OutletLiquid.P - STAGES(1).OutletLiquid.P;
764
765INITIAL
766
767for i in 1:NumberOfStages do
768
769"The initial temperature of the STAGES"
770        STAGES(i).OutletLiquid.T = INITIALIZATION.TopStageTemperature+(INITIALIZATION.BottomStageTemperature-INITIALIZATION.TopStageTemperature)*((i-1)/(NumberOfStages-1));
771
772"The Column Holdup of the STAGES"
773        STAGES(i).hl = INITIALIZATION.ColumnHoldup;
774
775end
776
777for i in 1:NComp-1 do
778
779for j in 1:NumberOfStages do
780
781"The initial composition of the TRAYS"
782        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));
783
784end
785
786end
787
788end
789
790Model Packed_Section_Column     as Packed_Section_ColumnBasic
791
792        ATTRIBUTES
793        Pallete         = true;
794        Icon            = "icon/PackedSectionColumn";
795        Brief           = "Model of a packed column section.";
796        Info            =
797"== Model of a packed column section containing ==
798* NStages theoretical stages.
799       
800== Specify ==
801* the feed stream of each tray (Inlet);
802* the InletLiquid stream of the top tray;
803* the InletVapour stream of the bottom tray;
804* the total pressure drop (dP) of the section.
805       
806== Initial Conditions ==
807* the stages temperature (OutletLiquid.T);
808* the stages liquid holdup;
809* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
810";
811
812SET
813        NumberOfFeeds = 1;
814
815VARIABLES
816       
817        in      FeedStage       as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
818
819EQUATIONS
820#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
821# Equating Feed Tray Variables to Trays Variables
822#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
823for i in 1:NumberOfStages do
824
825if   i equal FeedStageLocation(1) then   
826
827"FeedTrayTop Inlet Flow"       
828        FeedStage.F= STAGES(i).Inlet.F;
829
830"FeedTrayTop Inlet Temperature"
831        FeedStage.T = STAGES(i).Inlet.T;
832
833"FeedTrayTop Inlet Pressure"
834        FeedStage.P = STAGES(i).Inlet.P;
835
836"FeedTrayTop Inlet Composition"
837        FeedStage.z = STAGES(i).Inlet.z;
838
839"FeedTrayTop Inlet Vapour Fraction"
840        FeedStage.v = STAGES(i).Inlet.v;
841
842"FeedTrayTop Inlet Enthalpy"
843        FeedStage.h = STAGES(i).Inlet.h;
844
845else
846
847"Inlet Tray - Flow Sealed"
848    0*'mol/h'= STAGES(i).Inlet.F;
849       
850"Inlet Tray -  Temperature"
851    300*'K' = STAGES(i).Inlet.T;
852       
853"Inlet Tray -  Pressure"
854    1*'atm' = STAGES(i).Inlet.P;
855       
856"Inlet Tray -  Composition"
857    0.1 = STAGES(i).Inlet.z;
858       
859"Inlet Tray -  Vapour Fraction"
860    0 = STAGES(i).Inlet.v;
861       
862"Inlet Tray -  Enthalpy"
863    0*'J/mol' = STAGES(i).Inlet.h;
864
865end
866
867end
868
869end
870
871Model Packed_Section_Column2    as Packed_Section_ColumnBasic
872
873        ATTRIBUTES
874        Pallete         = true;
875        Icon            = "icon/PackedSectionColumn";
876        Brief           = "Model of a packed column section.";
877        Info            =
878"== Model of a packed column section containing ==
879* NStages theoretical stages.
880       
881== Specify ==
882* the feed stream of each tray (Inlet);
883* the InletLiquid stream of the top tray;
884* the InletVapour stream of the bottom tray;
885* the total pressure drop (dP) of the section.
886       
887== Initial Conditions ==
888* the stages temperature (OutletLiquid.T);
889* the stages liquid holdup;
890* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
891";
892
893SET
894        NumberOfFeeds = 2;
895
896VARIABLES
897       
898        in      FeedStageOne    as stream               (Brief="Feed stream", PosX=0, PosY=0.45);
899        in      FeedStageTwo    as stream               (Brief="Feed stream", PosX=0, PosY=0.65);
900
901EQUATIONS
902#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
903# Equating Feed Stage Variables to Stages Variables
904#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
905
906for i in 1:NumberOfStages do
907
908if   i equal FeedStageLocation(1) then   
909
910"FeedTrayTop Inlet Flow"       
911        FeedStageOne.F= STAGES(i).Inlet.F;
912
913"FeedTrayTop Inlet Temperature"
914        FeedStageOne.T = STAGES(i).Inlet.T;
915
916"FeedTrayTop Inlet Pressure"
917        FeedStageOne.P = STAGES(i).Inlet.P;
918
919"FeedTrayTop Inlet Composition"
920        FeedStageOne.z = STAGES(i).Inlet.z;
921
922"FeedTrayTop Inlet Vapour Fraction"
923        FeedStageOne.v = STAGES(i).Inlet.v;
924
925"FeedTrayTop Inlet Enthalpy"
926        FeedStageOne.h = STAGES(i).Inlet.h;
927
928else if   i equal FeedStageLocation(2) then   
929
930"FeedTrayBottom Inlet Flow"     
931        FeedStageTwo.F= STAGES(i).Inlet.F;
932
933"FeedTrayBottom Inlet Temperature"
934        FeedStageTwo.T = STAGES(i).Inlet.T;
935
936"FeedTrayBottom Inlet Pressure"
937        FeedStageTwo.P = STAGES(i).Inlet.P;
938
939"FeedTrayBottom Inlet Composition"
940        FeedStageTwo.z = STAGES(i).Inlet.z;
941
942"FeedTrayBottom Inlet Vapour Fraction"
943        FeedStageTwo.v = STAGES(i).Inlet.v;
944
945"FeedTrayBottom Inlet Enthalpy"
946        FeedStageTwo.h = STAGES(i).Inlet.h;
947
948else
949
950"Inlet Tray - Flow Sealed"
951    0*'mol/h'= STAGES(i).Inlet.F;
952       
953"Inlet Tray -  Temperature"
954    300*'K' = STAGES(i).Inlet.T;
955       
956"Inlet Tray -  Pressure"
957    1*'atm' = STAGES(i).Inlet.P;
958       
959"Inlet Tray -  Composition"
960    0.1 = STAGES(i).Inlet.z;
961       
962"Inlet Tray -  Vapour Fraction"
963    0 = STAGES(i).Inlet.v;
964       
965"Inlet Tray -  Enthalpy"
966    0*'J/mol' = STAGES(i).Inlet.h;
967
968end
969
970end
971
972end
973
974end
975
976
977# Models to be revised
978#*
979Model ColumnBasic
980
981ATTRIBUTES
982        Pallete = false;
983        Brief   = "Model of a basic column.";
984        Info    =
985"Model of a basic column containing a vetor of TRAYS numbered from the top-down.";
986
987PARAMETERS
988        outer PP                as Plugin       (Brief="External Physical Properties", Type="PP");
989        outer NComp     as Integer      (Brief="Number of components");
990
991        NumberOfFeeds                                           as Integer                      (Brief="Number of Feed Trays",Default=3,Protected=true);
992        FeedTrayLocation(NumberOfFeeds)         as Integer                      (Brief="Feed tray Location",Default=2);
993        NumberOfTrays                                           as Integer                      (Brief="Number of trays", Default=8);
994        LiqSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Liquid Side Tray Index", Default=0,Hidden=true);
995        VapSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Vapour Side Tray Index", Default=0,Hidden=true);
996        LiquidSideStreamLocation                        as Integer                      (Brief="Liquid Side Stream Location", Default=2);
997        VapourSideStreamLocation                        as Integer                      (Brief="Vapour Side Stream Location", Default=2);
998        g                                                                       as acceleration         (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
999        Mw(NComp)                                                       as molweight            (Brief="Component Mol Weight",Hidden=true);
1000
1001        VapourFlowModel         as Switcher     (Valid = ["Reepmeyer", "Feehery_Fv", "Roffel_Fv", "Klingberg", "Wang_Fv", "Elgue"], Default = "Reepmeyer");
1002        LiquidFlowModel         as Switcher     (Valid = ["default", "Wang_Fl", "Olsen", "Feehery_Fl", "Roffel_Fl"], Default = "default");
1003
1004        TrayDiameter                    as length               (Brief="Tray Diameter",Default=1.600);
1005        TraySpacing                             as length               (Brief="Tray Spacing",Default=0.600);
1006        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);
1007        Fraction_DowncomerArea  as fraction     (Brief="Fraction of the downcomer area with respect to the total tray area",Default=0.20);
1008        WeirLength                              as length               (Brief="Weir length", Default = 1);
1009        WeirHeight                              as length               (Brief="Weir height", Default= 0.05);
1010        TrayLiquidPasses                as positive     (Brief="Number of liquid passes in the tray", Lower = 1,Default=1);
1011        HeatSupply                              as heat_rate    (Brief="Rate of heat supply",Default = 0);
1012        AerationFraction                as Real                 (Brief="Aeration fraction", Default = 1);
1013        DryPdropCoeff                   as Real                 (Brief="Dry pressure drop coefficient", Default= 0.60);
1014       
1015        PlateArea               as area         (Brief="Plate area = Atray - Adowncomer",Protected=true);
1016        TrayVolume              as volume       (Brief="Total Volume of the tray",Protected=true);
1017        HolesArea               as area         (Brief="Total holes area",Protected=true);
1018       
1019        FeeheryCoeff            as Real                 (Brief="Feeherys correlation coefficient", Unit='1/m^4', Default=1,Hidden=true);
1020        ElgueCoeff                      as Real                 (Brief="Elgues correlation coefficient", Unit='kg/m/mol^2', Default=1,Hidden=true);
1021        OlsenCoeff                      as Real                 (Brief="Olsens correlation coefficient", Default=1,Hidden=true);
1022       
1023        Pi                      as constant             (Brief="Pi Number",Default=3.14159265, Symbol = "\pi",Hidden=true);
1024        zero_flow       as flow_mol             (Brief = "Stream Flow closed",Default = 0, Hidden=true);
1025        low_flow        as flow_mol             (Brief = "Low stream Flow",Default = 1E-6, Hidden=true);
1026        VapourFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
1027        LiquidFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
1028
1029SET
1030        VapSideTrayIndex(VapourSideStreamLocation) =1;
1031        LiqSideTrayIndex(LiquidSideStreamLocation) =1;
1032        Mw = PP.MolecularWeight();
1033        zero_flow = 0 * 'kmol/h';
1034        low_flow = 1E-6 * 'kmol/h';
1035
1036        PlateArea = 0.25*Pi*(TrayDiameter^2)*(1-Fraction_DowncomerArea);
1037        TrayVolume = 0.25*Pi*(TrayDiameter^2)*TraySpacing;
1038        HolesArea = 0.25*Pi*(TrayDiameter^2)*Fraction_HoleArea;
1039
1040VARIABLES
1041
1042        INITIALIZATION as InitializeSection (Brief = "Column Model Initialization");
1043        CONTROL                 as ControlSection (Brief = "Control");
1044       
1045        out     TCI as control_signal   (Brief="Temperature  Indicator", Protected = true, PosX=1, PosY=0.55);
1046        out     PCI as control_signal   (Brief="Pressure Indicator", Protected = true, PosX=0, PosY=0.23);
1047       
1048        TRAYS(NumberOfTrays)    as tray                 (Brief="Number of trays in the Column Section");
1049        VapourDrawOffFlow               as flow_mol     (Brief="Vapour Draw Off Stream Molar Flow Rate");
1050        LiquidDrawOffFlow               as flow_mol     (Brief="Vapour Draw Off Stream Molar Flow Rate");
1051        MurphreeEff                     as Real                 (Brief="Murphree efficiency for All Trays",Lower=0.01,Upper=1);
1052
1053        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.388,Protected = true);
1054        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.47,Protected = true);
1055
1056CONNECTIONS
1057
1058#Connecting Intermediate Trays
1059        TRAYS([2:NumberOfTrays]).OutletVapour   to TRAYS([1:NumberOfTrays-1]).InletVapour;
1060        TRAYS([1:NumberOfTrays-1]).OutletLiquid         to TRAYS([2:NumberOfTrays]).InletLiquid;
1061       
1062INITIAL
1063
1064for i in 1:NumberOfTrays do
1065
1066"The initial temperature of the TRAYS"
1067        TRAYS(i).OutletLiquid.T = INITIALIZATION.TopTemperature+(INITIALIZATION.BottomTemperature-INITIALIZATION.TopTemperature)*((i-1)/(NumberOfTrays-1));
1068
1069"The initial Level of the TRAYS"
1070        TRAYS(i).Level = INITIALIZATION.LevelFraction*WeirHeight;
1071end
1072
1073for i in 1:NComp-1 do
1074
1075for j in 1:NumberOfTrays do
1076
1077"The initial composition of the TRAYS - Normalized"
1078        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));
1079end
1080
1081end
1082
1083EQUATIONS
1084
1085        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1086        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1087        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1088        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1089
1090        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1091        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1092        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1093        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1094
1095        VapourDrawOffFlow = VapourDrawOff.F;
1096        LiquidDrawOffFlow = LiquidDrawOff.F;
1097       
1098"Tray Temperature Indicator"   
1099        #TCI*'K' = TRAYS(min([NumberOfTrays, CONTROL.Tindicator_TrayNumber])).OutletVapour.T;
1100        TCI*'K' = TRAYS(CONTROL.Tindicator_TrayNumber).OutletVapour.T;
1101
1102"Tray Pressure Indicator"       
1103        #PCI*'atm' = TRAYS(min([NumberOfTrays, CONTROL.Pindicator_TrayNumber])).OutletVapour.P;
1104        PCI*'atm' = TRAYS(CONTROL.Pindicator_TrayNumber).OutletVapour.P;
1105
1106for i in [1:NumberOfTrays] do
1107
1108"Murphree Efficiency"
1109        TRAYS(i).OutletVapour.z =  MurphreeEff * (TRAYS(i).yideal - TRAYS(i).InletVapour.z) + TRAYS(i).InletVapour.z;
1110
1111"Level of clear liquid over the weir"
1112        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/PlateArea;
1113
1114"Geometry Constraint"
1115        TrayVolume = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
1116
1117"Energy Holdup"
1118        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletLiquid.h + TRAYS(i).MV*TRAYS(i).OutletVapour.h - TRAYS(i).OutletLiquid.P*TrayVolume;
1119
1120"Energy Balance"
1121        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
1122        -TRAYS(i).VapourSideStream.F*TRAYS(i).VapourSideStream.h - TRAYS(i).LiquidSideStream.F*TRAYS(i).LiquidSideStream.h + HeatSupply );
1123
1124switch LiquidFlow
1125                case "on":
1126                        switch LiquidFlowModel
1127                                case "default":
1128                                "Francis Equation"
1129                                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'1/s'*WeirLength*((TRAYS(i).Level-(AerationFraction*WeirHeight))/(AerationFraction))^2;
1130                       
1131                                case "Wang_Fl":
1132                                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'m^0.5/s'*WeirLength*((TRAYS(i).Level-(AerationFraction*WeirHeight))/(AerationFraction))^1.5;
1133                       
1134                                case "Olsen":
1135                                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';
1136                       
1137                                case "Feehery_Fl":
1138                                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';
1139                       
1140                                case "Roffel_Fl":
1141                                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/
1142                                                        (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';
1143                        end
1144                when TRAYS(i).Level < (AerationFraction *WeirHeight) switchto "off";
1145               
1146                case "off":
1147                "Low level"
1148                TRAYS(i).OutletLiquid.F = 0 * 'mol/h';
1149                when TRAYS(i).Level > (AerationFraction * WeirHeight) switchto "on";
1150        end
1151       
1152switch VapourFlow
1153                case "on":
1154                        switch VapourFlowModel
1155                                case "Reepmeyer":
1156                                TRAYS(i).InletVapour.F*TRAYS(i).vV = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)/(TRAYS(i).rhoV*DryPdropCoeff))*HolesArea;
1157                       
1158                                case "Feehery_Fv":
1159                                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);
1160                       
1161                                case "Roffel_Fv":
1162                                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';
1163                       
1164                                case "Klingberg":
1165                                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);
1166                       
1167                                case "Wang_Fv":
1168                                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);
1169                               
1170                                case "Elgue":
1171                                TRAYS(i).InletVapour.F  = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)/ElgueCoeff);
1172                        end
1173                when TRAYS(i).InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
1174               
1175                case "off":
1176                TRAYS(i).InletVapour.F = 0 * 'mol/s';
1177                when TRAYS(i).InletVapour.P > TRAYS(i).OutletVapour.P switchto "on";
1178        end
1179
1180end
1181
1182end
1183
1184Model Distillation_kettle_cond                          as ColumnBasic
1185
1186ATTRIBUTES
1187        Pallete         = true;
1188        Icon            = "icon/DistillationKettleCond";
1189        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
1190        Info            =
1191"== Specify ==
1192* the feed stream of each tray (Inlet);
1193* the Murphree eficiency for each tray Emv;
1194* the pump pressure difference;
1195* the heat supllied in reboiler and condenser;
1196* the condenser vapor outlet flow (OutletVapour.F);
1197* the reboiler liquid outlet flow (OutletLiquid.F);
1198* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1199       
1200== Initial Conditions ==
1201* the TRAYS temperature (OutletLiquid.T);
1202* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1203* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1204       
1205* the condenser temperature (OutletLiquid.T);
1206* the condenser liquid level (Level);
1207* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1208       
1209* the reboiler temperature (OutletLiquid.T);
1210* the reboiler liquid level (Level);
1211* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1212";
1213
1214SET
1215        NumberOfFeeds = 1;
1216       
1217VARIABLES
1218
1219        CONDENSER               as condenser;
1220        REBOILER                as reboiler;
1221        SPLITTER                as splitter_column (Brief="splitter which separate reflux and distillate",Protected=true);
1222        PUMP                    as pump;
1223        RefluxRatio             as positive             (Brief="Reflux Ratio",Default=10, Lower = 0.5);
1224       
1225        out     TI_reb  as control_signal       (Brief="Temperature Indicator of Reboiler ",Protected = true, PosX=0.515, PosY=1);
1226        out     LI_reb  as control_signal       (Brief="Level Indicator of Reboiler", Protected = true, PosX=1, PosY=0.935);
1227        out     PI_reb  as control_signal       (Brief="Pressure Indicator of Reboiler", Protected = true, PosX=0.41, PosY=1);
1228       
1229        out     TI_cond         as control_signal       (Brief="Temperature Indicator of Condenser ", Protected = true, PosX=0.52, PosY=0);
1230        out     LI_cond         as control_signal       (Brief="Level Indicator of Condenser", Protected = true, PosX=1, PosY=0.084);
1231        out     PI_cond         as control_signal       (Brief="Pressure Indicator of Condenser", Protected = true, PosX=0.42, PosY=0);
1232       
1233        in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
1234
1235
1236
1237        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler",Protected = true, PosX=1, PosY=0.855);
1238        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", Protected = true, PosX=1, PosY=0.01);
1239
1240
1241        ConnectorHeatReboiler   as power        (Brief="Heat supplied to Reboiler", Hidden=true);
1242        ConnectorHeatCondenser  as power        (Brief="Heat supplied to Condenser", Hidden=true);
1243       
1244        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Condenser", Hidden=true);
1245        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1246        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1247
1248        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Condenser", PosX=0.615, PosY=0);
1249        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.235);
1250        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.62, PosY=1);
1251
1252EQUATIONS
1253
1254        SPLITTER.RefluxRatio = RefluxRatio;
1255
1256        TI_reb  = REBOILER.TI ;
1257        LI_reb  = REBOILER.LI;
1258        PI_reb  = REBOILER.PI;
1259       
1260        TI_cond = CONDENSER.TI;
1261        LI_cond = CONDENSER.LI;
1262        PI_cond = CONDENSER.PI;
1263       
1264for i in 1:NumberOfTrays do
1265
1266if i equal FeedTrayLocation(1) then   
1267
1268"FeedTrayTop Inlet Flow"       
1269        FeedTray.F= TRAYS(i).Inlet.F;
1270
1271"FeedTrayTop Inlet Temperature"
1272        FeedTray.T = TRAYS(i).Inlet.T;
1273
1274"FeedTrayTop Inlet Pressure"
1275        FeedTray.P = TRAYS(i).Inlet.P;
1276
1277"FeedTrayTop Inlet Composition"
1278        FeedTray.z = TRAYS(i).Inlet.z;
1279
1280"FeedTrayTop Inlet Vapour Fraction"
1281        FeedTray.v = TRAYS(i).Inlet.v;
1282
1283"FeedTrayTop Inlet Enthalpy"
1284        FeedTray.h = TRAYS(i).Inlet.h;
1285
1286else
1287
1288"Inlet Tray - Flow Sealed"
1289    0*'mol/h'= TRAYS(i).Inlet.F;
1290       
1291"Inlet Tray -  Temperature"
1292    300*'K' = TRAYS(i).Inlet.T;
1293       
1294"Inlet Tray -  Pressure"
1295    1*'atm' = TRAYS(i).Inlet.P;
1296       
1297"Inlet Tray -  Composition"
1298    0.1 = TRAYS(i).Inlet.z;
1299       
1300"Inlet Tray -  Vapour Fraction"
1301    0 = TRAYS(i).Inlet.v;
1302       
1303"Inlet Tray -  Enthalpy"
1304    0*'J/mol' = TRAYS(i).Inlet.h;
1305
1306end
1307
1308end
1309
1310# Condenser Connector Equations
1311        ConnectorCondenserVout.T = VapourDistillate.T;
1312        ConnectorCondenserVout.P = VapourDistillate.P;
1313        ConnectorCondenserVout.F = VapourDistillate.F;
1314        ConnectorCondenserVout.z = VapourDistillate.z;
1315
1316# Splitter Connector Equations
1317        ConnectorSplitterOut.T = LiquidDistillate.T;
1318        ConnectorSplitterOut.P = LiquidDistillate.P;
1319        ConnectorSplitterOut.F = LiquidDistillate.F;
1320        ConnectorSplitterOut.z = LiquidDistillate.z;
1321
1322# Reboiler Connector Equations
1323        ConnectorReboilerLout.T = BottomProduct.T;
1324        ConnectorReboilerLout.P = BottomProduct.P;
1325        ConnectorReboilerLout.F = BottomProduct.F;
1326        ConnectorReboilerLout.z = BottomProduct.z;
1327
1328        HeatToReboiler  = ConnectorHeatReboiler;
1329        HeatToCondenser = ConnectorHeatCondenser;
1330
1331CONNECTIONS
1332#vapor
1333        REBOILER.OutletVapour   to      TRAYS(NumberOfTrays).InletVapour;
1334        TRAYS(1).OutletVapour   to      CONDENSER.InletVapour;
1335
1336#liquid
1337        CONDENSER.OutletLiquid                          to      SPLITTER.Inlet;
1338        SPLITTER.Reflux                                         to      PUMP.Inlet;
1339        PUMP.Outlet                                             to      TRAYS(1).InletLiquid;
1340        TRAYS(NumberOfTrays).OutletLiquid       to      REBOILER.InletLiquid;
1341
1342#Connectors
1343        CONDENSER.OutletVapour  to ConnectorCondenserVout;
1344        SPLITTER.Distillate             to ConnectorSplitterOut;
1345        REBOILER.OutletLiquid   to ConnectorReboilerLout;
1346
1347        ConnectorHeatReboiler   to REBOILER.InletQ;
1348        ConnectorHeatCondenser  to CONDENSER.InletQ;
1349
1350end
1351
1352Model Distillation_thermosyphon_subcooling      as ColumnBasic
1353        ATTRIBUTES
1354        Pallete         = true;
1355        Icon            = "icon/DistillationThermosyphonSubcooling";
1356        Brief           = "Model of a distillation column with steady condenser and steady reboiler.";
1357        Info            =
1358"== Specify ==
1359* the feed stream of each tray (Inlet);
1360* the Murphree eficiency for each tray Emv;
1361* the pump head;
1362* the condenser pressure drop;
1363* the heat supllied in top and bottom tanks;
1364* the heat supllied in condenser and reboiler;
1365* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
1366* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1367       
1368== Initial Conditions ==
1369* the TRAYS temperature (OutletLiquid.T);
1370* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1371* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1372       
1373* the top tank temperature (OutletLiquid.T);
1374* the top tank liquid level (Level);
1375* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1376       
1377* the bottom tank temperature (OutletLiquid.T);
1378* the bottom tank liquid level (Level);
1379* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1380";
1381
1382SET
1383
1384        NumberOfFeeds = 1;
1385
1386VARIABLES
1387        CONDENSER                       as condenserSteady      (Brief="steady state condenser with subcooling");
1388        REFLUX_DRUM             as TankL                        (Brief="Reflux Drum");
1389        SPLITTER_TOP            as splitter_column      (Brief="splitter which separate reflux and distillate",Protected=true);
1390        PUMP                            as pump                         (Brief="pump in reflux stream");
1391        REBOILER                        as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
1392        SUMP                            as SumpTank                     (Brief="vessel in the bottom of column");
1393        SPLITTER_BOTTOM         as splitter2            (Brief="splitter to separate the bottom product and the stream to reboiler");
1394       
1395        in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
1396
1397        RefluxRatio             as positive             (Brief="Reflux Ratio",Default=10, Lower = 0.5);
1398
1399in              Q_cond          as power        (Brief="Heat supplied to Condenser",PosX=1, PosY=0, Protected=true);
1400in              Q_reb           as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.96,Protected=true);
1401in              Q_drum  as power        (Brief="Heat supplied to Reflux Drum", PosX=1, PosY=0.30,Protected=true);
1402
1403        out     TI_reb  as control_signal       (Brief="Temperature Indicator of Reboiler ",Protected = true, PosX=1, PosY=0.92);
1404        out     PI_reb  as control_signal       (Brief="Pressure Indicator of Reboiler", Protected = true, PosX=1, PosY=0.875);
1405       
1406        out     TI_cond         as control_signal       (Brief="Temperature Indicator of Condenser ", Protected = true, PosX=0.52, PosY=0);
1407        out     PI_cond         as control_signal       (Brief="Pressure Indicator of Condenser", Protected = true, PosX=0.42, PosY=0);
1408       
1409        out     TI_drum as control_signal       (Brief="Temperature Indicator of Reflux Drum ", Protected = true, PosX=1, PosY=0.20);
1410        out     PI_drum as control_signal       (Brief="Pressure Indicator of Reflux Drum", Protected = true, PosX=1, PosY=0.155);
1411        out     LI_drum as control_signal       (Brief="Level Indicator of Reflux Drum", Protected = true, PosX=1, PosY=0.24);
1412       
1413        out     LI_sump as control_signal       (Brief="Level Indicator of Column Sump", Protected = true, PosX=1, PosY=0.765);
1414        out     TI_sump as control_signal       (Brief="Temperature Indicator of Column Sump ",Protected = true, PosX=1, PosY=0.71);
1415       
1416        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.33);
1417        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=0.06, PosY=1);
1418
1419        in      ConnectorSplitterBottom         as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1420        in      ConnectorSplitterTop            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1421
1422        ConnectorHeatReboiler           as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1423        ConnectorHeatCondenser          as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1424        ConnectorHeatRefluxDrum         as power        (Brief="Connector for Heat supplied to Reflux Drum", Hidden=true);
1425
1426EQUATIONS
1427
1428        SPLITTER_TOP.RefluxRatio = RefluxRatio;
1429        TI_reb  = REBOILER.TI ;
1430        PI_reb  = REBOILER.PI;
1431       
1432        TI_cond = CONDENSER.TI;
1433        PI_cond = CONDENSER.PI;
1434       
1435        TI_drum = REFLUX_DRUM.TI;
1436        PI_drum = REFLUX_DRUM.PI;
1437        LI_drum = REFLUX_DRUM.LI;
1438       
1439        TI_sump = SUMP.TI;
1440        LI_sump = SUMP.LI;
1441       
1442for i in 1:NumberOfTrays do
1443
1444if i equal FeedTrayLocation(1) then   
1445
1446"FeedTrayTop Inlet Flow"       
1447        FeedTray.F= TRAYS(i).Inlet.F;
1448
1449"FeedTrayTop Inlet Temperature"
1450        FeedTray.T = TRAYS(i).Inlet.T;
1451
1452"FeedTrayTop Inlet Pressure"
1453        FeedTray.P = TRAYS(i).Inlet.P;
1454
1455"FeedTrayTop Inlet Composition"
1456        FeedTray.z = TRAYS(i).Inlet.z;
1457
1458"FeedTrayTop Inlet Vapour Fraction"
1459        FeedTray.v = TRAYS(i).Inlet.v;
1460
1461"FeedTrayTop Inlet Enthalpy"
1462        FeedTray.h = TRAYS(i).Inlet.h;
1463
1464else
1465
1466"Inlet Tray - Flow Sealed"
1467    0*'mol/h'= TRAYS(i).Inlet.F;
1468       
1469"Inlet Tray -  Temperature"
1470    300*'K' = TRAYS(i).Inlet.T;
1471       
1472"Inlet Tray -  Pressure"
1473    1*'atm' = TRAYS(i).Inlet.P;
1474       
1475"Inlet Tray -  Composition"
1476    0.1 = TRAYS(i).Inlet.z;
1477       
1478"Inlet Tray -  Vapour Fraction"
1479    0 = TRAYS(i).Inlet.v;
1480       
1481"Inlet Tray -  Enthalpy"
1482    0*'J/mol' = TRAYS(i).Inlet.h;
1483
1484end
1485
1486end
1487
1488# Heat Connector Equations
1489        Q_cond  =       ConnectorHeatCondenser;
1490        Q_reb   =       ConnectorHeatReboiler;
1491        Q_drum  =       ConnectorHeatRefluxDrum;
1492
1493# Top Splitter Connector Equations
1494        ConnectorSplitterTop.T = LiquidDistillate.T;
1495        ConnectorSplitterTop.P = LiquidDistillate.P;
1496        ConnectorSplitterTop.F = LiquidDistillate.F;
1497        ConnectorSplitterTop.z = LiquidDistillate.z;
1498
1499# Bottom Splitter Connector Equations
1500        ConnectorSplitterBottom.T = BottomProduct.T;
1501        ConnectorSplitterBottom.P = BottomProduct.P;
1502        ConnectorSplitterBottom.F = BottomProduct.F;
1503        ConnectorSplitterBottom.z = BottomProduct.z;
1504       
1505CONNECTIONS
1506#vapor
1507        REBOILER.OutletVapour   to SUMP.InletVapour;
1508        SUMP.OutletVapour               to TRAYS(NumberOfTrays).InletVapour;
1509        TRAYS(1).OutletVapour   to CONDENSER.InletVapour;
1510
1511#liquid
1512        CONDENSER.OutletLiquid                          to REFLUX_DRUM.Inlet;   
1513        REFLUX_DRUM.OutletLiquid                        to SPLITTER_TOP.Inlet;
1514        SPLITTER_TOP.Reflux                     to PUMP.Inlet; 
1515        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
1516        TRAYS(NumberOfTrays).OutletLiquid       to SUMP.InletLiquid;
1517        SUMP.OutletLiquid               to SPLITTER_BOTTOM.Inlet;
1518        SPLITTER_BOTTOM.Outlet2                 to REBOILER.InletLiquid;
1519
1520#Connectors
1521        ConnectorHeatCondenser                  to CONDENSER.InletQ;
1522        ConnectorHeatReboiler                   to REBOILER.InletQ;
1523        ConnectorHeatRefluxDrum                 to REFLUX_DRUM.InletQ;
1524        SPLITTER_TOP.Distillate                 to ConnectorSplitterTop;
1525        SPLITTER_BOTTOM.Outlet1                 to ConnectorSplitterBottom;
1526
1527end
1528
1529Model Distillation_thermosyphon_cond            as ColumnBasic
1530        ATTRIBUTES
1531        Pallete         = true;
1532        Icon            = "icon/DistillationThermosyphonCond";
1533        Brief           = "Model of a distillation column with dynamic condenser and steady reboiler.";
1534        Info            =
1535"== Specify ==
1536* the feed stream of each tray (Inlet);
1537* the Murphree eficiency for each tray Emv;
1538* the pump head;
1539* the condenser vapor outlet flow (OutletVapour.F);
1540* the heat supllied in bottom tank;
1541* the heat supllied in condenser and reboiler;
1542* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
1543       
1544== Initial Conditions ==
1545* the TRAYS temperature (OutletLiquid.T);
1546* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1547* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1548       
1549* the condenser temperature (OutletLiquid.T);
1550* the condenser liquid level (Level);
1551* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1552       
1553* the bottom tank temperature (OutletLiquid.T);
1554* the bottom tank liquid level (Level);
1555* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1556";
1557
1558SET
1559
1560        NumberOfFeeds = 1;
1561
1562VARIABLES
1563        CONDENSER                       as condenser            (Brief="dynamic condenser without subcooling");
1564        SPLITTER_TOP            as splitter_column      (Brief="splitter which separate reflux and distillate",Protected=true);
1565        PUMP                            as pump                         (Brief="pump in reflux stream");
1566        SUMP                            as SumpTank                     (Brief="vessel in the bottom of column");
1567        SPLITTER_BOTTOM         as splitter2            (Brief="splitter who separate the bottom product and the stream to reboiler");
1568        REBOILER                        as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
1569        RefluxRatio                     as positive             (Brief="Reflux Ratio",Default=10, Lower = 0.5);
1570       
1571        in      FeedTray        as stream       (Brief="Feed stream", PosX=0, PosY=0.55);
1572
1573in              Q_cond  as power        (Brief="Heat supplied to Condenser",PosX=1, PosY=0, Protected=true);
1574in              Q_reb   as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.96,Protected=true);
1575
1576        out     TI_cond as control_signal       (Brief="Temperature Indicator of Condenser ", Protected = true, PosX=0.48, PosY=0);
1577        out     LI_cond as control_signal       (Brief="Level Indicator of Condenser", Protected = true, PosX=1, PosY=0.084);
1578        out     PI_cond as control_signal       (Brief="Pressure Indicator of Condenser", Protected = true, PosX=0.40, PosY=0);
1579       
1580        out     TI_reb  as control_signal       (Brief="Temperature Indicator of Reboiler ",Protected = true, PosX=1, PosY=0.92);
1581        out     PI_reb  as control_signal       (Brief="Pressure Indicator of Reboiler", Protected = true, PosX=1, PosY=0.878);
1582       
1583        out     LI_sump as control_signal       (Brief="Level Indicator of Column Sump", Protected = true, PosX=1, PosY=0.76);
1584        out     TI_sump as control_signal       (Brief="Temperature Indicator of Column Sump ",Protected = true, PosX=1, PosY=0.71);
1585       
1586out     VapourDistillate as vapour_stream       (Brief="Vapour outlet stream From Top Condenser", PosX=0.62, PosY=0);
1587out     LiquidDistillate as liquid_stream       (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.185);
1588out     BottomProduct    as liquid_stream       (Brief="Liquid outlet stream From Bottom Splitter", PosX=0.06, PosY=1);
1589
1590in      ConnectorSplitterBottom as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1591in      ConnectorSplitterTop    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1592in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
1593
1594        ConnectorHeatReboiler   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1595        ConnectorHeatCondenser  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1596
1597EQUATIONS
1598
1599for i in 1:NumberOfTrays do
1600
1601if i equal FeedTrayLocation(1) then   
1602
1603"FeedTrayTop Inlet Flow"       
1604        FeedTray.F= TRAYS(i).Inlet.F;
1605
1606"FeedTrayTop Inlet Temperature"
1607        FeedTray.T = TRAYS(i).Inlet.T;
1608
1609"FeedTrayTop Inlet Pressure"
1610        FeedTray.P = TRAYS(i).Inlet.P;
1611
1612"FeedTrayTop Inlet Composition"
1613        FeedTray.z = TRAYS(i).Inlet.z;
1614
1615"FeedTrayTop Inlet Vapour Fraction"
1616        FeedTray.v = TRAYS(i).Inlet.v;
1617
1618"FeedTrayTop Inlet Enthalpy"
1619        FeedTray.h = TRAYS(i).Inlet.h;
1620
1621else
1622
1623"Inlet Tray - Flow Sealed"
1624    0*'mol/h'= TRAYS(i).Inlet.F;
1625       
1626"Inlet Tray -  Temperature"
1627    300*'K' = TRAYS(i).Inlet.T;
1628       
1629"Inlet Tray -  Pressure"
1630    1*'atm' = TRAYS(i).Inlet.P;
1631       
1632"Inlet Tray -  Composition"
1633    0.1 = TRAYS(i).Inlet.z;
1634       
1635"Inlet Tray -  Vapour Fraction"
1636    0 = TRAYS(i).Inlet.v;
1637       
1638"Inlet Tray -  Enthalpy"
1639    0*'J/mol' = TRAYS(i).Inlet.h;
1640
1641end
1642
1643end
1644
1645        SPLITTER_TOP.RefluxRatio = RefluxRatio;
1646
1647        TI_reb  = REBOILER.TI ;
1648        PI_reb  = REBOILER.PI;
1649       
1650        TI_cond = CONDENSER.TI;
1651        PI_cond = CONDENSER.PI;
1652        LI_cond = CONDENSER.LI;
1653       
1654        TI_sump = SUMP.TI;
1655        LI_sump = SUMP.LI;
1656       
1657# Heat Connector Equations
1658        Q_cond  =       ConnectorHeatCondenser;
1659        Q_reb   =       ConnectorHeatReboiler;
1660
1661# Condenser Connector Equations
1662        ConnectorCondenserVout.T = VapourDistillate.T;
1663        ConnectorCondenserVout.P = VapourDistillate.P;
1664        ConnectorCondenserVout.F = VapourDistillate.F;
1665        ConnectorCondenserVout.z = VapourDistillate.z;
1666
1667# Top Splitter Connector Equations
1668        ConnectorSplitterTop.T = LiquidDistillate.T;
1669        ConnectorSplitterTop.P = LiquidDistillate.P;
1670        ConnectorSplitterTop.F = LiquidDistillate.F;
1671        ConnectorSplitterTop.z = LiquidDistillate.z;
1672
1673# Bottom Splitter Connector Equations
1674        ConnectorSplitterBottom.T = BottomProduct.T;
1675        ConnectorSplitterBottom.P = BottomProduct.P;
1676        ConnectorSplitterBottom.F = BottomProduct.F;
1677        ConnectorSplitterBottom.z = BottomProduct.z;
1678
1679CONNECTIONS
1680#vapor
1681        SUMP.OutletVapour               to TRAYS(NumberOfTrays).InletVapour;
1682        REBOILER.OutletVapour   to SUMP.InletVapour;
1683        TRAYS(1).OutletVapour   to CONDENSER.InletVapour;
1684
1685#liquid
1686        CONDENSER.OutletLiquid          to SPLITTER_TOP.Inlet; 
1687        SPLITTER_TOP.Reflux                             to PUMP.Inlet;
1688        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
1689        TRAYS(NumberOfTrays).OutletLiquid       to SUMP.InletLiquid;
1690        SUMP.OutletLiquid                               to SPLITTER_BOTTOM.Inlet;
1691        SPLITTER_BOTTOM.Outlet2                         to REBOILER.InletLiquid;
1692
1693#Connectors
1694ConnectorHeatCondenser                  to CONDENSER.InletQ;
1695ConnectorHeatReboiler                   to REBOILER.InletQ;
1696CONDENSER.OutletVapour                  to ConnectorCondenserVout;
1697SPLITTER_TOP.Distillate                 to ConnectorSplitterTop;
1698SPLITTER_BOTTOM.Outlet1                 to ConnectorSplitterBottom;
1699
1700end
1701
1702Model Distillation_kettle_subcooling            as ColumnBasic
1703
1704ATTRIBUTES
1705        Pallete         = true;
1706        Icon            = "icon/DistillationKettleSubcooling";
1707        Brief   = "Model of a distillation column with steady condenser and dynamic reboiler.";
1708        Info            =
1709"== Specify ==
1710* the feed stream of each tray (Inlet);
1711* the Murphree eficiency for each tray (Emv);
1712* the pump pressure difference;
1713* the heat supllied in reboiler and condenser;
1714* the heat supllied in the top tank;
1715* the condenser pressure drop;
1716* the reboiler liquid outlet flow (OutletLiquid.F);
1717* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1718       
1719== Initial Conditions ==
1720* the TRAYS temperature (OutletLiquid.T);
1721* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1722* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1723       
1724* the top tank temperature (OutletLiquid.T);
1725* the top tank liquid level (Level);
1726* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1727       
1728* the reboiler temperature (OutletLiquid.T);
1729* the reboiler liquid level (Level);
1730* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1731";
1732
1733SET
1734
1735        NumberOfFeeds = 1;
1736
1737VARIABLES
1738        CONDENSER               as condenserSteady      (Brief="steady state condenser with subcooling");
1739        REFLUX_DRUM             as TankL                        (Brief="reflux drum");
1740        SPLITTER                as splitter_column              (Brief="splitter to separate reflux and distillate",Protected=true);
1741        PUMP                    as pump                         (Brief="pump in reflux stream");
1742        REBOILER                as reboiler                     (Brief="kettle reboiler");
1743
1744        RefluxRatio                     as positive             (Brief="Reflux Ratio",Default=10, Lower = 0.5);
1745
1746        in      Q_cond  as power        (Brief="Heat supplied to Condenser", PosX=1, PosY=0.065, Protected=true);
1747        in      Q_reb   as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.905, Protected=true);
1748        in      Q_drum  as power        (Brief="Heat supplied to Top Vessel", PosX=1, PosY=0.30, Protected=true);
1749
1750        in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
1751
1752        out     TI_reb  as control_signal       (Brief="Temperature Indicator of Reboiler ",Protected = true, PosX=0.515, PosY=1);
1753        out     LI_reb  as control_signal       (Brief="Level Indicator of Reboiler", Protected = true, PosX=1, PosY=0.935);
1754        out     PI_reb  as control_signal       (Brief="Pressure Indicator of Reboiler", Protected = true, PosX=0.41, PosY=1);
1755       
1756        out     TI_cond as control_signal       (Brief="Temperature Indicator of Condenser ", Protected = true, PosX=0.52, PosY=0);
1757        out     PI_cond as control_signal       (Brief="Pressure Indicator of Condenser", Protected = true, PosX=0.42, PosY=0);
1758       
1759        out     TI_drum as control_signal       (Brief="Temperature Indicator of Reflux Drum ", Protected = true, PosX=1, PosY=0.20);
1760        out     PI_drum as control_signal       (Brief="Pressure Indicator of Reflux Drum", Protected = true, PosX=1, PosY=0.155);
1761        out     LI_drum as control_signal       (Brief="Level Indicator of Reflux Drum", Protected = true, PosX=1, PosY=0.24);
1762       
1763       
1764in      ConnectorSplitterOut            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1765in      ConnectorReboilerLout           as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1766        ConnectorHeatReboiler           as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1767        ConnectorHeatCondenser          as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1768        ConnectorHeatAccumulator        as power        (Brief="Connector for Heat supplied to TopVessel", Hidden=true);
1769
1770out     LiquidDistillate as liquid_stream       (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.33);
1771out     BottomProduct    as liquid_stream       (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
1772
1773EQUATIONS
1774
1775        SPLITTER.RefluxRatio = RefluxRatio;
1776
1777        TI_reb  = REBOILER.TI ;
1778        PI_reb  = REBOILER.PI;
1779        LI_reb  = REBOILER.LI;
1780       
1781        TI_cond = CONDENSER.TI;
1782        PI_cond = CONDENSER.PI;
1783       
1784        TI_drum = REFLUX_DRUM.TI;
1785        PI_drum = REFLUX_DRUM.PI;
1786        LI_drum = REFLUX_DRUM.LI;
1787       
1788for i in 1:NumberOfTrays do
1789
1790if i equal FeedTrayLocation(1) then   
1791
1792"FeedTrayTop Inlet Flow"       
1793        FeedTray.F= TRAYS(i).Inlet.F;
1794
1795"FeedTrayTop Inlet Temperature"
1796        FeedTray.T = TRAYS(i).Inlet.T;
1797
1798"FeedTrayTop Inlet Pressure"
1799        FeedTray.P = TRAYS(i).Inlet.P;
1800
1801"FeedTrayTop Inlet Composition"
1802        FeedTray.z = TRAYS(i).Inlet.z;
1803
1804"FeedTrayTop Inlet Vapour Fraction"
1805        FeedTray.v = TRAYS(i).Inlet.v;
1806
1807"FeedTrayTop Inlet Enthalpy"
1808        FeedTray.h = TRAYS(i).Inlet.h;
1809
1810else
1811
1812"Inlet Tray - Flow Sealed"
1813    0*'mol/h'= TRAYS(i).Inlet.F;
1814       
1815"Inlet Tray -  Temperature"
1816    300*'K' = TRAYS(i).Inlet.T;
1817       
1818"Inlet Tray -  Pressure"
1819    1*'atm' = TRAYS(i).Inlet.P;
1820       
1821"Inlet Tray -  Composition"
1822    0.1 = TRAYS(i).Inlet.z;
1823       
1824"Inlet Tray -  Vapour Fraction"
1825    0 = TRAYS(i).Inlet.v;
1826       
1827"Inlet Tray -  Enthalpy"
1828    0*'J/mol' = TRAYS(i).Inlet.h;
1829
1830end
1831
1832end
1833
1834#Heat Connectors
1835        Q_cond  = ConnectorHeatCondenser;
1836        Q_reb   = ConnectorHeatReboiler;
1837        Q_drum  = ConnectorHeatAccumulator;
1838
1839# Splitter Connector Equations
1840        ConnectorSplitterOut.T = LiquidDistillate.T;
1841        ConnectorSplitterOut.P = LiquidDistillate.P;
1842        ConnectorSplitterOut.F = LiquidDistillate.F;
1843        ConnectorSplitterOut.z = LiquidDistillate.z;
1844
1845# Reboiler Connector Equations
1846        ConnectorReboilerLout.T = BottomProduct.T;
1847        ConnectorReboilerLout.P = BottomProduct.P;
1848        ConnectorReboilerLout.F = BottomProduct.F;
1849        ConnectorReboilerLout.z = BottomProduct.z;
1850
1851CONNECTIONS
1852#vapor
1853        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
1854        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
1855
1856#liquid
1857        CONDENSER.OutletLiquid                          to REFLUX_DRUM.Inlet;   
1858        REFLUX_DRUM.OutletLiquid                        to SPLITTER.Inlet;
1859        SPLITTER.Reflux                                         to PUMP.Inlet; 
1860        PUMP.Outlet                                             to TRAYS(1).InletLiquid;
1861        TRAYS(NumberOfTrays).OutletLiquid       to REBOILER.InletLiquid;
1862
1863#Connectors
1864        ConnectorHeatCondenser          to CONDENSER.InletQ;
1865        ConnectorHeatReboiler           to REBOILER.InletQ;
1866        ConnectorHeatAccumulator        to REFLUX_DRUM.InletQ;
1867
1868        SPLITTER.Distillate             to ConnectorSplitterOut;
1869        REBOILER.OutletLiquid   to ConnectorReboilerLout;
1870
1871end
1872
1873Model Rectifier                                                         as ColumnBasic
1874
1875ATTRIBUTES
1876        Pallete         = true;
1877        Icon            = "icon/RefluxedCond";
1878        Brief           = "Model of a rectifier column with dynamic condenser.";
1879        Info            =
1880"== Specify ==
1881* the feed stream of each tray (Inlet);
1882* the Murphree eficiency for each tray Emv;
1883* the InletVapour stream of the bottom tray unless its flow;
1884* the pump pressure difference;
1885* the heat supllied in the condenser;
1886* the condenser vapor outlet flow (OutletVapour.F);
1887* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1888       
1889== Initial Conditions ==
1890* the TRAYS temperature (OutletLiquid.T);
1891* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1892* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1893       
1894* the condenser temperature (OutletLiquid.T);
1895* the condenser liquid level (Level);
1896* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1897";
1898
1899SET
1900        NumberOfFeeds = 1;
1901
1902VARIABLES
1903        CONDENSER       as condenser    (Brief="dymamic condenser without subcooling");
1904        SPLITTER        as splitter2    (Brief="splitter which separate reflux and distillate");
1905        PUMP            as pump                 (Brief="pump in reflux stream");
1906
1907        out     TI_cond         as control_signal       (Brief="Temperature Indicator of Condenser ", Protected = true, PosX=0.52, PosY=0);
1908        out     LI_cond         as control_signal       (Brief="Level Indicator of Condenser", Protected = true, PosX=1, PosY=0.084);
1909        out     PI_cond         as control_signal       (Brief="Pressure Indicator of Condenser", Protected = true, PosX=0.42, PosY=0);
1910       
1911        in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
1912       
1913        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.66, PosY=0);
1914        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.24);
1915
1916        in      Q_cond          as power (Brief="Heat supplied to Condenser",PosX=1, PosY=0.04, Protected = true);
1917
1918        in      VapourInlet             as stream                       (Brief="Vapour Inlet in the section", PosX=0.07, PosY=1);
1919        out     LiquidOutlet    as liquid_stream        (Brief="Liquid Outlet in the section", PosX=0.32, PosY=1);
1920
1921        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1922        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
1923                VapourConnector                 as stream       (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
1924                ConnectorHeatCondenser  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1925       
1926EQUATIONS
1927
1928        TI_cond = CONDENSER.TI;
1929        LI_cond = CONDENSER.LI;
1930        PI_cond = CONDENSER.PI;
1931       
1932for i in 1:NumberOfTrays do
1933
1934if i equal FeedTrayLocation(1) then   
1935
1936"FeedTrayTop Inlet Flow"       
1937        FeedTray.F= TRAYS(i).Inlet.F;
1938
1939"FeedTrayTop Inlet Temperature"
1940        FeedTray.T = TRAYS(i).Inlet.T;
1941
1942"FeedTrayTop Inlet Pressure"
1943        FeedTray.P = TRAYS(i).Inlet.P;
1944
1945"FeedTrayTop Inlet Composition"
1946        FeedTray.z = TRAYS(i).Inlet.z;
1947
1948"FeedTrayTop Inlet Vapour Fraction"
1949        FeedTray.v = TRAYS(i).Inlet.v;
1950
1951"FeedTrayTop Inlet Enthalpy"
1952        FeedTray.h = TRAYS(i).Inlet.h;
1953
1954else
1955
1956"Inlet Tray - Flow Sealed"
1957    0*'mol/h'= TRAYS(i).Inlet.F;
1958       
1959"Inlet Tray -  Temperature"
1960    300*'K' = TRAYS(i).Inlet.T;
1961       
1962"Inlet Tray -  Pressure"
1963    1*'atm' = TRAYS(i).Inlet.P;
1964       
1965"Inlet Tray -  Composition"
1966    0.1 = TRAYS(i).Inlet.z;
1967       
1968"Inlet Tray -  Vapour Fraction"
1969    0 = TRAYS(i).Inlet.v;
1970       
1971"Inlet Tray -  Enthalpy"
1972    0*'J/mol' = TRAYS(i).Inlet.h;
1973
1974end
1975
1976end
1977
1978        Q_cond = ConnectorHeatCondenser;
1979
1980# Condenser Connector Equations
1981        ConnectorCondenserVout.T = VapourDistillate.T;
1982        ConnectorCondenserVout.P = VapourDistillate.P;
1983        ConnectorCondenserVout.F = VapourDistillate.F;
1984        ConnectorCondenserVout.z = VapourDistillate.z;
1985       
1986# Splitter Connector Equations
1987        ConnectorSplitterOut.T = LiquidDistillate.T;
1988        ConnectorSplitterOut.P = LiquidDistillate.P;
1989        ConnectorSplitterOut.F = LiquidDistillate.F;
1990        ConnectorSplitterOut.z = LiquidDistillate.z;
1991       
1992        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletLiquid.F;
1993        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
1994        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
1995        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
1996
1997        VapourConnector.F= VapourInlet.F;
1998        VapourConnector.T = VapourInlet.T;
1999        VapourConnector.P = VapourInlet.P;
2000        VapourConnector.z = VapourInlet.z;
2001        VapourConnector.v = VapourInlet.v;
2002        VapourConnector.h = VapourInlet.h;
2003
2004CONNECTIONS
2005#vapor
2006        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
2007
2008#liquid
2009        CONDENSER.OutletLiquid  to SPLITTER.Inlet;     
2010        SPLITTER.Outlet2        to PUMP.Inlet; 
2011        PUMP.Outlet             to TRAYS(1).InletLiquid;
2012
2013#Connectors
2014ConnectorHeatCondenser  to CONDENSER.InletQ;
2015VapourConnector                 to TRAYS(NumberOfTrays).InletVapour;
2016SPLITTER.Outlet1                to ConnectorSplitterOut;
2017CONDENSER.OutletVapour  to ConnectorCondenserVout;
2018
2019end
2020
2021Model PackedDistillation_kettle_cond as Packed_Section_ColumnBasic
2022        ATTRIBUTES
2023        Pallete         = true;
2024        Icon            = "icon/PackedDistillationKettleCond";
2025        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
2026        Info            =
2027"== Specify ==
2028* the feed stream of each tray (Inlet);
2029* the pump pressure difference;
2030* the total pressure drop (dP) of the packing;
2031* the heat supllied in reboiler and condenser;
2032* the condenser vapor outlet flow (OutletVapour.F);
2033* the reboiler liquid outlet flow (OutletLiquid.F);
2034* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
2035       
2036== Initial Conditions ==
2037* the stages temperature (OutletLiquid.T);
2038* the stages initial molar holdup;
2039* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each stage;
2040       
2041* the condenser temperature (OutletLiquid.T);
2042* the condenser liquid level (Level);
2043* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
2044       
2045* the reboiler temperature (OutletLiquid.T);
2046* the reboiler liquid level (Level);
2047* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
2048";
2049       
2050PARAMETERS
2051
2052        #VapourFlow as Switcher (Valid = ["on", "off"], Hidden = true ,Default = "on");
2053       
2054VARIABLES
2055#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2056# Column Devices
2057#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2058        CONDENSER       as condenser    (Brief="dymamic condenser");
2059        REBOILER        as reboiler             (Brief="kettle reboiler");
2060        SPLITTER        as splitter2            (Brief="splitter which separate reflux and distillate");
2061        PUMP            as pump                 (Brief="pump in reflux stream");
2062#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2063# Heat Ports
2064#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2065        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler",Protected = true, PosX=1, PosY=0.885);
2066        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", Protected = true, PosX=1, PosY=0.034);
2067#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2068# Column Products
2069#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2070        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.66, PosY=0);
2071        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
2072        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.68, PosY=1);
2073#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2074# Column Connectors
2075#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
2076        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
2077        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
2078        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
2079                ConnectorHeatReboiler   as power        (Brief="Heat supplied to Reboiler", Hidden=true);
2080                ConnectorHeatCondenser  as power        (Brief="Heat supplied to Condenser", Hidden=true);
2081
2082CONNECTIONS
2083
2084#vapor
2085        #REBOILER.OutletVapour          to STAGES(NumberOfStages).VapourConnector;
2086        STAGES(1).OutletVapour          to CONDENSER.InletVapour;
2087
2088#liquid
2089        CONDENSER.OutletLiquid                          to SPLITTER.Inlet;     
2090        SPLITTER.Outlet2                                to PUMP.Inlet;
2091        #PUMP.Outlet                                    to STAGES(1).InletLiquid;
2092        STAGES(NumberOfStages).OutletLiquid     to REBOILER.InletLiquid;
2093
2094#Connectors
2095ConnectorHeatReboiler   to REBOILER.InletQ;
2096ConnectorHeatCondenser  to CONDENSER.InletQ;
2097
2098CONDENSER.OutletVapour          to ConnectorCondenserVout;
2099SPLITTER.Outlet1                to ConnectorSplitterOut;
2100REBOILER.OutletLiquid           to ConnectorReboilerLout;
2101
2102EQUATIONS
2103        HeatToReboiler  = ConnectorHeatReboiler;
2104        HeatToCondenser = ConnectorHeatCondenser;
2105       
2106# Condenser Connector Equations
2107        ConnectorCondenserVout.T = VapourDistillate.T;
2108        ConnectorCondenserVout.P = VapourDistillate.P;
2109        ConnectorCondenserVout.F = VapourDistillate.F;
2110        ConnectorCondenserVout.z = VapourDistillate.z;
2111
2112# Splitter Connector Equations
2113        ConnectorSplitterOut.T = LiquidDistillate.T;
2114        ConnectorSplitterOut.P = LiquidDistillate.P;
2115        ConnectorSplitterOut.F = LiquidDistillate.F;
2116        ConnectorSplitterOut.z = LiquidDistillate.z;
2117
2118# Reboiler Connector Equations
2119        ConnectorReboilerLout.T = BottomProduct.T;
2120        ConnectorReboilerLout.P = BottomProduct.P;
2121        ConnectorReboilerLout.F = BottomProduct.F;
2122        ConnectorReboilerLout.z = BottomProduct.z;
2123
2124end
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.