Skip to content

Commit

Permalink
[Thermo] Use current partial molar volumes in BinarySolutionTabulated…
Browse files Browse the repository at this point in the history
…Thermo

Previously, calculations of partial molar enthalpies, entropies, and chemical
potentials were using the pure-species molar volumes rather than the ones
calculated by inverting the tabulated mixture molar volume.
  • Loading branch information
speth committed Mar 4, 2023
1 parent 8658c1b commit f19bd3f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 41 deletions.
5 changes: 3 additions & 2 deletions include/cantera/thermo/IdealSolidSolnPhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,10 @@ class IdealSolidSolnPhase : public ThermoPhase

//! Vector of molar volumes for each species in the solution
/**
* Species molar volumes \f$ m^3 kmol^-1 \f$
* Species molar volumes (\f$ m^3 kmol^-1 \f$) at the current mixture state.
* For the IdealSolidSolnPhase class, these are constant.
*/
vector_fp m_speciesMolarVolume;
mutable vector_fp m_speciesMolarVolume;

//! Vector containing the species reference enthalpies at T = m_tlast
mutable vector_fp m_h0_RT;
Expand Down
15 changes: 8 additions & 7 deletions src/thermo/BinarySolutionTabulatedThermo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,18 @@ void BinarySolutionTabulatedThermo::diff(const vector_fp& inputData,

void BinarySolutionTabulatedThermo::getPartialMolarVolumes(double* vbar) const
{
double Xtab = moleFraction(m_kk_tab);
double Vm = interpolate(Xtab, m_molar_volume_tab);
double dVdX_tab = interpolate(Xtab, m_derived_molar_volume_tab);
vbar[m_kk_tab] = Vm + (1 - Xtab) * dVdX_tab;
vbar[1-m_kk_tab] = Vm - Xtab * dVdX_tab;
std::copy(m_speciesMolarVolume.begin(), m_speciesMolarVolume.end(), vbar);
}

void BinarySolutionTabulatedThermo::calcDensity()
{
double vmol = interpolate(moleFraction(m_kk_tab), m_molar_volume_tab);
double dens = meanMolecularWeight()/vmol;
double Xtab = moleFraction(m_kk_tab);
double Vm = interpolate(Xtab, m_molar_volume_tab);
double dVdX_tab = interpolate(Xtab, m_derived_molar_volume_tab);
m_speciesMolarVolume[m_kk_tab] = Vm + (1 - Xtab) * dVdX_tab;
m_speciesMolarVolume[1-m_kk_tab] = Vm - Xtab * dVdX_tab;

double dens = meanMolecularWeight() / Vm;

// Set the density in the parent State object directly, by calling the
// Phase::assignDensity() function.
Expand Down
9 changes: 4 additions & 5 deletions test/data/consistency-cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,10 @@ binary-solution-tabulated:
file: BinarySolutionTabulatedThermo.yaml
phase: anode
known-failures:
g_eq_h_minus_Ts: "Inconsistent results when P != 1 atm. See GitHub Issue #1301"
g_eq_sum_gk_Xk: "Inconsistent results when P != 1 atm. See GitHub Issue #1301"
h_eq_sum_hk_Xk: "Inconsistent results. See GitHub Issue #1302"
s_eq_sum_sk_Xk: "Problems near composition limit. See GitHub Issue #1303"
gk_eq_hk_minus_T_sk: "Problems near composition limit. See GitHub Issue #1303"
g_eq_h_minus_Ts/4: "Problems near composition limit. See GitHub Issue #1303"
g_eq_sum_gk_Xk/4: "Problems near composition limit. See GitHub Issue #1303"
s_eq_sum_sk_Xk/4: "Problems near composition limit. See GitHub Issue #1303"
gk_eq_hk_minus_T_sk/[34]: "Problems near composition limit. See GitHub Issue #1303"
gk0_eq_hk0_minus_T_sk0/[34]:
"Problems near composition limit. See GitHub Issue #1303"
chem_potentials_to_activities/3:
Expand Down
54 changes: 27 additions & 27 deletions test/thermo/BinarySolutionTabulatedThermo_Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,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] = {
3839.8896914480647,
5260.8983334513332,
5764.7097019695211,
7786.429533070881,
10411.474081913055,
15276.785945165157,
17900.243436157067,
22085.482962782506,
25989.144060372793
3839.8897013463629,
5260.8983501505654,
5764.7097249117705,
7786.4295622389736,
10411.474117668258,
15276.785988429341,
17900.243488318705,
22085.483025077028,
25989.144133134443
};

double xmin = 0.10;
Expand All @@ -90,15 +90,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] = {
-19347891.714810669,
-14757822.388050893,
-12593133.605195494,
-12626837.865623865,
-12131010.479908356,
-10322881.86739888,
- 9573869.8636945337,
-10260863.826955771,
-10579827.307551134
-19347891.744322445,
-14757822.415520553,
-12593133.63125352,
-12626837.890922677,
-12131010.504991682,
-10322881.892878814,
-9573869.8901660107,
-10260863.854728648,
-10579827.336476315
};

double xmin = 0.10;
Expand All @@ -120,15 +120,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] = {
30514.752294683516,
21514.841983025333,
14848.02859501992,
15965.482659621264,
18272.567242414199,
24453.517437971925,
25299.003664716853,
28474.69918493319,
30810.094532734405
30514.752393666495,
21514.842075159024,
14848.028682418964,
15965.482744473897,
18272.567326544096,
24453.517523432041,
25299.003753502617,
28474.699278083881,
30810.094629749936
};

double xmin = 0.10;
Expand Down

0 comments on commit f19bd3f

Please sign in to comment.