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

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

updates

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