Brief Chemistry Background Conservation of matter is the basis for balancing chemical equations. Because matter is neither created nor destroyed during a chemical reaction, a balanced chemical equation must always contain the same number of each kind of atom on both sides of the equation. In this Demonstration, conservation of matter is reflected by the balanced chemical equation:

.
In words, the equation states that, with the application of heat, one mole of

(methane) reacts with two moles of

(dioxygen) to yield one mole of

(carbon dioxide) and two moles of

(water).
At initialization, the grid is configured as a random mixture of excess carbon (

), excess hydrogen (

), excess oxygen (

), and the reactants

and

. The reactant concentrations are relative to the grid size, and are fixed at 15%

to 30%

, which reflects the left-hand side of the equation.
A feedback-driven block cellular automaton (BCA) searches the grid for

locations surrounded by exactly two

molecules and rewrites the

and

locations to

and

, respectively, reflecting the right-hand side of the equation. Reaction catalyzing heat is introduced through the rotational mixing energy of the BCA. As the reaction proceeds, the plot label monitors the counts of the reactants and their ratio as well as the counts of the products and their ratio in order to show a left-hand side to right-hand side balance history of the rewritten grid. Thus grid rewrite, itself a function of respective bondings, is ultimately responsible for determining whether or not the equation balances. The time to balance the equation is an indication of how much heat was necessary to bring about the balance. In keeping with the law of conservation of matter, the equation must always ultimately balance.
After triggering the reaction first (only once is necessary), toggle the "change settings" control to rerun the reaction with a different grid size or to rerun with a different underlying grid and current settings.
[1] K. W. Whitten and K. D. Gailey,
General Chemistry, Philadelphia, PA: Saunders College Publishing, 1981.