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
    >>>>>>>>>>>>>>>>>>>>>> Comment begins >>>>>>>>>>>>>>>>>>>>
#cls
  DISPLAY
     This case concerns 3D flow of viscous fluid on the shell side
     of a heat exchanger.
 
     Two types of false-time under-relaxation are provided via 
     PLANT: namely 1. global and 2. local.
 
     For the purpose of illustration, the solution process is 
     divided into 3 stages, as follows:
 
     * No relaxation for             ISWEEP  < 101 ,
     * Global relaxation for         100 < ISWEEP < 201 ,
     * Local relaxation  for         200 < ISWEEP  .
 
    PLANT information :
     * Data input groups used: 17, 19
     * Ground groups planted : 13, 19-2, 19-3
     * Headings used  : SC02??, SC03??, SORC??
     * Functions used : None
     * Commands used  : IF, REGION
  ENDDIS
 
  <<<<<<<<<<<<<<<<<<<<<<< Comment ends <<<<<<<<<<<<<<<<<<<<<
 
   GROUP 1. Run title and other preliminaries
 
TEXT( Global and self-steering under-relaxatn
 
    **  FLO1 = mass-flow rate of shell fluid
REAL(FLO1);FLO1=0.1
   GROUP 3. X-direction grid specification
    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
NY=3
GRDPWR(Y,NY,0.5,1.0)
   GROUP 5. Z-direction grid specification
GRDPWR(Z,8,4.0,1.0)
   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)
STORE(EPOR,NPOR,HPOR)
   GROUP 8. Terms (in differential equations) & devices
TERMS(U1,Y,Y,Y,Y,Y,Y);TERMS(V1,Y,Y,Y,Y,Y,Y)
TERMS(W1,Y,Y,Y,Y,Y,Y)
   GROUP 9. Properties of the medium (or media)
ENUL=10.
   GROUP 11. Initialization of variable or porosity fields
FIINIT(W1)=FLO1;FIINIT(U1)=0.0;FIINIT(V1)=0.0
FIINIT(EPOR)=0.5;FIINIT(NPOR)=0.5;FIINIT(HPOR)=0.5
   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)
    ** 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)
    ** 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 15. Termination of sweeps
LSWEEP=400
   GROUP 16. Termination of iterations
LITER(P1)=100
   GROUP 17. Under-relaxation devices
NAMSAT=MOSG
RG(1)=ENUL

       PLANTBEGIN
    ** Global under-relaxation
    RG(2)=AMIN1(XULAST/FLOAT(NX),YVLAST/FLOAT(NY),$
                                        ZWLAST/FLOAT(NZ))/$
                                       AMAX1(U1,:FLO1:/2.)
    REGION(1,1,2,3,2,2)
    IF(ISWEEP.GT.100.AND.ISWEEP.LE.200)
 
    DTFALS(U1)=RG(2)
    REGION(1,1,1,1,1,1)
    IF(ISWEEP.GT.100.AND.ISWEEP.LE.200)
  >>>>>>>>>>>>>>>>>>>>>> Comment begins >>>>>>>>>>>>>>>>>>>>
     Global under-relaxation  is   introduced   by   PLANTed
     codings  for DTFALS(U1) at the start of each sweep.  It
     is assumed to be equal to  the  smallest  of  the  cell
     sizes  divided  by  the  largest  of  inlet  mass  flux
     velocity and local velocity  magnitude  normal  to  the
     inlet  plane.  It  is applied over the whole domain for
     the velocity in question IF isweep is greater than  100
     but less or equal than 200.
 
    Here and  for  next  two statemnts,  command REGION with
    unity arguments is  used  to  economize  the  operations
    needed for equivalences.
  <<<<<<<<<<<<<<<<<<<<<<< Comment ends <<<<<<<<<<<<<<<<<<<<<
    DTFALS(V1)=RG(2)
    REGION(1,1,1,1,1,1)
    IF(ISWEEP.GT.100.AND.ISWEEP.LE.200)
  >>>>>>>>>>>>>>>>>>>>>> Comment begins >>>>>>>>>>>>>>>>>>>>
    The above  settings do for DTFALS(V1) what has been done
    for DTFALS(U1) above.
  <<<<<<<<<<<<<<<<<<<<<<< Comment ends <<<<<<<<<<<<<<<<<<<<<
    DTFALS(W1)=RG(2)
    REGION(1,1,1,1,1,1)
    IF(ISWEEP.GT.100.AND.ISWEEP.LE.200)
  >>>>>>>>>>>>>>>>>>>>>> Comment begins >>>>>>>>>>>>>>>>>>>>
    The above settings do for DTFALS(W1) what has been  done
    for DTFALS(U1).
  <<<<<<<<<<<<<<<<<<<<<<< Comment ends <<<<<<<<<<<<<<<<<<<<<
    ** Local self-steering under-relaxation
