Cantera  2.0
Public Types | Public Member Functions | List of all members
Crystal Class Reference

A class for crystals. More...

#include <Crystal.h>

Inheritance diagram for Crystal:
[legend]
Collaboration diagram for Crystal:
[legend]

Public Types

typedef size_t index_t
 Shorthand for an index variable that can't be negative.
 

Public Member Functions

 Crystal ()
 Constructor.
 
virtual ~Crystal ()
 Destructor.
 
void addLattices (std::vector< LatticePhase * > &lattices, const vector_fp &latticeSiteDensity)
 
void addLattice (LatticePhase *lattice, doublereal siteDensity)
 Add a phase to the mixture.
 
LatticePhaselattice (index_t n)
 Return a reference to phase n.
 
void addPhases (std::vector< ThermoPhase * > &phases, const vector_fp &phaseMoles)
 Add a vector of phases to the mixture.
 
void addPhases (MultiPhase &mix)
 Add all phases present in 'mix' to this mixture.
 
void addPhase (ThermoPhase *p, doublereal moles)
 Add a phase to the mixture.
 
size_t nElements () const
 Number of elements.
 
void checkElementIndex (size_t m) const
 Check that the specified element index is in range Throws an exception if m is greater than nElements()-1.
 
void checkElementArraySize (size_t mm) const
 Check that an array size is at least nElements() Throws an exception if mm is less than nElements().
 
std::string elementName (size_t m) const
 Returns the string name of the global element m.
 
size_t elementIndex (std::string name) const
 Returns the index of the element with name name.
 
size_t nSpecies () const
 Number of species, summed over all phases.
 
void checkSpeciesIndex (size_t k) const
 Check that the specified species index is in range Throws an exception if k is greater than nSpecies()-1.
 
void checkSpeciesArraySize (size_t kk) const
 Check that an array size is at least nSpecies() Throws an exception if kk is less than nSpecies().
 
std::string speciesName (const size_t kGlob) const
 Name of species with global index kGlob.
 
doublereal nAtoms (const size_t kGlob, const size_t mGlob) const
 Returns the Number of atoms of global element mGlob in global species kGlob.
 
void getMoleFractions (doublereal *const x) const
 Returns the global Species mole fractions.
 
void init ()
 Process phases and build atomic composition array.
 
std::string phaseName (const index_t iph) const
 Returns the name of the n'th phase.
 
int phaseIndex (const std::string &pName) const
 Returns the index, given the phase name.
 
doublereal phaseMoles (const index_t n) const
 Return the number of moles in phase n.
 
void setPhaseMoles (const index_t n, const doublereal moles)
 Set the number of moles of phase with index n.
 
ThermoPhasephase (index_t n)
 Return a ThermoPhase reference to phase n.
 
void checkPhaseIndex (size_t m) const
 Check that the specified phase index is in range Throws an exception if m is greater than nPhases()
 
void checkPhaseArraySize (size_t mm) const
 Check that an array size is at least nPhases() Throws an exception if mm is less than nPhases().
 
doublereal speciesMoles (index_t kGlob) const
 Returns the moles of global species k.
 
size_t speciesIndex (index_t k, index_t p) const
 Return the global index of the species belonging to phase number p with local index k within the phase.
 
size_t speciesIndex (std::string speciesName, std::string phaseName)
 Return the global index of the species belonging to phase name phaseName with species name speciesName.
 
doublereal minTemp () const
 Minimum temperature for which all solution phases have valid thermo data.
 
doublereal maxTemp () const
 Maximum temperature for which all solution phases have valid thermo data.
 
doublereal charge () const
 Total charge summed over all phases (Coulombs).
 
doublereal phaseCharge (index_t p) const
 Charge (Coulombs) of phase with index p.
 
doublereal elementMoles (index_t m) const
 Total moles of global element m, summed over all phases.
 
void getChemPotentials (doublereal *mu) const
 Returns a vector of Chemical potentials.
 
void getValidChemPotentials (doublereal not_mu, doublereal *mu, bool standard=false) const
 Returns a vector of Valid chemical potentials.
 
doublereal temperature () const
 Temperature [K].
 
doublereal equilibrate (int XY, doublereal err=1.0e-9, int maxsteps=1000, int maxiter=200, int loglevel=-99)
 Set the mixture to a state of chemical equilibrium.
 
