Cantera  3.0.0
Loading...
Searching...
No Matches
vcs_VolPhase Class Reference

Phase information and Phase calculations for vcs. More...

#include <vcs_VolPhase.h>

Detailed Description

Phase information and Phase calculations for vcs.

Each phase in a vcs calculation has a vcs_VolPhase object associated with it. This object helps to coordinate property evaluations for species within the phase. Usually these evaluations must be carried out on a per phase basis. However, vcs frequently needs per species quantities. Therefore, we need an interface layer between vcs and Cantera's ThermoPhase.

The species stay in the same ordering within this structure. The vcs algorithm will change the ordering of species in the global species list. However, the indexing of species in this list stays the same. This structure contains structures that point to the species belonging to this phase in the global vcs species list.

This object is considered not to own the underlying Cantera ThermoPhase object for the phase.

This object contains an idea of the temperature and pressure. It checks to see if if the temperature and pressure has changed before calling underlying property evaluation routines.

The object contains values for the electric potential of a phase. It coordinates the evaluation of properties wrt when the electric potential of a phase has changed.

The object knows about the mole fractions of the phase. It controls the values of mole fractions, and coordinates the property evaluation wrt to changes in the mole fractions. It also will keep track of the likely values of mole fractions in multicomponent phases even when the phase doesn't actually exist within the thermo program.

The object knows about the total moles of a phase. It checks to 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).

Definition at line 78 of file vcs_VolPhase.h.

Public Member Functions

 vcs_VolPhase (VCS_SOLVE *owningSolverObject=0)
 
 vcs_VolPhase (const vcs_VolPhase &b)=delete
 
vcs_VolPhaseoperator= (const vcs_VolPhase &b)=delete
 
void resize (const size_t phaseNum, const size_t numSpecies, const size_t numElem, const char *const phaseName, const double molesInert=0.0)
 The resize() function fills in all of the initial information if it is not given in the constructor.
 
void elemResize (const size_t numElemConstraints)
 
void setMoleFractionsState (const double molNum, const double *const moleFracVec, const int vcsStateStatus)
 Set the moles and/or mole fractions within the phase.
 
void setMolesFromVCS (const int stateCalc, const double *molesSpeciesVCS=0)
 Set the moles within the phase.
 
void setMolesFromVCSCheck (const int vcsStateStatus, const double *molesSpeciesVCS, const double *const TPhMoles)
 Set the moles within the phase.
 
void updateFromVCS_MoleNumbers (const int stateCalc)
 Update the moles within the phase, if necessary.
 
void sendToVCS_ActCoeff (const int stateCalc, double *const AC)
 Fill in an activity coefficients vector within a VCS_SOLVE object.
 
void setElectricPotential (const double phi)
 set the electric potential of the phase
 
double electricPotential () const
 Returns the electric field of the phase.
 
double GStar_calc_one (size_t kspec) const
 Gibbs free energy calculation for standard state of one species.
 
double G0_calc_one (size_t kspec) const
 Gibbs free energy calculation at a temperature for the reference state of a species, return a value for one species.
 
double VolStar_calc_one (size_t kspec) const
 Molar volume calculation for standard state of one species.
 
double sendToVCS_VolPM (double *const VolPM) const
 Fill in the partial molar volume vector for VCS.
 
void sendToVCS_GStar (double *const gstar) const
 Fill in the standard state Gibbs free energy vector for VCS.
 
void setState_TP (const double temperature_Kelvin, const double pressure_PA)
 Sets the temperature and pressure in this object and underlying ThermoPhase objects.
 
void setState_T (const double temperature_Kelvin)
 Sets the temperature in this object and underlying ThermoPhase objects.
 
void sendToVCS_LnActCoeffJac (Array2D &LnACJac_VCS)
 Downloads the ln ActCoeff Jacobian into the VCS version of the ln ActCoeff Jacobian.
 
void setPtrThermoPhase (ThermoPhase *tp_ptr)
 Set the pointer for Cantera's ThermoPhase parameter.
 
const ThermoPhaseptrThermoPhase () const
 Return a const ThermoPhase pointer corresponding to this phase.
 
double totalMoles () const
 Return the total moles in the phase.
 
double molefraction (size_t kspec) const
 Returns the mole fraction of the kspec species.
 
void setTotalMoles (const double totalMols)
 Sets the total moles in the phase.
 
void setMolesOutOfDate (int stateCalc=-1)
 Sets the mole flag within the object to out of date.
 
void setMolesCurrent (int vcsStateStatus)
 Sets the mole flag within the object to be current.
 
const vector< double > & moleFractions () const
 Return a const reference to the mole fractions stored in the object.
 
double moleFraction (size_t klocal) const
 
