PHOTON USE
  p
 
 

 
  gr ou z 1
  msg           Temperature contours
  msg           (Numerical solution)
  con h1 z 1 fi;0.001
  msg Press Enter to continue
  pause
  con off;red
  con exac z 1 fi;0.001
  msg           Temperature contours
  msg             (Exact solution)
  msg Press e to END
  ENDUSE
 
    GROUP 1. Run title and other preliminaries
#cls
TEXT(2D HEAT CONDUCTION WITH SPACE DEPENDENT SOURCE:117
title
libref
  DISPLAY 
    PLANT solves a two-dimensional steady diffusion problem  with  
    space-dependent  source and boundary conditions.  
    It can be tested against exact solution  fields.  

    Governing equation:
    d(dT/dX)/dX + d(dT/dX)/dX +  S(X,Y)  =  0
    S(X,Y)  =  2.sinX.sinY
    Boundary  conditions:
    Y = 0 ;  T = 0
    Y = 1 ;  T = sin1.sinX
    X = 0 ;  T = 0
    X = 1 ;  T = sin1.sinY
    Exact solution:
    T(X,Y) = sinX.sinY
    
    
  ENDDIS
REAL(XLENGTH,YLENGTH)
XLENGTH=1.0;YLENGTH=1.0
NX=25;NY=25
    GROUP 3. X-direction grid specification
GRDPWR(X,NX,XLENGTH,1.0)
    GROUP 4. Y-direction grid specification
GRDPWR(Y,NY,YLENGTH,1.0)
    GROUP 7. Variables stored, solved & named
SOLVE(H1)
    GROUP 8. Terms (in differential equations) & devices
   **For pure conduction, cut out built-in source and convection
     terms
TERMS(H1,N,N,Y,N,Y,Y)
    GROUP 9. Properties of the medium (or media)
PRNDTL(H1)=1;ENUL=1.
    GROUP 13. Boundary conditions and special sources
   ** H1=0 at IX=0
PATCH(XEQ0,WWALL,1,1,1,NY,1,1,1,1)
    * Fix temperature to zero
COVAL(XEQ0,H1,1./PRNDTL(H1),0.0)
   ** H1=0 at IY=0
PATCH(YEQ0,SWALL,1,NX,1,1,1,1,1,1)
    * Fix temperature to zero
COVAL(YEQ0,H1,1./PRNDTL(H1),0.0)

  PLANTBEGIN
   ** H1=sin1.sinX at Y=1
PATCH(YEQ1,NWALL,1,NX,NY,NY,1,1,1,1)
    VAL=SIN(1.)*SIN(XG2D)
COVAL(YEQ1,H1,1./PRNDTL(H1),GRND)
   ** H1=sin1.sinY at X=1
PATCH(XEQ1,EWALL,NX,NX,1,NY,1,1,1,1)
    VAL=SIN(1.)*SIN(YG2D)
COVAL(XEQ1,H1,1./PRNDTL(H1),GRND)
   ** Space dependent source
PATCH(SOURCE,VOLUME,1,NX,1,NY,1,1,1,1)
    VAL=2.*SIN(XG2D)*SIN(YG2D)
COVAL(SOURCE,H1,FIXFLU,GRND)

STORE(EXAC)
    EXAC=SIN(XG2D)*SIN(YG2D)
  PLANTEND

    GROUP 15. Termination of sweeps
LSWEEP=10
    GROUP 19.
NAMSAT=MOSG
    GROUP 20. Preliminary print-out
    GROUP 21. Print-out of variables
OUTPUT(h1,Y,Y,Y,Y,Y,Y)
    GROUP 22. Spot-value print-out
IXMON=NX/2+1;IYMON=NY/2+1;IZMON=NZ/2+1
    GROUP 23. Field print-out and plot control
NXPRIN=NX/5;NYPRIN=NY/5;NZPRIN=NZ/5;nplt=1
tstswp=-1
dmpstk=t
DISTIL=T
EX(H1)=2.114E-01; EX(EXAC)=2.114E-01
 LIBREF=117
STOP