void setTemperature (const doublereal T)
 Set the temperature [K].
 
void setState_TP (const doublereal T, const doublereal Pres)
 Set the state of the underlying ThermoPhase objects in one call.
 
void setState_TPMoles (const doublereal T, const doublereal Pres, const doublereal *Moles)
 Set the state of the underlying ThermoPhase objects in one call.
 
doublereal pressure () const
 Pressure [Pa].
 
doublereal volume () const
 Volume [m^3].
 
void setPressure (doublereal P)
 Set the pressure [Pa].
 
doublereal enthalpy () const
 Enthalpy [J].
 
doublereal IntEnergy () const
 Enthalpy [J].
 
doublereal entropy () const
 Entropy [J/K].
 
doublereal gibbs () const
 Gibbs function [J].
 
doublereal cp () const
 Heat capacity at constant pressure [J/K].
 
index_t nPhases () const
 Number of phases.
 
bool solutionSpecies (index_t kGlob) const
 Return true is species kGlob is a species in a multicomponent solution phase.
 
size_t speciesPhaseIndex (const index_t kGlob) const
 Returns the phase index of the Kth "global" species.
 
doublereal moleFraction (const index_t kGlob) const
 Returns the mole fraction of global species k.
 
void setPhaseMoleFractions (const index_t n, const doublereal *const x)
 Set the Mole fractions of the nth phase.
 
void setMolesByName (compositionMap &xMap)
 Set the number numbers of species in the MultiPhase.
 
void setMolesByName (const std::string &x)
 Set the Moles via a string containing their names.
 
void getMoles (doublereal *molNum) const
 Return a vector of global species mole numbers.
 
void setMoles (const doublereal *n)
 Sets all of the global species mole numbers.
 
void addSpeciesMoles (const int indexS, const doublereal addedMoles)
 Adds moles of a certain species to the mixture.
 
void getElemAbundances (doublereal *elemAbundances) const
 Retrieves a vector of element abundances.
 
bool tempOK (index_t p) const
 Return true if the phase p has valid thermo data for the current temperature.
 
void updateMoleFractions ()
 Update the locally-stored composition within this object to match the current compositions of the phase objects.
 
void uploadMoleFractionsFromPhases ()
 Update the locally-stored composition within this object to match the current compositions of the phase objects.
 
void updatePhases () const
 Set the states of the phase objects to the locally-stored state within this MultiPhase object.
 

Detailed Description

A class for crystals.

Each crystal consists of one or more sublattices, each represented by an object of type LatticePhase.

Definition at line 16 of file Crystal.h.

Member Typedef Documentation

typedef size_t index_t
inherited

Shorthand for an index variable that can't be negative.

Definition at line 65 of file MultiPhase.h.

Constructor & Destructor Documentation

Crystal ( )
inline

Constructor.

The constructor takes no arguments, since phases are added using method addPhase.

Definition at line 21 of file Crystal.h.

virtual ~Crystal ( )
inlinevirtual

Destructor.

Does nothing. Class MultiPhase does not take "ownership" (i.e. responsibility for destroying) the phase objects.

Definition at line 26 of file Crystal.h.

Member Function Documentation

void addLattice ( LatticePhase lattice,
doublereal  siteDensity 
)
inline

Add a phase to the mixture.

Parameters
latticepointer to the phase object
siteDensitytotal density of sites in this phase

Definition at line 34 of file Crystal.h.

References MultiPhase::addPhase().

LatticePhase& lattice ( index_t  n)
inline

Return a reference to phase n.

The state of phase n is also updated to match the state stored locally in the mixture object.

Definition at line 41 of file Crystal.h.

References MultiPhase::phase().

void addPhases ( std::vector< ThermoPhase * > &  phases,
const vector_fp phaseMoles 
)
inherited

Add a vector of phases to the mixture.

See the single addPhases command. This just does a bunch of phases at one time

Parameters
phasesVector of pointers to phases
phaseMolesVector of mole numbers in each phase (kmol)

Definition at line 103 of file MultiPhase.cpp.

References MultiPhase::addPhase(), and MultiPhase::init().

void addPhases ( MultiPhase mix)
inherited