void setCreationMoleNumbers (const double *const n_k, const vector< size_t > &creationGlobalRxnNumbers)
 Sets the creationMoleNum's within the phase object.
 
const vector< double > & creationMoleNumbers (vector< size_t > &creationGlobalRxnNumbers) const
 Return a const reference to the creationMoleNumbers stored in the object.
 
bool isIdealSoln () const
 Returns whether the phase is an ideal solution phase.
 
size_t phiVarIndex () const
 Return the index of the species that represents the the voltage of the phase.
 
void setPhiVarIndex (size_t phiVarIndex)
 
vcs_SpeciesPropertiesspeciesProperty (const size_t kindex)
 Retrieve the kth Species structure for the species belonging to this phase.
 
int exists () const
 int indicating whether the phase exists or not
 
void setExistence (const int existence)
 Set the existence flag in the object.
 
size_t spGlobalIndexVCS (const size_t spIndex) const
 Return the Global VCS index of the kth species in the phase.
 
void setSpGlobalIndexVCS (const size_t spIndex, const size_t spGlobalIndex)
 set the Global VCS index of the kth species in the phase
 
void setTotalMolesInert (const double tMolesInert)
 Sets the total moles of inert in the phase.
 
double totalMolesInert () const
 Returns the value of the total kmol of inert in the phase.
 
size_t elemGlobalIndex (const size_t e) const
 Returns the global index of the local element index for the phase.
 
void setElemGlobalIndex (const size_t eLocal, const size_t eGlobal)
 sets a local phase element to a global index value
 
size_t nElemConstraints () const
 Returns the number of element constraints.
 
string elementName (const size_t e) const
 Name of the element constraint with index e.
 
int elementType (const size_t e) const
 Type of the element constraint with index e.
 
size_t transferElementsFM (const ThermoPhase *const tPhase)
 Transfer all of the element information from the ThermoPhase object to the vcs_VolPhase object.
 
const Array2DgetFormulaMatrix () const
 Get a constant form of the Species Formula Matrix.
 
int speciesUnknownType (const size_t k) const
 Returns the type of the species unknown.
 
int elementActive (const size_t e) const
 
size_t nSpecies () const
 Return the number of species in the phase.
 
string eos_name () const
 Return the name corresponding to the equation of state.
 

Public Attributes

size_t VP_ID_ = npos
 Original ID of the phase in the problem.
 
bool m_singleSpecies = true
 If true, this phase consists of a single species.
 
bool m_gasPhase = false
 If true, this phase is a gas-phase like phase.
 
int m_eqnState = VCS_EOS_CONSTANT
 Type of the equation of state.
 
size_t ChargeNeutralityElement = npos
 This is the element number for the charge neutrality condition of the phase.
 
int p_activityConvention = 0
 Convention for the activity formulation.
 
string PhaseName
 String name for the phase.
 

Private Member Functions

void setMoleFractions (const double *const xmol)
 Set the mole fractions from a conventional mole fraction vector.
 
void _updateActCoeff () const
 Evaluate the activity coefficients at the current conditions.
 
void _updateGStar () const
 Gibbs free energy calculation for standard states.
 
void _updateG0 () const
 Gibbs free energy calculation at a temperature for the reference state of each species.
 
void _updateVolStar () const
 Molar volume calculation for standard states.
 
double _updateVolPM () const
 Calculate the partial molar volumes of all species and return the total volume.
 
void _updateLnActCoeffJac ()
 Evaluation of Activity Coefficient Jacobians.
 
void _updateMoleFractionDependencies ()
 Updates the mole fraction dependencies.
 

Private Attributes

VCS_SOLVEm_owningSolverObject = nullptr
 Backtrack value of VCS_SOLVE *.
 
size_t m_numElemConstraints = 0
 Number of element constraints within the problem.
 
vector< string > m_elementNames
 vector of strings containing the element constraint names
 
vector< int > m_elementActive
 boolean indicating whether an element constraint is active for the current problem
 
vector< int > m_elementType
 Type of the element constraint.
 
Array2D m_formulaMatrix
 Formula Matrix for the phase.
 
vector< int > m_speciesUnknownType
 Type of the species unknown.
 
vector< size_t > m_elemGlobalIndex
 Index of the element number in the global list of elements stored in VCS_SOLVE.
 
size_t m_numSpecies = 0
 Number of species in the phase.
 
double m_totalMolesInert = 0.0
 Total moles of inert in the phase.
 
bool m_isIdealSoln = false
 Boolean indicating whether the phase is an ideal solution and therefore its molar-based activity coefficients are uniformly equal to one.
 
int m_existence = VCS_PHASE_EXIST_NO
 Current state of existence:
 
