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

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

changes in column model

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