Add all phases present in 'mix' to this mixture.

Parameters
mixAdd all of the phases in another MultiPhase object to the current object.

Definition at line 94 of file MultiPhase.cpp.

References MultiPhase::addPhase(), MultiPhase::m_moles, MultiPhase::m_np, and MultiPhase::m_phase.

void addPhase ( ThermoPhase p,
doublereal  moles 
)
inherited
size_t nElements ( ) const
inlineinherited
void checkElementIndex ( size_t  m) const
inherited

Check that the specified element index is in range Throws an exception if m is greater than nElements()-1.

Definition at line 1026 of file MultiPhase.cpp.

References MultiPhase::m_nel.

void checkElementArraySize ( size_t  mm) const
inherited

Check that an array size is at least nElements() Throws an exception if mm is less than nElements().

Used before calls which take an array pointer.

Definition at line 1033 of file MultiPhase.cpp.

References MultiPhase::m_nel.

std::string elementName ( size_t  m) const
inherited

Returns the string name of the global element m.

Parameters
mindex of the global element

Definition at line 1042 of file MultiPhase.cpp.

References MultiPhase::m_enames.

Referenced by MultiPhaseEquil::MultiPhaseEquil().

size_t elementIndex ( std::string  name) const
inherited

Returns the index of the element with name name.

Parameters
nameString name of the global element

Definition at line 1048 of file MultiPhase.cpp.

References MultiPhase::m_enames, MultiPhase::m_nel, and Cantera::npos.

size_t nSpecies ( ) const
inlineinherited
void checkSpeciesIndex ( size_t  k) const
inherited

Check that the specified species index is in range Throws an exception if k is greater than nSpecies()-1.

Definition at line 1058 of file MultiPhase.cpp.

References MultiPhase::m_nsp.

void checkSpeciesArraySize ( size_t  kk) const
inherited

Check that an array size is at least nSpecies() Throws an exception if kk is less than nSpecies().

Used before calls which take an array pointer.

Definition at line 1065 of file MultiPhase.cpp.

References MultiPhase::m_nsp.

std::string speciesName ( const size_t  kGlob) const
inherited

Name of species with global index kGlob.

Parameters
kGlobglobal species index

Definition at line 1074 of file MultiPhase.cpp.

References MultiPhase::m_snames.

Referenced by MultiPhaseEquil::MultiPhaseEquil(), MultiPhaseEquil::reactionString(), MultiPhase::setMolesByName(), and MultiPhaseEquil::stepComposition().

doublereal nAtoms ( const size_t  kGlob,
const size_t  mGlob 
) const
inherited

Returns the Number of atoms of global element mGlob in global species kGlob.

Parameters
kGlobglobal species index
mGlobglobal element index
Returns
returns the number of atoms.

Definition at line 1079 of file MultiPhase.cpp.

References MultiPhase::m_atoms.

Referenced by MultiPhaseEquil::getComponents(), and MultiPhaseEquil::MultiPhaseEquil().

void getMoleFractions ( doublereal *const  x) const
inherited

Returns the global Species mole fractions.

Write the array of species mole fractions into array x. The mole fractions are normalized to sum to one in each phase.

Parameters
xvector of mole fractions. Length = number of global species.

Definition at line 1084 of file MultiPhase.cpp.

References MultiPhase::m_moleFractions.

void init ( )
inherited
std::string phaseName ( const index_t  iph) const
inherited

Returns the name of the n'th phase.

Parameters
iphphase Index

Definition at line 1089 of file MultiPhase.cpp.

References Phase::id(), and MultiPhase::m_phase.

Referenced by vcs_MultiPhaseEquil::determine_PhaseStability().

int phaseIndex ( const std::string &  pName) const
inherited

Returns the index, given the phase name.

Parameters
pNameName of the phase
Returns
returns the index. A value of -1 means the phase isn't in the object.

Definition at line 1095 of file MultiPhase.cpp.

References Phase::id(), MultiPhase::m_np, and MultiPhase::m_phase.

Referenced by MultiPhase::speciesIndex().

doublereal phaseMoles ( const index_t  n) const
inherited

Return the number of moles in phase n.

Parameters
nIndex of the phase.

Definition at line 1108 of file MultiPhase.cpp.

References MultiPhase::m_moles.

