talk=t;run(1,1)
    PHOTON USE
  autoplot
  upause 1
  file; phi 5

  cl; da 1; yco2; da 1; yo2; da 1; yco; scale; cola 1; col3 2
  colf 3
  msg
  msg
  msg             Mass fractions of CO2 - yellow, O2 - blue,
  msg             CO - red   ................................more
  pause; cl; da 1; yh2o; da 1; YH2; scale; col3 1; colf 2
  msg
  msg
  msg             Mass fractions of H2O - blue and  H2 - red  ...mor
  pause; cl; da 1; fcl; da 1; YN2; scale; col3 1; colf 2
  msg
  msg
  msg             Mass fractions of N2 - red and
  msg             coal-derived gas - blue  ........more
  pause; cl; da 1; temp; colF 1;
  msg
  msg
  msg           Temperature of gas, K       .......more
  pause; cl; da 1; w1; col7 1;scale;
  msg
  msg
  msg           Gas velocity, m/s
  enduse
     GROUP 1. Run title and other preliminaries

TEXT(Combustion of packed bed of coke

  DISPLAY

    Air flow through combustion of coke packed bed:

    One-phase, 1D, one space.

  ENDDIS

REAL(HINCL,CINCL,NINCL,GASCON)
REAL(AIRO2,AIRN2)
REAL(MN2,MC,MO2,MH2,MCO,MCO2,MH2O)
REAL(FS,BURNRATE, WIN)
REAL(HCCO2,HCCO,HHH2O,HCHX,HCOCO2)
REAL(CP,HGIN,TGIN)
REAL(PORBED)
REAL(RHOIN1,WAIR)

    Operating data:
    ==============
    Blasting gas velocity, m/s
WIN=5.
    Blasting gas temperature and enthalpy:
TGIN = 350.0 
    Gas and coal composition:
AIRO2=0.232; AIRN2=0.768; HINCL=0.05; CINCL=0.9
NINCL=1.-CINCL-HINCL
    The estimated rate of coal burning, kg/s
BURNRATE=1.
     Bed porosity
PORBED=0.25

    Thermodynamics
    ==============
    Gas constant:
GASCON=8.3143e3
    Molecular masses:
MN2=28.; MC=12.; MO2=32.; MH2=2.; MCO=28.; MCO2=44.; MH2O=18.
    Specific heats:
CP=1100.
HGIN=CP*TGIN
    Heats of combustion:
HCCO2=3.279E7; HCCO=9.208E6; HHH2O=120.9E6
HCOCO2=(12.0/28.0)*(HCCO2-HCCO)
HCHX=CINCL*HCCO2+HINCL*HHH2O
    Carbon saturation mixture fraction:
FS=0.232/(0.232 + CINCL*16.0/12.0)

    Main simulation settings
    ========================
    GROUP 4. Y-direction grid specification
NY=1;GRDPWR(Y,NY,NY,1.0)
    GROUP 5. Z-direction grid specification
NZ=10;GRDPWR(Z,NZ,10.,1.0)
    GROUP 7. Variables stored, solved & named
SOLVE(P1,W1,H1,FCL)
STORE(RMIX,HSUB,TEMP,YN2,YH2,YO2,YCO,YCO2,YH2O,YSUM)
STORE(DEN1,FLIM,FRAC,GO,GC,GH,GOFU,GOPA,RO,RFE,RCO,RCO2)
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)
PRESS0=1.e5 ;WAIR=28.;RHOIN1=PRESS0*WAIR/(8314.*TGIN)
RHO1=GRND
        DEN1=PRESS0/(RMIX*TEMP)
        DEN1=AMIN1(VARMAX(139),AMAX1(0.0,DEN1,VARMIN(139)))
    GROUP 11. Initialization of variable or porosity fields
STORE(VPOR,HPOR)
FIINIT(W1)=1.; FIINIT(VPOR)=PORBED;FIINIT(FCL)=1.
    GROUP 13. Boundary conditions and special sources
  ** Inlet Boundaries
