11 #ifndef VCS_VOLPHASE_H
12 #define VCS_VOLPHASE_H
26 #define VCS_AC_CONSTANT 0
30 #define VCS_AC_UNK_CANTERA -1
34 #define VCS_SSVOL_IDEALGAS 0
35 #define VCS_SSVOL_CONSTANT 1
43 #define VCS_EOS_CONSTANT 0
44 #define VCS_EOS_IDEAL_GAS 1
45 #define VCS_EOS_STOICH_SUB 5
46 #define VCS_EOS_IDEAL_SOLN 22
47 #define VCS_EOS_DEBEYE_HUCKEL 23
48 #define VCS_EOS_REDLICK_KWONG 24
49 #define VCS_EOS_REGULAR_SOLN 25
50 #define VCS_EOS_UNK_CANTERA -1
53 class vcs_SpeciesProperties;
116 void resize(
const size_t phaseNum,
const size_t numSpecies,
117 const size_t numElem,
const char*
const phaseName,
118 const double molesInert = 0.0);
120 void elemResize(
const size_t numElemConstraints);
140 const int vcsStateStatus);
154 const double* molesSpeciesVCS = 0);
175 const double* molesSpeciesVCS,
176 const double*
const TPhMoles);
276 void setState_TP(
const double temperature_Kelvin,
const double pressure_PA);
282 void setState_T(
const double temperature_Kelvin);
296 void sendToVCS_LnActCoeffJac(
double*
const*
const LnACJac_VCS);
359 double moleFraction(
size_t klocal)
const;
365 void setCreationMoleNumbers(
const double*
const n_k,
const std::vector<size_t> &creationGlobalRxnNumbers);
371 const std::vector<double> &
creationMoleNumbers(std::vector<size_t> &creationGlobalRxnNumbers)
const;
383 void setPhiVarIndex(
size_t phiVarIndex);
519 int elementActive(
const size_t e)
const;
DoubleStarStar m_formulaMatrix
Formula Matrix for the phase.
int speciesUnknownType(const size_t k) const
Returns the type of the species unknown.
vcs_SpeciesProperties * speciesProperty(const size_t kindex)
Retrieve the kth Species structure for the species belonging to this phase.
VCS_SOLVE * m_owningSolverObject
Backtrack value of VCS_SOLVE *.
double v_totalMoles
Total mols in the phase. units are kmol.
size_t VP_ID_
Original ID of the phase in the problem.
std::vector< int > m_elementActive
boolean indicating whether an element constraint is active for the current problem ...
bool m_UpToDate_VolPM
Boolean indicating whether partial molar volumes are up to date.
void _updateLnActCoeffJac()
Evaluation of Activity Coefficient Jacobians.
void setElemGlobalIndex(const size_t eLocal, const size_t eGlobal)
sets a local phase element to a global index value
std::vector< int > m_speciesUnknownType
Type of the species unknown.
std::vector< double > creationMoleNumbers_
Vector of current creationMoleNumbers_.
bool m_UpToDate
Boolean indicating whether the object has an up-to-date mole number vector and potential with respect...
std::vector< double > StarChemicalPotential
Vector of calculated Star chemical potentials for the current Temperature and pressure.
std::string PhaseName
String name for the phase.
std::vector< double > SS0ChemicalPotential
Vector of calculated SS0 chemical potentials for the current Temperature.
double VolStar_calc_one(size_t kspec) const
Molar volume calculation for standard state of one species.
void _updateGStar() const
Gibbs free energy calculation for standard states.
void setExistence(const int existence)
Set the existence flag in the object.
std::string elementName(const size_t e) const
Name of the element constraint with index e.
bool m_useCanteraCalls
If this is true, then calculations are actually performed within Cantera.
size_t m_numSpecies
Number of species in the phase.
bool m_UpToDate_G0
Boolean indicating whether G0 is up to date.
size_t m_phiVarIndex
If the potential is a solution variable in VCS, it acts as a species.
void _updateActCoeff() const
Evaluate the activity coefficients at the current conditions.
size_t transferElementsFM(const Cantera::ThermoPhase *const tPhase)
Transfer all of the element information from the ThermoPhase object to the vcs_VolPhase object...
int p_activityConvention
Convention for the activity formulation.
Properties of a single species.
double m_totalVol
Total Volume of the phase. Units are m**3.
const Cantera::ThermoPhase * ptrThermoPhase() const
Return a const ThermoPhase pointer corresponding to this phase.
std::vector< size_t > m_elemGlobalIndex
Index of the element number in the global list of elements stored in VCS_PROB or VCS_SOLVE.
std::vector< vcs_SpeciesProperties * > ListSpeciesPtr
Vector of Species structures for the species belonging to this phase.
size_t elemGlobalIndex(const size_t e) const
Returns the global index of the local element index for the phase.
double GStar_calc_one(size_t kspec) const
Gibbs free energy calculation for standard state of one species.
double sendToVCS_VolPM(double *const VolPM) const
Fill in the partial molar volume vector for VCS.
Base class for a phase with thermodynamic properties.
bool usingCanteraCalls() const
Returns whether the object is using cantera calls.
Phase information and Phase calculations for vcs.
Header file for class DoubleStarStar.
bool isIdealSoln() const
Returns whether the phase is an ideal solution phase.
std::vector< double > StarMolarVol
Vector of the Star molar Volumes of the species. units m3 / kmol.
void setCreationMoleNumbers(const double *const n_k, const std::vector< size_t > &creationGlobalRxnNumbers)
Sets the creationMoleNum's within the phase object.
std::vector< double > Xmol_
Vector of the current mole fractions for species in the phase.
std::vector< std::string > m_elementNames
vector of strings containing the element constraint names
const std::vector< double > & creationMoleNumbers(std::vector< size_t > &creationGlobalRxnNumbers) const
Return a const reference to the creationMoleNumbers stored in the object.
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.
void setMolesCurrent(int vcsStateStatus)
Sets the mole flag within the object to be current.
double const *const * getFormulaMatrix() const
Get a constant form of the Species Formula Matrix.
void _updateG0() const
Gibbs free energy calculation at a temperature for the reference state of each species.
double AC_calc_one(size_t kspec) const
Evaluate activity coefficients and return the kspec coefficient.
std::vector< size_t > IndSpecies
Index into the species vectors.
double Pres_
Current value of the pressure for this object, and underlying objects.
size_t spGlobalIndexVCS(const size_t spIndex) const
Return the Global VCS index of the kth species in the phase.
void updateFromVCS_MoleNumbers(const int stateCalc)
Update the moles within the phase, if necessary.
void _updateMoleFractionDependencies()
Updates the mole fraction dependencies.
void setTotalMolesInert(const double tMolesInert)
Sets the total moles of inert in the phase.
size_t m_numElemConstraints
Number of element constraints within the problem.
void setTotalMoles(const double totalMols)
Sets the total moles in the phase.
void setState_T(const double temperature_Kelvin)
Sets the temperature in this object and underlying ThermoPhase objects.
size_t phiVarIndex() const
Return the index of the species that represents the the voltage of the phase.
void sendToVCS_GStar(double *const gstar) const
Fill in the partial molar volume vector for VCS.
void setSpGlobalIndexVCS(const size_t spIndex, const size_t spGlobalIndex)
set the Global VCS index of the kth species in the phase
bool m_UpToDate_GStar
Boolean indicating whether GStar is up to date.
double electricPotential() const
Returns the electric field of the phase.
This is the main structure used to hold the internal data used in vcs_solve_TP(), and to solve TP sys...
const std::vector< double > & moleFractions() const
Return a const reference to the mole fractions stored in the object.
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.
size_t nSpecies() const
Return the number of species in the phase.
std::vector< int > m_elementType
Type of the element constraint.
std::vector< size_t > creationGlobalRxnNumbers_
Vector of creation global reaction numbers for the phase stability problem.
bool m_singleSpecies
If true, this phase consists of a single species.
DoubleStarStar np_dLnActCoeffdMolNumber
Vector of the derivatives of the ln activity coefficient wrt to the current mole number multiplied by...
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 setMolesFromVCS(const int stateCalc, const double *molesSpeciesVCS=0)
Set the moles within the phase.
int p_VCS_UnitsFormat
Units for the chemical potential data, pressure data, volume, and species amounts.
void sendToVCS_ActCoeff(const int stateCalc, double *const AC)
Fill in an activity coefficients vector within a VCS_SOLVE object.
Cantera::ThermoPhase * TP_ptr
If we are using Cantera, this is the pointer to the ThermoPhase object.
std::vector< double > ActCoeff
Vector of calculated activity coefficients for the current state.
double totalMolesInert() const
returns the value of the total kmol of inert in the phase
size_t ChargeNeutralityElement
This is the element number for the charge neutrality condition of the phase.
size_t nElemConstraints() const
Returns the number of element constraints.
std::vector< double > PartialMolarVol
Vector of the Partial molar Volumes of the species. units m3 / kmol.
void setMolesFromVCSCheck(const int vcsStateStatus, const double *molesSpeciesVCS, const double *const TPhMoles)
Set the moles within the phase.
double m_phi
Value of the potential for the phase (Volts)
void setElectricPotential(const double phi)
set the electric potential of the phase
int m_vcsStateStatus
Status.
bool m_UpToDate_AC
Boolean indicating whether activity coefficients are up to date.
std::string string16_EOSType(int EOSType)
Return a string representing the equation of state.
int exists() const
int indicating whether the phase exists or not
double totalMoles() const
Return the total moles in the phase.
void setPtrThermoPhase(Cantera::ThermoPhase *tp_ptr)
Set the pointer for Cantera's ThermoPhase parameter.
int elementType(const size_t e) const
Type of the element constraint with index e.
void setState_TP(const double temperature_Kelvin, const double pressure_PA)
Sets the temperature and pressure in this object and underlying ThermoPhase objects.
double molefraction(size_t kspec) const
Returns the mole fraction of the kspec species.
double m_totalMolesInert
Total moles of inert in the phase.
int m_eqnState
Type of the equation of state.
void setMolesOutOfDate(int stateCalc=-1)
Sets the mole flag within the object to out of date.
bool m_UpToDate_VolStar
Boolean indicating whether Star volumes are up to date.
void setElementType(const size_t e, const int eType)
Set the element Type of the element constraint with index e.
int m_existence
Current state of existence:
bool m_isIdealSoln
Boolean indicating whether the phase is an ideal solution and therefore its molar-based activity coef...
double Temp_
Current value of the temperature for this object, and underlying objects.
A class for 2D double arrays stored in column-major (Fortran-compatible) form.
bool m_gasPhase
If true, this phase is a gas-phase like phase.
void setMoleFractions(const double *const xmol)
Set the mole fractions from a conventional mole fraction vector.
void setMoleFractionsState(const double molNum, const double *const moleFracVec, const int vcsStateStatus)
Set the moles and/or mole fractions within the phase.