TALK=f;RUN(1,1) 
  DISPLAY
  Heat exchanger with stress
  ENDDIS

  PHOTON USE
  extrapolate nolim
  phi                                                                        
  10 1
                                                                              
  set prop off 
  vi 1 1 1

  gr x 1 y 1 40
  gr ou y 40

  msg radial dimension enlarged *10 
  msg pressure contours
  msg flow directions
  msg inner:
  msg  right to left
  msg outer:
  msg  left to right

  con p1 z 1 y 1 10 fi;0.001  
  con p1 z 1 y 21 30 fi;0.001                                                          
  con p1 z m y 1 10 fi;0.001
  con p1 z m y 21 30 fi;0.001
  *dump tubep1                                                           

  pause;con off; red

  msg temperature contours
  con tem1 z 1 y 1 40 fi;0.001                                                           
  con tem1 z m y 1 40 fi;0.001
  *dump tubetem1                                                           

  pause;con off; red

  msg radial strain contours                                                                        
  con epsy z 1 y 11 20 fi;0.001 
  con epsy z 1 y 31 40 fi;0.001                                                            
  con epsy z m y 11 20 fi;0.001 
  con epsy z m y 31 40 fi;0.001                                                            
  *dump tubeepsy 
 
  pause;con off;red 
                                                                
  msg radial stress contours                                                                        
  con stry z 1 y 11 20 fi;0.001      
  con stry z 1 y 31 40 fi;0.001                                                     
  con stry z m y 11 20 fi;0.001      
  con stry z m y 31 40 fi;0.001                                                     
  *dump tubestry
  
  pause;con off;red                                                                   

  msg circumferential strain contours                                                                        
  con epsx z 1 y 11 20 fi;0.001  
  con epsx z 1 y 31 40 fi;0.001  
  con epsx z m y 11 20 fi;0.001  
  con epsx z m y 31 40 fi;0.001     
  *dump tubeepsx 

  * pause;con off;red                                                                    
  * msg circumferential stress contours      
  * con strx z 1 fi;0.001                                                           
  * pause                                                                   
  * axial strain contours                                                                        
  * con epsz z 1 fi;0.001      

  pause;con off;red                                                                   

  msg  axial stress contours                                                                        
  con strz z 1 y 11 20 fi;0.001                                                           
  con strz z 1 y 31 40 fi;0.001
  con strz z m y 11 20 fi;0.001
  con strz z m y 31 40 fi;0.001
  *dump tubestrz
  ENDUSE

Text(heat exchanger with stress
TITLE

integer(caseNO)
label ask
mesg(:title:
mesg( Variant of calculation:
mesg( caseno=1 : Staggered DM model 
mesg( caseno=2 :  Collocated DM model      
mesg(Enter 1, 2 or blank (default = 1)
readvdu(caseno,int,1)
if(caseno.lt.1) then
 goto ask
endif  
if(caseno.gt.2) then
 goto ask
endif 
caseno


  ******************************
  ***** Logical Flags **********
  ******************************  
cartes=f
boolean(axisym)
stra=t
axisym=t

  ******************************
     grid settings
  ******************************
 nx=12;nz=12
integer(nytu,nyin,nysh,nyou)  ! in denotes inner solid, ou outer solid
 nytu=10;nysh=10;nyin=10;nyou=10
integer(iy1,iy2)           ! integers and reals
real(rad1,rad2,rad3,rad4,rhotu,rhosh,inveltu,invelsh,prpstu,prpssh)
 rad1=0.03 ;rad2=0.04 ;rad3=0.06 ;rad4=0.08 ;yvlast=0.09

 inveltu = 1.e0
 invelsh = 1.e0
 
 prpssh=66; rhosh=1.353e4
 prpstu=67; rhotu=998.23

  ****************************************************
   <66 >   Mercury at 27. deg C
  66    1.353E4    1.125E-7   139.3     8.54    1.8E-4   
   <65 >   Glycerin at 27. deg C    ! these lines as reminder of what is in props
  65    1259.0     6.34E-4   2427.0    0.286    4.7E-4
   <67 >   WATER at 20. deg C
  67    998.23    1.006E-6   4181.8    0.597    1.18E-4
  ****************************************************


  ******************************
     Boundary values
  ******************************
real(intemtu,intemsh,pretuou,preshou,presurr,gravfac)
intemtu=20               ! tube inlet temperature
intemsh=80               ! shell inlet temperature 

preshou=1.e6
pretuou=1.e7

     preshou=0.0
     pretuou=0.0
presurr=1.e0
 
gravfac=100.0
if(axisym) then
 gravfac=0.0001
endif


  ***********************************************
  GROUP 3. X-direction grid specification 
  ***********************************************
 xulast=3.1415
 grdpwr(x,nx,xulast,1.0)

  ***********************************************
  GROUP 4. Y-direction grid specification
  ***********************************************
 ny=nytu + nyin + nysh + nyou + 1
 NREGY=5                              ! 5 regions
 IREGY=1;GRDPWR(Y,nytu,rad1,1.0)           ! inner pipe
 IREGY=2;GRDPWR(Y,nyin,Rad2-Rad1,1.0)        ! inner-pipe wall
 IREGY=3;GRDPWR(Y,nysh,rad3-rad2,1.0)        ! outer annulus 
 IREGY=4;GRDPWR(Y,nyou,rad4-rad3,1.0)        ! outer annulus wall 
 IREGY=5;GRDPWR(Y,1,0.001,1.0)               ! surrounding air
 
 
 integer(iyinf,iyouf,iyinl,iyoul)      !     iyoul
 integer(iyshf,iyshl)                  !            nyou
                                            iyouf
 iyinf=nytu+1; iyinl=nytu+nyin         !     iyshl
 iyshf=iyinl+1                         !            nysh
 iyshl=iyinl+nysh                      !     iyshf
 iyouf=iyshl+1; iyoul=iyshl+nyou       !     iyinl       
 nytu                                  !            nyin 
 iyinf                                 !     iyinf       
 iyinl                                 !     nytu       
 iyshf                                 !            nytu 
 iyshl
 iyouf
 iyoul

  ***********************************************
  GROUP 5. Z-direction grid specification 
  ***********************************************
 zwlast=1.0
 grdpwr(z,nz,zwlast,yvlast*20)

  ***********************************************
  GROUP 7. Variables stored, solved & named 
  ***********************************************
solve(p1,u1,v1,w1,tem1)
solutn(p1,y,y,y,p,p,p)
solutn(u1,y,y,y,p,p,p)
solutn(v1,y,y,y,p,p,p)
solutn(w1,y,y,y,p,p,p)
solutn(tem1,y,y,y,p,p,p)

if(caseNO.EQ.2.AND.STRA) then
 SOLVE(DISX,DISY,DISZ)
    SOLUTN(DISZ,Y,Y,N,N,N,N)      ! Slab
    SOLUTN(DISY,Y,Y,N,N,N,N)
    SOLUTN(DISX,Y,Y,N,N,N,N)
 TERMS (DISX  ,N,N,Y,N,Y,N)
 TERMS (DISY  ,N,N,Y,N,Y,N)
 TERMS (DISZ  ,N,N,Y,N,Y,N)
endif


store(prps,rho1,drh1,dvo1,enut,kond)

  ! for stress analysis
store(epsx,epsy,epsz,strx,stry,strz)
store(enul,drh1,dvo1,epst)
  ! end of stress analysis

  ***********************************************
  GROUP 9. Properties of the medium (or media)  
  ***********************************************
turmod(lvel)

  ***********************************************
   Group 11  initial conditions
  ***********************************************
fiinit(drh1)=0.0
fiinit(p1)=0.0
fiinit(u1)=0.0
fiinit(v1)=0.0
fiinit(w1)=0.0

if(caseNO.EQ.2.AND.STRA) then
fiinit(DISX)=0.0
fiinit(DISY)=0.0
fiinit(DISZ)=0.0
endif

  
  ! initial values, which define the geometry via prps 

patch(outerair,inival,1,nx,iyoul+1,ny,1,nz,1,1)
coval(outerair,prps,0.0,0.0)
coval(outerair,p1,0.0,presurr)
coval(outerair,u1,0.0,0.0)
coval(outerair,v1,0.0,0.0)
coval(outerair,w1,0.0,0.0)

patch(outersur,inival,1,nx,iyoul,iyoul,1,nz,1,1)
coval(outersur,tem1,1.e6,20.0)

patch(tube,inival,1,nx,1,nytu,1,nz,1,1)
coval(tube,prps,0.0,prpstu)
coval(tube,u1,0.0,0.0)
coval(tube,v1,0.0,0.0)
coval(tube,w1,0.0,inveltu)
coval(tube,rho1,0.0,rhotu)
coval(tube,p1,0.0,pretuou)
coval(tube,tem1,0.0,intemtu)


patch(innersol,inival,1,nx,iyinf,iyinl,1,nz,1,1)
coval(innersol,prps,0.0,100)
coval(innersol,rho1,0.0,2700)
coval(innersol,tem1,0.0,20)

patch(shell,inival,1,nx,iyshf,iyshl,1,nz,1,1)
coval(shell,prps,0.0,prpssh)
coval(shell,u1,0.0,0.0)
coval(shell,v1,0.0,0.0)
coval(shell,w1,0.0,-invelsh)
coval(shell,rho1,0.0,rhosh)
coval(shell,p1,0.0,preshou)
coval(shell,tem1,0.0,intemsh)


patch(outersol,inival,1,nx,iyouf,iyoul,1,nz,1,1)
coval(outersol,prps,0.0,100)
coval(outersol,rho1,0.0,2700)
coval(outersol,tem1,0.0,20)


patch(outerair,inival,1,nx,iyoul+1,ny,1,nz,1,1)
coval(outerair,prps,0.0,0.0)

  ***********************************************
     Group 13  Boundary conditions
  ***********************************************

  ! **** Surrounding air ****
patch(outside,north,1,nx,ny,ny,1,nz,1,1)  
coval(outside,p1,fixval,presurr)
coval(outside,u1,fixval,0.0)
coval(outside,v1,fixval,0.0)
coval(outside,w1,fixval,0.0)
coval(outside,tem1,fixval,intemtu)

patch(outsurf,north,1,nx,ny-1,ny-1,1,nz,1,1)
if(axisym) then
 (source of tem1 at outsurf is coval(fixval,40))
else
 (source of tem1 at outsurf is coval(fixval,50-30*ix/nx)) ! a source of asymmetry
endif

  ! **** inlet and outlet boundary conditions ***
patch(tubein,low,1,nx,1,nytu,1,1,1,1)
coval(tubein,p1,fixflu,rhotu*inveltu)
coval(tubein,w1,onlyms,inveltu)
coval(tubein,tem1,onlyms,intemtu)

patch(shellin,high,1,nx,iyshf,iyshl,nz,nz,1,1)
coval(shellin,p1,fixflu,rhosh*invelsh)
coval(shellin,w1,onlyms,-invelsh)
coval(shellin,tem1,onlyms,intemsh)

patch(shellou,low,1,nx,iyshf,iyshl,1,1,1,1)
   coval(shellou,p1,1.0,preshou)
coval(shellou,p1,1.0e3,preshou)

  ! **** Symmetry plane ***
patch(BegTube,WWALL,1,1,1,nytu,1,nz,1,1)
coval(BegTube,U1,1.0,0.0)
patch(EndTube,NWALL,nx-1,nx-1,1,nytu,1,nz,1,1)
coval(EndTube,U1,1.0,0.0)

patch(BegShell,WWALL,1,1,iyshf,iyshl,1,nz,1,1)
coval(BegShell,U1,1.0,0.0)
patch(EndShell,NWALL,nx-1,nx-1,iyshf,iyshl,1,nz,1,1)
coval(EndShell,U1,1.0,0.0)



  ! for stress analysis

if(stra.and.caseno.eq.2) then
 patch(lozendin,LWALL,1,nx,iyinf,iyinl,1,1,1,1)  ! low z end of inner tube
 coval(lozendin,DISX,1.0,0.0)  
 coval(lozendin,DISZ,1.0,0.0)  
 
 patch(hizendin,HWALL,1,nx,iyinf,iyinl,nz,nz,1,1)  ! high z end of inner tube
 coval(hizendin,DISX,1.0,0.0)  
 coval(hizendin,DISZ,1.0,0.0)  

 patch(XBegIn,WWALL,1,1,iyinf,iyinl,1,nz,1,1)
 coval(XBegIn,DISX,1.0,0.0)  
 patch(XEndIn,EWALL,nx,nx,iyinf,iyinl,1,nz,1,1)
 coval(XEndIn,DISX,1.0,0.0)  


 patch(lozendou,LWALL,1,nx,iyouf,iyoul,1,1,1,1)  ! low z end of outer tube
 coval(lozendou,DISX,1.0,0.0)  
 coval(lozendou,DISZ,1.0,0.0)  
 
 patch(hizendou,HWALL,1,nx,iyouf,iyoul,nz-1,nz-1,1,1)  ! high z end of outer tube
 coval(hizendou,DISX,1.0,0.0)  
 coval(hizendou,DISZ,1.0,0.0)  
 
 patch(XBegOu,WWALL,1,1,iyouf,iyoul,1,nz,1,1)
 coval(XBegOu,DISX,1.0,0.0)  
 patch(XEndOu,EWALL,nx,nx,iyouf,iyoul,1,nz,1,1)
 coval(XEndOu,DISX,1.0,0.0)  
endif

if(stra.and.caseno.eq.1) then
 patch(lozendin,cell,1,nx,iyinf,iyinl,1,1,1,1)  ! low z end of inner tube
 coval(lozendin,u1,1.e6,0.0)  
 coval(lozendin,w1,1.e6,0.0)  
 
 patch(hizendin,cell,1,nx,iyinf,iyinl,nz-1,nz-1,1,1)  ! high z end of inner tube
 coval(hizendin,u1,1.e6,0.0)  
 coval(hizendin,w1,1.e6,0.0)  

 patch(XBegIn,cell,1,1,iyinf,iyinl,1,nz,1,1)
 coval(XBegIn,u1,1.e6,0.0)  
 patch(XEndIn,cell,nx-1,nx-1,iyinf,iyinl,1,nz,1,1)
 coval(XEndIn,u1,1.e6,0.0)  


 patch(lozendou,cell,1,nx,iyouf,iyoul,1,1,1,1)  ! low z end of outer tube
 coval(lozendou,u1,1.e6,0.0)  
 coval(lozendou,w1,1.e6,0.0)  
 
 patch(hizendou,cell,1,nx,iyouf,iyoul,nz-1,nz-1,1,1)  ! high z end of outer tube
 coval(hizendou,u1,1.e6,0.0)  
 coval(hizendou,w1,1.e6,0.0)  
 
 patch(XBegOu,cell,1,1,iyouf,iyoul,1,nz,1,1)
 coval(XBegOu,u1,1.e6,0.0)  
 patch(XEndOu,cell,nx-1,nx-1,iyouf,iyoul,1,nz,1,1)
 coval(XEndOu,u1,1.e6,0.0)  
endif
 
 PATCH(BUOYtu,PHASEM, 1,NX, 1,Nytu, 1,NZ,1,LSTEP)
 COVAL (BUOYtu,U1  , FIXFLU      , GRND3       )  ! boussinesq
 COVAL (BUOYtu,V1  , FIXFLU      , GRND3       )
 BUOYA   = 0.000000E+00 ;
 BUOYB   = - 9.810000E+00 *gravfac 


 iy1=nytu+nyin+1
 iy2=nytu+nyin+nysh
 PATCH(BUOYsh,PHASEM, 1,NX, iy1,iy2, 1,NZ,1,LSTEP)
 COVAL (BUOYsh,U1  , FIXFLU      , GRND3       )  ! boussinesq
 COVAL (BUOYsh,V1  , FIXFLU      , GRND3       )
 BUOYA   = 0.000000E+00 ;
 BUOYB   = - 9.810000E+00 *gravfac

  ***********************************************
  GROUP 19 Data communicated by satellite to GROUND 
  ***********************************************

  ***********************************************
  GROUP 15. Termination of sweeps 
  GROUP 16. Termination of iterations 
  ***********************************************
 liter(p1)=100
 resref(tem1)=0.0
 liter(tem1)=100
 lsweep=200
 isg21=lsweep  

  ***********************************************
  GROUP 17. Under-relaxation devices 
  GROUP 18. Limits on variables or increments to them 
  ***********************************************
varmax(tem1)=123
varmin(tem1)=-.123
relax(u1,falsdt,1.e-2)
relax(v1,falsdt,1.e-2)
relax(w1,falsdt,1.e-2)

resfac=0
resref(p1)=0.0
resref(u1)=0.0
resref(v1)=0.0
resref(w1)=0.0

conwiz=f   ! conwiz=t leads to an inferior fluid-flow field. I particular, 
           ! u1s are not as close to zero as they sgould be for the axisym
           ! case with stra=f 
#maxabs
#endpause
  adddif=t           ! important for convergence at low RE
diswal             ! important for convergence at low RE
tstswp=-1
  
  ***********************************************
  GROUP 23. Field print-out and plot control 
  GROUP 24. Dumps for restarts STOP 
  ***********************************************
 yzpr=t
 nyprin=1
 NXPRIN=3 
 NZPRIN=3 



     restrt(all)

stop