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

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

updates (changes in icons/models/samples)

File size: 95.9 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
40Model InitializeSection
41
42ATTRIBUTES
43        Pallete = false;
[719]44        Brief = "Initial conditions for column section.";
[715]45
46PARAMETERS
47        outer NComp             as Integer      (Brief="Number of components");
48
49        TopTemperature          as temperature  (Brief = "Tray Temperature at Column Top", Default = 300);
50        BottomTemperature       as temperature  (Brief = "Tray Temperature at Column Bottom", Default = 330);
[721]51        LevelFraction           as fraction             (Brief = "Tray Level Fraction", Default = 0.5);
[715]52
53        TopComposition(NComp)           as fraction     (Brief = "Component Molar Fraction at Column Top", Default = 0.30);
54        BottomComposition(NComp)        as fraction     (Brief = "Component Molar Fraction at Column Bottom", Default = 0.30);
55
56end
57
[721]58Model InitializeStage
59
60ATTRIBUTES
61        Pallete = false;
62        Brief = "Initial conditions for Packed column section.";
63
64PARAMETERS
65        outer NComp             as Integer      (Brief="Number of components");
66
67        TopStageTemperature             as temperature  (Brief = "Tray Temperature at Column Top", Default = 300);
68        BottomStageTemperature          as temperature  (Brief = "Tray Temperature at Column Bottom", Default = 300);
69       
70        TopStageComposition(NComp)              as fraction     (Brief = "Component Molar Fraction at Top");
71        BottomStageComposition(NComp)   as fraction     (Brief = "Component Molar Fraction at Bottom");
72        LiquidMolarHoldup                               as mol          (Brief="Molar liquid holdup", Default=0.01);
73
74end
75
[715]76Model Section_ColumnBasic
77
78ATTRIBUTES
79        Pallete         = false;
80        Icon            = "icon/SectionColumn";
81        Brief   = "Model of a column section.";
82        Info            =
[721]83"Model of a basic column section containing a vetor of TRAYS numbered from the top-down.";
[715]84
85PARAMETERS
86        outer PP                                                        as Plugin                       (Brief="External Physical Properties", Type="PP");
87        outer NComp                                             as Integer                      (Brief="Number of components");
[721]88#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
89# Section Column Feed Tray - Side Streams  Location and Numbering
90#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[715]91        NumberOfTrays                                           as Integer                      (Brief="Number of trays", Default=8);
92        FeedTrayIndex(NumberOfTrays)            as Integer                      (Brief="Feed Tray Index", Default=0,Hidden=true);
93        LiqSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Liquid Side Tray Index", Default=0,Hidden=true);
94        VapSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Vapour Side Tray Index", Default=0,Hidden=true);
95        FeedTrayLocation                                        as Integer                      (Brief="Feed tray Location", Default=2);
96        LiquidSideStreamLocation                        as Integer                      (Brief="Liquid Side Stream Location", Default=2);
97        VapourSideStreamLocation                        as Integer                      (Brief="Vapour Side Stream Location", Default=2);
98        g                                                                       as acceleration         (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
99        Mw(NComp)                                                       as molweight            (Brief="Component Mol Weight",Hidden=true);
[721]100#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
101# Section Column Flow Model for Liquid and Vapour
102#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[715]103        VapourFlowModel         as Switcher     (Valid = ["Reepmeyer", "Feehery_Fv", "Roffel_Fv", "Klingberg", "Wang_Fv", "Elgue"], Default = "Reepmeyer");
104        LiquidFlowModel         as Switcher     (Valid = ["default", "Wang_Fl", "Olsen", "Feehery_Fl", "Roffel_Fl"], Default = "default");
[721]105#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
106# Section Column Tray Geometry and Auxiliar Parameters
107#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[715]108        VolumeOfTray            as volume               (Brief="Total Volume of the tray");
109        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
110        PlateArea                       as area                 (Brief="Plate area = Atray - Adowncomer");
[721]111        HolesArea                       as area                 (Brief="Total holes area");
112        WeirLength                      as length               (Brief="Weir length");
113        WeirHeight                      as length               (Brief="Weir height");
114        FeeheryCoeff            as Real                 (Brief="Feeherys correlation coefficient", Unit='1/m^4', Default=1);
115        ElgueCoeff                      as Real                 (Brief="Elgues correlation coefficient", Unit='kg/m/mol^2', Default=1);
116        OlsenCoeff                      as Real                 (Brief="Olsens correlation coefficient", Default=1);
117        TrayLiquidPasses        as Real                 (Brief="Number of liquid passes in the tray", Default=1);
[715]118       
119        V                               as volume               (Brief="Total Volume of the tray",Hidden=true);
120        Q                               as heat_rate    (Brief="Rate of heat supply",Hidden=true);
[721]121        Ap                              as area                 (Brief="Plate area = Atray - Adowncomer",Hidden=true);
122        Ah                              as area                 (Brief="Total holes area",Hidden=true);
123        lw                              as length               (Brief="Weir length",Hidden=true);
124        hw                              as length               (Brief="Weir height",Hidden=true);
125        beta                    as fraction     (Brief="Aeration fraction");
126        alfa                    as fraction     (Brief="Dry pressure drop coefficient");
127        w                               as Real                 (Brief="Feeherys correlation coefficient", Unit='1/m^4', Default=1,Hidden=true);
128        btray                   as Real                 (Brief="Elgues correlation coefficient", Unit='kg/m/mol^2', Default=1,Hidden=true);
129        fw                              as Real                 (Brief="Olsens correlation coefficient", Default=1,Hidden=true);
130        Np                              as Real                 (Brief="Number of liquid passes in the tray", Default=1,Hidden=true);
[715]131       
132        VapourFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
133        LiquidFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
134
135SET
136        FeedTrayIndex(FeedTrayLocation) =1;
137        VapSideTrayIndex(FeedTrayLocation) =1;
138        LiqSideTrayIndex(FeedTrayLocation) =1;
139        Mw = PP.MolecularWeight();
140
141        V=VolumeOfTray;
142        Q=HeatSupply;
143        Ap=PlateArea;
144        Ah=HolesArea;
145        lw=WeirLength;
146        hw=WeirHeight ;
147        w=FeeheryCoeff;
148        btray=ElgueCoeff;
149        fw=OlsenCoeff;
150        Np=TrayLiquidPasses;
151
152VARIABLES
[721]153#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
154# Tray Initialization For the Whole Column Section
155#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
156        INITIALIZATION as InitializeSection (Brief = "Column Model Initialization");
157#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
158# Column Feed - Side Stream Flow and Murphree Efficiency
159#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
160        in      FeedTray                                as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
161                TRAYS(NumberOfTrays)    as tray                 (Brief="Number of trays in the Column Section");
162                VapourDrawOffFlow               as flow_mol     (Brief="Stream Molar Flow Rate");
163                LiquidDrawOffFlow               as flow_mol     (Brief="Stream Molar Flow Rate");
164                MurphreeEff                     as Real                 (Brief="Murphree efficiency for All Trays");
[715]165
166CONNECTIONS
[721]167#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
168# Connecting Intermediate Trays
169#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[735]170        TRAYS([2:NumberOfTrays]).OutletVapour   to TRAYS([1:NumberOfTrays-1]).InletVapour;
171        TRAYS([1:NumberOfTrays-1]).OutletLiquid         to TRAYS([2:NumberOfTrays]).InletLiquid;
[715]172       
[719]173INITIAL
[721]174#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
175# Tray Initialization
176#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
177for i in 1:NumberOfTrays do
[719]178
179"The initial temperature of the TRAYS"
[735]180        TRAYS(i).OutletLiquid.T = INITIALIZATION.TopTemperature+(INITIALIZATION.BottomTemperature-INITIALIZATION.TopTemperature)*((i-1)/(NumberOfTrays-1));
[719]181
182"The initial Level of the TRAYS"
183        TRAYS(i).Level = INITIALIZATION.LevelFraction*hw;
184end
185
186for i in 1:NComp-1 do
[721]187
[719]188for j in 1:NumberOfTrays do
189
190"The initial composition of the TRAYS - Normalized"
[735]191        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));
[719]192end
193
194end
195
[715]196EQUATIONS
[721]197#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
198# Equating Feed Tray Variables to Trays Variables
199#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
200"Feed Tray Inlet Flow" 
[715]201        FeedTray.F*FeedTrayIndex= TRAYS.Inlet.F;
[721]202
203"Feed Tray Inlet Temperature"
[715]204        FeedTray.T = TRAYS.Inlet.T;
[721]205
206"Feed Tray Inlet Pressure"
[715]207        FeedTray.P = TRAYS.Inlet.P;
[721]208
209"Feed Tray Inlet Composition"
[715]210        FeedTray.z = TRAYS.Inlet.z;
[721]211
212"Feed Tray Inlet Vapour Fraction"
[715]213        FeedTray.v = TRAYS.Inlet.v;
[721]214
215"Feed Tray Inlet Enthalpy"
[715]216        FeedTray.h = TRAYS.Inlet.h;
[721]217
218#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
219# Trays Equations
220#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
221
[715]222for i in [1:NumberOfTrays] do
223
224"Murphree Efficiency"
[735]225        TRAYS(i).OutletVapour.z =  MurphreeEff * (TRAYS(i).yideal - TRAYS(i).InletVapour.z) + TRAYS(i).InletVapour.z;
[715]226
227"Level of clear liquid over the weir"
228        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/Ap;
229
230"Geometry Constraint"
231        V = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
232
233"Energy Holdup"
[735]234        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletLiquid.h + TRAYS(i).MV*TRAYS(i).OutletVapour.h - TRAYS(i).OutletLiquid.P*V;
[715]235
236"Energy Balance"
[735]237        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]238        -TRAYS(i).VapourSideStream.F*TRAYS(i).VapourSideStream.h - TRAYS(i).LiquidSideStream.F*TRAYS(i).LiquidSideStream.h + Q );
239
240switch LiquidFlow
241                case "on":
242                        switch LiquidFlowModel
243                                case "default":
244                                "Francis Equation"
[735]245                                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'1/s'*lw*((TRAYS(i).Level-(beta*hw))/(beta))^2;
[715]246                       
247                                case "Wang_Fl":
[735]248                                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'m^0.5/s'*lw*((TRAYS(i).Level-(beta*hw))/(beta))^1.5;
[715]249                       
250                                case "Olsen":
[735]251                                TRAYS(i).OutletLiquid.F / 'mol/s'= lw*Np*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletVapour.z)/(0.665*fw)^1.5 * ((TRAYS(i).ML*sum(Mw*TRAYS(i).OutletLiquid.z)/TRAYS(i).rhoL/Ap)-hw)^1.5 * 'm^0.5/mol';
[715]252                       
253                                case "Feehery_Fl":
[735]254                                TRAYS(i).OutletLiquid.F = lw*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletLiquid.z) * ((TRAYS(i).Level-hw)/750/'mm')^1.5 * 'm^2/s';
[715]255                       
256                                case "Roffel_Fl":
[735]257                                TRAYS(i).OutletLiquid.F = 2/3*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletLiquid.z)*lw*(TRAYS(i).ML*sum(Mw*TRAYS(i).OutletLiquid.z)/(Ap*1.3)/TRAYS(i).rhoL)^1.5*sqrt(2*g/
258                                                        (2*(1 - 0.3593/'Pa^0.0888545'*abs(TRAYS(i).OutletVapour.F*sum(Mw*TRAYS(i).OutletVapour.z)/(Ap*1.3)/sqrt(TRAYS(i).rhoV))^0.177709)-1)); #/'(kg/m)^0.0888545/s^0.177709';
[715]259                        end
260                when TRAYS(i).Level < (beta *hw) switchto "off";
261               
262                case "off":
263                "Low level"
[735]264                TRAYS(i).OutletLiquid.F = 0 * 'mol/h';
[715]265                when TRAYS(i).Level > (beta * hw) + 1e-6*'m' switchto "on";
266        end
267       
268switch VapourFlow
269                case "on":
270                        switch VapourFlowModel
271                                case "Reepmeyer":
[735]272                                TRAYS(i).InletVapour.F*TRAYS(i).vV = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)/(TRAYS(i).rhoV*alfa))*Ah;
[715]273                       
274                                case "Feehery_Fv":
[735]275                                TRAYS(i).InletVapour.F = TRAYS(i).rhoV/Ap/w/sum(Mw*TRAYS(i).OutletVapour.z) * sqrt(((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)-(TRAYS(i).rhoV*g*TRAYS(i).ML*TRAYS(i).vL/Ap))/TRAYS(i).rhoV);
[715]276                       
277                                case "Roffel_Fv":
[735]278                                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 - (beta*sum(TRAYS(i).M*Mw)/(Ap*1.3)*g*1e5) * (TRAYS(i).rhoV*Ah/sum(Mw*TRAYS(i).OutletVapour.z))^1.08 * 'm^1.08/mol^1.08';
[715]279                       
280                                case "Klingberg":
[735]281                                TRAYS(i).InletVapour.F * TRAYS(i).vV = Ap * sqrt(((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)-TRAYS(i).rhoL*g*TRAYS(i).Level)/TRAYS(i).rhoV);
[715]282                       
283                                case "Wang_Fv":
[735]284                                TRAYS(i).InletVapour.F * TRAYS(i).vV = Ap * sqrt(((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)-TRAYS(i).rhoL*g*TRAYS(i).Level)/TRAYS(i).rhoV*alfa);
[715]285                               
286                                case "Elgue":
[735]287                                TRAYS(i).InletVapour.F  = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)/btray);
[715]288                        end
[735]289                when TRAYS(i).InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
[715]290               
291                case "off":
[735]292                TRAYS(i).InletVapour.F = 0 * 'mol/s';
293                when TRAYS(i).InletVapour.P > TRAYS(i).OutletVapour.P + TRAYS(i).Level*g*TRAYS(i).rhoL + 1e-1 * 'atm' switchto "on";
[715]294        end
295
296end
297
298end
299
300Model Section_Column as Section_ColumnBasic
301
302ATTRIBUTES
303        Pallete         = true;
304        Icon            = "icon/SectionColumn";
305        Brief   = "Model of a column section.";
306        Info            =
307"== Model of a column section containing ==
308* NumberOfTrays TRAYS.
309       
310== Specify ==
311* the feed stream of each tray (Inlet);
312* the Murphree eficiency for each tray Emv;
[735]313* the InletLiquid stream of the top tray;
314* the InletVapour stream of the bottom tray.
[715]315       
316== Initial Conditions ==
[735]317* the TRAYS temperature (OutletLiquid.T);
318* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
319* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
[715]320";
321
322VARIABLES
[721]323#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
324# Section Inlet and Outlet Material Ports
325#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
326        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Draw Off Port in the section", PosX=1, PosY=0.35,Protected = true);
327        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Draw Off Port in the section", PosX=1, PosY=0.65,Protected = true);
[715]328       
329        in      LiquidInlet             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.70, PosY=0);
330        out     VapourOutlet    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.30, PosY=0);
331       
[721]332        in      VapourInlet             as stream                       (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1);
333        out     LiquidOutlet    as liquid_stream        (Brief="Liquid Outlet in the section", PosX=0.70, PosY=1);
[715]334       
[721]335        LiquidConnector as stream       (Brief="Liquid connection in the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
336        VapourConnector as stream       (Brief="Vapour connection in the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
[715]337
338CONNECTIONS
339
[735]340        LiquidConnector to TRAYS(1).InletLiquid;
341        VapourConnector to TRAYS(NumberOfTrays).InletVapour;
[715]342
343EQUATIONS
[721]344#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
345# Equating Inlet Liquid Connector Variables
346#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
347"Liquid Inlet Flow"     
348        LiquidConnector.F = LiquidInlet.F;
[715]349
[721]350"Liquid Inlet Temperature"             
[715]351        LiquidConnector.T = LiquidInlet.T;
[721]352
353"Liquid Inlet Pressure"         
[715]354        LiquidConnector.P = LiquidInlet.P;
[721]355
356"Liquid Inlet Composition"             
[715]357        LiquidConnector.z = LiquidInlet.z;
[721]358
359"Liquid Inlet Vapour Fraction"         
[715]360        LiquidConnector.v = LiquidInlet.v;
[721]361
362"Liquid Inlet Enthalpy"         
[715]363        LiquidConnector.h = LiquidInlet.h;
[721]364#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
365# Equating Inlet Vapour Connector Variables
366#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
367"Vapour Inlet Flow"             
368        VapourConnector.F = VapourInlet.F;
369
370"Vapour Inlet Temperature"             
[715]371        VapourConnector.T = VapourInlet.T;
[721]372
373"Vapour Inlet Pressure"         
[715]374        VapourConnector.P = VapourInlet.P;
[721]375
376"Vapour Inlet Composition"             
[715]377        VapourConnector.z = VapourInlet.z;
[721]378
379"Vapour Inlet Vapour Fraction"         
[715]380        VapourConnector.v = VapourInlet.v;
[721]381
382"Vapour Inlet Enthalpy"         
[715]383        VapourConnector.h = VapourInlet.h;
[721]384#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
385# Equating Outlet Liquid Variables
386#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
387"Liquid Outlet Flow"   
[735]388        LiquidOutlet.F = TRAYS(NumberOfTrays).OutletLiquid.F;
[721]389
390"Liquid Outlet Temperature"     
[735]391        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
[721]392
393"Liquid Outlet Pressure"       
[735]394        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
[721]395
396"Liquid Outlet Composition"     
[735]397        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
[721]398#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
399# Equating Outlet Vapour Variables
400#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
401"Vapour Outlet Flow"           
[735]402        VapourOutlet.F = TRAYS(1).OutletVapour.F;
[721]403
404"Vapour Outlet Temperature"             
[735]405        VapourOutlet.T = TRAYS(1).OutletVapour.T;
[721]406
407"Vapour Outlet Pressure"               
[735]408        VapourOutlet.P = TRAYS(1).OutletVapour.P;
[721]409
410"Vapour Outlet Composition"             
[735]411        VapourOutlet.z = TRAYS(1).OutletVapour.z;
[721]412#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
413# Equating Outlet Vapour Side Stream Variables
414#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
415"Vapour Draw Off Stream - Flow"         
416        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
[715]417
[721]418"Vapour Draw Off Stream - Temperature"         
[715]419        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
[721]420
421"Vapour Draw Off Stream - Pressure"             
[715]422        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
[721]423
424"Vapour Draw Off Stream - Composition"         
[715]425        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
426
[721]427"Vapour Draw Off Stream"       
428        VapourDrawOffFlow = VapourDrawOff.F;
429#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
430# Equating Outlet Liquid Side Stream Variables
431#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
432"Liquid Draw Off Stream - Flow"         
[715]433        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
[721]434
435"Liquid Draw Off Stream - Temperature" 
[715]436        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
[721]437
438"Liquid Draw Off Stream - Pressure"                     
[715]439        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
[721]440
441"Liquid Draw Off Stream - Composition" 
[715]442        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
443
[721]444"Liquid Draw Off Stream"       
[715]445        LiquidDrawOffFlow = LiquidDrawOff.F;
446
447end
[719]448
[721]449Model Distillation_kettle_cond  as Section_ColumnBasic
[719]450
451ATTRIBUTES
[715]452        Pallete         = true;
453        Icon            = "icon/DistillationKettleCond";
454        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
455        Info            =
456"== Specify ==
457* the feed stream of each tray (Inlet);
458* the Murphree eficiency for each tray Emv;
459* the pump pressure difference;
460* the heat supllied in reboiler and condenser;
[735]461* the condenser vapor outlet flow (OutletVapour.F);
462* the reboiler liquid outlet flow (OutletLiquid.F);
[715]463* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
464       
465== Initial Conditions ==
[735]466* the TRAYS temperature (OutletLiquid.T);
467* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
468* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]469       
[735]470* the condenser temperature (OutletLiquid.T);
[715]471* the condenser liquid level (Level);
[735]472* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
[715]473       
[735]474* the reboiler temperature (OutletLiquid.T);
[715]475* the reboiler liquid level (Level);
[735]476* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
[715]477";
478       
479PARAMETERS
480        CondenserVapourFlow             as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
481
482VARIABLES
[721]483        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.375,Protected = true);
484        out     LiquidDrawOff           as liquid_stream                        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.42,Protected = true);
485#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
486# Column Devices
487#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
488        CONDENSER               as condenser;
[715]489        REBOILER                as reboiler;
[739]490        SPLITTER                as splitter2;
[721]491        PUMP                    as pump;
492        alfaTopo                as Real;
493#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
494# Heat Ports
495#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
496        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler",Protected = true, PosX=1, PosY=0.90);
497        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", Protected = true, PosX=1, PosY=0.034);
498#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
499# Column Connectors
500#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
501                ConnectorHeatReboiler   as power        (Brief="Heat supplied to Reboiler", Hidden=true);
502                ConnectorHeatCondenser  as power        (Brief="Heat supplied to Condenser", Hidden=true);
503        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Condenser", Hidden=true);
504        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
505        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
506#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
507# Column products
508#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
509        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Condenser", PosX=0.66, PosY=0);
510        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
511        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
[715]512
513EQUATIONS
514
515switch CondenserVapourFlow
516
517        case "on":
[735]518                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo *Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
519                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
520                when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
[715]521
522        case "off":
[735]523                CONDENSER.InletVapour.F = 0 * 'mol/s';
524                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
[715]525
526end     
527
528# Condenser Connector Equations
529        ConnectorCondenserVout.T = VapourDistillate.T;
530        ConnectorCondenserVout.P = VapourDistillate.P;
531        ConnectorCondenserVout.F = VapourDistillate.F;
532        ConnectorCondenserVout.z = VapourDistillate.z;
533
534# Splitter Connector Equations
535        ConnectorSplitterOut.T = LiquidDistillate.T;
536        ConnectorSplitterOut.P = LiquidDistillate.P;
537        ConnectorSplitterOut.F = LiquidDistillate.F;
538        ConnectorSplitterOut.z = LiquidDistillate.z;
539
540# Reboiler Connector Equations
541        ConnectorReboilerLout.T = BottomProduct.T;
542        ConnectorReboilerLout.P = BottomProduct.P;
543        ConnectorReboilerLout.F = BottomProduct.F;
544        ConnectorReboilerLout.z = BottomProduct.z;
545
546        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
547        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
548        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
549        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
550
551        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
552        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
553        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
554        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
555
556        VapourDrawOffFlow = VapourDrawOff.F;
557        LiquidDrawOffFlow = LiquidDrawOff.F;
[719]558
559        HeatToReboiler  = ConnectorHeatReboiler;
560        HeatToCondenser = ConnectorHeatCondenser;
561
[715]562CONNECTIONS
563#vapor
[735]564        REBOILER.OutletVapour   to      TRAYS(NumberOfTrays).InletVapour;
565        TRAYS(1).OutletVapour   to      CONDENSER.InletVapour;
[715]566
567#liquid
[735]568        CONDENSER.OutletLiquid                          to      SPLITTER.Inlet;
[727]569        SPLITTER.Outlet2                        to      PUMP.Inlet;
[735]570        PUMP.Outlet                                     to      TRAYS(1).InletLiquid;
571        TRAYS(NumberOfTrays).OutletLiquid       to      REBOILER.InletLiquid;
[715]572
573#Connectors
[735]574        CONDENSER.OutletVapour  to ConnectorCondenserVout;
[727]575        SPLITTER.Outlet1 to ConnectorSplitterOut;
[735]576        REBOILER.OutletLiquid   to ConnectorReboilerLout;
[715]577
[719]578        ConnectorHeatReboiler   to REBOILER.InletQ;
579        ConnectorHeatCondenser  to CONDENSER.InletQ;
[715]580
581end
582
[721]583Model Distillation_thermosyphon_subcooling      as Section_ColumnBasic
[715]584        ATTRIBUTES
585        Pallete         = true;
586        Icon            = "icon/DistillationThermosyphonSubcooling";
587        Brief           = "Model of a distillation column with steady condenser and steady reboiler.";
588        Info            =
589"== Specify ==
590* the feed stream of each tray (Inlet);
591* the Murphree eficiency for each tray Emv;
592* the pump head;
593* the condenser pressure drop;
594* the heat supllied in top and bottom tanks;
595* the heat supllied in condenser and reboiler;
596* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
597* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
598       
599== Initial Conditions ==
[735]600* the TRAYS temperature (OutletLiquid.T);
601* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
602* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]603       
[735]604* the top tank temperature (OutletLiquid.T);
[715]605* the top tank liquid level (Level);
[735]606* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
[715]607       
[735]608* the bottom tank temperature (OutletLiquid.T);
[715]609* the bottom tank liquid level (Level);
[735]610* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
[715]611";
612
613PARAMETERS
614
615        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Hidden=true, Default = "on");
616
617VARIABLES
[721]618#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
619# Column Vapour and Liquid Draw Sides
620#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[715]621        out     VapourDrawOff   as vapour_stream                (Brief="Vapour Outlet in the section", PosX=1, PosY=0.41,Protected = true);
[721]622        out     LiquidDrawOff   as liquid_stream                (Brief="Liquid Outlet in the section", PosX=1, PosY=0.45,Protected = true);
623#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
624# Column Devices
625#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
626        CONDENSER                       as condenserSteady      (Brief="steady state condenser with subcooling");
627        ACCUMULATOR_TOP         as tank_cylindrical     (Brief="vessel drum (layed cilinder)");
[739]628        SPLITTER_TOP            as splitter2                    (Brief="splitter which separate reflux and distillate");
[721]629        PUMP                            as pump                         (Brief="pump in reflux stream");
630        REBOILER                        as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
631        ACCUMULATOR_BOTTOM      as tank                         (Brief="vessel in the bottom of column");
[739]632        SPLITTER_BOTTOM         as splitter2                    (Brief="splitter who separate the bottom product and the stream to reboiler");
[721]633        alfaTopo                        as Real;
634#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
635# Heat Ports
636#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
637in              HeatToCondenser                 as power        (Brief="Heat supplied to Condenser",PosX=1, PosY=0.065, Protected=true);
638in              HeatToReboiler                  as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.87,Protected=true);
639in              HeatToBottomAccumulator as power        (Brief="Heat supplied to Bottom Accumulator",PosX=0, PosY=0.925,Protected=true);
640in              HeatToTopAccumulator    as power        (Brief="Heat supplied to Top Accumulator", PosX=1, PosY=0.19,Protected=true);
641#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
642# Column Top and Bottom product
643#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
644out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.24);
645out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=0.18, PosY=1);
646#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
647# Column Model Connectors
648#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
649in      ConnectorSplitterBottom         as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
650in      ConnectorSplitterTop            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
[715]651
[721]652        ConnectorHeatReboiler                   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
653        ConnectorHeatCondenser                  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
654        ConnectorHeatTopAccumulator     as power        (Brief="Connector for Heat supplied to Top Accumulator", Hidden=true);
655        ConnectorHeatBottomAccumulator  as power        (Brief="Connector for Heat supplied to Bottom Accumulator", Hidden=true);
656       
[715]657EQUATIONS
[721]658# Heat Connector Equations
659        HeatToCondenser                 =       ConnectorHeatCondenser;
660        HeatToReboiler                  =       ConnectorHeatReboiler;
661        HeatToBottomAccumulator =       ConnectorHeatBottomAccumulator;
662        HeatToTopAccumulator    =       ConnectorHeatTopAccumulator;
[715]663
664# Top Splitter Connector Equations
665        ConnectorSplitterTop.T = LiquidDistillate.T;
666        ConnectorSplitterTop.P = LiquidDistillate.P;
667        ConnectorSplitterTop.F = LiquidDistillate.F;
668        ConnectorSplitterTop.z = LiquidDistillate.z;
669
670# Bottom Splitter Connector Equations
671        ConnectorSplitterBottom.T = BottomProduct.T;
672        ConnectorSplitterBottom.P = BottomProduct.P;
673        ConnectorSplitterBottom.F = BottomProduct.F;
674        ConnectorSplitterBottom.z = BottomProduct.z;
675
676        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
677        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
678        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
679        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
680
681        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
682        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
683        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
684        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
685
686        VapourDrawOffFlow = VapourDrawOff.F;
687        LiquidDrawOffFlow = LiquidDrawOff.F;
688
689switch CondenserVapourFlow
690
691        case "on":
[735]692                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
693                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
694                when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
[715]695
696        case "off":
[735]697                CONDENSER.InletVapour.F = 0 * 'mol/s';
698                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
[715]699
700end     
701
702CONNECTIONS
703#vapor
[735]704        REBOILER.OutletVapour   to TRAYS(NumberOfTrays).InletVapour;
705        TRAYS(1).OutletVapour   to CONDENSER.InletVapour;
[715]706
707#liquid
[735]708        CONDENSER.OutletLiquid                          to ACCUMULATOR_TOP.Inlet;       
[721]709        ACCUMULATOR_TOP.Outlet                  to SPLITTER_TOP.Inlet;
710        SPLITTER_TOP.Outlet2                    to PUMP.Inlet; 
[735]711        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
712        TRAYS(NumberOfTrays).OutletLiquid       to ACCUMULATOR_BOTTOM.Inlet;
[721]713        ACCUMULATOR_BOTTOM.Outlet               to SPLITTER_BOTTOM.Inlet;
[735]714        SPLITTER_BOTTOM.Outlet2                 to REBOILER.InletLiquid;
[715]715
716#Connectors
[721]717        ConnectorHeatCondenser                  to CONDENSER.InletQ;
718        ConnectorHeatReboiler                   to REBOILER.InletQ;
719        ConnectorHeatBottomAccumulator  to ACCUMULATOR_BOTTOM.InletQ;
720        ConnectorHeatTopAccumulator             to ACCUMULATOR_TOP.InletQ;
721        SPLITTER_TOP.Outlet1                    to ConnectorSplitterTop;
722        SPLITTER_BOTTOM.Outlet1                 to ConnectorSplitterBottom;
[715]723
724end
725
726Model Distillation_thermosyphon_cond as Section_ColumnBasic
727        ATTRIBUTES
728        Pallete         = true;
729        Icon            = "icon/DistillationThermosyphonCond";
730        Brief           = "Model of a distillation column with dynamic condenser and steady reboiler.";
731        Info            =
732"== Specify ==
733* the feed stream of each tray (Inlet);
734* the Murphree eficiency for each tray Emv;
735* the pump head;
[735]736* the condenser vapor outlet flow (OutletVapour.F);
[715]737* the heat supllied in bottom tank;
738* the heat supllied in condenser and reboiler;
739* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
740       
741== Initial Conditions ==
[735]742* the TRAYS temperature (OutletLiquid.T);
743* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
744* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]745       
[735]746* the condenser temperature (OutletLiquid.T);
[715]747* the condenser liquid level (Level);
[735]748* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
[715]749       
[735]750* the bottom tank temperature (OutletLiquid.T);
[715]751* the bottom tank liquid level (Level);
[735]752* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
[715]753";
754
755PARAMETERS
756        CondenserVapourFlow     as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
757
758VARIABLES
[721]759#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
760# Column Vapour and Liquid Draw Sides
761#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
762        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.379,Protected = true);
763        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.425,Protected = true);
764#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
765# Column Devices
766#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
767        CONDENSER                       as condenser            (Brief="dynamic condenser without subcooling");
[739]768        SPLITTER_TOP            as splitter2                    (Brief="splitter which separate reflux and distillate");
[721]769        PUMP                            as pump                         (Brief="pump in reflux stream");
770        ACCUMULATOR_BOTTOM      as tank                         (Brief="vessel in the bottom of column");
[739]771        SPLITTER_BOTTOM         as splitter2                    (Brief="splitter who separate the bottom product and the stream to reboiler");
[721]772        REBOILER                        as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
[715]773        alfaTopo                        as Real;
[721]774#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
775# Heat Ports
776#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
777in      HeatToCondenser                 as power        (Brief="Heat supplied to Condenser",PosX=1, PosY=0.035, Protected=true);
778in      HeatToReboiler                  as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.865,Protected=true);
779in      HeatToBottomAccumulator as power        (Brief="Heat supplied to Bottom Accumulator",PosX=0, PosY=0.92,Protected=true);
780#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
781# Column Top and Bottom product
782#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
783out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.665, PosY=0);
784out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
785out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Bottom Splitter", PosX=0.18, PosY=1);
786#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
787# Column Model Connectors
788#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
789in      ConnectorSplitterBottom as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
790in      ConnectorSplitterTop    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
791in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
[715]792
[721]793        ConnectorHeatReboiler                   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
794        ConnectorHeatCondenser                  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
795        ConnectorHeatBottomAccumulator  as power        (Brief="Connector for Heat supplied to Bottom Accumulator", Hidden=true);
[715]796
797EQUATIONS
[721]798# Heat Connector Equations
799        HeatToCondenser                 =       ConnectorHeatCondenser;
800        HeatToReboiler                  =       ConnectorHeatReboiler;
801        HeatToBottomAccumulator =       ConnectorHeatBottomAccumulator;
[715]802
803# Condenser Connector Equations
804        ConnectorCondenserVout.T = VapourDistillate.T;
805        ConnectorCondenserVout.P = VapourDistillate.P;
806        ConnectorCondenserVout.F = VapourDistillate.F;
807        ConnectorCondenserVout.z = VapourDistillate.z;
808
809# Top Splitter Connector Equations
810        ConnectorSplitterTop.T = LiquidDistillate.T;
811        ConnectorSplitterTop.P = LiquidDistillate.P;
812        ConnectorSplitterTop.F = LiquidDistillate.F;
813        ConnectorSplitterTop.z = LiquidDistillate.z;
814
815# Bottom Splitter Connector Equations
816        ConnectorSplitterBottom.T = BottomProduct.T;
817        ConnectorSplitterBottom.P = BottomProduct.P;
818        ConnectorSplitterBottom.F = BottomProduct.F;
819        ConnectorSplitterBottom.z = BottomProduct.z;
820
821        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
822        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
823        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
824        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
825
826        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
827        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
828        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
829        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
830
831        VapourDrawOffFlow = VapourDrawOff.F;
832        LiquidDrawOffFlow = LiquidDrawOff.F;
833       
834switch CondenserVapourFlow
835                case "on":
[735]836                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
837                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
838                when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
[715]839               
840                case "off":
[735]841                CONDENSER.InletVapour.F = 0 * 'mol/s';
842                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
[715]843end     
844
845CONNECTIONS
846#vapor
[735]847        REBOILER.OutletVapour   to TRAYS(NumberOfTrays).InletVapour;
848        TRAYS(1).OutletVapour                           to CONDENSER.InletVapour;
[715]849
850#liquid
[735]851        CONDENSER.OutletLiquid          to SPLITTER_TOP.Inlet; 
[721]852        SPLITTER_TOP.Outlet2                            to PUMP.Inlet;
[735]853        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
854        TRAYS(NumberOfTrays).OutletLiquid       to ACCUMULATOR_BOTTOM.Inlet;
[721]855        ACCUMULATOR_BOTTOM.Outlet                               to SPLITTER_BOTTOM.Inlet;
[735]856        SPLITTER_BOTTOM.Outlet2                         to REBOILER.InletLiquid;
[715]857
858#Connectors
[721]859ConnectorHeatCondenser                  to CONDENSER.InletQ;
860ConnectorHeatReboiler                   to REBOILER.InletQ;
861ConnectorHeatBottomAccumulator  to ACCUMULATOR_BOTTOM.InletQ;
[735]862CONDENSER.OutletVapour                          to ConnectorCondenserVout;
[721]863SPLITTER_TOP.Outlet1                    to ConnectorSplitterTop;
864SPLITTER_BOTTOM.Outlet1                 to ConnectorSplitterBottom;
[715]865
866end
867
868Model Distillation_kettle_subcooling as Section_ColumnBasic
869
870ATTRIBUTES
871        Pallete         = true;
872        Icon            = "icon/DistillationKettleSubcooling";
873        Brief   = "Model of a distillation column with steady condenser and dynamic reboiler.";
874        Info            =
875"== Specify ==
876* the feed stream of each tray (Inlet);
877* the Murphree eficiency for each tray (Emv);
878* the pump pressure difference;
879* the heat supllied in reboiler and condenser;
880* the heat supllied in the top tank;
881* the condenser pressure drop;
[735]882* the reboiler liquid outlet flow (OutletLiquid.F);
[715]883* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
884       
885== Initial Conditions ==
[735]886* the TRAYS temperature (OutletLiquid.T);
887* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
888* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]889       
[735]890* the top tank temperature (OutletLiquid.T);
[715]891* the top tank liquid level (Level);
[735]892* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
[715]893       
[735]894* the reboiler temperature (OutletLiquid.T);
[715]895* the reboiler liquid level (Level);
[735]896* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
[715]897";
898       
899PARAMETERS
900        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Default = "on",Hidden=true);
901
902VARIABLES
[721]903#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
904# Column Vapour and Liquid Draw Sides
905#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
906        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.41,Protected = true);
907        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.45,Protected = true);
908#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
909# Column Devices
910#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
911        CONDENSER               as condenserSteady      (Brief="steady state condenser with subcooling");
912        ACCUMULATOR             as tank_cylindrical     (Brief="vessel drum (layed cilinder)");
[739]913        SPLITTER                as splitter2                    (Brief="splitter which separate reflux and distillate");
[721]914        PUMP                    as pump                         (Brief="pump in reflux stream");
915        REBOILER                as reboiler                     (Brief="kettle reboiler");
916        alfaTopo                as Real;
917#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
918# Heat Ports
919#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
920in              HeatToCondenser         as power        (Brief="Heat supplied to Condenser", PosX=1, PosY=0.065, Protected=true);
921in              HeatToReboiler          as power        (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.905, Protected=true);
922in              HeatToAccumulator       as power        (Brief="Heat supplied to Top Vessel", PosX=1, PosY=0.195, Protected=true);
923#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
924# Column Model Connectors
925#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
926in      ConnectorSplitterOut            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
927in      ConnectorReboilerLout           as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
928        ConnectorHeatReboiler           as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
929        ConnectorHeatCondenser          as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
930        ConnectorHeatAccumulator        as power        (Brief="Connector for Heat supplied to TopVessel", Hidden=true);
931#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
932# Column Top and Bottom product
933#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
934out     LiquidDistillate as liquid_stream       (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.24);
935out     BottomProduct    as liquid_stream       (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
[715]936
[721]937EQUATIONS
[715]938
[721]939#Heat Connectors
940HeatToCondenser         = ConnectorHeatCondenser;
941HeatToReboiler          = ConnectorHeatReboiler;
942HeatToAccumulator       = ConnectorHeatAccumulator;
[715]943
944# Splitter Connector Equations
945        ConnectorSplitterOut.T = LiquidDistillate.T;
946        ConnectorSplitterOut.P = LiquidDistillate.P;
947        ConnectorSplitterOut.F = LiquidDistillate.F;
948        ConnectorSplitterOut.z = LiquidDistillate.z;
949
950# Reboiler Connector Equations
951        ConnectorReboilerLout.T = BottomProduct.T;
952        ConnectorReboilerLout.P = BottomProduct.P;
953        ConnectorReboilerLout.F = BottomProduct.F;
954        ConnectorReboilerLout.z = BottomProduct.z;
955       
956        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
957        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
958        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
959        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
960
961        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
962        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
963        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
964        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
965
966        VapourDrawOffFlow = VapourDrawOff.F;
967        LiquidDrawOffFlow = LiquidDrawOff.F;
968       
969        switch CondenserVapourFlow
970                case "on":
[735]971                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
972                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
973                when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
[715]974               
975                case "off":
[735]976                CONDENSER.InletVapour.F = 0 * 'mol/s';
977                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
[715]978end     
979
980CONNECTIONS
981#vapor
[735]982        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
983        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
[715]984
985#liquid
[735]986        CONDENSER.OutletLiquid                          to ACCUMULATOR.Inlet;   
[721]987        ACCUMULATOR.Outlet                                      to SPLITTER.Inlet;
988        SPLITTER.Outlet2                        to PUMP.Inlet; 
[735]989        PUMP.Outlet                                     to TRAYS(1).InletLiquid;
990        TRAYS(NumberOfTrays).OutletLiquid       to REBOILER.InletLiquid;
[715]991
992#Connectors
[721]993ConnectorHeatCondenser          to CONDENSER.InletQ;
994ConnectorHeatReboiler           to REBOILER.InletQ;
995ConnectorHeatAccumulator        to ACCUMULATOR.InletQ;
[715]996
[721]997SPLITTER.Outlet1 to ConnectorSplitterOut;
[735]998REBOILER.OutletLiquid   to ConnectorReboilerLout;
[715]999
1000end
1001
1002Model Rectifier as Section_ColumnBasic
1003
1004ATTRIBUTES
1005        Pallete         = true;
1006        Icon            = "icon/RefluxedCond";
1007        Brief           = "Model of a rectifier column with dynamic condenser.";
1008        Info            =
1009"== Specify ==
1010* the feed stream of each tray (Inlet);
1011* the Murphree eficiency for each tray Emv;
[735]1012* the InletVapour stream of the bottom tray unless its flow;
[715]1013* the pump pressure difference;
1014* the heat supllied in the condenser;
[735]1015* the condenser vapor outlet flow (OutletVapour.F);
[715]1016* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1017       
1018== Initial Conditions ==
[735]1019* the TRAYS temperature (OutletLiquid.T);
1020* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1021* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]1022       
[735]1023* the condenser temperature (OutletLiquid.T);
[715]1024* the condenser liquid level (Level);
[735]1025* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
[715]1026";
1027
1028PARAMETERS
1029        CondenserVapourFlow as Switcher(Valid = ["on", "off"], Default = "on",Hidden=true);
1030
1031VARIABLES
[721]1032#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1033# Column Vapour and Liquid Draw Sides
1034#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1035        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.45,Protected = true);
1036        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.50,Protected = true);
1037#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1038# Column Devices
1039#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1040        CONDENSER       as condenser    (Brief="dymamic condenser without subcooling");
[739]1041        SPLITTER        as splitter2            (Brief="splitter which separate reflux and distillate");
[721]1042        PUMP            as pump                 (Brief="pump in reflux stream");
1043        alfaTopo        as Real;
1044#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1045# Column Top product
1046#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1047        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.66, PosY=0);
1048        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.24);
1049#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1050# Heat Port
1051#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1052        in      HeatToCondenser         as power (Brief="Heat supplied to Condenser",PosX=1, PosY=0.04, Protected = true);
1053#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1054# Column Bottom Outlets
1055#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1056        in      VapourInlet             as stream                       (Brief="Vapour Inlet in the section", PosX=0.07, PosY=1);
1057        out     LiquidOutlet    as liquid_stream        (Brief="Liquid Outlet in the section", PosX=0.32, PosY=1);
1058#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1059# Column Model Connectors
1060#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1061        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1062        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
1063                VapourConnector                 as stream       (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
1064                ConnectorHeatCondenser  as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
[715]1065       
1066EQUATIONS
1067
1068switch CondenserVapourFlow
1069
1070        case "on":
[735]1071                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo * Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
1072                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1073                when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
[715]1074               
1075        case "off":
[735]1076                CONDENSER.InletVapour.F = 0 * 'mol/s';
1077                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
[715]1078
1079end     
1080
[721]1081HeatToCondenser = ConnectorHeatCondenser;
1082
[715]1083# Condenser Connector Equations
1084        ConnectorCondenserVout.T = VapourDistillate.T;
1085        ConnectorCondenserVout.P = VapourDistillate.P;
1086        ConnectorCondenserVout.F = VapourDistillate.F;
1087        ConnectorCondenserVout.z = VapourDistillate.z;
1088       
1089# Splitter Connector Equations
1090        ConnectorSplitterOut.T = LiquidDistillate.T;
1091        ConnectorSplitterOut.P = LiquidDistillate.P;
1092        ConnectorSplitterOut.F = LiquidDistillate.F;
1093        ConnectorSplitterOut.z = LiquidDistillate.z;
1094       
[735]1095        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletLiquid.F;
1096        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
1097        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
1098        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
[715]1099
1100        VapourConnector.F= VapourInlet.F;
1101        VapourConnector.T = VapourInlet.T;
1102        VapourConnector.P = VapourInlet.P;
1103        VapourConnector.z = VapourInlet.z;
1104        VapourConnector.v = VapourInlet.v;
1105        VapourConnector.h = VapourInlet.h;
1106
1107        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1108        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1109        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1110        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1111
1112        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1113        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1114        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1115        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1116
1117        VapourDrawOffFlow = VapourDrawOff.F;
1118        LiquidDrawOffFlow = LiquidDrawOff.F;
1119
1120CONNECTIONS
1121#vapor
[735]1122        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
[715]1123
1124#liquid
[735]1125        CONDENSER.OutletLiquid  to SPLITTER.Inlet;     
[721]1126        SPLITTER.Outlet2        to PUMP.Inlet; 
[735]1127        PUMP.Outlet             to TRAYS(1).InletLiquid;
[715]1128
1129#Connectors
[721]1130ConnectorHeatCondenser  to CONDENSER.InletQ;
[735]1131VapourConnector                 to TRAYS(NumberOfTrays).InletVapour;
[721]1132SPLITTER.Outlet1                to ConnectorSplitterOut;
[735]1133CONDENSER.OutletVapour          to ConnectorCondenserVout;
[715]1134
1135end
1136
1137Model Rectifier_subcooling as Section_ColumnBasic
1138
1139ATTRIBUTES
1140        Pallete         = true;
1141        Icon            = "icon/RefluxedSubcooling";
1142        Brief           = "Model of a rectifier column with steady condenser.";
1143        Info            =
1144"== Specify ==
1145* the feed stream of each tray (Inlet);
1146* the Murphree eficiency for each tray Emv;
[735]1147* the InletVapour stream of the bottom tray unless its flow;
[715]1148* the pump head;
1149* the condenser pressure drop;
1150* the heat supllied in  the top tank;
1151* the heat supllied in condenser;
1152* both  top splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1153       
1154== Initial Conditions ==
[735]1155* the TRAYS temperature (OutletLiquid.T);
1156* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1157* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]1158       
[735]1159* the top tank temperature (OutletLiquid.T);
[715]1160* the top tank liquid level (Level);
[735]1161* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
[715]1162";
1163       
1164PARAMETERS
1165        CondenserVapourFlow             as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
1166
1167VARIABLES
[721]1168#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1169# Column Vapour and Liquid Draw Sides
1170#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1171        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.485,Protected = true);
1172        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.535,Protected = true);
1173#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1174# Column Devices
1175#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1176        CONDENSER               as condenserSteady      (Brief="steady state condenser with subcooling");
1177        ACCUMULATOR             as tank_cylindrical     (Brief="vessel drum (layed cilinder)");
[739]1178        SPLITTER                as splitter2                    (Brief="plitter which separate reflux and distillate");
[721]1179        PUMP                    as pump                         (Brief="pump in reflux stream");
1180        alfaTopo                as Real;
1181#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1182# Column Bottom outlets
1183#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1184        in      VapourInlet             as stream                       (Brief="Vapour Inlet in the section", PosX=0.07, PosY=1);
1185        out     LiquidOutlet    as liquid_stream        (Brief="Liquid Outlet in the section", PosX=0.32, PosY=1);
1186#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1187# Heat Ports
1188#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1189        in      HeatToCondenser         as power        (Brief="Heat supplied to Condenser", PosX=1, PosY=0.070, Protected=true);
1190        in      HeatToAccumulator       as power        (Brief="Heat supplied to Top Accumulator", PosX=1, PosY=0.23, Protected=true);
1191#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1192# Column Top Product
1193#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1194        out     LiquidDistillate                as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.285);
1195#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1196# Column Connectors
1197#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1198in      ConnectorSplitterTop            as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1199        VapourConnector                         as stream       (Brief="Vapour connection at the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
1200        ConnectorHeatCondenser          as power        (Brief="Connector for Heat supplied to Condenser", Hidden=true);
1201        ConnectorHeatAccumulator        as power        (Brief="Connector for Heat supplied to Top Accumulator", Hidden=true);
[715]1202
1203EQUATIONS
[721]1204#Heat Connectors
1205        HeatToCondenser         = ConnectorHeatCondenser;
1206        HeatToAccumulator       = ConnectorHeatAccumulator;
1207       
[735]1208        LiquidOutlet.F= TRAYS(NumberOfTrays).OutletLiquid.F;
1209        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
1210        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
1211        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
[715]1212
1213        VapourConnector.F= VapourInlet.F;
1214        VapourConnector.T = VapourInlet.T;
1215        VapourConnector.P = VapourInlet.P;
1216        VapourConnector.z = VapourInlet.z;
1217        VapourConnector.v = VapourInlet.v;
1218        VapourConnector.h = VapourInlet.h;
1219       
1220# Splitter Connector Equations
1221        ConnectorSplitterTop.T = LiquidDistillate.T;
1222        ConnectorSplitterTop.P = LiquidDistillate.P;
1223        ConnectorSplitterTop.F = LiquidDistillate.F;
1224        ConnectorSplitterTop.z = LiquidDistillate.z;
1225
[729]1226        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1227        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1228        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1229        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1230
1231        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1232        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1233        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1234        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1235
1236        VapourDrawOffFlow = VapourDrawOff.F;
1237        LiquidDrawOffFlow = LiquidDrawOff.F;
1238       
[715]1239switch CondenserVapourFlow
1240
1241        case "on":
[735]1242                CONDENSER.InletVapour.F*TRAYS(1).vV = alfaTopo *Ah * sqrt(2*(TRAYS(1).OutletVapour.P -
1243                CONDENSER.OutletLiquid.P + 1e-8 * 'atm') / (alfa*TRAYS(1).rhoV));
1244        when CONDENSER.InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
[715]1245               
1246        case "off":
[735]1247                CONDENSER.InletVapour.F = 0 * 'mol/s';
1248        when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-1 * 'atm' switchto "on";
[715]1249
1250end     
1251
1252CONNECTIONS
1253#vapor
[735]1254        TRAYS(1).OutletVapour to CONDENSER.InletVapour;
[715]1255
1256#liquid
[735]1257        CONDENSER.OutletLiquid          to ACCUMULATOR.Inlet;   
[721]1258        ACCUMULATOR.Outlet                                      to SPLITTER.Inlet;
1259        SPLITTER.Outlet2                to PUMP.Inlet; 
[735]1260        PUMP.Outlet                                             to TRAYS(1).InletLiquid;
[715]1261
1262#Connectors
[735]1263        VapourConnector                         to TRAYS(NumberOfTrays).InletVapour;
[721]1264        ConnectorHeatCondenser                  to CONDENSER.InletQ;
1265        SPLITTER.Outlet1        to ConnectorSplitterTop;
1266        ConnectorHeatAccumulator                        to ACCUMULATOR.InletQ;
[715]1267
1268end
1269
1270Model Reboiled_Stripping_kettle as Section_ColumnBasic
1271       
1272ATTRIBUTES
1273        Pallete         = true;
1274        Icon            = "icon/ReboiledKettle";
1275        Brief           = "Model of a reboiled stripping column with dynamic reboiler.";
1276        Info            =
1277"== Specify ==
1278* the feed stream of each tray (Inlet);
1279* the Murphree eficiency for each tray Emv;
1280* the vapour flow leaving the top of the column;
[735]1281* the InletLiquidiquid stream of the top tray;
[715]1282* the heat supllied in the reboiler;
[735]1283* the reboiler liquid outlet flow (OutletLiquid.F);
[715]1284       
1285== Initial Conditions ==
[735]1286* the TRAYS temperature (OutletLiquid.T);
1287* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1288* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]1289       
[735]1290* the reboiler temperature (OutletLiquid.T);
[715]1291* the reboiler liquid level (Level);
[735]1292* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
[715]1293";
1294
1295VARIABLES
[721]1296#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1297# Column Vapour and Liquid Draw Sides
1298#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1299        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.28,Protected = true);
1300        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.33,Protected = true);
1301#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1302# Column Devices
1303#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
1304        REBOILER as reboiler (Brief="Kettle Reboiler");
1305#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1306# Heat Port
1307#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1308        in      HeatToReboiler  as power        (Brief="Heat supplied to Reboiler",PosX=1, PosY=0.865,Protected=true);
1309#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1310# Column Top Outlets
1311#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
1312        in      LiquidInlet             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.30, PosY=0);
1313        out     VapourOutlet    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.07, PosY=0);
1314#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1315# Column Bottom Product
1316#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1317        out     BottomProduct   as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.68, PosY=1);
1318#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1319# Column Connectors
1320#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1321        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1322                LiquidConnector                 as stream       (Brief="Liquid connection at the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
1323                ConnectorHeatReboiler   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
[715]1324
1325CONNECTIONS
1326#vapor
[735]1327        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
[715]1328       
1329#liquid
[735]1330        TRAYS(NumberOfTrays).OutletLiquid to REBOILER.InletLiquid;
[715]1331
1332#Connectors
[735]1333REBOILER.OutletLiquid           to ConnectorReboilerLout;
1334LiquidConnector                 to TRAYS(1).InletLiquid;
[721]1335ConnectorHeatReboiler   to REBOILER.InletQ;
[715]1336
1337EQUATIONS
[721]1338#Heat Connectors
1339        HeatToReboiler = ConnectorHeatReboiler;
1340       
[715]1341        LiquidConnector.F= LiquidInlet.F;
1342        LiquidConnector.T = LiquidInlet.T;
1343        LiquidConnector.P = LiquidInlet.P;
1344        LiquidConnector.z = LiquidInlet.z;
1345        LiquidConnector.v = LiquidInlet.v;
1346        LiquidConnector.h = LiquidInlet.h;
1347       
[735]1348        VapourOutlet.F= TRAYS(1).OutletVapour.F;
1349        VapourOutlet.T = TRAYS(1).OutletVapour.T;
1350        VapourOutlet.P = TRAYS(1).OutletVapour.P;
1351        VapourOutlet.z = TRAYS(1).OutletVapour.z;
[715]1352       
1353# Reboiler Connector Equations
1354        ConnectorReboilerLout.T = BottomProduct.T;
1355        ConnectorReboilerLout.P = BottomProduct.P;
1356        ConnectorReboilerLout.F = BottomProduct.F;
1357        ConnectorReboilerLout.z = BottomProduct.z;
1358       
1359        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1360        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1361        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1362        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1363
1364        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1365        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1366        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1367        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1368
1369        VapourDrawOffFlow = VapourDrawOff.F;
1370        LiquidDrawOffFlow = LiquidDrawOff.F;
1371
1372end
1373
1374Model Reboiled_Stripping_thermosyphon as Section_ColumnBasic
1375
1376ATTRIBUTES
1377        Pallete         = true;
1378        Icon            = "icon/ReboiledThermosyphon";
1379        Brief           = "Model of a reboiled stripping column with steady reboiler.";
1380        Info            =
1381"== Specify ==
1382* the feed stream of each tray (Inlet);
1383* the Murphree eficiency for each tray (Emv);
1384* the vapour flow leaving the top of the column;
[735]1385* the InletLiquidiquid stream of the top tray;
[715]1386* the heat supllied in bottom tank;
1387* the heat supllied in the reboiler;
1388* the Outlet1 flow in the bottom splitter (spbottom.Outlet1.F) that corresponds to the bottom product;
1389       
1390== Initial Conditions ==
[735]1391* the TRAYS temperature (OutletLiquid.T);
1392* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1393* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]1394
[735]1395* the bottom tank temperature (OutletLiquid.T);
[715]1396* the bottom tank liquid level (Level);
[735]1397* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
[715]1398";
[721]1399
[715]1400VARIABLES
[721]1401#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1402# Column Vapour and Liquid Draw Sides
1403#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1404        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.28,Protected = true);
1405        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.33,Protected = true);
1406#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1407# Column Devices
1408#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1409        REBOILER                as reboilerSteady       (Brief="steady state reboiler (thermosyphon)");
[739]1410        SPLITTER                as splitter2            (Brief="splitter which separate the bottom product and the stream to reboiler");
[721]1411        ACCUMULATOR     as tank                         (Brief="vessel in the bottom of column");
1412#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1413# Heat Ports
1414#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1415        in      HeatToReboiler          as power        (Brief="Heat supplied to Reboiler",PosX=1, PosY=0.84,Protected=true);
1416        in      HeatToAccumulator       as power        (Brief="Heat supplied to Bottom Vessel",PosX=0, PosY=0.91,Protected=true);
1417#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1418# Column Top Outlets
1419#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1420        in      LiquidInlet             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.32, PosY=0);
1421        out     VapourOutlet    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.07, PosY=0);
1422#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1423# Column Bottom Product
1424#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1425        out     BottomProduct   as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.19, PosY=1);
1426        LiquidConnector         as stream                       (Brief="Liquid connection at the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
1427#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1428# Column Connectors
1429#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1430        in      ConnectorSplitterBottom         as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1431        ConnectorHeatReboiler                   as power        (Brief="Connector for Heat supplied to Reboiler", Hidden=true);
1432        ConnectorHeatAccumulator                as power        (Brief="Connector for Heat supplied to Bottom Accumulator", Hidden=true);
[715]1433
1434CONNECTIONS
1435#vapor
[735]1436        REBOILER.OutletVapour to TRAYS(NumberOfTrays).InletVapour;
[715]1437       
1438#liquid
[735]1439        TRAYS(NumberOfTrays).OutletLiquid       to ACCUMULATOR.Inlet;
[721]1440        ACCUMULATOR.Outlet                              to SPLITTER.Inlet;
[735]1441        SPLITTER.Outlet2                                to REBOILER.InletLiquid;
[715]1442
1443#Connectors
[735]1444LiquidConnector                         to TRAYS(1).InletLiquid;
[721]1445ConnectorHeatReboiler           to REBOILER.InletQ;
1446ConnectorHeatAccumulator        to ACCUMULATOR.InletQ;
1447SPLITTER.Outlet1                        to ConnectorSplitterBottom;
[715]1448
1449EQUATIONS
[721]1450#Heat Connectors
1451        HeatToReboiler  = ConnectorHeatReboiler;
1452        HeatToAccumulator       = ConnectorHeatAccumulator;
1453       
[715]1454        ConnectorSplitterBottom.T = BottomProduct.T;
1455        ConnectorSplitterBottom.P = BottomProduct.P;
1456        ConnectorSplitterBottom.F = BottomProduct.F;
1457        ConnectorSplitterBottom.z = BottomProduct.z;
1458       
1459        LiquidConnector.F= LiquidInlet.F;
1460        LiquidConnector.T = LiquidInlet.T;
1461        LiquidConnector.P = LiquidInlet.P;
1462        LiquidConnector.z = LiquidInlet.z;
1463        LiquidConnector.v = LiquidInlet.v;
1464        LiquidConnector.h = LiquidInlet.h;
1465       
[735]1466        VapourOutlet.F= TRAYS(1).OutletVapour.F;
1467        VapourOutlet.T = TRAYS(1).OutletVapour.T;
1468        VapourOutlet.P = TRAYS(1).OutletVapour.P;
1469        VapourOutlet.z = TRAYS(1).OutletVapour.z;
[715]1470       
1471        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1472        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1473        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1474        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1475
1476        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1477        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1478        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1479        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1480
1481        VapourDrawOffFlow = VapourDrawOff.F;
1482        LiquidDrawOffFlow = LiquidDrawOff.F;
[721]1483
[715]1484end
1485
1486Model ReactiveDistillation
1487       
1488ATTRIBUTES
1489        Pallete         = true;
1490        Icon            = "icon/DistillationReac";
1491        Brief           = "Model of a reactive distillation column with dynamic condenser and reboiler.";
1492        Info            =
1493"== Specify ==
1494* the reaction related variables for each tray, condenser and reboiler;
1495* the feed stream of each tray (Inlet);
1496* the Murphree eficiency for each tray Emv;
1497* the pump pressure difference;
1498* the heat supllied in reboiler and condenser;
[735]1499* the condenser vapor outlet flow (OutletVapour.F);
1500* the reboiler liquid outlet flow (OutletLiquid.F);
[715]1501* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
1502       
1503== Initial Conditions ==
[735]1504* the TRAYS temperature (OutletLiquid.T);
1505* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
1506* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray;
[715]1507       
[735]1508* the condenser temperature (OutletLiquid.T);
[715]1509* the condenser liquid level (Level);
[735]1510* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
[715]1511       
[735]1512* the reboiler temperature (OutletLiquid.T);
[715]1513* the reboiler liquid level (Level);
[735]1514* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
[715]1515";
1516       
1517PARAMETERS
[721]1518        outer PP        as Plugin       (Type="PP");
1519        outer NComp as Integer  (Brief="Number of Components");
1520#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1521# Section Column Feed Tray - Side Streams  Location and Numbering
1522#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1523        NumberOfTrays                                           as Integer      (Brief="Number of TRAYS", Default=2);
1524        FeedTrayIndex(NumberOfTrays)            as Integer      (Brief="Feed Tray Index", Default=0,Hidden=true);
1525        LiqSideTrayIndex(NumberOfTrays)         as Integer      (Brief="Liquid Side Tray Index", Default=0,Hidden=true);
1526        VapSideTrayIndex(NumberOfTrays)         as Integer      (Brief="Vapour Side Tray Index", Default=0,Hidden=true);
1527        FeedTrayLocation                                        as Integer      (Brief="Feed tray Location", Default=2);
1528        LiquidSideStreamLocation                        as Integer      (Brief="Liquid Side Stream Location", Default=2);
1529        VapourSideStreamLocation                        as Integer      (Brief="Vapour Side Stream Location", Default=2);
1530#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1531# Section Column Flow Model for Liquid and Vapour
1532#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1533        VapourFlow              as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
[715]1534        TrayVapourFlow  as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
[721]1535        TrayLiquidFlow  as Switcher     (Valid = ["on", "off"], Default = "off",Hidden=true);
1536        alfacond                as Real;
1537#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1538# Section Column Tray Geometry and Auxiliar Parameters
1539#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1540        V               as volume               (Brief="Total Volume of the tray",Hidden=true);
1541        Q               as power                (Brief="Rate of heat supply",Hidden=true);
1542        Ap              as area                 (Brief="Plate area = Atray - Adowncomer",Hidden=true);
1543        Ah              as area                 (Brief="Total holes area",Hidden=true);
1544        lw              as length               (Brief="Weir length",Hidden=true);
1545        g               as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
1546        hw              as length               (Brief="Weir height",Hidden=true);
1547        beta    as fraction     (Brief="Aeration fraction");
1548        alfa    as fraction     (Brief="Dry pressure drop coefficient");
[715]1549
1550        VolumeOfTray            as volume               (Brief="Total Volume of the tray");
1551        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
[721]1552        PlateArea                       as area                 (Brief="Plate area = Atray - Adowncomer");
1553        HolesArea                       as area                 (Brief="Total holes area");
1554        WeirLength                      as length               (Brief="Weir length");
1555        WeirHeight                      as length               (Brief="Weir height");
[715]1556
1557        stoic(NComp)    as Real(Brief="Stoichiometric matrix");
1558        Hr                                              as energy_mol;
1559       
1560SET
1561
[721]1562        FeedTrayIndex(FeedTrayLocation)         =1;
[715]1563        VapSideTrayIndex(FeedTrayLocation)      =1;
1564        LiqSideTrayIndex(FeedTrayLocation)      =1;
1565
1566        V=VolumeOfTray;
1567        Q=HeatSupply;
1568        Ap=PlateArea;
1569        Ah=HolesArea;
1570        lw=WeirLength;
1571        hw=WeirHeight ;
1572       
1573VARIABLES
[721]1574#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1575# Tray Initialization For the Whole Column Section
1576#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1577        INITIALIZATION          as InitializeSection    (Brief = "Column Model Initialization");
1578#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1579# Column Feed - Side Stream Flow and Murphree Efficiency
1580#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
1581        in      FeedTray                        as stream       (Brief="Feed stream", PosX=0, PosY=0.55);
1582                VapourDrawOffFlow       as flow_mol (Brief = "Stream Molar Flow Rate");
1583                LiquidDrawOffFlow   as flow_mol (Brief = "Stream Molar Flow Rate");
1584                MurphreeEff             as Real         (Brief = "Murphree efficiency");
1585#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1586# Column Vapour and Liquid Draw Sides
1587#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1588        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.395,Protected = true);
1589        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.44,Protected = true);
1590#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1591# Heat Ports
1592#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1593        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler", PosX=1, PosY=0.89);
1594        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", PosX=1, PosY=0.07);
1595#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1596# Column Devices
1597#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[715]1598        TRAYS(NumberOfTrays)    as trayReac;
[721]1599        CONDENSER                               as condenserReact;
1600        REBOILER                                as reboilerReact;
[739]1601        SPLITTER                                as splitter2;
[721]1602        PUMP                                    as pump;
1603#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1604# Column Outlets
1605#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1606        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Condenser", PosX=0.59, PosY=0);
1607        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Splitter", PosX=1, PosY=0.23);
1608        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.67, PosY=1);
1609#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1610# Column Connectors
1611#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1612in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
1613in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
1614in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
1615#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1616# Column Control Ports
1617#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1618        out     TRI as control_signal   (Brief="Temperature of Reboiler Indicator", PosX=1, PosY=0.83);
1619        out     LRI as control_signal   (Brief="Level of Reboiler Indicator", PosX=1, PosY=0.855);
1620        out     TCI as control_signal   (Brief="Temperature of Condenser Indicator", PosX=1, PosY=0.01);
1621        out     LCI as control_signal   (Brief="Level of Condenser Indicator", PosX=1, PosY=0.04);
[715]1622
1623CONNECTIONS
1624#vapor
[735]1625        REBOILER.OutletVapour                                   to TRAYS(NumberOfTrays).InletVapour;
1626        TRAYS(1).OutletVapour                                   to CONDENSER.InletVapour;
1627        TRAYS([2:NumberOfTrays]).OutletVapour   to TRAYS([1:NumberOfTrays-1]).InletVapour;
[715]1628
1629#liquid
[735]1630        CONDENSER.OutletLiquid                                  to SPLITTER.Inlet;     
[721]1631        SPLITTER.Outlet2                                        to PUMP.Inlet;
[735]1632        PUMP.Outlet                                             to TRAYS(1).InletLiquid;
1633        TRAYS([1:NumberOfTrays-1]).OutletLiquid         to TRAYS([2:NumberOfTrays]).InletLiquid;
1634        TRAYS(NumberOfTrays).OutletLiquid               to REBOILER.InletLiquid;
[715]1635
1636#Connectors
[735]1637        CONDENSER.OutletVapour  to ConnectorCondenserVout;
[721]1638        SPLITTER.Outlet1        to ConnectorSplitterOut;
[735]1639        REBOILER.OutletLiquid   to ConnectorReboilerLout;
[715]1640
[721]1641INITIAL
1642#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1643# Tray Initialization
1644#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1645for i in 1:NumberOfTrays do
[715]1646
[721]1647"The initial temperature of the TRAYS"
[735]1648        TRAYS(i).OutletLiquid.T = INITIALIZATION.TopTemperature+(INITIALIZATION.BottomTemperature-INITIALIZATION.TopTemperature)*((i-1)/(NumberOfTrays-1));
[721]1649
1650"The initial Level of the TRAYS"
1651        TRAYS(i).Level = INITIALIZATION.LevelFraction*hw;
1652end
1653
1654for i in 1:NComp-1 do
1655
1656for j in 1:NumberOfTrays do
1657
1658"The initial composition of the TRAYS - Normalized"
[735]1659        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]1660end
1661
1662end
1663
[715]1664EQUATIONS
1665
1666for i in [1:NumberOfTrays] do
1667
1668"Murphree Efficiency"
[735]1669        TRAYS(i).OutletVapour.z =  MurphreeEff * (TRAYS(i).yideal - TRAYS(i).InletVapour.z) + TRAYS(i).InletVapour.z;
[715]1670       
1671"Energy Holdup"
[735]1672        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletLiquid.h + TRAYS(i).MV*TRAYS(i).OutletVapour.h - TRAYS(i).OutletLiquid.P*V;
[715]1673
1674"Component Molar Balance"
[735]1675        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]1676        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;
1677       
1678"Energy Balance"
[735]1679        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]1680        -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;
1681
1682"Level of clear liquid over the weir"
1683        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/Ap;
1684
1685"Geometry Constraint"
1686        V = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
1687
1688end
1689
1690switch VapourFlow
1691                case "on":
1692                "Pressure Drop through the condenser"
[735]1693                CONDENSER.InletVapour.F*TRAYS(1).vV / 'm^2' =
1694                        sqrt((TRAYS(1).OutletVapour.P - CONDENSER.OutletLiquid.P + 1e-8 * 'atm')/(TRAYS(1).rhoV*alfacond));
1695                when TRAYS(1).OutletVapour.P < CONDENSER.OutletLiquid.P switchto "off";
[715]1696               
1697                case "off":
1698                "Prato selado"
[735]1699                CONDENSER.InletVapour.F = 0.0 * 'mol/s';
1700                when TRAYS(1).OutletVapour.P > CONDENSER.OutletLiquid.P + 1e-3 * 'atm' switchto "on";
[715]1701        end
1702
1703for i in [1:NumberOfTrays] do
1704
1705        switch TrayLiquidFlow
1706                case "on":
1707                "Francis Equation"
[735]1708                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'1/s'*lw*((TRAYS(i).Level-(beta*hw)+1e-6*'m')/(beta))^2;
[715]1709                when TRAYS(i).Level < (beta * hw) switchto "off";
1710               
1711                case "off":
1712                "Low level"
[735]1713                TRAYS(i).OutletLiquid.F = 0 * 'mol/h';
[715]1714                when TRAYS(i).Level > (beta * hw) + 1e-6*'m' switchto "on";
1715        end
1716
1717        switch TrayVapourFlow
1718                case "on":
[735]1719                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;
1720                when TRAYS(i).InletVapour.P < TRAYS(i).OutletVapour.P + TRAYS(i).Level*g*TRAYS(i).rhoL switchto "off";
[715]1721               
1722                case "off":
[735]1723                TRAYS(i).InletVapour.F = 0 * 'mol/s';
1724                when TRAYS(i).InletVapour.P > TRAYS(i).OutletVapour.P + TRAYS(i).Level*g*TRAYS(i).rhoL + 3e-2 * 'atm' switchto "on";
[715]1725        end
1726
1727end
1728
1729# Connecting Trays
1730        FeedTray.F*FeedTrayIndex= TRAYS.Inlet.F;
1731        FeedTray.T = TRAYS.Inlet.T;
1732        FeedTray.P = TRAYS.Inlet.P;
1733        FeedTray.z = TRAYS.Inlet.z;
1734        FeedTray.v = TRAYS.Inlet.v;
1735        FeedTray.h = TRAYS.Inlet.h;
1736
[721]1737        HeatToReboiler  = REBOILER.InletQ;
1738        HeatToCondenser = CONDENSER.InletQ;
[715]1739
1740"Reboiler Temperature indicator"
[735]1741        TRI * 'K' = REBOILER.OutletLiquid.T;
[715]1742
1743"Reboiler Level indicator"
1744        LRI*REBOILER.V = REBOILER.Level*REBOILER.Across;
1745
1746"Condenser Temperature indicator"
[735]1747        TCI * 'K' = CONDENSER.OutletLiquid.T;
[715]1748
1749"Condenser Level indicator"
1750        LCI*CONDENSER.V = CONDENSER.Level*CONDENSER.Across;
1751
1752# Condenser Connector Equations
1753        ConnectorCondenserVout.T = VapourDistillate.T;
1754        ConnectorCondenserVout.P = VapourDistillate.P;
1755        ConnectorCondenserVout.F = VapourDistillate.F;
1756        ConnectorCondenserVout.z = VapourDistillate.z;
1757
1758# Splitter Connector Equations
1759        ConnectorSplitterOut.T = LiquidDistillate.T;
1760        ConnectorSplitterOut.P = LiquidDistillate.P;
1761        ConnectorSplitterOut.F = LiquidDistillate.F;
1762        ConnectorSplitterOut.z = LiquidDistillate.z;
1763
1764# Reboiler Connector Equations
1765        ConnectorReboilerLout.T = BottomProduct.T;
1766        ConnectorReboilerLout.P = BottomProduct.P;
1767        ConnectorReboilerLout.F = BottomProduct.F;
1768        ConnectorReboilerLout.z = BottomProduct.z;
1769
1770        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
1771        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
1772        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
1773        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
1774
1775        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
1776        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
1777        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
1778        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
1779
1780        VapourDrawOffFlow = VapourDrawOff.F;
1781        LiquidDrawOffFlow = LiquidDrawOff.F;
1782
1783end
1784
1785Model Packed_Section_ColumnBasic
1786        ATTRIBUTES
1787        Pallete         = false;
1788        Icon            = "icon/PackedSectionColumn";
1789        Brief           = "Model of a packed column section.";
1790        Info            =
1791"== Model of a packed column section containing ==
1792* NStages theoretical stages.
1793       
1794== Specify ==
1795* the feed stream of each tray (Inlet);
[735]1796* the InletLiquid stream of the top tray;
1797* the InletVapour stream of the bottom tray;
[715]1798* the total pressure drop (dP) of the section.
1799       
1800== Initial Conditions ==
[735]1801* the stages temperature (OutletLiquid.T);
[715]1802* the stages liquid holdup;
[735]1803* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
[715]1804";
1805       
1806PARAMETERS
1807
[721]1808        outer PP                as Plugin(Brief = "External Physical Properties", Type="PP");
[715]1809        outer NComp     as Integer;
1810       
[721]1811        NumberOfStages                                  as Integer      (Brief="Number of Stages", Default=3);
1812        FeedStageIndex(NumberOfStages)  as Integer      (Brief="Number of Stages", Default=0,Hidden=true);
1813        FeedStageLocation                               as Integer      (Brief="Feed Stage Location", Default=2);
[715]1814       
[721]1815        PackingHeight           as length               (Brief="Height of packing");
1816        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
[715]1817        ColumnDiameter          as length               (Brief="Column diameter");
[721]1818        VoidFraction            as Real                 (Brief="Void fraction of packing, m^3/m^3");
1819        ResistanceCoeff         as positive     (Brief="Resistance coefficient on the liquid load", Default=1);
1820        AreaPerPackingVol       as Real                 (Brief="surface area per packing volume", Unit='m^2/m^3');
[715]1821       
[721]1822        V                               as volume               (Brief="Total Volume of the tray",Hidden=true);
1823        g                               as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
1824        hs                              as length               (Brief="Height of the packing stage",Hidden=true);
1825        ColumnArea              as area                 (Brief="Column Sectional Cross Area",Hidden=true);
[715]1826
1827VARIABLES
[721]1828#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1829# Stages Initialization For the Whole Column Section
1830#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1831        INITIALIZATION          as InitializeStage      (Brief = "Column Model Initialization");
[715]1832        in      FeedStage       as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
1833       
1834        STAGES(NumberOfStages) as packedStage;
[721]1835        PressureDrop               as pressure;
[715]1836       
1837SET
1838        FeedStageIndex(FeedStageLocation) =1;
1839       
1840        ColumnArea = ColumnDiameter^2*3.14159*0.25;
1841        hs =PackingHeight/NumberOfStages;       
1842        V = hs * ColumnArea;
1843       
1844CONNECTIONS
1845
[735]1846        STAGES([2:NumberOfStages]).OutletVapour                 to STAGES([1:NumberOfStages-1]).InletVapour;
1847        STAGES([1:NumberOfStages-1]).OutletLiquid       to STAGES([2:NumberOfStages]).InletLiquid;
[715]1848
1849EQUATIONS
1850# Connecting STAGES
1851        FeedStage.F*FeedStageIndex= STAGES.Inlet.F;
1852        FeedStage.T = STAGES.Inlet.T;
1853        FeedStage.P = STAGES.Inlet.P;
1854        FeedStage.z = STAGES.Inlet.z;
1855        FeedStage.v = STAGES.Inlet.v;
1856        FeedStage.h = STAGES.Inlet.h;
1857
1858        STAGES.deltaP = PressureDrop/NumberOfStages;
1859
1860for i in [1:NumberOfStages] do
1861
1862"Energy Balance"
[735]1863        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
1864        - STAGES(i).OutletVapour.F*STAGES(i).OutletVapour.h + HeatSupply );
[715]1865       
1866"Energy Holdup"
[735]1867        STAGES(i).E = STAGES(i).ML*STAGES(i).OutletLiquid.h + STAGES(i).MV*STAGES(i).OutletVapour.h - STAGES(i).OutletLiquid.P*V;
[715]1868       
1869"Geometry Constraint"
1870        V*VoidFraction= STAGES(i).ML*STAGES(i).vL + STAGES(i).MV*STAGES(i).vV;
1871       
1872"Volume flow rate of vapor, m^3/m^2/s"
[735]1873        STAGES(i).uV * ((ColumnArea)*VoidFraction - STAGES(i).Al) = STAGES(i).OutletVapour.F * STAGES(i).vV;
[715]1874       
1875"Liquid holdup"
1876        STAGES(i).hl = STAGES(i).ML*STAGES(i).vL/V/VoidFraction;
1877       
1878"Particle diameter"
1879        STAGES(i).dp = 6 * (1-VoidFraction)/AreaPerPackingVol;
1880       
1881"Wall Factor"
1882        STAGES(i).invK = (1 + (2*STAGES(i).dp/(3*ColumnDiameter*(1-VoidFraction))));
1883       
1884"Reynolds number of the vapor stream"
1885        STAGES(i).Rev*STAGES(i).invK = STAGES(i).dp*STAGES(i).uV*STAGES(i).rhoV / (STAGES(i).miV*(1-VoidFraction));
1886       
1887"Pressure drop and Vapor flow"
1888        STAGES(i).deltaP/hs  = ResistanceCoeff*AreaPerPackingVol*STAGES(i).uV^2*STAGES(i).rhoV*STAGES(i).invK / (2*(VoidFraction-STAGES(i).hl)^3);
1889
1890"Liquid holdup"
1891        STAGES(i).hl = (12*STAGES(i).miL*AreaPerPackingVol^2*STAGES(i).uL/STAGES(i).rhoL/g)^1/3;
1892
1893"Area occupied by the liquid"
1894        STAGES(i).Al = STAGES(i).ML*STAGES(i).vL/hs;
1895
1896end
1897
1898INITIAL
1899
1900for i in 1:NumberOfStages do
1901
1902"The initial temperature of the STAGES"
[735]1903        STAGES(i).OutletLiquid.T = INITIALIZATION.TopStageTemperature+(INITIALIZATION.BottomStageTemperature-INITIALIZATION.TopStageTemperature)*((i-1)/(NumberOfStages-1));
[715]1904
1905"The Liquid Holdup of the STAGES"
[721]1906        STAGES(i).ML = INITIALIZATION.LiquidMolarHoldup;
[715]1907
1908end
1909
1910for i in 1:NComp-1 do
1911       
1912for j in 1:NumberOfStages do
1913
1914"The initial composition of the TRAYS"
[735]1915        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]1916
1917end
1918
1919end
1920
1921end
1922
1923Model Packed_Section_Column as Packed_Section_ColumnBasic
1924
1925        ATTRIBUTES
1926        Pallete         = true;
1927        Icon            = "icon/PackedSectionColumn";
1928        Brief           = "Model of a packed column section.";
1929        Info            =
1930"== Model of a packed column section containing ==
1931* NStages theoretical stages.
1932       
1933== Specify ==
1934* the feed stream of each tray (Inlet);
[735]1935* the InletLiquid stream of the top tray;
1936* the InletVapour stream of the bottom tray;
[715]1937* the total pressure drop (dP) of the section.
1938       
1939== Initial Conditions ==
[735]1940* the stages temperature (OutletLiquid.T);
[715]1941* the stages liquid holdup;
[735]1942* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
[715]1943";
1944
1945VARIABLES
1946
1947        in              LiquidInlet             as      stream                          (Brief="Liquid Inlet in the section", PosX=0.70, PosY=0);
1948        out     VapourOutlet            as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.30, PosY=0);
1949       
1950        in              VapourInlet             as stream                               (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1);
1951        out     LiquidOutlet            as liquid_stream                (Brief="Liquid Outlet in the section", PosX=0.70, PosY=1);
1952       
1953        LiquidConnector as stream       (Brief="Liquid connection at the middle STAGES", PosX=0.75, PosY=1,Hidden=true);
1954        VapourConnector as stream       (Brief="Vapour connection at the middle STAGES", PosX=0.55, PosY=0,Hidden=true);
1955
1956CONNECTIONS
1957
[735]1958        LiquidConnector to STAGES(1).InletLiquid;
1959        VapourConnector to STAGES(NumberOfStages).InletVapour;
[715]1960       
1961EQUATIONS
1962
1963        LiquidConnector.F= LiquidInlet.F;
1964        LiquidConnector.T = LiquidInlet.T;
1965        LiquidConnector.P = LiquidInlet.P;
1966        LiquidConnector.z = LiquidInlet.z;
1967        LiquidConnector.v = LiquidInlet.v;
1968        LiquidConnector.h = LiquidInlet.h;
1969       
1970        VapourConnector.F= VapourInlet.F;
1971        VapourConnector.T = VapourInlet.T;
1972        VapourConnector.P = VapourInlet.P;
1973        VapourConnector.z = VapourInlet.z;
1974        VapourConnector.v = VapourInlet.v;
1975        VapourConnector.h = VapourInlet.h;
1976       
[735]1977        LiquidOutlet.F= STAGES(NumberOfStages).OutletLiquid.F;
1978        LiquidOutlet.T = STAGES(NumberOfStages).OutletLiquid.T;
1979        LiquidOutlet.P = STAGES(NumberOfStages).OutletLiquid.P;
1980        LiquidOutlet.z = STAGES(NumberOfStages).OutletLiquid.z;
[715]1981       
[735]1982        VapourOutlet.F= STAGES(1).OutletVapour.F;
1983        VapourOutlet.T = STAGES(1).OutletVapour.T;
1984        VapourOutlet.P = STAGES(1).OutletVapour.P;
1985        VapourOutlet.z = STAGES(1).OutletVapour.z;
[715]1986
1987end
1988
1989Model PackedDistillation_kettle_cond as Packed_Section_ColumnBasic
1990        ATTRIBUTES
1991        Pallete         = true;
1992        Icon            = "icon/PackedDistillationKettleCond";
1993        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
1994        Info            =
1995"== Specify ==
1996* the feed stream of each tray (Inlet);
1997* the pump pressure difference;
1998* the total pressure drop (dP) of the packing;
1999* the heat supllied in reboiler and condenser;
[735]2000* the condenser vapor outlet flow (OutletVapour.F);
2001* the reboiler liquid outlet flow (OutletLiquid.F);
[715]2002* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
2003       
2004== Initial Conditions ==
[735]2005* the stages temperature (OutletLiquid.T);
[715]2006* the stages initial molar holdup;
[735]2007* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each stage;
[715]2008       
[735]2009* the condenser temperature (OutletLiquid.T);
[715]2010* the condenser liquid level (Level);
[735]2011* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
[715]2012       
[735]2013* the reboiler temperature (OutletLiquid.T);
[715]2014* the reboiler liquid level (Level);
[735]2015* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
[715]2016";
2017       
2018PARAMETERS
2019
[721]2020        VapourFlow as Switcher  (Valid = ["on", "off"], Hidden = true ,Default = "on");
[715]2021       
2022VARIABLES
[721]2023#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2024# Column Devices
2025#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2026        CONDENSER       as condenser    (Brief="dymamic condenser");
2027        REBOILER        as reboiler             (Brief="kettle reboiler");
[739]2028        SPLITTER        as splitter2            (Brief="splitter which separate reflux and distillate");
[721]2029        PUMP            as pump                 (Brief="pump in reflux stream");
2030#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2031# Heat Ports
2032#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2033        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler",Protected = true, PosX=1, PosY=0.885);
2034        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", Protected = true, PosX=1, PosY=0.034);
2035#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2036# Column Products
2037#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
2038        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.66, PosY=0);
2039        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
2040        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.68, PosY=1);
2041#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2042# Column Connectors
2043#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
2044        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
2045        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
2046        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
2047                ConnectorHeatReboiler   as power        (Brief="Heat supplied to Reboiler", Hidden=true);
2048                ConnectorHeatCondenser  as power        (Brief="Heat supplied to Condenser", Hidden=true);
[715]2049
2050CONNECTIONS
2051
2052#vapor
[735]2053        REBOILER.OutletVapour           to STAGES(NumberOfStages).InletVapour;
2054        STAGES(1).OutletVapour          to CONDENSER.InletVapour;
[715]2055
2056#liquid
[735]2057        CONDENSER.OutletLiquid                          to SPLITTER.Inlet;     
[721]2058        SPLITTER.Outlet2                                to PUMP.Inlet;
[735]2059        PUMP.Outlet                                     to STAGES(1).InletLiquid;
2060        STAGES(NumberOfStages).OutletLiquid     to REBOILER.InletLiquid;
[715]2061
2062#Connectors
[721]2063ConnectorHeatReboiler   to REBOILER.InletQ;
2064ConnectorHeatCondenser  to CONDENSER.InletQ;
[715]2065
[735]2066CONDENSER.OutletVapour          to ConnectorCondenserVout;
[721]2067SPLITTER.Outlet1                to ConnectorSplitterOut;
[735]2068REBOILER.OutletLiquid           to ConnectorReboilerLout;
[715]2069
2070EQUATIONS
[721]2071        HeatToReboiler  = ConnectorHeatReboiler;
2072        HeatToCondenser = ConnectorHeatCondenser;
2073       
[715]2074# Condenser Connector Equations
2075        ConnectorCondenserVout.T = VapourDistillate.T;
2076        ConnectorCondenserVout.P = VapourDistillate.P;
2077        ConnectorCondenserVout.F = VapourDistillate.F;
2078        ConnectorCondenserVout.z = VapourDistillate.z;
2079
2080# Splitter Connector Equations
2081        ConnectorSplitterOut.T = LiquidDistillate.T;
2082        ConnectorSplitterOut.P = LiquidDistillate.P;
2083        ConnectorSplitterOut.F = LiquidDistillate.F;
2084        ConnectorSplitterOut.z = LiquidDistillate.z;
2085
2086# Reboiler Connector Equations
2087        ConnectorReboilerLout.T = BottomProduct.T;
2088        ConnectorReboilerLout.P = BottomProduct.P;
2089        ConnectorReboilerLout.F = BottomProduct.F;
2090        ConnectorReboilerLout.z = BottomProduct.z;
2091
2092switch VapourFlow
2093        case "on":
[735]2094                STAGES(NumberOfStages).InletVapour.F*STAGES(NumberOfStages).vV = sqrt((REBOILER.OutletVapour.P - STAGES(NumberOfStages).OutletVapour.P)/
[715]2095                                        (STAGES(NumberOfStages).rhoV*ResistanceCoeff*20))*(ColumnArea*VoidFraction - STAGES(NumberOfStages).Al);
[735]2096                when STAGES(NumberOfStages).InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
[715]2097
2098        case "off":
[735]2099                STAGES(NumberOfStages).InletVapour.F = 0 * 'mol/s';
2100                when REBOILER.OutletVapour.P > STAGES(NumberOfStages).OutletVapour.P + 1e-1 * 'atm' switchto "on";
[715]2101end
2102
2103end
2104
Note: See TracBrowser for help on using the repository browser.