talk=t;run(1,1)

    PHOTON USE
  p

  *1 3 0.5



  up z
  con temp x 1 y 1 m z 7 14 fil;.001
  con temp x 1 y 1 m z 15 m sh;int 10
  vec x 1 y 1 m z 15 m sh
  vec x 1 y 1 m z 7 14
  set vec ref 4.
  vec x 1 y 1 m z 1 6 sh
  gr x 1 y 1 m z 7 14
  gr ou z 1
  gr ou y 1 z 1 25
  gr ou y m z 1 25
  gr ou z 26 y 16 m
  gr ou z 26 y 1 5
  gr ou z m y 6 15
  gr ou y 16 z 26 m
  gr ou y 6 z 26 m
  msg Velocity vectors and
  msg temperature contours
  msg
  msg
  msg Press 
  msg to continue
  pause;vec off;con off;red
  con temp x 1 fil;.001
  gr x 1 y 1 m z 7 14
  gr ou z 1
  gr ou y 1 z 1 25
  gr ou y m z 1 25
  gr ou z 26 y 16 m
  gr ou z 26 y 1 5
  gr ou z m y 6 15
  gr ou y 16 z 26 m
  gr ou y 6 z 26 m
  msg Temperature
  msg
  msg
  msg Press 
  msg to continue
  pause;con off;red
  con YO2 x 1 fil;.001
  gr x 1 y 1 m z 7 14
  gr ou z 1
  gr ou y 1 z 1 25
  gr ou y m z 1 25
  gr ou z 26 y 16 m
  gr ou z 26 y 1 5
  gr ou z m y 6 15
  gr ou y 16 z 26 m
  gr ou y 6 z 26 m
  msg Oxygen
  msg
  msg
  msg Press 
  msg to continue
  pause;con off;red
  con YN2 x 1 fil;.001
  gr x 1 y 1 m z 7 14
  gr ou z 1
  gr ou y 1 z 1 25
  gr ou y m z 1 25
  gr ou z 26 y 16 m
  gr ou z 26 y 1 5
  gr ou z m y 6 15
  gr ou y 16 z 26 m
  gr ou y 6 z 26 m
  msg Nitrogen
  msg
  msg
  msg Press 
  msg to continue
  pause;con off;red
  con YH2 x 1 fil;.001
  gr x 1 y 1 m z 7 14
  gr ou z 1
  gr ou y 1 z 1 25
  gr ou y m z 1 25
  gr ou z 26 y 16 m
  gr ou z 26 y 1 5
  gr ou z m y 6 15
  gr ou y 16 z 26 m
  gr ou y 6 z 26 m
  msg Hydrogen
  msg
  msg
  msg Press 
  msg to continue
  pause;con off;red
  con YH2O x 1 fil;.001
  gr x 1 y 1 m z 7 14
  gr ou z 1
  gr ou y 1 z 1 25
  gr ou y m z 1 25
  gr ou z 26 y 16 m
  gr ou z 26 y 1 5
  gr ou z m y 6 15
  gr ou y 16 z 26 m
  gr ou y 6 z 26 m
  msg Water vapour
  msg
  msg
  msg Press 
  msg to continue
  pause;con off;red
  con YCO2 x 1 fil;.001
  gr x 1 y 1 m z 7 14
  gr ou z 1
  gr ou y 1 z 1 25
  gr ou y m z 1 25
  gr ou z 26 y 16 m
  gr ou z 26 y 1 5
  gr ou z m y 6 15
  gr ou y 16 z 26 m
  gr ou y 6 z 26 m
  msg Carbon dioxide
  msg
  msg
  msg Press 
  msg to continue
  pause;con off;red
  con YCO x 1 fil;.001
  gr x 1 y 1 m z 7 14
  gr ou z 1
  gr ou y 1 z 1 25
  gr ou y m z 1 25
  gr ou z 26 y 16 m
  gr ou z 26 y 1 5
  gr ou z m y 6 15
  gr ou y 16 z 26 m
  gr ou y 6 z 26 m
  msg Carbon monoxide
  msg
  msg
  msg Press 
  msg to continue
  enduse
     GROUP 1. Run title and other preliminaries

