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

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

added heat_flow model for control purposes - starting to modify the reactive distillation column (BRANCH)

File size: 59.8 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
410EQUATIONS
411
412switch CondenserVapourFlow
413
414        case "on":
415                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo *Ah * sqrt(2*(TRAYS(1).OutletV.P -
416                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
417                when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
418
419        case "off":
420                CONDENSER.InletV.F = 0 * 'mol/s';
421                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
422
423end     
424
425# Condenser Connector Equations
426        ConnectorCondenserVout.T = VapourDistillate.T;
427        ConnectorCondenserVout.P = VapourDistillate.P;
428        ConnectorCondenserVout.F = VapourDistillate.F;
429        ConnectorCondenserVout.z = VapourDistillate.z;
430
431# Splitter Connector Equations
432        ConnectorSplitterOut.T = LiquidDistillate.T;
433        ConnectorSplitterOut.P = LiquidDistillate.P;
434        ConnectorSplitterOut.F = LiquidDistillate.F;
435        ConnectorSplitterOut.z = LiquidDistillate.z;
436
437# Reboiler Connector Equations
438        ConnectorReboilerLout.T = BottomProduct.T;
439        ConnectorReboilerLout.P = BottomProduct.P;
440        ConnectorReboilerLout.F = BottomProduct.F;
441        ConnectorReboilerLout.z = BottomProduct.z;
442
443        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
444        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
445        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
446        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
447
448        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
449        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
450        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
451        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
452
453        VapourDrawOffFlow = VapourDrawOff.F;
454        LiquidDrawOffFlow = LiquidDrawOff.F;
455       
456CONNECTIONS
457#vapor
458        REBOILER.OutletV        to      TRAYS(NumberOfTrays).InletV;
459        TRAYS(1).OutletV                                to      CONDENSER.InletV;
460
461#liquid
462        CONDENSER.OutletL               to      SPLITTERtop.Inlet;     
463        SPLITTERtop.Outlet2                             to      PUMP.Inlet;
464        PUMP.Outlet                                     to      TRAYS(1).InletL;
465        TRAYS(NumberOfTrays).OutletL    to      REBOILER.InletL;
466
467#Connectors
468HeatToReboiler  to REBOILER.InletQ;
469HeatToCondenser         to CONDENSER.InletQ;
470RebNoFlow.Outlet  to REBOILER.Inlet;
471
472CONDENSER.OutletV to ConnectorCondenserVout;
473SPLITTERtop.Outlet1             to ConnectorSplitterOut;
474REBOILER.OutletL        to ConnectorReboilerLout;
475
476end
477
478
479#* -------------------------------------------------------------------
480* Distillation Column model with:
481*
482*       - NumberOfTrays like tray;
483*       - a vessel in the bottom of column;
484*       - a splitter who separate the bottom product and the stream to reboiler;
485*       - steady state reboiler (thermosyphon);
486*       - a steady state condenser with subcooling;
487*       - a vessel drum (layed cilinder);
488*       - a splitter which separate reflux and distillate;
489*       - a pump in reflux stream.
490*
491* ------------------------------------------------------------------*#
492Model Distillation_thermosyphon_subcooling as Section_ColumnBasic
493        ATTRIBUTES
494        Pallete         = true;
495        Icon            = "icon/DistillationThermosyphonSubcooling";
496        Brief           = "Model of a distillation column with steady condenser and steady reboiler.";
497        Info            =
498"== Specify ==
499* the feed stream of each tray (Inlet);
500* the Murphree eficiency for each tray Emv;
501* the pump head;
502* the condenser pressure drop;
503* the heat supllied in top and bottom tanks;
504* the heat supllied in condenser and reboiler;
505* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
506* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
507       
508== Initial Conditions ==
509* the TRAYS temperature (OutletL.T);
510* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
511* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
512       
513* the top tank temperature (OutletL.T);
514* the top tank liquid level (Level);
515* (NoComps - 1) OutletL (OR OutletV) compositions;
516       
517* the bottom tank temperature (OutletL.T);
518* the bottom tank liquid level (Level);
519* (NoComps - 1) OutletL (OR OutletV) compositions.
520";
521
522PARAMETERS
523
524        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Hidden=true, Default = "on");
525
526VARIABLES
527
528        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.41,Protected = true);
529        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.515,Protected = true);
530
531        CONDENSER               as condenserSteady;
532        TANKtop                                 as tank_cylindrical;
533        SPLITTERtop             as splitter;
534        PUMP                                    as pump;
535        REBOILER                        as reboilerSteady;
536        TANKbottom                      as tank;
537        SPLITTERbottom  as splitter;
538        alfaTopo                                        as Real;
539
540out             HeatToCondenser         as power                                (Brief="Heat supplied to Condenser",Hidden=true);
541out             HeatToReboiler                  as power                                (Brief="Heat supplied to Reboiler",Hidden=true);
542out             HeatToBottomVessel      as power                                (Brief="Heat supplied to Bottom Vessel",Hidden=true);
543out             HeatToTopVessel         as power                                (Brief="Heat supplied to Top Vessel",Hidden=true);
544
545out     LiquidDistillate                                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.30);
546in              ConnectorSplitterTop            as stream                       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
547
548out     BottomProduct                                   as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=1, PosY=0.99);
549in              ConnectorSplitterBottom         as stream                       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
550
551EQUATIONS
552
553# Top Splitter Connector Equations
554        ConnectorSplitterTop.T = LiquidDistillate.T;
555        ConnectorSplitterTop.P = LiquidDistillate.P;
556        ConnectorSplitterTop.F = LiquidDistillate.F;
557        ConnectorSplitterTop.z = LiquidDistillate.z;
558
559# Bottom Splitter Connector Equations
560        ConnectorSplitterBottom.T = BottomProduct.T;
561        ConnectorSplitterBottom.P = BottomProduct.P;
562        ConnectorSplitterBottom.F = BottomProduct.F;
563        ConnectorSplitterBottom.z = BottomProduct.z;
564
565        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
566        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
567        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
568        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
569
570        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
571        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
572        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
573        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
574
575        VapourDrawOffFlow = VapourDrawOff.F;
576        LiquidDrawOffFlow = LiquidDrawOff.F;
577
578switch CondenserVapourFlow
579
580        case "on":
581                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletV.P -
582                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
583                when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
584
585        case "off":
586                CONDENSER.InletV.F = 0 * 'mol/s';
587                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
588
589end     
590
591CONNECTIONS
592#vapor
593        REBOILER.OutletV        to TRAYS(NumberOfTrays).InletV;
594        TRAYS(1).OutletV                        to CONDENSER.InletV;
595
596#liquid
597        CONDENSER.OutletL                               to TANKtop.Inlet;       
598        TANKtop.Outlet                                                  to SPLITTERtop.Inlet;
599        SPLITTERtop.Outlet2                             to PUMP.Inlet; 
600        PUMP.Outlet                                                             to TRAYS(1).InletL;
601        TRAYS(NumberOfTrays).OutletL    to TANKbottom.Inlet;
602        TANKbottom.Outlet                                       to SPLITTERbottom.Inlet;
603        SPLITTERbottom.Outlet2                          to REBOILER.InletL;
604
605#Connectors
606HeatToCondenser                         to CONDENSER.InletQ;
607HeatToReboiler                          to REBOILER.InletQ;
608HeatToBottomVessel      to TANKbottom.InletQ;
609HeatToTopVessel                 to TANKtop.InletQ;
610SPLITTERtop.Outlet1     to ConnectorSplitterTop;
611SPLITTERbottom.Outlet1  to ConnectorSplitterBottom;
612
613end
614
615
616#* -------------------------------------------------------------------
617* Distillation Column model with:
618*
619*       - NumberOfTrays like tray;
620*       - a vessel in the bottom of column;
621*       - a splitter who separate the bottom product and the stream to reboiler;
622*       - steady state reboiler (thermosyphon);
623*       - a dynamic condenser without subcooling;
624*       - a splitter which separate reflux and distillate;
625*       - a pump in reflux stream.
626*
627* ------------------------------------------------------------------*#
628Model Distillation_thermosyphon_cond as Section_ColumnBasic
629        ATTRIBUTES
630        Pallete         = true;
631        Icon            = "icon/DistillationThermosyphonCond";
632        Brief           = "Model of a distillation column with dynamic condenser and steady reboiler.";
633        Info            =
634"== Specify ==
635* the feed stream of each tray (Inlet);
636* the Murphree eficiency for each tray Emv;
637* the pump head;
638* the condenser vapor outlet flow (OutletV.F);
639* the heat supllied in bottom tank;
640* the heat supllied in condenser and reboiler;
641* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
642       
643== Initial Conditions ==
644* the TRAYS temperature (OutletL.T);
645* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
646* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
647       
648* the condenser temperature (OutletL.T);
649* the condenser liquid level (Level);
650* (NoComps - 1) OutletL (OR OutletV) compositions;
651       
652* the bottom tank temperature (OutletL.T);
653* the bottom tank liquid level (Level);
654* (NoComps - 1) OutletL (OR OutletV) compositions.
655";
656
657PARAMETERS
658        CondenserVapourFlow     as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
659
660VARIABLES
661
662        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.41,Protected = true);
663        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.515,Protected = true);
664       
665        CONDENSER as condenser;
666        SPLITTERtop             as splitter;
667        PUMP            as pump;
668        TANKbottom      as tank;
669        SPLITTERbottom  as splitter;
670        REBOILER        as reboilerSteady;
671        alfaTopo                        as Real;
672
673out             HeatToCondenser         as power                                (Brief="Heat supplied to Condenser",Hidden=true);
674out             HeatToReboiler                  as power                                (Brief="Heat supplied to Reboiler",Hidden=true);
675out             HeatToBottomVessel      as power                                (Brief="Heat supplied to Bottom Vessel",Hidden=true);
676
677out     VapourDistillate                                as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.74, PosY=0);
678in              ConnectorCondenserVout  as stream                               (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
679
680out     LiquidDistillate                                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.30);
681in              ConnectorSplitterTop    as stream                       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
682
683out     BottomProduct                                   as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=1, PosY=0.999);
684in              ConnectorSplitterBottom         as stream                       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
685
686EQUATIONS
687
688# Condenser Connector Equations
689        ConnectorCondenserVout.T = VapourDistillate.T;
690        ConnectorCondenserVout.P = VapourDistillate.P;
691        ConnectorCondenserVout.F = VapourDistillate.F;
692        ConnectorCondenserVout.z = VapourDistillate.z;
693
694# Top Splitter Connector Equations
695        ConnectorSplitterTop.T = LiquidDistillate.T;
696        ConnectorSplitterTop.P = LiquidDistillate.P;
697        ConnectorSplitterTop.F = LiquidDistillate.F;
698        ConnectorSplitterTop.z = LiquidDistillate.z;
699
700# Bottom Splitter Connector Equations
701        ConnectorSplitterBottom.T = BottomProduct.T;
702        ConnectorSplitterBottom.P = BottomProduct.P;
703        ConnectorSplitterBottom.F = BottomProduct.F;
704        ConnectorSplitterBottom.z = BottomProduct.z;
705
706        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
707        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
708        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
709        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
710
711        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
712        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
713        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
714        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
715
716        VapourDrawOffFlow = VapourDrawOff.F;
717        LiquidDrawOffFlow = LiquidDrawOff.F;
718       
719switch CondenserVapourFlow
720                case "on":
721                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletV.P -
722                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
723                when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
724               
725                case "off":
726                CONDENSER.InletV.F = 0 * 'mol/s';
727                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
728end     
729
730CONNECTIONS
731#vapor
732        REBOILER.OutletV        to TRAYS(NumberOfTrays).InletV;
733        TRAYS(1).OutletV                                to CONDENSER.InletV;
734
735#liquid
736        CONDENSER.OutletL               to SPLITTERtop.Inlet;   
737        SPLITTERtop.Outlet2                             to PUMP.Inlet;
738        PUMP.Outlet                                     to TRAYS(1).InletL;
739        TRAYS(NumberOfTrays).OutletL    to TANKbottom.Inlet;
740        TANKbottom.Outlet                               to SPLITTERbottom.Inlet;
741        SPLITTERbottom.Outlet2                  to REBOILER.InletL;
742
743#Connectors
744HeatToCondenser                         to CONDENSER.InletQ;
745HeatToReboiler                          to REBOILER.InletQ;
746HeatToBottomVessel      to TANKbottom.InletQ;
747CONDENSER.OutletV to ConnectorCondenserVout;
748SPLITTERtop.Outlet1             to ConnectorSplitterTop;
749SPLITTERbottom.Outlet1  to ConnectorSplitterBottom;
750
751end
752
753#* -------------------------------------------------------------------
754* Distillation Column model with:
755*
756*       - NumberOfTrays like tray;
757*       - a kettle reboiler;
758*       - a steady state condenser with subcooling;
759*       - a vessel drum (layed cilinder);
760*       - a splitter which separate reflux and distillate;
761*       - a pump in reflux stream.
762*
763* ------------------------------------------------------------------*#
764Model Distillation_kettle_subcooling as Section_ColumnBasic
765
766ATTRIBUTES
767        Pallete         = true;
768        Icon            = "icon/DistillationKettleSubcooling";
769        Brief   = "Model of a distillation column with steady condenser and dynamic reboiler.";
770        Info            =
771"== Specify ==
772* the feed stream of each tray (Inlet);
773* the Murphree eficiency for each tray (Emv);
774* the pump pressure difference;
775* the heat supllied in reboiler and condenser;
776* the heat supllied in the top tank;
777* the condenser pressure drop;
778* the reboiler liquid outlet flow (OutletL.F);
779* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
780       
781== Initial Conditions ==
782* the TRAYS temperature (OutletL.T);
783* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
784* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
785       
786* the top tank temperature (OutletL.T);
787* the top tank liquid level (Level);
788* (NoComps - 1) OutletL (OR OutletV) compositions;
789       
790* the reboiler temperature (OutletL.T);
791* the reboiler liquid level (Level);
792* (NoComps - 1) OutletL (OR OutletV) compositions.
793";
794       
795PARAMETERS
796        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Default = "on",Hidden=true);
797
798VARIABLES
799        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.46,Protected = true);
800        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.58,Protected = true);
801       
802        CONDENSER as condenserSteady;
803        TANKtop as tank_cylindrical;
804        SPLITTERtop             as splitter;
805        PUMP            as pump;
806        REBOILER        as reboiler;
807        alfaTopo as Real;
808
809out             HeatToCondenser         as power                                (Brief="Heat supplied to Condenser",Hidden=true);
810out             HeatToReboiler                  as power                                (Brief="Heat supplied to Reboiler",Hidden=true);
811out             HeatToTopVessel         as power                                (Brief="Heat supplied to Top Vessel",Hidden=true);
812
813out     LiquidDistillate                                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.33);
814in              ConnectorSplitterOut    as stream                       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
815
816out     BottomProduct                           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=1, PosY=1);
817in              ConnectorReboilerLout   as stream                       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
818
819RebNoFlow       as sourceNoFlow (Brief="No Inlet Flow to Reboiler",Hidden=true);
820
821EQUATIONS
822
823# Splitter Connector Equations
824        ConnectorSplitterOut.T = LiquidDistillate.T;
825        ConnectorSplitterOut.P = LiquidDistillate.P;
826        ConnectorSplitterOut.F = LiquidDistillate.F;
827        ConnectorSplitterOut.z = LiquidDistillate.z;
828
829# Reboiler Connector Equations
830        ConnectorReboilerLout.T = BottomProduct.T;
831        ConnectorReboilerLout.P = BottomProduct.P;
832        ConnectorReboilerLout.F = BottomProduct.F;
833        ConnectorReboilerLout.z = BottomProduct.z;
834       
835        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
836        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
837        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
838        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
839
840        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
841        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
842        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
843        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
844
845        VapourDrawOffFlow = VapourDrawOff.F;
846        LiquidDrawOffFlow = LiquidDrawOff.F;
847       
848        switch CondenserVapourFlow
849                case "on":
850                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletV.P -
851                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
852                when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
853               
854                case "off":
855                CONDENSER.InletV.F = 0 * 'mol/s';
856                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
857end     
858
859CONNECTIONS
860#vapor
861        REBOILER.OutletV to TRAYS(NumberOfTrays).InletV;
862        TRAYS(1).OutletV to CONDENSER.InletV;
863
864#liquid
865        CONDENSER.OutletL               to TANKtop.Inlet;       
866        TANKtop.Outlet                                  to SPLITTERtop.Inlet;
867        SPLITTERtop.Outlet2                             to PUMP.Inlet; 
868        PUMP.Outlet                                     to TRAYS(1).InletL;
869        TRAYS(NumberOfTrays).OutletL    to REBOILER.InletL;
870
871#Connectors
872HeatToCondenser                         to CONDENSER.InletQ;
873HeatToReboiler                          to REBOILER.InletQ;
874HeatToTopVessel                         to TANKtop.InletQ;
875RebNoFlow.Outlet                to REBOILER.Inlet;
876
877SPLITTERtop.Outlet1             to ConnectorSplitterOut;
878REBOILER.OutletL        to ConnectorReboilerLout;
879
880end
881
882
883#*----------------------------------------------------------------------
884* Model of a  rectifier containing:
885*       - NumberOfTrays like tray;
886*       - dymamic condenser without subcooling;
887*       - a splitter which separate reflux and distillate;
888*       - a pump in reflux stream;
889*---------------------------------------------------------------------*#
890Model Rectifier as Section_ColumnBasic
891
892ATTRIBUTES
893        Pallete         = true;
894        Icon            = "icon/RefluxedCond";
895        Brief           = "Model of a rectifier column with dynamic condenser.";
896        Info            =
897"== Specify ==
898* the feed stream of each tray (Inlet);
899* the Murphree eficiency for each tray Emv;
900* the InletV stream of the bottom tray unless its flow;
901* the pump pressure difference;
902* the heat supllied in the condenser;
903* the condenser vapor outlet flow (OutletV.F);
904* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
905       
906== Initial Conditions ==
907* the TRAYS temperature (OutletL.T);
908* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
909* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
910       
911* the condenser temperature (OutletL.T);
912* the condenser liquid level (Level);
913* (NoComps - 1) OutletL (OR OutletV) compositions;
914";
915
916PARAMETERS
917        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Default = "on",Hidden=true);
918
919VARIABLES
920
921        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.46,Protected = true);
922        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.58,Protected = true);
923       
924        CONDENSER as condenser;
925        SPLITTERtop as splitter;
926        PUMP as pump;
927        alfaTopo as Real;
928
929out     VapourDistillate                                as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.67, PosY=0);
930in              ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
931        in              VapourInlet             as stream                               (Brief="Vapour Inlet in the section", PosX=0.07, PosY=1);
932        out     LiquidOutlet            as liquid_stream                (Brief="Liquid Outlet in the section", PosX=0.20, PosY=1);
933        out     LiquidDistillate                                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.33);
934       
935        out             HeatToCondenser         as power                                (Brief="Heat supplied to Condenser",Hidden=true);
936        in              ConnectorSplitterOut    as stream                       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
937        VapourConnector as stream       (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
938       
939EQUATIONS
940
941switch CondenserVapourFlow
942
943        case "on":
944                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletV.P -
945                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
946                when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
947               
948        case "off":
949                CONDENSER.InletV.F = 0 * 'mol/s';
950                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
951
952end     
953
954# Condenser Connector Equations
955        ConnectorCondenserVout.T = VapourDistillate.T;
956        ConnectorCondenserVout.P = VapourDistillate.P;
957        ConnectorCondenserVout.F = VapourDistillate.F;
958        ConnectorCondenserVout.z = VapourDistillate.z;
959       
960# Splitter Connector Equations
961        ConnectorSplitterOut.T = LiquidDistillate.T;
962        ConnectorSplitterOut.P = LiquidDistillate.P;
963        ConnectorSplitterOut.F = LiquidDistillate.F;
964        ConnectorSplitterOut.z = LiquidDistillate.z;
965       
966        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletL.F;
967        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletL.T;
968        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletL.P;
969        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletL.z;
970
971        VapourConnector.F= VapourInlet.F;
972        VapourConnector.T = VapourInlet.T;
973        VapourConnector.P = VapourInlet.P;
974        VapourConnector.z = VapourInlet.z;
975        VapourConnector.v = VapourInlet.v;
976        VapourConnector.h = VapourInlet.h;
977
978        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
979        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
980        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
981        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
982
983        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
984        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
985        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
986        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
987
988        VapourDrawOffFlow = VapourDrawOff.F;
989        LiquidDrawOffFlow = LiquidDrawOff.F;
990
991CONNECTIONS
992#vapor
993        TRAYS(1).OutletV to CONDENSER.InletV;
994
995#liquid
996        CONDENSER.OutletL to SPLITTERtop.Inlet;
997        SPLITTERtop.Outlet2 to PUMP.Inlet;     
998        PUMP.Outlet to TRAYS(1).InletL;
999
1000#Connectors
1001HeatToCondenser         to CONDENSER.InletQ;
1002VapourConnector to TRAYS(NumberOfTrays).InletV;
1003SPLITTERtop.Outlet1             to ConnectorSplitterOut;
1004CONDENSER.OutletV to ConnectorCondenserVout;
1005
1006end
1007
1008
1009#* -------------------------------------------------------------------
1010* Rectifier Column with:
1011*
1012*       - NumberOfTrays like tray;
1013*       - a steady state condenser with subcooling;
1014*       - a vessel drum (layed cilinder);
1015*       - a splitter which separate reflux and distillate;
1016*       - a pump in reflux stream.
1017*
1018* ------------------------------------------------------------------*#
1019
1020Model Rectifier_subcooling as Section_ColumnBasic
1021
1022ATTRIBUTES
1023        Pallete         = true;
1024        Icon            = "icon/RefluxedSubcooling";
1025        Brief           = "Model of a rectifier column with steady condenser.";
1026        Info            =
1027"== Specify ==
1028* the feed stream of each tray (Inlet);
1029* the Murphree eficiency for each tray Emv;
1030* the InletV stream of the bottom tray unless its flow;
1031* the pump head;
1032* the condenser pressure drop;
1033* the heat supllied in  the top tank;
1034* the heat supllied in condenser;
1035* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1036       
1037== Initial Conditions ==
1038* the TRAYS temperature (OutletL.T);
1039* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
1040* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
1041       
1042* the top tank temperature (OutletL.T);
1043* the top tank liquid level (Level);
1044* (NoComps - 1) OutletL (OR OutletV) compositions;
1045";
1046       
1047PARAMETERS
1048        CondenserVapourFlow             as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
1049
1050VARIABLES
1051        CONDENSER as condenserSteady;
1052        TANKtop                 as tank_cylindrical;
1053        SPLITTERtop             as splitter;
1054        PUMP            as pump;
1055        alfaTopo                        as Real;
1056
1057        in              VapourInlet             as stream                               (Brief="Vapour Inlet in the section", PosX=0.18, PosY=1);
1058        out     LiquidOutlet            as liquid_stream                (Brief="Liquid Outlet in the section", PosX=0.25, PosY=1);
1059
1060        out             HeatToCondenser         as power                                (Brief="Heat supplied to Condenser",Hidden=true);
1061        out     LiquidDistillate                                as liquid_stream                (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.47);
1062        in              ConnectorSplitterTop            as stream                               (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1063        out             HeatToTopVessel         as power                                (Brief="Heat supplied to Top Vessel",Hidden=true);
1064
1065        VapourConnector as stream               (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
1066
1067EQUATIONS
1068
1069        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletL.F;
1070        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletL.T;
1071        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletL.P;
1072        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletL.z;
1073
1074        VapourConnector.F= VapourInlet.F;
1075        VapourConnector.T = VapourInlet.T;
1076        VapourConnector.P = VapourInlet.P;
1077        VapourConnector.z = VapourInlet.z;
1078        VapourConnector.v = VapourInlet.v;
1079        VapourConnector.h = VapourInlet.h;
1080       
1081# Splitter Connector Equations
1082        ConnectorSplitterTop.T = LiquidDistillate.T;
1083        ConnectorSplitterTop.P = LiquidDistillate.P;
1084        ConnectorSplitterTop.F = LiquidDistillate.F;
1085        ConnectorSplitterTop.z = LiquidDistillate.z;
1086
1087switch CondenserVapourFlow
1088
1089        case "on":
1090                CONDENSER.InletV.F*TRAYS(1).vV = alfaTopo *Ah * sqrt(2*(TRAYS(1).OutletV.P -
1091                CONDENSER.OutletL.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1092        when CONDENSER.InletV.F < 1e-6 * 'kmol/h' switchto "off";
1093               
1094        case "off":
1095                CONDENSER.InletV.F = 0 * 'mol/s';
1096        when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-1 * 'atm' switchto "on";
1097
1098end     
1099
1100CONNECTIONS
1101#vapor
1102        TRAYS(1).OutletV to CONDENSER.InletV;
1103
1104#liquid
1105        CONDENSER.OutletL               to TANKtop.Inlet;       
1106        TANKtop.Outlet                                  to SPLITTERtop.Inlet;
1107        SPLITTERtop.Outlet2             to PUMP.Inlet; 
1108        PUMP.Outlet                                             to TRAYS(1).InletL;
1109
1110#Connectors
1111        VapourConnector                         to TRAYS(NumberOfTrays).InletV;
1112        HeatToCondenser                         to CONDENSER.InletQ;
1113        SPLITTERtop.Outlet1     to ConnectorSplitterTop;
1114        HeatToTopVessel                 to TANKtop.InletQ;
1115
1116end
1117
1118
1119#* -------------------------------------------------------------------
1120* Reboiled Stripping Column model with:
1121*
1122*       - NumberOfTrays like tray;
1123*       - a kettle reboiler;
1124*
1125* ------------------------------------------------------------------*#
1126Model Reboiled_Stripping_kettle as Section_ColumnBasic
1127       
1128ATTRIBUTES
1129        Pallete         = true;
1130        Icon            = "icon/ReboiledKettle";
1131        Brief           = "Model of a reboiled stripping column with dynamic reboiler.";
1132        Info            =
1133"== Specify ==
1134* the feed stream of each tray (Inlet);
1135* the Murphree eficiency for each tray Emv;
1136* the vapour flow leaving the top of the column;
1137* the InletL stream of the top tray;
1138* the heat supllied in the reboiler;
1139* the reboiler liquid outlet flow (OutletL.F);
1140       
1141== Initial Conditions ==
1142* the TRAYS temperature (OutletL.T);
1143* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
1144* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
1145       
1146* the reboiler temperature (OutletL.T);
1147* the reboiler liquid level (Level);
1148* (NoComps - 1) OutletL (OR OutletV) compositions.
1149";
1150
1151VARIABLES
1152
1153        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.34,Protected = true);
1154        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.49,Protected = true);
1155       
1156        in              LiquidInlet                                             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.20, PosY=0);
1157        out     VapourOutlet                                    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.05, PosY=0);
1158        out     BottomProduct                           as liquid_stream                (Brief="Liquid outlet stream From Reboiler", PosX=1, PosY=1);
1159        in              ConnectorReboilerLout   as stream                               (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1160        out             HeatToReboiler                  as power                                (Brief="Heat supplied to Reboiler",Hidden=true);
1161       
1162        LiquidConnector as stream                               (Brief="Liquid connection at the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
1163        RebNoFlow               as sourceNoFlow (Brief="No Inlet Flow to Reboiler",Hidden=true);
1164       
1165        REBOILER as reboiler;
1166
1167CONNECTIONS
1168#vapor
1169        REBOILER.OutletV to TRAYS(NumberOfTrays).InletV;
1170       
1171#liquid
1172        TRAYS(NumberOfTrays).OutletL to REBOILER.InletL;
1173
1174#Connectors
1175REBOILER.OutletL        to ConnectorReboilerLout;
1176LiquidConnector                 to TRAYS(1).InletL;
1177RebNoFlow.Outlet        to REBOILER.Inlet;
1178HeatToReboiler                  to REBOILER.InletQ;
1179
1180EQUATIONS
1181
1182        LiquidConnector.F= LiquidInlet.F;
1183        LiquidConnector.T = LiquidInlet.T;
1184        LiquidConnector.P = LiquidInlet.P;
1185        LiquidConnector.z = LiquidInlet.z;
1186        LiquidConnector.v = LiquidInlet.v;
1187        LiquidConnector.h = LiquidInlet.h;
1188       
1189        VapourOutlet.F= TRAYS(1).OutletV.F;
1190        VapourOutlet.T = TRAYS(1).OutletV.T;
1191        VapourOutlet.P = TRAYS(1).OutletV.P;
1192        VapourOutlet.z = TRAYS(1).OutletV.z;
1193       
1194# Reboiler Connector Equations
1195        ConnectorReboilerLout.T = BottomProduct.T;
1196        ConnectorReboilerLout.P = BottomProduct.P;
1197        ConnectorReboilerLout.F = BottomProduct.F;
1198        ConnectorReboilerLout.z = BottomProduct.z;
1199       
1200        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1201        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1202        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1203        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1204
1205        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1206        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1207        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1208        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1209
1210        VapourDrawOffFlow = VapourDrawOff.F;
1211        LiquidDrawOffFlow = LiquidDrawOff.F;
1212
1213end
1214
1215
1216#* -------------------------------------------------------------------
1217* Reboiled Stripping Column model with:
1218*
1219*       - NumberOfTrays like tray;
1220*       - a vessel in the bottom of column;
1221*       - a splitter which separate the bottom product and the stream to reboiler;
1222*       - steady state reboiler (thermosyphon);
1223*
1224* ------------------------------------------------------------------*#
1225Model Reboiled_Stripping_thermosyphon as Section_ColumnBasic
1226
1227ATTRIBUTES
1228        Pallete         = true;
1229        Icon            = "icon/ReboiledThermosyphon";
1230        Brief           = "Model of a reboiled stripping column with steady reboiler.";
1231        Info            =
1232"== Specify ==
1233* the feed stream of each tray (Inlet);
1234* the Murphree eficiency for each tray (Emv);
1235* the vapour flow leaving the top of the column;
1236* the InletL stream of the top tray;
1237* the heat supllied in bottom tank;
1238* the heat supllied in the reboiler;
1239* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
1240       
1241== Initial Conditions ==
1242* the TRAYS temperature (OutletL.T);
1243* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
1244* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
1245
1246* the bottom tank temperature (OutletL.T);
1247* the bottom tank liquid level (Level);
1248* (NoComps - 1) OutletL (OR OutletV) compositions.
1249";
1250       
1251VARIABLES
1252        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.32,Protected = true);
1253        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.44,Protected = true);
1254       
1255        in              LiquidInlet                                             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.32, PosY=0);
1256        out     VapourOutlet                                    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.20, PosY=0);
1257        out     BottomProduct                           as liquid_stream                (Brief="Liquid outlet stream From Reboiler", PosX=1, PosY=1);
1258        LiquidConnector                                         as stream                               (Brief="Liquid connection at the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
1259        out             HeatToReboiler                  as power                                (Brief="Heat supplied to Reboiler",Hidden=true);
1260        out             HeatToTANKbottom        as power                                (Brief="Heat supplied to Bottom Vessel",Hidden=true);
1261        in              ConnectorSplitterBottom         as stream                       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1262       
1263        REBOILER                                as reboilerSteady;
1264        SPLITTERbottom  as splitter;
1265        TANKbottom                      as tank;
1266
1267CONNECTIONS
1268#vapor
1269        REBOILER.OutletV to TRAYS(NumberOfTrays).InletV;
1270       
1271#liquid
1272        TRAYS(NumberOfTrays).OutletL                            to TANKbottom.Inlet;
1273        TANKbottom.Outlet                                                               to SPLITTERbottom.Inlet;
1274        SPLITTERbottom.Outlet2                                          to REBOILER.InletL;
1275
1276#Connectors
1277LiquidConnector                                 to TRAYS(1).InletL;
1278HeatToReboiler                                  to REBOILER.InletQ;
1279HeatToTANKbottom                        to TANKbottom.InletQ;
1280SPLITTERbottom.Outlet1  to ConnectorSplitterBottom;
1281
1282EQUATIONS
1283
1284        ConnectorSplitterBottom.T = BottomProduct.T;
1285        ConnectorSplitterBottom.P = BottomProduct.P;
1286        ConnectorSplitterBottom.F = BottomProduct.F;
1287        ConnectorSplitterBottom.z = BottomProduct.z;
1288       
1289        LiquidConnector.F= LiquidInlet.F;
1290        LiquidConnector.T = LiquidInlet.T;
1291        LiquidConnector.P = LiquidInlet.P;
1292        LiquidConnector.z = LiquidInlet.z;
1293        LiquidConnector.v = LiquidInlet.v;
1294        LiquidConnector.h = LiquidInlet.h;
1295       
1296        VapourOutlet.F= TRAYS(1).OutletV.F;
1297        VapourOutlet.T = TRAYS(1).OutletV.T;
1298        VapourOutlet.P = TRAYS(1).OutletV.P;
1299        VapourOutlet.z = TRAYS(1).OutletV.z;
1300       
1301        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1302        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1303        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1304        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1305
1306        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1307        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1308        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1309        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1310
1311        VapourDrawOffFlow = VapourDrawOff.F;
1312        LiquidDrawOffFlow = LiquidDrawOff.F;
1313       
1314end
1315
1316#* -------------------------------------------------------------------
1317*  Reactive Distillation Column
1318*
1319* ------------------------------------------------------------------*#
1320Model ReactiveDistillation
1321       
1322ATTRIBUTES
1323        Pallete         = true;
1324        Icon            = "icon/DistillationReac";
1325        Brief           = "Model of a reactive distillation column with dynamic condenser and reboiler.";
1326        Info            =
1327"== Specify ==
1328* the reaction related variables for each tray, condenser and reboiler;
1329* the feed stream of each tray (Inlet);
1330* the Murphree eficiency for each tray Emv;
1331* the pump pressure difference;
1332* the heat supllied in reboiler and condenser;
1333* the condenser vapor outlet flow (OutletV.F);
1334* the reboiler liquid outlet flow (OutletL.F);
1335* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1336       
1337== Initial Conditions ==
1338* the TRAYS temperature (OutletL.T);
1339* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletL.F);
1340* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
1341       
1342* the condenser temperature (OutletL.T);
1343* the condenser liquid level (Level);
1344* (NoComps - 1) OutletL (OR OutletV) compositions;
1345       
1346* the reboiler temperature (OutletL.T);
1347* the reboiler liquid level (Level);
1348* (NoComps - 1) OutletL (OR OutletV) compositions.
1349";
1350       
1351PARAMETERS
1352       
1353        outer PP as Plugin(Type="PP");
1354        outer NComp as Integer;
1355
1356        NumberOfTrays as Integer(Brief="Number of TRAYS", Default=2);
1357
1358        FeedTrayIndex(NumberOfTrays)                    as Integer                      (Brief="Number of trays", Default=0,Hidden=true);
1359        LiqSideTrayIndex(NumberOfTrays)                 as Integer                      (Brief="Number of trays", Default=0,Hidden=true);
1360        VapSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Number of trays", Default=0,Hidden=true);
1361        FeedTrayLocation                                                                        as Integer                      (Brief="Feed tray Location", Default=2);
1362        LiquidSideStreamLocation                                                as Integer                      (Brief="Liquid Side Stream Location", Default=2);
1363        VapourSideStreamLocation                                        as Integer                      (Brief="Vapour Side Stream Location", Default=2);
1364
1365        alfacond as Real;
1366
1367        VapourFlow                      as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
1368        TrayVapourFlow  as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
1369        TrayLiquidFlow          as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
1370
1371        V       as volume                               (Brief="Total Volume of the tray",Hidden=true);
1372        Q       as power                                (Brief="Rate of heat supply",Hidden=true);
1373        Ap      as area                                         (Brief="Plate area = Atray - Adowncomer",Hidden=true);
1374        Ah      as      area                            (Brief="Total holes area",Hidden=true);
1375        lw      as      length                          (Brief="Weir length",Hidden=true);
1376        g               as acceleration                 (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
1377        hw      as      length                          (Brief="Weir height",Hidden=true);
1378        beta as         fraction                        (Brief="Aeration fraction");
1379        alfa    as      fraction                        (Brief="Dry pressure drop coefficient");
1380
1381        VolumeOfTray            as volume               (Brief="Total Volume of the tray");
1382        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
1383        PlateArea                               as area                         (Brief="Plate area = Atray - Adowncomer");
1384        HolesArea                               as area                         (Brief="Total holes area");
1385        WeirLength                              as length               (Brief="Weir length");
1386        WeirHeight                              as length               (Brief="Weir height");
1387
1388SET
1389
1390        FeedTrayIndex(FeedTrayLocation)                 =1;
1391        VapSideTrayIndex(FeedTrayLocation)      =1;
1392        LiqSideTrayIndex(FeedTrayLocation)      =1;
1393
1394        V=VolumeOfTray;
1395        Q=HeatSupply;
1396        Ap=PlateArea;
1397        Ah=HolesArea;
1398        lw=WeirLength;
1399        hw=WeirHeight ;
1400       
1401VARIABLES
1402       
1403        in      FeedTray                        as stream                               (Brief="Feed stream", PosX=0, PosY=0.55);
1404       
1405        VapourDrawOffFlow  as flow_mol          (Brief = "Stream Molar Flow Rate");
1406        LiquidDrawOffFlow   as flow_mol                         (Brief = "Stream Molar Flow Rate");
1407       
1408        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.46,Protected = true);
1409        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.58,Protected = true);
1410       
1411        RebNoFlow       as sourceNoFlow (Brief="No Inlet Flow to Reboiler",Hidden=true);
1412       
1413        in              HeatToReboiler                          as power                                (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.93);
1414        in              HeatToCondenser                 as power                                (Brief="Heat supplied to Condenser", PosX=1, PosY=0.10);
1415
1416        TRAYS(NumberOfTrays)    as trayReac;
1417        CONDENSER                                       as condenserReact;
1418        REBOILER                                                as reboilerReact;
1419        SPLITTER                                                        as splitter;
1420        PUMP                                                                    as pump;
1421
1422out     VapourDistillate                                as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.67, PosY=0);
1423in              ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
1424
1425out     LiquidDistillate                                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.33);
1426in              ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1427
1428out     BottomProduct                           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=1, PosY=0.99);
1429in              ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1430
1431
1432CONNECTIONS
1433#vapor
1434        REBOILER.OutletV                                                                to TRAYS(NumberOfTrays).InletV;
1435        TRAYS(1).OutletV                                                                        to CONDENSER.InletV;
1436        TRAYS([2:NumberOfTrays]).OutletV        to TRAYS([1:NumberOfTrays-1]).InletV;
1437
1438#liquid
1439        CONDENSER.OutletL                                                               to SPLITTER.Inlet;     
1440        SPLITTER.Outlet2                                                                        to PUMP.Inlet;
1441        PUMP.Outlet                                                                                             to TRAYS(1).InletL;
1442        TRAYS([1:NumberOfTrays-1]).OutletL      to TRAYS([2:NumberOfTrays]).InletL;
1443        TRAYS(NumberOfTrays).OutletL                    to REBOILER.InletL;
1444
1445#Connectors
1446RebNoFlow.Outlet  to REBOILER.Inlet;
1447
1448CONDENSER.OutletV to ConnectorCondenserVout;
1449SPLITTER.Outlet1                to ConnectorSplitterOut;
1450REBOILER.OutletL        to ConnectorReboilerLout;
1451
1452EQUATIONS
1453
1454for i in [1:NumberOfTrays] do
1455
1456"Energy Holdup"
1457        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletL.h + TRAYS(i).MV*TRAYS(i).OutletV.h - TRAYS(i).OutletL.P*V;
1458
1459"Energy Balance"
1460        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
1461        -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;
1462
1463"Level of clear liquid over the weir"
1464        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/Ap;
1465
1466"Geometry Constraint"
1467        V = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
1468
1469end
1470
1471switch VapourFlow
1472                case "on":
1473                "Pressure Drop through the condenser"
1474                CONDENSER.InletV.F*TRAYS(1).vV / 'm^2' =
1475                        sqrt((TRAYS(1).OutletV.P - CONDENSER.OutletL.P + 1e-8 * 'atm')/(TRAYS(1).rhoV*alfacond));
1476                when TRAYS(1).OutletV.P < CONDENSER.OutletL.P switchto "off";
1477               
1478                case "off":
1479                "Prato selado"
1480                CONDENSER.InletV.F = 0.0 * 'mol/s';
1481                when TRAYS(1).OutletV.P > CONDENSER.OutletL.P + 1e-3 * 'atm' switchto "on";
1482        end
1483
1484for i in [1:NumberOfTrays] do
1485
1486        switch TrayLiquidFlow
1487                case "on":
1488                "Francis Equation"
1489                TRAYS(i).OutletL.F*TRAYS(i).vL = 1.84*'1/s'*lw*((TRAYS(i).Level-(beta*hw)+1e-6*'m')/(beta))^2;
1490                when TRAYS(i).Level < (beta * hw) switchto "off";
1491               
1492                case "off":
1493                "Low level"
1494                TRAYS(i).OutletL.F = 0 * 'mol/h';
1495                when TRAYS(i).Level > (beta * hw) + 1e-6*'m' switchto "on";
1496        end
1497
1498        switch TrayVapourFlow
1499                case "on":
1500                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;
1501                when TRAYS(i).InletV.P < TRAYS(i).OutletV.P + TRAYS(i).Level*g*TRAYS(i).rhoL switchto "off";
1502               
1503                case "off":
1504                TRAYS(i).InletV.F = 0 * 'mol/s';
1505                when TRAYS(i).InletV.P > TRAYS(i).OutletV.P + TRAYS(i).Level*g*TRAYS(i).rhoL + 3e-2 * 'atm' switchto "on";
1506        end
1507
1508end
1509
1510# Connecting Trays
1511        FeedTray.F*FeedTrayIndex= TRAYS.Inlet.F;
1512        FeedTray.T = TRAYS.Inlet.T;
1513        FeedTray.P = TRAYS.Inlet.P;
1514        FeedTray.z = TRAYS.Inlet.z;
1515        FeedTray.v = TRAYS.Inlet.v;
1516        FeedTray.h = TRAYS.Inlet.h;
1517
1518        HeatToReboiler = REBOILER.InletQ;
1519        HeatToCondenser         = CONDENSER.InletQ;
1520
1521end
1522
1523#*----------------------------------------------------------------------
1524* Model of a  packed column section with:
1525*       - NStages = theoretical number of equilibrium stages.
1526*
1527*---------------------------------------------------------------------*
1528Model Packed_Section_ColumnTeste
1529        ATTRIBUTES
1530        Pallete         = true;
1531        Icon            = "icon/PackedSectionColumn";
1532        Brief           = "Model of a packed column section.";
1533        Info            =
1534"== Model of a packed column section containing ==
1535* NStages theoretical stages.
1536       
1537== Specify ==
1538* the feed stream of each tray (Inlet);
1539* the InletL stream of the top tray;
1540* the InletV stream of the bottom tray;
1541* the total pressure drop (dP) of the section.
1542       
1543== Initial Conditions ==
1544* the stages temperature (OutletL.T);
1545* the stages liquid holdup;
1546* (NoComps - 1) OutletL (OR OutletV) compositions for each tray.
1547";
1548       
1549        PARAMETERS
1550        outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
1551        outer NComp as Integer;
1552        NStages as Integer(Brief="Number of TRAYS", Default=2);
1553        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
1554        top as Integer(Brief="Number of top tray");
1555        bot as Integer(Brief="Number of bottom tray");
1556        H as length (Brief="Height of packing");
1557
1558        VARIABLES
1559        stage(NStages) as packedStageTeste;
1560        dP as pressure;
1561       
1562        SET
1563        top = (NStages-1)*(1-topdown)/2+1;
1564        bot = NStages/top;
1565        stage.hs = H/NStages;   
1566        stage.V = stage.hs * stage.d^2*3.14159/4;
1567       
1568        EQUATIONS
1569        stage.deltaP = dP/NStages;
1570       
1571        CONNECTIONS
1572        stage([top+topdown:topdown:bot]).OutletV to stage([top:topdown:bot-topdown]).InletV;
1573        stage([top:topdown:bot-topdown]).OutletL to stage([top+topdown:topdown:bot]).InletL;
1574end
1575
1576#*----------------------------------------------------------------------
1577* Model of a  packed distillation column containing:
1578*       - a section with NStages theoretical stages;
1579*       - a kettle reboiler;
1580*       - dymamic condenser;
1581*       - a splitter which separate reflux and distillate;
1582*       - a pump in reflux stream;
1583*---------------------------------------------------------------------*
1584Model PackedDistillation_kettle_cond as Packed_Section_ColumnTeste
1585        ATTRIBUTES
1586        Pallete         = true;
1587        Icon            = "icon/PackedDistillationKettleCond";
1588        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
1589        Info            =
1590"== Specify ==
1591* the feed stream of each tray (Inlet);
1592* the pump pressure difference;
1593* the total pressure drop (dP) of the packing;
1594* the heat supllied in reboiler and condenser;
1595* the condenser vapor outlet flow (OutletV.F);
1596* the reboiler liquid outlet flow (OutletL.F);
1597* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1598       
1599== Initial Conditions ==
1600* the stages temperature (OutletL.T);
1601* the stages initial molar holdup;
1602* (NoComps - 1) OutletL (OR OutletV) compositions for each stage;
1603       
1604* the condenser temperature (OutletL.T);
1605* the condenser liquid level (Level);
1606* (NoComps - 1) OutletL (OR OutletV) compositions;
1607       
1608* the reboiler temperature (OutletL.T);
1609* the reboiler liquid level (Level);
1610* (NoComps - 1) OutletL (OR OutletV) compositions.
1611";
1612       
1613        PARAMETERS
1614        VapourFlow as Switcher(Valid = ["on", "off"], Default = "on");
1615       
1616        VARIABLES
1617        cond as condenser;
1618        reb as reboiler;
1619        sptop as splitter;
1620        pump1 as pump;
1621       
1622        CONNECTIONS
1623        #vapor
1624        reb.OutletV to stage(bot).InletV;
1625        stage(top).OutletV to cond.InletV;
1626       
1627        #liquid
1628        cond.OutletL to sptop.Inlet;   
1629        sptop.Outlet2 to pump1.Inlet;
1630        pump1.Outlet to stage(top).InletL;
1631        stage(bot).OutletL to reb.InletL;
1632       
1633        EQUATIONS
1634        switch VapourFlow
1635                case "on":
1636                stage(bot).InletV.F*stage(bot).vV = sqrt((reb.OutletV.P - stage(bot).OutletV.P)/
1637                                        (stage(bot).rhoV*stage(bot).Qsil*20))*(stage(bot).d^2*3.14159/4*stage(bot).e - stage(bot).Al);
1638                when stage(bot).InletV.F < 1e-6 * 'kmol/h' switchto "off";
1639               
1640                case "off":
1641                stage(bot).InletV.F = 0 * 'mol/s';
1642                when reb.OutletV.P > stage(bot).OutletV.P + 1e-1 * 'atm' switchto "on";
1643        end
1644
1645end
1646*#
Note: See TracBrowser for help on using the repository browser.