int m_MFStartIndex = 0
 
vector< size_t > IndSpecies
 Index into the species vectors.
 
vector< vcs_SpeciesProperties * > ListSpeciesPtr
 Vector of Species structures for the species belonging to this phase.
 
ThermoPhaseTP_ptr = nullptr
 If we are using Cantera, this is the pointer to the ThermoPhase object.
 
double v_totalMoles = 0.0
 Total mols in the phase. units are kmol.
 
vector< double > Xmol_
 Vector of the current mole fractions for species in the phase.
 
vector< double > creationMoleNumbers_
 Vector of current creationMoleNumbers_.
 
vector< size_t > creationGlobalRxnNumbers_
 Vector of creation global reaction numbers for the phase stability problem.
 
size_t m_phiVarIndex = npos
 If the potential is a solution variable in VCS, it acts as a species.
 
double m_totalVol = 0.0
 Total Volume of the phase. Units are m**3.
 
vector< double > SS0ChemicalPotential
 Vector of calculated SS0 chemical potentials for the current Temperature.
 
vector< double > StarChemicalPotential
 Vector of calculated Star chemical potentials for the current Temperature and pressure.
 
vector< double > StarMolarVol
 Vector of the Star molar Volumes of the species. units m3 / kmol.
 
vector< double > PartialMolarVol
 Vector of the Partial molar Volumes of the species. units m3 / kmol.
 
vector< double > ActCoeff
 Vector of calculated activity coefficients for the current state.
 
Array2D np_dLnActCoeffdMolNumber
 Vector of the derivatives of the ln activity coefficient wrt to the current mole number multiplied by the current phase moles.
 
int m_vcsStateStatus = VCS_STATECALC_OLD
 Status.
 
double m_phi = 0.0
 Value of the potential for the phase (Volts)
 
bool m_UpToDate = false
 Boolean indicating whether the object has an up-to-date mole number vector and potential with respect to the current vcs state calc status.
 
bool m_UpToDate_AC = false
 Boolean indicating whether activity coefficients are up to date.
 
bool m_UpToDate_VolStar = false
 Boolean indicating whether Star volumes are up to date.
 
bool m_UpToDate_VolPM = false
 Boolean indicating whether partial molar volumes are up to date.
 
bool m_UpToDate_GStar = false
 Boolean indicating whether GStar is up to date.
 
bool m_UpToDate_G0 = false
 Boolean indicating whether G0 is up to date.
 
double Temp_ = 273.15
 Current value of the temperature for this object, and underlying objects.
 
double Pres_ = OneAtm
 Current value of the pressure for this object, and underlying objects.
 

Constructor & Destructor Documentation

◆ vcs_VolPhase()

vcs_VolPhase ( VCS_SOLVE owningSolverObject = 0)

Definition at line 20 of file vcs_VolPhase.cpp.

◆ ~vcs_VolPhase()

Definition at line 25 of file vcs_VolPhase.cpp.

Member Function Documentation

◆ resize()

void resize ( const size_t  phaseNum,
const size_t  numSpecies,
const size_t  numElem,
const char *const  phaseName,
const double  molesInert = 0.0 
)

The resize() function fills in all of the initial information if it is not given in the constructor.

Parameters
phaseNumindex of the phase in the vcs problem
numSpeciesNumber of species in the phase
numElemNumber of elements in the phase
phaseNameString name for the phase
molesInertkmoles of inert in the phase (defaults to zero)

Definition at line 32 of file vcs_VolPhase.cpp.

◆ elemResize()

void elemResize ( const size_t  numElemConstraints)

Definition at line 117 of file vcs_VolPhase.cpp.

◆ setMoleFractionsState()

void setMoleFractionsState ( const double  molNum,
const double *const  moleFracVec,
const int  vcsStateStatus 
)

Set the moles and/or mole fractions within the phase.

Parameters
molNumtotal moles in the phase
moleFracVecVector of input mole fractions
vcsStateStatusStatus flag for this update

Definition at line 205 of file vcs_VolPhase.cpp.

◆ setMolesFromVCS()

void setMolesFromVCS ( const int  stateCalc,
const double *  molesSpeciesVCS = 0 
)

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.

Parameters
stateCalcFlag indicating which mole numbers to update. Either VCS_STATECALC_OLD or VCS_STATECALC_NEW.
molesSpeciesVCSArray 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.

Definition at line 255 of file vcs_VolPhase.cpp.

◆ setMolesFromVCSCheck()

void setMolesFromVCSCheck ( const int  vcsStateStatus,
const double *  molesSpeciesVCS,
const double *const  TPhMoles 
)

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.

