diff --git a/test/data/BinarySolutionTabulatedThermo.cti b/test/data/BinarySolutionTabulatedThermo.cti new file mode 100755 index 000000000..bbcd946e3 --- /dev/null +++ b/test/data/BinarySolutionTabulatedThermo.cti @@ -0,0 +1,75 @@ +#===================================================================================== +# Electrodes +#===================================================================================== + +# Graphite (anode) +#------------------------------------------------------------------ +BinarySolutionTabulatedThermo( + name = "anode", + elements = "Li C", + species = "Li[anode] V[anode]", # Lithium atoms, vacancies, and electrons + initial_state = state( mole_fractions = "Li[anode]:0.5 V[anode]:0.5"), + tabulated_species = "Li[anode]", + 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, + 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, + 3.05977E-01,3.17986E-01,3.29995E-01,3.42004E-01,3.54014E-01, + 3.66023E-01,3.78032E-01,3.90041E-01,4.02050E-01,4.14059E-01, + 4.26068E-01,4.38077E-01,4.50086E-01,4.62095E-01,4.74104E-01, + 4.86114E-01,4.98123E-01,5.10132E-01,5.22141E-01,5.34150E-01, + 5.46159E-01,5.58168E-01,5.70177E-01,5.82186E-01,5.94195E-01, + 6.06205E-01,6.18214E-01,6.30223E-01,6.42232E-01,6.54241E-01, + 6.66250E-01,6.78259E-01,6.90268E-01,7.02277E-01,7.14286E-01, + 7.26295E-01,7.38305E-01,7.50314E-01,7.62323E-01,7.74332E-01, + 7.86341E-01,7.98350E-01],"1"), + enthalpy = ([-6.40692E+04,-3.78794E+04,-1.99748E+04,-1.10478E+04,-7.04973E+03, + -7.13749E+03,-8.79728E+03,-9.93655E+03,-1.03060E+04,-1.00679E+04, + -9.69664E+03,-9.31556E+03,-8.90503E+03,-8.57057E+03,-8.38117E+03, + -8.31928E+03,-8.31453E+03,-8.32977E+03,-8.33292E+03,-8.32931E+03, + -8.31339E+03,-8.21331E+03,-8.08920E+03,-8.00131E+03,-7.92294E+03, + -7.81543E+03,-7.77498E+03,-7.79440E+03,-7.78804E+03,-8.32931E+03, + -7.69063E+03,-7.69630E+03,-7.63241E+03,-7.41910E+03,-7.06828E+03, + -6.64544E+03,-6.17193E+03,-5.67055E+03,-5.14299E+03,-4.55704E+03, + -3.94568E+03,-3.35408E+03,-2.87825E+03,-2.57690E+03,-2.43468E+03, + -2.33952E+03,-2.23218E+03,-2.11482E+03,-2.03976E+03,-2.01990E+03, + -2.01329E+03,-1.97991E+03,-1.92686E+03,-1.86602E+03,-1.81419E+03, + -1.77693E+03,-1.74908E+03,-1.71494E+03,-1.67287E+03,-1.63685E+03, + -1.59649E+03,-1.52295E+03,-1.39033E+03,-1.11524E+03,-5.34643E+02, + 3.73854E+02, 1.60442E+03],"J/mol"), + entropy = ([3.05724E+01,4.04307E+01,4.75718E+01,5.25690E+01,5.10953E+01, + 4.43414E+01,3.71575E+01,3.23216E+01,2.91586E+01,2.70081E+01, + 2.53501E+01,2.40845E+01,2.30042E+01,2.19373E+01,2.07212E+01, + 1.93057E+01,1.77319E+01,1.61153E+01,1.46399E+01,1.34767E+01, + 1.27000E+01,1.23377E+01,1.22815E+01,1.23700E+01,1.24863E+01, + 1.26368E+01,1.26925E+01,1.26250E+01,1.24861E+01,1.23294E+01, + 1.21865E+01,1.20723E+01,1.21228E+01,1.24383E+01,1.30288E+01, + 1.37342E+01,1.44460E+01,1.50813E+01,1.56180E+01,1.62213E+01, + 1.70774E+01,1.80584E+01,1.88377E+01,1.92094E+01,1.92957E+01, + 1.93172E+01,1.93033E+01,1.92971E+01,1.92977E+01,1.62213E+01, + 1.92980E+01,1.92978E+01,1.92945E+01,1.92899E+01,1.92877E+01, + 1.92882E+01,1.92882E+01,1.92882E+01,1.92882E+01,1.92882E+01, + 1.92885E+01,1.92876E+01,1.92837E+01,1.92769E+01,1.92850E+01, + 1.93100E+01,1.93514E+01],"J/mol/K") + ) +) + + +#===================================================================================== +# Species definitions +#===================================================================================== + +species( + name = "Li[anode]", + atoms = "Li:1 C:6", + thermo = const_cp(h0 = (0, 'kJ/mol'), s0 = (0.0, 'J/mol/K')), + standardState = constantIncompressible(molarVolume = (13.02, 'cm3/mol'))) + +species( + name = "V[anode]", + atoms = "C:6", + thermo = const_cp(h0 = (0.0, 'kJ/mol'), s0 = (0.0, 'J/mol/K')), + standardState = constantIncompressible(molarVolume = (34.54, 'cm3/mol'))) diff --git a/test/thermo/BinarySolutionTabulatedThermo_Test.cpp b/test/thermo/BinarySolutionTabulatedThermo_Test.cpp new file mode 100755 index 000000000..16a007105 --- /dev/null +++ b/test/thermo/BinarySolutionTabulatedThermo_Test.cpp @@ -0,0 +1,160 @@ +#include "gtest/gtest.h" +#include "cantera/thermo/BinarySolutionTabulatedThermo.h" +#include "cantera/thermo/ThermoFactory.h" + +namespace Cantera +{ + +class BinarySolutionTabulatedThermo_Test : public testing::Test +{ +public: + BinarySolutionTabulatedThermo_Test(){ + test_phase.reset(newPhase("../data/BinarySolutionTabulatedThermo.cti")); + } + + void set_defect_X(const double x) { + vector_fp moleFracs(2); + moleFracs[0] = x; + moleFracs[1] = 1-x; + test_phase->setMoleFractions(&moleFracs[0]); + } + + std::unique_ptr test_phase; +}; + +TEST_F(BinarySolutionTabulatedThermo_Test,construct_from_cti) +{ + BinarySolutionTabulatedThermo* BinarySolutionTabulatedThermo_phase = dynamic_cast(test_phase.get()); + EXPECT_TRUE(BinarySolutionTabulatedThermo_phase != NULL); +} + +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, + -1512199.970459, + -2143625.893392, + -2704188.166163, + -2840293.936547, + -1534983.231904, + -1193196.003622, + -1184444.702197, + -1045348.216962, + }; + + double xmin = 0.10; + double xmax = 0.75; + int numSteps= 9; + double dx = (xmax-xmin)/(numSteps-1); + for (int i = 0; i < 9; ++i) + { + set_defect_X(xmin + i*dx); + EXPECT_NEAR(expected_result[i], test_phase->enthalpy_mole(), 1.e-6); + } +} + +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 + }; + + double xmin = 0.10; + double xmax = 0.75; + int numSteps= 9; + double dx = (xmax-xmin)/(numSteps-1); + 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); + } +} + + +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 + }; + + double xmin = 0.10; + double xmax = 0.75; + int numSteps= 9; + double dx = (xmax-xmin)/(numSteps-1); + vector_fp chemPotentials(2); + for (int i = 0; i < 9; ++i) + { + set_defect_X(xmin + i*dx); + test_phase->getChemPotentials(&chemPotentials[0]); + EXPECT_NEAR(expected_result[i], chemPotentials[0], 1.e-6); + } +} + + +TEST_F(BinarySolutionTabulatedThermo_Test,mole_fractions) +{ + test_phase->setState_TP(298.15,101325.); + double xmin = 0.10; + double xmax = 0.75; + int numSteps= 9; + double dx = (xmax-xmin)/(numSteps-1); + vector_fp molefracs(2); + for (int i = 0; i < 9; ++i) + { + set_defect_X(xmin + i*dx); + test_phase->getMoleFractions(&molefracs[0]); + EXPECT_NEAR(xmin + i*dx, molefracs[0], 1.e-6); + } +} + +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 + }; + + double xmin = 0.10; + double xmax = 0.75; + int numSteps= 9; + double dx = (xmax-xmin)/(numSteps-1); + vector_fp partialMolarEntropies(2); + for (int i = 0; i < 9; ++i) + { + set_defect_X(xmin + i*dx); + test_phase->getPartialMolarEntropies(&partialMolarEntropies[0]); + EXPECT_NEAR(expected_result[i], partialMolarEntropies[0], 1.e-6); + } +} +}