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

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

updates (tank/reboiler/condenser/column)

File size: 93.3 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 InitializeSection
41
42ATTRIBUTES
43        Pallete = false;
44        Brief = "Initial conditions for column section.";
45
46PARAMETERS
47        outer NComp             as Integer      (Brief="Number of components");
48
49        TopTemperature          as temperature  (Brief = "Tray Temperature at Column Top", Default = 300);
50        BottomTemperature       as temperature  (Brief = "Tray Temperature at Column Bottom", Default = 330);
51        LevelFraction           as fraction             (Brief = "Tray Level Fraction", Default = 0.5);
52
53        TopComposition(NComp)           as fraction     (Brief = "Component Molar Fraction at Column Top", Default = 0.30);
54        BottomComposition(NComp)        as fraction     (Brief = "Component Molar Fraction at Column Bottom", Default = 0.30);
55
56end
57
58Model InitializeStage
59
60ATTRIBUTES
61        Pallete = false;
62        Brief = "Initial conditions for Packed column section.";
63
64PARAMETERS
65        outer NComp             as Integer      (Brief="Number of components");
66
67        TopStageTemperature             as temperature  (Brief = "Tray Temperature at Column Top", Default = 300);
68        BottomStageTemperature          as temperature  (Brief = "Tray Temperature at Column Bottom", Default = 300);
69       
70        TopStageComposition(NComp)              as fraction     (Brief = "Component Molar Fraction at Top");
71        BottomStageComposition(NComp)   as fraction     (Brief = "Component Molar Fraction at Bottom");
72        LiquidMolarHoldup                               as mol          (Brief="Molar liquid holdup", Default=0.01);
73
74end
75
76Model Section_ColumnBasic
77
78ATTRIBUTES
79        Pallete         = false;
80        Icon            = "icon/SectionColumn";
81        Brief   = "Model of a column section.";
82        Info            =
83"Model of a basic column section containing a vetor of TRAYS numbered from the top-down.";
84
85PARAMETERS
86        outer PP                                                        as Plugin                       (Brief="External Physical Properties", Type="PP");
87        outer NComp                                             as Integer                      (Brief="Number of components");
88#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
89# Section Column Feed Tray - Side Streams  Location and Numbering
90#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
91        NumberOfTrays                                           as Integer                      (Brief="Number of trays", Default=8);
92        FeedTrayIndex(NumberOfTrays)            as Integer                      (Brief="Feed Tray Index", Default=0,Hidden=true);
93        LiqSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Liquid Side Tray Index", Default=0,Hidden=true);
94        VapSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Vapour Side Tray Index", Default=0,Hidden=true);
95        FeedTrayLocation                                        as Integer                      (Brief="Feed tray Location", Default=2);
96        LiquidSideStreamLocation                        as Integer                      (Brief="Liquid Side Stream Location", Default=2);
97        VapourSideStreamLocation                        as Integer                      (Brief="Vapour Side Stream Location", Default=2);
98        g                                                                       as acceleration         (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
99        Mw(NComp)                                                       as molweight            (Brief="Component Mol Weight",Hidden=true);
100#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
101# Section Column Flow Model for Liquid and Vapour
102#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
103        VapourFlowModel         as Switcher     (Valid = ["Reepmeyer", "Feehery_Fv", "Roffel_Fv", "Klingberg", "Wang_Fv", "Elgue"], Default = "Reepmeyer");
104        LiquidFlowModel         as Switcher     (Valid = ["default", "Wang_Fl", "Olsen", "Feehery_Fl", "Roffel_Fl"], Default = "default");
105#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
106# Section Column Tray Geometry and Auxiliar Parameters
107#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
108        VolumeOfTray            as volume               (Brief="Total Volume of the tray");
109        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
110        PlateArea                       as area                 (Brief="Plate area = Atray - Adowncomer");
111        HolesArea                       as area                 (Brief="Total holes area");
112        WeirLength                      as length               (Brief="Weir length");
113        WeirHeight                      as length               (Brief="Weir height");
114        FeeheryCoeff            as Real                 (Brief="Feeherys correlation coefficient", Unit='1/m^4', Default=1);
115        ElgueCoeff                      as Real                 (Brief="Elgues correlation coefficient", Unit='kg/m/mol^2', Default=1);
116        OlsenCoeff                      as Real                 (Brief="Olsens correlation coefficient", Default=1);
117        TrayLiquidPasses        as Real                 (Brief="Number of liquid passes in the tray", Default=1);
118       
119        V                               as volume               (Brief="Total Volume of the tray",Hidden=true);
120        Q                               as heat_rate    (Brief="Rate of heat supply",Hidden=true);
121        Ap                              as area                 (Brief="Plate area = Atray - Adowncomer",Hidden=true);
122        Ah                              as area                 (Brief="Total holes area",Hidden=true);
123        lw                              as length               (Brief="Weir length",Hidden=true);
124        hw                              as length               (Brief="Weir height",Hidden=true);
125        beta                    as fraction     (Brief="Aeration fraction");
126        alfa                    as fraction     (Brief="Dry pressure drop coefficient");
127        w                               as Real                 (Brief="Feeherys correlation coefficient", Unit='1/m^4', Default=1,Hidden=true);
128        btray                   as Real                 (Brief="Elgues correlation coefficient", Unit='kg/m/mol^2', Default=1,Hidden=true);
129        fw                              as Real                 (Brief="Olsens correlation coefficient", Default=1,Hidden=true);
130        Np                              as Real                 (Brief="Number of liquid passes in the tray", Default=1,Hidden=true);
131       
132        VapourFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
133        LiquidFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
134
135SET
136        FeedTrayIndex(FeedTrayLocation) =1;
137        VapSideTrayIndex(FeedTrayLocation) =1;
138        LiqSideTrayIndex(FeedTrayLocation) =1;
139        Mw = PP.MolecularWeight();
140
141        V=VolumeOfTray;
142        Q=HeatSupply;
143        Ap=PlateArea;
144        Ah=HolesArea;
145        lw=WeirLength;
146        hw=WeirHeight ;
147        w=FeeheryCoeff;
148        btray=ElgueCoeff;
149        fw=OlsenCoeff;
150        Np=TrayLiquidPasses;
151
152VARIABLES
153#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
154# Tray Initialization For the Whole Column Section
155#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
156        INITIALIZATION as InitializeSection (Brief = "Column Model Initialization");
157#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
158# Column Feed - Side Stream Flow and Murphree Efficiency
159#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
160        in      FeedTray                                as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
161                TRAYS(NumberOfTrays)    as tray                 (Brief="Number of trays in the Column Section");
162                VapourDrawOffFlow               as flow_mol     (Brief="Stream Molar Flow Rate");
163                LiquidDrawOffFlow               as flow_mol     (Brief="Stream Molar Flow Rate");
164                MurphreeEff                     as Real                 (Brief="Murphree efficiency for All Trays");
165
166CONNECTIONS
167#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
168# Connecting Intermediate Trays
169#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
170        TRAYS([2:NumberOfTrays]).OutletV        to TRAYS([1:NumberOfTrays-1]).InletV;
171        TRAYS([1:NumberOfTrays-1]).OutletL      to TRAYS([2:NumberOfTrays]).InletL;
172       
173INITIAL
174#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
175# Tray Initialization
176#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
177for i in 1:NumberOfTrays do
178
179"The initial temperature of the TRAYS"
180        TRAYS(i).OutletL.T = INITIALIZATION.TopTemperature+(INITIALIZATION.BottomTemperature-INITIALIZATION.TopTemperature)*((i-1)/(NumberOfTrays-1));
181
182"The initial Level of the TRAYS"
183        TRAYS(i).Level = INITIALIZATION.LevelFraction*hw;
184end
185
186for i in 1:NComp-1 do
187
188for j in 1:NumberOfTrays do
189
190"The initial composition of the TRAYS - Normalized"
191        TRAYS(j).OutletL.z(i) = INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) +(INITIALIZATION.BottomComposition(i)/sum(INITIALIZATION.BottomComposition)-INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) )*((j-1)/(NumberOfTrays-1));
192end
193
194end
195
196EQUATIONS
197#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
198# Equating Feed Tray Variables to Trays Variables
199#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
200"Feed Tray Inlet Flow" 
201        FeedTray.F*FeedTrayIndex= TRAYS.Inlet.F;
202
203"Feed Tray Inlet Temperature"
204        FeedTray.T = TRAYS.Inlet.T;
205
206"Feed Tray Inlet Pressure"
207        FeedTray.P = TRAYS.Inlet.P;
208
209"Feed Tray Inlet Composition"
210        FeedTray.z = TRAYS.Inlet.z;
211
212"Feed Tray Inlet Vapour Fraction"
213        FeedTray.v = TRAYS.Inlet.v;
214
215"Feed Tray Inlet Enthalpy"
216        FeedTray.h = TRAYS.Inlet.h;
217
218#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
219# Trays Equations
220#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
221
222for i in [1:NumberOfTrays] do
223
224"Murphree Efficiency"
225        TRAYS(i).OutletV.z =  MurphreeEff * (TRAYS(i).yideal - TRAYS(i).InletV.z) + TRAYS(i).InletV.z;
226
227"Level of clear liquid over the weir"
228        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/Ap;
229
230"Geometry Constraint"
231        V = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
232
233"Energy Holdup"
234        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletL.h + TRAYS(i).MV*TRAYS(i).OutletV.h - TRAYS(i).OutletL.P*V;
235
236"Energy Balance"
237        diff(TRAYS(i).E) = ( TRAYS(i).Inlet.F*TRAYS(i).Inlet.h + TRAYS(i).InletL.F*TRAYS(i).InletL.h + TRAYS(i).InletV.F*TRAYS(i).InletV.h- TRAYS(i).OutletL.F*TRAYS(i).OutletL.h - TRAYS(i).OutletV.F*TRAYS(i).OutletV.h
238        -TRAYS(i).VapourSideStream.F*TRAYS(i).VapourSideStream.h - TRAYS(i).LiquidSideStream.F*TRAYS(i).LiquidSideStream.h + Q );
239
240switch LiquidFlow
241                case "on":
242                        switch LiquidFlowModel
243                                case "default":
244                                "Francis Equation"
245                                TRAYS(i).OutletL.F*TRAYS(i).vL = 1.84*'1/s'*lw*((TRAYS(i).Level-(beta*hw))/(beta))^2;
246                       
247                                case "Wang_Fl":
248                                TRAYS(i).OutletL.F*TRAYS(i).vL = 1.84*'m^0.5/s'*lw*((TRAYS(i).Level-(beta*hw))/(beta))^1.5;
249                       
250                                case "Olsen":
251                                TRAYS(i).OutletL.F / 'mol/s'= lw*Np*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletV.z)/(0.665*fw)^1.5 * ((TRAYS(i).ML*sum(Mw*TRAYS(i).OutletL.z)/TRAYS(i).rhoL/Ap)-hw)^1.5 * 'm^0.5/mol';
252                       
253                                case "Feehery_Fl":
254                                TRAYS(i).OutletL.F = lw*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletL.z) * ((TRAYS(i).Level-hw)/750/'mm')^1.5 * 'm^2/s';
255                       
256                                case "Roffel_Fl":
257                                TRAYS(i).OutletL.F = 2/3*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletL.z)*lw*(TRAYS(i).ML*sum(Mw*TRAYS(i).OutletL.z)/(Ap*1.3)/TRAYS(i).rhoL)^1.5*sqrt(2*g/
258                                                        (2*(1 - 0.3593/'Pa^0.0888545'*abs(TRAYS(i).OutletV.F*sum(Mw*TRAYS(i).OutletV.z)/(Ap*1.3)/sqrt(TRAYS(i).rhoV))^0.177709)-1)); #/'(kg/m)^0.0888545/s^0.177709';
259                        end
260                when TRAYS(i).Level < (beta *hw) switchto "off";
261               
262                case "off":
263                "Low level"
264                TRAYS(i).OutletL.F = 0 * 'mol/h';
265                when TRAYS(i).Level > (beta * hw) + 1e-6*'m' switchto "on";
266        end
267       
268switch VapourFlow
269                case "on":
270                        switch VapourFlowModel
271                                case "Reepmeyer":
272                                TRAYS(i).InletV.F*TRAYS(i).vV = sqrt((TRAYS(i).InletV.P - TRAYS(i).OutletV.P)/(TRAYS(i).rhoV*alfa))*Ah;
273                       
274                                case "Feehery_Fv":
275                                TRAYS(i).InletV.F = TRAYS(i).rhoV/Ap/w/sum(Mw*TRAYS(i).OutletV.z) * sqrt(((TRAYS(i).InletV.P - TRAYS(i).OutletV.P)-(TRAYS(i).rhoV*g*TRAYS(i).ML*TRAYS(i).vL/Ap))/TRAYS(i).rhoV);
276                       
277                                case "Roffel_Fv":
278                                TRAYS(i).InletV.F^1.08 * 0.0013 * 'kg/m/mol^1.08/s^0.92*1e5' = (TRAYS(i).InletV.P - TRAYS(i).OutletV.P)*1e5 - (beta*sum(TRAYS(i).M*Mw)/(Ap*1.3)*g*1e5) * (TRAYS(i).rhoV*Ah/sum(Mw*TRAYS(i).OutletV.z))^1.08 * 'm^1.08/mol^1.08';
279                       
280                                case "Klingberg":
281                                TRAYS(i).InletV.F * TRAYS(i).vV = Ap * sqrt(((TRAYS(i).InletV.P - TRAYS(i).OutletV.P)-TRAYS(i).rhoL*g*TRAYS(i).Level)/TRAYS(i).rhoV);
282                       
283                                case "Wang_Fv":
284                                TRAYS(i).InletV.F * TRAYS(i).vV = Ap * sqrt(((TRAYS(i).InletV.P - TRAYS(i).OutletV.P)-TRAYS(i).rhoL*g*TRAYS(i).Level)/TRAYS(i).rhoV*alfa);
285                               
286                                case "Elgue":
287                                TRAYS(i).InletV.F  = sqrt((TRAYS(i).InletV.P - TRAYS(i).OutletV.P)/btray);
288                        end
289                when TRAYS(i).InletV.F < 1e-6 * 'kmol/h' switchto "off";
290               
291                case "off":
292                TRAYS(i).InletV.F = 0 * 'mol/s';
293                when TRAYS(i).InletV.P > TRAYS(i).OutletV.P + TRAYS(i).Level*g*TRAYS(i).rhoL + 1e-1 * 'atm' switchto "on";
294        end
295
296end
297
298end
299
300Model Section_Column as Section_ColumnBasic
301
302ATTRIBUTES
303        Pallete         = true;
304        Icon            = "icon/SectionColumn";
305        Brief   = "Model of a column section.";
306        Info            =
307"== Model of a column section containing ==
308* NumberOfTrays TRAYS.
309       
310== Specify ==
311* the feed stream of each tray (Inlet);
312* the Murphree eficiency for each tray Emv;
313* the InletL stream of the top tray;
314* the InletV stream of the bottom tray.
315       
316== Initial Conditions ==
317* the TRAYS temperature (OutletL.T);
318* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
319* (NoComps - 1) OutletL (OR OutletV) compositions for each tray.
320";
321
322VARIABLES
323#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
324# Section Inlet and Outlet Material Ports
325#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
326        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Draw Off Port in the section", PosX=1, PosY=0.35,Protected = true);
327        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Draw Off Port in the section", PosX=1, PosY=0.65,Protected = true);
328       
329        in      LiquidInlet             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.70, PosY=0);
330        out     VapourOutlet    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.30, PosY=0);
331       
332        in      VapourInlet             as stream                       (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1);
333        out     LiquidOutlet    as liquid_stream        (Brief="Liquid Outlet in the section", PosX=0.70, PosY=1);
334       
335        LiquidConnector as stream       (Brief="Liquid connection in the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
336        VapourConnector as stream       (Brief="Vapour connection in the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
337
338CONNECTIONS
339
340        LiquidConnector to TRAYS(1).InletL;
341        VapourConnector to TRAYS(NumberOfTrays).InletV;
342
343EQUATIONS
344#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
345# Equating Inlet Liquid Connector Variables
346#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
347"Liquid Inlet Flow"     
348        LiquidConnector.F = LiquidInlet.F;
349
350"Liquid Inlet Temperature"             
351        LiquidConnector.T = LiquidInlet.T;
352
353"Liquid Inlet Pressure"         
354        LiquidConnector.P = LiquidInlet.P;
355
356"Liquid Inlet Composition"             
357        LiquidConnector.z = LiquidInlet.z;
358
359"Liquid Inlet Vapour Fraction"         
360        LiquidConnector.v = LiquidInlet.v;
361
362"Liquid Inlet Enthalpy"         
363        LiquidConnector.h = LiquidInlet.h;
364#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
365# Equating Inlet Vapour Connector Variables
366#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
367"Vapour Inlet Flow"             
368        VapourConnector.F = VapourInlet.F;
369
370"Vapour Inlet Temperature"             
371        VapourConnector.T = VapourInlet.T;
372
373"Vapour Inlet Pressure"         
374        VapourConnector.P = VapourInlet.P;
375
376"Vapour Inlet Composition"             
377        VapourConnector.z = VapourInlet.z;
378
379"Vapour Inlet Vapour Fraction"         
380        VapourConnector.v = VapourInlet.v;
381
382"Vapour Inlet Enthalpy"         
383        VapourConnector.h = VapourInlet.h;
384#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
385# Equating Outlet Liquid Variables
386#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
387"Liquid Outlet Flow"   
388        LiquidOutlet.F = TRAYS(NumberOfTrays).OutletL.F;
389
390"Liquid Outlet Temperature"     
391        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletL.T;
392
393"Liquid Outlet Pressure"       
394        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletL.P;
395
396"Liquid Outlet Composition"     
397        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletL.z;
398#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
399# Equating Outlet Vapour Variables
400#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
401"Vapour Outlet Flow"           
402        VapourOutlet.F = TRAYS(1).OutletV.F;
403
404"Vapour Outlet Temperature"             
405        VapourOutlet.T = TRAYS(1).OutletV.T;
406
407"Vapour Outlet Pressure"               
408        VapourOutlet.P = TRAYS(1).OutletV.P;
409
410"Vapour Outlet Composition"             
411        VapourOutlet.z = TRAYS(1).OutletV.z;
412#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
413# Equating Outlet Vapour Side Stream Variables
414#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
415"Vapour Draw Off Stream - Flow"         
416        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
417
418"Vapour Draw Off Stream - Temperature"         
419        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
420
421"Vapour Draw Off Stream - Pressure"             
422        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
423
424"Vapour Draw Off Stream - Composition"         
425        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
426
427"Vapour Draw Off Stream"       
428        VapourDrawOffFlow = VapourDrawOff.F;
429#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
430# Equating Outlet Liquid Side Stream Variables
431#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
432"Liquid Draw Off Stream - Flow"         
433        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
434
435"Liquid Draw Off Stream - Temperature" 
436        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
437
438"Liquid Draw Off Stream - Pressure"                     
439        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
440
441"Liquid Draw Off Stream - Composition" 
442        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
443
444"Liquid Draw Off Stream"       
445        LiquidDrawOffFlow = LiquidDrawOff.F;
446
447end
448
449Model Distillation_kettle_cond  as Section_ColumnBasic
450
451ATTRIBUTES
452        Pallete         = true;
453        Icon            = "icon/DistillationKettleCond";
454        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
455        Info            =
456"== Specify ==
457* the feed stream of each tray (Inlet);
458* the Murphree eficiency for each tray Emv;
459* the pump pressure difference;
460* the heat supllied in reboiler and condenser;
461* the condenser vapor outlet flow (OutletV.F);
462* the reboiler liquid outlet flow (OutletL.F);
463* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
464       
465== Initial Conditions ==
466* the TRAYS temperature (OutletL.T);
467* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
468* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
469       
470* the condenser temperature (OutletL.T);
471* the condenser liquid level (Level);
472* (NoComps - 1) OutletL (OR OutletV) compositions;
473       
474* the reboiler temperature (OutletL.T);
475* the reboiler liquid level (Level);
476* (NoComps - 1) OutletL (OR OutletV) compositions.
477";
478       
479PARAMETERS
480        CondenserVapourFlow             as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
481
482VARIABLES
483        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.375,Protected = true);
484        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.42,Protected = true);
485#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
486# Column Devices
487#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
488        CONDENSER               as condenser;
489        REBOILER                as reboiler;
490        SPLITTERtop     as splitter;
491        PUMP                    as pump;
492        alfaTopo                as Real;
493#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
494# Heat Ports
495#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
496        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler",Protected = true, PosX=1, PosY=0.90);
497        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", Protected = true, PosX=1, PosY=0.034);
498#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
499# Column Connectors
500#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
501                ConnectorHeatReboiler   as power        (Brief="Heat supplied to Reboiler", Hidden=true);
502                ConnectorHeatCondenser  as power        (Brief="Heat supplied to Condenser", Hidden=true);
503        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Condenser", Hidden=true);
504        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
505        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
506#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
507# Column products
508#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
509        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Condenser", PosX=0.66, PosY=0);
510        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
511        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
512
513EQUATIONS
514
515switch CondenserVapourFlow
516
517        case "on":
518                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo *Ah * sqrt(2*(TRAYS(1).OutletV.P -
519                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
520                when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
521
522        case "off":
523                CONDENSER.InletV.F = 0 * 'mol/s';
524                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
525
526end     
527
528# Condenser Connector Equations
529        ConnectorCondenserVout.T = VapourDistillate.T;
530        ConnectorCondenserVout.P = VapourDistillate.P;
531        ConnectorCondenserVout.F = VapourDistillate.F;
532        ConnectorCondenserVout.z = VapourDistillate.z;
533
534# Splitter Connector Equations
535        ConnectorSplitterOut.T = LiquidDistillate.T;
536        ConnectorSplitterOut.P = LiquidDistillate.P;
537        ConnectorSplitterOut.F = LiquidDistillate.F;
538        ConnectorSplitterOut.z = LiquidDistillate.z;
539
540# Reboiler Connector Equations
541        ConnectorReboilerLout.T = BottomProduct.T;
542        ConnectorReboilerLout.P = BottomProduct.P;
543        ConnectorReboilerLout.F = BottomProduct.F;
544        ConnectorReboilerLout.z = BottomProduct.z;
545
546        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
547        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
548        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
549        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
550
551        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
552        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
553        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
554        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
555
556        VapourDrawOffFlow = VapourDrawOff.F;
557        LiquidDrawOffFlow = LiquidDrawOff.F;
558
559        HeatToReboiler  = ConnectorHeatReboiler;
560        HeatToCondenser = ConnectorHeatCondenser;
561
562CONNECTIONS
563#vapor
564        REBOILER.OutletV        to      TRAYS(NumberOfTrays).InletV;
565        TRAYS(1).OutletV        to      CONDENSER.InletV;
566
567#liquid
568        CONDENSER.OutletL                               to      SPLITTERtop.Inlet;     
569        SPLITTERtop.Outlet2                     to      PUMP.Inlet;
570        PUMP.Outlet                                     to      TRAYS(1).InletL;
571        TRAYS(NumberOfTrays).OutletL    to      REBOILER.InletL;
572
573#Connectors
574        CONDENSER.OutletV       to ConnectorCondenserVout;
575        SPLITTERtop.Outlet1 to ConnectorSplitterOut;
576        REBOILER.OutletL        to ConnectorReboilerLout;
577
578        ConnectorHeatReboiler   to REBOILER.InletQ;
579        ConnectorHeatCondenser  to CONDENSER.InletQ;
580
581end
582
583Model Distillation_thermosyphon_subcooling      as Section_ColumnBasic
584        ATTRIBUTES
585        Pallete         = true;
586        Icon            = "icon/DistillationThermosyphonSubcooling";
587        Brief           = "Model of a distillation column with steady condenser and steady reboiler.";
588        Info            =
589"== Specify ==
590* the feed stream of each tray (Inlet);
591* the Murphree eficiency for each tray Emv;
592* the pump head;
593* the condenser pressure drop;
594* the heat supllied in top and bottom tanks;
595* the heat supllied in condenser and reboiler;
596* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
597* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
598       
599== Initial Conditions ==
600* the TRAYS temperature (OutletL.T);
601* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
602* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
603       
604* the top tank temperature (OutletL.T);
605* the top tank liquid level (Level);
606* (NoComps - 1) OutletL (OR OutletV) compositions;
607       
608* the bottom tank temperature (OutletL.T);
609* the bottom tank liquid level (Level);
610* (NoComps - 1) OutletL (OR OutletV) compositions.
611";
612
613PARAMETERS
614
615        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Hidden=true, Default = "on");
616
617VARIABLES
618#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
619# Column Vapour and Liquid Draw Sides
620#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
621        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.41,Protected = true);
622        out     LiquidDrawOff   as liquid_stream                (Brief="Liquid Outlet in the section", PosX=1, PosY=0.45,Protected = true);
623#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
624# Column Devices
625#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
626        CONDENSER                       as condenserSteady      (Brief="steady state condenser with subcooling");
627        ACCUMULATOR_TOP         as tank_cylindrical     (Brief="vessel drum (layed cilinder)");
628        SPLITTER_TOP            as splitter                     (Brief="splitter which separate reflux and distillate");
629        PUMP                            as pump                         (Brief="pump in reflux stream");
630        REBOILER                        as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
631        ACCUMULATOR_BOTTOM      as tank                         (Brief="vessel in the bottom of column");
632        SPLITTER_BOTTOM         as splitter                     (Brief="splitter who separate the bottom product and the stream to reboiler");
633        alfaTopo                        as Real;
634#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
635# Heat Ports
636#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
637in              HeatToCondenser                 as power        (Brief="Heat supplied to Condenser",PosX=1, PosY=0.065, Protected=true);
638in              HeatToReboiler                  as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.87,Protected=true);
639in              HeatToBottomAccumulator as power        (Brief="Heat supplied to Bottom Accumulator",PosX=0, PosY=0.925,Protected=true);
640in              HeatToTopAccumulator    as power        (Brief="Heat supplied to Top Accumulator", PosX=1, PosY=0.19,Protected=true);
641#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
642# Column Top and Bottom product
643#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
644out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.24);
645out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=0.18, PosY=1);
646#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
647# Column Model Connectors
648#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
649in      ConnectorSplitterBottom         as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
650in      ConnectorSplitterTop            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
651
652        ConnectorHeatReboiler                   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
653        ConnectorHeatCondenser                  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
654        ConnectorHeatTopAccumulator     as power        (Brief="Connector for Heat supplied to Top Accumulator", Hidden=true);
655        ConnectorHeatBottomAccumulator  as power        (Brief="Connector for Heat supplied to Bottom Accumulator", Hidden=true);
656       
657EQUATIONS
658# Heat Connector Equations
659        HeatToCondenser                 =       ConnectorHeatCondenser;
660        HeatToReboiler                  =       ConnectorHeatReboiler;
661        HeatToBottomAccumulator =       ConnectorHeatBottomAccumulator;
662        HeatToTopAccumulator    =       ConnectorHeatTopAccumulator;
663
664# Top Splitter Connector Equations
665        ConnectorSplitterTop.T = LiquidDistillate.T;
666        ConnectorSplitterTop.P = LiquidDistillate.P;
667        ConnectorSplitterTop.F = LiquidDistillate.F;
668        ConnectorSplitterTop.z = LiquidDistillate.z;
669
670# Bottom Splitter Connector Equations
671        ConnectorSplitterBottom.T = BottomProduct.T;
672        ConnectorSplitterBottom.P = BottomProduct.P;
673        ConnectorSplitterBottom.F = BottomProduct.F;
674        ConnectorSplitterBottom.z = BottomProduct.z;
675
676        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
677        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
678        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
679        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
680
681        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
682        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
683        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
684        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
685
686        VapourDrawOffFlow = VapourDrawOff.F;
687        LiquidDrawOffFlow = LiquidDrawOff.F;
688
689switch CondenserVapourFlow
690
691        case "on":
692                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletV.P -
693                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
694                when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
695
696        case "off":
697                CONDENSER.InletV.F = 0 * 'mol/s';
698                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
699
700end     
701
702CONNECTIONS
703#vapor
704        REBOILER.OutletV        to TRAYS(NumberOfTrays).InletV;
705        TRAYS(1).OutletV        to CONDENSER.InletV;
706
707#liquid
708        CONDENSER.OutletL                               to ACCUMULATOR_TOP.Inlet;       
709        ACCUMULATOR_TOP.Outlet                  to SPLITTER_TOP.Inlet;
710        SPLITTER_TOP.Outlet2                    to PUMP.Inlet; 
711        PUMP.Outlet                                     to TRAYS(1).InletL;
712        TRAYS(NumberOfTrays).OutletL    to ACCUMULATOR_BOTTOM.Inlet;
713        ACCUMULATOR_BOTTOM.Outlet               to SPLITTER_BOTTOM.Inlet;
714        SPLITTER_BOTTOM.Outlet2                 to REBOILER.InletL;
715
716#Connectors
717        ConnectorHeatCondenser                  to CONDENSER.InletQ;
718        ConnectorHeatReboiler                   to REBOILER.InletQ;
719        ConnectorHeatBottomAccumulator  to ACCUMULATOR_BOTTOM.InletQ;
720        ConnectorHeatTopAccumulator             to ACCUMULATOR_TOP.InletQ;
721        SPLITTER_TOP.Outlet1                    to ConnectorSplitterTop;
722        SPLITTER_BOTTOM.Outlet1                 to ConnectorSplitterBottom;
723
724end
725
726Model Distillation_thermosyphon_cond as Section_ColumnBasic
727        ATTRIBUTES
728        Pallete         = true;
729        Icon            = "icon/DistillationThermosyphonCond";
730        Brief           = "Model of a distillation column with dynamic condenser and steady reboiler.";
731        Info            =
732"== Specify ==
733* the feed stream of each tray (Inlet);
734* the Murphree eficiency for each tray Emv;
735* the pump head;
736* the condenser vapor outlet flow (OutletV.F);
737* the heat supllied in bottom tank;
738* the heat supllied in condenser and reboiler;
739* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
740       
741== Initial Conditions ==
742* the TRAYS temperature (OutletL.T);
743* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
744* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
745       
746* the condenser temperature (OutletL.T);
747* the condenser liquid level (Level);
748* (NoComps - 1) OutletL (OR OutletV) compositions;
749       
750* the bottom tank temperature (OutletL.T);
751* the bottom tank liquid level (Level);
752* (NoComps - 1) OutletL (OR OutletV) compositions.
753";
754
755PARAMETERS
756        CondenserVapourFlow     as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
757
758VARIABLES
759#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
760# Column Vapour and Liquid Draw Sides
761#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
762        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.379,Protected = true);
763        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.425,Protected = true);
764#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
765# Column Devices
766#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
767        CONDENSER                       as condenser            (Brief="dynamic condenser without subcooling");
768        SPLITTER_TOP            as splitter                     (Brief="splitter which separate reflux and distillate");
769        PUMP                            as pump                         (Brief="pump in reflux stream");
770        ACCUMULATOR_BOTTOM      as tank                         (Brief="vessel in the bottom of column");
771        SPLITTER_BOTTOM         as splitter                     (Brief="splitter who separate the bottom product and the stream to reboiler");
772        REBOILER                        as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
773        alfaTopo                        as Real;
774#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
775# Heat Ports
776#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
777in      HeatToCondenser                 as power        (Brief="Heat supplied to Condenser",PosX=1, PosY=0.035, Protected=true);
778in      HeatToReboiler                  as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.865,Protected=true);
779in      HeatToBottomAccumulator as power        (Brief="Heat supplied to Bottom Accumulator",PosX=0, PosY=0.92,Protected=true);
780#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
781# Column Top and Bottom product
782#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
783out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.665, PosY=0);
784out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
785out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=0.18, PosY=1);
786#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
787# Column Model Connectors
788#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
789in      ConnectorSplitterBottom as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
790in      ConnectorSplitterTop    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
791in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
792
793        ConnectorHeatReboiler                   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
794        ConnectorHeatCondenser                  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
795        ConnectorHeatBottomAccumulator  as power        (Brief="Connector for Heat supplied to Bottom Accumulator", Hidden=true);
796
797EQUATIONS
798# Heat Connector Equations
799        HeatToCondenser                 =       ConnectorHeatCondenser;
800        HeatToReboiler                  =       ConnectorHeatReboiler;
801        HeatToBottomAccumulator =       ConnectorHeatBottomAccumulator;
802
803# Condenser Connector Equations
804        ConnectorCondenserVout.T = VapourDistillate.T;
805        ConnectorCondenserVout.P = VapourDistillate.P;
806        ConnectorCondenserVout.F = VapourDistillate.F;
807        ConnectorCondenserVout.z = VapourDistillate.z;
808
809# Top Splitter Connector Equations
810        ConnectorSplitterTop.T = LiquidDistillate.T;
811        ConnectorSplitterTop.P = LiquidDistillate.P;
812        ConnectorSplitterTop.F = LiquidDistillate.F;
813        ConnectorSplitterTop.z = LiquidDistillate.z;
814
815# Bottom Splitter Connector Equations
816        ConnectorSplitterBottom.T = BottomProduct.T;
817        ConnectorSplitterBottom.P = BottomProduct.P;
818        ConnectorSplitterBottom.F = BottomProduct.F;
819        ConnectorSplitterBottom.z = BottomProduct.z;
820
821        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
822        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
823        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
824        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
825
826        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
827        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
828        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
829        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
830
831        VapourDrawOffFlow = VapourDrawOff.F;
832        LiquidDrawOffFlow = LiquidDrawOff.F;
833       
834switch CondenserVapourFlow
835                case "on":
836                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletV.P -
837                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
838                when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
839               
840                case "off":
841                CONDENSER.InletV.F = 0 * 'mol/s';
842                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
843end     
844
845CONNECTIONS
846#vapor
847        REBOILER.OutletV        to TRAYS(NumberOfTrays).InletV;
848        TRAYS(1).OutletV                                to CONDENSER.InletV;
849
850#liquid
851        CONDENSER.OutletL               to SPLITTER_TOP.Inlet; 
852        SPLITTER_TOP.Outlet2                            to PUMP.Inlet;
853        PUMP.Outlet                                     to TRAYS(1).InletL;
854        TRAYS(NumberOfTrays).OutletL    to ACCUMULATOR_BOTTOM.Inlet;
855        ACCUMULATOR_BOTTOM.Outlet                               to SPLITTER_BOTTOM.Inlet;
856        SPLITTER_BOTTOM.Outlet2                         to REBOILER.InletL;
857
858#Connectors
859ConnectorHeatCondenser                  to CONDENSER.InletQ;
860ConnectorHeatReboiler                   to REBOILER.InletQ;
861ConnectorHeatBottomAccumulator  to ACCUMULATOR_BOTTOM.InletQ;
862CONDENSER.OutletV                               to ConnectorCondenserVout;
863SPLITTER_TOP.Outlet1                    to ConnectorSplitterTop;
864SPLITTER_BOTTOM.Outlet1                 to ConnectorSplitterBottom;
865
866end
867
868Model Distillation_kettle_subcooling as Section_ColumnBasic
869
870ATTRIBUTES
871        Pallete         = true;
872        Icon            = "icon/DistillationKettleSubcooling";
873        Brief   = "Model of a distillation column with steady condenser and dynamic reboiler.";
874        Info            =
875"== Specify ==
876* the feed stream of each tray (Inlet);
877* the Murphree eficiency for each tray (Emv);
878* the pump pressure difference;
879* the heat supllied in reboiler and condenser;
880* the heat supllied in the top tank;
881* the condenser pressure drop;
882* the reboiler liquid outlet flow (OutletL.F);
883* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
884       
885== Initial Conditions ==
886* the TRAYS temperature (OutletL.T);
887* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
888* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
889       
890* the top tank temperature (OutletL.T);
891* the top tank liquid level (Level);
892* (NoComps - 1) OutletL (OR OutletV) compositions;
893       
894* the reboiler temperature (OutletL.T);
895* the reboiler liquid level (Level);
896* (NoComps - 1) OutletL (OR OutletV) compositions.
897";
898       
899PARAMETERS
900        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Default = "on",Hidden=true);
901
902VARIABLES
903#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
904# Column Vapour and Liquid Draw Sides
905#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
906        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.41,Protected = true);
907        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.45,Protected = true);
908#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
909# Column Devices
910#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
911        CONDENSER               as condenserSteady      (Brief="steady state condenser with subcooling");
912        ACCUMULATOR             as tank_cylindrical     (Brief="vessel drum (layed cilinder)");
913        SPLITTER                as splitter                     (Brief="splitter which separate reflux and distillate");
914        PUMP                    as pump                         (Brief="pump in reflux stream");
915        REBOILER                as reboiler                     (Brief="kettle reboiler");
916        alfaTopo                as Real;
917#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
918# Heat Ports
919#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
920in              HeatToCondenser         as power        (Brief="Heat supplied to Condenser", PosX=1, PosY=0.065, Protected=true);
921in              HeatToReboiler          as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.905, Protected=true);
922in              HeatToAccumulator       as power        (Brief="Heat supplied to Top Vessel", PosX=1, PosY=0.195, Protected=true);
923#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
924# Column Model Connectors
925#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
926in      ConnectorSplitterOut            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
927in      ConnectorReboilerLout           as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
928        ConnectorHeatReboiler           as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
929        ConnectorHeatCondenser          as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
930        ConnectorHeatAccumulator        as power        (Brief="Connector for Heat supplied to TopVessel", Hidden=true);
931#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
932# Column Top and Bottom product
933#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
934out     LiquidDistillate as liquid_stream       (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.24);
935out     BottomProduct    as liquid_stream       (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
936
937EQUATIONS
938
939#Heat Connectors
940HeatToCondenser         = ConnectorHeatCondenser;
941HeatToReboiler          = ConnectorHeatReboiler;
942HeatToAccumulator       = ConnectorHeatAccumulator;
943
944# Splitter Connector Equations
945        ConnectorSplitterOut.T = LiquidDistillate.T;
946        ConnectorSplitterOut.P = LiquidDistillate.P;
947        ConnectorSplitterOut.F = LiquidDistillate.F;
948        ConnectorSplitterOut.z = LiquidDistillate.z;
949
950# Reboiler Connector Equations
951        ConnectorReboilerLout.T = BottomProduct.T;
952        ConnectorReboilerLout.P = BottomProduct.P;
953        ConnectorReboilerLout.F = BottomProduct.F;
954        ConnectorReboilerLout.z = BottomProduct.z;
955       
956        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
957        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
958        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
959        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
960
961        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
962        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
963        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
964        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
965
966        VapourDrawOffFlow = VapourDrawOff.F;
967        LiquidDrawOffFlow = LiquidDrawOff.F;
968       
969        switch CondenserVapourFlow
970                case "on":
971                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletV.P -
972                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
973                when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
974               
975                case "off":
976                CONDENSER.InletV.F = 0 * 'mol/s';
977                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
978end     
979
980CONNECTIONS
981#vapor
982        REBOILER.OutletV to TRAYS(NumberOfTrays).InletV;
983        TRAYS(1).OutletV to CONDENSER.InletV;
984
985#liquid
986        CONDENSER.OutletL                               to ACCUMULATOR.Inlet;   
987        ACCUMULATOR.Outlet                                      to SPLITTER.Inlet;
988        SPLITTER.Outlet2                        to PUMP.Inlet; 
989        PUMP.Outlet                                     to TRAYS(1).InletL;
990        TRAYS(NumberOfTrays).OutletL    to REBOILER.InletL;
991
992#Connectors
993ConnectorHeatCondenser          to CONDENSER.InletQ;
994ConnectorHeatReboiler           to REBOILER.InletQ;
995ConnectorHeatAccumulator        to ACCUMULATOR.InletQ;
996
997SPLITTER.Outlet1 to ConnectorSplitterOut;
998REBOILER.OutletL        to ConnectorReboilerLout;
999
1000end
1001
1002Model Rectifier as Section_ColumnBasic
1003
1004ATTRIBUTES
1005        Pallete         = true;
1006        Icon            = "icon/RefluxedCond";
1007        Brief           = "Model of a rectifier column with dynamic condenser.";
1008        Info            =
1009"== Specify ==
1010* the feed stream of each tray (Inlet);
1011* the Murphree eficiency for each tray Emv;
1012* the InletV stream of the bottom tray unless its flow;
1013* the pump pressure difference;
1014* the heat supllied in the condenser;
1015* the condenser vapor outlet flow (OutletV.F);
1016* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1017       
1018== Initial Conditions ==
1019* the TRAYS temperature (OutletL.T);
1020* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
1021* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
1022       
1023* the condenser temperature (OutletL.T);
1024* the condenser liquid level (Level);
1025* (NoComps - 1) OutletL (OR OutletV) compositions;
1026";
1027
1028PARAMETERS
1029        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Default = "on",Hidden=true);
1030
1031VARIABLES
1032#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1033# Column Vapour and Liquid Draw Sides
1034#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1035        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.45,Protected = true);
1036        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.50,Protected = true);
1037#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1038# Column Devices
1039#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1040        CONDENSER       as condenser    (Brief="dymamic condenser without subcooling");
1041        SPLITTER        as splitter             (Brief="splitter which separate reflux and distillate");
1042        PUMP            as pump                 (Brief="pump in reflux stream");
1043        alfaTopo        as Real;
1044#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1045# Column Top product
1046#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1047        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.66, PosY=0);
1048        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.24);
1049#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1050# Heat Port
1051#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1052        in      HeatToCondenser         as power (Brief="Heat supplied to Condenser",PosX=1, PosY=0.04, Protected = true);
1053#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1054# Column Bottom Outlets
1055#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1056        in      VapourInlet             as stream                       (Brief="Vapour Inlet in the section", PosX=0.07, PosY=1);
1057        out     LiquidOutlet    as liquid_stream        (Brief="Liquid Outlet in the section", PosX=0.32, PosY=1);
1058#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1059# Column Model Connectors
1060#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1061        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1062        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
1063                VapourConnector                 as stream       (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
1064                ConnectorHeatCondenser  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1065       
1066EQUATIONS
1067
1068switch CondenserVapourFlow
1069
1070        case "on":
1071                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletV.P -
1072                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1073                when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
1074               
1075        case "off":
1076                CONDENSER.InletV.F = 0 * 'mol/s';
1077                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
1078
1079end     
1080
1081HeatToCondenser = ConnectorHeatCondenser;
1082
1083# Condenser Connector Equations
1084        ConnectorCondenserVout.T = VapourDistillate.T;
1085        ConnectorCondenserVout.P = VapourDistillate.P;
1086        ConnectorCondenserVout.F = VapourDistillate.F;
1087        ConnectorCondenserVout.z = VapourDistillate.z;
1088       
1089# Splitter Connector Equations
1090        ConnectorSplitterOut.T = LiquidDistillate.T;
1091        ConnectorSplitterOut.P = LiquidDistillate.P;
1092        ConnectorSplitterOut.F = LiquidDistillate.F;
1093        ConnectorSplitterOut.z = LiquidDistillate.z;
1094       
1095        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletL.F;
1096        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletL.T;
1097        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletL.P;
1098        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletL.z;
1099
1100        VapourConnector.F= VapourInlet.F;
1101        VapourConnector.T = VapourInlet.T;
1102        VapourConnector.P = VapourInlet.P;
1103        VapourConnector.z = VapourInlet.z;
1104        VapourConnector.v = VapourInlet.v;
1105        VapourConnector.h = VapourInlet.h;
1106
1107        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1108        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1109        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1110        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1111
1112        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1113        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1114        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1115        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1116
1117        VapourDrawOffFlow = VapourDrawOff.F;
1118        LiquidDrawOffFlow = LiquidDrawOff.F;
1119
1120CONNECTIONS
1121#vapor
1122        TRAYS(1).OutletV to CONDENSER.InletV;
1123
1124#liquid
1125        CONDENSER.OutletL       to SPLITTER.Inlet;     
1126        SPLITTER.Outlet2        to PUMP.Inlet; 
1127        PUMP.Outlet             to TRAYS(1).InletL;
1128
1129#Connectors
1130ConnectorHeatCondenser  to CONDENSER.InletQ;
1131VapourConnector                 to TRAYS(NumberOfTrays).InletV;
1132SPLITTER.Outlet1                to ConnectorSplitterOut;
1133CONDENSER.OutletV               to ConnectorCondenserVout;
1134
1135end
1136
1137Model Rectifier_subcooling as Section_ColumnBasic
1138
1139ATTRIBUTES
1140        Pallete         = true;
1141        Icon            = "icon/RefluxedSubcooling";
1142        Brief           = "Model of a rectifier column with steady condenser.";
1143        Info            =
1144"== Specify ==
1145* the feed stream of each tray (Inlet);
1146* the Murphree eficiency for each tray Emv;
1147* the InletV stream of the bottom tray unless its flow;
1148* the pump head;
1149* the condenser pressure drop;
1150* the heat supllied in  the top tank;
1151* the heat supllied in condenser;
1152* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1153       
1154== Initial Conditions ==
1155* the TRAYS temperature (OutletL.T);
1156* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
1157* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
1158       
1159* the top tank temperature (OutletL.T);
1160* the top tank liquid level (Level);
1161* (NoComps - 1) OutletL (OR OutletV) compositions;
1162";
1163       
1164PARAMETERS
1165        CondenserVapourFlow             as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
1166
1167VARIABLES
1168#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1169# Column Vapour and Liquid Draw Sides
1170#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1171        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.485,Protected = true);
1172        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.535,Protected = true);
1173#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1174# Column Devices
1175#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1176        CONDENSER               as condenserSteady      (Brief="steady state condenser with subcooling");
1177        ACCUMULATOR             as tank_cylindrical     (Brief="vessel drum (layed cilinder)");
1178        SPLITTER                as splitter                     (Brief="plitter which separate reflux and distillate");
1179        PUMP                    as pump                         (Brief="pump in reflux stream");
1180        alfaTopo                as Real;
1181#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1182# Column Bottom outlets
1183#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1184        in      VapourInlet             as stream                       (Brief="Vapour Inlet in the section", PosX=0.07, PosY=1);
1185        out     LiquidOutlet    as liquid_stream        (Brief="Liquid Outlet in the section", PosX=0.32, PosY=1);
1186#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1187# Heat Ports
1188#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1189        in      HeatToCondenser         as power        (Brief="Heat supplied to Condenser", PosX=1, PosY=0.070, Protected=true);
1190        in      HeatToAccumulator       as power        (Brief="Heat supplied to Top Accumulator", PosX=1, PosY=0.23, Protected=true);
1191#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1192# Column Top Product
1193#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1194        out     LiquidDistillate                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.285);
1195#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1196# Column Connectors
1197#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1198in      ConnectorSplitterTop            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1199        VapourConnector                         as stream       (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
1200        ConnectorHeatCondenser          as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1201        ConnectorHeatAccumulator        as power        (Brief="Connector for Heat supplied to Top Accumulator", Hidden=true);
1202
1203EQUATIONS
1204#Heat Connectors
1205        HeatToCondenser         = ConnectorHeatCondenser;
1206        HeatToAccumulator       = ConnectorHeatAccumulator;
1207       
1208        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletL.F;
1209        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletL.T;
1210        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletL.P;
1211        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletL.z;
1212
1213        VapourConnector.F= VapourInlet.F;
1214        VapourConnector.T = VapourInlet.T;
1215        VapourConnector.P = VapourInlet.P;
1216        VapourConnector.z = VapourInlet.z;
1217        VapourConnector.v = VapourInlet.v;
1218        VapourConnector.h = VapourInlet.h;
1219       
1220# Splitter Connector Equations
1221        ConnectorSplitterTop.T = LiquidDistillate.T;
1222        ConnectorSplitterTop.P = LiquidDistillate.P;
1223        ConnectorSplitterTop.F = LiquidDistillate.F;
1224        ConnectorSplitterTop.z = LiquidDistillate.z;
1225
1226switch CondenserVapourFlow
1227
1228        case "on":
1229                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo *Ah * sqrt(2*(TRAYS(1).OutletV.P -
1230                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1231        when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
1232               
1233        case "off":
1234                CONDENSER.InletV.F = 0 * 'mol/s';
1235        when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
1236
1237end     
1238
1239CONNECTIONS
1240#vapor
1241        TRAYS(1).OutletV to CONDENSER.InletV;
1242
1243#liquid
1244        CONDENSER.OutletL               to ACCUMULATOR.Inlet;   
1245        ACCUMULATOR.Outlet                                      to SPLITTER.Inlet;
1246        SPLITTER.Outlet2                to PUMP.Inlet; 
1247        PUMP.Outlet                                             to TRAYS(1).InletL;
1248
1249#Connectors
1250        VapourConnector                         to TRAYS(NumberOfTrays).InletV;
1251        ConnectorHeatCondenser                  to CONDENSER.InletQ;
1252        SPLITTER.Outlet1        to ConnectorSplitterTop;
1253        ConnectorHeatAccumulator                        to ACCUMULATOR.InletQ;
1254
1255end
1256
1257Model Reboiled_Stripping_kettle as Section_ColumnBasic
1258       
1259ATTRIBUTES
1260        Pallete         = true;
1261        Icon            = "icon/ReboiledKettle";
1262        Brief           = "Model of a reboiled stripping column with dynamic reboiler.";
1263        Info            =
1264"== Specify ==
1265* the feed stream of each tray (Inlet);
1266* the Murphree eficiency for each tray Emv;
1267* the vapour flow leaving the top of the column;
1268* the InletL stream of the top tray;
1269* the heat supllied in the reboiler;
1270* the reboiler liquid outlet flow (OutletL.F);
1271       
1272== Initial Conditions ==
1273* the TRAYS temperature (OutletL.T);
1274* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
1275* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
1276       
1277* the reboiler temperature (OutletL.T);
1278* the reboiler liquid level (Level);
1279* (NoComps - 1) OutletL (OR OutletV) compositions.
1280";
1281
1282VARIABLES
1283#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1284# Column Vapour and Liquid Draw Sides
1285#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1286        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.28,Protected = true);
1287        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.33,Protected = true);
1288#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1289# Column Devices
1290#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
1291        REBOILER as reboiler (Brief="Kettle Reboiler");
1292#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1293# Heat Port
1294#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1295        in      HeatToReboiler  as power        (Brief="Heat supplied to Reboiler",PosX=1, PosY=0.865,Protected=true);
1296#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1297# Column Top Outlets
1298#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
1299        in      LiquidInlet             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.30, PosY=0);
1300        out     VapourOutlet    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.07, PosY=0);
1301#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1302# Column Bottom Product
1303#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1304        out     BottomProduct   as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.68, PosY=1);
1305#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1306# Column Connectors
1307#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1308        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1309                LiquidConnector                 as stream       (Brief="Liquid connection at the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
1310                ConnectorHeatReboiler   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1311
1312CONNECTIONS
1313#vapor
1314        REBOILER.OutletV to TRAYS(NumberOfTrays).InletV;
1315       
1316#liquid
1317        TRAYS(NumberOfTrays).OutletL to REBOILER.InletL;
1318
1319#Connectors
1320REBOILER.OutletL                to ConnectorReboilerLout;
1321LiquidConnector                 to TRAYS(1).InletL;
1322ConnectorHeatReboiler   to REBOILER.InletQ;
1323
1324EQUATIONS
1325#Heat Connectors
1326        HeatToReboiler = ConnectorHeatReboiler;
1327       
1328        LiquidConnector.F= LiquidInlet.F;
1329        LiquidConnector.T = LiquidInlet.T;
1330        LiquidConnector.P = LiquidInlet.P;
1331        LiquidConnector.z = LiquidInlet.z;
1332        LiquidConnector.v = LiquidInlet.v;
1333        LiquidConnector.h = LiquidInlet.h;
1334       
1335        VapourOutlet.F= TRAYS(1).OutletV.F;
1336        VapourOutlet.T = TRAYS(1).OutletV.T;
1337        VapourOutlet.P = TRAYS(1).OutletV.P;
1338        VapourOutlet.z = TRAYS(1).OutletV.z;
1339       
1340# Reboiler Connector Equations
1341        ConnectorReboilerLout.T = BottomProduct.T;
1342        ConnectorReboilerLout.P = BottomProduct.P;
1343        ConnectorReboilerLout.F = BottomProduct.F;
1344        ConnectorReboilerLout.z = BottomProduct.z;
1345       
1346        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1347        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1348        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1349        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1350
1351        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1352        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1353        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1354        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1355
1356        VapourDrawOffFlow = VapourDrawOff.F;
1357        LiquidDrawOffFlow = LiquidDrawOff.F;
1358
1359end
1360
1361Model Reboiled_Stripping_thermosyphon as Section_ColumnBasic
1362
1363ATTRIBUTES
1364        Pallete         = true;
1365        Icon            = "icon/ReboiledThermosyphon";
1366        Brief           = "Model of a reboiled stripping column with steady reboiler.";
1367        Info            =
1368"== Specify ==
1369* the feed stream of each tray (Inlet);
1370* the Murphree eficiency for each tray (Emv);
1371* the vapour flow leaving the top of the column;
1372* the InletL stream of the top tray;
1373* the heat supllied in bottom tank;
1374* the heat supllied in the reboiler;
1375* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
1376       
1377== Initial Conditions ==
1378* the TRAYS temperature (OutletL.T);
1379* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
1380* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
1381
1382* the bottom tank temperature (OutletL.T);
1383* the bottom tank liquid level (Level);
1384* (NoComps - 1) OutletL (OR OutletV) compositions.
1385";
1386
1387VARIABLES
1388#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1389# Column Vapour and Liquid Draw Sides
1390#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1391        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.28,Protected = true);
1392        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.33,Protected = true);
1393#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1394# Column Devices
1395#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1396        REBOILER                as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
1397        SPLITTER                as splitter             (Brief="splitter which separate the bottom product and the stream to reboiler");
1398        ACCUMULATOR     as tank                         (Brief="vessel in the bottom of column");
1399#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1400# Heat Ports
1401#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1402        in      HeatToReboiler          as power        (Brief="Heat supplied to Reboiler",PosX=1, PosY=0.84,Protected=true);
1403        in      HeatToAccumulator       as power        (Brief="Heat supplied to Bottom Vessel",PosX=0, PosY=0.91,Protected=true);
1404#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1405# Column Top Outlets
1406#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1407        in      LiquidInlet             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.32, PosY=0);
1408        out     VapourOutlet    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.07, PosY=0);
1409#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1410# Column Bottom Product
1411#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1412        out     BottomProduct   as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.19, PosY=1);
1413        LiquidConnector         as stream                       (Brief="Liquid connection at the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
1414#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1415# Column Connectors
1416#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1417        in      ConnectorSplitterBottom         as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1418        ConnectorHeatReboiler                   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1419        ConnectorHeatAccumulator                as power        (Brief="Connector for Heat supplied to Bottom Accumulator", Hidden=true);
1420
1421CONNECTIONS
1422#vapor
1423        REBOILER.OutletV to TRAYS(NumberOfTrays).InletV;
1424       
1425#liquid
1426        TRAYS(NumberOfTrays).OutletL    to ACCUMULATOR.Inlet;
1427        ACCUMULATOR.Outlet                              to SPLITTER.Inlet;
1428        SPLITTER.Outlet2                                to REBOILER.InletL;
1429
1430#Connectors
1431LiquidConnector                         to TRAYS(1).InletL;
1432ConnectorHeatReboiler           to REBOILER.InletQ;
1433ConnectorHeatAccumulator        to ACCUMULATOR.InletQ;
1434SPLITTER.Outlet1                        to ConnectorSplitterBottom;
1435
1436EQUATIONS
1437#Heat Connectors
1438        HeatToReboiler  = ConnectorHeatReboiler;
1439        HeatToAccumulator       = ConnectorHeatAccumulator;
1440       
1441        ConnectorSplitterBottom.T = BottomProduct.T;
1442        ConnectorSplitterBottom.P = BottomProduct.P;
1443        ConnectorSplitterBottom.F = BottomProduct.F;
1444        ConnectorSplitterBottom.z = BottomProduct.z;
1445       
1446        LiquidConnector.F= LiquidInlet.F;
1447        LiquidConnector.T = LiquidInlet.T;
1448        LiquidConnector.P = LiquidInlet.P;
1449        LiquidConnector.z = LiquidInlet.z;
1450        LiquidConnector.v = LiquidInlet.v;
1451        LiquidConnector.h = LiquidInlet.h;
1452       
1453        VapourOutlet.F= TRAYS(1).OutletV.F;
1454        VapourOutlet.T = TRAYS(1).OutletV.T;
1455        VapourOutlet.P = TRAYS(1).OutletV.P;
1456        VapourOutlet.z = TRAYS(1).OutletV.z;
1457       
1458        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1459        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1460        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1461        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1462
1463        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1464        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1465        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1466        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1467
1468        VapourDrawOffFlow = VapourDrawOff.F;
1469        LiquidDrawOffFlow = LiquidDrawOff.F;
1470
1471end
1472
1473Model ReactiveDistillation
1474       
1475ATTRIBUTES
1476        Pallete         = true;
1477        Icon            = "icon/DistillationReac";
1478        Brief           = "Model of a reactive distillation column with dynamic condenser and reboiler.";
1479        Info            =
1480"== Specify ==
1481* the reaction related variables for each tray, condenser and reboiler;
1482* the feed stream of each tray (Inlet);
1483* the Murphree eficiency for each tray Emv;
1484* the pump pressure difference;
1485* the heat supllied in reboiler and condenser;
1486* the condenser vapor outlet flow (OutletV.F);
1487* the reboiler liquid outlet flow (OutletL.F);
1488* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1489       
1490== Initial Conditions ==
1491* the TRAYS temperature (OutletL.T);
1492* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
1493* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
1494       
1495* the condenser temperature (OutletL.T);
1496* the condenser liquid level (Level);
1497* (NoComps - 1) OutletL (OR OutletV) compositions;
1498       
1499* the reboiler temperature (OutletL.T);
1500* the reboiler liquid level (Level);
1501* (NoComps - 1) OutletL (OR OutletV) compositions.
1502";
1503       
1504PARAMETERS
1505        outer PP        as Plugin       (Type="PP");
1506        outer NComp as Integer  (Brief="Number of Components");
1507#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1508# Section Column Feed Tray - Side Streams  Location and Numbering
1509#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1510        NumberOfTrays                                           as Integer      (Brief="Number of TRAYS", Default=2);
1511        FeedTrayIndex(NumberOfTrays)            as Integer      (Brief="Feed Tray Index", Default=0,Hidden=true);
1512        LiqSideTrayIndex(NumberOfTrays)         as Integer      (Brief="Liquid Side Tray Index", Default=0,Hidden=true);
1513        VapSideTrayIndex(NumberOfTrays)         as Integer      (Brief="Vapour Side Tray Index", Default=0,Hidden=true);
1514        FeedTrayLocation                                        as Integer      (Brief="Feed tray Location", Default=2);
1515        LiquidSideStreamLocation                        as Integer      (Brief="Liquid Side Stream Location", Default=2);
1516        VapourSideStreamLocation                        as Integer      (Brief="Vapour Side Stream Location", Default=2);
1517#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1518# Section Column Flow Model for Liquid and Vapour
1519#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1520        VapourFlow              as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
1521        TrayVapourFlow  as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
1522        TrayLiquidFlow  as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
1523        alfacond                as Real;
1524#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1525# Section Column Tray Geometry and Auxiliar Parameters
1526#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1527        V               as volume               (Brief="Total Volume of the tray",Hidden=true);
1528        Q               as power                (Brief="Rate of heat supply",Hidden=true);
1529        Ap              as area                 (Brief="Plate area = Atray - Adowncomer",Hidden=true);
1530        Ah              as area                 (Brief="Total holes area",Hidden=true);
1531        lw              as length               (Brief="Weir length",Hidden=true);
1532        g               as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
1533        hw              as length               (Brief="Weir height",Hidden=true);
1534        beta    as fraction     (Brief="Aeration fraction");
1535        alfa    as fraction     (Brief="Dry pressure drop coefficient");
1536
1537        VolumeOfTray            as volume               (Brief="Total Volume of the tray");
1538        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
1539        PlateArea                       as area                 (Brief="Plate area = Atray - Adowncomer");
1540        HolesArea                       as area                 (Brief="Total holes area");
1541        WeirLength                      as length               (Brief="Weir length");
1542        WeirHeight                      as length               (Brief="Weir height");
1543
1544        stoic(NComp)    as Real(Brief="Stoichiometric matrix");
1545        Hr                                              as energy_mol;
1546       
1547SET
1548
1549        FeedTrayIndex(FeedTrayLocation)         =1;
1550        VapSideTrayIndex(FeedTrayLocation)      =1;
1551        LiqSideTrayIndex(FeedTrayLocation)      =1;
1552
1553        V=VolumeOfTray;
1554        Q=HeatSupply;
1555        Ap=PlateArea;
1556        Ah=HolesArea;
1557        lw=WeirLength;
1558        hw=WeirHeight ;
1559       
1560VARIABLES
1561#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1562# Tray Initialization For the Whole Column Section
1563#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1564        INITIALIZATION          as InitializeSection    (Brief = "Column Model Initialization");
1565#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1566# Column Feed - Side Stream Flow and Murphree Efficiency
1567#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1568        in      FeedTray                        as stream       (Brief="Feed stream", PosX=0, PosY=0.55);
1569                VapourDrawOffFlow       as flow_mol (Brief = "Stream Molar Flow Rate");
1570                LiquidDrawOffFlow   as flow_mol (Brief = "Stream Molar Flow Rate");
1571                MurphreeEff             as Real         (Brief = "Murphree efficiency");
1572#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1573# Column Vapour and Liquid Draw Sides
1574#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1575        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.395,Protected = true);
1576        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.44,Protected = true);
1577#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1578# Heat Ports
1579#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1580        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.89);
1581        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", PosX=1, PosY=0.07);
1582#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1583# Column Devices
1584#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1585        TRAYS(NumberOfTrays)    as trayReac;
1586        CONDENSER                               as condenserReact;
1587        REBOILER                                as reboilerReact;
1588        SPLITTER                                as splitter;
1589        PUMP                                    as pump;
1590#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1591# Column Outlets
1592#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1593        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Condenser", PosX=0.59, PosY=0);
1594        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Splitter", PosX=1, PosY=0.23);
1595        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
1596#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1597# Column Connectors
1598#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1599in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
1600in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1601in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1602#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1603# Column Control Ports
1604#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1605        out     TRI as control_signal   (Brief="Temperature of Reboiler Indicator", PosX=1, PosY=0.83);
1606        out     LRI as control_signal   (Brief="Level of Reboiler Indicator", PosX=1, PosY=0.855);
1607        out     TCI as control_signal   (Brief="Temperature of Condenser Indicator", PosX=1, PosY=0.01);
1608        out     LCI as control_signal   (Brief="Level of Condenser Indicator", PosX=1, PosY=0.04);
1609
1610CONNECTIONS
1611#vapor
1612        REBOILER.OutletV                                        to TRAYS(NumberOfTrays).InletV;
1613        TRAYS(1).OutletV                                        to CONDENSER.InletV;
1614        TRAYS([2:NumberOfTrays]).OutletV        to TRAYS([1:NumberOfTrays-1]).InletV;
1615
1616#liquid
1617        CONDENSER.OutletL                                       to SPLITTER.Inlet;     
1618        SPLITTER.Outlet2                                        to PUMP.Inlet;
1619        PUMP.Outlet                                             to TRAYS(1).InletL;
1620        TRAYS([1:NumberOfTrays-1]).OutletL      to TRAYS([2:NumberOfTrays]).InletL;
1621        TRAYS(NumberOfTrays).OutletL            to REBOILER.InletL;
1622
1623#Connectors
1624        CONDENSER.OutletV       to ConnectorCondenserVout;
1625        SPLITTER.Outlet1        to ConnectorSplitterOut;
1626        REBOILER.OutletL        to ConnectorReboilerLout;
1627
1628INITIAL
1629#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1630# Tray Initialization
1631#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1632for i in 1:NumberOfTrays do
1633
1634"The initial temperature of the TRAYS"
1635        TRAYS(i).OutletL.T = INITIALIZATION.TopTemperature+(INITIALIZATION.BottomTemperature-INITIALIZATION.TopTemperature)*((i-1)/(NumberOfTrays-1));
1636
1637"The initial Level of the TRAYS"
1638        TRAYS(i).Level = INITIALIZATION.LevelFraction*hw;
1639end
1640
1641for i in 1:NComp-1 do
1642
1643for j in 1:NumberOfTrays do
1644
1645"The initial composition of the TRAYS - Normalized"
1646        TRAYS(j).OutletL.z(i) = INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) +(INITIALIZATION.BottomComposition(i)/sum(INITIALIZATION.BottomComposition)-INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) )*((j-1)/(NumberOfTrays-1));
1647end
1648
1649end
1650
1651EQUATIONS
1652
1653for i in [1:NumberOfTrays] do
1654
1655"Murphree Efficiency"
1656        TRAYS(i).OutletV.z =  MurphreeEff * (TRAYS(i).yideal - TRAYS(i).InletV.z) + TRAYS(i).InletV.z;
1657       
1658"Energy Holdup"
1659        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletL.h + TRAYS(i).MV*TRAYS(i).OutletV.h - TRAYS(i).OutletL.P*V;
1660
1661"Component Molar Balance"
1662        diff(TRAYS(i).M)=TRAYS(i).Inlet.F*TRAYS(i).Inlet.z + TRAYS(i).InletL.F*TRAYS(i).InletL.z + TRAYS(i).InletV.F*TRAYS(i).InletV.z- TRAYS(i).OutletL.F*TRAYS(i).OutletL.z - TRAYS(i).OutletV.F*TRAYS(i).OutletV.z-
1663        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;
1664       
1665"Energy Balance"
1666        diff(TRAYS(i).E) = ( TRAYS(i).Inlet.F*TRAYS(i).Inlet.h + TRAYS(i).InletL.F*TRAYS(i).InletL.h + TRAYS(i).InletV.F*TRAYS(i).InletV.h- TRAYS(i).OutletL.F*TRAYS(i).OutletL.h - TRAYS(i).OutletV.F*TRAYS(i).OutletV.h
1667        -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;
1668
1669"Level of clear liquid over the weir"
1670        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/Ap;
1671
1672"Geometry Constraint"
1673        V = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
1674
1675end
1676
1677switch VapourFlow
1678                case "on":
1679                "Pressure Drop through the condenser"
1680                CONDENSER.InletV.F*TRAYS(1).vV / 'm^2' =
1681                        sqrt((TRAYS(1).OutletV.P - CONDENSER.OutletL.P + 1e-8 * 'atm')/(TRAYS(1).rhoV*alfacond));
1682                when TRAYS(1).OutletV.P < CONDENSER.OutletL.P switchto "off";
1683               
1684                case "off":
1685                "Prato selado"
1686                CONDENSER.InletV.F = 0.0 * 'mol/s';
1687                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-3 * 'atm' switchto "on";
1688        end
1689
1690for i in [1:NumberOfTrays] do
1691
1692        switch TrayLiquidFlow
1693                case "on":
1694                "Francis Equation"
1695                TRAYS(i).OutletL.F*TRAYS(i).vL = 1.84*'1/s'*lw*((TRAYS(i).Level-(beta*hw)+1e-6*'m')/(beta))^2;
1696                when TRAYS(i).Level < (beta * hw) switchto "off";
1697               
1698                case "off":
1699                "Low level"
1700                TRAYS(i).OutletL.F = 0 * 'mol/h';
1701                when TRAYS(i).Level > (beta * hw) + 1e-6*'m' switchto "on";
1702        end
1703
1704        switch TrayVapourFlow
1705                case "on":
1706                TRAYS(i).InletV.F*TRAYS(i).vV = sqrt((TRAYS(i).InletV.P - TRAYS(i).OutletV.P - TRAYS(i).Level*g*TRAYS(i).rhoL + 1e-8 * 'atm')/(TRAYS(i).rhoV*alfa))*Ah;
1707                when TRAYS(i).InletV.P < TRAYS(i).OutletV.P + TRAYS(i).Level*g*TRAYS(i).rhoL switchto "off";
1708               
1709                case "off":
1710                TRAYS(i).InletV.F = 0 * 'mol/s';
1711                when TRAYS(i).InletV.P > TRAYS(i).OutletV.P + TRAYS(i).Level*g*TRAYS(i).rhoL + 3e-2 * 'atm' switchto "on";
1712        end
1713
1714end
1715
1716# Connecting Trays
1717        FeedTray.F*FeedTrayIndex= TRAYS.Inlet.F;
1718        FeedTray.T = TRAYS.Inlet.T;
1719        FeedTray.P = TRAYS.Inlet.P;
1720        FeedTray.z = TRAYS.Inlet.z;
1721        FeedTray.v = TRAYS.Inlet.v;
1722        FeedTray.h = TRAYS.Inlet.h;
1723
1724        HeatToReboiler  = REBOILER.InletQ;
1725        HeatToCondenser = CONDENSER.InletQ;
1726
1727"Reboiler Temperature indicator"
1728        TRI * 'K' = REBOILER.OutletL.T;
1729
1730"Reboiler Level indicator"
1731        LRI*REBOILER.V = REBOILER.Level*REBOILER.Across;
1732
1733"Condenser Temperature indicator"
1734        TCI * 'K' = CONDENSER.OutletL.T;
1735
1736"Condenser Level indicator"
1737        LCI*CONDENSER.V = CONDENSER.Level*CONDENSER.Across;
1738
1739# Condenser Connector Equations
1740        ConnectorCondenserVout.T = VapourDistillate.T;
1741        ConnectorCondenserVout.P = VapourDistillate.P;
1742        ConnectorCondenserVout.F = VapourDistillate.F;
1743        ConnectorCondenserVout.z = VapourDistillate.z;
1744
1745# Splitter Connector Equations
1746        ConnectorSplitterOut.T = LiquidDistillate.T;
1747        ConnectorSplitterOut.P = LiquidDistillate.P;
1748        ConnectorSplitterOut.F = LiquidDistillate.F;
1749        ConnectorSplitterOut.z = LiquidDistillate.z;
1750
1751# Reboiler Connector Equations
1752        ConnectorReboilerLout.T = BottomProduct.T;
1753        ConnectorReboilerLout.P = BottomProduct.P;
1754        ConnectorReboilerLout.F = BottomProduct.F;
1755        ConnectorReboilerLout.z = BottomProduct.z;
1756
1757        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1758        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1759        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1760        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1761
1762        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1763        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1764        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1765        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1766
1767        VapourDrawOffFlow = VapourDrawOff.F;
1768        LiquidDrawOffFlow = LiquidDrawOff.F;
1769
1770end
1771
1772Model Packed_Section_ColumnBasic
1773        ATTRIBUTES
1774        Pallete         = false;
1775        Icon            = "icon/PackedSectionColumn";
1776        Brief           = "Model of a packed column section.";
1777        Info            =
1778"== Model of a packed column section containing ==
1779* NStages theoretical stages.
1780       
1781== Specify ==
1782* the feed stream of each tray (Inlet);
1783* the InletL stream of the top tray;
1784* the InletV stream of the bottom tray;
1785* the total pressure drop (dP) of the section.
1786       
1787== Initial Conditions ==
1788* the stages temperature (OutletL.T);
1789* the stages liquid holdup;
1790* (NoComps - 1) OutletL (OR OutletV) compositions for each tray.
1791";
1792       
1793PARAMETERS
1794
1795        outer PP                as Plugin(Brief = "External Physical Properties", Type="PP");
1796        outer NComp     as Integer;
1797       
1798        NumberOfStages                                  as Integer      (Brief="Number of Stages", Default=3);
1799        FeedStageIndex(NumberOfStages)  as Integer      (Brief="Number of Stages", Default=0,Hidden=true);
1800        FeedStageLocation                               as Integer      (Brief="Feed Stage Location", Default=2);
1801       
1802        PackingHeight           as length               (Brief="Height of packing");
1803        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
1804        ColumnDiameter          as length               (Brief="Column diameter");
1805        VoidFraction            as Real                 (Brief="Void fraction of packing, m^3/m^3");
1806        ResistanceCoeff         as positive     (Brief="Resistance coefficient on the liquid load", Default=1);
1807        AreaPerPackingVol       as Real                 (Brief="surface area per packing volume", Unit='m^2/m^3');
1808       
1809        V                               as volume               (Brief="Total Volume of the tray",Hidden=true);
1810        g                               as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
1811        hs                              as length               (Brief="Height of the packing stage",Hidden=true);
1812        ColumnArea              as area                 (Brief="Column Sectional Cross Area",Hidden=true);
1813
1814VARIABLES
1815#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1816# Stages Initialization For the Whole Column Section
1817#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1818        INITIALIZATION          as InitializeStage      (Brief = "Column Model Initialization");
1819        in      FeedStage       as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
1820       
1821        STAGES(NumberOfStages) as packedStage;
1822        PressureDrop               as pressure;
1823       
1824SET
1825        FeedStageIndex(FeedStageLocation) =1;
1826       
1827        ColumnArea = ColumnDiameter^2*3.14159*0.25;
1828        hs =PackingHeight/NumberOfStages;       
1829        V = hs * ColumnArea;
1830       
1831CONNECTIONS
1832
1833        STAGES([2:NumberOfStages]).OutletV              to STAGES([1:NumberOfStages-1]).InletV;
1834        STAGES([1:NumberOfStages-1]).OutletL    to STAGES([2:NumberOfStages]).InletL;
1835
1836EQUATIONS
1837# Connecting STAGES
1838        FeedStage.F*FeedStageIndex= STAGES.Inlet.F;
1839        FeedStage.T = STAGES.Inlet.T;
1840        FeedStage.P = STAGES.Inlet.P;
1841        FeedStage.z = STAGES.Inlet.z;
1842        FeedStage.v = STAGES.Inlet.v;
1843        FeedStage.h = STAGES.Inlet.h;
1844
1845        STAGES.deltaP = PressureDrop/NumberOfStages;
1846
1847for i in [1:NumberOfStages] do
1848
1849"Energy Balance"
1850        diff(STAGES(i).E) = ( STAGES(i).Inlet.F*STAGES(i).Inlet.h + STAGES(i).InletL.F*STAGES(i).InletL.h + STAGES(i).InletV.F*STAGES(i).InletV.h- STAGES(i).OutletL.F*STAGES(i).OutletL.h
1851        - STAGES(i).OutletV.F*STAGES(i).OutletV.h + HeatSupply );
1852       
1853"Energy Holdup"
1854        STAGES(i).E = STAGES(i).ML*STAGES(i).OutletL.h + STAGES(i).MV*STAGES(i).OutletV.h - STAGES(i).OutletL.P*V;
1855       
1856"Geometry Constraint"
1857        V*VoidFraction= STAGES(i).ML*STAGES(i).vL + STAGES(i).MV*STAGES(i).vV;
1858       
1859"Volume flow rate of vapor, m^3/m^2/s"
1860        STAGES(i).uV * ((ColumnArea)*VoidFraction - STAGES(i).Al) = STAGES(i).OutletV.F * STAGES(i).vV;
1861       
1862"Liquid holdup"
1863        STAGES(i).hl = STAGES(i).ML*STAGES(i).vL/V/VoidFraction;
1864       
1865"Particle diameter"
1866        STAGES(i).dp = 6 * (1-VoidFraction)/AreaPerPackingVol;
1867       
1868"Wall Factor"
1869        STAGES(i).invK = (1 + (2*STAGES(i).dp/(3*ColumnDiameter*(1-VoidFraction))));
1870       
1871"Reynolds number of the vapor stream"
1872        STAGES(i).Rev*STAGES(i).invK = STAGES(i).dp*STAGES(i).uV*STAGES(i).rhoV / (STAGES(i).miV*(1-VoidFraction));
1873       
1874"Pressure drop and Vapor flow"
1875        STAGES(i).deltaP/hs  = ResistanceCoeff*AreaPerPackingVol*STAGES(i).uV^2*STAGES(i).rhoV*STAGES(i).invK / (2*(VoidFraction-STAGES(i).hl)^3);
1876
1877"Liquid holdup"
1878        STAGES(i).hl = (12*STAGES(i).miL*AreaPerPackingVol^2*STAGES(i).uL/STAGES(i).rhoL/g)^1/3;
1879
1880"Area occupied by the liquid"
1881        STAGES(i).Al = STAGES(i).ML*STAGES(i).vL/hs;
1882
1883end
1884
1885INITIAL
1886
1887for i in 1:NumberOfStages do
1888
1889"The initial temperature of the STAGES"
1890        STAGES(i).OutletL.T = INITIALIZATION.TopStageTemperature+(INITIALIZATION.BottomStageTemperature-INITIALIZATION.TopStageTemperature)*((i-1)/(NumberOfStages-1));
1891
1892"The Liquid Holdup of the STAGES"
1893        STAGES(i).ML = INITIALIZATION.LiquidMolarHoldup;
1894
1895end
1896
1897for i in 1:NComp-1 do
1898       
1899for j in 1:NumberOfStages do
1900
1901"The initial composition of the TRAYS"
1902        STAGES(j).OutletL.z(i) = INITIALIZATION.TopStageComposition(i)/sum(INITIALIZATION.TopStageComposition) +(INITIALIZATION.BottomStageComposition(i)/sum(INITIALIZATION.BottomStageComposition)-INITIALIZATION.TopStageComposition(i)/sum(INITIALIZATION.TopStageComposition) )*((j-1)/(NumberOfStages-1));
1903
1904end
1905
1906end
1907
1908end
1909
1910Model Packed_Section_Column as Packed_Section_ColumnBasic
1911
1912        ATTRIBUTES
1913        Pallete         = true;
1914        Icon            = "icon/PackedSectionColumn";
1915        Brief           = "Model of a packed column section.";
1916        Info            =
1917"== Model of a packed column section containing ==
1918* NStages theoretical stages.
1919       
1920== Specify ==
1921* the feed stream of each tray (Inlet);
1922* the InletL stream of the top tray;
1923* the InletV stream of the bottom tray;
1924* the total pressure drop (dP) of the section.
1925       
1926== Initial Conditions ==
1927* the stages temperature (OutletL.T);
1928* the stages liquid holdup;
1929* (NoComps - 1) OutletL (OR OutletV) compositions for each tray.
1930";
1931
1932VARIABLES
1933
1934        in              LiquidInlet             as      stream                          (Brief="Liquid Inlet in the section", PosX=0.70, PosY=0);
1935        out     VapourOutlet            as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.30, PosY=0);
1936       
1937        in              VapourInlet             as stream                               (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1);
1938        out     LiquidOutlet            as liquid_stream                (Brief="Liquid Outlet in the section", PosX=0.70, PosY=1);
1939       
1940        LiquidConnector as stream       (Brief="Liquid connection at the middle STAGES", PosX=0.75, PosY=1,Hidden=true);
1941        VapourConnector as stream       (Brief="Vapour connection at the middle STAGES", PosX=0.55, PosY=0,Hidden=true);
1942
1943CONNECTIONS
1944
1945        LiquidConnector to STAGES(1).InletL;
1946        VapourConnector to STAGES(NumberOfStages).InletV;
1947       
1948EQUATIONS
1949
1950        LiquidConnector.F= LiquidInlet.F;
1951        LiquidConnector.T = LiquidInlet.T;
1952        LiquidConnector.P = LiquidInlet.P;
1953        LiquidConnector.z = LiquidInlet.z;
1954        LiquidConnector.v = LiquidInlet.v;
1955        LiquidConnector.h = LiquidInlet.h;
1956       
1957        VapourConnector.F= VapourInlet.F;
1958        VapourConnector.T = VapourInlet.T;
1959        VapourConnector.P = VapourInlet.P;
1960        VapourConnector.z = VapourInlet.z;
1961        VapourConnector.v = VapourInlet.v;
1962        VapourConnector.h = VapourInlet.h;
1963       
1964        LiquidOutlet.F= STAGES(NumberOfStages).OutletL.F;
1965        LiquidOutlet.T = STAGES(NumberOfStages).OutletL.T;
1966        LiquidOutlet.P = STAGES(NumberOfStages).OutletL.P;
1967        LiquidOutlet.z = STAGES(NumberOfStages).OutletL.z;
1968       
1969        VapourOutlet.F= STAGES(1).OutletV.F;
1970        VapourOutlet.T = STAGES(1).OutletV.T;
1971        VapourOutlet.P = STAGES(1).OutletV.P;
1972        VapourOutlet.z = STAGES(1).OutletV.z;
1973
1974end
1975
1976Model PackedDistillation_kettle_cond as Packed_Section_ColumnBasic
1977        ATTRIBUTES
1978        Pallete         = true;
1979        Icon            = "icon/PackedDistillationKettleCond";
1980        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
1981        Info            =
1982"== Specify ==
1983* the feed stream of each tray (Inlet);
1984* the pump pressure difference;
1985* the total pressure drop (dP) of the packing;
1986* the heat supllied in reboiler and condenser;
1987* the condenser vapor outlet flow (OutletV.F);
1988* the reboiler liquid outlet flow (OutletL.F);
1989* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1990       
1991== Initial Conditions ==
1992* the stages temperature (OutletL.T);
1993* the stages initial molar holdup;
1994* (NoComps - 1) OutletL (OR OutletV) compositions for each stage;
1995       
1996* the condenser temperature (OutletL.T);
1997* the condenser liquid level (Level);
1998* (NoComps - 1) OutletL (OR OutletV) compositions;
1999       
2000* the reboiler temperature (OutletL.T);
2001* the reboiler liquid level (Level);
2002* (NoComps - 1) OutletL (OR OutletV) compositions.
2003";
2004       
2005PARAMETERS
2006
2007        VapourFlow as Switcher  (Valid = ["on", "off"], Hidden = true ,Default = "on");
2008       
2009VARIABLES
2010#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2011# Column Devices
2012#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2013        CONDENSER       as condenser    (Brief="dymamic condenser");
2014        REBOILER        as reboiler             (Brief="kettle reboiler");
2015        SPLITTER        as splitter             (Brief="splitter which separate reflux and distillate");
2016        PUMP            as pump                 (Brief="pump in reflux stream");
2017#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2018# Heat Ports
2019#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2020        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler",Protected = true, PosX=1, PosY=0.885);
2021        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", Protected = true, PosX=1, PosY=0.034);
2022#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023# Column Products
2024#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2025        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.66, PosY=0);
2026        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
2027        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.68, PosY=1);
2028#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2029# Column Connectors
2030#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
2031        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
2032        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
2033        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
2034                ConnectorHeatReboiler   as power        (Brief="Heat supplied to Reboiler", Hidden=true);
2035                ConnectorHeatCondenser  as power        (Brief="Heat supplied to Condenser", Hidden=true);
2036
2037CONNECTIONS
2038
2039#vapor
2040        REBOILER.OutletV                to STAGES(NumberOfStages).InletV;
2041        STAGES(1).OutletV               to CONDENSER.InletV;
2042
2043#liquid
2044        CONDENSER.OutletL                               to SPLITTER.Inlet;     
2045        SPLITTER.Outlet2                                to PUMP.Inlet;
2046        PUMP.Outlet                                     to STAGES(1).InletL;
2047        STAGES(NumberOfStages).OutletL  to REBOILER.InletL;
2048
2049#Connectors
2050ConnectorHeatReboiler   to REBOILER.InletQ;
2051ConnectorHeatCondenser  to CONDENSER.InletQ;
2052
2053CONDENSER.OutletV               to ConnectorCondenserVout;
2054SPLITTER.Outlet1                to ConnectorSplitterOut;
2055REBOILER.OutletL                to ConnectorReboilerLout;
2056
2057EQUATIONS
2058        HeatToReboiler  = ConnectorHeatReboiler;
2059        HeatToCondenser = ConnectorHeatCondenser;
2060       
2061# Condenser Connector Equations
2062        ConnectorCondenserVout.T = VapourDistillate.T;
2063        ConnectorCondenserVout.P = VapourDistillate.P;
2064        ConnectorCondenserVout.F = VapourDistillate.F;
2065        ConnectorCondenserVout.z = VapourDistillate.z;
2066
2067# Splitter Connector Equations
2068        ConnectorSplitterOut.T = LiquidDistillate.T;
2069        ConnectorSplitterOut.P = LiquidDistillate.P;
2070        ConnectorSplitterOut.F = LiquidDistillate.F;
2071        ConnectorSplitterOut.z = LiquidDistillate.z;
2072
2073# Reboiler Connector Equations
2074        ConnectorReboilerLout.T = BottomProduct.T;
2075        ConnectorReboilerLout.P = BottomProduct.P;
2076        ConnectorReboilerLout.F = BottomProduct.F;
2077        ConnectorReboilerLout.z = BottomProduct.z;
2078
2079switch VapourFlow
2080        case "on":
2081                STAGES(NumberOfStages).InletV.F*STAGES(NumberOfStages).vV = sqrt((REBOILER.OutletV.P - STAGES(NumberOfStages).OutletV.P)/
2082                                        (STAGES(NumberOfStages).rhoV*ResistanceCoeff*20))*(ColumnArea*VoidFraction - STAGES(NumberOfStages).Al);
2083                when STAGES(NumberOfStages).InletV.F < 1e-6 * 'kmol/h' switchto "off";
2084
2085        case "off":
2086                STAGES(NumberOfStages).InletV.F = 0 * 'mol/s';
2087                when REBOILER.OutletV.P > STAGES(NumberOfStages).OutletV.P + 1e-1 * 'atm' switchto "on";
2088end
2089
2090end
2091
Note: See TracBrowser for help on using the repository browser.