thermophysicalFunctions/integratedNonUniformTable <revised>
Summary
This code-bug is a simple mistake, but it can produce a serious problem at least for me. For several monthes, I've tried to test a tabulated thermo-data and found this bug. Today I found there is a worng formula to integrate the tabulated data to calculate the enthalpy of specie, for example table(T, Cp).
The bug is in "integratedNonUniformTableThermophysicalFunction.C" under src/thermophysicalProperties/thermophysicalFunctions/integratedNonUniformTable/.
Steps to reproduce
Just look the Constructor of "integratedNonUniformTable" or the fuction of "intfdT".
-
integral formula: Integral from Tst to Ti = Integral[i-1] + intfdT(Ti)*dT
-
in "intfdT" function, it returns the full integral value from Tst to Ti. return-value = intf_[i] + (fi + 0.5lambda(values()[i + 1].second() - fi))*dT
Example case
-
There are 2 tutorials in $FOAM_TUTORIALS, they use the thermo-type of tabulation. multiphase/icoReactingMultiphaseInterFoam/inertMultiphaseMultiComponent multiphase/icoReactingMultiphaseInterFoam/mixerVesselAMI2D
-
the bug is related only to calculate the enthalpy of hTabulated-thermo. Actually, two cases work. However if you use a large table of Cp, then a serious error occur to stop.
What is the current bug behaviour?
- If the element-number of tabulated data is small, then it might not produce a serious problem. Therefore, nobody notice any wrong result.
- for a large tabulated data, in most cases, the calculation must stop to say wrong temperature.
What is the expected correct behavior?
Relevant logs and/or images
Environment information
- OpenFOAM version : v2112(or any)
- Operating system : ubuntu
- Hardware info : any
- Compiler : any
Possible fixes
-
one simple suggestion for constructor "integratedNonUniformTable"
original code
for (label i = 1; i < intf_.size(); ++i)
{
intf_[i] = intf_[i-1] + intfdT(0, values()[i].first());
intfByT_[i] = intfByT_[i-1] + intfByTdT(0, values()[i].first());
}
suggestion
for (label i = 1; i < intf_.size(); ++i)
{
intf_[i] = intfdT(0, values()[i].first());
intfByT_[i] = intfByTdT(0, values()[i].first());
}