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

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

updates

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