Moved the external libraries to separate library files so that libcantera.a just contains its own namespace externals. Fixed several errors in the equilibrium program that occurred during the port. (int to size_t issues). Moved some equilibrium program headers to the include file system, so that it can link with equilibrium program. Worked on Cantera.mak. Needs more work. Fixed an issue with the Residual virtual base classes within numerics. They didn't inherit due to int to size_t migration. This caused numerous test problems to fail (issue with backwards compatibility - do we want it and how much do we want?). Added csvdiff back so that it's available for shell environment runtests.
94 lines
3 KiB
C++
94 lines
3 KiB
C++
/**
|
|
* @file vcs_Gibbs.cpp
|
|
* Functions which calculate the extrinsic Gibbs Free energies
|
|
*/
|
|
/*
|
|
* Copyright (2005) Sandia Corporation. Under the terms of
|
|
* Contract DE-AC04-94AL85000 with Sandia Corporation, the
|
|
* U.S. Government retains certain rights in this software.
|
|
*/
|
|
|
|
#include "cantera/equil/vcs_solve.h"
|
|
#include "cantera/equil/vcs_internal.h"
|
|
#include "cantera/equil/vcs_VolPhase.h"
|
|
#include "math.h"
|
|
|
|
namespace VCSnonideal
|
|
{
|
|
|
|
/***************************************************************************/
|
|
/***************************************************************************/
|
|
/***************************************************************************/
|
|
|
|
double VCS_SOLVE::vcs_Total_Gibbs(double* molesSp, double* chemPot,
|
|
double* tPhMoles)
|
|
|
|
/*************************************************************************
|
|
*
|
|
* vcs_Total_Gibbs:
|
|
*
|
|
* Calculate the total dimensionless Gibbs free energy
|
|
* -> Inert species are handled as if they had a standard free
|
|
* energy of zero.
|
|
* Note, for this algorithm this function should be MONOTONICALLY
|
|
* DECREASING.
|
|
*************************************************************************/
|
|
{
|
|
double g = 0.0;
|
|
|
|
for (size_t iph = 0; iph < m_numPhases; iph++) {
|
|
vcs_VolPhase* Vphase = m_VolPhaseList[iph];
|
|
if ((TPhInertMoles[iph] > 0.0) && (tPhMoles[iph] > 0.0)) {
|
|
g += TPhInertMoles[iph] *
|
|
log(TPhInertMoles[iph] / tPhMoles[iph]);
|
|
if (Vphase->m_gasPhase) {
|
|
g += TPhInertMoles[iph] * log(m_pressurePA/(1.01325E5));
|
|
}
|
|
}
|
|
}
|
|
|
|
for (size_t kspec = 0; kspec < m_numSpeciesRdc; ++kspec) {
|
|
if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
|
|
g += molesSp[kspec] * chemPot[kspec];
|
|
}
|
|
}
|
|
|
|
return g;
|
|
}
|
|
|
|
// Calculate the total dimensionless Gibbs free energy of a single phase
|
|
/*
|
|
* -> Inert species are handled as if they had a standard free
|
|
* energy of zero and if they obeyed ideal solution/gas theory
|
|
*
|
|
* @param iphase ID of the phase
|
|
* @param w Species mole number vector
|
|
* @param fe vector of partial molar free energies of the species.
|
|
*/
|
|
double VCS_SOLVE::vcs_GibbsPhase(size_t iphase, const double* const w,
|
|
const double* const fe)
|
|
{
|
|
double g = 0.0;
|
|
double phaseMols = 0.0;
|
|
for (size_t kspec = 0; kspec < m_numSpeciesRdc; ++kspec) {
|
|
if (m_phaseID[kspec] == iphase) {
|
|
if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
|
|
g += w[kspec] * fe[kspec];
|
|
phaseMols += w[kspec];
|
|
}
|
|
}
|
|
}
|
|
|
|
if (TPhInertMoles[iphase] > 0.0) {
|
|
phaseMols += TPhInertMoles[iphase];
|
|
g += TPhInertMoles[iphase] * log(TPhInertMoles[iphase] / phaseMols);
|
|
vcs_VolPhase* Vphase = m_VolPhaseList[iphase];
|
|
if (Vphase->m_gasPhase) {
|
|
g += TPhInertMoles[iphase] * log(m_pressurePA/1.01325E5);
|
|
}
|
|
}
|
|
|
|
return g;
|
|
}
|
|
|
|
}
|