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

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

updates

File size: 61.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
40#*----------------------------------------------------------------------
41* Model of a  column section with:
42*       - NumberOfTrays = number of trays.
43*
44*---------------------------------------------------------------------*#
45Model Section_ColumnBasic
46
47ATTRIBUTES
48        Pallete         = false;
49        Icon            = "icon/SectionColumn";
50        Brief   = "Model of a column section.";
51        Info            =
52"== Model of a column section containing ==
53* NumberOfTrays trays.
54       
55== Specify ==
56* the feed stream of each tray (Inlet);
57* the Murphree eficiency for each tray Emv;
58* the InletL stream of the top tray;
59* the InletV stream of the bottom tray.
60       
61== Initial Conditions ==
62* the trays temperature (OutletL.T);
63* the trays liquid level (Level) OR the trays liquid flow (OutletL.F);
64* (NoComps - 1) OutletL (OR OutletV) compositions for each tray.
65";
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="Number of trays", Default=0,Hidden=true);
72        LiqSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Number of trays", Default=0,Hidden=true);
73        VapSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Number of trays", 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        TopTemperature          as temperature;
96        TbottomTemperature      as temperature;
97        LevelFraction                   as fraction     (Brief = "Level Fraction");
98
99        TopComposition(NComp)                   as fraction     (Brief = "Component Molar Fraction at Top");
100        BottomComposition(NComp)                as fraction     (Brief = "Component Molar Fraction at Bottom");
101       
102        V                                       as volume               (Brief="Total Volume of the tray",Hidden=true);
103        Q                                       as heat_rate    (Brief="Rate of heat supply",Hidden=true);
104        Ap                              as area                         (Brief="Plate area = Atray - Adowncomer",Hidden=true);
105
106        Ah                              as area                                 (Brief="Total holes area",Hidden=true);
107        lw                              as length                       (Brief="Weir length",Hidden=true);
108        hw                              as length                       (Brief="Weir height",Hidden=true);
109        beta                            as fraction             (Brief="Aeration fraction");
110        alfa                            as fraction             (Brief="Dry pressure drop coefficient");
111        w                                       as Real                         (Brief="Feeherys correlation coefficient", Unit='1/m^4', Default=1,Hidden=true);
112        btray                   as Real                         (Brief="Elgues correlation coefficient", Unit='kg/m/mol^2', Default=1,Hidden=true);
113        fw                              as Real                         (Brief="Olsens correlation coefficient", Default=1,Hidden=true);
114        Np                              as Real                         (Brief="Number of liquid passes in the tray", Default=1,Hidden=true);
115       
116        VapourFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
117        LiquidFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
118
119SET
120        FeedTrayIndex(FeedTrayLocation) =1;
121        VapSideTrayIndex(FeedTrayLocation) =1;
122        LiqSideTrayIndex(FeedTrayLocation) =1;
123        Mw = PP.MolecularWeight();
124
125        V=VolumeOfTray;
126        Q=HeatSupply;
127        Ap=PlateArea;
128        Ah=HolesArea;
129        lw=WeirLength;
130        hw=WeirHeight ;
131        w=FeeheryCoeff;
132        btray=ElgueCoeff;
133        fw=OlsenCoeff;
134        Np=TrayLiquidPasses;
135
136VARIABLES
137
138        in      FeedTray                                as stream                               (Brief="Feed stream", PosX=0, PosY=0.55);
139       
140        TRAYS(NumberOfTrays) as tray                    (Brief="Number of trays");
141
142                VapourDrawOffFlow  as flow_mol                  (Brief = "Stream Molar Flow Rate");
143                LiquidDrawOffFlow   as flow_mol                         (Brief = "Stream Molar Flow Rate");
144
145        MurphreeEff                             as Real         (Brief = "Murphree efficiency");
146
147CONNECTIONS
148
149        TRAYS([2:NumberOfTrays]).OutletV        to TRAYS([1:NumberOfTrays-1]).InletV;
150        TRAYS([1:NumberOfTrays-1]).OutletL      to TRAYS([2:NumberOfTrays]).InletL;
151       
152       
153EQUATIONS
154# Connecting Trays
155        FeedTray.F*FeedTrayIndex= TRAYS.Inlet.F;
156        FeedTray.T = TRAYS.Inlet.T;
157        FeedTray.P = TRAYS.Inlet.P;
158        FeedTray.z = TRAYS.Inlet.z;
159        FeedTray.v = TRAYS.Inlet.v;
160        FeedTray.h = TRAYS.Inlet.h;
161       
162for i in [1:NumberOfTrays] do
163
164"Murphree Efficiency"
165        TRAYS(i).OutletV.z =  MurphreeEff * (TRAYS(i).yideal - TRAYS(i).InletV.z) + TRAYS(i).InletV.z;
166
167"Level of clear liquid over the weir"
168        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/Ap;
169
170"Geometry Constraint"
171        V = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
172
173"Energy Holdup"
174        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletL.h + TRAYS(i).MV*TRAYS(i).OutletV.h - TRAYS(i).OutletL.P*V;
175
176"Energy Balance"
177        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
178        -TRAYS(i).VapourSideStream.F*TRAYS(i).VapourSideStream.h - TRAYS(i).LiquidSideStream.F*TRAYS(i).LiquidSideStream.h + Q );
179
180switch LiquidFlow
181                case "on":
182                        switch LiquidFlowModel
183                                case "default":
184                                "Francis Equation"
185                                TRAYS(i).OutletL.F*TRAYS(i).vL = 1.84*'1/s'*lw*((TRAYS(i).Level-(beta*hw))/(beta))^2;
186                       
187                                case "Wang_Fl":
188                                TRAYS(i).OutletL.F*TRAYS(i).vL = 1.84*'m^0.5/s'*lw*((TRAYS(i).Level-(beta*hw))/(beta))^1.5;
189                       
190                                case "Olsen":
191                                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';
192                       
193                                case "Feehery_Fl":
194                                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';
195                       
196                                case "Roffel_Fl":
197                                TRAYS(i).OutletL.F = 2/3*sqrt(2*g)*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletL.z)*lw*(2*TRAYS(i).btemp-1)*(TRAYS(i).ML*sum(Mw*TRAYS(i).OutletL.z)/(Ap*1.3)/TRAYS(i).rhoL/(2*TRAYS(i).btemp-1))^1.5;
198                        end
199                when TRAYS(i).Level < (beta *hw) switchto "off";
200               
201                case "off":
202                "Low level"
203                TRAYS(i).OutletL.F = 0 * 'mol/h';
204                when TRAYS(i).Level > (beta * hw) + 1e-6*'m' switchto "on";
205        end
206       
207        TRAYS(i).btemp = 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; #/'(kg/m)^0.0888545/s^0.177709';
208
209switch VapourFlow
210                case "on":
211                        switch VapourFlowModel
212                                case "Reepmeyer":
213                                TRAYS(i).InletV.F*TRAYS(i).vV = sqrt((TRAYS(i).InletV.P - TRAYS(i).OutletV.P)/(TRAYS(i).rhoV*alfa))*Ah;
214                       
215                                case "Feehery_Fv":
216                                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);
217                       
218                                case "Roffel_Fv":
219                                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';
220                       
221                                case "Klingberg":
222                                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);
223                       
224                                case "Wang_Fv":
225                                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);
226                               
227                                case "Elgue":
228                                TRAYS(i).InletV.F  = sqrt((TRAYS(i).InletV.P - TRAYS(i).OutletV.P)/btray);
229                        end
230                when TRAYS(i).InletV.F < 1e-6 * 'kmol/h' switchto "off";
231               
232                case "off":
233                TRAYS(i).InletV.F = 0 * 'mol/s';
234                when TRAYS(i).InletV.P > TRAYS(i).OutletV.P + TRAYS(i).Level*g*TRAYS(i).rhoL + 1e-1 * 'atm' switchto "on";
235        end
236
237end
238
239INITIAL
240
241for i in 1:NumberOfTrays do
242       
243"The initial temperature of the TRAYS"
244        TRAYS(i).OutletL.T = TopTemperature+(TbottomTemperature-TopTemperature)*((i-1)/(NumberOfTrays-1));
245
246"The initial Level of the TRAYS"
247        TRAYS(i).Level = LevelFraction*hw;
248
249end
250
251for i in 1:NComp-1 do
252       
253for j in 1:NumberOfTrays do
254
255"The initial composition of the TRAYS"
256        TRAYS(j).OutletL.z(i) = TopComposition(i) +(BottomComposition(i)-TopComposition(i) )*((j-1)/(NumberOfTrays-1));
257
258end
259
260end
261
262end
263
264Model Section_Column as Section_ColumnBasic
265
266ATTRIBUTES
267        Pallete         = true;
268        Icon            = "icon/SectionColumn";
269        Brief   = "Model of a column section.";
270        Info            =
271"== Model of a column section containing ==
272* NumberOfTrays TRAYS.
273       
274== Specify ==
275* the feed stream of each tray (Inlet);
276* the Murphree eficiency for each tray Emv;
277* the InletL stream of the top tray;
278* the InletV stream of the bottom tray.
279       
280== Initial Conditions ==
281* the TRAYS temperature (OutletL.T);
282* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
283* (NoComps - 1) OutletL (OR OutletV) compositions for each tray.
284";
285
286VARIABLES
287
288        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.35,Protected = true);
289        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.65,Protected = true);
290       
291        in              LiquidInlet             as      stream                          (Brief="Liquid Inlet in the section", PosX=0.70, PosY=0);
292        out     VapourOutlet            as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.30, PosY=0);
293       
294        in              VapourInlet             as stream                               (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1);
295        out     LiquidOutlet            as liquid_stream                (Brief="Liquid Outlet in the section", PosX=0.70, PosY=1);
296       
297        LiquidConnector as stream       (Brief="Liquid connection at the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
298        VapourConnector as stream       (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
299
300CONNECTIONS
301
302        LiquidConnector to TRAYS(1).InletL;
303        VapourConnector to TRAYS(NumberOfTrays).InletV;
304       
305EQUATIONS
306
307        LiquidConnector.F= LiquidInlet.F;
308        LiquidConnector.T = LiquidInlet.T;
309        LiquidConnector.P = LiquidInlet.P;
310        LiquidConnector.z = LiquidInlet.z;
311        LiquidConnector.v = LiquidInlet.v;
312        LiquidConnector.h = LiquidInlet.h;
313       
314        VapourConnector.F= VapourInlet.F;
315        VapourConnector.T = VapourInlet.T;
316        VapourConnector.P = VapourInlet.P;
317        VapourConnector.z = VapourInlet.z;
318        VapourConnector.v = VapourInlet.v;
319        VapourConnector.h = VapourInlet.h;
320       
321        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletL.F;
322        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletL.T;
323        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletL.P;
324        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletL.z;
325       
326        VapourOutlet.F= TRAYS(1).OutletV.F;
327        VapourOutlet.T = TRAYS(1).OutletV.T;
328        VapourOutlet.P = TRAYS(1).OutletV.P;
329        VapourOutlet.z = TRAYS(1).OutletV.z;
330
331        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
332        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
333        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
334        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
335
336        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
337        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
338        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
339        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
340
341        VapourDrawOffFlow = VapourDrawOff.F;
342        LiquidDrawOffFlow = LiquidDrawOff.F;
343
344end
345
346#*----------------------------------------------------------------------
347* Model of a  distillation column containing:
348*       - NumberOfTrays like tray;
349*       - a kettle reboiler;
350*       - dynamic condenser;
351*       - a splitter which separate reflux and distillate;
352*       - a pump in reflux stream;
353*--------------------------------------------------------------------- *#
354Model Distillation_kettle_cond as Section_ColumnBasic
355        ATTRIBUTES
356        Pallete         = true;
357        Icon            = "icon/DistillationKettleCond";
358        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
359        Info            =
360"== Specify ==
361* the feed stream of each tray (Inlet);
362* the Murphree eficiency for each tray Emv;
363* the pump pressure difference;
364* the heat supllied in reboiler and condenser;
365* the condenser vapor outlet flow (OutletV.F);
366* the reboiler liquid outlet flow (OutletL.F);
367* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
368       
369== Initial Conditions ==
370* the TRAYS temperature (OutletL.T);
371* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
372* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
373       
374* the condenser temperature (OutletL.T);
375* the condenser liquid level (Level);
376* (NoComps - 1) OutletL (OR OutletV) compositions;
377       
378* the reboiler temperature (OutletL.T);
379* the reboiler liquid level (Level);
380* (NoComps - 1) OutletL (OR OutletV) compositions.
381";
382       
383PARAMETERS
384        CondenserVapourFlow             as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
385
386VARIABLES
387        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.46,Protected = true);
388        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.58,Protected = true);
389       
390        CONDENSER       as condenser;
391        REBOILER                as reboiler;
392        SPLITTERtop     as splitter;
393        PUMP                            as pump;
394        alfaTopo                                as Real;
395
396out             HeatToReboiler          as power                                (Brief="Heat supplied to Reboiler",Hidden=true);
397out             HeatToCondenser         as power                                (Brief="Heat supplied to Condenser",Hidden=true);
398
399RebNoFlow       as sourceNoFlow (Brief="No Inlet Flow to Reboiler",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       
457CONNECTIONS
458#vapor
459        REBOILER.OutletV        to      TRAYS(NumberOfTrays).InletV;
460        TRAYS(1).OutletV                                to      CONDENSER.InletV;
461
462#liquid
463        CONDENSER.OutletL               to      SPLITTERtop.Inlet;     
464        SPLITTERtop.Outlet2                             to      PUMP.Inlet;
465        PUMP.Outlet                                     to      TRAYS(1).InletL;
466        TRAYS(NumberOfTrays).OutletL    to      REBOILER.InletL;
467
468#Connectors
469HeatToReboiler  to REBOILER.InletQ;
470HeatToCondenser         to CONDENSER.InletQ;
471RebNoFlow.Outlet  to REBOILER.Inlet;
472
473CONDENSER.OutletV to ConnectorCondenserVout;
474SPLITTERtop.Outlet1             to ConnectorSplitterOut;
475REBOILER.OutletL        to ConnectorReboilerLout;
476
477end
478
479
480#* -------------------------------------------------------------------
481* Distillation Column model with:
482*
483*       - NumberOfTrays like tray;
484*       - a vessel in the bottom of column;
485*       - a splitter who separate the bottom product and the stream to reboiler;
486*       - steady state reboiler (thermosyphon);
487*       - a steady state condenser with subcooling;
488*       - a vessel drum (layed cilinder);
489*       - a splitter which separate reflux and distillate;
490*       - a pump in reflux stream.
491*
492* ------------------------------------------------------------------*#
493Model Distillation_thermosyphon_subcooling as Section_ColumnBasic
494        ATTRIBUTES
495        Pallete         = true;
496        Icon            = "icon/DistillationThermosyphonSubcooling";
497        Brief           = "Model of a distillation column with steady condenser and steady reboiler.";
498        Info            =
499"== Specify ==
500* the feed stream of each tray (Inlet);
501* the Murphree eficiency for each tray Emv;
502* the pump head;
503* the condenser pressure drop;
504* the heat supllied in top and bottom tanks;
505* the heat supllied in condenser and reboiler;
506* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
507* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
508       
509== Initial Conditions ==
510* the TRAYS temperature (OutletL.T);
511* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
512* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
513       
514* the top tank temperature (OutletL.T);
515* the top tank liquid level (Level);
516* (NoComps - 1) OutletL (OR OutletV) compositions;
517       
518* the bottom tank temperature (OutletL.T);
519* the bottom tank liquid level (Level);
520* (NoComps - 1) OutletL (OR OutletV) compositions.
521";
522
523PARAMETERS
524
525        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Hidden=true, Default = "on");
526
527VARIABLES
528
529        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.41,Protected = true);
530        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.515,Protected = true);
531
532        CONDENSER               as condenserSteady;
533        TANKtop                                 as tank_cylindrical;
534        SPLITTERtop             as splitter;
535        PUMP                                    as pump;
536        REBOILER                        as reboilerSteady;
537        TANKbottom                      as tank;
538        SPLITTERbottom  as splitter;
539        alfaTopo                                        as Real;
540
541out             HeatToCondenser         as power                                (Brief="Heat supplied to Condenser",Hidden=true);
542out             HeatToReboiler                  as power                                (Brief="Heat supplied to Reboiler",Hidden=true);
543out             HeatToBottomVessel      as power                                (Brief="Heat supplied to Bottom Vessel",Hidden=true);
544out             HeatToTopVessel         as power                                (Brief="Heat supplied to Top Vessel",Hidden=true);
545
546out     LiquidDistillate                                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.30);
547in              ConnectorSplitterTop            as stream                       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
548
549out     BottomProduct                                   as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=1, PosY=0.99);
550in              ConnectorSplitterBottom         as stream                       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
551
552EQUATIONS
553
554# Top Splitter Connector Equations
555        ConnectorSplitterTop.T = LiquidDistillate.T;
556        ConnectorSplitterTop.P = LiquidDistillate.P;
557        ConnectorSplitterTop.F = LiquidDistillate.F;
558        ConnectorSplitterTop.z = LiquidDistillate.z;
559
560# Bottom Splitter Connector Equations
561        ConnectorSplitterBottom.T = BottomProduct.T;
562        ConnectorSplitterBottom.P = BottomProduct.P;
563        ConnectorSplitterBottom.F = BottomProduct.F;
564        ConnectorSplitterBottom.z = BottomProduct.z;
565
566        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
567        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
568        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
569        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
570
571        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
572        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
573        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
574        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
575
576        VapourDrawOffFlow = VapourDrawOff.F;
577        LiquidDrawOffFlow = LiquidDrawOff.F;
578
579switch CondenserVapourFlow
580
581        case "on":
582                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletV.P -
583                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
584                when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
585
586        case "off":
587                CONDENSER.InletV.F = 0 * 'mol/s';
588                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
589
590end     
591
592CONNECTIONS
593#vapor
594        REBOILER.OutletV        to TRAYS(NumberOfTrays).InletV;
595        TRAYS(1).OutletV                        to CONDENSER.InletV;
596
597#liquid
598        CONDENSER.OutletL                               to TANKtop.Inlet;       
599        TANKtop.Outlet                                                  to SPLITTERtop.Inlet;
600        SPLITTERtop.Outlet2                             to PUMP.Inlet; 
601        PUMP.Outlet                                                             to TRAYS(1).InletL;
602        TRAYS(NumberOfTrays).OutletL    to TANKbottom.Inlet;
603        TANKbottom.Outlet                                       to SPLITTERbottom.Inlet;
604        SPLITTERbottom.Outlet2                          to REBOILER.InletL;
605
606#Connectors
607HeatToCondenser                         to CONDENSER.InletQ;
608HeatToReboiler                          to REBOILER.InletQ;
609HeatToBottomVessel      to TANKbottom.InletQ;
610HeatToTopVessel                 to TANKtop.InletQ;
611SPLITTERtop.Outlet1     to ConnectorSplitterTop;
612SPLITTERbottom.Outlet1  to ConnectorSplitterBottom;
613
614end
615
616
617#* -------------------------------------------------------------------
618* Distillation Column model with:
619*
620*       - NumberOfTrays like tray;
621*       - a vessel in the bottom of column;
622*       - a splitter who separate the bottom product and the stream to reboiler;
623*       - steady state reboiler (thermosyphon);
624*       - a dynamic condenser without subcooling;
625*       - a splitter which separate reflux and distillate;
626*       - a pump in reflux stream.
627*
628* ------------------------------------------------------------------*#
629Model Distillation_thermosyphon_cond as Section_ColumnBasic
630        ATTRIBUTES
631        Pallete         = true;
632        Icon            = "icon/DistillationThermosyphonCond";
633        Brief           = "Model of a distillation column with dynamic condenser and steady reboiler.";
634        Info            =
635"== Specify ==
636* the feed stream of each tray (Inlet);
637* the Murphree eficiency for each tray Emv;
638* the pump head;
639* the condenser vapor outlet flow (OutletV.F);
640* the heat supllied in bottom tank;
641* the heat supllied in condenser and reboiler;
642* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
643       
644== Initial Conditions ==
645* the TRAYS temperature (OutletL.T);
646* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
647* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
648       
649* the condenser temperature (OutletL.T);
650* the condenser liquid level (Level);
651* (NoComps - 1) OutletL (OR OutletV) compositions;
652       
653* the bottom tank temperature (OutletL.T);
654* the bottom tank liquid level (Level);
655* (NoComps - 1) OutletL (OR OutletV) compositions.
656";
657
658PARAMETERS
659        CondenserVapourFlow     as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
660
661VARIABLES
662
663        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.41,Protected = true);
664        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.515,Protected = true);
665       
666        CONDENSER as condenser;
667        SPLITTERtop             as splitter;
668        PUMP            as pump;
669        TANKbottom      as tank;
670        SPLITTERbottom  as splitter;
671        REBOILER        as reboilerSteady;
672        alfaTopo                        as Real;
673
674out             HeatToCondenser         as power                                (Brief="Heat supplied to Condenser",Hidden=true);
675out             HeatToReboiler                  as power                                (Brief="Heat supplied to Reboiler",Hidden=true);
676out             HeatToBottomVessel      as power                                (Brief="Heat supplied to Bottom Vessel",Hidden=true);
677
678out     VapourDistillate                                as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.74, PosY=0);
679in              ConnectorCondenserVout  as stream                               (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
680
681out     LiquidDistillate                                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.30);
682in              ConnectorSplitterTop    as stream                       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
683
684out     BottomProduct                                   as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=1, PosY=0.999);
685in              ConnectorSplitterBottom         as stream                       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
686
687EQUATIONS
688
689# Condenser Connector Equations
690        ConnectorCondenserVout.T = VapourDistillate.T;
691        ConnectorCondenserVout.P = VapourDistillate.P;
692        ConnectorCondenserVout.F = VapourDistillate.F;
693        ConnectorCondenserVout.z = VapourDistillate.z;
694
695# Top Splitter Connector Equations
696        ConnectorSplitterTop.T = LiquidDistillate.T;
697        ConnectorSplitterTop.P = LiquidDistillate.P;
698        ConnectorSplitterTop.F = LiquidDistillate.F;
699        ConnectorSplitterTop.z = LiquidDistillate.z;
700
701# Bottom Splitter Connector Equations
702        ConnectorSplitterBottom.T = BottomProduct.T;
703        ConnectorSplitterBottom.P = BottomProduct.P;
704        ConnectorSplitterBottom.F = BottomProduct.F;
705        ConnectorSplitterBottom.z = BottomProduct.z;
706
707        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
708        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
709        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
710        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
711
712        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
713        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
714        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
715        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
716
717        VapourDrawOffFlow = VapourDrawOff.F;
718        LiquidDrawOffFlow = LiquidDrawOff.F;
719       
720switch CondenserVapourFlow
721                case "on":
722                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletV.P -
723                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
724                when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
725               
726                case "off":
727                CONDENSER.InletV.F = 0 * 'mol/s';
728                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
729end     
730
731CONNECTIONS
732#vapor
733        REBOILER.OutletV        to TRAYS(NumberOfTrays).InletV;
734        TRAYS(1).OutletV                                to CONDENSER.InletV;
735
736#liquid
737        CONDENSER.OutletL               to SPLITTERtop.Inlet;   
738        SPLITTERtop.Outlet2                             to PUMP.Inlet;
739        PUMP.Outlet                                     to TRAYS(1).InletL;
740        TRAYS(NumberOfTrays).OutletL    to TANKbottom.Inlet;
741        TANKbottom.Outlet                               to SPLITTERbottom.Inlet;
742        SPLITTERbottom.Outlet2                  to REBOILER.InletL;
743
744#Connectors
745HeatToCondenser                         to CONDENSER.InletQ;
746HeatToReboiler                          to REBOILER.InletQ;
747HeatToBottomVessel      to TANKbottom.InletQ;
748CONDENSER.OutletV to ConnectorCondenserVout;
749SPLITTERtop.Outlet1             to ConnectorSplitterTop;
750SPLITTERbottom.Outlet1  to ConnectorSplitterBottom;
751
752end
753
754#* -------------------------------------------------------------------
755* Distillation Column model with:
756*
757*       - NumberOfTrays like tray;
758*       - a kettle reboiler;
759*       - a steady state condenser with subcooling;
760*       - a vessel drum (layed cilinder);
761*       - a splitter which separate reflux and distillate;
762*       - a pump in reflux stream.
763*
764* ------------------------------------------------------------------*#
765Model Distillation_kettle_subcooling as Section_ColumnBasic
766
767ATTRIBUTES
768        Pallete         = true;
769        Icon            = "icon/DistillationKettleSubcooling";
770        Brief   = "Model of a distillation column with steady condenser and dynamic reboiler.";
771        Info            =
772"== Specify ==
773* the feed stream of each tray (Inlet);
774* the Murphree eficiency for each tray (Emv);
775* the pump pressure difference;
776* the heat supllied in reboiler and condenser;
777* the heat supllied in the top tank;
778* the condenser pressure drop;
779* the reboiler liquid outlet flow (OutletL.F);
780* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
781       
782== Initial Conditions ==
783* the TRAYS temperature (OutletL.T);
784* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
785* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
786       
787* the top tank temperature (OutletL.T);
788* the top tank liquid level (Level);
789* (NoComps - 1) OutletL (OR OutletV) compositions;
790       
791* the reboiler temperature (OutletL.T);
792* the reboiler liquid level (Level);
793* (NoComps - 1) OutletL (OR OutletV) compositions.
794";
795       
796PARAMETERS
797        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Default = "on",Hidden=true);
798
799VARIABLES
800        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.46,Protected = true);
801        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.58,Protected = true);
802       
803        CONDENSER as condenserSteady;
804        TANKtop as tank_cylindrical;
805        SPLITTERtop             as splitter;
806        PUMP            as pump;
807        REBOILER        as reboiler;
808        alfaTopo as Real;
809
810out             HeatToCondenser         as power                                (Brief="Heat supplied to Condenser",Hidden=true);
811out             HeatToReboiler                  as power                                (Brief="Heat supplied to Reboiler",Hidden=true);
812out             HeatToTopVessel         as power                                (Brief="Heat supplied to Top Vessel",Hidden=true);
813
814out     LiquidDistillate                                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.33);
815in              ConnectorSplitterOut    as stream                       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
816
817out     BottomProduct                           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=1, PosY=1);
818in              ConnectorReboilerLout   as stream                       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
819
820RebNoFlow       as sourceNoFlow (Brief="No Inlet Flow to Reboiler",Hidden=true);
821
822EQUATIONS
823
824# Splitter Connector Equations
825        ConnectorSplitterOut.T = LiquidDistillate.T;
826        ConnectorSplitterOut.P = LiquidDistillate.P;
827        ConnectorSplitterOut.F = LiquidDistillate.F;
828        ConnectorSplitterOut.z = LiquidDistillate.z;
829
830# Reboiler Connector Equations
831        ConnectorReboilerLout.T = BottomProduct.T;
832        ConnectorReboilerLout.P = BottomProduct.P;
833        ConnectorReboilerLout.F = BottomProduct.F;
834        ConnectorReboilerLout.z = BottomProduct.z;
835       
836        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
837        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
838        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
839        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
840
841        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
842        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
843        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
844        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
845
846        VapourDrawOffFlow = VapourDrawOff.F;
847        LiquidDrawOffFlow = LiquidDrawOff.F;
848       
849        switch CondenserVapourFlow
850                case "on":
851                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletV.P -
852                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
853                when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
854               
855                case "off":
856                CONDENSER.InletV.F = 0 * 'mol/s';
857                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
858end     
859
860CONNECTIONS
861#vapor
862        REBOILER.OutletV to TRAYS(NumberOfTrays).InletV;
863        TRAYS(1).OutletV to CONDENSER.InletV;
864
865#liquid
866        CONDENSER.OutletL               to TANKtop.Inlet;       
867        TANKtop.Outlet                                  to SPLITTERtop.Inlet;
868        SPLITTERtop.Outlet2                             to PUMP.Inlet; 
869        PUMP.Outlet                                     to TRAYS(1).InletL;
870        TRAYS(NumberOfTrays).OutletL    to REBOILER.InletL;
871
872#Connectors
873HeatToCondenser                         to CONDENSER.InletQ;
874HeatToReboiler                          to REBOILER.InletQ;
875HeatToTopVessel                         to TANKtop.InletQ;
876RebNoFlow.Outlet                to REBOILER.Inlet;
877
878SPLITTERtop.Outlet1             to ConnectorSplitterOut;
879REBOILER.OutletL        to ConnectorReboilerLout;
880
881end
882
883
884#*----------------------------------------------------------------------
885* Model of a  rectifier containing:
886*       - NumberOfTrays like tray;
887*       - dymamic condenser without subcooling;
888*       - a splitter which separate reflux and distillate;
889*       - a pump in reflux stream;
890*---------------------------------------------------------------------*#
891Model Rectifier as Section_ColumnBasic
892
893ATTRIBUTES
894        Pallete         = true;
895        Icon            = "icon/RefluxedCond";
896        Brief           = "Model of a rectifier column with dynamic condenser.";
897        Info            =
898"== Specify ==
899* the feed stream of each tray (Inlet);
900* the Murphree eficiency for each tray Emv;
901* the InletV stream of the bottom tray unless its flow;
902* the pump pressure difference;
903* the heat supllied in the condenser;
904* the condenser vapor outlet flow (OutletV.F);
905* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
906       
907== Initial Conditions ==
908* the TRAYS temperature (OutletL.T);
909* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
910* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
911       
912* the condenser temperature (OutletL.T);
913* the condenser liquid level (Level);
914* (NoComps - 1) OutletL (OR OutletV) compositions;
915";
916
917PARAMETERS
918        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Default = "on",Hidden=true);
919
920VARIABLES
921
922        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.46,Protected = true);
923        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.58,Protected = true);
924       
925        CONDENSER as condenser;
926        SPLITTERtop as splitter;
927        PUMP as pump;
928        alfaTopo as Real;
929
930out     VapourDistillate                                as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.67, PosY=0);
931in              ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
932        in              VapourInlet             as stream                               (Brief="Vapour Inlet in the section", PosX=0.07, PosY=1);
933        out     LiquidOutlet            as liquid_stream                (Brief="Liquid Outlet in the section", PosX=0.20, PosY=1);
934        out     LiquidDistillate                                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.33);
935       
936        out             HeatToCondenser         as power                                (Brief="Heat supplied to Condenser",Hidden=true);
937        in              ConnectorSplitterOut    as stream                       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
938        VapourConnector as stream       (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
939       
940EQUATIONS
941
942switch CondenserVapourFlow
943
944        case "on":
945                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletV.P -
946                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
947                when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
948               
949        case "off":
950                CONDENSER.InletV.F = 0 * 'mol/s';
951                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
952
953end     
954
955# Condenser Connector Equations
956        ConnectorCondenserVout.T = VapourDistillate.T;
957        ConnectorCondenserVout.P = VapourDistillate.P;
958        ConnectorCondenserVout.F = VapourDistillate.F;
959        ConnectorCondenserVout.z = VapourDistillate.z;
960       
961# Splitter Connector Equations
962        ConnectorSplitterOut.T = LiquidDistillate.T;
963        ConnectorSplitterOut.P = LiquidDistillate.P;
964        ConnectorSplitterOut.F = LiquidDistillate.F;
965        ConnectorSplitterOut.z = LiquidDistillate.z;
966       
967        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletL.F;
968        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletL.T;
969        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletL.P;
970        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletL.z;
971
972        VapourConnector.F= VapourInlet.F;
973        VapourConnector.T = VapourInlet.T;
974        VapourConnector.P = VapourInlet.P;
975        VapourConnector.z = VapourInlet.z;
976        VapourConnector.v = VapourInlet.v;
977        VapourConnector.h = VapourInlet.h;
978
979        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
980        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
981        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
982        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
983
984        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
985        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
986        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
987        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
988
989        VapourDrawOffFlow = VapourDrawOff.F;
990        LiquidDrawOffFlow = LiquidDrawOff.F;
991
992CONNECTIONS
993#vapor
994        TRAYS(1).OutletV to CONDENSER.InletV;
995
996#liquid
997        CONDENSER.OutletL to SPLITTERtop.Inlet;
998        SPLITTERtop.Outlet2 to PUMP.Inlet;     
999        PUMP.Outlet to TRAYS(1).InletL;
1000
1001#Connectors
1002HeatToCondenser         to CONDENSER.InletQ;
1003VapourConnector to TRAYS(NumberOfTrays).InletV;
1004SPLITTERtop.Outlet1             to ConnectorSplitterOut;
1005CONDENSER.OutletV to ConnectorCondenserVout;
1006
1007end
1008
1009
1010#* -------------------------------------------------------------------
1011* Rectifier Column with:
1012*
1013*       - NumberOfTrays like tray;
1014*       - a steady state condenser with subcooling;
1015*       - a vessel drum (layed cilinder);
1016*       - a splitter which separate reflux and distillate;
1017*       - a pump in reflux stream.
1018*
1019* ------------------------------------------------------------------*#
1020
1021Model Rectifier_subcooling as Section_ColumnBasic
1022
1023ATTRIBUTES
1024        Pallete         = true;
1025        Icon            = "icon/RefluxedSubcooling";
1026        Brief           = "Model of a rectifier column with steady condenser.";
1027        Info            =
1028"== Specify ==
1029* the feed stream of each tray (Inlet);
1030* the Murphree eficiency for each tray Emv;
1031* the InletV stream of the bottom tray unless its flow;
1032* the pump head;
1033* the condenser pressure drop;
1034* the heat supllied in  the top tank;
1035* the heat supllied in condenser;
1036* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1037       
1038== Initial Conditions ==
1039* the TRAYS temperature (OutletL.T);
1040* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
1041* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
1042       
1043* the top tank temperature (OutletL.T);
1044* the top tank liquid level (Level);
1045* (NoComps - 1) OutletL (OR OutletV) compositions;
1046";
1047       
1048PARAMETERS
1049        CondenserVapourFlow             as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
1050
1051VARIABLES
1052        CONDENSER as condenserSteady;
1053        TANKtop                 as tank_cylindrical;
1054        SPLITTERtop             as splitter;
1055        PUMP            as pump;
1056        alfaTopo                        as Real;
1057
1058        in              VapourInlet             as stream                               (Brief="Vapour Inlet in the section", PosX=0.18, PosY=1);
1059        out     LiquidOutlet            as liquid_stream                (Brief="Liquid Outlet in the section", PosX=0.25, PosY=1);
1060
1061        out             HeatToCondenser         as power                                (Brief="Heat supplied to Condenser",Hidden=true);
1062        out     LiquidDistillate                                as liquid_stream                (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.47);
1063        in              ConnectorSplitterTop            as stream                               (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1064        out             HeatToTopVessel         as power                                (Brief="Heat supplied to Top Vessel",Hidden=true);
1065
1066        VapourConnector as stream               (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
1067
1068EQUATIONS
1069
1070        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletL.F;
1071        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletL.T;
1072        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletL.P;
1073        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletL.z;
1074
1075        VapourConnector.F= VapourInlet.F;
1076        VapourConnector.T = VapourInlet.T;
1077        VapourConnector.P = VapourInlet.P;
1078        VapourConnector.z = VapourInlet.z;
1079        VapourConnector.v = VapourInlet.v;
1080        VapourConnector.h = VapourInlet.h;
1081       
1082# Splitter Connector Equations
1083        ConnectorSplitterTop.T = LiquidDistillate.T;
1084        ConnectorSplitterTop.P = LiquidDistillate.P;
1085        ConnectorSplitterTop.F = LiquidDistillate.F;
1086        ConnectorSplitterTop.z = LiquidDistillate.z;
1087
1088switch CondenserVapourFlow
1089
1090        case "on":
1091                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo *Ah * sqrt(2*(TRAYS(1).OutletV.P -
1092                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1093        when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
1094               
1095        case "off":
1096                CONDENSER.InletV.F = 0 * 'mol/s';
1097        when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
1098
1099end     
1100
1101CONNECTIONS
1102#vapor
1103        TRAYS(1).OutletV to CONDENSER.InletV;
1104
1105#liquid
1106        CONDENSER.OutletL               to TANKtop.Inlet;       
1107        TANKtop.Outlet                                  to SPLITTERtop.Inlet;
1108        SPLITTERtop.Outlet2             to PUMP.Inlet; 
1109        PUMP.Outlet                                             to TRAYS(1).InletL;
1110
1111#Connectors
1112        VapourConnector                         to TRAYS(NumberOfTrays).InletV;
1113        HeatToCondenser                         to CONDENSER.InletQ;
1114        SPLITTERtop.Outlet1     to ConnectorSplitterTop;
1115        HeatToTopVessel                 to TANKtop.InletQ;
1116
1117end
1118
1119
1120#* -------------------------------------------------------------------
1121* Reboiled Stripping Column model with:
1122*
1123*       - NumberOfTrays like tray;
1124*       - a kettle reboiler;
1125*
1126* ------------------------------------------------------------------*#
1127Model Reboiled_Stripping_kettle as Section_ColumnBasic
1128       
1129ATTRIBUTES
1130        Pallete         = true;
1131        Icon            = "icon/ReboiledKettle";
1132        Brief           = "Model of a reboiled stripping column with dynamic reboiler.";
1133        Info            =
1134"== Specify ==
1135* the feed stream of each tray (Inlet);
1136* the Murphree eficiency for each tray Emv;
1137* the vapour flow leaving the top of the column;
1138* the InletL stream of the top tray;
1139* the heat supllied in the reboiler;
1140* the reboiler liquid outlet flow (OutletL.F);
1141       
1142== Initial Conditions ==
1143* the TRAYS temperature (OutletL.T);
1144* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
1145* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
1146       
1147* the reboiler temperature (OutletL.T);
1148* the reboiler liquid level (Level);
1149* (NoComps - 1) OutletL (OR OutletV) compositions.
1150";
1151
1152VARIABLES
1153
1154        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.34,Protected = true);
1155        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.49,Protected = true);
1156       
1157        in              LiquidInlet                                             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.20, PosY=0);
1158        out     VapourOutlet                                    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.05, PosY=0);
1159        out     BottomProduct                           as liquid_stream                (Brief="Liquid outlet stream From Reboiler", PosX=1, PosY=1);
1160        in              ConnectorReboilerLout   as stream                               (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1161        out             HeatToReboiler                  as power                                (Brief="Heat supplied to Reboiler",Hidden=true);
1162       
1163        LiquidConnector as stream                               (Brief="Liquid connection at the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
1164        RebNoFlow               as sourceNoFlow (Brief="No Inlet Flow to Reboiler",Hidden=true);
1165       
1166        REBOILER as reboiler;
1167
1168CONNECTIONS
1169#vapor
1170        REBOILER.OutletV to TRAYS(NumberOfTrays).InletV;
1171       
1172#liquid
1173        TRAYS(NumberOfTrays).OutletL to REBOILER.InletL;
1174
1175#Connectors
1176REBOILER.OutletL        to ConnectorReboilerLout;
1177LiquidConnector                 to TRAYS(1).InletL;
1178RebNoFlow.Outlet        to REBOILER.Inlet;
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
1389SET
1390
1391        FeedTrayIndex(FeedTrayLocation)                 =1;
1392        VapSideTrayIndex(FeedTrayLocation)      =1;
1393        LiqSideTrayIndex(FeedTrayLocation)      =1;
1394
1395        V=VolumeOfTray;
1396        Q=HeatSupply;
1397        Ap=PlateArea;
1398        Ah=HolesArea;
1399        lw=WeirLength;
1400        hw=WeirHeight ;
1401       
1402VARIABLES
1403       
1404        in      FeedTray                        as stream                               (Brief="Feed stream", PosX=0, PosY=0.55);
1405       
1406        VapourDrawOffFlow  as flow_mol          (Brief = "Stream Molar Flow Rate");
1407        LiquidDrawOffFlow   as flow_mol                         (Brief = "Stream Molar Flow Rate");
1408       
1409        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.50,Protected = true);
1410        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.61,Protected = true);
1411       
1412        RebNoFlow       as sourceNoFlow (Brief="No Inlet Flow to Reboiler",Hidden=true);
1413       
1414        in              HeatToReboiler                          as power                                (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.94);
1415        in              HeatToCondenser                 as power                                (Brief="Heat supplied to Condenser", PosX=1, PosY=0.19);
1416
1417        TRAYS(NumberOfTrays)    as trayReac;
1418        CONDENSER                                       as condenserReact;
1419        REBOILER                                                as reboilerReact;
1420        SPLITTER                                                        as splitter;
1421        PUMP                                                                    as pump;
1422
1423out     VapourDistillate                                as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.57, PosY=0);
1424in              ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
1425
1426out     LiquidDistillate                                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.39);
1427in              ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1428
1429out     BottomProduct                           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.57, PosY=1);
1430in              ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1431
1432
1433# Control
1434out     TRI as control_signal           (Brief="Temperature of Reboiler Indicator", PosX=1, PosY=0.78);
1435out     LRI as control_signal           (Brief="Level of Reboiler Indicator", PosX=1, PosY=0.85);
1436
1437out     TCI as control_signal           (Brief="Temperature of Condenser Indicator", PosX=1, PosY=0.01);
1438out     LCI as control_signal           (Brief="Level of Condenser Indicator", PosX=1, PosY=0.09);
1439
1440CONNECTIONS
1441#vapor
1442        REBOILER.OutletV                                                                to TRAYS(NumberOfTrays).InletV;
1443        TRAYS(1).OutletV                                                                        to CONDENSER.InletV;
1444        TRAYS([2:NumberOfTrays]).OutletV        to TRAYS([1:NumberOfTrays-1]).InletV;
1445
1446#liquid
1447        CONDENSER.OutletL                                                               to SPLITTER.Inlet;     
1448        SPLITTER.Outlet2                                                                        to PUMP.Inlet;
1449        PUMP.Outlet                                                                                             to TRAYS(1).InletL;
1450        TRAYS([1:NumberOfTrays-1]).OutletL      to TRAYS([2:NumberOfTrays]).InletL;
1451        TRAYS(NumberOfTrays).OutletL                    to REBOILER.InletL;
1452
1453#Connectors
1454RebNoFlow.Outlet  to REBOILER.Inlet;
1455
1456CONDENSER.OutletV to ConnectorCondenserVout;
1457SPLITTER.Outlet1                to ConnectorSplitterOut;
1458REBOILER.OutletL        to ConnectorReboilerLout;
1459
1460EQUATIONS
1461
1462for i in [1:NumberOfTrays] do
1463
1464"Energy Holdup"
1465        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletL.h + TRAYS(i).MV*TRAYS(i).OutletV.h - TRAYS(i).OutletL.P*V;
1466
1467"Energy Balance"
1468        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
1469        -TRAYS(i).VapourSideStream.F*TRAYS(i).VapourSideStream.h - TRAYS(i).LiquidSideStream.F*TRAYS(i).LiquidSideStream.h + Q ) + TRAYS(i).Hr * TRAYS(i).r3 *TRAYS(i). vL*TRAYS(i).ML;
1470
1471"Level of clear liquid over the weir"
1472        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/Ap;
1473
1474"Geometry Constraint"
1475        V = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
1476
1477end
1478
1479switch VapourFlow
1480                case "on":
1481                "Pressure Drop through the condenser"
1482                CONDENSER.InletV.F*TRAYS(1).vV / 'm^2' =
1483                        sqrt((TRAYS(1).OutletV.P - CONDENSER.OutletL.P + 1e-8 * 'atm')/(TRAYS(1).rhoV*alfacond));
1484                when TRAYS(1).OutletV.P < CONDENSER.OutletL.P switchto "off";
1485               
1486                case "off":
1487                "Prato selado"
1488                CONDENSER.InletV.F = 0.0 * 'mol/s';
1489                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-3 * 'atm' switchto "on";
1490        end
1491
1492for i in [1:NumberOfTrays] do
1493
1494        switch TrayLiquidFlow
1495                case "on":
1496                "Francis Equation"
1497                TRAYS(i).OutletL.F*TRAYS(i).vL = 1.84*'1/s'*lw*((TRAYS(i).Level-(beta*hw)+1e-6*'m')/(beta))^2;
1498                when TRAYS(i).Level < (beta * hw) switchto "off";
1499               
1500                case "off":
1501                "Low level"
1502                TRAYS(i).OutletL.F = 0 * 'mol/h';
1503                when TRAYS(i).Level > (beta * hw) + 1e-6*'m' switchto "on";
1504        end
1505
1506        switch TrayVapourFlow
1507                case "on":
1508                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;
1509                when TRAYS(i).InletV.P < TRAYS(i).OutletV.P + TRAYS(i).Level*g*TRAYS(i).rhoL switchto "off";
1510               
1511                case "off":
1512                TRAYS(i).InletV.F = 0 * 'mol/s';
1513                when TRAYS(i).InletV.P > TRAYS(i).OutletV.P + TRAYS(i).Level*g*TRAYS(i).rhoL + 3e-2 * 'atm' switchto "on";
1514        end
1515
1516end
1517
1518# Connecting Trays
1519        FeedTray.F*FeedTrayIndex= TRAYS.Inlet.F;
1520        FeedTray.T = TRAYS.Inlet.T;
1521        FeedTray.P = TRAYS.Inlet.P;
1522        FeedTray.z = TRAYS.Inlet.z;
1523        FeedTray.v = TRAYS.Inlet.v;
1524        FeedTray.h = TRAYS.Inlet.h;
1525
1526        HeatToReboiler = REBOILER.InletQ;
1527        HeatToCondenser         = CONDENSER.InletQ;
1528
1529"Reboiler Temperature indicator"
1530        TRI * 'K' = REBOILER.OutletL.T;
1531
1532"Reboiler Level indicator"
1533        LRI*REBOILER.V = REBOILER.Level*REBOILER.Across;
1534
1535"Condenser Temperature indicator"
1536        TCI * 'K' = CONDENSER.OutletL.T;
1537
1538"Condenser Level indicator"
1539        LCI*CONDENSER.V = CONDENSER.Level*CONDENSER.Across;
1540
1541# Condenser Connector Equations
1542        ConnectorCondenserVout.T = VapourDistillate.T;
1543        ConnectorCondenserVout.P = VapourDistillate.P;
1544        ConnectorCondenserVout.F = VapourDistillate.F;
1545        ConnectorCondenserVout.z = VapourDistillate.z;
1546
1547# Splitter Connector Equations
1548        ConnectorSplitterOut.T = LiquidDistillate.T;
1549        ConnectorSplitterOut.P = LiquidDistillate.P;
1550        ConnectorSplitterOut.F = LiquidDistillate.F;
1551        ConnectorSplitterOut.z = LiquidDistillate.z;
1552
1553# Reboiler Connector Equations
1554        ConnectorReboilerLout.T = BottomProduct.T;
1555        ConnectorReboilerLout.P = BottomProduct.P;
1556        ConnectorReboilerLout.F = BottomProduct.F;
1557        ConnectorReboilerLout.z = BottomProduct.z;
1558
1559        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1560        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1561        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1562        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1563
1564        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1565        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1566        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1567        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1568
1569        VapourDrawOffFlow = VapourDrawOff.F;
1570        LiquidDrawOffFlow = LiquidDrawOff.F;
1571
1572end
1573
1574#*----------------------------------------------------------------------
1575* Model of a  packed column section with:
1576*       - NStages = theoretical number of equilibrium stages.
1577*
1578*---------------------------------------------------------------------*
1579Model Packed_Section_ColumnTeste
1580        ATTRIBUTES
1581        Pallete         = true;
1582        Icon            = "icon/PackedSectionColumn";
1583        Brief           = "Model of a packed column section.";
1584        Info            =
1585"== Model of a packed column section containing ==
1586* NStages theoretical stages.
1587       
1588== Specify ==
1589* the feed stream of each tray (Inlet);
1590* the InletL stream of the top tray;
1591* the InletV stream of the bottom tray;
1592* the total pressure drop (dP) of the section.
1593       
1594== Initial Conditions ==
1595* the stages temperature (OutletL.T);
1596* the stages liquid holdup;
1597* (NoComps - 1) OutletL (OR OutletV) compositions for each tray.
1598";
1599       
1600        PARAMETERS
1601        outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
1602        outer NComp as Integer;
1603        NStages as Integer(Brief="Number of TRAYS", Default=2);
1604        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
1605        top as Integer(Brief="Number of top tray");
1606        bot as Integer(Brief="Number of bottom tray");
1607        H as length (Brief="Height of packing");
1608
1609        VARIABLES
1610        stage(NStages) as packedStageTeste;
1611        dP as pressure;
1612       
1613        SET
1614        top = (NStages-1)*(1-topdown)/2+1;
1615        bot = NStages/top;
1616        stage.hs = H/NStages;   
1617        stage.V = stage.hs * stage.d^2*3.14159/4;
1618       
1619        EQUATIONS
1620        stage.deltaP = dP/NStages;
1621       
1622        CONNECTIONS
1623        stage([top+topdown:topdown:bot]).OutletV to stage([top:topdown:bot-topdown]).InletV;
1624        stage([top:topdown:bot-topdown]).OutletL to stage([top+topdown:topdown:bot]).InletL;
1625end
1626
1627#*----------------------------------------------------------------------
1628* Model of a  packed distillation column containing:
1629*       - a section with NStages theoretical stages;
1630*       - a kettle reboiler;
1631*       - dymamic condenser;
1632*       - a splitter which separate reflux and distillate;
1633*       - a pump in reflux stream;
1634*---------------------------------------------------------------------*
1635Model PackedDistillation_kettle_cond as Packed_Section_ColumnTeste
1636        ATTRIBUTES
1637        Pallete         = true;
1638        Icon            = "icon/PackedDistillationKettleCond";
1639        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
1640        Info            =
1641"== Specify ==
1642* the feed stream of each tray (Inlet);
1643* the pump pressure difference;
1644* the total pressure drop (dP) of the packing;
1645* the heat supllied in reboiler and condenser;
1646* the condenser vapor outlet flow (OutletV.F);
1647* the reboiler liquid outlet flow (OutletL.F);
1648* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1649       
1650== Initial Conditions ==
1651* the stages temperature (OutletL.T);
1652* the stages initial molar holdup;
1653* (NoComps - 1) OutletL (OR OutletV) compositions for each stage;
1654       
1655* the condenser temperature (OutletL.T);
1656* the condenser liquid level (Level);
1657* (NoComps - 1) OutletL (OR OutletV) compositions;
1658       
1659* the reboiler temperature (OutletL.T);
1660* the reboiler liquid level (Level);
1661* (NoComps - 1) OutletL (OR OutletV) compositions.
1662";
1663       
1664        PARAMETERS
1665        VapourFlow as Switcher(Valid = ["on", "off"], Default = "on");
1666       
1667        VARIABLES
1668        cond as condenser;
1669        reb as reboiler;
1670        sptop as splitter;
1671        pump1 as pump;
1672       
1673        CONNECTIONS
1674        #vapor
1675        reb.OutletV to stage(bot).InletV;
1676        stage(top).OutletV to cond.InletV;
1677       
1678        #liquid
1679        cond.OutletL to sptop.Inlet;   
1680        sptop.Outlet2 to pump1.Inlet;
1681        pump1.Outlet to stage(top).InletL;
1682        stage(bot).OutletL to reb.InletL;
1683       
1684        EQUATIONS
1685        switch VapourFlow
1686                case "on":
1687                stage(bot).InletV.F*stage(bot).vV = sqrt((reb.OutletV.P - stage(bot).OutletV.P)/
1688                                        (stage(bot).rhoV*stage(bot).Qsil*20))*(stage(bot).d^2*3.14159/4*stage(bot).e - stage(bot).Al);
1689                when stage(bot).InletV.F < 1e-6 * 'kmol/h' switchto "off";
1690               
1691                case "off":
1692                stage(bot).InletV.F = 0 * 'mol/s';
1693                when reb.OutletV.P > stage(bot).OutletV.P + 1e-1 * 'atm' switchto "on";
1694        end
1695
1696end
1697*#
Note: See TracBrowser for help on using the repository browser.