INLET(INLET,LOW,1,NX,1,NY,1,1,1,1)
VALUE(INLET,P1  , RHOIN1*WIN); VALUE(INLET,W1  , WIN)
VALUE(INLET,FCL , 0.0)       ; VALUE(INLET,H1  , HGIN)
  ** Frictional momentum transfer
PATCH(FRICTION,VOLUME,1,NX,1,NY,1,NZ,1,1)
COVAL(FRICTION,W1,100.,0.0)
  **Outlet boundary
PATCH(OUTLET,HIGH,1,NX,1,NY,NZ,NZ,1,1)
COVAL(OUTLET,P1,fixp,0.0)
    GROUP 15. Termination of sweeps
LSWEEP=350; 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.25);RELAX(W1,FALSDT,0.025)
RELAX(V1,FALSDT,0.025);RELAX(FCL,FALSDT,0.025)
RELAX(H1,FALSDT,0.025);RELAX(DEN1,LINRLX,0.2)
    GROUP 22. Monitor print-out
IZMON=NZ-1;IYMON=NY-1;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

   ============= End of main settings ============

    Model settings
    ==============

    Sub-model 1: Carbon oxidation
    ------------------------------

    Reactions: C (s) + 0.5 O2  > CO
               CO    + 0.5 O2  > CO2
               C(s)  + CO2     > 2CO
               C(s)  + H2O     > CO  + H2
               H2    + 0.5 O2  > H2O

   (1)  Gas mixture 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)

  (2) Mass fraction of nytrogen

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

  (3) ** Region 1**  containing O2, CO2 & H2O

    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)

  (4) ** Region 2 **  containing CO2, H2O, H2 & CO

    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.)

  (5) ** Region 3 ** containing H2 & CO.

    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.)

    YH2=AMAX1(0.,YH2)
    YH2O=AMAX1(0.,YH2O)
    YCO=AMAX1(0.,YCO)
    YCO2=AMAX1(0.,YCO2)
    YN2=AMAX1(0.,YN2)
    YO2=AMAX1(0.,YO2)

    HSUB=0.0
   IF(FCL.LE.FLIM)
    RMIX=:GASCON:*(YO2/:MO2:+YH2O/:MH2O:+YCO2/:MCO2:+$
                 YN2/:MN2:)
   IF(FCL.LE.FLIM)

    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.)

    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.)

  ** Deduce the gas temperature from enthalpy
    TEMP=(H1-HSUB)/:CP:
    TEMP=AMIN1(VARMAX(147),AMAX1(100.,TEMP,VARMIN(147)))
  ** Check for the sum of mass fractions
    YSUM=YN2+YO2+YCO+YCO2+YH2O+YH2


    Interphase transport.
    --------------------

    Coke carbon mass transfer and related sources.
    ----------------------------------------------

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

  (1) Transfer of mass leading to increase of gas flow rate:
             m31c = const.R2.(fsat - fcl), kg/s/m^3
           (1 - VPOR) is volume fraction of lump solid

     VAL=:BURNRATE:*(1.-VPOR)*(:FS:-FCL)
COVAL(car2gas,P1,FIXFLU,GRND)

  (2) Transfer of carbon leading to increase of mixture
      fraction at the same rate:
             Sfcl = m31c.(1-fcl), kg/s/m^3
       - COF=1. signifies that mass transfer brings in
         material which is 100% carbon

COVAL(car2gas,FCL,ONLYMS,1.)

  (3) Transfer of enthalpy and heat leading to increase of
      gas enthalpy at the same rate:
             Shgas = m31c.(hint-hgas), W/m^3
       - Interphase gas temperature is assumed as TEMP.
       - HSUB = HCOCO2*YCO * HH2*YH2

     VAL=:CP:*TEMP+:HCHX: + HSUB
COVAL(car2gas,H1,ONLYMS,GRND)
STOP