TEXT(System-level coke-combustion simulation

  DISPLAY

    System level lump coke packed bad combustion.

    One-phase, 2D, one space, lump coke packed bed
    combustion, air supply underneath and above bed.

  ENDDIS

REAL(HINCL,CINCL,NINCL,AINCL,GASCON)
REAL(AIRO2,AIRN2)
REAL(MN2,MC,MO2,MH2,MCO,MCO2,MH2O)

GASCON=8.3143e3

HINCL=0.05
CINCL=0.95
NINCL=0.0
AINCL=1.-CINCL-HINCL-NINCL

AIRO2=0.232
AIRN2=0.768

MN2=28.; MC=12.; MO2=32.; MH2=2.; MCO=28.; MCO2=44.; MH2O=18.

REAL(HCCO2,HCCO,HHH2O,HCHX,HCOCO2)
HCCO2 =3.279E7
HCCO  = 9.208E6
HHH2O = 1.209E6

REAL(FS,BURNRATE, WIN)
  ** FS is the mass of fuel per unit mass of air/fuel mixture
     to convert all carbon and oxygen to carbon monoxide.
FS=0.232/(0.232 + CINCL*16.0/12.0)
  ** The heat of combustion per unit mass of co is hcco2 minus hcco
     the mass of c per unit mass of co, ie 12/28
HCOCO2=(12.0/28.0)*(HCCO2-HCCO)
  ** The heat of coal combustion per unit mass of carbon
HCHX=(CINCL*HCCO2+HINCL*HHH2O)*(HINCL*MH2+CINCL*MC+NINCL*MN2)/MC
  ** The rate of burning

BURNRATE=9.
  ** The inlet gas velocity
WIN=2.

    GROUP 4. Y-direction grid specification
NY=20;GRDPWR(Y,NY,1.,1.0)
    GROUP 5. Z-direction grid specification
NZ=30;GRDPWR(Z,NZ,1.5,1.0)
    GROUP 7. Variables stored, solved & named

  ** FCL - carbon element mass fraction;
  ** The specific heat at constant pressure, CP =1.100E3

    H = CP*T + HCHX*YCHX + HCOCO2*YCO * HHH2*YH2

SOLVE(P1,V1,W1,H1,FCL)

REAL(CP,TFUEL,HGIN,TGIN)
TGIN = 350.0
CP=  1100.
HGIN  = CP*TGIN

STORE(RMIX,HSUB,TEMP,YN2,YH2,YO2,YCO,YCO2,YH2O)
STORE(DEN1,FLIM,FRAC,GO,GC,GH,GOFU,GOPA)

SOLUTN(P1  ,Y,Y,Y,P,P,P)
SOLUTN(FCL,Y,Y,Y,P,P,P)
SOLUTN(H1  ,Y,Y,Y,P,P,P)

    GROUP 8. Terms (in differential equations) & devices
TERMS(FCL,N,Y,N,P,P,P)
TERMS(H1  ,N,Y,N,P,P,P)

    GROUP 9. Properties of the medium (or media)
REAL(RHOIN1,WAIR)
PRESS0=1.e5
WAIR=32.
RHOIN1=PRESS0*WAIR/(8314.*TGIN)

RHO1=GRND
     DEN1=PRESS0/(RMIX*TEMP+tiny)
     DEN1=AMIN1(VARMAX(140),AMAX1(0.0,DEN1,VARMIN(140)))
ENUL=0.0

    GROUP 11. Initialization of variable or porosity fields
FIINIT(W1)=1.
STORE(VPOR,NPOR,HPOR)
FIINIT(FCL)=FS
FIINIT(P1)=1.3E-4
INIADD=F
real(porbed);porbed=0.75
PATCH(POROS,INIVAL,1,NX,1,NY,7,14,1,1)
COVAL(POROS,VPOR,0.0,PORBED)
COVAL(POROS,NPOR,0.0,PORBED)
COVAL(POROS,HPOR,0.0,PORBED)

PATCH(SCHIMNEY,INIVAL,1,NX,1,5,26,NZ,1,1)
COVAL(SCHIMNEY,VPOR,0.0,0.)

PATCH(NCHIMNEY,INIVAL,1,NX,16,NY,26,NZ,1,1)
COVAL(NCHIMNEY,VPOR,0.0,0.0)

PATCH(POR1,INIVAL,1,NX,1,1,6,6,1,1)
COVAL(POR1,hpor,0.0,0.0)

PATCH(POR2,INIVAL,1,NX,4,5,6,6,1,1)
COVAL(POR2,hpor,0.0,0.0)

PATCH(POR3,INIVAL,1,NX,10,10,6,6,1,1)
COVAL(POR3,hpor,0.0,0.0)

PATCH(POR4,INIVAL,1,NX,11,11,6,6,1,1)
COVAL(POR4,hpor,0.0,0.0)

PATCH(POR5,INIVAL,1,NX,14,15,6,6,1,1)
COVAL(POR5,hpor,0.0,0.0)

PATCH(POR6,INIVAL,1,NX,20,20,6,6,1,1)
COVAL(POR6,hpor,0.0,0.0)
    GROUP 13. Boundary conditions and special sources
  ** Air to the fireplace bottom
INLET(INLET,EAST,1,1,1,NY,1,6,1,1)
VALUE(INLET,P1 , RHOIN1*WIN)
VALUE(INLET,W1 , WIN)
VALUE(INLET,FCL , 0.0)
VALUE(INLET,H1 , HGIN)
  ** Frictional momentum transfer
PATCH(BEDFRIC,VOLUME,1,NX,1,NY,7,14,1,1)
COVAL(BEDFRIC,W1,100.,0.0)
COVAL(BEDFRIC,v1,100.,0.0)
  ** Chimney outlet
PATCH(OUTLET,HIGH,1,NX,1,NY,NZ,NZ,1,1)
COVAL(OUTLET,P1,fixp,0.0)
  ** Air to the open flame area
PATCH(EASTAIR,EAST,1,NX,1,NY,15,25,1,1)
COVAL(EASTAIR,P1  , FIXFLU  , 2.*RHOIN1*WIN)
COVAL(EASTAIR,FCL , ONLYMS, 0.0)
COVAL(EASTAIR,H1  , ONLYMS, HGIN)
  **
  Carbon mass transfer related sources:
  ------------------------------------

PATCH(CARGAS,VOLUME,1,NX,1,NY,1,NZ,1,1)

  (1) Transfer of mass leading to increase of gas flow rate:
       - VPOR is volume fraction of lump coal
     VAL=:BURNRATE:*(1.-VPOR)*(:FS:-FCL)
COVAL(CARGAS,P1,FIXFLU,GRND)
  (2) Transfer of carbon leading to increase of mixture
      fraction at the same rate:
       - CO=1. signifies that mass tarnsfer brings in
         material which is 100% carbon
COVAL(CARGAS,FCL,ONLYMS,1.)
  (3) Transfer of enthalpy and heat leading to increase of
      gas enthalpy at the same rate:
       - Interphase gas temperature is assumed as TEMP.
       - HSUB = HCOCO2*YCO * HH2*YH2
     VAL=:CP:*TEMP+:HCHX:+HSUB
COVAL(CARGAS,H1,ONLYMS,GRND)


    GROUP 15. Termination of sweeps
LSWEEP=100
RESFAC=0.0001

    GROUP 16. Termination of iterations
LITHYD=10
VARMAX(FCL)=1.0;VARMIN(FCL)=0.0
VARMIN(TEMP)=TGIN;VARMAX(TEMP)=3000.
VARMIN(DEN1)=0.001;VARMAX(DEN1)=3.
    GROUP 17. Under-relaxation devices
RELAX(P1,LINRLX,0.175)
RELAX(W1,FALSDT,0.1)
RELAX(V1,FALSDT,0.1)
RELAX(FCL,FALSDT,0.1)
RELAX(DEN1,LINRLX,0.1)
    GROUP 22. Monitor print-out
IZMON=NZ/2;IYMON=NY/2;UWATCH=T

    GROUP 23. Field print-out and plot control
NPLT=1;NYPRIN=1;NZPRIN=1
NYPRIN=1;IYPRF=1;IYPRL=30
TSTSWP=-1
namsat=mosg

           ** Cell-wise composition parameters
              --------------------------------
    FLIM=:AIRO2:/(:AIRO2:+:CINCL:*:MO2:/:MC:+$
                          :HINCL:*:MO2:/(2*:MH2:))
    GO=:AIRO2:*(1-FCL)
    GC=:CINCL:*FCL
    GH=:HINCL:*FCL
    GOPA=GC*:MO2:/(2*:MC:)/(1-GO+GC*:MO2:/(2*:MC:)+TINY)
    GOFU=(GH*:MO2:/(2*:MH2:)+GC*:MO2:/:MC:)/$
            (1.-GO+GH*:MO2:/(2*:MH2:)+GC*:MO2:/:MC:+TINY)
    FRAC=(GO-GOPA)/(GOFU-GOPA+TINY)

           ** For all regions
              ---------------
    YN2=:NINCL:*FCL+:AIRN2:*(1.-FCL)

           ** Region 1
              --------
    YH2O=:HINCL:*FCL*:MH2O:/:MH2:
   IF(FCL.LE.FLIM)
    YCO2=:CINCL:*FCL*:MCO2:/:MC:
   IF(FCL.LE.FLIM)
    YO2 =:AIRO2:*(1-FCL)-:CINCL:*FCL*:MO2:/:MC:-$
                 :HINCL:*FCL*:MO2:/(2.*:MH2:)
   IF(FCL.LE.FLIM)
    YCO=0.0
   IF(FCL.LE.FLIM)
    YH2=0.0
   IF(FCL.LE.FLIM)
    HSUB=0.0
   IF(FCL.LE.FLIM)
    RMIX=:GASCON:*(YO2/:MO2:+YH2O/:MH2O:+YCO2/:MCO2:+$
                 YN2/:MN2:)
   IF(FCL.LE.FLIM)

           ** Region 2
              --------
    YH2O=:HINCL:*FCL*:MH2O:/:MH2:*FRAC*(1-GOFU)/(1-GO+TINY)
   IF(FCL.GT.FLIM.AND.FRAC.GE.0.)
    YCO2=:CINCL:*FCL*:MCO2:/:MC:*FRAC*(1-GOFU)/(1-GO+TINY)
   IF(FCL.GT.FLIM.AND.FRAC.GE.0.)
    YO2=0.0
   IF(FCL.GT.FLIM.AND.FRAC.GE.0.)
    YCO=:CINCL:*FCL*:MCO:/:MC:*(1-FRAC)*$
                 (1-GOPA)/(1-GO+TINY)
   IF(FCL.GT.FLIM.AND.FRAC.GE.0.)
    YH2=:HINCL:*FCL*(1-FRAC)*(1-GOPA)/(1-GO+TINY)
   IF(FCL.GT.FLIM.AND.FRAC.GE.0.)

    YH2O=AMAX1(0.,YH2O)
    YCO=AMAX1(0.,YCO)
    YCO2=AMAX1(0.,YCO2)

    HSUB=YCO*:HCOCO2:+YH2*:HHH2O:
   IF(FCL.GT.FLIM.AND.FRAC.GE.0.)
    RMIX=:GASCON:*(YH2O/:MH2O:+YCO/:MCO:+YCO2/:MCO2:+$
                 YH2/:MH2:+YN2/:MN2:)
   IF(FCL.GT.FLIM.AND.FRAC.GE.0.)

           ** Region 3
              --------
    YH2O=0.0
   IF(FCL.GT.FLIM.AND.FRAC.LT.0.)
    YCO2=0.0
   IF(FCL.GT.FLIM.AND.FRAC.LT.0.)
    YO2=0.0
   IF(FCL.GT.FLIM.AND.FRAC.LT.0.)
    YCO=:AIRO2:*(1-FCL)*2*:MCO:/:MO2:
   IF(FCL.GT.FLIM.AND.FRAC.LT.0.)
    YH2=:HINCL:*FCL
   IF(FCL.GT.FLIM.AND.FRAC.LT.0.)
    HSUB=YCO*:HCOCO2:+YH2*:HHH2O:
   IF(FCL.GT.FLIM.AND.FRAC.LT.0.)
    RMIX=:GASCON:*(YCO/:MCO:+YH2/:MH2:+YN2/:MN2:)
   IF(FCL.GT.FLIM.AND.FRAC.LT.0.)

     ** Calculation of absolute gas temperature
        --------------------------------------
    TEMP=(H1-HSUB)/:CP:
    TEMP=AMIN1(VARMAX(147),AMAX1(100.,TEMP,VARMIN(147)))
store(ysum)
    YSUM=YN2+YO2+YCO+YCO2+YH2O+YH2

STOP