Additionally it checks to see that the total moles value in TPhMoles[iplace] is equal to the internally computed value. If this isn't the case, an error exit is carried out.

Parameters
vcsStateStatusState calc value either VCS_STATECALC_OLD or VCS_STATECALC_NEW. With any other value nothing is done.
molesSpeciesVCSarray 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.
TPhMolesVCS's array containing the number of moles in each phase.

Definition at line 336 of file vcs_VolPhase.cpp.

◆ updateFromVCS_MoleNumbers()

void updateFromVCS_MoleNumbers ( const int  stateCalc)

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.

Parameters
stateCalcState calc value either VCS_STATECALC_OLD or VCS_STATECALC_NEW. With any other value nothing is done.

Definition at line 354 of file vcs_VolPhase.cpp.

◆ sendToVCS_ActCoeff()

void sendToVCS_ActCoeff ( const int  stateCalc,
double *const  AC 
)

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.

Parameters
stateCalcFlag indicating which mole numbers to update. Either VCS_STATECALC_OLD or VCS_STATECALC_NEW.
ACvector 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.

Definition at line 362 of file vcs_VolPhase.cpp.

◆ setElectricPotential()

void setElectricPotential ( const double  phi)

set the electric potential of the phase

Parameters
phielectric potential (volts)

Definition at line 398 of file vcs_VolPhase.cpp.

◆ electricPotential()

double electricPotential ( ) const

Returns the electric field of the phase.

Units are potential

Definition at line 409 of file vcs_VolPhase.cpp.

◆ GStar_calc_one()

double GStar_calc_one ( size_t  kspec) const

Gibbs free energy calculation for standard state of one species.

Calculate the Gibbs free energies for the standard state of the kth species. The results are held internally within the object.

Parameters
kspecSpecies number (within the phase)
Returns
the Gibbs free energy for the standard state of the kth species.

Definition at line 158 of file vcs_VolPhase.cpp.

◆ G0_calc_one()

double G0_calc_one ( size_t  kspec) const

Gibbs free energy calculation at a temperature for the reference state of a species, return a value for one species.

Parameters
kspecspecies index
Returns
value of the Gibbs free energy

Definition at line 144 of file vcs_VolPhase.cpp.

◆ VolStar_calc_one()

double VolStar_calc_one ( size_t  kspec) const

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.

Parameters
kspecSpecies number (within the phase)
Returns
molar volume of the kspec species's standard state (m**3/kmol)

Definition at line 441 of file vcs_VolPhase.cpp.

◆ sendToVCS_VolPM()

double sendToVCS_VolPM ( double *const  VolPM) const

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.

Parameters
[out]VolPMvector 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.

Definition at line 375 of file vcs_VolPhase.cpp.

◆ sendToVCS_GStar()

void sendToVCS_GStar ( double *const  gstar) const

Fill in the standard state Gibbs free energy vector for VCS.

This routine will calculate the standard state Gibbs free energies for the current phase (if needed), and fill in the corresponding entries in the VCS standard state gibbs free energy vector.

Parameters
[out]gstarvector of standard state Gibbs free energies for all of the species in all of the phases in a VCS problem. Only the entries for the current phase are filled in.

Definition at line 387 of file vcs_VolPhase.cpp.

◆ setState_TP()

void setState_TP ( const double  temperature_Kelvin,
const double  pressure_PA 
)

Sets the temperature and pressure in this object and underlying ThermoPhase objects.

Parameters
temperature_Kelvin(Kelvin)
pressure_PAPressure (MKS units - Pascal)

Definition at line 414 of file vcs_VolPhase.cpp.

◆ setState_T()

void setState_T ( const double  temperature_Kelvin)

Sets the temperature in this object and underlying ThermoPhase objects.

Parameters
temperature_Kelvin(Kelvin)

Definition at line 430 of file vcs_VolPhase.cpp.

◆ sendToVCS_LnActCoeffJac()

void sendToVCS_LnActCoeffJac ( Array2D LnACJac_VCS)

Downloads the ln ActCoeff Jacobian into the VCS version of the ln ActCoeff Jacobian.

This is essentially a scatter operation.

Parameters
LnACJac_VCSJacobian parameter The Jacobians are actually d( lnActCoeff) / d (MolNumber); dLnActCoeffdMolNumber(k,j)

j = id of the species mole number k = id of the species activity coefficient

Definition at line 535 of file vcs_VolPhase.cpp.

◆ setPtrThermoPhase()

void setPtrThermoPhase ( ThermoPhase tp_ptr)

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.

Parameters
tp_ptrPointer to the ThermoPhase object corresponding to this phase.

Definition at line 551 of file vcs_VolPhase.cpp.

◆ ptrThermoPhase()

