#cls
text(USP 2D UNSTEADY DIFFUSION PROBLEM
title
  DISPLAY
  
  This case solves a two-dimensional transient diffusion problem
  with time-dependen boundary conditions.

  The analytical solution is: TEM1 = X + Y + T ,
    where X and Y are cartesian coordinates and T is time.
 
  The TEM1 computed by PHOENICS, the exact solution is EXAC.

  The Q1 contains PHOTON USE commands
  ENDDIS  
  PHOTON USE
  p;;;;;
 
  con tem1 z 1 fi;0.01
  msg             Numerical solution  contours
  msg  Press Enter to continue
  pause;cl
  con exac z 1 fi;0.01
  msg             Exact solution  contours
  ENDUSE
TEXT(USP 2D UNSTEADY DIFFUSION PROBLEM
NX=10;NY=10;LSTEP=5
    GROUP 2. Transience; time-step specification
STEADY=F;GRDPWR(T,LSTEP,1.,1.0)
    GROUP 3. X-direction grid specification
GRDPWR(X,NX,1,1.0)
    GROUP 4. Y-direction grid specification
GRDPWR(Y,NY,1,1.0)
    GROUP 7. Variables stored, solved & named
SOLVE(TEM1);STORE(EXAC)
    GROUP 8. Terms (in differential equations) & devices
TERMS(TEM1,N,N,Y,P,P,P)
    GROUP 9. Properties of the medium (or media)
PRNDTL(TEM1)=1.0;ENUL=1.0
    GROUP 11. Initial values
REAL(TCOR,XCOR,YCOR,DTC,DXC,DYC)
DTC=TLAST/LSTEP
DXC=XULAST/NX
DYC=YVLAST/NY

     USP related parameters
USP    = T
UAUTO  = F
USPDBG = F
UTCPLT = T
USPIMB = F
MXLEV  = 4 
MYLEV  = 4 
MZLEV  = 4
DOMAT  = -1
MINPRP = -1
MAXPRP = 250
CELLST = 10
FACEST = 10
USPREL = 0.7

  Following commands set the initial field as.. TEM1 = X + Y
DO II=1,NX
 XCOR=0.5*DXC+(II-1)*DXC
 DO JJ=1,NY
+ YCOR=0.5*DYC+(JJ-1)*DYC
+ PATCH(I:II:I:JJ:,INIVAL,:II:,:II:,:JJ:,:JJ:,1,NZ,1,1)
+ INIT(I:II:I:JJ:,TEM1,0.0,XCOR+YCOR)
+ INIT(I:II:I:JJ:,EXAC,0.0,XCOR+YCOR+TLAST)
 ENDDO
ENDDO
 
    GROUP 13. Boundary conditions and special sources
  Following commands set the west values as.. TEM1 = T + Y
DO II=1,LSTEP
 TCOR=II*DTC
 DO JJ=1,NY
+ YCOR=0.5*DYC+(JJ-1)*DYC
+ PATCH(W:II:W:JJ:,WWALL,1,1,:JJ:,:JJ:,1,NZ,:II:,:II:)
+ COVAL(W:II:W:JJ:,TEM1,1.,TCOR+YCOR)
 ENDDO
ENDDO
 
  Following commands set the east values as.. TEM1 = T + 1 + Y
DO II=1,LSTEP
 TCOR=II*DTC
 DO JJ=1,NY
+ YCOR=0.5*DYC+(JJ-1)*DYC
+ PATCH(E:II:E:JJ:,EWALL,NX,NX,:JJ:,:JJ:,1,NZ,:II:,:II:)
+ COVAL(E:II:E:JJ:,TEM1,1.,TCOR+1.0+YCOR)
 ENDDO
ENDDO
 
  Following commands set south values as.. TEM1 = T + X
DO II=1,LSTEP
 TCOR=II*DTC
 DO JJ=1,NX
+ XCOR=0.5*DXC+(JJ-1)*DXC
+ PATCH(S:II:S:JJ:,SWALL,:JJ:,:JJ:,1,1,1,NZ,:II:,:II:)
+ COVAL(S:II:S:JJ:,TEM1,1.,TCOR+XCOR)
 ENDDO
ENDDO
 
  Following commands set north values as.. TEM1 = T + 1 + X
DO II=1,LSTEP
 TCOR=II*DTC
 DO JJ=1,NX
+ XCOR=0.5*DXC+(JJ-1)*DXC
+ PATCH(N:II:N:JJ:,NWALL,:JJ:,:JJ:,NY,NY,1,NZ,:II:,:II:)
+ COVAL(N:II:N:JJ:,TEM1,1.,TCOR+1.+XCOR)
 ENDDO     
ENDDO
 
  Following commands set the volumetric source as.. 1
PATCH(SOURC,VOLUME,1,NX,1,NY,1,NZ,1,LSTEP)
COVAL(SOURC,TEM1,FIXFLU,1.0)

    GROUP 15. Termination of sweeps
LITER(TEM1)=20
ENDIT(TEM1)=1.e-5
RESFAC=1.E-7
LSWEEP=5
    GROUP 21. Print-out of variables
IXMON=NX/2;IYMON=NY/2
OUTPUT(TEM1,Y,Y,Y,Y,Y,Y)
    GROUP 24. Dumps for restarts
dmpstk=t
DISTIL=T
EX(TEM1)=2.000E+00; EX(EXAC)=2.000E+00
STOP