Referenced by MultiPhaseEquil::computeReactionSteps(), vcs_MultiPhaseEquil::equilibrate_HP(), vcs_MultiPhaseEquil::equilibrate_SP(), and Cantera::operator<<().

void setPhaseMoles ( const index_t  n,
const doublereal  moles 
)
inherited

Set the number of moles of phase with index n.

Parameters
nIndex of the phase
molesNumber of moles in the phase (kmol)

Definition at line 1113 of file MultiPhase.cpp.

References MultiPhase::m_moles.

Referenced by vcs_MultiPhaseEquil::equilibrate_TP().

ThermoPhase & phase ( index_t  n)
inherited

Return a ThermoPhase reference to phase n.

The state of phase n is also updated to match the state stored locally in the mixture object.

Parameters
nPhase Index
Returns
Reference to the ThermoPhase object for the phase

Definition at line 260 of file MultiPhase.cpp.

References DATA_PTR, MultiPhase::init(), MultiPhase::m_init, MultiPhase::m_moleFractions, MultiPhase::m_phase, MultiPhase::m_press, MultiPhase::m_spstart, and MultiPhase::m_temp.

Referenced by MultiPhaseEquil::computeReactionSteps(), vcs_MultiPhaseEquil::equilibrate_TP(), Crystal::lattice(), Cantera::operator<<(), and vcs_MultiPhaseEquil::reportCSV().

void checkPhaseIndex ( size_t  m) const
inherited

Check that the specified phase index is in range Throws an exception if m is greater than nPhases()

Definition at line 271 of file MultiPhase.cpp.

References MultiPhase::nPhases().

void checkPhaseArraySize ( size_t  mm) const
inherited

Check that an array size is at least nPhases() Throws an exception if mm is less than nPhases().

Used before calls which take an array pointer.

Definition at line 278 of file MultiPhase.cpp.

References MultiPhase::nPhases().

doublereal speciesMoles ( index_t  kGlob) const
inherited

Returns the moles of global species k.

Moles of species k.

Returns the moles of global species k. units = kmol

Parameters
kGlobGlobal species index k

Definition at line 287 of file MultiPhase.cpp.

References MultiPhase::m_moleFractions, MultiPhase::m_moles, and MultiPhase::m_spphase.

Referenced by MultiPhaseEquil::computeReactionSteps(), and MultiPhaseEquil::MultiPhaseEquil().

size_t speciesIndex ( index_t  k,
index_t  p 
) const
inlineinherited

Return the global index of the species belonging to phase number p with local index k within the phase.

Returns the index of the global species

Parameters
klocal index of the species within the phase
pindex of the phase

Definition at line 259 of file MultiPhase.h.

References MultiPhase::m_spstart.

Referenced by MultiPhase::elementMoles(), MultiPhase::phaseCharge(), and vcs_MultiPhaseEquil::reportCSV().

size_t speciesIndex ( std::string  speciesName,
std::string  phaseName 
)
inherited

Return the global index of the species belonging to phase name phaseName with species name speciesName.

Returns the index of the global species

Parameters
speciesNameSpecies Name
phaseNamePhase Name
Returns
returns the global index

If the species or phase name is not recognized, this routine throws a CanteraError.

Definition at line 324 of file MultiPhase.cpp.

References MultiPhase::init(), MultiPhase::m_init, MultiPhase::m_phase, MultiPhase::m_spstart, Cantera::npos, and MultiPhase::phaseIndex().

doublereal minTemp ( ) const
inlineinherited

Minimum temperature for which all solution phases have valid thermo data.

Stoichiometric phases are not considered, since they may have thermo data only valid for conditions for which they are stable.

Definition at line 282 of file MultiPhase.h.

References MultiPhase::m_Tmin.

Referenced by vcs_MultiPhaseEquil::equilibrate(), vcs_MultiPhaseEquil::equilibrate_HP(), vcs_MultiPhaseEquil::equilibrate_SP(), vcs_MultiPhaseEquil::equilibrate_TV(), and MultiPhase::updatePhases().

doublereal maxTemp ( ) const
inlineinherited

Maximum temperature for which all solution phases have valid thermo data.

Stoichiometric phases are not considered, since they may have thermo data only valid for conditions for which they are stable.

Definition at line 290 of file MultiPhase.h.

References MultiPhase::m_Tmax.

Referenced by vcs_MultiPhaseEquil::equilibrate(), vcs_MultiPhaseEquil::equilibrate_HP(), vcs_MultiPhaseEquil::equilibrate_SP(), vcs_MultiPhaseEquil::equilibrate_TV(), and MultiPhase::updatePhases().

doublereal charge ( ) const
inherited

Total charge summed over all phases (Coulombs).

Definition at line 314 of file MultiPhase.cpp.

References MultiPhase::m_np, and MultiPhase::phaseCharge().

doublereal phaseCharge ( index_t  p) const
inherited

Charge (Coulombs) of phase with index p.

Net charge of one phase (Coulombs).

Parameters
pPhase Index

The net charge is computed as

\[ Q_p = N_p \sum_k F z_k X_k \]

where the sum runs only over species in phase p.

Parameters
pindex of the phase for which the charge is desired.

Definition at line 344 of file MultiPhase.cpp.

References MultiPhase::m_moleFractions, MultiPhase::m_moles, MultiPhase::m_phase, and MultiPhase::speciesIndex().

Referenced by MultiPhase::charge().

doublereal elementMoles ( index_t  m) const
inherited

Total moles of global element m, summed over all phases.

Parameters
mIndex of the global element

Definition at line 297 of file MultiPhase.cpp.

References MultiPhase::m_atoms, MultiPhase::m_moleFractions, MultiPhase::m_moles, MultiPhase::m_np, MultiPhase::m_phase, and MultiPhase::speciesIndex().

Referenced by MultiPhaseEquil::MultiPhaseEquil().

void getChemPotentials ( doublereal *  mu) const
inherited

Returns a vector of Chemical potentials.

Get the chemical potentials of all species in all phases.

Write into array mu the chemical potentials of all species [J/kmol]. The chemical potentials are related to the activities by

\( \mu_k = \mu_k^0(T, P) + RT \ln a_k. \).

Parameters
muChemical potential vector. Length = num global species. Units = J/kmol.

Definition at line 357 of file MultiPhase.cpp.

References MultiPhase::m_np, MultiPhase::m_phase, and MultiPhase::updatePhases().

Referenced by vcs_MultiPhaseEquil::determine_PhaseStability().

void getValidChemPotentials ( doublereal  not_mu,
doublereal *  mu,
bool  standard = false 
) const
inherited

Returns a vector of Valid chemical potentials.

Write into array mu the chemical potentials of all species with thermo data valid for the current temperature [J/kmol]. For other species, set the chemical potential to the value not_mu. If standard is set to true, then the values returned are standard chemical potentials.

This method is designed for use in computing chemical equilibrium by Gibbs minimization. For solution phases (more than one species), this does the same thing as getChemPotentials. But for stoichiometric phases, this writes into array mu the user-specified value not_mu instead of the chemical potential if the temperature is outside the range for which the thermo data for the one species in the phase are valid. The need for this arises since many condensed phases have thermo data fit only for the temperature range for which they are stable. For example, in the NASA database, the fits for H2O(s) are only done up to 0 C, the fits for H2O(L) are only done from 0 C to 100 C, etc. Using the polynomial fits outside the range for which the fits were done can result in spurious chemical potentials, and can lead to condensed phases appearing when in fact they should be absent.

By setting not_mu to a large positive value, it is possible to force routines which seek to minimize the Gibbs free energy of the mixture to zero out any phases outside the temperature range for which their thermo data are valid.

Parameters
not_muValue of the chemical potential to set species in phases, for which the thermo data is not valid
muVector of chemical potentials length = Global species, units = J kmol-1
standardIf this method is called with standard set to true, then the composition-independent standard chemical potentials are returned instead of the composition-dependent chemical potentials.

Definition at line 394 of file MultiPhase.cpp.

References MultiPhase::m_np, MultiPhase::m_phase, MultiPhase::nSpecies(), MultiPhase::tempOK(), and MultiPhase::updatePhases().

Referenced by MultiPhaseEquil::computeReactionSteps(), MultiPhaseEquil::setInitialMoles(), and MultiPhaseEquil::stepComposition().

