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

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

updates

File size: 102.5 KB
Line 
1#*-------------------------------------------------------------------
2* EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC.
3*
4* This LIBRARY is free software; you can distribute it and/or modify
5* it under the therms of the ALSOC FREE LICENSE as available at
6* http://www.enq.ufrgs.br/alsoc.
7*
8* EMSO Copyright (C) 2004 - 2007 ALSOC, original code
9* from http://www.rps.eng.br Copyright (C) 2002-2004.
10* All rights reserved.
11*
12* EMSO is distributed under the therms of the ALSOC LICENSE as
13* available at http://www.enq.ufrgs.br/alsoc.
14*
15*----------------------------------------------------------------------
16* File containg models of columns: distillation, stripping, absorbers
17* rectifier, ....
18*
19* The default nomenclature is:
20*               Type_Column_reboilertype_condensertyper
21*
22* where:
23*       Type = refluxed or reboiled or section
24*       Column = Stripping, Absorption, Rectifier, Distillation
25*       Reboiler type (if exists) = kettle or thermosyphon
26*       Condenser type (if exists) = with subccoling or without subcooling
27*
28*-----------------------------------------------------------------------
29* Author: Paula B. Staudt
30* $Id: column.mso 511 2008-05-12 17:25:33Z paula $
31*---------------------------------------------------------------------*#
32
33using "tray";
34using "reboiler";
35using "condenser";
36using "mixers_splitters/splitter";
37using "tank";
38using "pressure_changers/pump";
39
40Model ControlSection
41
42ATTRIBUTES
43        Pallete = false;
44        Brief = "Control variables for column section.";
45
46PARAMETERS
47        outer NComp             as Integer      (Brief="Number of components");
48
49        Tindicator_TrayNumber   as Integer      (Brief="Temperature Indicator in the tray");
50        Pindicator_TrayNumber   as Integer      (Brief="Pressure Indicator in the tray");
51
52end
53
54Model InitializeSection
55
56ATTRIBUTES
57        Pallete = false;
58        Brief = "Initial conditions for column section.";
59
60PARAMETERS
61        outer NComp             as Integer      (Brief="Number of components");
62
63        TopTemperature          as temperature  (Brief = "Tray Temperature at Column Top", Default = 300);
64        BottomTemperature       as temperature  (Brief = "Tray Temperature at Column Bottom", Default = 330);
65        LevelFraction           as fraction             (Brief = "Tray Level Fraction", Default = 0.5);
66
67        TopComposition(NComp)           as fraction     (Brief = "Component Molar Fraction at Column Top", Default = 0.30);
68        BottomComposition(NComp)        as fraction     (Brief = "Component Molar Fraction at Column Bottom", Default = 0.30);
69
70end
71
72Model InitializeStage
73
74ATTRIBUTES
75        Pallete = false;
76        Brief = "Initial conditions for Packed column section.";
77
78PARAMETERS
79        outer NComp             as Integer      (Brief="Number of components");
80
81        TopStageTemperature             as temperature  (Brief = "Tray Temperature at Column Top", Default = 300);
82        BottomStageTemperature          as temperature  (Brief = "Tray Temperature at Column Bottom", Default = 300);
83       
84        TopStageComposition(NComp)              as fraction     (Brief = "Component Molar Fraction at Top");
85        BottomStageComposition(NComp)   as fraction     (Brief = "Component Molar Fraction at Bottom");
86        LiquidMolarHoldup                               as mol          (Brief="Molar liquid holdup", Default=0.01);
87
88end
89
90
91Model SectionColumnBasic
92
93ATTRIBUTES
94        Pallete = false;
95        Brief   = "Model of a basic column section.";
96        Info    =
97"Model of a basic column section containing a vetor of TRAYS numbered from the top-down.";
98
99PARAMETERS
100        outer PP                as Plugin               (Brief="External Physical Properties", Type="PP");
101        outer NComp     as Integer              (Brief="Number of components");
102
103        NumberOfFeeds                                           as Integer                      (Brief="Number of Feed Trays",Default=3,Protected=true);
104        FeedTrayLocation(NumberOfFeeds)         as Integer                      (Brief="Feed tray Location",Default=2);
105        NumberOfTrays                                           as Integer                      (Brief="Number of trays", Default=8);
106        LiqSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Liquid Side Tray Index", Default=0,Hidden=true);
107        VapSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Vapour Side Tray Index", Default=0,Hidden=true);
108
109        LiquidSideStreamLocation                        as Integer                      (Brief="Liquid Side Stream Location", Default=2);
110        VapourSideStreamLocation                        as Integer                      (Brief="Vapour Side Stream Location", Default=2);
111        Pi                                                                      as constant             (Brief="Pi Number",Default=3.14159265, Symbol = "\pi",Hidden=true);
112        g                                                                       as acceleration         (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
113        Mw(NComp)                                                       as molweight            (Brief="Component Mol Weight",Hidden=true);
114
115        VapourFlowModel         as Switcher     (Valid = ["Reepmeyer", "Feehery_Fv", "Roffel_Fv", "Klingberg", "Wang_Fv", "Elgue"], Default = "Reepmeyer");
116        LiquidFlowModel         as Switcher     (Valid = ["default", "Wang_Fl", "Olsen", "Feehery_Fl", "Roffel_Fl"], Default = "default");
117
118        TrayDiameter                    as length               (Brief="Tray Diameter",Default=1.600);
119        TraySpacing                             as length               (Brief="Tray Spacing",Default=0.600);
120        Fraction_HoleArea               as fraction     (Brief="Fraction of the active area that is occupied by the holes with respect to the total tray area",Default=0.10);
121        Fraction_DowncomerArea  as fraction     (Brief="Fraction of the downcomer area with respect to the total tray area",Default=0.20);
122        WeirLength                              as length               (Brief="Weir length");
123        WeirHeight                              as length               (Brief="Weir height");
124        TrayLiquidPasses                as Real                 (Brief="Number of liquid passes in the tray", Default=1);
125        HeatSupply                              as heat_rate    (Brief="Rate of heat supply");
126        AerationFraction                as Real                 (Brief="Aeration fraction", Default = 1);
127        DryPdropCoeff                   as Real                 (Brief="Dry pressure drop coefficient", Default= 0.60);
128       
129        PlateArea               as area         (Brief="Plate area = Atray - Adowncomer",Protected=true);
130        TrayVolume              as volume       (Brief="Total Volume of the tray",Protected=true);
131        HolesArea               as area         (Brief="Total holes area",Protected=true);
132
133        FeeheryCoeff    as Real         (Brief="Feeherys correlation coefficient", Unit='1/m^4', Default=1,Hidden=true);
134        ElgueCoeff              as Real         (Brief="Elgues correlation coefficient", Unit='kg/m/mol^2', Default=1,Hidden=true);
135        OlsenCoeff              as Real         (Brief="Olsens correlation coefficient", Default=1,Hidden=true);
136       
137        VapourFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
138        LiquidFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
139
140SET
141        VapSideTrayIndex(VapourSideStreamLocation) =1;
142        LiqSideTrayIndex(LiquidSideStreamLocation) =1;
143        Mw = PP.MolecularWeight();
144
145        PlateArea = 0.25*Pi*(TrayDiameter^2)*(1-Fraction_DowncomerArea);
146        TrayVolume = 0.25*Pi*(TrayDiameter^2)*TraySpacing;
147        HolesArea = 0.25*Pi*(TrayDiameter^2)*Fraction_HoleArea;
148
149VARIABLES
150
151        INITIALIZATION as InitializeSection (Brief="Column Model Initialization");
152        CONTROL                 as ControlSection (Brief="Column Model Control");
153       
154        out     TCI as control_signal   (Brief="Temperature  Indicator", Protected = true, PosX=1, PosY=0.73);
155        out     PCI as control_signal   (Brief="Pressure Indicator", Protected = true, PosX=0, PosY=0.24);
156       
157    in  LiquidInlet     as stream         (Brief="Liquid Inlet in the section", PosX=0.70, PosY=0);
158    out VapourOutlet    as vapour_stream  (Brief="Vapour Outlet in the section", PosX=0.30, PosY=0);
159
160    out VapourDrawOff   as vapour_stream  (Brief="Vapour Draw Off Port in the section", PosX=1, PosY=0.35,Protected = true);
161        out LiquidDrawOff   as liquid_stream  (Brief="Liquid Draw Off Port in the section", PosX=1, PosY=0.65,Protected = true);
162       
163        TRAYS(NumberOfTrays)    as tray                 (Brief="Number of trays in the Column Section",Protected=true);
164        VapourDrawOffFlow               as flow_mol     (Brief="Vapour Draw Off Stream Molar Flow Rate");
165        LiquidDrawOffFlow               as flow_mol     (Brief="Vapour Draw Off Stream Molar Flow Rate");
166        MurphreeEff                     as Real                 (Brief="Murphree efficiency for All Trays",Lower=0.01,Upper=1);
167
168        in      VapourInlet     as stream             (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1);
169        out     LiquidOutlet    as liquid_stream      (Brief="Liquid Outlet in the section", PosX=0.70, PosY=1);
170       
171        LiquidConnector as stream    (Brief="Liquid connection in the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
172        VapourConnector as stream    (Brief="Vapour connection in the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
173       
174CONNECTIONS
175        TRAYS([2:NumberOfTrays]).OutletVapour   to TRAYS([1:NumberOfTrays-1]).InletVapour;
176        TRAYS([1:NumberOfTrays-1]).OutletLiquid to TRAYS([2:NumberOfTrays]).InletLiquid;
177       
178    LiquidConnector to TRAYS(1).InletLiquid;
179    VapourConnector to TRAYS(NumberOfTrays).InletVapour;
180       
181INITIAL
182
183for i in 1:NumberOfTrays do
184
185"The initial temperature of the TRAYS"
186        TRAYS(i).OutletLiquid.T = INITIALIZATION.TopTemperature+(INITIALIZATION.BottomTemperature-INITIALIZATION.TopTemperature)*((i-1)/(NumberOfTrays-1));
187
188"The initial Level of the TRAYS"
189        TRAYS(i).Level = INITIALIZATION.LevelFraction*WeirHeight;
190end
191
192for i in 1:NComp-1 do
193
194for j in 1:NumberOfTrays do
195
196"The initial composition of the TRAYS - Normalized"
197        TRAYS(j).OutletLiquid.z(i) = INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) +(INITIALIZATION.BottomComposition(i)/sum(INITIALIZATION.BottomComposition)-INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) )*((j-1)/(NumberOfTrays-1));
198end
199
200end
201
202EQUATIONS
203
204"Tray Temperature Indicator"   
205        #TCI*'K' = TRAYS(min([NumberOfTrays, CONTROL.Tindicator_TrayNumber])).OutletVapour.T;
206        TCI*'K' = TRAYS(CONTROL.Tindicator_TrayNumber).OutletVapour.T;
207
208"Tray Pressure Indicator"       
209        #PCI*'atm' = TRAYS(min([NumberOfTrays, CONTROL.Pindicator_TrayNumber])).OutletVapour.P;
210        PCI*'atm' = TRAYS(CONTROL.Pindicator_TrayNumber).OutletVapour.P;
211
212for i in [1:NumberOfTrays] do
213
214"Murphree Efficiency"
215        TRAYS(i).OutletVapour.z =  MurphreeEff * (TRAYS(i).yideal - TRAYS(i).InletVapour.z) + TRAYS(i).InletVapour.z;
216
217"Level of clear liquid over the weir"
218        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/PlateArea;
219
220"Geometry Constraint"
221        TrayVolume = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
222
223"Energy Holdup"
224        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletLiquid.h + TRAYS(i).MV*TRAYS(i).OutletVapour.h - TRAYS(i).OutletLiquid.P*TrayVolume;
225
226"Energy Balance"
227        diff(TRAYS(i).E) = ( TRAYS(i).Inlet.F*TRAYS(i).Inlet.h + TRAYS(i).InletLiquid.F*TRAYS(i).InletLiquid.h + TRAYS(i).InletVapour.F*TRAYS(i).InletVapour.h- TRAYS(i).OutletLiquid.F*TRAYS(i).OutletLiquid.h - TRAYS(i).OutletVapour.F*TRAYS(i).OutletVapour.h
228        -TRAYS(i).VapourSideStream.F*TRAYS(i).VapourSideStream.h - TRAYS(i).LiquidSideStream.F*TRAYS(i).LiquidSideStream.h + HeatSupply );
229
230switch LiquidFlow
231                case "on":
232                        switch LiquidFlowModel
233                                case "default":
234                                "Francis Equation"
235                                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'1/s'*WeirLength*((TRAYS(i).Level-(AerationFraction*WeirHeight))/(AerationFraction))^2;
236                       
237                                case "Wang_Fl":
238                                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'m^0.5/s'*WeirLength*((TRAYS(i).Level-(AerationFraction*WeirHeight))/(AerationFraction))^1.5;
239                       
240                                case "Olsen":
241                                TRAYS(i).OutletLiquid.F / 'mol/s'= WeirLength*TrayLiquidPasses*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletVapour.z)/(0.665*OlsenCoeff)^1.5 * ((TRAYS(i).ML*sum(Mw*TRAYS(i).OutletLiquid.z)/TRAYS(i).rhoL/PlateArea)-WeirHeight)^1.5 * 'm^0.5/mol';
242                       
243                                case "Feehery_Fl":
244                                TRAYS(i).OutletLiquid.F = WeirLength*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletLiquid.z) * ((TRAYS(i).Level-WeirHeight)/750/'mm')^1.5 * 'm^2/s';
245                       
246                                case "Roffel_Fl":
247                                TRAYS(i).OutletLiquid.F = 2/3*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletLiquid.z)*WeirLength*(TRAYS(i).ML*sum(Mw*TRAYS(i).OutletLiquid.z)/(PlateArea*1.3)/TRAYS(i).rhoL)^1.5*sqrt(2*g/
248                                                        (2*(1 - 0.3593/'Pa^0.0888545'*abs(TRAYS(i).OutletVapour.F*sum(Mw*TRAYS(i).OutletVapour.z)/(PlateArea*1.3)/sqrt(TRAYS(i).rhoV))^0.177709)-1)); #/'(kg/m)^0.0888545/s^0.177709';
249                        end
250                when TRAYS(i).Level < (AerationFraction *WeirHeight) switchto "off";
251               
252                case "off":
253                "Low level"
254                TRAYS(i).OutletLiquid.F = 0 * 'mol/h';
255                when TRAYS(i).Level > (AerationFraction * WeirHeight) + 1e-6*'m' switchto "on";
256        end
257       
258switch VapourFlow
259                case "on":
260                        switch VapourFlowModel
261                                case "Reepmeyer":
262                                TRAYS(i).InletVapour.F*TRAYS(i).vV = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)/(TRAYS(i).rhoV*DryPdropCoeff))*HolesArea;
263                       
264                                case "Feehery_Fv":
265                                TRAYS(i).InletVapour.F = TRAYS(i).rhoV/PlateArea/FeeheryCoeff/sum(Mw*TRAYS(i).OutletVapour.z) * sqrt(((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)-(TRAYS(i).rhoV*g*TRAYS(i).ML*TRAYS(i).vL/PlateArea))/TRAYS(i).rhoV);
266                       
267                                case "Roffel_Fv":
268                                TRAYS(i).InletVapour.F^1.08 * 0.0013 * 'kg/m/mol^1.08/s^0.92*1e5' = (TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)*1e5 - (AerationFraction*sum(TRAYS(i).M*Mw)/(PlateArea*1.3)*g*1e5) * (TRAYS(i).rhoV*HolesArea/sum(Mw*TRAYS(i).OutletVapour.z))^1.08 * 'm^1.08/mol^1.08';
269                       
270                                case "Klingberg":
271                                TRAYS(i).InletVapour.F * TRAYS(i).vV = PlateArea * sqrt(((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)-TRAYS(i).rhoL*g*TRAYS(i).Level)/TRAYS(i).rhoV);
272                       
273                                case "Wang_Fv":
274                                TRAYS(i).InletVapour.F * TRAYS(i).vV = PlateArea * sqrt(((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)-TRAYS(i).rhoL*g*TRAYS(i).Level)/TRAYS(i).rhoV*DryPdropCoeff);
275                               
276                                case "Elgue":
277                                TRAYS(i).InletVapour.F  = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)/ElgueCoeff);
278                        end
279                when TRAYS(i).InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
280               
281                case "off":
282                TRAYS(i).InletVapour.F = 0 * 'mol/s';
283                when TRAYS(i).InletVapour.P > TRAYS(i).OutletVapour.P + TRAYS(i).Level*g*TRAYS(i).rhoL + 1e-1 * 'atm' switchto "on";
284        end
285
286end
287
288"Liquid Inlet Flow"     
289        LiquidConnector.F = LiquidInlet.F;
290
291"Liquid Inlet Temperature"             
292        LiquidConnector.T = LiquidInlet.T;
293
294"Liquid Inlet Pressure"         
295        LiquidConnector.P = LiquidInlet.P;
296
297"Liquid Inlet Composition"             
298        LiquidConnector.z = LiquidInlet.z;
299
300"Liquid Inlet Vapour Fraction"         
301        LiquidConnector.v = LiquidInlet.v;
302
303"Liquid Inlet Enthalpy"         
304        LiquidConnector.h = LiquidInlet.h;
305
306"Vapour Inlet Flow"             
307        VapourConnector.F = VapourInlet.F;
308
309"Vapour Inlet Temperature"             
310        VapourConnector.T = VapourInlet.T;
311
312"Vapour Inlet Pressure"         
313        VapourConnector.P = VapourInlet.P;
314
315"Vapour Inlet Composition"             
316        VapourConnector.z = VapourInlet.z;
317
318"Vapour Inlet Vapour Fraction"         
319        VapourConnector.v = VapourInlet.v;
320
321"Vapour Inlet Enthalpy"         
322        VapourConnector.h = VapourInlet.h;
323
324"Liquid Outlet Flow"   
325        LiquidOutlet.F = TRAYS(NumberOfTrays).OutletLiquid.F;
326
327"Liquid Outlet Temperature"     
328        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
329
330"Liquid Outlet Pressure"       
331        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
332
333"Liquid Outlet Composition"     
334        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
335
336"Vapour Outlet Flow"           
337        VapourOutlet.F = TRAYS(1).OutletVapour.F;
338
339"Vapour Outlet Temperature"             
340        VapourOutlet.T = TRAYS(1).OutletVapour.T;
341
342"Vapour Outlet Pressure"               
343        VapourOutlet.P = TRAYS(1).OutletVapour.P;
344
345"Vapour Outlet Composition"             
346        VapourOutlet.z = TRAYS(1).OutletVapour.z;
347
348"Vapour Draw Off Stream - Flow"         
349        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
350
351"Vapour Draw Off Stream - Temperature"         
352        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
353
354"Vapour Draw Off Stream - Pressure"             
355        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
356
357"Vapour Draw Off Stream - Composition"         
358        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
359
360"Vapour Draw Off Stream"       
361        VapourDrawOffFlow = VapourDrawOff.F;
362
363"Liquid Draw Off Stream - Flow"         
364        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
365
366"Liquid Draw Off Stream - Temperature" 
367        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
368
369"Liquid Draw Off Stream - Pressure"                     
370        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
371
372"Liquid Draw Off Stream - Composition" 
373        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
374
375"Liquid Draw Off Stream"       
376        LiquidDrawOffFlow = LiquidDrawOff.F;
377
378end
379
380Model Section_Column    as SectionColumnBasic
381
382ATTRIBUTES
383        Pallete         = true;
384        Icon            = "icon/SectionColumn";
385        Brief   = "Model of a column section.";
386        Info            =
387"== Model of a column section containing ==
388* NumberOfTrays TRAYS.
389* One Feed Inlet.
390       
391== Specify ==
392* the feed stream of each tray (Inlet);
393* the Murphree eficiency for each tray Emv;
394* the InletLiquid stream of the top tray;
395* the InletVapour stream of the bottom tray.
396       
397== Initial Conditions ==
398* the TRAYS temperature (OutletLiquid.T);
399* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
400* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
401";
402
403SET
404        NumberOfFeeds = 1;
405
406VARIABLES
407       
408        in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
409
410EQUATIONS
411#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
412# Equating Feed Tray Variables to Trays Variables
413#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
414for i in 1:NumberOfTrays do
415
416if   i equal FeedTrayLocation(1) then   
417
418"FeedTrayTop Inlet Flow"       
419        FeedTray.F= TRAYS(i).Inlet.F;
420
421"FeedTrayTop Inlet Temperature"
422        FeedTray.T = TRAYS(i).Inlet.T;
423
424"FeedTrayTop Inlet Pressure"
425        FeedTray.P = TRAYS(i).Inlet.P;
426
427"FeedTrayTop Inlet Composition"
428        FeedTray.z = TRAYS(i).Inlet.z;
429
430"FeedTrayTop Inlet Vapour Fraction"
431        FeedTray.v = TRAYS(i).Inlet.v;
432
433"FeedTrayTop Inlet Enthalpy"
434        FeedTray.h = TRAYS(i).Inlet.h;
435
436else
437
438"Inlet Tray - Flow Sealed"     
439        0*'mol/h'= TRAYS(i).Inlet.F;
440
441"Inlet Tray -  Temperature"
442        FeedTray.T = TRAYS(i).Inlet.T;
443
444"Inlet Tray -  Pressure"
445        FeedTray.P = TRAYS(i).Inlet.P;
446
447"Inlet Tray -  Composition"
448        FeedTray.z = TRAYS(i).Inlet.z;
449
450"Inlet Tray -  Vapour Fraction"
451        FeedTray.v = TRAYS(i).Inlet.v;
452
453"Inlet Tray -  Enthalpy"
454        FeedTray.h = TRAYS(i).Inlet.h;
455
456end
457
458end
459
460end
461
462Model Section_Column2   as SectionColumnBasic
463
464ATTRIBUTES
465        Pallete         = true;
466        Icon            = "icon/SectionColumn";
467        Brief   = "Model of a column section.";
468        Info            =
469"== Model of a column section containing ==
470* NumberOfTrays TRAYS.
471* Two Feed Inlets.
472       
473== Specify ==
474* the feed stream of each tray (Inlet);
475* the Murphree eficiency for each tray Emv;
476* the InletLiquid stream of the top tray;
477* the InletVapour stream of the bottom tray.
478       
479== Initial Conditions ==
480* the TRAYS temperature (OutletLiquid.T);
481* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
482* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
483";
484
485SET
486        NumberOfFeeds = 2;
487
488VARIABLES
489       
490        in      FeedTrayOne     as stream               (Brief="Feed stream", PosX=0, PosY=0.45);
491        in      FeedTrayTwo     as stream               (Brief="Feed stream", PosX=0, PosY=0.65);
492
493EQUATIONS
494
495for i in 1:NumberOfTrays do
496
497if   i equal FeedTrayLocation(1) then   
498
499"FeedTrayTop Inlet Flow"       
500        FeedTrayOne.F= TRAYS(i).Inlet.F;
501
502"FeedTrayTop Inlet Temperature"
503        FeedTrayOne.T = TRAYS(i).Inlet.T;
504
505"FeedTrayTop Inlet Pressure"
506        FeedTrayOne.P = TRAYS(i).Inlet.P;
507
508"FeedTrayTop Inlet Composition"
509        FeedTrayOne.z = TRAYS(i).Inlet.z;
510
511"FeedTrayTop Inlet Vapour Fraction"
512        FeedTrayOne.v = TRAYS(i).Inlet.v;
513
514"FeedTrayTop Inlet Enthalpy"
515        FeedTrayOne.h = TRAYS(i).Inlet.h;
516
517else if   i equal FeedTrayLocation(2) then   
518
519"FeedTrayBottom Inlet Flow"     
520        FeedTrayTwo.F= TRAYS(i).Inlet.F;
521
522"FeedTrayBottom Inlet Temperature"
523        FeedTrayTwo.T = TRAYS(i).Inlet.T;
524
525"FeedTrayBottom Inlet Pressure"
526        FeedTrayTwo.P = TRAYS(i).Inlet.P;
527
528"FeedTrayBottom Inlet Composition"
529        FeedTrayTwo.z = TRAYS(i).Inlet.z;
530
531"FeedTrayBottom Inlet Vapour Fraction"
532        FeedTrayTwo.v = TRAYS(i).Inlet.v;
533
534"FeedTrayBottom Inlet Enthalpy"
535        FeedTrayTwo.h = TRAYS(i).Inlet.h;
536
537else
538
539"Inlet Tray - Flow Sealed"     
540        0*'mol/h'= TRAYS(i).Inlet.F;
541
542"Inlet Tray -  Temperature"
543        FeedTrayTwo.T = TRAYS(i).Inlet.T;
544
545"Inlet Tray -  Pressure"
546        FeedTrayTwo.P = TRAYS(i).Inlet.P;
547
548"Inlet Tray -  Composition"
549        FeedTrayTwo.z = TRAYS(i).Inlet.z;
550
551"Inlet Tray -  Vapour Fraction"
552        FeedTrayTwo.v = TRAYS(i).Inlet.v;
553
554"Inlet Tray -  Enthalpy"
555        FeedTrayTwo.h = TRAYS(i).Inlet.h;
556
557end
558
559end
560
561end
562
563end
564
565Model Section_Column3   as SectionColumnBasic
566
567ATTRIBUTES
568        Pallete         = true;
569        Icon            = "icon/SectionColumn";
570        Brief   = "Model of a column section.";
571        Info            =
572"== Model of a column section containing ==
573* NumberOfTrays TRAYS.
574* Three Feed Inlets.
575       
576== Specify ==
577* the feed stream of each tray (Inlet);
578* the Murphree eficiency for each tray Emv;
579* the InletLiquid stream of the top tray;
580* the InletVapour stream of the bottom tray.
581       
582== Initial Conditions ==
583* the TRAYS temperature (OutletLiquid.T);
584* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
585* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
586";
587
588SET
589        NumberOfFeeds = 3;
590
591VARIABLES
592       
593        in      FeedTrayOne     as stream               (Brief="Feed stream", PosX=0, PosY=0.45);
594        in      FeedTrayTwo     as stream               (Brief="Feed stream", PosX=0, PosY=0.65);
595        in      FeedTrayThree   as stream               (Brief="Feed stream", PosX=0, PosY=0.85);
596
597EQUATIONS
598
599for i in 1:NumberOfTrays do
600
601if   i equal FeedTrayLocation(1) then   
602
603"FeedTrayTop Inlet Flow"       
604        FeedTrayOne.F= TRAYS(i).Inlet.F;
605
606"FeedTrayTop Inlet Temperature"
607        FeedTrayOne.T = TRAYS(i).Inlet.T;
608
609"FeedTrayTop Inlet Pressure"
610        FeedTrayOne.P = TRAYS(i).Inlet.P;
611
612"FeedTrayTop Inlet Composition"
613        FeedTrayOne.z = TRAYS(i).Inlet.z;
614
615"FeedTrayTop Inlet Vapour Fraction"
616        FeedTrayOne.v = TRAYS(i).Inlet.v;
617
618"FeedTrayTop Inlet Enthalpy"
619        FeedTrayOne.h = TRAYS(i).Inlet.h;
620
621else if   i equal FeedTrayLocation(2) then   
622
623"FeedTrayBottom Inlet Flow"     
624        FeedTrayTwo.F= TRAYS(i).Inlet.F;
625
626"FeedTrayBottom Inlet Temperature"
627        FeedTrayTwo.T = TRAYS(i).Inlet.T;
628
629"FeedTrayBottom Inlet Pressure"
630        FeedTrayTwo.P = TRAYS(i).Inlet.P;
631
632"FeedTrayBottom Inlet Composition"
633        FeedTrayTwo.z = TRAYS(i).Inlet.z;
634
635"FeedTrayBottom Inlet Vapour Fraction"
636        FeedTrayTwo.v = TRAYS(i).Inlet.v;
637
638"FeedTrayBottom Inlet Enthalpy"
639        FeedTrayTwo.h = TRAYS(i).Inlet.h;
640
641else if   i equal FeedTrayLocation(3) then   
642
643"FeedTrayBottom Inlet Flow"     
644        FeedTrayThree.F= TRAYS(i).Inlet.F;
645
646"FeedTrayBottom Inlet Temperature"
647        FeedTrayThree.T = TRAYS(i).Inlet.T;
648
649"FeedTrayBottom Inlet Pressure"
650        FeedTrayThree.P = TRAYS(i).Inlet.P;
651
652"FeedTrayBottom Inlet Composition"
653        FeedTrayThree.z = TRAYS(i).Inlet.z;
654
655"FeedTrayBottom Inlet Vapour Fraction"
656        FeedTrayThree.v = TRAYS(i).Inlet.v;
657
658"FeedTrayBottom Inlet Enthalpy"
659        FeedTrayThree.h = TRAYS(i).Inlet.h;
660
661else
662
663"Inlet Tray - Flow Sealed"     
664        0*'mol/h'= TRAYS(i).Inlet.F;
665
666"Inlet Tray -  Temperature"
667        FeedTrayTwo.T = TRAYS(i).Inlet.T;
668
669"Inlet Tray -  Pressure"
670        FeedTrayTwo.P = TRAYS(i).Inlet.P;
671
672"Inlet Tray -  Composition"
673        FeedTrayTwo.z = TRAYS(i).Inlet.z;
674
675"Inlet Tray -  Vapour Fraction"
676        FeedTrayTwo.v = TRAYS(i).Inlet.v;
677
678"Inlet Tray -  Enthalpy"
679        FeedTrayTwo.h = TRAYS(i).Inlet.h;
680
681end
682
683end
684
685end
686
687end
688
689end
690
691
692Model ColumnBasic
693
694ATTRIBUTES
695        Pallete = false;
696        Brief   = "Model of a basic column.";
697        Info    =
698"Model of a basic column containing a vetor of TRAYS numbered from the top-down.";
699
700PARAMETERS
701        outer PP                as Plugin       (Brief="External Physical Properties", Type="PP");
702        outer NComp     as Integer      (Brief="Number of components");
703
704        NumberOfFeeds                                           as Integer                      (Brief="Number of Feed Trays",Default=3,Protected=true);
705        FeedTrayLocation(NumberOfFeeds)         as Integer                      (Brief="Feed tray Location",Default=2);
706        NumberOfTrays                                           as Integer                      (Brief="Number of trays", Default=8);
707        LiqSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Liquid Side Tray Index", Default=0,Hidden=true);
708        VapSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Vapour Side Tray Index", Default=0,Hidden=true);
709        LiquidSideStreamLocation                        as Integer                      (Brief="Liquid Side Stream Location", Default=2);
710        VapourSideStreamLocation                        as Integer                      (Brief="Vapour Side Stream Location", Default=2);
711        g                                                                       as acceleration         (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
712        Mw(NComp)                                                       as molweight            (Brief="Component Mol Weight",Hidden=true);
713
714        VapourFlowModel         as Switcher     (Valid = ["Reepmeyer", "Feehery_Fv", "Roffel_Fv", "Klingberg", "Wang_Fv", "Elgue"], Default = "Reepmeyer");
715        LiquidFlowModel         as Switcher     (Valid = ["default", "Wang_Fl", "Olsen", "Feehery_Fl", "Roffel_Fl"], Default = "default");
716
717        VolumeOfTray            as volume               (Brief="Total Volume of the tray");
718        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
719        PlateArea                       as area                 (Brief="Plate area = Atray - Adowncomer");
720        HolesArea                       as area                 (Brief="Total holes area");
721        WeirLength                      as length               (Brief="Weir length");
722        WeirHeight                      as length               (Brief="Weir height");
723        TrayLiquidPasses        as Real                 (Brief="Number of liquid passes in the tray", Default=1);
724       
725        FeeheryCoeff            as Real                 (Brief="Feeherys correlation coefficient", Unit='1/m^4', Default=1,Hidden=true);
726        ElgueCoeff                      as Real                 (Brief="Elgues correlation coefficient", Unit='kg/m/mol^2', Default=1,Hidden=true);
727        OlsenCoeff                      as Real                 (Brief="Olsens correlation coefficient", Default=1,Hidden=true);
728       
729        V                               as volume               (Brief="Total Volume of the tray",Hidden=true);
730        Q                               as heat_rate    (Brief="Rate of heat supply",Hidden=true);
731        Ap                              as area                 (Brief="Plate area = Atray - Adowncomer",Hidden=true);
732        Ah                              as area                 (Brief="Total holes area",Hidden=true);
733        lw                              as length               (Brief="Weir length",Hidden=true);
734        hw                              as length               (Brief="Weir height",Hidden=true);
735        AerationFraction                        as fraction     (Brief="Aeration fraction");
736        alfa                    as fraction     (Brief="Dry pressure drop coefficient");
737        w                               as Real                 (Brief="Feeherys correlation coefficient", Unit='1/m^4', Default=1,Hidden=true);
738        btray                   as Real                 (Brief="Elgues correlation coefficient", Unit='kg/m/mol^2', Default=1,Hidden=true);
739        fw                              as Real                 (Brief="Olsens correlation coefficient", Default=1,Hidden=true);
740        Np                              as Real                 (Brief="Number of liquid passes in the tray", Default=1,Hidden=true);
741
742        VapourFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
743        LiquidFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
744
745SET
746        VapSideTrayIndex(VapourSideStreamLocation) =1;
747        LiqSideTrayIndex(LiquidSideStreamLocation) =1;
748        Mw = PP.MolecularWeight();
749
750        V=VolumeOfTray;
751        Q=HeatSupply;
752        Ap=PlateArea;
753        Ah=HolesArea;
754        lw=WeirLength;
755        hw=WeirHeight ;
756        w=FeeheryCoeff;
757        btray=ElgueCoeff;
758        fw=OlsenCoeff;
759        Np=TrayLiquidPasses;
760
761VARIABLES
762
763        INITIALIZATION as InitializeSection (Brief = "Column Model Initialization");
764        CONTROL                 as ControlSection (Brief = "Control");
765       
766        out     TCI as control_signal   (Brief="Temperature  Indicator", Protected = true, PosX=1, PosY=0.55);
767        out     PCI as control_signal   (Brief="Pressure Indicator", Protected = true, PosX=0, PosY=0.23);
768       
769        TRAYS(NumberOfTrays)    as tray                 (Brief="Number of trays in the Column Section");
770        VapourDrawOffFlow               as flow_mol     (Brief="Vapour Draw Off Stream Molar Flow Rate");
771        LiquidDrawOffFlow               as flow_mol     (Brief="Vapour Draw Off Stream Molar Flow Rate");
772        MurphreeEff                     as Real                 (Brief="Murphree efficiency for All Trays",Lower=0.01,Upper=1);
773
774        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.388,Protected = true);
775        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.47,Protected = true);
776
777CONNECTIONS
778
779#Connecting Intermediate Trays
780        TRAYS([2:NumberOfTrays]).OutletVapour   to TRAYS([1:NumberOfTrays-1]).InletVapour;
781        TRAYS([1:NumberOfTrays-1]).OutletLiquid         to TRAYS([2:NumberOfTrays]).InletLiquid;
782       
783INITIAL
784
785for i in 1:NumberOfTrays do
786
787"The initial temperature of the TRAYS"
788        TRAYS(i).OutletLiquid.T = INITIALIZATION.TopTemperature+(INITIALIZATION.BottomTemperature-INITIALIZATION.TopTemperature)*((i-1)/(NumberOfTrays-1));
789
790"The initial Level of the TRAYS"
791        TRAYS(i).Level = INITIALIZATION.LevelFraction*hw;
792end
793
794for i in 1:NComp-1 do
795
796for j in 1:NumberOfTrays do
797
798"The initial composition of the TRAYS - Normalized"
799        TRAYS(j).OutletLiquid.z(i) = INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) +(INITIALIZATION.BottomComposition(i)/sum(INITIALIZATION.BottomComposition)-INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) )*((j-1)/(NumberOfTrays-1));
800end
801
802end
803
804EQUATIONS
805
806        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
807        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
808        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
809        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
810
811        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
812        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
813        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
814        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
815
816        VapourDrawOffFlow = VapourDrawOff.F;
817        LiquidDrawOffFlow = LiquidDrawOff.F;
818       
819"Tray Temperature Indicator"   
820        #TCI*'K' = TRAYS(min([NumberOfTrays, CONTROL.Tindicator_TrayNumber])).OutletVapour.T;
821        TCI*'K' = TRAYS(CONTROL.Tindicator_TrayNumber).OutletVapour.T;
822
823"Tray Pressure Indicator"       
824        #PCI*'atm' = TRAYS(min([NumberOfTrays, CONTROL.Pindicator_TrayNumber])).OutletVapour.P;
825        PCI*'atm' = TRAYS(CONTROL.Pindicator_TrayNumber).OutletVapour.P;
826
827for i in [1:NumberOfTrays] do
828
829"Murphree Efficiency"
830        TRAYS(i).OutletVapour.z =  MurphreeEff * (TRAYS(i).yideal - TRAYS(i).InletVapour.z) + TRAYS(i).InletVapour.z;
831
832"Level of clear liquid over the weir"
833        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/Ap;
834
835"Geometry Constraint"
836        V = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
837
838"Energy Holdup"
839        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletLiquid.h + TRAYS(i).MV*TRAYS(i).OutletVapour.h - TRAYS(i).OutletLiquid.P*V;
840
841"Energy Balance"
842        diff(TRAYS(i).E) = ( TRAYS(i).Inlet.F*TRAYS(i).Inlet.h + TRAYS(i).InletLiquid.F*TRAYS(i).InletLiquid.h + TRAYS(i).InletVapour.F*TRAYS(i).InletVapour.h- TRAYS(i).OutletLiquid.F*TRAYS(i).OutletLiquid.h - TRAYS(i).OutletVapour.F*TRAYS(i).OutletVapour.h
843        -TRAYS(i).VapourSideStream.F*TRAYS(i).VapourSideStream.h - TRAYS(i).LiquidSideStream.F*TRAYS(i).LiquidSideStream.h + Q );
844
845switch LiquidFlow
846                case "on":
847                        switch LiquidFlowModel
848                                case "default":
849                                "Francis Equation"
850                                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'1/s'*lw*((TRAYS(i).Level-(AerationFraction*hw))/(AerationFraction))^2;
851                       
852                                case "Wang_Fl":
853                                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'m^0.5/s'*lw*((TRAYS(i).Level-(AerationFraction*hw))/(AerationFraction))^1.5;
854                       
855                                case "Olsen":
856                                TRAYS(i).OutletLiquid.F / 'mol/s'= lw*Np*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletVapour.z)/(0.665*fw)^1.5 * ((TRAYS(i).ML*sum(Mw*TRAYS(i).OutletLiquid.z)/TRAYS(i).rhoL/Ap)-hw)^1.5 * 'm^0.5/mol';
857                       
858                                case "Feehery_Fl":
859                                TRAYS(i).OutletLiquid.F = lw*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletLiquid.z) * ((TRAYS(i).Level-hw)/750/'mm')^1.5 * 'm^2/s';
860                       
861                                case "Roffel_Fl":
862                                TRAYS(i).OutletLiquid.F = 2/3*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletLiquid.z)*lw*(TRAYS(i).ML*sum(Mw*TRAYS(i).OutletLiquid.z)/(Ap*1.3)/TRAYS(i).rhoL)^1.5*sqrt(2*g/
863                                                        (2*(1 - 0.3593/'Pa^0.0888545'*abs(TRAYS(i).OutletVapour.F*sum(Mw*TRAYS(i).OutletVapour.z)/(Ap*1.3)/sqrt(TRAYS(i).rhoV))^0.177709)-1)); #/'(kg/m)^0.0888545/s^0.177709';
864                        end
865                when TRAYS(i).Level < (AerationFraction *hw) switchto "off";
866               
867                case "off":
868                "Low level"
869                TRAYS(i).OutletLiquid.F = 0 * 'mol/h';
870                when TRAYS(i).Level > (AerationFraction * hw) + 1e-6*'m' switchto "on";
871        end
872       
873switch VapourFlow
874                case "on":
875                        switch VapourFlowModel
876                                case "Reepmeyer":
877                                TRAYS(i).InletVapour.F*TRAYS(i).vV = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)/(TRAYS(i).rhoV*alfa))*Ah;
878                       
879                                case "Feehery_Fv":
880                                TRAYS(i).InletVapour.F = TRAYS(i).rhoV/Ap/w/sum(Mw*TRAYS(i).OutletVapour.z) * sqrt(((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)-(TRAYS(i).rhoV*g*TRAYS(i).ML*TRAYS(i).vL/Ap))/TRAYS(i).rhoV);
881                       
882                                case "Roffel_Fv":
883                                TRAYS(i).InletVapour.F^1.08 * 0.0013 * 'kg/m/mol^1.08/s^0.92*1e5' = (TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)*1e5 - (AerationFraction*sum(TRAYS(i).M*Mw)/(Ap*1.3)*g*1e5) * (TRAYS(i).rhoV*Ah/sum(Mw*TRAYS(i).OutletVapour.z))^1.08 * 'm^1.08/mol^1.08';
884                       
885                                case "Klingberg":
886                                TRAYS(i).InletVapour.F * TRAYS(i).vV = Ap * sqrt(((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)-TRAYS(i).rhoL*g*TRAYS(i).Level)/TRAYS(i).rhoV);
887                       
888                                case "Wang_Fv":
889                                TRAYS(i).InletVapour.F * TRAYS(i).vV = Ap * sqrt(((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)-TRAYS(i).rhoL*g*TRAYS(i).Level)/TRAYS(i).rhoV*alfa);
890                               
891                                case "Elgue":
892                                TRAYS(i).InletVapour.F  = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)/btray);
893                        end
894                when TRAYS(i).InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
895               
896                case "off":
897                TRAYS(i).InletVapour.F = 0 * 'mol/s';
898                when TRAYS(i).InletVapour.P > TRAYS(i).OutletVapour.P + TRAYS(i).Level*g*TRAYS(i).rhoL + 1e-1 * 'atm' switchto "on";
899        end
900
901end
902
903end
904
905Model Distillation_kettle_cond                          as ColumnBasic
906
907ATTRIBUTES
908        Pallete         = true;
909        Icon            = "icon/DistillationKettleCond";
910        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
911        Info            =
912"== Specify ==
913* the feed stream of each tray (Inlet);
914* the Murphree eficiency for each tray Emv;
915* the pump pressure difference;
916* the heat supllied in reboiler and condenser;
917* the condenser vapor outlet flow (OutletVapour.F);
918* the reboiler liquid outlet flow (OutletLiquid.F);
919* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
920       
921== Initial Conditions ==
922* the TRAYS temperature (OutletLiquid.T);
923* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
924* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
925       
926* the condenser temperature (OutletLiquid.T);
927* the condenser liquid level (Level);
928* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
929       
930* the reboiler temperature (OutletLiquid.T);
931* the reboiler liquid level (Level);
932* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
933";
934
935SET
936        NumberOfFeeds = 1;
937       
938VARIABLES
939
940        out     TI_reb  as control_signal       (Brief="Temperature Indicator of Reboiler ",Protected = true, PosX=0.515, PosY=1);
941        out     LI_reb  as control_signal       (Brief="Level Indicator of Reboiler", Protected = true, PosX=1, PosY=0.935);
942        out     PI_reb  as control_signal       (Brief="Pressure Indicator of Reboiler", Protected = true, PosX=0.41, PosY=1);
943       
944        out     TI_cond         as control_signal       (Brief="Temperature Indicator of Condenser ", Protected = true, PosX=0.52, PosY=0);
945        out     LI_cond         as control_signal       (Brief="Level Indicator of Condenser", Protected = true, PosX=1, PosY=0.084);
946        out     PI_cond         as control_signal       (Brief="Pressure Indicator of Condenser", Protected = true, PosX=0.42, PosY=0);
947       
948        in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
949
950        CONDENSER               as condenser;
951        REBOILER                as reboiler;
952        SPLITTER                as splitter2;
953        PUMP                    as pump;
954
955        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler",Protected = true, PosX=1, PosY=0.855);
956        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", Protected = true, PosX=1, PosY=0.01);
957
958
959        ConnectorHeatReboiler   as power        (Brief="Heat supplied to Reboiler", Hidden=true);
960        ConnectorHeatCondenser  as power        (Brief="Heat supplied to Condenser", Hidden=true);
961       
962        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Condenser", Hidden=true);
963        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
964        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
965
966        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Condenser", PosX=0.615, PosY=0);
967        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.235);
968        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.62, PosY=1);
969
970EQUATIONS
971
972        TI_reb  = REBOILER.TI ;
973        LI_reb  = REBOILER.LI;
974        PI_reb  = REBOILER.PI;
975       
976        TI_cond = CONDENSER.TI;
977        LI_cond = CONDENSER.LI;
978        PI_cond = CONDENSER.PI;
979       
980for i in 1:NumberOfTrays do
981
982if i equal FeedTrayLocation(1) then   
983
984"FeedTrayTop Inlet Flow"       
985        FeedTray.F= TRAYS(i).Inlet.F;
986
987"FeedTrayTop Inlet Temperature"
988        FeedTray.T = TRAYS(i).Inlet.T;
989
990"FeedTrayTop Inlet Pressure"
991        FeedTray.P = TRAYS(i).Inlet.P;
992
993"FeedTrayTop Inlet Composition"
994        FeedTray.z = TRAYS(i).Inlet.z;
995
996"FeedTrayTop Inlet Vapour Fraction"
997        FeedTray.v = TRAYS(i).Inlet.v;
998
999"FeedTrayTop Inlet Enthalpy"
1000        FeedTray.h = TRAYS(i).Inlet.h;
1001
1002else
1003
1004"Inlet Tray - Flow Sealed"     
1005        0*'mol/h'= TRAYS(i).Inlet.F;
1006
1007"Inlet Tray -  Temperature"
1008        FeedTray.T = TRAYS(i).Inlet.T;
1009
1010"Inlet Tray -  Pressure"
1011        FeedTray.P = TRAYS(i).Inlet.P;
1012
1013"Inlet Tray -  Composition"
1014        FeedTray.z = TRAYS(i).Inlet.z;
1015
1016"Inlet Tray -  Vapour Fraction"
1017        FeedTray.v = TRAYS(i).Inlet.v;
1018
1019"Inlet Tray -  Enthalpy"
1020        FeedTray.h = TRAYS(i).Inlet.h;
1021
1022end
1023
1024end
1025
1026# Condenser Connector Equations
1027        ConnectorCondenserVout.T = VapourDistillate.T;
1028        ConnectorCondenserVout.P = VapourDistillate.P;
1029        ConnectorCondenserVout.F = VapourDistillate.F;
1030        ConnectorCondenserVout.z = VapourDistillate.z;
1031
1032# Splitter Connector Equations
1033        ConnectorSplitterOut.T = LiquidDistillate.T;
1034        ConnectorSplitterOut.P = LiquidDistillate.P;
1035        ConnectorSplitterOut.F = LiquidDistillate.F;
1036        ConnectorSplitterOut.z = LiquidDistillate.z;
1037
1038# Reboiler Connector Equations
1039        ConnectorReboilerLout.T = BottomProduct.T;
1040        ConnectorReboilerLout.P = BottomProduct.P;
1041        ConnectorReboilerLout.F = BottomProduct.F;
1042        ConnectorReboilerLout.z = BottomProduct.z;
1043
1044        HeatToReboiler  = ConnectorHeatReboiler;
1045        HeatToCondenser = ConnectorHeatCondenser;
1046
1047CONNECTIONS
1048#vapor
1049        REBOILER.OutletVapour   to      TRAYS(NumberOfTrays).InletVapour;
1050        TRAYS(1).OutletVapour   to      CONDENSER.InletVapour;
1051
1052#liquid
1053        CONDENSER.OutletLiquid                          to      SPLITTER.Inlet;
1054        SPLITTER.Outlet2                                        to      PUMP.Inlet;
1055        PUMP.Outlet                                             to      TRAYS(1).InletLiquid;
1056        TRAYS(NumberOfTrays).OutletLiquid       to      REBOILER.InletLiquid;
1057
1058#Connectors
1059        CONDENSER.OutletVapour  to ConnectorCondenserVout;
1060        SPLITTER.Outlet1                to ConnectorSplitterOut;
1061        REBOILER.OutletLiquid   to ConnectorReboilerLout;
1062
1063        ConnectorHeatReboiler   to REBOILER.InletQ;
1064        ConnectorHeatCondenser  to CONDENSER.InletQ;
1065
1066end
1067
1068Model Distillation_thermosyphon_subcooling      as ColumnBasic
1069        ATTRIBUTES
1070        Pallete         = true;
1071        Icon            = "icon/DistillationThermosyphonSubcooling";
1072        Brief           = "Model of a distillation column with steady condenser and steady reboiler.";
1073        Info            =
1074"== Specify ==
1075* the feed stream of each tray (Inlet);
1076* the Murphree eficiency for each tray Emv;
1077* the pump head;
1078* the condenser pressure drop;
1079* the heat supllied in top and bottom tanks;
1080* the heat supllied in condenser and reboiler;
1081* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
1082* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1083       
1084== Initial Conditions ==
1085* the TRAYS temperature (OutletLiquid.T);
1086* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1087* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1088       
1089* the top tank temperature (OutletLiquid.T);
1090* the top tank liquid level (Level);
1091* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1092       
1093* the bottom tank temperature (OutletLiquid.T);
1094* the bottom tank liquid level (Level);
1095* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1096";
1097
1098SET
1099
1100        NumberOfFeeds = 1;
1101
1102VARIABLES
1103        CONDENSER                       as condenserSteady      (Brief="steady state condenser with subcooling");
1104        REFLUX_DRUM             as TankL                        (Brief="Reflux Drum");
1105        SPLITTER_TOP            as splitter2            (Brief="splitter which separate reflux and distillate");
1106        PUMP                            as pump                         (Brief="pump in reflux stream");
1107        REBOILER                        as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
1108        SUMP                            as SumpTank                     (Brief="vessel in the bottom of column");
1109        SPLITTER_BOTTOM         as splitter2            (Brief="splitter to separate the bottom product and the stream to reboiler");
1110       
1111        in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
1112
1113in              Q_cond          as power        (Brief="Heat supplied to Condenser",PosX=1, PosY=0, Protected=true);
1114in              Q_reb           as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.96,Protected=true);
1115in              Q_drum  as power        (Brief="Heat supplied to Reflux Drum", PosX=1, PosY=0.30,Protected=true);
1116
1117        out     TI_reb  as control_signal       (Brief="Temperature Indicator of Reboiler ",Protected = true, PosX=1, PosY=0.92);
1118        out     PI_reb  as control_signal       (Brief="Pressure Indicator of Reboiler", Protected = true, PosX=1, PosY=0.875);
1119       
1120        out     TI_cond         as control_signal       (Brief="Temperature Indicator of Condenser ", Protected = true, PosX=0.52, PosY=0);
1121        out     PI_cond         as control_signal       (Brief="Pressure Indicator of Condenser", Protected = true, PosX=0.42, PosY=0);
1122       
1123        out     TI_drum as control_signal       (Brief="Temperature Indicator of Reflux Drum ", Protected = true, PosX=1, PosY=0.20);
1124        out     PI_drum as control_signal       (Brief="Pressure Indicator of Reflux Drum", Protected = true, PosX=1, PosY=0.155);
1125        out     LI_drum as control_signal       (Brief="Level Indicator of Reflux Drum", Protected = true, PosX=1, PosY=0.24);
1126       
1127        out     LI_sump as control_signal       (Brief="Level Indicator of Column Sump", Protected = true, PosX=1, PosY=0.765);
1128        out     TI_sump as control_signal       (Brief="Temperature Indicator of Column Sump ",Protected = true, PosX=1, PosY=0.71);
1129       
1130        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.33);
1131        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=0.06, PosY=1);
1132
1133        in      ConnectorSplitterBottom         as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1134        in      ConnectorSplitterTop            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1135
1136        ConnectorHeatReboiler           as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1137        ConnectorHeatCondenser          as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1138        ConnectorHeatRefluxDrum         as power        (Brief="Connector for Heat supplied to Reflux Drum", Hidden=true);
1139
1140EQUATIONS
1141
1142        TI_reb  = REBOILER.TI ;
1143        PI_reb  = REBOILER.PI;
1144       
1145        TI_cond = CONDENSER.TI;
1146        PI_cond = CONDENSER.PI;
1147       
1148        TI_drum = REFLUX_DRUM.TI;
1149        PI_drum = REFLUX_DRUM.PI;
1150        LI_drum = REFLUX_DRUM.LI;
1151       
1152        TI_sump = SUMP.TI;
1153        LI_sump = SUMP.LI;
1154       
1155for i in 1:NumberOfTrays do
1156
1157if i equal FeedTrayLocation(1) then   
1158
1159"FeedTrayTop Inlet Flow"       
1160        FeedTray.F= TRAYS(i).Inlet.F;
1161
1162"FeedTrayTop Inlet Temperature"
1163        FeedTray.T = TRAYS(i).Inlet.T;
1164
1165"FeedTrayTop Inlet Pressure"
1166        FeedTray.P = TRAYS(i).Inlet.P;
1167
1168"FeedTrayTop Inlet Composition"
1169        FeedTray.z = TRAYS(i).Inlet.z;
1170
1171"FeedTrayTop Inlet Vapour Fraction"
1172        FeedTray.v = TRAYS(i).Inlet.v;
1173
1174"FeedTrayTop Inlet Enthalpy"
1175        FeedTray.h = TRAYS(i).Inlet.h;
1176
1177else
1178
1179"Inlet Tray - Flow Sealed"     
1180        0*'mol/h'= TRAYS(i).Inlet.F;
1181
1182"Inlet Tray -  Temperature"
1183        FeedTray.T = TRAYS(i).Inlet.T;
1184
1185"Inlet Tray -  Pressure"
1186        FeedTray.P = TRAYS(i).Inlet.P;
1187
1188"Inlet Tray -  Composition"
1189        FeedTray.z = TRAYS(i).Inlet.z;
1190
1191"Inlet Tray -  Vapour Fraction"
1192        FeedTray.v = TRAYS(i).Inlet.v;
1193
1194"Inlet Tray -  Enthalpy"
1195        FeedTray.h = TRAYS(i).Inlet.h;
1196
1197end
1198
1199end
1200
1201# Heat Connector Equations
1202        Q_cond  =       ConnectorHeatCondenser;
1203        Q_reb   =       ConnectorHeatReboiler;
1204        Q_drum  =       ConnectorHeatRefluxDrum;
1205
1206# Top Splitter Connector Equations
1207        ConnectorSplitterTop.T = LiquidDistillate.T;
1208        ConnectorSplitterTop.P = LiquidDistillate.P;
1209        ConnectorSplitterTop.F = LiquidDistillate.F;
1210        ConnectorSplitterTop.z = LiquidDistillate.z;
1211
1212# Bottom Splitter Connector Equations
1213        ConnectorSplitterBottom.T = BottomProduct.T;
1214        ConnectorSplitterBottom.P = BottomProduct.P;
1215        ConnectorSplitterBottom.F = BottomProduct.F;
1216        ConnectorSplitterBottom.z = BottomProduct.z;
1217       
1218CONNECTIONS
1219#vapor
1220        REBOILER.OutletVapour   to SUMP.InletVapour;
1221        SUMP.OutletVapour               to TRAYS(NumberOfTrays).InletVapour;
1222        TRAYS(1).OutletVapour   to CONDENSER.InletVapour;
1223
1224#liquid
1225        CONDENSER.OutletLiquid                          to REFLUX_DRUM.Inlet;   
1226        REFLUX_DRUM.OutletLiquid                        to SPLITTER_TOP.Inlet;
1227        SPLITTER_TOP.Outlet2                    to PUMP.Inlet; 
1228        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
1229        TRAYS(NumberOfTrays).OutletLiquid       to SUMP.InletLiquid;
1230        SUMP.OutletLiquid               to SPLITTER_BOTTOM.Inlet;
1231        SPLITTER_BOTTOM.Outlet2                 to REBOILER.InletLiquid;
1232
1233#Connectors
1234        ConnectorHeatCondenser                  to CONDENSER.InletQ;
1235        ConnectorHeatReboiler                   to REBOILER.InletQ;
1236        ConnectorHeatRefluxDrum                 to REFLUX_DRUM.InletQ;
1237        SPLITTER_TOP.Outlet1                    to ConnectorSplitterTop;
1238        SPLITTER_BOTTOM.Outlet1                 to ConnectorSplitterBottom;
1239
1240end
1241
1242Model Distillation_thermosyphon_cond            as ColumnBasic
1243        ATTRIBUTES
1244        Pallete         = true;
1245        Icon            = "icon/DistillationThermosyphonCond";
1246        Brief           = "Model of a distillation column with dynamic condenser and steady reboiler.";
1247        Info            =
1248"== Specify ==
1249* the feed stream of each tray (Inlet);
1250* the Murphree eficiency for each tray Emv;
1251* the pump head;
1252* the condenser vapor outlet flow (OutletVapour.F);
1253* the heat supllied in bottom tank;
1254* the heat supllied in condenser and reboiler;
1255* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
1256       
1257== Initial Conditions ==
1258* the TRAYS temperature (OutletLiquid.T);
1259* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1260* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1261       
1262* the condenser temperature (OutletLiquid.T);
1263* the condenser liquid level (Level);
1264* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1265       
1266* the bottom tank temperature (OutletLiquid.T);
1267* the bottom tank liquid level (Level);
1268* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1269";
1270
1271SET
1272
1273        NumberOfFeeds = 1;
1274
1275VARIABLES
1276        CONDENSER                       as condenser            (Brief="dynamic condenser without subcooling");
1277        SPLITTER_TOP            as splitter2            (Brief="splitter which separate reflux and distillate");
1278        PUMP                            as pump                         (Brief="pump in reflux stream");
1279        SUMP                            as SumpTank                     (Brief="vessel in the bottom of column");
1280        SPLITTER_BOTTOM         as splitter2            (Brief="splitter who separate the bottom product and the stream to reboiler");
1281        REBOILER                        as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
1282
1283        in      FeedTray        as stream       (Brief="Feed stream", PosX=0, PosY=0.55);
1284
1285in              Q_cond  as power        (Brief="Heat supplied to Condenser",PosX=1, PosY=0, Protected=true);
1286in              Q_reb   as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.96,Protected=true);
1287
1288        out     TI_cond as control_signal       (Brief="Temperature Indicator of Condenser ", Protected = true, PosX=0.48, PosY=0);
1289        out     LI_cond as control_signal       (Brief="Level Indicator of Condenser", Protected = true, PosX=1, PosY=0.084);
1290        out     PI_cond as control_signal       (Brief="Pressure Indicator of Condenser", Protected = true, PosX=0.40, PosY=0);
1291       
1292        out     TI_reb  as control_signal       (Brief="Temperature Indicator of Reboiler ",Protected = true, PosX=1, PosY=0.92);
1293        out     PI_reb  as control_signal       (Brief="Pressure Indicator of Reboiler", Protected = true, PosX=1, PosY=0.878);
1294       
1295        out     LI_sump as control_signal       (Brief="Level Indicator of Column Sump", Protected = true, PosX=1, PosY=0.76);
1296        out     TI_sump as control_signal       (Brief="Temperature Indicator of Column Sump ",Protected = true, PosX=1, PosY=0.71);
1297       
1298out     VapourDistillate as vapour_stream       (Brief="Vapour outlet stream From Top Condenser", PosX=0.62, PosY=0);
1299out     LiquidDistillate as liquid_stream       (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.185);
1300out     BottomProduct    as liquid_stream       (Brief="Liquid outlet stream From Bottom Splitter", PosX=0.06, PosY=1);
1301
1302in      ConnectorSplitterBottom as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1303in      ConnectorSplitterTop    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1304in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
1305
1306        ConnectorHeatReboiler   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1307        ConnectorHeatCondenser  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1308
1309EQUATIONS
1310
1311for i in 1:NumberOfTrays do
1312
1313if i equal FeedTrayLocation(1) then   
1314
1315"FeedTrayTop Inlet Flow"       
1316        FeedTray.F= TRAYS(i).Inlet.F;
1317
1318"FeedTrayTop Inlet Temperature"
1319        FeedTray.T = TRAYS(i).Inlet.T;
1320
1321"FeedTrayTop Inlet Pressure"
1322        FeedTray.P = TRAYS(i).Inlet.P;
1323
1324"FeedTrayTop Inlet Composition"
1325        FeedTray.z = TRAYS(i).Inlet.z;
1326
1327"FeedTrayTop Inlet Vapour Fraction"
1328        FeedTray.v = TRAYS(i).Inlet.v;
1329
1330"FeedTrayTop Inlet Enthalpy"
1331        FeedTray.h = TRAYS(i).Inlet.h;
1332
1333else
1334
1335"Inlet Tray - Flow Sealed"     
1336        0*'mol/h'= TRAYS(i).Inlet.F;
1337
1338"Inlet Tray -  Temperature"
1339        FeedTray.T = TRAYS(i).Inlet.T;
1340
1341"Inlet Tray -  Pressure"
1342        FeedTray.P = TRAYS(i).Inlet.P;
1343
1344"Inlet Tray -  Composition"
1345        FeedTray.z = TRAYS(i).Inlet.z;
1346
1347"Inlet Tray -  Vapour Fraction"
1348        FeedTray.v = TRAYS(i).Inlet.v;
1349
1350"Inlet Tray -  Enthalpy"
1351        FeedTray.h = TRAYS(i).Inlet.h;
1352
1353end
1354
1355end
1356
1357        TI_reb  = REBOILER.TI ;
1358        PI_reb  = REBOILER.PI;
1359       
1360        TI_cond = CONDENSER.TI;
1361        PI_cond = CONDENSER.PI;
1362        LI_cond = CONDENSER.LI;
1363       
1364        TI_sump = SUMP.TI;
1365        LI_sump = SUMP.LI;
1366       
1367# Heat Connector Equations
1368        Q_cond  =       ConnectorHeatCondenser;
1369        Q_reb   =       ConnectorHeatReboiler;
1370
1371# Condenser Connector Equations
1372        ConnectorCondenserVout.T = VapourDistillate.T;
1373        ConnectorCondenserVout.P = VapourDistillate.P;
1374        ConnectorCondenserVout.F = VapourDistillate.F;
1375        ConnectorCondenserVout.z = VapourDistillate.z;
1376
1377# Top Splitter Connector Equations
1378        ConnectorSplitterTop.T = LiquidDistillate.T;
1379        ConnectorSplitterTop.P = LiquidDistillate.P;
1380        ConnectorSplitterTop.F = LiquidDistillate.F;
1381        ConnectorSplitterTop.z = LiquidDistillate.z;
1382
1383# Bottom Splitter Connector Equations
1384        ConnectorSplitterBottom.T = BottomProduct.T;
1385        ConnectorSplitterBottom.P = BottomProduct.P;
1386        ConnectorSplitterBottom.F = BottomProduct.F;
1387        ConnectorSplitterBottom.z = BottomProduct.z;
1388
1389CONNECTIONS
1390#vapor
1391        SUMP.OutletVapour               to TRAYS(NumberOfTrays).InletVapour;
1392        REBOILER.OutletVapour   to SUMP.InletVapour;
1393        TRAYS(1).OutletVapour   to CONDENSER.InletVapour;
1394
1395#liquid
1396        CONDENSER.OutletLiquid          to SPLITTER_TOP.Inlet; 
1397        SPLITTER_TOP.Outlet2                            to PUMP.Inlet;
1398        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
1399        TRAYS(NumberOfTrays).OutletLiquid       to SUMP.InletLiquid;
1400        SUMP.OutletLiquid                               to SPLITTER_BOTTOM.Inlet;
1401        SPLITTER_BOTTOM.Outlet2                         to REBOILER.InletLiquid;
1402
1403#Connectors
1404ConnectorHeatCondenser                  to CONDENSER.InletQ;
1405ConnectorHeatReboiler                   to REBOILER.InletQ;
1406CONDENSER.OutletVapour                  to ConnectorCondenserVout;
1407SPLITTER_TOP.Outlet1                    to ConnectorSplitterTop;
1408SPLITTER_BOTTOM.Outlet1                 to ConnectorSplitterBottom;
1409
1410end
1411
1412Model Distillation_kettle_subcooling            as ColumnBasic
1413
1414ATTRIBUTES
1415        Pallete         = true;
1416        Icon            = "icon/DistillationKettleSubcooling";
1417        Brief   = "Model of a distillation column with steady condenser and dynamic reboiler.";
1418        Info            =
1419"== Specify ==
1420* the feed stream of each tray (Inlet);
1421* the Murphree eficiency for each tray (Emv);
1422* the pump pressure difference;
1423* the heat supllied in reboiler and condenser;
1424* the heat supllied in the top tank;
1425* the condenser pressure drop;
1426* the reboiler liquid outlet flow (OutletLiquid.F);
1427* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1428       
1429== Initial Conditions ==
1430* the TRAYS temperature (OutletLiquid.T);
1431* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1432* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1433       
1434* the top tank temperature (OutletLiquid.T);
1435* the top tank liquid level (Level);
1436* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1437       
1438* the reboiler temperature (OutletLiquid.T);
1439* the reboiler liquid level (Level);
1440* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1441";
1442
1443SET
1444
1445        NumberOfFeeds = 1;
1446
1447VARIABLES
1448        CONDENSER               as condenserSteady      (Brief="steady state condenser with subcooling");
1449        REFLUX_DRUM             as TankL                        (Brief="reflux drum");
1450        SPLITTER                as splitter2            (Brief="splitter to separate reflux and distillate");
1451        PUMP                    as pump                         (Brief="pump in reflux stream");
1452        REBOILER                as reboiler                     (Brief="kettle reboiler");
1453
1454        in      Q_cond  as power        (Brief="Heat supplied to Condenser", PosX=1, PosY=0.065, Protected=true);
1455        in      Q_reb   as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.905, Protected=true);
1456        in      Q_drum  as power        (Brief="Heat supplied to Top Vessel", PosX=1, PosY=0.30, Protected=true);
1457
1458        in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
1459
1460        out     TI_reb  as control_signal       (Brief="Temperature Indicator of Reboiler ",Protected = true, PosX=0.515, PosY=1);
1461        out     LI_reb  as control_signal       (Brief="Level Indicator of Reboiler", Protected = true, PosX=1, PosY=0.935);
1462        out     PI_reb  as control_signal       (Brief="Pressure Indicator of Reboiler", Protected = true, PosX=0.41, PosY=1);
1463       
1464        out     TI_cond as control_signal       (Brief="Temperature Indicator of Condenser ", Protected = true, PosX=0.52, PosY=0);
1465        out     PI_cond as control_signal       (Brief="Pressure Indicator of Condenser", Protected = true, PosX=0.42, PosY=0);
1466       
1467        out     TI_drum as control_signal       (Brief="Temperature Indicator of Reflux Drum ", Protected = true, PosX=1, PosY=0.20);
1468        out     PI_drum as control_signal       (Brief="Pressure Indicator of Reflux Drum", Protected = true, PosX=1, PosY=0.155);
1469        out     LI_drum as control_signal       (Brief="Level Indicator of Reflux Drum", Protected = true, PosX=1, PosY=0.24);
1470       
1471       
1472in      ConnectorSplitterOut            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1473in      ConnectorReboilerLout           as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1474        ConnectorHeatReboiler           as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1475        ConnectorHeatCondenser          as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1476        ConnectorHeatAccumulator        as power        (Brief="Connector for Heat supplied to TopVessel", Hidden=true);
1477
1478out     LiquidDistillate as liquid_stream       (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.33);
1479out     BottomProduct    as liquid_stream       (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
1480
1481EQUATIONS
1482
1483        TI_reb  = REBOILER.TI ;
1484        PI_reb  = REBOILER.PI;
1485        LI_reb  = REBOILER.LI;
1486       
1487        TI_cond = CONDENSER.TI;
1488        PI_cond = CONDENSER.PI;
1489       
1490        TI_drum = REFLUX_DRUM.TI;
1491        PI_drum = REFLUX_DRUM.PI;
1492        LI_drum = REFLUX_DRUM.LI;
1493       
1494for i in 1:NumberOfTrays do
1495
1496if i equal FeedTrayLocation(1) then   
1497
1498"FeedTrayTop Inlet Flow"       
1499        FeedTray.F= TRAYS(i).Inlet.F;
1500
1501"FeedTrayTop Inlet Temperature"
1502        FeedTray.T = TRAYS(i).Inlet.T;
1503
1504"FeedTrayTop Inlet Pressure"
1505        FeedTray.P = TRAYS(i).Inlet.P;
1506
1507"FeedTrayTop Inlet Composition"
1508        FeedTray.z = TRAYS(i).Inlet.z;
1509
1510"FeedTrayTop Inlet Vapour Fraction"
1511        FeedTray.v = TRAYS(i).Inlet.v;
1512
1513"FeedTrayTop Inlet Enthalpy"
1514        FeedTray.h = TRAYS(i).Inlet.h;
1515
1516else
1517
1518"Inlet Tray - Flow Sealed"     
1519        0*'mol/h'= TRAYS(i).Inlet.F;
1520
1521"Inlet Tray -  Temperature"
1522        FeedTray.T = TRAYS(i).Inlet.T;
1523
1524"Inlet Tray -  Pressure"
1525        FeedTray.P = TRAYS(i).Inlet.P;
1526
1527"Inlet Tray -  Composition"
1528        FeedTray.z = TRAYS(i).Inlet.z;
1529
1530"Inlet Tray -  Vapour Fraction"
1531        FeedTray.v = TRAYS(i).Inlet.v;
1532
1533"Inlet Tray -  Enthalpy"
1534        FeedTray.h = TRAYS(i).Inlet.h;
1535
1536end
1537
1538end
1539
1540#Heat Connectors
1541        Q_cond  = ConnectorHeatCondenser;
1542        Q_reb   = ConnectorHeatReboiler;
1543        Q_drum  = ConnectorHeatAccumulator;
1544
1545# Splitter Connector Equations
1546        ConnectorSplitterOut.T = LiquidDistillate.T;
1547        ConnectorSplitterOut.P = LiquidDistillate.P;
1548        ConnectorSplitterOut.F = LiquidDistillate.F;
1549        ConnectorSplitterOut.z = LiquidDistillate.z;
1550
1551# Reboiler Connector Equations
1552        ConnectorReboilerLout.T = BottomProduct.T;
1553        ConnectorReboilerLout.P = BottomProduct.P;
1554        ConnectorReboilerLout.F = BottomProduct.F;
1555        ConnectorReboilerLout.z = BottomProduct.z;
1556
1557CONNECTIONS
1558#vapor
1559        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
1560        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
1561
1562#liquid
1563        CONDENSER.OutletLiquid                          to REFLUX_DRUM.Inlet;   
1564        REFLUX_DRUM.OutletLiquid                        to SPLITTER.Inlet;
1565        SPLITTER.Outlet2                                        to PUMP.Inlet; 
1566        PUMP.Outlet                                             to TRAYS(1).InletLiquid;
1567        TRAYS(NumberOfTrays).OutletLiquid       to REBOILER.InletLiquid;
1568
1569#Connectors
1570        ConnectorHeatCondenser          to CONDENSER.InletQ;
1571        ConnectorHeatReboiler           to REBOILER.InletQ;
1572        ConnectorHeatAccumulator        to REFLUX_DRUM.InletQ;
1573
1574        SPLITTER.Outlet1                to ConnectorSplitterOut;
1575        REBOILER.OutletLiquid   to ConnectorReboilerLout;
1576
1577end
1578
1579Model Rectifier                                                         as ColumnBasic
1580
1581ATTRIBUTES
1582        Pallete         = true;
1583        Icon            = "icon/RefluxedCond";
1584        Brief           = "Model of a rectifier column with dynamic condenser.";
1585        Info            =
1586"== Specify ==
1587* the feed stream of each tray (Inlet);
1588* the Murphree eficiency for each tray Emv;
1589* the InletVapour stream of the bottom tray unless its flow;
1590* the pump pressure difference;
1591* the heat supllied in the condenser;
1592* the condenser vapor outlet flow (OutletVapour.F);
1593* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1594       
1595== Initial Conditions ==
1596* the TRAYS temperature (OutletLiquid.T);
1597* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1598* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1599       
1600* the condenser temperature (OutletLiquid.T);
1601* the condenser liquid level (Level);
1602* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1603";
1604
1605SET
1606        NumberOfFeeds = 1;
1607
1608VARIABLES
1609        CONDENSER       as condenser    (Brief="dymamic condenser without subcooling");
1610        SPLITTER        as splitter2    (Brief="splitter which separate reflux and distillate");
1611        PUMP            as pump                 (Brief="pump in reflux stream");
1612
1613        out     TI_cond         as control_signal       (Brief="Temperature Indicator of Condenser ", Protected = true, PosX=0.52, PosY=0);
1614        out     LI_cond         as control_signal       (Brief="Level Indicator of Condenser", Protected = true, PosX=1, PosY=0.084);
1615        out     PI_cond         as control_signal       (Brief="Pressure Indicator of Condenser", Protected = true, PosX=0.42, PosY=0);
1616       
1617        in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
1618       
1619        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.66, PosY=0);
1620        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.24);
1621
1622        in      Q_cond          as power (Brief="Heat supplied to Condenser",PosX=1, PosY=0.04, Protected = true);
1623
1624        in      VapourInlet             as stream                       (Brief="Vapour Inlet in the section", PosX=0.07, PosY=1);
1625        out     LiquidOutlet    as liquid_stream        (Brief="Liquid Outlet in the section", PosX=0.32, PosY=1);
1626
1627        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1628        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
1629                VapourConnector                 as stream       (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
1630                ConnectorHeatCondenser  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1631       
1632EQUATIONS
1633
1634        TI_cond = CONDENSER.TI;
1635        LI_cond = CONDENSER.LI;
1636        PI_cond = CONDENSER.PI;
1637       
1638for i in 1:NumberOfTrays do
1639
1640if i equal FeedTrayLocation(1) then   
1641
1642"FeedTrayTop Inlet Flow"       
1643        FeedTray.F= TRAYS(i).Inlet.F;
1644
1645"FeedTrayTop Inlet Temperature"
1646        FeedTray.T = TRAYS(i).Inlet.T;
1647
1648"FeedTrayTop Inlet Pressure"
1649        FeedTray.P = TRAYS(i).Inlet.P;
1650
1651"FeedTrayTop Inlet Composition"
1652        FeedTray.z = TRAYS(i).Inlet.z;
1653
1654"FeedTrayTop Inlet Vapour Fraction"
1655        FeedTray.v = TRAYS(i).Inlet.v;
1656
1657"FeedTrayTop Inlet Enthalpy"
1658        FeedTray.h = TRAYS(i).Inlet.h;
1659
1660else
1661
1662"Inlet Tray - Flow Sealed"     
1663        0*'mol/h'= TRAYS(i).Inlet.F;
1664
1665"Inlet Tray -  Temperature"
1666        FeedTray.T = TRAYS(i).Inlet.T;
1667
1668"Inlet Tray -  Pressure"
1669        FeedTray.P = TRAYS(i).Inlet.P;
1670
1671"Inlet Tray -  Composition"
1672        FeedTray.z = TRAYS(i).Inlet.z;
1673
1674"Inlet Tray -  Vapour Fraction"
1675        FeedTray.v = TRAYS(i).Inlet.v;
1676
1677"Inlet Tray -  Enthalpy"
1678        FeedTray.h = TRAYS(i).Inlet.h;
1679
1680end
1681
1682end
1683
1684        Q_cond = ConnectorHeatCondenser;
1685
1686# Condenser Connector Equations
1687        ConnectorCondenserVout.T = VapourDistillate.T;
1688        ConnectorCondenserVout.P = VapourDistillate.P;
1689        ConnectorCondenserVout.F = VapourDistillate.F;
1690        ConnectorCondenserVout.z = VapourDistillate.z;
1691       
1692# Splitter Connector Equations
1693        ConnectorSplitterOut.T = LiquidDistillate.T;
1694        ConnectorSplitterOut.P = LiquidDistillate.P;
1695        ConnectorSplitterOut.F = LiquidDistillate.F;
1696        ConnectorSplitterOut.z = LiquidDistillate.z;
1697       
1698        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletLiquid.F;
1699        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
1700        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
1701        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
1702
1703        VapourConnector.F= VapourInlet.F;
1704        VapourConnector.T = VapourInlet.T;
1705        VapourConnector.P = VapourInlet.P;
1706        VapourConnector.z = VapourInlet.z;
1707        VapourConnector.v = VapourInlet.v;
1708        VapourConnector.h = VapourInlet.h;
1709
1710CONNECTIONS
1711#vapor
1712        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
1713
1714#liquid
1715        CONDENSER.OutletLiquid  to SPLITTER.Inlet;     
1716        SPLITTER.Outlet2        to PUMP.Inlet; 
1717        PUMP.Outlet             to TRAYS(1).InletLiquid;
1718
1719#Connectors
1720ConnectorHeatCondenser  to CONDENSER.InletQ;
1721VapourConnector                 to TRAYS(NumberOfTrays).InletVapour;
1722SPLITTER.Outlet1                to ConnectorSplitterOut;
1723CONDENSER.OutletVapour  to ConnectorCondenserVout;
1724
1725end
1726
1727#*
1728Model Rectifier_subcooling as Section_ColumnBasicX
1729
1730ATTRIBUTES
1731        Pallete         = true;
1732        Icon            = "icon/RefluxedSubcooling";
1733        Brief           = "Model of a rectifier column with steady condenser.";
1734        Info            =
1735"== Specify ==
1736* the feed stream of each tray (Inlet);
1737* the Murphree eficiency for each tray Emv;
1738* the InletVapour stream of the bottom tray unless its flow;
1739* the pump head;
1740* the condenser pressure drop;
1741* the heat supllied in  the top tank;
1742* the heat supllied in condenser;
1743* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1744       
1745== Initial Conditions ==
1746* the TRAYS temperature (OutletLiquid.T);
1747* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1748* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1749       
1750* the top tank temperature (OutletLiquid.T);
1751* the top tank liquid level (Level);
1752* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
1753";
1754       
1755PARAMETERS
1756        CondenserVapourFlow             as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
1757
1758VARIABLES
1759#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1760# Column Vapour and Liquid Draw Sides
1761#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1762        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.485,Protected = true);
1763        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.535,Protected = true);
1764#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1765# Column Devices
1766#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1767        CONDENSER               as condenserSteady      (Brief="steady state condenser with subcooling");
1768        ACCUMULATOR             as tank_cylindrical     (Brief="vessel drum (layed cilinder)");
1769        SPLITTER                as splitter2                    (Brief="plitter which separate reflux and distillate");
1770        PUMP                    as pump                         (Brief="pump in reflux stream");
1771        alfaTopo                as Real;
1772#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1773# Column Bottom outlets
1774#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1775        in      VapourInlet             as stream                       (Brief="Vapour Inlet in the section", PosX=0.07, PosY=1);
1776        out     LiquidOutlet    as liquid_stream        (Brief="Liquid Outlet in the section", PosX=0.32, PosY=1);
1777#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1778# Heat Ports
1779#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1780        in      HeatToCondenser         as power        (Brief="Heat supplied to Condenser", PosX=1, PosY=0.070, Protected=true);
1781        in      HeatToAccumulator       as power        (Brief="Heat supplied to Top Accumulator", PosX=1, PosY=0.23, Protected=true);
1782#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1783# Column Top Product
1784#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1785        out     LiquidDistillate                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.285);
1786#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1787# Column Connectors
1788#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1789in      ConnectorSplitterTop            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1790        VapourConnector                         as stream       (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
1791        ConnectorHeatCondenser          as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1792        ConnectorHeatAccumulator        as power        (Brief="Connector for Heat supplied to Top Accumulator", Hidden=true);
1793
1794EQUATIONS
1795#Heat Connectors
1796        HeatToCondenser         = ConnectorHeatCondenser;
1797        HeatToAccumulator       = ConnectorHeatAccumulator;
1798       
1799        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletLiquid.F;
1800        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
1801        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
1802        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
1803
1804        VapourConnector.F= VapourInlet.F;
1805        VapourConnector.T = VapourInlet.T;
1806        VapourConnector.P = VapourInlet.P;
1807        VapourConnector.z = VapourInlet.z;
1808        VapourConnector.v = VapourInlet.v;
1809        VapourConnector.h = VapourInlet.h;
1810       
1811# Splitter Connector Equations
1812        ConnectorSplitterTop.T = LiquidDistillate.T;
1813        ConnectorSplitterTop.P = LiquidDistillate.P;
1814        ConnectorSplitterTop.F = LiquidDistillate.F;
1815        ConnectorSplitterTop.z = LiquidDistillate.z;
1816
1817        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1818        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1819        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1820        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1821
1822        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1823        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1824        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1825        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1826
1827        VapourDrawOffFlow = VapourDrawOff.F;
1828        LiquidDrawOffFlow = LiquidDrawOff.F;
1829       
1830switch CondenserVapourFlow
1831
1832        case "on":
1833                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo *Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
1834                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1835        when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
1836               
1837        case "off":
1838                CONDENSER.InletVapour.F = 0 * 'mol/s';
1839        when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
1840
1841end     
1842
1843CONNECTIONS
1844#vapor
1845        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
1846
1847#liquid
1848        CONDENSER.OutletLiquid          to ACCUMULATOR.Inlet;   
1849        ACCUMULATOR.Outlet                                      to SPLITTER.Inlet;
1850        SPLITTER.Outlet2                to PUMP.Inlet; 
1851        PUMP.Outlet                                             to TRAYS(1).InletLiquid;
1852
1853#Connectors
1854        VapourConnector                         to TRAYS(NumberOfTrays).InletVapour;
1855        ConnectorHeatCondenser                  to CONDENSER.InletQ;
1856        SPLITTER.Outlet1        to ConnectorSplitterTop;
1857        ConnectorHeatAccumulator                        to ACCUMULATOR.InletQ;
1858
1859end
1860
1861Model Reboiled_Stripping_kettle as Section_ColumnBasicX
1862       
1863ATTRIBUTES
1864        Pallete         = true;
1865        Icon            = "icon/ReboiledKettle";
1866        Brief           = "Model of a reboiled stripping column with dynamic reboiler.";
1867        Info            =
1868"== Specify ==
1869* the feed stream of each tray (Inlet);
1870* the Murphree eficiency for each tray Emv;
1871* the vapour flow leaving the top of the column;
1872* the InletLiquidiquid stream of the top tray;
1873* the heat supllied in the reboiler;
1874* the reboiler liquid outlet flow (OutletLiquid.F);
1875       
1876== Initial Conditions ==
1877* the TRAYS temperature (OutletLiquid.T);
1878* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1879* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1880       
1881* the reboiler temperature (OutletLiquid.T);
1882* the reboiler liquid level (Level);
1883* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1884";
1885
1886VARIABLES
1887#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1888# Column Vapour and Liquid Draw Sides
1889#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1890        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.28,Protected = true);
1891        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.33,Protected = true);
1892#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1893# Column Devices
1894#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
1895        REBOILER as reboiler (Brief="Kettle Reboiler");
1896#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1897# Heat Port
1898#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1899        in      HeatToReboiler  as power        (Brief="Heat supplied to Reboiler",PosX=1, PosY=0.865,Protected=true);
1900#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1901# Column Top Outlets
1902#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
1903        in      LiquidInlet             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.30, PosY=0);
1904        out     VapourOutlet    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.07, PosY=0);
1905#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1906# Column Bottom Product
1907#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1908        out     BottomProduct   as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.68, PosY=1);
1909#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1910# Column Connectors
1911#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1912        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1913                LiquidConnector                 as stream       (Brief="Liquid connection at the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
1914                ConnectorHeatReboiler   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1915
1916CONNECTIONS
1917#vapor
1918        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
1919       
1920#liquid
1921        TRAYS(NumberOfTrays).OutletLiquid to REBOILER.InletLiquid;
1922
1923#Connectors
1924REBOILER.OutletLiquid           to ConnectorReboilerLout;
1925LiquidConnector                 to TRAYS(1).InletLiquid;
1926ConnectorHeatReboiler   to REBOILER.InletQ;
1927
1928EQUATIONS
1929#Heat Connectors
1930        HeatToReboiler = ConnectorHeatReboiler;
1931       
1932        LiquidConnector.F= LiquidInlet.F;
1933        LiquidConnector.T = LiquidInlet.T;
1934        LiquidConnector.P = LiquidInlet.P;
1935        LiquidConnector.z = LiquidInlet.z;
1936        LiquidConnector.v = LiquidInlet.v;
1937        LiquidConnector.h = LiquidInlet.h;
1938       
1939        VapourOutlet.F= TRAYS(1).OutletVapour.F;
1940        VapourOutlet.T = TRAYS(1).OutletVapour.T;
1941        VapourOutlet.P = TRAYS(1).OutletVapour.P;
1942        VapourOutlet.z = TRAYS(1).OutletVapour.z;
1943       
1944# Reboiler Connector Equations
1945        ConnectorReboilerLout.T = BottomProduct.T;
1946        ConnectorReboilerLout.P = BottomProduct.P;
1947        ConnectorReboilerLout.F = BottomProduct.F;
1948        ConnectorReboilerLout.z = BottomProduct.z;
1949       
1950        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1951        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1952        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1953        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1954
1955        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1956        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1957        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1958        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1959
1960        VapourDrawOffFlow = VapourDrawOff.F;
1961        LiquidDrawOffFlow = LiquidDrawOff.F;
1962
1963end
1964
1965Model Reboiled_Stripping_thermosyphon as Section_ColumnBasicX
1966
1967ATTRIBUTES
1968        Pallete         = true;
1969        Icon            = "icon/ReboiledThermosyphon";
1970        Brief           = "Model of a reboiled stripping column with steady reboiler.";
1971        Info            =
1972"== Specify ==
1973* the feed stream of each tray (Inlet);
1974* the Murphree eficiency for each tray (Emv);
1975* the vapour flow leaving the top of the column;
1976* the InletLiquidiquid stream of the top tray;
1977* the heat supllied in bottom tank;
1978* the heat supllied in the reboiler;
1979* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
1980       
1981== Initial Conditions ==
1982* the TRAYS temperature (OutletLiquid.T);
1983* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1984* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
1985
1986* the bottom tank temperature (OutletLiquid.T);
1987* the bottom tank liquid level (Level);
1988* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
1989";
1990
1991VARIABLES
1992#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1993# Column Vapour and Liquid Draw Sides
1994#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1995        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.28,Protected = true);
1996        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.33,Protected = true);
1997#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1998# Column Devices
1999#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2000        REBOILER                as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
2001        SPLITTER                as splitter2            (Brief="splitter which separate the bottom product and the stream to reboiler");
2002        ACCUMULATOR     as tank                         (Brief="vessel in the bottom of column");
2003#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2004# Heat Ports
2005#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2006        in      HeatToReboiler          as power        (Brief="Heat supplied to Reboiler",PosX=1, PosY=0.84,Protected=true);
2007        in      HeatToAccumulator       as power        (Brief="Heat supplied to Bottom Vessel",PosX=0, PosY=0.91,Protected=true);
2008#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2009# Column Top Outlets
2010#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2011        in      LiquidInlet             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.32, PosY=0);
2012        out     VapourOutlet    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.07, PosY=0);
2013#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2014# Column Bottom Product
2015#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2016        out     BottomProduct   as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.19, PosY=1);
2017        LiquidConnector         as stream                       (Brief="Liquid connection at the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
2018#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2019# Column Connectors
2020#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2021        in      ConnectorSplitterBottom         as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
2022        ConnectorHeatReboiler                   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
2023        ConnectorHeatAccumulator                as power        (Brief="Connector for Heat supplied to Bottom Accumulator", Hidden=true);
2024
2025CONNECTIONS
2026#vapor
2027        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
2028       
2029#liquid
2030        TRAYS(NumberOfTrays).OutletLiquid       to ACCUMULATOR.Inlet;
2031        ACCUMULATOR.Outlet                              to SPLITTER.Inlet;
2032        SPLITTER.Outlet2                                to REBOILER.InletLiquid;
2033
2034#Connectors
2035LiquidConnector                         to TRAYS(1).InletLiquid;
2036ConnectorHeatReboiler           to REBOILER.InletQ;
2037ConnectorHeatAccumulator        to ACCUMULATOR.InletQ;
2038SPLITTER.Outlet1                        to ConnectorSplitterBottom;
2039
2040EQUATIONS
2041#Heat Connectors
2042        HeatToReboiler  = ConnectorHeatReboiler;
2043        HeatToAccumulator       = ConnectorHeatAccumulator;
2044       
2045        ConnectorSplitterBottom.T = BottomProduct.T;
2046        ConnectorSplitterBottom.P = BottomProduct.P;
2047        ConnectorSplitterBottom.F = BottomProduct.F;
2048        ConnectorSplitterBottom.z = BottomProduct.z;
2049       
2050        LiquidConnector.F= LiquidInlet.F;
2051        LiquidConnector.T = LiquidInlet.T;
2052        LiquidConnector.P = LiquidInlet.P;
2053        LiquidConnector.z = LiquidInlet.z;
2054        LiquidConnector.v = LiquidInlet.v;
2055        LiquidConnector.h = LiquidInlet.h;
2056       
2057        VapourOutlet.F= TRAYS(1).OutletVapour.F;
2058        VapourOutlet.T = TRAYS(1).OutletVapour.T;
2059        VapourOutlet.P = TRAYS(1).OutletVapour.P;
2060        VapourOutlet.z = TRAYS(1).OutletVapour.z;
2061       
2062        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
2063        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
2064        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
2065        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
2066
2067        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
2068        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
2069        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
2070        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
2071
2072        VapourDrawOffFlow = VapourDrawOff.F;
2073        LiquidDrawOffFlow = LiquidDrawOff.F;
2074
2075end
2076
2077Model ReactiveDistillation
2078       
2079ATTRIBUTES
2080        Pallete         = true;
2081        Icon            = "icon/DistillationReac";
2082        Brief           = "Model of a reactive distillation column with dynamic condenser and reboiler.";
2083        Info            =
2084"== Specify ==
2085* the reaction related variables for each tray, condenser and reboiler;
2086* the feed stream of each tray (Inlet);
2087* the Murphree eficiency for each tray Emv;
2088* the pump pressure difference;
2089* the heat supllied in reboiler and condenser;
2090* the condenser vapor outlet flow (OutletVapour.F);
2091* the reboiler liquid outlet flow (OutletLiquid.F);
2092* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
2093       
2094== Initial Conditions ==
2095* the TRAYS temperature (OutletLiquid.T);
2096* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
2097* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
2098       
2099* the condenser temperature (OutletLiquid.T);
2100* the condenser liquid level (Level);
2101* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
2102       
2103* the reboiler temperature (OutletLiquid.T);
2104* the reboiler liquid level (Level);
2105* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
2106";
2107       
2108PARAMETERS
2109        outer PP        as Plugin       (Type="PP");
2110        outer NComp as Integer  (Brief="Number of Components");
2111#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2112# Section Column Feed Tray - Side Streams  Location and Numbering
2113#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2114        NumberOfTrays                                           as Integer      (Brief="Number of TRAYS", Default=2);
2115        FeedTrayIndex(NumberOfTrays)            as Integer      (Brief="Feed Tray Index", Default=0,Hidden=true);
2116        LiqSideTrayIndex(NumberOfTrays)         as Integer      (Brief="Liquid Side Tray Index", Default=0,Hidden=true);
2117        VapSideTrayIndex(NumberOfTrays)         as Integer      (Brief="Vapour Side Tray Index", Default=0,Hidden=true);
2118        FeedTrayLocation                                        as Integer      (Brief="Feed tray Location", Default=2);
2119        LiquidSideStreamLocation                        as Integer      (Brief="Liquid Side Stream Location", Default=2);
2120        VapourSideStreamLocation                        as Integer      (Brief="Vapour Side Stream Location", Default=2);
2121#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2122# Section Column Flow Model for Liquid and Vapour
2123#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2124        VapourFlow              as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
2125        TrayVapourFlow  as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
2126        TrayLiquidFlow  as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
2127        alfacond                as Real;
2128#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2129# Section Column Tray Geometry and Auxiliar Parameters
2130#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2131        V               as volume               (Brief="Total Volume of the tray",Hidden=true);
2132        Q               as power                (Brief="Rate of heat supply",Hidden=true);
2133        Ap              as area                 (Brief="Plate area = Atray - Adowncomer",Hidden=true);
2134        Ah              as area                 (Brief="Total holes area",Hidden=true);
2135        lw              as length               (Brief="Weir length",Hidden=true);
2136        g               as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
2137        hw              as length               (Brief="Weir height",Hidden=true);
2138        beta    as fraction     (Brief="Aeration fraction");
2139        alfa    as fraction     (Brief="Dry pressure drop coefficient");
2140
2141        VolumeOfTray            as volume               (Brief="Total Volume of the tray");
2142        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
2143        PlateArea                       as area                 (Brief="Plate area = Atray - Adowncomer");
2144        HolesArea                       as area                 (Brief="Total holes area");
2145        WeirLength                      as length               (Brief="Weir length");
2146        WeirHeight                      as length               (Brief="Weir height");
2147
2148        stoic(NComp)    as Real(Brief="Stoichiometric matrix");
2149        Hr                                              as energy_mol;
2150       
2151SET
2152
2153        FeedTrayIndex(FeedTrayLocation)         =1;
2154        VapSideTrayIndex(FeedTrayLocation)      =1;
2155        LiqSideTrayIndex(FeedTrayLocation)      =1;
2156
2157        V=VolumeOfTray;
2158        Q=HeatSupply;
2159        Ap=PlateArea;
2160        Ah=HolesArea;
2161        lw=WeirLength;
2162        hw=WeirHeight ;
2163       
2164VARIABLES
2165#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2166# Tray Initialization For the Whole Column Section
2167#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2168        INITIALIZATION          as InitializeSection    (Brief = "Column Model Initialization");
2169#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2170# Column Feed - Side Stream Flow and Murphree Efficiency
2171#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2172        in      FeedTray                        as stream       (Brief="Feed stream", PosX=0, PosY=0.55);
2173                VapourDrawOffFlow       as flow_mol (Brief = "Stream Molar Flow Rate");
2174                LiquidDrawOffFlow   as flow_mol (Brief = "Stream Molar Flow Rate");
2175                MurphreeEff             as Real         (Brief = "Murphree efficiency");
2176#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2177# Column Vapour and Liquid Draw Sides
2178#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2179        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.395,Protected = true);
2180        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.44,Protected = true);
2181#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2182# Heat Ports
2183#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2184        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.89);
2185        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", PosX=1, PosY=0.07);
2186#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2187# Column Devices
2188#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2189        TRAYS(NumberOfTrays)    as trayReac;
2190        CONDENSER                               as condenserReact;
2191        REBOILER                                as reboilerReact;
2192        SPLITTER                                as splitter2;
2193        PUMP                                    as pump;
2194#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2195# Column Outlets
2196#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2197        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Condenser", PosX=0.59, PosY=0);
2198        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Splitter", PosX=1, PosY=0.23);
2199        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
2200#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2201# Column Connectors
2202#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2203in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
2204in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
2205in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
2206#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2207# Column Control Ports
2208#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2209        out     TRI as control_signal   (Brief="Temperature of Reboiler Indicator", PosX=1, PosY=0.83);
2210        out     LRI as control_signal   (Brief="Level of Reboiler Indicator", PosX=1, PosY=0.855);
2211        out     TCI as control_signal   (Brief="Temperature of Condenser Indicator", PosX=1, PosY=0.01);
2212        out     LCI as control_signal   (Brief="Level of Condenser Indicator", PosX=1, PosY=0.04);
2213
2214CONNECTIONS
2215#vapor
2216        REBOILER.OutletVapour                                   to TRAYS(NumberOfTrays).InletVapour;
2217        TRAYS(1).OutletVapour                                   to CONDENSER.InletVapour;
2218        TRAYS([2:NumberOfTrays]).OutletVapour   to TRAYS([1:NumberOfTrays-1]).InletVapour;
2219
2220#liquid
2221        CONDENSER.OutletLiquid                                  to SPLITTER.Inlet;     
2222        SPLITTER.Outlet2                                        to PUMP.Inlet;
2223        PUMP.Outlet                                             to TRAYS(1).InletLiquid;
2224        TRAYS([1:NumberOfTrays-1]).OutletLiquid         to TRAYS([2:NumberOfTrays]).InletLiquid;
2225        TRAYS(NumberOfTrays).OutletLiquid               to REBOILER.InletLiquid;
2226
2227#Connectors
2228        CONDENSER.OutletVapour  to ConnectorCondenserVout;
2229        SPLITTER.Outlet1        to ConnectorSplitterOut;
2230        REBOILER.OutletLiquid   to ConnectorReboilerLout;
2231
2232INITIAL
2233#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2234# Tray Initialization
2235#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2236for i in 1:NumberOfTrays do
2237
2238"The initial temperature of the TRAYS"
2239        TRAYS(i).OutletLiquid.T = INITIALIZATION.TopTemperature+(INITIALIZATION.BottomTemperature-INITIALIZATION.TopTemperature)*((i-1)/(NumberOfTrays-1));
2240
2241"The initial Level of the TRAYS"
2242        TRAYS(i).Level = INITIALIZATION.LevelFraction*hw;
2243end
2244
2245for i in 1:NComp-1 do
2246
2247for j in 1:NumberOfTrays do
2248
2249"The initial composition of the TRAYS - Normalized"
2250        TRAYS(j).OutletLiquid.z(i) = INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) +(INITIALIZATION.BottomComposition(i)/sum(INITIALIZATION.BottomComposition)-INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) )*((j-1)/(NumberOfTrays-1));
2251end
2252
2253end
2254
2255EQUATIONS
2256
2257for i in [1:NumberOfTrays] do
2258
2259"Murphree Efficiency"
2260        TRAYS(i).OutletVapour.z =  MurphreeEff * (TRAYS(i).yideal - TRAYS(i).InletVapour.z) + TRAYS(i).InletVapour.z;
2261       
2262"Energy Holdup"
2263        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletLiquid.h + TRAYS(i).MV*TRAYS(i).OutletVapour.h - TRAYS(i).OutletLiquid.P*V;
2264
2265"Component Molar Balance"
2266        diff(TRAYS(i).M)=TRAYS(i).Inlet.F*TRAYS(i).Inlet.z + TRAYS(i).InletLiquid.F*TRAYS(i).InletLiquid.z + TRAYS(i).InletVapour.F*TRAYS(i).InletVapour.z- TRAYS(i).OutletLiquid.F*TRAYS(i).OutletLiquid.z - TRAYS(i).OutletVapour.F*TRAYS(i).OutletVapour.z-
2267        TRAYS(i).LiquidSideStream.F*TRAYS(i).LiquidSideStream.z-TRAYS(i).VapourSideStream.F*TRAYS(i).VapourSideStream.z + stoic*TRAYS(i).r3*TRAYS(i).ML*TRAYS(i).vL;
2268       
2269"Energy Balance"
2270        diff(TRAYS(i).E) = ( TRAYS(i).Inlet.F*TRAYS(i).Inlet.h + TRAYS(i).InletLiquid.F*TRAYS(i).InletLiquid.h + TRAYS(i).InletVapour.F*TRAYS(i).InletVapour.h- TRAYS(i).OutletLiquid.F*TRAYS(i).OutletLiquid.h - TRAYS(i).OutletVapour.F*TRAYS(i).OutletVapour.h
2271        -TRAYS(i).VapourSideStream.F*TRAYS(i).VapourSideStream.h - TRAYS(i).LiquidSideStream.F*TRAYS(i).LiquidSideStream.h + Q ) + Hr * TRAYS(i).r3 *TRAYS(i). vL*TRAYS(i).ML;
2272
2273"Level of clear liquid over the weir"
2274        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/Ap;
2275
2276"Geometry Constraint"
2277        V = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
2278
2279end
2280
2281switch VapourFlow
2282                case "on":
2283                "Pressure Drop through the condenser"
2284                CONDENSER.InletVapour.F*TRAYS(1).vV / 'm^2' =
2285                        sqrt((TRAYS(1).OutletVapour.P - CONDENSER.OutletLiquid.P + 1e-8 * 'atm')/(TRAYS(1).rhoV*alfacond));
2286                when TRAYS(1).OutletVapour.P < CONDENSER.OutletLiquid.P switchto "off";
2287               
2288                case "off":
2289                "Prato selado"
2290                CONDENSER.InletVapour.F = 0.0 * 'mol/s';
2291                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-3 * 'atm' switchto "on";
2292        end
2293
2294for i in [1:NumberOfTrays] do
2295
2296        switch TrayLiquidFlow
2297                case "on":
2298                "Francis Equation"
2299                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'1/s'*lw*((TRAYS(i).Level-(beta*hw)+1e-6*'m')/(beta))^2;
2300                when TRAYS(i).Level < (beta * hw) switchto "off";
2301               
2302                case "off":
2303                "Low level"
2304                TRAYS(i).OutletLiquid.F = 0 * 'mol/h';
2305                when TRAYS(i).Level > (beta * hw) + 1e-6*'m' switchto "on";
2306        end
2307
2308        switch TrayVapourFlow
2309                case "on":
2310                TRAYS(i).InletVapour.F*TRAYS(i).vV = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P - TRAYS(i).Level*g*TRAYS(i).rhoL + 1e-8 * 'atm')/(TRAYS(i).rhoV*alfa))*Ah;
2311                when TRAYS(i).InletVapour.P < TRAYS(i).OutletVapour.P + TRAYS(i).Level*g*TRAYS(i).rhoL switchto "off";
2312               
2313                case "off":
2314                TRAYS(i).InletVapour.F = 0 * 'mol/s';
2315                when TRAYS(i).InletVapour.P > TRAYS(i).OutletVapour.P + TRAYS(i).Level*g*TRAYS(i).rhoL + 3e-2 * 'atm' switchto "on";
2316        end
2317
2318end
2319
2320# Connecting Trays
2321        FeedTray.F*FeedTrayIndex= TRAYS.Inlet.F;
2322        FeedTray.T = TRAYS.Inlet.T;
2323        FeedTray.P = TRAYS.Inlet.P;
2324        FeedTray.z = TRAYS.Inlet.z;
2325        FeedTray.v = TRAYS.Inlet.v;
2326        FeedTray.h = TRAYS.Inlet.h;
2327
2328        HeatToReboiler  = REBOILER.InletQ;
2329        HeatToCondenser = CONDENSER.InletQ;
2330
2331"Reboiler Temperature indicator"
2332        TRI * 'K' = REBOILER.OutletLiquid.T;
2333
2334"Reboiler Level indicator"
2335        LRI*REBOILER.V = REBOILER.Level*REBOILER.Across;
2336
2337"Condenser Temperature indicator"
2338        TCI * 'K' = CONDENSER.OutletLiquid.T;
2339
2340"Condenser Level indicator"
2341        LCI*CONDENSER.V = CONDENSER.Level*CONDENSER.Across;
2342
2343# Condenser Connector Equations
2344        ConnectorCondenserVout.T = VapourDistillate.T;
2345        ConnectorCondenserVout.P = VapourDistillate.P;
2346        ConnectorCondenserVout.F = VapourDistillate.F;
2347        ConnectorCondenserVout.z = VapourDistillate.z;
2348
2349# Splitter Connector Equations
2350        ConnectorSplitterOut.T = LiquidDistillate.T;
2351        ConnectorSplitterOut.P = LiquidDistillate.P;
2352        ConnectorSplitterOut.F = LiquidDistillate.F;
2353        ConnectorSplitterOut.z = LiquidDistillate.z;
2354
2355# Reboiler Connector Equations
2356        ConnectorReboilerLout.T = BottomProduct.T;
2357        ConnectorReboilerLout.P = BottomProduct.P;
2358        ConnectorReboilerLout.F = BottomProduct.F;
2359        ConnectorReboilerLout.z = BottomProduct.z;
2360
2361        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
2362        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
2363        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
2364        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
2365
2366        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
2367        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
2368        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
2369        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
2370
2371        VapourDrawOffFlow = VapourDrawOff.F;
2372        LiquidDrawOffFlow = LiquidDrawOff.F;
2373
2374end
2375
2376Model Packed_Section_ColumnBasic
2377        ATTRIBUTES
2378        Pallete         = false;
2379        Icon            = "icon/PackedSectionColumn";
2380        Brief           = "Model of a packed column section.";
2381        Info            =
2382"== Model of a packed column section containing ==
2383* NStages theoretical stages.
2384       
2385== Specify ==
2386* the feed stream of each tray (Inlet);
2387* the InletLiquid stream of the top tray;
2388* the InletVapour stream of the bottom tray;
2389* the total pressure drop (dP) of the section.
2390       
2391== Initial Conditions ==
2392* the stages temperature (OutletLiquid.T);
2393* the stages liquid holdup;
2394* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
2395";
2396       
2397PARAMETERS
2398
2399        outer PP                as Plugin(Brief = "External Physical Properties", Type="PP");
2400        outer NComp     as Integer;
2401       
2402        NumberOfStages                                  as Integer      (Brief="Number of Stages", Default=3);
2403        FeedStageIndex(NumberOfStages)  as Integer      (Brief="Number of Stages", Default=0,Hidden=true);
2404        FeedStageLocation                               as Integer      (Brief="Feed Stage Location", Default=2);
2405       
2406        PackingHeight           as length               (Brief="Height of packing");
2407        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
2408        ColumnDiameter          as length               (Brief="Column diameter");
2409        VoidFraction            as Real                 (Brief="Void fraction of packing, m^3/m^3");
2410        ResistanceCoeff         as positive     (Brief="Resistance coefficient on the liquid load", Default=1);
2411        AreaPerPackingVol       as Real                 (Brief="surface area per packing volume", Unit='m^2/m^3');
2412       
2413        V                               as volume               (Brief="Total Volume of the tray",Hidden=true);
2414        g                               as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
2415        hs                              as length               (Brief="Height of the packing stage",Hidden=true);
2416        ColumnArea              as area                 (Brief="Column Sectional Cross Area",Hidden=true);
2417
2418VARIABLES
2419#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2420# Stages Initialization For the Whole Column Section
2421#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2422        INITIALIZATION          as InitializeStage      (Brief = "Column Model Initialization");
2423        in      FeedStage       as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
2424       
2425        STAGES(NumberOfStages) as packedStage;
2426        PressureDrop               as pressure;
2427       
2428SET
2429        FeedStageIndex(FeedStageLocation) =1;
2430       
2431        ColumnArea = ColumnDiameter^2*3.14159*0.25;
2432        hs =PackingHeight/NumberOfStages;       
2433        V = hs * ColumnArea;
2434       
2435CONNECTIONS
2436
2437        STAGES([2:NumberOfStages]).OutletVapour                 to STAGES([1:NumberOfStages-1]).InletVapour;
2438        STAGES([1:NumberOfStages-1]).OutletLiquid       to STAGES([2:NumberOfStages]).InletLiquid;
2439
2440EQUATIONS
2441# Connecting STAGES
2442        FeedStage.F*FeedStageIndex= STAGES.Inlet.F;
2443        FeedStage.T = STAGES.Inlet.T;
2444        FeedStage.P = STAGES.Inlet.P;
2445        FeedStage.z = STAGES.Inlet.z;
2446        FeedStage.v = STAGES.Inlet.v;
2447        FeedStage.h = STAGES.Inlet.h;
2448
2449        STAGES.deltaP = PressureDrop/NumberOfStages;
2450
2451for i in [1:NumberOfStages] do
2452
2453"Energy Balance"
2454        diff(STAGES(i).E) = ( STAGES(i).Inlet.F*STAGES(i).Inlet.h + STAGES(i).InletLiquid.F*STAGES(i).InletLiquid.h + STAGES(i).InletVapour.F*STAGES(i).InletVapour.h- STAGES(i).OutletLiquid.F*STAGES(i).OutletLiquid.h
2455        - STAGES(i).OutletVapour.F*STAGES(i).OutletVapour.h + HeatSupply );
2456       
2457"Energy Holdup"
2458        STAGES(i).E = STAGES(i).ML*STAGES(i).OutletLiquid.h + STAGES(i).MV*STAGES(i).OutletVapour.h - STAGES(i).OutletLiquid.P*V;
2459       
2460"Geometry Constraint"
2461        V*VoidFraction= STAGES(i).ML*STAGES(i).vL + STAGES(i).MV*STAGES(i).vV;
2462       
2463"Volume flow rate of vapor, m^3/m^2/s"
2464        STAGES(i).uV * ((ColumnArea)*VoidFraction - STAGES(i).Al) = STAGES(i).OutletVapour.F * STAGES(i).vV;
2465       
2466"Liquid holdup"
2467        STAGES(i).hl = STAGES(i).ML*STAGES(i).vL/V/VoidFraction;
2468       
2469"Particle diameter"
2470        STAGES(i).dp = 6 * (1-VoidFraction)/AreaPerPackingVol;
2471       
2472"Wall Factor"
2473        STAGES(i).invK = (1 + (2*STAGES(i).dp/(3*ColumnDiameter*(1-VoidFraction))));
2474       
2475"Reynolds number of the vapor stream"
2476        STAGES(i).Rev*STAGES(i).invK = STAGES(i).dp*STAGES(i).uV*STAGES(i).rhoV / (STAGES(i).miV*(1-VoidFraction));
2477       
2478"Pressure drop and Vapor flow"
2479        STAGES(i).deltaP/hs  = ResistanceCoeff*AreaPerPackingVol*STAGES(i).uV^2*STAGES(i).rhoV*STAGES(i).invK / (2*(VoidFraction-STAGES(i).hl)^3);
2480
2481"Liquid holdup"
2482        STAGES(i).hl = (12*STAGES(i).miL*AreaPerPackingVol^2*STAGES(i).uL/STAGES(i).rhoL/g)^1/3;
2483
2484"Area occupied by the liquid"
2485        STAGES(i).Al = STAGES(i).ML*STAGES(i).vL/hs;
2486
2487end
2488
2489INITIAL
2490
2491for i in 1:NumberOfStages do
2492
2493"The initial temperature of the STAGES"
2494        STAGES(i).OutletLiquid.T = INITIALIZATION.TopStageTemperature+(INITIALIZATION.BottomStageTemperature-INITIALIZATION.TopStageTemperature)*((i-1)/(NumberOfStages-1));
2495
2496"The Liquid Holdup of the STAGES"
2497        STAGES(i).ML = INITIALIZATION.LiquidMolarHoldup;
2498
2499end
2500
2501for i in 1:NComp-1 do
2502       
2503for j in 1:NumberOfStages do
2504
2505"The initial composition of the TRAYS"
2506        STAGES(j).OutletLiquid.z(i) = INITIALIZATION.TopStageComposition(i)/sum(INITIALIZATION.TopStageComposition) +(INITIALIZATION.BottomStageComposition(i)/sum(INITIALIZATION.BottomStageComposition)-INITIALIZATION.TopStageComposition(i)/sum(INITIALIZATION.TopStageComposition) )*((j-1)/(NumberOfStages-1));
2507
2508end
2509
2510end
2511
2512end
2513
2514Model Packed_Section_Column as Packed_Section_ColumnBasic
2515
2516        ATTRIBUTES
2517        Pallete         = true;
2518        Icon            = "icon/PackedSectionColumn";
2519        Brief           = "Model of a packed column section.";
2520        Info            =
2521"== Model of a packed column section containing ==
2522* NStages theoretical stages.
2523       
2524== Specify ==
2525* the feed stream of each tray (Inlet);
2526* the InletLiquid stream of the top tray;
2527* the InletVapour stream of the bottom tray;
2528* the total pressure drop (dP) of the section.
2529       
2530== Initial Conditions ==
2531* the stages temperature (OutletLiquid.T);
2532* the stages liquid holdup;
2533* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
2534";
2535
2536VARIABLES
2537
2538        in              LiquidInlet             as      stream                          (Brief="Liquid Inlet in the section", PosX=0.70, PosY=0);
2539        out     VapourOutlet            as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.30, PosY=0);
2540       
2541        in              VapourInlet             as stream                               (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1);
2542        out     LiquidOutlet            as liquid_stream                (Brief="Liquid Outlet in the section", PosX=0.70, PosY=1);
2543       
2544        LiquidConnector as stream       (Brief="Liquid connection at the middle STAGES", PosX=0.75, PosY=1,Hidden=true);
2545        VapourConnector as stream       (Brief="Vapour connection at the middle STAGES", PosX=0.55, PosY=0,Hidden=true);
2546
2547CONNECTIONS
2548
2549        LiquidConnector to STAGES(1).InletLiquid;
2550        VapourConnector to STAGES(NumberOfStages).InletVapour;
2551       
2552EQUATIONS
2553
2554        LiquidConnector.F= LiquidInlet.F;
2555        LiquidConnector.T = LiquidInlet.T;
2556        LiquidConnector.P = LiquidInlet.P;
2557        LiquidConnector.z = LiquidInlet.z;
2558        LiquidConnector.v = LiquidInlet.v;
2559        LiquidConnector.h = LiquidInlet.h;
2560       
2561        VapourConnector.F= VapourInlet.F;
2562        VapourConnector.T = VapourInlet.T;
2563        VapourConnector.P = VapourInlet.P;
2564        VapourConnector.z = VapourInlet.z;
2565        VapourConnector.v = VapourInlet.v;
2566        VapourConnector.h = VapourInlet.h;
2567       
2568        LiquidOutlet.F= STAGES(NumberOfStages).OutletLiquid.F;
2569        LiquidOutlet.T = STAGES(NumberOfStages).OutletLiquid.T;
2570        LiquidOutlet.P = STAGES(NumberOfStages).OutletLiquid.P;
2571        LiquidOutlet.z = STAGES(NumberOfStages).OutletLiquid.z;
2572       
2573        VapourOutlet.F= STAGES(1).OutletVapour.F;
2574        VapourOutlet.T = STAGES(1).OutletVapour.T;
2575        VapourOutlet.P = STAGES(1).OutletVapour.P;
2576        VapourOutlet.z = STAGES(1).OutletVapour.z;
2577
2578end
2579
2580Model PackedDistillation_kettle_cond as Packed_Section_ColumnBasic
2581        ATTRIBUTES
2582        Pallete         = true;
2583        Icon            = "icon/PackedDistillationKettleCond";
2584        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
2585        Info            =
2586"== Specify ==
2587* the feed stream of each tray (Inlet);
2588* the pump pressure difference;
2589* the total pressure drop (dP) of the packing;
2590* the heat supllied in reboiler and condenser;
2591* the condenser vapor outlet flow (OutletVapour.F);
2592* the reboiler liquid outlet flow (OutletLiquid.F);
2593* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
2594       
2595== Initial Conditions ==
2596* the stages temperature (OutletLiquid.T);
2597* the stages initial molar holdup;
2598* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each stage;
2599       
2600* the condenser temperature (OutletLiquid.T);
2601* the condenser liquid level (Level);
2602* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
2603       
2604* the reboiler temperature (OutletLiquid.T);
2605* the reboiler liquid level (Level);
2606* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
2607";
2608       
2609PARAMETERS
2610
2611        VapourFlow as Switcher  (Valid = ["on", "off"], Hidden = true ,Default = "on");
2612       
2613VARIABLES
2614#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2615# Column Devices
2616#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2617        CONDENSER       as condenser    (Brief="dymamic condenser");
2618        REBOILER        as reboiler             (Brief="kettle reboiler");
2619        SPLITTER        as splitter2            (Brief="splitter which separate reflux and distillate");
2620        PUMP            as pump                 (Brief="pump in reflux stream");
2621#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2622# Heat Ports
2623#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2624        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler",Protected = true, PosX=1, PosY=0.885);
2625        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", Protected = true, PosX=1, PosY=0.034);
2626#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2627# Column Products
2628#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2629        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.66, PosY=0);
2630        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
2631        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.68, PosY=1);
2632#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2633# Column Connectors
2634#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
2635        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
2636        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
2637        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
2638                ConnectorHeatReboiler   as power        (Brief="Heat supplied to Reboiler", Hidden=true);
2639                ConnectorHeatCondenser  as power        (Brief="Heat supplied to Condenser", Hidden=true);
2640
2641CONNECTIONS
2642
2643#vapor
2644        REBOILER.OutletVapour           to STAGES(NumberOfStages).InletVapour;
2645        STAGES(1).OutletVapour          to CONDENSER.InletVapour;
2646
2647#liquid
2648        CONDENSER.OutletLiquid                          to SPLITTER.Inlet;     
2649        SPLITTER.Outlet2                                to PUMP.Inlet;
2650        PUMP.Outlet                                     to STAGES(1).InletLiquid;
2651        STAGES(NumberOfStages).OutletLiquid     to REBOILER.InletLiquid;
2652
2653#Connectors
2654ConnectorHeatReboiler   to REBOILER.InletQ;
2655ConnectorHeatCondenser  to CONDENSER.InletQ;
2656
2657CONDENSER.OutletVapour          to ConnectorCondenserVout;
2658SPLITTER.Outlet1                to ConnectorSplitterOut;
2659REBOILER.OutletLiquid           to ConnectorReboilerLout;
2660
2661EQUATIONS
2662        HeatToReboiler  = ConnectorHeatReboiler;
2663        HeatToCondenser = ConnectorHeatCondenser;
2664       
2665# Condenser Connector Equations
2666        ConnectorCondenserVout.T = VapourDistillate.T;
2667        ConnectorCondenserVout.P = VapourDistillate.P;
2668        ConnectorCondenserVout.F = VapourDistillate.F;
2669        ConnectorCondenserVout.z = VapourDistillate.z;
2670
2671# Splitter Connector Equations
2672        ConnectorSplitterOut.T = LiquidDistillate.T;
2673        ConnectorSplitterOut.P = LiquidDistillate.P;
2674        ConnectorSplitterOut.F = LiquidDistillate.F;
2675        ConnectorSplitterOut.z = LiquidDistillate.z;
2676
2677# Reboiler Connector Equations
2678        ConnectorReboilerLout.T = BottomProduct.T;
2679        ConnectorReboilerLout.P = BottomProduct.P;
2680        ConnectorReboilerLout.F = BottomProduct.F;
2681        ConnectorReboilerLout.z = BottomProduct.z;
2682
2683switch VapourFlow
2684        case "on":
2685                STAGES(NumberOfStages).InletVapour.F*STAGES(NumberOfStages).vV = sqrt((REBOILER.OutletVapour.P - STAGES(NumberOfStages).OutletVapour.P)/
2686                                        (STAGES(NumberOfStages).rhoV*ResistanceCoeff*20))*(ColumnArea*VoidFraction - STAGES(NumberOfStages).Al);
2687                when STAGES(NumberOfStages).InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
2688
2689        case "off":
2690                STAGES(NumberOfStages).InletVapour.F = 0 * 'mol/s';
2691                when REBOILER.OutletVapour.P > STAGES(NumberOfStages).OutletVapour.P + 1e-1 * 'atm' switchto "on";
2692end
2693
2694end
2695
2696*#
Note: See TracBrowser for help on using the repository browser.