Ignore:
Timestamp:
Aug 7, 2009, 1:12:57 PM (13 years ago)
Author:
gerson bicca
Message:

updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/eml/stage_separators/column.mso

    r815 r816  
    111111        LiquidSideStreamLocation                        as Integer                      (Brief="Liquid Side Stream Location", Default=2);
    112112        VapourSideStreamLocation                        as Integer                      (Brief="Vapour Side Stream Location", Default=2);
     113        Pi                                                                      as constant             (Brief="Pi Number",Default=3.14159265, Symbol = "\pi",Hidden=true);
    113114        g                                                                       as acceleration         (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
    114115        Mw(NComp)                                                       as molweight            (Brief="Component Mol Weight",Hidden=true);
     
    121122# Section Column Tray Geometry and Auxiliar Parameters
    122123#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     124        TrayDiameter                    as length               (Brief="Tray Diameter",Default=1.600);
     125        TraySpacing                             as length               (Brief="Tray Spacing",Default=0.600);
     126        Fraction_HoleArea               as fraction     (Brief="Fraction of the active area that is occupied by the holes with respect to the total tray area",Default=0.10);
     127        Fraction_DowncomerArea  as fraction     (Brief="Fraction of the downcomer area with respect to the total tray area",Default=0.20);
     128        WeirLength                              as length               (Brief="Weir length");
     129        WeirHeight                              as length               (Brief="Weir height");
     130        TrayLiquidPasses                as Real                 (Brief="Number of liquid passes in the tray", Default=1);
     131        HeatSupply                              as heat_rate    (Brief="Rate of heat supply");
     132        beta                                    as fraction     (Brief="Aeration fraction");
     133        alfa                                    as fraction     (Brief="Dry pressure drop coefficient");
     134       
     135        PlateArea               as area                 (Brief="Plate area = Atray - Adowncomer",Protected=false);
     136        TrayVolume              as volume               (Brief="Total Volume of the tray",Protected=false);
     137        HolesArea               as area                 (Brief="Total holes area",Protected=false);
     138
     139        FeeheryCoeff    as Real                 (Brief="Feeherys correlation coefficient", Unit='1/m^4', Default=1,Hidden=true);
     140        ElgueCoeff              as Real                 (Brief="Elgues correlation coefficient", Unit='kg/m/mol^2', Default=1,Hidden=true);
     141        OlsenCoeff              as Real                 (Brief="Olsens correlation coefficient", Default=1,Hidden=true);
     142       
     143
     144        VapourFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
     145        LiquidFlow      as Switcher     (Valid = ["on", "off"], Default = "on",Hidden=true);
     146
     147SET
     148        VapSideTrayIndex(VapourSideStreamLocation) =1;
     149        LiqSideTrayIndex(LiquidSideStreamLocation) =1;
     150        Mw = PP.MolecularWeight();
     151
     152
     153        PlateArea = 0.25*Pi*(TrayDiameter^2)*Fraction_DowncomerArea;
     154        TrayVolume = 0.25*Pi*(TrayDiameter^2)*TraySpacing;
     155        HolesArea = 0.25*Pi*(TrayDiameter^2)*Fraction_HoleArea;
     156
     157VARIABLES
     158#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     159# Tray Initialization For the Whole Column Section
     160#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     161        INITIALIZATION as InitializeSection (Brief = "Column Model Initialization");
     162#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     163# Control Ports
     164#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     165        CONTROL as ControlSection (Brief = "Control");
     166        out     TCI as control_signal   (Brief="Temperature  Indicator", Protected = true, PosX=1, PosY=0.73);
     167        out     PCI as control_signal   (Brief="Pressure Indicator", Protected = true, PosX=0, PosY=0.24);
     168#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     169# Column Feed - Side Stream Flow and Murphree Efficiency
     170#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
     171    in      LiquidInlet             as      stream                  (Brief="Liquid Inlet in the section", PosX=0.70, PosY=0);
     172    out     VapourOutlet    as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.30, PosY=0);
     173
     174    out     VapourDrawOff   as vapour_stream        (Brief="Vapour Draw Off Port in the section", PosX=1, PosY=0.35,Protected = true);
     175        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Draw Off Port in the section", PosX=1, PosY=0.65,Protected = true);
     176       
     177        TRAYS(NumberOfTrays)    as tray                 (Brief="Number of trays in the Column Section");
     178        VapourDrawOffFlow               as flow_mol     (Brief="Vapour Draw Off Stream Molar Flow Rate");
     179        LiquidDrawOffFlow               as flow_mol     (Brief="Vapour Draw Off Stream Molar Flow Rate");
     180        MurphreeEff                     as Real                 (Brief="Murphree efficiency for All Trays",Lower=0.01,Upper=1);
     181
     182#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     183# Section Inlet Vapour and Outlet Liquid Material Ports
     184#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     185        in      VapourInlet     as stream             (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1);
     186        out     LiquidOutlet    as liquid_stream      (Brief="Liquid Outlet in the section", PosX=0.70, PosY=1);
     187       
     188                LiquidConnector as stream       (Brief="Liquid connection in the middle TRAYS", PosX=0.75, PosY=1,Hidden=true);
     189            VapourConnector as stream       (Brief="Vapour connection in the middle TRAYS", PosX=0.55, PosY=0,Hidden=true);
     190CONNECTIONS
     191#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     192# Connecting Intermediate Trays
     193#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     194        TRAYS([2:NumberOfTrays]).OutletVapour   to TRAYS([1:NumberOfTrays-1]).InletVapour;
     195        TRAYS([1:NumberOfTrays-1]).OutletLiquid         to TRAYS([2:NumberOfTrays]).InletLiquid;
     196       
     197#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     198# Connecting Connectors
     199#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     200    LiquidConnector to TRAYS(1).InletLiquid;
     201    VapourConnector to TRAYS(NumberOfTrays).InletVapour;
     202       
     203INITIAL
     204#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     205# Tray Initialization
     206#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     207for i in 1:NumberOfTrays do
     208
     209"The initial temperature of the TRAYS"
     210        TRAYS(i).OutletLiquid.T = INITIALIZATION.TopTemperature+(INITIALIZATION.BottomTemperature-INITIALIZATION.TopTemperature)*((i-1)/(NumberOfTrays-1));
     211
     212"The initial Level of the TRAYS"
     213        TRAYS(i).Level = INITIALIZATION.LevelFraction*WeirHeight;
     214end
     215
     216for i in 1:NComp-1 do
     217
     218for j in 1:NumberOfTrays do
     219
     220"The initial composition of the TRAYS - Normalized"
     221        TRAYS(j).OutletLiquid.z(i) = INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) +(INITIALIZATION.BottomComposition(i)/sum(INITIALIZATION.BottomComposition)-INITIALIZATION.TopComposition(i)/sum(INITIALIZATION.TopComposition) )*((j-1)/(NumberOfTrays-1));
     222end
     223
     224end
     225
     226EQUATIONS
     227#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     228# Control Ports
     229#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     230
     231"Tray Temperature Indicator"   
     232        #TCI*'K' = TRAYS(min([NumberOfTrays, CONTROL.Tindicator_TrayNumber])).OutletVapour.T;
     233        TCI*'K' = TRAYS(CONTROL.Tindicator_TrayNumber).OutletVapour.T;
     234
     235"Tray Pressure Indicator"       
     236        #PCI*'atm' = TRAYS(min([NumberOfTrays, CONTROL.Pindicator_TrayNumber])).OutletVapour.P;
     237        PCI*'atm' = TRAYS(CONTROL.Pindicator_TrayNumber).OutletVapour.P;
     238
     239#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     240# Trays Equations
     241#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     242
     243for i in [1:NumberOfTrays] do
     244
     245"Murphree Efficiency"
     246        TRAYS(i).OutletVapour.z =  MurphreeEff * (TRAYS(i).yideal - TRAYS(i).InletVapour.z) + TRAYS(i).InletVapour.z;
     247
     248"Level of clear liquid over the weir"
     249        TRAYS(i).Level = TRAYS(i).ML*TRAYS(i).vL/PlateArea;
     250
     251"Geometry Constraint"
     252        TrayVolume = TRAYS(i).ML* TRAYS(i).vL + TRAYS(i).MV*TRAYS(i).vV;
     253
     254"Energy Holdup"
     255        TRAYS(i).E = TRAYS(i).ML*TRAYS(i).OutletLiquid.h + TRAYS(i).MV*TRAYS(i).OutletVapour.h - TRAYS(i).OutletLiquid.P*TrayVolume;
     256
     257"Energy Balance"
     258        diff(TRAYS(i).E) = ( TRAYS(i).Inlet.F*TRAYS(i).Inlet.h + TRAYS(i).InletLiquid.F*TRAYS(i).InletLiquid.h + TRAYS(i).InletVapour.F*TRAYS(i).InletVapour.h- TRAYS(i).OutletLiquid.F*TRAYS(i).OutletLiquid.h - TRAYS(i).OutletVapour.F*TRAYS(i).OutletVapour.h
     259        -TRAYS(i).VapourSideStream.F*TRAYS(i).VapourSideStream.h - TRAYS(i).LiquidSideStream.F*TRAYS(i).LiquidSideStream.h + HeatSupply );
     260
     261switch LiquidFlow
     262                case "on":
     263                        switch LiquidFlowModel
     264                                case "default":
     265                                "Francis Equation"
     266                                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'1/s'*WeirLength*((TRAYS(i).Level-(beta*WeirHeight))/(beta))^2;
     267                       
     268                                case "Wang_Fl":
     269                                TRAYS(i).OutletLiquid.F*TRAYS(i).vL = 1.84*'m^0.5/s'*WeirLength*((TRAYS(i).Level-(beta*WeirHeight))/(beta))^1.5;
     270                       
     271                                case "Olsen":
     272                                TRAYS(i).OutletLiquid.F / 'mol/s'= WeirLength*TrayLiquidPasses*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletVapour.z)/(0.665*OlsenCoeff)^1.5 * ((TRAYS(i).ML*sum(Mw*TRAYS(i).OutletLiquid.z)/TRAYS(i).rhoL/PlateArea)-WeirHeight)^1.5 * 'm^0.5/mol';
     273                       
     274                                case "Feehery_Fl":
     275                                TRAYS(i).OutletLiquid.F = WeirLength*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletLiquid.z) * ((TRAYS(i).Level-WeirHeight)/750/'mm')^1.5 * 'm^2/s';
     276                       
     277                                case "Roffel_Fl":
     278                                TRAYS(i).OutletLiquid.F = 2/3*TRAYS(i).rhoL/sum(Mw*TRAYS(i).OutletLiquid.z)*WeirLength*(TRAYS(i).ML*sum(Mw*TRAYS(i).OutletLiquid.z)/(PlateArea*1.3)/TRAYS(i).rhoL)^1.5*sqrt(2*g/
     279                                                        (2*(1 - 0.3593/'Pa^0.0888545'*abs(TRAYS(i).OutletVapour.F*sum(Mw*TRAYS(i).OutletVapour.z)/(PlateArea*1.3)/sqrt(TRAYS(i).rhoV))^0.177709)-1)); #/'(kg/m)^0.0888545/s^0.177709';
     280                        end
     281                when TRAYS(i).Level < (beta *WeirHeight) switchto "off";
     282               
     283                case "off":
     284                "Low level"
     285                TRAYS(i).OutletLiquid.F = 0 * 'mol/h';
     286                when TRAYS(i).Level > (beta * WeirHeight) + 1e-6*'m' switchto "on";
     287        end
     288       
     289switch VapourFlow
     290                case "on":
     291                        switch VapourFlowModel
     292                                case "Reepmeyer":
     293                                TRAYS(i).InletVapour.F*TRAYS(i).vV = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)/(TRAYS(i).rhoV*alfa))*HolesArea;
     294                       
     295                                case "Feehery_Fv":
     296                                TRAYS(i).InletVapour.F = TRAYS(i).rhoV/PlateArea/FeeheryCoeff/sum(Mw*TRAYS(i).OutletVapour.z) * sqrt(((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)-(TRAYS(i).rhoV*g*TRAYS(i).ML*TRAYS(i).vL/PlateArea))/TRAYS(i).rhoV);
     297                       
     298                                case "Roffel_Fv":
     299                                TRAYS(i).InletVapour.F^1.08 * 0.0013 * 'kg/m/mol^1.08/s^0.92*1e5' = (TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)*1e5 - (beta*sum(TRAYS(i).M*Mw)/(PlateArea*1.3)*g*1e5) * (TRAYS(i).rhoV*HolesArea/sum(Mw*TRAYS(i).OutletVapour.z))^1.08 * 'm^1.08/mol^1.08';
     300                       
     301                                case "Klingberg":
     302                                TRAYS(i).InletVapour.F * TRAYS(i).vV = PlateArea * sqrt(((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)-TRAYS(i).rhoL*g*TRAYS(i).Level)/TRAYS(i).rhoV);
     303                       
     304                                case "Wang_Fv":
     305                                TRAYS(i).InletVapour.F * TRAYS(i).vV = PlateArea * sqrt(((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)-TRAYS(i).rhoL*g*TRAYS(i).Level)/TRAYS(i).rhoV*alfa);
     306                               
     307                                case "Elgue":
     308                                TRAYS(i).InletVapour.F  = sqrt((TRAYS(i).InletVapour.P - TRAYS(i).OutletVapour.P)/ElgueCoeff);
     309                        end
     310                when TRAYS(i).InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
     311               
     312                case "off":
     313                TRAYS(i).InletVapour.F = 0 * 'mol/s';
     314                when TRAYS(i).InletVapour.P > TRAYS(i).OutletVapour.P + TRAYS(i).Level*g*TRAYS(i).rhoL + 1e-1 * 'atm' switchto "on";
     315        end
     316
     317end
     318
     319#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     320# Equating Inlet Liquid Connector Variables
     321#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     322"Liquid Inlet Flow"     
     323        LiquidConnector.F = LiquidInlet.F;
     324
     325"Liquid Inlet Temperature"             
     326        LiquidConnector.T = LiquidInlet.T;
     327
     328"Liquid Inlet Pressure"         
     329        LiquidConnector.P = LiquidInlet.P;
     330
     331"Liquid Inlet Composition"             
     332        LiquidConnector.z = LiquidInlet.z;
     333
     334"Liquid Inlet Vapour Fraction"         
     335        LiquidConnector.v = LiquidInlet.v;
     336
     337"Liquid Inlet Enthalpy"         
     338        LiquidConnector.h = LiquidInlet.h;
     339#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     340# Equating Inlet Vapour Connector Variables
     341#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     342"Vapour Inlet Flow"             
     343        VapourConnector.F = VapourInlet.F;
     344
     345"Vapour Inlet Temperature"             
     346        VapourConnector.T = VapourInlet.T;
     347
     348"Vapour Inlet Pressure"         
     349        VapourConnector.P = VapourInlet.P;
     350
     351"Vapour Inlet Composition"             
     352        VapourConnector.z = VapourInlet.z;
     353
     354"Vapour Inlet Vapour Fraction"         
     355        VapourConnector.v = VapourInlet.v;
     356
     357"Vapour Inlet Enthalpy"         
     358        VapourConnector.h = VapourInlet.h;
     359#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     360# Equating Outlet Liquid Variables
     361#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     362"Liquid Outlet Flow"   
     363        LiquidOutlet.F = TRAYS(NumberOfTrays).OutletLiquid.F;
     364
     365"Liquid Outlet Temperature"     
     366        LiquidOutlet.T = TRAYS(NumberOfTrays).OutletLiquid.T;
     367
     368"Liquid Outlet Pressure"       
     369        LiquidOutlet.P = TRAYS(NumberOfTrays).OutletLiquid.P;
     370
     371"Liquid Outlet Composition"     
     372        LiquidOutlet.z = TRAYS(NumberOfTrays).OutletLiquid.z;
     373#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     374# Equating Outlet Vapour Variables
     375#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     376"Vapour Outlet Flow"           
     377        VapourOutlet.F = TRAYS(1).OutletVapour.F;
     378
     379"Vapour Outlet Temperature"             
     380        VapourOutlet.T = TRAYS(1).OutletVapour.T;
     381
     382"Vapour Outlet Pressure"               
     383        VapourOutlet.P = TRAYS(1).OutletVapour.P;
     384
     385"Vapour Outlet Composition"             
     386        VapourOutlet.z = TRAYS(1).OutletVapour.z;
     387#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     388# Equating Outlet Vapour Side Stream Variables
     389#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     390"Vapour Draw Off Stream - Flow"         
     391        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
     392
     393"Vapour Draw Off Stream - Temperature"         
     394        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
     395
     396"Vapour Draw Off Stream - Pressure"             
     397        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
     398
     399"Vapour Draw Off Stream - Composition"         
     400        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
     401
     402"Vapour Draw Off Stream"       
     403        VapourDrawOffFlow = VapourDrawOff.F;
     404#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     405# Equating Outlet Liquid Side Stream Variables
     406#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     407"Liquid Draw Off Stream - Flow"         
     408        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
     409
     410"Liquid Draw Off Stream - Temperature" 
     411        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
     412
     413"Liquid Draw Off Stream - Pressure"                     
     414        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
     415
     416"Liquid Draw Off Stream - Composition" 
     417        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
     418
     419"Liquid Draw Off Stream"       
     420        LiquidDrawOffFlow = LiquidDrawOff.F;
     421
     422end
     423
     424Model Section_Column    as SectionColumnBasic
     425
     426ATTRIBUTES
     427        Pallete         = true;
     428        Icon            = "icon/SectionColumn";
     429        Brief   = "Model of a column section.";
     430        Info            =
     431"== Model of a column section containing ==
     432* NumberOfTrays TRAYS.
     433* One Feed Inlet.
     434       
     435== Specify ==
     436* the feed stream of each tray (Inlet);
     437* the Murphree eficiency for each tray Emv;
     438* the InletLiquid stream of the top tray;
     439* the InletVapour stream of the bottom tray.
     440       
     441== Initial Conditions ==
     442* the TRAYS temperature (OutletLiquid.T);
     443* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
     444* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
     445";
     446
     447SET
     448        NumberOfFeeds = 1;
     449
     450VARIABLES
     451       
     452        in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
     453
     454EQUATIONS
     455#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     456# Equating Feed Tray Variables to Trays Variables
     457#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     458for i in 1:NumberOfTrays do
     459
     460if   i equal FeedTrayLocation(1) then   
     461
     462"FeedTrayTop Inlet Flow"       
     463        FeedTray.F= TRAYS(i).Inlet.F;
     464
     465"FeedTrayTop Inlet Temperature"
     466        FeedTray.T = TRAYS(i).Inlet.T;
     467
     468"FeedTrayTop Inlet Pressure"
     469        FeedTray.P = TRAYS(i).Inlet.P;
     470
     471"FeedTrayTop Inlet Composition"
     472        FeedTray.z = TRAYS(i).Inlet.z;
     473
     474"FeedTrayTop Inlet Vapour Fraction"
     475        FeedTray.v = TRAYS(i).Inlet.v;
     476
     477"FeedTrayTop Inlet Enthalpy"
     478        FeedTray.h = TRAYS(i).Inlet.h;
     479
     480else
     481
     482"Inlet Tray - Flow Sealed"     
     483        0*'mol/h'= TRAYS(i).Inlet.F;
     484
     485"Inlet Tray -  Temperature"
     486        FeedTray.T = TRAYS(i).Inlet.T;
     487
     488"Inlet Tray -  Pressure"
     489        FeedTray.P = TRAYS(i).Inlet.P;
     490
     491"Inlet Tray -  Composition"
     492        FeedTray.z = TRAYS(i).Inlet.z;
     493
     494"Inlet Tray -  Vapour Fraction"
     495        FeedTray.v = TRAYS(i).Inlet.v;
     496
     497"Inlet Tray -  Enthalpy"
     498        FeedTray.h = TRAYS(i).Inlet.h;
     499
     500end
     501
     502end
     503
     504end
     505
     506Model Section_Column2   as SectionColumnBasic
     507
     508ATTRIBUTES
     509        Pallete         = true;
     510        Icon            = "icon/SectionColumn";
     511        Brief   = "Model of a column section.";
     512        Info            =
     513"== Model of a column section containing ==
     514* NumberOfTrays TRAYS.
     515* Two Feed Inlets.
     516       
     517== Specify ==
     518* the feed stream of each tray (Inlet);
     519* the Murphree eficiency for each tray Emv;
     520* the InletLiquid stream of the top tray;
     521* the InletVapour stream of the bottom tray.
     522       
     523== Initial Conditions ==
     524* the TRAYS temperature (OutletLiquid.T);
     525* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
     526* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
     527";
     528
     529SET
     530        NumberOfFeeds = 2;
     531
     532VARIABLES
     533       
     534        in      FeedTrayOne     as stream               (Brief="Feed stream", PosX=0, PosY=0.45);
     535        in      FeedTrayTwo     as stream               (Brief="Feed stream", PosX=0, PosY=0.65);
     536
     537EQUATIONS
     538
     539for i in 1:NumberOfTrays do
     540
     541if   i equal FeedTrayLocation(1) then   
     542
     543"FeedTrayTop Inlet Flow"       
     544        FeedTrayOne.F= TRAYS(i).Inlet.F;
     545
     546"FeedTrayTop Inlet Temperature"
     547        FeedTrayOne.T = TRAYS(i).Inlet.T;
     548
     549"FeedTrayTop Inlet Pressure"
     550        FeedTrayOne.P = TRAYS(i).Inlet.P;
     551
     552"FeedTrayTop Inlet Composition"
     553        FeedTrayOne.z = TRAYS(i).Inlet.z;
     554
     555"FeedTrayTop Inlet Vapour Fraction"
     556        FeedTrayOne.v = TRAYS(i).Inlet.v;
     557
     558"FeedTrayTop Inlet Enthalpy"
     559        FeedTrayOne.h = TRAYS(i).Inlet.h;
     560
     561else if   i equal FeedTrayLocation(2) then   
     562
     563"FeedTrayBottom Inlet Flow"     
     564        FeedTrayTwo.F= TRAYS(i).Inlet.F;
     565
     566"FeedTrayBottom Inlet Temperature"
     567        FeedTrayTwo.T = TRAYS(i).Inlet.T;
     568
     569"FeedTrayBottom Inlet Pressure"
     570        FeedTrayTwo.P = TRAYS(i).Inlet.P;
     571
     572"FeedTrayBottom Inlet Composition"
     573        FeedTrayTwo.z = TRAYS(i).Inlet.z;
     574
     575"FeedTrayBottom Inlet Vapour Fraction"
     576        FeedTrayTwo.v = TRAYS(i).Inlet.v;
     577
     578"FeedTrayBottom Inlet Enthalpy"
     579        FeedTrayTwo.h = TRAYS(i).Inlet.h;
     580
     581else
     582
     583"Inlet Tray - Flow Sealed"     
     584        0*'mol/h'= TRAYS(i).Inlet.F;
     585
     586"Inlet Tray -  Temperature"
     587        FeedTrayTwo.T = TRAYS(i).Inlet.T;
     588
     589"Inlet Tray -  Pressure"
     590        FeedTrayTwo.P = TRAYS(i).Inlet.P;
     591
     592"Inlet Tray -  Composition"
     593        FeedTrayTwo.z = TRAYS(i).Inlet.z;
     594
     595"Inlet Tray -  Vapour Fraction"
     596        FeedTrayTwo.v = TRAYS(i).Inlet.v;
     597
     598"Inlet Tray -  Enthalpy"
     599        FeedTrayTwo.h = TRAYS(i).Inlet.h;
     600
     601end
     602
     603end
     604
     605end
     606
     607end
     608
     609Model Section_Column3   as SectionColumnBasic
     610
     611ATTRIBUTES
     612        Pallete         = true;
     613        Icon            = "icon/SectionColumn";
     614        Brief   = "Model of a column section.";
     615        Info            =
     616"== Model of a column section containing ==
     617* NumberOfTrays TRAYS.
     618* Three Feed Inlets.
     619       
     620== Specify ==
     621* the feed stream of each tray (Inlet);
     622* the Murphree eficiency for each tray Emv;
     623* the InletLiquid stream of the top tray;
     624* the InletVapour stream of the bottom tray.
     625       
     626== Initial Conditions ==
     627* the TRAYS temperature (OutletLiquid.T);
     628* the TRAYS liquid level (Level) OR the TRAYS liquid flow (OutletLiquid.F);
     629* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
     630";
     631
     632SET
     633        NumberOfFeeds = 3;
     634
     635VARIABLES
     636       
     637        in      FeedTrayOne     as stream               (Brief="Feed stream", PosX=0, PosY=0.45);
     638        in      FeedTrayTwo     as stream               (Brief="Feed stream", PosX=0, PosY=0.65);
     639        in      FeedTrayThree   as stream               (Brief="Feed stream", PosX=0, PosY=0.85);
     640
     641EQUATIONS
     642
     643for i in 1:NumberOfTrays do
     644
     645if   i equal FeedTrayLocation(1) then   
     646
     647"FeedTrayTop Inlet Flow"       
     648        FeedTrayOne.F= TRAYS(i).Inlet.F;
     649
     650"FeedTrayTop Inlet Temperature"
     651        FeedTrayOne.T = TRAYS(i).Inlet.T;
     652
     653"FeedTrayTop Inlet Pressure"
     654        FeedTrayOne.P = TRAYS(i).Inlet.P;
     655
     656"FeedTrayTop Inlet Composition"
     657        FeedTrayOne.z = TRAYS(i).Inlet.z;
     658
     659"FeedTrayTop Inlet Vapour Fraction"
     660        FeedTrayOne.v = TRAYS(i).Inlet.v;
     661
     662"FeedTrayTop Inlet Enthalpy"
     663        FeedTrayOne.h = TRAYS(i).Inlet.h;
     664
     665else if   i equal FeedTrayLocation(2) then   
     666
     667"FeedTrayBottom Inlet Flow"     
     668        FeedTrayTwo.F= TRAYS(i).Inlet.F;
     669
     670"FeedTrayBottom Inlet Temperature"
     671        FeedTrayTwo.T = TRAYS(i).Inlet.T;
     672
     673"FeedTrayBottom Inlet Pressure"
     674        FeedTrayTwo.P = TRAYS(i).Inlet.P;
     675
     676"FeedTrayBottom Inlet Composition"
     677        FeedTrayTwo.z = TRAYS(i).Inlet.z;
     678
     679"FeedTrayBottom Inlet Vapour Fraction"
     680        FeedTrayTwo.v = TRAYS(i).Inlet.v;
     681
     682"FeedTrayBottom Inlet Enthalpy"
     683        FeedTrayTwo.h = TRAYS(i).Inlet.h;
     684
     685else if   i equal FeedTrayLocation(3) then   
     686
     687"FeedTrayBottom Inlet Flow"     
     688        FeedTrayThree.F= TRAYS(i).Inlet.F;
     689
     690"FeedTrayBottom Inlet Temperature"
     691        FeedTrayThree.T = TRAYS(i).Inlet.T;
     692
     693"FeedTrayBottom Inlet Pressure"
     694        FeedTrayThree.P = TRAYS(i).Inlet.P;
     695
     696"FeedTrayBottom Inlet Composition"
     697        FeedTrayThree.z = TRAYS(i).Inlet.z;
     698
     699"FeedTrayBottom Inlet Vapour Fraction"
     700        FeedTrayThree.v = TRAYS(i).Inlet.v;
     701
     702"FeedTrayBottom Inlet Enthalpy"
     703        FeedTrayThree.h = TRAYS(i).Inlet.h;
     704
     705else
     706
     707"Inlet Tray - Flow Sealed"     
     708        0*'mol/h'= TRAYS(i).Inlet.F;
     709
     710"Inlet Tray -  Temperature"
     711        FeedTrayTwo.T = TRAYS(i).Inlet.T;
     712
     713"Inlet Tray -  Pressure"
     714        FeedTrayTwo.P = TRAYS(i).Inlet.P;
     715
     716"Inlet Tray -  Composition"
     717        FeedTrayTwo.z = TRAYS(i).Inlet.z;
     718
     719"Inlet Tray -  Vapour Fraction"
     720        FeedTrayTwo.v = TRAYS(i).Inlet.v;
     721
     722"Inlet Tray -  Enthalpy"
     723        FeedTrayTwo.h = TRAYS(i).Inlet.h;
     724
     725end
     726
     727end
     728
     729end
     730
     731end
     732
     733end
     734
     735
     736Model ColumnBasic
     737
     738ATTRIBUTES
     739        Pallete = false;
     740        Brief   = "Model of a basic column.";
     741        Info    =
     742"Model of a basic column containing a vetor of TRAYS numbered from the top-down.";
     743
     744PARAMETERS
     745        outer PP                as Plugin       (Brief="External Physical Properties", Type="PP");
     746        outer NComp     as Integer      (Brief="Number of components");
     747
     748        NumberOfFeeds                                           as Integer                      (Brief="Number of Feed Trays",Default=3,Protected=true);
     749        FeedTrayLocation(NumberOfFeeds)         as Integer                      (Brief="Feed tray Location",Default=2);
     750        NumberOfTrays                                           as Integer                      (Brief="Number of trays", Default=8);
     751        LiqSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Liquid Side Tray Index", Default=0,Hidden=true);
     752        VapSideTrayIndex(NumberOfTrays)         as Integer                      (Brief="Vapour Side Tray Index", Default=0,Hidden=true);
     753        LiquidSideStreamLocation                        as Integer                      (Brief="Liquid Side Stream Location", Default=2);
     754        VapourSideStreamLocation                        as Integer                      (Brief="Vapour Side Stream Location", Default=2);
     755        g                                                                       as acceleration         (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
     756        Mw(NComp)                                                       as molweight            (Brief="Component Mol Weight",Hidden=true);
     757
     758        VapourFlowModel         as Switcher     (Valid = ["Reepmeyer", "Feehery_Fv", "Roffel_Fv", "Klingberg", "Wang_Fv", "Elgue"], Default = "Reepmeyer");
     759        LiquidFlowModel         as Switcher     (Valid = ["default", "Wang_Fl", "Olsen", "Feehery_Fl", "Roffel_Fl"], Default = "default");
     760
    123761        VolumeOfTray            as volume               (Brief="Total Volume of the tray");
    124762        HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
     
    127765        WeirLength                      as length               (Brief="Weir length");
    128766        WeirHeight                      as length               (Brief="Weir height");
     767        TrayLiquidPasses        as Real                 (Brief="Number of liquid passes in the tray", Default=1);
     768       
    129769        FeeheryCoeff            as Real                 (Brief="Feeherys correlation coefficient", Unit='1/m^4', Default=1,Hidden=true);
    130770        ElgueCoeff                      as Real                 (Brief="Elgues correlation coefficient", Unit='kg/m/mol^2', Default=1,Hidden=true);
    131771        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);
    133772       
    134773        V                               as volume               (Brief="Total Volume of the tray",Hidden=true);
     
    165804
    166805VARIABLES
    167 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    168 # Tray Initialization For the Whole Column Section
    169 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     806
    170807        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);
     808        CONTROL                 as ControlSection (Brief = "Control");
     809       
     810        out     TCI as control_signal   (Brief="Temperature  Indicator", Protected = true, PosX=1, PosY=0.55);
     811        out     PCI as control_signal   (Brief="Pressure Indicator", Protected = true, PosX=0, PosY=0.23);
    185812       
    186813        TRAYS(NumberOfTrays)    as tray                 (Brief="Number of trays in the Column Section");
     
    189816        MurphreeEff                     as Real                 (Brief="Murphree efficiency for All Trays",Lower=0.01,Upper=1);
    190817
    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);
     818        out     VapourDrawOff   as vapour_stream        (Brief="Vapour Outlet in the section", PosX=1, PosY=0.388,Protected = true);
     819        out     LiquidDrawOff   as liquid_stream        (Brief="Liquid Outlet in the section", PosX=1, PosY=0.47,Protected = true);
     820
    199821CONNECTIONS
    200 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    201 # Connecting Intermediate Trays
    202 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     822
     823#Connecting Intermediate Trays
    203824        TRAYS([2:NumberOfTrays]).OutletVapour   to TRAYS([1:NumberOfTrays-1]).InletVapour;
    204825        TRAYS([1:NumberOfTrays-1]).OutletLiquid         to TRAYS([2:NumberOfTrays]).InletLiquid;
    205826       
    206 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    207 # Connecting Connectors
    208 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    209     LiquidConnector to TRAYS(1).InletLiquid;
    210     VapourConnector to TRAYS(NumberOfTrays).InletVapour;
    211        
    212827INITIAL
    213 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    214 # Tray Initialization
    215 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     828
    216829for i in 1:NumberOfTrays do
    217830
     
    234847
    235848EQUATIONS
    236 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    237 # Control Ports
    238 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    239 
     849
     850        VapourDrawOff.F*VapSideTrayIndex= TRAYS.VapourSideStream.F;
     851        VapourDrawOff.T = TRAYS(VapourSideStreamLocation).VapourSideStream.T;
     852        VapourDrawOff.P = TRAYS(VapourSideStreamLocation).VapourSideStream.P;
     853        VapourDrawOff.z = TRAYS(VapourSideStreamLocation).VapourSideStream.z;
     854
     855        LiquidDrawOff.F*LiqSideTrayIndex= TRAYS.LiquidSideStream.F;
     856        LiquidDrawOff.T = TRAYS(LiquidSideStreamLocation).LiquidSideStream.T;
     857        LiquidDrawOff.P = TRAYS(LiquidSideStreamLocation).LiquidSideStream.P;
     858        LiquidDrawOff.z = TRAYS(LiquidSideStreamLocation).LiquidSideStream.z;
     859
     860        VapourDrawOffFlow = VapourDrawOff.F;
     861        LiquidDrawOffFlow = LiquidDrawOff.F;
     862       
    240863"Tray Temperature Indicator"   
    241864        #TCI*'K' = TRAYS(min([NumberOfTrays, CONTROL.Tindicator_TrayNumber])).OutletVapour.T;
     
    245868        #PCI*'atm' = TRAYS(min([NumberOfTrays, CONTROL.Pindicator_TrayNumber])).OutletVapour.P;
    246869        PCI*'atm' = TRAYS(CONTROL.Pindicator_TrayNumber).OutletVapour.P;
    247 
    248 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    249 # Trays Equations
    250 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    251870
    252871for i in [1:NumberOfTrays] do
     
    326945end
    327946
    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 
    431 end
    432 
    433 Model Section_Column    as SectionColumnBasic
    434 
    435 ATTRIBUTES
    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 
    456 SET
    457         NumberOfFeeds = 1;
    458 
    459 VARIABLES
    460        
    461         in      FeedTray        as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
    462 
    463 EQUATIONS
    464 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    465 # Equating Feed Tray Variables to Trays Variables
    466 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    467 for i in 1:NumberOfTrays do
    468 
    469 if   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 
    489 else
    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 
    509 end
    510 
    511 end
    512 
    513 end
    514 
    515 Model Section_Column2   as SectionColumnBasic
    516 
    517 ATTRIBUTES
    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 
    538 SET
    539         NumberOfFeeds = 2;
    540 
    541 VARIABLES
    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 
    546 EQUATIONS
    547 
    548 for i in 1:NumberOfTrays do
    549 
    550 if   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 
    570 else 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 
    590 else
    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 
    610 end
    611 
    612 end
    613 
    614 end
    615 
    616 end
    617 
    618 Model Section_Column3   as SectionColumnBasic
    619 
    620 ATTRIBUTES
    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 
    641 SET
    642         NumberOfFeeds = 3;
    643 
    644 VARIABLES
    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 
    650 EQUATIONS
    651 
    652 for i in 1:NumberOfTrays do
    653 
    654 if   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 
    674 else 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 
    694 else 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 
    714 else
    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 
    734 end
    735 
    736 end
    737 
    738 end
    739 
    740 end
    741 
    742 end
    743 
    744 
    745 Model ColumnBasic
    746 
    747 ATTRIBUTES
    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 
    753 PARAMETERS
    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 
    798 SET
    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 
    814 VARIABLES
    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 
    830 CONNECTIONS
    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        
    836 INITIAL
    837 
    838 for 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;
    845 end
    846 
    847 for i in 1:NComp-1 do
    848 
    849 for 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));
    853 end
    854 
    855 end
    856 
    857 EQUATIONS
    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 
    880 for 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 
    898 switch 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        
    926 switch 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 
    954 end
    955 
    956947end
    957948
Note: See TracChangeset for help on using the changeset viewer.