const ThermoPhase * ptrThermoPhase ( ) const

Return a const ThermoPhase pointer corresponding to this phase.

Returns
pointer to the ThermoPhase.

Definition at line 579 of file vcs_VolPhase.cpp.

◆ totalMoles()

double totalMoles ( ) const

Return the total moles in the phase.

Definition at line 584 of file vcs_VolPhase.cpp.

◆ molefraction()

double molefraction ( size_t  kspec) const

Returns the mole fraction of the kspec species.

Parameters
kspecIndex of the species in the phase
Returns
Value of the mole fraction

Definition at line 589 of file vcs_VolPhase.cpp.

◆ setTotalMoles()

void setTotalMoles ( const double  totalMols)

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.

Parameters
totalMolsTotal moles in the phase (kmol)

Definition at line 610 of file vcs_VolPhase.cpp.

◆ setMolesOutOfDate()

void setMolesOutOfDate ( int  stateCalc = -1)

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.

Definition at line 632 of file vcs_VolPhase.cpp.

◆ setMolesCurrent()

void setMolesCurrent ( int  vcsStateStatus)

Sets the mole flag within the object to be current.

Definition at line 640 of file vcs_VolPhase.cpp.

◆ setMoleFractions()

void setMoleFractions ( const double *const  xmol)
private

Set the mole fractions from a conventional mole fraction vector.

Parameters
xmolValue of the mole fractions for the species in the phase. These are contiguous.

Definition at line 166 of file vcs_VolPhase.cpp.

◆ moleFractions()

const vector< double > & moleFractions ( ) const

Return a const reference to the mole fractions stored in the object.

Definition at line 195 of file vcs_VolPhase.cpp.

◆ moleFraction()

double moleFraction ( size_t  klocal) const

Definition at line 200 of file vcs_VolPhase.cpp.

◆ setCreationMoleNumbers()

void setCreationMoleNumbers ( const double *const  n_k,
const vector< size_t > &  creationGlobalRxnNumbers 
)

Sets the creationMoleNum's within the phase object.

Parameters
n_kPointer to a vector of n_k's
creationGlobalRxnNumbersVector of global creation reaction numbers

Definition at line 594 of file vcs_VolPhase.cpp.

◆ creationMoleNumbers()

const vector< double > & creationMoleNumbers ( vector< size_t > &  creationGlobalRxnNumbers) const

Return a const reference to the creationMoleNumbers stored in the object.

Returns
a const reference to the vector of creationMoleNumbers

Definition at line 603 of file vcs_VolPhase.cpp.

◆ isIdealSoln()

bool isIdealSoln ( ) const

Returns whether the phase is an ideal solution phase.

Definition at line 646 of file vcs_VolPhase.cpp.

◆ phiVarIndex()

size_t phiVarIndex ( ) const

Return the index of the species that represents the the voltage of the phase.

Definition at line 651 of file vcs_VolPhase.cpp.

◆ setPhiVarIndex()

void setPhiVarIndex ( size_t  phiVarIndex)

Definition at line 656 of file vcs_VolPhase.cpp.

◆ speciesProperty()

vcs_SpeciesProperties * speciesProperty ( const size_t  kindex)

Retrieve the kth Species structure for the species belonging to this phase.

The index into this vector is the species index within the phase.

Parameters
kindexkth species index.

Definition at line 665 of file vcs_VolPhase.cpp.

◆ exists()

int exists ( ) const

int indicating whether the phase exists or not

returns the m_existence int for the 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, for example, it's an electron metal phase.

Definition at line 670 of file vcs_VolPhase.cpp.

◆ setExistence()

void setExistence ( const int  existence)

Set the existence flag in the object.

Note the total moles of the phase must have been set appropriately before calling this routine.

Parameters
existencePhase existence flag
Note
try to eliminate this routine

Definition at line 675 of file vcs_VolPhase.cpp.

◆ spGlobalIndexVCS()

size_t spGlobalIndexVCS ( const size_t  spIndex) const

Return the Global VCS index of the kth species in the phase.

Parameters
spIndexlocal species index (0 to the number of species in the phase)
Returns
the VCS_SOLVE species index of the species. This changes as rearrangements are carried out.

Definition at line 695 of file vcs_VolPhase.cpp.

◆ setSpGlobalIndexVCS()

void setSpGlobalIndexVCS ( const size_t  spIndex,
const size_t  spGlobalIndex 
)

set the Global VCS index of the kth species in the phase

Parameters
spIndexlocal species index (0 to the number of species in the phase)
spGlobalIndexGlobal species index (across all phases)

Definition at line 700 of file vcs_VolPhase.cpp.

◆ setTotalMolesInert()