PATCH(RELAX,PHASEM,1,NX,1,NY,1,NZ,1,1)
   CO=1./TFAL
COVAL(RELAX,U1,GRND,SAME)
  IF(ISWEEP.GT.200)
   CO=1./TFAL
COVAL(RELAX,V1,GRND,SAME)
  IF(ISWEEP.GT.200)
   CO=1./TFAL
COVAL(RELAX,W1,GRND,SAME)
  IF(ISWEEP.GT.200)
  >>>>>>>>>>>>>>>>>>>>>> Comment begins >>>>>>>>>>>>>>>>>>>>
     Local self-steering   under-relaxation   is  introduced
     through the sources of momentum for  the  whole  domain
     defined  by  PATCH  named RELAX,  which TYPE is PHASEM,
     VALue is SAME,  COefficient, which is set to reciprocal
     of  false-time  step.  It  is  applied  for  each sweep
     greater than 200.
  <<<<<<<<<<<<<<<<<<<<<<< Comment ends <<<<<<<<<<<<<<<<<<<<<
    ** Local fals-time step
STORE(TFAL);OUTPUT(TFAL,Y,Y,Y,Y,Y,Y)
   TFAL=1/(SQRT(U1**2+W1**2+V1**2)/$
               AMIN1(DXU2D*1,AMIN1(DYV2D*1,DZ*1))+$
               RG(1)/AMIN1(DXU2D*1,AMIN1(DYV2D*1,DZ*1))**2)
  IF(ISWEEP.GT.200)
  >>>>>>>>>>>>>>>>>>>>>> Comment begins >>>>>>>>>>>>>>>>>>>>
 
     The reciprocal of local self-steering  false-time  step
     is  set  to the local velocity vector magnitude divided
     by smallest distance between walls of  continuity  cell
     in  question plus local diffusivities,  i.e.  kinematic
     viscosities, divided by the smallest distance squarred.
 
     The variable TFAL,  false-time,  is provided to  assist
     the  computations.  It is calculated right at the start
     of each IZ-slab for all sweeps greter than 200 and  can
     be used to monitor the variation of local magnitudes of
     false-time steps.
 
   <<<<<<<<<<<<<<<<<<<<<<< Comment ends <<<<<<<<<<<<<<<<<<<<<
    PLANTEND
 
    GROUP 19. Data communicated by satellite to GROUND
    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)
 
    GROUP 22. Spot-value print-out
IXMON=NX-2;IYMON=2;IZMON=4
    GROUP 23. Field print-out and plot control
IPLTL=LSWEEP;IPROF=1;ORSIZ=0.4;XZPR=T;NPLT=1
TSTSWP=-1
dmpstk=t
DISTIL=T
EX(P1)=3.711E+02; EX(U1)=3.000E-01; EX(V1)=2.753E-02
EX(W1)=3.253E-01; EX(TFAL)=2.757E-03
 LIBREF=613
STOP