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

Last change on this file since 715 was 715, checked in by gerson bicca, 14 years ago

some modifications on column model

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