source: trunk/eml/stage_separators/column.mso @ 990

Last change on this file since 990 was 910, checked in by Argimiro Resende Secchi, 13 years ago

Checking new EML.

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