doublereal temperature ( ) const
inlineinherited
doublereal equilibrate ( int  XY,
doublereal  err = 1.0e-9,
int  maxsteps = 1000,
int  maxiter = 200,
int  loglevel = -99 
)
inherited

Set the mixture to a state of chemical equilibrium.

Parameters
XYInteger flag specifying properties to hold fixed.
errError tolerance for \(\Delta \mu/RT \) for all reactions. Also used as the relative error tolerance for the outer loop.
maxstepsMaximum number of steps to take in solving the fixed TP problem.
maxiterMaximum number of "outer" iterations for problems holding fixed something other than (T,P).
loglevelLevel of diagnostic output, written to a file in HTML format.

Definition at line 679 of file MultiPhase.cpp.

References Cantera::addLogEntry(), Cantera::beginLogGroup(), MultiPhase::cp(), Cantera::endLogGroup(), MultiPhase::enthalpy(), MultiPhase::entropy(), Cantera::fp2str(), MultiPhase::init(), Cantera::int2str(), MultiPhase::m_init, MultiPhase::m_temp, MultiPhase::m_Tmax, MultiPhase::m_Tmin, MultiPhase::pressure(), CanteraError::save(), MultiPhase::setPressure(), MultiPhase::setTemperature(), MultiPhase::temperature(), Cantera::Undef, and MultiPhase::volume().

Referenced by Cantera::equilibrate(), and Cantera::vcs_equilibrate_1().

void setTemperature ( const doublereal  T)
inherited
void setState_TP ( const doublereal  T,
const doublereal  Pres 
)
inherited

Set the state of the underlying ThermoPhase objects in one call.

Parameters
TTemperature of the system (kelvin)
Prespressure of the system (pascal) (kmol)

Definition at line 615 of file MultiPhase.cpp.

References MultiPhase::init(), MultiPhase::m_init, MultiPhase::m_press, MultiPhase::m_temp, and MultiPhase::updatePhases().

void setState_TPMoles ( const doublereal  T,
const doublereal  Pres,
const doublereal *  Moles 
)
inherited

Set the state of the underlying ThermoPhase objects in one call.

Parameters
TTemperature of the system (kelvin)
Prespressure of the system (pascal)
MolesVector of mole numbers of all the species in all the phases (kmol)

Definition at line 625 of file MultiPhase.cpp.

References MultiPhase::m_press, MultiPhase::m_temp, and MultiPhase::setMoles().

doublereal pressure ( ) const
inlineinherited
doublereal volume ( ) const
inherited

Volume [m^3].

The total mixture volume [m^3].

Returns the cummulative sum of the volumes of all the phases in the MultiPhase.

Definition at line 668 of file MultiPhase.cpp.

References MultiPhase::m_moles, MultiPhase::m_np, and MultiPhase::m_phase.

Referenced by MultiPhase::equilibrate(), and vcs_MultiPhaseEquil::equilibrate_TV().

void setPressure ( doublereal  P)
inlineinherited

Set the pressure [Pa].

Parameters
PSet the pressure in the MultiPhase object (Pa)

Definition at line 431 of file MultiPhase.h.

References MultiPhase::m_press, and MultiPhase::updatePhases().

Referenced by MultiPhase::equilibrate(), and vcs_MultiPhaseEquil::equilibrate_TV().

doublereal enthalpy ( ) const
inherited
doublereal IntEnergy ( ) const
inherited

Enthalpy [J].

The internal energy of the mixture (J).

Definition at line 454 of file MultiPhase.cpp.

References MultiPhase::m_moles, MultiPhase::m_np, MultiPhase::m_phase, and MultiPhase::updatePhases().

Referenced by vcs_MultiPhaseEquil::equilibrate(), and vcs_MultiPhaseEquil::equilibrate_HP().

doublereal entropy ( ) const
inherited
doublereal gibbs ( ) const
inherited

Gibbs function [J].

The Gibbs free energy of the mixture (J).

Definition at line 426 of file MultiPhase.cpp.

References MultiPhase::m_moles, MultiPhase::m_np, MultiPhase::m_phase, and MultiPhase::updatePhases().

doublereal cp ( ) const
inherited

Heat capacity at constant pressure [J/K].

The specific heat at constant pressure and composition (J/K).

Note that this does not account for changes in composition of the mixture with temperature.

