Updates to BinarySolutionTabulatedThermo and test file.
-Fixes small typo id incclude/cantera/base/utilities.h docstring -Removes `m_formGC` from BinarySolutionTabulatedThermo class, and instead utilizes version and functionality inherited from parent class `IdealSolidSolnPhase`. -Moves samples/matlab/lithium_ion_battery/lithium_ion_battery.cti to data/inputs/lithium_ion_battery.cti -Fixes typo in test/data/BinarySolutionTabulatedThermo.cti -Updates expected_result values in several test cases in test/thermo/BinarySolutionTabulatedThermo_Test.cpp
This commit is contained in:
parent
ae555fb063
commit
05fdd356f2
5 changed files with 41 additions and 95 deletions
|
|
@ -397,7 +397,7 @@ inline void scatter_mult(InputIter mult_begin, InputIter mult_end,
|
|||
* The template arguments are: template<class InputIter>
|
||||
*
|
||||
* A small number (1.0E-20) is added before taking the log. This templated
|
||||
* class does the indicated sun. The template must be an iterator.
|
||||
* class does the indicated sum. The template must be an iterator.
|
||||
*
|
||||
* @param begin Iterator pointing to the beginning, belonging to the
|
||||
* iterator class InputIter.
|
||||
|
|
|
|||
|
|
@ -113,47 +113,31 @@ namespace Cantera
|
|||
class BinarySolutionTabulatedThermo : public IdealSolidSolnPhase
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor for BinarySolutionTabulatedThermo.
|
||||
* The generalized concentrations can have three different forms
|
||||
* depending on the value of the member attribute #m_formGC, which
|
||||
* is supplied in the constructor or read from the XML data file.
|
||||
*
|
||||
* @param formCG This parameter initializes the #m_formGC variable.
|
||||
*/
|
||||
BinarySolutionTabulatedThermo(int formCG=0);
|
||||
//! Default constructor for BinarySolutionTabulatedThermo
|
||||
BinarySolutionTabulatedThermo();
|
||||
|
||||
//! Construct and initialize an BinarySolutionTabulatedThermo ThermoPhase object
|
||||
//! directly from an ASCII input file
|
||||
/*!
|
||||
* This constructor will also fully initialize the object.
|
||||
* The generalized concentrations can have three different forms
|
||||
* depending on the value of the member attribute #m_formGC, which
|
||||
* is supplied in the constructor or read from the XML data file.
|
||||
*
|
||||
* @param infile File name for the XML datafile containing information
|
||||
* for this phase
|
||||
* @param id The name of this phase. This is used to look up
|
||||
* the phase in the XML datafile.
|
||||
* @param formCG This parameter initializes the #m_formGC variable.
|
||||
*/
|
||||
BinarySolutionTabulatedThermo(const std::string& infile, const std::string& id="", int formCG=0);
|
||||
BinarySolutionTabulatedThermo(const std::string& infile, const std::string& id="");
|
||||
|
||||
//! Construct and initialize an BinarySolutionTabulatedThermo ThermoPhase object
|
||||
//! directly from an XML database
|
||||
/*!
|
||||
* The generalized concentrations can have three different forms
|
||||
* depending on the value of the member attribute #m_formGC, which
|
||||
* is supplied in the constructor and/or read from the data file.
|
||||
*
|
||||
* @param root XML tree containing a description of the phase.
|
||||
* The tree must be positioned at the XML element
|
||||
* named phase with id, "id", on input to this routine.
|
||||
* @param id The name of this phase. This is used to look up
|
||||
* the phase in the XML datafile.
|
||||
* @param formCG This parameter initializes the #m_formGC variable.
|
||||
*/
|
||||
BinarySolutionTabulatedThermo(XML_Node& root, const std::string& id="", int formCG=0);
|
||||
BinarySolutionTabulatedThermo(XML_Node& root, const std::string& id="");
|
||||
|
||||
virtual std::string type() const {
|
||||
return "BinarySolutionTabulatedThermo";
|
||||
|
|
@ -162,15 +146,6 @@ public:
|
|||
virtual void initThermoXML(XML_Node& phaseNode, const std::string& id_);
|
||||
|
||||
protected:
|
||||
|
||||
int m_formGC;
|
||||
|
||||
double m_Pref;
|
||||
|
||||
double m_Pcurrent;
|
||||
|
||||
vector_fp m_speciesMolarVolume;
|
||||
|
||||
//! If the compositions have changed, update the tabulated thermo lookup
|
||||
virtual void compositionChanged();
|
||||
|
||||
|
|
|
|||
|
|
@ -19,40 +19,19 @@
|
|||
namespace Cantera
|
||||
{
|
||||
|
||||
BinarySolutionTabulatedThermo::BinarySolutionTabulatedThermo(int formGC) :
|
||||
m_formGC(formGC),
|
||||
m_Pref(OneAtm),
|
||||
m_Pcurrent(OneAtm)
|
||||
BinarySolutionTabulatedThermo::BinarySolutionTabulatedThermo()
|
||||
{
|
||||
if (formGC < 0 || formGC > 2) {
|
||||
throw CanteraError(" BinarySolutionTabulatedThermo Constructor",
|
||||
" Illegal value of formGC");
|
||||
}
|
||||
}
|
||||
|
||||
BinarySolutionTabulatedThermo::BinarySolutionTabulatedThermo(const std::string& inputFile,
|
||||
const std::string& id_, int formGC) :
|
||||
m_formGC(formGC),
|
||||
m_Pref(OneAtm),
|
||||
m_Pcurrent(OneAtm)
|
||||
const std::string& id_)
|
||||
{
|
||||
if (formGC < 0 || formGC > 2) {
|
||||
throw CanteraError(" BinarySolutionTabulatedThermo Constructor",
|
||||
" Illegal value of formGC");
|
||||
}
|
||||
initThermoFile(inputFile, id_);
|
||||
}
|
||||
|
||||
BinarySolutionTabulatedThermo::BinarySolutionTabulatedThermo(XML_Node& root, const std::string& id_,
|
||||
int formGC) :
|
||||
m_formGC(formGC),
|
||||
m_Pref(OneAtm),
|
||||
m_Pcurrent(OneAtm)
|
||||
BinarySolutionTabulatedThermo::BinarySolutionTabulatedThermo(XML_Node& root,
|
||||
const std::string& id_)
|
||||
{
|
||||
if (formGC < 0 || formGC > 2) {
|
||||
throw CanteraError(" BinarySolutionTabulatedThermo Constructor",
|
||||
" Illegal value of formGC");
|
||||
}
|
||||
importPhase(root, this);
|
||||
}
|
||||
|
||||
|
|
@ -86,6 +65,7 @@ void BinarySolutionTabulatedThermo::_updateThermo()
|
|||
dS_corr = GasConstant*std::log(xnow/(1.0-xnow)) + GasConstant/Faraday*std::log(this->standardConcentration(1-m_kk_tab)/this->standardConcentration(m_kk_tab));
|
||||
}
|
||||
c[2] = d[1] * 1e3 + dS_corr; // 1e3 for conversion J/K/mol -> J/K/kmol
|
||||
|
||||
c[3] = 0.0;
|
||||
type = m_spthermo.reportType(m_kk_tab);
|
||||
tlow = m_spthermo.minTemp(m_kk_tab);
|
||||
|
|
@ -184,17 +164,7 @@ void BinarySolutionTabulatedThermo::initThermoXML(XML_Node& phaseNode, const std
|
|||
*/
|
||||
if (phaseNode.hasChild("standardConc")) {
|
||||
XML_Node& scNode = phaseNode.child("standardConc");
|
||||
std::string formString = scNode.attrib("model");
|
||||
if (caseInsensitiveEquals(formString, "unity")) {
|
||||
m_formGC = 0;
|
||||
} else if (caseInsensitiveEquals(formString, "molar_volume")) {
|
||||
m_formGC = 1;
|
||||
} else if (caseInsensitiveEquals(formString, "solvent_volume")) {
|
||||
m_formGC = 2;
|
||||
} else {
|
||||
throw CanteraError("BinarySolutionTabulatedThermo::initThermoXML",
|
||||
"Unknown standardConc model: " + formString);
|
||||
}
|
||||
setStandardConcentrationModel(scNode.attrib("model"));
|
||||
} else {
|
||||
throw CanteraError("BinarySolutionTabulatedThermo::initThermoXML",
|
||||
"Unspecified standardConc model");
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ BinarySolutionTabulatedThermo(
|
|||
standard_concentration = "molar_volume",
|
||||
tabulated_thermo = table(
|
||||
moleFraction = ([5.75000E-03,1.77591E-02,2.97682E-02,4.17773E-02,5.37864E-02,
|
||||
6.57954E-02,7.78045E-02,8.98136E-06,1.01823E-01,1.13832E-01,
|
||||
6.57954E-02,7.78045E-02,8.98136E-02,1.01823E-01,1.13832E-01,
|
||||
1.25841E-01,1.37850E-01,1.49859E-01,1.61868E-01,1.73877E-01,
|
||||
1.85886E-01,1.97896E-01,2.09904E-01,2.21914E-01,2.33923E-01,
|
||||
2.45932E-01,2.57941E-01,2.69950E-01,2.81959E-01,2.93968E-01,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ TEST_F(BinarySolutionTabulatedThermo_Test,interp_h)
|
|||
test_phase->setState_TP(298.15, 101325.);
|
||||
// These expected results are purely a regression test
|
||||
const double expected_result[9] = {
|
||||
-1019148.841268,
|
||||
-1024991.831815,
|
||||
-1512199.970459,
|
||||
-2143625.893392,
|
||||
-2704188.166163,
|
||||
|
|
@ -60,15 +60,15 @@ TEST_F(BinarySolutionTabulatedThermo_Test,interp_s)
|
|||
test_phase->setState_TP(298.15, 101325.);
|
||||
// These expected results are purely a regression test
|
||||
const double expected_result[9] = {
|
||||
3852.587527,
|
||||
5260.898245,
|
||||
5764.709566,
|
||||
7786.429343,
|
||||
10411.473830,
|
||||
15276.785622,
|
||||
17900.243026,
|
||||
22085.482446,
|
||||
25989.143405
|
||||
3839.8896369,
|
||||
5260.8982298,
|
||||
5764.7095442,
|
||||
7786.4293148,
|
||||
10411.4737952,
|
||||
15276.7855795,
|
||||
17900.2429773,
|
||||
22085.4823903,
|
||||
25989.1433421
|
||||
};
|
||||
|
||||
double xmin = 0.10;
|
||||
|
|
@ -78,6 +78,7 @@ TEST_F(BinarySolutionTabulatedThermo_Test,interp_s)
|
|||
for (int i = 0; i < 9; ++i)
|
||||
{
|
||||
set_defect_X(xmin + i*dx);
|
||||
|
||||
EXPECT_NEAR(expected_result[i], test_phase->entropy_mole(), 1.e-6);
|
||||
}
|
||||
}
|
||||
|
|
@ -88,15 +89,15 @@ TEST_F(BinarySolutionTabulatedThermo_Test,chem_potentials)
|
|||
test_phase->setState_TP(298.15,101325.);
|
||||
// These expected results are purely a regression test
|
||||
const double expected_result[9] = {
|
||||
-19327320.552727,
|
||||
-14757822.382223,
|
||||
-12593133.583222,
|
||||
-12626837.825618,
|
||||
-12131010.419483,
|
||||
-10322881.783439,
|
||||
- 9573869.751959,
|
||||
-10260863.681331,
|
||||
-10579827.118452
|
||||
-19347891.6985338,
|
||||
-14757822.3571570,
|
||||
-12593133.5581558,
|
||||
-12626837.8005517,
|
||||
-12131010.3944173,
|
||||
-10322881.7583731,
|
||||
- 9573869.7268930,
|
||||
-10260863.6562655,
|
||||
-10579827.0933861
|
||||
};
|
||||
|
||||
double xmin = 0.10;
|
||||
|
|
@ -134,15 +135,15 @@ TEST_F(BinarySolutionTabulatedThermo_Test,partialMolarEntropies)
|
|||
test_phase->setState_TP(298.15,101325.);
|
||||
// These expected results are purely a regression test
|
||||
const double expected_result[9] = {
|
||||
30641.731142,
|
||||
21514.841963,
|
||||
14848.028521,
|
||||
15965.482525,
|
||||
18272.567039,
|
||||
24453.517156,
|
||||
25299.003289,
|
||||
28474.698696,
|
||||
30810.093898
|
||||
30514.7522401,
|
||||
21514.8418794,
|
||||
14848.0284372,
|
||||
15965.4824414,
|
||||
18272.5669557,
|
||||
24453.5170723,
|
||||
25299.0032059,
|
||||
28474.6986124,
|
||||
30810.0938144
|
||||
};
|
||||
|
||||
double xmin = 0.10;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue