Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate redundant ThermoPhase classes #787

Merged
merged 2 commits into from
Apr 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/sphinx/yaml/phases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ Example::
A phase defined by a fixed value of the chemical potential, as
`described here <https://cantera.org/documentation/dev/doxygen/html/d6/db0/classCantera_1_1FixedChemPotSSTP.html#details>`__.

.. deprecated:: 2.5
Use class StoichSubstance with a constant-cp species thermo model, with 'h0'
set to the desired chemical potential and 's0' set to 0.

Additional fields:

``chemical-potential``
Expand Down Expand Up @@ -538,6 +542,9 @@ The ideal gas model as
The ideal gas model, using variable pressure standard state methods as
`described here <https://cantera.org/documentation/dev/doxygen/html/dc/ddb/classCantera_1_1IdealSolnGasVPSS.html#details>`__.

.. deprecated:: 2.5
Use the ``ideal-gas`` model instead.


.. _sec-yaml-ideal-molal-solution:

Expand Down
2 changes: 1 addition & 1 deletion ext/sundials
Submodule sundials updated 997 files
9 changes: 8 additions & 1 deletion include/cantera/thermo/IdealSolnGasVPSS.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ namespace Cantera
*
* An ideal solution or an ideal gas approximation of a phase. Uses variable
* pressure standard state methods for calculating thermodynamic properties.
*
* @deprecated "Gas" mode to be removed after Cantera 2.5. Use IdealGasPhase for
* ideal gas phases instead.
*/
class IdealSolnGasVPSS : public VPStandardStateTP
{
Expand Down Expand Up @@ -62,7 +65,11 @@ class IdealSolnGasVPSS : public VPStandardStateTP
}

//! Set this phase to represent an ideal gas
void setGasMode() { m_idealGas = true; }
void setGasMode() {
warn_deprecated("IdealSolnGasVPSS::setGasMode",
"To be removed after Cantera 2.5. Use class IdealGasPhase instead.");
m_idealGas = true;
}

//! Set this phase to represent an ideal liquid or solid solution
void setSolnMode() { m_idealGas = false; }
Expand Down
8 changes: 7 additions & 1 deletion interfaces/cython/cantera/test/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,13 +1054,16 @@ def test_fractional_stoich_coeffs(self):
self.checkThermo(ctmlGas, yamlGas, [300, 500, 1300, 2000])
self.checkKinetics(ctmlGas, yamlGas, [900, 1800], [2e5, 20e5])

# @todo Remove after Cantera 2.5 - class FixedChemPotSSTP is deprecated
def test_fixed_chemical_potential_thermo(self):
ct.suppress_deprecation_warnings()
ctml2yaml.convert(
Path(self.test_data_dir).joinpath("LiFixed.xml"),
Path(self.test_work_dir).joinpath("LiFixed.yaml"),
)
ctmlGas, yamlGas = self.checkConversion("LiFixed")
self.checkThermo(ctmlGas, yamlGas, [300, 500, 1300, 2000])
ct.make_deprecation_warnings_fatal()

def test_water_IAPWS95_thermo(self):
ctml2yaml.convert(
Expand Down Expand Up @@ -1187,7 +1190,9 @@ def test_vpss_and_hkft(self):
Path(self.test_data_dir).joinpath("pdss_hkft.xml"),
Path(self.test_work_dir).joinpath("pdss_hkft.yaml"),
)

# @todo Remove "gas" mode test after Cantera 2.5 - "gas" mode of class
# IdealSolnGasVPSS is deprecated
ct.suppress_deprecation_warnings()
for name in ["vpss_gas_pdss_hkft_phase", "vpss_soln_pdss_hkft_phase"]:
ctmlPhase = ct.ThermoPhase("pdss_hkft.xml", name=name)
yamlPhase = ct.ThermoPhase("pdss_hkft.yaml", name=name)
Expand All @@ -1200,6 +1205,7 @@ def test_vpss_and_hkft(self):
self.assertEqual(ctmlPhase.element_names, yamlPhase.element_names)
self.assertEqual(ctmlPhase.species_names, yamlPhase.species_names)
self.checkThermo(ctmlPhase, yamlPhase, [300, 500])
ct.make_deprecation_warnings_fatal()

