```

PHOTON USE
p

up 1 0 0;vi 0.5 1 0.75
gr ou x 1;gr ou y 1;gr ou z 1
gr ou x m;gr ou y m;gr ou z m
gr ou x 1 y 1 2 z 2 2 col 2
gr ou x 6 y 1 2 z 7 7 col 2
gr ou z 4 x 1 4 y 1 3 col 6
gr ou z 6 x 2 5 y 1 3 col 6
ve y 2 sh

msg                3D SHELL-AND-TUBE HEAT EXCHANGER
msg                --------------------------------
msg                    Velocity 1 phase:
msg  Press Enter to continue
pause;vi 0 1 0
msg                3D SHELL-AND-TUBE HEAT EXCHANGER
msg                --------------------------------
msg              Temperature distribution 1 phase:
con 1sth y 2 sh;in 50
msg  Press Enter to continue
pause
con off;red
msg                3D SHELL-AND-TUBE HEAT EXCHANGER
msg                --------------------------------
msg              Temperature distribution 2 phase:
con 2ndh y 2 sh;in 50
msg Press e to END
ENDUSE

GROUP 1. Run title
TEXT(3D SHELL-AND-TUBE HEAT EXCHANGER:135

DISPLAY
The heat exchanger considered has two baffles within
the shell and the tubes arranged if five passes.
The overall heat transfer coefficient depends on the
local velocity and  the resistance to flow exerted by
tubes depends on the flow direction, on the local
velocities and Reynolds numbers. They are introduced
by PLANT.
ENDDIS
=====================
REAL(T1IN,T2IN,FLO1,FLO2)
T1IN=1.0;T2IN=0.0;FLO1=0.1;FLO2=0.1

The heat exchanger is a rectangular box, 1m high,
1m wide and 4m long. A uniform 5*3*8 grid is used,
as was done by Patankar and Spalding.

Only one half of the exchanger is included in the
calculation domain, because of the symmetry of the
geometry.

GRDPWR(X,5,1.0,1.0)
GROUP 4. Y-direction grid specification
GRDPWR(Y,3,0.5,1.0)
GROUP 5. Z-direction grid specification
GRDPWR(Z,8,4.0,1.0)

GROUP 6. Body-fitted coordinates or grid distortion
GROUP 7. Variables stored, solved & named

The shell-side fluid is a single-phase one, for which
five variables must be solved; only the enthalpy needs
be computed for the tube-side fluid.

SOLVE(P1,U1,V1,W1,H1,H2)
NAME(H1)=1STH;NAME(H2)=2NDH
STORE(EPOR,NPOR,HPOR)

GROUP 8. Terms (in differential equations) & devices

The "diffusion" terms are cut out for all vaiables, and
the built-in sources for the enthalpies.

TERMS(U1,Y,Y,N,Y,Y,Y);TERMS(V1,Y,Y,N,Y,Y,Y)
TERMS(W1,Y,Y,N,Y,Y,Y);TERMS(1STH,N,Y,N,Y,Y,Y)
TERMS(2NDH,N,N,N,Y,N,N)
GROUP 9. Properties of the medium (or media)
GROUP 10. Inter-phase-transfer processes and properties
GROUP 11. Initialization of variable or porosity fields
FIINIT(W1)=FLO1;FIINIT(U1)=0.0;FIINIT(V1)=0.0
FIINIT(1STH)=T1IN;FIINIT(2NDH)=T2IN
FIINIT(EPOR)=0.5;FIINIT(NPOR)=0.5;FIINIT(HPOR)=0.5
GROUP 12. Convection and diffusion adjustments
GROUP 13. Boundary conditions and special sources

West boundary; shell fluid inlet ; 2 cells in west wall
PATCH(INLET1,CELL,1,1,2,3,2,2,1,1000)
COVAL(INLET1,P1,FIXFLU,FLO1/2.0)
COVAL(INLET1,1STH,ONLYMS,T1IN)
COVAL(INLET1,2NDH,ONLYMS,SAME)

East boundary; shell fluid outlet; 2 cells in east wall
PATCH(OUTLET1,EAST,NX,NX,2,3,NZ-1,NZ-1,1,1000)
COVAL(OUTLET1,P1,FIXP,0.0)

High boundary, tube fluid inlet; 5 cells in high wall
PATCH(INLET2,CELL,1,1,1,NY,NZ,NZ,1,1000)
COVAL(INLET2,2NDH,FLO2/3.0,T2IN)

Note how the giving of special names to patches,
beginning NE (for neighbour), coupled with LOCNE (GRND8) in
the "value" location, produces sources which simulate along-
the-tube convection fluid-to-metal heat transfer etc,
by activating special calls to GROUND, the relevant
extract from which appears in an appendix to this file.

Flow of tube fluid in first pass
PATCH(NEH1,CELL,1,1,1,NY,1,NZ-1,1,1000)
COVAL(NEH1,2NDH,FLO2/3.0,LOCNE)

Flow of tube fluid in first bend
PATCH(NEW1,CELL,2,2,1,NY,1,1,1,1000)
COVAL(NEW1,2NDH,FLO2/3.0,LOCNE)

Flow of tube fluid in second pass
PATCH(NEL1,CELL,2,2,1,NY,2,NZ,1,1000)
COVAL(NEL1,2NDH,FLO2/3.0,LOCNE)

Flow of tube fluid in second bend
PATCH(NEW2,CELL,3,3,1,NY,NZ,NZ,1,1000)
COVAL(NEW2,2NDH,FLO2/3.0,LOCNE)

Flow of tube fluid in third pass
PATCH(NEH2,CELL,3,3,1,NY,1,NZ-1,1,1000)
COVAL(NEH2,2NDH,FLO2/3.0,LOCNE)

Flow of tube fluid in third bend
PATCH(NEW3,CELL,4,4,1,NY,1,1,1,1000)
COVAL(NEW3,2NDH,FLO2/3.0,LOCNE)

Flow of tube fluid in fourth pass
PATCH(NEL2,CELL,4,4,1,NY,2,NZ,1,1000)
COVAL(NEL2,2NDH,FLO2/3.0,LOCNE)

Flow of tube fluid in fourth bend
PATCH(NEW4,CELL,NX,NX,1,NY,NZ,NZ,1,1000)
COVAL(NEW4,2NDH,FLO2/3.0,LOCNE)

Flow of tube fluid in fifth pass
PATCH(NEH3,CELL,NX,NX,1,NY,1,NZ-1,1,1000)
COVAL(NEH3,2NDH,FLO2/3.0,LOCNE)

PLANTBEGIN
Heat-exchange with tube fluid, throughout the exchanger.
PATCH(HEX,VOLUME,1,NX,1,NY,1,NZ,1,1000)
CO=0.2*(U1**2+V1**2+W1**2)**0.25
VAL=2NDH
COVAL(HEX,1STH,GRND,GRND)
Heat-exchange with shell fluid, throughout the exchanger.
CO=0.2*(U1**2+W1**2+V1**2)**0.25
VAL=1STH
COVAL(HEX,2NDH,GRND,GRND)
Resistance to flow exerted by tubes, throughout the shell.
PATCH(RESIST,PHASEM,1,NX,1,NY,1,NZ,1,1000)
VAL=-0.01*(U1**2+W1**2+V1**2)**1.85
COVAL(RESIST,U1,FIXFLU,GRND)
VAL=-0.01*(U1**2+W1**2+V1**2)**1.85
COVAL(RESIST,V1,FIXFLU,GRND)
CO=0.02*(U1**2+W1**2+V1**2)**0.8
COVAL(RESIST,W1,GRND,0.0)
PLANTEND

Baffle 1 at NZ=3
PATCH(BAFFLE1,HIGH,1,NX-1,1,NY,3,3,1,1000)
COVAL(BAFFLE1,W1,FIXVAL,0.0)

Baffle 2 at NZ=5
PATCH(BAFFLE2,HIGH,2,NX,1,NY,5,5,1,1000)
COVAL(BAFFLE2,W1,FIXVAL,0.0)

GROUP 14. Downstream pressure for PARAB=.TRUE.
GROUP 15. Termination of sweeps
LSWEEP=270
GROUP 16. Termination of iterations
LITER(P1)=10
GROUP 17. Under-relaxation devices
RELAX(U1,FALSDT,1.0);RELAX(V1,FALSDT,1.0)
RELAX(W1,FALSDT,1.0)
RELAX(1STH,FALSDT,100.0);RELAX(2NDH,FALSDT,100.0)

GROUP 18. Limits on variables or increments to them
GROUP 19. Data communicated by satellite to GROUND
NAMSAT=MOSG
GROUP 20. Preliminary print-out
GROUP 21. Print-out of variables
Print-out of porosities is suppressed.
OUTPUT(EPOR,N,N,N,N,N,N);OUTPUT(NPOR,N,N,N,N,N,N)
OUTPUT(HPOR,N,N,N,N,N,N)
OUTPUT(1STH,N,N,Y,Y,Y,Y);OUTPUT(2NDH,N,N,Y,Y,Y,Y)

GROUP 22. Spot-value print-out
IXMON=6;IYMON=6;TSTSWP=5
GROUP 23. Field print-out and plot control
IPLTL=LSWEEP;IPROF=1;ORSIZ=0.4;XZPR=T;NPLT=1

PATCH(PASS1,PROFIL,1,1,2,2,1,NZ,1,1000)
PLOT(PASS1,1STH,T2IN,T1IN);PLOT(PASS1,2NDH,T2IN,T1IN)

PATCH(PASS2,PROFIL,2,2,2,2,1,NZ,1,1000)
PLOT(PASS2,1STH,T2IN,T1IN);PLOT(PASS2,2NDH,T2IN,T1IN)

PATCH(PASS3,PROFIL,3,3,2,2,1,NZ,1,1000)
PLOT(PASS3,1STH,T2IN,T1IN);PLOT(PASS3,2NDH,T2IN,T1IN)

PATCH(PASS4,PROFIL,4,4,2,2,1,NZ,1,1000)
PLOT(PASS4,1STH,T2IN,T1IN);PLOT(PASS4,2NDH,T2IN,T1IN)

PATCH(PASS5,PROFIL,5,5,2,2,1,NZ,1,1000)
PLOT(PASS5,1STH,T2IN,T1IN);PLOT(PASS5,2NDH,T2IN,T1IN)

tstswp=-1
dmpstk=t
DISTIL=T
EX(P1)=5.331E+00; EX(U1)=4.051E-01; EX(V1)=5.103E-02
EX(W1)=5.309E-01; EX(1STH)=5.923E-01; EX(2NDH)=4.084E-01
LIBREF=135
STOP
```