Definition at line 484 of file MultiPhase.cpp.

References MultiPhase::m_moles, MultiPhase::m_np, MultiPhase::m_phase, and MultiPhase::updatePhases().

Referenced by MultiPhase::equilibrate().

index_t nPhases ( ) const
inlineinherited
bool solutionSpecies ( index_t  kGlob) const
inherited

Return true is species kGlob is a species in a multicomponent solution phase.

True if species k belongs to a solution phase.

Parameters
kGlobindex of the global species

Definition at line 416 of file MultiPhase.cpp.

References MultiPhase::m_phase, MultiPhase::m_spphase, and MultiPhase::nSpecies().

Referenced by MultiPhaseEquil::getComponents(), and MultiPhaseEquil::MultiPhaseEquil().

size_t speciesPhaseIndex ( const index_t  kGlob) const
inherited

Returns the phase index of the Kth "global" species.

Parameters
kGlobGlobal species index.
Returns
Returns the index of the owning phase.

Definition at line 1118 of file MultiPhase.cpp.

References MultiPhase::m_spphase.

Referenced by MultiPhaseEquil::computeReactionSteps(), and MultiPhaseEquil::MultiPhaseEquil().

doublereal moleFraction ( const index_t  kGlob) const
inherited

Returns the mole fraction of global species k.

Parameters
kGlobIndex of the global species.

Definition at line 1123 of file MultiPhase.cpp.

References MultiPhase::m_moleFractions.

void setPhaseMoleFractions ( const index_t  n,
const doublereal *const  x 
)
inherited

Set the Mole fractions of the nth phase.

Set the mole fractions of phase n to the values in array x.

This function sets the mole fractions of the nth phase. Note, the mole number of the phase stays constant

Parameters
nID of the phase
xVector of input mole fractions.

Definition at line 501 of file MultiPhase.cpp.

References MultiPhase::init(), MultiPhase::m_init, MultiPhase::m_moleFractions, MultiPhase::m_phase, MultiPhase::m_press, MultiPhase::m_spstart, MultiPhase::m_temp, Phase::nSpecies(), and ThermoPhase::setState_TPX().

void setMolesByName ( compositionMap xMap)
inherited

Set the number numbers of species in the MultiPhase.

Parameters
xMapCompositionMap of the species with nonzero mole numbers units = kmol.

Definition at line 517 of file MultiPhase.cpp.

References DATA_PTR, MultiPhase::nSpecies(), MultiPhase::setMoles(), and MultiPhase::speciesName().

Referenced by MultiPhase::setMolesByName().

void setMolesByName ( const std::string &  x)
inherited

Set the Moles via a string containing their names.

The string x is in the form of a composition map Species which are not listed by name in the composition map are set to zero.

Parameters
xstring x in the form of a composition map where values are the moles of the species.

Definition at line 533 of file MultiPhase.cpp.

References MultiPhase::nSpecies(), Cantera::parseCompString(), MultiPhase::setMolesByName(), and MultiPhase::speciesName().

void getMoles ( doublereal *  molNum) const
inherited

Return a vector of global species mole numbers.

Returns a vector of the number of moles of each species in the multiphase object.

Parameters
molNumVector of doubles of length nSpecies containing the global mole numbers (kmol).

Definition at line 552 of file MultiPhase.cpp.

References MultiPhase::m_moleFractions, MultiPhase::m_moles, MultiPhase::m_np, MultiPhase::m_phase, and Phase::nSpecies().

Referenced by MultiPhase::addSpeciesMoles().

void setMoles ( const doublereal *  n)
inherited

Sets all of the global species mole numbers.

Set the species moles to the values in array n.

Sets the number of moles of each species in the multiphase object.

Parameters
nVector of doubles of length nSpecies containing the global mole numbers (kmol).

The state of each phase object is also updated to have the specified composition and the mixture temperature and pressure.

Definition at line 573 of file MultiPhase.cpp.

References DATA_PTR, Phase::getMoleFractions(), MultiPhase::init(), MultiPhase::m_init, MultiPhase::m_moleFractions, MultiPhase::m_moles, MultiPhase::m_np, MultiPhase::m_phase, MultiPhase::m_press, MultiPhase::m_temp, Phase::nSpecies(), and ThermoPhase::setState_TPX().