void setTotalMolesInert ( const double  tMolesInert)

Sets the total moles of inert in the phase.

Parameters
tMolesInertValue of the total kmols of inert species in the phase.

Definition at line 709 of file vcs_VolPhase.cpp.

◆ totalMolesInert()

double totalMolesInert ( ) const

Returns the value of the total kmol of inert in the phase.

Definition at line 734 of file vcs_VolPhase.cpp.

◆ elemGlobalIndex()

size_t elemGlobalIndex ( const size_t  e) const

Returns the global index of the local element index for the phase.

Definition at line 739 of file vcs_VolPhase.cpp.

◆ setElemGlobalIndex()

void setElemGlobalIndex ( const size_t  eLocal,
const size_t  eGlobal 
)

sets a local phase element to a global index value

Parameters
eLocalLocal phase element index
eGlobalGlobal phase element index

Definition at line 745 of file vcs_VolPhase.cpp.

◆ nElemConstraints()

size_t nElemConstraints ( ) const

Returns the number of element constraints.

Definition at line 752 of file vcs_VolPhase.cpp.

◆ elementName()

string elementName ( const size_t  e) const

Name of the element constraint with index e.

Parameters
eElement index.

Definition at line 757 of file vcs_VolPhase.cpp.

◆ elementType()

int elementType ( const size_t  e) const

Type of the element constraint with index e.

Parameters
eElement index.

Definition at line 890 of file vcs_VolPhase.cpp.

◆ transferElementsFM()

size_t transferElementsFM ( const ThermoPhase *const  tPhase)

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.

Parameters
tPhasePointer to the ThermoPhase object

Definition at line 786 of file vcs_VolPhase.cpp.

◆ getFormulaMatrix()

const Array2D & getFormulaMatrix ( ) const

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

Definition at line 895 of file vcs_VolPhase.cpp.

◆ speciesUnknownType()

int speciesUnknownType ( const size_t  k) const

Returns the type of the species unknown.

Parameters
kspecies 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))

Definition at line 900 of file vcs_VolPhase.cpp.

◆ elementActive()

int elementActive ( const size_t  e) const

Definition at line 905 of file vcs_VolPhase.cpp.

◆ nSpecies()

size_t nSpecies ( ) const

Return the number of species in the phase.

Definition at line 910 of file vcs_VolPhase.cpp.

◆ eos_name()

string eos_name ( ) const

Return the name corresponding to the equation of state.

Definition at line 915 of file vcs_VolPhase.cpp.

◆ _updateActCoeff()

void _updateActCoeff ( ) const
private

Evaluate the activity coefficients at the current conditions.

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.

Definition at line 128 of file vcs_VolPhase.cpp.

◆ _updateGStar()

void _updateGStar ( ) const
private

Gibbs free energy calculation for standard states.

Calculate the Gibbs free energies for the standard states The results are held internally within the object.

Definition at line 152 of file vcs_VolPhase.cpp.

◆ _updateG0()

void _updateG0 ( ) const
private

Gibbs free energy calculation at a temperature for the reference state of each species.

Definition at line 138 of file vcs_VolPhase.cpp.

◆ _updateVolStar()

void _updateVolStar ( ) const
private

Molar volume calculation for standard states.

Calculate the molar volume for the standard states. The results are held internally within the object. Units are in m**3/kmol.

Definition at line 435 of file vcs_VolPhase.cpp.

◆ _updateVolPM()

double _updateVolPM ( ) const
private

Calculate the partial molar volumes of all species and return the total volume.

Calculates these quantities internally and then stores them

Returns
total volume [m^3]

Definition at line 449 of file vcs_VolPhase.cpp.

◆ _updateLnActCoeffJac()

void _updateLnActCoeffJac ( )
private

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)

We employ a finite difference derivative approach here. Because we have to change the mole numbers, this is not a const function, even though the paradigm would say that it should be.

Definition at line 470 of file vcs_VolPhase.cpp.

◆ _updateMoleFractionDependencies()

void _updateMoleFractionDependencies ( )
private

Updates the mole fraction dependencies.

Whenever the mole fractions change, this routine should be called.

Definition at line 183 of file vcs_VolPhase.cpp.

Member Data Documentation

◆ m_owningSolverObject

VCS_SOLVE* m_owningSolverObject = nullptr
private

Backtrack value of VCS_SOLVE *.

Definition at line 529 of file vcs_VolPhase.h.

◆ VP_ID_

size_t VP_ID_ = npos

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.

Definition at line 537 of file vcs_VolPhase.h.

◆ m_singleSpecies

bool m_singleSpecies = true

If true, this phase consists of a single species.

Definition at line 540 of file vcs_VolPhase.h.

