Parser for chemical reactions silently accepts faulty equations
Summary
The parser for chemical reactions accepts chemical reactions with typos, ignores the parts it doesn't understand and the simulations then run with chemical reactions that are different from what the user expects
The two main issues are
- punctuation tokens that don't make sense
- species that are not in the species list are ignored
Steps to reproduce
Use the tutorial case combustion/fireFoam/LES/simplePMMApanel
and edit the file constant/reactions
to modify the reaction in
reactions
{
methaneReaction
{
type irreversibleArrheniusReaction;
reaction "CH4 + 2O2 = CO2 + 2H2O";
A 5.2e16;
beta 0;
Ta 14906;
}
}
Possible problems are
reaction "CH4 + 2O2 = CO2 - 2H2O";
(wrong punctuation token) and
reaction "CH4 + 2O2 = COO2 + 2H2O";
(unknown species COO2).
What is the current bug behaviour?
The simulation runs without a hint that there is a problem but the used chemical equation is fundamentally different)
What is the expected correct behavior?
Program should crash while reading the faulty equation to give the user a chance to fix it
Environment information
- OpenFOAM version : any OF version of the last year. Tested on the current git-version
- Operating system :
- Hardware info :
- Compiler :
Possible fixes
Attached there are 2 patches to fix these problems. One to fail on unknown punctuation tokens. The other one to fail if there is an unknown species (this patch slightly changes the API of the speciesCoeffs-class because for solid reactions when calling the base class the parser should not fail for unknown species because these might be from the "other" phase
0001-Failing-on-extra-punctuation-tokens-in-chemical-equa.patch0002-Fail-for-unknown-species.patch