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( Ore reduction in a packed bed

  DISPLAY

    Ore reduction in a packed bed:

    One-phase, 1D, one space, coke combustion,
    mass transfer related ore reduction sources only.


  ENDDIS

   Coal-combustion model.

   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

      The numerical values which appear below are:-
      * the mass fractions of O2 and N2 in air, namely: 0.232 and 0.
      * the molecular weights of O2, N2, CO2, CO, H2O, H2, -
                  32.0, 28.0, 44.0, 28.0, 18.0 and 2.0
      * the Universal Gas Constant,                    GASCON: 8.314
      * the heat of reaction for    C  + O2     -> CO2, HCCO2: 3.279
      * the heat of reaction for    C  + 0.5*O2 -> CO , HCCO : 9.208
      * the heat of reaction for    H2 + 0.5*O2 -> H2O, HHH2O: 1.209
      * the specific heat at constant pressure,         CP   : 1.100
                                                        all in SI un

      CINCL, the mass fraction of C in the coal;
      HINCL, the mass fraction of H in the fuel;
      NINCL, the mass fraction of N in the fuel;
      AINCL, the mass fraction of ash in the fuel.


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=3.
  ** The inlet gas velocity
WIN=5.

    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

  ** 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,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)
     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)
FIINIT(VPOR)=0.25
FIINIT(FCL)=1.
FIINIT(P1)=1.3E-4
    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)

  Carbon mass transfer related sources:
  ------------------------------------

PATCH(CARGAS,CELL,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 increse 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)

  Ore reduction mass transfer related sources:
  --------------------------------------------
REAL(AGS,HGS,ORE)
AGS=150.
HGS=20.
ORE=0.6

  (1) Transfer of mass leading to increase of gas flow rate:
        m31 = Ags.(Rco2-Rco), kg/m^3/s

PATCH(OREGAS,VOLUME,1,NX,1,NY,1,NZ,1,1)
  VAL=0.01*150.*((1.+84./160.)*132./244.-3.*28./160.)
COVAL(OREGAS,P1,FIXFLU,GRND)

  (2) Transfer of carbon element leading to decrease of
      coal-derived gas mass fraction:
        Sfcl,co = -Rco.Mc/Mco.FCL
PATCH(CO4FCL,VOLUME,1,NX,1,NY,1,NZ,1,1)
  CO=3.*:HGS:*YCO*:ORE:/:CP:*:AGS:*28./160.*12./28.
COVAL(CO4FCL,FCL,GRND,0.)
  (2) Transfer of carbon element leading to increase of
      coal-derived gas mass fraction:
        Sfcl,co2 = Rco2.Mc/Mco2.(FS-FCL)
PATCH(COO4FCL,VOLUME,1,NX,1,NY,1,NZ,1,1)
  CO=20.*YCO*0.6/1100.*150.*(1+84./160.)*132./244.*12./28.
COVAL(COO4FCL,FCL,GRND,FS)

  In which,  Rco = 3.Ro.Ags.28/160
             Ro  = hgs.Yco.Yore/Cpgas
             Rco2= Ro.Ags.(1+84/160).132/244

  To be considered,

    - the mass transfer related enthalpy and heat transfer.

    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

      Coal oxidation is presumed to proceed in two stages, viz:
        (1) to create CO2 and H2O, and then
        (2) to create CO and H2, as more fuel is added.

      The gas composition diagram, taking account of the elemental
      mass fractions of O, C and H, has got three regions:
      (1) Region 1  containing O2, CO2 & H2O
      (2) Region 2  containing CO2, H2O, H2 & CO
      (3) Region 3  containing H2 & CO.

      The values of oxygen fraction GO at which the formulae exbibit
      discontinuities of slope are called:-
        GOPA, where the oxygen has consumed part of the fuel, so as
                create CO and H2; and
        GOFU, where the products of combustion are CO2 and H2O.

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

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


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

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


     ** 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
dmpstk=t
 LIBREF=104
STOP