◆ m_gasPhase

bool m_gasPhase = false

If true, this phase is a gas-phase like phase.

A RTlog(p/1atm) term is added onto the chemical potential for inert species if this is true.

Definition at line 547 of file vcs_VolPhase.h.

◆ m_eqnState

int m_eqnState = VCS_EOS_CONSTANT

Type of the equation of state.

The known types are listed at the top of this file.

Definition at line 553 of file vcs_VolPhase.h.

◆ ChargeNeutralityElement

size_t ChargeNeutralityElement = npos

This is the element number for the charge neutrality condition of the phase.

If it has one. If it does not have a charge neutrality constraint, then this value is equal to -1

Definition at line 561 of file vcs_VolPhase.h.

◆ p_activityConvention

int p_activityConvention = 0

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

Definition at line 569 of file vcs_VolPhase.h.

◆ m_numElemConstraints

size_t m_numElemConstraints = 0
private

Number of element constraints within the problem.

This is usually equal to the number of elements.

Definition at line 576 of file vcs_VolPhase.h.

◆ m_elementNames

vector<string> m_elementNames
private

vector of strings containing the element constraint names

Length = nElemConstraints

Definition at line 582 of file vcs_VolPhase.h.

◆ m_elementActive

vector<int> m_elementActive
private

boolean indicating whether an element constraint is active for the current problem

Definition at line 586 of file vcs_VolPhase.h.

◆ m_elementType

vector<int> m_elementType
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_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)

Definition at line 599 of file vcs_VolPhase.h.

◆ m_formulaMatrix

Array2D m_formulaMatrix
private

Formula Matrix for the phase.

FormulaMatrix(kspec,j) = Formula Matrix for the species Number of elements, j, in the kspec species

Definition at line 606 of file vcs_VolPhase.h.

◆ m_speciesUnknownType

vector<int> m_speciesUnknownType
private

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))

Definition at line 616 of file vcs_VolPhase.h.

◆ m_elemGlobalIndex

vector<size_t> m_elemGlobalIndex
private

Index of the element number in the global list of elements stored in VCS_SOLVE.

Definition at line 619 of file vcs_VolPhase.h.

◆ m_numSpecies

size_t m_numSpecies = 0
private

Number of species in the phase.

Definition at line 622 of file vcs_VolPhase.h.

◆ PhaseName

string PhaseName

String name for the phase.

Definition at line 626 of file vcs_VolPhase.h.

◆ m_totalMolesInert

double m_totalMolesInert = 0.0
private

Total moles of inert in the phase.

Definition at line 630 of file vcs_VolPhase.h.

◆ m_isIdealSoln

bool m_isIdealSoln = false
private

Boolean indicating whether the phase is an ideal solution and therefore its molar-based activity coefficients are uniformly equal to one.

Definition at line 635 of file vcs_VolPhase.h.

◆ m_existence

int m_existence = VCS_PHASE_EXIST_NO
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, for example, its an electron metal phase.

Definition at line 651 of file vcs_VolPhase.h.

◆ m_MFStartIndex

int m_MFStartIndex = 0
private

This is always equal to zero. Am anticipating the case where the phase potential is species # 0, for multiphase phases. Right now we have the phase potential equal to 0 for single species phases, where we set by hand the mole fraction of species 0 to one.

Definition at line 661 of file vcs_VolPhase.h.

◆ IndSpecies

vector<size_t> IndSpecies
private

Index into the species vectors.

Maps the phase species number into the global species number. Note, as part of the vcs algorithm, the order of the species vector is changed during the algorithm

Definition at line 669 of file vcs_VolPhase.h.

◆ ListSpeciesPtr

vector<vcs_SpeciesProperties*> ListSpeciesPtr
private

Vector of Species structures for the species belonging to this phase.

The index into this vector is the species index within the phase.

Definition at line 675 of file vcs_VolPhase.h.

◆ TP_ptr

ThermoPhase* TP_ptr = nullptr
private

If we are using Cantera, this is the pointer to the ThermoPhase object.

If not, this is null.

Definition at line 681 of file vcs_VolPhase.h.

◆ v_totalMoles

double v_totalMoles = 0.0
private

Total mols in the phase. units are kmol.

Definition at line 684 of file vcs_VolPhase.h.

◆ Xmol_

vector<double> Xmol_
private

Vector of the current mole fractions for species in the phase.

Definition at line 687 of file vcs_VolPhase.h.

◆ creationMoleNumbers_

vector<double> creationMoleNumbers_
private

Vector of current creationMoleNumbers_.

These are the actual unknowns in the phase stability problem

Definition at line 693 of file vcs_VolPhase.h.

◆ creationGlobalRxnNumbers_

