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

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

updates

File size: 119.1 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
823SET
824        NumberOfFeeds = 1;
825
826VARIABLES
827       
828        in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
829
830EQUATIONS
831#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
832# Equating Feed Tray Variables to Trays Variables
833#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
834for i in 1:NumberOfTrays do
835
836if   i equal FeedTrayLocation(1) then   
837
838"FeedTrayTop Inlet Flow"       
839        FeedTray.F= TRAYS(i).Inlet.F;
840
841"FeedTrayTop Inlet Temperature"
842        FeedTray.T = TRAYS(i).Inlet.T;
843
844"FeedTrayTop Inlet Pressure"
845        FeedTray.P = TRAYS(i).Inlet.P;
846
847"FeedTrayTop Inlet Composition"
848        FeedTray.z = TRAYS(i).Inlet.z;
849
850"FeedTrayTop Inlet Vapour Fraction"
851        FeedTray.v = TRAYS(i).Inlet.v;
852
853"FeedTrayTop Inlet Enthalpy"
854        FeedTray.h = TRAYS(i).Inlet.h;
855
856else
857
858"Inlet Tray - Flow Sealed"     
859        0*'mol/h'= TRAYS(i).Inlet.F;
860
861"Inlet Tray -  Temperature"
862        FeedTray.T = TRAYS(i).Inlet.T;
863
864"Inlet Tray -  Pressure"
865        FeedTray.P = TRAYS(i).Inlet.P;
866
867"Inlet Tray -  Composition"
868        FeedTray.z = TRAYS(i).Inlet.z;
869
870"Inlet Tray -  Vapour Fraction"
871        FeedTray.v = TRAYS(i).Inlet.v;
872
873"Inlet Tray -  Enthalpy"
874        FeedTray.h = TRAYS(i).Inlet.h;
875
876end
877
878end
879
880end
881
882Model Section_Column2   as SectionColumnBasic
883
884ATTRIBUTES
885        Pallete         = true;
886        Icon            = "icon/SectionColumn";
887        Brief   = "Model of a column section.";
888        Info            =
889"== Model of a column section containing ==
890* NumberOfTrays TRAYS.
891* Two Feed Inlets.
892       
893== Specify ==
894* the feed stream of each tray (Inlet);
895* the Murphree eficiency for each tray Emv;
896* the InletLiquid stream of the top tray;
897* the InletVapour stream of the bottom tray.
898       
899== Initial Conditions ==
900* the TRAYS temperature (OutletLiquid.T);
901* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
902* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
903";
904
905SET
906        NumberOfFeeds = 2;
907
908VARIABLES
909       
910        in      FeedTrayOne     as stream               (Brief="Feed stream", PosX=0, PosY=0.45);
911        in      FeedTrayTwo     as stream               (Brief="Feed stream", PosX=0, PosY=0.65);
912
913EQUATIONS
914
915for i in 1:NumberOfTrays do
916
917if   i equal FeedTrayLocation(1) then   
918
919"FeedTrayTop Inlet Flow"       
920        FeedTrayOne.F= TRAYS(i).Inlet.F;
921
922"FeedTrayTop Inlet Temperature"
923        FeedTrayOne.T = TRAYS(i).Inlet.T;
924
925"FeedTrayTop Inlet Pressure"
926        FeedTrayOne.P = TRAYS(i).Inlet.P;
927
928"FeedTrayTop Inlet Composition"
929        FeedTrayOne.z = TRAYS(i).Inlet.z;
930
931"FeedTrayTop Inlet Vapour Fraction"
932        FeedTrayOne.v = TRAYS(i).Inlet.v;
933
934"FeedTrayTop Inlet Enthalpy"
935        FeedTrayOne.h = TRAYS(i).Inlet.h;
936
937else if   i equal FeedTrayLocation(2) then   
938
939"FeedTrayBottom Inlet Flow"     
940        FeedTrayTwo.F= TRAYS(i).Inlet.F;
941
942"FeedTrayBottom Inlet Temperature"
943        FeedTrayTwo.T = TRAYS(i).Inlet.T;
944
945"FeedTrayBottom Inlet Pressure"
946        FeedTrayTwo.P = TRAYS(i).Inlet.P;
947
948"FeedTrayBottom Inlet Composition"
949        FeedTrayTwo.z = TRAYS(i).Inlet.z;
950
951"FeedTrayBottom Inlet Vapour Fraction"
952        FeedTrayTwo.v = TRAYS(i).Inlet.v;
953
954"FeedTrayBottom Inlet Enthalpy"
955        FeedTrayTwo.h = TRAYS(i).Inlet.h;
956
957else
958
959"Inlet Tray - Flow Sealed"     
960        0*'mol/h'= TRAYS(i).Inlet.F;
961
962"Inlet Tray -  Temperature"
963        FeedTrayTwo.T = TRAYS(i).Inlet.T;
964
965"Inlet Tray -  Pressure"
966        FeedTrayTwo.P = TRAYS(i).Inlet.P;
967
968"Inlet Tray -  Composition"
969        FeedTrayTwo.z = TRAYS(i).Inlet.z;
970
971"Inlet Tray -  Vapour Fraction"
972        FeedTrayTwo.v = TRAYS(i).Inlet.v;
973
974"Inlet Tray -  Enthalpy"
975        FeedTrayTwo.h = TRAYS(i).Inlet.h;
976
977end
978
979end
980
981end
982
983end
984
985Model Section_Column3   as SectionColumnBasic
986
987ATTRIBUTES
988        Pallete         = true;
989        Icon            = "icon/SectionColumn";
990        Brief   = "Model of a column section.";
991        Info            =
992"== Model of a column section containing ==
993* NumberOfTrays TRAYS.
994* Three Feed Inlets.
995       
996== Specify ==
997* the feed stream of each tray (Inlet);
998* the Murphree eficiency for each tray Emv;
999* the InletLiquid stream of the top tray;
1000* the InletVapour stream of the bottom tray.
1001       
1002== Initial Conditions ==
1003* the TRAYS temperature (OutletLiquid.T);
1004* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1005* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
1006";
1007
1008SET
1009        NumberOfFeeds = 3;
1010
1011VARIABLES
1012       
1013        in      FeedTrayOne     as stream               (Brief="Feed stream", PosX=0, PosY=0.45);
1014        in      FeedTrayTwo     as stream               (Brief="Feed stream", PosX=0, PosY=0.65);
1015        in      FeedTrayThree   as stream               (Brief="Feed stream", PosX=0, PosY=0.85);
1016
1017EQUATIONS
1018
1019for i in 1:NumberOfTrays do
1020
1021if   i equal FeedTrayLocation(1) then   
1022
1023"FeedTrayTop Inlet Flow"       
1024        FeedTrayOne.F= TRAYS(i).Inlet.F;
1025
1026"FeedTrayTop Inlet Temperature"
1027        FeedTrayOne.T = TRAYS(i).Inlet.T;
1028
1029"FeedTrayTop Inlet Pressure"
1030        FeedTrayOne.P = TRAYS(i).Inlet.P;
1031
1032"FeedTrayTop Inlet Composition"
1033        FeedTrayOne.z = TRAYS(i).Inlet.z;
1034
1035"FeedTrayTop Inlet Vapour Fraction"
1036        FeedTrayOne.v = TRAYS(i).Inlet.v;
1037
1038"FeedTrayTop Inlet Enthalpy"
1039        FeedTrayOne.h = TRAYS(i).Inlet.h;
1040
1041else if   i equal FeedTrayLocation(2) then   
1042
1043"FeedTrayBottom Inlet Flow"     
1044        FeedTrayTwo.F= TRAYS(i).Inlet.F;
1045
1046"FeedTrayBottom Inlet Temperature"
1047        FeedTrayTwo.T = TRAYS(i).Inlet.T;
1048
1049"FeedTrayBottom Inlet Pressure"
1050        FeedTrayTwo.P = TRAYS(i).Inlet.P;
1051
1052"FeedTrayBottom Inlet Composition"
1053        FeedTrayTwo.z = TRAYS(i).Inlet.z;
1054
1055"FeedTrayBottom Inlet Vapour Fraction"
1056        FeedTrayTwo.v = TRAYS(i).Inlet.v;
1057
1058"FeedTrayBottom Inlet Enthalpy"
1059        FeedTrayTwo.h = TRAYS(i).Inlet.h;
1060
1061else if   i equal FeedTrayLocation(3) then   
1062
1063"FeedTrayBottom Inlet Flow"     
1064        FeedTrayThree.F= TRAYS(i).Inlet.F;
1065
1066"FeedTrayBottom Inlet Temperature"
1067        FeedTrayThree.T = TRAYS(i).Inlet.T;
1068
1069"FeedTrayBottom Inlet Pressure"
1070        FeedTrayThree.P = TRAYS(i).Inlet.P;
1071
1072"FeedTrayBottom Inlet Composition"
1073        FeedTrayThree.z = TRAYS(i).Inlet.z;
1074
1075"FeedTrayBottom Inlet Vapour Fraction"
1076        FeedTrayThree.v = TRAYS(i).Inlet.v;
1077
1078"FeedTrayBottom Inlet Enthalpy"
1079        FeedTrayThree.h = TRAYS(i).Inlet.h;
1080
1081else
1082
1083"Inlet Tray - Flow Sealed"     
1084        0*'mol/h'= TRAYS(i).Inlet.F;
1085
1086"Inlet Tray -  Temperature"
1087        FeedTrayTwo.T = TRAYS(i).Inlet.T;
1088
1089"Inlet Tray -  Pressure"
1090        FeedTrayTwo.P = TRAYS(i).Inlet.P;
1091
1092"Inlet Tray -  Composition"
1093        FeedTrayTwo.z = TRAYS(i).Inlet.z;
1094
1095"Inlet Tray -  Vapour Fraction"
1096        FeedTrayTwo.v = TRAYS(i).Inlet.v;
1097
1098"Inlet Tray -  Enthalpy"
1099        FeedTrayTwo.h = TRAYS(i).Inlet.h;
1100
1101end
1102
1103end
1104
1105end
1106
1107end
1108
1109end
1110
1111
1112Model Distillation_kettle_cond  as Section_ColumnBasicX
1113
1114ATTRIBUTES
1115        Pallete         = true;
1116        Icon            = "icon/DistillationKettleCond";
1117        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
1118        Info            =
1119"== Specify ==
1120* the feed stream of each tray (Inlet);
1121* the Murphree eficiency for each tray Emv;
1122* the pump pressure difference;
1123* the heat supllied in reboiler and condenser;
1124* the condenser vapor outlet flow (OutletVapour.F);
1125* the reboiler liquid outlet flow (OutletLiquid.F);
1126* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1127       
1128== Initial Conditions ==
1129* the TRAYS temperature (OutletLiquid.T);
1130* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1131* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1132       
1133* the condenser temperature (OutletLiquid.T);
1134* the condenser liquid level (Level);
1135* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1136       
1137* the reboiler temperature (OutletLiquid.T);
1138* the reboiler liquid level (Level);
1139* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1140";
1141       
1142PARAMETERS
1143        CondenserVapourFlow             as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
1144
1145VARIABLES
1146        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.375,Protected = true);
1147        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.42,Protected = true);
1148#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1149# Column Devices
1150#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1151        CONDENSER               as condenser;
1152        REBOILER                as reboiler;
1153        SPLITTER                as splitter2;
1154        PUMP                    as pump;
1155        alfaTopo                as Real;
1156#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1157# Heat Ports
1158#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1159        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler",Protected = true, PosX=1, PosY=0.90);
1160        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", Protected = true, PosX=1, PosY=0.034);
1161#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1162# Column Connectors
1163#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1164                ConnectorHeatReboiler   as power        (Brief="Heat supplied to Reboiler", Hidden=true);
1165                ConnectorHeatCondenser  as power        (Brief="Heat supplied to Condenser", Hidden=true);
1166        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Condenser", Hidden=true);
1167        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1168        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1169#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1170# Column products
1171#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1172        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Condenser", PosX=0.66, PosY=0);
1173        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
1174        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
1175
1176EQUATIONS
1177
1178switch CondenserVapourFlow
1179
1180        case "on":
1181                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo *Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
1182                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1183                when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
1184
1185        case "off":
1186                CONDENSER.InletVapour.F = 0 * 'mol/s';
1187                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
1188
1189end     
1190
1191# Condenser Connector Equations
1192        ConnectorCondenserVout.T = VapourDistillate.T;
1193        ConnectorCondenserVout.P = VapourDistillate.P;
1194        ConnectorCondenserVout.F = VapourDistillate.F;
1195        ConnectorCondenserVout.z = VapourDistillate.z;
1196
1197# Splitter Connector Equations
1198        ConnectorSplitterOut.T = LiquidDistillate.T;
1199        ConnectorSplitterOut.P = LiquidDistillate.P;
1200        ConnectorSplitterOut.F = LiquidDistillate.F;
1201        ConnectorSplitterOut.z = LiquidDistillate.z;
1202
1203# Reboiler Connector Equations
1204        ConnectorReboilerLout.T = BottomProduct.T;
1205        ConnectorReboilerLout.P = BottomProduct.P;
1206        ConnectorReboilerLout.F = BottomProduct.F;
1207        ConnectorReboilerLout.z = BottomProduct.z;
1208
1209        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1210        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1211        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1212        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1213
1214        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1215        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1216        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1217        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1218
1219        VapourDrawOffFlow = VapourDrawOff.F;
1220        LiquidDrawOffFlow = LiquidDrawOff.F;
1221
1222        HeatToReboiler  = ConnectorHeatReboiler;
1223        HeatToCondenser = ConnectorHeatCondenser;
1224
1225CONNECTIONS
1226#vapor
1227        REBOILER.OutletVapour   to      TRAYS(NumberOfTrays).InletVapour;
1228        TRAYS(1).OutletVapour   to      CONDENSER.InletVapour;
1229
1230#liquid
1231        CONDENSER.OutletLiquid                          to      SPLITTER.Inlet;
1232        SPLITTER.Outlet2                        to      PUMP.Inlet;
1233        PUMP.Outlet                                     to      TRAYS(1).InletLiquid;
1234        TRAYS(NumberOfTrays).OutletLiquid       to      REBOILER.InletLiquid;
1235
1236#Connectors
1237        CONDENSER.OutletVapour  to ConnectorCondenserVout;
1238        SPLITTER.Outlet1 to ConnectorSplitterOut;
1239        REBOILER.OutletLiquid   to ConnectorReboilerLout;
1240
1241        ConnectorHeatReboiler   to REBOILER.InletQ;
1242        ConnectorHeatCondenser  to CONDENSER.InletQ;
1243
1244end
1245
1246Model Distillation_thermosyphon_subcooling      as Section_ColumnBasicX
1247        ATTRIBUTES
1248        Pallete         = true;
1249        Icon            = "icon/DistillationThermosyphonSubcooling";
1250        Brief           = "Model of a distillation column with steady condenser and steady reboiler.";
1251        Info            =
1252"== Specify ==
1253* the feed stream of each tray (Inlet);
1254* the Murphree eficiency for each tray Emv;
1255* the pump head;
1256* the condenser pressure drop;
1257* the heat supllied in top and bottom tanks;
1258* the heat supllied in condenser and reboiler;
1259* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
1260* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1261       
1262== Initial Conditions ==
1263* the TRAYS temperature (OutletLiquid.T);
1264* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1265* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1266       
1267* the top tank temperature (OutletLiquid.T);
1268* the top tank liquid level (Level);
1269* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1270       
1271* the bottom tank temperature (OutletLiquid.T);
1272* the bottom tank liquid level (Level);
1273* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1274";
1275
1276PARAMETERS
1277
1278        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Hidden=true, Default = "on");
1279
1280VARIABLES
1281#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1282# Column Vapour and Liquid Draw Sides
1283#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1284        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.41,Protected = true);
1285        out     LiquidDrawOff   as liquid_stream                (Brief="Liquid Outlet in the section", PosX=1, PosY=0.45,Protected = true);
1286#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1287# Column Devices
1288#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1289        CONDENSER                       as condenserSteady      (Brief="steady state condenser with subcooling");
1290        ACCUMULATOR_TOP         as tank_cylindrical     (Brief="vessel drum (layed cilinder)");
1291        SPLITTER_TOP            as splitter2                    (Brief="splitter which separate reflux and distillate");
1292        PUMP                            as pump                         (Brief="pump in reflux stream");
1293        REBOILER                        as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
1294        ACCUMULATOR_BOTTOM      as tank                         (Brief="vessel in the bottom of column");
1295        SPLITTER_BOTTOM         as splitter2                    (Brief="splitter who separate the bottom product and the stream to reboiler");
1296        alfaTopo                        as Real;
1297#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1298# Heat Ports
1299#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1300in              HeatToCondenser                 as power        (Brief="Heat supplied to Condenser",PosX=1, PosY=0.099, Protected=true);
1301in              HeatToReboiler                  as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.92,Protected=true);
1302in              HeatToBottomAccumulator as power        (Brief="Heat supplied to Bottom Accumulator",PosX=0, PosY=0.925,Protected=true);
1303in              HeatToTopAccumulator    as power        (Brief="Heat supplied to Top Accumulator", PosX=1, PosY=0.19,Protected=true);
1304#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1305# Column Control Ports
1306#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1307        out     TRI as control_signal   (Brief="Temperature Indicator of Reboiler ", PosX=1, PosY=0.88);
1308        out     LTAI as control_signal  (Brief="Level Indicator of Top Accumulator ", PosX=1, PosY=0.15);
1309        out     TCI as control_signal   (Brief="Temperature Indicator of Condenser ", PosX=1, PosY=0.059);
1310        out     LBAI as control_signal  (Brief="Level Indicator of Bottom Accumulator", PosX=1, PosY=0.77);
1311#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1312# Column Top and Bottom product
1313#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1314out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.24);
1315out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=0.18, PosY=1);
1316#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1317# Column Model Connectors
1318#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1319in      ConnectorSplitterBottom         as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1320in      ConnectorSplitterTop            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1321
1322        ConnectorHeatReboiler                   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1323        ConnectorHeatCondenser                  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1324        ConnectorHeatTopAccumulator     as power        (Brief="Connector for Heat supplied to Top Accumulator", Hidden=true);
1325        ConnectorHeatBottomAccumulator  as power        (Brief="Connector for Heat supplied to Bottom Accumulator", Hidden=true);
1326       
1327EQUATIONS
1328
1329"Reboiler Temperature indicator"
1330        TRI * 'K' = REBOILER.OutletVapour.T;
1331
1332"Condenser Temperature indicator"
1333        TCI * 'K' = CONDENSER.OutletLiquid.T;
1334
1335"Top Accumulator Level indicator"
1336        LTAI*ACCUMULATOR_TOP.Vtotal = ACCUMULATOR_TOP.Vfilled;
1337
1338"Bottom Accumulator Level indicator"
1339        LBAI*ACCUMULATOR_BOTTOM.Vtotal = ACCUMULATOR_BOTTOM.Vfilled;
1340       
1341# Heat Connector Equations
1342        HeatToCondenser                 =       ConnectorHeatCondenser;
1343        HeatToReboiler                  =       ConnectorHeatReboiler;
1344        HeatToBottomAccumulator =       ConnectorHeatBottomAccumulator;
1345        HeatToTopAccumulator    =       ConnectorHeatTopAccumulator;
1346
1347# Top Splitter Connector Equations
1348        ConnectorSplitterTop.T = LiquidDistillate.T;
1349        ConnectorSplitterTop.P = LiquidDistillate.P;
1350        ConnectorSplitterTop.F = LiquidDistillate.F;
1351        ConnectorSplitterTop.z = LiquidDistillate.z;
1352
1353# Bottom Splitter Connector Equations
1354        ConnectorSplitterBottom.T = BottomProduct.T;
1355        ConnectorSplitterBottom.P = BottomProduct.P;
1356        ConnectorSplitterBottom.F = BottomProduct.F;
1357        ConnectorSplitterBottom.z = BottomProduct.z;
1358
1359        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1360        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1361        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1362        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1363
1364        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1365        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1366        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1367        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1368
1369        VapourDrawOffFlow = VapourDrawOff.F;
1370        LiquidDrawOffFlow = LiquidDrawOff.F;
1371
1372switch CondenserVapourFlow
1373
1374        case "on":
1375                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
1376                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1377                when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
1378
1379        case "off":
1380                CONDENSER.InletVapour.F = 0 * 'mol/s';
1381                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
1382
1383end     
1384
1385CONNECTIONS
1386#vapor
1387        REBOILER.OutletVapour   to TRAYS(NumberOfTrays).InletVapour;
1388        TRAYS(1).OutletVapour   to CONDENSER.InletVapour;
1389
1390#liquid
1391        CONDENSER.OutletLiquid                          to ACCUMULATOR_TOP.Inlet;       
1392        ACCUMULATOR_TOP.Outlet                  to SPLITTER_TOP.Inlet;
1393        SPLITTER_TOP.Outlet2                    to PUMP.Inlet; 
1394        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
1395        TRAYS(NumberOfTrays).OutletLiquid       to ACCUMULATOR_BOTTOM.Inlet;
1396        ACCUMULATOR_BOTTOM.Outlet               to SPLITTER_BOTTOM.Inlet;
1397        SPLITTER_BOTTOM.Outlet2                 to REBOILER.InletLiquid;
1398
1399#Connectors
1400        ConnectorHeatCondenser                  to CONDENSER.InletQ;
1401        ConnectorHeatReboiler                   to REBOILER.InletQ;
1402        ConnectorHeatBottomAccumulator  to ACCUMULATOR_BOTTOM.InletQ;
1403        ConnectorHeatTopAccumulator             to ACCUMULATOR_TOP.InletQ;
1404        SPLITTER_TOP.Outlet1                    to ConnectorSplitterTop;
1405        SPLITTER_BOTTOM.Outlet1                 to ConnectorSplitterBottom;
1406
1407end
1408
1409Model Distillation_thermosyphon_cond as Section_ColumnBasicX
1410        ATTRIBUTES
1411        Pallete         = true;
1412        Icon            = "icon/DistillationThermosyphonCond";
1413        Brief           = "Model of a distillation column with dynamic condenser and steady reboiler.";
1414        Info            =
1415"== Specify ==
1416* the feed stream of each tray (Inlet);
1417* the Murphree eficiency for each tray Emv;
1418* the pump head;
1419* the condenser vapor outlet flow (OutletVapour.F);
1420* the heat supllied in bottom tank;
1421* the heat supllied in condenser and reboiler;
1422* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
1423       
1424== Initial Conditions ==
1425* the TRAYS temperature (OutletLiquid.T);
1426* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1427* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1428       
1429* the condenser temperature (OutletLiquid.T);
1430* the condenser liquid level (Level);
1431* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1432       
1433* the bottom tank temperature (OutletLiquid.T);
1434* the bottom tank liquid level (Level);
1435* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1436";
1437
1438PARAMETERS
1439        CondenserVapourFlow     as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
1440
1441VARIABLES
1442#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1443# Column Vapour and Liquid Draw Sides
1444#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1445        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.379,Protected = true);
1446        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.425,Protected = true);
1447#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1448# Column Devices
1449#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1450        CONDENSER                       as condenser            (Brief="dynamic condenser without subcooling");
1451        SPLITTER_TOP            as splitter2                    (Brief="splitter which separate reflux and distillate");
1452        PUMP                            as pump                         (Brief="pump in reflux stream");
1453        ACCUMULATOR_BOTTOM      as tank                         (Brief="vessel in the bottom of column");
1454        SPLITTER_BOTTOM         as splitter2                    (Brief="splitter who separate the bottom product and the stream to reboiler");
1455        REBOILER                        as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
1456        alfaTopo                        as Real;
1457#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1458# Heat Ports
1459#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1460in      HeatToCondenser                 as power        (Brief="Heat supplied to Condenser",PosX=1, PosY=0.035, Protected=true);
1461in      HeatToReboiler                  as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.865,Protected=true);
1462in      HeatToBottomAccumulator as power        (Brief="Heat supplied to Bottom Accumulator",PosX=0, PosY=0.92,Protected=true);
1463#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1464# Column Top and Bottom product
1465#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1466out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.665, PosY=0);
1467out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
1468out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=0.18, PosY=1);
1469#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1470# Column Model Connectors
1471#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1472in      ConnectorSplitterBottom as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1473in      ConnectorSplitterTop    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1474in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
1475
1476        ConnectorHeatReboiler                   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1477        ConnectorHeatCondenser                  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1478        ConnectorHeatBottomAccumulator  as power        (Brief="Connector for Heat supplied to Bottom Accumulator", Hidden=true);
1479
1480EQUATIONS
1481# Heat Connector Equations
1482        HeatToCondenser                 =       ConnectorHeatCondenser;
1483        HeatToReboiler                  =       ConnectorHeatReboiler;
1484        HeatToBottomAccumulator =       ConnectorHeatBottomAccumulator;
1485
1486# Condenser Connector Equations
1487        ConnectorCondenserVout.T = VapourDistillate.T;
1488        ConnectorCondenserVout.P = VapourDistillate.P;
1489        ConnectorCondenserVout.F = VapourDistillate.F;
1490        ConnectorCondenserVout.z = VapourDistillate.z;
1491
1492# Top Splitter Connector Equations
1493        ConnectorSplitterTop.T = LiquidDistillate.T;
1494        ConnectorSplitterTop.P = LiquidDistillate.P;
1495        ConnectorSplitterTop.F = LiquidDistillate.F;
1496        ConnectorSplitterTop.z = LiquidDistillate.z;
1497
1498# Bottom Splitter Connector Equations
1499        ConnectorSplitterBottom.T = BottomProduct.T;
1500        ConnectorSplitterBottom.P = BottomProduct.P;
1501        ConnectorSplitterBottom.F = BottomProduct.F;
1502        ConnectorSplitterBottom.z = BottomProduct.z;
1503
1504        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1505        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1506        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1507        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1508
1509        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1510        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1511        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1512        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1513
1514        VapourDrawOffFlow = VapourDrawOff.F;
1515        LiquidDrawOffFlow = LiquidDrawOff.F;
1516       
1517switch CondenserVapourFlow
1518                case "on":
1519                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
1520                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1521                when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
1522               
1523                case "off":
1524                CONDENSER.InletVapour.F = 0 * 'mol/s';
1525                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
1526end     
1527
1528CONNECTIONS
1529#vapor
1530        REBOILER.OutletVapour   to TRAYS(NumberOfTrays).InletVapour;
1531        TRAYS(1).OutletVapour                           to CONDENSER.InletVapour;
1532
1533#liquid
1534        CONDENSER.OutletLiquid          to SPLITTER_TOP.Inlet; 
1535        SPLITTER_TOP.Outlet2                            to PUMP.Inlet;
1536        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
1537        TRAYS(NumberOfTrays).OutletLiquid       to ACCUMULATOR_BOTTOM.Inlet;
1538        ACCUMULATOR_BOTTOM.Outlet                               to SPLITTER_BOTTOM.Inlet;
1539        SPLITTER_BOTTOM.Outlet2                         to REBOILER.InletLiquid;
1540
1541#Connectors
1542ConnectorHeatCondenser                  to CONDENSER.InletQ;
1543ConnectorHeatReboiler                   to REBOILER.InletQ;
1544ConnectorHeatBottomAccumulator  to ACCUMULATOR_BOTTOM.InletQ;
1545CONDENSER.OutletVapour                          to ConnectorCondenserVout;
1546SPLITTER_TOP.Outlet1                    to ConnectorSplitterTop;
1547SPLITTER_BOTTOM.Outlet1                 to ConnectorSplitterBottom;
1548
1549end
1550
1551Model Distillation_kettle_subcooling as Section_ColumnBasicX
1552
1553ATTRIBUTES
1554        Pallete         = true;
1555        Icon            = "icon/DistillationKettleSubcooling";
1556        Brief   = "Model of a distillation column with steady condenser and dynamic reboiler.";
1557        Info            =
1558"== Specify ==
1559* the feed stream of each tray (Inlet);
1560* the Murphree eficiency for each tray (Emv);
1561* the pump pressure difference;
1562* the heat supllied in reboiler and condenser;
1563* the heat supllied in the top tank;
1564* the condenser pressure drop;
1565* the reboiler liquid outlet flow (OutletLiquid.F);
1566* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1567       
1568== Initial Conditions ==
1569* the TRAYS temperature (OutletLiquid.T);
1570* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1571* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1572       
1573* the top tank temperature (OutletLiquid.T);
1574* the top tank liquid level (Level);
1575* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1576       
1577* the reboiler temperature (OutletLiquid.T);
1578* the reboiler liquid level (Level);
1579* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1580";
1581       
1582PARAMETERS
1583        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Default = "on",Hidden=true);
1584
1585VARIABLES
1586#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1587# Column Vapour and Liquid Draw Sides
1588#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1589        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.41,Protected = true);
1590        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.45,Protected = true);
1591#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1592# Column Devices
1593#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1594        CONDENSER               as condenserSteady      (Brief="steady state condenser with subcooling");
1595        ACCUMULATOR             as tank_cylindrical     (Brief="vessel drum (layed cilinder)");
1596        SPLITTER                as splitter2                    (Brief="splitter which separate reflux and distillate");
1597        PUMP                    as pump                         (Brief="pump in reflux stream");
1598        REBOILER                as reboiler                     (Brief="kettle reboiler");
1599        alfaTopo                as Real;
1600#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1601# Heat Ports
1602#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1603in              HeatToCondenser         as power        (Brief="Heat supplied to Condenser", PosX=1, PosY=0.065, Protected=true);
1604in              HeatToReboiler          as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.905, Protected=true);
1605in              HeatToAccumulator       as power        (Brief="Heat supplied to Top Vessel", PosX=1, PosY=0.195, Protected=true);
1606#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1607# Column Model Connectors
1608#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1609in      ConnectorSplitterOut            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1610in      ConnectorReboilerLout           as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1611        ConnectorHeatReboiler           as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1612        ConnectorHeatCondenser          as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1613        ConnectorHeatAccumulator        as power        (Brief="Connector for Heat supplied to TopVessel", Hidden=true);
1614#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1615# Column Top and Bottom product
1616#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1617out     LiquidDistillate as liquid_stream       (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.24);
1618out     BottomProduct    as liquid_stream       (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
1619
1620EQUATIONS
1621
1622#Heat Connectors
1623HeatToCondenser         = ConnectorHeatCondenser;
1624HeatToReboiler          = ConnectorHeatReboiler;
1625HeatToAccumulator       = ConnectorHeatAccumulator;
1626
1627# Splitter Connector Equations
1628        ConnectorSplitterOut.T = LiquidDistillate.T;
1629        ConnectorSplitterOut.P = LiquidDistillate.P;
1630        ConnectorSplitterOut.F = LiquidDistillate.F;
1631        ConnectorSplitterOut.z = LiquidDistillate.z;
1632
1633# Reboiler Connector Equations
1634        ConnectorReboilerLout.T = BottomProduct.T;
1635        ConnectorReboilerLout.P = BottomProduct.P;
1636        ConnectorReboilerLout.F = BottomProduct.F;
1637        ConnectorReboilerLout.z = BottomProduct.z;
1638       
1639        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1640        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1641        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1642        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1643
1644        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1645        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1646        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1647        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1648
1649        VapourDrawOffFlow = VapourDrawOff.F;
1650        LiquidDrawOffFlow = LiquidDrawOff.F;
1651       
1652        switch CondenserVapourFlow
1653                case "on":
1654                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
1655                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1656                when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
1657               
1658                case "off":
1659                CONDENSER.InletVapour.F = 0 * 'mol/s';
1660                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
1661end     
1662
1663CONNECTIONS
1664#vapor
1665        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
1666        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
1667
1668#liquid
1669        CONDENSER.OutletLiquid                          to ACCUMULATOR.Inlet;   
1670        ACCUMULATOR.Outlet                                      to SPLITTER.Inlet;
1671        SPLITTER.Outlet2                        to PUMP.Inlet; 
1672        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
1673        TRAYS(NumberOfTrays).OutletLiquid       to REBOILER.InletLiquid;
1674
1675#Connectors
1676ConnectorHeatCondenser          to CONDENSER.InletQ;
1677ConnectorHeatReboiler           to REBOILER.InletQ;
1678ConnectorHeatAccumulator        to ACCUMULATOR.InletQ;
1679
1680SPLITTER.Outlet1 to ConnectorSplitterOut;
1681REBOILER.OutletLiquid   to ConnectorReboilerLout;
1682
1683end
1684
1685Model Rectifier as Section_ColumnBasicX
1686
1687ATTRIBUTES
1688        Pallete         = true;
1689        Icon            = "icon/RefluxedCond";
1690        Brief           = "Model of a rectifier column with dynamic condenser.";
1691        Info            =
1692"== Specify ==
1693* the feed stream of each tray (Inlet);
1694* the Murphree eficiency for each tray Emv;
1695* the InletVapour stream of the bottom tray unless its flow;
1696* the pump pressure difference;
1697* the heat supllied in the condenser;
1698* the condenser vapor outlet flow (OutletVapour.F);
1699* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1700       
1701== Initial Conditions ==
1702* the TRAYS temperature (OutletLiquid.T);
1703* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1704* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1705       
1706* the condenser temperature (OutletLiquid.T);
1707* the condenser liquid level (Level);
1708* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1709";
1710
1711PARAMETERS
1712        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Default = "on",Hidden=true);
1713
1714VARIABLES
1715#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1716# Column Vapour and Liquid Draw Sides
1717#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1718        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.45,Protected = true);
1719        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.50,Protected = true);
1720#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1721# Column Devices
1722#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1723        CONDENSER       as condenser    (Brief="dymamic condenser without subcooling");
1724        SPLITTER        as splitter2            (Brief="splitter which separate reflux and distillate");
1725        PUMP            as pump                 (Brief="pump in reflux stream");
1726        alfaTopo        as Real;
1727#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1728# Column Top product
1729#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1730        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.66, PosY=0);
1731        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.24);
1732#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1733# Heat Port
1734#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1735        in      HeatToCondenser         as power (Brief="Heat supplied to Condenser",PosX=1, PosY=0.04, Protected = true);
1736#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1737# Column Bottom Outlets
1738#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1739        in      VapourInlet             as stream                       (Brief="Vapour Inlet in the section", PosX=0.07, PosY=1);
1740        out     LiquidOutlet    as liquid_stream        (Brief="Liquid Outlet in the section", PosX=0.32, PosY=1);
1741#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1742# Column Model Connectors
1743#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1744        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1745        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
1746                VapourConnector                 as stream       (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
1747                ConnectorHeatCondenser  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1748       
1749EQUATIONS
1750
1751switch CondenserVapourFlow
1752
1753        case "on":
1754                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
1755                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1756                when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
1757               
1758        case "off":
1759                CONDENSER.InletVapour.F = 0 * 'mol/s';
1760                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
1761
1762end     
1763
1764HeatToCondenser = ConnectorHeatCondenser;
1765
1766# Condenser Connector Equations
1767        ConnectorCondenserVout.T = VapourDistillate.T;
1768        ConnectorCondenserVout.P = VapourDistillate.P;
1769        ConnectorCondenserVout.F = VapourDistillate.F;
1770        ConnectorCondenserVout.z = VapourDistillate.z;
1771       
1772# Splitter Connector Equations
1773        ConnectorSplitterOut.T = LiquidDistillate.T;
1774        ConnectorSplitterOut.P = LiquidDistillate.P;
1775        ConnectorSplitterOut.F = LiquidDistillate.F;
1776        ConnectorSplitterOut.z = LiquidDistillate.z;
1777       
1778        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletLiquid.F;
1779        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
1780        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
1781        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
1782
1783        VapourConnector.F= VapourInlet.F;
1784        VapourConnector.T = VapourInlet.T;
1785        VapourConnector.P = VapourInlet.P;
1786        VapourConnector.z = VapourInlet.z;
1787        VapourConnector.v = VapourInlet.v;
1788        VapourConnector.h = VapourInlet.h;
1789
1790        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1791        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1792        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1793        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1794
1795        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1796        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1797        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1798        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1799
1800        VapourDrawOffFlow = VapourDrawOff.F;
1801        LiquidDrawOffFlow = LiquidDrawOff.F;
1802
1803CONNECTIONS
1804#vapor
1805        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
1806
1807#liquid
1808        CONDENSER.OutletLiquid  to SPLITTER.Inlet;     
1809        SPLITTER.Outlet2        to PUMP.Inlet; 
1810        PUMP.Outlet             to TRAYS(1).InletLiquid;
1811
1812#Connectors
1813ConnectorHeatCondenser  to CONDENSER.InletQ;
1814VapourConnector                 to TRAYS(NumberOfTrays).InletVapour;
1815SPLITTER.Outlet1                to ConnectorSplitterOut;
1816CONDENSER.OutletVapour          to ConnectorCondenserVout;
1817
1818end
1819
1820Model Rectifier_subcooling as Section_ColumnBasicX
1821
1822ATTRIBUTES
1823        Pallete         = true;
1824        Icon            = "icon/RefluxedSubcooling";
1825        Brief           = "Model of a rectifier column with steady condenser.";
1826        Info            =
1827"== Specify ==
1828* the feed stream of each tray (Inlet);
1829* the Murphree eficiency for each tray Emv;
1830* the InletVapour stream of the bottom tray unless its flow;
1831* the pump head;
1832* the condenser pressure drop;
1833* the heat supllied in  the top tank;
1834* the heat supllied in condenser;
1835* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1836       
1837== Initial Conditions ==
1838* the TRAYS temperature (OutletLiquid.T);
1839* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1840* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1841       
1842* the top tank temperature (OutletLiquid.T);
1843* the top tank liquid level (Level);
1844* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1845";
1846       
1847PARAMETERS
1848        CondenserVapourFlow             as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
1849
1850VARIABLES
1851#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1852# Column Vapour and Liquid Draw Sides
1853#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1854        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.485,Protected = true);
1855        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.535,Protected = true);
1856#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1857# Column Devices
1858#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1859        CONDENSER               as condenserSteady      (Brief="steady state condenser with subcooling");
1860        ACCUMULATOR             as tank_cylindrical     (Brief="vessel drum (layed cilinder)");
1861        SPLITTER                as splitter2                    (Brief="plitter which separate reflux and distillate");
1862        PUMP                    as pump                         (Brief="pump in reflux stream");
1863        alfaTopo                as Real;
1864#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1865# Column Bottom outlets
1866#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1867        in      VapourInlet             as stream                       (Brief="Vapour Inlet in the section", PosX=0.07, PosY=1);
1868        out     LiquidOutlet    as liquid_stream        (Brief="Liquid Outlet in the section", PosX=0.32, PosY=1);
1869#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1870# Heat Ports
1871#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1872        in      HeatToCondenser         as power        (Brief="Heat supplied to Condenser", PosX=1, PosY=0.070, Protected=true);
1873        in      HeatToAccumulator       as power        (Brief="Heat supplied to Top Accumulator", PosX=1, PosY=0.23, Protected=true);
1874#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1875# Column Top Product
1876#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1877        out     LiquidDistillate                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.285);
1878#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1879# Column Connectors
1880#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1881in      ConnectorSplitterTop            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1882        VapourConnector                         as stream       (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
1883        ConnectorHeatCondenser          as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1884        ConnectorHeatAccumulator        as power        (Brief="Connector for Heat supplied to Top Accumulator", Hidden=true);
1885
1886EQUATIONS
1887#Heat Connectors
1888        HeatToCondenser         = ConnectorHeatCondenser;
1889        HeatToAccumulator       = ConnectorHeatAccumulator;
1890       
1891        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletLiquid.F;
1892        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
1893        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
1894        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
1895
1896        VapourConnector.F= VapourInlet.F;
1897        VapourConnector.T = VapourInlet.T;
1898        VapourConnector.P = VapourInlet.P;
1899        VapourConnector.z = VapourInlet.z;
1900        VapourConnector.v = VapourInlet.v;
1901        VapourConnector.h = VapourInlet.h;
1902       
1903# Splitter Connector Equations
1904        ConnectorSplitterTop.T = LiquidDistillate.T;
1905        ConnectorSplitterTop.P = LiquidDistillate.P;
1906        ConnectorSplitterTop.F = LiquidDistillate.F;
1907        ConnectorSplitterTop.z = LiquidDistillate.z;
1908
1909        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1910        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1911        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1912        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1913
1914        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1915        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1916        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1917        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1918
1919        VapourDrawOffFlow = VapourDrawOff.F;
1920        LiquidDrawOffFlow = LiquidDrawOff.F;
1921       
1922switch CondenserVapourFlow
1923
1924        case "on":
1925                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo *Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
1926                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1927        when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
1928               
1929        case "off":
1930                CONDENSER.InletVapour.F = 0 * 'mol/s';
1931        when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
1932
1933end     
1934
1935CONNECTIONS
1936#vapor
1937        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
1938
1939#liquid
1940        CONDENSER.OutletLiquid          to ACCUMULATOR.Inlet;   
1941        ACCUMULATOR.Outlet                                      to SPLITTER.Inlet;
1942        SPLITTER.Outlet2                to PUMP.Inlet; 
1943        PUMP.Outlet                                             to TRAYS(1).InletLiquid;
1944
1945#Connectors
1946        VapourConnector                         to TRAYS(NumberOfTrays).InletVapour;
1947        ConnectorHeatCondenser                  to CONDENSER.InletQ;
1948        SPLITTER.Outlet1        to ConnectorSplitterTop;
1949        ConnectorHeatAccumulator                        to ACCUMULATOR.InletQ;
1950
1951end
1952
1953Model Reboiled_Stripping_kettle as Section_ColumnBasicX
1954       
1955ATTRIBUTES
1956        Pallete         = true;
1957        Icon            = "icon/ReboiledKettle";
1958        Brief           = "Model of a reboiled stripping column with dynamic reboiler.";
1959        Info            =
1960"== Specify ==
1961* the feed stream of each tray (Inlet);
1962* the Murphree eficiency for each tray Emv;
1963* the vapour flow leaving the top of the column;
1964* the InletLiquidiquid stream of the top tray;
1965* the heat supllied in the reboiler;
1966* the reboiler liquid outlet flow (OutletLiquid.F);
1967       
1968== Initial Conditions ==
1969* the TRAYS temperature (OutletLiquid.T);
1970* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1971* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1972       
1973* the reboiler temperature (OutletLiquid.T);
1974* the reboiler liquid level (Level);
1975* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1976";
1977
1978VARIABLES
1979#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1980# Column Vapour and Liquid Draw Sides
1981#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1982        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.28,Protected = true);
1983        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.33,Protected = true);
1984#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1985# Column Devices
1986#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
1987        REBOILER as reboiler (Brief="Kettle Reboiler");
1988#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1989# Heat Port
1990#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1991        in      HeatToReboiler  as power        (Brief="Heat supplied to Reboiler",PosX=1, PosY=0.865,Protected=true);
1992#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1993# Column Top Outlets
1994#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
1995        in      LiquidInlet             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.30, PosY=0);
1996        out     VapourOutlet    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.07, PosY=0);
1997#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1998# Column Bottom Product
1999#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2000        out     BottomProduct   as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.68, PosY=1);
2001#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2002# Column Connectors
2003#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2004        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
2005                LiquidConnector                 as stream       (Brief="Liquid connection at the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
2006                ConnectorHeatReboiler   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
2007
2008CONNECTIONS
2009#vapor
2010        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
2011       
2012#liquid
2013        TRAYS(NumberOfTrays).OutletLiquid to REBOILER.InletLiquid;
2014
2015#Connectors
2016REBOILER.OutletLiquid           to ConnectorReboilerLout;
2017LiquidConnector                 to TRAYS(1).InletLiquid;
2018ConnectorHeatReboiler   to REBOILER.InletQ;
2019
2020EQUATIONS
2021#Heat Connectors
2022        HeatToReboiler = ConnectorHeatReboiler;
2023       
2024        LiquidConnector.F= LiquidInlet.F;
2025        LiquidConnector.T = LiquidInlet.T;
2026        LiquidConnector.P = LiquidInlet.P;
2027        LiquidConnector.z = LiquidInlet.z;
2028        LiquidConnector.v = LiquidInlet.v;
2029        LiquidConnector.h = LiquidInlet.h;
2030       
2031        VapourOutlet.F= TRAYS(1).OutletVapour.F;
2032        VapourOutlet.T = TRAYS(1).OutletVapour.T;
2033        VapourOutlet.P = TRAYS(1).OutletVapour.P;
2034        VapourOutlet.z = TRAYS(1).OutletVapour.z;
2035       
2036# Reboiler Connector Equations
2037        ConnectorReboilerLout.T = BottomProduct.T;
2038        ConnectorReboilerLout.P = BottomProduct.P;
2039        ConnectorReboilerLout.F = BottomProduct.F;
2040        ConnectorReboilerLout.z = BottomProduct.z;
2041       
2042        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
2043        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
2044        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
2045        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
2046
2047        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
2048        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
2049        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
2050        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
2051
2052        VapourDrawOffFlow = VapourDrawOff.F;
2053        LiquidDrawOffFlow = LiquidDrawOff.F;
2054
2055end
2056
2057Model Reboiled_Stripping_thermosyphon as Section_ColumnBasicX
2058
2059ATTRIBUTES
2060        Pallete         = true;
2061        Icon            = "icon/ReboiledThermosyphon";
2062        Brief           = "Model of a reboiled stripping column with steady reboiler.";
2063        Info            =
2064"== Specify ==
2065* the feed stream of each tray (Inlet);
2066* the Murphree eficiency for each tray (Emv);
2067* the vapour flow leaving the top of the column;
2068* the InletLiquidiquid stream of the top tray;
2069* the heat supllied in bottom tank;
2070* the heat supllied in the reboiler;
2071* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
2072       
2073== Initial Conditions ==
2074* the TRAYS temperature (OutletLiquid.T);
2075* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
2076* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
2077
2078* the bottom tank temperature (OutletLiquid.T);
2079* the bottom tank liquid level (Level);
2080* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
2081";
2082
2083VARIABLES
2084#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2085# Column Vapour and Liquid Draw Sides
2086#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2087        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.28,Protected = true);
2088        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.33,Protected = true);
2089#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2090# Column Devices
2091#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2092        REBOILER                as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
2093        SPLITTER                as splitter2            (Brief="splitter which separate the bottom product and the stream to reboiler");
2094        ACCUMULATOR     as tank                         (Brief="vessel in the bottom of column");
2095#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2096# Heat Ports
2097#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2098        in      HeatToReboiler          as power        (Brief="Heat supplied to Reboiler",PosX=1, PosY=0.84,Protected=true);
2099        in      HeatToAccumulator       as power        (Brief="Heat supplied to Bottom Vessel",PosX=0, PosY=0.91,Protected=true);
2100#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2101# Column Top Outlets
2102#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2103        in      LiquidInlet             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.32, PosY=0);
2104        out     VapourOutlet    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.07, PosY=0);
2105#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2106# Column Bottom Product
2107#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2108        out     BottomProduct   as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.19, PosY=1);
2109        LiquidConnector         as stream                       (Brief="Liquid connection at the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
2110#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2111# Column Connectors
2112#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2113        in      ConnectorSplitterBottom         as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
2114        ConnectorHeatReboiler                   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
2115        ConnectorHeatAccumulator                as power        (Brief="Connector for Heat supplied to Bottom Accumulator", Hidden=true);
2116
2117CONNECTIONS
2118#vapor
2119        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
2120       
2121#liquid
2122        TRAYS(NumberOfTrays).OutletLiquid       to ACCUMULATOR.Inlet;
2123        ACCUMULATOR.Outlet                              to SPLITTER.Inlet;
2124        SPLITTER.Outlet2                                to REBOILER.InletLiquid;
2125
2126#Connectors
2127LiquidConnector                         to TRAYS(1).InletLiquid;
2128ConnectorHeatReboiler           to REBOILER.InletQ;
2129ConnectorHeatAccumulator        to ACCUMULATOR.InletQ;
2130SPLITTER.Outlet1                        to ConnectorSplitterBottom;
2131
2132EQUATIONS
2133#Heat Connectors
2134        HeatToReboiler  = ConnectorHeatReboiler;
2135        HeatToAccumulator       = ConnectorHeatAccumulator;
2136       
2137        ConnectorSplitterBottom.T = BottomProduct.T;
2138        ConnectorSplitterBottom.P = BottomProduct.P;
2139        ConnectorSplitterBottom.F = BottomProduct.F;
2140        ConnectorSplitterBottom.z = BottomProduct.z;
2141       
2142        LiquidConnector.F= LiquidInlet.F;
2143        LiquidConnector.T = LiquidInlet.T;
2144        LiquidConnector.P = LiquidInlet.P;
2145        LiquidConnector.z = LiquidInlet.z;
2146        LiquidConnector.v = LiquidInlet.v;
2147        LiquidConnector.h = LiquidInlet.h;
2148       
2149        VapourOutlet.F= TRAYS(1).OutletVapour.F;
2150        VapourOutlet.T = TRAYS(1).OutletVapour.T;
2151        VapourOutlet.P = TRAYS(1).OutletVapour.P;
2152        VapourOutlet.z = TRAYS(1).OutletVapour.z;
2153       
2154        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
2155        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
2156        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
2157        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
2158
2159        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
2160        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
2161        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
2162        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
2163
2164        VapourDrawOffFlow = VapourDrawOff.F;
2165        LiquidDrawOffFlow = LiquidDrawOff.F;
2166
2167end
2168
2169Model ReactiveDistillation
2170       
2171ATTRIBUTES
2172        Pallete         = true;
2173        Icon            = "icon/DistillationReac";
2174        Brief           = "Model of a reactive distillation column with dynamic condenser and reboiler.";
2175        Info            =
2176"== Specify ==
2177* the reaction related variables for each tray, condenser and reboiler;
2178* the feed stream of each tray (Inlet);
2179* the Murphree eficiency for each tray Emv;
2180* the pump pressure difference;
2181* the heat supllied in reboiler and condenser;
2182* the condenser vapor outlet flow (OutletVapour.F);
2183* the reboiler liquid outlet flow (OutletLiquid.F);
2184* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
2185       
2186== Initial Conditions ==
2187* the TRAYS temperature (OutletLiquid.T);
2188* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
2189* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
2190       
2191* the condenser temperature (OutletLiquid.T);
2192* the condenser liquid level (Level);
2193* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
2194       
2195* the reboiler temperature (OutletLiquid.T);
2196* the reboiler liquid level (Level);
2197* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
2198";
2199       
2200PARAMETERS
2201        outer PP        as Plugin       (Type="PP");
2202        outer NComp as Integer  (Brief="Number of Components");
2203#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2204# Section Column Feed Tray - Side Streams  Location and Numbering
2205#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2206        NumberOfTrays                                           as Integer      (Brief="Number of TRAYS", Default=2);
2207        FeedTrayIndex(NumberOfTrays)            as Integer      (Brief="Feed Tray Index", Default=0,Hidden=true);
2208        LiqSideTrayIndex(NumberOfTrays)         as Integer      (Brief="Liquid Side Tray Index", Default=0,Hidden=true);
2209        VapSideTrayIndex(NumberOfTrays)         as Integer      (Brief="Vapour Side Tray Index", Default=0,Hidden=true);
2210        FeedTrayLocation                                        as Integer      (Brief="Feed tray Location", Default=2);
2211        LiquidSideStreamLocation                        as Integer      (Brief="Liquid Side Stream Location", Default=2);
2212        VapourSideStreamLocation                        as Integer      (Brief="Vapour Side Stream Location", Default=2);
2213#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2214# Section Column Flow Model for Liquid and Vapour
2215#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2216        VapourFlow              as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
2217        TrayVapourFlow  as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
2218        TrayLiquidFlow  as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
2219        alfacond                as Real;
2220#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2221# Section Column Tray Geometry and Auxiliar Parameters
2222#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2223        V               as volume               (Brief="Total Volume of the tray",Hidden=true);
2224        Q               as power                (Brief="Rate of heat supply",Hidden=true);
2225        Ap              as area                 (Brief="Plate area = Atray - Adowncomer",Hidden=true);
2226        Ah              as area                 (Brief="Total holes area",Hidden=true);
2227        lw              as length               (Brief="Weir length",Hidden=true);
2228        g               as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
2229        hw              as length               (Brief="Weir height",Hidden=true);
2230        beta    as fraction     (Brief="Aeration fraction");
2231        alfa    as fraction     (Brief="Dry pressure drop coefficient");
2232
2233        VolumeOfTray            as volume               (Brief="Total Volume of the tray");
2234        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
2235        PlateArea                       as area                 (Brief="Plate area = Atray - Adowncomer");
2236        HolesArea                       as area                 (Brief="Total holes area");
2237        WeirLength                      as length               (Brief="Weir length");
2238        WeirHeight                      as length               (Brief="Weir height");
2239
2240        stoic(NComp)    as Real(Brief="Stoichiometric matrix");
2241        Hr                                              as energy_mol;
2242       
2243SET
2244
2245        FeedTrayIndex(FeedTrayLocation)         =1;
2246        VapSideTrayIndex(FeedTrayLocation)      =1;
2247        LiqSideTrayIndex(FeedTrayLocation)      =1;
2248
2249        V=VolumeOfTray;
2250        Q=HeatSupply;
2251        Ap=PlateArea;
2252        Ah=HolesArea;
2253        lw=WeirLength;
2254        hw=WeirHeight ;
2255       
2256VARIABLES
2257#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2258# Tray Initialization For the Whole Column Section
2259#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2260        INITIALIZATION          as InitializeSection    (Brief = "Column Model Initialization");
2261#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2262# Column Feed - Side Stream Flow and Murphree Efficiency
2263#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2264        in      FeedTray                        as stream       (Brief="Feed stream", PosX=0, PosY=0.55);
2265                VapourDrawOffFlow       as flow_mol (Brief = "Stream Molar Flow Rate");
2266                LiquidDrawOffFlow   as flow_mol (Brief = "Stream Molar Flow Rate");
2267                MurphreeEff             as Real         (Brief = "Murphree efficiency");
2268#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2269# Column Vapour and Liquid Draw Sides
2270#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2271        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.395,Protected = true);
2272        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.44,Protected = true);
2273#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2274# Heat Ports
2275#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2276        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.89);
2277        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", PosX=1, PosY=0.07);
2278#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2279# Column Devices
2280#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2281        TRAYS(NumberOfTrays)    as trayReac;
2282        CONDENSER                               as condenserReact;
2283        REBOILER                                as reboilerReact;
2284        SPLITTER                                as splitter2;
2285        PUMP                                    as pump;
2286#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2287# Column Outlets
2288#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2289        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Condenser", PosX=0.59, PosY=0);
2290        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Splitter", PosX=1, PosY=0.23);
2291        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
2292#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2293# Column Connectors
2294#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2295in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
2296in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
2297in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
2298#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2299# Column Control Ports
2300#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2301        out     TRI as control_signal   (Brief="Temperature of Reboiler Indicator", PosX=1, PosY=0.83);
2302        out     LRI as control_signal   (Brief="Level of Reboiler Indicator", PosX=1, PosY=0.855);
2303        out     TCI as control_signal   (Brief="Temperature of Condenser Indicator", PosX=1, PosY=0.01);
2304        out     LCI as control_signal   (Brief="Level of Condenser Indicator", PosX=1, PosY=0.04);
2305
2306CONNECTIONS
2307#vapor
2308        REBOILER.OutletVapour                                   to TRAYS(NumberOfTrays).InletVapour;
2309        TRAYS(1).OutletVapour                                   to CONDENSER.InletVapour;
2310        TRAYS([2:NumberOfTrays]).OutletVapour   to TRAYS([1:NumberOfTrays-1]).InletVapour;
2311
2312#liquid
2313        CONDENSER.OutletLiquid                                  to SPLITTER.Inlet;     
2314        SPLITTER.Outlet2                                        to PUMP.Inlet;
2315        PUMP.Outlet                                             to TRAYS(1).InletLiquid;
2316        TRAYS([1:NumberOfTrays-1]).OutletLiquid         to TRAYS([2:NumberOfTrays]).InletLiquid;
2317        TRAYS(NumberOfTrays).OutletLiquid               to REBOILER.InletLiquid;
2318
2319#Connectors
2320        CONDENSER.OutletVapour  to ConnectorCondenserVout;
2321        SPLITTER.Outlet1        to ConnectorSplitterOut;
2322        REBOILER.OutletLiquid   to ConnectorReboilerLout;
2323
2324INITIAL
2325#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2326# Tray Initialization
2327#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2328for i in 1:NumberOfTrays do
2329
2330"The initial temperature of the TRAYS"
2331        TRAYS(i).OutletLiquid.T = INITIALIZATION.TopTemperature+(INITIALIZATION.BottomTemperature-INITIALIZATION.TopTemperature)*((i-1)/(NumberOfTrays-1));
2332
2333"The initial Level of the TRAYS"
2334        TRAYS(i).Level = INITIALIZATION.LevelFraction*hw;
2335end
2336
2337for i in 1:NComp-1 do
2338
2339for j in 1:NumberOfTrays do
2340
2341"The initial composition of the TRAYS - Normalized"
2342        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));
2343end
2344
2345end
2346
2347EQUATIONS
2348
2349for i in [1:NumberOfTrays] do
2350
2351"Murphree Efficiency"
2352        TRAYS(i).OutletVapour.z =  MurphreeEff * (TRAYS(i).yideal - TRAYS(i).InletVapour.z) + TRAYS(i).InletVapour.z;
2353       
2354"Energy Holdup"
2355        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletLiquid.h + TRAYS(i).MV*TRAYS(i).OutletVapour.h - TRAYS(i).OutletLiquid.P*V;
2356
2357"Component Molar Balance"
2358        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-
2359        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;
2360       
2361"Energy Balance"
2362        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
2363        -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;
2364
2365"Level of clear liquid over the weir"
2366        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/Ap;
2367
2368"Geometry Constraint"
2369        V = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
2370
2371end
2372
2373switch VapourFlow
2374                case "on":
2375                "Pressure Drop through the condenser"
2376                CONDENSER.InletVapour.F*TRAYS(1).vV / 'm^2' =
2377                        sqrt((TRAYS(1).OutletVapour.P - CONDENSER.OutletLiquid.P + 1e-8 * 'atm')/(TRAYS(1).rhoV*alfacond));
2378                when TRAYS(1).OutletVapour.P < CONDENSER.OutletLiquid.P switchto "off";
2379               
2380                case "off":
2381                "Prato selado"
2382                CONDENSER.InletVapour.F = 0.0 * 'mol/s';
2383                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-3 * 'atm' switchto "on";
2384        end
2385
2386for i in [1:NumberOfTrays] do
2387
2388        switch TrayLiquidFlow
2389                case "on":
2390                "Francis Equation"
2391                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'1/s'*lw*((TRAYS(i).Level-(beta*hw)+1e-6*'m')/(beta))^2;
2392                when TRAYS(i).Level < (beta * hw) switchto "off";
2393               
2394                case "off":
2395                "Low level"
2396                TRAYS(i).OutletLiquid.F = 0 * 'mol/h';
2397                when TRAYS(i).Level > (beta * hw) + 1e-6*'m' switchto "on";
2398        end
2399
2400        switch TrayVapourFlow
2401                case "on":
2402                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;
2403                when TRAYS(i).InletVapour.P < TRAYS(i).OutletVapour.P + TRAYS(i).Level*g*TRAYS(i).rhoL switchto "off";
2404               
2405                case "off":
2406                TRAYS(i).InletVapour.F = 0 * 'mol/s';
2407                when TRAYS(i).InletVapour.P > TRAYS(i).OutletVapour.P + TRAYS(i).Level*g*TRAYS(i).rhoL + 3e-2 * 'atm' switchto "on";
2408        end
2409
2410end
2411
2412# Connecting Trays
2413        FeedTray.F*FeedTrayIndex= TRAYS.Inlet.F;
2414        FeedTray.T = TRAYS.Inlet.T;
2415        FeedTray.P = TRAYS.Inlet.P;
2416        FeedTray.z = TRAYS.Inlet.z;
2417        FeedTray.v = TRAYS.Inlet.v;
2418        FeedTray.h = TRAYS.Inlet.h;
2419
2420        HeatToReboiler  = REBOILER.InletQ;
2421        HeatToCondenser = CONDENSER.InletQ;
2422
2423"Reboiler Temperature indicator"
2424        TRI * 'K' = REBOILER.OutletLiquid.T;
2425
2426"Reboiler Level indicator"
2427        LRI*REBOILER.V = REBOILER.Level*REBOILER.Across;
2428
2429"Condenser Temperature indicator"
2430        TCI * 'K' = CONDENSER.OutletLiquid.T;
2431
2432"Condenser Level indicator"
2433        LCI*CONDENSER.V = CONDENSER.Level*CONDENSER.Across;
2434
2435# Condenser Connector Equations
2436        ConnectorCondenserVout.T = VapourDistillate.T;
2437        ConnectorCondenserVout.P = VapourDistillate.P;
2438        ConnectorCondenserVout.F = VapourDistillate.F;
2439        ConnectorCondenserVout.z = VapourDistillate.z;
2440
2441# Splitter Connector Equations
2442        ConnectorSplitterOut.T = LiquidDistillate.T;
2443        ConnectorSplitterOut.P = LiquidDistillate.P;
2444        ConnectorSplitterOut.F = LiquidDistillate.F;
2445        ConnectorSplitterOut.z = LiquidDistillate.z;
2446
2447# Reboiler Connector Equations
2448        ConnectorReboilerLout.T = BottomProduct.T;
2449        ConnectorReboilerLout.P = BottomProduct.P;
2450        ConnectorReboilerLout.F = BottomProduct.F;
2451        ConnectorReboilerLout.z = BottomProduct.z;
2452
2453        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
2454        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
2455        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
2456        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
2457
2458        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
2459        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
2460        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
2461        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
2462
2463        VapourDrawOffFlow = VapourDrawOff.F;
2464        LiquidDrawOffFlow = LiquidDrawOff.F;
2465
2466end
2467
2468Model Packed_Section_ColumnBasic
2469        ATTRIBUTES
2470        Pallete         = false;
2471        Icon            = "icon/PackedSectionColumn";
2472        Brief           = "Model of a packed column section.";
2473        Info            =
2474"== Model of a packed column section containing ==
2475* NStages theoretical stages.
2476       
2477== Specify ==
2478* the feed stream of each tray (Inlet);
2479* the InletLiquid stream of the top tray;
2480* the InletVapour stream of the bottom tray;
2481* the total pressure drop (dP) of the section.
2482       
2483== Initial Conditions ==
2484* the stages temperature (OutletLiquid.T);
2485* the stages liquid holdup;
2486* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
2487";
2488       
2489PARAMETERS
2490
2491        outer PP                as Plugin(Brief = "External Physical Properties", Type="PP");
2492        outer NComp     as Integer;
2493       
2494        NumberOfStages                                  as Integer      (Brief="Number of Stages", Default=3);
2495        FeedStageIndex(NumberOfStages)  as Integer      (Brief="Number of Stages", Default=0,Hidden=true);
2496        FeedStageLocation                               as Integer      (Brief="Feed Stage Location", Default=2);
2497       
2498        PackingHeight           as length               (Brief="Height of packing");
2499        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
2500        ColumnDiameter          as length               (Brief="Column diameter");
2501        VoidFraction            as Real                 (Brief="Void fraction of packing, m^3/m^3");
2502        ResistanceCoeff         as positive     (Brief="Resistance coefficient on the liquid load", Default=1);
2503        AreaPerPackingVol       as Real                 (Brief="surface area per packing volume", Unit='m^2/m^3');
2504       
2505        V                               as volume               (Brief="Total Volume of the tray",Hidden=true);
2506        g                               as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
2507        hs                              as length               (Brief="Height of the packing stage",Hidden=true);
2508        ColumnArea              as area                 (Brief="Column Sectional Cross Area",Hidden=true);
2509
2510VARIABLES
2511#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2512# Stages Initialization For the Whole Column Section
2513#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2514        INITIALIZATION          as InitializeStage      (Brief = "Column Model Initialization");
2515        in      FeedStage       as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
2516       
2517        STAGES(NumberOfStages) as packedStage;
2518        PressureDrop               as pressure;
2519       
2520SET
2521        FeedStageIndex(FeedStageLocation) =1;
2522       
2523        ColumnArea = ColumnDiameter^2*3.14159*0.25;
2524        hs =PackingHeight/NumberOfStages;       
2525        V = hs * ColumnArea;
2526       
2527CONNECTIONS
2528
2529        STAGES([2:NumberOfStages]).OutletVapour                 to STAGES([1:NumberOfStages-1]).InletVapour;
2530        STAGES([1:NumberOfStages-1]).OutletLiquid       to STAGES([2:NumberOfStages]).InletLiquid;
2531
2532EQUATIONS
2533# Connecting STAGES
2534        FeedStage.F*FeedStageIndex= STAGES.Inlet.F;
2535        FeedStage.T = STAGES.Inlet.T;
2536        FeedStage.P = STAGES.Inlet.P;
2537        FeedStage.z = STAGES.Inlet.z;
2538        FeedStage.v = STAGES.Inlet.v;
2539        FeedStage.h = STAGES.Inlet.h;
2540
2541        STAGES.deltaP = PressureDrop/NumberOfStages;
2542
2543for i in [1:NumberOfStages] do
2544
2545"Energy Balance"
2546        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
2547        - STAGES(i).OutletVapour.F*STAGES(i).OutletVapour.h + HeatSupply );
2548       
2549"Energy Holdup"
2550        STAGES(i).E = STAGES(i).ML*STAGES(i).OutletLiquid.h + STAGES(i).MV*STAGES(i).OutletVapour.h - STAGES(i).OutletLiquid.P*V;
2551       
2552"Geometry Constraint"
2553        V*VoidFraction= STAGES(i).ML*STAGES(i).vL + STAGES(i).MV*STAGES(i).vV;
2554       
2555"Volume flow rate of vapor, m^3/m^2/s"
2556        STAGES(i).uV * ((ColumnArea)*VoidFraction - STAGES(i).Al) = STAGES(i).OutletVapour.F * STAGES(i).vV;
2557       
2558"Liquid holdup"
2559        STAGES(i).hl = STAGES(i).ML*STAGES(i).vL/V/VoidFraction;
2560       
2561"Particle diameter"
2562        STAGES(i).dp = 6 * (1-VoidFraction)/AreaPerPackingVol;
2563       
2564"Wall Factor"
2565        STAGES(i).invK = (1 + (2*STAGES(i).dp/(3*ColumnDiameter*(1-VoidFraction))));
2566       
2567"Reynolds number of the vapor stream"
2568        STAGES(i).Rev*STAGES(i).invK = STAGES(i).dp*STAGES(i).uV*STAGES(i).rhoV / (STAGES(i).miV*(1-VoidFraction));
2569       
2570"Pressure drop and Vapor flow"
2571        STAGES(i).deltaP/hs  = ResistanceCoeff*AreaPerPackingVol*STAGES(i).uV^2*STAGES(i).rhoV*STAGES(i).invK / (2*(VoidFraction-STAGES(i).hl)^3);
2572
2573"Liquid holdup"
2574        STAGES(i).hl = (12*STAGES(i).miL*AreaPerPackingVol^2*STAGES(i).uL/STAGES(i).rhoL/g)^1/3;
2575
2576"Area occupied by the liquid"
2577        STAGES(i).Al = STAGES(i).ML*STAGES(i).vL/hs;
2578
2579end
2580
2581INITIAL
2582
2583for i in 1:NumberOfStages do
2584
2585"The initial temperature of the STAGES"
2586        STAGES(i).OutletLiquid.T = INITIALIZATION.TopStageTemperature+(INITIALIZATION.BottomStageTemperature-INITIALIZATION.TopStageTemperature)*((i-1)/(NumberOfStages-1));
2587
2588"The Liquid Holdup of the STAGES"
2589        STAGES(i).ML = INITIALIZATION.LiquidMolarHoldup;
2590
2591end
2592
2593for i in 1:NComp-1 do
2594       
2595for j in 1:NumberOfStages do
2596
2597"The initial composition of the TRAYS"
2598        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));
2599
2600end
2601
2602end
2603
2604end
2605
2606Model Packed_Section_Column as Packed_Section_ColumnBasic
2607
2608        ATTRIBUTES
2609        Pallete         = true;
2610        Icon            = "icon/PackedSectionColumn";
2611        Brief           = "Model of a packed column section.";
2612        Info            =
2613"== Model of a packed column section containing ==
2614* NStages theoretical stages.
2615       
2616== Specify ==
2617* the feed stream of each tray (Inlet);
2618* the InletLiquid stream of the top tray;
2619* the InletVapour stream of the bottom tray;
2620* the total pressure drop (dP) of the section.
2621       
2622== Initial Conditions ==
2623* the stages temperature (OutletLiquid.T);
2624* the stages liquid holdup;
2625* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
2626";
2627
2628VARIABLES
2629
2630        in              LiquidInlet             as      stream                          (Brief="Liquid Inlet in the section", PosX=0.70, PosY=0);
2631        out     VapourOutlet            as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.30, PosY=0);
2632       
2633        in              VapourInlet             as stream                               (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1);
2634        out     LiquidOutlet            as liquid_stream                (Brief="Liquid Outlet in the section", PosX=0.70, PosY=1);
2635       
2636        LiquidConnector as stream       (Brief="Liquid connection at the middle STAGES", PosX=0.75, PosY=1,Hidden=true);
2637        VapourConnector as stream       (Brief="Vapour connection at the middle STAGES", PosX=0.55, PosY=0,Hidden=true);
2638
2639CONNECTIONS
2640
2641        LiquidConnector to STAGES(1).InletLiquid;
2642        VapourConnector to STAGES(NumberOfStages).InletVapour;
2643       
2644EQUATIONS
2645
2646        LiquidConnector.F= LiquidInlet.F;
2647        LiquidConnector.T = LiquidInlet.T;
2648        LiquidConnector.P = LiquidInlet.P;
2649        LiquidConnector.z = LiquidInlet.z;
2650        LiquidConnector.v = LiquidInlet.v;
2651        LiquidConnector.h = LiquidInlet.h;
2652       
2653        VapourConnector.F= VapourInlet.F;
2654        VapourConnector.T = VapourInlet.T;
2655        VapourConnector.P = VapourInlet.P;
2656        VapourConnector.z = VapourInlet.z;
2657        VapourConnector.v = VapourInlet.v;
2658        VapourConnector.h = VapourInlet.h;
2659       
2660        LiquidOutlet.F= STAGES(NumberOfStages).OutletLiquid.F;
2661        LiquidOutlet.T = STAGES(NumberOfStages).OutletLiquid.T;
2662        LiquidOutlet.P = STAGES(NumberOfStages).OutletLiquid.P;
2663        LiquidOutlet.z = STAGES(NumberOfStages).OutletLiquid.z;
2664       
2665        VapourOutlet.F= STAGES(1).OutletVapour.F;
2666        VapourOutlet.T = STAGES(1).OutletVapour.T;
2667        VapourOutlet.P = STAGES(1).OutletVapour.P;
2668        VapourOutlet.z = STAGES(1).OutletVapour.z;
2669
2670end
2671
2672Model PackedDistillation_kettle_cond as Packed_Section_ColumnBasic
2673        ATTRIBUTES
2674        Pallete         = true;
2675        Icon            = "icon/PackedDistillationKettleCond";
2676        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
2677        Info            =
2678"== Specify ==
2679* the feed stream of each tray (Inlet);
2680* the pump pressure difference;
2681* the total pressure drop (dP) of the packing;
2682* the heat supllied in reboiler and condenser;
2683* the condenser vapor outlet flow (OutletVapour.F);
2684* the reboiler liquid outlet flow (OutletLiquid.F);
2685* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
2686       
2687== Initial Conditions ==
2688* the stages temperature (OutletLiquid.T);
2689* the stages initial molar holdup;
2690* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each stage;
2691       
2692* the condenser temperature (OutletLiquid.T);
2693* the condenser liquid level (Level);
2694* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
2695       
2696* the reboiler temperature (OutletLiquid.T);
2697* the reboiler liquid level (Level);
2698* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
2699";
2700       
2701PARAMETERS
2702
2703        VapourFlow as Switcher  (Valid = ["on", "off"], Hidden = true ,Default = "on");
2704       
2705VARIABLES
2706#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2707# Column Devices
2708#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2709        CONDENSER       as condenser    (Brief="dymamic condenser");
2710        REBOILER        as reboiler             (Brief="kettle reboiler");
2711        SPLITTER        as splitter2            (Brief="splitter which separate reflux and distillate");
2712        PUMP            as pump                 (Brief="pump in reflux stream");
2713#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2714# Heat Ports
2715#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2716        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler",Protected = true, PosX=1, PosY=0.885);
2717        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", Protected = true, PosX=1, PosY=0.034);
2718#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2719# Column Products
2720#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2721        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.66, PosY=0);
2722        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
2723        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.68, PosY=1);
2724#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2725# Column Connectors
2726#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
2727        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
2728        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
2729        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
2730                ConnectorHeatReboiler   as power        (Brief="Heat supplied to Reboiler", Hidden=true);
2731                ConnectorHeatCondenser  as power        (Brief="Heat supplied to Condenser", Hidden=true);
2732
2733CONNECTIONS
2734
2735#vapor
2736        REBOILER.OutletVapour           to STAGES(NumberOfStages).InletVapour;
2737        STAGES(1).OutletVapour          to CONDENSER.InletVapour;
2738
2739#liquid
2740        CONDENSER.OutletLiquid                          to SPLITTER.Inlet;     
2741        SPLITTER.Outlet2                                to PUMP.Inlet;
2742        PUMP.Outlet                                     to STAGES(1).InletLiquid;
2743        STAGES(NumberOfStages).OutletLiquid     to REBOILER.InletLiquid;
2744
2745#Connectors
2746ConnectorHeatReboiler   to REBOILER.InletQ;
2747ConnectorHeatCondenser  to CONDENSER.InletQ;
2748
2749CONDENSER.OutletVapour          to ConnectorCondenserVout;
2750SPLITTER.Outlet1                to ConnectorSplitterOut;
2751REBOILER.OutletLiquid           to ConnectorReboilerLout;
2752
2753EQUATIONS
2754        HeatToReboiler  = ConnectorHeatReboiler;
2755        HeatToCondenser = ConnectorHeatCondenser;
2756       
2757# Condenser Connector Equations
2758        ConnectorCondenserVout.T = VapourDistillate.T;
2759        ConnectorCondenserVout.P = VapourDistillate.P;
2760        ConnectorCondenserVout.F = VapourDistillate.F;
2761        ConnectorCondenserVout.z = VapourDistillate.z;
2762
2763# Splitter Connector Equations
2764        ConnectorSplitterOut.T = LiquidDistillate.T;
2765        ConnectorSplitterOut.P = LiquidDistillate.P;
2766        ConnectorSplitterOut.F = LiquidDistillate.F;
2767        ConnectorSplitterOut.z = LiquidDistillate.z;
2768
2769# Reboiler Connector Equations
2770        ConnectorReboilerLout.T = BottomProduct.T;
2771        ConnectorReboilerLout.P = BottomProduct.P;
2772        ConnectorReboilerLout.F = BottomProduct.F;
2773        ConnectorReboilerLout.z = BottomProduct.z;
2774
2775switch VapourFlow
2776        case "on":
2777                STAGES(NumberOfStages).InletVapour.F*STAGES(NumberOfStages).vV = sqrt((REBOILER.OutletVapour.P - STAGES(NumberOfStages).OutletVapour.P)/
2778                                        (STAGES(NumberOfStages).rhoV*ResistanceCoeff*20))*(ColumnArea*VoidFraction - STAGES(NumberOfStages).Al);
2779                when STAGES(NumberOfStages).InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
2780
2781        case "off":
2782                STAGES(NumberOfStages).InletVapour.F = 0 * 'mol/s';
2783                when REBOILER.OutletVapour.P > STAGES(NumberOfStages).OutletVapour.P + 1e-1 * 'atm' switchto "on";
2784end
2785
2786end
2787
Note: See TracBrowser for help on using the repository browser.