Create a custom chemistry unit-test

Thanks, @wfullmer for the detailed information. It has been helpful.

Could you help with building a standalone mfix executable for a sub-case, e.g. unit-tests/chemistry?

yes, probably. I’m guessing you have already been working with @YupengXu? Perhaps he already has something in hand that is what you want? If so, it would be nice if you could post it publicly on the forum for others.

Thanks, @wfullmer … You are right, I have been working with @YupengXu. I am attaching the modified files based on our biomass pyrolysis problem. I am unable to successfully compile the case with these modifications.

latest_file.zip (8.0 KB)

@oyedejifemi Can you please provide the input file for your case so we can look at it with your modifications?

@oyedejifemi, could you provide a little information about what you are hoping to achieve?

The chemistry unit test framework is limited, but there are ways to use it to provide some useful information. One very important item to keep in mind is that the testing framework only steps through the chemistry update portions of the code – i.e., there is no convection or diffusion. It’s best to think of the setup as a single, fully periodic computational cell.

A good starting point is running one of the existing chemistry unit-tests.

Adiabatic flame unit test

Although simple, the adiabatic flame is instructive. The setup contains a single homogeneous fluid phase reaction,

chemistry.AdiabaticFlame.reaction = CH4(g) + 2O2(g) --> CO2(g) + 2H2O(g)

with reaction rate

reactions.rate(0) = k0 * c_O2 * c_CH4;

where k0 is a defined constant and c_O2 and c_CH4 are the molar concentrations of oxygen and methane, respectively.

initial state

The starting temperature and gas composition are defined in the initial conditions section of inputs.adibatic-flame.

ic.regions = full-domain

ic.full-domain.fluid.volfrac     =  1.0
ic.full-domain.fluid.velocity    =  0.0  0.0  0.0
ic.full-domain.fluid.temperature =  298.15

ic.full-domain.fluid.species.CH4 = 0.046290939
ic.full-domain.fluid.species.O2  = 0.222196505
ic.full-domain.fluid.species.N2  = 0.731512556

building and running

Change directories to unit-tests/chemistry and edit GNUmakefile to include the following:

CPPFLAGS += -DCHEM_TEST_EULERIAN02

This sets a compile definition to enable the adiabatic flame reaction rate. The case will likely fail if you miss this step.

Next, you can build the executable simply by typing make. This uses the AMReX GNUMake build system. There is an option to use CMake, but it’s a little more involved and beyond the scope of this discussion. After building, you can run the local executable with a command like.

./mfix.unit-test.chem3d.gnu.DEBUG.ex inputs.adiabatic-flame test.verbose=1

mfix.unit-test.chem3d.gnu.DEBUG.ex is the executable you created, the first argument is the adiabatic flame inputs file, and the second argument tells the test to write some information to the screen. You could add test.verbose = 1 to the inputs.adibatic-flame file so you do not have to pass it as an additional argument.

output

Below is a snippet of the output which includes time, density, species mass fractions, enthalpy and temperature.

0.00000000e+00,   1.133564,   0.046291,   0.222197,   0.000000,   0.000000,   0.731513,   -215255.004650,   298.150000
1.00000000e-03,   1.133564,   0.046218,   0.221906,   0.000200,   0.000164,   0.731513,   -215255.004650,   301.564068
2.00000000e-03,   1.133564,   0.046145,   0.221616,   0.000399,   0.000327,   0.731513,   -215255.004650,   304.966211
3.00000000e-03,   1.133564,   0.046073,   0.221327,   0.000598,   0.000490,   0.731513,   -215255.004650,   308.356442
...
9.99980000e+01,   1.133564,   0.000000,   0.037533,   0.126989,   0.103965,   0.731513,   -215255.004650,   2066.048859
9.99990000e+01,   1.133564,   0.000000,   0.037533,   0.126989,   0.103965,   0.731513,   -215255.004650,   2066.048859
1.00000000e+02,   1.133564,   0.000000,   0.037533,   0.126989,   0.103965,   0.731513,   -215255.004650,   2066.048859

For this basic test, we are only interested in the final temperature and composition.

I’ve looked at the rates you specified and was able to cook up a ‘unit-test’ setup that ran. All rates were evaluated at 700K, and particle enthalpy was not updated to avoid issues with the temperature getting too low.