View Issue Details

IDProjectCategoryView StatusLast Update
0000657OpenFOAMBugpublic2013-02-25 18:35
Reporteruser503Assigned Tohenry  
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
PlatformLinux 2.6.32-279.2.1.el6.x86_64OSRed Hat Enterprise LinuxOS Version6.3
Summary0000657: Reaction rate calculation causes sigFpe when nMoles == SMALL is used in K(T)
DescriptionWhen species are added together (for mixtures) nMoles is clipped to be SMALL when they should be 0 to avoid numerical issues. In specieThermoI.H, the Kc(T) and Kn(T) functions guard against using this artificially clipped value when calculating Kc or Kn. However, K(T) does not guard against this.

Because of the way the JANAF coefficients are combined, very large coefficients can result for mixtures of "zero" species (see henry's comment 0000764 in bug 0000327 showing the size of the H2 coefficients). This can result in K(T) = very small (10^-60 in my case) when it really should be 1, which crashes the calculation of the reverse reaction rates
(kr = kf / Kc(T)).

I suggest adding a guard in specieThermo::K(const scalar T) as:

    if (equal(this->nMoles(), SMALL))
    {
        return 1.0; //exp(0) = 1
    }
    else
    {
        scalar arg = -this->nMoles()*this->g(T)/(this->RR*T);

        if (arg < 600.0)
        {
            return ::exp(arg);
        }
        else
        {
            return VGREAT;
        }
    }
Additional InformationTo make sure this wasn't the same issue as in Bug 0000327 I used species which all had the same value for Tcommon.
TagsNo tags attached.

Activities

henry

2012-10-04 18:03

manager   ~0001701

Thanks for the bug report and suggested fix.
Resolved by commit 607fe3a131a7c8d61be49dedc3209e33d98e6ca2

henry

2012-11-01 14:34

manager   ~0001762

The proposed fix is erroneous. For example try running the tutorial

OpenFOAM-2.1.x/tutorials/combustion/chemFoam/gri

The change has been reverted pending an acceptable change.

Issue History

Date Modified Username Field Change
2012-10-04 17:02 user503 New Issue
2012-10-04 18:03 henry Note Added: 0001701
2012-10-04 18:03 henry Status new => resolved
2012-10-04 18:03 henry Resolution open => fixed
2012-10-04 18:03 henry Assigned To => henry
2012-11-01 14:34 henry Note Added: 0001762