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

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

basic column model changed (added two feed streams)

File size: 110.9 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_ColumnBasic
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=1, PosY=0.77);
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 Section_Column
385
386ATTRIBUTES
387        Pallete         = true;
388        Icon            = "icon/SectionColumn";
389        Brief   = "Model of a column section.";
390        Info            =
391"== Model of a column section containing ==
392* NumberOfTrays TRAYS.
393       
394== Specify ==
395* the feed stream of each tray (Inlet);
396* the Murphree eficiency for each tray Emv;
397* the InletLiquid stream of the top tray;
398* the InletVapour stream of the bottom tray.
399       
400== Initial Conditions ==
401* the TRAYS temperature (OutletLiquid.T);
402* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
403* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
404";
405
406PARAMETERS
407        outer PP                                                        as Plugin                       (Brief="External Physical Properties", Type="PP");
408        outer NComp                                             as Integer                      (Brief="Number of components");
409#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
410# Section Column Feed Tray - Side Streams  Location and Numbering
411#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
412        NumberOfTrays                                           as Integer                      (Brief="Number of trays", Default=8);
413        FeedTrayIndex(NumberOfTrays)            as Integer                      (Brief="Feed Tray Index", Default=0,Hidden=true);
414        LiqSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Liquid Side Tray Index", Default=0,Hidden=true);
415        VapSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Vapour Side Tray Index", Default=0,Hidden=true);
416        FeedTrayLocation                                        as Integer                      (Brief="Feed tray Location", Default=2);
417        LiquidSideStreamLocation                        as Integer                      (Brief="Liquid Side Stream Location", Default=2);
418        VapourSideStreamLocation                        as Integer                      (Brief="Vapour Side Stream Location", Default=2);
419        g                                                                       as acceleration         (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
420        Mw(NComp)                                                       as molweight            (Brief="Component Mol Weight",Hidden=true);
421#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
422# Section Column Flow Model for Liquid and Vapour
423#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
424        VapourFlowModel         as Switcher     (Valid = ["Reepmeyer", "Feehery_Fv", "Roffel_Fv", "Klingberg", "Wang_Fv", "Elgue"], Default = "Reepmeyer");
425        LiquidFlowModel         as Switcher     (Valid = ["default", "Wang_Fl", "Olsen", "Feehery_Fl", "Roffel_Fl"], Default = "default");
426#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
427# Section Column Tray Geometry and Auxiliar Parameters
428#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
429        VolumeOfTray            as volume               (Brief="Total Volume of the tray");
430        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
431        PlateArea                       as area                 (Brief="Plate area = Atray - Adowncomer");
432        HolesArea                       as area                 (Brief="Total holes area");
433        WeirLength                      as length               (Brief="Weir length");
434        WeirHeight                      as length               (Brief="Weir height");
435        FeeheryCoeff            as Real                 (Brief="Feeherys correlation coefficient", Unit='1/m^4', Default=1);
436        ElgueCoeff                      as Real                 (Brief="Elgues correlation coefficient", Unit='kg/m/mol^2', Default=1);
437        OlsenCoeff                      as Real                 (Brief="Olsens correlation coefficient", Default=1);
438        TrayLiquidPasses        as Real                 (Brief="Number of liquid passes in the tray", Default=1);
439       
440        V                               as volume               (Brief="Total Volume of the tray",Hidden=true);
441        Q                               as heat_rate    (Brief="Rate of heat supply",Hidden=true);
442        Ap                              as area                 (Brief="Plate area = Atray - Adowncomer",Hidden=true);
443        Ah                              as area                 (Brief="Total holes area",Hidden=true);
444        lw                              as length               (Brief="Weir length",Hidden=true);
445        hw                              as length               (Brief="Weir height",Hidden=true);
446        beta                    as fraction     (Brief="Aeration fraction");
447        alfa                    as fraction     (Brief="Dry pressure drop coefficient");
448        w                               as Real                 (Brief="Feeherys correlation coefficient", Unit='1/m^4', Default=1,Hidden=true);
449        btray                   as Real                 (Brief="Elgues correlation coefficient", Unit='kg/m/mol^2', Default=1,Hidden=true);
450        fw                              as Real                 (Brief="Olsens correlation coefficient", Default=1,Hidden=true);
451        Np                              as Real                 (Brief="Number of liquid passes in the tray", Default=1,Hidden=true);
452       
453        VapourFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
454        LiquidFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
455
456SET
457        FeedTrayIndex(FeedTrayLocation) =1;
458        VapSideTrayIndex(FeedTrayLocation) =1;
459        LiqSideTrayIndex(FeedTrayLocation) =1;
460        Mw = PP.MolecularWeight();
461
462        V=VolumeOfTray;
463        Q=HeatSupply;
464        Ap=PlateArea;
465        Ah=HolesArea;
466        lw=WeirLength;
467        hw=WeirHeight ;
468        w=FeeheryCoeff;
469        btray=ElgueCoeff;
470        fw=OlsenCoeff;
471        Np=TrayLiquidPasses;
472
473VARIABLES
474#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
475# Tray Initialization For the Whole Column Section
476#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
477        INITIALIZATION as InitializeSection (Brief = "Column Model Initialization");
478#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
479# Control Ports
480#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
481        CONTROL as ControlSection (Brief = "Control");
482        out     TCI as control_signal   (Brief="Temperature  Indicator", Protected = true, PosX=1, PosY=0.90);
483        out     PCI as control_signal   (Brief="Pressure Indicator", Protected = true, PosX=1, PosY=0.80);
484#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
485# Section Inlet Liquid and Outlet Vapour Material Ports
486#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
487        in      LiquidInlet             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.70, PosY=0);
488        out     VapourOutlet    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.30, PosY=0);
489       
490        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Draw Off Port in the section", PosX=1, PosY=0.35,Protected = true);
491        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Draw Off Port in the section", PosX=1, PosY=0.65,Protected = true);
492#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
493# Column Feed - Side Stream Flow and Murphree Efficiency
494#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
495        in      FeedTray                                as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
496                TRAYS(NumberOfTrays)    as tray                 (Brief="Number of trays in the Column Section");
497                VapourDrawOffFlow               as flow_mol     (Brief="Stream Molar Flow Rate");
498                LiquidDrawOffFlow               as flow_mol     (Brief="Stream Molar Flow Rate");
499                MurphreeEff                     as positive             (Brief="Murphree efficiency for All Trays");
500#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
501# Section Inlet Vapour and Outlet Liquid Material Ports
502#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
503        in      VapourInlet             as stream                       (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1);
504        out     LiquidOutlet    as liquid_stream        (Brief="Liquid Outlet in the section", PosX=0.70, PosY=1);
505
506        LiquidConnector as stream       (Brief="Liquid connection in the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
507        VapourConnector as stream       (Brief="Vapour connection in the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
508
509CONNECTIONS
510#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
511# Connecting Intermediate Trays
512#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
513        TRAYS([2:NumberOfTrays]).OutletVapour   to TRAYS([1:NumberOfTrays-1]).InletVapour;
514        TRAYS([1:NumberOfTrays-1]).OutletLiquid         to TRAYS([2:NumberOfTrays]).InletLiquid;
515
516#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
517# Connecting Connectors
518#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
519        LiquidConnector to TRAYS(1).InletLiquid;
520        VapourConnector to TRAYS(NumberOfTrays).InletVapour;
521
522INITIAL
523#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
524# Tray Initialization
525#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
526for i in 1:NumberOfTrays do
527
528"The initial temperature of the TRAYS"
529        TRAYS(i).OutletLiquid.T = INITIALIZATION.TopTemperature+(INITIALIZATION.BottomTemperature-INITIALIZATION.TopTemperature)*((i-1)/(NumberOfTrays-1));
530
531"The initial Level of the TRAYS"
532        TRAYS(i).Level = INITIALIZATION.LevelFraction*hw;
533end
534
535for i in 1:NComp-1 do
536
537for j in 1:NumberOfTrays do
538
539"The initial composition of the TRAYS - Normalized"
540        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));
541end
542
543end
544
545EQUATIONS
546#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
547# Control Ports
548#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
549
550"Tray Temperature Indicator"   
551        #TCI*'K' = TRAYS(min([NumberOfTrays, CONTROL.Tindicator_TrayNumber])).OutletVapour.T;
552        TCI*'K' = TRAYS(CONTROL.Tindicator_TrayNumber).OutletVapour.T;
553
554"Tray Pressure Indicator"       
555        #PCI*'atm' = TRAYS(min([NumberOfTrays, CONTROL.Pindicator_TrayNumber])).OutletVapour.P;
556        PCI*'atm' = TRAYS(CONTROL.Pindicator_TrayNumber).OutletVapour.P;
557
558#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
559# Equating Feed Tray Variables to Trays Variables
560#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
561"Feed Tray Inlet Flow" 
562        FeedTray.F*FeedTrayIndex= TRAYS.Inlet.F;
563
564"Feed Tray Inlet Temperature"
565        FeedTray.T = TRAYS.Inlet.T;
566
567"Feed Tray Inlet Pressure"
568        FeedTray.P = TRAYS.Inlet.P;
569
570"Feed Tray Inlet Composition"
571        FeedTray.z = TRAYS.Inlet.z;
572
573"Feed Tray Inlet Vapour Fraction"
574        FeedTray.v = TRAYS.Inlet.v;
575
576"Feed Tray Inlet Enthalpy"
577        FeedTray.h = TRAYS.Inlet.h;
578
579#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
580# Trays Equations
581#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
582for i in [1:NumberOfTrays] do
583
584"Murphree Efficiency"
585        TRAYS(i).OutletVapour.z =  MurphreeEff * (TRAYS(i).yideal - TRAYS(i).InletVapour.z) + TRAYS(i).InletVapour.z;
586
587"Level of clear liquid over the weir"
588        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/Ap;
589
590"Geometry Constraint"
591        V = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
592
593"Energy Holdup"
594        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletLiquid.h + TRAYS(i).MV*TRAYS(i).OutletVapour.h - TRAYS(i).OutletLiquid.P*V;
595
596"Energy Balance"
597        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
598        -TRAYS(i).VapourSideStream.F*TRAYS(i).VapourSideStream.h - TRAYS(i).LiquidSideStream.F*TRAYS(i).LiquidSideStream.h + Q );
599
600switch LiquidFlow
601                case "on":
602                        switch LiquidFlowModel
603                                case "default":
604                                "Francis Equation"
605                                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'1/s'*lw*((TRAYS(i).Level-(beta*hw))/(beta))^2;
606                       
607                                case "Wang_Fl":
608                                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'m^0.5/s'*lw*((TRAYS(i).Level-(beta*hw))/(beta))^1.5;
609                       
610                                case "Olsen":
611                                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';
612                       
613                                case "Feehery_Fl":
614                                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';
615                       
616                                case "Roffel_Fl":
617                                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/
618                                                        (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';
619                        end
620                when TRAYS(i).Level < (beta *hw) switchto "off";
621               
622                case "off":
623                "Low level"
624                TRAYS(i).OutletLiquid.F = 0 * 'mol/h';
625                when TRAYS(i).Level > (beta * hw) + 1e-6*'m' switchto "on";
626        end
627       
628switch VapourFlow
629                case "on":
630                        switch VapourFlowModel
631                                case "Reepmeyer":
632                                TRAYS(i).InletVapour.F*TRAYS(i).vV = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)/(TRAYS(i).rhoV*alfa))*Ah;
633                       
634                                case "Feehery_Fv":
635                                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);
636                       
637                                case "Roffel_Fv":
638                                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';
639                       
640                                case "Klingberg":
641                                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);
642                       
643                                case "Wang_Fv":
644                                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);
645                               
646                                case "Elgue":
647                                TRAYS(i).InletVapour.F  = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)/btray);
648                        end
649                when TRAYS(i).InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
650               
651                case "off":
652                TRAYS(i).InletVapour.F = 0 * 'mol/s';
653                when TRAYS(i).InletVapour.P > TRAYS(i).OutletVapour.P + TRAYS(i).Level*g*TRAYS(i).rhoL + 1e-1 * 'atm' switchto "on";
654        end
655
656end
657
658#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
659# Equating Inlet Liquid Connector Variables
660#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
661"Liquid Inlet Flow"     
662        LiquidConnector.F = LiquidInlet.F;
663
664"Liquid Inlet Temperature"             
665        LiquidConnector.T = LiquidInlet.T;
666
667"Liquid Inlet Pressure"         
668        LiquidConnector.P = LiquidInlet.P;
669
670"Liquid Inlet Composition"             
671        LiquidConnector.z = LiquidInlet.z;
672
673"Liquid Inlet Vapour Fraction"         
674        LiquidConnector.v = LiquidInlet.v;
675
676"Liquid Inlet Enthalpy"         
677        LiquidConnector.h = LiquidInlet.h;
678#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
679# Equating Inlet Vapour Connector Variables
680#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
681"Vapour Inlet Flow"             
682        VapourConnector.F = VapourInlet.F;
683
684"Vapour Inlet Temperature"             
685        VapourConnector.T = VapourInlet.T;
686
687"Vapour Inlet Pressure"         
688        VapourConnector.P = VapourInlet.P;
689
690"Vapour Inlet Composition"             
691        VapourConnector.z = VapourInlet.z;
692
693"Vapour Inlet Vapour Fraction"         
694        VapourConnector.v = VapourInlet.v;
695
696"Vapour Inlet Enthalpy"         
697        VapourConnector.h = VapourInlet.h;
698#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
699# Equating Outlet Liquid Variables
700#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
701"Liquid Outlet Flow"   
702        LiquidOutlet.F = TRAYS(NumberOfTrays).OutletLiquid.F;
703
704"Liquid Outlet Temperature"     
705        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
706
707"Liquid Outlet Pressure"       
708        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
709
710"Liquid Outlet Composition"     
711        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
712#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
713# Equating Outlet Vapour Variables
714#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
715"Vapour Outlet Flow"           
716        VapourOutlet.F = TRAYS(1).OutletVapour.F;
717
718"Vapour Outlet Temperature"             
719        VapourOutlet.T = TRAYS(1).OutletVapour.T;
720
721"Vapour Outlet Pressure"               
722        VapourOutlet.P = TRAYS(1).OutletVapour.P;
723
724"Vapour Outlet Composition"             
725        VapourOutlet.z = TRAYS(1).OutletVapour.z;
726#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
727# Equating Outlet Vapour Side Stream Variables
728#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
729"Vapour Draw Off Stream - Flow"         
730        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
731
732"Vapour Draw Off Stream - Temperature"         
733        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
734
735"Vapour Draw Off Stream - Pressure"             
736        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
737
738"Vapour Draw Off Stream - Composition"         
739        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
740
741"Vapour Draw Off Stream"       
742        VapourDrawOffFlow = VapourDrawOff.F;
743#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
744# Equating Outlet Liquid Side Stream Variables
745#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
746"Liquid Draw Off Stream - Flow"         
747        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
748
749"Liquid Draw Off Stream - Temperature" 
750        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
751
752"Liquid Draw Off Stream - Pressure"                     
753        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
754
755"Liquid Draw Off Stream - Composition" 
756        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
757
758"Liquid Draw Off Stream"       
759        LiquidDrawOffFlow = LiquidDrawOff.F;
760
761end
762
763Model Distillation_kettle_cond  as Section_ColumnBasic
764
765ATTRIBUTES
766        Pallete         = true;
767        Icon            = "icon/DistillationKettleCond";
768        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
769        Info            =
770"== Specify ==
771* the feed stream of each tray (Inlet);
772* the Murphree eficiency for each tray Emv;
773* the pump pressure difference;
774* the heat supllied in reboiler and condenser;
775* the condenser vapor outlet flow (OutletVapour.F);
776* the reboiler liquid outlet flow (OutletLiquid.F);
777* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
778       
779== Initial Conditions ==
780* the TRAYS temperature (OutletLiquid.T);
781* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
782* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
783       
784* the condenser temperature (OutletLiquid.T);
785* the condenser liquid level (Level);
786* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
787       
788* the reboiler temperature (OutletLiquid.T);
789* the reboiler liquid level (Level);
790* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
791";
792       
793PARAMETERS
794        CondenserVapourFlow             as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
795
796VARIABLES
797        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.375,Protected = true);
798        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.42,Protected = true);
799#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
800# Column Devices
801#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
802        CONDENSER               as condenser;
803        REBOILER                as reboiler;
804        SPLITTER                as splitter2;
805        PUMP                    as pump;
806        alfaTopo                as Real;
807#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
808# Heat Ports
809#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
810        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler",Protected = true, PosX=1, PosY=0.90);
811        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", Protected = true, PosX=1, PosY=0.034);
812#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
813# Column Connectors
814#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
815                ConnectorHeatReboiler   as power        (Brief="Heat supplied to Reboiler", Hidden=true);
816                ConnectorHeatCondenser  as power        (Brief="Heat supplied to Condenser", Hidden=true);
817        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Condenser", Hidden=true);
818        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
819        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
820#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
821# Column products
822#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
823        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Condenser", PosX=0.66, PosY=0);
824        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
825        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
826
827EQUATIONS
828
829switch CondenserVapourFlow
830
831        case "on":
832                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo *Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
833                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
834                when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
835
836        case "off":
837                CONDENSER.InletVapour.F = 0 * 'mol/s';
838                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
839
840end     
841
842# Condenser Connector Equations
843        ConnectorCondenserVout.T = VapourDistillate.T;
844        ConnectorCondenserVout.P = VapourDistillate.P;
845        ConnectorCondenserVout.F = VapourDistillate.F;
846        ConnectorCondenserVout.z = VapourDistillate.z;
847
848# Splitter Connector Equations
849        ConnectorSplitterOut.T = LiquidDistillate.T;
850        ConnectorSplitterOut.P = LiquidDistillate.P;
851        ConnectorSplitterOut.F = LiquidDistillate.F;
852        ConnectorSplitterOut.z = LiquidDistillate.z;
853
854# Reboiler Connector Equations
855        ConnectorReboilerLout.T = BottomProduct.T;
856        ConnectorReboilerLout.P = BottomProduct.P;
857        ConnectorReboilerLout.F = BottomProduct.F;
858        ConnectorReboilerLout.z = BottomProduct.z;
859
860        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
861        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
862        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
863        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
864
865        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
866        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
867        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
868        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
869
870        VapourDrawOffFlow = VapourDrawOff.F;
871        LiquidDrawOffFlow = LiquidDrawOff.F;
872
873        HeatToReboiler  = ConnectorHeatReboiler;
874        HeatToCondenser = ConnectorHeatCondenser;
875
876CONNECTIONS
877#vapor
878        REBOILER.OutletVapour   to      TRAYS(NumberOfTrays).InletVapour;
879        TRAYS(1).OutletVapour   to      CONDENSER.InletVapour;
880
881#liquid
882        CONDENSER.OutletLiquid                          to      SPLITTER.Inlet;
883        SPLITTER.Outlet2                        to      PUMP.Inlet;
884        PUMP.Outlet                                     to      TRAYS(1).InletLiquid;
885        TRAYS(NumberOfTrays).OutletLiquid       to      REBOILER.InletLiquid;
886
887#Connectors
888        CONDENSER.OutletVapour  to ConnectorCondenserVout;
889        SPLITTER.Outlet1 to ConnectorSplitterOut;
890        REBOILER.OutletLiquid   to ConnectorReboilerLout;
891
892        ConnectorHeatReboiler   to REBOILER.InletQ;
893        ConnectorHeatCondenser  to CONDENSER.InletQ;
894
895end
896
897Model Distillation_thermosyphon_subcooling      as Section_ColumnBasic
898        ATTRIBUTES
899        Pallete         = true;
900        Icon            = "icon/DistillationThermosyphonSubcooling";
901        Brief           = "Model of a distillation column with steady condenser and steady reboiler.";
902        Info            =
903"== Specify ==
904* the feed stream of each tray (Inlet);
905* the Murphree eficiency for each tray Emv;
906* the pump head;
907* the condenser pressure drop;
908* the heat supllied in top and bottom tanks;
909* the heat supllied in condenser and reboiler;
910* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
911* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
912       
913== Initial Conditions ==
914* the TRAYS temperature (OutletLiquid.T);
915* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
916* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
917       
918* the top tank temperature (OutletLiquid.T);
919* the top tank liquid level (Level);
920* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
921       
922* the bottom tank temperature (OutletLiquid.T);
923* the bottom tank liquid level (Level);
924* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
925";
926
927PARAMETERS
928
929        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Hidden=true, Default = "on");
930
931VARIABLES
932#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
933# Column Vapour and Liquid Draw Sides
934#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
935        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.41,Protected = true);
936        out     LiquidDrawOff   as liquid_stream                (Brief="Liquid Outlet in the section", PosX=1, PosY=0.45,Protected = true);
937#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
938# Column Devices
939#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
940        CONDENSER                       as condenserSteady      (Brief="steady state condenser with subcooling");
941        ACCUMULATOR_TOP         as tank_cylindrical     (Brief="vessel drum (layed cilinder)");
942        SPLITTER_TOP            as splitter2                    (Brief="splitter which separate reflux and distillate");
943        PUMP                            as pump                         (Brief="pump in reflux stream");
944        REBOILER                        as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
945        ACCUMULATOR_BOTTOM      as tank                         (Brief="vessel in the bottom of column");
946        SPLITTER_BOTTOM         as splitter2                    (Brief="splitter who separate the bottom product and the stream to reboiler");
947        alfaTopo                        as Real;
948#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
949# Heat Ports
950#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
951in              HeatToCondenser                 as power        (Brief="Heat supplied to Condenser",PosX=1, PosY=0.065, Protected=true);
952in              HeatToReboiler                  as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.87,Protected=true);
953in              HeatToBottomAccumulator as power        (Brief="Heat supplied to Bottom Accumulator",PosX=0, PosY=0.925,Protected=true);
954in              HeatToTopAccumulator    as power        (Brief="Heat supplied to Top Accumulator", PosX=1, PosY=0.19,Protected=true);
955#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
956# Column Top and Bottom product
957#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
958out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.24);
959out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=0.18, PosY=1);
960#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
961# Column Model Connectors
962#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
963in      ConnectorSplitterBottom         as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
964in      ConnectorSplitterTop            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
965
966        ConnectorHeatReboiler                   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
967        ConnectorHeatCondenser                  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
968        ConnectorHeatTopAccumulator     as power        (Brief="Connector for Heat supplied to Top Accumulator", Hidden=true);
969        ConnectorHeatBottomAccumulator  as power        (Brief="Connector for Heat supplied to Bottom Accumulator", Hidden=true);
970       
971EQUATIONS
972# Heat Connector Equations
973        HeatToCondenser                 =       ConnectorHeatCondenser;
974        HeatToReboiler                  =       ConnectorHeatReboiler;
975        HeatToBottomAccumulator =       ConnectorHeatBottomAccumulator;
976        HeatToTopAccumulator    =       ConnectorHeatTopAccumulator;
977
978# Top Splitter Connector Equations
979        ConnectorSplitterTop.T = LiquidDistillate.T;
980        ConnectorSplitterTop.P = LiquidDistillate.P;
981        ConnectorSplitterTop.F = LiquidDistillate.F;
982        ConnectorSplitterTop.z = LiquidDistillate.z;
983
984# Bottom Splitter Connector Equations
985        ConnectorSplitterBottom.T = BottomProduct.T;
986        ConnectorSplitterBottom.P = BottomProduct.P;
987        ConnectorSplitterBottom.F = BottomProduct.F;
988        ConnectorSplitterBottom.z = BottomProduct.z;
989
990        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
991        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
992        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
993        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
994
995        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
996        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
997        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
998        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
999
1000        VapourDrawOffFlow = VapourDrawOff.F;
1001        LiquidDrawOffFlow = LiquidDrawOff.F;
1002
1003switch CondenserVapourFlow
1004
1005        case "on":
1006                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
1007                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1008                when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
1009
1010        case "off":
1011                CONDENSER.InletVapour.F = 0 * 'mol/s';
1012                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
1013
1014end     
1015
1016CONNECTIONS
1017#vapor
1018        REBOILER.OutletVapour   to TRAYS(NumberOfTrays).InletVapour;
1019        TRAYS(1).OutletVapour   to CONDENSER.InletVapour;
1020
1021#liquid
1022        CONDENSER.OutletLiquid                          to ACCUMULATOR_TOP.Inlet;       
1023        ACCUMULATOR_TOP.Outlet                  to SPLITTER_TOP.Inlet;
1024        SPLITTER_TOP.Outlet2                    to PUMP.Inlet; 
1025        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
1026        TRAYS(NumberOfTrays).OutletLiquid       to ACCUMULATOR_BOTTOM.Inlet;
1027        ACCUMULATOR_BOTTOM.Outlet               to SPLITTER_BOTTOM.Inlet;
1028        SPLITTER_BOTTOM.Outlet2                 to REBOILER.InletLiquid;
1029
1030#Connectors
1031        ConnectorHeatCondenser                  to CONDENSER.InletQ;
1032        ConnectorHeatReboiler                   to REBOILER.InletQ;
1033        ConnectorHeatBottomAccumulator  to ACCUMULATOR_BOTTOM.InletQ;
1034        ConnectorHeatTopAccumulator             to ACCUMULATOR_TOP.InletQ;
1035        SPLITTER_TOP.Outlet1                    to ConnectorSplitterTop;
1036        SPLITTER_BOTTOM.Outlet1                 to ConnectorSplitterBottom;
1037
1038end
1039
1040Model Distillation_thermosyphon_cond as Section_ColumnBasic
1041        ATTRIBUTES
1042        Pallete         = true;
1043        Icon            = "icon/DistillationThermosyphonCond";
1044        Brief           = "Model of a distillation column with dynamic condenser and steady reboiler.";
1045        Info            =
1046"== Specify ==
1047* the feed stream of each tray (Inlet);
1048* the Murphree eficiency for each tray Emv;
1049* the pump head;
1050* the condenser vapor outlet flow (OutletVapour.F);
1051* the heat supllied in bottom tank;
1052* the heat supllied in condenser and reboiler;
1053* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
1054       
1055== Initial Conditions ==
1056* the TRAYS temperature (OutletLiquid.T);
1057* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1058* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1059       
1060* the condenser temperature (OutletLiquid.T);
1061* the condenser liquid level (Level);
1062* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1063       
1064* the bottom tank temperature (OutletLiquid.T);
1065* the bottom tank liquid level (Level);
1066* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1067";
1068
1069PARAMETERS
1070        CondenserVapourFlow     as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
1071
1072VARIABLES
1073#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1074# Column Vapour and Liquid Draw Sides
1075#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1076        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.379,Protected = true);
1077        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.425,Protected = true);
1078#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1079# Column Devices
1080#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1081        CONDENSER                       as condenser            (Brief="dynamic condenser without subcooling");
1082        SPLITTER_TOP            as splitter2                    (Brief="splitter which separate reflux and distillate");
1083        PUMP                            as pump                         (Brief="pump in reflux stream");
1084        ACCUMULATOR_BOTTOM      as tank                         (Brief="vessel in the bottom of column");
1085        SPLITTER_BOTTOM         as splitter2                    (Brief="splitter who separate the bottom product and the stream to reboiler");
1086        REBOILER                        as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
1087        alfaTopo                        as Real;
1088#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1089# Heat Ports
1090#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1091in      HeatToCondenser                 as power        (Brief="Heat supplied to Condenser",PosX=1, PosY=0.035, Protected=true);
1092in      HeatToReboiler                  as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.865,Protected=true);
1093in      HeatToBottomAccumulator as power        (Brief="Heat supplied to Bottom Accumulator",PosX=0, PosY=0.92,Protected=true);
1094#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1095# Column Top and Bottom product
1096#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1097out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.665, PosY=0);
1098out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
1099out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=0.18, PosY=1);
1100#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1101# Column Model Connectors
1102#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1103in      ConnectorSplitterBottom as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1104in      ConnectorSplitterTop    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1105in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
1106
1107        ConnectorHeatReboiler                   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1108        ConnectorHeatCondenser                  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1109        ConnectorHeatBottomAccumulator  as power        (Brief="Connector for Heat supplied to Bottom Accumulator", Hidden=true);
1110
1111EQUATIONS
1112# Heat Connector Equations
1113        HeatToCondenser                 =       ConnectorHeatCondenser;
1114        HeatToReboiler                  =       ConnectorHeatReboiler;
1115        HeatToBottomAccumulator =       ConnectorHeatBottomAccumulator;
1116
1117# Condenser Connector Equations
1118        ConnectorCondenserVout.T = VapourDistillate.T;
1119        ConnectorCondenserVout.P = VapourDistillate.P;
1120        ConnectorCondenserVout.F = VapourDistillate.F;
1121        ConnectorCondenserVout.z = VapourDistillate.z;
1122
1123# Top Splitter Connector Equations
1124        ConnectorSplitterTop.T = LiquidDistillate.T;
1125        ConnectorSplitterTop.P = LiquidDistillate.P;
1126        ConnectorSplitterTop.F = LiquidDistillate.F;
1127        ConnectorSplitterTop.z = LiquidDistillate.z;
1128
1129# Bottom Splitter Connector Equations
1130        ConnectorSplitterBottom.T = BottomProduct.T;
1131        ConnectorSplitterBottom.P = BottomProduct.P;
1132        ConnectorSplitterBottom.F = BottomProduct.F;
1133        ConnectorSplitterBottom.z = BottomProduct.z;
1134
1135        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1136        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1137        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1138        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1139
1140        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1141        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1142        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1143        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1144
1145        VapourDrawOffFlow = VapourDrawOff.F;
1146        LiquidDrawOffFlow = LiquidDrawOff.F;
1147       
1148switch CondenserVapourFlow
1149                case "on":
1150                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
1151                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1152                when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
1153               
1154                case "off":
1155                CONDENSER.InletVapour.F = 0 * 'mol/s';
1156                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
1157end     
1158
1159CONNECTIONS
1160#vapor
1161        REBOILER.OutletVapour   to TRAYS(NumberOfTrays).InletVapour;
1162        TRAYS(1).OutletVapour                           to CONDENSER.InletVapour;
1163
1164#liquid
1165        CONDENSER.OutletLiquid          to SPLITTER_TOP.Inlet; 
1166        SPLITTER_TOP.Outlet2                            to PUMP.Inlet;
1167        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
1168        TRAYS(NumberOfTrays).OutletLiquid       to ACCUMULATOR_BOTTOM.Inlet;
1169        ACCUMULATOR_BOTTOM.Outlet                               to SPLITTER_BOTTOM.Inlet;
1170        SPLITTER_BOTTOM.Outlet2                         to REBOILER.InletLiquid;
1171
1172#Connectors
1173ConnectorHeatCondenser                  to CONDENSER.InletQ;
1174ConnectorHeatReboiler                   to REBOILER.InletQ;
1175ConnectorHeatBottomAccumulator  to ACCUMULATOR_BOTTOM.InletQ;
1176CONDENSER.OutletVapour                          to ConnectorCondenserVout;
1177SPLITTER_TOP.Outlet1                    to ConnectorSplitterTop;
1178SPLITTER_BOTTOM.Outlet1                 to ConnectorSplitterBottom;
1179
1180end
1181
1182Model Distillation_kettle_subcooling as Section_ColumnBasic
1183
1184ATTRIBUTES
1185        Pallete         = true;
1186        Icon            = "icon/DistillationKettleSubcooling";
1187        Brief   = "Model of a distillation column with steady condenser and dynamic reboiler.";
1188        Info            =
1189"== Specify ==
1190* the feed stream of each tray (Inlet);
1191* the Murphree eficiency for each tray (Emv);
1192* the pump pressure difference;
1193* the heat supllied in reboiler and condenser;
1194* the heat supllied in the top tank;
1195* the condenser pressure drop;
1196* the reboiler liquid outlet flow (OutletLiquid.F);
1197* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1198       
1199== Initial Conditions ==
1200* the TRAYS temperature (OutletLiquid.T);
1201* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1202* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1203       
1204* the top tank temperature (OutletLiquid.T);
1205* the top tank liquid level (Level);
1206* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1207       
1208* the reboiler temperature (OutletLiquid.T);
1209* the reboiler liquid level (Level);
1210* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1211";
1212       
1213PARAMETERS
1214        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Default = "on",Hidden=true);
1215
1216VARIABLES
1217#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1218# Column Vapour and Liquid Draw Sides
1219#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1220        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.41,Protected = true);
1221        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.45,Protected = true);
1222#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1223# Column Devices
1224#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1225        CONDENSER               as condenserSteady      (Brief="steady state condenser with subcooling");
1226        ACCUMULATOR             as tank_cylindrical     (Brief="vessel drum (layed cilinder)");
1227        SPLITTER                as splitter2                    (Brief="splitter which separate reflux and distillate");
1228        PUMP                    as pump                         (Brief="pump in reflux stream");
1229        REBOILER                as reboiler                     (Brief="kettle reboiler");
1230        alfaTopo                as Real;
1231#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1232# Heat Ports
1233#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1234in              HeatToCondenser         as power        (Brief="Heat supplied to Condenser", PosX=1, PosY=0.065, Protected=true);
1235in              HeatToReboiler          as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.905, Protected=true);
1236in              HeatToAccumulator       as power        (Brief="Heat supplied to Top Vessel", PosX=1, PosY=0.195, Protected=true);
1237#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1238# Column Model Connectors
1239#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1240in      ConnectorSplitterOut            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1241in      ConnectorReboilerLout           as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1242        ConnectorHeatReboiler           as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1243        ConnectorHeatCondenser          as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1244        ConnectorHeatAccumulator        as power        (Brief="Connector for Heat supplied to TopVessel", Hidden=true);
1245#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1246# Column Top and Bottom product
1247#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1248out     LiquidDistillate as liquid_stream       (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.24);
1249out     BottomProduct    as liquid_stream       (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
1250
1251EQUATIONS
1252
1253#Heat Connectors
1254HeatToCondenser         = ConnectorHeatCondenser;
1255HeatToReboiler          = ConnectorHeatReboiler;
1256HeatToAccumulator       = ConnectorHeatAccumulator;
1257
1258# Splitter Connector Equations
1259        ConnectorSplitterOut.T = LiquidDistillate.T;
1260        ConnectorSplitterOut.P = LiquidDistillate.P;
1261        ConnectorSplitterOut.F = LiquidDistillate.F;
1262        ConnectorSplitterOut.z = LiquidDistillate.z;
1263
1264# Reboiler Connector Equations
1265        ConnectorReboilerLout.T = BottomProduct.T;
1266        ConnectorReboilerLout.P = BottomProduct.P;
1267        ConnectorReboilerLout.F = BottomProduct.F;
1268        ConnectorReboilerLout.z = BottomProduct.z;
1269       
1270        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1271        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1272        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1273        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1274
1275        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1276        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1277        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1278        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1279
1280        VapourDrawOffFlow = VapourDrawOff.F;
1281        LiquidDrawOffFlow = LiquidDrawOff.F;
1282       
1283        switch CondenserVapourFlow
1284                case "on":
1285                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
1286                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1287                when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
1288               
1289                case "off":
1290                CONDENSER.InletVapour.F = 0 * 'mol/s';
1291                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
1292end     
1293
1294CONNECTIONS
1295#vapor
1296        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
1297        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
1298
1299#liquid
1300        CONDENSER.OutletLiquid                          to ACCUMULATOR.Inlet;   
1301        ACCUMULATOR.Outlet                                      to SPLITTER.Inlet;
1302        SPLITTER.Outlet2                        to PUMP.Inlet; 
1303        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
1304        TRAYS(NumberOfTrays).OutletLiquid       to REBOILER.InletLiquid;
1305
1306#Connectors
1307ConnectorHeatCondenser          to CONDENSER.InletQ;
1308ConnectorHeatReboiler           to REBOILER.InletQ;
1309ConnectorHeatAccumulator        to ACCUMULATOR.InletQ;
1310
1311SPLITTER.Outlet1 to ConnectorSplitterOut;
1312REBOILER.OutletLiquid   to ConnectorReboilerLout;
1313
1314end
1315
1316Model Rectifier as Section_ColumnBasic
1317
1318ATTRIBUTES
1319        Pallete         = true;
1320        Icon            = "icon/RefluxedCond";
1321        Brief           = "Model of a rectifier column with dynamic condenser.";
1322        Info            =
1323"== Specify ==
1324* the feed stream of each tray (Inlet);
1325* the Murphree eficiency for each tray Emv;
1326* the InletVapour stream of the bottom tray unless its flow;
1327* the pump pressure difference;
1328* the heat supllied in the condenser;
1329* the condenser vapor outlet flow (OutletVapour.F);
1330* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1331       
1332== Initial Conditions ==
1333* the TRAYS temperature (OutletLiquid.T);
1334* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1335* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1336       
1337* the condenser temperature (OutletLiquid.T);
1338* the condenser liquid level (Level);
1339* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1340";
1341
1342PARAMETERS
1343        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Default = "on",Hidden=true);
1344
1345VARIABLES
1346#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1347# Column Vapour and Liquid Draw Sides
1348#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1349        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.45,Protected = true);
1350        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.50,Protected = true);
1351#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1352# Column Devices
1353#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1354        CONDENSER       as condenser    (Brief="dymamic condenser without subcooling");
1355        SPLITTER        as splitter2            (Brief="splitter which separate reflux and distillate");
1356        PUMP            as pump                 (Brief="pump in reflux stream");
1357        alfaTopo        as Real;
1358#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1359# Column Top product
1360#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1361        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.66, PosY=0);
1362        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.24);
1363#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1364# Heat Port
1365#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1366        in      HeatToCondenser         as power (Brief="Heat supplied to Condenser",PosX=1, PosY=0.04, Protected = true);
1367#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1368# Column Bottom Outlets
1369#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1370        in      VapourInlet             as stream                       (Brief="Vapour Inlet in the section", PosX=0.07, PosY=1);
1371        out     LiquidOutlet    as liquid_stream        (Brief="Liquid Outlet in the section", PosX=0.32, PosY=1);
1372#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1373# Column Model Connectors
1374#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1375        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1376        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
1377                VapourConnector                 as stream       (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
1378                ConnectorHeatCondenser  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1379       
1380EQUATIONS
1381
1382switch CondenserVapourFlow
1383
1384        case "on":
1385                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
1386                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1387                when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
1388               
1389        case "off":
1390                CONDENSER.InletVapour.F = 0 * 'mol/s';
1391                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
1392
1393end     
1394
1395HeatToCondenser = ConnectorHeatCondenser;
1396
1397# Condenser Connector Equations
1398        ConnectorCondenserVout.T = VapourDistillate.T;
1399        ConnectorCondenserVout.P = VapourDistillate.P;
1400        ConnectorCondenserVout.F = VapourDistillate.F;
1401        ConnectorCondenserVout.z = VapourDistillate.z;
1402       
1403# Splitter Connector Equations
1404        ConnectorSplitterOut.T = LiquidDistillate.T;
1405        ConnectorSplitterOut.P = LiquidDistillate.P;
1406        ConnectorSplitterOut.F = LiquidDistillate.F;
1407        ConnectorSplitterOut.z = LiquidDistillate.z;
1408       
1409        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletLiquid.F;
1410        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
1411        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
1412        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
1413
1414        VapourConnector.F= VapourInlet.F;
1415        VapourConnector.T = VapourInlet.T;
1416        VapourConnector.P = VapourInlet.P;
1417        VapourConnector.z = VapourInlet.z;
1418        VapourConnector.v = VapourInlet.v;
1419        VapourConnector.h = VapourInlet.h;
1420
1421        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1422        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1423        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1424        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1425
1426        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1427        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1428        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1429        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1430
1431        VapourDrawOffFlow = VapourDrawOff.F;
1432        LiquidDrawOffFlow = LiquidDrawOff.F;
1433
1434CONNECTIONS
1435#vapor
1436        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
1437
1438#liquid
1439        CONDENSER.OutletLiquid  to SPLITTER.Inlet;     
1440        SPLITTER.Outlet2        to PUMP.Inlet; 
1441        PUMP.Outlet             to TRAYS(1).InletLiquid;
1442
1443#Connectors
1444ConnectorHeatCondenser  to CONDENSER.InletQ;
1445VapourConnector                 to TRAYS(NumberOfTrays).InletVapour;
1446SPLITTER.Outlet1                to ConnectorSplitterOut;
1447CONDENSER.OutletVapour          to ConnectorCondenserVout;
1448
1449end
1450
1451Model Rectifier_subcooling as Section_ColumnBasic
1452
1453ATTRIBUTES
1454        Pallete         = true;
1455        Icon            = "icon/RefluxedSubcooling";
1456        Brief           = "Model of a rectifier column with steady condenser.";
1457        Info            =
1458"== Specify ==
1459* the feed stream of each tray (Inlet);
1460* the Murphree eficiency for each tray Emv;
1461* the InletVapour stream of the bottom tray unless its flow;
1462* the pump head;
1463* the condenser pressure drop;
1464* the heat supllied in  the top tank;
1465* the heat supllied in condenser;
1466* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1467       
1468== Initial Conditions ==
1469* the TRAYS temperature (OutletLiquid.T);
1470* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1471* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1472       
1473* the top tank temperature (OutletLiquid.T);
1474* the top tank liquid level (Level);
1475* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1476";
1477       
1478PARAMETERS
1479        CondenserVapourFlow             as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
1480
1481VARIABLES
1482#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1483# Column Vapour and Liquid Draw Sides
1484#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1485        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.485,Protected = true);
1486        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.535,Protected = true);
1487#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1488# Column Devices
1489#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1490        CONDENSER               as condenserSteady      (Brief="steady state condenser with subcooling");
1491        ACCUMULATOR             as tank_cylindrical     (Brief="vessel drum (layed cilinder)");
1492        SPLITTER                as splitter2                    (Brief="plitter which separate reflux and distillate");
1493        PUMP                    as pump                         (Brief="pump in reflux stream");
1494        alfaTopo                as Real;
1495#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1496# Column Bottom outlets
1497#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1498        in      VapourInlet             as stream                       (Brief="Vapour Inlet in the section", PosX=0.07, PosY=1);
1499        out     LiquidOutlet    as liquid_stream        (Brief="Liquid Outlet in the section", PosX=0.32, PosY=1);
1500#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1501# Heat Ports
1502#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1503        in      HeatToCondenser         as power        (Brief="Heat supplied to Condenser", PosX=1, PosY=0.070, Protected=true);
1504        in      HeatToAccumulator       as power        (Brief="Heat supplied to Top Accumulator", PosX=1, PosY=0.23, Protected=true);
1505#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1506# Column Top Product
1507#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1508        out     LiquidDistillate                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.285);
1509#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1510# Column Connectors
1511#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1512in      ConnectorSplitterTop            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1513        VapourConnector                         as stream       (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
1514        ConnectorHeatCondenser          as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1515        ConnectorHeatAccumulator        as power        (Brief="Connector for Heat supplied to Top Accumulator", Hidden=true);
1516
1517EQUATIONS
1518#Heat Connectors
1519        HeatToCondenser         = ConnectorHeatCondenser;
1520        HeatToAccumulator       = ConnectorHeatAccumulator;
1521       
1522        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletLiquid.F;
1523        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
1524        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
1525        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
1526
1527        VapourConnector.F= VapourInlet.F;
1528        VapourConnector.T = VapourInlet.T;
1529        VapourConnector.P = VapourInlet.P;
1530        VapourConnector.z = VapourInlet.z;
1531        VapourConnector.v = VapourInlet.v;
1532        VapourConnector.h = VapourInlet.h;
1533       
1534# Splitter Connector Equations
1535        ConnectorSplitterTop.T = LiquidDistillate.T;
1536        ConnectorSplitterTop.P = LiquidDistillate.P;
1537        ConnectorSplitterTop.F = LiquidDistillate.F;
1538        ConnectorSplitterTop.z = LiquidDistillate.z;
1539
1540        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1541        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1542        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1543        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1544
1545        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1546        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1547        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1548        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1549
1550        VapourDrawOffFlow = VapourDrawOff.F;
1551        LiquidDrawOffFlow = LiquidDrawOff.F;
1552       
1553switch CondenserVapourFlow
1554
1555        case "on":
1556                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo *Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
1557                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1558        when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
1559               
1560        case "off":
1561                CONDENSER.InletVapour.F = 0 * 'mol/s';
1562        when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
1563
1564end     
1565
1566CONNECTIONS
1567#vapor
1568        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
1569
1570#liquid
1571        CONDENSER.OutletLiquid          to ACCUMULATOR.Inlet;   
1572        ACCUMULATOR.Outlet                                      to SPLITTER.Inlet;
1573        SPLITTER.Outlet2                to PUMP.Inlet; 
1574        PUMP.Outlet                                             to TRAYS(1).InletLiquid;
1575
1576#Connectors
1577        VapourConnector                         to TRAYS(NumberOfTrays).InletVapour;
1578        ConnectorHeatCondenser                  to CONDENSER.InletQ;
1579        SPLITTER.Outlet1        to ConnectorSplitterTop;
1580        ConnectorHeatAccumulator                        to ACCUMULATOR.InletQ;
1581
1582end
1583
1584Model Reboiled_Stripping_kettle as Section_ColumnBasic
1585       
1586ATTRIBUTES
1587        Pallete         = true;
1588        Icon            = "icon/ReboiledKettle";
1589        Brief           = "Model of a reboiled stripping column with dynamic reboiler.";
1590        Info            =
1591"== Specify ==
1592* the feed stream of each tray (Inlet);
1593* the Murphree eficiency for each tray Emv;
1594* the vapour flow leaving the top of the column;
1595* the InletLiquidiquid stream of the top tray;
1596* the heat supllied in the reboiler;
1597* the reboiler liquid outlet flow (OutletLiquid.F);
1598       
1599== Initial Conditions ==
1600* the TRAYS temperature (OutletLiquid.T);
1601* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1602* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1603       
1604* the reboiler temperature (OutletLiquid.T);
1605* the reboiler liquid level (Level);
1606* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1607";
1608
1609VARIABLES
1610#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1611# Column Vapour and Liquid Draw Sides
1612#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1613        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.28,Protected = true);
1614        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.33,Protected = true);
1615#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1616# Column Devices
1617#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
1618        REBOILER as reboiler (Brief="Kettle Reboiler");
1619#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1620# Heat Port
1621#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1622        in      HeatToReboiler  as power        (Brief="Heat supplied to Reboiler",PosX=1, PosY=0.865,Protected=true);
1623#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1624# Column Top Outlets
1625#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
1626        in      LiquidInlet             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.30, PosY=0);
1627        out     VapourOutlet    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.07, PosY=0);
1628#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1629# Column Bottom Product
1630#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1631        out     BottomProduct   as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.68, PosY=1);
1632#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1633# Column Connectors
1634#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1635        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1636                LiquidConnector                 as stream       (Brief="Liquid connection at the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
1637                ConnectorHeatReboiler   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1638
1639CONNECTIONS
1640#vapor
1641        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
1642       
1643#liquid
1644        TRAYS(NumberOfTrays).OutletLiquid to REBOILER.InletLiquid;
1645
1646#Connectors
1647REBOILER.OutletLiquid           to ConnectorReboilerLout;
1648LiquidConnector                 to TRAYS(1).InletLiquid;
1649ConnectorHeatReboiler   to REBOILER.InletQ;
1650
1651EQUATIONS
1652#Heat Connectors
1653        HeatToReboiler = ConnectorHeatReboiler;
1654       
1655        LiquidConnector.F= LiquidInlet.F;
1656        LiquidConnector.T = LiquidInlet.T;
1657        LiquidConnector.P = LiquidInlet.P;
1658        LiquidConnector.z = LiquidInlet.z;
1659        LiquidConnector.v = LiquidInlet.v;
1660        LiquidConnector.h = LiquidInlet.h;
1661       
1662        VapourOutlet.F= TRAYS(1).OutletVapour.F;
1663        VapourOutlet.T = TRAYS(1).OutletVapour.T;
1664        VapourOutlet.P = TRAYS(1).OutletVapour.P;
1665        VapourOutlet.z = TRAYS(1).OutletVapour.z;
1666       
1667# Reboiler Connector Equations
1668        ConnectorReboilerLout.T = BottomProduct.T;
1669        ConnectorReboilerLout.P = BottomProduct.P;
1670        ConnectorReboilerLout.F = BottomProduct.F;
1671        ConnectorReboilerLout.z = BottomProduct.z;
1672       
1673        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1674        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1675        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1676        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1677
1678        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1679        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1680        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1681        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1682
1683        VapourDrawOffFlow = VapourDrawOff.F;
1684        LiquidDrawOffFlow = LiquidDrawOff.F;
1685
1686end
1687
1688Model Reboiled_Stripping_thermosyphon as Section_ColumnBasic
1689
1690ATTRIBUTES
1691        Pallete         = true;
1692        Icon            = "icon/ReboiledThermosyphon";
1693        Brief           = "Model of a reboiled stripping column with steady reboiler.";
1694        Info            =
1695"== Specify ==
1696* the feed stream of each tray (Inlet);
1697* the Murphree eficiency for each tray (Emv);
1698* the vapour flow leaving the top of the column;
1699* the InletLiquidiquid stream of the top tray;
1700* the heat supllied in bottom tank;
1701* the heat supllied in the reboiler;
1702* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
1703       
1704== Initial Conditions ==
1705* the TRAYS temperature (OutletLiquid.T);
1706* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1707* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1708
1709* the bottom tank temperature (OutletLiquid.T);
1710* the bottom tank liquid level (Level);
1711* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1712";
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.28,Protected = true);
1719        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.33,Protected = true);
1720#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1721# Column Devices
1722#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1723        REBOILER                as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
1724        SPLITTER                as splitter2            (Brief="splitter which separate the bottom product and the stream to reboiler");
1725        ACCUMULATOR     as tank                         (Brief="vessel in the bottom of column");
1726#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1727# Heat Ports
1728#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1729        in      HeatToReboiler          as power        (Brief="Heat supplied to Reboiler",PosX=1, PosY=0.84,Protected=true);
1730        in      HeatToAccumulator       as power        (Brief="Heat supplied to Bottom Vessel",PosX=0, PosY=0.91,Protected=true);
1731#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1732# Column Top Outlets
1733#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1734        in      LiquidInlet             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.32, PosY=0);
1735        out     VapourOutlet    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.07, PosY=0);
1736#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1737# Column Bottom Product
1738#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1739        out     BottomProduct   as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.19, PosY=1);
1740        LiquidConnector         as stream                       (Brief="Liquid connection at the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
1741#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1742# Column Connectors
1743#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1744        in      ConnectorSplitterBottom         as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1745        ConnectorHeatReboiler                   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1746        ConnectorHeatAccumulator                as power        (Brief="Connector for Heat supplied to Bottom Accumulator", Hidden=true);
1747
1748CONNECTIONS
1749#vapor
1750        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
1751       
1752#liquid
1753        TRAYS(NumberOfTrays).OutletLiquid       to ACCUMULATOR.Inlet;
1754        ACCUMULATOR.Outlet                              to SPLITTER.Inlet;
1755        SPLITTER.Outlet2                                to REBOILER.InletLiquid;
1756
1757#Connectors
1758LiquidConnector                         to TRAYS(1).InletLiquid;
1759ConnectorHeatReboiler           to REBOILER.InletQ;
1760ConnectorHeatAccumulator        to ACCUMULATOR.InletQ;
1761SPLITTER.Outlet1                        to ConnectorSplitterBottom;
1762
1763EQUATIONS
1764#Heat Connectors
1765        HeatToReboiler  = ConnectorHeatReboiler;
1766        HeatToAccumulator       = ConnectorHeatAccumulator;
1767       
1768        ConnectorSplitterBottom.T = BottomProduct.T;
1769        ConnectorSplitterBottom.P = BottomProduct.P;
1770        ConnectorSplitterBottom.F = BottomProduct.F;
1771        ConnectorSplitterBottom.z = BottomProduct.z;
1772       
1773        LiquidConnector.F= LiquidInlet.F;
1774        LiquidConnector.T = LiquidInlet.T;
1775        LiquidConnector.P = LiquidInlet.P;
1776        LiquidConnector.z = LiquidInlet.z;
1777        LiquidConnector.v = LiquidInlet.v;
1778        LiquidConnector.h = LiquidInlet.h;
1779       
1780        VapourOutlet.F= TRAYS(1).OutletVapour.F;
1781        VapourOutlet.T = TRAYS(1).OutletVapour.T;
1782        VapourOutlet.P = TRAYS(1).OutletVapour.P;
1783        VapourOutlet.z = TRAYS(1).OutletVapour.z;
1784       
1785        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1786        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1787        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1788        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1789
1790        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1791        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1792        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1793        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1794
1795        VapourDrawOffFlow = VapourDrawOff.F;
1796        LiquidDrawOffFlow = LiquidDrawOff.F;
1797
1798end
1799
1800Model ReactiveDistillation
1801       
1802ATTRIBUTES
1803        Pallete         = true;
1804        Icon            = "icon/DistillationReac";
1805        Brief           = "Model of a reactive distillation column with dynamic condenser and reboiler.";
1806        Info            =
1807"== Specify ==
1808* the reaction related variables for each tray, condenser and reboiler;
1809* the feed stream of each tray (Inlet);
1810* the Murphree eficiency for each tray Emv;
1811* the pump pressure difference;
1812* the heat supllied in reboiler and condenser;
1813* the condenser vapor outlet flow (OutletVapour.F);
1814* the reboiler liquid outlet flow (OutletLiquid.F);
1815* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1816       
1817== Initial Conditions ==
1818* the TRAYS temperature (OutletLiquid.T);
1819* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1820* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1821       
1822* the condenser temperature (OutletLiquid.T);
1823* the condenser liquid level (Level);
1824* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1825       
1826* the reboiler temperature (OutletLiquid.T);
1827* the reboiler liquid level (Level);
1828* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1829";
1830       
1831PARAMETERS
1832        outer PP        as Plugin       (Type="PP");
1833        outer NComp as Integer  (Brief="Number of Components");
1834#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1835# Section Column Feed Tray - Side Streams  Location and Numbering
1836#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1837        NumberOfTrays                                           as Integer      (Brief="Number of TRAYS", Default=2);
1838        FeedTrayIndex(NumberOfTrays)            as Integer      (Brief="Feed Tray Index", Default=0,Hidden=true);
1839        LiqSideTrayIndex(NumberOfTrays)         as Integer      (Brief="Liquid Side Tray Index", Default=0,Hidden=true);
1840        VapSideTrayIndex(NumberOfTrays)         as Integer      (Brief="Vapour Side Tray Index", Default=0,Hidden=true);
1841        FeedTrayLocation                                        as Integer      (Brief="Feed tray Location", Default=2);
1842        LiquidSideStreamLocation                        as Integer      (Brief="Liquid Side Stream Location", Default=2);
1843        VapourSideStreamLocation                        as Integer      (Brief="Vapour Side Stream Location", Default=2);
1844#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1845# Section Column Flow Model for Liquid and Vapour
1846#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1847        VapourFlow              as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
1848        TrayVapourFlow  as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
1849        TrayLiquidFlow  as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
1850        alfacond                as Real;
1851#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1852# Section Column Tray Geometry and Auxiliar Parameters
1853#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1854        V               as volume               (Brief="Total Volume of the tray",Hidden=true);
1855        Q               as power                (Brief="Rate of heat supply",Hidden=true);
1856        Ap              as area                 (Brief="Plate area = Atray - Adowncomer",Hidden=true);
1857        Ah              as area                 (Brief="Total holes area",Hidden=true);
1858        lw              as length               (Brief="Weir length",Hidden=true);
1859        g               as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
1860        hw              as length               (Brief="Weir height",Hidden=true);
1861        beta    as fraction     (Brief="Aeration fraction");
1862        alfa    as fraction     (Brief="Dry pressure drop coefficient");
1863
1864        VolumeOfTray            as volume               (Brief="Total Volume of the tray");
1865        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
1866        PlateArea                       as area                 (Brief="Plate area = Atray - Adowncomer");
1867        HolesArea                       as area                 (Brief="Total holes area");
1868        WeirLength                      as length               (Brief="Weir length");
1869        WeirHeight                      as length               (Brief="Weir height");
1870
1871        stoic(NComp)    as Real(Brief="Stoichiometric matrix");
1872        Hr                                              as energy_mol;
1873       
1874SET
1875
1876        FeedTrayIndex(FeedTrayLocation)         =1;
1877        VapSideTrayIndex(FeedTrayLocation)      =1;
1878        LiqSideTrayIndex(FeedTrayLocation)      =1;
1879
1880        V=VolumeOfTray;
1881        Q=HeatSupply;
1882        Ap=PlateArea;
1883        Ah=HolesArea;
1884        lw=WeirLength;
1885        hw=WeirHeight ;
1886       
1887VARIABLES
1888#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1889# Tray Initialization For the Whole Column Section
1890#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1891        INITIALIZATION          as InitializeSection    (Brief = "Column Model Initialization");
1892#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1893# Column Feed - Side Stream Flow and Murphree Efficiency
1894#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1895        in      FeedTray                        as stream       (Brief="Feed stream", PosX=0, PosY=0.55);
1896                VapourDrawOffFlow       as flow_mol (Brief = "Stream Molar Flow Rate");
1897                LiquidDrawOffFlow   as flow_mol (Brief = "Stream Molar Flow Rate");
1898                MurphreeEff             as Real         (Brief = "Murphree efficiency");
1899#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1900# Column Vapour and Liquid Draw Sides
1901#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1902        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.395,Protected = true);
1903        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.44,Protected = true);
1904#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1905# Heat Ports
1906#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1907        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.89);
1908        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", PosX=1, PosY=0.07);
1909#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1910# Column Devices
1911#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1912        TRAYS(NumberOfTrays)    as trayReac;
1913        CONDENSER                               as condenserReact;
1914        REBOILER                                as reboilerReact;
1915        SPLITTER                                as splitter2;
1916        PUMP                                    as pump;
1917#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1918# Column Outlets
1919#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1920        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Condenser", PosX=0.59, PosY=0);
1921        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Splitter", PosX=1, PosY=0.23);
1922        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
1923#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1924# Column Connectors
1925#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1926in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
1927in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1928in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1929#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1930# Column Control Ports
1931#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1932        out     TRI as control_signal   (Brief="Temperature of Reboiler Indicator", PosX=1, PosY=0.83);
1933        out     LRI as control_signal   (Brief="Level of Reboiler Indicator", PosX=1, PosY=0.855);
1934        out     TCI as control_signal   (Brief="Temperature of Condenser Indicator", PosX=1, PosY=0.01);
1935        out     LCI as control_signal   (Brief="Level of Condenser Indicator", PosX=1, PosY=0.04);
1936
1937CONNECTIONS
1938#vapor
1939        REBOILER.OutletVapour                                   to TRAYS(NumberOfTrays).InletVapour;
1940        TRAYS(1).OutletVapour                                   to CONDENSER.InletVapour;
1941        TRAYS([2:NumberOfTrays]).OutletVapour   to TRAYS([1:NumberOfTrays-1]).InletVapour;
1942
1943#liquid
1944        CONDENSER.OutletLiquid                                  to SPLITTER.Inlet;     
1945        SPLITTER.Outlet2                                        to PUMP.Inlet;
1946        PUMP.Outlet                                             to TRAYS(1).InletLiquid;
1947        TRAYS([1:NumberOfTrays-1]).OutletLiquid         to TRAYS([2:NumberOfTrays]).InletLiquid;
1948        TRAYS(NumberOfTrays).OutletLiquid               to REBOILER.InletLiquid;
1949
1950#Connectors
1951        CONDENSER.OutletVapour  to ConnectorCondenserVout;
1952        SPLITTER.Outlet1        to ConnectorSplitterOut;
1953        REBOILER.OutletLiquid   to ConnectorReboilerLout;
1954
1955INITIAL
1956#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1957# Tray Initialization
1958#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1959for i in 1:NumberOfTrays do
1960
1961"The initial temperature of the TRAYS"
1962        TRAYS(i).OutletLiquid.T = INITIALIZATION.TopTemperature+(INITIALIZATION.BottomTemperature-INITIALIZATION.TopTemperature)*((i-1)/(NumberOfTrays-1));
1963
1964"The initial Level of the TRAYS"
1965        TRAYS(i).Level = INITIALIZATION.LevelFraction*hw;
1966end
1967
1968for i in 1:NComp-1 do
1969
1970for j in 1:NumberOfTrays do
1971
1972"The initial composition of the TRAYS - Normalized"
1973        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));
1974end
1975
1976end
1977
1978EQUATIONS
1979
1980for i in [1:NumberOfTrays] do
1981
1982"Murphree Efficiency"
1983        TRAYS(i).OutletVapour.z =  MurphreeEff * (TRAYS(i).yideal - TRAYS(i).InletVapour.z) + TRAYS(i).InletVapour.z;
1984       
1985"Energy Holdup"
1986        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletLiquid.h + TRAYS(i).MV*TRAYS(i).OutletVapour.h - TRAYS(i).OutletLiquid.P*V;
1987
1988"Component Molar Balance"
1989        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-
1990        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;
1991       
1992"Energy Balance"
1993        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
1994        -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;
1995
1996"Level of clear liquid over the weir"
1997        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/Ap;
1998
1999"Geometry Constraint"
2000        V = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
2001
2002end
2003
2004switch VapourFlow
2005                case "on":
2006                "Pressure Drop through the condenser"
2007                CONDENSER.InletVapour.F*TRAYS(1).vV / 'm^2' =
2008                        sqrt((TRAYS(1).OutletVapour.P - CONDENSER.OutletLiquid.P + 1e-8 * 'atm')/(TRAYS(1).rhoV*alfacond));
2009                when TRAYS(1).OutletVapour.P < CONDENSER.OutletLiquid.P switchto "off";
2010               
2011                case "off":
2012                "Prato selado"
2013                CONDENSER.InletVapour.F = 0.0 * 'mol/s';
2014                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-3 * 'atm' switchto "on";
2015        end
2016
2017for i in [1:NumberOfTrays] do
2018
2019        switch TrayLiquidFlow
2020                case "on":
2021                "Francis Equation"
2022                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'1/s'*lw*((TRAYS(i).Level-(beta*hw)+1e-6*'m')/(beta))^2;
2023                when TRAYS(i).Level < (beta * hw) switchto "off";
2024               
2025                case "off":
2026                "Low level"
2027                TRAYS(i).OutletLiquid.F = 0 * 'mol/h';
2028                when TRAYS(i).Level > (beta * hw) + 1e-6*'m' switchto "on";
2029        end
2030
2031        switch TrayVapourFlow
2032                case "on":
2033                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;
2034                when TRAYS(i).InletVapour.P < TRAYS(i).OutletVapour.P + TRAYS(i).Level*g*TRAYS(i).rhoL switchto "off";
2035               
2036                case "off":
2037                TRAYS(i).InletVapour.F = 0 * 'mol/s';
2038                when TRAYS(i).InletVapour.P > TRAYS(i).OutletVapour.P + TRAYS(i).Level*g*TRAYS(i).rhoL + 3e-2 * 'atm' switchto "on";
2039        end
2040
2041end
2042
2043# Connecting Trays
2044        FeedTray.F*FeedTrayIndex= TRAYS.Inlet.F;
2045        FeedTray.T = TRAYS.Inlet.T;
2046        FeedTray.P = TRAYS.Inlet.P;
2047        FeedTray.z = TRAYS.Inlet.z;
2048        FeedTray.v = TRAYS.Inlet.v;
2049        FeedTray.h = TRAYS.Inlet.h;
2050
2051        HeatToReboiler  = REBOILER.InletQ;
2052        HeatToCondenser = CONDENSER.InletQ;
2053
2054"Reboiler Temperature indicator"
2055        TRI * 'K' = REBOILER.OutletLiquid.T;
2056
2057"Reboiler Level indicator"
2058        LRI*REBOILER.V = REBOILER.Level*REBOILER.Across;
2059
2060"Condenser Temperature indicator"
2061        TCI * 'K' = CONDENSER.OutletLiquid.T;
2062
2063"Condenser Level indicator"
2064        LCI*CONDENSER.V = CONDENSER.Level*CONDENSER.Across;
2065
2066# Condenser Connector Equations
2067        ConnectorCondenserVout.T = VapourDistillate.T;
2068        ConnectorCondenserVout.P = VapourDistillate.P;
2069        ConnectorCondenserVout.F = VapourDistillate.F;
2070        ConnectorCondenserVout.z = VapourDistillate.z;
2071
2072# Splitter Connector Equations
2073        ConnectorSplitterOut.T = LiquidDistillate.T;
2074        ConnectorSplitterOut.P = LiquidDistillate.P;
2075        ConnectorSplitterOut.F = LiquidDistillate.F;
2076        ConnectorSplitterOut.z = LiquidDistillate.z;
2077
2078# Reboiler Connector Equations
2079        ConnectorReboilerLout.T = BottomProduct.T;
2080        ConnectorReboilerLout.P = BottomProduct.P;
2081        ConnectorReboilerLout.F = BottomProduct.F;
2082        ConnectorReboilerLout.z = BottomProduct.z;
2083
2084        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
2085        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
2086        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
2087        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
2088
2089        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
2090        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
2091        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
2092        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
2093
2094        VapourDrawOffFlow = VapourDrawOff.F;
2095        LiquidDrawOffFlow = LiquidDrawOff.F;
2096
2097end
2098
2099Model Packed_Section_ColumnBasic
2100        ATTRIBUTES
2101        Pallete         = false;
2102        Icon            = "icon/PackedSectionColumn";
2103        Brief           = "Model of a packed column section.";
2104        Info            =
2105"== Model of a packed column section containing ==
2106* NStages theoretical stages.
2107       
2108== Specify ==
2109* the feed stream of each tray (Inlet);
2110* the InletLiquid stream of the top tray;
2111* the InletVapour stream of the bottom tray;
2112* the total pressure drop (dP) of the section.
2113       
2114== Initial Conditions ==
2115* the stages temperature (OutletLiquid.T);
2116* the stages liquid holdup;
2117* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
2118";
2119       
2120PARAMETERS
2121
2122        outer PP                as Plugin(Brief = "External Physical Properties", Type="PP");
2123        outer NComp     as Integer;
2124       
2125        NumberOfStages                                  as Integer      (Brief="Number of Stages", Default=3);
2126        FeedStageIndex(NumberOfStages)  as Integer      (Brief="Number of Stages", Default=0,Hidden=true);
2127        FeedStageLocation                               as Integer      (Brief="Feed Stage Location", Default=2);
2128       
2129        PackingHeight           as length               (Brief="Height of packing");
2130        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
2131        ColumnDiameter          as length               (Brief="Column diameter");
2132        VoidFraction            as Real                 (Brief="Void fraction of packing, m^3/m^3");
2133        ResistanceCoeff         as positive     (Brief="Resistance coefficient on the liquid load", Default=1);
2134        AreaPerPackingVol       as Real                 (Brief="surface area per packing volume", Unit='m^2/m^3');
2135       
2136        V                               as volume               (Brief="Total Volume of the tray",Hidden=true);
2137        g                               as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
2138        hs                              as length               (Brief="Height of the packing stage",Hidden=true);
2139        ColumnArea              as area                 (Brief="Column Sectional Cross Area",Hidden=true);
2140
2141VARIABLES
2142#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2143# Stages Initialization For the Whole Column Section
2144#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2145        INITIALIZATION          as InitializeStage      (Brief = "Column Model Initialization");
2146        in      FeedStage       as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
2147       
2148        STAGES(NumberOfStages) as packedStage;
2149        PressureDrop               as pressure;
2150       
2151SET
2152        FeedStageIndex(FeedStageLocation) =1;
2153       
2154        ColumnArea = ColumnDiameter^2*3.14159*0.25;
2155        hs =PackingHeight/NumberOfStages;       
2156        V = hs * ColumnArea;
2157       
2158CONNECTIONS
2159
2160        STAGES([2:NumberOfStages]).OutletVapour                 to STAGES([1:NumberOfStages-1]).InletVapour;
2161        STAGES([1:NumberOfStages-1]).OutletLiquid       to STAGES([2:NumberOfStages]).InletLiquid;
2162
2163EQUATIONS
2164# Connecting STAGES
2165        FeedStage.F*FeedStageIndex= STAGES.Inlet.F;
2166        FeedStage.T = STAGES.Inlet.T;
2167        FeedStage.P = STAGES.Inlet.P;
2168        FeedStage.z = STAGES.Inlet.z;
2169        FeedStage.v = STAGES.Inlet.v;
2170        FeedStage.h = STAGES.Inlet.h;
2171
2172        STAGES.deltaP = PressureDrop/NumberOfStages;
2173
2174for i in [1:NumberOfStages] do
2175
2176"Energy Balance"
2177        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
2178        - STAGES(i).OutletVapour.F*STAGES(i).OutletVapour.h + HeatSupply );
2179       
2180"Energy Holdup"
2181        STAGES(i).E = STAGES(i).ML*STAGES(i).OutletLiquid.h + STAGES(i).MV*STAGES(i).OutletVapour.h - STAGES(i).OutletLiquid.P*V;
2182       
2183"Geometry Constraint"
2184        V*VoidFraction= STAGES(i).ML*STAGES(i).vL + STAGES(i).MV*STAGES(i).vV;
2185       
2186"Volume flow rate of vapor, m^3/m^2/s"
2187        STAGES(i).uV * ((ColumnArea)*VoidFraction - STAGES(i).Al) = STAGES(i).OutletVapour.F * STAGES(i).vV;
2188       
2189"Liquid holdup"
2190        STAGES(i).hl = STAGES(i).ML*STAGES(i).vL/V/VoidFraction;
2191       
2192"Particle diameter"
2193        STAGES(i).dp = 6 * (1-VoidFraction)/AreaPerPackingVol;
2194       
2195"Wall Factor"
2196        STAGES(i).invK = (1 + (2*STAGES(i).dp/(3*ColumnDiameter*(1-VoidFraction))));
2197       
2198"Reynolds number of the vapor stream"
2199        STAGES(i).Rev*STAGES(i).invK = STAGES(i).dp*STAGES(i).uV*STAGES(i).rhoV / (STAGES(i).miV*(1-VoidFraction));
2200       
2201"Pressure drop and Vapor flow"
2202        STAGES(i).deltaP/hs  = ResistanceCoeff*AreaPerPackingVol*STAGES(i).uV^2*STAGES(i).rhoV*STAGES(i).invK / (2*(VoidFraction-STAGES(i).hl)^3);
2203
2204"Liquid holdup"
2205        STAGES(i).hl = (12*STAGES(i).miL*AreaPerPackingVol^2*STAGES(i).uL/STAGES(i).rhoL/g)^1/3;
2206
2207"Area occupied by the liquid"
2208        STAGES(i).Al = STAGES(i).ML*STAGES(i).vL/hs;
2209
2210end
2211
2212INITIAL
2213
2214for i in 1:NumberOfStages do
2215
2216"The initial temperature of the STAGES"
2217        STAGES(i).OutletLiquid.T = INITIALIZATION.TopStageTemperature+(INITIALIZATION.BottomStageTemperature-INITIALIZATION.TopStageTemperature)*((i-1)/(NumberOfStages-1));
2218
2219"The Liquid Holdup of the STAGES"
2220        STAGES(i).ML = INITIALIZATION.LiquidMolarHoldup;
2221
2222end
2223
2224for i in 1:NComp-1 do
2225       
2226for j in 1:NumberOfStages do
2227
2228"The initial composition of the TRAYS"
2229        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));
2230
2231end
2232
2233end
2234
2235end
2236
2237Model Packed_Section_Column as Packed_Section_ColumnBasic
2238
2239        ATTRIBUTES
2240        Pallete         = true;
2241        Icon            = "icon/PackedSectionColumn";
2242        Brief           = "Model of a packed column section.";
2243        Info            =
2244"== Model of a packed column section containing ==
2245* NStages theoretical stages.
2246       
2247== Specify ==
2248* the feed stream of each tray (Inlet);
2249* the InletLiquid stream of the top tray;
2250* the InletVapour stream of the bottom tray;
2251* the total pressure drop (dP) of the section.
2252       
2253== Initial Conditions ==
2254* the stages temperature (OutletLiquid.T);
2255* the stages liquid holdup;
2256* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
2257";
2258
2259VARIABLES
2260
2261        in              LiquidInlet             as      stream                          (Brief="Liquid Inlet in the section", PosX=0.70, PosY=0);
2262        out     VapourOutlet            as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.30, PosY=0);
2263       
2264        in              VapourInlet             as stream                               (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1);
2265        out     LiquidOutlet            as liquid_stream                (Brief="Liquid Outlet in the section", PosX=0.70, PosY=1);
2266       
2267        LiquidConnector as stream       (Brief="Liquid connection at the middle STAGES", PosX=0.75, PosY=1,Hidden=true);
2268        VapourConnector as stream       (Brief="Vapour connection at the middle STAGES", PosX=0.55, PosY=0,Hidden=true);
2269
2270CONNECTIONS
2271
2272        LiquidConnector to STAGES(1).InletLiquid;
2273        VapourConnector to STAGES(NumberOfStages).InletVapour;
2274       
2275EQUATIONS
2276
2277        LiquidConnector.F= LiquidInlet.F;
2278        LiquidConnector.T = LiquidInlet.T;
2279        LiquidConnector.P = LiquidInlet.P;
2280        LiquidConnector.z = LiquidInlet.z;
2281        LiquidConnector.v = LiquidInlet.v;
2282        LiquidConnector.h = LiquidInlet.h;
2283       
2284        VapourConnector.F= VapourInlet.F;
2285        VapourConnector.T = VapourInlet.T;
2286        VapourConnector.P = VapourInlet.P;
2287        VapourConnector.z = VapourInlet.z;
2288        VapourConnector.v = VapourInlet.v;
2289        VapourConnector.h = VapourInlet.h;
2290       
2291        LiquidOutlet.F= STAGES(NumberOfStages).OutletLiquid.F;
2292        LiquidOutlet.T = STAGES(NumberOfStages).OutletLiquid.T;
2293        LiquidOutlet.P = STAGES(NumberOfStages).OutletLiquid.P;
2294        LiquidOutlet.z = STAGES(NumberOfStages).OutletLiquid.z;
2295       
2296        VapourOutlet.F= STAGES(1).OutletVapour.F;
2297        VapourOutlet.T = STAGES(1).OutletVapour.T;
2298        VapourOutlet.P = STAGES(1).OutletVapour.P;
2299        VapourOutlet.z = STAGES(1).OutletVapour.z;
2300
2301end
2302
2303Model PackedDistillation_kettle_cond as Packed_Section_ColumnBasic
2304        ATTRIBUTES
2305        Pallete         = true;
2306        Icon            = "icon/PackedDistillationKettleCond";
2307        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
2308        Info            =
2309"== Specify ==
2310* the feed stream of each tray (Inlet);
2311* the pump pressure difference;
2312* the total pressure drop (dP) of the packing;
2313* the heat supllied in reboiler and condenser;
2314* the condenser vapor outlet flow (OutletVapour.F);
2315* the reboiler liquid outlet flow (OutletLiquid.F);
2316* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
2317       
2318== Initial Conditions ==
2319* the stages temperature (OutletLiquid.T);
2320* the stages initial molar holdup;
2321* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each stage;
2322       
2323* the condenser temperature (OutletLiquid.T);
2324* the condenser liquid level (Level);
2325* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
2326       
2327* the reboiler temperature (OutletLiquid.T);
2328* the reboiler liquid level (Level);
2329* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
2330";
2331       
2332PARAMETERS
2333
2334        VapourFlow as Switcher  (Valid = ["on", "off"], Hidden = true ,Default = "on");
2335       
2336VARIABLES
2337#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2338# Column Devices
2339#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2340        CONDENSER       as condenser    (Brief="dymamic condenser");
2341        REBOILER        as reboiler             (Brief="kettle reboiler");
2342        SPLITTER        as splitter2            (Brief="splitter which separate reflux and distillate");
2343        PUMP            as pump                 (Brief="pump in reflux stream");
2344#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2345# Heat Ports
2346#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2347        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler",Protected = true, PosX=1, PosY=0.885);
2348        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", Protected = true, PosX=1, PosY=0.034);
2349#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2350# Column Products
2351#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2352        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.66, PosY=0);
2353        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
2354        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.68, PosY=1);
2355#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2356# Column Connectors
2357#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
2358        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
2359        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
2360        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
2361                ConnectorHeatReboiler   as power        (Brief="Heat supplied to Reboiler", Hidden=true);
2362                ConnectorHeatCondenser  as power        (Brief="Heat supplied to Condenser", Hidden=true);
2363
2364CONNECTIONS
2365
2366#vapor
2367        REBOILER.OutletVapour           to STAGES(NumberOfStages).InletVapour;
2368        STAGES(1).OutletVapour          to CONDENSER.InletVapour;
2369
2370#liquid
2371        CONDENSER.OutletLiquid                          to SPLITTER.Inlet;     
2372        SPLITTER.Outlet2                                to PUMP.Inlet;
2373        PUMP.Outlet                                     to STAGES(1).InletLiquid;
2374        STAGES(NumberOfStages).OutletLiquid     to REBOILER.InletLiquid;
2375
2376#Connectors
2377ConnectorHeatReboiler   to REBOILER.InletQ;
2378ConnectorHeatCondenser  to CONDENSER.InletQ;
2379
2380CONDENSER.OutletVapour          to ConnectorCondenserVout;
2381SPLITTER.Outlet1                to ConnectorSplitterOut;
2382REBOILER.OutletLiquid           to ConnectorReboilerLout;
2383
2384EQUATIONS
2385        HeatToReboiler  = ConnectorHeatReboiler;
2386        HeatToCondenser = ConnectorHeatCondenser;
2387       
2388# Condenser Connector Equations
2389        ConnectorCondenserVout.T = VapourDistillate.T;
2390        ConnectorCondenserVout.P = VapourDistillate.P;
2391        ConnectorCondenserVout.F = VapourDistillate.F;
2392        ConnectorCondenserVout.z = VapourDistillate.z;
2393
2394# Splitter Connector Equations
2395        ConnectorSplitterOut.T = LiquidDistillate.T;
2396        ConnectorSplitterOut.P = LiquidDistillate.P;
2397        ConnectorSplitterOut.F = LiquidDistillate.F;
2398        ConnectorSplitterOut.z = LiquidDistillate.z;
2399
2400# Reboiler Connector Equations
2401        ConnectorReboilerLout.T = BottomProduct.T;
2402        ConnectorReboilerLout.P = BottomProduct.P;
2403        ConnectorReboilerLout.F = BottomProduct.F;
2404        ConnectorReboilerLout.z = BottomProduct.z;
2405
2406switch VapourFlow
2407        case "on":
2408                STAGES(NumberOfStages).InletVapour.F*STAGES(NumberOfStages).vV = sqrt((REBOILER.OutletVapour.P - STAGES(NumberOfStages).OutletVapour.P)/
2409                                        (STAGES(NumberOfStages).rhoV*ResistanceCoeff*20))*(ColumnArea*VoidFraction - STAGES(NumberOfStages).Al);
2410                when STAGES(NumberOfStages).InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
2411
2412        case "off":
2413                STAGES(NumberOfStages).InletVapour.F = 0 * 'mol/s';
2414                when REBOILER.OutletVapour.P > STAGES(NumberOfStages).OutletVapour.P + 1e-1 * 'atm' switchto "on";
2415end
2416
2417end
2418
Note: See TracBrowser for help on using the repository browser.