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

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

starting some modifications on column models (BRANCH)

File size: 51.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.80, 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.80, 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        CondenserUnity  as condenser;
391        ReboilerUnity           as reboiler;
392        SplitterTop                     as splitter;
393        PumpUnity                       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                CondenserUnity.InletV.F*trays(1).vV = alfaTopo *Ah * sqrt(2*(trays(1).OutletV.P -
416                CondenserUnity.OutletL.P + 1e-8 * 'atm') / (alfa*trays(1).rhoV));
417                when CondenserUnity.InletV.F < 1e-6 * 'kmol/h' switchto "off";
418
419        case "off":
420                CondenserUnity.InletV.F = 0 * 'mol/s';
421                when trays(1).OutletV.P > CondenserUnity.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
443VapourDrawOff.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        ReboilerUnity.OutletV   to      trays(NumberOfTrays).InletV;
459        trays(1).OutletV                                to      CondenserUnity.InletV;
460
461#liquid
462        CondenserUnity.OutletL          to      SplitterTop.Inlet;     
463        SplitterTop.Outlet2                             to      PumpUnity.Inlet;
464        PumpUnity.Outlet                                        to      trays(1).InletL;
465        trays(NumberOfTrays).OutletL    to      ReboilerUnity.InletL;
466
467#Connectors
468HeatToReboiler  to ReboilerUnity.InletQ;
469HeatToCondenser         to CondenserUnity.InletQ;
470RebNoFlow.Outlet  to ReboilerUnity.Inlet;
471
472CondenserUnity.OutletV to ConnectorCondenserVout;
473SplitterTop.Outlet1             to ConnectorSplitterOut;
474ReboilerUnity.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        CondenserUnity as condenserSteady;
532        TopVessel               as tank_cylindrical;
533        TopSplitter             as splitter;
534        PumpUnity               as pump;
535        ReboilerUnity   as reboilerSteady;
536        BottomVessel    as tank;
537        BottomSplitter  as splitter;
538
539
540        alfaTopo                        as Real;
541
542out             HeatToCondenser         as power                                (Brief="Heat supplied to Condenser",Hidden=true);
543out             HeatToReboiler          as power                                (Brief="Heat supplied to Reboiler",Hidden=true);
544out             HeatToBottomVessel      as power                                (Brief="Heat supplied to Bottom Vessel",Hidden=true);
545out             HeatToTopVessel         as power                                (Brief="Heat supplied to Top Vessel",Hidden=true);
546
547out     LiquidDistillate                                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.30);
548in              ConnectorSplitterTop            as stream                       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
549
550out     BottomProduct                                   as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=1, PosY=0.99);
551in              ConnectorSplitterBottom         as stream                       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
552
553EQUATIONS
554
555# Top Splitter Connector Equations
556        ConnectorSplitterTop.T = LiquidDistillate.T;
557        ConnectorSplitterTop.P = LiquidDistillate.P;
558        ConnectorSplitterTop.F = LiquidDistillate.F;
559        ConnectorSplitterTop.z = LiquidDistillate.z;
560
561# Bottom Splitter Connector Equations
562        ConnectorSplitterBottom.T = BottomProduct.T;
563        ConnectorSplitterBottom.P = BottomProduct.P;
564        ConnectorSplitterBottom.F = BottomProduct.F;
565        ConnectorSplitterBottom.z = BottomProduct.z;
566
567        VapourDrawOff.F*VapSideTrayIndex= trays.VapourSideStream.F;
568        VapourDrawOff.T = trays(VapourSideStreamLocation).VapourSideStream.T;
569        VapourDrawOff.P = trays(VapourSideStreamLocation).VapourSideStream.P;
570        VapourDrawOff.z = trays(VapourSideStreamLocation).VapourSideStream.z;
571
572        LiquidDrawOff.F*LiqSideTrayIndex= trays.LiquidSideStream.F;
573        LiquidDrawOff.T = trays(LiquidSideStreamLocation).LiquidSideStream.T;
574        LiquidDrawOff.P = trays(LiquidSideStreamLocation).LiquidSideStream.P;
575        LiquidDrawOff.z = trays(LiquidSideStreamLocation).LiquidSideStream.z;
576
577        VapourDrawOffFlow = VapourDrawOff.F;
578        LiquidDrawOffFlow = LiquidDrawOff.F;
579       
580switch CondenserVapourFlow
581
582        case "on":
583                CondenserUnity.InletV.F*trays(1).vV = alfaTopo * Ah * sqrt(2*(trays(1).OutletV.P -
584                CondenserUnity.OutletL.P + 1e-8 * 'atm') / (alfa*trays(1).rhoV));
585                when CondenserUnity.InletV.F < 1e-6 * 'kmol/h' switchto "off";
586
587        case "off":
588                CondenserUnity.InletV.F = 0 * 'mol/s';
589                when trays(1).OutletV.P > CondenserUnity.OutletL.P + 1e-1 * 'atm' switchto "on";
590
591end     
592       
593CONNECTIONS
594#vapor
595        ReboilerUnity.OutletV   to trays(NumberOfTrays).InletV;
596        trays(1).OutletV                                to CondenserUnity.InletV;
597
598#liquid
599        CondenserUnity.OutletL          to TopVessel.Inlet;     
600        TopVessel.Outlet                                        to TopSplitter.Inlet;
601        TopSplitter.Outlet2                             to PumpUnity.Inlet;     
602        PumpUnity.Outlet                                        to trays(1).InletL;
603        trays(NumberOfTrays).OutletL    to BottomVessel.Inlet;
604        BottomVessel.Outlet                             to BottomSplitter.Inlet;
605        BottomSplitter.Outlet2                  to ReboilerUnity.InletL;
606
607#Connectors
608HeatToCondenser                         to CondenserUnity.InletQ;
609HeatToReboiler                  to ReboilerUnity.InletQ;
610HeatToBottomVessel      to BottomVessel.InletQ;
611HeatToTopVessel                 to TopVessel.InletQ;
612TopSplitter.Outlet1             to ConnectorSplitterTop;
613BottomSplitter.Outlet1  to ConnectorSplitterBottom;
614
615end
616
617
618#* -------------------------------------------------------------------
619* Distillation Column model with:
620*
621*       - NumberOfTrays like tray;
622*       - a vessel in the bottom of column;
623*       - a splitter who separate the bottom product and the stream to reboiler;
624*       - steady state reboiler (thermosyphon);
625*       - a dynamic condenser without subcooling;
626*       - a splitter which separate reflux and distillate;
627*       - a pump in reflux stream.
628*
629* ------------------------------------------------------------------*#
630Model Distillation_thermosyphon_cond as Section_ColumnBasic
631        ATTRIBUTES
632        Pallete         = true;
633        Icon            = "icon/DistillationThermosyphonCond";
634        Brief           = "Model of a distillation column with dynamic condenser and steady reboiler.";
635        Info            =
636"== Specify ==
637* the feed stream of each tray (Inlet);
638* the Murphree eficiency for each tray Emv;
639* the pump head;
640* the condenser vapor outlet flow (OutletV.F);
641* the heat supllied in bottom tank;
642* the heat supllied in condenser and reboiler;
643* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
644       
645== Initial Conditions ==
646* the trays temperature (OutletL.T);
647* the trays liquid level (Level) OR the trays liquid flow (OutletL.F);
648* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
649       
650* the condenser temperature (OutletL.T);
651* the condenser liquid level (Level);
652* (NoComps - 1) OutletL (OR OutletV) compositions;
653       
654* the bottom tank temperature (OutletL.T);
655* the bottom tank liquid level (Level);
656* (NoComps - 1) OutletL (OR OutletV) compositions.
657";
658
659PARAMETERS
660        CondenserVapourFlow     as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
661
662VARIABLES
663
664        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.41,Protected = true);
665        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.515,Protected = true);
666       
667        CondenserUnity as condenser;
668        SplitterTop             as splitter;
669        PumpUnity               as pump;
670        BottomVessel    as tank;
671        SplitterBottom  as splitter;
672        ReboilerUnity   as reboilerSteady;
673        alfaTopo                        as Real;
674
675out             HeatToCondenser         as power                                (Brief="Heat supplied to Condenser",Hidden=true);
676out             HeatToReboiler                  as power                                (Brief="Heat supplied to Reboiler",Hidden=true);
677out             HeatToBottomVessel      as power                                (Brief="Heat supplied to Bottom Vessel",Hidden=true);
678
679out     VapourDistillate                                as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.74, PosY=0);
680in              ConnectorCondenserVout  as stream                               (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
681
682out     LiquidDistillate                                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.30);
683in              ConnectorSplitterTop    as stream                       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
684
685out     BottomProduct                                   as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=1, PosY=0.999);
686in              ConnectorSplitterBottom         as stream                       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
687
688EQUATIONS
689
690# Condenser Connector Equations
691        ConnectorCondenserVout.T = VapourDistillate.T;
692        ConnectorCondenserVout.P = VapourDistillate.P;
693        ConnectorCondenserVout.F = VapourDistillate.F;
694        ConnectorCondenserVout.z = VapourDistillate.z;
695
696# Top Splitter Connector Equations
697        ConnectorSplitterTop.T = LiquidDistillate.T;
698        ConnectorSplitterTop.P = LiquidDistillate.P;
699        ConnectorSplitterTop.F = LiquidDistillate.F;
700        ConnectorSplitterTop.z = LiquidDistillate.z;
701
702# Bottom Splitter Connector Equations
703        ConnectorSplitterBottom.T = BottomProduct.T;
704        ConnectorSplitterBottom.P = BottomProduct.P;
705        ConnectorSplitterBottom.F = BottomProduct.F;
706        ConnectorSplitterBottom.z = BottomProduct.z;
707
708        VapourDrawOff.F*VapSideTrayIndex= trays.VapourSideStream.F;
709        VapourDrawOff.T = trays(VapourSideStreamLocation).VapourSideStream.T;
710        VapourDrawOff.P = trays(VapourSideStreamLocation).VapourSideStream.P;
711        VapourDrawOff.z = trays(VapourSideStreamLocation).VapourSideStream.z;
712
713        LiquidDrawOff.F*LiqSideTrayIndex= trays.LiquidSideStream.F;
714        LiquidDrawOff.T = trays(LiquidSideStreamLocation).LiquidSideStream.T;
715        LiquidDrawOff.P = trays(LiquidSideStreamLocation).LiquidSideStream.P;
716        LiquidDrawOff.z = trays(LiquidSideStreamLocation).LiquidSideStream.z;
717
718        VapourDrawOffFlow = VapourDrawOff.F;
719        LiquidDrawOffFlow = LiquidDrawOff.F;
720       
721switch CondenserVapourFlow
722                case "on":
723                CondenserUnity.InletV.F*trays(1).vV = alfaTopo * Ah * sqrt(2*(trays(1).OutletV.P -
724                CondenserUnity.OutletL.P + 1e-8 * 'atm') / (alfa*trays(1).rhoV));
725                when CondenserUnity.InletV.F < 1e-6 * 'kmol/h' switchto "off";
726               
727                case "off":
728                CondenserUnity.InletV.F = 0 * 'mol/s';
729                when trays(1).OutletV.P > CondenserUnity.OutletL.P + 1e-1 * 'atm' switchto "on";
730end     
731
732CONNECTIONS
733#vapor
734        ReboilerUnity.OutletV   to trays(NumberOfTrays).InletV;
735        trays(1).OutletV                                to CondenserUnity.InletV;
736
737#liquid
738        CondenserUnity.OutletL          to SplitterTop.Inlet;   
739        SplitterTop.Outlet2                             to PumpUnity.Inlet;
740        PumpUnity.Outlet                                        to trays(1).InletL;
741        trays(NumberOfTrays).OutletL    to BottomVessel.Inlet;
742        BottomVessel.Outlet                             to SplitterBottom.Inlet;
743        SplitterBottom.Outlet2                  to ReboilerUnity.InletL;
744
745#Connectors
746HeatToCondenser                         to CondenserUnity.InletQ;
747HeatToReboiler                          to ReboilerUnity.InletQ;
748HeatToBottomVessel      to BottomVessel.InletQ;
749CondenserUnity.OutletV to ConnectorCondenserVout;
750SplitterTop.Outlet1             to ConnectorSplitterTop;
751SplitterBottom.Outlet1  to ConnectorSplitterBottom;
752
753end
754
755#* -------------------------------------------------------------------
756* Distillation Column model with:
757*
758*       - NumberOfTrays like tray;
759*       - a kettle reboiler;
760*       - a steady state condenser with subcooling;
761*       - a vessel drum (layed cilinder);
762*       - a splitter which separate reflux and distillate;
763*       - a pump in reflux stream.
764*
765* ------------------------------------------------------------------*#
766Model Distillation_kettle_subcooling as Section_ColumnBasic
767
768ATTRIBUTES
769        Pallete         = true;
770        Icon            = "icon/DistillationKettleSubcooling";
771        Brief   = "Model of a distillation column with steady condenser and dynamic reboiler.";
772        Info            =
773"== Specify ==
774* the feed stream of each tray (Inlet);
775* the Murphree eficiency for each tray (Emv);
776* the pump pressure difference;
777* the heat supllied in reboiler and condenser;
778* the heat supllied in the top tank;
779* the condenser pressure drop;
780* the reboiler liquid outlet flow (OutletL.F);
781* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
782       
783== Initial Conditions ==
784* the trays temperature (OutletL.T);
785* the trays liquid level (Level) OR the trays liquid flow (OutletL.F);
786* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
787       
788* the top tank temperature (OutletL.T);
789* the top tank liquid level (Level);
790* (NoComps - 1) OutletL (OR OutletV) compositions;
791       
792* the reboiler temperature (OutletL.T);
793* the reboiler liquid level (Level);
794* (NoComps - 1) OutletL (OR OutletV) compositions.
795";
796       
797PARAMETERS
798        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Default = "on",Hidden=true);
799
800VARIABLES
801        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.46,Protected = true);
802        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.58,Protected = true);
803        CondenserUnity as condenserSteady;
804        TopVessel               as tank_cylindrical;
805        SplitterTop             as splitter;
806        PumpUnity               as pump;
807        ReboilerUnity   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                CondenserUnity.InletV.F*trays(1).vV = alfaTopo * Ah * sqrt(2*(trays(1).OutletV.P -
852                CondenserUnity.OutletL.P + 1e-8 * 'atm') / (alfa*trays(1).rhoV));
853                when CondenserUnity.InletV.F < 1e-6 * 'kmol/h' switchto "off";
854               
855                case "off":
856                CondenserUnity.InletV.F = 0 * 'mol/s';
857                when trays(1).OutletV.P > CondenserUnity.OutletL.P + 1e-1 * 'atm' switchto "on";
858end     
859
860CONNECTIONS
861#vapor
862        ReboilerUnity.OutletV to trays(NumberOfTrays).InletV;
863        trays(1).OutletV to CondenserUnity.InletV;
864
865#liquid
866        CondenserUnity.OutletL          to TopVessel.Inlet;     
867        TopVessel.Outlet                                        to SplitterTop.Inlet;
868        SplitterTop.Outlet2                             to PumpUnity.Inlet;     
869        PumpUnity.Outlet                                        to trays(1).InletL;
870        trays(NumberOfTrays).OutletL    to ReboilerUnity.InletL;
871
872#Connectors
873HeatToCondenser                         to CondenserUnity.InletQ;
874HeatToReboiler                          to ReboilerUnity.InletQ;
875HeatToTopVessel                         to TopVessel.InletQ;
876RebNoFlow.Outlet                to ReboilerUnity.Inlet;
877
878SplitterTop.Outlet1             to ConnectorSplitterOut;
879ReboilerUnity.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        CondenserUnity as condenser;
926        SplitterTop as splitter;
927        PumpUnity 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                CondenserUnity.InletV.F*trays(1).vV = alfaTopo * Ah * sqrt(2*(trays(1).OutletV.P -
946                CondenserUnity.OutletL.P + 1e-8 * 'atm') / (alfa*trays(1).rhoV));
947                when CondenserUnity.InletV.F < 1e-6 * 'kmol/h' switchto "off";
948               
949        case "off":
950                CondenserUnity.InletV.F = 0 * 'mol/s';
951                when trays(1).OutletV.P > CondenserUnity.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 CondenserUnity.InletV;
995
996#liquid
997        CondenserUnity.OutletL to SplitterTop.Inlet;   
998        SplitterTop.Outlet2 to PumpUnity.Inlet;
999        PumpUnity.Outlet to trays(1).InletL;
1000
1001#Connectors
1002HeatToCondenser         to CondenserUnity.InletQ;
1003VapourConnector to trays(NumberOfTrays).InletV;
1004SplitterTop.Outlet1             to ConnectorSplitterOut;
1005CondenserUnity.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        CondenserUnity as condenserSteady;
1053        TopVessel               as tank_cylindrical;
1054        SplitterTop             as splitter;
1055        PumpUnity               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                CondenserUnity.InletV.F*trays(1).vV = alfaTopo *Ah * sqrt(2*(trays(1).OutletV.P -
1092                CondenserUnity.OutletL.P + 1e-8 * 'atm') / (alfa*trays(1).rhoV));
1093        when CondenserUnity.InletV.F < 1e-6 * 'kmol/h' switchto "off";
1094               
1095        case "off":
1096                CondenserUnity.InletV.F = 0 * 'mol/s';
1097        when trays(1).OutletV.P > CondenserUnity.OutletL.P + 1e-1 * 'atm' switchto "on";
1098
1099end     
1100       
1101CONNECTIONS
1102#vapor
1103        trays(1).OutletV to CondenserUnity.InletV;
1104       
1105#liquid
1106        CondenserUnity.OutletL to TopVessel.Inlet;     
1107        TopVessel.Outlet                        to SplitterTop.Inlet;
1108        SplitterTop.Outlet2             to PumpUnity.Inlet;     
1109        PumpUnity.Outlet                        to trays(1).InletL;
1110
1111#Connectors
1112        VapourConnector                 to trays(NumberOfTrays).InletV;
1113        HeatToCondenser                 to CondenserUnity.InletQ;
1114        SplitterTop.Outlet1     to ConnectorSplitterTop;
1115        HeatToTopVessel         to TopVessel.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.325,Protected = true);
1155        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.47,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       
1160        REBOILER as reboiler;
1161
1162CONNECTIONS
1163#vapor
1164        REBOILER.OutletV to trays(NumberOfTrays).InletV;
1165       
1166#liquid
1167        trays(NumberOfTrays).OutletL to REBOILER.InletL;
1168
1169end
1170
1171
1172#* -------------------------------------------------------------------
1173* Reboiled Stripping Column model with:
1174*
1175*       - NumberOfTrays like tray;
1176*       - a vessel in the bottom of column;
1177*       - a splitter which separate the bottom product and the stream to reboiler;
1178*       - steady state reboiler (thermosyphon);
1179*
1180* ------------------------------------------------------------------*
1181Model Reboiled_Stripping_thermosyphon
1182        ATTRIBUTES
1183        Pallete         = true;
1184        Icon            = "icon/ReboiledThermosyphon";
1185        Brief           = "Model of a reboiled stripping column with steady reboiler.";
1186        Info            =
1187"== Specify ==
1188* the feed stream of each tray (Inlet);
1189* the Murphree eficiency for each tray (Emv);
1190* the vapour flow leaving the top of the column;
1191* the InletL stream of the top tray;
1192* the heat supllied in bottom tank;
1193* the heat supllied in the reboiler;
1194* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
1195       
1196== Initial Conditions ==
1197* the trays temperature (OutletL.T);
1198* the trays liquid level (Level) OR the trays liquid flow (OutletL.F);
1199* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
1200
1201* the bottom tank temperature (OutletL.T);
1202* the bottom tank liquid level (Level);
1203* (NoComps - 1) OutletL (OR OutletV) compositions.
1204";
1205       
1206        PARAMETERS
1207        outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
1208        outer NComp as Integer;
1209        NumberOfTrays as Integer(Brief="Number of trays", Default=2);
1210        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
1211        top as Integer(Brief="Number of top tray");
1212        bot as Integer(Brief="Number of bottom tray");
1213
1214        SET
1215        top = (NumberOfTrays-1)*(1-topdown)/2+1;
1216        bot = NumberOfTrays/top;
1217       
1218        VARIABLES
1219        trays(NumberOfTrays) as trayTeste;
1220        reb as reboilerSteady;
1221        spbottom as splitter;
1222        tbottom as tank;
1223
1224        CONNECTIONS
1225        #vapor
1226        reb.OutletV to trays(bot).InletV;
1227        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
1228       
1229        #liquid
1230        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
1231        trays(bot).OutletL to tbottom.Inlet;
1232        tbottom.Outlet to spbottom.Inlet;
1233        spbottom.Outlet2 to reb.InletL;
1234end
1235
1236#* -------------------------------------------------------------------
1237*  Reactive Distillation Column
1238*
1239* ------------------------------------------------------------------*
1240Model ReactiveDistillationTeste
1241        ATTRIBUTES
1242        Pallete         = true;
1243        Icon            = "icon/DistillationKettleCond";
1244        Brief           = "Model of a reactive distillation column with dynamic condenser and reboiler.";
1245        Info            =
1246"== Specify ==
1247* the reaction related variables for each tray, condenser and reboiler;
1248* the feed stream of each tray (Inlet);
1249* the Murphree eficiency for each tray Emv;
1250* the pump pressure difference;
1251* the heat supllied in reboiler and condenser;
1252* the condenser vapor outlet flow (OutletV.F);
1253* the reboiler liquid outlet flow (OutletL.F);
1254* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1255       
1256== Initial Conditions ==
1257* the trays temperature (OutletL.T);
1258* the trays liquid level (Level) OR the trays liquid flow (OutletL.F);
1259* (NoComps - 1) OutletL (OR OutletV) compositions for each tray;
1260       
1261* the condenser temperature (OutletL.T);
1262* the condenser liquid level (Level);
1263* (NoComps - 1) OutletL (OR OutletV) compositions;
1264       
1265* the reboiler temperature (OutletL.T);
1266* the reboiler liquid level (Level);
1267* (NoComps - 1) OutletL (OR OutletV) compositions.
1268";
1269       
1270        PARAMETERS
1271        outer PP as Plugin(Type="PP");
1272        outer NComp as Integer;
1273        NumberOfTrays as Integer(Brief="Number of trays", Default=2);
1274        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
1275        top as Integer(Brief="Number of top tray");
1276        bot as Integer(Brief="Number of bottom tray");
1277        alfacond as Real;
1278
1279        VapourFlow as Switcher(Valid = ["on", "off"], Default = "off");
1280       
1281        SET
1282        top = (NumberOfTrays-1)*(1-topdown)/2+1;
1283        bot = NumberOfTrays/top;
1284       
1285        VARIABLES
1286        trays(NumberOfTrays) as trayReactTeste;
1287        cond as condenserReact;
1288        reb as reboilerReact;
1289        sp as splitter;
1290        p as pump;
1291       
1292        EQUATIONS
1293       
1294        switch VapourFlow
1295                case "on":
1296                "Pressure Drop through the condenser"
1297                cond.InletV.F*trays(top).vV / 'm^2' =
1298                        sqrt((trays(top).OutletV.P - cond.OutletL.P + 1e-8 * 'atm')/(trays(top).rhoV*alfacond));
1299                when trays(top).OutletV.P < cond.OutletL.P switchto "off";
1300               
1301                case "off":
1302                "Prato selado"
1303                cond.InletV.F = 0.0 * 'mol/s';
1304                when trays(top).OutletV.P > cond.OutletL.P + 1e-3 * 'atm' switchto "on";
1305        end
1306
1307        CONNECTIONS
1308        #vapor
1309        reb.OutletV to trays(bot).InletV;
1310        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
1311        trays(top).OutletV to cond.InletV;
1312       
1313        #liquid
1314        cond.OutletL to sp.Inlet;       
1315        sp.Outlet2 to p.Inlet;
1316        p.Outlet to trays(top).InletL;
1317        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
1318        trays(bot).OutletL to reb.InletL;
1319       
1320end
1321
1322#*----------------------------------------------------------------------
1323* Model of a  packed column section with:
1324*       - NStages = theoretical number of equilibrium stages.
1325*
1326*---------------------------------------------------------------------*
1327Model Packed_Section_ColumnTeste
1328        ATTRIBUTES
1329        Pallete         = true;
1330        Icon            = "icon/PackedSectionColumn";
1331        Brief           = "Model of a packed column section.";
1332        Info            =
1333"== Model of a packed column section containing ==
1334* NStages theoretical stages.
1335       
1336== Specify ==
1337* the feed stream of each tray (Inlet);
1338* the InletL stream of the top tray;
1339* the InletV stream of the bottom tray;
1340* the total pressure drop (dP) of the section.
1341       
1342== Initial Conditions ==
1343* the stages temperature (OutletL.T);
1344* the stages liquid holdup;
1345* (NoComps - 1) OutletL (OR OutletV) compositions for each tray.
1346";
1347       
1348        PARAMETERS
1349        outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
1350        outer NComp as Integer;
1351        NStages as Integer(Brief="Number of trays", Default=2);
1352        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
1353        top as Integer(Brief="Number of top tray");
1354        bot as Integer(Brief="Number of bottom tray");
1355        H as length (Brief="Height of packing");
1356
1357        VARIABLES
1358        stage(NStages) as packedStageTeste;
1359        dP as pressure;
1360       
1361        SET
1362        top = (NStages-1)*(1-topdown)/2+1;
1363        bot = NStages/top;
1364        stage.hs = H/NStages;   
1365        stage.V = stage.hs * stage.d^2*3.14159/4;
1366       
1367        EQUATIONS
1368        stage.deltaP = dP/NStages;
1369       
1370        CONNECTIONS
1371        stage([top+topdown:topdown:bot]).OutletV to stage([top:topdown:bot-topdown]).InletV;
1372        stage([top:topdown:bot-topdown]).OutletL to stage([top+topdown:topdown:bot]).InletL;
1373end
1374
1375#*----------------------------------------------------------------------
1376* Model of a  packed distillation column containing:
1377*       - a section with NStages theoretical stages;
1378*       - a kettle reboiler;
1379*       - dymamic condenser;
1380*       - a splitter which separate reflux and distillate;
1381*       - a pump in reflux stream;
1382*---------------------------------------------------------------------*
1383Model PackedDistillation_kettle_cond as Packed_Section_ColumnTeste
1384        ATTRIBUTES
1385        Pallete         = true;
1386        Icon            = "icon/PackedDistillationKettleCond";
1387        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
1388        Info            =
1389"== Specify ==
1390* the feed stream of each tray (Inlet);
1391* the pump pressure difference;
1392* the total pressure drop (dP) of the packing;
1393* the heat supllied in reboiler and condenser;
1394* the condenser vapor outlet flow (OutletV.F);
1395* the reboiler liquid outlet flow (OutletL.F);
1396* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1397       
1398== Initial Conditions ==
1399* the stages temperature (OutletL.T);
1400* the stages initial molar holdup;
1401* (NoComps - 1) OutletL (OR OutletV) compositions for each stage;
1402       
1403* the condenser temperature (OutletL.T);
1404* the condenser liquid level (Level);
1405* (NoComps - 1) OutletL (OR OutletV) compositions;
1406       
1407* the reboiler temperature (OutletL.T);
1408* the reboiler liquid level (Level);
1409* (NoComps - 1) OutletL (OR OutletV) compositions.
1410";
1411       
1412        PARAMETERS
1413        VapourFlow as Switcher(Valid = ["on", "off"], Default = "on");
1414       
1415        VARIABLES
1416        cond as condenser;
1417        reb as reboiler;
1418        sptop as splitter;
1419        pump1 as pump;
1420       
1421        CONNECTIONS
1422        #vapor
1423        reb.OutletV to stage(bot).InletV;
1424        stage(top).OutletV to cond.InletV;
1425       
1426        #liquid
1427        cond.OutletL to sptop.Inlet;   
1428        sptop.Outlet2 to pump1.Inlet;
1429        pump1.Outlet to stage(top).InletL;
1430        stage(bot).OutletL to reb.InletL;
1431       
1432        EQUATIONS
1433        switch VapourFlow
1434                case "on":
1435                stage(bot).InletV.F*stage(bot).vV = sqrt((reb.OutletV.P - stage(bot).OutletV.P)/
1436                                        (stage(bot).rhoV*stage(bot).Qsil*20))*(stage(bot).d^2*3.14159/4*stage(bot).e - stage(bot).Al);
1437                when stage(bot).InletV.F < 1e-6 * 'kmol/h' switchto "off";
1438               
1439                case "off":
1440                stage(bot).InletV.F = 0 * 'mol/s';
1441                when reb.OutletV.P > stage(bot).OutletV.P + 1e-1 * 'atm' switchto "on";
1442        end
1443
1444end
1445*#
Note: See TracBrowser for help on using the repository browser.