(X_C (= 1 - m_C/m_{C,0})) denotes the mass conversion fraction of reacted coke in biomass. (P_{O_2}) stands for the partial pressure of oxygen in the gas system. (n_C) represents the molar amount of residual coke inside the biomass.
I would like to ask how to express (X_C) and (n_C) in the UDF code. Is (m_C) the most fundamental variable among all these parameters?
The per-particle quantities MFiX actually stores are the total mass PMASS(NP) and species mass fractions DES_X_s(NP,:). Everything in your expression derives from those:
where Char is the species index from the generated species.inc and pM is the phase index passed into USR_RATES_DES.
For X_C you also need the initial char mass m_C,0, which MFiX does not keep for you. Two ways to get it:
If all particles start with the same composition (diameters may vary), use the fact that ash/inert mass in a particle never changes: m_C,0 = (X_C,0 / X_ash,0) · PMASS(NP) · DES_X_s(NP, Ash) with X_C,0 and X_ash,0 the initial mass fractions. No extra storage, and it survives restarts and mass inflows.
General case: store it per particle. Set des_usr_var_size = 1 in the project, and in usr0_des.f (guarded with IF (RUN_TYPE == 'NEW') so restarts don’t overwrite it):
DES_USR_VAR(1,NP) = PMASS(NP) * DES_X_s(NP, Char)
Then X_C = 1 − m_C / DES_USR_VAR(1,NP). DES_USR_VAR is written to the restart files. Particles injected later by a mass inflow need the same initialization.
Oxygen partial pressure comes from the fluid cell IJK containing the particle:
This requires a compressible run (ro_g0 unset) so that P_g is absolute pressure. If ro_g0 is set, P_g is only a relative pressure and can’t be used for partial pressures.
MFiX uses SI units (with the exception that we use kmol instead of mol): kg, m, s, K, kmol, Pa. Literature kinetics are often in atm/mol/cm - convert the pre-exponential factor’s units too.
DES_RATES(rxn) is the molar rate of that reaction for this particle, in kmol/s, and must be non-negative; the stoichiometric coefficients in your reaction definition handle species consumption/production. If the kinetics use particle temperature, that’s DES_T_s(NP).