def test_lattice_solid(self):
ctml2yaml.convert(
Expand Down
12 changes: 12 additions & 0 deletions src/thermo/FixedChemPotSSTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,34 @@ namespace Cantera
FixedChemPotSSTP::FixedChemPotSSTP() :
chemPot_(0.0)
{
warn_deprecated("class FixedChemPotSSTP", "To be removed after Cantera 2.5. "
"Use class StoichSubstance with a constant-cp species thermo model, "
"with 'h0' set to the desired chemical potential and 's0' set to 0.");
}

FixedChemPotSSTP::FixedChemPotSSTP(const std::string& infile, const std::string& id_) :
chemPot_(0.0)
{
warn_deprecated("class FixedChemPotSSTP", "To be removed after Cantera 2.5. "
"Use class StoichSubstance with a constant-cp species thermo model, "
"with 'h0' set to the desired chemical potential and 's0' set to 0.");
initThermoFile(infile, id_);
}
FixedChemPotSSTP::FixedChemPotSSTP(XML_Node& xmlphase, const std::string& id_) :
chemPot_(0.0)
{
warn_deprecated("class FixedChemPotSSTP", "To be removed after Cantera 2.5. "
"Use class StoichSubstance with a constant-cp species thermo model, "
"with 'h0' set to the desired chemical potential and 's0' set to 0.");
importPhase(xmlphase, this);
}

FixedChemPotSSTP::FixedChemPotSSTP(const std::string& Ename, doublereal val) :
chemPot_(0.0)
{
warn_deprecated("class FixedChemPotSSTP", "To be removed after Cantera 2.5. "
"Use class StoichSubstance with a constant-cp species thermo model, "
"with 'h0' set to the desired chemical potential and 's0' set to 0.");
std::string pname = Ename + "Fixed";
setName(pname);
setNDim(3);
Expand Down
3 changes: 3 additions & 0 deletions test/data/thermo-models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ phases:
transport: water
species: [H2O(l)]

# @todo Remove after Cantera 2.5 - class FixedChemPotSSTP is deprecated
- name: Li-fixed
thermo: fixed-chemical-potential
species: [Li]
Expand Down Expand Up @@ -93,6 +94,8 @@ phases:
species: [KCl(l)]
thermo: Margules

# todo: Remove after Cantera 2.5 - the "gas" moode of class IdealSolnGasVPSS is
# deprecated.
- name: IdealSolnGas-gas
thermo: ideal-gas-VPSS
species: [{gas-species: [H2O, H2, O2]}]
Expand Down
10 changes: 9 additions & 1 deletion test/thermo/phaseConstructors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,31 @@ shared_ptr<Species> make_const_cp_species(const std::string& name,
return species;
}


//! @todo Remove after Cantera 2.5 - class FixedChemPotSSTP is deprecated
class FixedChemPotSstpConstructorTest : public testing::Test
{
};

TEST_F(FixedChemPotSstpConstructorTest, fromXML)
{
suppress_deprecation_warnings();
std::unique_ptr<ThermoPhase> p(newPhase("../data/LiFixed.xml"));
ASSERT_EQ((int) p->nSpecies(), 1);
double mu;
p->getChemPotentials(&mu);
ASSERT_DOUBLE_EQ(-2.3e7, mu);
make_deprecation_warnings_fatal();
}

TEST_F(FixedChemPotSstpConstructorTest, SimpleConstructor)
{
suppress_deprecation_warnings();
FixedChemPotSSTP p("Li", -2.3e7);
ASSERT_EQ((int) p.nSpecies(), 1);
double mu;
p.getChemPotentials(&mu);
ASSERT_DOUBLE_EQ(-2.3e7, mu);
make_deprecation_warnings_fatal();
}

TEST(IonsFromNeutralConstructor, fromXML)
Expand Down Expand Up @@ -344,8 +348,11 @@ TEST_F(ConstructFromScratch, RedlichKwongMFTP_missing_coeffs)
EXPECT_THROW(p.setState_TP(300, 200e5), CanteraError);
}

//! @todo Remove after Cantera 2.5 - "gas" mode of IdealSolnGasVPSS is
//! deprecated
TEST_F(ConstructFromScratch, IdealSolnGasVPSS_gas)
{
suppress_deprecation_warnings();
IdealSolnGasVPSS p;
p.addSpecies(sH2O);
p.addSpecies(sH2);
Expand All @@ -367,6 +374,7 @@ TEST_F(ConstructFromScratch, IdealSolnGasVPSS_gas)
EXPECT_NEAR(p.temperature(), 479.929, 1e-3); // based on h2o2.cti
EXPECT_NEAR(p.moleFraction("H2O"), 0.01, 1e-4);
EXPECT_NEAR(p.moleFraction("H2"), 0.0, 1e-4);
make_deprecation_warnings_fatal();
}

TEST(PureFluidFromScratch, CarbonDioxide)
Expand Down
7 changes: 7 additions & 0 deletions test/thermo/thermoFromYaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,16 @@ TEST(ThermoFromYaml, WaterSSTP)
EXPECT_NEAR(thermo->enthalpy_mass(), -15649685.52296013, 1e-6);
}

