Cantera  2.3.0
vcs_Gibbs.cpp
Go to the documentation of this file.
1 /**
2  * @file vcs_Gibbs.cpp
3  * Functions which calculate the extrinsic Gibbs Free energies
4  */
5 
6 // This file is part of Cantera. See License.txt in the top-level directory or
7 // at http://www.cantera.org/license.txt for license and copyright information.
8 
11 
12 namespace Cantera
13 {
14 double VCS_SOLVE::vcs_Total_Gibbs(double* molesSp, double* chemPot,
15  double* tPhMoles)
16 {
17  double g = 0.0;
18 
19  for (size_t iph = 0; iph < m_numPhases; iph++) {
20  vcs_VolPhase* Vphase = m_VolPhaseList[iph];
21  if ((TPhInertMoles[iph] > 0.0) && (tPhMoles[iph] > 0.0)) {
22  g += TPhInertMoles[iph] *
23  log(TPhInertMoles[iph] / tPhMoles[iph]);
24  if (Vphase->m_gasPhase) {
25  g += TPhInertMoles[iph] * log(m_pressurePA/(1.01325E5));
26  }
27  }
28  }
29 
30  for (size_t kspec = 0; kspec < m_numSpeciesRdc; ++kspec) {
32  g += molesSp[kspec] * chemPot[kspec];
33  }
34  }
35 
36  return g;
37 }
38 
39 double VCS_SOLVE::vcs_GibbsPhase(size_t iphase, const double* const w,
40  const double* const fe)
41 {
42  double g = 0.0;
43  double phaseMols = 0.0;
44  for (size_t kspec = 0; kspec < m_numSpeciesRdc; ++kspec) {
45  if (m_phaseID[kspec] == iphase && m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
46  g += w[kspec] * fe[kspec];
47  phaseMols += w[kspec];
48  }
49  }
50 
51  if (TPhInertMoles[iphase] > 0.0) {
52  phaseMols += TPhInertMoles[iphase];
53  g += TPhInertMoles[iphase] * log(TPhInertMoles[iphase] / phaseMols);
54  vcs_VolPhase* Vphase = m_VolPhaseList[iphase];
55  if (Vphase->m_gasPhase) {
56  g += TPhInertMoles[iphase] * log(m_pressurePA/1.01325E5);
57  }
58  }
59 
60  return g;
61 }
62 
63 }
std::vector< size_t > m_phaseID
Mapping from the species number to the phase number.
Definition: vcs_solve.h:1703
double vcs_Total_Gibbs(double *w, double *fe, double *tPhMoles)
Calculate the total dimensionless Gibbs free energy.
Definition: vcs_Gibbs.cpp:14
vector_int m_speciesUnknownType
Specifies the species unknown type.
Definition: vcs_solve.h:1511
std::vector< vcs_VolPhase * > m_VolPhaseList
Array of Phase Structures. Length = number of phases.
Definition: vcs_solve.h:1740
size_t m_numSpeciesRdc
Current number of species in the problems.
Definition: vcs_solve.h:1403
double vcs_GibbsPhase(size_t iphase, const double *const w, const double *const fe)
Calculate the total dimensionless Gibbs free energy of a single phase.
Definition: vcs_Gibbs.cpp:39
Header file for the internal object that holds the vcs equilibrium problem (see Class VCS_SOLVE and E...
Header for the object representing each phase within vcs.
vector_fp TPhInertMoles
Total kmoles of inert to add to each phase.
Definition: vcs_solve.h:1626
bool m_gasPhase
If true, this phase is a gas-phase like phase.
Definition: vcs_VolPhase.h:573
Phase information and Phase calculations for vcs.
Definition: vcs_VolPhase.h:81
double m_pressurePA
Pressure.
Definition: vcs_solve.h:1619
#define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE
Unknown refers to the voltage level of a phase.
Definition: vcs_defs.h:309
Namespace for the Cantera kernel.
Definition: application.cpp:29
size_t m_numPhases
Number of Phases in the problem.
Definition: vcs_solve.h:1414