Cantera  2.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  * 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 
19 /***************************************************************************/
20 /***************************************************************************/
21 /***************************************************************************/
22 
23 double VCS_SOLVE::vcs_Total_Gibbs(double* molesSp, double* chemPot,
24  double* tPhMoles)
25 
26 /*************************************************************************
27  *
28  * vcs_Total_Gibbs:
29  *
30  * Calculate the total dimensionless Gibbs free energy
31  * -> Inert species are handled as if they had a standard free
32  * energy of zero.
33  * Note, for this algorithm this function should be MONOTONICALLY
34  * DECREASING.
35  *************************************************************************/
36 {
37  double g = 0.0;
38 
39  for (size_t iph = 0; iph < m_numPhases; iph++) {
40  vcs_VolPhase* Vphase = m_VolPhaseList[iph];
41  if ((TPhInertMoles[iph] > 0.0) && (tPhMoles[iph] > 0.0)) {
42  g += TPhInertMoles[iph] *
43  log(TPhInertMoles[iph] / tPhMoles[iph]);
44  if (Vphase->m_gasPhase) {
45  g += TPhInertMoles[iph] * log(m_pressurePA/(1.01325E5));
46  }
47  }
48  }
49 
50  for (size_t kspec = 0; kspec < m_numSpeciesRdc; ++kspec) {
52  g += molesSp[kspec] * chemPot[kspec];
53  }
54  }
55 
56  return g;
57 }
58 
59 // Calculate the total dimensionless Gibbs free energy of a single phase
60 /*
61  * -> Inert species are handled as if they had a standard free
62  * energy of zero and if they obeyed ideal solution/gas theory
63  *
64  * @param iphase ID of the phase
65  * @param w Species mole number vector
66  * @param fe vector of partial molar free energies of the species.
67  */
68 double VCS_SOLVE::vcs_GibbsPhase(size_t iphase, const double* const w,
69  const double* const fe)
70 {
71  double g = 0.0;
72  double phaseMols = 0.0;
73  for (size_t kspec = 0; kspec < m_numSpeciesRdc; ++kspec) {
74  if (m_phaseID[kspec] == iphase) {
76  g += w[kspec] * fe[kspec];
77  phaseMols += w[kspec];
78  }
79  }
80  }
81 
82  if (TPhInertMoles[iphase] > 0.0) {
83  phaseMols += TPhInertMoles[iphase];
84  g += TPhInertMoles[iphase] * log(TPhInertMoles[iphase] / phaseMols);
85  vcs_VolPhase* Vphase = m_VolPhaseList[iphase];
86  if (Vphase->m_gasPhase) {
87  g += TPhInertMoles[iphase] * log(m_pressurePA/1.01325E5);
88  }
89  }
90 
91  return g;
92 }
93 
94 }