vector<size_t> creationGlobalRxnNumbers_
private

Vector of creation global reaction numbers for the phase stability problem.

The phase stability problem requires a global reaction number for each species in the phase. Usually this is the krxn = kglob - M for species 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

Definition at line 710 of file vcs_VolPhase.h.

◆ m_phiVarIndex

size_t m_phiVarIndex = npos
private

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

Definition at line 714 of file vcs_VolPhase.h.

◆ m_totalVol

double m_totalVol = 0.0
mutableprivate

Total Volume of the phase. Units are m**3.

Definition at line 717 of file vcs_VolPhase.h.

◆ SS0ChemicalPotential

vector<double> SS0ChemicalPotential
mutableprivate

Vector of calculated SS0 chemical potentials for the current Temperature.

Note, This is the chemical potential derived strictly from the polynomial in temperature. Pressure effects have to be added in to get to the standard state. Units are J/kmol.

Definition at line 726 of file vcs_VolPhase.h.

◆ StarChemicalPotential

vector<double> StarChemicalPotential
mutableprivate

Vector of calculated Star chemical potentials for the current Temperature and pressure.

Note, This is the chemical potential at unit activity. Thus, we can call it the standard state chemical potential as well. Units are J/kmol.

Definition at line 734 of file vcs_VolPhase.h.

◆ StarMolarVol

vector<double> StarMolarVol
mutableprivate

Vector of the Star molar Volumes of the species. units m3 / kmol.

Definition at line 737 of file vcs_VolPhase.h.

◆ PartialMolarVol

vector<double> PartialMolarVol
mutableprivate

Vector of the Partial molar Volumes of the species. units m3 / kmol.

Definition at line 740 of file vcs_VolPhase.h.

◆ ActCoeff

vector<double> ActCoeff
mutableprivate

Vector of calculated activity coefficients for the current state.

Whether or not this vector is current is determined by the bool m_UpToDate_AC.

Definition at line 747 of file vcs_VolPhase.h.

◆ np_dLnActCoeffdMolNumber

Array2D np_dLnActCoeffdMolNumber
mutableprivate

Vector of the derivatives of the ln activity coefficient wrt to the current mole number multiplied by the current phase moles.

np_dLnActCoeffdMolNumber(k,j);

  • j = id of the species mole number
  • k = id of the species activity coefficient

Definition at line 756 of file vcs_VolPhase.h.

◆ m_vcsStateStatus

int m_vcsStateStatus = VCS_STATECALC_OLD
private

Status.

valid values are

  • VCS_STATECALC_OLD
  • VCS_STATECALC_NEW
  • VCS_STATECALC_TMP

Definition at line 765 of file vcs_VolPhase.h.

◆ m_phi

double m_phi = 0.0
private

Value of the potential for the phase (Volts)

Definition at line 768 of file vcs_VolPhase.h.

◆ m_UpToDate

bool m_UpToDate = false
private

Boolean indicating whether the object has an up-to-date mole number vector and potential with respect to the current vcs state calc status.

Definition at line 772 of file vcs_VolPhase.h.

◆ m_UpToDate_AC

bool m_UpToDate_AC = false
mutableprivate

Boolean indicating whether activity coefficients are up to date.

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).

Definition at line 780 of file vcs_VolPhase.h.

◆ m_UpToDate_VolStar

bool m_UpToDate_VolStar = false
mutableprivate

Boolean indicating whether Star volumes are up to date.

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). Star volumes are sensitive to temperature and pressure

Definition at line 789 of file vcs_VolPhase.h.

◆ m_UpToDate_VolPM

bool m_UpToDate_VolPM = false
mutableprivate

Boolean indicating whether partial molar volumes are up to date.

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). partial molar volumes are sensitive to everything

Definition at line 798 of file vcs_VolPhase.h.

◆ m_UpToDate_GStar

bool m_UpToDate_GStar = false
mutableprivate

Boolean indicating whether GStar is up to date.

GStar is sensitive to the temperature and the pressure, only

Definition at line 804 of file vcs_VolPhase.h.

◆ m_UpToDate_G0

bool m_UpToDate_G0 = false
mutableprivate

Boolean indicating whether G0 is up to date.

G0 is sensitive to the temperature and the pressure, only

Definition at line 810 of file vcs_VolPhase.h.

◆ Temp_

double Temp_ = 273.15
private

Current value of the temperature for this object, and underlying objects.

Definition at line 813 of file vcs_VolPhase.h.

◆ Pres_

double Pres_ = OneAtm
private

Current value of the pressure for this object, and underlying objects.

Definition at line 816 of file vcs_VolPhase.h.


The documentation for this class was generated from the following files: