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

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

some modifications on column model

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