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

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

improved section column model (1,2,3 inputs)

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