source: mso/eml/heat_exchangers/HeatExchangerDiscretized.mso @ 100

Last change on this file since 100 was 100, checked in by gerson bicca, 15 years ago

updated

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 57.2 KB
Line 
1#*-------------------------------------------------------------------
2* EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC.
3*
4* This LIBRARY is free software; you can distribute it and/or modify
5* it under the therms of the ALSOC FREE LICENSE as available at
6* http://www.enq.ufrgs.br/alsoc.
7*
8* EMSO Copyright (C) 2004 - 2007 ALSOC, original code
9* from http://www.rps.eng.br Copyright (C) 2002-2004.
10* All rights reserved.
11*
12* EMSO is distributed under the therms of the ALSOC LICENSE as
13* available at http://www.enq.ufrgs.br/alsoc.
14*
15*--------------------------------------------------------------------
16* Author: Gerson Balbueno Bicca
17* $Id: HeatExchangerDiscretized.mso 100 2007-01-09 14:15:56Z bicca $
18*------------------------------------------------------------------*#
19
20using "HEX_Engine";
21
22#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
23#       Basic Model for Discretized Heat Exchangers
24#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
25
26Model HeatExchangerDiscretized_Basic
27
28PARAMETERS
29
30ext PP      as CalcObject(Brief="External Physical Properties");
31        HE          as CalcObject(Brief="STHE Calculations",File="heatex");
32ext NComp   as Integer   (Brief="Number of Components");
33  M(NComp)  as molweight (Brief="Component Mol Weight");
34       
35VARIABLES
36
37in  Inlet           as Inlet_Main_Stream;       # Hot and Cold Inlets
38out Outlet      as Outlet_Main_Stream;  # Hot and Cold Outlets
39        Properties  as Main_Properties;         # Hot and Cold Properties
40        Details     as Details_Main;
41        Tubes           as Tube_Side_Main;     
42        Shell           as Shell_Side_Main;
43        Resistances as Main_Resistances;
44        Baffles     as Baffles_Main;
45       
46SET
47
48M   = PP.MolecularWeight();
49
50EQUATIONS
51
52"Hot Stream Average Temperature"
53        Properties.Hot.Average.T = 0.5*Inlet.Hot.T + 0.5*Outlet.Hot.T;
54       
55"Cold Stream Average Temperature"
56        Properties.Cold.Average.T = 0.5*Inlet.Cold.T + 0.5*Outlet.Cold.T;
57       
58"Hot Stream Average Pressure"
59        Properties.Hot.Average.P = 0.5*Inlet.Hot.P+0.5*Outlet.Hot.P;
60       
61"Cold Stream Average Pressure"
62        Properties.Cold.Average.P = 0.5*Inlet.Cold.P+0.5*Outlet.Cold.P;
63       
64"Hot Stream Average Molecular Weight"
65        Properties.Hot.Average.Mw = sum(M*Inlet.Hot.z);
66
67"Cold Stream Average Molecular Weight"
68        Properties.Cold.Average.Mw = sum(M*Inlet.Cold.z);
69       
70
71if Inlet.Cold.v equal 0
72       
73        then   
74       
75"Cold Stream Average Heat Capacity"
76        Properties.Cold.Average.Cp      =       PP.LiquidCp(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
77
78"Cold Stream Inlet Heat Capacity"
79        Properties.Cold.Inlet.Cp        =       PP.LiquidCp(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
80
81"Cold Stream Outlet Heat Capacity"
82        Properties.Cold.Outlet.Cp       =       PP.LiquidCp(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
83
84"Cold Stream Average Mass Density"
85        Properties.Cold.Average.rho =   PP.LiquidDensity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
86
87"Cold Stream Inlet Mass Density"
88        Properties.Cold.Inlet.rho       =       PP.LiquidDensity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
89
90"Cold Stream Outlet Mass Density"
91        Properties.Cold.Outlet.rho      =       PP.LiquidDensity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
92
93"Cold Stream Average Viscosity"
94        Properties.Cold.Average.Mu      =       PP.LiquidViscosity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
95
96"Cold Stream inlet Viscosity"
97        Properties.Cold.Inlet.Mu        =       PP.LiquidViscosity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
98       
99"Cold Stream Outlet Viscosity"
100        Properties.Cold.Outlet.Mu       =       PP.LiquidViscosity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
101
102"Cold Stream Average Conductivity"
103        Properties.Cold.Average.K       =       PP.LiquidThermalConductivity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
104
105"Cold Stream Inlet Conductivity"       
106        Properties.Cold.Inlet.K         =       PP.LiquidThermalConductivity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
107
108"Cold Stream Outlet Conductivity"
109        Properties.Cold.Outlet.K        =       PP.LiquidThermalConductivity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
110
111"Cold Stream Heat Capacity at Wall Temperature"
112        Properties.Cold.Wall.Cp         =       PP.LiquidCp(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
113       
114"Cold Stream Viscosity at Wall Temperature"
115        Properties.Cold.Wall.Mu         =       PP.LiquidViscosity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
116
117"Cold Stream Conductivity at Wall Temperature"
118        Properties.Cold.Wall.K          =       PP.LiquidThermalConductivity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
119
120
121        else
122
123"Cold Stream Average Heat Capacity"
124        Properties.Cold.Average.Cp      =       PP.VapourCp(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
125
126"Cold Stream Inlet Heat Capacity"       
127        Properties.Cold.Inlet.Cp        =       PP.VapourCp(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
128
129"Cold Stream Outlet Heat Capacity"     
130        Properties.Cold.Outlet.Cp       =       PP.VapourCp(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
131
132"Cold Stream Average Mass Density"
133        Properties.Cold.Average.rho =   PP.VapourDensity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
134
135"Cold Stream Inlet Mass Density"
136        Properties.Cold.Inlet.rho       =       PP.VapourDensity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
137
138"Cold Stream Outlet Mass Density"       
139        Properties.Cold.Outlet.rho      =       PP.VapourDensity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
140
141"Cold Stream Average Viscosity "
142        Properties.Cold.Average.Mu      =       PP.VapourViscosity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
143
144"Cold Stream Inlet Viscosity " 
145        Properties.Cold.Inlet.Mu        =       PP.VapourViscosity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
146
147"Cold Stream Outlet Viscosity "
148        Properties.Cold.Outlet.Mu       =       PP.VapourViscosity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
149
150"Cold Stream Average Conductivity "
151        Properties.Cold.Average.K       =       PP.VapourThermalConductivity(Properties.Cold.Average.T,Properties.Cold.Average.P,Inlet.Cold.z);
152
153"Cold Stream Inlet Conductivity "
154        Properties.Cold.Inlet.K         =       PP.VapourThermalConductivity(Inlet.Cold.T,Inlet.Cold.P,Inlet.Cold.z);
155
156"Cold Stream Outlet Conductivity "
157        Properties.Cold.Outlet.K        =       PP.VapourThermalConductivity(Outlet.Cold.T,Outlet.Cold.P,Outlet.Cold.z);
158       
159"Cold Stream Heat Capacity at Wall Temperature"
160        Properties.Cold.Wall.Cp         =       PP.VapourCp(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
161
162
163"Cold Stream Viscosity at Wall Temperature"
164        Properties.Cold.Wall.Mu         =       PP.VapourViscosity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
165
166"Cold Stream Conductivity at Wall Temperature"
167        Properties.Cold.Wall.K          =       PP.VapourThermalConductivity(Properties.Cold.Wall.Twall,Properties.Cold.Average.P,Inlet.Cold.z);
168       
169       
170       
171end
172
173
174if Inlet.Hot.v equal 0
175
176        then
177
178"Hot Stream Average Heat Capacity"
179        Properties.Hot.Average.Cp       =               PP.LiquidCp(Properties.Hot.Average.T,Properties.Hot.Average.P,Inlet.Hot.z);
180
181"Hot Stream Inlet Heat Capacity"
182        Properties.Hot.Inlet.Cp         =               PP.LiquidCp(Inlet.Hot.T,Inlet.Hot.P,Inlet.Hot.z);
183
184"Hot Stream Outlet Heat Capacity"
185        Properties.Hot.Outlet.Cp        =               PP.LiquidCp(Outlet.Hot.T,Outlet.Hot.P,Outlet.Hot.z);
186
187"Hot Stream Average Mass Density"
188        Properties.Hot.Average.rho      =               PP.LiquidDensity(Properties.Hot.Average.T,Properties.Hot.Average.P,Inlet.Hot.z);
189
190"Hot Stream Inlet Mass Density"
191        Properties.Hot.Inlet.rho        =               PP.LiquidDensity(Inlet.Hot.T,Inlet.Hot.P,Inlet.Hot.z);
192
193"Hot Stream Outlet Mass Density"       
194        Properties.Hot.Outlet.rho       =               PP.LiquidDensity(Outlet.Hot.T,Outlet.Hot.P,Outlet.Hot.z);
195
196"Hot Stream Average Viscosity"
197        Properties.Hot.Average.Mu       =               PP.LiquidViscosity(Properties.Hot.Average.T,Properties.Hot.Average.P,Inlet.Hot.z);     
198
199"Hot Stream Inlet Viscosity"
200        Properties.Hot.Inlet.Mu         =               PP.LiquidViscosity(Inlet.Hot.T,Inlet.Hot.P,Inlet.Hot.z);       
201
202"Hot Stream Outlet Viscosity"
203        Properties.Hot.Outlet.Mu        =               PP.LiquidViscosity(Outlet.Hot.T,Outlet.Hot.P,Outlet.Hot.z);     
204
205"Hot Stream Average Conductivity"
206        Properties.Hot.Average.K        =               PP.LiquidThermalConductivity(Properties.Hot.Average.T,Properties.Hot.Average.P,Inlet.Hot.z);   
207
208"Hot Stream Inlet Conductivity"
209        Properties.Hot.Inlet.K          =               PP.LiquidThermalConductivity(Inlet.Hot.T,Inlet.Hot.P,Inlet.Hot.z);     
210
211"Hot Stream Outlet Conductivity"
212        Properties.Hot.Outlet.K         =               PP.LiquidThermalConductivity(Outlet.Hot.T,Outlet.Hot.P,Outlet.Hot.z);   
213
214"Hot Stream Heat Capacity at Wall Temperature"
215        Properties.Hot.Wall.Cp          =               PP.LiquidCp(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);
216
217"Hot Stream Viscosity  at Wall Temperature"
218        Properties.Hot.Wall.Mu          =               PP.LiquidViscosity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);     
219
220"Hot Stream Conductivity at Wall Temperature"
221        Properties.Hot.Wall.K           =               PP.LiquidThermalConductivity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);   
222       
223
224        else
225
226"Hot Stream Average Heat Capacity"
227        Properties.Hot.Average.Cp       =               PP.VapourCp(Properties.Hot.Average.T,Properties.Hot.Average.P,Inlet.Hot.z);
228
229"Hot Stream Inlet Heat Capacity"
230        Properties.Hot.Inlet.Cp         =               PP.VapourCp(Inlet.Hot.T,Inlet.Hot.P,Inlet.Hot.z);
231
232"Hot Stream Outlet Heat Capacity"
233        Properties.Hot.Outlet.Cp        =               PP.VapourCp(Outlet.Hot.T,Outlet.Hot.P,Outlet.Hot.z);
234
235"Hot Stream Average Mass Density"
236        Properties.Hot.Average.rho      =               PP.VapourDensity(Properties.Hot.Average.T,Properties.Hot.Average.P,Inlet.Hot.z);
237
238"Hot Stream Inlet Mass Density"
239        Properties.Hot.Inlet.rho        =               PP.VapourDensity(Inlet.Hot.T,Inlet.Hot.P,Inlet.Hot.z);
240
241"Hot Stream Outlet Mass Density"
242        Properties.Hot.Outlet.rho       =               PP.VapourDensity(Outlet.Hot.T,Outlet.Hot.P,Outlet.Hot.z);
243
244"Hot Stream Average Viscosity"
245        Properties.Hot.Average.Mu       =               PP.VapourViscosity(Properties.Hot.Average.T,Properties.Hot.Average.P,Inlet.Hot.z);
246
247"Hot Stream Inlet Viscosity"
248        Properties.Hot.Inlet.Mu         =               PP.VapourViscosity(Inlet.Hot.T,Inlet.Hot.P,Inlet.Hot.z);
249
250"Hot Stream Outlet Viscosity"
251        Properties.Hot.Outlet.Mu        =               PP.VapourViscosity(Outlet.Hot.T,Outlet.Hot.P,Outlet.Hot.z);
252
253"Hot Stream Average Conductivity"
254        Properties.Hot.Average.K        =               PP.VapourThermalConductivity(Properties.Hot.Average.T,Properties.Hot.Average.P,Inlet.Hot.z);   
255
256"Hot Stream Inlet Conductivity"
257        Properties.Hot.Inlet.K          =               PP.VapourThermalConductivity(Inlet.Hot.T,Inlet.Hot.P,Inlet.Hot.z);     
258       
259"Hot Stream Outlet Conductivity"
260        Properties.Hot.Outlet.K         =               PP.VapourThermalConductivity(Outlet.Hot.T,Outlet.Hot.P,Outlet.Hot.z);   
261
262"Hot Stream Heat Capacity at Wall Temperature"
263        Properties.Hot.Wall.Cp          =               PP.VapourCp(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);
264
265"Hot Stream Viscosity at Wall Temperature"
266        Properties.Hot.Wall.Mu          =               PP.VapourViscosity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);
267
268"Hot Stream Conductivity at Wall Temperature"
269        Properties.Hot.Wall.K           =               PP.VapourThermalConductivity(Properties.Hot.Wall.Twall,Properties.Hot.Average.P,Inlet.Hot.z);   
270
271
272end
273
274#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
275#       Thermal Details
276#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
277"Hot Stream Heat Capacity"
278        Details.Ch =Inlet.Hot.F*Properties.Hot.Average.Cp;
279       
280"Cold Stream Heat Capacity"
281        Details.Cc =Inlet.Cold.F*Properties.Cold.Average.Cp;
282       
283"Minimum Heat Capacity"
284        Details.Cmin  = min([Details.Ch,Details.Cc]);
285
286"Maximum Heat Capacity"
287        Details.Cmax  = max([Details.Ch,Details.Cc]);
288
289"Heat Capacity Ratio"
290        Details.Cr    = Details.Cmin/Details.Cmax;
291       
292#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
293#       Energy Balance
294#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
295"Energy Balance Hot Stream"
296        Details.Q = Inlet.Hot.F*(Inlet.Hot.h-Outlet.Hot.h);
297
298"Energy Balance Cold Stream"
299        Details.Q =-Inlet.Cold.F*(Inlet.Cold.h-Outlet.Cold.h);
300
301#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
302#       Material Balance
303#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
304"Flow Mass Inlet Cold Stream"
305        Properties.Cold.Inlet.Fw        =  sum(M*Inlet.Cold.z)*Inlet.Cold.F;
306
307"Flow Mass Outlet Cold Stream"
308        Properties.Cold.Outlet.Fw       =  sum(M*Outlet.Cold.z)*Outlet.Cold.F;
309
310"Flow Mass Inlet Hot Stream"
311        Properties.Hot.Inlet.Fw         =  sum(M*Inlet.Hot.z)*Inlet.Hot.F;
312
313"Flow Mass Outlet Hot Stream"   
314        Properties.Hot.Outlet.Fw        =  sum(M*Outlet.Hot.z)*Outlet.Hot.F;
315
316"Molar Balance Hot Stream"
317        Inlet.Hot.F  = Outlet.Hot.F;
318       
319"Molar Balance Cold Stream"
320        Inlet.Cold.F = Outlet.Cold.F;
321
322#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
323#       Constraints
324#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
325"Hot Stream Molar Fraction Constraint"
326        Outlet.Hot.z=Inlet.Hot.z;
327       
328"Cold Stream Molar Fraction Constraint"
329        Outlet.Cold.z=Inlet.Cold.z;
330       
331"No Phase Change In Cold Stream"
332        Inlet.Cold.v=Outlet.Cold.v;
333
334"No Phase Change In Hot Stream"
335        Inlet.Hot.v=Outlet.Hot.v;
336
337       
338end
339
340Model Heatex_Discretized_NTU            as HeatExchangerDiscretized_Basic
341       
342VARIABLES
343
344Eft             as positive (Brief="Effectiveness",Default=0.05,Lower=1e-8);
345       
346EQUATIONS
347
348"Exchange Surface Area"
349        Details.Q       = Eft*Details.Cmin*(Inlet.Hot.T-Inlet.Cold.T); 
350
351"TEMA E Shell Effectiveness"
352        Eft = HE.EshellEffectiveness(Details.Cr,Details.NTU);
353
354end
355
356Model Heatex_Discretized_LMTD           as HeatExchangerDiscretized_Basic
357       
358VARIABLES
359DT0     as temp_delta   (Brief="Temperature Difference at Inlet",Lower=1);
360DTL             as temp_delta   (Brief="Temperature Difference at Outlet",Lower=1);
361LMTD    as temp_delta   (Brief="Logarithmic Mean Temperature Difference",Lower=5);
362Fc              as positive             (Brief="LMTD Correction Factor",Lower=0.5);
363MTD             as temp_delta   (Brief="Mean Temperature Difference",Lower=1);
364
365EQUATIONS
366"Exchange Surface Area"
367        Details.Q   = Details.Ud*Details.A*MTD;
368       
369"Mean Temperature Difference"   
370        MTD   = Fc*LMTD;
371       
372"LMTD Correction Factor"
373        Fc = HE.EshellCorrectionFactor(Inlet.Hot.T,Outlet.Hot.T,Inlet.Cold.T,Outlet.Cold.T);
374
375"Temperature Difference at Inlet"
376        DT0 = Inlet.Hot.T - Outlet.Cold.T;
377
378"Temperature Difference at Outlet"
379        DTL = Outlet.Hot.T - Inlet.Cold.T;
380#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
381#                       Log Mean Temperature Difference
382#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
383if abs(DT0 - DTL) > 0.05*max(abs([DT0,DTL]))
384       
385        then
386"Log Mean Temperature Difference"
387        LMTD= (DT0-DTL)/ln(DT0/DTL);
388
389        else
390       
391if DT0*DTL equal 0
392       
393        then
394"Log Mean Temperature Difference"
395        LMTD = 0.5*(DT0+DTL);
396       
397        else
398"Log Mean Temperature Difference"
399        LMTD = 0.5*(DT0+DTL)*(1-(DT0-DTL)^2/(DT0*DTL)*(1+(DT0-DTL)^2/(DT0*DTL)/2)/12);
400       
401end
402       
403end
404
405       
406end
407
408Model Profiles
409
410PARAMETERS
411
412Zones   as Integer(Brief="Number of Zones");
413
414VARIABLES
415
416Lz(Zones)               as length                       (Brief="Zone Tube Length");
417Area                            as area                         (Brief="Area Total");
418Q                               as power                        (Brief="Total Duty");
419PdropTubesNozzle        as pressure                     (Brief="Total Tube Nozzles Pressure Drop");
420PdropTubes                      as pressure                     (Brief="Total Tube Pressure Drop");
421PdropWin                        as pressure                     (Brief="Total Shell Side Window Pressure Drop");
422PdropCross                      as pressure                     (Brief="Total Shell Side Cross Flow Pressure Drop");
423PdropEnds                       as pressure                     (Brief="Total Shell Side Ends Pressure Drop");
424PdropShellNozzle        as pressure                     (Brief="Total Shell Side Nozzles Pressure Drop");
425PdropShell                      as pressure                     (Brief="Total Shell Side Pressure Drop");
426Udaverage                       as heat_trans_coeff (Brief="Average Overall Heat Transfer Coefficient Dirty",Default=1,Lower=1e-6,Upper=1e10);
427Ucaverage                       as heat_trans_coeff (Brief="Average Overall Heat Transfer Coefficient Clean",Default=1,Lower=1e-6,Upper=1e10);
428hshellaverage           as heat_trans_coeff     (Brief="Average Shell Side Film Coefficient",Default=1,Lower=1e-12, Upper=1e6);
429htubeaverage            as heat_trans_coeff     (Brief="Average Tube Side Film Coefficient",Default=1,Lower=1e-12, Upper=1e6);
430Thot(Zones)             as temperature          (Brief="Hot Temperature",Lower = 300, Upper = 500);
431Tcold(Zones)            as temperature          (Brief="Cold Temperature",Lower = 300, Upper = 500);
432Phot(Zones)             as pressure                     (Brief="Hot Pressure",Lower = 0.8, Upper = 30);
433Pcold(Zones)            as pressure                     (Brief="Cold Pressure",Lower = 0.8, Upper = 30);
434
435end
436
437Model E_Shell_NTU_Disc           
438#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
439#       Shell and Tubes Heat Exchanger with 1 shell pass - NTU Method
440#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
441PARAMETERS
442
443        HE      as CalcObject   (Brief="STHE Calculations",File="heatex");
444ext PP  as CalcObject   (Brief="External Physical Properties");
445side    as Integer              (Brief="Fluid Alocation",Lower=0,Upper=1);
446Pi              as constant     (Brief="Pi Number",Default=3.14159265);
447
448#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
449#       Shell Geometrical Parameters
450#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
451Tpass                   as Integer              (Brief="Number of Tube Passes",Lower=1);
452Nss                             as Integer              (Brief="Number of Sealing Strips pairs",Lower=1);
453Dishell                 as length               (Brief="Inside Shell Diameter",Lower=10e-6);
454Donozzle_Shell  as length               (Brief="Shell Outlet Nozzle Diameter",Lower=10e-6);
455Dinozzle_Shell  as length               (Brief="Shell Inlet Nozzle Diameter",Lower=10e-6);
456Hinozzle_Shell  as length               (Brief="Height Under Shell Inlet Nozzle",Lower=10e-6);
457Honozzle_Shell  as length               (Brief="Height Under Shell Outlet Nozzle",Lower=10e-6);
458Lcf                     as length               (Brief="Bundle-to-Shell Clearance",Lower=10e-8);
459#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
460#       Tubes Geometrical Parameters
461#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
462Ntt                             as Integer              (Brief="Total Number of Tubes in Shell",Default=100,Lower=1);
463Pattern         as Integer              (Brief="Tube Layout Characteristic Angle",Lower=30);
464Ltube                   as length               (Brief="Effective Tube Length",Lower=0.1);
465pitch                   as length               (Brief="Tube Pitch",Lower=1e-8);
466Kwall                   as conductivity (Brief="Tube Wall Material Thermal Conductivity");
467Dotube                  as length               (Brief="Tube Outside Diameter",Lower=10e-6);
468Ditube                  as length               (Brief="Tube Inside Diameter",Lower=10e-6);
469Donozzle_Tube   as length               (Brief="Tube Outlet Nozzle Diameter",Lower=10e-6);
470Dinozzle_Tube   as length               (Brief="Tube Inlett Nozzle Diameter",Lower=10e-6);
471#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
472#       Baffles Geometrical Parameters
473#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
474Bc                      as Integer              (Brief="Baffle Cut",Default=25,Lower=25);
475Nb              as Integer              (Brief="Number of Baffles",Default=4);
476Lcd                     as length               (Brief="Baffle-to-Shell Clearance",Lower=10e-8);
477Ltd                             as length               (Brief="Tube-to-Bafflehole Clearance",Lower=10e-8);
478#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
479VARIABLES
480
481Unity(Nb+1)     as Heatex_Discretized_NTU;
482Sumary          as Profiles;
483
484CONNECTIONS
485
486Unity([1:Nb]).Outlet.Hot  to Unity([2:Nb+1]).Inlet.Hot;
487Unity([2:Nb+1]).Outlet.Cold to Unity([1:Nb]).Inlet.Cold;
488
489EQUATIONS
490
491"Hot Temperatures"
492        Sumary.Thot     = Unity.Outlet.Hot.T;
493       
494"Cold Temperatures"
495        Sumary.Tcold    = Unity.Outlet.Cold.T ;
496
497"Hot Pressures"
498        Sumary.Phot     = Unity.Outlet.Hot.P ;
499       
500"Cold Pressures"
501        Sumary.Pcold    = Unity.Outlet.Cold.P ;
502
503"Average Shell Side Film Coefficient"
504        Sumary.hshellaverage            = sum(Unity.Shell.HeatTransfer.hshell)/Sumary.Zones;
505
506"Average Tube Side Film Coefficient"
507        Sumary.htubeaverage             = sum(Unity.Tubes.HeatTransfer.htube)/Sumary.Zones;
508
509"Average Overall Heat Transfer Coefficient Dirty"
510        Sumary.Udaverage                = sum(Unity.Details.Ud)/Sumary.Zones;
511       
512"Average Overall Heat Transfer Coefficient Clean"
513        Sumary.Ucaverage                = sum(Unity.Details.Uc)/Sumary.Zones;
514
515"Area Total"
516        Sumary.Area                             = sum(Unity.Details.A);
517
518"Duty Total"
519        Sumary.Q                                = sum(Unity.Details.Q);
520
521"Length Inlet zone"
522        Sumary.Lz(1)                            = Unity(1).Baffles.Lsi;
523
524"Length Outlet zone"
525        Sumary.Lz(Nb+1)                         = Unity(1).Baffles.Lso;
526
527"Total Shell Side Pressure Drop"
528        Sumary.PdropShell                       = sum(Unity.Shell.PressureDrop.Pdtotal);
529
530"Total Tube Side Pressure Drop"
531        Sumary.PdropTubes                       = sum(Unity.Tubes.PressureDrop.Pdtotal);
532
533"Total Tube Side Nozzles Pressure Drop"
534        Sumary.PdropTubesNozzle         = sum(Unity.Tubes.PressureDrop.Pdnozzle_in + Unity.Tubes.PressureDrop.Pdnozzle_out);
535
536"Total Shell Side Nozzles Pressure Drop"
537        Sumary.PdropShellNozzle         = sum(Unity.Shell.PressureDrop.Pdnozzle_in + Unity.Shell.PressureDrop.Pdnozzle_out);
538
539"Total Shell Side Window Pressure Drop"
540        Sumary.PdropWin                         = sum(Unity.Shell.PressureDrop.Pdwindow);
541
542"Total Shell Side Cross Flow Pressure Drop"
543        Sumary.PdropCross                       = sum(Unity.Shell.PressureDrop.PdCross);
544
545"Total Shell Side Ends Pressure Drop"
546        Sumary.PdropEnds                        = sum(Unity.Shell.PressureDrop.PdEndZones);
547
548"Shell Side Cross Flow Area"
549        Unity(1).Shell.HeatTransfer.Sm = HE.CrossFlowArea(Unity(1).Baffles.Lsi);
550       
551"Shell Side Cross Flow Area"
552        Unity(Nb+1).Shell.HeatTransfer.Sm = HE.CrossFlowArea(Unity(Nb+1).Baffles.Lso);
553
554
555if side equal 1
556       
557        then
558       
559"Shell Side inlet Nozzle rho-V^2"
560        Unity(1).Shell.PressureDrop.RVsquare_in = Unity(1).Properties.Hot.Inlet.rho*(Unity(1).Shell.PressureDrop.Vnozzle_in)^2;
561
562"Shell Side Outlet Nozzle rho-V^2"
563        Unity(Nb+1).Shell.PressureDrop.RVsquare_out = Unity(Nb+1).Properties.Hot.Outlet.rho*(Unity(Nb+1).Shell.PressureDrop.Vnozzle_out)^2;
564
565"Shell Pressure End Zones"
566        Unity(1).Shell.PressureDrop.PdEndZones          =       HE.DeltaPendZonesIncremental(Unity(1).Shell.HeatTransfer.Re,Unity(1).Baffles.Ls,Unity(1).Baffles.Lso,
567        Unity(1).Baffles.Lsi,Unity(1).Properties.Hot.Inlet.Fw,Unity(1).Shell.HeatTransfer.Phi,Unity(1).Properties.Hot.Average.rho);
568
569"Shell Pressure End Zones"
570        Unity(Nb+1).Shell.PressureDrop.PdEndZones       =       HE.DeltaPendZonesIncremental(Unity(Nb+1).Shell.HeatTransfer.Re,Unity(Nb+1).Baffles.Ls,Unity(Nb+1).Baffles.Lso,
571        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);
572
573"Pressure Drop Tube Side Inlet Nozzle"
574        Unity(1).Tubes.PressureDrop.Pdnozzle_in = HE.DeltaPtubeNozzlein(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
575
576"Velocity Tube Side Inlet Nozzle"
577        Unity(1).Tubes.PressureDrop.Vnozzle_in  = HE.TubeVelocityNozzlein(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
578
579"Pressure Drop Tube Side Outlet Nozzle"
580        Unity(Nb+1).Tubes.PressureDrop.Pdnozzle_out     = HE.DeltaPtubeNozzleout(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
581
582"Velocity Tube Side Outlet Nozzle"
583        Unity(Nb+1).Tubes.PressureDrop.Vnozzle_out      = HE.TubeVelocityNozzleout(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
584
585"Shell Pressure Drop Inlet Nozzle"
586        Unity(1).Shell.PressureDrop.Pdnozzle_in = HE.DeltaPshellNozzleIn(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
587
588"Velocity Shell Side Inlet Nozzle"
589        Unity(1).Shell.PressureDrop.Vnozzle_in  = HE.ShellVelocityNozzleIn(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
590
591"Shell Pressure Drop Outlet Nozzle"
592        Unity(Nb+1).Shell.PressureDrop.Pdnozzle_out     =HE.DeltaPshellNozzleOut(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);
593
594"Velocity Shell Side Outlet Nozzle"
595        Unity(Nb+1).Shell.PressureDrop.Vnozzle_out      =HE.ShellVelocityNozzleOut(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);
596       
597
598        else
599       
600"Shell Side inlet Nozzle rho-V^2"
601        Unity(1).Shell.PressureDrop.RVsquare_in = Unity(1).Properties.Cold.Inlet.rho*(Unity(1).Shell.PressureDrop.Vnozzle_in)^2;
602
603"Shell Side Outlet Nozzle rho-V^2"
604        Unity(Nb+1).Shell.PressureDrop.RVsquare_out = Unity(Nb+1).Properties.Cold.Outlet.rho*(Unity(Nb+1).Shell.PressureDrop.Vnozzle_out)^2;
605
606"Shell Pressure End Zones"
607        Unity(1).Shell.PressureDrop.PdEndZones          =       HE.DeltaPendZonesIncremental(Unity(1).Shell.HeatTransfer.Re,Unity(1).Baffles.Ls,Unity(1).Baffles.Lso,
608        Unity(1).Baffles.Lsi,Unity(1).Properties.Cold.Inlet.Fw,Unity(1).Shell.HeatTransfer.Phi,Unity(1).Properties.Cold.Average.rho);
609
610"Shell Pressure End Zones"
611        Unity(Nb+1).Shell.PressureDrop.PdEndZones       =       HE.DeltaPendZonesIncremental(Unity(Nb+1).Shell.HeatTransfer.Re,Unity(Nb+1).Baffles.Ls,Unity(Nb+1).Baffles.Lso,
612        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);
613
614
615"Pressure Drop Tube Side Inlet Nozzle"
616        Unity(1).Tubes.PressureDrop.Pdnozzle_in = HE.DeltaPtubeNozzlein(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
617
618"Velocity Tube Side Inlet Nozzle"
619        Unity(1).Tubes.PressureDrop.Vnozzle_in  = HE.TubeVelocityNozzlein(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
620
621"Pressure Drop Tube Side Outlet Nozzle"
622        Unity(Nb+1).Tubes.PressureDrop.Pdnozzle_out     = HE.DeltaPtubeNozzleout(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);   
623
624"Velocity Tube Side Outlet Nozzle"
625        Unity(Nb+1).Tubes.PressureDrop.Vnozzle_out      = HE.TubeVelocityNozzleout(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw); 
626
627"Shell Pressure Drop Inlet Nozzle"
628        Unity(1).Shell.PressureDrop.Pdnozzle_in = HE.DeltaPshellNozzleIn(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
629
630"Velocity Shell Side Inlet Nozzle"
631        Unity(1).Shell.PressureDrop.Vnozzle_in  = HE.ShellVelocityNozzleIn(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
632
633"Shell Pressure Drop Outlet Nozzle"
634        Unity(Nb+1).Shell.PressureDrop.Pdnozzle_out = HE.DeltaPshellNozzleOut(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
635
636"Velocity Shell Side Outlet Nozzle"
637        Unity(Nb+1).Shell.PressureDrop.Vnozzle_out  = HE.ShellVelocityNozzleOut(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
638
639
640end
641
642
643for i in [2:Nb]
644
645"Pressure Drop Tube Side Inlet Nozzle"
646        Unity(i).Tubes.PressureDrop.Pdnozzle_in = 0;
647
648"Velocity Tube Side Inlet Nozzle"
649        Unity(i).Tubes.PressureDrop.Vnozzle_in  = 0;
650
651"Pressure Drop Tube Side Outlet Nozzle"
652        Unity(i).Tubes.PressureDrop.Pdnozzle_out        = 0;   
653
654"Velocity Tube Side Outlet Nozzle"
655        Unity(i).Tubes.PressureDrop.Vnozzle_out = 0;   
656
657"Shell Pressure Drop Inlet Nozzle"
658        Unity(i).Shell.PressureDrop.Pdnozzle_in = 0;
659
660"Velocity Shell Side Inlet Nozzle"
661        Unity(i).Shell.PressureDrop.Vnozzle_in  = 0;
662
663"Shell Pressure Drop Outlet Nozzle"
664        Unity(i).Shell.PressureDrop.Pdnozzle_out = 0;
665
666"Velocity Shell Side Outlet Nozzle"
667        Unity(i).Shell.PressureDrop.Vnozzle_out  = 0;
668
669"Shell Pressure End Zones"
670        Unity(i).Shell.PressureDrop.PdEndZones          =       0;
671       
672"Shell Side Outlet Nozzle rho-V^2"
673        Unity(i).Shell.PressureDrop.RVsquare_out = 0;
674       
675"Shell Side inlet Nozzle rho-V^2"
676        Unity(i).Shell.PressureDrop.RVsquare_in = 0;
677
678if side equal 1
679       
680        then
681       
682"Shell Pressure Drop Cross Flow"
683        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);
684
685
686        else
687
688"Shell Pressure Drop Cross Flow"
689        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);
690
691
692end
693
694"Zone Length"
695        Sumary.Lz(i) = Unity(1).Baffles.Ls;
696
697"Shell Side Cross Flow Area"
698        Unity(i).Shell.HeatTransfer.Sm = HE.CrossFlowArea(Unity(i).Baffles.Ls);
699       
700end
701
702
703for i in [1:Nb+1]
704       
705if side equal 1
706       
707        then
708"Pressure Drop Hot Stream"
709        Unity(i).Outlet.Hot.P  = Unity(i).Inlet.Hot.P - Unity(i).Shell.PressureDrop.Pdtotal;   
710
711"Pressure Drop Cold Stream"
712        Unity(i).Outlet.Cold.P  = Unity(i).Inlet.Cold.P - Unity(i).Tubes.PressureDrop.Pdtotal;
713       
714"Shell Side Reynolds Number"
715        Unity(i).Shell.HeatTransfer.Re=(Dotube*Unity(i).Properties.Hot.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)/Unity(i).Properties.Hot.Average.Mu;
716
717"Shell Heat Transfer Coefficient"
718        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;
719
720
721"Shell Pressure Baffle Window"
722        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);
723
724"Hot Wall Temperature"
725        Unity(i).Properties.Hot.Wall.Twall  = (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
726
727"Cold Wall Temperature"
728        Unity(i).Properties.Cold.Wall.Twall =   (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
729
730"Tube Side Velocity"
731        Unity(i).Tubes.HeatTransfer.Vtube  = Unity(i).Properties.Cold.Inlet.Fw*Tpass/((Pi*Ditube*Ditube/4)*Unity(i).Properties.Cold.Average.rho*Ntt);
732
733"Tube Side Reynolds Number"
734        Unity(i).Tubes.HeatTransfer.Re          =       (Unity(i).Properties.Cold.Average.rho*Unity(i).Tubes.HeatTransfer.Vtube*Ditube)/Unity(i).Properties.Cold.Average.Mu;
735       
736"Tube Side Prandtl Number"
737        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;
738
739"Tube Side Prandtl Number at Wall"
740        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;
741
742"Tube Side Film Coefficient"
743        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;
744       
745"Shell Side Prandtl Number"
746        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;
747
748"Shell Side Prandtl Number at Wall"
749        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; 
750
751"Tube Side Pressure Drop"
752        Unity(i).Tubes.PressureDrop.PdTube      =       HE.DeltaPtubeIncremental(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Properties.Cold.Average.rho,Unity(i).Tubes.HeatTransfer.Vtube,
753        Unity(i).Tubes.HeatTransfer.Phi,Sumary.Lz(i));
754       
755"Shell Side Phi correction for viscosity"
756        Unity(i).Shell.HeatTransfer.Phi         =       HE.PhiCorrection(Unity(i).Properties.Hot.Average.Mu,Unity(i).Properties.Hot.Wall.Mu);
757       
758"Tube Side Phi correction for viscosity"
759        Unity(i).Tubes.HeatTransfer.Phi         =       HE.PhiCorrection(Unity(i).Properties.Cold.Average.Mu,Unity(i).Properties.Cold.Wall.Mu);
760       
761        else
762
763"Pressure Drop Hot Stream"
764        Unity(i).Outlet.Hot.P  = Unity(i).Inlet.Hot.P- Unity(i).Tubes.PressureDrop.Pdtotal;     
765       
766"Pressure Drop Cold Stream"
767        Unity(i).Outlet.Cold.P  = Unity(i).Inlet.Cold.P - Unity(i).Shell.PressureDrop.Pdtotal;
768       
769"Shell Side Reynolds Number"
770        Unity(i).Shell.HeatTransfer.Re=(Dotube*Unity(i).Properties.Cold.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)/Unity(i).Properties.Cold.Average.Mu;
771
772"Shell Heat Transfer Coefficient"
773        Unity(i).Shell.HeatTransfer.hshell      =Unity(i).Shell.HeatTransfer.Ji*(Unity(i).Properties.Cold.Average.Cp/Unity(i).Properties.Cold.Average.Mw)*
774        (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;
775
776
777"Shell Pressure Baffle Window"
778        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);
779
780"Hot Wall Temperature"
781        Unity(i).Properties.Hot.Wall.Twall      =       (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
782
783"Cold Wall Temperature"
784        Unity(i).Properties.Cold.Wall.Twall     =       (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
785
786"Tube Side Velocity"
787        Unity(i).Tubes.HeatTransfer.Vtube               = Unity(i).Properties.Hot.Inlet.Fw*Tpass/((Pi*Ditube*Ditube/4)*Unity(i).Properties.Hot.Average.rho*Ntt);
788
789"Tube Side Reynolds Number"
790        Unity(i).Tubes.HeatTransfer.Re                  =       (Unity(i).Properties.Hot.Average.rho*Unity(i).Tubes.HeatTransfer.Vtube*Ditube)/Unity(i).Properties.Hot.Average.Mu;
791       
792"Tube Side Prandtl Number"
793        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;
794       
795"Tube Side Prandtl Number at Wall"
796        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;
797       
798"Tube Side Film Coefficient"
799        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;
800       
801"Shell Side Prandtl Number"
802        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;
803
804"Shell Side Prandtl Number at Wall"
805        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;
806
807"Tube Side Pressure Drop"
808        Unity(i).Tubes.PressureDrop.PdTube              =       HE.DeltaPtubeIncremental(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Properties.Hot.Average.rho,Unity(i).Tubes.HeatTransfer.Vtube,
809        Unity(i).Tubes.HeatTransfer.Phi,Sumary.Lz(i));
810
811"Shell Side Phi correction for viscosity"
812        Unity(i).Shell.HeatTransfer.Phi                 =       HE.PhiCorrection(Unity(i).Properties.Cold.Average.Mu,Unity(i).Properties.Cold.Wall.Mu);
813       
814"Tube Side Phi correction for viscosity"
815        Unity(i).Tubes.HeatTransfer.Phi                 =       HE.PhiCorrection(Unity(i).Properties.Hot.Average.Mu,Unity(i).Properties.Hot.Wall.Mu);
816
817end
818
819"Tube Resistance"       
820        Unity(i).Resistances.Rtube*(Unity(i).Tubes.HeatTransfer.htube*Ditube) = Dotube;
821       
822"Wall Resistance"
823        Unity(i).Resistances.Rwall      =       Dotube*ln(Dotube/Ditube)/(2*Kwall);
824       
825"Shell Resistance"
826        Unity(i).Resistances.Rshell*(Unity(i).Shell.HeatTransfer.hshell)        =       1;
827       
828"Overall Heat Transfer Coefficient Dirty"
829        Unity(i).Details.Ud*(Dotube/(Unity(i).Tubes.HeatTransfer.htube*Ditube)+(Dotube*ln(Dotube/Ditube)/(2*Kwall))+(1/(Unity(i).Shell.HeatTransfer.hshell)))=1;
830
831"Overall Heat Transfer Coefficient Clean"
832        (1/Unity(i).Details.Ud)=(1/Unity(i).Details.Uc)+Unity(i).Resistances.Rfo+Unity(i).Resistances.Rfi*(Dotube/Ditube);
833
834"Exchange Surface Area"
835        Unity(i).Details.A      =       Pi*Dotube*Ntt*Sumary.Lz(i);
836
837"Baffles Spacing"
838        Ltube = Unity(i).Baffles.Lsi+Unity(i).Baffles.Lso+Unity(i).Baffles.Ls*(Nb-1);
839       
840"Js Factor"     
841        Unity(i).Shell.HeatTransfer.Js                  =       1;
842       
843"Ji Factor"
844        Unity(i).Shell.HeatTransfer.Ji                  =       HE.JiFactor(Unity(i).Shell.HeatTransfer.Re);
845
846"Jc Factor"
847        Unity(i).Shell.HeatTransfer.Jc                  =       HE.JcFactor();
848       
849"Jl Factor"
850        Unity(i).Shell.HeatTransfer.Jl                  =       HE.JlFactor(Unity(i).Shell.HeatTransfer.Sm);
851
852"Jb Factor"
853        Unity(i).Shell.HeatTransfer.Jb                  =       HE.JbFactor(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Ls,Unity(i).Shell.HeatTransfer.Sm);
854
855"Jr Factor"     
856        Unity(i).Shell.HeatTransfer.Jr                  =       HE.JrFactor(Unity(i).Shell.HeatTransfer.Re);
857       
858"Total J Factor"
859        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;
860end
861
862"Velocity Tube Side Inlet Nozzle"
863        Unity(Nb+1).Tubes.PressureDrop.Vnozzle_in       = 0;
864
865"Velocity Tube Side Outlet Nozzle"
866        Unity(1).Tubes.PressureDrop.Vnozzle_out = 0;
867       
868"Tube Pressure Drop Inlet Nozzle"
869        Unity(Nb+1).Tubes.PressureDrop.Pdnozzle_in      = 0;
870
871"Tube Pressure Drop Outlet Nozzle"
872        Unity(1).Tubes.PressureDrop.Pdnozzle_out        = 0;
873
874"Velocity Shell Side Inlet Nozzle"
875        Unity(Nb+1).Shell.PressureDrop.Vnozzle_in       = 0;
876
877"Velocity Shell Side Outlet Nozzle"
878        Unity(1).Shell.PressureDrop.Vnozzle_out = 0;
879       
880"Shell Pressure Drop Inlet Nozzle"
881        Unity(Nb+1).Shell.PressureDrop.Pdnozzle_in      = 0;
882       
883"Shell Pressure Drop Outlet Nozzle"
884        Unity(1).Shell.PressureDrop.Pdnozzle_out        = 0;
885
886"Shell Cross Flow Pressure Drop"
887        Unity(1).Shell.PressureDrop.PdCross             = 0;
888       
889"Shell Cross Flow Pressure Drop"
890        Unity(Nb+1).Shell.PressureDrop.PdCross          = 0;
891       
892"Shell Side Outlet Nozzle rho-V^2"
893        Unity(1).Shell.PressureDrop.RVsquare_out = 0;
894       
895"Shell Side inlet Nozzle rho-V^2"
896        Unity(Nb+1).Shell.PressureDrop.RVsquare_in = 0;
897
898SET
899#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
900#  Set Parameters for heatex Calculation
901#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
902        Sumary.Zones        = Nb+1;
903        Pi                              = 3.14159265;
904        HE.Tpass                        = Tpass;
905        HE.Nss                          = Nss;
906        HE.Ntt                          = Ntt;
907        HE.Pattern                      = Pattern;
908        HE.Bc                           = Bc;
909        HE.Donozzle_Shell       = Donozzle_Shell;
910        HE.Dinozzle_Shell       = Dinozzle_Shell;
911        HE.Honozzle_Shell       = Honozzle_Shell;
912        HE.Hinozzle_Shell       = Hinozzle_Shell;
913        HE.Donozzle_Tube        = Donozzle_Tube;
914        HE.Dinozzle_Tube        = Dinozzle_Tube;
915        HE.Nb                       = Nb;
916        HE.Dishell                      = Dishell;             
917        HE.Lcf                          = Lcf; 
918        HE.pitch                        = pitch;               
919        HE.Dotube                       = Dotube;       
920        HE.Ditube                       = Ditube;       
921        HE.Lcd                          = Lcd;
922        HE.Ltd                          = Ltd;
923        side                            = HE.FluidAlocation();
924end
925
926Model E_Shell_LMTD_Disc         
927#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
928#       Shell and Tubes Heat Exchanger with 1 shell pass - LMTD Method
929#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
930PARAMETERS
931
932        HE      as CalcObject   (Brief="STHE Calculations",File="heatex");
933ext PP  as CalcObject   (Brief="External Physical Properties");
934side    as Integer              (Brief="Fluid Alocation",Lower=0,Upper=1);
935Pi              as constant     (Brief="Pi Number",Default=3.14159265);
936
937#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
938#       Shell Geometrical Parameters
939#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
940Tpass                   as Integer              (Brief="Number of Tube Passes",Lower=1);
941Nss                             as Integer              (Brief="Number of Sealing Strips pairs",Lower=1);
942Dishell                 as length               (Brief="Inside Shell Diameter",Lower=10e-6);
943Donozzle_Shell  as length               (Brief="Shell Outlet Nozzle Diameter",Lower=10e-6);
944Dinozzle_Shell  as length               (Brief="Shell Inlet Nozzle Diameter",Lower=10e-6);
945Hinozzle_Shell  as length               (Brief="Height Under Shell Inlet Nozzle",Lower=10e-6);
946Honozzle_Shell  as length               (Brief="Height Under Shell Outlet Nozzle",Lower=10e-6);
947Lcf                     as length               (Brief="Bundle-to-Shell Clearance",Lower=10e-8);
948#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
949#       Tubes Geometrical Parameters
950#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
951Ntt                             as Integer              (Brief="Total Number of Tubes in Shell",Default=100,Lower=1);
952Pattern         as Integer              (Brief="Tube Layout Characteristic Angle",Lower=30);
953Ltube                   as length               (Brief="Effective Tube Length",Lower=0.1);
954pitch                   as length               (Brief="Tube Pitch",Lower=1e-8);
955Kwall                   as conductivity (Brief="Tube Wall Material Thermal Conductivity");
956Dotube                  as length               (Brief="Tube Outside Diameter",Lower=10e-6);
957Ditube                  as length               (Brief="Tube Inside Diameter",Lower=10e-6);
958Donozzle_Tube   as length               (Brief="Tube Outlet Nozzle Diameter",Lower=10e-6);
959Dinozzle_Tube   as length               (Brief="Tube Inlett Nozzle Diameter",Lower=10e-6);
960#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
961#       Baffles Geometrical Parameters
962#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
963Bc                      as Integer              (Brief="Baffle Cut",Default=25,Lower=25);
964Nb              as Integer              (Brief="Number of Baffles",Default=4);
965Lcd                     as length               (Brief="Baffle-to-Shell Clearance",Lower=10e-8);
966Ltd                             as length               (Brief="Tube-to-Bafflehole Clearance",Lower=10e-8);
967#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
968VARIABLES
969
970Unity(Nb+1)     as Heatex_Discretized_LMTD;
971Sumary          as Profiles;
972
973CONNECTIONS
974
975Unity([1:Nb]).Outlet.Hot        to Unity([2:Nb+1]).Inlet.Hot;
976Unity([2:Nb+1]).Outlet.Cold to Unity([1:Nb]).Inlet.Cold;
977
978EQUATIONS
979
980"Hot Temperatures"
981        Sumary.Thot     = Unity.Outlet.Hot.T;
982       
983"Cold Temperatures"
984        Sumary.Tcold    = Unity.Outlet.Cold.T ;
985
986"Hot Pressures"
987        Sumary.Phot     = Unity.Outlet.Hot.P ;
988       
989"Cold Pressures"
990        Sumary.Pcold    = Unity.Outlet.Cold.P ;
991
992"Average Shell Side Film Coefficient"
993        Sumary.hshellaverage            = sum(Unity.Shell.HeatTransfer.hshell)/Sumary.Zones;
994
995"Average Tube Side Film Coefficient"
996        Sumary.htubeaverage             = sum(Unity.Tubes.HeatTransfer.htube)/Sumary.Zones;
997
998"Average Overall Heat Transfer Coefficient Dirty"
999        Sumary.Udaverage                = sum(Unity.Details.Ud)/Sumary.Zones;
1000       
1001"Average Overall Heat Transfer Coefficient Clean"
1002        Sumary.Ucaverage                = sum(Unity.Details.Uc)/Sumary.Zones;   
1003
1004"Area Total"
1005        Sumary.Area                             = sum(Unity.Details.A);
1006
1007"Duty Total"
1008        Sumary.Q                                = sum(Unity.Details.Q);
1009
1010"Length Inlet zone"
1011        Sumary.Lz(1)                            = Unity(1).Baffles.Lsi;
1012
1013"Length Outlet zone"
1014        Sumary.Lz(Nb+1)                         = Unity(1).Baffles.Lso;
1015
1016"Total Shell Side Pressure Drop"
1017        Sumary.PdropShell                       = sum(Unity.Shell.PressureDrop.Pdtotal);
1018
1019"Total Tube Side Pressure Drop"
1020        Sumary.PdropTubes                       = sum(Unity.Tubes.PressureDrop.Pdtotal);
1021
1022"Total Tube Side Nozzles Pressure Drop"
1023        Sumary.PdropTubesNozzle         = sum(Unity.Tubes.PressureDrop.Pdnozzle_in + Unity.Tubes.PressureDrop.Pdnozzle_out);
1024
1025"Total Shell Side Nozzles Pressure Drop"
1026        Sumary.PdropShellNozzle         = sum(Unity.Shell.PressureDrop.Pdnozzle_in + Unity.Shell.PressureDrop.Pdnozzle_out);
1027
1028"Total Shell Side Window Pressure Drop"
1029        Sumary.PdropWin                         = sum(Unity.Shell.PressureDrop.Pdwindow);
1030
1031"Total Shell Side Cross Flow Pressure Drop"
1032        Sumary.PdropCross                       = sum(Unity.Shell.PressureDrop.PdCross);
1033
1034"Total Shell Side Ends Pressure Drop"
1035        Sumary.PdropEnds                        = sum(Unity.Shell.PressureDrop.PdEndZones);
1036
1037"Shell Side Cross Flow Area"
1038        Unity(1).Shell.HeatTransfer.Sm = HE.CrossFlowArea(Unity(1).Baffles.Lsi);
1039       
1040"Shell Side Cross Flow Area"
1041        Unity(Nb+1).Shell.HeatTransfer.Sm = HE.CrossFlowArea(Unity(Nb+1).Baffles.Lso);
1042
1043if side equal 1
1044       
1045        then
1046
1047"Shell Side inlet Nozzle rho-V^2"
1048        Unity(1).Shell.PressureDrop.RVsquare_in = Unity(1).Properties.Hot.Inlet.rho*(Unity(1).Shell.PressureDrop.Vnozzle_in)^2;
1049
1050"Shell Side Outlet Nozzle rho-V^2"
1051        Unity(Nb+1).Shell.PressureDrop.RVsquare_out = Unity(Nb+1).Properties.Hot.Outlet.rho*(Unity(Nb+1).Shell.PressureDrop.Vnozzle_out)^2;
1052
1053"Shell Pressure End Zones"
1054        Unity(1).Shell.PressureDrop.PdEndZones          =       HE.DeltaPendZonesIncremental(Unity(1).Shell.HeatTransfer.Re,Unity(1).Baffles.Ls,Unity(1).Baffles.Lso,
1055        Unity(1).Baffles.Lsi,Unity(1).Properties.Hot.Inlet.Fw,Unity(1).Shell.HeatTransfer.Phi,Unity(1).Properties.Hot.Average.rho);
1056
1057"Shell Pressure End Zones"
1058        Unity(Nb+1).Shell.PressureDrop.PdEndZones       =       HE.DeltaPendZonesIncremental(Unity(Nb+1).Shell.HeatTransfer.Re,Unity(Nb+1).Baffles.Ls,Unity(Nb+1).Baffles.Lso,
1059        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);
1060
1061"Pressure Drop Tube Side Inlet Nozzle"
1062        Unity(1).Tubes.PressureDrop.Pdnozzle_in = HE.DeltaPtubeNozzlein(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
1063
1064"Velocity Tube Side Inlet Nozzle"
1065        Unity(1).Tubes.PressureDrop.Vnozzle_in  = HE.TubeVelocityNozzlein(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
1066
1067"Pressure Drop Tube Side Outlet Nozzle"
1068        Unity(Nb+1).Tubes.PressureDrop.Pdnozzle_out     = HE.DeltaPtubeNozzleout(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
1069
1070"Velocity Tube Side Outlet Nozzle"
1071        Unity(Nb+1).Tubes.PressureDrop.Vnozzle_out      = HE.TubeVelocityNozzleout(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
1072
1073"Shell Pressure Drop Inlet Nozzle"
1074        Unity(1).Shell.PressureDrop.Pdnozzle_in = HE.DeltaPshellNozzleIn(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
1075
1076"Velocity Shell Side Inlet Nozzle"
1077        Unity(1).Shell.PressureDrop.Vnozzle_in  = HE.ShellVelocityNozzleIn(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
1078
1079"Shell Pressure Drop Outlet Nozzle"
1080        Unity(Nb+1).Shell.PressureDrop.Pdnozzle_out     =HE.DeltaPshellNozzleOut(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);
1081
1082"Velocity Shell Side Outlet Nozzle"
1083        Unity(Nb+1).Shell.PressureDrop.Vnozzle_out      =HE.ShellVelocityNozzleOut(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);
1084       
1085
1086        else
1087
1088"Shell Side inlet Nozzle rho-V^2"
1089        Unity(1).Shell.PressureDrop.RVsquare_in = Unity(1).Properties.Cold.Inlet.rho*(Unity(1).Shell.PressureDrop.Vnozzle_in)^2;
1090
1091"Shell Side Outlet Nozzle rho-V^2"
1092        Unity(Nb+1).Shell.PressureDrop.RVsquare_out = Unity(Nb+1).Properties.Cold.Outlet.rho*(Unity(Nb+1).Shell.PressureDrop.Vnozzle_out)^2;
1093
1094"Shell Pressure End Zones"
1095        Unity(1).Shell.PressureDrop.PdEndZones          =       HE.DeltaPendZonesIncremental(Unity(1).Shell.HeatTransfer.Re,Unity(1).Baffles.Ls,Unity(1).Baffles.Lso,
1096        Unity(1).Baffles.Lsi,Unity(1).Properties.Cold.Inlet.Fw,Unity(1).Shell.HeatTransfer.Phi,Unity(1).Properties.Cold.Average.rho);
1097
1098"Shell Pressure End Zones"
1099        Unity(Nb+1).Shell.PressureDrop.PdEndZones       =       HE.DeltaPendZonesIncremental(Unity(Nb+1).Shell.HeatTransfer.Re,Unity(Nb+1).Baffles.Ls,Unity(Nb+1).Baffles.Lso,
1100        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);
1101
1102
1103"Pressure Drop Tube Side Inlet Nozzle"
1104        Unity(1).Tubes.PressureDrop.Pdnozzle_in = HE.DeltaPtubeNozzlein(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
1105
1106"Velocity Tube Side Inlet Nozzle"
1107        Unity(1).Tubes.PressureDrop.Vnozzle_in  = HE.TubeVelocityNozzlein(Unity(1).Properties.Hot.Inlet.rho,Unity(1).Properties.Hot.Inlet.Fw);
1108
1109"Pressure Drop Tube Side Outlet Nozzle"
1110        Unity(Nb+1).Tubes.PressureDrop.Pdnozzle_out     = HE.DeltaPtubeNozzleout(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw);   
1111
1112"Velocity Tube Side Outlet Nozzle"
1113        Unity(Nb+1).Tubes.PressureDrop.Vnozzle_out      = HE.TubeVelocityNozzleout(Unity(Nb+1).Properties.Hot.Outlet.rho,Unity(Nb+1).Properties.Hot.Inlet.Fw); 
1114
1115"Shell Pressure Drop Inlet Nozzle"
1116        Unity(1).Shell.PressureDrop.Pdnozzle_in = HE.DeltaPshellNozzleIn(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
1117
1118"Velocity Shell Side Inlet Nozzle"
1119        Unity(1).Shell.PressureDrop.Vnozzle_in  = HE.ShellVelocityNozzleIn(Unity(1).Properties.Cold.Inlet.rho,Unity(1).Properties.Cold.Inlet.Fw);
1120
1121"Shell Pressure Drop Outlet Nozzle"
1122        Unity(Nb+1).Shell.PressureDrop.Pdnozzle_out = HE.DeltaPshellNozzleOut(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
1123
1124"Velocity Shell Side Outlet Nozzle"
1125        Unity(Nb+1).Shell.PressureDrop.Vnozzle_out  = HE.ShellVelocityNozzleOut(Unity(Nb+1).Properties.Cold.Outlet.rho,Unity(Nb+1).Properties.Cold.Inlet.Fw);
1126
1127
1128end
1129
1130
1131for i in [2:Nb]
1132
1133"Pressure Drop Tube Side Inlet Nozzle"
1134        Unity(i).Tubes.PressureDrop.Pdnozzle_in = 0;
1135
1136"Velocity Tube Side Inlet Nozzle"
1137        Unity(i).Tubes.PressureDrop.Vnozzle_in  = 0;
1138
1139"Pressure Drop Tube Side Outlet Nozzle"
1140        Unity(i).Tubes.PressureDrop.Pdnozzle_out        = 0;   
1141
1142"Velocity Tube Side Outlet Nozzle"
1143        Unity(i).Tubes.PressureDrop.Vnozzle_out = 0;   
1144
1145"Shell Pressure Drop Inlet Nozzle"
1146        Unity(i).Shell.PressureDrop.Pdnozzle_in = 0;
1147
1148"Velocity Shell Side Inlet Nozzle"
1149        Unity(i).Shell.PressureDrop.Vnozzle_in  = 0;
1150
1151"Shell Pressure Drop Outlet Nozzle"
1152        Unity(i).Shell.PressureDrop.Pdnozzle_out = 0;
1153
1154"Velocity Shell Side Outlet Nozzle"
1155        Unity(i).Shell.PressureDrop.Vnozzle_out  = 0;
1156
1157"Shell Pressure End Zones"
1158        Unity(i).Shell.PressureDrop.PdEndZones          =       0;
1159
1160"Shell Side Outlet Nozzle rho-V^2"
1161        Unity(i).Shell.PressureDrop.RVsquare_out = 0;
1162       
1163"Shell Side inlet Nozzle rho-V^2"
1164        Unity(i).Shell.PressureDrop.RVsquare_in = 0;
1165       
1166if side equal 1
1167       
1168        then
1169       
1170"Shell Pressure Drop Cross Flow"
1171        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);
1172
1173
1174        else
1175
1176"Shell Pressure Drop Cross Flow"
1177        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);
1178
1179
1180end
1181
1182"Zone Length"
1183        Sumary.Lz(i) = Unity(1).Baffles.Ls;
1184
1185"Shell Side Cross Flow Area"
1186        Unity(i).Shell.HeatTransfer.Sm = HE.CrossFlowArea(Unity(i).Baffles.Ls);
1187       
1188end
1189
1190
1191for i in [1:Nb+1]
1192
1193
1194if side equal 1
1195       
1196        then
1197"Pressure Drop Hot Stream"
1198        Unity(i).Outlet.Hot.P  = Unity(i).Inlet.Hot.P - Unity(i).Shell.PressureDrop.Pdtotal;   
1199
1200"Pressure Drop Cold Stream"
1201        Unity(i).Outlet.Cold.P  = Unity(i).Inlet.Cold.P - Unity(i).Tubes.PressureDrop.Pdtotal;
1202       
1203"Shell Side Reynolds Number"
1204        Unity(i).Shell.HeatTransfer.Re=(Dotube*Unity(i).Properties.Hot.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)/Unity(i).Properties.Hot.Average.Mu;
1205
1206"Shell Heat Transfer Coefficient"
1207        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;
1208
1209"Shell Pressure Baffle Window"
1210        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);
1211
1212"Hot Wall Temperature"
1213        Unity(i).Properties.Hot.Wall.Twall  = (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
1214       
1215"Cold Wall Temperature"
1216        Unity(i).Properties.Cold.Wall.Twall =   (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
1217
1218"Tube Side Velocity"
1219        Unity(i).Tubes.HeatTransfer.Vtube       =       Unity(i).Properties.Cold.Inlet.Fw*Tpass/((Pi*Ditube*Ditube/4)*Unity(i).Properties.Cold.Average.rho*Ntt);
1220
1221"Tube Side Reynolds Number"
1222        Unity(i).Tubes.HeatTransfer.Re          =       (Unity(i).Properties.Cold.Average.rho*Unity(i).Tubes.HeatTransfer.Vtube*Ditube)/Unity(i).Properties.Cold.Average.Mu;
1223       
1224"Tube Side Prandtl Number"
1225        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;
1226
1227"Tube Side Prandtl Number at Wall"
1228        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;
1229
1230"Tube Side Film Coefficient"
1231        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;
1232       
1233"Shell Side Prandtl Number"
1234        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;
1235
1236"Shell Side Prandtl Number at Wall"
1237        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; 
1238
1239"Tube Side Pressure Drop"
1240        Unity(i).Tubes.PressureDrop.PdTube      =       HE.DeltaPtubeIncremental(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Properties.Cold.Average.rho,Unity(i).Tubes.HeatTransfer.Vtube,
1241        Unity(i).Tubes.HeatTransfer.Phi,Sumary.Lz(i));
1242       
1243"Shell Side Phi correction for viscosity"
1244        Unity(i).Shell.HeatTransfer.Phi         =       HE.PhiCorrection(Unity(i).Properties.Hot.Average.Mu,Unity(i).Properties.Hot.Wall.Mu);
1245       
1246"Tube Side Phi correction for viscosity"
1247        Unity(i).Tubes.HeatTransfer.Phi         =       HE.PhiCorrection(Unity(i).Properties.Cold.Average.Mu,Unity(i).Properties.Cold.Wall.Mu);
1248       
1249        else
1250
1251"Pressure Drop Hot Stream"
1252        Unity(i).Outlet.Hot.P  = Unity(i).Inlet.Hot.P- Unity(i).Tubes.PressureDrop.Pdtotal;     
1253       
1254"Pressure Drop Cold Stream"
1255        Unity(i).Outlet.Cold.P  = Unity(i).Inlet.Cold.P - Unity(i).Shell.PressureDrop.Pdtotal;
1256       
1257"Shell Side Reynolds Number"
1258        Unity(i).Shell.HeatTransfer.Re=(Dotube*Unity(i).Properties.Cold.Inlet.Fw/Unity(i).Shell.HeatTransfer.Sm)/Unity(i).Properties.Cold.Average.Mu;
1259
1260"Shell Heat Transfer Coefficient"
1261        Unity(i).Shell.HeatTransfer.hshell      =Unity(i).Shell.HeatTransfer.Ji*(Unity(i).Properties.Cold.Average.Cp/Unity(i).Properties.Cold.Average.Mw)*
1262        (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;
1263
1264
1265"Shell Pressure Baffle Window"
1266        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);
1267
1268
1269"Hot Wall Temperature"
1270        Unity(i).Properties.Hot.Wall.Twall      =       (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
1271       
1272"Cold Wall Temperature"
1273        Unity(i).Properties.Cold.Wall.Twall     =       (Unity(i).Properties.Hot.Average.T+Unity(i).Properties.Cold.Average.T)/2;
1274
1275"Tube Side Velocity"
1276        Unity(i).Tubes.HeatTransfer.Vtube               = Unity(i).Properties.Hot.Inlet.Fw*Tpass/((Pi*Ditube*Ditube/4)*Unity(i).Properties.Hot.Average.rho*Ntt);
1277
1278"Tube Side Reynolds Number"
1279        Unity(i).Tubes.HeatTransfer.Re                  =       (Unity(i).Properties.Hot.Average.rho*Unity(i).Tubes.HeatTransfer.Vtube*Ditube)/Unity(i).Properties.Hot.Average.Mu;
1280       
1281"Tube Side Prandtl Number"
1282        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;
1283       
1284"Tube Side Prandtl Number at Wall"
1285        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;
1286       
1287       
1288"Tube Side Film Coefficient"
1289        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;
1290       
1291"Shell Side Prandtl Number"
1292        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;
1293
1294"Shell Side Prandtl Number at Wall"
1295        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;
1296
1297"Tube Side Pressure Drop"
1298        Unity(i).Tubes.PressureDrop.PdTube              =       HE.DeltaPtubeIncremental(Unity(i).Tubes.HeatTransfer.Re,Unity(i).Properties.Hot.Average.rho,Unity(i).Tubes.HeatTransfer.Vtube,
1299        Unity(i).Tubes.HeatTransfer.Phi,Sumary.Lz(i));
1300
1301"Shell Side Phi correction for viscosity"
1302        Unity(i).Shell.HeatTransfer.Phi                 =       HE.PhiCorrection(Unity(i).Properties.Cold.Average.Mu,Unity(i).Properties.Cold.Wall.Mu);
1303       
1304"Tube Side Phi correction for viscosity"
1305        Unity(i).Tubes.HeatTransfer.Phi                 =       HE.PhiCorrection(Unity(i).Properties.Hot.Average.Mu,Unity(i).Properties.Hot.Wall.Mu);
1306
1307end
1308
1309"Tube Resistance"       
1310        Unity(i).Resistances.Rtube*(Unity(i).Tubes.HeatTransfer.htube*Ditube) = Dotube;
1311       
1312"Wall Resistance"
1313        Unity(i).Resistances.Rwall      =       Dotube*ln(Dotube/Ditube)/(2*Kwall);
1314       
1315"Shell Resistance"
1316        Unity(i).Resistances.Rshell*(Unity(i).Shell.HeatTransfer.hshell)        =       1;
1317       
1318"Overall Heat Transfer Coefficient Dirty"
1319        Unity(i).Details.Ud*(Dotube/(Unity(i).Tubes.HeatTransfer.htube*Ditube)+(Dotube*ln(Dotube/Ditube)/(2*Kwall))+(1/(Unity(i).Shell.HeatTransfer.hshell)))=1;
1320
1321"Overall Heat Transfer Coefficient Clean"
1322        (1/Unity(i).Details.Ud)=(1/Unity(i).Details.Uc)+Unity(i).Resistances.Rfo+Unity(i).Resistances.Rfi*(Dotube/Ditube);
1323
1324"Exchange Surface Area"
1325        Unity(i).Details.A      =       Pi*Dotube*Ntt*Sumary.Lz(i);
1326
1327"Baffles Spacing"
1328        Ltube = Unity(i).Baffles.Lsi+Unity(i).Baffles.Lso+Unity(i).Baffles.Ls*(Nb-1);
1329
1330"Js Factor"     
1331        Unity(i).Shell.HeatTransfer.Js                  =       1;
1332
1333"Ji Factor"
1334        Unity(i).Shell.HeatTransfer.Ji                  =       HE.JiFactor(Unity(i).Shell.HeatTransfer.Re);
1335
1336"Jc Factor"
1337        Unity(i).Shell.HeatTransfer.Jc                  =       HE.JcFactor();
1338       
1339"Jl Factor"
1340        Unity(i).Shell.HeatTransfer.Jl                  =       HE.JlFactor(Unity(i).Shell.HeatTransfer.Sm);
1341
1342"Jb Factor"
1343        Unity(i).Shell.HeatTransfer.Jb                  =       HE.JbFactor(Unity(i).Shell.HeatTransfer.Re,Unity(i).Baffles.Ls,Unity(i).Shell.HeatTransfer.Sm);
1344
1345"Jr Factor"     
1346        Unity(i).Shell.HeatTransfer.Jr                  =       HE.JrFactor(Unity(i).Shell.HeatTransfer.Re);
1347       
1348"Total J Factor"
1349        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;
1350end
1351
1352"Velocity Tube Side Inlet Nozzle"
1353        Unity(Nb+1).Tubes.PressureDrop.Vnozzle_in       = 0;
1354
1355"Velocity Tube Side Outlet Nozzle"
1356        Unity(1).Tubes.PressureDrop.Vnozzle_out = 0;
1357       
1358"Tube Pressure Drop Inlet Nozzle"
1359        Unity(Nb+1).Tubes.PressureDrop.Pdnozzle_in      = 0;
1360
1361"Tube Pressure Drop Outlet Nozzle"
1362        Unity(1).Tubes.PressureDrop.Pdnozzle_out        = 0;
1363
1364"Velocity Shell Side Inlet Nozzle"
1365        Unity(Nb+1).Shell.PressureDrop.Vnozzle_in       = 0;
1366
1367"Velocity Shell Side Outlet Nozzle"
1368        Unity(1).Shell.PressureDrop.Vnozzle_out = 0;
1369       
1370"Shell Pressure Drop Inlet Nozzle"
1371        Unity(Nb+1).Shell.PressureDrop.Pdnozzle_in      = 0;
1372       
1373"Shell Pressure Drop Outlet Nozzle"
1374        Unity(1).Shell.PressureDrop.Pdnozzle_out        = 0;
1375
1376"Shell Cross Flow Pressure Drop"
1377        Unity(1).Shell.PressureDrop.PdCross             = 0;
1378       
1379"Shell Cross Flow Pressure Drop"
1380        Unity(Nb+1).Shell.PressureDrop.PdCross          = 0;
1381       
1382"Shell Side Outlet Nozzle rho-V^2"
1383        Unity(1).Shell.PressureDrop.RVsquare_out = 0;
1384       
1385"Shell Side inlet Nozzle rho-V^2"
1386        Unity(Nb+1).Shell.PressureDrop.RVsquare_in = 0;
1387
1388SET
1389#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
1390#  Set Parameters for heatex Calculation
1391#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
1392        Sumary.Zones        = Nb+1;
1393        Pi                              = 3.14159265;
1394        HE.Tpass                        = Tpass;
1395        HE.Nss                          = Nss;
1396        HE.Ntt                          = Ntt;
1397        HE.Pattern                      = Pattern;
1398        HE.Bc                           = Bc;
1399        HE.Donozzle_Shell       = Donozzle_Shell;
1400        HE.Dinozzle_Shell       = Dinozzle_Shell;
1401        HE.Honozzle_Shell       = Honozzle_Shell;
1402        HE.Hinozzle_Shell       = Hinozzle_Shell;
1403        HE.Donozzle_Tube        = Donozzle_Tube;
1404        HE.Dinozzle_Tube        = Dinozzle_Tube;
1405        HE.Nb                       = Nb;
1406        HE.Dishell                      = Dishell;             
1407        HE.Lcf                          = Lcf; 
1408        HE.pitch                        = pitch;               
1409        HE.Dotube                       = Dotube;       
1410        HE.Ditube                       = Ditube;       
1411        HE.Lcd                          = Lcd;
1412        HE.Ltd                          = Ltd;
1413        side                            = HE.FluidAlocation();
1414end
Note: See TracBrowser for help on using the repository browser.