From 51457432eeff0028f5c97ef1fc87b87760bdb1b4 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Wed, 2 Sep 2015 15:34:43 +0100 Subject: [PATCH] chemkinReader: Add tolerance to element balance check Patch provided by Daniel Jasinski Resolved bug-report http://www.openfoam.org/mantisbt/view.php?id=1843 --- .../chemistryReaders/chemkinReader/chemkinReader.C | 13 ++++++++----- .../chemistryReaders/chemkinReader/chemkinReader.H | 5 ++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C index 701ce73c..e8d882a4 100644 --- a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C +++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -753,10 +753,11 @@ void Foam::chemkinReader::addReaction forAll(nAtoms, i) { - if (mag(nAtoms[i]) > SMALL) + if (mag(nAtoms[i]) > imbalanceTol_) { FatalErrorIn("chemkinReader::addReaction") - << "Elemental imbalance in " << elementNames_[i] + << "Elemental imbalance of " << mag(nAtoms[i]) + << " in " << elementNames_[i] << " in reaction" << nl << reactions_.last() << nl << " on line " << lineNo_-1 @@ -839,7 +840,8 @@ Foam::chemkinReader::chemkinReader specieNames_(10), speciesTable_(species), reactions_(speciesTable_, speciesThermo_), - newFormat_(newFormat) + newFormat_(newFormat), + imbalanceTol_(sqrt(SMALL)) { read(CHEMKINFileName, thermoFileName); } @@ -855,7 +857,8 @@ Foam::chemkinReader::chemkinReader specieNames_(10), speciesTable_(species), reactions_(speciesTable_, speciesThermo_), - newFormat_(thermoDict.lookupOrDefault("newFormat", false)) + newFormat_(thermoDict.lookupOrDefault("newFormat", false)), + imbalanceTol_(thermoDict.lookupOrDefault("imbalanceTolerance", sqrt(SMALL))) { if (newFormat_) { diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.H b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.H index ad1c50ab..ee1986f6 100644 --- a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.H +++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -211,6 +211,9 @@ private: //- Flag to indicate that file is in new format Switch newFormat_; + //- Tolerance for element imbalance in a reaction + scalar imbalanceTol_; + // Private Member Functions