//! @todo Remove after Cantera 2.5 - class FixedChemPotSSTP is deprecated
TEST(ThermoFromYaml, FixedChemPot)
{
suppress_deprecation_warnings();
auto thermo = newThermo("thermo-models.yaml", "Li-fixed");
EXPECT_EQ(thermo->nSpecies(), (size_t) 1);
double mu;
thermo->getChemPotentials(&mu);
EXPECT_DOUBLE_EQ(mu, -2.3e7);
make_deprecation_warnings_fatal();
}

TEST(ThermoFromYaml, Margules)
Expand Down Expand Up @@ -234,9 +237,13 @@ TEST(ThermoFromYaml, IonsFromNeutral_fromString)
EXPECT_NEAR(mu[1], -2.88157316e+06, 1e-1);
}

//! @todo Remove after Cantera 2.5 - "gas" mode of IdealSolnGasVPSS is
//! deprecated
TEST(ThermoFromYaml, IdealSolnGas_gas)
{
suppress_deprecation_warnings();
auto thermo = newThermo("thermo-models.yaml", "IdealSolnGas-gas");
make_deprecation_warnings_fatal();
thermo->equilibrate("HP");
EXPECT_NEAR(thermo->temperature(), 479.929, 1e-3); // based on h2o2.cti
EXPECT_NEAR(thermo->moleFraction("H2O"), 0.01, 1e-4);
Expand Down
26 changes: 25 additions & 1 deletion test_problems/VCSnonideal/LatticeSolid_LiSi/Li7Si3_ls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<transport model="None"/>
<kinetics model="none"/>
</phase>

<!-- phase Li7Si3_Interstitial -->

<phase dim="3" id="Li7Si3_Interstitial">
Expand Down Expand Up @@ -55,6 +55,18 @@
</thermo>
</phase>

<phase dim="3" id="LiFixed">
<elementArray datasrc="elements.xml">
Li
</elementArray>
<speciesArray datasrc="#species_LiSi(S)"> LiFixed </speciesArray>
<thermo model="StoichSubstance">
<density units="g/cm3"> 0.534 </density>
</thermo>
<transport model="None"/>
<kinetics model="none"/>
</phase>


<!-- species definitions -->
<speciesData id="species_LiSi(S)">
Expand Down Expand Up @@ -148,6 +160,18 @@
</thermo>
</species>

<!-- species Li_Fixed -->
<species name="LiFixed">
<atomArray> Li:1 </atomArray>
<thermo>
<const_cp Pref="1 bar" Tmax="5000.0" Tmin="100.0">
<t0 units="K">298.15</t0>
<h0 units="J/kmol"> -2.3e7 </h0>
<s0 units="J/mol/K"> 0.0 </s0>
<cp0 units="J/mol/K"> 0.0 </cp0>
</const_cp>
</thermo>
</species>


</speciesData>
Expand Down
15 changes: 9 additions & 6 deletions test_problems/VCSnonideal/LatticeSolid_LiSi/latsol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include "cantera/thermo/MargulesVPSSTP.h"
#include "cantera/thermo/FixedChemPotSSTP.h"
#include "cantera/thermo/LatticeSolidPhase.h"
#include "cantera/thermo/ConstCpPoly.h"
#include "cantera/equil/vcs_MultiPhaseEquil.h"
#include "cantera/thermo.h"

#include <stdio.h>

Expand All @@ -18,7 +18,7 @@ void testProblem(int printLvl)
std::unique_ptr<ThermoPhase> LiSi_solid(newPhase("Li7Si3_ls.xml",
"Li7Si3_and_Interstitials(S)"));
std::unique_ptr<ThermoPhase> Li_liq(newPhase("Li_Liquid.xml", "Li(L)"));
FixedChemPotSSTP LiFixed("Li", -2.3E7);
std::unique_ptr<ThermoPhase> LiFixed(newPhase("Li7Si3_ls.xml", "LiFixed"));
MargulesVPSSTP salt("LiKCl_liquid.xml", "MoltenSalt_electrolyte");

// set states
Expand All @@ -32,10 +32,10 @@ void testProblem(int printLvl)
int ee = static_cast<int>(LiSi_solid->nElements());
printf("Number of elements = %d\n", ee);

LiFixed.setState_TP(T, OneAtm);
LiFixed->setState_TP(T, OneAtm);

double um[20];
LiFixed.getChemPotentials(um);
LiFixed->getChemPotentials(um);
printf(" chem pot = %g\n", um[0]);

double volts = 1.635; // has some Fe in it // test suite
Expand All @@ -45,13 +45,16 @@ void testProblem(int printLvl)
Li_liq->getChemPotentials(um);
double um_li_chempot = um[0] + dg_corr;
printf("um_li_chempot = %g\n", um_li_chempot);
LiFixed.setChemicalPotential(um_li_chempot);
auto LiFixed_species = LiFixed->species(0);
auto spthermo = std::dynamic_pointer_cast<ConstCpPoly>(LiFixed_species->thermo);
spthermo->setParameters(298.15, um_li_chempot, 0, 0);
LiFixed->modifySpecies(0, LiFixed_species);

MultiPhase mmm;

mmm.addPhase(&salt, 10.);
mmm.addPhase(LiSi_solid.get(), 1.);
mmm.addPhase(&LiFixed, 100.);
mmm.addPhase(LiFixed.get(), 100.);

int estimateEquil = 0;

Expand Down
13 changes: 6 additions & 7 deletions test_problems/VCSnonideal/LatticeSolid_LiSi/output_blessed.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ um_li_chempot = -1.65555e+08
Trying VCS equilibrium solver
Unknown Cantera EOS to VCSnonideal: 'Margules'
Unknown Cantera EOS to VCSnonideal: 'LatticeSolid'
Unknown Cantera EOS to VCSnonideal: 'FixedChemPot'

================================================================================
================ Cantera_to_vprob: START OF PROBLEM STATEMENT ====================
Expand All @@ -24,7 +23,7 @@ Unknown Cantera EOS to VCSnonideal: 'FixedChemPot'
PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec TMolesInert Tmoles(kmol)
MoltenSalt_electrolyte 0 0 0 UnkType: -1 2 0.000000e+00 1.000000e+01
Li7Si3_and_Interstitials(S) 1 0 0 UnkType: -1 3 0.000000e+00 1.000000e+00
LiFixed 2 1 0 UnkType: -1 1 0.000000e+00 1.000000e+02
LiFixed 2 1 0 Stoich Sub 1 0.000000e+00 1.000000e+02

================================================================================
================ Cantera_to_vprob: END OF PROBLEM STATEMENT ====================
Expand All @@ -49,7 +48,7 @@ Li7Si3_and_Interstitials(S) 1 0 0 UnkType: -1 3 0
PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec TMolesInert Tmoles(kmol)
MoltenSalt_electrolyte 0 0 0 UnkType: -1 2 0.000000e+00 1.000000e+01
Li7Si3_and_Interstitials(S) 1 0 0 UnkType: -1 3 0.000000e+00 1.000000e+00
LiFixed 2 1 0 UnkType: -1 1 0.000000e+00 1.000000e+02
LiFixed 2 1 0 Stoich Sub 1 0.000000e+00 1.000000e+02

================================================================================
==================== Cantera_to_vprob: END OF PROBLEM STATEMENT ====================
Expand Down Expand Up @@ -78,7 +77,7 @@ Li7Si3_and_Interstitials(S) 1 0 0 UnkType: -1 3 0
PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec TMolesInert TKmoles
MoltenSalt_electrolyte 0 0 0 UnkType: -1 2 0.000000e+00 1.000000e+01
Li7Si3_and_Interstitials(S) 1 0 0 UnkType: -1 3 0.000000e+00 1.000000e+00
LiFixed 2 1 0 UnkType: -1 1 0.000000e+00 1.000000e+02
LiFixed 2 1 0 Stoich Sub 1 0.000000e+00 1.000000e+02

Elemental Abundances: Target_kmol ElemType ElActive
Li 1.105050000000E+02 0 1
Expand Down Expand Up @@ -145,7 +144,7 @@ VCS CALCULATION METHOD
--------------------------------------------------------------------------------
Temperature = 6.3e+02 Kelvin
Pressure = 1.0132e+05 Pa
total Volume = 0.35041 m**3
total Volume = 1.6501 m**3


--------------------------------------------------------------------------------
Expand Down Expand Up @@ -295,14 +294,14 @@ Moles: 100.005

temperature 625.15 K
pressure 1.0132e+05 Pa
density 0.001 kg/m^3
density 534 kg/m^3
mean mol. weight 6.94 kg/kmol
phase of matter unspecified

1 kg 1 kmol
--------------- ---------------
enthalpy -2.3855e+07 -1.6556e+08 J
internal energy -1.2399e+14 -8.6052e+14 J
internal energy -2.3855e+07 -1.6556e+08 J
entropy 0 0 J/K
Gibbs function -2.3855e+07 -1.6556e+08 J
heat capacity c_p 0 0 J/K
Expand Down
Loading