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

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

added control ports in column model

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