Changeset 6 for mso/eml


Ignore:
Timestamp:
Jun 29, 2006, 5:28:01 PM (16 years ago)
Author:
Paula Bettio Staudt
Message:

Fixed problems in colum.mso

File:
1 edited

Legend:

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

    r1 r6  
    2121using "condenser";
    2222using "mixers_splitters/splitter";
     23using "mixers_splitters/mixer";
    2324using "tank";
    2425using "pressure_changers/pump";
     
    3435ext NComp as Integer;
    3536        NTrays as Integer(Brief="Number of trays", Default=2);
    36        
    37         VARIABLES
    38         trays(NTrays) as tray;
    39 
    40         EQUATIONS
    41         "Pressure Drop through the tray"
    42         trays([1:NTrays]).OutletV.F = (1 + tanh(1 * (trays([1:NTrays]).OutletV.P - trays([1:NTrays]).InletL.P)))/2 *
    43                 trays([1:NTrays]).Ah/trays([1:NTrays]).vV * sqrt(2*(trays([1:NTrays]).OutletV.P -
    44                 trays([1:NTrays]).InletL.P + 1e-8 * "atm") / (trays([1:NTrays]).alfa*trays([1:NTrays]).rhoV));
    45        
    46         CONNECTIONS
    47         trays([2:NTrays]).OutletV to trays([1:NTrays-1]).InletV;
    48         trays([1:NTrays-1]).OutletL to trays([2:NTrays]).InletL;
     37        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
     38        top as Integer(Brief="Number of top tray");
     39        bot as Integer(Brief="Number of bottom tray");
     40
     41        SET
     42        top = (NTrays-1)*(1-topdown)/2+1;
     43        bot = NTrays/top;
     44       
     45        VARIABLES
     46        trays(NTrays) as tray;
     47
     48        EQUATIONS
     49        "Pressure Drop through the tray"
     50        trays([top:topdown:bot]).OutletV.F = (1 + tanh(1 *
     51            (trays([top:topdown:bot]).OutletV.P -
     52            trays([top:topdown:bot]).InletL.P)))/2 *
     53            trays([top:topdown:bot]).Ah/trays([top:topdown:bot]).vV *
     54            sqrt(2*(trays([top:topdown:bot]).OutletV.P -
     55                trays([top:topdown:bot]).InletL.P + 1e-8 * "atm") /
     56            (trays([top:topdown:bot]).alfa*trays([top:topdown:bot]).rhoV));
     57
     58        CONNECTIONS
     59        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
     60        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
    4961end
    5062
     
    6375ext NComp as Integer;
    6476        NTrays as Integer(Brief="Number of trays", Default=2);
     77        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
     78        top as Integer(Brief="Number of top tray");
     79        bot as Integer(Brief="Number of bottom tray");
     80
     81        SET
     82        top = (NTrays-1)*(1-topdown)/2+1;
     83        bot = NTrays/top;
    6584       
    6685        VARIABLES
     
    6887        cond as condenser;
    6988        reb as reboiler;
    70         sp as splitter;
     89        sptop as splitter;
    7190        pump1 as pump;
    7291
    7392        EQUATIONS
    7493        if (reb.OutletV.P > reb.InletL.P) then
    75                 "Pressure Drop through the tray"
    76                 reb.OutletV.F = 34803 * "mm^2"/reb.vV * sqrt((reb.OutletV.P - trays(NTrays).OutletL.P)
    77                                 / (1.3*reb.rhoV) ); # para o modelo com 25 pratos, o beta do refervedor é 0.8. Para a coluna com 80, o beta é:1.3
     94                "Pressure Drop through the reboiler"
     95                reb.OutletV.F = trays(bot).Ah/reb.vV * sqrt((reb.OutletV.P - trays(bot).OutletL.P)
     96                                / (trays(bot).beta*reb.rhoV) );
    7897        else
    79                 "Prato selado"
     98                "No flow in reboiler"
    8099                reb.OutletV.F = 0.0 * "mol/s";
    81100        end
    82101
    83102        "Pressure Drop through the tray"
    84         trays(1).OutletV.F = (1 + tanh(1 * (trays(1).OutletV.P - cond.OutletL.P)))/2 *
    85                 trays(1).Ah/trays(1).vV * sqrt(2*(trays(1).OutletV.P -
    86                 cond.OutletL.P + 1e-8 * "atm") / (trays(1).alfa*trays(1).rhoV));
     103        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - cond.OutletL.P)))/2 *
     104                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
     105                cond.OutletL.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
    87106               
    88         trays([2:NTrays]).OutletV.F = (1 + tanh(1 * (trays([2:NTrays]).OutletV.P - trays([2:NTrays]).InletL.P)))/2 *
    89                 trays([2:NTrays]).Ah/trays([2:NTrays]).vV * sqrt(2*(trays([2:NTrays]).OutletV.P -
    90                 trays([2:NTrays]).InletL.P + 1e-8 * "atm") / (trays([2:NTrays]).alfa*trays([2:NTrays]).rhoV));
    91        
    92         CONNECTIONS
    93         #vapor
    94         reb.OutletV to trays([NTrays]).InletV;
    95         trays([2:NTrays]).OutletV to trays([1:NTrays-1]).InletV;
    96         trays(1).OutletV to cond.InletV;
    97 
    98         #liquid
    99         cond.OutletL to sp.Inlet;       
    100         sp.Outlet2 to pump1.Inlet;
    101         pump1.Outlet to trays(1).InletL;
    102         trays([1:NTrays-1]).OutletL to trays([2:NTrays]).InletL;
    103         trays(NTrays).OutletL to reb.InletL;
     107        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
     108            (trays([top+topdown:topdown:bot]).OutletV.P -
     109            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
     110            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
     111            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     112                trays([top+topdown:topdown:bot]).InletL.P + 1e-8 * "atm") /
     113            (trays([top+topdown:topdown:bot]).alfa*trays([top+topdown:topdown:bot]).rhoV));
     114
     115        CONNECTIONS
     116        #vapor
     117        reb.OutletV to trays(bot).InletV;
     118        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
     119        trays(top).OutletV to cond.InletV;
     120       
     121        #liquid
     122        cond.OutletL to sptop.Inlet;   
     123        sptop.Outlet2 to pump1.Inlet;
     124        pump1.Outlet to trays(top).InletL;
     125        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
     126        trays(bot).OutletL to reb.InletL;
    104127end
    105128
     
    123146ext NComp as Integer;
    124147        NTrays as Integer(Brief="Number of trays", Default=2);
     148        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
     149        top as Integer(Brief="Number of top tray");
     150        bot as Integer(Brief="Number of bottom tray");
     151
     152        SET
     153        top = (NTrays-1)*(1-topdown)/2+1;
     154        bot = NTrays/top;
    125155       
    126156        VARIABLES
     
    136166        EQUATIONS
    137167        if (reb.OutletV.P > reb.InletL.P) then
    138                 "Pressure Drop through the tray"
    139                 reb.OutletV.F = 34803 * "mm^2"/reb.vV * sqrt((reb.OutletV.P - trays(NTrays).OutletL.P)
    140                                 / (1.3*reb.rhoV) ); # para o modelo com 25 pratos, o beta do refervedor é 0.8. Para a coluna com 80, o beta é:1.3
     168                "Pressure Drop through the reboiler"
     169                reb.OutletV.F = trays(bot).Ah/reb.vV * sqrt((reb.OutletV.P - trays(bot).OutletL.P)
     170                                / (trays(bot).beta*reb.rhoV) );
    141171        else
    142                 "Prato selado"
     172                "No flow in reboiler"
    143173                reb.OutletV.F = 0.0 * "mol/s";
    144174        end
    145175
    146176        "Pressure Drop through the tray"
    147         trays(1).OutletV.F = (1 + tanh(1 * (trays(1).OutletV.P - ttop.Outlet.P)))/2 *
    148                 trays(1).Ah/trays(1).vV * sqrt(2*(trays(1).OutletV.P -
    149                 ttop.Outlet.P + 1e-8 * "atm") / (trays(1).alfa*trays(1).rhoV));
     177        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - ttop.Outlet.P)))/2 *
     178                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
     179                ttop.Outlet.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
    150180               
    151         trays([2:NTrays]).OutletV.F = (1 + tanh(1 * (trays([2:NTrays]).OutletV.P - trays([2:NTrays]).InletL.P)))/2 *
    152                 trays([2:NTrays]).Ah/trays([2:NTrays]).vV * sqrt(2*(trays([2:NTrays]).OutletV.P -
    153                 trays([2:NTrays]).InletL.P + 1e-8 * "atm") / (trays([2:NTrays]).alfa*trays([2:NTrays]).rhoV));
    154        
    155         CONNECTIONS
    156         #vapor
    157         reb.OutletV to trays(NTrays).InletV;
    158         trays([2:NTrays]).OutletV to trays([1:NTrays-1]).InletV;
    159         trays(1).OutletV to cond.InletV;
    160        
    161         #liquid
    162         cond.OutletL to ttop.Inlet;
    163         ttop.Outlet to sptop.Inlet;     
    164         sptop.Outlet2 to pump1.Inlet;
    165         pump1.Outlet to trays(1).InletL;
    166         trays([1:NTrays-1]).OutletL to trays([2:NTrays]).InletL;
    167         trays(NTrays).OutletL to tbottom.Inlet;
     181        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
     182            (trays([top+topdown:topdown:bot]).OutletV.P -
     183            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
     184            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
     185            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     186                trays([top+topdown:topdown:bot]).InletL.P + 1e-8 * "atm") /
     187            (trays([top+topdown:topdown:bot]).alfa*trays([top+topdown:topdown:bot]).rhoV));
     188       
     189        CONNECTIONS
     190        #vapor
     191        reb.OutletV to trays(bot).InletV;
     192        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
     193        trays(top).OutletV to cond.InletV;
     194       
     195        #liquid
     196        cond.OutletL to ttop.Inlet;     
     197        ttop.Outlet to sptop.Inlet;
     198        sptop.Outlet2 to pump1.Inlet;   
     199        pump1.Outlet to trays(top).InletL;
     200        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
     201        trays(bot).OutletL to tbottom.Inlet;
    168202        tbottom.Outlet to spbottom.Inlet;
    169203        spbottom.Outlet2 to reb.InletL;
     
    188222ext NComp as Integer;
    189223        NTrays as Integer(Brief="Number of trays", Default=2);
     224        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
     225        top as Integer(Brief="Number of top tray");
     226        bot as Integer(Brief="Number of bottom tray");
     227
     228        SET
     229        top = (NTrays-1)*(1-topdown)/2+1;
     230        bot = NTrays/top;
    190231       
    191232        VARIABLES
     
    200241        EQUATIONS
    201242        if (reb.OutletV.P > reb.InletL.P) then
    202                 "Pressure Drop through the tray"
    203                 reb.OutletV.F = 34803 * "mm^2"/reb.vV * sqrt((reb.OutletV.P - trays(NTrays).OutletL.P)
    204                                 / (1.3*reb.rhoV) ); # para o modelo com 25 pratos, o beta do refervedor é 0.8. Para a coluna com 80, o beta é:1.3
     243                "Pressure Drop through the reboiler"
     244                reb.OutletV.F = trays(bot).Ah/reb.vV * sqrt((reb.OutletV.P - trays(bot).OutletL.P)
     245                                / (trays(bot).beta*reb.rhoV) );
    205246        else
    206                 "Prato selado"
     247                "No flow in reboiler"
    207248                reb.OutletV.F = 0.0 * "mol/s";
    208249        end
    209250
    210251        "Pressure Drop through the tray"
    211         trays(1).OutletV.F = (1 + tanh(1 * (trays(1).OutletV.P - cond.OutletL.P)))/2 *
    212                 trays(1).Ah/trays(1).vV * sqrt(2*(trays(1).OutletV.P -
    213                 cond.OutletL.P + 1e-8 * "atm") / (trays(1).alfa*trays(1).rhoV));
     252        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - cond.OutletL.P)))/2 *
     253                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
     254                cond.OutletL.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
    214255               
    215         trays([2:NTrays]).OutletV.F = (1 + tanh(1 * (trays([2:NTrays]).OutletV.P - trays([2:NTrays]).InletL.P)))/2 *
    216                 trays([2:NTrays]).Ah/trays([2:NTrays]).vV * sqrt(2*(trays([2:NTrays]).OutletV.P -
    217                 trays([2:NTrays]).InletL.P + 1e-8 * "atm") / (trays([2:NTrays]).alfa*trays([2:NTrays]).rhoV));
     256        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
     257            (trays([top+topdown:topdown:bot]).OutletV.P -
     258            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
     259            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
     260            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     261                trays([top+topdown:topdown:bot]).InletL.P + 1e-8 * "atm") /
     262            (trays([top+topdown:topdown:bot]).alfa*trays([top+topdown:topdown:bot]).rhoV));
    218263                       
    219264        CONNECTIONS
    220265        #vapor
    221         reb.OutletV to trays(NTrays).InletV;
    222         trays([2:NTrays]).OutletV to trays([1:NTrays-1]).InletV;
    223         trays(1).OutletV to cond.InletV;
     266        reb.OutletV to trays(bot).InletV;
     267        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
     268        trays(top).OutletV to cond.InletV;
    224269       
    225270        #liquid
    226271        cond.OutletL to sptop.Inlet;   
    227272        sptop.Outlet2 to pump1.Inlet;
    228         pump1.Outlet to trays(1).InletL;
    229         trays([1:NTrays-1]).OutletL to trays([2:NTrays]).InletL;
    230         trays(NTrays).OutletL to tbottom.Inlet;
     273        pump1.Outlet to trays(top).InletL;
     274        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
     275        trays(bot).OutletL to tbottom.Inlet;
     276        tbottom.Outlet to spbottom.Inlet;
     277        spbottom.Outlet2 to reb.InletL;
     278end
     279
     280
     281#* -------------------------------------------------------------------
     282* Distillation Column model with:
     283*
     284*       - NTrays like tray;
     285*       - a vessel in the bottom of column;
     286*       - a splitter who separate the bottom product and the stream to reboiler;
     287*       - steady state reboiler (thermosyphon) with partial vaporization;
     288*       - a dynamic condenser without subcooling;
     289*       - a splitter which separate reflux and distillate;
     290*       - a pump in reflux stream.
     291*
     292* ------------------------------------------------------------------*#
     293Model Distillation_thermosyphon_partial_cond
     294        PARAMETERS
     295ext PP as CalcObject;
     296ext NComp as Integer;
     297        NTrays as Integer(Brief="Number of trays", Default=2);
     298        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
     299        top as Integer(Brief="Number of top tray");
     300        bot as Integer(Brief="Number of bottom tray");
     301
     302        SET
     303        top = (NTrays-1)*(1-topdown)/2+1;
     304        bot = NTrays/top;
     305
     306        VARIABLES
     307        trays(NTrays) as tray;
     308        cond as condenser;
     309        reb as reboilerSteady_partial;
     310        mix as mixer_phase;
     311        tbottom as tank;
     312        spbottom as splitter;
     313        sptop as splitter;
     314        pump1 as pump;
     315
     316        SET
     317        mix.Npres = 1;
     318
     319        EQUATIONS
     320
     321        if (reb.OutletV.P > reb.InletL.P) then
     322                "Pressure Drop through the reboiler"
     323                reb.InletL.F = trays(bot).Ah/reb.vV * sqrt((reb.OutletV.P - trays(bot).OutletL.P)
     324                                / (trays(bot).beta*reb.rho) );
     325        else
     326                "No flow in reboiler"
     327                reb.InletL.F = 0.0 * "mol/s";
     328        end
     329
     330        if trays(1).vV > 0 then
     331                "Pressure Drop through the tray"
     332                trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - cond.OutletL.P)))/2 *
     333                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
     334                cond.OutletL.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
     335        else
     336                "Pressure Drop through the tray"
     337                trays(top).OutletV.F = 0;
     338        end
     339       
     340        for i in [top+topdown:topdown:bot]
     341                if trays(i).vV > 0 then
     342                        trays(i).OutletV.F = (1 + tanh(1 * (trays(i).OutletV.P - trays(i).InletL.P)))/2 *
     343                        trays(i).Ah/trays(i).vV * sqrt(2*(trays(i).OutletV.P -
     344                        trays(i).InletL.P + 1e-8 * "atm") / (trays(i).alfa*trays(i).rhoV));
     345                else
     346                        trays(i).OutletV.F = 0;
     347                end
     348        end
     349       
     350        CONNECTIONS
     351        #vapor
     352        reb.OutletV to trays(bot).InletV;
     353        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
     354        trays(top).OutletV to cond.InletV;
     355       
     356        #liquid
     357        cond.OutletL to sptop.Inlet;   
     358        sptop.Outlet2 to pump1.Inlet;
     359        pump1.Outlet to trays(top).InletL;
     360        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
     361#       trays(bot).OutletL to tbottom.Inlet;
     362        trays(bot).OutletL to mix.Inlet_mixer(1);
     363        reb.OutletL to mix.Inlet_mixer(2);
     364        mix.Outlet to tbottom.Inlet;
    231365        tbottom.Outlet to spbottom.Inlet;
    232366        spbottom.Outlet2 to reb.InletL;
     
    250384ext NComp as Integer;
    251385        NTrays as Integer(Brief="Number of trays", Default=2);
     386        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
     387        top as Integer(Brief="Number of top tray");
     388        bot as Integer(Brief="Number of bottom tray");
     389
     390        SET
     391        top = (NTrays-1)*(1-topdown)/2+1;
     392        bot = NTrays/top;
    252393       
    253394        VARIABLES
     
    261402        EQUATIONS
    262403        if (reb.OutletV.P > reb.InletL.P) then
    263                 "Pressure Drop through the tray"
    264                 reb.OutletV.F = 34803 * "mm^2"/reb.vV * sqrt((reb.OutletV.P - trays(NTrays).OutletL.P)
    265                                 / (1.3*reb.rhoV) ); # para o modelo com 25 pratos, o beta do refervedor é 0.8. Para a coluna com 80, o beta é:1.3
     404                "Pressure Drop through the reboiler"
     405                reb.OutletV.F = trays(bot).Ah/reb.vV * sqrt((reb.OutletV.P - trays(bot).OutletL.P)
     406                                / (trays(bot).beta*reb.rhoV) );
    266407        else
    267                 "Prato selado"
     408                "No flow in reboiler"
    268409                reb.OutletV.F = 0.0 * "mol/s";
    269410        end
    270411
    271412        "Pressure Drop through the tray"
    272         trays(1).OutletV.F = (1 + tanh(1 * (trays(1).OutletV.P - ttop.Outlet.P)))/2 *
    273                 trays(1).Ah/trays(1).vV * sqrt(2*(trays(1).OutletV.P -
    274                 ttop.Outlet.P + 1e-8 * "atm") / (trays(1).alfa*trays(1).rhoV));
     413        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - ttop.Outlet.P)))/2 *
     414                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
     415                ttop.Outlet.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
    275416               
    276         trays([2:NTrays]).OutletV.F = (1 + tanh(1 * (trays([2:NTrays]).OutletV.P - trays([2:NTrays]).InletL.P)))/2 *
    277                 trays([2:NTrays]).Ah/trays([2:NTrays]).vV * sqrt(2*(trays([2:NTrays]).OutletV.P -
    278                 trays([2:NTrays]).InletL.P + 1e-8 * "atm") / (trays([2:NTrays]).alfa*trays([2:NTrays]).rhoV));
    279        
    280         CONNECTIONS
    281         #vapor
    282         reb.OutletV to trays(NTrays).InletV;
    283         trays([2:NTrays]).OutletV to trays([1:NTrays-1]).InletV;
    284         trays(1).OutletV to cond.InletV;
    285        
    286         #liquid
    287         cond.OutletL to ttop.Inlet;
    288         ttop.Outlet to sptop.Inlet;     
    289         sptop.Outlet2 to pump1.Inlet;
    290         pump1.Outlet to trays(1).InletL;
    291         trays([1:NTrays-1]).OutletL to trays([2:NTrays]).InletL;
    292         trays(NTrays).OutletL to reb.InletL;
     417        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
     418            (trays([top+topdown:topdown:bot]).OutletV.P -
     419            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
     420            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
     421            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     422                trays([top+topdown:topdown:bot]).InletL.P + 1e-8 * "atm") /
     423            (trays([top+topdown:topdown:bot]).alfa*trays([top+topdown:topdown:bot]).rhoV));
     424       
     425        CONNECTIONS
     426        #vapor
     427        reb.OutletV to trays(bot).InletV;
     428        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
     429        trays(top).OutletV to cond.InletV;
     430       
     431        #liquid
     432        cond.OutletL to ttop.Inlet;     
     433        ttop.Outlet to sptop.Inlet;
     434        sptop.Outlet2 to pump1.Inlet;   
     435        pump1.Outlet to trays(top).InletL;
     436        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
     437        trays(bot).OutletL to reb.InletL;
    293438end
    294439
     
    306451ext NComp as Integer;
    307452        NTrays as Integer(Brief="Number of trays", Default=2);
     453        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
     454        top as Integer(Brief="Number of top tray");
     455        bot as Integer(Brief="Number of bottom tray");
     456
     457        SET
     458        top = (NTrays-1)*(1-topdown)/2+1;
     459        bot = NTrays/top;
    308460       
    309461        VARIABLES
    310462        trays(NTrays) as tray;
    311463        cond as condenser;
    312         sp as splitter;
     464        sptop as splitter;
    313465        pump1 as pump;
    314466
    315467        EQUATIONS
    316468        "Pressure Drop through the tray"
    317         trays(1).OutletV.F = (1 + tanh(1 * (trays(1).OutletV.P - cond.OutletL.P)))/2 *
    318                 trays(1).Ah/trays(1).vV * sqrt(2*(trays(1).OutletV.P -
    319                 cond.OutletL.P + 1e-8 * "atm") / (trays(1).alfa*trays(1).rhoV));
     469        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - cond.OutletL.P)))/2 *
     470                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
     471                cond.OutletL.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
    320472               
    321         trays([2:NTrays]).OutletV.F = (1 + tanh(1 * (trays([2:NTrays]).OutletV.P - trays([2:NTrays]).InletL.P)))/2 *
    322                 trays([2:NTrays]).Ah/trays([2:NTrays]).vV * sqrt(2*(trays([2:NTrays]).OutletV.P -
    323                 trays([2:NTrays]).InletL.P + 1e-8 * "atm") / (trays([2:NTrays]).alfa*trays([2:NTrays]).rhoV));
    324        
    325         CONNECTIONS
    326         #vapor
    327         trays([2:NTrays]).OutletV to trays([1:NTrays-1]).InletV;
    328         trays(1).OutletV to cond.InletV;
    329 
    330         #liquid
    331         cond.OutletL to sp.Inlet;       
    332         sp.Outlet2 to pump1.Inlet;
    333         pump1.Outlet to trays(1).InletL;
    334         trays([1:NTrays-1]).OutletL to trays([2:NTrays]).InletL;
     473        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
     474            (trays([top+topdown:topdown:bot]).OutletV.P -
     475            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
     476            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
     477            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     478                trays([top+topdown:topdown:bot]).InletL.P + 1e-8 * "atm") /
     479            (trays([top+topdown:topdown:bot]).alfa*trays([top+topdown:topdown:bot]).rhoV));
     480       
     481        CONNECTIONS
     482        #vapor
     483        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
     484        trays(top).OutletV to cond.InletV;
     485       
     486        #liquid
     487        cond.OutletL to sptop.Inlet;   
     488        sptop.Outlet2 to pump1.Inlet;   
     489        pump1.Outlet to trays(top).InletL;
     490        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
    335491end
    336492
     
    351507ext NComp as Integer;
    352508        NTrays as Integer(Brief="Number of trays", Default=2);
     509        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
     510        top as Integer(Brief="Number of top tray");
     511        bot as Integer(Brief="Number of bottom tray");
     512
     513        SET
     514        top = (NTrays-1)*(1-topdown)/2+1;
     515        bot = NTrays/top;
    353516       
    354517        VARIABLES
     
    361524        EQUATIONS
    362525        "Pressure Drop through the tray"
    363         trays(1).OutletV.F = (1 + tanh(1 * (trays(1).OutletV.P - ttop.Outlet.P)))/2 *
    364                 trays(1).Ah/trays(1).vV * sqrt(2*(trays(1).OutletV.P -
    365                 ttop.Outlet.P + 1e-8 * "atm") / (trays(1).alfa*trays(1).rhoV));
     526        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - ttop.Outlet.P)))/2 *
     527                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
     528                ttop.Outlet.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
    366529               
    367         trays([2:NTrays]).OutletV.F = (1 + tanh(1 * (trays([2:NTrays]).OutletV.P - trays([2:NTrays]).InletL.P)))/2 *
    368                 trays([2:NTrays]).Ah/trays([2:NTrays]).vV * sqrt(2*(trays([2:NTrays]).OutletV.P -
    369                 trays([2:NTrays]).InletL.P + 1e-8 * "atm") / (trays([2:NTrays]).alfa*trays([2:NTrays]).rhoV));
    370        
    371         CONNECTIONS
    372         #vapor
    373         trays([2:NTrays]).OutletV to trays([1:NTrays-1]).InletV;
    374         trays(1).OutletV to cond.InletV;
    375        
    376         #liquid
    377         cond.OutletL to ttop.Inlet;
    378         ttop.Outlet to sptop.Inlet;     
    379         sptop.Outlet2 to pump1.Inlet;
    380         pump1.Outlet to trays(1).InletL;
    381         trays([1:NTrays-1]).OutletL to trays([2:NTrays]).InletL;
     530        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
     531            (trays([top+topdown:topdown:bot]).OutletV.P -
     532            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
     533            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
     534            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     535                trays([top+topdown:topdown:bot]).InletL.P + 1e-8 * "atm") /
     536            (trays([top+topdown:topdown:bot]).alfa*trays([top+topdown:topdown:bot]).rhoV));
     537       
     538        CONNECTIONS
     539        #vapor
     540        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
     541        trays(top).OutletV to cond.InletV;
     542       
     543        #liquid
     544        cond.OutletL to ttop.Inlet;     
     545        ttop.Outlet to sptop.Inlet;
     546        sptop.Outlet2 to pump1.Inlet;   
     547        pump1.Outlet to trays(top).InletL;
     548        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
    382549end
    383550
     
    395562ext NComp as Integer;
    396563        NTrays as Integer(Brief="Number of trays", Default=2);
     564        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
     565        top as Integer(Brief="Number of top tray");
     566        bot as Integer(Brief="Number of bottom tray");
     567
     568        SET
     569        top = (NTrays-1)*(1-topdown)/2+1;
     570        bot = NTrays/top;
    397571       
    398572        VARIABLES
    399573        trays(NTrays) as tray;
    400574        cond as condenser;
    401         sp as splitter;
     575        sptop as splitter;
    402576        pump1 as pump;
    403577
    404578        EQUATIONS
    405579        "Pressure Drop through the tray"
    406         trays(1).OutletV.F = (1 + tanh(1 * (trays(1).OutletV.P - cond.OutletL.P)))/2 *
    407                 trays(1).Ah/trays(1).vV * sqrt(2*(trays(1).OutletV.P -
    408                 cond.OutletL.P + 1e-8 * "atm") / (trays(1).alfa*trays(1).rhoV));
     580        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - cond.OutletL.P)))/2 *
     581                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
     582                cond.OutletL.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
    409583               
    410         trays([2:NTrays]).OutletV.F = (1 + tanh(1 * (trays([2:NTrays]).OutletV.P - trays([2:NTrays]).InletL.P)))/2 *
    411                 trays([2:NTrays]).Ah/trays([2:NTrays]).vV * sqrt(2*(trays([2:NTrays]).OutletV.P -
    412                 trays([2:NTrays]).InletL.P + 1e-8 * "atm") / (trays([2:NTrays]).alfa*trays([2:NTrays]).rhoV));
    413        
    414         CONNECTIONS
    415         #vapor
    416         trays([2:NTrays]).OutletV to trays([1:NTrays-1]).InletV;
    417         trays(1).OutletV to cond.InletV;
    418 
    419         #liquid
    420         cond.OutletL to sp.Inlet;       
    421         sp.Outlet2 to pump1.Inlet;
    422         pump1.Outlet to trays(1).InletL;
    423         trays([1:NTrays-1]).OutletL to trays([2:NTrays]).InletL;
     584        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
     585            (trays([top+topdown:topdown:bot]).OutletV.P -
     586            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
     587            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
     588            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     589                trays([top+topdown:topdown:bot]).InletL.P + 1e-8 * "atm") /
     590            (trays([top+topdown:topdown:bot]).alfa*trays([top+topdown:topdown:bot]).rhoV));
     591       
     592        CONNECTIONS
     593        #vapor
     594        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
     595        trays(top).OutletV to cond.InletV;
     596       
     597        #liquid
     598        cond.OutletL to sptop.Inlet;   
     599        sptop.Outlet2 to pump1.Inlet;   
     600        pump1.Outlet to trays(top).InletL;
     601        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
    424602end
    425603
     
    440618ext NComp as Integer;
    441619        NTrays as Integer(Brief="Number of trays", Default=2);
     620        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
     621        top as Integer(Brief="Number of top tray");
     622        bot as Integer(Brief="Number of bottom tray");
     623
     624        SET
     625        top = (NTrays-1)*(1-topdown)/2+1;
     626        bot = NTrays/top;
    442627       
    443628        VARIABLES
     
    450635        EQUATIONS
    451636        "Pressure Drop through the tray"
    452         trays(1).OutletV.F = (1 + tanh(1 * (trays(1).OutletV.P - ttop.Outlet.P)))/2 *
    453                 trays(1).Ah/trays(1).vV * sqrt(2*(trays(1).OutletV.P -
    454                 ttop.Outlet.P + 1e-8 * "atm") / (trays(1).alfa*trays(1).rhoV));
     637        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - ttop.Outlet.P)))/2 *
     638                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
     639                ttop.Outlet.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
    455640               
    456         trays([2:NTrays]).OutletV.F = (1 + tanh(1 * (trays([2:NTrays]).OutletV.P - trays([2:NTrays]).InletL.P)))/2 *
    457                 trays([2:NTrays]).Ah/trays([2:NTrays]).vV * sqrt(2*(trays([2:NTrays]).OutletV.P -
    458                 trays([2:NTrays]).InletL.P + 1e-8 * "atm") / (trays([2:NTrays]).alfa*trays([2:NTrays]).rhoV));
    459        
    460         CONNECTIONS
    461         #vapor
    462         trays([2:NTrays]).OutletV to trays([1:NTrays-1]).InletV;
    463         trays(1).OutletV to cond.InletV;
    464        
    465         #liquid
    466         cond.OutletL to ttop.Inlet;
    467         ttop.Outlet to sptop.Inlet;     
    468         sptop.Outlet2 to pump1.Inlet;
    469         pump1.Outlet to trays(1).InletL;
    470         trays([1:NTrays-1]).OutletL to trays([2:NTrays]).InletL;
     641        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
     642            (trays([top+topdown:topdown:bot]).OutletV.P -
     643            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
     644            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
     645            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     646                trays([top+topdown:topdown:bot]).InletL.P + 1e-8 * "atm") /
     647            (trays([top+topdown:topdown:bot]).alfa*trays([top+topdown:topdown:bot]).rhoV));
     648       
     649        CONNECTIONS
     650        #vapor
     651        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
     652        trays(top).OutletV to cond.InletV;
     653       
     654        #liquid
     655        cond.OutletL to ttop.Inlet;     
     656        ttop.Outlet to sptop.Inlet;
     657        sptop.Outlet2 to pump1.Inlet;   
     658        pump1.Outlet to trays(top).InletL;
     659        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
    471660end
    472661
     
    484673ext NComp as Integer;
    485674        NTrays as Integer(Brief="Number of trays", Default=2);
     675        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
     676        top as Integer(Brief="Number of top tray");
     677        bot as Integer(Brief="Number of bottom tray");
     678
     679        SET
     680        top = (NTrays-1)*(1-topdown)/2+1;
     681        bot = NTrays/top;
    486682       
    487683        VARIABLES
    488684        trays(NTrays) as tray;
    489685        cond as condenser;
    490         sp as splitter;
     686        sptop as splitter;
    491687        pump1 as pump;
    492688
    493689        EQUATIONS
    494690        "Pressure Drop through the tray"
    495         trays(1).OutletV.F = (1 + tanh(1 * (trays(1).OutletV.P - cond.OutletL.P)))/2 *
    496                 trays(1).Ah/trays(1).vV * sqrt(2*(trays(1).OutletV.P -
    497                 cond.OutletL.P + 1e-8 * "atm") / (trays(1).alfa*trays(1).rhoV));
     691        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - cond.OutletL.P)))/2 *
     692                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
     693                cond.OutletL.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
    498694               
    499         trays([2:NTrays]).OutletV.F = (1 + tanh(1 * (trays([2:NTrays]).OutletV.P - trays([2:NTrays]).InletL.P)))/2 *
    500                 trays([2:NTrays]).Ah/trays([2:NTrays]).vV * sqrt(2*(trays([2:NTrays]).OutletV.P -
    501                 trays([2:NTrays]).InletL.P + 1e-8 * "atm") / (trays([2:NTrays]).alfa*trays([2:NTrays]).rhoV));
    502        
    503         CONNECTIONS
    504         #vapor
    505         trays([2:NTrays]).OutletV to trays([1:NTrays-1]).InletV;
    506         trays(1).OutletV to cond.InletV;
    507 
    508         #liquid
    509         cond.OutletL to sp.Inlet;       
    510         sp.Outlet2 to pump1.Inlet;
    511         pump1.Outlet to trays(1).InletL;
    512         trays([1:NTrays-1]).OutletL to trays([2:NTrays]).InletL;
     695        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
     696            (trays([top+topdown:topdown:bot]).OutletV.P -
     697            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
     698            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
     699            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     700                trays([top+topdown:topdown:bot]).InletL.P + 1e-8 * "atm") /
     701            (trays([top+topdown:topdown:bot]).alfa*trays([top+topdown:topdown:bot]).rhoV));
     702       
     703        CONNECTIONS
     704        #vapor
     705        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
     706        trays(top).OutletV to cond.InletV;
     707       
     708        #liquid
     709        cond.OutletL to cond.InletV;   
     710        cond.OutletL to sptop.Inlet;
     711        sptop.Outlet2 to pump1.Inlet;   
     712        pump1.Outlet to trays(top).InletL;
     713        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
    513714end
    514715
     
    529730ext NComp as Integer;
    530731        NTrays as Integer(Brief="Number of trays", Default=2);
     732        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
     733        top as Integer(Brief="Number of top tray");
     734        bot as Integer(Brief="Number of bottom tray");
     735
     736        SET
     737        top = (NTrays-1)*(1-topdown)/2+1;
     738        bot = NTrays/top;
    531739       
    532740        VARIABLES
     
    539747        EQUATIONS
    540748        "Pressure Drop through the tray"
    541         trays(1).OutletV.F = (1 + tanh(1 * (trays(1).OutletV.P - ttop.Outlet.P)))/2 *
    542                 trays(1).Ah/trays(1).vV * sqrt(2*(trays(1).OutletV.P -
    543                 ttop.Outlet.P + 1e-8 * "atm") / (trays(1).alfa*trays(1).rhoV));
     749        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - ttop.Outlet.P)))/2 *
     750                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
     751                ttop.Outlet.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
    544752               
    545         trays([2:NTrays]).OutletV.F = (1 + tanh(1 * (trays([2:NTrays]).OutletV.P - trays([2:NTrays]).InletL.P)))/2 *
    546                 trays([2:NTrays]).Ah/trays([2:NTrays]).vV * sqrt(2*(trays([2:NTrays]).OutletV.P -
    547                 trays([2:NTrays]).InletL.P + 1e-8 * "atm") / (trays([2:NTrays]).alfa*trays([2:NTrays]).rhoV));
    548        
    549         CONNECTIONS
    550         #vapor
    551         trays([2:NTrays]).OutletV to trays([1:NTrays-1]).InletV;
    552         trays(1).OutletV to cond.InletV;
    553        
    554         #liquid
    555         cond.OutletL to ttop.Inlet;
    556         ttop.Outlet to sptop.Inlet;     
    557         sptop.Outlet2 to pump1.Inlet;
    558         pump1.Outlet to trays(1).InletL;
    559         trays([1:NTrays-1]).OutletL to trays([2:NTrays]).InletL;
     753        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
     754            (trays([top+topdown:topdown:bot]).OutletV.P -
     755            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
     756            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
     757            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     758                trays([top+topdown:topdown:bot]).InletL.P + 1e-8 * "atm") /
     759            (trays([top+topdown:topdown:bot]).alfa*trays([top+topdown:topdown:bot]).rhoV));
     760       
     761        CONNECTIONS
     762        #vapor
     763        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
     764        trays(top).OutletV to cond.InletV;
     765       
     766        #liquid
     767        cond.OutletL to ttop.Inlet;     
     768        ttop.Outlet to sptop.Inlet;
     769        sptop.Outlet2 to pump1.Inlet;   
     770        pump1.Outlet to trays(top).InletL;
     771        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
    560772end
    561773
     
    573785ext NComp as Integer;
    574786        NTrays as Integer(Brief="Number of trays", Default=2);
     787        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
     788        top as Integer(Brief="Number of top tray");
     789        bot as Integer(Brief="Number of bottom tray");
     790
     791        SET
     792        top = (NTrays-1)*(1-topdown)/2+1;
     793        bot = NTrays/top;
    575794       
    576795        VARIABLES
     
    581800        if (reb.OutletV.P > reb.InletL.P) then
    582801                "Pressure Drop through the tray"
    583                 reb.OutletV.F = 34803 * "mm^2"/reb.vV * sqrt((reb.OutletV.P - trays(NTrays).OutletL.P)
    584                                 / (1.3*reb.rhoV) ); # para o modelo com 25 pratos, o beta do refervedor é 0.8. Para a coluna com 80, o beta é:1.3
     802                reb.OutletV.F = trays(bot).Ah/reb.vV * sqrt((reb.OutletV.P - trays(bot).OutletL.P)
     803                                / (trays(bot).beta*reb.rhoV) );
    585804        else
    586805                "Prato selado"
     
    589808
    590809        "Pressure Drop through the tray"
    591         trays([1:NTrays]).OutletV.F = (1 + tanh(1 * (trays([1:NTrays]).OutletV.P - trays([1:NTrays]).InletL.P)))/2 *
    592                 trays([1:NTrays]).Ah/trays([1:NTrays]).vV * sqrt(2*(trays([1:NTrays]).OutletV.P -
    593                 trays([1:NTrays]).InletL.P + 1e-8 * "atm") / (trays([1:NTrays]).alfa*trays([1:NTrays]).rhoV));
    594        
    595         CONNECTIONS
    596         #vapor
    597         reb.OutletV to trays(NTrays).InletV;
    598         trays([2:NTrays]).OutletV to trays([1:NTrays-1]).InletV;
    599        
    600         #liquid
    601         trays([1:NTrays-1]).OutletL to trays([2:NTrays]).InletL;
    602         trays(NTrays).OutletL to reb.InletL;
     810        trays([top:topdown:bot]).OutletV.F = (1 + tanh(1 *
     811            (trays([top:topdown:bot]).OutletV.P -
     812            trays([top:topdown:bot]).InletL.P)))/2 *
     813            trays([top:topdown:bot]).Ah/trays([top:topdown:bot]).vV *
     814            sqrt(2*(trays([top:topdown:bot]).OutletV.P -
     815                trays([top:topdown:bot]).InletL.P + 1e-8 * "atm") /
     816            (trays([top:topdown:bot]).alfa*trays([top:topdown:bot]).rhoV));
     817       
     818        CONNECTIONS
     819        #vapor
     820        reb.OutletV to trays(bot).InletV;
     821        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
     822       
     823        #liquid
     824        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
     825        trays(bot).OutletL to reb.InletL;
    603826end
    604827
     
    618841ext NComp as Integer;
    619842        NTrays as Integer(Brief="Number of trays", Default=2);
     843        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
     844        top as Integer(Brief="Number of top tray");
     845        bot as Integer(Brief="Number of bottom tray");
     846
     847        SET
     848        top = (NTrays-1)*(1-topdown)/2+1;
     849        bot = NTrays/top;
    620850       
    621851        VARIABLES
     
    628858        if (reb.OutletV.P > reb.InletL.P) then
    629859                "Pressure Drop through the tray"
    630                 reb.OutletV.F = 34803 * "mm^2"/reb.vV * sqrt((reb.OutletV.P - trays(NTrays).OutletL.P)
    631                                 / (1.3*reb.rhoV) ); # para o modelo com 25 pratos, o beta do refervedor é 0.8. Para a coluna com 80, o beta é:1.3
     860                reb.OutletV.F = trays(bot).Ah/reb.vV * sqrt((reb.OutletV.P - trays(bot).OutletL.P)
     861                                / (trays(bot).beta*reb.rhoV) );
    632862        else
    633863                "Prato selado"
     
    636866
    637867        "Pressure Drop through the tray"
    638         trays([1:NTrays]).OutletV.F = (1 + tanh(1 * (trays([1:NTrays]).OutletV.P - trays([1:NTrays]).InletL.P)))/2 *
    639                 trays([1:NTrays]).Ah/trays([1:NTrays]).vV * sqrt(2*(trays([1:NTrays]).OutletV.P -
    640                 trays([1:NTrays]).InletL.P + 1e-8 * "atm") / (trays([1:NTrays]).alfa*trays([1:NTrays]).rhoV));
    641        
    642         CONNECTIONS
    643         #vapor
    644         reb.OutletV to trays(NTrays).InletV;
    645         trays([2:NTrays]).OutletV to trays([1:NTrays-1]).InletV;
    646        
    647         #liquid
    648         trays([1:NTrays-1]).OutletL to trays([2:NTrays]).InletL;
    649         trays(NTrays).OutletL to tbottom.Inlet;
     868        trays([top:topdown:bot]).OutletV.F = (1 + tanh(1 *
     869            (trays([top:topdown:bot]).OutletV.P -
     870            trays([top:topdown:bot]).InletL.P)))/2 *
     871            trays([top:topdown:bot]).Ah/trays([top:topdown:bot]).vV *
     872            sqrt(2*(trays([top:topdown:bot]).OutletV.P -
     873                trays([top:topdown:bot]).InletL.P + 1e-8 * "atm") /
     874            (trays([top:topdown:bot]).alfa*trays([top:topdown:bot]).rhoV));
     875       
     876        CONNECTIONS
     877        #vapor
     878        reb.OutletV to trays(bot).InletV;
     879        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
     880       
     881        #liquid
     882        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
     883        trays(bot).OutletL to tbottom.Inlet;
    650884        tbottom.Outlet to spbottom.Inlet;
    651885        spbottom.Outlet2 to reb.InletL;
     
    665899ext NComp as Integer;
    666900        NTrays as Integer(Brief="Number of trays", Default=2);
     901        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
     902        top as Integer(Brief="Number of top tray");
     903        bot as Integer(Brief="Number of bottom tray");
     904
     905        SET
     906        top = (NTrays-1)*(1-topdown)/2+1;
     907        bot = NTrays/top;
    667908       
    668909        VARIABLES
     
    673914        if (reb.OutletV.P > reb.InletL.P) then
    674915                "Pressure Drop through the tray"
    675                 reb.OutletV.F = 34803 * "mm^2"/reb.vV * sqrt((reb.OutletV.P - trays(NTrays).OutletL.P)
    676                                 / (1.3*reb.rhoV) ); # para o modelo com 25 pratos, o beta do refervedor é 0.8. Para a coluna com 80, o beta é:1.3
     916                reb.OutletV.F = trays(bot).Ah/reb.vV * sqrt((reb.OutletV.P - trays(bot).OutletL.P)
     917                                / (trays(bot).beta*reb.rhoV) ); # para o modelo com 25 pratos, o beta do refervedor é 0.8. Para a coluna com 80, o beta é:1.3
    677918        else
    678919                "Prato selado"
     
    681922
    682923        "Pressure Drop through the tray"
    683         trays([1:NTrays]).OutletV.F = (1 + tanh(1 * (trays([1:NTrays]).OutletV.P - trays([1:NTrays]).InletL.P)))/2 *
    684                 trays([1:NTrays]).Ah/trays([1:NTrays]).vV * sqrt(2*(trays([1:NTrays]).OutletV.P -
    685                 trays([1:NTrays]).InletL.P + 1e-8 * "atm") / (trays([1:NTrays]).alfa*trays([1:NTrays]).rhoV));
    686        
    687         CONNECTIONS
    688         #vapor
    689         reb.OutletV to trays(NTrays).InletV;
    690         trays([2:NTrays]).OutletV to trays([1:NTrays-1]).InletV;
    691        
    692         #liquid
    693         trays([1:NTrays-1]).OutletL to trays([2:NTrays]).InletL;
    694         trays(NTrays).OutletL to reb.InletL;
     924        trays([top:topdown:bot]).OutletV.F = (1 + tanh(1 *
     925            (trays([top:topdown:bot]).OutletV.P -
     926            trays([top:topdown:bot]).InletL.P)))/2 *
     927            trays([top:topdown:bot]).Ah/trays([top:topdown:bot]).vV *
     928            sqrt(2*(trays([top:topdown:bot]).OutletV.P -
     929                trays([top:topdown:bot]).InletL.P + 1e-8 * "atm") /
     930            (trays([top:topdown:bot]).alfa*trays([top:topdown:bot]).rhoV));
     931       
     932        CONNECTIONS
     933        #vapor
     934        reb.OutletV to trays(bot).InletV;
     935        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
     936       
     937        #liquid
     938        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
     939        trays(bot).OutletL to reb.InletL;
    695940end
    696941
     
    710955ext NComp as Integer;
    711956        NTrays as Integer(Brief="Number of trays", Default=2);
     957        topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
     958        top as Integer(Brief="Number of top tray");
     959        bot as Integer(Brief="Number of bottom tray");
     960
     961        SET
     962        top = (NTrays-1)*(1-topdown)/2+1;
     963        bot = NTrays/top;
    712964       
    713965        VARIABLES
     
    720972        if (reb.OutletV.P > reb.InletL.P) then
    721973                "Pressure Drop through the tray"
    722                 reb.OutletV.F = 34803 * "mm^2"/reb.vV * sqrt((reb.OutletV.P - trays(NTrays).OutletL.P)
    723                                 / (1.3*reb.rhoV) ); # para o modelo com 25 pratos, o beta do refervedor é 0.8. Para a coluna com 80, o beta é:1.3
     974                reb.OutletV.F = trays(bot).Ah/reb.vV * sqrt((reb.OutletV.P - trays(bot).OutletL.P)
     975                                / (trays(bot).beta*reb.rhoV) ); # para o modelo com 25 pratos, o beta do refervedor é 0.8. Para a coluna com 80, o beta é:1.3
    724976        else
    725977                "Prato selado"
     
    728980
    729981        "Pressure Drop through the tray"
    730         trays([1:NTrays]).OutletV.F = (1 + tanh(1 * (trays([1:NTrays]).OutletV.P - trays([1:NTrays]).InletL.P)))/2 *
    731                 trays([1:NTrays]).Ah/trays([1:NTrays]).vV * sqrt(2*(trays([1:NTrays]).OutletV.P -
    732                 trays([1:NTrays]).InletL.P + 1e-8 * "atm") / (trays([1:NTrays]).alfa*trays([1:NTrays]).rhoV));
    733        
    734         CONNECTIONS
    735         #vapor
    736         reb.OutletV to trays(NTrays).InletV;
    737         trays([2:NTrays]).OutletV to trays([1:NTrays-1]).InletV;
    738        
    739         #liquid
    740         trays([1:NTrays-1]).OutletL to trays([2:NTrays]).InletL;
    741         trays(NTrays).OutletL to tbottom.Inlet;
     982        trays([top:topdown:bot]).OutletV.F = (1 + tanh(1 *
     983            (trays([top:topdown:bot]).OutletV.P -
     984            trays([top:topdown:bot]).InletL.P)))/2 *
     985            trays([top:topdown:bot]).Ah/trays([top:topdown:bot]).vV *
     986            sqrt(2*(trays([top:topdown:bot]).OutletV.P -
     987                trays([top:topdown:bot]).InletL.P + 1e-8 * "atm") /
     988            (trays([top:topdown:bot]).alfa*trays([top:topdown:bot]).rhoV));
     989       
     990        CONNECTIONS
     991        #vapor
     992        reb.OutletV to trays(bot).InletV;
     993        trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
     994       
     995        #liquid
     996        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
     997        trays(bot).OutletL to tbottom.Inlet;
    742998        tbottom.Outlet to spbottom.Inlet;
    743999        spbottom.Outlet2 to reb.InletL;
Note: See TracChangeset for help on using the changeset viewer.