Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  * Copyright (2005) Sandia Corporation. Under the terms of
7  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
8  * U.S. Government retains certain rights in this software.
9  */
10 
13 
14 namespace Cantera
15 {
16 double VCS_SOLVE::vcs_Total_Gibbs(double* molesSp, double* chemPot,
17  double* tPhMoles)
18 {
19  double g = 0.0;
20 
21  for (size_t iph = 0; iph < m_numPhases; iph++) {
22  vcs_VolPhase* Vphase = m_VolPhaseList[iph];
23  if ((TPhInertMoles[iph] > 0.0) && (tPhMoles[iph] > 0.0)) {
24  g += TPhInertMoles[iph] *
25  log(TPhInertMoles[iph] / tPhMoles[iph]);
26  if (Vphase->m_gasPhase) {
27  g += TPhInertMoles[iph] * log(m_pressurePA/(1.01325E5));
28  }
29  }
30  }
31 
32  for (size_t kspec = 0; kspec < m_numSpeciesRdc; ++kspec) {
34  g += molesSp[kspec] * chemPot[kspec];
35  }
36  }
37 
38  return g;
39 }
40 
41 double VCS_SOLVE::vcs_GibbsPhase(size_t iphase, const double* const w,
42  const double* const fe)
43 {
44  double g = 0.0;
45  double phaseMols = 0.0;
46  for (size_t kspec = 0; kspec < m_numSpeciesRdc; ++kspec) {
47  if (m_phaseID[kspec] == iphase) {
49  g += w[kspec] * fe[kspec];
50  phaseMols += w[kspec];
51  }
52  }
53  }
54 
55  if (TPhInertMoles[iphase] > 0.0) {
56  phaseMols += TPhInertMoles[iphase];
57  g += TPhInertMoles[iphase] * log(TPhInertMoles[iphase] / phaseMols);
58  vcs_VolPhase* Vphase = m_VolPhaseList[iphase];
59  if (Vphase->m_gasPhase) {
60  g += TPhInertMoles[iphase] * log(m_pressurePA/1.01325E5);
61  }
62  }
63 
64  return g;
65 }
66 
67 }
std::vector< size_t > m_phaseID
Mapping from the species number to the phase number.
Definition: vcs_solve.h:1832
double vcs_Total_Gibbs(double *w, double *fe, double *tPhMoles)
Calculate the total dimensionless Gibbs free energy.
Definition: vcs_Gibbs.cpp:16
std::vector< vcs_VolPhase * > m_VolPhaseList
Array of Phase Structures. Length = number of phases.
Definition: vcs_solve.h:1869
size_t m_numSpeciesRdc
Current number of species in the problems.
Definition: vcs_solve.h:1512
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:41
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.
std::vector< int > m_speciesUnknownType
Specifies the species unknown type.
Definition: vcs_solve.h:1625
bool m_gasPhase
If true, this phase is a gas-phase like phase.
Definition: vcs_VolPhase.h:591
Phase information and Phase calculations for vcs.
Definition: vcs_VolPhase.h:86
double m_pressurePA
Pressure (units are determined by m_VCS_UnitsFormat.
Definition: vcs_solve.h:1748
#define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE
Unknown refers to the voltage level of a phase.
Definition: vcs_defs.h:352
size_t m_numPhases
Number of Phases in the problem.
Definition: vcs_solve.h:1526
std::vector< double > TPhInertMoles
Total kmoles of inert to add to each phase.
Definition: vcs_solve.h:1755