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

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

updated packed column

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