Referenced by MultiPhase::addSpeciesMoles(), MultiPhaseEquil::finish(), MultiPhase::setMolesByName(), and MultiPhase::setState_TPMoles().

void addSpeciesMoles ( const int  indexS,
const doublereal  addedMoles 
)
inherited

Adds moles of a certain species to the mixture.

Parameters
indexSIndex of the species in the MultiPhase object
addedMolesValue of the moles that are added to the species.

Definition at line 604 of file MultiPhase.cpp.

References DATA_PTR, MultiPhase::getMoles(), MultiPhase::m_nsp, and MultiPhase::setMoles().

void getElemAbundances ( doublereal *  elemAbundances) const
inherited

Retrieves a vector of element abundances.

Parameters
elemAbundancesVector of element abundances Length = number of elements in the MultiPhase object. Index is the global element index units is in kmol.

Definition at line 633 of file MultiPhase.cpp.

References MultiPhase::calcElemAbundances(), MultiPhase::m_elemAbundances, and MultiPhase::m_nel.

bool tempOK ( index_t  p) const
inherited

Return true if the phase p has valid thermo data for the current temperature.

Parameters
pIndex of the phase.

Definition at line 1129 of file MultiPhase.cpp.

References MultiPhase::m_temp_OK.

Referenced by MultiPhase::getValidChemPotentials(), and MultiPhaseEquil::MultiPhaseEquil().

void updateMoleFractions ( )
inherited

Update the locally-stored composition within this object to match the current compositions of the phase objects.

Update the locally-stored species mole fractions.

Deprecated:
'update' is confusing within this context. Switching to the terminology 'uploadFrom' and 'downloadTo'. uploadFrom means to query the underlying ThermoPhase objects and fill in the resulting information within this object. downloadTo means to take information from this object and put it into the underlying ThermoPhase objects. switch to uploadMoleFractionsFromPhases();

Definition at line 1135 of file MultiPhase.cpp.

References MultiPhase::uploadMoleFractionsFromPhases().

void uploadMoleFractionsFromPhases ( )
inherited

Update the locally-stored composition within this object to match the current compositions of the phase objects.

Update the locally-stored species mole fractions.

Query the underlying ThermoPhase objects for their mole fractions and fill in the mole fraction vector of this current object. Adjust element compositions within this object to match.

This is an upload operation in the sense that we are taking downstream information (ThermoPhase object info) and applying it to an upstream object (MultiPhase object).

Definition at line 1141 of file MultiPhase.cpp.

References MultiPhase::calcElemAbundances(), DATA_PTR, Phase::getMoleFractions(), MultiPhase::m_moleFractions, MultiPhase::m_np, MultiPhase::m_phase, and Phase::nSpecies().

Referenced by vcs_MultiPhaseEquil::determine_PhaseStability(), vcs_MultiPhaseEquil::equilibrate_TP(), MultiPhase::init(), and MultiPhase::updateMoleFractions().

void updatePhases ( ) const
inherited

Set the states of the phase objects to the locally-stored state within this MultiPhase object.

synchronize the phase objects with the mixture state.

Note that if individual phases have T and P different than that stored locally, the phase T and P will be modified.

This is an download operation in the sense that we are taking upstream object information (MultiPhase object) and applying it to downstream objects (ThermoPhase object information)

Therefore, the term, "update", is appropriate for a downstream operation.

This method sets each phase to the mixture temperature and pressure, and sets the phase mole fractions based on the mixture mole numbers.

Definition at line 1164 of file MultiPhase.cpp.

References DATA_PTR, MultiPhase::m_moleFractions, MultiPhase::m_np, MultiPhase::m_phase, MultiPhase::m_press, MultiPhase::m_temp, MultiPhase::m_temp_OK, MultiPhase::maxTemp(), and MultiPhase::minTemp().

Referenced by MultiPhase::cp(), MultiPhase::enthalpy(), MultiPhase::entropy(), MultiPhase::getChemPotentials(), MultiPhase::getValidChemPotentials(), MultiPhase::gibbs(), MultiPhase::init(), MultiPhase::IntEnergy(), MultiPhase::setPressure(), MultiPhase::setState_TP(), and MultiPhase::setTemperature().


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