From c7ce446b32ac81d90910a9b86f0b4e2d9ae57118 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Wed, 27 Oct 2010 21:07:51 +0000 Subject: [PATCH] Added a special constructor for setting the element potential directly. --- Cantera/src/thermo/FixedChemPotSSTP.cpp | 35 ++++++++++++++++++++- Cantera/src/thermo/FixedChemPotSSTP.h | 41 +++++++++++++++++++------ 2 files changed, 66 insertions(+), 10 deletions(-) diff --git a/Cantera/src/thermo/FixedChemPotSSTP.cpp b/Cantera/src/thermo/FixedChemPotSSTP.cpp index 38aabe132..e9d565e82 100644 --- a/Cantera/src/thermo/FixedChemPotSSTP.cpp +++ b/Cantera/src/thermo/FixedChemPotSSTP.cpp @@ -22,8 +22,9 @@ #include "SpeciesThermo.h" #include "ThermoFactory.h" -#include +#include +#include "SimpleThermo.h" namespace Cantera { //==================================================================================================================== /* @@ -96,6 +97,38 @@ namespace Cantera { chemPot_ = (m_h0_RT[0] - m_s0_R[0]) * GasConstant * temperature(); } } + //==================================================================================================================== + FixedChemPotSSTP::FixedChemPotSSTP(std::string Ename, doublereal val) : + SingleSpeciesTP(), + chemPot_(0.0) + { + + std::string pname = Ename + "Fixed"; + setID(pname); + setName(pname); + setNDim(3); + addUniqueElement(Ename, -12345.); + freezeElements(); + int nel = nElements(); + vector_fp ecomp(nel, 0.0); + ecomp[0] = 1.0; + double chrg = 0.0; + SpeciesThermo* spth = new SimpleThermo(); + setSpeciesThermo(spth); + addUniqueSpecies(pname, &ecomp[0], chrg, 0.0); + double c[4]; + c[0] = 298.15; + c[1] = val; + c[2] = 0.0; + c[3] = 0.0; + m_spthermo->install(pname, 0, SIMPLE, c, 0.0, 1.0E30, OneAtm); + freezeSpecies(); + initThermo(); + m_p0 = OneAtm; + m_tlast = 298.15; + setChemicalPotential(val); + } + //==================================================================================================================== // Copy constructor /* diff --git a/Cantera/src/thermo/FixedChemPotSSTP.h b/Cantera/src/thermo/FixedChemPotSSTP.h index 1df7ec613..8090aac8a 100644 --- a/Cantera/src/thermo/FixedChemPotSSTP.h +++ b/Cantera/src/thermo/FixedChemPotSSTP.h @@ -76,9 +76,11 @@ namespace Cantera { * * Instanteation of the Class * - * The constructor for this phase is located in the default ThermoFactory - * for %Cantera. A new %FixedChemPotSSTP may be created by a standalone xml file - * which is given below. + * This phase may be instanteated by calling the default ThermoFactory routine + * for %Cantera. This new %FixedChemPotSSTP object must then have a standalone xml file + * description an example of which is given below. + * + * * * It may also be created by the following code snippets. The code * includes the special member function setChemicalPotential( chempot), which @@ -101,13 +103,19 @@ namespace Cantera { * importPhase(*xm, &solid); * @endcode * + * The phase may also be created by a special constructor so that element + * potentials may be set. The constructor takes the name of the element and + * the value of the element chemical potential. An example is given below. + * + * @code + * FixedChemPotSSTP *LiFixed = new FixedChemPotSSTP("Li", -2.3E7); + * @endcode + * * XML Example * - * The phase model name for this is called StoichSubstance. It must be supplied + * The phase model name for this is called FixedChemPot. It must be supplied * as the model attribute of the thermo XML element entry. - * Within the phase XML block, - * the density of the phase must be specified. An example of an XML file - * this phase is given below. + * * * @verbatim @@ -182,6 +190,18 @@ namespace Cantera { * @param right Object to be copied */ FixedChemPotSSTP(const FixedChemPotSSTP &right); + + //! Special constructor for the FixecChemPotSSTP class setting an element chemical + //! potential directly + /*! + * This will create a %FixedChemPotSSTP consisting of a single species with the + * stoichiometry of one of the specified atom. It will have a chemical potential + * that is given by the second argument. + * + * @param Ename String name of the element + * @param chemPot Value of the chemical potential of that element (J/kmol) + */ + FixedChemPotSSTP(std::string Ename, doublereal chemPot); //! Assignment operator /*! @@ -619,8 +639,11 @@ namespace Cantera { protected: - - double chemPot_; + //! Value of the chemical potential of the bath species + /*! + * units are J/kmol + */ + doublereal chemPot_; };