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
  vec cl;red
  con TFAL y 2 fil;.001
  msg         False-time under-relaxation distribution
  msg Press e to END
  ENDUSE
 
    GROUP 1. Run title
TEXT( SELF-STEERING UNDER-RELAXATION

  DISPLAY 
     The 3D flow in a shell om imaginery heat exchanger is
     simulated. The heat exchanger considered has two baffles
     within the shell.
 
     The self-steering   local  false-time  under-relaxation
     for  the velocities is introduced by PLANTed codings for
     sources as follows:
 
     TYPE is PHASEM, VALue is SAME, CO, which is reciprocal
     of DTFALS, 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.
 
     Interesting variants include comparison of the rate of
     convergence for conventional once-for-all under-ralaxations
     and PLANTed ones for enul=0.0 and enul=1000 as for
     NX*NY*NZ=5*3*8, and for NY=3 and NY=10 as for enul=0.0.
 
     FLO1 = mass-flow rate of shell fluid

  ENDDIS
 
enul=100.;rg(1)=enul
ny=3
 
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
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 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=100
    GROUP 16. Termination of iterations
LITER(P1)=100
 
    GROUP 17. Under-relaxation devices

NAMSAT=MOSG

  PLANTBEGIN
PATCH(RELAX,PHASEM,1,NX,1,NY,1,NZ,1,1)
   CO=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
COVAL(RELAX,U1,GRND,SAME)
   CO=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
COVAL(RELAX,V1,GRND,SAME)
   CO=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
COVAL(RELAX,W1,GRND,SAME)
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)
  PLANTEND

    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.704E+03; EX(U1)=3.000E-01; EX(V1)=2.755E-02
EX(W1)=3.252E-01; EX(TFAL)=2.776E-04
 LIBREF=115
STOP