Cantera  2.1.2
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 
14 #include "math.h"
15 
16 namespace VCSnonideal
17 {
18 double VCS_SOLVE::vcs_Total_Gibbs(double* molesSp, double* chemPot,
19  double* tPhMoles)
20 {
21  double g = 0.0;
22 
23  for (size_t iph = 0; iph < m_numPhases; iph++) {
24  vcs_VolPhase* Vphase = m_VolPhaseList[iph];
25  if ((TPhInertMoles[iph] > 0.0) && (tPhMoles[iph] > 0.0)) {
26  g += TPhInertMoles[iph] *
27  log(TPhInertMoles[iph] / tPhMoles[iph]);
28  if (Vphase->m_gasPhase) {
29  g += TPhInertMoles[iph] * log(m_pressurePA/(1.01325E5));
30  }
31  }
32  }
33 
34  for (size_t kspec = 0; kspec < m_numSpeciesRdc; ++kspec) {
36  g += molesSp[kspec] * chemPot[kspec];
37  }
38  }
39 
40  return g;
41 }
42 
43 double VCS_SOLVE::vcs_GibbsPhase(size_t iphase, const double* const w,
44  const double* const fe)
45 {
46  double g = 0.0;
47  double phaseMols = 0.0;
48  for (size_t kspec = 0; kspec < m_numSpeciesRdc; ++kspec) {
49  if (m_phaseID[kspec] == iphase) {
51  g += w[kspec] * fe[kspec];
52  phaseMols += w[kspec];
53  }
54  }
55  }
56 
57  if (TPhInertMoles[iphase] > 0.0) {
58  phaseMols += TPhInertMoles[iphase];
59  g += TPhInertMoles[iphase] * log(TPhInertMoles[iphase] / phaseMols);
60  vcs_VolPhase* Vphase = m_VolPhaseList[iphase];
61  if (Vphase->m_gasPhase) {
62  g += TPhInertMoles[iphase] * log(m_pressurePA/1.01325E5);
63  }
64  }
65 
66  return g;
67 }
68 
69 }
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.
Phase information and Phase calculations for vcs.
Definition: vcs_VolPhase.h:97
Internal declarations for the VCSnonideal package.
std::vector< vcs_VolPhase * > m_VolPhaseList
Array of Phase Structures. Length = number of phases.
Definition: vcs_solve.h:1873
double vcs_Total_Gibbs(double *w, double *fe, double *tPhMoles)
Calculate the total dimensionless Gibbs free energy.
Definition: vcs_Gibbs.cpp:18
size_t m_numPhases
Number of Phases in the problem.
Definition: vcs_solve.h:1530
std::vector< size_t > m_phaseID
Mapping from the species number to the phase number.
Definition: vcs_solve.h:1836
std::vector< double > TPhInertMoles
Total kmoles of inert to add to each phase.
Definition: vcs_solve.h:1759
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:43
#define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE
Unknown refers to the voltage level of a phase.
Definition: vcs_defs.h:368
double m_pressurePA
Pressure (units are determined by m_VCS_UnitsFormat.
Definition: vcs_solve.h:1752
std::vector< int > m_speciesUnknownType
Specifies the species unknown type.
Definition: vcs_solve.h:1629
bool m_gasPhase
If true, this phase is a gas-phase like phase.
Definition: vcs_VolPhase.h:602
size_t m_numSpeciesRdc
Current number of species in the problems.
Definition: vcs_solve.h:1516