Implement MaskellSolidSolnPhase::getPartialMolarVolumes()
User VPStandardStateVP as base class and just return the standard state molar volumes.
This commit is contained in:
parent
b328e396b0
commit
5898bf025f
4 changed files with 52 additions and 60 deletions
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "mix_defs.h"
|
||||
#include "ThermoPhase.h"
|
||||
#include "VPStandardStateTP.h"
|
||||
#include "ThermoFactory.h"
|
||||
#include "SpeciesThermo.h"
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ namespace Cantera
|
|||
*
|
||||
* @ingroup thermoprops
|
||||
*/
|
||||
class MaskellSolidSolnPhase : public ThermoPhase
|
||||
class MaskellSolidSolnPhase : public VPStandardStateTP
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
@ -137,6 +138,8 @@ public:
|
|||
*/
|
||||
virtual void setDensity(const doublereal rho);
|
||||
|
||||
virtual void calcDensity();
|
||||
|
||||
/**
|
||||
* Overwritten setMolarDensity() function is necessary because the
|
||||
* density is not an independent variable.
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ namespace Cantera
|
|||
{
|
||||
//=====================================================================================================
|
||||
MaskellSolidSolnPhase::MaskellSolidSolnPhase() :
|
||||
ThermoPhase(),
|
||||
m_Pref(OneAtm),
|
||||
m_Pcurrent(OneAtm),
|
||||
m_tlast(-1.0),
|
||||
|
|
@ -34,7 +33,6 @@ MaskellSolidSolnPhase::MaskellSolidSolnPhase() :
|
|||
}
|
||||
//=====================================================================================================
|
||||
MaskellSolidSolnPhase::MaskellSolidSolnPhase(const MaskellSolidSolnPhase& b) :
|
||||
ThermoPhase(),
|
||||
m_Pref(OneAtm),
|
||||
m_Pcurrent(OneAtm),
|
||||
m_tlast(-1.0),
|
||||
|
|
@ -51,7 +49,7 @@ MaskellSolidSolnPhase& MaskellSolidSolnPhase::
|
|||
operator=(const MaskellSolidSolnPhase& b)
|
||||
{
|
||||
if (this != &b) {
|
||||
ThermoPhase::operator=(b);
|
||||
VPStandardStateTP::operator=(b);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -110,6 +108,21 @@ setDensity(const doublereal rho)
|
|||
}
|
||||
}
|
||||
|
||||
void MaskellSolidSolnPhase::
|
||||
calcDensity()
|
||||
{
|
||||
const vector_fp & vbar = getStandardVolumes();
|
||||
|
||||
vector_fp moleFracs(m_kk);
|
||||
Phase::getMoleFractions(&moleFracs[0]);
|
||||
doublereal vtotal = 0.0;
|
||||
for (size_t i = 0; i < m_kk; i++) {
|
||||
vtotal += vbar[i] * moleFracs[i];
|
||||
}
|
||||
doublereal dd = meanMolecularWeight() / vtotal;
|
||||
Phase::setDensity(dd);
|
||||
}
|
||||
|
||||
void MaskellSolidSolnPhase::setPressure(doublereal p)
|
||||
{
|
||||
m_Pcurrent = p;
|
||||
|
|
@ -180,6 +193,7 @@ getPartialMolarCp(doublereal* cpbar) const
|
|||
void MaskellSolidSolnPhase::
|
||||
getPartialMolarVolumes(doublereal* vbar) const
|
||||
{
|
||||
getStandardVolumes(vbar);
|
||||
}
|
||||
|
||||
void MaskellSolidSolnPhase::
|
||||
|
|
@ -254,7 +268,7 @@ void MaskellSolidSolnPhase::initThermoXML(XML_Node& phaseNode, const std::string
|
|||
* Call the base initThermo, which handles setting the initial
|
||||
* state.
|
||||
*/
|
||||
ThermoPhase::initThermoXML(phaseNode, id_);
|
||||
VPStandardStateTP::initThermoXML(phaseNode, id_);
|
||||
}
|
||||
|
||||
void MaskellSolidSolnPhase::_updateThermo() const
|
||||
|
|
|
|||
|
|
@ -29,17 +29,12 @@
|
|||
<species name="H(s)">
|
||||
<atomArray> H:1 He:2 </atomArray>
|
||||
<thermo>
|
||||
<Shomate Pref="1 bar" Tmax="800." Tmin="250.0">
|
||||
<floatArray size="1">
|
||||
1.,
|
||||
1.,
|
||||
1.,
|
||||
1.,
|
||||
1.,
|
||||
1.,
|
||||
1.,
|
||||
</floatArray>
|
||||
</Shomate>
|
||||
<const_cp Pref="1 bar" Tmax="800." Tmin="250.0">
|
||||
<t0>1</t0>
|
||||
<h0>0</h0>
|
||||
<s0>0</s0>
|
||||
<cp0>0</cp0>
|
||||
</const_cp>
|
||||
</thermo>
|
||||
<standardState model="constant_incompressible">
|
||||
<molarVolume units="m3/kmol"> 0.005 </molarVolume>
|
||||
|
|
@ -49,20 +44,15 @@
|
|||
<species name="He(s)">
|
||||
<atomArray> H:0 He:1 </atomArray>
|
||||
<thermo>
|
||||
<Shomate Pref="1 bar" Tmax="800." Tmin="250.0">
|
||||
<floatArray size="1">
|
||||
6.94544000E+01,
|
||||
6.94544000E+01,
|
||||
6.94544000E+01,
|
||||
6.94544000E+01,
|
||||
6.94544000E+01,
|
||||
6.94544000E+01,
|
||||
6.94544000E+01,
|
||||
</floatArray>
|
||||
</Shomate>
|
||||
<const_cp Pref="1 bar" Tmax="800." Tmin="250.0">
|
||||
<t0>1</t0>
|
||||
<h0>1000</h0>
|
||||
<s0>0</s0>
|
||||
<cp0>0</cp0>
|
||||
</const_cp>
|
||||
</thermo>
|
||||
<standardState model="constant_incompressible">
|
||||
<molarVolume units="m3/kmol"> 0.005 </molarVolume>
|
||||
<molarVolume units="m3/kmol"> 0.01 </molarVolume>
|
||||
</standardState>
|
||||
</species>
|
||||
</speciesData>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "gtest/gtest.h"
|
||||
#include "cantera/thermo/MaskellSolidSolnPhase.h"
|
||||
#include "cantera/thermo/SimpleThermo.h"
|
||||
#include "cantera/thermo/VPSSMgr_General.h"
|
||||
#include "cantera/thermo/ThermoFactory.h"
|
||||
#include <iostream>
|
||||
|
||||
|
|
@ -16,37 +17,6 @@ public:
|
|||
|
||||
~MaskellSolidSolnPhase_Test() { delete test_phase; }
|
||||
|
||||
void initializeTestPhaseWithSimpleThermo()
|
||||
{
|
||||
test_phase = new MaskellSolidSolnPhase();
|
||||
test_phase->addElement("A", 1.);
|
||||
test_phase->addElement("B", 2.);
|
||||
std::vector<double> comp(2);
|
||||
comp[0] = 1.;
|
||||
comp[1] = 0.;
|
||||
test_phase->addSpecies("A", &comp[0], 0., 1.);
|
||||
comp[0] = 0.;
|
||||
comp[1] = 1.;
|
||||
test_phase->addSpecies("B", &comp[0], 0., 1.);
|
||||
|
||||
// Setup simple thermo so that the standard state enthalpy and
|
||||
// gibbs free energies are always 0 so that we can just test the
|
||||
// additional contribution from the Maskell model
|
||||
SimpleThermo * spec_thermo = new SimpleThermo();
|
||||
std::vector<double> coeffs(4);
|
||||
coeffs[0] = 1;
|
||||
coeffs[1] = 0;
|
||||
coeffs[2] = 0;
|
||||
coeffs[3] = 0;
|
||||
spec_thermo->install("A", 0, 0, &coeffs[0], 0., 1000., 1.);
|
||||
coeffs[1] = 1000;
|
||||
spec_thermo->install("B", 1, 0, &coeffs[0], 0., 1000., 1.);
|
||||
test_phase->setSpeciesThermo(spec_thermo);
|
||||
|
||||
test_phase->setState_TP(298., 1.);
|
||||
set_r(0.5);
|
||||
}
|
||||
|
||||
void initializeTestPhaseWithXML(const std::string & filename)
|
||||
{
|
||||
test_phase = newPhase(filename.c_str(), "");
|
||||
|
|
@ -87,7 +57,10 @@ TEST_F(MaskellSolidSolnPhase_Test, construct_from_xml)
|
|||
|
||||
TEST_F(MaskellSolidSolnPhase_Test, chem_potentials)
|
||||
{
|
||||
initializeTestPhaseWithSimpleThermo();
|
||||
const std::string valid_file("../data/MaskellSolidSolnPhase_valid.xml");
|
||||
initializeTestPhaseWithXML(valid_file);
|
||||
test_phase->setState_TP(298., 1.);
|
||||
set_r(0.5);
|
||||
|
||||
MaskellSolidSolnPhase * maskell_phase = dynamic_cast<MaskellSolidSolnPhase *>(test_phase);
|
||||
|
||||
|
|
@ -104,4 +77,16 @@ TEST_F(MaskellSolidSolnPhase_Test, chem_potentials)
|
|||
check_chemPotentials(expected_result_minus_5000);
|
||||
}
|
||||
|
||||
TEST_F(MaskellSolidSolnPhase_Test, partialMolarVolumes)
|
||||
{
|
||||
const std::string valid_file("../data/MaskellSolidSolnPhase_valid.xml");
|
||||
initializeTestPhaseWithXML(valid_file);
|
||||
ASSERT_TRUE(dynamic_cast<MaskellSolidSolnPhase *>(test_phase) != NULL);
|
||||
|
||||
std::vector<double> pmv(2);
|
||||
test_phase->getPartialMolarVolumes(&pmv[0]);
|
||||
EXPECT_EQ(0.005, pmv[0]);
|
||||
EXPECT_EQ(0.01, pmv[1]);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue