Cleaned up Doxygen documentation for class vcs_VolPhase

This commit is contained in:
Ray Speth 2013-04-18 22:08:11 +00:00
parent 30b01ab8fd
commit fa9f58cb8a
2 changed files with 113 additions and 486 deletions

View file

@ -17,9 +17,6 @@
#include <vector>
#include <string>
/*
* Forward references
*/
// Forward reference for ThermoPhase object within the Cantera namespace
namespace Cantera
{
@ -28,29 +25,23 @@ class ThermoPhase;
namespace VCSnonideal
{
/*
* Models for the species activity coefficients
*
*/
// Models for the species activity coefficients
#define VCS_AC_CONSTANT 0
//#define VCS_AC_DEBYE_HUCKEL 23
//#define VCS_AC_REGULAR_SOLN 25
//#define VCS_AC_MARGULES 300
#define VCS_AC_UNK_CANTERA -1
#define VCS_AC_UNK -2
/*
*
* Models for the standard state volume of each species
*/
//! Models for the standard state volume of each species
#define VCS_SSVOL_IDEALGAS 0
#define VCS_SSVOL_CONSTANT 1
/*
* DEFINITIONS FOR THE vcs_VolPhase structure
* DEFINITIONS FOR THE vcs_VolPhase structure
*
*
* Equation of State Types
* - Permissible values for the EqnState variable in CPC_PHASE structure
* Equation of State Types
* - Permissible values for the EqnState variable in CPC_PHASE structure
*/
#define VCS_EOS_CONSTANT 0
#define VCS_EOS_IDEAL_GAS 1
@ -61,12 +52,10 @@ namespace VCSnonideal
#define VCS_EOS_REGULAR_SOLN 25
#define VCS_EOS_UNK_CANTERA -1
struct VCS_SPECIES;
class vcs_SpeciesProperties;
class VCS_SOLVE;
//! Phase information and Phase calculations for vcs.
/*!
* Each phase in a vcs calculation has a vcs_VolPhase object associated
@ -104,7 +93,6 @@ class VCS_SOLVE;
* see if the phase currently exists or not, and modifies its behavior
* accordingly.
*
*
* Activity coefficients and volume calculations are lagged. They are only
* called when they are needed (and when the state has changed so that they
* need to be recalculated).
@ -112,30 +100,14 @@ class VCS_SOLVE;
class vcs_VolPhase
{
public:
/*************************************************************************
* FUNCTIONS *
************************************************************************/
//! Base constructor for the class
vcs_VolPhase(VCS_SOLVE* owningSolverObject = 0);
//! Copy constructor
/*!
* @param b object to be copied
*/
vcs_VolPhase(const vcs_VolPhase& b);
//! Assignment operator
/*!
* @param b object to be copied
*/
vcs_VolPhase& operator=(const vcs_VolPhase& b);
//! Destructor
~vcs_VolPhase();
//! The resize() function fills in all of the initial information if it
//! is not given in the constructor.
/*!
@ -152,8 +124,9 @@ public:
//! Evaluate activity coefficients and return the kspec coefficient
/*!
* We carry out a calculation whenever UpTODate_AC is false. Specifically
* whenever a phase goes zero, we do not carry out calculations on it.
* We carry out a calculation whenever #m_UpToDate_AC is false.
* Specifically whenever a phase goes zero, we do not carry out
* calculations on it.
*
* @param kspec species number
*/
@ -162,8 +135,6 @@ public:
//! Set the moles and/or mole fractions within the phase
/*!
* Sets the mole fraction and total moles within the phase
*
* @param molNum total moles in the phase
* @param moleFracVec Vector of input mole fractions
* @param vcsStateStatus Status flag for this update
@ -177,11 +148,10 @@ public:
* then updates this object with their values. This is essentially
* a gather routine.
*
* @param molesSpeciesVCS Array of mole numbers. Note, the indices
* for species in
* this array may not be contiguous. IndSpecies[] is needed
* to gather the species into the local contiguous vector
* format.
* @param molesSpeciesVCS Array of mole numbers. Note, the indices for
* species in this array may not be contiguous. IndSpecies[] is
* needed to gather the species into the local contiguous
* vector format.
*/
void setMolesFromVCS(const int stateCalc,
const double* molesSpeciesVCS = 0);
@ -196,8 +166,8 @@ public:
* TPhMoles[iplace] is equal to the internally computed value.
* If this isn't the case, an error exit is carried out.
*
* @param vcsStateStatus State calc value either VCS_STATECALC_OLD
* or VCS_STATECALC_NEW. With any other value nothing is done.
* @param vcsStateStatus State calc value either `VCS_STATECALC_OLD` or
* `VCS_STATECALC_NEW`. With any other value nothing is done.
* @param molesSpeciesVCS array of mole numbers. Note, the indices
* for species in this array may not be contiguous. IndSpecies[] is
* needed to gather the species into the local contiguous vector
@ -210,15 +180,13 @@ public:
//! Update the moles within the phase, if necessary
/*!
* This function takes as input the stateCalc value, which
* determines where within VCS_SOLVE to fetch the mole numbers.
* It then updates this object with their values. This is essentially
* a gather routine.
*
* @param stateCalc State calc value either VCS_STATECALC_OLD
* or VCS_STATECALC_NEW. With any other value
* nothing is done.
* This function takes as input the stateCalc value, which determines
* where within VCS_SOLVE to fetch the mole numbers. It then updates this
* object with their values. This is essentially a gather routine.
*
* @param stateCalc State calc value either VCS_STATECALC_OLD
* or VCS_STATECALC_NEW. With any other value
* nothing is done.
*/
void updateFromVCS_MoleNumbers(const int stateCalc);
@ -269,7 +237,7 @@ public:
//! Molar volume calculation for standard state of one species
/*!
* Calculate the molar volume for the standard states. The results are held
* internally within the object. Return the molar volume for one species.
* internally within the object.
*
* @param kspec Species number (within the phase)
* @return molar volume of the kspec species's standard state (m**3/kmol)
@ -302,25 +270,16 @@ public:
*/
void sendToVCS_GStar(double* const gstar) const;
//! Sets the temperature and pressure in this object and
//! underlying objects
//! Sets the temperature and pressure in this object and underlying
//! ThermoPhase objects
/*!
* Sets the temperature and pressure in this object and
* underlying objects. The underlying objects refers to the
* Cantera's ThermoPhase object for this phase.
*
* @param temperature_Kelvin (Kelvin)
* @param pressure_PA Pressure (MKS units - Pascal)
*/
void setState_TP(const double temperature_Kelvin, const double pressure_PA);
//! Sets the temperature in this object and
//! underlying objects
//! Sets the temperature in this object and underlying ThermoPhase objects
/*!
* Sets the temperature and pressure in this object and
* underlying objects. The underlying objects refers to the
* Cantera's ThermoPhase object for this phase.
*
* @param temperature_Kelvin (Kelvin)
*/
void setState_T(const double temperature_Kelvin);
@ -328,7 +287,6 @@ public:
// Downloads the ln ActCoeff jacobian into the VCS version of the
// ln ActCoeff jacobian.
/*
*
* This is essentially a scatter operation.
*
* @param LnAcJac_VCS jacobian parameter
@ -358,9 +316,7 @@ public:
//! Return the total moles in the phase
/*!
*
* Units -> depends on VCS_UnitsFormat variable
* Cantera -> J/kmol
* Units -> depends on VCS_UnitsFormat variable. Cantera -> J/kmol
*/
double totalMoles() const;
@ -389,24 +345,18 @@ public:
void setMolesOutOfDate(int stateCalc = -1);
//! Sets the mole flag within the object to be current
/*!
*
*/
void setMolesCurrent(int vcsStateStatus);
private:
//! Set the mole fractions from a conventional mole fraction vector
/*!
*
* @param xmol Value of the mole fractions for the species
* in the phase. These are contiguous.
*/
void setMoleFractions(const double* const xmol);
public:
//! Return a const reference to the mole fractions stored in the
//! object.
//! Return a const reference to the mole fractions stored in the object.
const std::vector<double> & moleFractions() const;
double moleFraction(size_t klocal) const;
@ -543,9 +493,8 @@ public:
//! Transfer all of the element information from the
//! ThermoPhase object to the vcs_VolPhase object.
/*!
* Also decide whether we need a new charge neutrality
* element in the phase to enforce a charge neutrality
* constraint.
* Also decide whether we need a new charge neutrality element in the
* phase to enforce a charge neutrality constraint.
*
* @param tPhase Pointer to the thermophase object
*/
@ -553,9 +502,8 @@ public:
//! Get a constant form of the Species Formula Matrix
/*!
* Returns a double ** pointer such that
*
* fm[e][f] is the formula matrix entry for element e for species k
* Returns a `double**` pointer such that `fm[e][f]` is the formula
* matrix entry for element `e` for species `k`
*/
double const* const* getFormulaMatrix() const;
@ -563,27 +511,25 @@ public:
/*!
* @param k species index
*
* returns the SpeciesUnknownType[k] = type of species
* Normal -> VCS_SPECIES_TYPE_MOLUNK
* ( unknown is the mole number in the phase)
* metal electron -> VCS_SPECIES_INTERFACIALVOLTAGE
* ( unknown is the interfacial voltage (volts)
* @return the SpeciesUnknownType[k] = type of species
* - Normal -> VCS_SPECIES_TYPE_MOLUNK (unknown is the mole number in
* the phase)
* - metal electron -> VCS_SPECIES_INTERFACIALVOLTAGE (unknown is the
* interfacial voltage (volts))
*/
int speciesUnknownType(const size_t k) const;
int elementActive(const size_t e) const;
//! Return the number of species in the phase
size_t nSpecies() const;
private:
//! Evaluate the activity coefficients at the current conditions
/*!
* We carry out a calculation whenever UpTODate_AC is false. Specifically
* whenever a phase goes zero, we do not carry out calculations on it.
* We carry out a calculation whenever #m_UpToDate_AC is false.
* Specifically whenever a phase goes zero, we do not carry out
* calculations on it.
*/
void _updateActCoeff() const;
@ -608,17 +554,17 @@ private:
//! Calculate the partial molar volumes of all species and return the
//! total volume
/*!
* Calculates these quantities internally
* Calculates these quantities internally and then stores them
*
* @return total volume
* @return total volume [m^3]
*/
double _updateVolPM() const;
//! Evaluation of Activity Coefficient Jacobians
/*!
* This is the derivative of the ln of the activity coefficient
* with respect to mole number of jth species.
* (temp, pressure, and other mole numbers held constant)
* This is the derivative of the ln of the activity coefficient with
* respect to mole number of jth species. (temp, pressure, and other mole
* numbers held constant)
*
* We employ a finite difference derivative approach here. Because we have
* to change the mole numbers, this is not a const function, even though
@ -628,16 +574,10 @@ private:
//! Updates the mole fraction dependencies
/*!
* Whenever the mole fractions change, this routine
* should be called.
* Whenever the mole fractions change, this routine should be called.
*/
void _updateMoleFractionDependencies();
/*************************************************************************
* MEMBER DATA *
************************************************************************/
private:
//! Backtrack value of VCS_SOLVE *
/*!
@ -649,9 +589,8 @@ private:
public:
//! Original ID of the phase in the problem.
/*!
* If a non-ideal phase splits into two due to a
* miscibility gap, these numbers will stay the
* same after the split.
* If a non-ideal phase splits into two due to a miscibility gap, these
* numbers will stay the same after the split.
*/
size_t VP_ID_;
@ -686,14 +625,13 @@ public:
* quantities will display in these units. Input quantities are expected
* in these units.
*
* Chem_Pot Pres vol moles
* ----------------------------------------------------------------------
* -1 VCS_UNITS_KCALMOL = kcal/gmol Pa m**3 kmol
* 0 VCS_UNITS_UNITLESS = MU / RT -> no units Pa m**3 kmol
* 1 VCS_UNITS_KJMOL = kJ / gmol Pa m**3 kmol
* 2 VCS_UNITS_KELVIN = KELVIN -> MU / R Pa m**3 kmol
* 3 VCS_UNITS_MKS = Joules / Kmol (Cantera) Pa m**3 kmol
* ----------------------------------------------------------------------
* | | | Chem_Pot | Pres | vol | moles|
* |---|--------------------|-------------------------|------|------|------|
* |-1 | VCS_UNITS_KCALMOL | kcal/gmol | Pa | m**3 | kmol |
* | 0 | VCS_UNITS_UNITLESS | MU / RT -> no units | Pa | m**3 | kmol |
* | 1 | VCS_UNITS_KJMOL | kJ / gmol | Pa | m**3 | kmol |
* | 2 | VCS_UNITS_KELVIN | KELVIN -> MU / R | Pa | m**3 | kmol |
* | 3 | VCS_UNITS_MKS | Joules / Kmol (Cantera) | Pa | m**3 | kmol |
*
* see vcs_defs.h for more information.
*
@ -707,10 +645,9 @@ public:
//! Convention for the activity formulation
/*!
* 0 = molar based activities (default)
* 1 = Molality based activities
* mu = mu_0 + ln a_molality
* standard state is based on unity molality
* * 0 = molar based activities (default)
* * 1 = Molality based activities, mu = mu_0 + ln a_molality. Standard
* state is based on unity molality
*/
int p_activityConvention;
@ -733,33 +670,31 @@ private:
//! Type of the element constraint
/*!
* m_elType[j] = type of the element
* 0 VCS_ELEM_TYPE_ABSPOS Normal element that is positive
* or zero in all species.
* 1 VCS_ELEM_TPYE_ELECTRONCHARGE element dof that corresponds
* to the charge DOF.
* 2 VCS_ELEM_TYPE_OTHERCONSTRAINT Other constraint which may
* mean that a species has neg 0 or pos value
* of that constraint (other than charge)
* m_elType[j] = type of the element:
* * 0 VCS_ELEM_TYPE_ABSPOS Normal element that is positive or zero in
* all species.
* * 1 VCS_ELEM_TYPE_ELECTRONCHARGE element dof that corresponds to the
* charge DOF.
* * 2 VCS_ELEM_TYPE_OTHERCONSTRAINT Other constraint which may mean that
* a species has neg 0 or pos value of that constraint (other than
* charge)
*/
std::vector<int> m_elementType;
//! Formula Matrix for the phase
/*!
* FormulaMatrix[j][kspec]
* = Formula Matrix for the species
* Number of elements, j,
* in the kspec species
* FormulaMatrix[j][kspec] = Formula Matrix for the species
* Number of elements, j, in the kspec species
*/
DoubleStarStar m_formulaMatrix;
//! Type of the species unknown
/*!
* SpeciesUnknownType[k] = type of species
* Normal -> VCS_SPECIES_TYPE_MOLUNK
* ( unknown is the mole number in the phase)
* metal electron -> VCS_SPECIES_INTERFACIALVOLTAGE
* ( unknown is the interfacial voltage (volts)
* - Normal -> VCS_SPECIES_TYPE_MOLUNK.
* (unknown is the mole number in the phase)
* - metal electron -> VCS_SPECIES_INTERFACIALVOLTAGE.
* (unknown is the interfacial voltage (volts))
*/
std::vector<int> m_speciesUnknownType;
@ -785,19 +720,17 @@ private:
//! Current state of existence:
/*!
* VCS_PHASE_EXIST_ZEROEDPHASE = -6: Set to not exist by fiat from a
* higher level.
* This is used in phase stability boundary calculations
* VCS_PHASE_EXIST_NO = 0: Doesn't exist currently
* VCS_PHASE_EXIST_MINORCONC = 1: Exists, but the concentration is
* so low that an alternate
* method is used to calculate the total phase concentrations.
* VCS_PHASE_EXIST_YES = 2 : Does exist currently
* VCS_PHASE_EXIST_ALWAYS = 3: Always exists because it contains
* inerts which can't exist in any other phase. Or,
* the phase exists always because it consists of a single
* species, which is identified with the voltage, i.e.,
* its an electron metal phase.
* - VCS_PHASE_EXIST_ZEROEDPHASE = -6: Set to not exist by fiat from a
* higher level. This is used in phase stability boundary calculations
* - VCS_PHASE_EXIST_NO = 0: Doesn't exist currently
* - VCS_PHASE_EXIST_MINORCONC = 1: Exists, but the concentration is so
* low that an alternate method is used to calculate the total phase
* concentrations.
* - VCS_PHASE_EXIST_YES = 2 : Does exist currently
* - VCS_PHASE_EXIST_ALWAYS = 3: Always exists because it contains inerts
* which can't exist in any other phase. Or, the phase exists always
* because it consists of a single species, which is identified with the
* voltage, i.e., its an electron metal phase.
*/
int m_existence;
@ -828,20 +761,17 @@ private:
//! If this is true, then calculations are actually performed within
//! Cantera
bool m_useCanteraCalls;
/**
* If we are using Cantera, this is the
* pointer to the ThermoPhase object. If not, this is null.
* If we are using Cantera, this is the pointer to the ThermoPhase
* object. If not, this is null.
*/
Cantera::ThermoPhase* TP_ptr;
//! Total mols in the phase
/*!
* units are kmol
*/
//! Total mols in the phase. units are kmol
double v_totalMoles;
//! Vector of the current mole fractions for species
//! in the phase
//! Vector of the current mole fractions for species in the phase
std::vector<double> Xmol_;
//! Vector of current creationMoleNumbers_
@ -857,23 +787,21 @@ private:
* in the phase that are not components. For component species, the
* choice of the reaction is one which maximizes the chance that the phase
* pops into (or remains in) existence.
* The index here is the local phase species index.
* the value of the variable is the global vcs reaction number. Note,
* that the global reaction number will go out of order when the species positions
* are swapped. So, this number has to be recalculated.
*
* Length = number of species in phase
* The index here is the local phase species index. the value of the
* variable is the global vcs reaction number. Note, that the global
* reaction number will go out of order when the species positions are
* swapped. So, this number has to be recalculated.
*
* Length = number of species in phase
*/
std::vector<size_t> creationGlobalRxnNumbers_;
//! If the potential is a solution variable in VCS, it acts as a species.
//! This is the species index in the phase for the potential
//! This is the species index in the phase for the potential
size_t m_phiVarIndex;
//! Total Volume of the phase
/*!
* units are m**3
*/
//! Total Volume of the phase. Units are m**3.
mutable double m_totalVol;
//! Vector of calculated SS0 chemical potentials for the
@ -883,8 +811,7 @@ private:
* in temperature. Pressure effects have to be added in to
* get to the standard state.
*
* Units -> depends on VCS_UnitsFormat variable
* Cantera -> J/kmol
* Units -> depends on VCS_UnitsFormat variable. Cantera -> J/kmol
*/
mutable std::vector<double> SS0ChemicalPotential;
@ -894,27 +821,20 @@ private:
* Note, This is the chemical potential at unit activity. Thus, we can call
* it the standard state chemical potential as well.
*
* Units -> depends on VCS_UnitsFormat variable
* Cantera -> J/kmol
* Units -> depends on VCS_UnitsFormat variable. Cantera -> J/kmol.
*/
mutable std::vector<double> StarChemicalPotential;
//! Vector of the Star molar Volumes of the species.
/*!
* units m3 / kmol
*/
//! Vector of the Star molar Volumes of the species. units m3 / kmol
mutable std::vector<double> StarMolarVol;
//! Vector of the Partial molar Volumes of the species.
/*!
* units m3 / kmol
*/
//! Vector of the Partial molar Volumes of the species. units m3 / kmol
mutable std::vector<double> PartialMolarVol;
//! Vector of calculated activity coefficients for the current state
/*!
* Whether or not this vector is current is determined by
* the bool m_UpToDate_AC.
* the bool #m_UpToDate_AC.
*/
mutable std::vector<double> ActCoeff;
@ -922,21 +842,20 @@ private:
//! current mole number multiplied by the current phase moles
/*!
* np_dLnActCoeffdMolNumber[j][k];
* j = id of the species mole number
* k = id of the species activity coefficient
* - j = id of the species mole number
* - k = id of the species activity coefficient
*/
mutable DoubleStarStar np_dLnActCoeffdMolNumber;
//! Status
/*!
* valid values are
* VCS_STATECALC_OLD
* VCS_STATECALC_NEW
* VCS_STATECALC_TMP
* - VCS_STATECALC_OLD
* - VCS_STATECALC_NEW
* - VCS_STATECALC_TMP
*/
int m_vcsStateStatus;
//! Value of the potential for the phase (Volts)
double m_phi;
@ -976,7 +895,6 @@ private:
*/
mutable bool m_UpToDate_GStar;
//! Boolean indicating whether G0 is up to date.
/*!
* G0 is sensitive to the temperature and the pressure, only
@ -988,16 +906,13 @@ private:
//! Current value of the pressure for this object, and underlying objects
double Pres_;
};
//! Return a string representing the equation of state
/*!
* @param EOSType : integer value of the equation of state
*
* @return returns a string representing the EOS
* @return returns a string representing the EOS. The string is no more than 16 characters.
*/
std::string string16_EOSType(int EOSType);

View file

@ -23,12 +23,6 @@
namespace VCSnonideal
{
/*
*
* vcs_VolPhase():
*
* Constructor for the VolPhase object.
*/
vcs_VolPhase::vcs_VolPhase(VCS_SOLVE* owningSolverObject) :
m_owningSolverObject(0),
VP_ID_(npos),
@ -66,14 +60,7 @@ vcs_VolPhase::vcs_VolPhase(VCS_SOLVE* owningSolverObject) :
{
m_owningSolverObject = owningSolverObject;
}
/***************************************************************************/
/*
*
* ~vcs_VolPhase():
*
* Destructor for the VolPhase object.
*/
vcs_VolPhase::~vcs_VolPhase()
{
for (size_t k = 0; k < m_numSpecies; k++) {
@ -82,16 +69,7 @@ vcs_VolPhase::~vcs_VolPhase()
sp = 0;
}
}
/************************************************************************************/
/*
*
* Copy Constructor():
*
* Objects that are owned by this object are deep copied here, except
* for the ThermoPhase object.
* The assignment operator does most of the work.
*/
vcs_VolPhase::vcs_VolPhase(const vcs_VolPhase& b) :
m_owningSolverObject(b.m_owningSolverObject),
VP_ID_(b.VP_ID_),
@ -125,19 +103,11 @@ vcs_VolPhase::vcs_VolPhase(const vcs_VolPhase& b) :
Temp_(b.Temp_),
Pres_(b.Pres_)
{
/*
* Call the Assignment operator to do the heavy
* lifting.
*/
//! Objects that are owned by this object are deep copied here, except for
//! the ThermoPhase object. The assignment operator does most of the work.
*this = b;
}
/***************************************************************************/
/*
* Assignment operator()
*
* (note, this is used, so keep it current!)
*/
vcs_VolPhase& vcs_VolPhase::operator=(const vcs_VolPhase& b)
{
if (&b != this) {
@ -230,7 +200,6 @@ vcs_VolPhase& vcs_VolPhase::operator=(const vcs_VolPhase& b)
}
return *this;
}
/***************************************************************************/
void vcs_VolPhase::resize(const size_t phaseNum, const size_t nspecies,
const size_t numElem, const char* const phaseName,
@ -331,7 +300,6 @@ void vcs_VolPhase::resize(const size_t phaseNum, const size_t nspecies,
elemResize(numElem);
}
/***************************************************************************/
void vcs_VolPhase::elemResize(const size_t numElemConstraints)
{
@ -347,14 +315,7 @@ void vcs_VolPhase::elemResize(const size_t numElemConstraints)
m_numElemConstraints = numElemConstraints;
}
/***************************************************************************/
// Evaluate activity coefficients
/*
* We carry out a calculation whenever UpTODate_AC is false. Specifically
* whenever a phase goes zero, we do not carry out calculations on it.
*
* (private)
*/
void vcs_VolPhase::_updateActCoeff() const
{
if (m_isIdealSoln) {
@ -366,15 +327,7 @@ void vcs_VolPhase::_updateActCoeff() const
}
m_UpToDate_AC = true;
}
/***************************************************************************/
/*
*
* Evaluate one activity coefficients.
*
* return one activity coefficient. Have to recalculate them all to get
* one.
*/
double vcs_VolPhase::AC_calc_one(size_t kspec) const
{
if (! m_UpToDate_AC) {
@ -382,10 +335,7 @@ double vcs_VolPhase::AC_calc_one(size_t kspec) const
}
return ActCoeff[kspec];
}
/***************************************************************************/
// Gibbs free energy calculation at a temperature for the reference state
// of each species
void vcs_VolPhase::_updateG0() const
{
if (m_useCanteraCalls) {
@ -402,7 +352,6 @@ void vcs_VolPhase::_updateG0() const
}
m_UpToDate_G0 = true;
}
/***************************************************************************/
double vcs_VolPhase::G0_calc_one(size_t kspec) const
{
@ -411,7 +360,6 @@ double vcs_VolPhase::G0_calc_one(size_t kspec) const
}
return SS0ChemicalPotential[kspec];
}
/***************************************************************************/
void vcs_VolPhase::_updateGStar() const
{
@ -429,7 +377,6 @@ void vcs_VolPhase::_updateGStar() const
}
m_UpToDate_GStar = true;
}
/***************************************************************************/
double vcs_VolPhase::GStar_calc_one(size_t kspec) const
{
@ -438,14 +385,7 @@ double vcs_VolPhase::GStar_calc_one(size_t kspec) const
}
return StarChemicalPotential[kspec];
}
/***************************************************************************/
// Set the mole fractions from a conventional mole fraction vector
/*
*
* @param xmol Value of the mole fractions for the species
* in the phase. These are contiguous.
*/
void vcs_VolPhase::setMoleFractions(const double* const xmol)
{
double sum = -1.0;
@ -462,13 +402,7 @@ void vcs_VolPhase::setMoleFractions(const double* const xmol)
m_UpToDate = false;
m_vcsStateStatus = VCS_STATECALC_TMP;
}
/***************************************************************************/
// Updates the mole fractions in subobjects
/*
* Whenever the mole fractions change, this routine
* should be called.
*/
void vcs_VolPhase::_updateMoleFractionDependencies()
{
if (m_useCanteraCalls) {
@ -481,9 +415,7 @@ void vcs_VolPhase::_updateMoleFractionDependencies()
m_UpToDate_VolPM = false;
}
}
/***************************************************************************/
// Return a const reference to the mole fraction vector in the phase
const std::vector<double> & vcs_VolPhase::moleFractions() const
{
return Xmol_;
@ -493,9 +425,7 @@ double vcs_VolPhase::moleFraction(size_t k) const
{
return Xmol_[k];
}
/***************************************************************************/
// Set the moles and/or mole fractions within the phase
void vcs_VolPhase::setMoleFractionsState(const double totalMoles,
const double* const moleFractions,
const int vcsStateStatus)
@ -549,21 +479,7 @@ void vcs_VolPhase::setMoleFractionsState(const double totalMoles,
_updateMoleFractionDependencies();
}
/***************************************************************************/
// Set the moles within the phase
/*
* This function takes as input the mole numbers in vcs format, and
* then updates this object with their values. This is essentially
* a gather routine.
*
*
* @param molesSpeciesVCS array of mole numbers. Note, the indices
* for species in
* this array may not be contiguous. IndSpecies[] is needed
* to gather the species into the local contiguous vector
* format.
*/
void vcs_VolPhase::setMolesFromVCS(const int stateCalc,
const double* molesSpeciesVCS)
{
@ -671,9 +587,7 @@ void vcs_VolPhase::setMolesFromVCS(const int stateCalc,
*/
m_UpToDate = true;
m_vcsStateStatus = stateCalc;
}
/***************************************************************************/
void vcs_VolPhase::setMolesFromVCSCheck(const int vcsStateStatus,
const double* molesSpeciesVCS,
@ -695,20 +609,7 @@ void vcs_VolPhase::setMolesFromVCSCheck(const int vcsStateStatus,
}
}
}
/***************************************************************************/
// Update the moles within the phase, if necessary
/*
* This function takes as input the stateCalc value, which
* determines where within VCS_SOLVE to fetch the mole numbers.
* It then updates this object with their values. This is essentially
* a gather routine.
*
* @param vcsStateStatus State calc value either VCS_STATECALC_OLD
* or VCS_STATECALC_NEW. With any other value
* nothing is done.
*
*/
void vcs_VolPhase::updateFromVCS_MoleNumbers(const int vcsStateStatus)
{
if (!m_UpToDate || (vcsStateStatus != m_vcsStateStatus)) {
@ -719,18 +620,7 @@ void vcs_VolPhase::updateFromVCS_MoleNumbers(const int vcsStateStatus)
}
}
}
/**************************************************************************/
// Fill in an activity coefficients vector within a VCS_SOLVE object
/*
* This routine will calculate the activity coefficients for the
* current phase, and fill in the corresponding entries in the
* VCS activity coefficients vector.
*
* @param AC vector of activity coefficients for all of the species
* in all of the phases in a VCS problem. Only the
* entries for the current phase are filled in.
*/
void vcs_VolPhase::sendToVCS_ActCoeff(const int vcsStateStatus,
double* const AC)
{
@ -743,18 +633,7 @@ void vcs_VolPhase::sendToVCS_ActCoeff(const int vcsStateStatus,
AC[kglob] = ActCoeff[k];
}
}
/***************************************************************************/
// Fill in the partial molar volume vector for VCS
/*
* This routine will calculate the partial molar volumes for the
* current phase (if needed), and fill in the corresponding entries in the
* VCS partial molar volumes vector.
*
* @param VolPM vector of partial molar volumes for all of the species
* in all of the phases in a VCS problem. Only the
* entries for the current phase are filled in.
*/
double vcs_VolPhase::sendToVCS_VolPM(double* const VolPM) const
{
if (!m_UpToDate_VolPM) {
@ -766,7 +645,6 @@ double vcs_VolPhase::sendToVCS_VolPM(double* const VolPM) const
}
return m_totalVol;
}
/***************************************************************************/
void vcs_VolPhase::sendToVCS_GStar(double* const gstar) const
{
@ -778,8 +656,6 @@ void vcs_VolPhase::sendToVCS_GStar(double* const gstar) const
gstar[kglob] = StarChemicalPotential[k];
}
}
/***************************************************************************/
void vcs_VolPhase::setElectricPotential(const double phi)
{
@ -793,24 +669,12 @@ void vcs_VolPhase::setElectricPotential(const double phi)
m_UpToDate_VolPM = false;
m_UpToDate_GStar = false;
}
/***************************************************************************/
double vcs_VolPhase::electricPotential() const
{
return m_phi;
}
/***************************************************************************/
// Sets the temperature and pressure in this object and
// underlying objects
/*
* Sets the temperature and pressure in this object and
* underlying objects. The underlying objects refers to the
* Cantera's ThermoPhase object for this phase.
*
* @param temperature_Kelvin (Kelvin)
* @param pressure_PA Pressure (MKS units - Pascal)
*/
void vcs_VolPhase::setState_TP(const double temp, const double pres)
{
if (Temp_ == temp) {
@ -830,22 +694,11 @@ void vcs_VolPhase::setState_TP(const double temp, const double pres)
m_UpToDate_GStar = false;
m_UpToDate_G0 = false;
}
/***************************************************************************/
// Sets the temperature in this object and
// underlying objects
/*
* Sets the temperature and pressure in this object and
* underlying objects. The underlying objects refers to the
* Cantera's ThermoPhase object for this phase.
*
* @param temperature_Kelvin (Kelvin)
*/
void vcs_VolPhase::setState_T(const double temp)
{
setState_TP(temp, Pres_);
}
/***************************************************************************/
void vcs_VolPhase::_updateVolStar() const
{
@ -861,7 +714,6 @@ void vcs_VolPhase::_updateVolStar() const
}
m_UpToDate_VolStar = true;
}
/***************************************************************************/
double vcs_VolPhase::VolStar_calc_one(size_t kspec) const
{
@ -870,15 +722,7 @@ double vcs_VolPhase::VolStar_calc_one(size_t kspec) const
}
return StarMolarVol[kspec];
}
/***************************************************************************/
// Calculate the partial molar volumes of all species and return the
// total volume
/*
* Calculates these quantities internally and then stores them
*
* @return total volume (m**3)
*/
double vcs_VolPhase::_updateVolPM() const
{
if (m_useCanteraCalls) {
@ -913,7 +757,6 @@ double vcs_VolPhase::_updateVolPM() const
m_UpToDate_VolPM = true;
return m_totalVol;
}
/***************************************************************************/
void vcs_VolPhase::_updateLnActCoeffJac()
{
@ -1007,22 +850,8 @@ void vcs_VolPhase::_updateLnActCoeffJac()
_updateMoleFractionDependencies();
_updateActCoeff();
}
/***************************************************************************/
// Downloads the ln ActCoeff jacobian into the VCS version of the
// ln ActCoeff jacobian.
/*
*
* This is essentially a scatter operation.
*
* The Jacobians are actually d( lnActCoeff) / d (MolNumber);
* dLnActCoeffdMolNumber[j][k]
*
* j = id of the species mole number
* k = id of the species activity coefficient
*/
void
vcs_VolPhase::sendToVCS_LnActCoeffJac(double* const* const np_LnACJac_VCS)
void vcs_VolPhase::sendToVCS_LnActCoeffJac(double* const* const np_LnACJac_VCS)
{
/*
* update the Ln Act Coeff jacobian entries with respect to the
@ -1044,16 +873,7 @@ vcs_VolPhase::sendToVCS_LnActCoeffJac(double* const* const np_LnACJac_VCS)
}
}
}
/***************************************************************************/
// Set the pointer for Cantera's ThermoPhase parameter
/*
* When we first initialize the ThermoPhase object, we read the
* state of the ThermoPhase into vcs_VolPhase object.
*
* @param tp_ptr Pointer to the ThermoPhase object corresponding
* to this phase.
*/
void vcs_VolPhase::setPtrThermoPhase(Cantera::ThermoPhase* tp_ptr)
{
TP_ptr = tp_ptr;
@ -1104,29 +924,21 @@ void vcs_VolPhase::setPtrThermoPhase(Cantera::ThermoPhase* tp_ptr)
m_useCanteraCalls = false;
}
}
/***************************************************************************/
// Return a const ThermoPhase pointer corresponding to this phase
/*
* @return pointer to the ThermoPhase.
*/
const Cantera::ThermoPhase* vcs_VolPhase::ptrThermoPhase() const
{
return TP_ptr;
}
/***************************************************************************/
double vcs_VolPhase::totalMoles() const
{
return v_totalMoles;
}
/***************************************************************************/
double vcs_VolPhase::molefraction(size_t k) const
{
return Xmol_[k];
}
/***************************************************************************/
void vcs_VolPhase::setCreationMoleNumbers(const double* const n_k,
const std::vector<size_t> &creationGlobalRxnNumbers)
@ -1136,22 +948,13 @@ void vcs_VolPhase::setCreationMoleNumbers(const double* const n_k,
creationGlobalRxnNumbers_[k] = creationGlobalRxnNumbers[k];
}
}
/***************************************************************************/
const std::vector<double> & vcs_VolPhase::creationMoleNumbers(std::vector<size_t> &creationGlobalRxnNumbers) const
{
creationGlobalRxnNumbers = creationGlobalRxnNumbers_;
return creationMoleNumbers_;
}
/***************************************************************************/
// Sets the total moles in the phase
/*
* We don't have to flag the internal state as changing here
* because we have just changed the total moles.
*
* @param totalMols Total moles in the phase (kmol)
*/
void vcs_VolPhase::setTotalMoles(const double totalMols)
{
v_totalMoles = totalMols;
@ -1177,13 +980,7 @@ void vcs_VolPhase::setTotalMoles(const double totalMols)
}
}
}
/***************************************************************************/
// Sets the mole flag within the object to out of date
/*
* This will trigger the object to go get the current mole numbers
* when it needs it.
*/
void vcs_VolPhase::setMolesOutOfDate(int stateCalc)
{
m_UpToDate = false;
@ -1191,24 +988,13 @@ void vcs_VolPhase::setMolesOutOfDate(int stateCalc)
m_vcsStateStatus = stateCalc;
}
}
/***************************************************************************/
// Sets the mole flag within the object to be current
void vcs_VolPhase::setMolesCurrent(int stateCalc)
{
m_UpToDate = true;
m_vcsStateStatus = stateCalc;
}
/***************************************************************************/
// Return a string representing the equation of state
/*
* The string is no more than 16 characters.
* @param EOSType : integer value of the equation of state
*
* @return returns a string representing the EOS
*/
std::string string16_EOSType(int EOSType)
{
char st[32];
@ -1242,28 +1028,21 @@ std::string string16_EOSType(int EOSType)
st[16] = '\0';
return st;
}
/***************************************************************************/
// Returns whether the phase is an ideal solution phase
bool vcs_VolPhase::isIdealSoln() const
{
return m_isIdealSoln;
}
/***************************************************************************/
// Returns whether the phase uses Cantera calls
bool vcs_VolPhase::usingCanteraCalls() const
{
return m_useCanteraCalls;
}
/***************************************************************************/
size_t vcs_VolPhase::phiVarIndex() const
{
return m_phiVarIndex;
}
/***************************************************************************/
void vcs_VolPhase::setPhiVarIndex(size_t phiVarIndex)
{
@ -1275,28 +1054,17 @@ void vcs_VolPhase::setPhiVarIndex(size_t phiVarIndex)
}
}
}
/***************************************************************************/
// Retrieve the kth Species structure for the species belonging to this phase
/*
* The index into this vector is the species index within the phase.
*
* @param kindex kth species index.
*/
vcs_SpeciesProperties* vcs_VolPhase::speciesProperty(const size_t kindex)
{
return ListSpeciesPtr[kindex];
}
/***************************************************************************/
// Boolean indicating whether the phase exists or not
int vcs_VolPhase::exists() const
{
return m_existence;
}
/**********************************************************************/
// Set the existence flag in the object
void vcs_VolPhase::setExistence(const int existence)
{
if (existence == VCS_PHASE_EXIST_NO || existence == VCS_PHASE_EXIST_ZEROEDPHASE) {
@ -1336,30 +1104,12 @@ void vcs_VolPhase::setExistence(const int existence)
#endif
m_existence = existence;
}
/**********************************************************************/
// Return the Global VCS index of the kth species in the phase
/*
* @param spIndex local species index (0 to the number of species
* in the phase)
*
* @return Returns the VCS_SOLVE species index of the that species
* This changes as rearrangements are carried out.
*/
size_t vcs_VolPhase::spGlobalIndexVCS(const size_t spIndex) const
{
return IndSpecies[spIndex];
}
/**********************************************************************/
//! set the Global VCS index of the kth species in the phase
/*!
* @param spIndex local species index (0 to the number of species
* in the phase)
*
* @return Returns the VCS_SOLVE species index of the that species
* This changes as rearrangements are carried out.
*/
void vcs_VolPhase::setSpGlobalIndexVCS(const size_t spIndex,
const size_t spGlobalIndex)
{
@ -1368,13 +1118,7 @@ void vcs_VolPhase::setSpGlobalIndexVCS(const size_t spIndex,
creationGlobalRxnNumbers_[spIndex] = spGlobalIndex - m_numElemConstraints;
}
}
/**********************************************************************/
// Sets the total moles of inert in the phase
/*
* @param tMolesInert Value of the total kmols of inert species in the
* phase.
*/
void vcs_VolPhase::setTotalMolesInert(const double tMolesInert)
{
if (m_totalMolesInert != tMolesInert) {
@ -1399,48 +1143,36 @@ void vcs_VolPhase::setTotalMolesInert(const double tMolesInert)
}
}
}
/**********************************************************************/
// returns the value of the total kmol of inert in the phase
double vcs_VolPhase::totalMolesInert() const
{
return m_totalMolesInert;
}
/**********************************************************************/
// Returns the global index of the local element index for the phase
size_t vcs_VolPhase::elemGlobalIndex(const size_t e) const
{
AssertThrow(e < m_numElemConstraints, " vcs_VolPhase::elemGlobalIndex");
return m_elemGlobalIndex[e];
}
/**********************************************************************/
// Returns the global index of the local element index for the phase
void vcs_VolPhase::setElemGlobalIndex(const size_t eLocal, const size_t eGlobal)
{
AssertThrow(eLocal < m_numElemConstraints,
"vcs_VolPhase::setElemGlobalIndex");
m_elemGlobalIndex[eLocal] = eGlobal;
}
/**********************************************************************/
size_t vcs_VolPhase::nElemConstraints() const
{
return m_numElemConstraints;
}
/**********************************************************************/
std::string vcs_VolPhase::elementName(const size_t e) const
{
return m_elementNames[e];
}
/**********************************************************************/
/*!
* This function decides whether a phase has charged species
* or not.
*/
//! This function decides whether a phase has charged species or not.
static bool hasChargedSpecies(const Cantera::ThermoPhase* const tPhase)
{
for (size_t k = 0; k < tPhase->nSpecies(); k++) {
@ -1450,10 +1182,8 @@ static bool hasChargedSpecies(const Cantera::ThermoPhase* const tPhase)
}
return false;
}
/**********************************************************************
*
* chargeNeutralityElement():
*
/*!
* This utility routine decides whether a Cantera ThermoPhase needs
* a constraint equation representing the charge neutrality of the
* phase. It does this by searching for charged species. If it
@ -1598,53 +1328,35 @@ size_t vcs_VolPhase::transferElementsFM(const Cantera::ThermoPhase* const tPhase
return ne;
}
/***************************************************************************/
// Type of the element constraint with index \c e.
/*
* @param e Element index.
*/
int vcs_VolPhase::elementType(const size_t e) const
{
return m_elementType[e];
}
/***************************************************************************/
// Set the element Type of the element constraint with index \c e.
/*
* @param e Element index
* @param eType type of the element.
*/
void vcs_VolPhase::setElementType(const size_t e, const int eType)
{
m_elementType[e] = eType;
}
/***************************************************************************/
double const* const* vcs_VolPhase::getFormulaMatrix() const
{
return m_formulaMatrix.constBaseDataAddr();
}
/***************************************************************************/
int vcs_VolPhase::speciesUnknownType(const size_t k) const
{
return m_speciesUnknownType[k];
}
/***************************************************************************/
int vcs_VolPhase::elementActive(const size_t e) const
{
return m_elementActive[e];
}
/***************************************************************************/
//! Return the number of species in the phase
size_t vcs_VolPhase::nSpecies() const
{
return m_numSpecies;
}
/***************************************************************************/
}