Changes in / [49:25]


Ignore:
Location:
/mso
Files:
4 added
14 deleted
56 edited

Legend:

Unmodified
Added
Removed
  • /mso/eml/controllers/lead_lag.mso

    r49 r25  
    3939
    4040        INITIAL
    41         diff(aux)= 0 * "1/s";
     41        diff(aux)=0;
    4242       
    4343end
  • /mso/eml/heat_exchangers/HEX_Engine.mso

    r49 r25  
    11#*--------------------------------------------------------------------*
    2 *                       Heat Exchangers Abstract Models
    3 *--------------------------------------------------------------------
    4 *       - Inlet_Main_Stream     : Inlet Streams
    5 *--------------------------------------------------------------------
    6 *                                       - Hot   : Inlet Hot Stream
    7 *                                       - Cold  : Inlet Cold Stream
    8 *--------------------------------------------------------------------
    9 *       - Outlet_Main_Stream    : Outlet Streams
    10 *--------------------------------------------------------------------
    11 *                                       - Hot   : Outlet Hot Stream
    12 *                                       - Cold  : Outlet Cold Stream
    13 *--------------------------------------------------------------------
    14 *       - Main_Properties               : Physical Properties for Hot and Cold Side
    15 *--------------------------------------------------------------------
    16 *               Physical_Properties
    17 *                       Properties_In_Out       :       Inlet/Outlet Physical Properties
    18 *                       Properties_Average      :       Average Physical Properties
    19 *                       Properties_Wall         :       Physical Properties at Wall Temperature
    20 *--------------------------------------------------------------------
    21 *       - Tube_Side_Main        : Tube Side Main Variables
    22 *----------------------------------------------------------------------
    23 *                       Tube_Pdrop                      : Tube Side Pressure Drop
    24 *                       Tube_Heat_Transfer      : Tube Side Heat Transfer
    25 *----------------------------------------------------------------------
    26 *       - Shell_Side_Main       : Shell Side Main Variables
    27 *----------------------------------------------------------------------
    28 *                       Shell_Pdrop                     : Shell Side Pressure Drop
    29 *                       Shell_Heat_Transfer     : Shell Side Heat Transfer
    30 *----------------------------------------------------------------------
    31 *       - Baffles_Main  : Baffles Spacing
    32 *----------------------------------------------------------------------
    33 *       - Main_Resistances      : Thermal Resistances
    34 *----------------------------------------------------------------------
    35 *       - Details_Main  : Heat Exchanger Thermal Details
    36 *----------------------------------------------------------------------
    37 *       - Main_Pdrop : Heat Exchanger Pressure Drop (Simplified)
    38 *               Basic_Pdrop     : Hot and Cold Side Pressure Drop
     2*
    393*----------------------------------------------------------------------
    404* Author: Gerson Balbueno Bicca
     
    426*--------------------------------------------------------------------*#
    437
     8#using "streamspetroil";
    449using "streams";
     10#=====================================================================
     11# Hot and Cold Streams
     12#=====================================================================
    4513
    4614Model Inlet_Main_Stream
     
    4917#===================================================================== 
    5018VARIABLES
    51 Hot     as stream; # Inlet Hot Stream
    52 Cold    as stream; # Inlet Cold Stream
     19Hot     as stream;# Inlet Hot Stream
     20Cold    as stream;# Inlet Cold Stream
     21       
    5322end
    5423
     
    5827#===================================================================== 
    5928VARIABLES
    60 Hot     as stream_therm;  # Outlet Hot Stream
    61 Cold    as stream_therm;  # Outlet Cold Stream
     29Hot     as stream_therm;# Outlet Hot Stream
     30Cold    as stream_therm;# Outlet Cold Stream
     31       
    6232end
    6333
     
    7141#===================================================================== 
    7242VARIABLES
    73 Mw              as molweight            (Brief="Average Mol Weight",Default=75, Lower=1, Upper=1e8);
    74 T               as temperature          (Brief="Average  Temperature",Lower=50);
    75 P               as pressure                     (Brief="Average  Pressure",Default=1, Lower=1e-10, Upper=30);
    76 rho             as dens_mass            (Brief="Stream Density" ,Default=1000, Lower=1e-3, Upper=5e5);
    77 Mu              as viscosity            (Brief="Stream Viscosity",Lower=0.0001);
    78 Cp              as cp_mol                       (Brief="Stream Molar Heat Capacity", Upper=10e10);
    79 K               as conductivity         (Brief="Stream Thermal Conductivity", Default=1.0, Lower=1e-5, Upper=500);
     43
     44Mw              as molweight    (Brief="Average Mol Weight",Default=75, Lower=1, Upper=1e8);
     45T               as temperature  (Brief="Average  Temperature",Lower=50);
     46P               as pressure             (Brief="Average  Pressure",Default=1, Lower=1e-10, Upper=30);
     47rho             as dens_mass    (Brief="Stream Density" ,Default=1000, Lower=1e-3, Upper=5e5);
     48Mu              as viscosity    (Brief="Stream Viscosity",Lower=0.0001);
     49Cp              as cp_mol               (Brief="Stream Molar Heat Capacity", Upper=10e10);
     50K               as conductivity (Brief="Stream Thermal Conductivity", Default=1.0, Lower=1e-5, Upper=500);
     51
    8052end
    8153
     
    8557#===================================================================== 
    8658VARIABLES
    87 Fw              as flow_mass    (Brief="Stream Mass Flow");
     59
     60Fw              as flow_mass    (Brief="Inlet Stream Mass Flow");
    8861rho             as dens_mass    (Brief="Stream Density" ,Default=1000, Lower=1e-3, Upper=5e5);
    8962Mu              as viscosity    (Brief="Stream Viscosity",Default=1, Lower=1e-5, Upper=1e5);
    9063Cp              as cp_mol               (Brief="Stream Molar Heat Capacity", Upper=10e10);
    9164K               as conductivity (Brief="Stream Thermal Conductivity", Default=1.0, Lower=1e-5, Upper=500);
     65
    9266end
    9367
     
    9771#===================================================================== 
    9872VARIABLES
     73
    9974Mu              as viscosity    (Brief="Stream Viscosity",Default=1, Lower=1e-5, Upper=1e5);
    10075Cp              as cp_mol               (Brief="Stream Molar Heat Capacity", Upper=10e10);
    10176K               as conductivity (Brief="Stream Thermal Conductivity", Default=1.0, Lower=1e-5, Upper=500);
    102 Twall   as temperature  (Brief="Wall Temperature",Lower=50);
     77Twall   as temperature  (Brief="Tube Wall Temperature",Lower=50);
     78
    10379end
    10480
     
    10884#===================================================================== 
    10985VARIABLES
    110 Inlet           as Properties_In_Out;           # Properties at Inlet Stream
    111 Average         as Properties_Average;      # Properties at Average Temperature
    112 Outlet          as Properties_In_Out;           # Properties at Outlet Stream
    113 Wall            as Properties_Wall;                     # Properties at Wall Temperature
     86
     87Inlet   as Properties_In_Out;   # Properties at Inlet Stream
     88Average as Properties_Average;  # Properties at Average Temperature
     89Outlet  as Properties_In_Out;   # Properties at Outlet Stream
     90Wall    as Properties_Wall;             # Properties at Wall Temperature
     91
    11492end
    11593
     
    11997#===================================================================== 
    12098VARIABLES
    121 Hot  as Physical_Properties; # Hot Stream
    122 Cold as Physical_Properties; # Cold Stream
     99
     100Hot  as Physical_Properties;# Hot Stream
     101Cold as Physical_Properties;# Cold Stream
     102       
    123103end
    124104
    125105Model Tube_Pdrop
    126106#=====================================================================
    127 #       Tube Side Pressure Drop block
    128 #===================================================================== 
    129 VARIABLES
    130 
    131 PdTube                  as press_delta  (Brief="Tube Pressure Drop",Default=0.01, Lower=1e-10);
    132 Pdtotal                 as press_delta  (Brief="Total Pressure Drop",Default=0.01, Lower=1e-10);
    133 Pdnozzle_in     as press_delta  (Brief="Inlet Nozzle Pressure Drop",Default=0.01, Lower=0);
    134 Pdnozzle_out    as press_delta  (Brief="Outlet Nozzle Pressure Drop",Default=0.01, Lower=0);
    135 Vnozzle_in      as velocity             (Brief="Inlet Nozzle Velocity",Default=1, Upper=1e5, Lower=0);
    136 Vnozzle_out     as velocity             (Brief="Outlet Nozzle Velocity",Default=1, Upper=1e5, Lower=0);
    137 
    138 EQUATIONS
    139 "Total Pressure Drop"
    140         Pdtotal = PdTube + Pdnozzle_in + Pdnozzle_out;
     107#       Pressure Drop block
     108#===================================================================== 
     109VARIABLES
     110
     111PdTube                  as press_delta(Default=0.01, Lower=1e-10);
     112Pdtotal                 as press_delta(Default=0.01, Lower=1e-10);
     113Pdnozzle_in     as press_delta(Default=0.01, Lower=1e-10);
     114Pdnozzle_out    as press_delta(Default=0.01, Lower=1e-10);
     115Vnozzle_in      as velocity       (Default=1, Upper=1e5, Lower=1e-10);
     116Vnozzle_out     as velocity       (Default=1, Upper=1e5, Lower=1e-10);
     117
     118EQUATIONS
     119
     120Pdtotal = PdTube + Pdnozzle_in + Pdnozzle_out;
     121
     122end
     123
     124Model Tube_Pdrop_Nozzles
     125#=====================================================================
     126#       Pressure Drop block
     127#===================================================================== 
     128VARIABLES
     129
     130Pdnozzle_in     as press_delta(Default=0.01, Lower=1e-10);
     131Pdnozzle_out    as press_delta(Default=0.01, Lower=1e-10);
     132Vnozzle_in      as velocity       (Default=1, Upper=1e5, Lower=1e-10);
     133Vnozzle_out     as velocity       (Default=1, Upper=1e5, Lower=1e-10);
     134
     135end
     136
     137Model Tube_Pdrop_Disc
     138#=====================================================================
     139#       Pressure Drop block
     140#===================================================================== 
     141VARIABLES
     142
     143PdTube                  as press_delta(Default=0.01, Lower=1e-10);
     144Pdtotal                 as press_delta(Default=0.01, Lower=1e-10);
     145
     146EQUATIONS
     147
     148Pdtotal = PdTube;
    141149
    142150end
     
    144152Model Tube_Heat_Transfer
    145153#=====================================================================
    146 #       Tube Side Heat Transfer Block
    147 #===================================================================== 
    148 VARIABLES
    149 Re        as positive             (Brief="Tube Side Reynolds Number",Default=1000,Lower=1);
    150 htube as heat_trans_coeff (Brief="Tube Side Film Coefficient",Default=1,Lower=1e-12, Upper=1e6);
    151 PR        as positive             (Brief="Tube Side Prandtl Number",Default=0.5,Lower=1e-8);
    152 PRw   as positive                 (Brief="Tube Side Prandtl Number at Wall Temperature",Default=0.5,Lower=1e-8);
    153 Phi   as positive                 (Brief="Phi Correction",Default=1,Lower=1e-3);
    154 Vtube as velocity                 (Brief="Tube Side Velocity",Lower=1e-8);
     154#       Pressure Drop block
     155#===================================================================== 
     156VARIABLES
     157Re                      as positive                     (Brief="Tube Side Reynolds Number",Default=1000,Lower=1);
     158htube           as heat_trans_coeff     (Brief="Tube Side Film Coefficient",Default=1,Lower=1e-12, Upper=1e6);
     159PR                      as positive                     (Brief="Tube Side Prandtl Number",Default=0.5,Lower=1e-8);
     160PRw             as positive                     (Brief="Tube Side Prandtl Number",Default=0.5,Lower=1e-8);
     161Phi             as positive                     (Brief="Phi Correction",Default=1,Lower=1e-3);
     162Vtube           as velocity                     (Brief="Tube Side Velocity",Lower=1e-8);
     163
     164
    155165end
    156166
    157167Model Shell_Pdrop
    158168#=====================================================================
    159 #       Shell Side Pressure Drop block
    160 #===================================================================== 
    161 VARIABLES
    162 PdCross                 as press_delta  (Brief="Cross Flow Pressure Drop",Default=0.01, Lower=0);
    163 PdEndZones      as press_delta  (Brief="End Zones Pressure Drop",Default=0.01, Lower=0);
    164 Pdwindow                as press_delta  (Brief="Window Pressure Drop",Default=0.01, Lower=1e-10);
    165 Pdtotal                 as press_delta  (Brief="Total Pressure Drop",Default=0.01, Lower=0);
    166 Pdnozzle_in     as press_delta  (Brief="Inlet Nozzle Pressure Drop",Default=0.01, Lower=0);
    167 Pdnozzle_out    as press_delta  (Brief="Outlet Nozzle Pressure Drop",Default=0.01, Lower=0);
    168 Vnozzle_in      as velocity             (Brief="Inlet Nozzle Velocity",Default=1, Upper=1e5, Lower=0);
    169 Vnozzle_out     as velocity             (Brief="Outlet Nozzle Velocity",Default=1, Upper=1e5, Lower=0);
    170 RVsquare_in     as flux_mass    (Brief="Inlet Nozzle rho-V^2");
    171 RVsquare_out    as flux_mass    (Brief="Outlet Nozzle rho-V^2");
    172 
    173 EQUATIONS
    174 
    175 "Shell Side Total Pressure Drop"
    176         Pdtotal = PdCross + PdEndZones + Pdnozzle_in + Pdnozzle_out + Pdwindow;
     169#       Pressure Drop block
     170#===================================================================== 
     171VARIABLES
     172
     173PdCross                 as press_delta(Default=0.01, Lower=1e-10);
     174PdEndZones      as press_delta(Default=0.01, Lower=1e-10);
     175Pdwindow                as press_delta(Default=0.01, Lower=1e-10);
     176Pdtotal                 as press_delta(Default=0.01, Lower=1e-10);
     177Pdnozzle_in     as press_delta(Default=0.01, Lower=1e-10);
     178Pdnozzle_out    as press_delta(Default=0.01, Lower=1e-10);
     179Vnozzle_in      as velocity(Default=1, Upper=1e5, Lower=1e-10);
     180Vnozzle_out     as velocity(Default=1, Upper=1e5, Lower=1e-10);
     181
     182EQUATIONS
     183
     184Pdtotal = PdCross + PdEndZones + Pdnozzle_in + Pdnozzle_out + Pdwindow;
     185
     186end
     187
     188Model Shell_Pdrop_Nozzles
     189#=====================================================================
     190#       Pressure Drop block
     191#===================================================================== 
     192VARIABLES
     193
     194Pdnozzle_in     as press_delta(Default=0.01, Lower=1e-10);
     195Pdnozzle_out    as press_delta(Default=0.01, Lower=1e-10);
     196Vnozzle_in      as velocity(Default=1, Upper=1e5, Lower=1e-10);
     197Vnozzle_out     as velocity(Default=1, Upper=1e5, Lower=1e-10);
     198
     199end
     200
     201Model Shell_Pdrop_Disc
     202#=====================================================================
     203#       Pressure Drop block
     204#===================================================================== 
     205VARIABLES
     206
     207PdCross                 as press_delta(Default=0.01, Lower=1e-10);
     208PdEndZones      as press_delta(Default=0.01, Lower=1e-10);
     209Pdwindow                as press_delta(Default=0.01, Lower=1e-10);
     210Pdtotal                 as press_delta(Default=0.01, Lower=1e-10);
     211
     212EQUATIONS
     213
     214Pdtotal = PdCross + PdEndZones + Pdwindow;
    177215
    178216end
     
    180218Model Shell_Heat_Transfer
    181219#=====================================================================
    182 # Shell Side Heat Transfer Block       
     220#      
    183221#===================================================================== 
    184222VARIABLES
    185223Re                      as positive                     (Brief="Shell Side Reynolds Number",Default=100,Lower=1);
    186224PR                      as positive                     (Brief="Shell Side Prandtl Number",Default=0.7,Lower=1e-6);
    187 PRw             as positive                     (Brief="Shell Side Prandtl Number",Default=0.5,Lower=1e-8);
     225PRw                     as positive                     (Brief="Shell Side Prandtl Number",Default=0.5,Lower=1e-8);
    188226hshell          as heat_trans_coeff     (Brief="Shell Side Film Coefficient",Default=1,Lower=1e-12, Upper=1e6);
    189227Phi             as positive                     (Brief="Phi Correction",Default=1,Lower=1e-3);
     
    199237end
    200238
     239Model Tube_Side_Main
     240#=====================================================================
     241#       Tube Side Main Variables
     242#===================================================================== 
     243VARIABLES
     244PressureDrop    as Tube_Pdrop;
     245HeatTransfer    as Tube_Heat_Transfer;
     246end
     247
     248Model Tube_Side_Main_Disc
     249#=====================================================================
     250#       Tube Side Main Variables
     251#===================================================================== 
     252VARIABLES
     253PressureDrop    as Tube_Pdrop_Disc;
     254HeatTransfer    as Tube_Heat_Transfer;
     255end
     256
     257Model Shell_Side_Main
     258#=====================================================================
     259#       Shell Side Main Variables
     260#===================================================================== 
     261VARIABLES
     262PressureDrop    as Shell_Pdrop;
     263HeatTransfer    as Shell_Heat_Transfer;
     264end
     265
     266Model Shell_Side_Main_Disc
     267#=====================================================================
     268#       Shell Side Main Variables
     269#===================================================================== 
     270VARIABLES
     271PressureDrop    as Shell_Pdrop_Disc;
     272HeatTransfer    as Shell_Heat_Transfer;
     273end
     274
     275Model Pdrop_Nozzles_Main
     276#=====================================================================
     277#       Tube Side Main Variables
     278#===================================================================== 
     279VARIABLES
     280
     281Tubes   as Tube_Pdrop_Nozzles;
     282Shell   as Shell_Pdrop_Nozzles;
     283
     284end
     285
    201286Model Baffles_Main
    202287#=====================================================================
    203 #       Baffles Spacing
     288#       Baffles Main Variables
    204289#=====================================================================
    205290VARIABLES
     
    216301VARIABLES
    217302
    218 Rtube   as positive     (Brief="Tube Resistance",Unit="m^2*K/kW",Lower=1e-6);
    219 Rwall   as positive     (Brief="Wall Resistance",Unit="m^2*K/kW",Lower=1e-6);
    220 Rshell  as positive     (Brief="Shell Resistance",Unit="m^2*K/kW",Lower=1e-6);
     303Rtube                   as positive(Unit="m^2*K/kW",Lower=1e-6);
     304Rwall                   as positive(Unit="m^2*K/kW",Lower=1e-6);
     305Rshell                  as positive(Unit="m^2*K/kW",Lower=1e-6);
     306#pctRtube        as percent(Lower=1e-6);
     307#pctRwall        as percent(Lower=1e-6);
     308#pctRshell       as percent(Lower=1e-6);
     309
     310#EQUATIONS
     311
     312#pctRtube       = 100*Rtube/(Rtube+Rwall+Rshell);
     313#pctRwall       = 100*Rwall/(Rtube+Rwall+Rshell);
     314#pctRshell      = 100*Rshell/(Rtube+Rwall+Rshell);
    221315
    222316end
     
    232326Ch      as positive                     (Brief="Hot Stream Heat Capacity",Lower=1e-3,Default=1e3,Unit="W/K");
    233327Cc      as positive                     (Brief="Cold Stream Heat Capacity",Lower=1e-3,Default=1e3,Unit="W/K");
    234 Cr      as positive             (Brief="Heat Capacity Ratio",Default=0.5,Lower=1e-6);
     328Cr      as positive             (Default=0.5,Lower=1e-6);
    235329Cmin    as positive             (Brief="Minimum Heat Capacity",Lower=1e-10,Default=1e3,Unit="W/K");
    236330Cmax    as positive             (Brief="Maximum Heat Capacity",Lower=1e-10,Default=1e3,Unit="W/K");
    237 NTU             as positive                     (Brief="Number of Units Transference",Default=0.05,Lower=1e-10);
    238 
    239 EQUATIONS
     331NTU             as positive                     (Brief="Number of Units Transference",Default=0.05,Lower=1e-10);
     332
     333
     334EQUATIONS
     335
    240336"Number of Units Transference"
    241337        NTU*Cmin = U*A;
    242 end
    243 
    244 Model Tube_Side_Main
    245 #=====================================================================
    246 #       Tube Side Main Variables
    247 #===================================================================== 
    248 VARIABLES
    249 PressureDrop    as Tube_Pdrop;                  #Tube Side Pressure Drop
    250 HeatTransfer    as Tube_Heat_Transfer;  #Tube Side Heat Transfer
    251 end
    252 
    253 Model Shell_Side_Main
    254 #=====================================================================
    255 #       Shell Side Main Variables
    256 #===================================================================== 
    257 VARIABLES
    258 PressureDrop    as Shell_Pdrop;                 # Shell Side Pressure Drop
    259 HeatTransfer    as Shell_Heat_Transfer; # Shell Side Heat Transfer
     338       
    260339end
    261340
     
    265344#===================================================================== 
    266345VARIABLES
    267 Pdrop   as press_delta  (Brief="Pressure Drop",Default=0.01, Lower=0);
    268 FPdrop  as Real                 (Brief="Pressure Drop : Fraction of Inlet",Lower=0,Upper=0.8);
     346
     347Pdrop           as press_delta  (Brief="Pressure Drop",Default=0.01, Lower=0);
     348FPdrop          as Real                 (Brief="Pressure Drop : Fraction of Inlet",Lower=0,Upper=0.8);
     349
    269350end
    270351
     
    274355#===================================================================== 
    275356VARIABLES
    276 Hot     as Basic_Pdrop;# Hot Stream
    277 Cold    as Basic_Pdrop;# Cold Stream
     357Hot  as Basic_Pdrop;# Hot Stream
     358Cold as Basic_Pdrop;# Cold Stream
     359
    278360end     
     361
  • /mso/eml/heat_exchangers/HeatExchangerDetailed.mso

    r49 r25  
    1  
    2 #--------------------------------------------------------------------
    3 # Author: Gerson Balbueno Bicca
    4 # $Id$
    5 #--------------------------------------------------------------------
     1 #*--------------------------------------------------------------------*
     2*
     3*
     4*
     5*
     6*
     7*
     8*               
     9*                                               
     10*
     11*
     12*----------------------------------------------------------------------
     13* Author: Gerson Balbueno Bicca
     14* $Id$
     15*--------------------------------------------------------------------*#
    616
    717using "HEX_Engine";
    818
    9 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    10 #       Basic Model for Detailed Shell and Tubes Heat Exchangers
    11 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     19#=====================================================================
     20#       Basic Model for Detailed Heat Exchangers
     21#=====================================================================
    1222
    1323Model HeatExchangerDetailed_Basic
    14        
     24
    1525PARAMETERS
    1626
    17 ext PP          as CalcObject   (Brief="External Physical Properties");
    18 ext NComp       as Integer      (Brief="Number of Components");
    19         HE              as CalcObject   (Brief="STHE Calculations",File="heatex");
    20         M(NComp)        as molweight    (Brief="Component Mol Weight");
     27ext PP      as CalcObject(Brief="External Physical Properties");
     28ext HE      as CalcObject(Brief="STHE Calculations",File="heatex.dll");
     29ext NComp   as Integer   (Brief="Number of Components");
     30  M(NComp)  as molweight (Brief="Component Mol Weight");
    2131       
    2232VARIABLES
    2333
    24 in  Inlet               as Inlet_Main_Stream;   
    25 out Outlet              as Outlet_Main_Stream; 
    26         Properties      as Main_Properties;             
    27         Details                 as Details_Main;
    28         Tubes                   as Tube_Side_Main;     
    29         Shell                   as Shell_Side_Main;
    30         Resistances     as Main_Resistances;
    31         Baffles         as Baffles_Main;
     34in  Inlet           as Inlet_Main_Stream;       # Hot and Cold Inlets
     35out Outlet      as Outlet_Main_Stream;  # Hot and Cold Outlets
     36        Properties  as Main_Properties;         # Hot and Cold Properties
     37        Details     as Details_Main;
     38        Tubes           as Tube_Side_Main;     
     39        Shell           as Shell_Side_Main;
     40        Resistances as Main_Resistances;
     41        Baffles     as Baffles_Main;
    3242
    3343SET
    34         M   = PP.MolecularWeight();
     44
     45M   = PP.MolecularWeight();
    3546
    3647EQUATIONS
    37 
    38 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    39 #                                               Properties                                                                      #
    40 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    4148
    4249"Hot Stream Average Temperature"
     
    6370        then   
    6471       
    65 "Cold Stream Average Heat Capacity"
     72"Heat Capacity Cold Stream"
    6673        Properties.Cold.Average.Cp      =       PP.LiquidCp(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    67 
    68 "Cold Stream Inlet Heat Capacity"
    6974        Properties.Cold.Inlet.Cp        =       PP.LiquidCp(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
    70 
    71 "Cold Stream Outlet Heat Capacity"
    7275        Properties.Cold.Outlet.Cp       =       PP.LiquidCp(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
    7376
    74 "Cold Stream Average Mass Density"
    75         Properties.Cold.Average.rho =   PP.LiquidDensity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    76 
    77 "Cold Stream Inlet Mass Density"
     77"Mass Density Cold Stream"
     78        Properties.Cold.Average.rho     =       PP.LiquidDensity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    7879        Properties.Cold.Inlet.rho       =       PP.LiquidDensity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
    79 
    80 "Cold Stream Outlet Mass Density"
    8180        Properties.Cold.Outlet.rho      =       PP.LiquidDensity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
    8281
    83 "Cold Stream Average Viscosity"
    84         Properties.Cold.Average.Mu      =       PP.LiquidViscosity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    85 
    86 "Cold Stream inlet Viscosity"
    87         Properties.Cold.Inlet.Mu        =       PP.LiquidViscosity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
    88        
    89 "Cold Stream Outlet Viscosity"
    90         Properties.Cold.Outlet.Mu       =       PP.LiquidViscosity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
    91 
    92 "Cold Stream Average Conductivity"
    93         Properties.Cold.Average.K       =       PP.LiquidThermalConductivity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    94 
    95 "Cold Stream Inlet Conductivity"       
    96         Properties.Cold.Inlet.K         =       PP.LiquidThermalConductivity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
    97 
    98 "Cold Stream Outlet Conductivity"
    99         Properties.Cold.Outlet.K        =       PP.LiquidThermalConductivity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
    100 
    101 "Cold Stream Heat Capacity at Wall Temperature"
     82"Viscosity Cold Stream"
     83        Properties.Cold.Average.Mu =    PP.LiquidViscosity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
     84        Properties.Cold.Inlet.Mu =              PP.LiquidViscosity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
     85        Properties.Cold.Outlet.Mu =     PP.LiquidViscosity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
     86
     87"Conductivity Cold Stream"
     88        Properties.Cold.Average.K =     PP.LiquidThermalConductivity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
     89        Properties.Cold.Inlet.K =               PP.LiquidThermalConductivity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
     90        Properties.Cold.Outlet.K =              PP.LiquidThermalConductivity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
     91
     92"Heat Capacity Cold Stream"
    10293        Properties.Cold.Wall.Cp         =       PP.LiquidCp(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
    10394       
    104 "Cold Stream Viscosity at Wall Temperature"
    105         Properties.Cold.Wall.Mu         =       PP.LiquidViscosity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
    106 
    107 "Cold Stream Conductivity at Wall Temperature"
    108         Properties.Cold.Wall.K          =       PP.LiquidThermalConductivity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
     95"Viscosity Cold Stream"
     96        Properties.Cold.Wall.Mu =       PP.LiquidViscosity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
     97
     98"Conductivity Cold Stream"
     99        Properties.Cold.Wall.K =        PP.LiquidThermalConductivity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
    109100
    110101
    111102        else
    112103
    113 "Cold Stream Average Heat Capacity"
     104"Heat Capacity Cold Stream"
    114105        Properties.Cold.Average.Cp      =       PP.VapourCp(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    115 
    116 "Cold Stream Inlet Heat Capacity"       
    117106        Properties.Cold.Inlet.Cp        =       PP.VapourCp(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
    118 
    119 "Cold Stream Outlet Heat Capacity"     
    120107        Properties.Cold.Outlet.Cp       =       PP.VapourCp(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
    121108
    122 "Cold Stream Average Mass Density"
    123         Properties.Cold.Average.rho =   PP.VapourDensity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    124 
    125 "Cold Stream Inlet Mass Density"
     109"Mass Density Cold Stream"
     110        Properties.Cold.Average.rho     =       PP.VapourDensity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    126111        Properties.Cold.Inlet.rho       =       PP.VapourDensity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
    127 
    128 "Cold Stream Outlet Mass Density"       
    129112        Properties.Cold.Outlet.rho      =       PP.VapourDensity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
    130113
    131 "Cold Stream Average Viscosity "
    132         Properties.Cold.Average.Mu      =       PP.VapourViscosity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    133 
    134 "Cold Stream Inlet Viscosity " 
    135         Properties.Cold.Inlet.Mu        =       PP.VapourViscosity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
    136 
    137 "Cold Stream Outlet Viscosity "
    138         Properties.Cold.Outlet.Mu       =       PP.VapourViscosity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
    139 
    140 "Cold Stream Average Conductivity "
    141         Properties.Cold.Average.K       =       PP.VapourThermalConductivity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    142 
    143 "Cold Stream Inlet Conductivity "
    144         Properties.Cold.Inlet.K         =       PP.VapourThermalConductivity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
    145 
    146 "Cold Stream Outlet Conductivity "
    147         Properties.Cold.Outlet.K        =       PP.VapourThermalConductivity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
    148        
    149 "Cold Stream Heat Capacity at Wall Temperature"
     114"Viscosity Cold Stream"
     115        Properties.Cold.Average.Mu =    PP.VapourViscosity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
     116        Properties.Cold.Inlet.Mu =              PP.VapourViscosity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
     117        Properties.Cold.Outlet.Mu =             PP.VapourViscosity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
     118
     119"Conductivity Cold Stream"
     120        Properties.Cold.Average.K =     PP.VapourThermalConductivity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
     121        Properties.Cold.Inlet.K =               PP.VapourThermalConductivity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
     122        Properties.Cold.Outlet.K =              PP.VapourThermalConductivity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
     123       
     124"Heat Capacity Cold Stream"
    150125        Properties.Cold.Wall.Cp         =       PP.VapourCp(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
    151126
    152127
    153 "Cold Stream Viscosity at Wall Temperature"
    154         Properties.Cold.Wall.Mu         =       PP.VapourViscosity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
    155 
    156 "Cold Stream Conductivity at Wall Temperature"
    157         Properties.Cold.Wall.K          =       PP.VapourThermalConductivity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
     128"Viscosity Cold Stream"
     129        Properties.Cold.Wall.Mu =       PP.VapourViscosity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
     130
     131"Conductivity Cold Stream"
     132        Properties.Cold.Wall.K =        PP.VapourThermalConductivity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
    158133       
    159134       
     
    181156
    182157"Conductivity Hot Stream"
    183         Properties.Hot.Average.K        =       PP.LiquidThermalConductivity(Properties.Hot.Average.T,Properties.Hot.Average.P,Inlet.Hot.z);   
     158        Properties.Hot.Average.K        =               PP.LiquidThermalConductivity(Properties.Hot.Average.T,Properties.Hot.Average.P,Inlet.Hot.z);   
    184159        Properties.Hot.Inlet.K  =               PP.LiquidThermalConductivity(Inlet.Hot.T,Inlet.Hot.P,Inlet.Hot.z);     
    185         Properties.Hot.Outlet.K         =       PP.LiquidThermalConductivity(Outlet.Hot.T,Outlet.Hot.P,Outlet.Hot.z);   
     160        Properties.Hot.Outlet.K         =               PP.LiquidThermalConductivity(Outlet.Hot.T,Outlet.Hot.P,Outlet.Hot.z);   
    186161
    187162"Heat Capacity Hot Stream"
    188         Properties.Hot.Wall.Cp          =       PP.LiquidCp(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);
     163        Properties.Hot.Wall.Cp  =               PP.LiquidCp(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);
    189164
    190165"Viscosity Hot Stream"
    191         Properties.Hot.Wall.Mu          =       PP.LiquidViscosity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);     
     166        Properties.Hot.Wall.Mu  =               PP.LiquidViscosity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);     
    192167
    193168"Conductivity Hot Stream"
    194         Properties.Hot.Wall.K           =       PP.LiquidThermalConductivity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);   
     169        Properties.Hot.Wall.K   =               PP.LiquidThermalConductivity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);   
    195170       
    196171
     
    213188
    214189"Conductivity Hot Stream"
    215         Properties.Hot.Average.K        =       PP.VapourThermalConductivity(Properties.Hot.Average.T,Properties.Hot.Average.P,Inlet.Hot.z);   
     190        Properties.Hot.Average.K        =               PP.VapourThermalConductivity(Properties.Hot.Average.T,Properties.Hot.Average.P,Inlet.Hot.z);   
    216191        Properties.Hot.Inlet.K  =               PP.VapourThermalConductivity(Inlet.Hot.T,Inlet.Hot.P,Inlet.Hot.z);     
    217         Properties.Hot.Outlet.K         =       PP.VapourThermalConductivity(Outlet.Hot.T,Outlet.Hot.P,Outlet.Hot.z);   
     192        Properties.Hot.Outlet.K         =               PP.VapourThermalConductivity(Outlet.Hot.T,Outlet.Hot.P,Outlet.Hot.z);   
    218193
    219194"Heat Capacity Hot Stream"
    220         Properties.Hot.Wall.Cp  =       PP.VapourCp(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);
     195        Properties.Hot.Wall.Cp  =               PP.VapourCp(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);
    221196
    222197"Viscosity Hot Stream"
    223         Properties.Hot.Wall.Mu  =       PP.VapourViscosity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);
     198        Properties.Hot.Wall.Mu  =               PP.VapourViscosity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);
    224199
    225200"Conductivity Hot Stream"
    226         Properties.Hot.Wall.K   =       PP.VapourThermalConductivity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);   
    227 
    228 
    229 end
    230 
    231 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    232 #                                       Thermal Details                                                                 #
    233 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    234 
     201        Properties.Hot.Wall.K   =               PP.VapourThermalConductivity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);   
     202
     203
     204end
     205
     206#=====================================================================
     207#       Thermal Details
     208#=====================================================================
    235209"Hot Stream Heat Capacity"
    236210        Details.Ch =Inlet.Hot.F*Properties.Hot.Average.Cp;
     
    239213        Details.Cc =Inlet.Cold.F*Properties.Cold.Average.Cp;
    240214       
    241 "Minimum Heat Capacity"
    242         Details.Cmin  = min([Details.Ch,Details.Cc]);
    243        
    244 "Maximum Heat Capacity"
    245         Details.Cmax  = max([Details.Ch,Details.Cc]);
    246 
    247215"Heat Capacity Ratio"
    248         Details.Cr    = Details.Cmin/Details.Cmax;
    249 
    250 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    251 #                                       Energy Balance
    252 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    253 
     216        [Details.Cmin,Details.Cmax,Details.Cr]  = HE.HeatCapacityRatio(Details.Ch,Details.Cc);
     217
     218#=====================================================================
     219#       Energy Balance
     220#=====================================================================
    254221"Energy Balance Hot Stream"
    255222        Details.Q = Inlet.Hot.F*(Inlet.Hot.h-Outlet.Hot.h);
     
    258225        Details.Q =-Inlet.Cold.F*(Inlet.Cold.h-Outlet.Cold.h);
    259226
    260 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    261 #                                       Material Balance
    262 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     227#=====================================================================
     228#       Material Balance
     229#=====================================================================
    263230"Flow Mass Inlet Cold Stream"
    264231        Properties.Cold.Inlet.Fw        =  sum(M*Inlet.Cold.z)*Inlet.Cold.F;
     
    279246        Inlet.Cold.F = Outlet.Cold.F;
    280247
    281 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    282 #                                       Constraints
    283 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     248#======================================
     249#       Constraints
     250#======================================
    284251"Hot Stream Molar Fraction Constraint"
    285252        Outlet.Hot.z=Inlet.Hot.z;
     
    293260"No Phase Change In Hot Stream"
    294261        Inlet.Hot.v=Outlet.Hot.v;
     262
    295263       
    296264end
     
    300268PARAMETERS
    301269
    302 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    303 #                               Basic  Parameters                                                                       #
    304 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    305 ext PP          as CalcObject   (Brief="External Physical Properties");
    306 side        as Integer          (Brief="Fluid Alocation Flag",Lower=0,Upper=1);
     270ext PP          as CalcObject;
     271ext     HE              as CalcObject   (Brief="STHE Calculations",File="heatex.dll");
     272side        as Integer          (Brief="Fluid Alocation",Lower=0,Upper=1);
    307273Pi                      as constant     (Brief="Pi Number",Default=3.14159265);
    308 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    309 #                               Shell Geometrical Parameters                                            #
    310 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     274
     275#=====================================================================
     276#       Shell Geometrical Parameters
     277#=====================================================================
    311278Tpass                   as Integer              (Brief="Number of Tube Passes",Lower=1);
    312279Nss                             as Integer              (Brief="Number of Sealing Strips pairs",Lower=1);
     
    317284Honozzle_Shell  as length               (Brief="Height Under Shell Outlet Nozzle",Lower=10e-6);
    318285Lcf                     as length               (Brief="Bundle-to-Shell Clearance",Lower=10e-8);
    319 
    320 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    321 #                               Tubes Geometrical Parameters                                            #
    322 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    323 Ntt                       as Integer            (Brief="Total Number of Tubes in Shell",Default=100,Lower=1);
    324 Pattern       as Integer                (Brief="Tube Layout Characteristic Angle",Lower=30);
    325 Ltube             as length                     (Brief="Effective Tube Length",Lower=0.1);
    326 pitch             as length                     (Brief="Tube Pitch",Lower=1e-8);
    327 Kwall             as conductivity       (Brief="Tube Wall Material Thermal Conductivity");
    328 Dotube            as length                     (Brief="Tube Outside Diameter",Lower=10e-6);
    329 Ditube            as length                     (Brief="Tube Inside Diameter",Lower=10e-6);
    330 Donozzle_Tube as length                 (Brief="Tube Outlet Nozzle Diameter",Lower=10e-6);
    331 Dinozzle_Tube as length                 (Brief="Tube Inlett Nozzle Diameter",Lower=10e-6);
    332 
    333 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    334 #                               Baffles Geometrical Parameters                                          #
    335 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    336 Bc     as Integer (Brief="Baffle Cut",Default=25,Lower=25);
    337 Nb     as Real    (Brief="Number of Baffles",Lower=1);
    338 Lcd    as length  (Brief="Baffle-to-Shell Clearance",Lower=10e-8);
    339 Ltd        as length  (Brief="Tube-to-Bafflehole Clearance",Lower=10e-8);
    340 
    341 SET
    342 
    343 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    344 #             Set Parameters for heatex Calculation                                     #
    345 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     286#=====================================================================
     287#       Tubes Geometrical Parameters
     288#=====================================================================
     289Ntt                             as Integer              (Brief="Total Number of Tubes in Shell",Default=100,Lower=1);
     290Pattern         as Integer              (Brief="Tube Layout Characteristic Angle",Lower=30);
     291Ltube                   as length               (Brief="Effective Tube Length",Lower=0.1);
     292pitch                   as length               (Brief="Tube Pitch",Lower=1e-8);
     293Kwall                   as conductivity (Brief="Tube Wall Material Thermal Conductivity");
     294Dotube                  as length               (Brief="Tube Outside Diameter",Lower=10e-6);
     295Ditube                  as length               (Brief="Tube Inside Diameter",Lower=10e-6);
     296Donozzle_Tube   as length               (Brief="Tube Outlet Nozzle Diameter",Lower=10e-6);
     297Dinozzle_Tube   as length               (Brief="Tube Inlett Nozzle Diameter",Lower=10e-6);
     298#=====================================================================
     299#       Baffles Geometrical Parameters
     300#=====================================================================
     301Bc                      as Integer              (Brief="Baffle Cut",Default=25,Lower=25);
     302Nb              as Real                 (Brief="Number of Baffles",Lower=1);
     303Lcd                     as length               (Brief="Baffle-to-Shell Clearance",Lower=10e-8);
     304Ltd                             as length               (Brief="Tube-to-Bafflehole Clearance",Lower=10e-8);
     305#=====================================================================
     306#=====================================================================
     307EQUATIONS
     308#=====================================================================
     309
     310"Shell Side Cross Flow Area"
     311        Shell.HeatTransfer.Sm = HE.CrossFlowArea(Baffles.Ls);
     312       
     313"Ji Factor"
     314        Shell.HeatTransfer.Ji = HE.JiFactor(Shell.HeatTransfer.Re);
     315
     316"Jc Factor"
     317        Shell.HeatTransfer.Jc = HE.JcFactor();
     318       
     319"Jl Factor"
     320        Shell.HeatTransfer.Jl = HE.JlFactor(Shell.HeatTransfer.Sm);
     321
     322"Jb Factor"
     323        Shell.HeatTransfer.Jb = HE.JbFactor(Shell.HeatTransfer.Re,Baffles.Ls,Shell.HeatTransfer.Sm);
     324
     325"Jr Factor"     
     326        Shell.HeatTransfer.Jr = HE.JrFactor(Shell.HeatTransfer.Re);
     327       
     328"Total J Factor"
     329        Shell.HeatTransfer.Jtotal=Shell.HeatTransfer.Jc*Shell.HeatTransfer.Jl*Shell.HeatTransfer.Jb*Shell.HeatTransfer.Jr*Shell.HeatTransfer.Js;
     330
     331#=====================================================================
     332#  Fluid Alocation
     333#=====================================================================
     334
     335if side equal 1 then
     336       
     337       
     338"Shell Side Phi correction"
     339        Shell.HeatTransfer.Phi = HE.PhiCorrection(Properties.Hot.Average.Mu,Properties.Hot.Wall.Mu);
     340       
     341"Tube Side Phi correction"
     342        Tubes.HeatTransfer.Phi  = HE.PhiCorrection(Properties.Cold.Average.Mu,Properties.Cold.Wall.Mu);
     343       
     344        else
     345       
     346
     347"Shell Side Phi correction"
     348        Shell.HeatTransfer.Phi = HE.PhiCorrection(Properties.Cold.Average.Mu,Properties.Cold.Wall.Mu);
     349       
     350"Tube Side Phi correction"
     351        Tubes.HeatTransfer.Phi  = HE.PhiCorrection(Properties.Hot.Average.Mu,Properties.Hot.Wall.Mu);
     352
     353end
     354
     355
     356if side equal 1
     357       
     358        then
     359       
     360"Wall Temperature"
     361#       Properties.Hot.Wall.Twall = HE.WallTemperature(Properties.Hot.Average.T,Properties.Cold.Average.T,Tubes.HeatTransfer.htube,Shell.HeatTransfer.hshell);
     362
     363#       Properties.Cold.Wall.Twall = HE.WallTemperature(Properties.Cold.Average.T,Properties.Hot.Average.T,Tubes.HeatTransfer.htube,Shell.HeatTransfer.hshell);
     364
     365Properties.Hot.Wall.Twall  = (Properties.Hot.Average.T+Properties.Cold.Average.T)/2;
     366
     367Properties.Cold.Wall.Twall  = (Properties.Hot.Average.T+Properties.Cold.Average.T)/2;
     368
     369"Tube Side Velocity"
     370        Tubes.HeatTransfer.Vtube  = HE.TubeVelocity(Properties.Cold.Inlet.Fw,Properties.Cold.Average.rho);
     371
     372"Tube Side Reynolds Number"
     373        Tubes.HeatTransfer.Re = HE.TubeReynoldsNumber(Properties.Cold.Average.rho,Tubes.HeatTransfer.Vtube,Properties.Cold.Average.Mu);
     374       
     375"Tube Side Prandtl Number"
     376        Tubes.HeatTransfer.PR = HE.PrandtlNumber(Properties.Cold.Average.K,Properties.Cold.Average.Cp,Properties.Cold.Average.Mw,Properties.Cold.Average.Mu);
     377
     378"Tube Side Prandtl Number at Wall Temperature"
     379        Tubes.HeatTransfer.PRw = HE.PrandtlNumber(Properties.Cold.Wall.K,Properties.Cold.Wall.Cp,Properties.Cold.Average.Mw,Properties.Cold.Wall.Mu);
     380
     381"Tube Side Film Coefficient"
     382        Tubes.HeatTransfer.htube= HE.TubeFilmCoeff(Tubes.HeatTransfer.Re,Tubes.HeatTransfer.PR,Properties.Cold.Average.K,Tubes.HeatTransfer.Phi);
     383       
     384"Shell Side Prandtl Number"
     385        Shell.HeatTransfer.PR=HE.PrandtlNumber(Properties.Hot.Average.K,Properties.Hot.Average.Cp,Properties.Hot.Average.Mw,Properties.Hot.Average.Mu);
     386
     387"Shell Side Prandtl Number at Wall Temperature"
     388        Shell.HeatTransfer.PRw = HE.PrandtlNumber(Properties.Hot.Wall.K,Properties.Hot.Wall.Cp,Properties.Hot.Average.Mw,Properties.Hot.Wall.Mu);       
     389
     390"Tube Side Pressure Drop"
     391        Tubes.PressureDrop.PdTube               = HE.DeltaPtube(Tubes.HeatTransfer.Re,Properties.Cold.Average.rho,Tubes.HeatTransfer.Vtube,Tubes.HeatTransfer.Phi);
     392
     393"Pressure Drop Tube Side Inlet Nozzle"
     394        Tubes.PressureDrop.Pdnozzle_in  = HE.DeltaPtubeNozzlein(Properties.Cold.Inlet.rho,Properties.Cold.Inlet.Fw);
     395
     396"Velocity Tube Side Inlet Nozzle"
     397        Tubes.PressureDrop.Vnozzle_in   = HE.TubeVelocityNozzlein(Properties.Cold.Inlet.rho,Properties.Cold.Inlet.Fw);
     398
     399"Pressure Drop Tube Side Outlet Nozzle"
     400        Tubes.PressureDrop.Pdnozzle_out = HE.DeltaPtubeNozzleout(Properties.Cold.Outlet.rho,Properties.Cold.Inlet.Fw);
     401
     402"Velocity Tube Side Outlet Nozzle"
     403        Tubes.PressureDrop.Vnozzle_out  = HE.TubeVelocityNozzleout(Properties.Cold.Outlet.rho,Properties.Cold.Inlet.Fw);
     404
     405"Shell Pressure Drop Inlet Nozzle"
     406        Shell.PressureDrop.Pdnozzle_in  = HE.DeltaPshellNozzleIn(Properties.Hot.Inlet.rho,Properties.Hot.Inlet.Fw);
     407
     408"Velocity Shell Side Inlet Nozzle"
     409        Shell.PressureDrop.Vnozzle_in   = HE.ShellVelocityNozzleIn(Properties.Hot.Inlet.rho,Properties.Hot.Inlet.Fw);
     410
     411"Shell Pressure Drop Outlet Nozzle"
     412        Shell.PressureDrop.Pdnozzle_out =HE.DeltaPshellNozzleOut(Properties.Hot.Outlet.rho,Properties.Hot.Inlet.Fw);
     413
     414"Velocity Shell Side Outlet Nozzle"
     415        Shell.PressureDrop.Vnozzle_out  =HE.ShellVelocityNozzleOut(Properties.Hot.Outlet.rho,Properties.Hot.Inlet.Fw);
     416
     417"Pressure Drop Hot Stream"
     418        Outlet.Hot.P  = Inlet.Hot.P- Shell.PressureDrop.Pdtotal;       
     419       
     420"Pressure Drop Cold Stream"
     421        Outlet.Cold.P  = Inlet.Cold.P - Tubes.PressureDrop.Pdtotal;
     422
     423
     424        else
     425
     426"Wall Temperature"
     427#       Properties.Cold.Wall.Twall = HE.WallTemperature(Properties.Cold.Average.T,Properties.Hot.Average.T,Tubes.HeatTransfer.htube,Shell.HeatTransfer.hshell);
     428
     429#       Properties.Hot.Wall.Twall = HE.WallTemperature(Properties.Hot.Average.T,Properties.Cold.Average.T,Tubes.HeatTransfer.htube,Shell.HeatTransfer.hshell);
     430
     431
     432Properties.Hot.Wall.Twall  = (Properties.Hot.Average.T+Properties.Cold.Average.T)/2;
     433
     434Properties.Cold.Wall.Twall  = (Properties.Hot.Average.T+Properties.Cold.Average.T)/2;
     435
     436"Tube Side Velocity"
     437        Tubes.HeatTransfer.Vtube=HE.TubeVelocity(Properties.Hot.Inlet.Fw,Properties.Hot.Average.rho);
     438
     439"Tube Side Reynolds Number"
     440        Tubes.HeatTransfer.Re=HE.TubeReynoldsNumber(Properties.Hot.Average.rho,Tubes.HeatTransfer.Vtube,Properties.Hot.Average.Mu);
     441       
     442"Tube Side Prandtl Number"
     443        Tubes.HeatTransfer.PR=HE.PrandtlNumber(Properties.Hot.Average.K,Properties.Hot.Average.Cp,Properties.Hot.Average.Mw,Properties.Hot.Average.Mu);
     444
     445"Tube Side Prandtl Number at Wall"
     446        Tubes.HeatTransfer.PRw=HE.PrandtlNumber(Properties.Hot.Wall.K,Properties.Hot.Wall.Cp,Properties.Hot.Average.Mw,Properties.Hot.Wall.Mu);
     447
     448"Tube Side Film Coefficient"
     449        Tubes.HeatTransfer.htube= HE.TubeFilmCoeff(Tubes.HeatTransfer.Re,Tubes.HeatTransfer.PR,Properties.Hot.Average.K,Tubes.HeatTransfer.Phi);
     450       
     451"Shell Side Prandtl Number"
     452        Shell.HeatTransfer.PR=HE.PrandtlNumber(Properties.Cold.Average.K,Properties.Cold.Average.Cp,Properties.Cold.Average.Mw,Properties.Cold.Average.Mu);
     453
     454"Shell Side Prandtl Number at Wall"
     455        Shell.HeatTransfer.PRw=HE.PrandtlNumber(Properties.Cold.Wall.K,Properties.Cold.Wall.Cp,Properties.Cold.Average.Mw,Properties.Cold.Wall.Mu);
     456
     457"Tube Side Pressure Drop"
     458        Tubes.PressureDrop.PdTube               = HE.DeltaPtube(Tubes.HeatTransfer.Re,Properties.Hot.Average.rho,Tubes.HeatTransfer.Vtube,Tubes.HeatTransfer.Phi);
     459
     460"Pressure Drop Tube Side Inlet Nozzle"
     461        Tubes.PressureDrop.Pdnozzle_in  = HE.DeltaPtubeNozzlein(Properties.Hot.Inlet.rho,Properties.Hot.Inlet.Fw);
     462
     463"Velocity Tube Side Inlet Nozzle"
     464        Tubes.PressureDrop.Vnozzle_in   = HE.TubeVelocityNozzlein(Properties.Hot.Inlet.rho,Properties.Hot.Inlet.Fw);
     465
     466"Pressure Drop Tube Side Outlet Nozzle"
     467        Tubes.PressureDrop.Pdnozzle_out = HE.DeltaPtubeNozzleout(Properties.Hot.Outlet.rho,Properties.Hot.Inlet.Fw);   
     468
     469"Velocity Tube Side Outlet Nozzle"
     470        Tubes.PressureDrop.Vnozzle_out  = HE.TubeVelocityNozzleout(Properties.Hot.Outlet.rho,Properties.Hot.Inlet.Fw); 
     471
     472"Shell Pressure Drop Inlet Nozzle"
     473        Shell.PressureDrop.Pdnozzle_in  = HE.DeltaPshellNozzleIn(Properties.Cold.Inlet.rho,Properties.Cold.Inlet.Fw);
     474
     475"Velocity Shell Side Inlet Nozzle"
     476        Shell.PressureDrop.Vnozzle_in   = HE.ShellVelocityNozzleIn(Properties.Cold.Inlet.rho,Properties.Cold.Inlet.Fw);
     477
     478"Shell Pressure Drop Outlet Nozzle"
     479        Shell.PressureDrop.Pdnozzle_out = HE.DeltaPshellNozzleOut(Properties.Cold.Outlet.rho,Properties.Cold.Inlet.Fw);
     480
     481"Velocity Shell Side Outlet Nozzle"
     482        Shell.PressureDrop.Vnozzle_out  = HE.ShellVelocityNozzleOut(Properties.Cold.Outlet.rho,Properties.Cold.Inlet.Fw);
     483
     484"Pressure Drop Hot Stream"
     485        Outlet.Hot.P  = Inlet.Hot.P- Tubes.PressureDrop.Pdtotal;       
     486       
     487"Pressure Drop Cold Stream"
     488        Outlet.Cold.P  = Inlet.Cold.P - Shell.PressureDrop.Pdtotal;
     489
     490
     491end
     492
     493#=====================================================================
     494
     495"Tube Resistance"       
     496        Resistances.Rtube*(Tubes.HeatTransfer.htube*Ditube) = Dotube;
     497       
     498"Wall Resistance"
     499        Resistances.Rwall=Dotube*ln(Dotube/Ditube)/(2*Kwall);
     500       
     501"Shell Resistance"
     502        Resistances.Rshell*(Shell.HeatTransfer.hshell)=1;
     503       
     504"Overall Heat Transfer Coefficient"
     505        Details.U=1/(Dotube/(Tubes.HeatTransfer.htube*Ditube)+(Dotube*ln(Dotube/Ditube)/(2*Kwall))+(1/(Shell.HeatTransfer.hshell)));
     506
     507"Exchange Surface Area"
     508        Details.A=Pi*Dotube*Ntt*Ltube;
     509
     510"Baffles Spacing"
     511        Ltube = Baffles.Lsi+Baffles.Lso+Baffles.Ls*(Nb-1);
     512       
     513       
     514
     515        SET
     516#=====================================================================
     517#  Set Parameters for heatex Calculation
     518#=====================================================================
    346519        Pi                              = 3.14159265;
    347520        HE.Tpass                        = Tpass;
     
    367540        side                            = HE.FluidAlocation();
    368541       
     542end
     543
     544Model Heatex_Detailed_NTU               as Heatex_Detailed
     545       
     546VARIABLES
     547
     548Eft                              as positive            (Brief="Effectiveness",Default=0.05,Lower=1e-8);
     549       
     550EQUATIONS       
     551Details.Q       = Eft*Details.Cmin*(Inlet.Hot.T-Inlet.Cold.T); 
     552       
     553end
     554
     555Model Heatex_Detailed_LMTD              as Heatex_Detailed
     556       
     557VARIABLES
     558LMTD            as temp_delta   (Brief="Logarithmic Mean Temperature Difference",Lower=5);
     559Fc                      as positive             (Brief="LMTD Correction Factor",Lower=0.7);
     560MTD                     as temp_delta   (Brief="Mean Temperature Difference",Lower=5);
     561
    369562EQUATIONS
    370 
    371 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    372 #                               Heat Transfer Correction Factors                                        #
    373 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    374 "Ji Factor"
    375         Shell.HeatTransfer.Ji = HE.JiFactor(Shell.HeatTransfer.Re);
    376 
    377 "Jc Factor"
    378         Shell.HeatTransfer.Jc = HE.JcFactor();
    379        
    380 "Jl Factor"
    381         Shell.HeatTransfer.Jl = HE.JlFactor(Shell.HeatTransfer.Sm);
    382 
    383 "Jb Factor"
    384         Shell.HeatTransfer.Jb = HE.JbFactor(Shell.HeatTransfer.Re,Baffles.Ls,Shell.HeatTransfer.Sm);
    385 
    386 "Jr Factor"     
    387         Shell.HeatTransfer.Jr = HE.JrFactor(Shell.HeatTransfer.Re);
    388        
    389 "Total J Factor"
    390         Shell.HeatTransfer.Jtotal =     Shell.HeatTransfer.Jc*Shell.HeatTransfer.Jl*Shell.HeatTransfer.Jb*Shell.HeatTransfer.Jr*Shell.HeatTransfer.Js;
    391 
    392 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    393 #                                        Nozzles rho-V^2                                                                #
    394 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    395 
    396 if side equal 1
    397        
    398         then
    399 
    400 "Shell Side inlet Nozzle rho-V^2"
    401         Shell.PressureDrop.RVsquare_in = Properties.Hot.Inlet.rho*(Shell.PressureDrop.Vnozzle_in)^2;
    402 
    403 "Shell Side Outlet Nozzle rho-V^2"
    404         Shell.PressureDrop.RVsquare_out = Properties.Hot.Outlet.rho*(Shell.PressureDrop.Vnozzle_out)^2;
    405        
    406         else
    407        
    408 "Shell Side inlet Nozzle rho-V^2"
    409         Shell.PressureDrop.RVsquare_in = Properties.Cold.Inlet.rho*(Shell.PressureDrop.Vnozzle_in)^2;
    410 
    411 "Shell Side Outlet Nozzle rho-V^2"
    412         Shell.PressureDrop.RVsquare_out = Properties.Cold.Outlet.rho*(Shell.PressureDrop.Vnozzle_out)^2;
    413 
    414 end
    415 
    416 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    417 #                                        Phi correction                                                                 #
    418 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    419 
    420 if side equal 1
    421        
    422         then
    423 
    424 "Shell Side Phi correction"
    425         Shell.HeatTransfer.Phi = HE.PhiCorrection(Properties.Hot.Average.Mu,Properties.Hot.Wall.Mu);
    426        
    427 "Tube Side Phi correction"
    428         Tubes.HeatTransfer.Phi  = HE.PhiCorrection(Properties.Cold.Average.Mu,Properties.Cold.Wall.Mu);
    429        
    430         else
    431        
    432 "Shell Side Phi correction"
    433         Shell.HeatTransfer.Phi = HE.PhiCorrection(Properties.Cold.Average.Mu,Properties.Cold.Wall.Mu);
    434        
    435 "Tube Side Phi correction"
    436         Tubes.HeatTransfer.Phi  = HE.PhiCorrection(Properties.Hot.Average.Mu,Properties.Hot.Wall.Mu);
    437 
    438 end
    439 
    440 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    441 #                                                                                                                                       #
    442 #                                                                                                                                       #
    443 #                                                                                                                                       #
    444 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    445 
    446 if side equal 1
    447        
    448         then
    449        
    450 "Hot Wall Temperature"
    451         Properties.Hot.Wall.Twall  = (Properties.Hot.Average.T+Properties.Cold.Average.T)/2;
    452 
    453 "ColdWall Temperature"
    454         Properties.Cold.Wall.Twall  = (Properties.Hot.Average.T+Properties.Cold.Average.T)/2;
    455 
    456 "Tube Side Velocity"
    457         Tubes.HeatTransfer.Vtube  = Properties.Cold.Inlet.Fw*Tpass/((Pi*Ditube*Ditube/4)*Properties.Cold.Average.rho*Ntt);
    458 
    459 "Tube Side Reynolds Number"
    460         Tubes.HeatTransfer.Re     =     (Properties.Cold.Average.rho*Tubes.HeatTransfer.Vtube*Ditube)/Properties.Cold.Average.Mu;
    461        
    462 "Tube Side Prandtl Number"
    463         Tubes.HeatTransfer.PR = ((Properties.Cold.Average.Cp/Properties.Cold.Average.Mw)*Properties.Cold.Average.Mu)/Properties.Cold.Average.K;
    464 
    465 "Tube Side Prandtl Number at Wall Temperature"
    466         Tubes.HeatTransfer.PRw = ((Properties.Cold.Wall.Cp/Properties.Cold.Average.Mw)*Properties.Cold.Wall.Mu)/Properties.Cold.Wall.K;
    467 
    468 "Tube Side Film Coefficient"
    469         Tubes.HeatTransfer.htube= HE.TubeFilmCoeff(Tubes.HeatTransfer.Re,Tubes.HeatTransfer.PR,Properties.Cold.Average.K)*Tubes.HeatTransfer.Phi;
    470 
    471 "Shell Side Prandtl Number"
    472         Shell.HeatTransfer.PR = ((Properties.Hot.Average.Cp/Properties.Hot.Average.Mw)*Properties.Hot.Average.Mu)/Properties.Hot.Average.K;
    473 
    474 "Shell Side Prandtl Number at Wall Temperature"
    475         Shell.HeatTransfer.PRw = ((Properties.Hot.Wall.Cp/Properties.Hot.Average.Mw)*Properties.Hot.Wall.Mu)/Properties.Hot.Wall.K;
    476 
    477 "Tube Side Pressure Drop"
    478         Tubes.PressureDrop.PdTube               = HE.DeltaPtube(Tubes.HeatTransfer.Re,Properties.Cold.Average.rho,Tubes.HeatTransfer.Vtube,Tubes.HeatTransfer.Phi);
    479 
    480 "Pressure Drop Tube Side Inlet Nozzle"
    481         Tubes.PressureDrop.Pdnozzle_in  = HE.DeltaPtubeNozzlein(Properties.Cold.Inlet.rho,Properties.Cold.Inlet.Fw);
    482 
    483 "Velocity Tube Side Inlet Nozzle"
    484         Tubes.PressureDrop.Vnozzle_in   = HE.TubeVelocityNozzlein(Properties.Cold.Inlet.rho,Properties.Cold.Inlet.Fw);
    485 
    486 "Pressure Drop Tube Side Outlet Nozzle"
    487         Tubes.PressureDrop.Pdnozzle_out = HE.DeltaPtubeNozzleout(Properties.Cold.Outlet.rho,Properties.Cold.Inlet.Fw);
    488 
    489 "Velocity Tube Side Outlet Nozzle"
    490         Tubes.PressureDrop.Vnozzle_out  = HE.TubeVelocityNozzleout(Properties.Cold.Outlet.rho,Properties.Cold.Inlet.Fw);
    491 
    492 "Shell Pressure Drop Inlet Nozzle"
    493         Shell.PressureDrop.Pdnozzle_in  = HE.DeltaPshellNozzleIn(Properties.Hot.Inlet.rho,Properties.Hot.Inlet.Fw);
    494 
    495 "Velocity Shell Side Inlet Nozzle"
    496         Shell.PressureDrop.Vnozzle_in   = HE.ShellVelocityNozzleIn(Properties.Hot.Inlet.rho,Properties.Hot.Inlet.Fw);
    497 
    498 "Shell Pressure Drop Outlet Nozzle"
    499         Shell.PressureDrop.Pdnozzle_out =HE.DeltaPshellNozzleOut(Properties.Hot.Outlet.rho,Properties.Hot.Inlet.Fw);
    500 
    501 "Velocity Shell Side Outlet Nozzle"
    502         Shell.PressureDrop.Vnozzle_out  =HE.ShellVelocityNozzleOut(Properties.Hot.Outlet.rho,Properties.Hot.Inlet.Fw);
    503 
    504 "Pressure Drop Hot Stream"
    505         Outlet.Hot.P  = Inlet.Hot.P- Shell.PressureDrop.Pdtotal;       
    506        
    507 "Pressure Drop Cold Stream"
    508         Outlet.Cold.P  = Inlet.Cold.P - Tubes.PressureDrop.Pdtotal;
    509 
    510 
    511         else
    512 
    513 "Hot Wall Temperature"
    514         Properties.Hot.Wall.Twall  = (Properties.Hot.Average.T+Properties.Cold.Average.T)/2;
    515 
    516 "Cold Wall Temperature"
    517         Properties.Cold.Wall.Twall  = (Properties.Hot.Average.T+Properties.Cold.Average.T)/2;
    518 
    519 "Tube Side Velocity"
    520         Tubes.HeatTransfer.Vtube  = Properties.Hot.Inlet.Fw*Tpass/((Pi*Ditube*Ditube/4)*Properties.Hot.Average.rho*Ntt);
    521 
    522 "Tube Side Reynolds Number"
    523         Tubes.HeatTransfer.Re=(Properties.Hot.Average.rho*Tubes.HeatTransfer.Vtube*Ditube)/Properties.Hot.Average.Mu;
    524 
    525 "Tube Side Prandtl Number"
    526         Tubes.HeatTransfer.PR = ((Properties.Hot.Average.Cp/Properties.Hot.Average.Mw)*Properties.Hot.Average.Mu)/Properties.Hot.Average.K;
    527 
    528 "Tube Side Prandtl Number at Wall"
    529         Tubes.HeatTransfer.PRw = ((Properties.Hot.Wall.Cp/Properties.Hot.Average.Mw)*Properties.Hot.Wall.Mu)/Properties.Hot.Wall.K;
    530 
    531 "Tube Side Film Coefficient"
    532         Tubes.HeatTransfer.htube= HE.TubeFilmCoeff(Tubes.HeatTransfer.Re,Tubes.HeatTransfer.PR,Properties.Hot.Average.K)*Tubes.HeatTransfer.Phi;
    533        
    534 "Shell Side Prandtl Number"
    535         Shell.HeatTransfer.PR = ((Properties.Cold.Average.Cp/Properties.Cold.Average.Mw)*Properties.Cold.Average.Mu)/Properties.Cold.Average.K;
    536 
    537 "Shell Side Prandtl Number at Wall"
    538         Shell.HeatTransfer.PRw=((Properties.Cold.Wall.Cp/Properties.Cold.Average.Mw)*Properties.Cold.Wall.Mu)/Properties.Cold.Wall.K;
    539 
    540 "Tube Side Pressure Drop"
    541         Tubes.PressureDrop.PdTube               = HE.DeltaPtube(Tubes.HeatTransfer.Re,Properties.Hot.Average.rho,Tubes.HeatTransfer.Vtube,Tubes.HeatTransfer.Phi);
    542 
    543 "Pressure Drop Tube Side Inlet Nozzle"
    544         Tubes.PressureDrop.Pdnozzle_in  = HE.DeltaPtubeNozzlein(Properties.Hot.Inlet.rho,Properties.Hot.Inlet.Fw);
    545 
    546 "Velocity Tube Side Inlet Nozzle"
    547         Tubes.PressureDrop.Vnozzle_in   = HE.TubeVelocityNozzlein(Properties.Hot.Inlet.rho,Properties.Hot.Inlet.Fw);
    548 
    549 "Pressure Drop Tube Side Outlet Nozzle"
    550         Tubes.PressureDrop.Pdnozzle_out = HE.DeltaPtubeNozzleout(Properties.Hot.Outlet.rho,Properties.Hot.Inlet.Fw);   
    551 
    552 "Velocity Tube Side Outlet Nozzle"
    553         Tubes.PressureDrop.Vnozzle_out  = HE.TubeVelocityNozzleout(Properties.Hot.Outlet.rho,Properties.Hot.Inlet.Fw); 
    554 
    555 "Shell Pressure Drop Inlet Nozzle"
    556         Shell.PressureDrop.Pdnozzle_in  = HE.DeltaPshellNozzleIn(Properties.Cold.Inlet.rho,Properties.Cold.Inlet.Fw);
    557 
    558 "Velocity Shell Side Inlet Nozzle"
    559         Shell.PressureDrop.Vnozzle_in   = HE.ShellVelocityNozzleIn(Properties.Cold.Inlet.rho,Properties.Cold.Inlet.Fw);
    560 
    561 "Shell Pressure Drop Outlet Nozzle"
    562         Shell.PressureDrop.Pdnozzle_out = HE.DeltaPshellNozzleOut(Properties.Cold.Outlet.rho,Properties.Cold.Inlet.Fw);
    563 
    564 "Velocity Shell Side Outlet Nozzle"
    565         Shell.PressureDrop.Vnozzle_out  = HE.ShellVelocityNozzleOut(Properties.Cold.Outlet.rho,Properties.Cold.Inlet.Fw);
    566 
    567 "Pressure Drop Hot Stream"
    568         Outlet.Hot.P  = Inlet.Hot.P- Tubes.PressureDrop.Pdtotal;       
    569        
    570 "Pressure Drop Cold Stream"
    571         Outlet.Cold.P  = Inlet.Cold.P - Shell.PressureDrop.Pdtotal;
    572 
    573 end
    574 
    575 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    576 #                                               Resistances                                                                     #
    577 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    578 
    579 "Tube Resistance"       
    580         Resistances.Rtube*(Tubes.HeatTransfer.htube*Ditube) = Dotube;
    581        
    582 "Wall Resistance"
    583         Resistances.Rwall=Dotube*ln(Dotube/Ditube)/(2*Kwall);
    584        
    585 "Shell Resistance"
    586         Resistances.Rshell*(Shell.HeatTransfer.hshell)=1;
    587 
    588 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    589 #                                                                                                                                       #
    590 #                                                                                                                                       #
    591 #                                                                                                                                       #
    592 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    593 
    594 "Shell Side Cross Flow Area"
    595         Shell.HeatTransfer.Sm = HE.CrossFlowArea(Baffles.Ls);
    596        
    597 "Overall Heat Transfer Coefficient"
    598         Details.U=1/(Dotube/(Tubes.HeatTransfer.htube*Ditube)+(Dotube*ln(Dotube/Ditube)/(2*Kwall))+(1/(Shell.HeatTransfer.hshell)));
    599 
    600 "Exchange Surface Area"
    601         Details.A=Pi*Dotube*Ntt*Ltube;
    602 
    603 "Baffles Spacing"
    604         Ltube = Baffles.Lsi+Baffles.Lso+Baffles.Ls*(Nb-1);
    605 
    606 end
    607 
    608 Model Heatex_Detailed_NTU               as Heatex_Detailed
    609        
    610 VARIABLES
    611 
    612 Eft                      as positive (Brief="Effectiveness",Default=0.05,Lower=1e-8);
    613        
    614 EQUATIONS
    615 "Duty"
    616         Details.Q       = Eft*Details.Cmin*(Inlet.Hot.T-Inlet.Cold.T); 
    617        
    618 end
    619 
    620 Model Heatex_Detailed_LMTD              as Heatex_Detailed
    621        
    622 VARIABLES
    623 DT0     as temp_delta   (Brief="Temperature Difference at Inlet",Lower=1);
    624 DTL             as temp_delta   (Brief="Temperature Difference at Outlet",Lower=1);
    625 LMTD    as temp_delta   (Brief="Logarithmic Mean Temperature Difference",Lower=5);
    626 Fc              as positive             (Brief="LMTD Correction Factor",Lower=0.4);
    627 MTD             as temp_delta   (Brief="Mean Temperature Difference",Lower=5);
    628 
    629 EQUATIONS
    630 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    631 #                       Log Mean Temperature Difference
    632 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    633 if abs(DT0 - DTL) > 0.05*max(abs([DT0,DTL]))
    634        
    635         then
    636 "Log Mean Temperature Difference"
    637         LMTD= (DT0-DTL)/ln(DT0/DTL);
    638 
    639         else
    640        
    641 if DT0*DTL equal 0
    642        
    643         then
    644 "Log Mean Temperature Difference"
    645         LMTD = 0.5*(DT0+DTL);
    646        
    647         else
    648 "Log Mean Temperature Difference"
    649         LMTD = 0.5*(DT0+DTL)*(1-(DT0-DTL)^2/(DT0*DTL)*(1+(DT0-DTL)^2/(DT0*DTL)/2)/12);
    650        
    651 end
    652        
    653 end
    654563
    655564"Exchange Surface Area"
     
    657566       
    658567"Mean Temperature Difference"   
    659         MTD = Fc*LMTD;
    660        
    661 end
     568        MTD   = Fc*LMTD;
     569       
     570end
     571
    662572
    663573Model E_Shell_NTU_Det                   as Heatex_Detailed_NTU
    664 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     574#=====================================================================
    665575#       Shell and Tubes Heat Exchanger with 1 shell pass - LMTD Method
    666 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     576#=====================================================================
    667577EQUATIONS
    668578
    669579"TEMA E Shell Effectiveness"
    670 #       Eft = 2*(1+Details.Cr+sqrt(1+Details.Cr^2)*((1+exp(-Details.NTU*sqrt(1+Details.Cr^2)))/(1-exp(-Details.NTU*sqrt(1+Details.Cr^2)))) )^-1;
    671         Eft = HE.EshellEffectiveness(Details.Cr,Details.NTU);
     580        Eft = 2*(1+Details.Cr+sqrt(1+Details.Cr^2)*((1+exp(-Details.NTU*sqrt(1+Details.Cr^2)))/(1-exp(-Details.NTU*sqrt(1+Details.Cr^2)))) )^-1;
    672581
    673582"Js Factor"     
     
    679588       
    680589"Shell Side Reynolds Number"
    681         Shell.HeatTransfer.Re=(Dotube*Properties.Hot.Inlet.Fw/Shell.HeatTransfer.Sm)/Properties.Hot.Average.Mu;
     590        Shell.HeatTransfer.Re=HE.ShellReynoldsNumber(Properties.Hot.Inlet.Fw,Shell.HeatTransfer.Sm,Properties.Hot.Average.Mu);
    682591
    683592"Shell Heat Transfer Coefficient"
    684         Shell.HeatTransfer.hshell=Shell.HeatTransfer.Ji*(Properties.Hot.Average.Cp/Properties.Hot.Average.Mw)*(Properties.Hot.Inlet.Fw/Shell.HeatTransfer.Sm)*(Shell.HeatTransfer.PR^(-2/3))*Shell.HeatTransfer.Jtotal*Shell.HeatTransfer.Phi;
     593        Shell.HeatTransfer.hshell=HE.ShellFilmCoeff(Shell.HeatTransfer.Ji,Properties.Hot.Average.Cp,Properties.Hot.Average.Mw,Properties.Hot.Inlet.Fw,Shell.HeatTransfer.Sm,Shell.HeatTransfer.PR,Shell.HeatTransfer.Jtotal,Shell.HeatTransfer.Phi);
    685594
    686595"Shell Pressure Drop Cross Flow"
     
    697606
    698607"Shell Side Reynolds Number"
    699         Shell.HeatTransfer.Re=(Dotube*Properties.Cold.Inlet.Fw/Shell.HeatTransfer.Sm)/Properties.Cold.Average.Mu;
     608        Shell.HeatTransfer.Re=HE.ShellReynoldsNumber(Properties.Cold.Inlet.Fw,Shell.HeatTransfer.Sm,Properties.Cold.Average.Mu);
    700609
    701610"Shell Heat Transfer Coefficient"
    702         Shell.HeatTransfer.hshell=Shell.HeatTransfer.Ji*(Properties.Cold.Average.Cp/Properties.Cold.Average.Mw)*(Properties.Cold.Inlet.Fw/Shell.HeatTransfer.Sm)*(Shell.HeatTransfer.PR^(-2/3))*Shell.HeatTransfer.Jtotal*Shell.HeatTransfer.Phi;
     611        Shell.HeatTransfer.hshell=HE.ShellFilmCoeff(Shell.HeatTransfer.Ji,Properties.Cold.Average.Cp,Properties.Cold.Average.Mw,Properties.Cold.Inlet.Fw,Shell.HeatTransfer.Sm,Shell.HeatTransfer.PR,Shell.HeatTransfer.Jtotal,Shell.HeatTransfer.Phi);
    703612
    704613"Shell Pressure Drop Cross Flow"
     
    714623end
    715624
     625
    716626end
    717627
    718628Model F_Shell_NTU_Det                   as Heatex_Detailed_NTU
    719 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     629#=====================================================================
    720630#       Shell and Tubes Heat Exchanger with 1 shell pass - LMTD Method
    721 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     631#=====================================================================
    722632VARIABLES
    723633
     
    740650       
    741651"Shell Side Reynolds Number"
    742         Shell.HeatTransfer.Re=(Dotube*Properties.Hot.Inlet.Fw/Shell.HeatTransfer.Sm)/Properties.Hot.Average.Mu;
     652        Shell.HeatTransfer.Re= HE.ShellReynoldsNumber(Properties.Hot.Inlet.Fw,Shell.HeatTransfer.Sm,Properties.Hot.Average.Mu);
    743653
    744654"Shell Heat Transfer Coefficient"
    745         Shell.HeatTransfer.hshell= Shell.HeatTransfer.Ji*(Properties.Hot.Average.Cp/Properties.Hot.Average.Mw)*(Properties.Hot.Inlet.Fw/Shell.HeatTransfer.Sm)*(Shell.HeatTransfer.PR^(-2/3))*Shell.HeatTransfer.Jtotal*Shell.HeatTransfer.Phi;
     655        Shell.HeatTransfer.hshell= HE.ShellFilmCoeff(Shell.HeatTransfer.Ji,Properties.Hot.Average.Cp,Properties.Hot.Average.Mw,Properties.Hot.Inlet.Fw,Shell.HeatTransfer.Sm,Shell.HeatTransfer.PR,Shell.HeatTransfer.Jtotal,Shell.HeatTransfer.Phi);
    746656
    747657"Shell Pressure Drop Cross Flow"
     
    758668
    759669"Shell Side Reynolds Number"
    760         Shell.HeatTransfer.Re=(Dotube*Properties.Cold.Inlet.Fw/Shell.HeatTransfer.Sm)/Properties.Cold.Average.Mu;
     670        Shell.HeatTransfer.Re=HE.ShellReynoldsNumber(Properties.Cold.Inlet.Fw,Shell.HeatTransfer.Sm,Properties.Cold.Average.Mu);
    761671
    762672"Shell Heat Transfer Coefficient"
    763         Shell.HeatTransfer.hshell=Shell.HeatTransfer.Ji*(Properties.Cold.Average.Cp/Properties.Cold.Average.Mw)*(Properties.Cold.Inlet.Fw/Shell.HeatTransfer.Sm)*(Shell.HeatTransfer.PR^(-2/3))*Shell.HeatTransfer.Jtotal*Shell.HeatTransfer.Phi;
     673        Shell.HeatTransfer.hshell=HE.ShellFilmCoeff(Shell.HeatTransfer.Ji,Properties.Cold.Average.Cp,Properties.Cold.Average.Mw,Properties.Cold.Inlet.Fw,Shell.HeatTransfer.Sm,Shell.HeatTransfer.PR,Shell.HeatTransfer.Jtotal,Shell.HeatTransfer.Phi);
    764674
    765675"Shell Pressure Drop Cross Flow"
     
    779689
    780690Model Multipass_NTU_Det         
    781 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     691#============================================================================
    782692#       Shell and Tubes Heat Exchanger In Series with 1 shell pass - LMTD Method
    783 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     693#============================================================================
    784694PARAMETERS
    785695
    786         Nshell          as Integer              (Brief="N Shell in Series",Default=2);
    787 ext PP                  as CalcObject   (Brief="External Physical Properties");
    788         HE                      as CalcObject   (Brief="heatex Calculations", File="heatex");
    789         side        as Integer          (Brief="Fluid Alocation",Lower=0,Upper=1);
    790         Pi                      as constant     (Brief="Pi Number",Default=3.14159265);
    791 
    792 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     696Nshell          as Integer              (Brief="N Shell in Series",Default=2);
     697ext     HE              as CalcObject   (Brief="STHE Calculations",File="heatex.dll");
     698ext PP          as CalcObject;
     699side        as Integer          (Brief="Fluid Alocation",Lower=0,Upper=1);
     700Pi                      as constant     (Brief="Pi Number",Default=3.14159265);
     701
     702#=====================================================================
    793703#       Shell Geometrical Parameters
    794 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     704#=====================================================================
    795705Tpass                   as Integer              (Brief="Number of Tube Passes",Lower=1);
    796706Nss                             as Integer              (Brief="Number of Sealing Strips pairs",Lower=1);
     
    801711Honozzle_Shell  as length               (Brief="Height Under Shell Outlet Nozzle",Lower=10e-6);
    802712Lcf                     as length               (Brief="Bundle-to-Shell Clearance",Lower=10e-8);
    803 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     713#=====================================================================
    804714#       Tubes Geometrical Parameters
    805 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     715#=====================================================================
    806716Ntt                             as Integer              (Brief="Total Number of Tubes in Shell",Default=100,Lower=1);
    807717Pattern         as Integer              (Brief="Tube Layout Characteristic Angle",Lower=30);
     
    813723Donozzle_Tube   as length               (Brief="Tube Outlet Nozzle Diameter",Lower=10e-6);
    814724Dinozzle_Tube   as length               (Brief="Tube Inlett Nozzle Diameter",Lower=10e-6);
    815 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     725#=====================================================================
    816726#       Baffles Geometrical Parameters
    817 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     727#=====================================================================
    818728Bc                      as Integer              (Brief="Baffle Cut",Default=25,Lower=25);
    819729Nb              as Real                 (Brief="Number of Baffles",Lower=1);
    820730Lcd                     as length               (Brief="Baffle-to-Shell Clearance",Lower=10e-8);
    821731Ltd                             as length               (Brief="Tube-to-Bafflehole Clearance",Lower=10e-8);
    822 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     732#=====================================================================
    823733VARIABLES
    824734
     
    829739
    830740Unity([1:Nshell-1]).Outlet.Hot  to Unity([2:Nshell]).Inlet.Hot;
    831 Unity([2:Nshell]).Outlet.Cold   to Unity([1:Nshell-1]).Inlet.Cold;
     741Unity([2:Nshell]).Outlet.Cold to Unity([1:Nshell-1]).Inlet.Cold;
    832742
    833743EQUATIONS
     
    839749
    840750"Ji Factor"
    841         Unity(i).Shell.HeatTransfer.Ji =HE.JiFactor(Unity(i).Shell.HeatTransfer.Re);
     751        Unity(i).Shell.HeatTransfer.Ji = HE.JiFactor(Unity(i).Shell.HeatTransfer.Re);
    842752
    843753"Jc Factor"
     
    856766        Unity(i).Shell.HeatTransfer.Jtotal=Unity(i).Shell.HeatTransfer.Jc*Unity(i).Shell.HeatTransfer.Jl*Unity(i).Shell.HeatTransfer.Jb*Unity(i).Shell.HeatTransfer.Jr*Unity(i).Shell.HeatTransfer.Js;
    857767
    858 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     768
     769
     770#=====================================================================
    859771#  Fluid Alocation
    860 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     772#=====================================================================
    861773
    862774if side equal 1 then
     
    883795        then
    884796       
    885 "Hot Wall Temperature"
     797"Wall Temperature"
     798#       Unity(i).Tubes.HeatTransfer.Twall  = HE.WallTemperature(Unity(i).Properties.Hot.Average.T,Unity(i).Properties.Cold.Average.T,Unity(i).Tubes.HeatTransfer.htube,Unity(i).Shell.HeatTransfer.hshell);
    886799        Unity(i).Properties.Hot.Wall.Twall  = (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
    887 
    888 "Cold Wall Temperature"
    889800        Unity(i).Properties.Cold.Wall.Twall  = (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
    890801
    891802"Tube Side Velocity"
    892         Unity(i).Tubes.HeatTransfer.Vtube  = Unity(i).Properties.Cold.Inlet.Fw*Tpass/((Pi*Ditube*Ditube/4)*Unity(i).Properties.Cold.Average.rho*Ntt);
     803        Unity(i).Tubes.HeatTransfer.Vtube  = HE.TubeVelocity(Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Properties.Cold.Average.rho);
    893804
    894805"Tube Side Reynolds Number"
    895         Unity(i).Tubes.HeatTransfer.Re=(Unity(i).Properties.Cold.Average.rho*Unity(i).Tubes.HeatTransfer.Vtube*Ditube)/Unity(i).Properties.Cold.Average.Mu;
    896 
     806        Unity(i).Tubes.HeatTransfer.Re = HE.TubeReynoldsNumber(Unity(i).Properties.Cold.Average.rho,Unity(i).Tubes.HeatTransfer.Vtube,Unity(i).Properties.Cold.Average.Mu);
     807       
    897808"Tube Side Prandtl Number"
    898         Unity(i).Tubes.HeatTransfer.PR = ((Unity(i).Properties.Cold.Average.Cp/Unity(i).Properties.Cold.Average.Mw)*Unity(i).Properties.Cold.Average.Mu)/Unity(i).Properties.Cold.Average.K;
     809        Unity(i).Tubes.HeatTransfer.PR = HE.PrandtlNumber(Unity(i).Properties.Cold.Average.K,Unity(i).Properties.Cold.Average.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Average.Mu);
    899810
    900811"Tube Side Prandtl Number at Wall Temperature"
    901         Unity(i).Tubes.HeatTransfer.PRw = ((Unity(i).Properties.Cold.Wall.Cp/Unity(i).Properties.Cold.Average.Mw)*Unity(i).Properties.Cold.Wall.Mu)/Unity(i).Properties.Cold.Wall.K;
     812        Unity(i).Tubes.HeatTransfer.PRw = HE.PrandtlNumber(Unity(i).Properties.Cold.Wall.K,Unity(i).Properties.Cold.Wall.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Wall.Mu);
     813
    902814
    903815"Tube Side Film Coefficient"
    904         Unity(i).Tubes.HeatTransfer.htube= HE.TubeFilmCoeff(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Tubes.HeatTransfer.PR,Unity(i).Properties.Cold.Average.K)*Unity(i).Tubes.HeatTransfer.Phi;
     816        Unity(i).Tubes.HeatTransfer.htube= HE.TubeFilmCoeff(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Tubes.HeatTransfer.PR,Unity(i).Properties.Cold.Average.K,Unity(i).Tubes.HeatTransfer.Phi);
    905817       
    906818"Shell Side Prandtl Number"
    907         Unity(i).Shell.HeatTransfer.PR=((Unity(i).Properties.Hot.Average.Cp/Unity(i).Properties.Hot.Average.Mw)*Unity(i).Properties.Hot.Average.Mu)/Unity(i).Properties.Hot.Average.K
     819        Unity(i).Shell.HeatTransfer.PR=HE.PrandtlNumber(Unity(i).Properties.Hot.Average.K,Unity(i).Properties.Hot.Average.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Average.Mu);   
    908820
    909821"Shell Side Prandtl Number at Wall Temperature"
    910         Unity(i).Shell.HeatTransfer.PRw = ((Unity(i).Properties.Hot.Wall.Cp/Unity(i).Properties.Hot.Average.Mw)*Unity(i).Properties.Hot.Wall.Mu)/Unity(i).Properties.Hot.Wall.K;       
     822        Unity(i).Shell.HeatTransfer.PRw = HE.PrandtlNumber(Unity(i).Properties.Hot.Wall.K,Unity(i).Properties.Hot.Wall.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Wall.Mu)
    911823
    912824"Tube Side Pressure Drop"
     
    946858        else
    947859
    948 "Hot Wall Temperature"
     860"Wall Temperature"
     861#       Unity(i).Tubes.HeatTransfer.Twall       =       HE.WallTemperature(Unity(i).Properties.Cold.Average.T,Unity(i).Properties.Hot.Average.T,Unity(i).Tubes.HeatTransfer.htube,Unity(i).Shell.HeatTransfer.hshell);
    949862        Unity(i).Properties.Hot.Wall.Twall  = (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
    950 
    951 "Cold Wall Temperature"
    952863        Unity(i).Properties.Cold.Wall.Twall  = (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
    953864
    954865"Tube Side Velocity"
    955         Unity(i).Tubes.HeatTransfer.Vtube  = Unity(i).Properties.Hot.Inlet.Fw*Tpass/((Pi*Ditube*Ditube/4)*Unity(i).Properties.Hot.Average.rho*Ntt);
     866        Unity(i).Tubes.HeatTransfer.Vtube       =       HE.TubeVelocity(Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Properties.Hot.Average.rho);
    956867
    957868"Tube Side Reynolds Number"
    958         Unity(i).Tubes.HeatTransfer.Re          =       (Unity(i).Properties.Hot.Average.rho*Unity(i).Tubes.HeatTransfer.Vtube*Ditube)/Unity(i).Properties.Hot.Average.Mu;
     869        Unity(i).Tubes.HeatTransfer.Re          =       HE.TubeReynoldsNumber(Unity(i).Properties.Hot.Average.rho,Unity(i).Tubes.HeatTransfer.Vtube,Unity(i).Properties.Hot.Average.Mu);
    959870       
    960871"Tube Side Prandtl Number"
    961         Unity(i).Tubes.HeatTransfer.PR          =       ((Unity(i).Properties.Hot.Average.Cp/Unity(i).Properties.Hot.Average.Mw)*Unity(i).Properties.Hot.Average.Mu)/Unity(i).Properties.Hot.Average.K;
     872        Unity(i).Tubes.HeatTransfer.PR          =       HE.PrandtlNumber(Unity(i).Properties.Hot.Average.K,Unity(i).Properties.Hot.Average.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Average.Mu);
    962873       
    963874"Tube Side Prandtl Number at Wall"
    964         Unity(i).Tubes.HeatTransfer.PRw     =  ((Unity(i).Properties.Hot.Wall.Cp/Unity(i).Properties.Hot.Average.Mw)*Unity(i).Properties.Hot.Wall.Mu)/Unity(i).Properties.Hot.Wall.K;
     875        Unity(i).Tubes.HeatTransfer.PRw     =  HE.PrandtlNumber(Unity(i).Properties.Hot.Wall.K,Unity(i).Properties.Hot.Wall.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Wall.Mu);
     876
    965877
    966878"Tube Side Film Coefficient"
    967         Unity(i).Tubes.HeatTransfer.htube       =       HE.TubeFilmCoeff(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Tubes.HeatTransfer.PR,Unity(i).Properties.Hot.Average.K)*Unity(i).Tubes.HeatTransfer.Phi;
     879        Unity(i).Tubes.HeatTransfer.htube       =       HE.TubeFilmCoeff(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Tubes.HeatTransfer.PR,Unity(i).Properties.Hot.Average.K,Unity(i).Tubes.HeatTransfer.Phi);
    968880       
    969881"Shell Side Prandtl Number"
    970         Unity(i).Shell.HeatTransfer.PR          =       ((Unity(i).Properties.Cold.Average.Cp/Unity(i).Properties.Cold.Average.Mw)*Unity(i).Properties.Cold.Average.Mu)/Unity(i).Properties.Cold.Average.K;
     882        Unity(i).Shell.HeatTransfer.PR          =       HE.PrandtlNumber(Unity(i).Properties.Cold.Average.K,Unity(i).Properties.Cold.Average.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Average.Mu);
    971883       
    972884"Shell Side Prandtl Number at Wall"
    973         Unity(i).Shell.HeatTransfer.PRw     =   ((Unity(i).Properties.Cold.Wall.Cp/Unity(i).Properties.Cold.Average.Mw)*Unity(i).Properties.Cold.Wall.Mu)/Unity(i).Properties.Cold.Wall.K;
     885        Unity(i).Shell.HeatTransfer.PRw     =   HE.PrandtlNumber(Unity(i).Properties.Cold.Wall.K,Unity(i).Properties.Cold.Wall.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Wall.Mu);
     886
    974887
    975888"Tube Side Pressure Drop"
     
    1009922end
    1010923
    1011 if side equal 1
    1012        
    1013         then
    1014 
    1015 "Shell Side inlet Nozzle rho-V^2"
    1016         Unity(i).Shell.PressureDrop.RVsquare_in = Unity(i).Properties.Hot.Inlet.rho*(Unity(i).Shell.PressureDrop.Vnozzle_in)^2;
    1017 
    1018 "Shell Side Outlet Nozzle rho-V^2"
    1019         Unity(i).Shell.PressureDrop.RVsquare_out = Unity(i).Properties.Hot.Outlet.rho*(Unity(i).Shell.PressureDrop.Vnozzle_out)^2;
    1020        
    1021         else
    1022        
    1023 "Shell Side inlet Nozzle rho-V^2"
    1024         Unity(i).Shell.PressureDrop.RVsquare_in = Unity(i).Properties.Cold.Inlet.rho*(Unity(i).Shell.PressureDrop.Vnozzle_in)^2;
    1025 
    1026 "Shell Side Outlet Nozzle rho-V^2"
    1027         Unity(i).Shell.PressureDrop.RVsquare_out = Unity(i).Properties.Cold.Outlet.rho*(Unity(i).Shell.PressureDrop.Vnozzle_out)^2;
    1028 
    1029 end
    1030 
    1031924"Tube Resistance"       
    1032925        Unity(i).Resistances.Rtube*(Unity(i).Tubes.HeatTransfer.htube*Ditube) = Dotube;
     
    1046939"Baffles Spacing"
    1047940        Ltube = Unity(i).Baffles.Lsi+Unity(i).Baffles.Lso+Unity(i).Baffles.Ls*(Nb-1);
     941       
    1048942
    1049943"TEMA E Shell Effectiveness"
     
    1058952       
    1059953"Shell Side Reynolds Number"
    1060         Unity(i).Shell.HeatTransfer.Re=(Dotube*Unity(i).Properties.Hot.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)/Unity(i).Properties.Hot.Average.Mu;
     954        Unity(i).Shell.HeatTransfer.Re=HE.ShellReynoldsNumber(Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Properties.Hot.Average.Mu);
    1061955
    1062956"Shell Heat Transfer Coefficient"
    1063         Unity(i).Shell.HeatTransfer.hshell=Unity(i).Shell.HeatTransfer.Ji*(Unity(i).Properties.Hot.Average.Cp/Unity(i).Properties.Hot.Average.Mw)*(Unity(i).Properties.Hot.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)*(Unity(i).Shell.HeatTransfer.PR^(-2/3))*Unity(i).Shell.HeatTransfer.Jtotal*Unity(i).Shell.HeatTransfer.Phi;
     957        Unity(i).Shell.HeatTransfer.hshell=HE.ShellFilmCoeff(Unity(i).Shell.HeatTransfer.Ji,Unity(i).Properties.Hot.Average.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Shell.HeatTransfer.PR,Unity(i).Shell.HeatTransfer.Jtotal,Unity(i).Shell.HeatTransfer.Phi);
    1064958
    1065959"Shell Pressure Drop Cross Flow"
     
    1076970
    1077971"Shell Side Reynolds Number"
    1078         Unity(i).Shell.HeatTransfer.Re=(Dotube*Unity(i).Properties.Cold.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)/Unity(i).Properties.Cold.Average.Mu;
     972        Unity(i).Shell.HeatTransfer.Re=HE.ShellReynoldsNumber(Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Properties.Cold.Average.Mu);
    1079973
    1080974"Shell Heat Transfer Coefficient"
    1081         Unity(i).Shell.HeatTransfer.hshell=Unity(i).Shell.HeatTransfer.Ji*(Unity(i).Properties.Cold.Average.Cp/Unity(i).Properties.Cold.Average.Mw)*(Unity(i).Properties.Cold.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)*(Unity(i).Shell.HeatTransfer.PR^(-2/3))*Unity(i).Shell.HeatTransfer.Jtotal*Unity(i).Shell.HeatTransfer.Phi;
     975        Unity(i).Shell.HeatTransfer.hshell=HE.ShellFilmCoeff(Unity(i).Shell.HeatTransfer.Ji,Unity(i).Properties.Cold.Average.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Shell.HeatTransfer.PR,Unity(i).Shell.HeatTransfer.Jtotal,Unity(i).Shell.HeatTransfer.Phi);
    1082976
    1083977"Shell Pressure Drop Cross Flow"
     
    1093987end
    1094988
    1095 "Duty"
    1096989        Unity(i).Details.Q      = Eft(i)*Unity(i).Details.Cmin*(Unity(i).Inlet.Hot.T-Unity(i).Inlet.Cold.T);
    1097990
     
    1099992
    1100993        SET
    1101 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     994#=====================================================================
    1102995#  Set Parameters for heatex Calculation
    1103 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     996#=====================================================================
    1104997        Pi                              = 3.14159265;
    1105998        HE.Tpass                        = Tpass;
     
    11281021
    11291022Model E_Shell_LMTD_Det                  as Heatex_Detailed_LMTD
    1130 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1023#=====================================================================
    11311024#       Shell and Tubes Heat Exchanger with 1 shell pass - LMTD Method
    1132 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1025#=====================================================================
    11331026EQUATIONS
    11341027
     
    11361029        Fc = HE.EshellCorrectionFactor(Inlet.Hot.T,Outlet.Hot.T,Inlet.Cold.T,Outlet.Cold.T);
    11371030
    1138 "Temperature Difference at Inlet"
    1139         DT0 = Inlet.Hot.T - Outlet.Cold.T;
    1140 
    1141 "Temperature Difference at Outlet"
    1142         DTL = Outlet.Hot.T - Inlet.Cold.T;
    1143        
     1031"Counter Flow LMTD"
     1032        LMTD = HE.CounterLMTD(Inlet.Hot.T,Outlet.Hot.T,Inlet.Cold.T,Outlet.Cold.T);
     1033
    11441034"Js Factor"     
    11451035        Shell.HeatTransfer.Js = HE.JsFactor(Shell.HeatTransfer.Re,Baffles.Lsi,Baffles.Lso,Baffles.Ls);
     
    11501040       
    11511041"Shell Side Reynolds Number"
    1152         Shell.HeatTransfer.Re=(Dotube*Properties.Hot.Inlet.Fw/Shell.HeatTransfer.Sm)/Properties.Hot.Average.Mu;
     1042        Shell.HeatTransfer.Re=HE.ShellReynoldsNumber(Properties.Hot.Inlet.Fw,Shell.HeatTransfer.Sm,Properties.Hot.Average.Mu);
    11531043
    11541044"Shell Heat Transfer Coefficient"
    1155         Shell.HeatTransfer.hshell=Shell.HeatTransfer.Ji*(Properties.Hot.Average.Cp/Properties.Hot.Average.Mw)*(Properties.Hot.Inlet.Fw/Shell.HeatTransfer.Sm)*(Shell.HeatTransfer.PR^(-2/3))*Shell.HeatTransfer.Jtotal*Shell.HeatTransfer.Phi;
     1045        Shell.HeatTransfer.hshell=HE.ShellFilmCoeff(Shell.HeatTransfer.Ji,Properties.Hot.Average.Cp,Properties.Hot.Average.Mw,Properties.Hot.Inlet.Fw,Shell.HeatTransfer.Sm,Shell.HeatTransfer.PR,Shell.HeatTransfer.Jtotal,Shell.HeatTransfer.Phi);
    11561046
    11571047"Shell Pressure Drop Cross Flow"
     
    11681058
    11691059"Shell Side Reynolds Number"
    1170         Shell.HeatTransfer.Re=(Dotube*Properties.Cold.Inlet.Fw/Shell.HeatTransfer.Sm)/Properties.Cold.Average.Mu;
     1060        Shell.HeatTransfer.Re=HE.ShellReynoldsNumber(Properties.Cold.Inlet.Fw,Shell.HeatTransfer.Sm,Properties.Cold.Average.Mu);
    11711061
    11721062"Shell Heat Transfer Coefficient"
    1173         Shell.HeatTransfer.hshell=Shell.HeatTransfer.Ji*(Properties.Cold.Average.Cp/Properties.Cold.Average.Mw)*(Properties.Cold.Inlet.Fw/Shell.HeatTransfer.Sm)*(Shell.HeatTransfer.PR^(-2/3))*Shell.HeatTransfer.Jtotal*Shell.HeatTransfer.Phi;
     1063        Shell.HeatTransfer.hshell=HE.ShellFilmCoeff(Shell.HeatTransfer.Ji,Properties.Cold.Average.Cp,Properties.Cold.Average.Mw,Properties.Cold.Inlet.Fw,Shell.HeatTransfer.Sm,Shell.HeatTransfer.PR,Shell.HeatTransfer.Jtotal,Shell.HeatTransfer.Phi);
    11741064
    11751065"Shell Pressure Drop Cross Flow"
     
    11901080
    11911081Model F_Shell_LMTD_Det                  as Heatex_Detailed_LMTD
    1192 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1082#=====================================================================
    11931083#       Shell and Tubes Heat Exchanger with 2 shell pass - LMTD Method
    1194 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1084#=====================================================================
    11951085
    11961086EQUATIONS
     
    11991089        Fc = HE.FshellCorrectionFactor(Inlet.Hot.T,Outlet.Hot.T,Inlet.Cold.T,Outlet.Cold.T);
    12001090
    1201 "Temperature Difference at Inlet"
    1202         DT0 = Inlet.Hot.T - Outlet.Cold.T;
    1203 
    1204 "Temperature Difference at Outlet"
    1205         DTL = Outlet.Hot.T - Inlet.Cold.T;
    1206        
     1091"Counter Flow LMTD"
     1092        LMTD = HE.CounterLMTD(Inlet.Hot.T,Outlet.Hot.T,Inlet.Cold.T,Outlet.Cold.T);
     1093
    12071094"Js Factor"     
    12081095        Shell.HeatTransfer.Js = HE.JsFactor(Shell.HeatTransfer.Re,Baffles.Lsi,Baffles.Lso,Baffles.Ls);
     
    12131100       
    12141101"Shell Side Reynolds Number"
    1215         Shell.HeatTransfer.Re=(Dotube*Properties.Hot.Inlet.Fw/Shell.HeatTransfer.Sm)/Properties.Hot.Average.Mu;
     1102        Shell.HeatTransfer.Re=HE.ShellReynoldsNumber(Properties.Hot.Inlet.Fw,Shell.HeatTransfer.Sm,Properties.Hot.Average.Mu);
    12161103
    12171104"Shell Heat Transfer Coefficient"
    1218         Shell.HeatTransfer.hshell=Shell.HeatTransfer.Ji*(Properties.Hot.Average.Cp/Properties.Hot.Average.Mw)*(Properties.Hot.Inlet.Fw/Shell.HeatTransfer.Sm)*(Shell.HeatTransfer.PR^(-2/3))*Shell.HeatTransfer.Jtotal*Shell.HeatTransfer.Phi;
     1105        Shell.HeatTransfer.hshell=HE.ShellFilmCoeff(Shell.HeatTransfer.Ji,Properties.Hot.Average.Cp,Properties.Hot.Average.Mw,Properties.Hot.Inlet.Fw,Shell.HeatTransfer.Sm,Shell.HeatTransfer.PR,Shell.HeatTransfer.Jtotal,Shell.HeatTransfer.Phi);
    12191106
    12201107"Shell Pressure Drop Cross Flow"
     
    12311118
    12321119"Shell Side Reynolds Number"
    1233         Shell.HeatTransfer.Re=(Dotube*Properties.Cold.Inlet.Fw/Shell.HeatTransfer.Sm)/Properties.Cold.Average.Mu;
     1120        Shell.HeatTransfer.Re=HE.ShellReynoldsNumber(Properties.Cold.Inlet.Fw,Shell.HeatTransfer.Sm,Properties.Cold.Average.Mu);
    12341121
    12351122"Shell Heat Transfer Coefficient"
    1236         Shell.HeatTransfer.hshell=Shell.HeatTransfer.Ji*(Properties.Cold.Average.Cp/Properties.Cold.Average.Mw)*(Properties.Cold.Inlet.Fw/Shell.HeatTransfer.Sm)*(Shell.HeatTransfer.PR^(-2/3))*Shell.HeatTransfer.Jtotal*Shell.HeatTransfer.Phi;
     1123        Shell.HeatTransfer.hshell=HE.ShellFilmCoeff(Shell.HeatTransfer.Ji,Properties.Cold.Average.Cp,Properties.Cold.Average.Mw,Properties.Cold.Inlet.Fw,Shell.HeatTransfer.Sm,Shell.HeatTransfer.PR,Shell.HeatTransfer.Jtotal,Shell.HeatTransfer.Phi);
    12371124
    12381125"Shell Pressure Drop Cross Flow"
     
    12481135end
    12491136
     1137
     1138
    12501139end
    12511140
    12521141Model Multipass_LMTD_Det         
    1253 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1142#============================================================================
    12541143#       Shell and Tubes Heat Exchanger In Series with 1 shell pass - LMTD Method
    1255 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1144#============================================================================
    12561145PARAMETERS
    12571146
    1258 Nshell          as Integer              (Brief="N Shell in Series",Default=2);
    1259         HE              as CalcObject   (Brief="STHE Calculations",File="heatex");
    1260 ext PP          as CalcObject   (Brief="External Physical Properties");
     1147Nshell          as Integer      (Brief="N Shell in Series",Default=2);
     1148ext     HE              as CalcObject   (Brief="STHE Calculations",File="heatex.dll");
     1149ext PP          as CalcObject;
    12611150side        as Integer          (Brief="Fluid Alocation",Lower=0,Upper=1);
    12621151Pi                      as constant     (Brief="Pi Number",Default=3.14159265);
    12631152
    1264 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1153#=====================================================================
    12651154#       Shell Geometrical Parameters
    1266 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1155#=====================================================================
    12671156Tpass                   as Integer              (Brief="Number of Tube Passes",Lower=1);
    12681157Nss                             as Integer              (Brief="Number of Sealing Strips pairs",Lower=1);
     
    12731162Honozzle_Shell  as length               (Brief="Height Under Shell Outlet Nozzle",Lower=10e-6);
    12741163Lcf                     as length               (Brief="Bundle-to-Shell Clearance",Lower=10e-8);
    1275 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1164#=====================================================================
    12761165#       Tubes Geometrical Parameters
    1277 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1166#=====================================================================
    12781167Ntt                             as Integer              (Brief="Total Number of Tubes in Shell",Default=100,Lower=1);
    12791168Pattern         as Integer              (Brief="Tube Layout Characteristic Angle",Lower=30);
     
    12851174Donozzle_Tube   as length               (Brief="Tube Outlet Nozzle Diameter",Lower=10e-6);
    12861175Dinozzle_Tube   as length               (Brief="Tube Inlett Nozzle Diameter",Lower=10e-6);
    1287 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1176#=====================================================================
    12881177#       Baffles Geometrical Parameters
    1289 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1178#=====================================================================
    12901179Bc                      as Integer              (Brief="Baffle Cut",Default=25,Lower=25);
    12911180Nb              as Real                 (Brief="Number of Baffles",Lower=1);
    12921181Lcd                     as length               (Brief="Baffle-to-Shell Clearance",Lower=10e-8);
    12931182Ltd                             as length               (Brief="Tube-to-Bafflehole Clearance",Lower=10e-8);
    1294 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1183#=====================================================================
    12951184VARIABLES
    12961185
     
    12981187Fc(Nshell)                      as positive             (Brief="LMTD Correction Factor",Lower=0.75);
    12991188MTD(Nshell)                     as temp_delta   (Brief="Mean Temperature Difference");
    1300 Unity(Nshell)           as HeatExchangerDetailed_Basic;
     1189
     1190Unity(Nshell) as HeatExchangerDetailed_Basic;
    13011191
    13021192CONNECTIONS
     
    13301220        Unity(i).Shell.HeatTransfer.Jtotal=Unity(i).Shell.HeatTransfer.Jc*Unity(i).Shell.HeatTransfer.Jl*Unity(i).Shell.HeatTransfer.Jb*Unity(i).Shell.HeatTransfer.Jr*Unity(i).Shell.HeatTransfer.Js;
    13311221
    1332 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1222
     1223
     1224#=====================================================================
    13331225#  Fluid Alocation
    1334 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1226#=====================================================================
    13351227
    13361228if side equal 1 then
     
    13591251        then
    13601252       
    1361 "Cold Wall Temperature"
     1253"Wall Temperature"
     1254#       Tubes.HeatTransfer.Twall  = HE.WallTemperature(Properties.Hot.Average.T,Properties.Cold.Average.T,Tubes.HeatTransfer.htube,Shell.HeatTransfer.hshell);
     1255
     1256#       Tubes.HeatTransfer.Twall  = HE.WallTemperature(Properties.Hot.Average.T,Properties.Cold.Average.T,Tubes.HeatTransfer.htube,Shell.HeatTransfer.hshell);
     1257
     1258
    13621259        Unity(i).Properties.Cold.Wall.Twall  = (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
    1363 
    1364 "Hot Wall Temperature" 
     1260       
    13651261        Unity(i).Properties.Hot.Wall.Twall  = (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
    13661262
    13671263"Tube Side Velocity"
    1368         Unity(i).Tubes.HeatTransfer.Vtube  = Unity(i).Properties.Cold.Inlet.Fw*Tpass/((Pi*Ditube*Ditube/4)*Unity(i).Properties.Cold.Average.rho*Ntt);
     1264        Unity(i).Tubes.HeatTransfer.Vtube  = HE.TubeVelocity(Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Properties.Cold.Average.rho);
    13691265
    13701266"Tube Side Reynolds Number"
    1371         Unity(i).Tubes.HeatTransfer.Re=(Unity(i).Properties.Cold.Average.rho*Unity(i).Tubes.HeatTransfer.Vtube*Ditube)/Unity(i).Properties.Cold.Average.Mu;
    1372 
     1267        Unity(i).Tubes.HeatTransfer.Re = HE.TubeReynoldsNumber(Unity(i).Properties.Cold.Average.rho,Unity(i).Tubes.HeatTransfer.Vtube,Unity(i).Properties.Cold.Average.Mu);
     1268       
    13731269"Tube Side Prandtl Number"
    1374         Unity(i).Tubes.HeatTransfer.PR = ((Unity(i).Properties.Cold.Average.Cp/Unity(i).Properties.Cold.Average.Mw)*Unity(i).Properties.Cold.Average.Mu)/Unity(i).Properties.Cold.Average.K;
     1270        Unity(i).Tubes.HeatTransfer.PR = HE.PrandtlNumber(Unity(i).Properties.Cold.Average.K,Unity(i).Properties.Cold.Average.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Average.Mu);
    13751271
    13761272"Tube Side Prandtl Number at Wall"
    1377         Unity(i).Tubes.HeatTransfer.PRw = ((Unity(i).Properties.Cold.Wall.Cp/Unity(i).Properties.Cold.Average.Mw)*Unity(i).Properties.Cold.Wall.Mu)/Unity(i).Properties.Cold.Wall.K;
     1273        Unity(i).Tubes.HeatTransfer.PRw = HE.PrandtlNumber(Unity(i).Properties.Cold.Wall.K,Unity(i).Properties.Cold.Wall.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Wall.Mu);
     1274
    13781275
    13791276"Tube Side Film Coefficient"
    1380         Unity(i).Tubes.HeatTransfer.htube= HE.TubeFilmCoeff(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Tubes.HeatTransfer.PR,Unity(i).Properties.Cold.Average.K)*Unity(i).Tubes.HeatTransfer.Phi;
     1277        Unity(i).Tubes.HeatTransfer.htube= HE.TubeFilmCoeff(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Tubes.HeatTransfer.PR,Unity(i).Properties.Cold.Average.K,Unity(i).Tubes.HeatTransfer.Phi);
    13811278       
    13821279"Shell Side Prandtl Number"
    1383         Unity(i).Shell.HeatTransfer.PR=((Unity(i).Properties.Hot.Average.Cp/Unity(i).Properties.Hot.Average.Mw)*Unity(i).Properties.Hot.Average.Mu)/Unity(i).Properties.Hot.Average.K
     1280        Unity(i).Shell.HeatTransfer.PR=HE.PrandtlNumber(Unity(i).Properties.Hot.Average.K,Unity(i).Properties.Hot.Average.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Average.Mu);   
    13841281
    13851282"Shell Side Prandtl Number at Wall"
    1386         Unity(i).Shell.HeatTransfer.PRw=((Unity(i).Properties.Hot.Wall.Cp/Unity(i).Properties.Hot.Average.Mw)*Unity(i).Properties.Hot.Wall.Mu)/Unity(i).Properties.Hot.Wall.K
     1283        Unity(i).Shell.HeatTransfer.PRw=HE.PrandtlNumber(Unity(i).Properties.Hot.Wall.K,Unity(i).Properties.Hot.Wall.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Wall.Mu);   
    13871284
    13881285"Tube Side Pressure Drop"
     
    14221319        else
    14231320
    1424 "Cold Wall Temperature"
     1321"Wall Temperature"
     1322#       Tubes.HeatTransfer.Twall = HE.WallTemperature(Properties.Cold.Average.T,Properties.Hot.Average.T,Tubes.HeatTransfer.htube,Shell.HeatTransfer.hshell);
     1323
     1324#       Tubes.HeatTransfer.Twall = HE.WallTemperature(Properties.Cold.Average.T,Properties.Hot.Average.T,Tubes.HeatTransfer.htube,Shell.HeatTransfer.hshell);
     1325
    14251326        Unity(i).Properties.Cold.Wall.Twall  = (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
    1426 
    1427 "Hot Wall Temperature"
     1327       
    14281328        Unity(i).Properties.Hot.Wall.Twall  = (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
    14291329
     1330
     1331
    14301332"Tube Side Velocity"
    1431         Unity(i).Tubes.HeatTransfer.Vtube  = Unity(i).Properties.Hot.Inlet.Fw*Tpass/((Pi*Ditube*Ditube/4)*Unity(i).Properties.Hot.Average.rho*Ntt);
     1333        Unity(i).Tubes.HeatTransfer.Vtube=HE.TubeVelocity(Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Properties.Hot.Average.rho);
    14321334
    14331335"Tube Side Reynolds Number"
    1434         Unity(i).Tubes.HeatTransfer.Re=(Unity(i).Properties.Hot.Average.rho*Unity(i).Tubes.HeatTransfer.Vtube*Ditube)/Unity(i).Properties.Hot.Average.Mu;
     1336        Unity(i).Tubes.HeatTransfer.Re=HE.TubeReynoldsNumber(Unity(i).Properties.Hot.Average.rho,Unity(i).Tubes.HeatTransfer.Vtube,Unity(i).Properties.Hot.Average.Mu);
    14351337       
    14361338"Tube Side Prandtl Number"
    1437         Unity(i).Tubes.HeatTransfer.PR=((Unity(i).Properties.Hot.Average.Cp/Unity(i).Properties.Hot.Average.Mw)*Unity(i).Properties.Hot.Average.Mu)/Unity(i).Properties.Hot.Average.K;
     1339        Unity(i).Tubes.HeatTransfer.PR=HE.PrandtlNumber(Unity(i).Properties.Hot.Average.K,Unity(i).Properties.Hot.Average.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Average.Mu);
    14381340
    14391341"Tube Side Prandtl Number at Wall"
    1440         Unity(i).Tubes.HeatTransfer.PRw=((Unity(i).Properties.Hot.Wall.Cp/Unity(i).Properties.Hot.Average.Mw)*Unity(i).Properties.Hot.Wall.Mu)/Unity(i).Properties.Hot.Wall.K;
     1342        Unity(i).Tubes.HeatTransfer.PRw=HE.PrandtlNumber(Unity(i).Properties.Hot.Wall.K,Unity(i).Properties.Hot.Wall.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Wall.Mu);
    14411343
    14421344"Tube Side Film Coefficient"
    1443         Unity(i).Tubes.HeatTransfer.htube= HE.TubeFilmCoeff(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Tubes.HeatTransfer.PR,Unity(i).Properties.Hot.Average.K)*Unity(i).Tubes.HeatTransfer.Phi;
     1345        Unity(i).Tubes.HeatTransfer.htube= HE.TubeFilmCoeff(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Tubes.HeatTransfer.PR,Unity(i).Properties.Hot.Average.K,Unity(i).Tubes.HeatTransfer.Phi);
    14441346       
    14451347"Shell Side Prandtl Number"
    1446         Unity(i).Shell.HeatTransfer.PR=((Unity(i).Properties.Cold.Average.Cp/Unity(i).Properties.Cold.Average.Mw)*Unity(i).Properties.Cold.Average.Mu)/Unity(i).Properties.Cold.Average.K;
     1348        Unity(i).Shell.HeatTransfer.PR=HE.PrandtlNumber(Unity(i).Properties.Cold.Average.K,Unity(i).Properties.Cold.Average.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Average.Mu);
    14471349
    14481350"Shell Side Prandtl Number at Wall"
    1449         Unity(i).Shell.HeatTransfer.PRw=((Unity(i).Properties.Cold.Wall.Cp/Unity(i).Properties.Cold.Average.Mw)*Unity(i).Properties.Cold.Wall.Mu)/Unity(i).Properties.Cold.Wall.K;
     1351        Unity(i).Shell.HeatTransfer.PRw=HE.PrandtlNumber(Unity(i).Properties.Cold.Wall.K,Unity(i).Properties.Cold.Wall.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Wall.Mu);
    14501352
    14511353"Tube Side Pressure Drop"
     
    14851387end
    14861388
    1487 if side equal 1
    1488        
    1489         then
    1490 
    1491 "Shell Side inlet Nozzle rho-V^2"
    1492         Unity(i).Shell.PressureDrop.RVsquare_in = Unity(i).Properties.Hot.Inlet.rho*(Unity(i).Shell.PressureDrop.Vnozzle_in)^2;
    1493 
    1494 "Shell Side Outlet Nozzle rho-V^2"
    1495         Unity(i).Shell.PressureDrop.RVsquare_out = Unity(i).Properties.Hot.Outlet.rho*(Unity(i).Shell.PressureDrop.Vnozzle_out)^2;
    1496        
    1497         else
    1498        
    1499 "Shell Side inlet Nozzle rho-V^2"
    1500         Unity(i).Shell.PressureDrop.RVsquare_in = Unity(i).Properties.Cold.Inlet.rho*(Unity(i).Shell.PressureDrop.Vnozzle_in)^2;
    1501 
    1502 "Shell Side Outlet Nozzle rho-V^2"
    1503         Unity(i).Shell.PressureDrop.RVsquare_out = Unity(i).Properties.Cold.Outlet.rho*(Unity(i).Shell.PressureDrop.Vnozzle_out)^2;
    1504 
    1505 end
    1506 
    15071389"Tube Resistance"       
    15081390        Unity(i).Resistances.Rtube*(Unity(i).Tubes.HeatTransfer.htube*Ditube) = Dotube;
     
    15371419       
    15381420"Shell Side Reynolds Number"
    1539         Unity(i).Shell.HeatTransfer.Re=(Dotube*Unity(i).Properties.Hot.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)/Unity(i).Properties.Hot.Average.Mu;
     1421        Unity(i).Shell.HeatTransfer.Re=HE.ShellReynoldsNumber(Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Properties.Hot.Average.Mu);
    15401422
    15411423"Shell Heat Transfer Coefficient"
    1542         Unity(i).Shell.HeatTransfer.hshell=Unity(i).Shell.HeatTransfer.Ji*(Unity(i).Properties.Hot.Average.Cp/Unity(i).Properties.Hot.Average.Mw)*(Unity(i).Properties.Hot.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)*(Unity(i).Shell.HeatTransfer.PR^(-2/3))*Unity(i).Shell.HeatTransfer.Jtotal*Unity(i).Shell.HeatTransfer.Phi;
     1424        Unity(i).Shell.HeatTransfer.hshell=HE.ShellFilmCoeff(Unity(i).Shell.HeatTransfer.Ji,Unity(i).Properties.Hot.Average.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Shell.HeatTransfer.PR,Unity(i).Shell.HeatTransfer.Jtotal,Unity(i).Shell.HeatTransfer.Phi);
    15431425
    15441426"Shell Pressure Drop Cross Flow"
     
    15551437
    15561438"Shell Side Reynolds Number"
    1557         Unity(i).Shell.HeatTransfer.Re=(Dotube*Unity(i).Properties.Cold.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)/Unity(i).Properties.Cold.Average.Mu;
     1439        Unity(i).Shell.HeatTransfer.Re=HE.ShellReynoldsNumber(Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Properties.Cold.Average.Mu);
    15581440
    15591441"Shell Heat Transfer Coefficient"
    1560         Unity(i).Shell.HeatTransfer.hshell=Unity(i).Shell.HeatTransfer.Ji*(Unity(i).Properties.Cold.Average.Cp/Unity(i).Properties.Cold.Average.Mw)*(Unity(i).Properties.Cold.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)*(Unity(i).Shell.HeatTransfer.PR^(-2/3))*Unity(i).Shell.HeatTransfer.Jtotal*Unity(i).Shell.HeatTransfer.Phi;
     1442        Unity(i).Shell.HeatTransfer.hshell=HE.ShellFilmCoeff(Unity(i).Shell.HeatTransfer.Ji,Unity(i).Properties.Cold.Average.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Shell.HeatTransfer.PR,Unity(i).Shell.HeatTransfer.Jtotal,Unity(i).Shell.HeatTransfer.Phi);
    15611443
    15621444"Shell Pressure Drop Cross Flow"
     
    15811463
    15821464        SET
    1583 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1465#=====================================================================
    15841466#  Set Parameters for heatex Calculation
    1585 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1467#=====================================================================
    15861468        Pi                              = 3.14159265;
    15871469        HE.Tpass                        = Tpass;
  • /mso/eml/heat_exchangers/HeatExchangerDiscretized.mso

    r49 r25  
    1 
    2 #--------------------------------------------------------------------
    3 # Author: Gerson Balbueno Bicca
    4 # $Id$
    5 #--------------------------------------------------------------------
     1 #*--------------------------------------------------------------------*
     2*
     3*
     4*
     5*
     6*
     7*
     8*               
     9*                                               
     10*
     11*
     12*----------------------------------------------------------------------
     13* Author: Gerson Balbueno Bicca
     14* $Id$
     15*--------------------------------------------------------------------*#
    616
    717using "HEX_Engine";
    818
    9 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     19#=====================================================================
    1020#       Basic Model for Discretized Heat Exchangers
    11 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     21#=====================================================================
    1222
    1323Model HeatExchangerDiscretized_Basic
     
    1626
    1727ext PP      as CalcObject(Brief="External Physical Properties");
    18         HE          as CalcObject(Brief="STHE Calculations",File="heatex");
     28ext HE      as CalcObject(Brief="STHE Calculations",File="heatex.dll");
    1929ext NComp   as Integer   (Brief="Number of Components");
    2030  M(NComp)  as molweight (Brief="Component Mol Weight");
     
    2636        Properties  as Main_Properties;         # Hot and Cold Properties
    2737        Details     as Details_Main;
    28         Tubes           as Tube_Side_Main;     
    29         Shell           as Shell_Side_Main;
     38        Tubes           as Tube_Side_Main_Disc;
     39        Shell           as Shell_Side_Main_Disc;
    3040        Resistances as Main_Resistances;
    3141        Baffles     as Baffles_Main;
     
    194204end
    195205
    196 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     206#=====================================================================
    197207#       Thermal Details
    198 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     208#=====================================================================
    199209"Hot Stream Heat Capacity"
    200210        Details.Ch =Inlet.Hot.F*Properties.Hot.Average.Cp;
     
    203213        Details.Cc =Inlet.Cold.F*Properties.Cold.Average.Cp;
    204214       
    205 "Minimum Heat Capacity"
    206         Details.Cmin  = min([Details.Ch,Details.Cc]);
    207 
    208 "Maximum Heat Capacity"
    209         Details.Cmax  = max([Details.Ch,Details.Cc]);
    210 
    211215"Heat Capacity Ratio"
    212         Details.Cr    = Details.Cmin/Details.Cmax;
    213        
    214 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     216        [Details.Cmin,Details.Cmax,Details.Cr]  = HE.HeatCapacityRatio(Details.Ch,Details.Cc);
     217
     218#=====================================================================
    215219#       Energy Balance
    216 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     220#=====================================================================
    217221"Energy Balance Hot Stream"
    218222        Details.Q = Inlet.Hot.F*(Inlet.Hot.h-Outlet.Hot.h);
     
    221225        Details.Q =-Inlet.Cold.F*(Inlet.Cold.h-Outlet.Cold.h);
    222226
    223 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     227#=====================================================================
    224228#       Material Balance
    225 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     229#=====================================================================
    226230"Flow Mass Inlet Cold Stream"
    227231        Properties.Cold.Inlet.Fw        =  sum(M*Inlet.Cold.z)*Inlet.Cold.F;
     
    242246        Inlet.Cold.F = Outlet.Cold.F;
    243247
    244 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     248#======================================
    245249#       Constraints
    246 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     250#======================================
    247251"Hot Stream Molar Fraction Constraint"
    248252        Outlet.Hot.z=Inlet.Hot.z;
     
    260264end
    261265
     266Model Heatex_Discretized_LMTD           as HeatExchangerDiscretized_Basic
     267       
     268VARIABLES
     269LMTD            as temp_delta   (Brief="Logarithmic Mean Temperature Difference",Lower=5);
     270Fc                      as positive             (Brief="LMTD Correction Factor",Lower=0.1);
     271MTD                     as temp_delta   (Brief="Mean Temperature Difference",Lower=5);
     272
     273EQUATIONS
     274
     275"Exchange Surface Area"
     276        Details.Q   = Details.U*Details.A*MTD;
     277       
     278"Mean Temperature Difference"   
     279        MTD   = Fc*LMTD;
     280       
     281"LMTD Correction Factor"
     282        Fc = HE.EshellCorrectionFactor(Inlet.Hot.T,Outlet.Hot.T,Inlet.Cold.T,Outlet.Cold.T);
     283
     284"LMTD"
     285        LMTD = HE.CounterLMTD(Inlet.Hot.T,Outlet.Hot.T,Inlet.Cold.T,Outlet.Cold.T);
     286
     287end
     288
    262289Model Heatex_Discretized_NTU            as HeatExchangerDiscretized_Basic
    263290       
     
    272299
    273300"TEMA E Shell Effectiveness"
    274         Eft = HE.EshellEffectiveness(Details.Cr,Details.NTU);
    275        
    276 end
    277 
    278 Model Heatex_Discretized_LMTD           as HeatExchangerDiscretized_Basic
    279        
     301#       Eft = HE.EshellEffectiveness(Details.Cr,Details.NTU);
     302       
     303        Eft = 0.10;
     304       
     305end
     306
     307Model Profiles
     308
     309PARAMETERS
     310
     311Zones                   as Integer;
     312
    280313VARIABLES
    281 DT0     as temp_delta   (Brief="Temperature Difference at Inlet",Lower=1);
    282 DTL             as temp_delta   (Brief="Temperature Difference at Outlet",Lower=1);
    283 LMTD    as temp_delta   (Brief="Logarithmic Mean Temperature Difference",Lower=5);
    284 Fc              as positive             (Brief="LMTD Correction Factor",Lower=0.5);
    285 MTD             as temp_delta   (Brief="Mean Temperature Difference",Lower=1);
    286 
    287 EQUATIONS
    288 "Exchange Surface Area"
    289         Details.Q   = Details.U*Details.A*MTD;
    290        
    291 "Mean Temperature Difference"   
    292         MTD   = Fc*LMTD;
    293        
    294 #"LMTD Correction Factor"
    295 #       Fc = HE.EshellCorrectionFactor(Inlet.Hot.T,Outlet.Hot.T,Inlet.Cold.T,Outlet.Cold.T);
    296 
    297 "Temperature Difference at Inlet"
    298         DT0 = Inlet.Hot.T - Outlet.Cold.T;
    299 
    300 "Temperature Difference at Outlet"
    301         DTL = Outlet.Hot.T - Inlet.Cold.T;
    302 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    303 #                       Log Mean Temperature Difference
    304 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    305 if abs(DT0 - DTL) > 0.05*max(abs([DT0,DTL]))
    306        
    307         then
    308 "Log Mean Temperature Difference"
    309         LMTD= (DT0-DTL)/ln(DT0/DTL);
    310 
    311         else
    312        
    313 if DT0*DTL equal 0
    314        
    315         then
    316 "Log Mean Temperature Difference"
    317         LMTD = 0.5*(DT0+DTL);
    318        
    319         else
    320 "Log Mean Temperature Difference"
    321         LMTD = 0.5*(DT0+DTL)*(1-(DT0-DTL)^2/(DT0*DTL)*(1+(DT0-DTL)^2/(DT0*DTL)/2)/12);
    322        
    323 end
    324        
    325 end
    326 
    327        
    328 end
    329 
    330 Model Profiles
    331 
     314
     315Lz(Zones)        as length;
     316Lpos(Zones)      as length;
     317Area                    as area;
     318Q                       as power;
     319PdropShellTotal as pressure;
     320PdropTubesTotal as pressure;
     321PdropWinTotal   as pressure;
     322PdropCrossTotal as pressure;
     323PdropEndsTotal  as pressure;
     324Uaverage                as heat_trans_coeff (Brief="Overall Heat Transfer Coefficient",Default=1,Lower=1e-6,Upper=1e10);
     325hshellaverage   as heat_trans_coeff     (Brief="Shell Side Film Coefficient",Default=1,Lower=1e-12, Upper=1e6);
     326htubeaverage    as heat_trans_coeff     (Brief="Shell Side Film Coefficient",Default=1,Lower=1e-12, Upper=1e6);
     327Thot(Zones)      as temperature(Lower = 70, Upper = 500);
     328Tcold(Zones)     as temperature(Lower = 70, Upper = 500);
     329Phot(Zones)      as pressure(Lower = 0.8, Upper = 30);
     330Pcold(Zones)     as pressure(Lower = 0.8, Upper = 30);
     331
     332end
     333
     334
     335Model E_Shell_LMTD_Disc         
     336#============================================================================
     337#       Shell and Tubes Heat Exchanger In Series with 1 shell pass - LMTD Method
     338#============================================================================
    332339PARAMETERS
    333340
    334 Zones   as Integer(Brief="Number of Zones");
    335 
    336 VARIABLES
    337 
    338 Lz(Zones)               as length                       (Brief="Zone Tube Length");
    339 Area                            as area                         (Brief="Area Total");
    340 Q                               as power                        (Brief="Total Duty");
    341 PdropTubesNozzle        as pressure                     (Brief="Total Tube Nozzles Pressure Drop");
    342 PdropTubes                      as pressure                     (Brief="Total Tube Pressure Drop");
    343 PdropWin                        as pressure                     (Brief="Total Shell Side Window Pressure Drop");
    344 PdropCross                      as pressure                     (Brief="Total Shell Side Cross Flow Pressure Drop");
    345 PdropEnds                       as pressure                     (Brief="Total Shell Side Ends Pressure Drop");
    346 PdropShellNozzle        as pressure                     (Brief="Total Shell Side Nozzles Pressure Drop");
    347 PdropShell                      as pressure                     (Brief="Total Shell Side Pressure Drop");
    348 Uaverage                        as heat_trans_coeff (Brief="Average Overall Heat Transfer Coefficient",Default=1,Lower=1e-6,Upper=1e10);
    349 hshellaverage           as heat_trans_coeff     (Brief="Average Shell Side Film Coefficient",Default=1,Lower=1e-12, Upper=1e6);
    350 htubeaverage            as heat_trans_coeff     (Brief="Average Tube Side Film Coefficient",Default=1,Lower=1e-12, Upper=1e6);
    351 Thot(Zones)             as temperature          (Brief="Hot Temperature",Lower = 300, Upper = 500);
    352 Tcold(Zones)            as temperature          (Brief="Cold Temperature",Lower = 300, Upper = 500);
    353 Phot(Zones)             as pressure                     (Brief="Hot Pressure",Lower = 0.8, Upper = 30);
    354 Pcold(Zones)            as pressure                     (Brief="Cold Pressure",Lower = 0.8, Upper = 30);
    355 
    356 end
    357 
    358 Model E_Shell_NTU_Disc           
    359 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    360 #       Shell and Tubes Heat Exchanger with 1 shell pass - NTU Method
    361 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    362 PARAMETERS
    363 
    364         HE      as CalcObject   (Brief="STHE Calculations",File="heatex");
    365 ext PP  as CalcObject   (Brief="External Physical Properties");
    366 side    as Integer              (Brief="Fluid Alocation",Lower=0,Upper=1);
    367 Pi              as constant     (Brief="Pi Number",Default=3.14159265);
    368 
    369 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     341ext     HE              as CalcObject   (Brief="STHE Calculations",File="heatex.dll");
     342ext PP          as CalcObject;
     343side            as Integer              (Brief="Fluid Alocation",Lower=0,Upper=1);
     344Pi                      as constant     (Brief="Pi Number",Default=3.14159265);
     345
     346#=====================================================================
    370347#       Shell Geometrical Parameters
    371 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     348#=====================================================================
    372349Tpass                   as Integer              (Brief="Number of Tube Passes",Lower=1);
    373350Nss                             as Integer              (Brief="Number of Sealing Strips pairs",Lower=1);
     
    378355Honozzle_Shell  as length               (Brief="Height Under Shell Outlet Nozzle",Lower=10e-6);
    379356Lcf                     as length               (Brief="Bundle-to-Shell Clearance",Lower=10e-8);
    380 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     357#=====================================================================
    381358#       Tubes Geometrical Parameters
    382 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     359#=====================================================================
    383360Ntt                             as Integer              (Brief="Total Number of Tubes in Shell",Default=100,Lower=1);
    384361Pattern         as Integer              (Brief="Tube Layout Characteristic Angle",Lower=30);
     
    390367Donozzle_Tube   as length               (Brief="Tube Outlet Nozzle Diameter",Lower=10e-6);
    391368Dinozzle_Tube   as length               (Brief="Tube Inlett Nozzle Diameter",Lower=10e-6);
    392 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     369#=====================================================================
    393370#       Baffles Geometrical Parameters
    394 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     371#=====================================================================
    395372Bc                      as Integer              (Brief="Baffle Cut",Default=25,Lower=25);
    396373Nb              as Integer              (Brief="Number of Baffles",Default=4);
    397374Lcd                     as length               (Brief="Baffle-to-Shell Clearance",Lower=10e-8);
    398375Ltd                             as length               (Brief="Tube-to-Bafflehole Clearance",Lower=10e-8);
    399 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     376#=====================================================================
    400377VARIABLES
    401378
    402 Unity(Nb+1)     as Heatex_Discretized_NTU;
     379PdropNozzles    as Pdrop_Nozzles_Main;
     380Unity(Nb+1)     as Heatex_Discretized_LMTD;
    403381Sumary          as Profiles;
    404382
     
    410388EQUATIONS
    411389
    412 "Hot Temperatures"
    413         Sumary.Thot     = Unity.Outlet.Hot.T;
    414        
    415 "Cold Temperatures"
    416         Sumary.Tcold    = Unity.Outlet.Cold.T ;
    417 
    418 "Hot Pressures"
    419         Sumary.Phot     = Unity.Outlet.Hot.P ;
    420        
    421 "Cold Pressures"
    422         Sumary.Pcold    = Unity.Outlet.Cold.P ;
    423 
    424 "Average Shell Side Film Coefficient"
    425         Sumary.hshellaverage            = sum(Unity.Shell.HeatTransfer.hshell)/Sumary.Zones;
    426 
    427 "Average Tube Side Film Coefficient"
    428         Sumary.htubeaverage             = sum(Unity.Tubes.HeatTransfer.htube)/Sumary.Zones;
    429 
    430 "Average Overall Heat Transfer Coefficient"
    431         Sumary.Uaverage                 = sum(Unity.Details.U)/Sumary.Zones;
    432 
    433 "Area Total"
    434         Sumary.Area                             = sum(Unity.Details.A);
    435 
    436 "Duty Total"
    437         Sumary.Q                                = sum(Unity.Details.Q);
    438 
    439 "Length Inlet zone"
    440         Sumary.Lz(1)                            = Unity(1).Baffles.Lsi;
    441 
    442 "Length Outlet zone"
    443         Sumary.Lz(Nb+1)                         = Unity(1).Baffles.Lso;
    444 
    445 "Total Shell Side Pressure Drop"
    446         Sumary.PdropShell                       = sum(Unity.Shell.PressureDrop.Pdtotal);
    447 
    448 "Total Tube Side Pressure Drop"
    449         Sumary.PdropTubes                       = sum(Unity.Tubes.PressureDrop.Pdtotal);
    450 
    451 "Total Tube Side Nozzles Pressure Drop"
    452         Sumary.PdropTubesNozzle         = sum(Unity.Tubes.PressureDrop.Pdnozzle_in + Unity.Tubes.PressureDrop.Pdnozzle_out);
    453 
    454 "Total Shell Side Nozzles Pressure Drop"
    455         Sumary.PdropShellNozzle         = sum(Unity.Shell.PressureDrop.Pdnozzle_in + Unity.Shell.PressureDrop.Pdnozzle_out);
    456 
    457 "Total Shell Side Window Pressure Drop"
    458         Sumary.PdropWin                         = sum(Unity.Shell.PressureDrop.Pdwindow);
    459 
    460 "Total Shell Side Cross Flow Pressure Drop"
    461         Sumary.PdropCross                       = sum(Unity.Shell.PressureDrop.PdCross);
    462 
    463 "Total Shell Side Ends Pressure Drop"
    464         Sumary.PdropEnds                        = sum(Unity.Shell.PressureDrop.PdEndZones);
     390"Outlet Hot Temperature"
     391        Sumary.Thot                 = Unity.Outlet.Hot.T ;
     392       
     393"Outlet Cold Temperature"
     394        Sumary.Tcold            = Unity.Outlet.Cold.T ;
     395Sumary.Phot                 = Unity.Outlet.Hot.P ;
     396Sumary.Pcold                = Unity.Outlet.Cold.P ;
     397
     398Sumary.hshellaverage = sum(Unity.Shell.HeatTransfer.hshell)/Sumary.Zones;
     399Sumary.htubeaverage  = sum(Unity.Tubes.HeatTransfer.htube)/Sumary.Zones;
     400Sumary.Uaverage     = sum(Unity.Details.U)/Sumary.Zones;
     401Sumary.Area             = sum(Unity.Details.A);
     402Sumary.Q                = sum(Unity.Details.Q);
     403
     404Sumary.PdropShellTotal = sum(Unity.Shell.PressureDrop.Pdtotal)+PdropNozzles.Shell.Pdnozzle_in + PdropNozzles.Shell.Pdnozzle_out;
     405Sumary.PdropTubesTotal = sum(Unity.Tubes.PressureDrop.Pdtotal)+PdropNozzles.Tubes.Pdnozzle_in + PdropNozzles.Tubes.Pdnozzle_out;
     406Sumary.PdropWinTotal    = sum(Unity.Shell.PressureDrop.Pdwindow);
     407Sumary.PdropCrossTotal = sum(Unity.Shell.PressureDrop.PdCross);
     408Sumary.PdropEndsTotal   = sum(Unity.Shell.PressureDrop.PdEndZones);
     409
     410Sumary.Lz(1)    = Unity(1).Baffles.Lsi;
    465411
    466412"Shell Side Cross Flow Area"
     
    469415"Shell Side Cross Flow Area"
    470416        Unity(Nb+1).Shell.HeatTransfer.Sm = HE.CrossFlowArea(Unity(Nb+1).Baffles.Lso);
    471 
     417       
     418Sumary.Lz(Nb+1) = Unity(1).Baffles.Lso;
    472419
    473420if side equal 1
    474421       
    475422        then
    476        
    477 "Shell Side inlet Nozzle rho-V^2"
    478         Unity(1).Shell.PressureDrop.RVsquare_in = Unity(1).Properties.Hot.Inlet.rho*(Unity(1).Shell.PressureDrop.Vnozzle_in)^2;
    479 
    480 "Shell Side Outlet Nozzle rho-V^2"
    481         Unity(Nb+1).Shell.PressureDrop.RVsquare_out = Unity(Nb+1).Properties.Hot.Outlet.rho*(Unity(Nb+1).Shell.PressureDrop.Vnozzle_out)^2;
    482 
    483 "Shell Pressure End Zones"
    484         Unity(1).Shell.PressureDrop.PdEndZones          =       HE.DeltaPendZonesIncremental(Unity(1).Shell.HeatTransfer.Re,Unity(1).Baffles.Ls,Unity(1).Baffles.Lso,
    485         Unity(1).Baffles.Lsi,Unity(1).Properties.Hot.Inlet.Fw,Unity(1).Shell.HeatTransfer.Phi,Unity(1).Properties.Hot.Average.rho);
    486 
    487 "Shell Pressure End Zones"
    488         Unity(Nb+1).Shell.PressureDrop.PdEndZones       =       HE.DeltaPendZonesIncremental(Unity(Nb+1).Shell.HeatTransfer.Re,Unity(Nb+1).Baffles.Ls,Unity(Nb+1).Baffles.Lso,
    489         Unity(Nb+1).Baffles.Lsi,Unity(Nb+1).Properties.Hot.Inlet.Fw,Unity(Nb+1).Shell.HeatTransfer.Phi,Unity(Nb+1).Properties.Hot.Average.rho);
     423
     424"Pressure Drop Hot Stream"
     425        Unity(1).Outlet.Hot.P  = Unity(1).Inlet.Hot.P - Unity(1).Shell.PressureDrop.Pdtotal - PdropNozzles.Shell.Pdnozzle_in;   
     426        Unity(Nb+1).Outlet.Hot.P  = Unity(Nb+1).Inlet.Hot.P - Unity(Nb+1).Shell.PressureDrop.Pdtotal - PdropNozzles.Shell.Pdnozzle_out;
     427
     428"Pressure Drop Cold Stream"
     429        Unity(1).Outlet.Cold.P  = Unity(1).Inlet.Cold.P - Unity(1).Tubes.PressureDrop.Pdtotal - PdropNozzles.Tubes.Pdnozzle_in;
     430        Unity(Nb+1).Outlet.Cold.P  = Unity(Nb+1).Inlet.Cold.P - Unity(Nb+1).Tubes.PressureDrop.Pdtotal - PdropNozzles.Tubes.Pdnozzle_out;
    490431
    491432"Pressure Drop Tube Side Inlet Nozzle"
    492         Unity(1).Tubes.PressureDrop.Pdnozzle_in = HE.DeltaPtubeNozzlein(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
     433        PdropNozzles.Tubes.Pdnozzle_in  = HE.DeltaPtubeNozzlein(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
    493434
    494435"Velocity Tube Side Inlet Nozzle"
    495         Unity(1).Tubes.PressureDrop.Vnozzle_in  = HE.TubeVelocityNozzlein(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
     436        PdropNozzles.Tubes.Vnozzle_in   = HE.TubeVelocityNozzlein(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
    496437
    497438"Pressure Drop Tube Side Outlet Nozzle"
    498         Unity(Nb+1).Tubes.PressureDrop.Pdnozzle_out     = HE.DeltaPtubeNozzleout(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
     439        PdropNozzles.Tubes.Pdnozzle_out = HE.DeltaPtubeNozzleout(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
    499440
    500441"Velocity Tube Side Outlet Nozzle"
    501         Unity(Nb+1).Tubes.PressureDrop.Vnozzle_out      = HE.TubeVelocityNozzleout(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
     442        PdropNozzles.Tubes.Vnozzle_out  = HE.TubeVelocityNozzleout(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
    502443
    503444"Shell Pressure Drop Inlet Nozzle"
    504         Unity(1).Shell.PressureDrop.Pdnozzle_in = HE.DeltaPshellNozzleIn(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
     445        PdropNozzles.Shell.Pdnozzle_in  = HE.DeltaPshellNozzleIn(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
    505446
    506447"Velocity Shell Side Inlet Nozzle"
    507         Unity(1).Shell.PressureDrop.Vnozzle_in  = HE.ShellVelocityNozzleIn(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
     448        PdropNozzles.Shell.Vnozzle_in   = HE.ShellVelocityNozzleIn(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
    508449
    509450"Shell Pressure Drop Outlet Nozzle"
    510         Unity(Nb+1).Shell.PressureDrop.Pdnozzle_out     =HE.DeltaPshellNozzleOut(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);
     451        PdropNozzles.Shell.Pdnozzle_out =HE.DeltaPshellNozzleOut(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);
    511452
    512453"Velocity Shell Side Outlet Nozzle"
    513         Unity(Nb+1).Shell.PressureDrop.Vnozzle_out      =HE.ShellVelocityNozzleOut(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);
    514        
     454        PdropNozzles.Shell.Vnozzle_out  =HE.ShellVelocityNozzleOut(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);
     455
    515456
    516457        else
    517458       
    518 "Shell Side inlet Nozzle rho-V^2"
    519         Unity(1).Shell.PressureDrop.RVsquare_in = Unity(1).Properties.Cold.Inlet.rho*(Unity(1).Shell.PressureDrop.Vnozzle_in)^2;
    520 
    521 "Shell Side Outlet Nozzle rho-V^2"
    522         Unity(Nb+1).Shell.PressureDrop.RVsquare_out = Unity(Nb+1).Properties.Cold.Outlet.rho*(Unity(Nb+1).Shell.PressureDrop.Vnozzle_out)^2;
    523 
    524 "Shell Pressure End Zones"
    525         Unity(1).Shell.PressureDrop.PdEndZones          =       HE.DeltaPendZonesIncremental(Unity(1).Shell.HeatTransfer.Re,Unity(1).Baffles.Ls,Unity(1).Baffles.Lso,
    526         Unity(1).Baffles.Lsi,Unity(1).Properties.Cold.Inlet.Fw,Unity(1).Shell.HeatTransfer.Phi,Unity(1).Properties.Cold.Average.rho);
    527 
    528 "Shell Pressure End Zones"
    529         Unity(Nb+1).Shell.PressureDrop.PdEndZones       =       HE.DeltaPendZonesIncremental(Unity(Nb+1).Shell.HeatTransfer.Re,Unity(Nb+1).Baffles.Ls,Unity(Nb+1).Baffles.Lso,
    530         Unity(Nb+1).Baffles.Lsi,Unity(Nb+1).Properties.Cold.Inlet.Fw,Unity(Nb+1).Shell.HeatTransfer.Phi,Unity(Nb+1).Properties.Cold.Average.rho);
    531 
     459"Pressure Drop Hot Stream"
     460        Unity(1).Outlet.Hot.P  = Unity(1).Inlet.Hot.P- Unity(1).Tubes.PressureDrop.Pdtotal - PdropNozzles.Tubes.Pdnozzle_in;   
     461        Unity(Nb+1).Outlet.Hot.P  = Unity(Nb+1).Inlet.Hot.P- Unity(Nb+1).Tubes.PressureDrop.Pdtotal - PdropNozzles.Tubes.Pdnozzle_out; 
     462       
     463"Pressure Drop Cold Stream"
     464        Unity(1).Outlet.Cold.P  = Unity(1).Inlet.Cold.P - Unity(1).Shell.PressureDrop.Pdtotal- PdropNozzles.Shell.Pdnozzle_in;
     465        Unity(Nb+1).Outlet.Cold.P  = Unity(Nb+1).Inlet.Cold.P - Unity(Nb+1).Shell.PressureDrop.Pdtotal- PdropNozzles.Shell.Pdnozzle_out;
    532466
    533467"Pressure Drop Tube Side Inlet Nozzle"
    534         Unity(1).Tubes.PressureDrop.Pdnozzle_in = HE.DeltaPtubeNozzlein(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
     468        PdropNozzles.Tubes.Pdnozzle_in  = HE.DeltaPtubeNozzlein(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
    535469
    536470"Velocity Tube Side Inlet Nozzle"
    537         Unity(1).Tubes.PressureDrop.Vnozzle_in  = HE.TubeVelocityNozzlein(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
     471        PdropNozzles.Tubes.Vnozzle_in   = HE.TubeVelocityNozzlein(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
    538472
    539473"Pressure Drop Tube Side Outlet Nozzle"
    540         Unity(Nb+1).Tubes.PressureDrop.Pdnozzle_out     = HE.DeltaPtubeNozzleout(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);   
     474        PdropNozzles.Tubes.Pdnozzle_out = HE.DeltaPtubeNozzleout(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);   
    541475
    542476"Velocity Tube Side Outlet Nozzle"
    543         Unity(Nb+1).Tubes.PressureDrop.Vnozzle_out      = HE.TubeVelocityNozzleout(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw); 
     477        PdropNozzles.Tubes.Vnozzle_out  = HE.TubeVelocityNozzleout(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw); 
    544478
    545479"Shell Pressure Drop Inlet Nozzle"
    546         Unity(1).Shell.PressureDrop.Pdnozzle_in = HE.DeltaPshellNozzleIn(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
     480        PdropNozzles.Shell.Pdnozzle_in  = HE.DeltaPshellNozzleIn(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
    547481
    548482"Velocity Shell Side Inlet Nozzle"
    549         Unity(1).Shell.PressureDrop.Vnozzle_in  = HE.ShellVelocityNozzleIn(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
     483        PdropNozzles.Shell.Vnozzle_in   = HE.ShellVelocityNozzleIn(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
    550484
    551485"Shell Pressure Drop Outlet Nozzle"
    552         Unity(Nb+1).Shell.PressureDrop.Pdnozzle_out = HE.DeltaPshellNozzleOut(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
     486        PdropNozzles.Shell.Pdnozzle_out = HE.DeltaPshellNozzleOut(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
    553487
    554488"Velocity Shell Side Outlet Nozzle"
    555         Unity(Nb+1).Shell.PressureDrop.Vnozzle_out  = HE.ShellVelocityNozzleOut(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
    556 
     489        PdropNozzles.Shell.Vnozzle_out  = HE.ShellVelocityNozzleOut(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
    557490
    558491end
     
    561494for i in [2:Nb]
    562495
    563 "Pressure Drop Tube Side Inlet Nozzle"
    564         Unity(i).Tubes.PressureDrop.Pdnozzle_in = 0;
    565 
    566 "Velocity Tube Side Inlet Nozzle"
    567         Unity(i).Tubes.PressureDrop.Vnozzle_in  = 0;
    568 
    569 "Pressure Drop Tube Side Outlet Nozzle"
    570         Unity(i).Tubes.PressureDrop.Pdnozzle_out        = 0;   
    571 
    572 "Velocity Tube Side Outlet Nozzle"
    573         Unity(i).Tubes.PressureDrop.Vnozzle_out = 0;   
    574 
    575 "Shell Pressure Drop Inlet Nozzle"
    576         Unity(i).Shell.PressureDrop.Pdnozzle_in = 0;
    577 
    578 "Velocity Shell Side Inlet Nozzle"
    579         Unity(i).Shell.PressureDrop.Vnozzle_in  = 0;
    580 
    581 "Shell Pressure Drop Outlet Nozzle"
    582         Unity(i).Shell.PressureDrop.Pdnozzle_out = 0;
    583 
    584 "Velocity Shell Side Outlet Nozzle"
    585         Unity(i).Shell.PressureDrop.Vnozzle_out  = 0;
    586 
    587 "Shell Pressure End Zones"
    588         Unity(i).Shell.PressureDrop.PdEndZones          =       0;
    589        
    590 "Shell Side Outlet Nozzle rho-V^2"
    591         Unity(i).Shell.PressureDrop.RVsquare_out = 0;
    592        
    593 "Shell Side inlet Nozzle rho-V^2"
    594         Unity(i).Shell.PressureDrop.RVsquare_in = 0;
    595 
    596496if side equal 1
    597497       
    598498        then
    599499       
    600 "Shell Pressure Drop Cross Flow"
    601         Unity(i).Shell.PressureDrop.PdCross             =       HE.DeltaPcrossIncremental(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Ls,Unity(i).Baffles.Lso,Unity(i).Baffles.Lsi,Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Shell.HeatTransfer.Phi,Unity(i).Properties.Hot.Average.rho);
     500"Pressure Drop Hot Stream"
     501        Unity(i).Outlet.Hot.P  = Unity(i).Inlet.Hot.P - Unity(i).Shell.PressureDrop.Pdtotal;   
     502
     503"Pressure Drop Cold Stream"
     504        Unity(i).Outlet.Cold.P  = Unity(i).Inlet.Cold.P - Unity(i).Tubes.PressureDrop.Pdtotal;
    602505
    603506
    604507        else
    605508
    606 "Shell Pressure Drop Cross Flow"
    607         Unity(i).Shell.PressureDrop.PdCross     =       HE.DeltaPcrossIncremental(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Ls,Unity(i).Baffles.Lso,Unity(i).Baffles.Lsi,Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Phi,Unity(i).Properties.Cold.Average.rho);
    608 
    609 
    610 end
    611 
    612 "Zone Length"
     509"Pressure Drop Hot Stream"
     510        Unity(i).Outlet.Hot.P  = Unity(i).Inlet.Hot.P- Unity(i).Tubes.PressureDrop.Pdtotal;     
     511       
     512"Pressure Drop Cold Stream"
     513        Unity(i).Outlet.Cold.P  = Unity(i).Inlet.Cold.P - Unity(i).Shell.PressureDrop.Pdtotal;
     514
     515
     516end
     517
     518"Position for discretization"
    613519        Sumary.Lz(i) = Unity(1).Baffles.Ls;
    614520
    615521"Shell Side Cross Flow Area"
    616522        Unity(i).Shell.HeatTransfer.Sm = HE.CrossFlowArea(Unity(i).Baffles.Ls);
    617        
     523
    618524end
    619525
     
    621527for i in [1:Nb+1]
    622528       
     529"Js Factor"     
     530        Unity(i).Shell.HeatTransfer.Js = HE.JsFactor(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Lsi,Unity(i).Baffles.Lso,Unity(i).Baffles.Ls);
     531
     532"Position for discretization"
     533        Sumary.Lpos(i)                                                  =       sum(Sumary.Lz([1:i]));
     534       
     535"Ji Factor"
     536        Unity(i).Shell.HeatTransfer.Ji          =       HE.JiFactor(Unity(i).Shell.HeatTransfer.Re);
     537
     538"Jc Factor"
     539        Unity(i).Shell.HeatTransfer.Jc          =       HE.JcFactor();
     540       
     541"Jl Factor"
     542        Unity(i).Shell.HeatTransfer.Jl          =       HE.JlFactor(Unity(i).Shell.HeatTransfer.Sm);
     543
     544"Jb Factor"
     545        Unity(i).Shell.HeatTransfer.Jb          =       HE.JbFactor(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Ls,Unity(i).Shell.HeatTransfer.Sm);
     546
     547"Jr Factor"     
     548        Unity(i).Shell.HeatTransfer.Jr          =       HE.JrFactor(Unity(i).Shell.HeatTransfer.Re);
     549       
     550"Total J Factor"
     551        Unity(i).Shell.HeatTransfer.Jtotal      =       Unity(i).Shell.HeatTransfer.Jc*Unity(i).Shell.HeatTransfer.Jl*Unity(i).Shell.HeatTransfer.Jb*Unity(i).Shell.HeatTransfer.Jr*Unity(i).Shell.HeatTransfer.Js;
     552
    623553if side equal 1
    624554       
    625         then
    626 "Pressure Drop Hot Stream"
    627         Unity(i).Outlet.Hot.P  = Unity(i).Inlet.Hot.P - Unity(i).Shell.PressureDrop.Pdtotal;   
    628 
    629 "Pressure Drop Cold Stream"
    630         Unity(i).Outlet.Cold.P  = Unity(i).Inlet.Cold.P - Unity(i).Tubes.PressureDrop.Pdtotal;
    631        
     555then
     556
    632557"Shell Side Reynolds Number"
    633         Unity(i).Shell.HeatTransfer.Re=(Dotube*Unity(i).Properties.Hot.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)/Unity(i).Properties.Hot.Average.Mu;
     558        Unity(i).Shell.HeatTransfer.Re                  = HE.ShellReynoldsNumber(Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Properties.Hot.Average.Mu);
    634559
    635560"Shell Heat Transfer Coefficient"
    636         Unity(i).Shell.HeatTransfer.hshell =Unity(i).Shell.HeatTransfer.Ji*(Unity(i).Properties.Hot.Average.Cp/Unity(i).Properties.Hot.Average.Mw)*(Unity(i).Properties.Hot.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)*(Unity(i).Shell.HeatTransfer.PR^(-2/3))*Unity(i).Shell.HeatTransfer.Jtotal*Unity(i).Shell.HeatTransfer.Phi;
    637 
     561        Unity(i).Shell.HeatTransfer.hshell              = HE.ShellFilmCoeff(Unity(i).Shell.HeatTransfer.Ji,Unity(i).Properties.Hot.Average.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Shell.HeatTransfer.PR,Unity(i).Shell.HeatTransfer.Jtotal,Unity(i).Shell.HeatTransfer.Phi);
     562
     563"Shell Pressure Drop Cross Flow"
     564        Unity(i).Shell.PressureDrop.PdCross     = HE.DeltaPcrossIncremental(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Ls,Unity(i).Baffles.Lso,Unity(i).Baffles.Lsi,Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Shell.HeatTransfer.Phi,Unity(i).Properties.Hot.Average.rho);
    638565
    639566"Shell Pressure Baffle Window"
    640         Unity(i).Shell.PressureDrop.Pdwindow            =       HE.DeltaPwindowIncremental(Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Properties.Hot.Average.rho,Unity(i).Properties.Hot.Average.Mu,Unity(i).Baffles.Ls);
    641 
    642 "Hot Wall Temperature"
    643         Unity(i).Properties.Hot.Wall.Twall  = (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
    644 
    645 "Cold Wall Temperature"
    646         Unity(i).Properties.Cold.Wall.Twall =   (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
     567        Unity(i).Shell.PressureDrop.Pdwindow    = HE.DeltaPwindowIncremental(Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Properties.Hot.Average.rho,Unity(i).Properties.Hot.Average.Mu,Unity(i).Baffles.Ls);
     568
     569"Shell Pressure End Zones"
     570        Unity(i).Shell.PressureDrop.PdEndZones  = HE.DeltaPendZonesIncremental(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Ls,Unity(i).Baffles.Lso,Unity(i).Baffles.Lsi,Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Shell.HeatTransfer.Phi,Unity(i).Properties.Hot.Average.rho);
     571
     572#       Tubes.HeatTransfer.Twall                                = HE.WallTemperature(Properties.Hot.Average.T,Properties.Cold.Average.T,Tubes.HeatTransfer.htube,Shell.HeatTransfer.hshell);
     573
     574"Wall Temperature for Cold Side"
     575        Unity(i).Properties.Cold.Wall.Twall     =       (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
     576       
     577"Wall Temperature for Hot Side"
     578        Unity(i).Properties.Hot.Wall.Twall      =       (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
    647579
    648580"Tube Side Velocity"
    649         Unity(i).Tubes.HeatTransfer.Vtube  = Unity(i).Properties.Cold.Inlet.Fw*Tpass/((Pi*Ditube*Ditube/4)*Unity(i).Properties.Cold.Average.rho*Ntt);
     581        Unity(i).Tubes.HeatTransfer.Vtube               =       HE.TubeVelocity(Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Properties.Cold.Average.rho);
    650582
    651583"Tube Side Reynolds Number"
    652         Unity(i).Tubes.HeatTransfer.Re          =       (Unity(i).Properties.Cold.Average.rho*Unity(i).Tubes.HeatTransfer.Vtube*Ditube)/Unity(i).Properties.Cold.Average.Mu;
     584        Unity(i).Tubes.HeatTransfer.Re                  =       HE.TubeReynoldsNumber(Unity(i).Properties.Cold.Average.rho,Unity(i).Tubes.HeatTransfer.Vtube,Unity(i).Properties.Cold.Average.Mu);
    653585       
    654586"Tube Side Prandtl Number"
    655         Unity(i).Tubes.HeatTransfer.PR          = ((Unity(i).Properties.Cold.Average.Cp/Unity(i).Properties.Cold.Average.Mw)*Unity(i).Properties.Cold.Average.Mu)/Unity(i).Properties.Cold.Average.K;
     587        Unity(i).Tubes.HeatTransfer.PR                  =       HE.PrandtlNumber(Unity(i).Properties.Cold.Average.K,Unity(i).Properties.Cold.Average.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Average.Mu);
    656588
    657589"Tube Side Prandtl Number at Wall"
    658         Unity(i).Tubes.HeatTransfer.PRw         =       ((Unity(i).Properties.Cold.Wall.Cp/Unity(i).Properties.Cold.Average.Mw)*Unity(i).Properties.Cold.Wall.Mu)/Unity(i).Properties.Cold.Wall.K;
     590        Unity(i).Tubes.HeatTransfer.PRw                 =       HE.PrandtlNumber(Unity(i).Properties.Cold.Wall.K,Unity(i).Properties.Cold.Wall.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Wall.Mu);
    659591
    660592"Tube Side Film Coefficient"
    661         Unity(i).Tubes.HeatTransfer.htube       =       HE.TubeFilmCoeffIncremental(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Tubes.HeatTransfer.PR,Unity(i).Properties.Cold.Average.K,Sumary.Lz(i))*Unity(i).Tubes.HeatTransfer.Phi;
     593        Unity(i).Tubes.HeatTransfer.htube               =       HE.TubeFilmCoeffIncremental(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Tubes.HeatTransfer.PR,Unity(i).Properties.Cold.Average.K,
     594        Unity(i).Tubes.HeatTransfer.Phi,Sumary.Lpos(i));
    662595       
    663596"Shell Side Prandtl Number"
    664         Unity(i).Shell.HeatTransfer.PR          =       ((Unity(i).Properties.Hot.Average.Cp/Unity(i).Properties.Hot.Average.Mw)*Unity(i).Properties.Hot.Average.Mu)/Unity(i).Properties.Hot.Average.K;
     597        Unity(i).Shell.HeatTransfer.PR                  =       HE.PrandtlNumber(Unity(i).Properties.Hot.Average.K,Unity(i).Properties.Hot.Average.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Average.Mu);   
    665598
    666599"Shell Side Prandtl Number at Wall"
    667         Unity(i).Shell.HeatTransfer.PRw         =       ((Unity(i).Properties.Hot.Wall.Cp/Unity(i).Properties.Hot.Average.Mw)*Unity(i).Properties.Hot.Wall.Mu)/Unity(i).Properties.Hot.Wall.K
     600        Unity(i).Shell.HeatTransfer.PRw                 =       HE.PrandtlNumber(Unity(i).Properties.Hot.Wall.K,Unity(i).Properties.Hot.Wall.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Wall.Mu);   
    668601
    669602"Tube Side Pressure Drop"
    670         Unity(i).Tubes.PressureDrop.PdTube      =       HE.DeltaPtubeIncremental(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Properties.Cold.Average.rho,Unity(i).Tubes.HeatTransfer.Vtube,
     603        Unity(i).Tubes.PressureDrop.PdTube              =       HE.DeltaPtubeIncremental(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Properties.Cold.Average.rho,Unity(i).Tubes.HeatTransfer.Vtube,
    671604        Unity(i).Tubes.HeatTransfer.Phi,Sumary.Lz(i));
    672605       
    673606"Shell Side Phi correction for viscosity"
    674         Unity(i).Shell.HeatTransfer.Phi         =       HE.PhiCorrection(Unity(i).Properties.Hot.Average.Mu,Unity(i).Properties.Hot.Wall.Mu);
     607        Unity(i).Shell.HeatTransfer.Phi                 =       HE.PhiCorrection(Unity(i).Properties.Hot.Average.Mu,Unity(i).Properties.Hot.Wall.Mu);
    675608       
    676609"Tube Side Phi correction for viscosity"
    677         Unity(i).Tubes.HeatTransfer.Phi         =       HE.PhiCorrection(Unity(i).Properties.Cold.Average.Mu,Unity(i).Properties.Cold.Wall.Mu);
     610        Unity(i).Tubes.HeatTransfer.Phi                 =       HE.PhiCorrection(Unity(i).Properties.Cold.Average.Mu,Unity(i).Properties.Cold.Wall.Mu);
    678611       
    679612        else
    680 
    681 "Pressure Drop Hot Stream"
    682         Unity(i).Outlet.Hot.P  = Unity(i).Inlet.Hot.P- Unity(i).Tubes.PressureDrop.Pdtotal;     
    683        
    684 "Pressure Drop Cold Stream"
    685         Unity(i).Outlet.Cold.P  = Unity(i).Inlet.Cold.P - Unity(i).Shell.PressureDrop.Pdtotal;
    686613       
    687614"Shell Side Reynolds Number"
    688         Unity(i).Shell.HeatTransfer.Re=(Dotube*Unity(i).Properties.Cold.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)/Unity(i).Properties.Cold.Average.Mu;
     615        Unity(i).Shell.HeatTransfer.Re                  =       HE.ShellReynoldsNumber(Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Properties.Cold.Average.Mu);
    689616
    690617"Shell Heat Transfer Coefficient"
    691         Unity(i).Shell.HeatTransfer.hshell      =Unity(i).Shell.HeatTransfer.Ji*(Unity(i).Properties.Cold.Average.Cp/Unity(i).Properties.Cold.Average.Mw)*
    692         (Unity(i).Properties.Cold.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)*(Unity(i).Shell.HeatTransfer.PR^(-2/3))*Unity(i).Shell.HeatTransfer.Jtotal*Unity(i).Shell.HeatTransfer.Phi;
    693 
     618        Unity(i).Shell.HeatTransfer.hshell       = HE.ShellFilmCoeff(Unity(i).Shell.HeatTransfer.Ji,Unity(i).Properties.Cold.Average.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Shell.HeatTransfer.PR,Unity(i).Shell.HeatTransfer.Jtotal,Unity(i).Shell.HeatTransfer.Phi);
     619
     620"Shell Pressure Drop Cross Flow"
     621        Unity(i).Shell.PressureDrop.PdCross      = HE.DeltaPcrossIncremental(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Ls,Unity(i).Baffles.Lso,Unity(i).Baffles.Lsi,Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Phi,Unity(i).Properties.Cold.Average.rho);
    694622
    695623"Shell Pressure Baffle Window"
    696         Unity(i).Shell.PressureDrop.Pdwindow    =       HE.DeltaPwindowIncremental(Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Properties.Cold.Average.rho,Unity(i).Properties.Cold.Average.Mu,Unity(i).Baffles.Ls);
    697 
    698 "Hot Wall Temperature"
    699         Unity(i).Properties.Hot.Wall.Twall      =       (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
    700 
    701 "Cold Wall Temperature"
    702         Unity(i).Properties.Cold.Wall.Twall     =       (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
     624        Unity(i).Shell.PressureDrop.Pdwindow     = HE.DeltaPwindowIncremental(Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Properties.Cold.Average.rho,Unity(i).Properties.Cold.Average.Mu,Unity(i).Baffles.Ls);
     625
     626"Shell Pressure End Zones"
     627        Unity(i).Shell.PressureDrop.PdEndZones  = HE.DeltaPendZonesIncremental(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Ls,Unity(i).Baffles.Lso,Unity(i).Baffles.Lsi,Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Phi,Unity(i).Properties.Cold.Average.rho);
     628
     629#       Tubes.HeatTransfer.Twall                                = HE.WallTemperature(Properties.Cold.Average.T,Properties.Hot.Average.T,Tubes.HeatTransfer.htube,Shell.HeatTransfer.hshell);
     630
     631"Wall Temperature for Cold Side"
     632        Unity(i).Properties.Cold.Wall.Twall     = (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
     633       
     634"Wall Temperature for Hot Side"
     635        Unity(i).Properties.Hot.Wall.Twall      =  (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
    703636
    704637"Tube Side Velocity"
    705         Unity(i).Tubes.HeatTransfer.Vtube               = Unity(i).Properties.Hot.Inlet.Fw*Tpass/((Pi*Ditube*Ditube/4)*Unity(i).Properties.Hot.Average.rho*Ntt);
     638        Unity(i).Tubes.HeatTransfer.Vtube       =  HE.TubeVelocity(Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Properties.Hot.Average.rho);
    706639
    707640"Tube Side Reynolds Number"
    708         Unity(i).Tubes.HeatTransfer.Re                  =       (Unity(i).Properties.Hot.Average.rho*Unity(i).Tubes.HeatTransfer.Vtube*Ditube)/Unity(i).Properties.Hot.Average.Mu;
     641        Unity(i).Tubes.HeatTransfer.Re          =  HE.TubeReynoldsNumber(Unity(i).Properties.Hot.Average.rho,Unity(i).Tubes.HeatTransfer.Vtube,Unity(i).Properties.Hot.Average.Mu);
    709642       
    710643"Tube Side Prandtl Number"
    711         Unity(i).Tubes.HeatTransfer.PR                  =       ((Unity(i).Properties.Hot.Average.Cp/Unity(i).Properties.Hot.Average.Mw)*Unity(i).Properties.Hot.Average.Mu)/Unity(i).Properties.Hot.Average.K;
    712        
     644        Unity(i).Tubes.HeatTransfer.PR          =  HE.PrandtlNumber(Unity(i).Properties.Hot.Average.K,Unity(i).Properties.Hot.Average.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Average.Mu);
     645
    713646"Tube Side Prandtl Number at Wall"
    714         Unity(i).Tubes.HeatTransfer.PRw                 =       ((Unity(i).Properties.Hot.Wall.Cp/Unity(i).Properties.Hot.Average.Mw)*Unity(i).Properties.Hot.Wall.Mu)/Unity(i).Properties.Hot.Wall.K;
    715        
     647        Unity(i).Tubes.HeatTransfer.PRw         =       HE.PrandtlNumber(Unity(i).Properties.Hot.Wall.K,Unity(i).Properties.Hot.Wall.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Wall.Mu);
     648
    716649"Tube Side Film Coefficient"
    717         Unity(i).Tubes.HeatTransfer.htube               =       HE.TubeFilmCoeffIncremental(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Tubes.HeatTransfer.PR,Unity(i).Properties.Hot.Average.K,Sumary.Lz(i))*Unity(i).Tubes.HeatTransfer.Phi;
     650        Unity(i).Tubes.HeatTransfer.htube               =       HE.TubeFilmCoeffIncremental(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Tubes.HeatTransfer.PR,Unity(i).Properties.Hot.Average.K,
     651        Unity(i).Tubes.HeatTransfer.Phi,Sumary.Lpos(i));
    718652       
    719653"Shell Side Prandtl Number"
    720         Unity(i).Shell.HeatTransfer.PR                  =       ((Unity(i).Properties.Cold.Average.Cp/Unity(i).Properties.Cold.Average.Mw)*Unity(i).Properties.Cold.Average.Mu)/Unity(i).Properties.Cold.Average.K;
     654        Unity(i).Shell.HeatTransfer.PR                  =       HE.PrandtlNumber(Unity(i).Properties.Cold.Average.K,Unity(i).Properties.Cold.Average.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Average.Mu);
    721655
    722656"Shell Side Prandtl Number at Wall"
    723         Unity(i).Shell.HeatTransfer.PRw                 =       ((Unity(i).Properties.Cold.Wall.Cp/Unity(i).Properties.Cold.Average.Mw)*Unity(i).Properties.Cold.Wall.Mu)/Unity(i).Properties.Cold.Wall.K;
     657        Unity(i).Shell.HeatTransfer.PRw                 =       HE.PrandtlNumber(Unity(i).Properties.Cold.Wall.K,Unity(i).Properties.Cold.Wall.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Wall.Mu);
     658
    724659
    725660"Tube Side Pressure Drop"
    726         Unity(i).Tubes.PressureDrop.PdTube              =       HE.DeltaPtubeIncremental(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Properties.Hot.Average.rho,Unity(i).Tubes.HeatTransfer.Vtube,
     661        Unity(i).Tubes.PressureDrop.PdTube              =       HE.DeltaPtubeIncremental(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Properties.Hot.Average.rho,Unity(i).Tubes.HeatTransfer.Vtube,
    727662        Unity(i).Tubes.HeatTransfer.Phi,Sumary.Lz(i));
    728663
     
    754689       
    755690
    756 "Js Factor"     
    757         Unity(i).Shell.HeatTransfer.Js                  =       1;
    758        
    759 "Ji Factor"
    760         Unity(i).Shell.HeatTransfer.Ji                  =       HE.JiFactor(Unity(i).Shell.HeatTransfer.Re);
    761 
    762 "Jc Factor"
    763         Unity(i).Shell.HeatTransfer.Jc                  =       HE.JcFactor();
    764        
    765 "Jl Factor"
    766         Unity(i).Shell.HeatTransfer.Jl                  =       HE.JlFactor(Unity(i).Shell.HeatTransfer.Sm);
    767 
    768 "Jb Factor"
    769         Unity(i).Shell.HeatTransfer.Jb                  =       HE.JbFactor(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Ls,Unity(i).Shell.HeatTransfer.Sm);
    770 
    771 "Jr Factor"     
    772         Unity(i).Shell.HeatTransfer.Jr                  =       HE.JrFactor(Unity(i).Shell.HeatTransfer.Re);
    773        
    774 "Total J Factor"
    775         Unity(i).Shell.HeatTransfer.Jtotal              =       Unity(i).Shell.HeatTransfer.Jc*Unity(i).Shell.HeatTransfer.Jl*Unity(i).Shell.HeatTransfer.Jb*Unity(i).Shell.HeatTransfer.Jr*Unity(i).Shell.HeatTransfer.Js;
    776 end
    777 
    778 
    779 "Velocity Tube Side Inlet Nozzle"
    780         Unity(Nb+1).Tubes.PressureDrop.Vnozzle_in       = 0;
    781 
    782 "Velocity Tube Side Outlet Nozzle"
    783         Unity(1).Tubes.PressureDrop.Vnozzle_out = 0;
    784        
    785 "Tube Pressure Drop Inlet Nozzle"
    786         Unity(Nb+1).Tubes.PressureDrop.Pdnozzle_in      = 0;
    787 
    788 "Tube Pressure Drop Outlet Nozzle"
    789         Unity(1).Tubes.PressureDrop.Pdnozzle_out        = 0;
    790 
    791 "Velocity Shell Side Inlet Nozzle"
    792         Unity(Nb+1).Shell.PressureDrop.Vnozzle_in       = 0;
    793 
    794 "Velocity Shell Side Outlet Nozzle"
    795         Unity(1).Shell.PressureDrop.Vnozzle_out = 0;
    796        
    797 "Shell Pressure Drop Inlet Nozzle"
    798         Unity(Nb+1).Shell.PressureDrop.Pdnozzle_in      = 0;
    799        
    800 "Shell Pressure Drop Outlet Nozzle"
    801         Unity(1).Shell.PressureDrop.Pdnozzle_out        = 0;
    802 
    803 "Shell Cross Flow Pressure Drop"
    804         Unity(1).Shell.PressureDrop.PdCross             = 0;
    805        
    806 "Shell Cross Flow Pressure Drop"
    807         Unity(Nb+1).Shell.PressureDrop.PdCross          = 0;
    808        
    809 "Shell Side Outlet Nozzle rho-V^2"
    810         Unity(1).Shell.PressureDrop.RVsquare_out = 0;
    811        
    812 "Shell Side inlet Nozzle rho-V^2"
    813         Unity(Nb+1).Shell.PressureDrop.RVsquare_in = 0;
     691end
    814692
    815693SET
    816 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    817 #  Set Parameters for heatex Calculation
    818 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     694#=====================================================================
     695#  Set Parameters for External Object Calculation - HE
     696#=====================================================================
    819697        Sumary.Zones        = Nb+1;
    820698        Pi                              = 3.14159265;
     
    841719end
    842720
    843 Model E_Shell_LMTD_Disc         
    844 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    845 #       Shell and Tubes Heat Exchanger with 1 shell pass - LMTD Method
    846 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     721Model E_Shell_NTU_Disc           
     722#============================================================================
     723#       Shell and Tubes Heat Exchanger In Series with 1 shell pass - LMTD Method
     724#============================================================================
    847725PARAMETERS
    848726
    849         HE      as CalcObject   (Brief="STHE Calculations",File="heatex");
    850 ext PP  as CalcObject   (Brief="External Physical Properties");
     727ext     HE              as CalcObject   (Brief="STHE Calculations",File="heatex.dll");
     728ext PP          as CalcObject;
    851729side    as Integer              (Brief="Fluid Alocation",Lower=0,Upper=1);
    852 Pi              as constant     (Brief="Pi Number",Default=3.14159265);
    853 
    854 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     730Pi                      as constant     (Brief="Pi Number",Default=3.14159265);
     731
     732#=====================================================================
    855733#       Shell Geometrical Parameters
    856 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     734#=====================================================================
    857735Tpass                   as Integer              (Brief="Number of Tube Passes",Lower=1);
    858736Nss                             as Integer              (Brief="Number of Sealing Strips pairs",Lower=1);
     
    863741Honozzle_Shell  as length               (Brief="Height Under Shell Outlet Nozzle",Lower=10e-6);
    864742Lcf                     as length               (Brief="Bundle-to-Shell Clearance",Lower=10e-8);
    865 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     743#=====================================================================
    866744#       Tubes Geometrical Parameters
    867 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     745#=====================================================================
    868746Ntt                             as Integer              (Brief="Total Number of Tubes in Shell",Default=100,Lower=1);
    869747Pattern         as Integer              (Brief="Tube Layout Characteristic Angle",Lower=30);
     
    875753Donozzle_Tube   as length               (Brief="Tube Outlet Nozzle Diameter",Lower=10e-6);
    876754Dinozzle_Tube   as length               (Brief="Tube Inlett Nozzle Diameter",Lower=10e-6);
    877 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     755#=====================================================================
    878756#       Baffles Geometrical Parameters
    879 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     757#=====================================================================
    880758Bc                      as Integer              (Brief="Baffle Cut",Default=25,Lower=25);
    881759Nb              as Integer              (Brief="Number of Baffles",Default=4);
    882760Lcd                     as length               (Brief="Baffle-to-Shell Clearance",Lower=10e-8);
    883761Ltd                             as length               (Brief="Tube-to-Bafflehole Clearance",Lower=10e-8);
    884 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     762#=====================================================================
    885763VARIABLES
    886764
    887 Unity(Nb+1)     as Heatex_Discretized_LMTD;
     765PdropNozzles    as Pdrop_Nozzles_Main;
     766Unity(Nb+1)     as Heatex_Discretized_NTU;
    888767Sumary          as Profiles;
    889768
    890769CONNECTIONS
    891770
    892 Unity([1:Nb]).Outlet.Hot        to Unity([2:Nb+1]).Inlet.Hot;
     771Unity([1:Nb]).Outlet.Hot  to Unity([2:Nb+1]).Inlet.Hot;
    893772Unity([2:Nb+1]).Outlet.Cold to Unity([1:Nb]).Inlet.Cold;
    894773
    895774EQUATIONS
    896775
    897 "Hot Temperatures"
    898         Sumary.Thot     = Unity.Outlet.Hot.T;
    899        
    900 "Cold Temperatures"
    901         Sumary.Tcold    = Unity.Outlet.Cold.T ;
    902 
    903 "Hot Pressures"
    904         Sumary.Phot     = Unity.Outlet.Hot.P ;
    905        
    906 "Cold Pressures"
    907         Sumary.Pcold    = Unity.Outlet.Cold.P ;
    908 
    909 "Average Shell Side Film Coefficient"
    910         Sumary.hshellaverage            = sum(Unity.Shell.HeatTransfer.hshell)/Sumary.Zones;
    911 
    912 "Average Tube Side Film Coefficient"
    913         Sumary.htubeaverage             = sum(Unity.Tubes.HeatTransfer.htube)/Sumary.Zones;
    914 
    915 "Average Overall Heat Transfer Coefficient"
    916         Sumary.Uaverage                 = sum(Unity.Details.U)/Sumary.Zones;
    917 
    918 "Area Total"
    919         Sumary.Area                             = sum(Unity.Details.A);
    920 
    921 "Duty Total"
    922         Sumary.Q                                = sum(Unity.Details.Q);
    923 
    924 "Length Inlet zone"
    925         Sumary.Lz(1)                            = Unity(1).Baffles.Lsi;
    926 
    927 "Length Outlet zone"
    928         Sumary.Lz(Nb+1)                         = Unity(1).Baffles.Lso;
    929 
    930 "Total Shell Side Pressure Drop"
    931         Sumary.PdropShell                       = sum(Unity.Shell.PressureDrop.Pdtotal);
    932 
    933 "Total Tube Side Pressure Drop"
    934         Sumary.PdropTubes                       = sum(Unity.Tubes.PressureDrop.Pdtotal);
    935 
    936 "Total Tube Side Nozzles Pressure Drop"
    937         Sumary.PdropTubesNozzle         = sum(Unity.Tubes.PressureDrop.Pdnozzle_in + Unity.Tubes.PressureDrop.Pdnozzle_out);
    938 
    939 "Total Shell Side Nozzles Pressure Drop"
    940         Sumary.PdropShellNozzle         = sum(Unity.Shell.PressureDrop.Pdnozzle_in + Unity.Shell.PressureDrop.Pdnozzle_out);
    941 
    942 "Total Shell Side Window Pressure Drop"
    943         Sumary.PdropWin                         = sum(Unity.Shell.PressureDrop.Pdwindow);
    944 
    945 "Total Shell Side Cross Flow Pressure Drop"
    946         Sumary.PdropCross                       = sum(Unity.Shell.PressureDrop.PdCross);
    947 
    948 "Total Shell Side Ends Pressure Drop"
    949         Sumary.PdropEnds                        = sum(Unity.Shell.PressureDrop.PdEndZones);
     776Sumary.Thot     = Unity.Outlet.Hot.T ;
     777Sumary.Tcold                = Unity.Outlet.Cold.T ;
     778Sumary.Phot                 = Unity.Outlet.Hot.P ;
     779Sumary.Pcold                = Unity.Outlet.Cold.P ;
     780
     781Sumary.hshellaverage            = sum(Unity.Shell.HeatTransfer.hshell)/Sumary.Zones;
     782Sumary.htubeaverage             = sum(Unity.Tubes.HeatTransfer.htube)/Sumary.Zones;
     783Sumary.Uaverage                 = sum(Unity.Details.U)/Sumary.Zones;
     784Sumary.Area             = sum(Unity.Details.A);
     785Sumary.Q                = sum(Unity.Details.Q);
     786Sumary.Lz(1)                    = Unity(1).Baffles.Lsi;
     787Sumary.Lz(Nb+1)                 = Unity(1).Baffles.Lso;
     788Sumary.PdropShellTotal = sum(Unity.Shell.PressureDrop.Pdtotal)+PdropNozzles.Shell.Pdnozzle_in + PdropNozzles.Shell.Pdnozzle_out;
     789Sumary.PdropTubesTotal = sum(Unity.Tubes.PressureDrop.Pdtotal)+PdropNozzles.Tubes.Pdnozzle_in + PdropNozzles.Tubes.Pdnozzle_out;
     790Sumary.PdropWinTotal    = sum(Unity.Shell.PressureDrop.Pdwindow);
     791Sumary.PdropCrossTotal = sum(Unity.Shell.PressureDrop.PdCross);
     792Sumary.PdropEndsTotal   = sum(Unity.Shell.PressureDrop.PdEndZones);
    950793
    951794"Shell Side Cross Flow Area"
     
    955798        Unity(Nb+1).Shell.HeatTransfer.Sm = HE.CrossFlowArea(Unity(Nb+1).Baffles.Lso);
    956799
    957 "LMTD Correction Factor"
    958         Unity.Fc = HE.EshellCorrectionFactor(Unity(1).Inlet.Hot.T,Unity(Nb+1).Outlet.Hot.T,Unity(Nb+1).Inlet.Cold.T,Unity(1).Outlet.Cold.T);
    959800
    960801if side equal 1
    961802       
    962803        then
    963 
    964 "Shell Side inlet Nozzle rho-V^2"
    965         Unity(1).Shell.PressureDrop.RVsquare_in = Unity(1).Properties.Hot.Inlet.rho*(Unity(1).Shell.PressureDrop.Vnozzle_in)^2;
    966 
    967 "Shell Side Outlet Nozzle rho-V^2"
    968         Unity(Nb+1).Shell.PressureDrop.RVsquare_out = Unity(Nb+1).Properties.Hot.Outlet.rho*(Unity(Nb+1).Shell.PressureDrop.Vnozzle_out)^2;
    969 
    970 "Shell Pressure End Zones"
    971         Unity(1).Shell.PressureDrop.PdEndZones          =       HE.DeltaPendZonesIncremental(Unity(1).Shell.HeatTransfer.Re,Unity(1).Baffles.Ls,Unity(1).Baffles.Lso,
    972         Unity(1).Baffles.Lsi,Unity(1).Properties.Hot.Inlet.Fw,Unity(1).Shell.HeatTransfer.Phi,Unity(1).Properties.Hot.Average.rho);
    973 
    974 "Shell Pressure End Zones"
    975         Unity(Nb+1).Shell.PressureDrop.PdEndZones       =       HE.DeltaPendZonesIncremental(Unity(Nb+1).Shell.HeatTransfer.Re,Unity(Nb+1).Baffles.Ls,Unity(Nb+1).Baffles.Lso,
    976         Unity(Nb+1).Baffles.Lsi,Unity(Nb+1).Properties.Hot.Inlet.Fw,Unity(Nb+1).Shell.HeatTransfer.Phi,Unity(Nb+1).Properties.Hot.Average.rho);
    977 
     804       
    978805"Pressure Drop Tube Side Inlet Nozzle"
    979         Unity(1).Tubes.PressureDrop.Pdnozzle_in = HE.DeltaPtubeNozzlein(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
     806        PdropNozzles.Tubes.Pdnozzle_in  = HE.DeltaPtubeNozzlein(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
    980807
    981808"Velocity Tube Side Inlet Nozzle"
    982         Unity(1).Tubes.PressureDrop.Vnozzle_in  = HE.TubeVelocityNozzlein(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
     809        PdropNozzles.Tubes.Vnozzle_in   = HE.TubeVelocityNozzlein(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
    983810
    984811"Pressure Drop Tube Side Outlet Nozzle"
    985         Unity(Nb+1).Tubes.PressureDrop.Pdnozzle_out     = HE.DeltaPtubeNozzleout(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
     812        PdropNozzles.Tubes.Pdnozzle_out = HE.DeltaPtubeNozzleout(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
    986813
    987814"Velocity Tube Side Outlet Nozzle"
    988         Unity(Nb+1).Tubes.PressureDrop.Vnozzle_out      = HE.TubeVelocityNozzleout(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
     815        PdropNozzles.Tubes.Vnozzle_out  = HE.TubeVelocityNozzleout(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
    989816
    990817"Shell Pressure Drop Inlet Nozzle"
    991         Unity(1).Shell.PressureDrop.Pdnozzle_in = HE.DeltaPshellNozzleIn(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
     818        PdropNozzles.Shell.Pdnozzle_in  = HE.DeltaPshellNozzleIn(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
    992819
    993820"Velocity Shell Side Inlet Nozzle"
    994         Unity(1).Shell.PressureDrop.Vnozzle_in  = HE.ShellVelocityNozzleIn(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
     821        PdropNozzles.Shell.Vnozzle_in   = HE.ShellVelocityNozzleIn(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
    995822
    996823"Shell Pressure Drop Outlet Nozzle"
    997         Unity(Nb+1).Shell.PressureDrop.Pdnozzle_out     =HE.DeltaPshellNozzleOut(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);
     824        PdropNozzles.Shell.Pdnozzle_out =HE.DeltaPshellNozzleOut(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);
    998825
    999826"Velocity Shell Side Outlet Nozzle"
    1000         Unity(Nb+1).Shell.PressureDrop.Vnozzle_out      =HE.ShellVelocityNozzleOut(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);
    1001        
     827        PdropNozzles.Shell.Vnozzle_out  =HE.ShellVelocityNozzleOut(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);
     828       
     829"Pressure Drop Hot Stream"
     830        Unity(1).Outlet.Hot.P  = Unity(1).Inlet.Hot.P - Unity(1).Shell.PressureDrop.Pdtotal - PdropNozzles.Shell.Pdnozzle_in;   
     831        Unity(Nb+1).Outlet.Hot.P  = Unity(Nb+1).Inlet.Hot.P - Unity(Nb+1).Shell.PressureDrop.Pdtotal - PdropNozzles.Shell.Pdnozzle_out;
     832
     833"Pressure Drop Cold Stream"
     834        Unity(1).Outlet.Cold.P  = Unity(1).Inlet.Cold.P - Unity(1).Tubes.PressureDrop.Pdtotal - PdropNozzles.Tubes.Pdnozzle_in;
     835        Unity(Nb+1).Outlet.Cold.P  = Unity(Nb+1).Inlet.Cold.P - Unity(Nb+1).Tubes.PressureDrop.Pdtotal - PdropNozzles.Tubes.Pdnozzle_out;
     836
    1002837
    1003838        else
    1004839
    1005 "Shell Side inlet Nozzle rho-V^2"
    1006         Unity(1).Shell.PressureDrop.RVsquare_in = Unity(1).Properties.Cold.Inlet.rho*(Unity(1).Shell.PressureDrop.Vnozzle_in)^2;
    1007 
    1008 "Shell Side Outlet Nozzle rho-V^2"
    1009         Unity(Nb+1).Shell.PressureDrop.RVsquare_out = Unity(Nb+1).Properties.Cold.Outlet.rho*(Unity(Nb+1).Shell.PressureDrop.Vnozzle_out)^2;
    1010 
    1011 "Shell Pressure End Zones"
    1012         Unity(1).Shell.PressureDrop.PdEndZones          =       HE.DeltaPendZonesIncremental(Unity(1).Shell.HeatTransfer.Re,Unity(1).Baffles.Ls,Unity(1).Baffles.Lso,
    1013         Unity(1).Baffles.Lsi,Unity(1).Properties.Cold.Inlet.Fw,Unity(1).Shell.HeatTransfer.Phi,Unity(1).Properties.Cold.Average.rho);
    1014 
    1015 "Shell Pressure End Zones"
    1016         Unity(Nb+1).Shell.PressureDrop.PdEndZones       =       HE.DeltaPendZonesIncremental(Unity(Nb+1).Shell.HeatTransfer.Re,Unity(Nb+1).Baffles.Ls,Unity(Nb+1).Baffles.Lso,
    1017         Unity(Nb+1).Baffles.Lsi,Unity(Nb+1).Properties.Cold.Inlet.Fw,Unity(Nb+1).Shell.HeatTransfer.Phi,Unity(Nb+1).Properties.Cold.Average.rho);
    1018 
    1019 
    1020840"Pressure Drop Tube Side Inlet Nozzle"
    1021         Unity(1).Tubes.PressureDrop.Pdnozzle_in = HE.DeltaPtubeNozzlein(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
     841        PdropNozzles.Tubes.Pdnozzle_in  = HE.DeltaPtubeNozzlein(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
    1022842
    1023843"Velocity Tube Side Inlet Nozzle"
    1024         Unity(1).Tubes.PressureDrop.Vnozzle_in  = HE.TubeVelocityNozzlein(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
     844        PdropNozzles.Tubes.Vnozzle_in   = HE.TubeVelocityNozzlein(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
    1025845
    1026846"Pressure Drop Tube Side Outlet Nozzle"
    1027         Unity(Nb+1).Tubes.PressureDrop.Pdnozzle_out     = HE.DeltaPtubeNozzleout(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);   
     847        PdropNozzles.Tubes.Pdnozzle_out = HE.DeltaPtubeNozzleout(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);   
    1028848
    1029849"Velocity Tube Side Outlet Nozzle"
    1030         Unity(Nb+1).Tubes.PressureDrop.Vnozzle_out      = HE.TubeVelocityNozzleout(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw); 
     850        PdropNozzles.Tubes.Vnozzle_out  = HE.TubeVelocityNozzleout(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw); 
    1031851
    1032852"Shell Pressure Drop Inlet Nozzle"
    1033         Unity(1).Shell.PressureDrop.Pdnozzle_in = HE.DeltaPshellNozzleIn(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
     853        PdropNozzles.Shell.Pdnozzle_in  = HE.DeltaPshellNozzleIn(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
    1034854
    1035855"Velocity Shell Side Inlet Nozzle"
    1036         Unity(1).Shell.PressureDrop.Vnozzle_in  = HE.ShellVelocityNozzleIn(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
     856        PdropNozzles.Shell.Vnozzle_in   = HE.ShellVelocityNozzleIn(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
    1037857
    1038858"Shell Pressure Drop Outlet Nozzle"
    1039         Unity(Nb+1).Shell.PressureDrop.Pdnozzle_out = HE.DeltaPshellNozzleOut(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
     859        PdropNozzles.Shell.Pdnozzle_out = HE.DeltaPshellNozzleOut(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
    1040860
    1041861"Velocity Shell Side Outlet Nozzle"
    1042         Unity(Nb+1).Shell.PressureDrop.Vnozzle_out  = HE.ShellVelocityNozzleOut(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
     862        PdropNozzles.Shell.Vnozzle_out  = HE.ShellVelocityNozzleOut(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
     863
     864"Pressure Drop Hot Stream"
     865        Unity(1).Outlet.Hot.P  = Unity(1).Inlet.Hot.P- Unity(1).Tubes.PressureDrop.Pdtotal - PdropNozzles.Tubes.Pdnozzle_in;   
     866        Unity(Nb+1).Outlet.Hot.P  = Unity(Nb+1).Inlet.Hot.P- Unity(Nb+1).Tubes.PressureDrop.Pdtotal - PdropNozzles.Tubes.Pdnozzle_out; 
     867       
     868"Pressure Drop Cold Stream"
     869        Unity(1).Outlet.Cold.P  = Unity(1).Inlet.Cold.P - Unity(1).Shell.PressureDrop.Pdtotal- PdropNozzles.Shell.Pdnozzle_in;
     870        Unity(Nb+1).Outlet.Cold.P  = Unity(Nb+1).Inlet.Cold.P - Unity(Nb+1).Shell.PressureDrop.Pdtotal- PdropNozzles.Shell.Pdnozzle_out;
    1043871
    1044872
     
    1048876for i in [2:Nb]
    1049877
    1050 "Pressure Drop Tube Side Inlet Nozzle"
    1051         Unity(i).Tubes.PressureDrop.Pdnozzle_in = 0;
    1052 
    1053 "Velocity Tube Side Inlet Nozzle"
    1054         Unity(i).Tubes.PressureDrop.Vnozzle_in  = 0;
    1055 
    1056 "Pressure Drop Tube Side Outlet Nozzle"
    1057         Unity(i).Tubes.PressureDrop.Pdnozzle_out        = 0;   
    1058 
    1059 "Velocity Tube Side Outlet Nozzle"
    1060         Unity(i).Tubes.PressureDrop.Vnozzle_out = 0;   
    1061 
    1062 "Shell Pressure Drop Inlet Nozzle"
    1063         Unity(i).Shell.PressureDrop.Pdnozzle_in = 0;
    1064 
    1065 "Velocity Shell Side Inlet Nozzle"
    1066         Unity(i).Shell.PressureDrop.Vnozzle_in  = 0;
    1067 
    1068 "Shell Pressure Drop Outlet Nozzle"
    1069         Unity(i).Shell.PressureDrop.Pdnozzle_out = 0;
    1070 
    1071 "Velocity Shell Side Outlet Nozzle"
    1072         Unity(i).Shell.PressureDrop.Vnozzle_out  = 0;
    1073 
    1074 "Shell Pressure End Zones"
    1075         Unity(i).Shell.PressureDrop.PdEndZones          =       0;
    1076 
    1077 "Shell Side Outlet Nozzle rho-V^2"
    1078         Unity(i).Shell.PressureDrop.RVsquare_out = 0;
    1079        
    1080 "Shell Side inlet Nozzle rho-V^2"
    1081         Unity(i).Shell.PressureDrop.RVsquare_in = 0;
    1082        
     878
    1083879if side equal 1
    1084880       
    1085881        then
    1086882       
     883"Pressure Drop Hot Stream"
     884        Unity(i).Outlet.Hot.P  = Unity(i).Inlet.Hot.P - Unity(i).Shell.PressureDrop.Pdtotal;   
     885
     886"Pressure Drop Cold Stream"
     887        Unity(i).Outlet.Cold.P  = Unity(i).Inlet.Cold.P - Unity(i).Tubes.PressureDrop.Pdtotal;
     888
     889
     890        else
     891
     892"Pressure Drop Hot Stream"
     893        Unity(i).Outlet.Hot.P  = Unity(i).Inlet.Hot.P- Unity(i).Tubes.PressureDrop.Pdtotal;     
     894       
     895"Pressure Drop Cold Stream"
     896        Unity(i).Outlet.Cold.P  = Unity(i).Inlet.Cold.P - Unity(i).Shell.PressureDrop.Pdtotal;
     897
     898
     899end
     900
     901Sumary.Lz(i) = Unity(1).Baffles.Ls;
     902
     903"Shell Side Cross Flow Area"
     904        Unity(i).Shell.HeatTransfer.Sm = HE.CrossFlowArea(Unity(i).Baffles.Ls);
     905       
     906end
     907
     908
     909for i in [1:Nb+1]
     910       
     911if side equal 1
     912       
     913        then
     914
     915"Shell Side Reynolds Number"
     916        Unity(i).Shell.HeatTransfer.Re                          =       HE.ShellReynoldsNumber(Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Properties.Hot.Average.Mu);
     917
     918"Shell Heat Transfer Coefficient"
     919        Unity(i).Shell.HeatTransfer.hshell                      =       HE.ShellFilmCoeff(Unity(i).Shell.HeatTransfer.Ji,Unity(i).Properties.Hot.Average.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Shell.HeatTransfer.PR,Unity(i).Shell.HeatTransfer.Jtotal,Unity(i).Shell.HeatTransfer.Phi);
     920
    1087921"Shell Pressure Drop Cross Flow"
    1088922        Unity(i).Shell.PressureDrop.PdCross             =       HE.DeltaPcrossIncremental(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Ls,Unity(i).Baffles.Lso,Unity(i).Baffles.Lsi,Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Shell.HeatTransfer.Phi,Unity(i).Properties.Hot.Average.rho);
    1089923
    1090 
    1091         else
    1092 
    1093 "Shell Pressure Drop Cross Flow"
    1094         Unity(i).Shell.PressureDrop.PdCross     =       HE.DeltaPcrossIncremental(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Ls,Unity(i).Baffles.Lso,Unity(i).Baffles.Lsi,Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Phi,Unity(i).Properties.Cold.Average.rho);
    1095 
    1096 
    1097 end
    1098 
    1099 "Zone Length"
    1100         Sumary.Lz(i) = Unity(1).Baffles.Ls;
    1101 
    1102 "Shell Side Cross Flow Area"
    1103         Unity(i).Shell.HeatTransfer.Sm = HE.CrossFlowArea(Unity(i).Baffles.Ls);
    1104        
    1105 end
    1106 
    1107 
    1108 for i in [1:Nb+1]
    1109 
    1110 
    1111 if side equal 1
    1112        
    1113         then
    1114 "Pressure Drop Hot Stream"
    1115         Unity(i).Outlet.Hot.P  = Unity(i).Inlet.Hot.P - Unity(i).Shell.PressureDrop.Pdtotal;   
    1116 
    1117 "Pressure Drop Cold Stream"
    1118         Unity(i).Outlet.Cold.P  = Unity(i).Inlet.Cold.P - Unity(i).Tubes.PressureDrop.Pdtotal;
    1119        
    1120 "Shell Side Reynolds Number"
    1121         Unity(i).Shell.HeatTransfer.Re=(Dotube*Unity(i).Properties.Hot.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)/Unity(i).Properties.Hot.Average.Mu;
    1122 
    1123 "Shell Heat Transfer Coefficient"
    1124         Unity(i).Shell.HeatTransfer.hshell =Unity(i).Shell.HeatTransfer.Ji*(Unity(i).Properties.Hot.Average.Cp/Unity(i).Properties.Hot.Average.Mw)*(Unity(i).Properties.Hot.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)*(Unity(i).Shell.HeatTransfer.PR^(-2/3))*Unity(i).Shell.HeatTransfer.Jtotal*Unity(i).Shell.HeatTransfer.Phi;
    1125 
    1126924"Shell Pressure Baffle Window"
    1127925        Unity(i).Shell.PressureDrop.Pdwindow            =       HE.DeltaPwindowIncremental(Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Properties.Hot.Average.rho,Unity(i).Properties.Hot.Average.Mu,Unity(i).Baffles.Ls);
    1128926
    1129 "Hot Wall Temperature"
     927"Shell Pressure End Zones"
     928        Unity(i).Shell.PressureDrop.PdEndZones          =       HE.DeltaPendZonesIncremental(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Ls,Unity(i).Baffles.Lso,Unity(i).Baffles.Lsi,Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Shell.HeatTransfer.Phi,Unity(i).Properties.Hot.Average.rho);
     929
     930"Wall Temperature"
     931#       Tubes.HeatTransfer.Twall  = HE.WallTemperature(Properties.Hot.Average.T,Properties.Cold.Average.T,Tubes.HeatTransfer.htube,Shell.HeatTransfer.hshell);
     932       
    1130933        Unity(i).Properties.Hot.Wall.Twall  = (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
    1131934       
    1132 "Cold Wall Temperature"
    1133935        Unity(i).Properties.Cold.Wall.Twall =   (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
    1134936
    1135937"Tube Side Velocity"
    1136         Unity(i).Tubes.HeatTransfer.Vtube       =       Unity(i).Properties.Cold.Inlet.Fw*Tpass/((Pi*Ditube*Ditube/4)*Unity(i).Properties.Cold.Average.rho*Ntt);
     938        Unity(i).Tubes.HeatTransfer.Vtube       =       HE.TubeVelocity(Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Properties.Cold.Average.rho);
    1137939
    1138940"Tube Side Reynolds Number"
    1139         Unity(i).Tubes.HeatTransfer.Re          =       (Unity(i).Properties.Cold.Average.rho*Unity(i).Tubes.HeatTransfer.Vtube*Ditube)/Unity(i).Properties.Cold.Average.Mu;
     941        Unity(i).Tubes.HeatTransfer.Re          =       HE.TubeReynoldsNumber(Unity(i).Properties.Cold.Average.rho,Unity(i).Tubes.HeatTransfer.Vtube,Unity(i).Properties.Cold.Average.Mu);
    1140942       
    1141943"Tube Side Prandtl Number"
    1142         Unity(i).Tubes.HeatTransfer.PR          =       ((Unity(i).Properties.Cold.Average.Cp/Unity(i).Properties.Cold.Average.Mw)*Unity(i).Properties.Cold.Average.Mu)/Unity(i).Properties.Cold.Average.K;
     944        Unity(i).Tubes.HeatTransfer.PR          =       HE.PrandtlNumber(Unity(i).Properties.Cold.Average.K,Unity(i).Properties.Cold.Average.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Average.Mu);
    1143945
    1144946"Tube Side Prandtl Number at Wall"
    1145         Unity(i).Tubes.HeatTransfer.PRw         =       ((Unity(i).Properties.Cold.Wall.Cp/Unity(i).Properties.Cold.Average.Mw)*Unity(i).Properties.Cold.Wall.Mu)/Unity(i).Properties.Cold.Wall.K;
     947        Unity(i).Tubes.HeatTransfer.PRw         =       HE.PrandtlNumber(Unity(i).Properties.Cold.Wall.K,Unity(i).Properties.Cold.Wall.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Wall.Mu);
    1146948
    1147949"Tube Side Film Coefficient"
    1148         Unity(i).Tubes.HeatTransfer.htube       =       HE.TubeFilmCoeffIncremental(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Tubes.HeatTransfer.PR,Unity(i).Properties.Cold.Average.K,Sumary.Lz(i))*Unity(i).Tubes.HeatTransfer.Phi;
     950        Unity(i).Tubes.HeatTransfer.htube       =       HE.TubeFilmCoeffIncremental(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Tubes.HeatTransfer.PR,Unity(i).Properties.Cold.Average.K,
     951        Unity(i).Tubes.HeatTransfer.Phi,Sumary.Lpos(i));
    1149952       
    1150953"Shell Side Prandtl Number"
    1151         Unity(i).Shell.HeatTransfer.PR          =       ((Unity(i).Properties.Hot.Average.Cp/Unity(i).Properties.Hot.Average.Mw)*Unity(i).Properties.Hot.Average.Mu)/Unity(i).Properties.Hot.Average.K;
     954        Unity(i).Shell.HeatTransfer.PR          =       HE.PrandtlNumber(Unity(i).Properties.Hot.Average.K,Unity(i).Properties.Hot.Average.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Average.Mu);   
    1152955
    1153956"Shell Side Prandtl Number at Wall"
    1154         Unity(i).Shell.HeatTransfer.PRw         =       ((Unity(i).Properties.Hot.Wall.Cp/Unity(i).Properties.Hot.Average.Mw)*Unity(i).Properties.Hot.Wall.Mu)/Unity(i).Properties.Hot.Wall.K
     957        Unity(i).Shell.HeatTransfer.PRw         =       HE.PrandtlNumber(Unity(i).Properties.Hot.Wall.K,Unity(i).Properties.Hot.Wall.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Wall.Mu);   
    1155958
    1156959"Tube Side Pressure Drop"
     
    1166969        else
    1167970
    1168 "Pressure Drop Hot Stream"
    1169         Unity(i).Outlet.Hot.P  = Unity(i).Inlet.Hot.P- Unity(i).Tubes.PressureDrop.Pdtotal;     
    1170        
    1171 "Pressure Drop Cold Stream"
    1172         Unity(i).Outlet.Cold.P  = Unity(i).Inlet.Cold.P - Unity(i).Shell.PressureDrop.Pdtotal;
    1173        
    1174971"Shell Side Reynolds Number"
    1175         Unity(i).Shell.HeatTransfer.Re=(Dotube*Unity(i).Properties.Cold.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)/Unity(i).Properties.Cold.Average.Mu;
     972        Unity(i).Shell.HeatTransfer.Re                  =       HE.ShellReynoldsNumber(Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Properties.Cold.Average.Mu);
    1176973
    1177974"Shell Heat Transfer Coefficient"
    1178         Unity(i).Shell.HeatTransfer.hshell      =Unity(i).Shell.HeatTransfer.Ji*(Unity(i).Properties.Cold.Average.Cp/Unity(i).Properties.Cold.Average.Mw)*
    1179         (Unity(i).Properties.Cold.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)*(Unity(i).Shell.HeatTransfer.PR^(-2/3))*Unity(i).Shell.HeatTransfer.Jtotal*Unity(i).Shell.HeatTransfer.Phi;
    1180 
     975        Unity(i).Shell.HeatTransfer.hshell              =       HE.ShellFilmCoeff(Unity(i).Shell.HeatTransfer.Ji,Unity(i).Properties.Cold.Average.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Shell.HeatTransfer.PR,Unity(i).Shell.HeatTransfer.Jtotal,Unity(i).Shell.HeatTransfer.Phi);
     976
     977"Shell Pressure Drop Cross Flow"
     978        Unity(i).Shell.PressureDrop.PdCross     =       HE.DeltaPcrossIncremental(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Ls,Unity(i).Baffles.Lso,Unity(i).Baffles.Lsi,Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Phi,Unity(i).Properties.Cold.Average.rho);
    1181979
    1182980"Shell Pressure Baffle Window"
    1183981        Unity(i).Shell.PressureDrop.Pdwindow    =       HE.DeltaPwindowIncremental(Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Sm,Unity(i).Properties.Cold.Average.rho,Unity(i).Properties.Cold.Average.Mu,Unity(i).Baffles.Ls);
    1184982
    1185 
    1186 "Hot Wall Temperature"
     983"Shell Pressure End Zones"
     984        Unity(i).Shell.PressureDrop.PdEndZones  =       HE.DeltaPendZonesIncremental(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Ls,Unity(i).Baffles.Lso,Unity(i).Baffles.Lsi,Unity(i).Properties.Cold.Inlet.Fw,Unity(i).Shell.HeatTransfer.Phi,Unity(i).Properties.Cold.Average.rho);
     985
     986"Wall Temperature"
     987#       Tubes.HeatTransfer.Twall = HE.WallTemperature(Properties.Cold.Average.T,Properties.Hot.Average.T,Tubes.HeatTransfer.htube,Shell.HeatTransfer.hshell);
     988       
    1187989        Unity(i).Properties.Hot.Wall.Twall      =       (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
    1188990       
    1189 "Cold Wall Temperature"
    1190991        Unity(i).Properties.Cold.Wall.Twall     =       (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
    1191992
    1192993"Tube Side Velocity"
    1193         Unity(i).Tubes.HeatTransfer.Vtube               = Unity(i).Properties.Hot.Inlet.Fw*Tpass/((Pi*Ditube*Ditube/4)*Unity(i).Properties.Hot.Average.rho*Ntt);
     994        Unity(i).Tubes.HeatTransfer.Vtube               =       HE.TubeVelocity(Unity(i).Properties.Hot.Inlet.Fw,Unity(i).Properties.Hot.Average.rho);
    1194995
    1195996"Tube Side Reynolds Number"
    1196         Unity(i).Tubes.HeatTransfer.Re                  =       (Unity(i).Properties.Hot.Average.rho*Unity(i).Tubes.HeatTransfer.Vtube*Ditube)/Unity(i).Properties.Hot.Average.Mu;
     997        Unity(i).Tubes.HeatTransfer.Re                  =       HE.TubeReynoldsNumber(Unity(i).Properties.Hot.Average.rho,Unity(i).Tubes.HeatTransfer.Vtube,Unity(i).Properties.Hot.Average.Mu);
    1197998       
    1198999"Tube Side Prandtl Number"
    1199         Unity(i).Tubes.HeatTransfer.PR                  =((Unity(i).Properties.Hot.Average.Cp/Unity(i).Properties.Hot.Average.Mw)*Unity(i).Properties.Hot.Average.Mu)/Unity(i).Properties.Hot.Average.K;
     1000        Unity(i).Tubes.HeatTransfer.PR                  =       HE.PrandtlNumber(Unity(i).Properties.Hot.Average.K,Unity(i).Properties.Hot.Average.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Average.Mu);
    12001001       
    12011002"Tube Side Prandtl Number at Wall"
    1202         Unity(i).Tubes.HeatTransfer.PRw                 =       ((Unity(i).Properties.Hot.Wall.Cp/Unity(i).Properties.Hot.Average.Mw)*Unity(i).Properties.Hot.Wall.Mu)/Unity(i).Properties.Hot.Wall.K;
     1003        Unity(i).Tubes.HeatTransfer.PRw                 =       HE.PrandtlNumber(Unity(i).Properties.Hot.Wall.K,Unity(i).Properties.Hot.Wall.Cp,Unity(i).Properties.Hot.Average.Mw,Unity(i).Properties.Hot.Wall.Mu);
    12031004       
    12041005       
    12051006"Tube Side Film Coefficient"
    1206         Unity(i).Tubes.HeatTransfer.htube               =       HE.TubeFilmCoeffIncremental(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Tubes.HeatTransfer.PR,Unity(i).Properties.Hot.Average.K,Sumary.Lz(i))*Unity(i).Tubes.HeatTransfer.Phi;
     1007        Unity(i).Tubes.HeatTransfer.htube               =       HE.TubeFilmCoeffIncremental(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Tubes.HeatTransfer.PR,Unity(i).Properties.Hot.Average.K,
     1008        Unity(i).Tubes.HeatTransfer.Phi,Sumary.Lpos(i));
    12071009       
    12081010"Shell Side Prandtl Number"
    1209         Unity(i).Shell.HeatTransfer.PR                  =       ((Unity(i).Properties.Cold.Average.Cp/Unity(i).Properties.Cold.Average.Mw)*Unity(i).Properties.Cold.Average.Mu)/Unity(i).Properties.Cold.Average.K;
     1011        Unity(i).Shell.HeatTransfer.PR                  =       HE.PrandtlNumber(Unity(i).Properties.Cold.Average.K,Unity(i).Properties.Cold.Average.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Average.Mu);
    12101012
    12111013"Shell Side Prandtl Number at Wall"
    1212         Unity(i).Shell.HeatTransfer.PRw                 =       ((Unity(i).Properties.Cold.Wall.Cp/Unity(i).Properties.Cold.Average.Mw)*Unity(i).Properties.Cold.Wall.Mu)/Unity(i).Properties.Cold.Wall.K;
     1014        Unity(i).Shell.HeatTransfer.PRw                 =       HE.PrandtlNumber(Unity(i).Properties.Cold.Wall.K,Unity(i).Properties.Cold.Wall.Cp,Unity(i).Properties.Cold.Average.Mw,Unity(i).Properties.Cold.Wall.Mu);
    12131015
    12141016"Tube Side Pressure Drop"
     
    12241026end
    12251027
     1028"Position for discretization"
     1029        Sumary.Lpos(i)                                                  =       sum(Sumary.Lz([1:i]));
     1030
    12261031"Tube Resistance"       
    12271032        Unity(i).Resistances.Rtube*(Unity(i).Tubes.HeatTransfer.htube*Ditube) = Dotube;
     
    12411046"Baffles Spacing"
    12421047        Ltube = Unity(i).Baffles.Lsi+Unity(i).Baffles.Lso+Unity(i).Baffles.Ls*(Nb-1);
     1048       
    12431049
    12441050"Js Factor"     
    1245         Unity(i).Shell.HeatTransfer.Js                  =       1;
     1051        Unity(i).Shell.HeatTransfer.Js                  =       HE.JsFactor(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Lsi,Unity(i).Baffles.Lso,Unity(i).Baffles.Ls);
    12461052
    12471053"Ji Factor"
     
    12621068"Total J Factor"
    12631069        Unity(i).Shell.HeatTransfer.Jtotal              =       Unity(i).Shell.HeatTransfer.Jc*Unity(i).Shell.HeatTransfer.Jl*Unity(i).Shell.HeatTransfer.Jb*Unity(i).Shell.HeatTransfer.Jr*Unity(i).Shell.HeatTransfer.Js;
    1264 end
    1265 
    1266 "Velocity Tube Side Inlet Nozzle"
    1267         Unity(Nb+1).Tubes.PressureDrop.Vnozzle_in       = 0;
    1268 
    1269 "Velocity Tube Side Outlet Nozzle"
    1270         Unity(1).Tubes.PressureDrop.Vnozzle_out = 0;
    1271        
    1272 "Tube Pressure Drop Inlet Nozzle"
    1273         Unity(Nb+1).Tubes.PressureDrop.Pdnozzle_in      = 0;
    1274 
    1275 "Tube Pressure Drop Outlet Nozzle"
    1276         Unity(1).Tubes.PressureDrop.Pdnozzle_out        = 0;
    1277 
    1278 "Velocity Shell Side Inlet Nozzle"
    1279         Unity(Nb+1).Shell.PressureDrop.Vnozzle_in       = 0;
    1280 
    1281 "Velocity Shell Side Outlet Nozzle"
    1282         Unity(1).Shell.PressureDrop.Vnozzle_out = 0;
    1283        
    1284 "Shell Pressure Drop Inlet Nozzle"
    1285         Unity(Nb+1).Shell.PressureDrop.Pdnozzle_in      = 0;
    1286        
    1287 "Shell Pressure Drop Outlet Nozzle"
    1288         Unity(1).Shell.PressureDrop.Pdnozzle_out        = 0;
    1289 
    1290 "Shell Cross Flow Pressure Drop"
    1291         Unity(1).Shell.PressureDrop.PdCross             = 0;
    1292        
    1293 "Shell Cross Flow Pressure Drop"
    1294         Unity(Nb+1).Shell.PressureDrop.PdCross          = 0;
    1295        
    1296 "Shell Side Outlet Nozzle rho-V^2"
    1297         Unity(1).Shell.PressureDrop.RVsquare_out = 0;
    1298        
    1299 "Shell Side inlet Nozzle rho-V^2"
    1300         Unity(Nb+1).Shell.PressureDrop.RVsquare_in = 0;
     1070
     1071end
     1072
    13011073
    13021074SET
    1303 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1075#=====================================================================
    13041076#  Set Parameters for heatex Calculation
    1305 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     1077#=====================================================================
    13061078        Sumary.Zones        = Nb+1;
    13071079        Pi                              = 3.14159265;
  • /mso/eml/heat_exchangers/HeatExchangerSimplified.mso

    r49 r25  
    1 #--------------------------------------------------------------------
    2 # Author: Gerson Balbueno Bicca
    3 # $Id$
    4 #--------------------------------------------------------------------
     1 #*--------------------------------------------------------------------*
     2*
     3*
     4*
     5*
     6*
     7*
     8*               
     9*                                               
     10*
     11*
     12*----------------------------------------------------------------------
     13* Author: Gerson Balbueno Bicca
     14* $Id$
     15*--------------------------------------------------------------------*#
     16
    517using "HEX_Engine";
     18
    619#=====================================================================
    720#       Basic Models for Simplified Heat Exchangers
    821#=====================================================================
     22
    923Model HeatExchangerSimplified_Basic
     24
    1025PARAMETERS
    11 ext PP          as CalcObject   (Brief="External Physical Properties");
    12         HE              as CalcObject   (Brief="STHE Calculations",File="heatex");
    13 ext NComp       as Integer      (Brief="Number of Components");
    14         M(NComp)        as molweight    (Brief="Component Mol Weight");
     26
     27ext PP      as CalcObject(Brief="External Physical Properties");
     28ext HE      as CalcObject(Brief="STHE Calculations",File="heatex.dll");
     29ext NComp   as Integer   (Brief="Number of Components");
     30  M(NComp)  as molweight (Brief="Component Mol Weight");
    1531       
    1632VARIABLES
     
    5571
    5672if Inlet.Cold.v equal 0
     73       
    5774        then   
     75       
    5876"Heat Capacity Cold Stream"
    59         Properties.Cold.Average.Cp              =       PP.LiquidCp(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    60         Properties.Cold.Inlet.Cp                =       PP.LiquidCp(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
    61         Properties.Cold.Outlet.Cp               =       PP.LiquidCp(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
     77        Properties.Cold.Average.Cp      =       PP.LiquidCp(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
     78        Properties.Cold.Inlet.Cp        =       PP.LiquidCp(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
     79        Properties.Cold.Outlet.Cp       =       PP.LiquidCp(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
    6280
    6381"Mass Density Cold Stream"
    6482        Properties.Cold.Average.rho     =       PP.LiquidDensity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    65         Properties.Cold.Inlet.rho               =       PP.LiquidDensity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
    66         Properties.Cold.Outlet.rho              =       PP.LiquidDensity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
     83        Properties.Cold.Inlet.rho       =       PP.LiquidDensity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
     84        Properties.Cold.Outlet.rho      =       PP.LiquidDensity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
    6785
    6886"Viscosity Cold Stream"
    69         Properties.Cold.Average.Mu              =       PP.LiquidViscosity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    70         Properties.Cold.Inlet.Mu                =       PP.LiquidViscosity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
    71         Properties.Cold.Outlet.Mu               =       PP.LiquidViscosity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
     87        Properties.Cold.Average.Mu =    PP.LiquidViscosity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
     88        Properties.Cold.Inlet.Mu =              PP.LiquidViscosity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
     89        Properties.Cold.Outlet.Mu =     PP.LiquidViscosity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
    7290
    7391"Conductivity Cold Stream"
    74         Properties.Cold.Average.K               =       PP.LiquidThermalConductivity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    75         Properties.Cold.Inlet.K                 =       PP.LiquidThermalConductivity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
    76         Properties.Cold.Outlet.K                =       PP.LiquidThermalConductivity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
     92        Properties.Cold.Average.K =     PP.LiquidThermalConductivity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
     93        Properties.Cold.Inlet.K =               PP.LiquidThermalConductivity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
     94        Properties.Cold.Outlet.K =              PP.LiquidThermalConductivity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
    7795
    7896"Heat Capacity Cold Stream"
    79         Properties.Cold.Wall.Cp                 =       PP.LiquidCp(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
     97        Properties.Cold.Wall.Cp         =       PP.LiquidCp(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
    8098       
    8199"Viscosity Cold Stream"
    82         Properties.Cold.Wall.Mu                 =       PP.LiquidViscosity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
     100        Properties.Cold.Wall.Mu =       PP.LiquidViscosity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
    83101
    84102"Conductivity Cold Stream"
    85         Properties.Cold.Wall.K                  =       PP.LiquidThermalConductivity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
     103        Properties.Cold.Wall.K =        PP.LiquidThermalConductivity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
    86104
    87105
     
    95113"Mass Density Cold Stream"
    96114        Properties.Cold.Average.rho     =       PP.VapourDensity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    97         Properties.Cold.Inlet.rho               =       PP.VapourDensity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
    98         Properties.Cold.Outlet.rho              =       PP.VapourDensity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
     115        Properties.Cold.Inlet.rho       =       PP.VapourDensity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
     116        Properties.Cold.Outlet.rho      =       PP.VapourDensity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
    99117
    100118"Viscosity Cold Stream"
    101         Properties.Cold.Average.Mu              =       PP.VapourViscosity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    102         Properties.Cold.Inlet.Mu                =       PP.VapourViscosity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
    103         Properties.Cold.Outlet.Mu               =       PP.VapourViscosity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
     119        Properties.Cold.Average.Mu =    PP.VapourViscosity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
     120        Properties.Cold.Inlet.Mu =              PP.VapourViscosity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
     121        Properties.Cold.Outlet.Mu =             PP.VapourViscosity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
    104122
    105123"Conductivity Cold Stream"
    106         Properties.Cold.Average.K               =       PP.VapourThermalConductivity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
    107         Properties.Cold.Inlet.K                 =       PP.VapourThermalConductivity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
    108         Properties.Cold.Outlet.K                =       PP.VapourThermalConductivity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
     124        Properties.Cold.Average.K =     PP.VapourThermalConductivity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
     125        Properties.Cold.Inlet.K =               PP.VapourThermalConductivity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
     126        Properties.Cold.Outlet.K =              PP.VapourThermalConductivity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
    109127       
    110128"Heat Capacity Cold Stream"
    111         Properties.Cold.Wall.Cp                 =       PP.VapourCp(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
     129        Properties.Cold.Wall.Cp         =       PP.VapourCp(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
    112130
    113131
    114132"Viscosity Cold Stream"
    115         Properties.Cold.Wall.Mu                 =       PP.VapourViscosity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
     133        Properties.Cold.Wall.Mu =       PP.VapourViscosity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
    116134
    117135"Conductivity Cold Stream"
    118         Properties.Cold.Wall.K                  =       PP.VapourThermalConductivity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
     136        Properties.Cold.Wall.K =        PP.VapourThermalConductivity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
    119137       
    120138       
     
    143161"Conductivity Hot Stream"
    144162        Properties.Hot.Average.K        =               PP.LiquidThermalConductivity(Properties.Hot.Average.T,Properties.Hot.Average.P,Inlet.Hot.z);   
    145         Properties.Hot.Inlet.K          =               PP.LiquidThermalConductivity(Inlet.Hot.T,Inlet.Hot.P,Inlet.Hot.z);     
     163        Properties.Hot.Inlet.K  =               PP.LiquidThermalConductivity(Inlet.Hot.T,Inlet.Hot.P,Inlet.Hot.z);     
    146164        Properties.Hot.Outlet.K         =               PP.LiquidThermalConductivity(Outlet.Hot.T,Outlet.Hot.P,Outlet.Hot.z);   
    147165
    148166"Heat Capacity Hot Stream"
    149         Properties.Hot.Wall.Cp          =               PP.LiquidCp(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);
     167        Properties.Hot.Wall.Cp  =               PP.LiquidCp(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);
    150168
    151169"Viscosity Hot Stream"
    152         Properties.Hot.Wall.Mu          =               PP.LiquidViscosity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);     
     170        Properties.Hot.Wall.Mu  =               PP.LiquidViscosity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);     
    153171
    154172"Conductivity Hot Stream"
    155         Properties.Hot.Wall.K           =               PP.LiquidThermalConductivity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);   
     173        Properties.Hot.Wall.K   =               PP.LiquidThermalConductivity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);   
    156174       
    157175
     
    175193"Conductivity Hot Stream"
    176194        Properties.Hot.Average.K        =               PP.VapourThermalConductivity(Properties.Hot.Average.T,Properties.Hot.Average.P,Inlet.Hot.z);   
    177         Properties.Hot.Inlet.K          =               PP.VapourThermalConductivity(Inlet.Hot.T,Inlet.Hot.P,Inlet.Hot.z);     
     195        Properties.Hot.Inlet.K  =               PP.VapourThermalConductivity(Inlet.Hot.T,Inlet.Hot.P,Inlet.Hot.z);     
    178196        Properties.Hot.Outlet.K         =               PP.VapourThermalConductivity(Outlet.Hot.T,Outlet.Hot.P,Outlet.Hot.z);   
    179197
    180198"Heat Capacity Hot Stream"
    181         Properties.Hot.Wall.Cp          =               PP.VapourCp(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);
     199        Properties.Hot.Wall.Cp  =               PP.VapourCp(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);
    182200
    183201"Viscosity Hot Stream"
    184         Properties.Hot.Wall.Mu          =               PP.VapourViscosity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);
     202        Properties.Hot.Wall.Mu  =               PP.VapourViscosity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);
    185203
    186204"Conductivity Hot Stream"
    187         Properties.Hot.Wall.K           =               PP.VapourThermalConductivity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);   
     205        Properties.Hot.Wall.K   =               PP.VapourThermalConductivity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);   
    188206
    189207
     
    198216"Cold Stream Heat Capacity"
    199217        Details.Cc =Inlet.Cold.F*Properties.Cold.Average.Cp;
    200 
    201 "Minimum Heat Capacity"
    202         Details.Cmin  = min([Details.Ch,Details.Cc]);
    203 
    204 "Maximum Heat Capacity"
    205         Details.Cmax  = max([Details.Ch,Details.Cc]);
    206 
    207 "Heat Capacity Ratio"   
    208         Details.Cr    = Details.Cmin/Details.Cmax;
     218       
     219"Heat Capacity Ratio"
     220        [Details.Cmin,Details.Cmax,Details.Cr]  = HE.HeatCapacityRatio(Details.Ch,Details.Cc);
     221
    209222#=====================================================================
    210223#       Energy Balance
     
    291304#       Basic Model for Heat Exchangers - LMTD Method
    292305#=====================================================================
     306
    293307VARIABLES
    294308
    295 DT0     as temp_delta   (Brief="Temperature Difference at Inlet",Lower=1);
    296 DTL             as temp_delta   (Brief="Temperature Difference at Outlet",Lower=1);
    297 LMTD    as temp_delta   (Brief="Logarithmic Mean Temperature Difference",Lower=1);
    298 Fc              as positive             (Brief="LMTD Correction Factor",Lower=0.5);
    299 MTD             as temp_delta   (Brief="Mean Temperature Difference",Lower=1);
    300 
    301 EQUATIONS
    302 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    303 #                       Log Mean Temperature Difference
    304 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    305 if abs(DT0 - DTL) > 0.05*max(abs([DT0,DTL]))
    306        
    307         then
    308 "Log Mean Temperature Difference"
    309         LMTD= (DT0-DTL)/ln(DT0/DTL);
    310 
    311         else
    312        
    313 if DT0*DTL equal 0
    314        
    315         then
    316 "Log Mean Temperature Difference"
    317         LMTD = 0.5*(DT0+DTL);
    318        
    319         else
    320 "Log Mean Temperature Difference"
    321         LMTD = 0.5*(DT0+DTL)*(1-(DT0-DTL)^2/(DT0*DTL)*(1+(DT0-DTL)^2/(DT0*DTL)/2)/12);
    322        
    323 end
    324        
    325 end
     309LMTD                    as temp_delta   (Brief="Logarithmic Mean Temperature Difference");
     310Fc                              as positive             (Brief="LMTD Correction Factor",Lower=0.75);
     311MTD                             as temp_delta   (Brief="Mean Temperature Difference");
     312
     313EQUATIONS
    326314
    327315"Exchange Surface Area"
    328         Details.Q = Details.U*Details.A*MTD;   
     316        Details.Q = Details.U*Details.A*Fc*LMTD;       
    329317       
    330318"Mean Temperature Difference"   
     
    344332Model HeatExchanger_LMTD        as Heatex_Basic_LMTD
    345333
    346 PARAMETERS
    347 
    348         Side as Integer         (Brief="Flow Direction",Lower=0,Upper=1);
    349 
    350 SET
    351 
    352 Side = HE.FlowDir(); # Return Flow Direction
    353 
    354 EQUATIONS
    355 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    356 #       Flow Direction
    357 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    358 if Side equal 0
    359 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    360 #       Cocurrent Flow
    361 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#   
    362         then
    363 "Temperature Difference at Inlet"
    364         DT0 = Inlet.Hot.T - Inlet.Cold.T;
    365 
    366 "Temperature Difference at Outlet"
    367         DTL = Outlet.Hot.T - Outlet.Cold.T;
    368 
    369         else
    370 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    371 #       Counter Flow
    372 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#           
    373 "Temperature Difference at Inlet"
    374         DT0 = Inlet.Hot.T - Outlet.Cold.T;
    375 
    376 "Temperature Difference at Outlet"
    377         DTL = Outlet.Hot.T - Inlet.Cold.T;
    378 end
     334EQUATIONS
     335
     336"Cocurrent Flow LMTD"
     337        LMTD = HE.LogMeanTemperature(Inlet.Hot.T,Outlet.Hot.T,Inlet.Cold.T,Outlet.Cold.T);
    379338
    380339end
     
    385344#===================================================================== 
    386345EQUATIONS
    387 "Temperature Difference at Inlet"
    388         DT0 = Inlet.Hot.T - Outlet.Cold.T;
    389 
    390 "Temperature Difference at Outlet"
    391         DTL = Outlet.Hot.T - Inlet.Cold.T;
    392        
     346
     347"Counter Flow LMTD"
     348        LMTD = HE.CounterLMTD(Inlet.Hot.T,Outlet.Hot.T,Inlet.Cold.T,Outlet.Cold.T);
     349
    393350"LMTD Correction Factor"
    394351        Fc = HE.EshellCorrectionFactor(Inlet.Hot.T,Outlet.Hot.T,Inlet.Cold.T,Outlet.Cold.T);
     
    401358#=====================================================================
    402359EQUATIONS
    403 "Temperature Difference at Inlet"
    404         DT0 = Inlet.Hot.T - Outlet.Cold.T;
    405 
    406 "Temperature Difference at Outlet"
    407         DTL = Outlet.Hot.T - Inlet.Cold.T;
    408        
     360
     361"Counter Flow LMTD"
     362        LMTD = HE.CounterLMTD(Inlet.Hot.T,Outlet.Hot.T,Inlet.Cold.T,Outlet.Cold.T);
     363
    409364"LMTD Correction Factor"
    410365        Fc = HE.FshellCorrectionFactor(Inlet.Hot.T,Outlet.Hot.T,Inlet.Cold.T,Outlet.Cold.T);
     
    412367end
    413368
     369Model Multipass_LMTD            as Heatex_Basic_LMTD
     370#============================================================================
     371#       Shell and Tubes Heat Exchanger In Series with 1 shell pass - LMTD Method
     372#============================================================================
     373PARAMETERS
     374
     375Nshell  as Integer      (Brief="N Shell in Series",Lower=2);
     376
     377EQUATIONS
     378
     379"Counter Flow LMTD"
     380        LMTD = HE.CounterLMTD(Inlet.Hot.T,Outlet.Hot.T,Inlet.Cold.T,Outlet.Cold.T);
     381
     382"LMTD Correction Factor"
     383        Fc = HE.MpassCorrectionFactor(Inlet.Hot.T,Outlet.Hot.T,Inlet.Cold.T,Outlet.Cold.T,Nshell);
     384
     385end
     386
     387
    414388#=====================================================================
    415389# NTU Method
     
    419393
    420394EQUATIONS
     395
    421396"Effectiveness"
    422397        Eft=HE.Effectiveness(Details.Cr,Details.NTU);
     
    429404#=====================================================================
    430405EQUATIONS
     406
    431407"TEMA E Shell Effectiveness"
    432408        Eft = 2*(1+Details.Cr+sqrt(1+Details.Cr^2)*((1+exp(-Details.NTU*sqrt(1+Details.Cr^2)))/(1-exp(-Details.NTU*sqrt(1+Details.Cr^2)))) )^-1;
  • /mso/eml/heat_exchangers/Mheatex.mso

    r49 r25  
    11#*---------------------------------------------------------------------
    2 * Model of a Multistream Heat Exchanger
     2* This file is property of the author and cannot be used, copyed
     3* or modified without permission.
    34*
    4 *       Streams:
    5 *               * Inlet(Ninlet) streams ....    at least one material stream
    6 *               * Outlet stream             ....        one material stream
     5* Copyright (C) 2004-2006  the author
    76*
    8 *       Purpose:
    9 *               * Determines thermal and phase conditions of outlet stream
    107*
     8*               Multistream Heat Exchanger                                                     
     9*               Cocurrent and Counter Flow
     10
    1111*----------------------------------------------------------------------
    1212* Author: Gerson Balbueno Bicca
     
    1616using "streams.mso";
    1717
    18 Model Inlet_Main_Stream         
    19 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     18Model Parameters
     19#=====================================================================
     20#       Heat Exchanger Parameters
     21#===================================================================== 
     22PARAMETERS
     23       
     24ext PP                  as CalcObject;
     25ext     NComp           as Integer              (Brief="Number of Components");
     26ext     Ncold           as Integer              (Brief="Number of Inlet Cold Streams",Lower=1,Default=1);
     27ext     Nhot            as Integer              (Brief="Number of Inlet Hot Streams",Lower=1,Default=1);
     28       
     29end     
     30
     31Model Inlet_Main_Stream         as Parameters
     32#=====================================================================
    2033#       Inlet Streams
    21 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    22 PARAMETERS
     34#===================================================================== 
    2335
    24         Ncold   as Integer      (Brief="Number of Inlet Cold Streams",Lower=1);
    25         Nhot    as Integer      (Brief="Number of Inlet Hot Streams",Lower=1);
    26        
    2736VARIABLES
    2837
    29         Hot  (Nhot)     as stream;# Inlet Hot Streams
    30         Cold (Ncold)    as stream;# Inlet Cold Streams
     38Hot(Nhot)               as stream;# Inlet Hot Streams
     39Cold(Ncold)     as stream;# Inlet Cold Streams
    3140       
    3241end
    3342
    34 Model Outlet_Main_Stream       
    35 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     43Model Outlet_Main_Stream        as Parameters
     44#=====================================================================
    3645#       Outlet Streams
    37 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    38 PARAMETERS
     46#===================================================================== 
    3947
    40         Ncold   as Integer      (Brief="Number of Inlet Cold Streams",Lower=1);
    41         Nhot    as Integer      (Brief="Number of Inlet Hot Streams",Lower=1);
    42        
    4348VARIABLES
    4449
    45         Hot  (Nhot)     as stream_therm;# Outlet Hot Streams
    46         Cold (Ncold)    as stream_therm;# Outlet Cold Streams
     50Hot(Nhot)               as stream_therm;# Outlet Hot Streams
     51Cold(Ncold)     as stream_therm;# Outlet Cold Streams
    4752       
    4853end
    4954
    5055Model Mheatex
    51 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     56#=====================================================================
    5257#       Multistream Heat Exchanger Basic Calculation
    53 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     58#=====================================================================         
    5459PARAMETERS
    5560
    56 ext PP          as CalcObject   (Brief="Physical Properties");
    57 ext     NComp   as Integer              (Brief="Number of Components");
    58         HE              as CalcObject   (Brief="Cold Box Calculations",File="heatex");
     61ext     HE              as CalcObject   (Brief="Cold Box Calculations",File="Heatex.dll");
    5962        Side    as Integer              (Brief="Flow Direction",Lower=0,Upper=1);
    60         Ncold   as Integer              (Brief="Number of Inlet Cold Streams",Lower=1);
    61         Nhot    as Integer              (Brief="Number of Inlet Hot Streams",Lower=1);
    62        
     63
     64SET
     65
     66Side = HE.FlowDirection();
     67
    6368VARIABLES
    6469
     
    6974        LMTD    as temp_delta   (Brief="Logarithmic Mean Temperature Difference");
    7075        UA      as positive     (Unit="W/K");
    71 
    72 SET
    73 
    74 Side = HE.FlowDir();
    75 
    76 Inlet.Ncold  = Ncold;
    77 Outlet.Ncold = Ncold;
    78 
    79 Inlet.Nhot  = Nhot ;
    80 Outlet.Nhot = Nhot ;
    81 
    82 
     76       
    8377EQUATIONS
    8478
     
    110104        Q=UA*LMTD;
    111105
    112 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     106#===================================================================
    113107#       Flow Direction
    114 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
    115 
     108#===================================================================
    116109if Side equal 0
    117110       
    118111        then
     112#=====================================================================
     113#       Cocurrent Flow Multistream Heat Exchanger
     114#===================================================================
    119115"Cocurrent Flow LMTD"
    120116        LMTD = HE.CocurrentLMTD(max(Inlet.Hot.T),min(Outlet.Hot.T),min(Inlet.Cold.T),max(Outlet.Cold.T));
    121117       
    122118        else
     119#=====================================================================
     120#       Counter Flow Multistream Heat Exchanger
     121#=====================================================================
    123122"Counter Flow LMTD"
    124123        LMTD = HE.CounterLMTD(max(Inlet.Hot.T),min(Outlet.Hot.T),max(Inlet.Cold.T),min(Outlet.Cold.T));
  • /mso/eml/heat_exchangers/heater.mso

    r49 r25  
    11#*---------------------------------------------------------------------
    2 * Model of a Heater and Cooler
     2* This file is property of the author and cannot be used, copyed
     3* or modified without permission.
    34*
    4 *       Streams:
    5 *               * Inlet(Ninlet) streams ....    at least one material stream
    6 *               * Outlet stream             ....        one material stream
     5* Copyright (C) 2004-2005  the author
    76*
    8 *       Purpose:
    9 *               * Determines thermal and phase conditions of outlet stream
     7*
     8*                                       Heater and Cooler                                                       
     9*
    1010*
    1111*----------------------------------------------------------------------
     
    1414*--------------------------------------------------------------------*#
    1515
     16
    1617using "streams.mso";
    1718
    1819Model Heater_Cooler_Basic
    19        
    20 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     20#=====================================================================
    2121#       Heater or Cooler Basic Equations
    22 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#   
     22#=====================================================================         
    2323PARAMETERS
    24         ext PP          as CalcObject(Brief="Physical Properties");
    25         ext     NComp   as Integer       (Brief="Number of Components");       
    26                 Ninlet  as Integer       (Brief="Number of Inlet Streams",Lower=1);
     24        ext PP                  as CalcObject   (Brief="Physical Properties");
     25        ext     NComp           as Integer              (Brief="Number of Components");
     26        ext     Ninlet      as Integer          (Brief="Number of Inlet Streams",Lower=1);
    2727       
    2828VARIABLES
    2929        in  Inlet(Ninlet)       as stream;              #(Brief="Inlet Streams")
    3030        out Outlet              as stream_therm;#(Brief="Outlet Stream")
    31         Q                               as power                (Brief = "Heat Transfer");
    32         Vfrac                           as fraction     (Brief = "Vapor fraction Outlet Stream");
    33         Lfrac                           as fraction     (Brief = "Liquid fraction Outlet Stream");
     31        Q                               as power                (Brief="Heat Transfer");
    3432       
    3533EQUATIONS
     
    4543end
    4644
     45
    4746"Outlet Vapourisation Fraction"
    48         Outlet.v = PP.VapourFraction(Outlet.T,Outlet.P,Outlet.z);
    49 
    50 "Vapor fraction Outlet Stream"
    51         Vfrac = Outlet.v;
    52 
    53 "Liquid fraction Outlet Stream"
    54         Lfrac = 1-Vfrac;
     47        Outlet.v = PP.VapourFraction(Outlet.T,Outlet.P,Outlet.z);       
    5548       
    5649end
    5750
    5851Model Heater            as Heater_Cooler_Basic
    59 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     52#=====================================================================
    6053#       Heater
    61 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#   
     54#=====================================================================
    6255EQUATIONS
    6356
     
    6861
    6962Model Cooler            as Heater_Cooler_Basic
    70 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
     63#=====================================================================
    7164#       Cooler
    72 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#   
     65#=====================================================================
    7366EQUATIONS
    7467
  • /mso/eml/pressure_changers/valve.mso

    r49 r25  
    4040        x as fraction (Brief="Plug Position");
    4141        rho as dens_mass (Brief="Fluid Density", Default=1e3);
    42         v as vol_mol (Brief="Specific volume", Default=1e3);
    4342
    4443        PARAMETERS
     
    6160                (1-Inlet.v)*PP.LiquidDensity((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z);
    6261
    63         "Volume"
    64         v = Inlet.v*PP.VapourVolume((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z) +
    65                 (1-Inlet.v)*PP.LiquidVolume((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z);
    66 
    6762        #if Inlet.P > Outlet.P then
    6863        #       "Flow"
    69                 Outlet.F * v = k*x*sqrt((Inlet.P - Outlet.P)*rho_ref / rho ) ;
     64                Outlet.F = k*x*sqrt((Inlet.P - Outlet.P)*rho_ref / rho );
    7065        #else
    7166        #       "Closed"
  • /mso/eml/stage_separators/column.mso

    r49 r25  
    5050        trays([top:topdown:bot]).OutletV.F = (1 + tanh(1 *
    5151            (trays([top:topdown:bot]).OutletV.P -
    52             trays([top:topdown:bot]).InletL.P)/"Pa"))/2 *
     52            trays([top:topdown:bot]).InletL.P)))/2 *
    5353            trays([top:topdown:bot]).Ah/trays([top:topdown:bot]).vV *
    5454            sqrt(2*(trays([top:topdown:bot]).OutletV.P -
     
    101101
    102102        "Pressure Drop through the tray"
    103         trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - cond.OutletL.P)/"Pa"))/2 *
     103        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - cond.OutletL.P)))/2 *
    104104                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
    105105                cond.OutletL.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
     
    107107        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
    108108            (trays([top+topdown:topdown:bot]).OutletV.P -
    109             trays([top+topdown:topdown:bot]).InletL.P)/"Pa"))/2 *
     109            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
    110110            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
    111111            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     
    160160        tbottom as tank;
    161161        ttop as tank_cylindrical;
    162         spbottom as splitter;
    163         sptop as splitter;
    164         pump1 as pump;
    165 
    166         EQUATIONS
    167         "Pressure Drop through the tray"
    168         trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - ttop.Outlet.P)/"Pa"))/2 *
    169                 trays(top).Ah/trays(top).vV /2* sqrt(2*(trays(top).OutletV.P -
    170                 ttop.Outlet.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
    171                
    172         trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
    173             (trays([top+topdown:topdown:bot]).OutletV.P -
    174             trays([top+topdown:topdown:bot]).InletL.P)/"Pa"))/2 *
    175             trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV /2*
    176             sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
    177                 trays([top+topdown:topdown:bot]).InletL.P + 1e-8 * "atm") /
    178             (trays([top+topdown:topdown:bot]).alfa*trays([top+topdown:topdown:bot]).rhoV));
    179        
    180         CONNECTIONS
    181         #vapor
    182         reb.OutletV to trays(bot).InletV;
    183         trays([top+topdown:topdown:bot]).OutletV to trays([top:topdown:bot-topdown]).InletV;
    184         trays(top).OutletV to cond.InletV;
    185        
    186         #liquid
    187         cond.OutletL to ttop.Inlet;     
    188         ttop.Outlet to sptop.Inlet;
    189         sptop.Outlet2 to pump1.Inlet;   
    190         pump1.Outlet to trays(top).InletL;
    191         trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
    192         trays(bot).OutletL to tbottom.Inlet;
    193         tbottom.Outlet to spbottom.Inlet;
    194         spbottom.Outlet2 to reb.InletL;
    195 end
    196 
    197 
    198 #* -------------------------------------------------------------------
    199 * Distillation Column model with:
    200 *
    201 *       - NTrays like tray;
    202 *       - a vessel in the bottom of column;
    203 *       - a splitter who separate the bottom product and the stream to reboiler;
    204 *       - steady state reboiler (thermosyphon);
    205 *       - a dynamic condenser without subcooling;
    206 *       - a splitter which separate reflux and distillate;
    207 *       - a pump in reflux stream.
    208 *
    209 * ------------------------------------------------------------------*#
    210 Model Distillation_thermosyphon_cond
    211         PARAMETERS
    212 ext PP as CalcObject;
    213 ext NComp as Integer;
    214         NTrays as Integer(Brief="Number of trays", Default=2);
    215         topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
    216         top as Integer(Brief="Number of top tray");
    217         bot as Integer(Brief="Number of bottom tray");
    218 
    219         SET
    220         top = (NTrays-1)*(1-topdown)/2+1;
    221         bot = NTrays/top;
    222        
    223         VARIABLES
    224         trays(NTrays) as tray;
    225         cond as condenser;
    226         reb as reboilerSteady;
    227         tbottom as tank;
    228162        spbottom as splitter;
    229163        sptop as splitter;
     
    241175
    242176        "Pressure Drop through the tray"
    243         trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - cond.OutletL.P)/"Pa"))/2 *
     177        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - ttop.Outlet.P)))/2 *
    244178                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
    245                 cond.OutletL.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
     179                ttop.Outlet.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
    246180               
    247181        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
    248182            (trays([top+topdown:topdown:bot]).OutletV.P -
    249             trays([top+topdown:topdown:bot]).InletL.P)/"Pa"))/2 *
     183            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
    250184            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
    251185            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
    252186                trays([top+topdown:topdown:bot]).InletL.P + 1e-8 * "atm") /
    253187            (trays([top+topdown:topdown:bot]).alfa*trays([top+topdown:topdown:bot]).rhoV));
    254                        
     188       
    255189        CONNECTIONS
    256190        #vapor
     
    260194       
    261195        #liquid
    262         cond.OutletL to sptop.Inlet;   
    263         sptop.Outlet2 to pump1.Inlet;
     196        cond.OutletL to ttop.Inlet;     
     197        ttop.Outlet to sptop.Inlet;
     198        sptop.Outlet2 to pump1.Inlet;   
    264199        pump1.Outlet to trays(top).InletL;
    265200        trays([top:topdown:bot-topdown]).OutletL to trays([top+topdown:topdown:bot]).InletL;
     
    269204end
    270205
     206
    271207#* -------------------------------------------------------------------
    272208* Distillation Column model with:
    273209*
    274210*       - NTrays like tray;
    275 *       - a kettle reboiler;
    276 *       - a steady state condenser with subcooling;
    277 *       - a vessel drum (layed cilinder);
     211*       - a vessel in the bottom of column;
     212*       - a splitter who separate the bottom product and the stream to reboiler;
     213*       - steady state reboiler (thermosyphon);
     214*       - a dynamic condenser without subcooling;
    278215*       - a splitter which separate reflux and distillate;
    279216*       - a pump in reflux stream.
    280217*
    281218* ------------------------------------------------------------------*#
    282 Model Distillation_kettle_subcooling
    283         PARAMETERS
    284 ext PP as CalcObject;
    285 ext NComp as Integer;
    286         NTrays as Integer(Brief="Number of trays", Default=2);
    287         topdown as Integer(Brief="Trays counting (1=top-down, -1=bottom-up)", Default=1);
    288         top as Integer(Brief="Number of top tray");
    289         bot as Integer(Brief="Number of bottom tray");
    290 
    291         SET
    292         top = (NTrays-1)*(1-topdown)/2+1;
    293         bot = NTrays/top;
    294        
    295         VARIABLES
    296         trays(NTrays) as tray;
    297         cond as condenserSteady;
    298         reb as reboiler;
    299         ttop as tank_cylindrical;
     219Model Distillation_thermosyphon_cond
     220        PARAMETERS
     221ext PP as CalcObject;
     222ext NComp as Integer;
     223        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;
     231       
     232        VARIABLES
     233        trays(NTrays) as tray;
     234        cond as condenser;
     235        reb as reboilerSteady;
     236        tbottom as tank;
     237        spbottom as splitter;
    300238        sptop as splitter;
    301239        pump1 as pump;
     
    312250
    313251        "Pressure Drop through the tray"
    314         trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - ttop.Outlet.P)/"Pa"))/2 *
     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));
     255               
     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));
     263                       
     264        CONNECTIONS
     265        #vapor
     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;
     269       
     270        #liquid
     271        cond.OutletL to sptop.Inlet;   
     272        sptop.Outlet2 to pump1.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;
     365        tbottom.Outlet to spbottom.Inlet;
     366        spbottom.Outlet2 to reb.InletL;
     367end
     368
     369
     370#* -------------------------------------------------------------------
     371* Distillation Column model with:
     372*
     373*       - NTrays like tray;
     374*       - a kettle reboiler;
     375*       - a steady state condenser with subcooling;
     376*       - a vessel drum (layed cilinder);
     377*       - a splitter which separate reflux and distillate;
     378*       - a pump in reflux stream.
     379*
     380* ------------------------------------------------------------------*#
     381Model Distillation_kettle_subcooling
     382        PARAMETERS
     383ext PP as CalcObject;
     384ext NComp as Integer;
     385        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;
     393       
     394        VARIABLES
     395        trays(NTrays) as tray;
     396        cond as condenserSteady;
     397        reb as reboiler;
     398        ttop as tank_cylindrical;
     399        sptop as splitter;
     400        pump1 as pump;
     401
     402        EQUATIONS
     403        if (reb.OutletV.P > reb.InletL.P) then
     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) );
     407        else
     408                "No flow in reboiler"
     409                reb.OutletV.F = 0.0 * "mol/s";
     410        end
     411
     412        "Pressure Drop through the tray"
     413        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - ttop.Outlet.P)))/2 *
    315414                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
    316415                ttop.Outlet.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
     
    318417        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
    319418            (trays([top+topdown:topdown:bot]).OutletV.P -
    320             trays([top+topdown:topdown:bot]).InletL.P)/"Pa"))/2 *
     419            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
    321420            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
    322421            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     
    368467        EQUATIONS
    369468        "Pressure Drop through the tray"
    370         trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - cond.OutletL.P)/"Pa"))/2 *
     469        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - cond.OutletL.P)))/2 *
    371470                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
    372471                cond.OutletL.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
     
    374473        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
    375474            (trays([top+topdown:topdown:bot]).OutletV.P -
    376             trays([top+topdown:topdown:bot]).InletL.P)/"Pa"))/2 *
     475            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
    377476            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
    378477            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     
    425524        EQUATIONS
    426525        "Pressure Drop through the tray"
    427         trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - ttop.Outlet.P)/"Pa"))/2 *
     526        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - ttop.Outlet.P)))/2 *
    428527                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
    429528                ttop.Outlet.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
     
    431530        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
    432531            (trays([top+topdown:topdown:bot]).OutletV.P -
    433             trays([top+topdown:topdown:bot]).InletL.P)/"Pa"))/2 *
     532            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
    434533            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
    435534            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     
    479578        EQUATIONS
    480579        "Pressure Drop through the tray"
    481         trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - cond.OutletL.P)/"Pa"))/2 *
     580        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - cond.OutletL.P)))/2 *
    482581                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
    483582                cond.OutletL.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
     
    485584        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
    486585            (trays([top+topdown:topdown:bot]).OutletV.P -
    487             trays([top+topdown:topdown:bot]).InletL.P)/"Pa"))/2 *
     586            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
    488587            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
    489588            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     
    536635        EQUATIONS
    537636        "Pressure Drop through the tray"
    538         trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - ttop.Outlet.P)/"Pa"))/2 *
     637        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - ttop.Outlet.P)))/2 *
    539638                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
    540639                ttop.Outlet.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
     
    542641        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
    543642            (trays([top+topdown:topdown:bot]).OutletV.P -
    544             trays([top+topdown:topdown:bot]).InletL.P)/"Pa"))/2 *
     643            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
    545644            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
    546645            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     
    590689        EQUATIONS
    591690        "Pressure Drop through the tray"
    592         trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - cond.OutletL.P)/"Pa"))/2 *
     691        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - cond.OutletL.P)))/2 *
    593692                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
    594693                cond.OutletL.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
     
    596695        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
    597696            (trays([top+topdown:topdown:bot]).OutletV.P -
    598             trays([top+topdown:topdown:bot]).InletL.P)/"Pa"))/2 *
     697            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
    599698            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
    600699            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     
    648747        EQUATIONS
    649748        "Pressure Drop through the tray"
    650         trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - ttop.Outlet.P)/"Pa"))/2 *
     749        trays(top).OutletV.F = (1 + tanh(1 * (trays(top).OutletV.P - ttop.Outlet.P)))/2 *
    651750                trays(top).Ah/trays(top).vV * sqrt(2*(trays(top).OutletV.P -
    652751                ttop.Outlet.P + 1e-8 * "atm") / (trays(top).alfa*trays(top).rhoV));
     
    654753        trays([top+topdown:topdown:bot]).OutletV.F = (1 + tanh(1 *
    655754            (trays([top+topdown:topdown:bot]).OutletV.P -
    656             trays([top+topdown:topdown:bot]).InletL.P)/"Pa"))/2 *
     755            trays([top+topdown:topdown:bot]).InletL.P)))/2 *
    657756            trays([top+topdown:topdown:bot]).Ah/trays([top+topdown:topdown:bot]).vV *
    658757            sqrt(2*(trays([top+topdown:topdown:bot]).OutletV.P -
     
    711810        trays([top:topdown:bot]).OutletV.F = (1 + tanh(1 *
    712811            (trays([top:topdown:bot]).OutletV.P -
    713             trays([top:topdown:bot]).InletL.P)/"Pa"))/2 *
     812            trays([top:topdown:bot]).InletL.P)))/2 *
    714813            trays([top:topdown:bot]).Ah/trays([top:topdown:bot]).vV *
    715814            sqrt(2*(trays([top:topdown:bot]).OutletV.P -
     
    769868        trays([top:topdown:bot]).OutletV.F = (1 + tanh(1 *
    770869            (trays([top:topdown:bot]).OutletV.P -
    771             trays([top:topdown:bot]).InletL.P)/"Pa"))/2 *
     870            trays([top:topdown:bot]).InletL.P)))/2 *
    772871            trays([top:topdown:bot]).Ah/trays([top:topdown:bot]).vV *
    773872            sqrt(2*(trays([top:topdown:bot]).OutletV.P -
     
    816915                "Pressure Drop through the tray"
    817916                reb.OutletV.F = trays(bot).Ah/reb.vV * sqrt((reb.OutletV.P - trays(bot).OutletL.P)
    818                                 / (trays(bot).beta*reb.rhoV) );
     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
    819918        else
    820919                "Prato selado"
     
    825924        trays([top:topdown:bot]).OutletV.F = (1 + tanh(1 *
    826925            (trays([top:topdown:bot]).OutletV.P -
    827             trays([top:topdown:bot]).InletL.P)/"Pa"))/2 *
     926            trays([top:topdown:bot]).InletL.P)))/2 *
    828927            trays([top:topdown:bot]).Ah/trays([top:topdown:bot]).vV *
    829928            sqrt(2*(trays([top:topdown:bot]).OutletV.P -
     
    874973                "Pressure Drop through the tray"
    875974                reb.OutletV.F = trays(bot).Ah/reb.vV * sqrt((reb.OutletV.P - trays(bot).OutletL.P)
    876                                 / (trays(bot).beta*reb.rhoV) );
     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
    877976        else
    878977                "Prato selado"
     
    883982        trays([top:topdown:bot]).OutletV.F = (1 + tanh(1 *
    884983            (trays([top:topdown:bot]).OutletV.P -
    885             trays([top:topdown:bot]).InletL.P)/"Pa"))/2 *
     984            trays([top:topdown:bot]).InletL.P)))/2 *
    886985            trays([top:topdown:bot]).Ah/trays([top:topdown:bot]).vV *
    887986            sqrt(2*(trays([top:topdown:bot]).OutletV.P -
     
    900999        spbottom.Outlet2 to reb.InletL;
    9011000end
    902 
    903 # Reactive Distillation!!
    904 Model ReactiveDistillation
    905         PARAMETERS
    906 ext PP as CalcObject;
    907 ext NComp as Integer;
    908         NTrays as Integer(Brief="Number of trays", Default=2);
    909        
    910         VARIABLES
    911         trays(NTrays) as trayReact;
    912         cond as condenserReact;
    913         reb as reboilerReact;
    914         sp as splitter;
    915         p as pump;
    916        
    917         EQUATIONS
    918         if ( reb.OutletV.P > 1 * "atm" ) then
    919                 "Pressure Drop through the tray"
    920                 reb.OutletV.F = trays(1).Ah/reb.vV * sqrt((reb.OutletV.P - 1*"atm") / (0.15*reb.rhoV) );
    921         else
    922                 "Prato selado"
    923                 reb.OutletV.F = 0.0 * "mol/s";
    924         end
    925        
    926         CONNECTIONS
    927         #vapor
    928         reb.OutletV to trays([NTrays]).InletV;
    929         trays([2:NTrays]).OutletV to trays([1:NTrays-1]).InletV;
    930         trays(1).OutletV to cond.InletV;
    931 
    932         #liquid
    933         cond.OutletL to sp.Inlet;       
    934         sp.Outlet2 to p.Inlet;
    935         p.Outlet to trays(1).InletL;
    936         trays([1:NTrays-1]).OutletL to trays([2:NTrays]).InletL;
    937         trays(NTrays).OutletL to reb.InletL;
    938 end
  • /mso/eml/stage_separators/condenser.mso

    r49 r25  
    122122        OutletL.v = 0.0;
    123123end
    124 
    125 #*-------------------------------------------------------------------
    126 * Condenser with reaction in liquid phase
    127 *--------------------------------------------------------------------*#
    128 Model condenserReact
    129         PARAMETERS
    130 ext PP as CalcObject;
    131 ext NComp as Integer;
    132         V as volume (Brief="Condenser total volume");
    133         Across as area (Brief="Cross Section Area of reboiler");
    134 
    135         stoic(NComp) as Real(Brief="Stoichiometric matrix");
    136         Hr as energy_mol;
    137         Pstartup as pressure;
    138 
    139         VARIABLES
    140 in      InletV as stream;                       #(Brief="Vapour inlet stream");
    141 out     OutletL as stream_therm;        #(Brief="Liquid outlet stream");
    142 out     OutletV as stream_therm;        #(Brief="Vapour outlet stream");
    143 
    144         M(NComp) as mol (Brief="Molar Holdup in the tray");
    145         ML as mol (Brief="Molar liquid holdup");
    146         MV as mol (Brief="Molar vapour holdup");
    147         E as energy (Brief="Total Energy Holdup on tray");
    148         vL as volume_mol (Brief="Liquid Molar Volume");
    149         vV as volume_mol (Brief="Vapour Molar volume");
    150         Level as length (Brief="Level of liquid phase");
    151         Q as heat_rate (Brief="Heat supplied");
    152         Vol as volume;
    153         r as reaction_mol (Brief = "Reaction rate", Unit = "mol/l/s");
    154         C(NComp) as conc_mol (Brief = "Molar concentration", Lower = -1);
    155 
    156         EQUATIONS
    157         "Molar Concentration"
    158         OutletL.z = vL * C;
    159        
    160         "Component Molar Balance"
    161         diff(M) = InletV.F*InletV.z - OutletL.F*OutletL.z
    162                                 - OutletV.F*OutletV.z + stoic*r*ML*vL;
    163 
    164         "Energy Balance"
    165         diff(E) = InletV.F*InletV.h - OutletL.F*OutletL.h
    166                                 - OutletV.F*OutletV.h + Q + Hr * r * ML*vL;
    167 
    168         "Molar Holdup"
    169         M = ML*OutletL.z + MV*OutletV.z;
    170        
    171         "Energy Holdup"
    172         E = ML*OutletL.h + MV*OutletV.h - OutletV.P*V;
    173        
    174         "Mol fraction normalisation"
    175         sum(OutletL.z)=1.0;
    176 
    177         "Liquid Volume"
    178         vL = PP.LiquidVolume(OutletL.T, OutletL.P, OutletL.z);
    179         "Vapour Volume"
    180         vV = PP.VapourVolume(OutletV.T, OutletV.P, OutletV.z);
    181 
    182         "Thermal Equilibrium"
    183         OutletL.T = OutletV.T;
    184 
    185         "Mechanical Equilibrium"
    186         OutletV.P = OutletL.P;
    187 
    188         "Geometry Constraint"
    189         V = ML*vL + MV*vV;
    190 
    191         Vol = ML*vL;
    192        
    193         "Level of liquid phase"
    194         Level = ML*vL/Across;
    195        
    196         "Vapourisation Fraction"
    197         OutletL.v = 0.0;
    198         OutletV.v = 1.0;
    199        
    200         "Chemical Equilibrium"
    201         PP.LiquidFugacityCoefficient(OutletL.T, OutletL.P, OutletL.z)*OutletL.z =
    202         PP.VapourFugacityCoefficient(OutletV.T, OutletV.P, OutletV.z)*OutletV.z;
    203 
    204         sum(OutletL.z)=sum(OutletV.z);
    205 
    206 end
  • /mso/eml/stage_separators/reboiler.mso

    r49 r25  
    141141end
    142142
    143 Model reboilerSteady_fakeH
    144         PARAMETERS
    145 ext PP as CalcObject;
    146 ext NComp as Integer;
    147         DP as press_delta (Brief="Pressure Drop in the reboiler");
    148         k as Real (Brief = "Flow Constant", Unit="mol/J");
    149        
    150         VARIABLES
    151 in      InletL as stream; #(Brief="Liquid inlet stream");
    152 out     OutletV as stream; #(Brief="Vapour outlet stream");
    153 in      Q as heat_rate (Brief="Heat supplied");
    154 
    155         EQUATIONS
    156         "Molar Balance"
    157         InletL.F = OutletV.F;
    158         InletL.z = OutletV.z;
    159        
    160         "Energy Balance"
    161         InletL.F*InletL.h + Q = OutletV.F*OutletV.h;
    162        
    163         "Pressure"
    164         DP = InletL.P - OutletV.P;
    165 
    166         "Fake Vapourisation Fraction"
    167         OutletV.v = 1.0;
    168        
    169         "Fake output temperature"
    170         OutletV.T = 300*"K";
    171        
    172         "Pressure Drop through the reboiler"
    173         OutletV.F = k*Q;
    174 end
    175 
    176 #*-------------------------------------------------------------------
    177 * Model of a dynamic reboiler with reaction
    178 *-------------------------------------------------------------------*#
    179 Model reboilerReact
    180         PARAMETERS
    181 ext PP as CalcObject;
    182 ext NComp as Integer;
    183         Across as area (Brief="Cross Section Area of reboiler");
    184         V as volume (Brief="Total volume of reboiler");
    185 
    186         stoic(NComp) as Real(Brief="Stoichiometric matrix");
    187         Hr as energy_mol;
    188         Pstartup as pressure;
    189 
    190         VARIABLES
    191 in      Inlet as stream;                        #(Brief="Feed Stream");
    192 in      InletL as stream;                       #(Brief="Liquid inlet stream");
    193 out     OutletL as stream_therm;        #(Brief="Liquid outlet stream");
    194 out     OutletV as stream_therm;        #(Brief="Vapour outlet stream");
    195 
    196         Q as heat_rate (Brief="Heat supplied");
    197         M(NComp) as mol (Brief="Molar Holdup in the tray");
    198         ML as mol (Brief="Molar liquid holdup");
    199         MV as mol (Brief="Molar vapour holdup");
    200         E as energy (Brief="Total Energy Holdup on tray");
    201         vL as volume_mol (Brief="Liquid Molar Volume");
    202         vV as volume_mol (Brief="Vapour Molar volume");
    203         Level as length (Brief="Level of liquid phase");
    204         Vol as volume;
    205         startup as Real;
    206         rhoV as dens_mass;
    207         r as reaction_mol (Brief = "Reaction resulting ethyl acetate", Unit = "mol/l/s");
    208         C(NComp) as conc_mol (Brief = "Molar concentration", Lower = -1);
    209 
    210         EQUATIONS
    211         "Molar Concentration"
    212         OutletL.z = vL * C;
    213        
    214         "Component Molar Balance"
    215         diff(M)= Inlet.F*Inlet.z + InletL.F*InletL.z
    216                 - OutletL.F*OutletL.z - OutletV.F*OutletV.z + stoic*r*ML*vL;
    217        
    218         "Energy Balance"
    219         diff(E) = Inlet.F*Inlet.h + InletL.F*InletL.h
    220                 - OutletL.F*OutletL.h - OutletV.F*OutletV.h + Q + Hr * r * vL*ML;
    221        
    222         "Molar Holdup"
    223         M = ML*OutletL.z + MV*OutletV.z;
    224        
    225         "Energy Holdup"
    226         E = ML*OutletL.h + MV*OutletV.h - OutletL.P*V;
    227        
    228         "Mol fraction normalisation"
    229         sum(OutletL.z)=1.0;
    230        
    231         "Liquid Volume"
    232         vL = PP.LiquidVolume(OutletL.T, OutletL.P, OutletL.z);
    233         "Vapour Volume"
    234         vV = PP.VapourVolume(OutletV.T, OutletV.P, OutletV.z); 
    235         "Vapour Density"
    236         rhoV = PP.VapourDensity(OutletV.T, OutletV.P, OutletV.z);
    237        
    238         "Level of liquid phase"
    239         Level = ML*vL/Across;
    240 
    241         Vol = ML*vL;
    242        
    243         "vaporization fraction "
    244         OutletV.v = 1.0;
    245         OutletL.v = 0.0;
    246        
    247         "Mechanical Equilibrium"
    248         OutletL.P = OutletV.P;
    249        
    250         "Thermal Equilibrium"
    251         OutletL.T = OutletV.T; 
    252        
    253         "Geometry Constraint"
    254         V = ML*vL + MV*vV;             
    255 
    256         "Chemical Equilibrium"
    257         PP.LiquidFugacityCoefficient(OutletL.T, OutletL.P, OutletL.z)*OutletL.z =
    258         PP.VapourFugacityCoefficient(OutletV.T, OutletV.P, OutletV.z)*OutletV.z;
    259 
    260         sum(OutletL.z)=sum(OutletV.z);
    261        
    262 end
  • /mso/eml/stage_separators/tank.mso

    r49 r25  
    3333out     Outlet as stream_therm;
    3434
    35 in      Q as heat_rate (Brief="Rate of heat supply");
     35        Q as heat_rate (Brief="Rate of heat supply");
    3636        Level    as length(Brief="Tank level");
    3737        M(NComp) as mol (Brief="Molar Holdup in the tank");
     
    7777out     Outlet as stream_therm;
    7878
    79 in      Q as heat_rate (Brief="Rate of heat supply");
     79        Q as heat_rate (Brief="Rate of heat supply");
    8080        Level    as length(Brief="Tank level");
    8181        Across as area (Brief="Tank cross section area", Default=2);
  • /mso/eml/stage_separators/tray.mso

    r49 r25  
    134134        if (Level > (beta * hw)) then
    135135                "Francis Equation"
    136                 OutletL.F = 1.84*"m^0.5/s"*lw*((Level-(beta*hw))/(beta))^1.5/vL;
     136                OutletL.F = 1.84*lw*((Level-(beta*hw))/(beta))^1.5/vL;
    137137        else
    138138                "Low level"
     
    142142end
    143143
    144 #*-------------------------------------------------------------------
    145 * Model of a tray with reaction
    146 *-------------------------------------------------------------------*#
    147 Model trayReact
    148 
    149         PARAMETERS
    150 ext PP as CalcObject;
    151 ext NComp as Integer;
    152         V as volume(Brief="Total Volume of the tray");
    153         Q as power (Brief="Rate of heat supply");
    154         Ap as area (Brief="Plate area = Atray - Adowncomer");
    155        
    156         Ah as area (Brief="Total holes area");
    157         lw as length (Brief="Weir length");
    158         g as acceleration (Default=9.81);
    159         hw as length (Brief="Weir height");
    160         beta as fraction (Brief="Aeration fraction");
    161         alfa as fraction (Brief="Dry pressure drop coefficient");
    162 
    163         stoic(NComp) as Real(Brief="Stoichiometric matrix");
    164         Hr as energy_mol;
    165         Pstartup as pressure;
    166        
    167         VARIABLES
    168 in      Inlet as stream;
    169 in      InletL as stream;
    170 in      InletV as stream;
    171 out     OutletL as stream_therm;
    172 out     OutletV as stream_therm;
    173 
    174         yideal(NComp) as fraction;
    175         Emv as Real (Brief = "Murphree efficiency");
    176 
    177         M(NComp) as mol (Brief="Molar Holdup in the tray");
    178         ML as mol (Brief="Molar liquid holdup");
    179         MV as mol (Brief="Molar vapour holdup");
    180         E as energy (Brief="Total Energy Holdup on tray");
    181         vL as volume_mol (Brief="Liquid Molar Volume");
    182         vV as volume_mol (Brief="Vapour Molar volume");
    183         Level as length (Brief="Height of clear liquid on plate");
    184         Vol as volume;
    185        
    186         rhoL as dens_mass;
    187         rhoV as dens_mass;
    188         r as reaction_mol (Brief = "Reaction rate", Unit = "mol/l/s");
    189         C(NComp) as conc_mol (Brief = "Molar concentration", Lower = -1); #, Unit = "mol/l");
    190        
    191         EQUATIONS
    192         "Molar Concentration"
    193         OutletL.z = vL * C;
    194        
    195         "Component Molar Balance"
    196         diff(M)=Inlet.F*Inlet.z + InletL.F*InletL.z + InletV.F*InletV.z
    197                 - OutletL.F*OutletL.z - OutletV.F*OutletV.z + stoic*r*ML*vL;
    198        
    199         "Energy Balance"
    200         diff(E) = ( Inlet.F*Inlet.h + InletL.F*InletL.h + InletV.F*InletV.h
    201                 - OutletL.F*OutletL.h - OutletV.F*OutletV.h + Q ) + Hr * r * vL*ML;
    202        
    203         "Molar Holdup"
    204         M = ML*OutletL.z + MV*OutletV.z;
    205        
    206         "Energy Holdup"
    207         E = ML*OutletL.h + MV*OutletV.h - OutletL.P*V;
    208        
    209         "Mol fraction normalisation"
    210         sum(OutletL.z)= 1.0;
    211        
    212         "Liquid Volume"
    213         vL = PP.LiquidVolume(OutletL.T, OutletL.P, OutletL.z);
    214         "Vapour Volume"
    215         vV = PP.VapourVolume(OutletV.T, OutletV.P, OutletV.z);
    216 
    217         "Thermal Equilibrium"
    218         OutletV.T = OutletL.T;
    219        
    220         "Mechanical Equilibrium"
    221         OutletV.P = OutletL.P;
    222        
    223         "vaporization fraction "
    224         OutletV.v = 1.0;
    225         OutletL.v = 0.0;
    226        
    227         "Level of clear liquid over the weir"
    228         Level = ML*vL/Ap;
    229 
    230         Vol = ML*vL;
    231        
    232         "Liquid Density"
    233         rhoL = PP.LiquidDensity(OutletL.T, OutletL.P, OutletL.z);
    234         "Vapour Density"
    235         rhoV = PP.VapourDensity(InletV.T, InletV.P, InletV.z);
    236 
    237         if (Level > (beta * hw)) then
    238                 "Francis Equation"
    239                 OutletL.F = (1.84*"m^0.5/s"*lw*((Level-(beta*hw))/(beta))^1.5/vL);
    240         else
    241                 "Low level"
    242                 OutletL.F = 0 * "mol/h";
    243         end
    244 
    245                
    246         "Pressure Drop through the tray"
    247         OutletV.F = (1 + tanh(1 * (OutletV.P - Pstartup)/"Pa"))/2 *
    248                 Ah/vV * sqrt(2*(OutletV.P - InletL.P + 1e-8 * "atm") / (alfa*rhoV) );
    249        
    250 
    251         "Chemical Equilibrium"
    252         PP.LiquidFugacityCoefficient(OutletL.T, OutletL.P, OutletL.z)*OutletL.z =
    253                 PP.VapourFugacityCoefficient(OutletV.T, OutletV.P, OutletV.z)*yideal;
    254        
    255         OutletV.z = Emv * (yideal - InletV.z) + InletV.z;
    256        
    257         sum(OutletL.z)= sum(OutletV.z);
    258        
    259         "Geometry Constraint"
    260         V = ML* vL + MV*vV;
    261 end
  • /mso/eml/types.mso

    r49 r25  
    144144
    145145# Velocity
    146 vel_angular as Real (Brief = "Angular Velocity RPM", Default=1000, Lower=-100000, Upper=100000, Unit = "rpm");
    147 rotation as Real (Brief = "Angular Velocity", Default=500, Lower=-10000, Upper=10000, Unit = "rad/s");
    148 velocity as Real (Brief = "Velocity", Default=1, Lower=-1E5, Upper=1e5, Unit = "m/s");
    149 velocity_delta as velocity (Brief = "Difference of Velocity", Default=0, Lower=-1E3, Upper=-1E3);
     146vel_angular as positive (Brief = "Angular Velocity RPM", Default=1000, Upper=100000, Unit = "rpm");
     147rotation as positive (Brief = "Angular Velocity", Default=500, Upper=10000, Unit = "rad/s");
     148velocity as positive (Brief = "Velocity", Default=1, Upper=1e5, Unit = "m/s");
     149velocity_delta as velocity (Brief = "Difference of Velocity", Lower=-1E5);
    150150acceleration as Real (Brief = "General Acceleration", Default=9.81, Lower=-1e3, Upper=1e3, Unit = "m/s^2");
    151151
  • /mso/sample/controllers/CSTR_noniso_pid.mso

    r49 r25  
    4040        "Balanço de Massa Global"
    4141        diff(V) = Inlet.F - Outlet.F;
    42        
    4342        "Balanço de Massa por Componente"
    4443