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

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

updated column model (to keep it working)

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