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

Last change on this file since 818 was 818, checked in by mamuller, 13 years ago

Correction for the plate area equation.

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